Skip to content

Commit

Permalink
feat(sdk-node): Run Context (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith authored Nov 13, 2024
1 parent 08075f1 commit 86affdb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sdk-node/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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(),
}),
),
},
Expand Down
6 changes: 4 additions & 2 deletions sdk-node/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type CallMessage = {
id: string;
function: string;
input?: unknown;
customerAuthContext?: unknown;
authContext?: unknown;
runContext?: string;
};

export class Service {
Expand Down Expand Up @@ -270,7 +271,8 @@ export class Service {
const result = await executeFn(
registration.func,
[args, {
customerAuthContext: call.customerAuthContext,
authContext: call.authContext,
runContext: call.runContext,
}],
);

Expand Down
3 changes: 2 additions & 1 deletion sdk-node/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof FunctionConfigSchema>;
Expand Down

0 comments on commit 86affdb

Please sign in to comment.