Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk-node): Run Context #97

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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