skedyul 1.6.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/schemas.d.ts CHANGED
@@ -339,6 +339,87 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
339
339
  placeholder: z.ZodOptional<z.ZodString>;
340
340
  }, z.core.$strip>>>;
341
341
  }, z.core.$strip>;
342
+ export declare const EntityFieldDefinitionSchema: z.ZodObject<{
343
+ handle: z.ZodString;
344
+ label: z.ZodString;
345
+ description: z.ZodOptional<z.ZodString>;
346
+ type: z.ZodOptional<z.ZodEnum<{
347
+ string: "string";
348
+ number: "number";
349
+ boolean: "boolean";
350
+ object: "object";
351
+ long_string: "long_string";
352
+ date: "date";
353
+ datetime: "datetime";
354
+ }>>;
355
+ isUnique: z.ZodOptional<z.ZodBoolean>;
356
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
357
+ required: z.ZodOptional<z.ZodBoolean>;
358
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
359
+ value: z.ZodString;
360
+ label: z.ZodString;
361
+ }, z.core.$strip>]>>>;
362
+ }, z.core.$strip>;
363
+ export declare const EntityRelationshipDefinitionSchema: z.ZodObject<{
364
+ handle: z.ZodString;
365
+ label: z.ZodString;
366
+ targetEntity: z.ZodOptional<z.ZodString>;
367
+ description: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>;
369
+ export declare const EntityDefinitionSchema: z.ZodObject<{
370
+ handle: z.ZodString;
371
+ label: z.ZodString;
372
+ labelPlural: z.ZodOptional<z.ZodString>;
373
+ description: z.ZodOptional<z.ZodString>;
374
+ fields: z.ZodArray<z.ZodObject<{
375
+ handle: z.ZodString;
376
+ label: z.ZodString;
377
+ description: z.ZodOptional<z.ZodString>;
378
+ type: z.ZodOptional<z.ZodEnum<{
379
+ string: "string";
380
+ number: "number";
381
+ boolean: "boolean";
382
+ object: "object";
383
+ long_string: "long_string";
384
+ date: "date";
385
+ datetime: "datetime";
386
+ }>>;
387
+ isUnique: z.ZodOptional<z.ZodBoolean>;
388
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
389
+ required: z.ZodOptional<z.ZodBoolean>;
390
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
391
+ value: z.ZodString;
392
+ label: z.ZodString;
393
+ }, z.core.$strip>]>>>;
394
+ }, z.core.$strip>>;
395
+ contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
396
+ handle: z.ZodString;
397
+ label: z.ZodString;
398
+ description: z.ZodOptional<z.ZodString>;
399
+ type: z.ZodOptional<z.ZodEnum<{
400
+ string: "string";
401
+ number: "number";
402
+ boolean: "boolean";
403
+ object: "object";
404
+ long_string: "long_string";
405
+ date: "date";
406
+ datetime: "datetime";
407
+ }>>;
408
+ isUnique: z.ZodOptional<z.ZodBoolean>;
409
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
410
+ required: z.ZodOptional<z.ZodBoolean>;
411
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
412
+ value: z.ZodString;
413
+ label: z.ZodString;
414
+ }, z.core.$strip>]>>>;
415
+ }, z.core.$strip>>>;
416
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
417
+ handle: z.ZodString;
418
+ label: z.ZodString;
419
+ targetEntity: z.ZodOptional<z.ZodString>;
420
+ description: z.ZodOptional<z.ZodString>;
421
+ }, z.core.$strip>>>;
422
+ }, z.core.$strip>;
342
423
  export declare const RelationshipCardinalitySchema: z.ZodEnum<{
343
424
  ONE_TO_ONE: "ONE_TO_ONE";
344
425
  ONE_TO_MANY: "ONE_TO_MANY";
@@ -2088,11 +2169,6 @@ export declare const ListBlockDefinitionSchema: z.ZodObject<{
2088
2169
  icon: z.ZodOptional<z.ZodString>;
2089
2170
  emptyMessage: z.ZodOptional<z.ZodString>;
2090
2171
  }, z.core.$strip>;
2091
- /** Model mapper block definition - for mapping SHARED models to workspace models */
2092
- export declare const ModelMapperBlockDefinitionSchema: z.ZodObject<{
2093
- type: z.ZodLiteral<"model_mapper">;
2094
- model: z.ZodString;
2095
- }, z.core.$strip>;
2096
2172
  /** Union of all block types */
2097
2173
  export declare const PageBlockDefinitionSchema: z.ZodUnion<readonly [z.ZodObject<{
2098
2174
  type: z.ZodLiteral<"card">;
@@ -2491,9 +2567,6 @@ export declare const PageBlockDefinitionSchema: z.ZodUnion<readonly [z.ZodObject
2491
2567
  descriptionField: z.ZodOptional<z.ZodString>;
2492
2568
  icon: z.ZodOptional<z.ZodString>;
2493
2569
  emptyMessage: z.ZodOptional<z.ZodString>;
2494
- }, z.core.$strip>, z.ZodObject<{
2495
- type: z.ZodLiteral<"model_mapper">;
2496
- model: z.ZodString;
2497
2570
  }, z.core.$strip>]>;
2498
2571
  /** Mode for context data fetching */
2499
2572
  export declare const PageContextModeSchema: z.ZodPipe<z.ZodEnum<{
@@ -3041,9 +3114,6 @@ export declare const PageDefinitionSchema: z.ZodObject<{
3041
3114
  descriptionField: z.ZodOptional<z.ZodString>;
3042
3115
  icon: z.ZodOptional<z.ZodString>;
3043
3116
  emptyMessage: z.ZodOptional<z.ZodString>;
3044
- }, z.core.$strip>, z.ZodObject<{
3045
- type: z.ZodLiteral<"model_mapper">;
3046
- model: z.ZodString;
3047
3117
  }, z.core.$strip>]>>;
3048
3118
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3049
3119
  handle: z.ZodString;
@@ -3263,6 +3333,30 @@ export declare const InstallConfigSchema: z.ZodObject<{
3263
3333
  }>>;
3264
3334
  }, z.core.$strip>>>;
3265
3335
  }, z.core.$strip>;
3336
+ export declare const SetupStepKindSchema: z.ZodEnum<{
3337
+ crm: "crm";
3338
+ env: "env";
3339
+ app: "app";
3340
+ realtime: "realtime";
3341
+ }>;
3342
+ export declare const SetupStepDefinitionSchema: z.ZodObject<{
3343
+ handle: z.ZodString;
3344
+ label: z.ZodString;
3345
+ description: z.ZodOptional<z.ZodString>;
3346
+ kind: z.ZodEnum<{
3347
+ crm: "crm";
3348
+ env: "env";
3349
+ app: "app";
3350
+ realtime: "realtime";
3351
+ }>;
3352
+ requires: z.ZodOptional<z.ZodArray<z.ZodString>>;
3353
+ entities: z.ZodOptional<z.ZodArray<z.ZodString>>;
3354
+ workflowHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
3355
+ envKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
3356
+ listenToCrm: z.ZodOptional<z.ZodBoolean>;
3357
+ listenToEnv: z.ZodOptional<z.ZodBoolean>;
3358
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
3359
+ }, z.core.$strip>;
3266
3360
  export declare const ProvisionConfigSchema: z.ZodObject<{
3267
3361
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3268
3362
  label: z.ZodString;
@@ -3375,6 +3469,60 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
3375
3469
  placeholder: z.ZodOptional<z.ZodString>;
3376
3470
  }, z.core.$strip>>>;
3377
3471
  }, z.core.$strip>>>;
3472
+ entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
3473
+ handle: z.ZodString;
3474
+ label: z.ZodString;
3475
+ labelPlural: z.ZodOptional<z.ZodString>;
3476
+ description: z.ZodOptional<z.ZodString>;
3477
+ fields: z.ZodArray<z.ZodObject<{
3478
+ handle: z.ZodString;
3479
+ label: z.ZodString;
3480
+ description: z.ZodOptional<z.ZodString>;
3481
+ type: z.ZodOptional<z.ZodEnum<{
3482
+ string: "string";
3483
+ number: "number";
3484
+ boolean: "boolean";
3485
+ object: "object";
3486
+ long_string: "long_string";
3487
+ date: "date";
3488
+ datetime: "datetime";
3489
+ }>>;
3490
+ isUnique: z.ZodOptional<z.ZodBoolean>;
3491
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
3492
+ required: z.ZodOptional<z.ZodBoolean>;
3493
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3494
+ value: z.ZodString;
3495
+ label: z.ZodString;
3496
+ }, z.core.$strip>]>>>;
3497
+ }, z.core.$strip>>;
3498
+ contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
3499
+ handle: z.ZodString;
3500
+ label: z.ZodString;
3501
+ description: z.ZodOptional<z.ZodString>;
3502
+ type: z.ZodOptional<z.ZodEnum<{
3503
+ string: "string";
3504
+ number: "number";
3505
+ boolean: "boolean";
3506
+ object: "object";
3507
+ long_string: "long_string";
3508
+ date: "date";
3509
+ datetime: "datetime";
3510
+ }>>;
3511
+ isUnique: z.ZodOptional<z.ZodBoolean>;
3512
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
3513
+ required: z.ZodOptional<z.ZodBoolean>;
3514
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3515
+ value: z.ZodString;
3516
+ label: z.ZodString;
3517
+ }, z.core.$strip>]>>>;
3518
+ }, z.core.$strip>>>;
3519
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
3520
+ handle: z.ZodString;
3521
+ label: z.ZodString;
3522
+ targetEntity: z.ZodOptional<z.ZodString>;
3523
+ description: z.ZodOptional<z.ZodString>;
3524
+ }, z.core.$strip>>>;
3525
+ }, z.core.$strip>>>;
3378
3526
  relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
3379
3527
  source: z.ZodObject<{
3380
3528
  model: z.ZodString;
@@ -3961,9 +4109,6 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
3961
4109
  descriptionField: z.ZodOptional<z.ZodString>;
3962
4110
  icon: z.ZodOptional<z.ZodString>;
3963
4111
  emptyMessage: z.ZodOptional<z.ZodString>;
3964
- }, z.core.$strip>, z.ZodObject<{
3965
- type: z.ZodLiteral<"model_mapper">;
3966
- model: z.ZodString;
3967
4112
  }, z.core.$strip>]>>;
3968
4113
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3969
4114
  handle: z.ZodString;
@@ -3998,6 +4143,24 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
3998
4143
  where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3999
4144
  }, z.core.$strip>>;
4000
4145
  }, z.core.$strip>>>;
4146
+ setup: z.ZodOptional<z.ZodArray<z.ZodObject<{
4147
+ handle: z.ZodString;
4148
+ label: z.ZodString;
4149
+ description: z.ZodOptional<z.ZodString>;
4150
+ kind: z.ZodEnum<{
4151
+ crm: "crm";
4152
+ env: "env";
4153
+ app: "app";
4154
+ realtime: "realtime";
4155
+ }>;
4156
+ requires: z.ZodOptional<z.ZodArray<z.ZodString>>;
4157
+ entities: z.ZodOptional<z.ZodArray<z.ZodString>>;
4158
+ workflowHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
4159
+ envKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
4160
+ listenToCrm: z.ZodOptional<z.ZodBoolean>;
4161
+ listenToEnv: z.ZodOptional<z.ZodBoolean>;
4162
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
4163
+ }, z.core.$strip>>>;
4001
4164
  }, z.core.$strip>;
4002
4165
  export declare const SkedyulConfigSchema: z.ZodObject<{
4003
4166
  name: z.ZodString;
@@ -4121,6 +4284,60 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4121
4284
  placeholder: z.ZodOptional<z.ZodString>;
4122
4285
  }, z.core.$strip>>>;
4123
4286
  }, z.core.$strip>>>;
4287
+ entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
4288
+ handle: z.ZodString;
4289
+ label: z.ZodString;
4290
+ labelPlural: z.ZodOptional<z.ZodString>;
4291
+ description: z.ZodOptional<z.ZodString>;
4292
+ fields: z.ZodArray<z.ZodObject<{
4293
+ handle: z.ZodString;
4294
+ label: z.ZodString;
4295
+ description: z.ZodOptional<z.ZodString>;
4296
+ type: z.ZodOptional<z.ZodEnum<{
4297
+ string: "string";
4298
+ number: "number";
4299
+ boolean: "boolean";
4300
+ object: "object";
4301
+ long_string: "long_string";
4302
+ date: "date";
4303
+ datetime: "datetime";
4304
+ }>>;
4305
+ isUnique: z.ZodOptional<z.ZodBoolean>;
4306
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
4307
+ required: z.ZodOptional<z.ZodBoolean>;
4308
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4309
+ value: z.ZodString;
4310
+ label: z.ZodString;
4311
+ }, z.core.$strip>]>>>;
4312
+ }, z.core.$strip>>;
4313
+ contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
4314
+ handle: z.ZodString;
4315
+ label: z.ZodString;
4316
+ description: z.ZodOptional<z.ZodString>;
4317
+ type: z.ZodOptional<z.ZodEnum<{
4318
+ string: "string";
4319
+ number: "number";
4320
+ boolean: "boolean";
4321
+ object: "object";
4322
+ long_string: "long_string";
4323
+ date: "date";
4324
+ datetime: "datetime";
4325
+ }>>;
4326
+ isUnique: z.ZodOptional<z.ZodBoolean>;
4327
+ matchCandidate: z.ZodOptional<z.ZodBoolean>;
4328
+ required: z.ZodOptional<z.ZodBoolean>;
4329
+ options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4330
+ value: z.ZodString;
4331
+ label: z.ZodString;
4332
+ }, z.core.$strip>]>>>;
4333
+ }, z.core.$strip>>>;
4334
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
4335
+ handle: z.ZodString;
4336
+ label: z.ZodString;
4337
+ targetEntity: z.ZodOptional<z.ZodString>;
4338
+ description: z.ZodOptional<z.ZodString>;
4339
+ }, z.core.$strip>>>;
4340
+ }, z.core.$strip>>>;
4124
4341
  relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
4125
4342
  source: z.ZodObject<{
4126
4343
  model: z.ZodString;
@@ -4707,9 +4924,6 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4707
4924
  descriptionField: z.ZodOptional<z.ZodString>;
4708
4925
  icon: z.ZodOptional<z.ZodString>;
4709
4926
  emptyMessage: z.ZodOptional<z.ZodString>;
4710
- }, z.core.$strip>, z.ZodObject<{
4711
- type: z.ZodLiteral<"model_mapper">;
4712
- model: z.ZodString;
4713
4927
  }, z.core.$strip>]>>;
4714
4928
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
4715
4929
  handle: z.ZodString;
@@ -4744,6 +4958,24 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4744
4958
  where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4745
4959
  }, z.core.$strip>>;
4746
4960
  }, z.core.$strip>>>;
4961
+ setup: z.ZodOptional<z.ZodArray<z.ZodObject<{
4962
+ handle: z.ZodString;
4963
+ label: z.ZodString;
4964
+ description: z.ZodOptional<z.ZodString>;
4965
+ kind: z.ZodEnum<{
4966
+ crm: "crm";
4967
+ env: "env";
4968
+ app: "app";
4969
+ realtime: "realtime";
4970
+ }>;
4971
+ requires: z.ZodOptional<z.ZodArray<z.ZodString>>;
4972
+ entities: z.ZodOptional<z.ZodArray<z.ZodString>>;
4973
+ workflowHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
4974
+ envKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
4975
+ listenToCrm: z.ZodOptional<z.ZodBoolean>;
4976
+ listenToEnv: z.ZodOptional<z.ZodBoolean>;
4977
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
4978
+ }, z.core.$strip>>>;
4747
4979
  }, z.core.$strip>, z.ZodUnknown]>>;
4748
4980
  agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
4749
4981
  handle: z.ZodString;
@@ -4792,6 +5024,9 @@ export type WorkflowDependency = z.infer<typeof WorkflowDependencySchema>;
4792
5024
  export type ResourceDependency = z.infer<typeof ResourceDependencySchema>;
4793
5025
  export type ModelFieldDefinition = z.infer<typeof ModelFieldDefinitionSchema>;
4794
5026
  export type ModelDefinition = z.infer<typeof ModelDefinitionSchema>;
5027
+ export type EntityFieldDefinition = z.infer<typeof EntityFieldDefinitionSchema>;
5028
+ export type EntityRelationshipDefinition = z.infer<typeof EntityRelationshipDefinitionSchema>;
5029
+ export type EntityDefinition = z.infer<typeof EntityDefinitionSchema>;
4795
5030
  export type ChannelCapabilityType = z.infer<typeof ChannelCapabilityTypeSchema>;
4796
5031
  export type ChannelCapability = z.infer<typeof ChannelCapabilitySchema>;
4797
5032
  export type ChannelFieldDefinition = z.infer<typeof ChannelFieldDefinitionSchema>;
@@ -4802,6 +5037,8 @@ export type WebhookHandlerDefinition = z.infer<typeof WebhookHandlerDefinitionSc
4802
5037
  export type Webhooks = z.infer<typeof WebhooksSchema>;
4803
5038
  export type InstallConfig = z.infer<typeof InstallConfigSchema>;
4804
5039
  export type ProvisionConfig = z.infer<typeof ProvisionConfigSchema>;
5040
+ export type SetupStepKind = z.infer<typeof SetupStepKindSchema>;
5041
+ export type SetupStepDefinition = z.infer<typeof SetupStepDefinitionSchema>;
4805
5042
  export type FormV2StyleProps = z.infer<typeof FormV2StylePropsSchema>;
4806
5043
  export type FieldSettingButtonProps = z.infer<typeof FieldSettingButtonPropsSchema>;
4807
5044
  export type RelationshipExtension = z.infer<typeof RelationshipExtensionSchema>;
@@ -4814,7 +5051,6 @@ export type CardBlockHeader = z.infer<typeof CardBlockHeaderSchema>;
4814
5051
  export type CardBlockDefinition = z.infer<typeof CardBlockDefinitionSchema>;
4815
5052
  export type LegacyFormBlockDefinition = z.infer<typeof LegacyFormBlockDefinitionSchema>;
4816
5053
  export type ListBlockDefinition = z.infer<typeof ListBlockDefinitionSchema>;
4817
- export type ModelMapperBlockDefinition = z.infer<typeof ModelMapperBlockDefinitionSchema>;
4818
5054
  export declare const MessageSendChannelSchema: z.ZodObject<{
4819
5055
  id: z.ZodString;
4820
5056
  handle: z.ZodString;
@@ -8,5 +8,6 @@ export * from './types';
8
8
  export { handleInstall } from './install-handler';
9
9
  export { handleUninstall } from './uninstall-handler';
10
10
  export { handleProvision } from './provision-handler';
11
+ export { handleSetupRevalidate } from './setup-revalidate-handler';
11
12
  export { handleOAuthCallback } from './oauth-callback-handler';
12
13
  export { parseWebhookRequest, executeWebhookHandler, isMethodAllowed, type ParsedWebhookData, } from './webhook-handler';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Setup revalidate handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { ServerHooks } from '../../types';
5
+ import type { HandlerResult, SetupRevalidateRequestBody } from './types';
6
+ /**
7
+ * Handle setup revalidate request (CRM/env change notification).
8
+ */
9
+ export declare function handleSetupRevalidate(body: SetupRevalidateRequestBody, hooks: ServerHooks | undefined): Promise<HandlerResult>;
@@ -99,3 +99,37 @@ export interface ProvisionRequestBody {
99
99
  };
100
100
  };
101
101
  }
102
+ /**
103
+ * Setup revalidate request body format.
104
+ */
105
+ export interface SetupRevalidateRequestBody {
106
+ env?: Record<string, string>;
107
+ invocation?: InvocationContext;
108
+ reason: 'crm_changed' | 'env_changed';
109
+ steps: string[];
110
+ crm?: {
111
+ migrationId?: string;
112
+ deletedModelIds?: string[];
113
+ deletedFieldIds?: string[];
114
+ createdModelIds?: string[];
115
+ updatedModelIds?: string[];
116
+ createdFieldIds?: string[];
117
+ updatedFieldIds?: string[];
118
+ };
119
+ envChange?: {
120
+ keys: string[];
121
+ };
122
+ context?: {
123
+ app: {
124
+ id: string;
125
+ versionId: string;
126
+ handle: string;
127
+ versionHandle: string;
128
+ };
129
+ appInstallationId: string;
130
+ workplace: {
131
+ id: string;
132
+ subdomain: string;
133
+ };
134
+ };
135
+ }
@@ -37,6 +37,10 @@ export declare function handleUninstallRoute(req: UnifiedRequest, ctx: RouteCont
37
37
  * Handle POST /provision
38
38
  */
39
39
  export declare function handleProvisionRoute(req: UnifiedRequest, ctx: RouteContext): Promise<UnifiedResponse>;
40
+ /**
41
+ * Handle POST /setup/revalidate
42
+ */
43
+ export declare function handleSetupRevalidateRoute(req: UnifiedRequest, ctx: RouteContext): Promise<UnifiedResponse>;
40
44
  /**
41
45
  * Handle POST /oauth_callback
42
46
  */
@@ -6,5 +6,5 @@
6
6
  */
7
7
  export type { UnifiedRequest, UnifiedResponse, RouteContext, CallToolFn, ParsedJsonRpcBody, SkedyulToolCallArgs, ParseResult, } from './types';
8
8
  export { fromLambdaEvent, toLambdaResponse, parseJsonBody, parseJsonRpcBody, getHeader, getContentType, parseBodyByContentType, } from './adapters';
9
- export { handleHealthRoute, handleConfigRoute, handleCoreRoute, handleCoreWebhookRoute, handleEstimateRoute, handleInstallRoute, handleUninstallRoute, handleProvisionRoute, handleOAuthCallbackRoute, handleWebhookRoute, handleMcpRoute, createNotFoundResponse, createOptionsResponse, createErrorResponse, } from './handlers';
9
+ export { handleHealthRoute, handleConfigRoute, handleCoreRoute, handleCoreWebhookRoute, handleEstimateRoute, handleInstallRoute, handleUninstallRoute, handleProvisionRoute, handleSetupRevalidateRoute, handleOAuthCallbackRoute, handleWebhookRoute, handleMcpRoute, createNotFoundResponse, createOptionsResponse, createErrorResponse, } from './handlers';
10
10
  export { routeRequest } from './router';
package/dist/server.js CHANGED
@@ -1200,6 +1200,72 @@ async function handleProvision(body, hooks) {
1200
1200
  }
1201
1201
  }
1202
1202
 
1203
+ // src/server/handlers/setup-revalidate-handler.ts
1204
+ async function handleSetupRevalidate(body, hooks) {
1205
+ const revalidateHook = hooks?.setup?.revalidate;
1206
+ if (!revalidateHook) {
1207
+ return {
1208
+ status: 404,
1209
+ body: { error: "Setup revalidate handler not configured" }
1210
+ };
1211
+ }
1212
+ if (!body.context?.appInstallationId || !body.context?.workplace || !body.context?.app || !body.reason || !Array.isArray(body.steps)) {
1213
+ return {
1214
+ status: 400,
1215
+ body: {
1216
+ error: {
1217
+ code: -32602,
1218
+ message: "Missing context (appInstallationId, workplace, app, reason, and steps required)"
1219
+ }
1220
+ }
1221
+ };
1222
+ }
1223
+ const ctx = {
1224
+ env: body.env ?? {},
1225
+ workplace: body.context.workplace,
1226
+ appInstallationId: body.context.appInstallationId,
1227
+ app: body.context.app,
1228
+ reason: body.reason,
1229
+ steps: body.steps,
1230
+ crm: body.crm,
1231
+ envChange: body.envChange,
1232
+ invocation: body.invocation,
1233
+ log: createContextLogger()
1234
+ };
1235
+ const requestConfig = {
1236
+ baseUrl: body.env?.SKEDYUL_API_URL ?? process.env.SKEDYUL_API_URL ?? "",
1237
+ apiToken: body.env?.SKEDYUL_API_TOKEN ?? process.env.SKEDYUL_API_TOKEN ?? ""
1238
+ };
1239
+ try {
1240
+ const handler = typeof revalidateHook === "function" ? revalidateHook : revalidateHook.handler;
1241
+ const result = await runWithLogContext(
1242
+ { invocation: body.invocation },
1243
+ async () => {
1244
+ return await runWithConfig(requestConfig, async () => {
1245
+ return await handler(ctx);
1246
+ });
1247
+ }
1248
+ );
1249
+ return {
1250
+ status: 200,
1251
+ body: {
1252
+ completed: result?.completed ?? [],
1253
+ invalidated: result?.invalidated ?? []
1254
+ }
1255
+ };
1256
+ } catch (err) {
1257
+ return {
1258
+ status: 500,
1259
+ body: {
1260
+ error: {
1261
+ code: -32603,
1262
+ message: err instanceof Error ? err.message : String(err ?? "")
1263
+ }
1264
+ }
1265
+ };
1266
+ }
1267
+ }
1268
+
1203
1269
  // src/server/handler-helpers.ts
1204
1270
  function parseHandlerEnvelope(parsedBody) {
1205
1271
  if (typeof parsedBody !== "object" || parsedBody === null || Array.isArray(parsedBody) || !("env" in parsedBody) || !("request" in parsedBody)) {
@@ -1591,6 +1657,14 @@ async function handleProvisionRoute(req, ctx) {
1591
1657
  const result = await handleProvision(parseResult.data, ctx.config.hooks);
1592
1658
  return { status: result.status, body: result.body };
1593
1659
  }
1660
+ async function handleSetupRevalidateRoute(req, ctx) {
1661
+ const parseResult = parseJsonBody(req);
1662
+ if (!parseResult.success) {
1663
+ return parseResult.error;
1664
+ }
1665
+ const result = await handleSetupRevalidate(parseResult.data, ctx.config.hooks);
1666
+ return { status: result.status, body: result.body };
1667
+ }
1594
1668
  async function handleOAuthCallbackRoute(req, ctx) {
1595
1669
  const parseResult = parseJsonBody(req);
1596
1670
  if (!parseResult.success) {
@@ -1952,6 +2026,9 @@ async function routeRequest(req, ctx) {
1952
2026
  if (req.path === "/provision" && req.method === "POST") {
1953
2027
  return handleProvisionRoute(req, ctx);
1954
2028
  }
2029
+ if (req.path === "/setup/revalidate" && req.method === "POST") {
2030
+ return handleSetupRevalidateRoute(req, ctx);
2031
+ }
1955
2032
  if (req.path === "/oauth_callback" && req.method === "POST") {
1956
2033
  return handleOAuthCallbackRoute(req, ctx);
1957
2034
  }
@@ -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
  }