From b6f770d36fa77bb347c20e24fea64332b7231b18 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 13 Nov 2024 14:48:31 +1030 Subject: [PATCH] feat(sdk-node): Run Context --- sdk-node/src/contract.ts | 6 +++++- sdk-node/src/service.ts | 6 ++++-- sdk-node/src/types.ts | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sdk-node/src/contract.ts b/sdk-node/src/contract.ts index 1427f7ae..8ea6b174 100644 --- a/sdk-node/src/contract.ts +++ b/sdk-node/src/contract.ts @@ -429,6 +429,9 @@ export const definition = { .optional(), }) .optional(), + context: anyObject + .optional() + .describe("Additional context to propogate to all calls in the run"), template: z .object({ id: z.string().describe("DEPRECATED"), @@ -1400,7 +1403,8 @@ export const definition = { id: z.string(), function: z.string(), input: z.any(), - customerAuthContext: z.any().nullable(), + authContext: z.any().nullable(), + runContext: z.any().nullable(), }), ), }, diff --git a/sdk-node/src/service.ts b/sdk-node/src/service.ts index a56d062f..21cd39d1 100644 --- a/sdk-node/src/service.ts +++ b/sdk-node/src/service.ts @@ -16,7 +16,8 @@ type CallMessage = { id: string; function: string; input?: unknown; - customerAuthContext?: unknown; + authContext?: unknown; + runContext?: string; }; export class Service { @@ -270,7 +271,8 @@ export class Service { const result = await executeFn( registration.func, [args, { - customerAuthContext: call.customerAuthContext, + authContext: call.authContext, + runContext: call.runContext, }], ); diff --git a/sdk-node/src/types.ts b/sdk-node/src/types.ts index 4868bafc..37774c8d 100644 --- a/sdk-node/src/types.ts +++ b/sdk-node/src/types.ts @@ -5,7 +5,8 @@ import { FunctionConfigSchema } from "./contract"; * Context object which is passed to function calls */ export type ContextInput = { - customerAuthContext?: unknown; + authContext?: unknown; + runContext?: unknown; } export type FunctionConfig = z.infer;