skedyul 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +77 -0
- package/dist/config/app-config.d.ts +6 -1
- package/dist/config/define.d.ts +16 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/types/entity.d.ts +9 -1
- package/dist/config/types/form.d.ts +1 -9
- package/dist/config/types/index.d.ts +1 -0
- package/dist/config/types/setup.d.ts +37 -0
- package/dist/core/client.d.ts +39 -0
- package/dist/dedicated/server.js +77 -0
- package/dist/esm/index.mjs +145 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +149 -10
- package/dist/schemas.d.ts +69 -18
- package/dist/server/handlers/index.d.ts +1 -0
- package/dist/server/handlers/setup-revalidate-handler.d.ts +9 -0
- package/dist/server/handlers/types.d.ts +34 -0
- package/dist/server/route-handlers/handlers.d.ts +4 -0
- package/dist/server/route-handlers/index.d.ts +1 -1
- package/dist/server.js +77 -0
- package/dist/serverless/server.mjs +77 -0
- package/dist/types/handlers.d.ts +42 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/invocation.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1161,6 +1161,72 @@ async function handleProvision(body, hooks) {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
1163
|
|
|
1164
|
+
// src/server/handlers/setup-revalidate-handler.ts
|
|
1165
|
+
async function handleSetupRevalidate(body, hooks) {
|
|
1166
|
+
const revalidateHook = hooks?.setup?.revalidate;
|
|
1167
|
+
if (!revalidateHook) {
|
|
1168
|
+
return {
|
|
1169
|
+
status: 404,
|
|
1170
|
+
body: { error: "Setup revalidate handler not configured" }
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
if (!body.context?.appInstallationId || !body.context?.workplace || !body.context?.app || !body.reason || !Array.isArray(body.steps)) {
|
|
1174
|
+
return {
|
|
1175
|
+
status: 400,
|
|
1176
|
+
body: {
|
|
1177
|
+
error: {
|
|
1178
|
+
code: -32602,
|
|
1179
|
+
message: "Missing context (appInstallationId, workplace, app, reason, and steps required)"
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
const ctx = {
|
|
1185
|
+
env: body.env ?? {},
|
|
1186
|
+
workplace: body.context.workplace,
|
|
1187
|
+
appInstallationId: body.context.appInstallationId,
|
|
1188
|
+
app: body.context.app,
|
|
1189
|
+
reason: body.reason,
|
|
1190
|
+
steps: body.steps,
|
|
1191
|
+
crm: body.crm,
|
|
1192
|
+
envChange: body.envChange,
|
|
1193
|
+
invocation: body.invocation,
|
|
1194
|
+
log: createContextLogger()
|
|
1195
|
+
};
|
|
1196
|
+
const requestConfig = {
|
|
1197
|
+
baseUrl: body.env?.SKEDYUL_API_URL ?? process.env.SKEDYUL_API_URL ?? "",
|
|
1198
|
+
apiToken: body.env?.SKEDYUL_API_TOKEN ?? process.env.SKEDYUL_API_TOKEN ?? ""
|
|
1199
|
+
};
|
|
1200
|
+
try {
|
|
1201
|
+
const handler = typeof revalidateHook === "function" ? revalidateHook : revalidateHook.handler;
|
|
1202
|
+
const result = await runWithLogContext(
|
|
1203
|
+
{ invocation: body.invocation },
|
|
1204
|
+
async () => {
|
|
1205
|
+
return await runWithConfig(requestConfig, async () => {
|
|
1206
|
+
return await handler(ctx);
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
);
|
|
1210
|
+
return {
|
|
1211
|
+
status: 200,
|
|
1212
|
+
body: {
|
|
1213
|
+
completed: result?.completed ?? [],
|
|
1214
|
+
invalidated: result?.invalidated ?? []
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
} catch (err) {
|
|
1218
|
+
return {
|
|
1219
|
+
status: 500,
|
|
1220
|
+
body: {
|
|
1221
|
+
error: {
|
|
1222
|
+
code: -32603,
|
|
1223
|
+
message: err instanceof Error ? err.message : String(err ?? "")
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1164
1230
|
// src/server/handler-helpers.ts
|
|
1165
1231
|
function parseHandlerEnvelope(parsedBody) {
|
|
1166
1232
|
if (typeof parsedBody !== "object" || parsedBody === null || Array.isArray(parsedBody) || !("env" in parsedBody) || !("request" in parsedBody)) {
|
|
@@ -1552,6 +1618,14 @@ async function handleProvisionRoute(req, ctx) {
|
|
|
1552
1618
|
const result = await handleProvision(parseResult.data, ctx.config.hooks);
|
|
1553
1619
|
return { status: result.status, body: result.body };
|
|
1554
1620
|
}
|
|
1621
|
+
async function handleSetupRevalidateRoute(req, ctx) {
|
|
1622
|
+
const parseResult = parseJsonBody(req);
|
|
1623
|
+
if (!parseResult.success) {
|
|
1624
|
+
return parseResult.error;
|
|
1625
|
+
}
|
|
1626
|
+
const result = await handleSetupRevalidate(parseResult.data, ctx.config.hooks);
|
|
1627
|
+
return { status: result.status, body: result.body };
|
|
1628
|
+
}
|
|
1555
1629
|
async function handleOAuthCallbackRoute(req, ctx) {
|
|
1556
1630
|
const parseResult = parseJsonBody(req);
|
|
1557
1631
|
if (!parseResult.success) {
|
|
@@ -1913,6 +1987,9 @@ async function routeRequest(req, ctx) {
|
|
|
1913
1987
|
if (req.path === "/provision" && req.method === "POST") {
|
|
1914
1988
|
return handleProvisionRoute(req, ctx);
|
|
1915
1989
|
}
|
|
1990
|
+
if (req.path === "/setup/revalidate" && req.method === "POST") {
|
|
1991
|
+
return handleSetupRevalidateRoute(req, ctx);
|
|
1992
|
+
}
|
|
1916
1993
|
if (req.path === "/oauth_callback" && req.method === "POST") {
|
|
1917
1994
|
return handleOAuthCallbackRoute(req, ctx);
|
|
1918
1995
|
}
|
package/dist/types/handlers.d.ts
CHANGED
|
@@ -63,6 +63,37 @@ export interface ProvisionHandlerContext {
|
|
|
63
63
|
export interface ProvisionHandlerResult {
|
|
64
64
|
}
|
|
65
65
|
export type ProvisionHandler = (ctx: ProvisionHandlerContext) => Promise<ProvisionHandlerResult>;
|
|
66
|
+
export type SetupRevalidateReason = 'crm_changed' | 'env_changed';
|
|
67
|
+
export interface SetupRevalidateContext {
|
|
68
|
+
env: Record<string, string>;
|
|
69
|
+
workplace: WorkplaceInfo;
|
|
70
|
+
appInstallationId: string;
|
|
71
|
+
app: AppInfoWithHandles;
|
|
72
|
+
reason: SetupRevalidateReason;
|
|
73
|
+
/** Step handles that listen for this change */
|
|
74
|
+
steps: string[];
|
|
75
|
+
crm?: {
|
|
76
|
+
migrationId?: string;
|
|
77
|
+
deletedModelIds?: string[];
|
|
78
|
+
deletedFieldIds?: string[];
|
|
79
|
+
createdModelIds?: string[];
|
|
80
|
+
updatedModelIds?: string[];
|
|
81
|
+
createdFieldIds?: string[];
|
|
82
|
+
updatedFieldIds?: string[];
|
|
83
|
+
};
|
|
84
|
+
envChange?: {
|
|
85
|
+
keys: string[];
|
|
86
|
+
};
|
|
87
|
+
/** Invocation context for log traceability */
|
|
88
|
+
invocation?: InvocationContext;
|
|
89
|
+
/** Context-aware logger that automatically includes invocation context */
|
|
90
|
+
log: ContextLogger;
|
|
91
|
+
}
|
|
92
|
+
export interface SetupRevalidateResult {
|
|
93
|
+
completed?: string[];
|
|
94
|
+
invalidated?: string[];
|
|
95
|
+
}
|
|
96
|
+
export type SetupRevalidateHandler = (ctx: SetupRevalidateContext) => Promise<SetupRevalidateResult | void>;
|
|
66
97
|
/**
|
|
67
98
|
* Base ServerHooks type with common fields
|
|
68
99
|
*/
|
|
@@ -79,6 +110,17 @@ type BaseServerHooks = {
|
|
|
79
110
|
/** Timeout in milliseconds. Defaults to 60000 (1 minute) if not specified. */
|
|
80
111
|
timeout?: number;
|
|
81
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Setup revalidation after CRM migrations or env key removal.
|
|
115
|
+
* App should call setup.complete / setup.invalidate for listening steps.
|
|
116
|
+
*/
|
|
117
|
+
setup?: {
|
|
118
|
+
revalidate?: SetupRevalidateHandler | {
|
|
119
|
+
handler: SetupRevalidateHandler;
|
|
120
|
+
/** Timeout in milliseconds. Defaults to 60000 (1 minute) if not specified. */
|
|
121
|
+
timeout?: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
82
124
|
};
|
|
83
125
|
/**
|
|
84
126
|
* ServerHooks when oauth_callback is present.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type { FormatMoneyMinorEstimateOptions } from './estimation';
|
|
|
16
16
|
export { ToolResponseMetaSchema } from './tool';
|
|
17
17
|
export { createSuccessResponse, createListResponse, createErrorResponse, createValidationError, createNotFoundError, createAuthError, createRateLimitError, createExternalError, createTimeoutError, createPermissionError, createConflictError, isSuccess, isFailure, isRetryable, getRetryDelay, } from './tool-response';
|
|
18
18
|
export type { HealthStatus, ComputeLayer, DedicatedServerInstance, ServerlessServerInstance, SkedyulServerInstance, } from './server';
|
|
19
|
-
export type { InstallHandlerContext, InstallHandlerResponseOAuth, InstallHandlerResponseStandard, HasOAuthCallback, InstallHandlerResult, InstallHandler, UninstallHandlerContext, UninstallHandlerResult, UninstallHandler, OAuthCallbackContext, OAuthCallbackResult, OAuthCallbackHandler, ProvisionHandlerContext, ProvisionHandlerResult, ProvisionHandler, ServerHooksWithOAuth, ServerHooksWithoutOAuth, ServerHooks, } from './handlers';
|
|
19
|
+
export type { InstallHandlerContext, InstallHandlerResponseOAuth, InstallHandlerResponseStandard, HasOAuthCallback, InstallHandlerResult, InstallHandler, UninstallHandlerContext, UninstallHandlerResult, UninstallHandler, OAuthCallbackContext, OAuthCallbackResult, OAuthCallbackHandler, ProvisionHandlerContext, ProvisionHandlerResult, ProvisionHandler, SetupRevalidateReason, SetupRevalidateContext, SetupRevalidateResult, SetupRevalidateHandler, ServerHooksWithOAuth, ServerHooksWithoutOAuth, ServerHooks, } from './handlers';
|
|
20
20
|
export type { APIGatewayProxyEvent, APIGatewayProxyResult } from './aws';
|
|
21
21
|
export type { WebhookWireRequest, HandlerRawRequest, WebhookRequest, WebhookResponse, ProvisionWebhookContext, RuntimeWebhookContext, WebhookContext, WebhookHandler, WebhookLifecycleContext, CommunicationChannelLifecycleContext, WebhookLifecycleResult, WebhookLifecycleHook, WebhookInvocationMode, WebhookType, WebhookDefinition, WebhookRegistry, WebhookName, WebhookMetadata, } from './webhook';
|
|
22
22
|
export { isRuntimeWebhookContext } from './webhook';
|
|
@@ -5,7 +5,7 @@ export type InvocationType = 'tool_call' | 'server_hook' | 'workflow_step' | 'we
|
|
|
5
5
|
/**
|
|
6
6
|
* Server hook handles for lifecycle events
|
|
7
7
|
*/
|
|
8
|
-
export type ServerHookHandle = 'provision' | 'install' | 'uninstall' | 'oauth_callback';
|
|
8
|
+
export type ServerHookHandle = 'provision' | 'install' | 'uninstall' | 'oauth_callback' | 'setup.revalidate';
|
|
9
9
|
/**
|
|
10
10
|
* Context for tracking how an executable was invoked.
|
|
11
11
|
* Used for log traceability and filtering.
|
|
@@ -19,7 +19,7 @@ export interface InvocationContext {
|
|
|
19
19
|
toolCallId?: string;
|
|
20
20
|
/** The tool's handle for searching (e.g., "get_customers") */
|
|
21
21
|
toolHandle?: string;
|
|
22
|
-
/** Hook type: "provision", "install", "uninstall", "oauth_callback" */
|
|
22
|
+
/** Hook type: "provision", "install", "uninstall", "oauth_callback", "setup.revalidate" */
|
|
23
23
|
serverHookHandle?: ServerHookHandle;
|
|
24
24
|
/** The app installation that triggered the call */
|
|
25
25
|
appInstallationId?: string;
|