@boboddy/sdk 0.4.3 → 0.5.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/client.js +0 -23
- package/dist/definitions/advancement-policies/define-advancement-policy.d.ts +30 -5
- package/dist/definitions/advancement-policies/index.js +11 -1
- package/dist/definitions/pipelines/bindings.d.ts +62 -0
- package/dist/definitions/pipelines/builder-helpers.d.ts +19 -106
- package/dist/definitions/pipelines/chain-graph.d.ts +15 -14
- package/dist/definitions/pipelines/compile-node-definitions.d.ts +27 -0
- package/dist/definitions/pipelines/define-pipeline.d.ts +101 -154
- package/dist/definitions/pipelines/index.d.ts +0 -2
- package/dist/definitions/pipelines/index.js +470 -615
- package/dist/definitions/pipelines/node-input-ctx.d.ts +31 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +18 -4
- package/dist/definitions/pipelines/pipeline-states.d.ts +104 -0
- package/dist/definitions/steps/define-code-step.d.ts +50 -0
- package/dist/definitions/steps/define-step.d.ts +22 -1
- package/dist/definitions/steps/index.d.ts +1 -0
- package/dist/definitions/steps/index.js +41 -24
- package/dist/definitions/steps/step-definitions-client.d.ts +29 -5
- package/dist/definitions/validation/index.js +15148 -94
- package/dist/definitions/validation/validate-definition-specs.d.ts +19 -1
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/sdk.gen.d.ts +1 -4
- package/dist/generated/types.gen.d.ts +296 -878
- package/dist/index.js +510 -615
- package/dist/push/collect-definitions.d.ts +40 -1
- package/dist/push/index.d.ts +2 -2
- package/dist/push/index.js +788 -738
- package/dist/step-execution-plane-client.d.ts +9 -4
- package/package.json +2 -2
- package/dist/definitions/pipelines/builder.d.ts +0 -80
- package/dist/definitions/pipelines/fan-out-builder.d.ts +0 -66
- package/dist/definitions/pipelines/input-accessor.d.ts +0 -25
package/dist/client.js
CHANGED
|
@@ -1093,29 +1093,6 @@ class PipelineDefinitions extends HeyApiClient {
|
|
|
1093
1093
|
unarchivePipelineDefinition(options) {
|
|
1094
1094
|
return (options.client ?? this.client).put({ url: "/api/pipeline-definitions/{pipelineDefinitionId}/unarchive", ...options });
|
|
1095
1095
|
}
|
|
1096
|
-
addPipelineStep(options) {
|
|
1097
|
-
return (options.client ?? this.client).post({
|
|
1098
|
-
url: "/api/pipeline-definitions/{pipelineDefinitionId}/steps",
|
|
1099
|
-
...options,
|
|
1100
|
-
headers: {
|
|
1101
|
-
"Content-Type": "application/json",
|
|
1102
|
-
...options.headers
|
|
1103
|
-
}
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
removePipelineStep(options) {
|
|
1107
|
-
return (options.client ?? this.client).delete({ url: "/api/pipeline-definitions/{pipelineDefinitionId}/steps/{pipelineStepDefinitionId}", ...options });
|
|
1108
|
-
}
|
|
1109
|
-
updatePipelineStep(options) {
|
|
1110
|
-
return (options.client ?? this.client).put({
|
|
1111
|
-
url: "/api/pipeline-definitions/{pipelineDefinitionId}/steps/{pipelineStepDefinitionId}",
|
|
1112
|
-
...options,
|
|
1113
|
-
headers: {
|
|
1114
|
-
"Content-Type": "application/json",
|
|
1115
|
-
...options.headers
|
|
1116
|
-
}
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
1096
|
setPipelineStepAdvancementPolicy(options) {
|
|
1120
1097
|
return (options.client ?? this.client).put({
|
|
1121
1098
|
url: "/api/pipeline-definitions/{pipelineDefinitionId}/steps/{pipelineStepDefinitionId}/advancement-policy",
|
|
@@ -184,13 +184,23 @@ declare function all<TSignalKeys extends string>(conditions: RuleCondition<TSign
|
|
|
184
184
|
declare function any<TSignalKeys extends string>(conditions: RuleCondition<TSignalKeys>[]): AnyCondition<TSignalKeys>;
|
|
185
185
|
declare function any<TSignalKeys extends string>(conditions: RuleCondition<TSignalKeys>[], outcome: AdvancementOutcome): Rule<TSignalKeys>;
|
|
186
186
|
/**
|
|
187
|
-
*
|
|
188
|
-
* `
|
|
187
|
+
* When called with only `signal`/`operator`/`value`: returns a bare
|
|
188
|
+
* `SignalCondition` — used by a `choice` node's `choices[].when`, a `loop`
|
|
189
|
+
* node's `until`, and a `step` node's `blockWhen` (see
|
|
190
|
+
* docs/research/flat-pipeline-sdk-and-visual-designer.md §4/§5), none of
|
|
191
|
+
* which attach an outcome of their own (the routing target / block
|
|
192
|
+
* decision lives on the surrounding state, not on the condition).
|
|
193
|
+
*
|
|
194
|
+
* When called with `signal`/`operator`/`value`/`outcome`: returns a
|
|
195
|
+
* top-level `Rule` — shorthand for
|
|
196
|
+
* `Rule.all([Rule.signal(signal, operator, value)], outcome)`, used by the
|
|
197
|
+
* (legacy) full step-advancement-policy shape.
|
|
189
198
|
*
|
|
190
199
|
* @example
|
|
191
|
-
* Rule.when("
|
|
192
|
-
* Rule.when("
|
|
200
|
+
* Rule.when("severity", "equal", "critical") // bare condition
|
|
201
|
+
* Rule.when("passed", "equal", true, "continue") // full rule
|
|
193
202
|
*/
|
|
203
|
+
declare function when<TSignalKeys extends string>(signal: TSignalKeys | InlineComputedSignal<string, TSignalKeys>, operator: ConditionOperator, value: unknown): SignalCondition<TSignalKeys>;
|
|
194
204
|
declare function when<TSignalKeys extends string>(signal: TSignalKeys | InlineComputedSignal<string, TSignalKeys>, operator: ConditionOperator, value: unknown, outcome: AdvancementOutcome): Rule<TSignalKeys>;
|
|
195
205
|
/**
|
|
196
206
|
* All factories for building advancement rules.
|
|
@@ -252,7 +262,15 @@ type SerializedConditionGroup = {
|
|
|
252
262
|
all?: SerializedCondition[];
|
|
253
263
|
any?: SerializedCondition[];
|
|
254
264
|
};
|
|
255
|
-
|
|
265
|
+
/**
|
|
266
|
+
* The bare-condition wire format (no outcome) — structurally identical to
|
|
267
|
+
* `packages/core`'s `RuleCondition`/`rule-condition.ts` (leaves:
|
|
268
|
+
* `{fact,operator,value}`, groups: `{all:[...]}`/`{any:[...]}`). Reused
|
|
269
|
+
* verbatim for a `choice` node's `choices[].conditionJson` and a `loop`
|
|
270
|
+
* node's `untilConditionJson` (see
|
|
271
|
+
* docs/research/flat-pipeline-sdk-and-visual-designer.md §7.2).
|
|
272
|
+
*/
|
|
273
|
+
export type SerializedCondition = SerializedLeafCondition | SerializedConditionGroup;
|
|
256
274
|
type SerializedRule = {
|
|
257
275
|
conditions: SerializedConditionGroup;
|
|
258
276
|
event: {
|
|
@@ -269,6 +287,13 @@ export type SerializedAdvancementPolicy = {
|
|
|
269
287
|
defaultEventParamsJson: Record<string, unknown> | null;
|
|
270
288
|
allowedEventTypes: AdvancementEventType[];
|
|
271
289
|
};
|
|
290
|
+
/**
|
|
291
|
+
* Serializes an authored `RuleCondition` (leaf or `all`/`any` group) to its
|
|
292
|
+
* bare wire format — no outcome attached. Reused directly by `choice`'s
|
|
293
|
+
* `choices[].when`, `loop`'s `until`, and `step`'s `blockWhen` (see
|
|
294
|
+
* `SerializedCondition`'s own doc comment).
|
|
295
|
+
*/
|
|
296
|
+
export declare function serializeCondition(condition: RuleCondition): SerializedCondition;
|
|
272
297
|
export declare function serializeAdvancementPolicy(policy: AdvancementPolicy | undefined): SerializedAdvancementPolicy;
|
|
273
298
|
/** Wire-format computed signal definition emitted on the pipeline step. */
|
|
274
299
|
export type SerializedComputedSignalDefinition = {
|
|
@@ -52,10 +52,19 @@ function any(conditions, outcome) {
|
|
|
52
52
|
return { _tag: "rule", mode: "any", conditions, outcome };
|
|
53
53
|
}
|
|
54
54
|
function when(signal2, operator, value, outcome) {
|
|
55
|
+
const condition = {
|
|
56
|
+
_tag: "signal",
|
|
57
|
+
signal: signal2,
|
|
58
|
+
operator,
|
|
59
|
+
value
|
|
60
|
+
};
|
|
61
|
+
if (outcome === undefined) {
|
|
62
|
+
return condition;
|
|
63
|
+
}
|
|
55
64
|
return {
|
|
56
65
|
_tag: "rule",
|
|
57
66
|
mode: "all",
|
|
58
|
-
conditions: [
|
|
67
|
+
conditions: [condition],
|
|
59
68
|
outcome
|
|
60
69
|
};
|
|
61
70
|
}
|
|
@@ -479,6 +488,7 @@ function makeAdvanceAllCtx() {
|
|
|
479
488
|
};
|
|
480
489
|
}
|
|
481
490
|
export {
|
|
491
|
+
serializeCondition,
|
|
482
492
|
serializeCohortAdvancementPolicy,
|
|
483
493
|
serializeAdvancementPolicy,
|
|
484
494
|
makeAdvanceEachCtx,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type PipelineInputBinding = {
|
|
2
|
+
source: "pipeline_input";
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
export type WorkItemBinding = {
|
|
6
|
+
source: "work_item";
|
|
7
|
+
field: string;
|
|
8
|
+
};
|
|
9
|
+
/** Reads a signal declared by an earlier node, addressed by its state key. */
|
|
10
|
+
export type StepSignalBinding = {
|
|
11
|
+
source: "step_signal";
|
|
12
|
+
nodeKey: string;
|
|
13
|
+
signalKey: string;
|
|
14
|
+
};
|
|
15
|
+
/** Reads an earlier node's whole result output, addressed by its state key. */
|
|
16
|
+
export type StepOutputBinding = {
|
|
17
|
+
source: "step_output";
|
|
18
|
+
nodeKey: string;
|
|
19
|
+
};
|
|
20
|
+
export type LiteralBinding = {
|
|
21
|
+
source: "literal";
|
|
22
|
+
value: unknown;
|
|
23
|
+
};
|
|
24
|
+
/** Reaches a fan-out's whole cohort (every terminal branch's signals + output). */
|
|
25
|
+
export type SignalsListBinding = {
|
|
26
|
+
source: "signals_list";
|
|
27
|
+
nodeKey: string;
|
|
28
|
+
};
|
|
29
|
+
/** A fan-out's own per-branch item — see `FanOutNodeInputCtx`. */
|
|
30
|
+
export type FanOutItemBinding = {
|
|
31
|
+
source: "fan_out_item";
|
|
32
|
+
};
|
|
33
|
+
export type AnyBinding = PipelineInputBinding | WorkItemBinding | StepSignalBinding | StepOutputBinding | LiteralBinding | SignalsListBinding | FanOutItemBinding;
|
|
34
|
+
export type SerializedBinding = {
|
|
35
|
+
source: "pipeline_input";
|
|
36
|
+
path: string;
|
|
37
|
+
} | {
|
|
38
|
+
source: "work_item";
|
|
39
|
+
field: string;
|
|
40
|
+
} | {
|
|
41
|
+
source: "step_signal";
|
|
42
|
+
stepKey: string;
|
|
43
|
+
signalKey: string;
|
|
44
|
+
} | {
|
|
45
|
+
source: "step_output";
|
|
46
|
+
stepKey: string;
|
|
47
|
+
} | {
|
|
48
|
+
source: "literal";
|
|
49
|
+
value: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
source: "signals_list";
|
|
52
|
+
stepKey: string;
|
|
53
|
+
} | {
|
|
54
|
+
source: "fan_out_item";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Builds the wire `inputBindingsJson` for any working node: `workItemTitle`/
|
|
58
|
+
* `workItemDescription` are always auto-bound (mirroring the retired
|
|
59
|
+
* builder's own behavior), then overridden/extended by whatever the
|
|
60
|
+
* author's `input` mapper returned.
|
|
61
|
+
*/
|
|
62
|
+
export declare function serializeInputBindings(input: Partial<Record<string, AnyBinding | undefined>>): Record<string, SerializedBinding>;
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
import { type AnyBinding, type FanOutItemBinding, type LiteralBinding, type SignalsListBinding, type StepOutputBinding, type StepSignalBinding, type WorkItemBinding } from "./define-pipeline";
|
|
4
|
-
import { type InputAccessor } from "./input-accessor";
|
|
1
|
+
import type { TypedStepDefinitionSpec } from "../steps/define-step";
|
|
2
|
+
import { type AnyBinding, type LiteralBinding, type WorkItemBinding } from "./define-pipeline";
|
|
5
3
|
import { type WorkItemTopLevelField } from "./work-item-fields";
|
|
6
4
|
export type AnyTypedStep = TypedStepDefinitionSpec<any, any, any, any>;
|
|
7
|
-
type ElementOf<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer U> ? U : never;
|
|
8
|
-
export type LastStep<T extends ReadonlyArray<AnyTypedStep>> = T extends readonly [...AnyTypedStep[], infer L] ? L extends AnyTypedStep ? L : never : never;
|
|
9
|
-
export type LastSignalKeys<T extends ReadonlyArray<AnyTypedStep>> = LastStep<T> extends AnyTypedStep ? LastStep<T>["__signalKeys"] : never;
|
|
10
|
-
/**
|
|
11
|
-
* The per-branch `item` type a fan-out's `over` key resolves to (issue
|
|
12
|
-
* #167): `never` unless `K` names a signal on the most recent ordinary step
|
|
13
|
-
* (`LastStep<TSteps>`) whose resolved TS type is itself an array — in which
|
|
14
|
-
* case this is that array's element type. A number-typed signal (count-only
|
|
15
|
-
* mode) resolves to `never`, which is how `FanOutInputCtx` below decides
|
|
16
|
-
* whether `item` exists on the ctx type at all.
|
|
17
|
-
*/
|
|
18
|
-
export type FanOutItemType<TSteps extends ReadonlyArray<AnyTypedStep>, K extends string> = K extends keyof LastStep<TSteps>["__signalTypeMap"] ? LastStep<TSteps>["__signalTypeMap"][K] extends ReadonlyArray<infer Item> ? Item : never : never;
|
|
19
|
-
/**
|
|
20
|
-
* A fan-out's own `input` mapper ctx: everything `StepInputCtx` already
|
|
21
|
-
* offers, plus `item` when `FanOutItemType` resolves to something other
|
|
22
|
-
* than `never`. `item`'s exposed type is intersected with `FanOutItemBinding`
|
|
23
|
-
* (the same "phantom binding" trick `WithWorkItemFields`/`InputAccessor`
|
|
24
|
-
* use elsewhere in this file) so it reads as the real per-item TS type
|
|
25
|
-
* (e.g. `string`) to callers while still structurally satisfying `AnyBinding`
|
|
26
|
-
* when assigned straight into a `FanOutInputMapping` field — at runtime it
|
|
27
|
-
* is always the single `{ source: "fan_out_item" }` binding object,
|
|
28
|
-
* regardless of `Item`'s shape.
|
|
29
|
-
*/
|
|
30
|
-
export type FanOutInputCtx<TInput extends ZodType, TSteps extends ReadonlyArray<AnyTypedStep>, TFanOuts extends ReadonlyArray<AnyTypedStep>, K extends string> = StepInputCtx<TInput, TSteps, TFanOuts> & (FanOutItemType<TSteps, K> extends never ? unknown : {
|
|
31
|
-
item: FanOutItemBinding & FanOutItemType<TSteps, K>;
|
|
32
|
-
});
|
|
33
5
|
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
6
|
+
export type RequiredInputKeys<T extends object> = {
|
|
7
|
+
[K in keyof T & string]-?: undefined extends T[K] ? never : K;
|
|
8
|
+
}[keyof T & string];
|
|
9
|
+
export type OptionalInputKeys<T extends object> = {
|
|
10
|
+
[K in keyof T & string]-?: undefined extends T[K] ? K : never;
|
|
11
|
+
}[keyof T & string];
|
|
34
12
|
/**
|
|
35
|
-
* Work-item accessor for `
|
|
36
|
-
*
|
|
37
|
-
* `workItem.
|
|
13
|
+
* Work-item accessor for a `step`/`fanOut`/`loop`/parallel-branch state's
|
|
14
|
+
* `input` mapper (`ctx.workItem`, `NodeInputCtx` in `node-input-ctx.ts`): a
|
|
15
|
+
* top-level property (`workItem.title`, `workItem.platform`, `workItem.url`,
|
|
16
|
+
* ...) for every member of `WORK_ITEM_TOP_LEVEL_FIELDS`, plus
|
|
38
17
|
* `workItem.field(name)` for the platform-specific `fields` bag.
|
|
39
18
|
*
|
|
40
19
|
* Mirrors the default-pipeline-assignment DSL's `WorkItemAssignmentAccessor`
|
|
@@ -57,78 +36,12 @@ export type WorkItemAccessor = {
|
|
|
57
36
|
} & {
|
|
58
37
|
field<TName extends string = string>(fieldName: TName): WorkItemBinding;
|
|
59
38
|
};
|
|
60
|
-
export type PinnedWorkItemComment = {
|
|
61
|
-
createdAt: string;
|
|
62
|
-
body: string;
|
|
63
|
-
};
|
|
64
|
-
export type WithWorkItemFields<T> = {
|
|
65
|
-
workItemTitle: string;
|
|
66
|
-
workItemDescription: string | null;
|
|
67
|
-
workItemComments: PinnedWorkItemComment[];
|
|
68
|
-
} & T;
|
|
69
|
-
export type RequiredInputKeys<T extends object> = {
|
|
70
|
-
[K in keyof T & string]-?: undefined extends T[K] ? never : K;
|
|
71
|
-
}[keyof T & string];
|
|
72
|
-
export type OptionalInputKeys<T extends object> = {
|
|
73
|
-
[K in keyof T & string]-?: undefined extends T[K] ? K : never;
|
|
74
|
-
}[keyof T & string];
|
|
75
|
-
type Prettify<T> = {
|
|
76
|
-
[K in keyof T]: T[K];
|
|
77
|
-
} & {};
|
|
78
|
-
export type StepInputCtx<TInput extends ZodType, TSteps extends ReadonlyArray<AnyTypedStep>, TFanOuts extends ReadonlyArray<AnyTypedStep> = []> = {
|
|
79
|
-
input: InputAccessor<Prettify<WithWorkItemFields<TInput["_output"]>>>;
|
|
80
|
-
signal: <S extends ElementOf<TSteps>>(step: S, key: S["__signalKeys"]) => StepSignalBinding;
|
|
81
|
-
output: (step: ElementOf<TSteps>) => StepOutputBinding;
|
|
82
|
-
literal: (value: unknown) => LiteralBinding;
|
|
83
|
-
/**
|
|
84
|
-
* Reaches a fan-out's whole cohort — every terminal branch's own signals
|
|
85
|
-
* + output, resolved server-side — from a later, non-adjacent step's
|
|
86
|
-
* input mapper (issue #167). `fanOutStep` is constrained to a fan-out
|
|
87
|
-
* step already seen earlier in this pipeline (`.fanOutStep(fanOutStep, ...)`),
|
|
88
|
-
* the same way `signal`/`output` are constrained to `TSteps`.
|
|
89
|
-
*/
|
|
90
|
-
signalsList: (fanOutStep: ElementOf<TFanOuts>) => SignalsListBinding;
|
|
91
|
-
};
|
|
92
|
-
type ReservedPipelineInputKeys = "workItemTitle" | "workItemDescription" | "workItemComments";
|
|
93
|
-
export type NoReservedKeys<T extends ZodType> = T extends {
|
|
94
|
-
shape: infer Shape;
|
|
95
|
-
} ? [keyof Shape & ReservedPipelineInputKeys] extends [never] ? T : never : T;
|
|
96
|
-
export type PipelineMeta<TInput extends ZodType = z.ZodUnknown> = {
|
|
97
|
-
key: string;
|
|
98
|
-
name: string;
|
|
99
|
-
description?: string;
|
|
100
|
-
version?: number;
|
|
101
|
-
status?: "draft" | "active";
|
|
102
|
-
additionalPipelineInput?: {
|
|
103
|
-
schema: NoReservedKeys<TInput>;
|
|
104
|
-
bindings: (ctx: {
|
|
105
|
-
workItem: WorkItemAccessor;
|
|
106
|
-
literal: (value: unknown) => LiteralBinding;
|
|
107
|
-
}) => TInput["_output"] extends object ? {
|
|
108
|
-
[K in RequiredInputKeys<TInput["_output"]>]: AnyBinding;
|
|
109
|
-
} & {
|
|
110
|
-
[K in OptionalInputKeys<TInput["_output"]>]?: AnyBinding;
|
|
111
|
-
} : Partial<Record<string, AnyBinding>>;
|
|
112
|
-
};
|
|
113
|
-
additionalStepInput?: {
|
|
114
|
-
schema: ZodType;
|
|
115
|
-
bindings: (ctx: {
|
|
116
|
-
/**
|
|
117
|
-
* References a platform-specific field (Jira custom field, GitHub
|
|
118
|
-
* label, etc.) in the work item's `fields` bag. `TName` optionally
|
|
119
|
-
* accepts a literal union of known field names (e.g. the generated
|
|
120
|
-
* `WorkItemFieldName`) for compile-time validation and autocomplete,
|
|
121
|
-
* exactly like `WorkItemAccessor.field` above.
|
|
122
|
-
*/
|
|
123
|
-
workItemField: <TName extends string = string>(fieldName: TName) => WorkItemBinding;
|
|
124
|
-
literal: (value: unknown) => LiteralBinding;
|
|
125
|
-
}) => Partial<Record<string, AdditionalStepInputBinding>>;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
39
|
export declare const WORK_ITEM_ACCESSOR: WorkItemAccessor;
|
|
129
|
-
export declare function makeStepInputCtx<TInput extends ZodType>(inputSchema: TInput): StepInputCtx<TInput, ReadonlyArray<AnyTypedStep>, ReadonlyArray<AnyTypedStep>>;
|
|
130
40
|
export declare function literal(value: unknown): LiteralBinding;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Strips `undefined` values out of a node's `input` mapper return value —
|
|
43
|
+
* an author may return `{ foo: someCondition ? binding : undefined }` to
|
|
44
|
+
* conditionally omit a field, which should not become a real
|
|
45
|
+
* `{foo: undefined}` wire entry.
|
|
46
|
+
*/
|
|
47
|
+
export declare function normalizeInputMapping(mapping: Record<string, AnyBinding | undefined> | undefined): Record<string, AnyBinding>;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { DependencyEdgeSpec, NodeDefinitionSpec } from "./define-pipeline";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Computes, for every node key, the longest-path-from-root depth ("topo
|
|
4
|
+
* rank") over the given edges, using Kahn's algorithm — identical in
|
|
5
|
+
* approach to `packages/core`'s own `computeTopoRanks`. Returns `null`
|
|
6
|
+
* (does not throw) if the graph contains a cycle, or if `dependencyEdges`
|
|
7
|
+
* references a node key outside `nodeDefinitions` (a malformed/hand-edited
|
|
8
|
+
* spec) — every caller here is a diagnostic tool, not a build-time
|
|
9
|
+
* assertion, so it degrades gracefully rather than crashing the whole
|
|
10
|
+
* validation pass.
|
|
7
11
|
*/
|
|
8
|
-
export declare function
|
|
12
|
+
export declare function tryComputeTopoRanks(nodeDefinitions: readonly Pick<NodeDefinitionSpec, "nodeKey">[], dependencyEdges: readonly DependencyEdgeSpec[]): Map<string, number> | null;
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* `tryComputeTopoRanks`, ordering `nodeDefinitions` by ascending rank (ties
|
|
15
|
+
* broken by declaration order) instead of returning the raw rank map —
|
|
16
|
+
* the shape `validate-definition-specs.ts`'s "runs before its consumer"
|
|
17
|
+
* check wants directly. Returns `null` under the same conditions
|
|
18
|
+
* `tryComputeTopoRanks` does.
|
|
13
19
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
/**
|
|
16
|
-
* `tryOrderChainNodeDefinitions`, but throws a descriptive error instead of
|
|
17
|
-
* returning `null` when the graph isn't a single valid chain.
|
|
18
|
-
*/
|
|
19
|
-
export declare function orderChainNodeDefinitions(nodeDefinitions: readonly NodeDefinitionSpec[], dependencyEdges: readonly DependencyEdgeSpec[]): NodeDefinitionSpec[];
|
|
20
|
+
export declare function tryOrderNodeDefinitionsByTopoRank(nodeDefinitions: readonly NodeDefinitionSpec[], dependencyEdges: readonly DependencyEdgeSpec[]): NodeDefinitionSpec[] | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnyTypedStep } from "./builder-helpers";
|
|
2
|
+
import type { DependencyEdgeSpec, NodeDefinitionSpec } from "./define-pipeline";
|
|
3
|
+
import type { ChoiceState, FanOutState, LoopState, ParallelState, StepState } from "./pipeline-states";
|
|
4
|
+
export type CompileContext = {
|
|
5
|
+
pipelineKey: string;
|
|
6
|
+
stateKeys: ReadonlySet<string>;
|
|
7
|
+
registerStep: (step: AnyTypedStep) => void;
|
|
8
|
+
};
|
|
9
|
+
export type CompiledState = {
|
|
10
|
+
nodeDefinitions: NodeDefinitionSpec[];
|
|
11
|
+
edges: DependencyEdgeSpec[];
|
|
12
|
+
};
|
|
13
|
+
export declare function assertTargetExists(ctx: CompileContext, fromKey: string, toKey: string): void;
|
|
14
|
+
export declare function compileStepState(stateKey: string, state: StepState, ctx: CompileContext): CompiledState;
|
|
15
|
+
export declare function compileChoiceState(stateKey: string, state: ChoiceState, ctx: CompileContext): CompiledState;
|
|
16
|
+
export declare function compileFanOutState(stateKey: string, state: FanOutState, ctx: CompileContext): CompiledState;
|
|
17
|
+
export declare function compileParallelState(stateKey: string, state: ParallelState, ctx: CompileContext): CompiledState;
|
|
18
|
+
export declare function compileLoopState(stateKey: string, state: LoopState, ctx: CompileContext): CompiledState;
|
|
19
|
+
export declare function compileTerminalState(stateKey: string, kind: "succeed" | "fail"): CompiledState;
|
|
20
|
+
/**
|
|
21
|
+
* The SDK-side mirror of §6's domain invariant: a node may have more than
|
|
22
|
+
* one incoming edge only when every source is a `choice`/`loop` state
|
|
23
|
+
* (never an unconditional `step`/`fanOut`/`parallel`/`cohortGate`
|
|
24
|
+
* successor) — gives authors a fast local error instead of a round-trip to
|
|
25
|
+
* the server.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertNoIllegalConvergentEdges(pipelineKey: string, nodeKindByKey: ReadonlyMap<string, NodeDefinitionSpec["kind"]>, edges: readonly DependencyEdgeSpec[]): void;
|