@rigkit/engine 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/authoring.ts +28 -13
- package/src/authoring.typecheck.ts +21 -1
- package/src/engine.test.ts +193 -28
- package/src/engine.ts +282 -30
- package/src/host-storage.ts +128 -0
- package/src/index.ts +5 -0
- package/src/provider/types.ts +2 -0
- package/src/state.ts +40 -0
- package/src/types.ts +139 -46
- package/src/version.ts +1 -1
package/src/provider/types.ts
CHANGED
|
@@ -82,6 +82,8 @@ export interface WorkflowProviderController<Runtime = unknown> {
|
|
|
82
82
|
export type ProviderFactoryInput = {
|
|
83
83
|
provider: LoadedProviderDefinition;
|
|
84
84
|
storage: ProviderStorage;
|
|
85
|
+
hostStorage: ProviderStorage;
|
|
86
|
+
local: LocalWorkspaceRuntime;
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
export type ProviderFactory = (
|
package/src/state.ts
CHANGED
|
@@ -60,6 +60,10 @@ export interface StateService {
|
|
|
60
60
|
upstreamRunIds: readonly string[];
|
|
61
61
|
}): WorkflowNodeRunRecord | undefined;
|
|
62
62
|
saveNodeRun(run: WorkflowNodeRunRecord): void;
|
|
63
|
+
invalidateNodeRuns(input: {
|
|
64
|
+
workflow: string;
|
|
65
|
+
nodePaths: readonly string[];
|
|
66
|
+
}): string[];
|
|
63
67
|
providerStorage(providerId: string): ProviderStorage;
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -170,6 +174,42 @@ export class StateStore implements StateService {
|
|
|
170
174
|
this.db.insert(workflowNodeRuns).values(run).run();
|
|
171
175
|
}
|
|
172
176
|
|
|
177
|
+
invalidateNodeRuns(input: {
|
|
178
|
+
workflow: string;
|
|
179
|
+
nodePaths: readonly string[];
|
|
180
|
+
}): string[] {
|
|
181
|
+
const targetPaths = new Set(input.nodePaths);
|
|
182
|
+
if (targetPaths.size === 0) return [];
|
|
183
|
+
|
|
184
|
+
const rows = this.db
|
|
185
|
+
.select()
|
|
186
|
+
.from(workflowNodeRuns)
|
|
187
|
+
.where(eq(workflowNodeRuns.workflow, input.workflow))
|
|
188
|
+
.orderBy(asc(workflowNodeRuns.createdAt))
|
|
189
|
+
.all()
|
|
190
|
+
.map(toNodeRunRecord);
|
|
191
|
+
|
|
192
|
+
const invalidatedIds = new Set<string>();
|
|
193
|
+
let changed = true;
|
|
194
|
+
while (changed) {
|
|
195
|
+
changed = false;
|
|
196
|
+
for (const row of rows) {
|
|
197
|
+
if (row.invalidated || invalidatedIds.has(row.id)) continue;
|
|
198
|
+
const isTarget = targetPaths.has(row.nodePath);
|
|
199
|
+
const dependsOnInvalidated = row.upstreamRunIds.some((id) => invalidatedIds.has(id));
|
|
200
|
+
if (!isTarget && !dependsOnInvalidated) continue;
|
|
201
|
+
invalidatedIds.add(row.id);
|
|
202
|
+
changed = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
for (const id of invalidatedIds) {
|
|
207
|
+
this.db.update(workflowNodeRuns).set({ invalidated: true }).where(eq(workflowNodeRuns.id, id)).run();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return [...invalidatedIds];
|
|
211
|
+
}
|
|
212
|
+
|
|
173
213
|
providerStorage(providerId: string): ProviderStorage {
|
|
174
214
|
return new StateProviderStorage(this.db, providerId);
|
|
175
215
|
}
|
package/src/types.ts
CHANGED
|
@@ -55,13 +55,22 @@ export type CommandOptions = ExecOptions & {
|
|
|
55
55
|
export type LocalWorkspaceRuntime = {
|
|
56
56
|
open(target: string): MaybePromise<void>;
|
|
57
57
|
command?(input: LocalCommandRequest): MaybePromise<LocalCommandResult>;
|
|
58
|
-
requestCapability?<Result = unknown>(
|
|
58
|
+
requestCapability?<Result = unknown>(
|
|
59
|
+
capability: string,
|
|
60
|
+
params: unknown,
|
|
61
|
+
options?: LocalHostCapabilityRequestOptions,
|
|
62
|
+
): MaybePromise<Result>;
|
|
59
63
|
requestCapabilitySession?<Result = unknown>(
|
|
60
64
|
capability: string,
|
|
61
65
|
params: unknown,
|
|
66
|
+
options?: LocalHostCapabilityRequestOptions,
|
|
62
67
|
): MaybePromise<HostCapabilitySession<Result>>;
|
|
63
68
|
};
|
|
64
69
|
|
|
70
|
+
export type LocalHostCapabilityRequestOptions = {
|
|
71
|
+
nodePath?: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
65
74
|
export type HostCapabilitySession<Result = unknown> = {
|
|
66
75
|
result: Result;
|
|
67
76
|
closed: Promise<void>;
|
|
@@ -133,22 +142,47 @@ export type WorkflowRuntimeHelpers = {
|
|
|
133
142
|
log(data: string, options?: { stream?: WorkflowLogStream; label?: string }): void;
|
|
134
143
|
};
|
|
135
144
|
|
|
145
|
+
export const STEP_INVALIDATION_KIND = "rigkit.step.invalidate" as const;
|
|
146
|
+
|
|
147
|
+
export type WorkflowStepInvalidation<Target extends string = string> = {
|
|
148
|
+
readonly kind: typeof STEP_INVALIDATION_KIND;
|
|
149
|
+
readonly target: Target;
|
|
150
|
+
readonly targetNodePath: string;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type WorkflowStepRuntime<
|
|
154
|
+
Context extends JsonObject = JsonObject,
|
|
155
|
+
PreviousTaskIds extends string = string,
|
|
156
|
+
> = WorkflowRuntimeHelpers & {
|
|
157
|
+
readonly ctx: Readonly<Context>;
|
|
158
|
+
invalidate<const Target extends PreviousTaskIds>(target: Target): WorkflowStepInvalidation<Target>;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type WorkflowTaskContextResult<Context extends JsonObject = JsonObject> = {
|
|
162
|
+
readonly ctx: Context;
|
|
163
|
+
};
|
|
164
|
+
|
|
136
165
|
export type WorkflowTaskRuntime<
|
|
137
166
|
Providers extends WorkflowProviderMap,
|
|
138
167
|
Context extends JsonObject,
|
|
168
|
+
PreviousTaskIds extends string = string,
|
|
139
169
|
> = ProviderRuntimeMap<Providers> & {
|
|
140
170
|
readonly providers: ProviderRuntimeMap<Providers>;
|
|
141
|
-
readonly
|
|
142
|
-
readonly runtime: WorkflowRuntimeHelpers;
|
|
171
|
+
readonly step: WorkflowStepRuntime<Context, PreviousTaskIds>;
|
|
143
172
|
};
|
|
144
173
|
|
|
145
|
-
export type WorkflowTaskResult =
|
|
174
|
+
export type WorkflowTaskResult =
|
|
175
|
+
| void
|
|
176
|
+
| undefined
|
|
177
|
+
| WorkflowTaskContextResult<JsonObject>
|
|
178
|
+
| WorkflowStepInvalidation<string>;
|
|
146
179
|
|
|
147
180
|
export type WorkflowTaskHandler<
|
|
148
181
|
Providers extends WorkflowProviderMap,
|
|
149
182
|
Context extends JsonObject,
|
|
183
|
+
PreviousTaskIds extends string = string,
|
|
150
184
|
Result extends WorkflowTaskResult = WorkflowTaskResult,
|
|
151
|
-
> = (context: WorkflowTaskRuntime<Providers, Context>) => MaybePromise<Result>;
|
|
185
|
+
> = (context: WorkflowTaskRuntime<Providers, Context, PreviousTaskIds>) => MaybePromise<Result>;
|
|
152
186
|
|
|
153
187
|
export type WorkflowInputFieldKind = "workspace" | "string" | "boolean" | "number";
|
|
154
188
|
|
|
@@ -224,6 +258,7 @@ export type WorkflowOperationRuntime<
|
|
|
224
258
|
readonly providers: ProviderRuntimeMap<Providers>;
|
|
225
259
|
readonly local: LocalWorkspaceRuntime;
|
|
226
260
|
readonly workflow: string;
|
|
261
|
+
readonly step: WorkflowStepRuntime;
|
|
227
262
|
};
|
|
228
263
|
|
|
229
264
|
export type WorkflowOperationResult = void | undefined | JsonValue;
|
|
@@ -260,6 +295,7 @@ export type WorkflowWorkspaceCreateRuntime<
|
|
|
260
295
|
readonly workspace: WorkspaceCreateRuntimeRecord;
|
|
261
296
|
readonly providers: ProviderRuntimeMap<Providers>;
|
|
262
297
|
readonly local: LocalWorkspaceRuntime;
|
|
298
|
+
readonly step: WorkflowStepRuntime;
|
|
263
299
|
};
|
|
264
300
|
|
|
265
301
|
export type WorkflowWorkspaceCreateHandler<
|
|
@@ -277,6 +313,7 @@ export type WorkflowWorkspaceRemoveRuntime<
|
|
|
277
313
|
readonly workspace: WorkspaceRuntimeRecord<ReadonlyWorkspaceContext<Data>>;
|
|
278
314
|
readonly providers: ProviderRuntimeMap<Providers>;
|
|
279
315
|
readonly local: LocalWorkspaceRuntime;
|
|
316
|
+
readonly step: WorkflowStepRuntime;
|
|
280
317
|
};
|
|
281
318
|
|
|
282
319
|
export type WorkflowWorkspaceRemoveHandler<
|
|
@@ -296,6 +333,7 @@ export type WorkflowWorkspaceOperationRuntime<
|
|
|
296
333
|
readonly workspace: WorkspaceRuntimeRecord<Data>;
|
|
297
334
|
readonly providers: ProviderRuntimeMap<Providers>;
|
|
298
335
|
readonly local: LocalWorkspaceRuntime;
|
|
336
|
+
readonly step: WorkflowStepRuntime;
|
|
299
337
|
};
|
|
300
338
|
|
|
301
339
|
export type WorkflowWorkspaceOperationHandler<
|
|
@@ -372,8 +410,19 @@ export type OutputSchemaValue<Schema> =
|
|
|
372
410
|
export type WorkflowTaskOptions<Output extends JsonObject = JsonObject> = {
|
|
373
411
|
output?: OutputSchema<Output>;
|
|
374
412
|
version?: string;
|
|
413
|
+
cacheTTL?: WorkflowTaskCacheTTL;
|
|
375
414
|
};
|
|
376
415
|
|
|
416
|
+
export type WorkflowTaskCacheTTL =
|
|
417
|
+
| number
|
|
418
|
+
| string
|
|
419
|
+
| {
|
|
420
|
+
seconds?: number;
|
|
421
|
+
minutes?: number;
|
|
422
|
+
hours?: number;
|
|
423
|
+
days?: number;
|
|
424
|
+
};
|
|
425
|
+
|
|
377
426
|
export type WorkflowNodeKind = "task" | "sequence" | "parallel";
|
|
378
427
|
|
|
379
428
|
export type WorkflowDefinition<
|
|
@@ -387,29 +436,39 @@ export type WorkflowDefinition<
|
|
|
387
436
|
sequence<InputContext extends JsonObject = {}>(name: string): WorkflowSequenceBuilder<
|
|
388
437
|
Providers,
|
|
389
438
|
InputContext,
|
|
390
|
-
InputContext
|
|
439
|
+
InputContext,
|
|
440
|
+
JsonObject,
|
|
441
|
+
never,
|
|
442
|
+
never,
|
|
443
|
+
never
|
|
391
444
|
>;
|
|
392
445
|
|
|
393
446
|
task<Result extends WorkflowTaskResult>(
|
|
394
447
|
name: string,
|
|
395
|
-
handler: WorkflowTaskHandler<Providers, {}, Result>,
|
|
448
|
+
handler: WorkflowTaskHandler<Providers, {}, never, Result>,
|
|
396
449
|
): WorkflowTaskNode<Providers, {}, TaskReturnContext<Result>>;
|
|
397
450
|
|
|
398
|
-
task<
|
|
451
|
+
task<
|
|
452
|
+
Schema extends OutputSchema<JsonObject>,
|
|
453
|
+
Result extends MaybePromise<WorkflowTaskContextResult<OutputSchemaValue<Schema>> | WorkflowStepInvalidation<string> | void>,
|
|
454
|
+
>(
|
|
399
455
|
name: string,
|
|
400
456
|
options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
|
|
401
|
-
handler: WorkflowTaskHandler<Providers, {}, Awaited<Result> & WorkflowTaskResult>,
|
|
457
|
+
handler: WorkflowTaskHandler<Providers, {}, never, Awaited<Result> & WorkflowTaskResult>,
|
|
402
458
|
): WorkflowTaskNode<Providers, {}, TaskReturnContext<Result>>;
|
|
403
459
|
|
|
404
460
|
step<Result extends WorkflowTaskResult>(
|
|
405
461
|
name: string,
|
|
406
|
-
handler: WorkflowTaskHandler<Providers, {}, Result>,
|
|
462
|
+
handler: WorkflowTaskHandler<Providers, {}, never, Result>,
|
|
407
463
|
): WorkflowTaskNode<Providers, {}, TaskReturnContext<Result>>;
|
|
408
464
|
|
|
409
|
-
step<
|
|
465
|
+
step<
|
|
466
|
+
Schema extends OutputSchema<JsonObject>,
|
|
467
|
+
Result extends MaybePromise<WorkflowTaskContextResult<OutputSchemaValue<Schema>> | WorkflowStepInvalidation<string> | void>,
|
|
468
|
+
>(
|
|
410
469
|
name: string,
|
|
411
470
|
options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
|
|
412
|
-
handler: WorkflowTaskHandler<Providers, {}, Awaited<Result> & WorkflowTaskResult>,
|
|
471
|
+
handler: WorkflowTaskHandler<Providers, {}, never, Awaited<Result> & WorkflowTaskResult>,
|
|
413
472
|
): WorkflowTaskNode<Providers, {}, TaskReturnContext<Result>>;
|
|
414
473
|
};
|
|
415
474
|
|
|
@@ -446,7 +505,7 @@ export type WorkflowTaskNode<
|
|
|
446
505
|
> = WorkflowNodeDefinition<Providers, InputContext, OutputContext> & {
|
|
447
506
|
readonly nodeKind: "task";
|
|
448
507
|
readonly options?: WorkflowTaskOptions;
|
|
449
|
-
readonly handler: WorkflowTaskHandler<Providers, InputContext, any>;
|
|
508
|
+
readonly handler: WorkflowTaskHandler<Providers, InputContext, string, any>;
|
|
450
509
|
};
|
|
451
510
|
|
|
452
511
|
export type WorkflowSequenceBuilder<
|
|
@@ -456,58 +515,71 @@ export type WorkflowSequenceBuilder<
|
|
|
456
515
|
WorkspaceData extends object = JsonObject,
|
|
457
516
|
OperationIds extends string = never,
|
|
458
517
|
WorkspaceOperationIds extends string = never,
|
|
518
|
+
PreviousTaskIds extends string = never,
|
|
459
519
|
> = WorkflowNodeDefinition<Providers, InputContext, OutputContext> & {
|
|
460
520
|
readonly nodeKind: "sequence";
|
|
461
521
|
readonly children: readonly WorkflowNodeDefinition<Providers, any, any>[];
|
|
462
522
|
|
|
463
|
-
task<Result extends WorkflowTaskResult>(
|
|
464
|
-
name:
|
|
465
|
-
handler: WorkflowTaskHandler<Providers, OutputContext, Result>,
|
|
523
|
+
task<const Id extends string, Result extends WorkflowTaskResult>(
|
|
524
|
+
name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
|
|
525
|
+
handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result>,
|
|
466
526
|
): WorkflowSequenceBuilder<
|
|
467
527
|
Providers,
|
|
468
528
|
InputContext,
|
|
469
|
-
|
|
529
|
+
TaskReturnContext<Result>,
|
|
470
530
|
WorkspaceData,
|
|
471
531
|
OperationIds,
|
|
472
|
-
WorkspaceOperationIds
|
|
532
|
+
WorkspaceOperationIds,
|
|
533
|
+
PreviousTaskIds | Id
|
|
473
534
|
>;
|
|
474
535
|
|
|
475
|
-
task<
|
|
476
|
-
|
|
536
|
+
task<
|
|
537
|
+
const Id extends string,
|
|
538
|
+
Schema extends OutputSchema<JsonObject>,
|
|
539
|
+
Result extends MaybePromise<WorkflowTaskContextResult<OutputSchemaValue<Schema>> | WorkflowStepInvalidation<string> | void>,
|
|
540
|
+
>(
|
|
541
|
+
name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
|
|
477
542
|
options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
|
|
478
|
-
handler: WorkflowTaskHandler<Providers, OutputContext, Awaited<Result> & WorkflowTaskResult>,
|
|
543
|
+
handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult>,
|
|
479
544
|
): WorkflowSequenceBuilder<
|
|
480
545
|
Providers,
|
|
481
546
|
InputContext,
|
|
482
|
-
|
|
547
|
+
TaskReturnContext<Result>,
|
|
483
548
|
WorkspaceData,
|
|
484
549
|
OperationIds,
|
|
485
|
-
WorkspaceOperationIds
|
|
550
|
+
WorkspaceOperationIds,
|
|
551
|
+
PreviousTaskIds | Id
|
|
486
552
|
>;
|
|
487
553
|
|
|
488
|
-
step<Result extends WorkflowTaskResult>(
|
|
489
|
-
name:
|
|
490
|
-
handler: WorkflowTaskHandler<Providers, OutputContext, Result>,
|
|
554
|
+
step<const Id extends string, Result extends WorkflowTaskResult>(
|
|
555
|
+
name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
|
|
556
|
+
handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Result>,
|
|
491
557
|
): WorkflowSequenceBuilder<
|
|
492
558
|
Providers,
|
|
493
559
|
InputContext,
|
|
494
|
-
|
|
560
|
+
TaskReturnContext<Result>,
|
|
495
561
|
WorkspaceData,
|
|
496
562
|
OperationIds,
|
|
497
|
-
WorkspaceOperationIds
|
|
563
|
+
WorkspaceOperationIds,
|
|
564
|
+
PreviousTaskIds | Id
|
|
498
565
|
>;
|
|
499
566
|
|
|
500
|
-
step<
|
|
501
|
-
|
|
567
|
+
step<
|
|
568
|
+
const Id extends string,
|
|
569
|
+
Schema extends OutputSchema<JsonObject>,
|
|
570
|
+
Result extends MaybePromise<WorkflowTaskContextResult<OutputSchemaValue<Schema>> | WorkflowStepInvalidation<string> | void>,
|
|
571
|
+
>(
|
|
572
|
+
name: Id & WorkflowTaskIdConstraint<Id, PreviousTaskIds>,
|
|
502
573
|
options: WorkflowTaskOptions<OutputSchemaValue<Schema>>,
|
|
503
|
-
handler: WorkflowTaskHandler<Providers, OutputContext, Awaited<Result> & WorkflowTaskResult>,
|
|
574
|
+
handler: WorkflowTaskHandler<Providers, OutputContext, PreviousTaskIds, Awaited<Result> & WorkflowTaskResult>,
|
|
504
575
|
): WorkflowSequenceBuilder<
|
|
505
576
|
Providers,
|
|
506
577
|
InputContext,
|
|
507
|
-
|
|
578
|
+
TaskReturnContext<Result>,
|
|
508
579
|
WorkspaceData,
|
|
509
580
|
OperationIds,
|
|
510
|
-
WorkspaceOperationIds
|
|
581
|
+
WorkspaceOperationIds,
|
|
582
|
+
PreviousTaskIds | Id
|
|
511
583
|
>;
|
|
512
584
|
|
|
513
585
|
add<Node extends WorkflowNodeDefinition<Providers, any, any>>(
|
|
@@ -515,10 +587,11 @@ export type WorkflowSequenceBuilder<
|
|
|
515
587
|
): WorkflowSequenceBuilder<
|
|
516
588
|
Providers,
|
|
517
589
|
InputContext,
|
|
518
|
-
|
|
590
|
+
WorkflowNodeOutput<Node>,
|
|
519
591
|
WorkspaceData,
|
|
520
592
|
OperationIds,
|
|
521
|
-
WorkspaceOperationIds
|
|
593
|
+
WorkspaceOperationIds,
|
|
594
|
+
PreviousTaskIds
|
|
522
595
|
>;
|
|
523
596
|
|
|
524
597
|
parallel<const Branches extends Record<string, WorkflowNodeDefinition<Providers, any, any>>>(
|
|
@@ -533,7 +606,8 @@ export type WorkflowSequenceBuilder<
|
|
|
533
606
|
Merge<OutputContext, ParallelOutput<Branches>>,
|
|
534
607
|
WorkspaceData,
|
|
535
608
|
OperationIds,
|
|
536
|
-
WorkspaceOperationIds
|
|
609
|
+
WorkspaceOperationIds,
|
|
610
|
+
PreviousTaskIds
|
|
537
611
|
>;
|
|
538
612
|
|
|
539
613
|
workspace<Data extends JsonObject>(
|
|
@@ -544,7 +618,8 @@ export type WorkflowSequenceBuilder<
|
|
|
544
618
|
OutputContext,
|
|
545
619
|
ReadonlyWorkspaceContext<Data>,
|
|
546
620
|
OperationIds,
|
|
547
|
-
WorkspaceOperationIds
|
|
621
|
+
WorkspaceOperationIds,
|
|
622
|
+
PreviousTaskIds
|
|
548
623
|
>;
|
|
549
624
|
|
|
550
625
|
operation<const Id extends string, Input extends object = {}>(
|
|
@@ -556,7 +631,8 @@ export type WorkflowSequenceBuilder<
|
|
|
556
631
|
OutputContext,
|
|
557
632
|
WorkspaceData,
|
|
558
633
|
OperationIds | Id,
|
|
559
|
-
WorkspaceOperationIds
|
|
634
|
+
WorkspaceOperationIds,
|
|
635
|
+
PreviousTaskIds
|
|
560
636
|
>;
|
|
561
637
|
|
|
562
638
|
workspaceOperation<const Id extends string, Input extends object = {}>(
|
|
@@ -568,7 +644,8 @@ export type WorkflowSequenceBuilder<
|
|
|
568
644
|
OutputContext,
|
|
569
645
|
WorkspaceData,
|
|
570
646
|
OperationIds,
|
|
571
|
-
WorkspaceOperationIds | Id
|
|
647
|
+
WorkspaceOperationIds | Id,
|
|
648
|
+
PreviousTaskIds
|
|
572
649
|
>;
|
|
573
650
|
};
|
|
574
651
|
|
|
@@ -607,6 +684,21 @@ export type WorkflowOperationIdConstraint<
|
|
|
607
684
|
? WorkflowOperationIdError<`Operation id "${Id}" cannot contain "/"`>
|
|
608
685
|
: unknown;
|
|
609
686
|
|
|
687
|
+
type WorkflowTaskIdError<Message extends string> = {
|
|
688
|
+
readonly __rigkitTaskIdError: Message;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
export type WorkflowTaskIdConstraint<
|
|
692
|
+
Id extends string,
|
|
693
|
+
Existing extends string,
|
|
694
|
+
> = string extends Id
|
|
695
|
+
? unknown
|
|
696
|
+
: Id extends Existing
|
|
697
|
+
? WorkflowTaskIdError<`Task id "${Id}" is already defined`>
|
|
698
|
+
: Id extends ""
|
|
699
|
+
? WorkflowTaskIdError<"Task ids must be non-empty">
|
|
700
|
+
: unknown;
|
|
701
|
+
|
|
610
702
|
export type WorkflowNodeInput<Node> =
|
|
611
703
|
Node extends WorkflowNodeDefinition<any, infer Input extends JsonObject, any>
|
|
612
704
|
? Input
|
|
@@ -621,13 +713,14 @@ export type ParallelOutput<Branches extends Record<string, WorkflowNodeDefinitio
|
|
|
621
713
|
[Key in keyof Branches & string]: WorkflowNodeOutput<Branches[Key]>;
|
|
622
714
|
};
|
|
623
715
|
|
|
624
|
-
export type TaskReturnContext<Return> =
|
|
625
|
-
|
|
626
|
-
?
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
716
|
+
export type TaskReturnContext<Return> =
|
|
717
|
+
Exclude<Awaited<Return>, void | undefined | WorkflowStepInvalidation<string>> extends infer Result
|
|
718
|
+
? [Result] extends [never]
|
|
719
|
+
? {}
|
|
720
|
+
: Result extends { ctx: infer Context extends JsonObject }
|
|
721
|
+
? Simplify<Context>
|
|
722
|
+
: never
|
|
723
|
+
: {};
|
|
631
724
|
|
|
632
725
|
export type Merge<Left extends JsonObject, Right extends JsonObject> =
|
|
633
726
|
Simplify<Omit<Left, keyof Right> & Right>;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RIGKIT_ENGINE_VERSION = "0.2.
|
|
1
|
+
export const RIGKIT_ENGINE_VERSION = "0.2.4";
|