skedyul 1.5.13 → 1.7.0
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 +178 -148
- package/dist/config/app-config.d.ts +12 -1
- package/dist/config/define.d.ts +23 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/sequencer-config.d.ts +20 -0
- package/dist/config/types/entity.d.ts +59 -0
- package/dist/config/types/index.d.ts +1 -0
- package/dist/config/types/model.d.ts +2 -0
- package/dist/core/client.d.ts +23 -8
- package/dist/dedicated/server.js +35 -11
- package/dist/esm/index.mjs +573 -42
- package/dist/index.d.ts +4 -2
- package/dist/index.js +594 -42
- package/dist/schemas/crm-schema.d.ts +10 -0
- package/dist/schemas.d.ts +229 -0
- package/dist/sequencer/backends/index.d.ts +10 -0
- package/dist/sequencer/backends/memory.d.ts +26 -0
- package/dist/sequencer/backends/platform.d.ts +22 -0
- package/dist/sequencer/config-loader.d.ts +9 -0
- package/dist/sequencer/errors.d.ts +17 -0
- package/dist/sequencer/index.d.ts +24 -0
- package/dist/sequencer/resolve-sequencer-key.d.ts +7 -0
- package/dist/sequencer/types.d.ts +50 -0
- package/dist/server.js +35 -11
- package/dist/serverless/server.mjs +35 -11
- package/package.json +2 -2
|
@@ -280,6 +280,11 @@ export declare const CRMPageSchemaZ: z.ZodObject<{
|
|
|
280
280
|
icon: z.ZodOptional<z.ZodString>;
|
|
281
281
|
modelHandle: z.ZodString;
|
|
282
282
|
parentPath: z.ZodOptional<z.ZodString>;
|
|
283
|
+
isDefault: z.ZodOptional<z.ZodBoolean>;
|
|
284
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
285
|
+
team: "team";
|
|
286
|
+
private: "private";
|
|
287
|
+
}>>;
|
|
283
288
|
baseQuery: z.ZodOptional<z.ZodUnknown>;
|
|
284
289
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
285
290
|
type: z.ZodEnum<{
|
|
@@ -406,6 +411,11 @@ export declare const CRMSchemaZ: z.ZodObject<{
|
|
|
406
411
|
icon: z.ZodOptional<z.ZodString>;
|
|
407
412
|
modelHandle: z.ZodString;
|
|
408
413
|
parentPath: z.ZodOptional<z.ZodString>;
|
|
414
|
+
isDefault: z.ZodOptional<z.ZodBoolean>;
|
|
415
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
416
|
+
team: "team";
|
|
417
|
+
private: "private";
|
|
418
|
+
}>>;
|
|
409
419
|
baseQuery: z.ZodOptional<z.ZodUnknown>;
|
|
410
420
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
411
421
|
type: z.ZodEnum<{
|
package/dist/schemas.d.ts
CHANGED
|
@@ -327,6 +327,95 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
|
|
|
327
327
|
addDefaultPages: z.ZodOptional<z.ZodBoolean>;
|
|
328
328
|
addNavigation: z.ZodOptional<z.ZodBoolean>;
|
|
329
329
|
page: z.ZodOptional<z.ZodString>;
|
|
330
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
331
|
+
label: z.ZodString;
|
|
332
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
333
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
334
|
+
visible: "visible";
|
|
335
|
+
encrypted: "encrypted";
|
|
336
|
+
}>>;
|
|
337
|
+
default: z.ZodOptional<z.ZodString>;
|
|
338
|
+
description: z.ZodOptional<z.ZodString>;
|
|
339
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
340
|
+
}, z.core.$strip>>>;
|
|
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
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
356
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
357
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
358
|
+
value: z.ZodString;
|
|
359
|
+
label: z.ZodString;
|
|
360
|
+
}, z.core.$strip>]>>>;
|
|
361
|
+
}, z.core.$strip>;
|
|
362
|
+
export declare const EntityRelationshipDefinitionSchema: z.ZodObject<{
|
|
363
|
+
handle: z.ZodString;
|
|
364
|
+
label: z.ZodString;
|
|
365
|
+
targetEntity: z.ZodOptional<z.ZodString>;
|
|
366
|
+
description: z.ZodOptional<z.ZodString>;
|
|
367
|
+
}, z.core.$strip>;
|
|
368
|
+
export declare const EntityDefinitionSchema: z.ZodObject<{
|
|
369
|
+
handle: z.ZodString;
|
|
370
|
+
label: z.ZodString;
|
|
371
|
+
labelPlural: z.ZodOptional<z.ZodString>;
|
|
372
|
+
description: z.ZodOptional<z.ZodString>;
|
|
373
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
374
|
+
handle: z.ZodString;
|
|
375
|
+
label: z.ZodString;
|
|
376
|
+
description: z.ZodOptional<z.ZodString>;
|
|
377
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
378
|
+
string: "string";
|
|
379
|
+
number: "number";
|
|
380
|
+
boolean: "boolean";
|
|
381
|
+
object: "object";
|
|
382
|
+
long_string: "long_string";
|
|
383
|
+
date: "date";
|
|
384
|
+
datetime: "datetime";
|
|
385
|
+
}>>;
|
|
386
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
387
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
388
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
389
|
+
value: z.ZodString;
|
|
390
|
+
label: z.ZodString;
|
|
391
|
+
}, z.core.$strip>]>>>;
|
|
392
|
+
}, z.core.$strip>>;
|
|
393
|
+
contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
394
|
+
handle: z.ZodString;
|
|
395
|
+
label: z.ZodString;
|
|
396
|
+
description: z.ZodOptional<z.ZodString>;
|
|
397
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
398
|
+
string: "string";
|
|
399
|
+
number: "number";
|
|
400
|
+
boolean: "boolean";
|
|
401
|
+
object: "object";
|
|
402
|
+
long_string: "long_string";
|
|
403
|
+
date: "date";
|
|
404
|
+
datetime: "datetime";
|
|
405
|
+
}>>;
|
|
406
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
407
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
408
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
409
|
+
value: z.ZodString;
|
|
410
|
+
label: z.ZodString;
|
|
411
|
+
}, z.core.$strip>]>>>;
|
|
412
|
+
}, z.core.$strip>>>;
|
|
413
|
+
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
414
|
+
handle: z.ZodString;
|
|
415
|
+
label: z.ZodString;
|
|
416
|
+
targetEntity: z.ZodOptional<z.ZodString>;
|
|
417
|
+
description: z.ZodOptional<z.ZodString>;
|
|
418
|
+
}, z.core.$strip>>>;
|
|
330
419
|
}, z.core.$strip>;
|
|
331
420
|
export declare const RelationshipCardinalitySchema: z.ZodEnum<{
|
|
332
421
|
ONE_TO_ONE: "ONE_TO_ONE";
|
|
@@ -3218,6 +3307,17 @@ export declare const InstallConfigSchema: z.ZodObject<{
|
|
|
3218
3307
|
addDefaultPages: z.ZodOptional<z.ZodBoolean>;
|
|
3219
3308
|
addNavigation: z.ZodOptional<z.ZodBoolean>;
|
|
3220
3309
|
page: z.ZodOptional<z.ZodString>;
|
|
3310
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3311
|
+
label: z.ZodString;
|
|
3312
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
3313
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
3314
|
+
visible: "visible";
|
|
3315
|
+
encrypted: "encrypted";
|
|
3316
|
+
}>>;
|
|
3317
|
+
default: z.ZodOptional<z.ZodString>;
|
|
3318
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3319
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
3320
|
+
}, z.core.$strip>>>;
|
|
3221
3321
|
}, z.core.$strip>>>;
|
|
3222
3322
|
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3223
3323
|
source: z.ZodObject<{
|
|
@@ -3341,6 +3441,69 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
|
|
|
3341
3441
|
addDefaultPages: z.ZodOptional<z.ZodBoolean>;
|
|
3342
3442
|
addNavigation: z.ZodOptional<z.ZodBoolean>;
|
|
3343
3443
|
page: z.ZodOptional<z.ZodString>;
|
|
3444
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3445
|
+
label: z.ZodString;
|
|
3446
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
3447
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
3448
|
+
visible: "visible";
|
|
3449
|
+
encrypted: "encrypted";
|
|
3450
|
+
}>>;
|
|
3451
|
+
default: z.ZodOptional<z.ZodString>;
|
|
3452
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3453
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
3454
|
+
}, z.core.$strip>>>;
|
|
3455
|
+
}, z.core.$strip>>>;
|
|
3456
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3457
|
+
handle: z.ZodString;
|
|
3458
|
+
label: z.ZodString;
|
|
3459
|
+
labelPlural: z.ZodOptional<z.ZodString>;
|
|
3460
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3461
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
3462
|
+
handle: z.ZodString;
|
|
3463
|
+
label: z.ZodString;
|
|
3464
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3465
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
3466
|
+
string: "string";
|
|
3467
|
+
number: "number";
|
|
3468
|
+
boolean: "boolean";
|
|
3469
|
+
object: "object";
|
|
3470
|
+
long_string: "long_string";
|
|
3471
|
+
date: "date";
|
|
3472
|
+
datetime: "datetime";
|
|
3473
|
+
}>>;
|
|
3474
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
3475
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
3476
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
3477
|
+
value: z.ZodString;
|
|
3478
|
+
label: z.ZodString;
|
|
3479
|
+
}, z.core.$strip>]>>>;
|
|
3480
|
+
}, z.core.$strip>>;
|
|
3481
|
+
contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3482
|
+
handle: z.ZodString;
|
|
3483
|
+
label: z.ZodString;
|
|
3484
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3485
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
3486
|
+
string: "string";
|
|
3487
|
+
number: "number";
|
|
3488
|
+
boolean: "boolean";
|
|
3489
|
+
object: "object";
|
|
3490
|
+
long_string: "long_string";
|
|
3491
|
+
date: "date";
|
|
3492
|
+
datetime: "datetime";
|
|
3493
|
+
}>>;
|
|
3494
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
3495
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
3496
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
3497
|
+
value: z.ZodString;
|
|
3498
|
+
label: z.ZodString;
|
|
3499
|
+
}, z.core.$strip>]>>>;
|
|
3500
|
+
}, z.core.$strip>>>;
|
|
3501
|
+
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3502
|
+
handle: z.ZodString;
|
|
3503
|
+
label: z.ZodString;
|
|
3504
|
+
targetEntity: z.ZodOptional<z.ZodString>;
|
|
3505
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3506
|
+
}, z.core.$strip>>>;
|
|
3344
3507
|
}, z.core.$strip>>>;
|
|
3345
3508
|
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3346
3509
|
source: z.ZodObject<{
|
|
@@ -4076,6 +4239,69 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
|
|
|
4076
4239
|
addDefaultPages: z.ZodOptional<z.ZodBoolean>;
|
|
4077
4240
|
addNavigation: z.ZodOptional<z.ZodBoolean>;
|
|
4078
4241
|
page: z.ZodOptional<z.ZodString>;
|
|
4242
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
4243
|
+
label: z.ZodString;
|
|
4244
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
4245
|
+
visibility: z.ZodOptional<z.ZodEnum<{
|
|
4246
|
+
visible: "visible";
|
|
4247
|
+
encrypted: "encrypted";
|
|
4248
|
+
}>>;
|
|
4249
|
+
default: z.ZodOptional<z.ZodString>;
|
|
4250
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4251
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
4252
|
+
}, z.core.$strip>>>;
|
|
4253
|
+
}, z.core.$strip>>>;
|
|
4254
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4255
|
+
handle: z.ZodString;
|
|
4256
|
+
label: z.ZodString;
|
|
4257
|
+
labelPlural: z.ZodOptional<z.ZodString>;
|
|
4258
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4259
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
4260
|
+
handle: z.ZodString;
|
|
4261
|
+
label: z.ZodString;
|
|
4262
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4263
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
4264
|
+
string: "string";
|
|
4265
|
+
number: "number";
|
|
4266
|
+
boolean: "boolean";
|
|
4267
|
+
object: "object";
|
|
4268
|
+
long_string: "long_string";
|
|
4269
|
+
date: "date";
|
|
4270
|
+
datetime: "datetime";
|
|
4271
|
+
}>>;
|
|
4272
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
4273
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
4274
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
4275
|
+
value: z.ZodString;
|
|
4276
|
+
label: z.ZodString;
|
|
4277
|
+
}, z.core.$strip>]>>>;
|
|
4278
|
+
}, z.core.$strip>>;
|
|
4279
|
+
contextFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4280
|
+
handle: z.ZodString;
|
|
4281
|
+
label: z.ZodString;
|
|
4282
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4283
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
4284
|
+
string: "string";
|
|
4285
|
+
number: "number";
|
|
4286
|
+
boolean: "boolean";
|
|
4287
|
+
object: "object";
|
|
4288
|
+
long_string: "long_string";
|
|
4289
|
+
date: "date";
|
|
4290
|
+
datetime: "datetime";
|
|
4291
|
+
}>>;
|
|
4292
|
+
matchCandidate: z.ZodOptional<z.ZodBoolean>;
|
|
4293
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
4294
|
+
options: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
4295
|
+
value: z.ZodString;
|
|
4296
|
+
label: z.ZodString;
|
|
4297
|
+
}, z.core.$strip>]>>>;
|
|
4298
|
+
}, z.core.$strip>>>;
|
|
4299
|
+
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4300
|
+
handle: z.ZodString;
|
|
4301
|
+
label: z.ZodString;
|
|
4302
|
+
targetEntity: z.ZodOptional<z.ZodString>;
|
|
4303
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4304
|
+
}, z.core.$strip>>>;
|
|
4079
4305
|
}, z.core.$strip>>>;
|
|
4080
4306
|
relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4081
4307
|
source: z.ZodObject<{
|
|
@@ -4748,6 +4974,9 @@ export type WorkflowDependency = z.infer<typeof WorkflowDependencySchema>;
|
|
|
4748
4974
|
export type ResourceDependency = z.infer<typeof ResourceDependencySchema>;
|
|
4749
4975
|
export type ModelFieldDefinition = z.infer<typeof ModelFieldDefinitionSchema>;
|
|
4750
4976
|
export type ModelDefinition = z.infer<typeof ModelDefinitionSchema>;
|
|
4977
|
+
export type EntityFieldDefinition = z.infer<typeof EntityFieldDefinitionSchema>;
|
|
4978
|
+
export type EntityRelationshipDefinition = z.infer<typeof EntityRelationshipDefinitionSchema>;
|
|
4979
|
+
export type EntityDefinition = z.infer<typeof EntityDefinitionSchema>;
|
|
4751
4980
|
export type ChannelCapabilityType = z.infer<typeof ChannelCapabilityTypeSchema>;
|
|
4752
4981
|
export type ChannelCapability = z.infer<typeof ChannelCapabilitySchema>;
|
|
4753
4982
|
export type ChannelFieldDefinition = z.infer<typeof ChannelFieldDefinitionSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { platformSequencerBackend } from './platform';
|
|
2
|
+
import { memorySequencerBackend, resetMemorySequencerBackendForTests } from './memory';
|
|
3
|
+
import type { SequencerBackend } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the active sequencer backend.
|
|
6
|
+
* Uses platform proxy by default; falls back to in-memory when configured or on local errors.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSequencerBackend(): SequencerBackend;
|
|
9
|
+
export declare function resetSequencerBackendForTests(): void;
|
|
10
|
+
export { platformSequencerBackend, memorySequencerBackend, resetMemorySequencerBackendForTests };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SequencerBackend, SequencerAllowResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* In-process sequencer backend for local development and tests.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemorySequencerBackend implements SequencerBackend {
|
|
6
|
+
private readonly state;
|
|
7
|
+
private getState;
|
|
8
|
+
allow(sequencerKey: string, input: {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
leaseId?: string;
|
|
11
|
+
watermarkTtlMs?: number;
|
|
12
|
+
}): Promise<SequencerAllowResult>;
|
|
13
|
+
acquire(sequencerKey: string, input: {
|
|
14
|
+
leaseId: string;
|
|
15
|
+
timestamp?: number;
|
|
16
|
+
lockTtlMs?: number;
|
|
17
|
+
watermarkTtlMs?: number;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
acquired: boolean;
|
|
20
|
+
reason: 'ok' | 'locked';
|
|
21
|
+
}>;
|
|
22
|
+
release(sequencerKey: string, leaseId: string): Promise<void>;
|
|
23
|
+
resetForTests(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const memorySequencerBackend: MemorySequencerBackend;
|
|
26
|
+
export declare function resetMemorySequencerBackendForTests(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SequencerBackend, SequencerAllowResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP backend that delegates allow/acquire/release to the Skedyul platform proxy.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PlatformSequencerBackend implements SequencerBackend {
|
|
6
|
+
allow(sequencerKey: string, input: {
|
|
7
|
+
timestamp: number;
|
|
8
|
+
leaseId?: string;
|
|
9
|
+
watermarkTtlMs?: number;
|
|
10
|
+
}): Promise<SequencerAllowResult>;
|
|
11
|
+
acquire(sequencerKey: string, input: {
|
|
12
|
+
leaseId: string;
|
|
13
|
+
timestamp?: number;
|
|
14
|
+
lockTtlMs?: number;
|
|
15
|
+
watermarkTtlMs?: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
acquired: boolean;
|
|
18
|
+
reason: 'ok' | 'locked';
|
|
19
|
+
}>;
|
|
20
|
+
release(sequencerKey: string, leaseId: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare const platformSequencerBackend: PlatformSequencerBackend;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SkedyulConfig } from '../config/app-config';
|
|
2
|
+
import type { SerializableSequencerConfig } from '../config/sequencer-config';
|
|
3
|
+
/**
|
|
4
|
+
* Register in-process server config for sequencer resolution at runtime.
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerSequencerConfig(config: SkedyulConfig): void;
|
|
7
|
+
export declare function clearRegisteredSequencerConfig(): void;
|
|
8
|
+
export declare function getSequencerDefinitions(): Record<string, SerializableSequencerConfig>;
|
|
9
|
+
export declare function getSequencerConfig(sequencerName: string): SerializableSequencerConfig | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class SequencerContextError extends Error {
|
|
2
|
+
readonly code = "SEQUENCER_CONTEXT_ERROR";
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SequencerNotFoundError extends Error {
|
|
6
|
+
readonly code = "SEQUENCER_NOT_FOUND";
|
|
7
|
+
constructor(name: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class SequencerBackendError extends Error {
|
|
10
|
+
readonly code = "SEQUENCER_BACKEND_ERROR";
|
|
11
|
+
readonly statusCode?: number;
|
|
12
|
+
constructor(message: string, statusCode?: number);
|
|
13
|
+
}
|
|
14
|
+
export declare class SequencerLockError extends Error {
|
|
15
|
+
readonly code = "SEQUENCER_LOCK_ERROR";
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SequencerInput, SequencerAllowInput, SequencerAcquireInput, SequencerReleaseInput, SequencerAllowResult, ResolvedSequencer } from './types';
|
|
2
|
+
import type { RateLimitExecutionContext } from '../ratelimit/types';
|
|
3
|
+
export declare function resolveSequencer(sequencerInput: SequencerInput, ctxOverride?: Partial<RateLimitExecutionContext>): ResolvedSequencer;
|
|
4
|
+
export declare function createSequencerHandle(sequencerInput: SequencerInput, ctxOverride?: Partial<RateLimitExecutionContext>): {
|
|
5
|
+
allow(input: Omit<SequencerAllowInput, "key">): Promise<SequencerAllowResult>;
|
|
6
|
+
acquire(input: Omit<SequencerAcquireInput, "key">): Promise<void>;
|
|
7
|
+
release(input: Omit<SequencerReleaseInput, "key">): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare function allow(sequencerInput: SequencerInput, input: SequencerAllowInput, ctxOverride?: Partial<RateLimitExecutionContext>): Promise<SequencerAllowResult>;
|
|
10
|
+
export declare function acquire(sequencerInput: SequencerInput, input: SequencerAcquireInput, ctxOverride?: Partial<RateLimitExecutionContext>): Promise<void>;
|
|
11
|
+
export declare function release(sequencerInput: SequencerInput, input: SequencerReleaseInput, ctxOverride?: Partial<RateLimitExecutionContext>): Promise<void>;
|
|
12
|
+
export { registerSequencerConfig, clearRegisteredSequencerConfig, getSequencerConfig, getSequencerDefinitions, } from './config-loader';
|
|
13
|
+
export { resolveSequencerKey } from './resolve-sequencer-key';
|
|
14
|
+
export { getSequencerBackend, resetSequencerBackendForTests, memorySequencerBackend, platformSequencerBackend, resetMemorySequencerBackendForTests, } from './backends';
|
|
15
|
+
export { SequencerContextError, SequencerNotFoundError, SequencerBackendError, SequencerLockError, } from './errors';
|
|
16
|
+
export type { SequencerInput, SequencerSelector, SequencerAllowInput, SequencerAcquireInput, SequencerReleaseInput, SequencerAllowResult, ResolvedSequencer, SequencerBackend, SequencerReason, SequencerExecutionContext, } from './types';
|
|
17
|
+
export type { SequencerScope, SerializableSequencerConfig, SequencerRegistry, } from '../config/sequencer-config';
|
|
18
|
+
export declare const sequencer: {
|
|
19
|
+
allow: typeof allow;
|
|
20
|
+
acquire: typeof acquire;
|
|
21
|
+
release: typeof release;
|
|
22
|
+
resolve: typeof resolveSequencer;
|
|
23
|
+
createHandle: typeof createSequencerHandle;
|
|
24
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RateLimitExecutionContext } from '../ratelimit/types';
|
|
2
|
+
import type { SerializableSequencerConfig } from '../config/sequencer-config';
|
|
3
|
+
/**
|
|
4
|
+
* Build the Redis sequencer key for a named sequencer definition.
|
|
5
|
+
* Must stay in sync with skedyul-core sequencer validation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveSequencerKey(sequencerName: string, config: SerializableSequencerConfig, ctx: RateLimitExecutionContext, subKey?: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SerializableSequencerConfig } from '../config/sequencer-config';
|
|
2
|
+
export type { RateLimitExecutionContext as SequencerExecutionContext } from '../ratelimit/types';
|
|
3
|
+
export type SequencerReason = 'ok' | 'stale' | 'locked' | 'disabled';
|
|
4
|
+
export interface SequencerSelector {
|
|
5
|
+
sequencer: string;
|
|
6
|
+
key?: string;
|
|
7
|
+
}
|
|
8
|
+
export type SequencerInput = string | SequencerSelector;
|
|
9
|
+
export interface SequencerAllowInput {
|
|
10
|
+
key?: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
leaseId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SequencerAcquireInput {
|
|
15
|
+
key?: string;
|
|
16
|
+
leaseId: string;
|
|
17
|
+
timestamp?: number;
|
|
18
|
+
lockTtlMs?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SequencerReleaseInput {
|
|
21
|
+
key?: string;
|
|
22
|
+
leaseId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SequencerAllowResult {
|
|
25
|
+
allowed: boolean;
|
|
26
|
+
reason: SequencerReason;
|
|
27
|
+
watermark?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ResolvedSequencer {
|
|
30
|
+
name: string;
|
|
31
|
+
sequencerKey: string;
|
|
32
|
+
config: SerializableSequencerConfig;
|
|
33
|
+
}
|
|
34
|
+
export interface SequencerBackend {
|
|
35
|
+
allow(sequencerKey: string, input: {
|
|
36
|
+
timestamp: number;
|
|
37
|
+
leaseId?: string;
|
|
38
|
+
watermarkTtlMs?: number;
|
|
39
|
+
}): Promise<SequencerAllowResult>;
|
|
40
|
+
acquire(sequencerKey: string, input: {
|
|
41
|
+
leaseId: string;
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
lockTtlMs?: number;
|
|
44
|
+
watermarkTtlMs?: number;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
acquired: boolean;
|
|
47
|
+
reason: 'ok' | 'locked';
|
|
48
|
+
}>;
|
|
49
|
+
release(sequencerKey: string, leaseId: string): Promise<void>;
|
|
50
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -97,6 +97,16 @@ function registerQueueConfig(config) {
|
|
|
97
97
|
cachedRuntimeQueues = config.queues ?? null;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// src/sequencer/config-loader.ts
|
|
101
|
+
var fs2 = __toESM(require("fs"));
|
|
102
|
+
var path2 = __toESM(require("path"));
|
|
103
|
+
var cachedRuntimeSequencers = null;
|
|
104
|
+
var registeredServerConfig2 = null;
|
|
105
|
+
function registerSequencerConfig(config) {
|
|
106
|
+
registeredServerConfig2 = config;
|
|
107
|
+
cachedRuntimeSequencers = config.sequencers ?? null;
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
// src/server/utils/schema.ts
|
|
101
111
|
var z = __toESM(require("zod"));
|
|
102
112
|
function normalizeBilling(billing) {
|
|
@@ -733,7 +743,7 @@ function printStartupLog(config, tools, port) {
|
|
|
733
743
|
|
|
734
744
|
// src/server/route-handlers/adapters.ts
|
|
735
745
|
function fromLambdaEvent(event) {
|
|
736
|
-
const
|
|
746
|
+
const path4 = event.path || event.rawPath || "/";
|
|
737
747
|
const method = event.httpMethod || event.requestContext?.http?.method || "POST";
|
|
738
748
|
const forwardedProto = event.headers?.["x-forwarded-proto"] ?? event.headers?.["X-Forwarded-Proto"];
|
|
739
749
|
const protocol = forwardedProto ?? "https";
|
|
@@ -741,9 +751,9 @@ function fromLambdaEvent(event) {
|
|
|
741
751
|
const queryString = event.queryStringParameters ? "?" + new URLSearchParams(
|
|
742
752
|
event.queryStringParameters
|
|
743
753
|
).toString() : "";
|
|
744
|
-
const url = `${protocol}://${host}${
|
|
754
|
+
const url = `${protocol}://${host}${path4}${queryString}`;
|
|
745
755
|
return {
|
|
746
|
-
path:
|
|
756
|
+
path: path4,
|
|
747
757
|
method,
|
|
748
758
|
headers: event.headers,
|
|
749
759
|
query: event.queryStringParameters ?? {},
|
|
@@ -825,8 +835,8 @@ function parseBodyByContentType(req) {
|
|
|
825
835
|
}
|
|
826
836
|
|
|
827
837
|
// src/server/route-handlers/handlers.ts
|
|
828
|
-
var
|
|
829
|
-
var
|
|
838
|
+
var fs3 = __toESM(require("fs"));
|
|
839
|
+
var path3 = __toESM(require("path"));
|
|
830
840
|
|
|
831
841
|
// src/server/core-api-handler.ts
|
|
832
842
|
async function handleCoreMethod(method, params) {
|
|
@@ -1293,8 +1303,13 @@ async function handleOAuthCallback(parsedBody, hooks) {
|
|
|
1293
1303
|
}
|
|
1294
1304
|
}
|
|
1295
1305
|
|
|
1306
|
+
// src/types/webhook.ts
|
|
1307
|
+
function isRuntimeWebhookContext(ctx) {
|
|
1308
|
+
return "appInstallationId" in ctx && ctx.appInstallationId !== void 0;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1296
1311
|
// src/server/handlers/webhook-handler.ts
|
|
1297
|
-
function parseWebhookRequest(parsedBody, method, url,
|
|
1312
|
+
function parseWebhookRequest(parsedBody, method, url, path4, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
|
|
1298
1313
|
const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
|
|
1299
1314
|
if (isEnvelope) {
|
|
1300
1315
|
const envelope = parsedBody;
|
|
@@ -1348,7 +1363,7 @@ function parseWebhookRequest(parsedBody, method, url, path3, headers, query, raw
|
|
|
1348
1363
|
const webhookRequest = {
|
|
1349
1364
|
method,
|
|
1350
1365
|
url,
|
|
1351
|
-
path:
|
|
1366
|
+
path: path4,
|
|
1352
1367
|
headers,
|
|
1353
1368
|
query,
|
|
1354
1369
|
body: parsedBody,
|
|
@@ -1377,9 +1392,17 @@ async function executeWebhookHandler(handle, webhookRegistry, data) {
|
|
|
1377
1392
|
};
|
|
1378
1393
|
let webhookResponse;
|
|
1379
1394
|
try {
|
|
1395
|
+
const rateLimitContext = {
|
|
1396
|
+
app: data.webhookContext.app,
|
|
1397
|
+
appInstallationId: isRuntimeWebhookContext(data.webhookContext) ? data.webhookContext.appInstallationId : void 0,
|
|
1398
|
+
invocation: data.invocation,
|
|
1399
|
+
isProvisionContext: !isRuntimeWebhookContext(data.webhookContext)
|
|
1400
|
+
};
|
|
1380
1401
|
webhookResponse = await runWithLogContext({ invocation: data.invocation }, async () => {
|
|
1381
1402
|
return await runWithConfig(requestConfig, async () => {
|
|
1382
|
-
return await
|
|
1403
|
+
return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
|
|
1404
|
+
return await webhookDef.handler(data.webhookRequest, data.webhookContext);
|
|
1405
|
+
});
|
|
1383
1406
|
});
|
|
1384
1407
|
});
|
|
1385
1408
|
} catch (err) {
|
|
@@ -1406,7 +1429,7 @@ function isMethodAllowed(webhookRegistry, handle, method) {
|
|
|
1406
1429
|
|
|
1407
1430
|
// src/server/route-handlers/handlers.ts
|
|
1408
1431
|
function getConfigFilePath() {
|
|
1409
|
-
return process.env.LAMBDA_TASK_ROOT ?
|
|
1432
|
+
return process.env.LAMBDA_TASK_ROOT ? path3.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
|
|
1410
1433
|
}
|
|
1411
1434
|
function findToolInRegistry(registry, toolName) {
|
|
1412
1435
|
for (const [key, t] of Object.entries(registry)) {
|
|
@@ -1445,8 +1468,8 @@ function handleHealthRoute(ctx) {
|
|
|
1445
1468
|
function handleConfigRoute(ctx) {
|
|
1446
1469
|
const configFilePath = getConfigFilePath();
|
|
1447
1470
|
try {
|
|
1448
|
-
if (
|
|
1449
|
-
const fileConfig = JSON.parse(
|
|
1471
|
+
if (fs3.existsSync(configFilePath)) {
|
|
1472
|
+
const fileConfig = JSON.parse(fs3.readFileSync(configFilePath, "utf-8"));
|
|
1450
1473
|
return { status: 200, body: fileConfig };
|
|
1451
1474
|
}
|
|
1452
1475
|
} catch (err) {
|
|
@@ -2134,6 +2157,7 @@ installContextLogger();
|
|
|
2134
2157
|
function createSkedyulServer(config) {
|
|
2135
2158
|
mergeRuntimeEnv();
|
|
2136
2159
|
registerQueueConfig(config);
|
|
2160
|
+
registerSequencerConfig(config);
|
|
2137
2161
|
const registry = config.tools;
|
|
2138
2162
|
const webhookRegistry = config.webhooks;
|
|
2139
2163
|
if (config.coreApi?.service) {
|