tubeless 0.2.12 → 0.2.13
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/core/child-execution.d.ts +0 -23
- package/dist/core/child-execution.js +10 -12
- package/dist/core/child-execution.js.map +1 -1
- package/dist/core/child-progress.js +7 -2
- package/dist/core/child-progress.js.map +1 -1
- package/dist/core/iteration.d.ts +27 -0
- package/dist/core/iteration.js +111 -0
- package/dist/core/iteration.js.map +1 -0
- package/dist/core/lifecycle.d.ts +7 -5
- package/dist/core/lifecycle.js +36 -4
- package/dist/core/lifecycle.js.map +1 -1
- package/dist/core/pipeline-artifacts.d.ts +11 -0
- package/dist/core/pipeline-artifacts.js +2 -0
- package/dist/core/pipeline-artifacts.js.map +1 -0
- package/dist/core/pipeline-compiler.d.ts +1 -0
- package/dist/core/pipeline-compiler.js +1 -0
- package/dist/core/pipeline-compiler.js.map +1 -1
- package/dist/core/pipeline-definition-identity.d.ts +2 -2
- package/dist/core/pipeline-definition-identity.js +28 -5
- package/dist/core/pipeline-definition-identity.js.map +1 -1
- package/dist/core/pipeline-execute.d.ts +1 -6
- package/dist/core/pipeline-execute.js +28 -215
- package/dist/core/pipeline-execute.js.map +1 -1
- package/dist/core/pipeline-execution-error.d.ts +35 -0
- package/dist/core/pipeline-execution-error.js +195 -0
- package/dist/core/pipeline-execution-error.js.map +1 -0
- package/dist/core/pipeline-identity.d.ts +1 -0
- package/dist/core/pipeline-identity.js +1 -0
- package/dist/core/pipeline-identity.js.map +1 -1
- package/dist/core/pipeline-mermaid.js +4 -1
- package/dist/core/pipeline-mermaid.js.map +1 -1
- package/dist/core/pipeline-run-state.d.ts +4 -4
- package/dist/core/pipeline-run-state.js +10 -16
- package/dist/core/pipeline-run-state.js.map +1 -1
- package/dist/core/pipeline-step-executor.d.ts +2 -0
- package/dist/core/pipeline-step-executor.js +11 -3
- package/dist/core/pipeline-step-executor.js.map +1 -1
- package/dist/core/pipeline-steps.d.ts +20 -0
- package/dist/core/pipeline-steps.js +62 -0
- package/dist/core/pipeline-steps.js.map +1 -1
- package/dist/core/pipeline-types.d.ts +15 -2
- package/dist/core/pipeline-types.js.map +1 -1
- package/dist/core/pipeline.d.ts +4 -1
- package/dist/core/pipeline.js +18 -3
- package/dist/core/pipeline.js.map +1 -1
- package/dist/project/project-compiler.d.ts +3 -31
- package/dist/project/project-compiler.js +11 -180
- package/dist/project/project-compiler.js.map +1 -1
- package/dist/project/project-registry.d.ts +44 -0
- package/dist/project/project-registry.js +107 -0
- package/dist/project/project-registry.js.map +1 -0
- package/dist/project/project-step-graph.d.ts +9 -0
- package/dist/project/project-step-graph.js +99 -0
- package/dist/project/project-step-graph.js.map +1 -0
- package/dist/render/render.js +1 -1
- package/dist/render/render.js.map +1 -1
- package/dist/reporter/interactive-reporter.js +6 -3
- package/dist/reporter/interactive-reporter.js.map +1 -1
- package/dist/reporter/live-ticker-frame.d.ts +21 -0
- package/dist/reporter/live-ticker-frame.js +196 -0
- package/dist/reporter/live-ticker-frame.js.map +1 -0
- package/dist/reporter/live-ticker-protocol.d.ts +41 -0
- package/dist/reporter/live-ticker-protocol.js +59 -0
- package/dist/reporter/live-ticker-protocol.js.map +1 -0
- package/dist/reporter/live-ticker-worker.js +11 -25
- package/dist/reporter/live-ticker-worker.js.map +1 -1
- package/dist/reporter/live-ticker.d.ts +0 -15
- package/dist/reporter/live-ticker.js +11 -216
- package/dist/reporter/live-ticker.js.map +1 -1
- package/dist/reporter/reporter.js +7 -6
- package/dist/reporter/reporter.js.map +1 -1
- package/dist/run-store/definition-projection.d.ts +8 -0
- package/dist/run-store/definition-projection.js +89 -0
- package/dist/run-store/definition-projection.js.map +1 -0
- package/dist/run-store/run-projection.d.ts +15 -0
- package/dist/run-store/run-projection.js +203 -0
- package/dist/run-store/run-projection.js.map +1 -0
- package/dist/run-store/run-store-codec.d.ts +2 -0
- package/dist/run-store/run-store-codec.js +11 -0
- package/dist/run-store/run-store-codec.js.map +1 -1
- package/dist/run-store/run-store-event-decoder.js +3 -0
- package/dist/run-store/run-store-event-decoder.js.map +1 -1
- package/dist/run-store/run-store-reader.d.ts +7 -0
- package/dist/run-store/run-store-reader.js +31 -0
- package/dist/run-store/run-store-reader.js.map +1 -0
- package/dist/run-store/run-store-sqlite.js +23 -7
- package/dist/run-store/run-store-sqlite.js.map +1 -1
- package/dist/run-store/run-store.d.ts +16 -4
- package/dist/run-store/run-store.js +14 -263
- package/dist/run-store/run-store.js.map +1 -1
- package/dist/studio/run-store-ui-api.d.ts +13 -0
- package/dist/studio/run-store-ui-api.js +163 -0
- package/dist/studio/run-store-ui-api.js.map +1 -0
- package/dist/studio/run-store-ui-client-browser.js +2 -2
- package/dist/studio/run-store-ui-client-transport.js +28 -3
- package/dist/studio/run-store-ui-client-transport.js.map +1 -1
- package/dist/studio/run-store-ui-client.d.ts +2 -1
- package/dist/studio/run-store-ui-client.js +15 -9
- package/dist/studio/run-store-ui-client.js.map +1 -1
- package/dist/studio/run-store-ui-http.d.ts +11 -0
- package/dist/studio/run-store-ui-http.js +52 -0
- package/dist/studio/run-store-ui-http.js.map +1 -1
- package/dist/studio/run-store-ui-state.d.ts +1 -1
- package/dist/studio/run-store-ui-state.js +10 -28
- package/dist/studio/run-store-ui-state.js.map +1 -1
- package/dist/studio/run-store-ui.d.ts +5 -11
- package/dist/studio/run-store-ui.js +5 -203
- package/dist/studio/run-store-ui.js.map +1 -1
- package/dist/testing/testing.d.ts +18 -2
- package/dist/testing/testing.js +35 -2
- package/dist/testing/testing.js.map +1 -1
- package/dist/tracing/artifact-metadata.d.ts +28 -0
- package/dist/tracing/artifact-metadata.js +105 -0
- package/dist/tracing/artifact-metadata.js.map +1 -0
- package/dist/tracing/tracing-codec.d.ts +1 -1
- package/dist/tracing/tracing-codec.js +1 -1
- package/dist/tracing/tracing-codec.js.map +1 -1
- package/dist/tracing/tracing-constants.d.ts +1 -1
- package/dist/tracing/tracing-constants.js +1 -1
- package/dist/tracing/tracing-constants.js.map +1 -1
- package/dist/tracing/tracing-contracts.d.ts +3 -1
- package/dist/tracing/tracing-contracts.js.map +1 -1
- package/dist/tracing/tracing-internal.d.ts +2 -0
- package/dist/tracing/tracing-internal.js +36 -13
- package/dist/tracing/tracing-internal.js.map +1 -1
- package/dist/tracing/tracing-schema.d.ts +330 -49
- package/dist/tracing/tracing-schema.js +102 -10
- package/dist/tracing/tracing-schema.js.map +1 -1
- package/dist/workbench/workbench-command-execution.d.ts +6 -0
- package/dist/workbench/workbench-command-execution.js +48 -0
- package/dist/workbench/workbench-command-execution.js.map +1 -0
- package/dist/workbench/workbench-history.js +11 -18
- package/dist/workbench/workbench-history.js.map +1 -1
- package/dist/workbench/workbench-launch-session.d.ts +2 -2
- package/dist/workbench/workbench-launch-session.js.map +1 -1
- package/dist/workbench/workbench-run.d.ts +0 -4
- package/dist/workbench/workbench-run.js +3 -47
- package/dist/workbench/workbench-run.js.map +1 -1
- package/dist/workbench/workbench-studio-launcher.d.ts +27 -0
- package/dist/workbench/workbench-studio-launcher.js +95 -0
- package/dist/workbench/workbench-studio-launcher.js.map +1 -0
- package/dist/workbench/workbench-ui.js +10 -83
- package/dist/workbench/workbench-ui.js.map +1 -1
- package/docs/README.md +13 -7
- package/docs/agent-guide.md +69 -6
- package/docs/airflow.md +187 -0
- package/docs/api-reference.md +87 -76
- package/docs/api-report.json +17 -6
- package/docs/artifacts.md +173 -0
- package/docs/child-pipeline-composition.md +65 -2
- package/docs/comparison.md +20 -0
- package/docs/concepts.md +70 -2
- package/docs/dagster.md +161 -0
- package/docs/inngest.md +163 -0
- package/docs/llms.txt +30 -1
- package/docs/recipes.md +82 -33
- package/docs/remote-step-composition.md +6 -0
- package/docs/step-functions.md +190 -0
- package/docs/studio.md +31 -12
- package/docs/temporal.md +183 -0
- package/examples/airflow/contract.ts +46 -0
- package/examples/airflow/hosted.ts +70 -0
- package/examples/airflow/remote.ts +175 -0
- package/examples/airflow/tubeless_example.py +49 -0
- package/examples/airflow/worker.ts +24 -0
- package/examples/artifact-lineage.ts +70 -0
- package/examples/dagster/definitions.py +59 -0
- package/examples/dagster/hosted.ts +78 -0
- package/examples/dagster/pipeline.ts +62 -0
- package/examples/dagster/test_definitions.py +47 -0
- package/examples/dagster/tsconfig.build.json +10 -0
- package/examples/dagster/worker.ts +22 -0
- package/examples/inngest/client.ts +4 -0
- package/examples/inngest/functions.ts +65 -0
- package/examples/inngest/pipeline.ts +41 -0
- package/examples/inngest/send.ts +11 -0
- package/examples/inngest/server.ts +17 -0
- package/examples/inngest/tsconfig.build.json +10 -0
- package/examples/iteration.ts +52 -0
- package/examples/parameterized-steps.ts +96 -0
- package/examples/project/tubeless.project.ts +46 -0
- package/examples/step-functions/handler.ts +110 -0
- package/examples/step-functions/input.json +1 -0
- package/examples/step-functions/pipeline.ts +41 -0
- package/examples/step-functions/state-machine.asl.json +41 -0
- package/examples/step-functions/template.json +42 -0
- package/examples/step-output-overrides.ts +41 -0
- package/examples/temporal/activities.ts +94 -0
- package/examples/temporal/client.ts +19 -0
- package/examples/temporal/pipeline.ts +41 -0
- package/examples/temporal/tsconfig.build.json +10 -0
- package/examples/temporal/worker.ts +21 -0
- package/examples/temporal/workflows.ts +16 -0
- package/package.json +13 -4
- package/skills/tubeless/SKILL.md +30 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-types.js","sourceRoot":"","sources":["../../src/core/pipeline-types.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AA4JlG,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAK9E,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AA2UD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC","sourcesContent":["import type {\n PipelineDefinitionIdentityContract,\n PipelineDefinitionSnapshotContract,\n} from \"../tracing/tracing-schema.js\";\n\n/** Versioned graph identity, separate from the optional handler implementation version. */\nexport type PipelineDefinitionIdentity = Readonly<PipelineDefinitionIdentityContract>;\n/** Serializable compiled semantics; no handlers, inputs, or application imports. */\ntype ReadonlyDefinition<T> = T extends object\n ? { readonly [K in keyof T]: ReadonlyDefinition<T[K]> }\n : T;\n/** Immutable snapshot of the compiled pipeline definition recorded for inspection and tracing. */\nexport type PipelineDefinitionSnapshot = ReadonlyDefinition<PipelineDefinitionSnapshotContract>;\n\nimport type { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { PIPELINE_ERROR_CODES as PIPELINE_ERROR_CODE_VALUES } from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineErrorKindContract,\n PipelineErrorPhaseContract,\n} from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n PipelineTracingOptions,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Minimal logger used by pipeline execution, reporters, and CLI adapters. */\nexport interface PipelineLogger {\n error(message?: unknown, ...optionalParams: unknown[]): void;\n log(message?: unknown, ...optionalParams: unknown[]): void;\n warn(message?: unknown, ...optionalParams: unknown[]): void;\n}\n\n/** Caller-supplied services and metadata shared by one pipeline execution. */\nexport interface PipelineContext {\n /** Optional caller-owned identifier used to correlate separate executions. */\n correlationId?: string;\n cwd: string;\n /** Hook sets run in order and failures are isolated per set. */\n hooks?: PipelineHooks | readonly PipelineHooks[];\n log: PipelineLogger;\n /** Timestamp source for persisted run records. Defaults to `Date.now`. */\n now?: () => number;\n /** Optional package-generated execution identity of this run's parent. */\n parentRunId?: string;\n signal?: AbortSignal;\n sleep?: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n /** Optional structured lifecycle tracing configuration for this run. */\n tracing?: PipelineTracingOptions;\n}\n\n/** Built-in run controls. Choose targets or stepIds, or omit both to run every step. */\nexport type PipelineRunControls<\n TStepId extends string = string,\n TTargetId extends string = string,\n> = {\n /** Maximum simultaneous steps, including skip predicates and output validation. Defaults to 1. */\n maxConcurrency?: number;\n /** Continue eligible branches after failure; otherwise stop dispatch and drain active steps. */\n continueOnError?: boolean;\n dryRun?: boolean;\n} & (\n | {\n /**\n * Run only these steps, without adding prerequisites. Omit both stepIds and\n * targets to run every step. An empty array is invalid and fails planning.\n */\n stepIds?: readonly TStepId[];\n targets?: undefined;\n }\n | {\n stepIds?: undefined;\n /**\n * Run these declared targets and their required inputs and failure gates,\n * recursively; optional-only inputs are not included. Omit both targets\n * and stepIds to run every step; no target is selected automatically.\n */\n targets?: readonly TTargetId[];\n }\n);\n\n/** Resolved caller context. Core fills `now` and `sleep` before execution. */\nexport interface PipelineRuntime extends PipelineContext {\n now: () => number;\n sleep: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n}\n\n/** Resolved execution context provided to pipeline handlers. */\nexport interface PipelineExecutionContext<TOptions extends object> extends PipelineRuntime {\n dryRun: boolean;\n options: TOptions;\n /** Stable identity for this execution, whether or not tracing is configured. */\n runId: string;\n /** Stable identities for this traced run; absent unless `context.tracing` is configured. */\n trace?: PipelineTraceContext;\n}\n\n/**\n * Lifecycle status displayed for an optional nested progress row.\n *\n * Detail rows are indented under a parent step's progress.\n * Domain-agnostic: mapped children, nested work units, per-file status, etc.\n */\nexport type PipelineStepProgressDetailStatus =\n | \"cancelled\"\n | \"completed\"\n | \"failed\"\n | \"pending\"\n | \"running\"\n | \"skipped\";\n\n/** One optional nested row in a step progress snapshot. */\nexport interface PipelineStepProgressDetail {\n /** Stable identity for the row (item key, path, job id, …). */\n id: string;\n /** Optional display name; identity remains `id`. */\n name?: string;\n /** Indentation relative to direct child rows (0). Rows are in tree preorder. */\n depth?: number;\n /** Inner work counts, independent of the parent's lifecycle count. */\n completed?: number;\n total?: number;\n /** Short status text shown after the id. */\n label?: string;\n /** Controls the detail row symbol. Defaults to `running`. */\n status?: PipelineStepProgressDetailStatus;\n}\n\n/** Latest progress snapshot reported by a running step. */\nexport interface PipelineStepProgress {\n /** Work completed so far. Values outside the reported total are allowed but renderers may clamp them. */\n completed: number;\n /** Total work when known. Omit for indeterminate progress. */\n total?: number;\n /** Optional short status shown next to the step. Prefer one-line summaries. */\n message?: string;\n /**\n * Optional multi-line detail rows for capable reporters (interactive TTY).\n * Keep the parent `message` as a summary; put per-item status here so high\n * concurrency does not collapse onto one truncated line.\n */\n details?: readonly PipelineStepProgressDetail[];\n}\n\n/** Step execution context with attempt identity and progress reporting helpers. */\nexport interface PipelineStepContext<\n TOptions extends object,\n> extends PipelineExecutionContext<TOptions> {\n /** Stable identity for this execution of the current step. */\n attemptId: string;\n /** Emit a retry/attempt trace event for this step when tracing is enabled. */\n reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n /** Publish the latest progress snapshot for this step. */\n reportProgress(progress: PipelineStepProgress): void;\n}\n\n/** Adapter that invokes one step on an external execution engine. */\nexport interface RemoteStepAdapter<TOptions extends object, TPayload, TResult> {\n /** Presentation only. The kernel never switches on this. */\n readonly engine: string;\n /** Function name, workflow type, URL, queue. Presentation only. */\n readonly target?: string;\n invoke(payload: TPayload, context: PipelineStepContext<TOptions>): Promise<TResult>;\n}\n\n/** Pipeline lifecycle phase in which an error occurred. */\nexport type PipelineErrorPhase = PipelineErrorPhaseContract;\n\n/** Broad category of a structured pipeline error. */\nexport type PipelineErrorKind = PipelineErrorKindContract;\n\n/** Ordered catalog of every stable package-owned pipeline error code. */\nexport const PIPELINE_ERROR_CODES = Object.freeze(PIPELINE_ERROR_CODE_VALUES);\n\n/** Stable package-owned code for a pipeline error. */\nexport type PipelineErrorCode = (typeof PIPELINE_ERROR_CODES)[number];\n\nconst pipelineErrorCodeSet: ReadonlySet<string> = new Set(PIPELINE_ERROR_CODES);\n\n/** Return whether an unknown value is a stable package-owned pipeline error code. */\nexport function isPipelineErrorCode(value: unknown): value is PipelineErrorCode {\n return typeof value === \"string\" && pipelineErrorCodeSet.has(value);\n}\n\n/** One dependency-free Standard Schema issue normalized for reports and traces. */\nexport interface PipelineValidationIssue {\n message: string;\n path?: readonly (number | string)[];\n}\n\n/** Bounded diagnostics for a failed or cancelled runtime fan-out. */\nexport interface PipelineFanOutFailure {\n /** Original input position, including when the key is truncated. */\n index: number;\n /** At most 1024 UTF-16 code units; do not rerun by key when keyTruncated is true. */\n key: string;\n keyTruncated: boolean;\n cancelled: boolean;\n error: PipelineErrorCause;\n}\n\n/** Bounded diagnostics collected from a failed or cancelled fan-out step. */\nexport interface PipelineFanOutDiagnostics {\n /** Failed started items, in input order; at most 32 entries. */\n failures: readonly PipelineFanOutFailure[];\n /** Total failed started items, including omitted diagnostics. */\n failureCount: number;\n omittedFailureCount: number;\n /** Scheduler failure is separate and never assigned an item key. */\n schedulerError?: PipelineErrorCause;\n}\n\n/** Structured, machine-readable error stored in plans, runs, and traces. */\nexport interface PipelineError {\n /** Present for aggregated fan-out failures; absent for setup errors. */\n fanOut?: PipelineFanOutDiagnostics;\n /** Bounded, JSON-safe snapshot of the thrown error's cause chain. */\n cause?: PipelineErrorCause;\n code: PipelineErrorCode;\n kind: PipelineErrorKind;\n message: string;\n phase: PipelineErrorPhase;\n /** Present when a Standard Schema rejected a boundary value. */\n issues?: readonly PipelineValidationIssue[];\n stepId?: string;\n /** Machine-readable code copied from the original thrown error, when present. */\n sourceCode?: string;\n stack?: string;\n}\n\n/** Dependency-free subset of the Standard Schema V1 protocol. */\nexport interface StandardSchemaV1<TInput = unknown, TOutput = TInput> {\n readonly \"~standard\": StandardSchemaV1Props<TInput, TOutput>;\n}\n\n/** Standard Schema V1 metadata and validation contract consumed by Tubeless. */\ninterface StandardSchemaV1Props<TInput = unknown, TOutput = TInput> {\n /** Optional Standard JSON Schema input converter, used to infer CLI flags. */\n readonly jsonSchema?: {\n readonly input: (options: { readonly target: \"draft-2020-12\" }) => Record<string, unknown>;\n };\n readonly types?: { readonly input: TInput; readonly output: TOutput };\n readonly validate: (\n value: unknown,\n options?: { readonly libraryOptions?: Record<string, unknown> }\n ) => StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>;\n readonly vendor: string;\n readonly version: 1;\n}\n\n/** Successful value or validation issues returned by a Standard Schema V1 validator. */\nexport type StandardSchemaV1Result<TOutput> =\n | { readonly issues?: undefined; readonly value: TOutput }\n | { readonly issues: readonly StandardSchemaV1Issue[] };\n\n/** Validation issue shape accepted from a Standard Schema V1 validator. */\nexport interface StandardSchemaV1Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | { readonly key: PropertyKey })[];\n}\n\n/** Infer the accepted input type from a Standard Schema without importing its package. */\nexport type InferSchemaInput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"input\"];\n\n/** Infer the validated output type from a Standard Schema without importing its package. */\nexport type InferSchemaOutput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"output\"];\n\n/** Bounded JSON-safe snapshot of a thrown value and its cause chain. */\nexport interface PipelineErrorCause {\n cause?: PipelineErrorCause;\n message: string;\n name?: string;\n /** Machine-readable code copied from this cause, when present. */\n sourceCode?: string;\n}\n\ninterface PipelineStepReportBase {\n /** Present when the step started an execution attempt. */\n attemptId?: string;\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n description?: string;\n /** Wall-clock time when this terminal report was recorded. */\n finishedAtMs: number;\n /** Wall-clock time when execution began; absent when the step never started. */\n startedAtMs?: number;\n}\n\n/** Terminal report for a successfully completed step. */\nexport interface PipelineStepCompleteReport extends PipelineStepReportBase {\n attemptId: string;\n startedAtMs: number;\n status: \"completed\";\n}\n\n/** Terminal report for a structurally or intentionally skipped step. */\nexport interface PipelineStepSkippedReport extends PipelineStepReportBase {\n /** Dependency that blocked this step, when applicable. */\n dependencyId?: string;\n /** Human-readable skip detail, especially for policy and fail-fast skips. */\n message?: string;\n reason: PipelineStepSkipReason;\n status: \"skipped\";\n}\n\n/** Terminal report for a cancelled step. */\nexport interface PipelineStepCancelledReport extends PipelineStepReportBase {\n error: PipelineError;\n status: \"cancelled\";\n}\n\n/** Terminal report for a failed step. */\nexport interface PipelineStepFailedReport extends PipelineStepReportBase {\n attemptId: string;\n error: PipelineError;\n startedAtMs: number;\n status: \"failed\";\n}\n\n/** Terminal state recorded for one step after a run. */\nexport type PipelineStepReport =\n | PipelineStepCancelledReport\n | PipelineStepFailedReport\n | PipelineStepSkippedReport\n | PipelineStepCompleteReport;\n\n/** Terminal status recorded in a step report. */\nexport type PipelineStepReportStatus = PipelineStepReport[\"status\"];\n\n/** Terminal disposition of a completed run record. */\nexport type PipelineRunStatus = \"cancelled\" | \"completed\" | \"failed\";\n\ninterface PipelineRunRecord {\n definitionIdentity?: PipelineDefinitionIdentity;\n /** Caller-owned identifier shared by related executions, when supplied. */\n correlationId?: string;\n pipelineId: string;\n dryRun: boolean;\n /** Run-level errors first, step errors in plan order, then finalization errors. */\n errors: PipelineError[];\n finishedAtMs: number;\n parentRunId?: string;\n runId: string;\n startedAtMs: number;\n status: PipelineRunStatus;\n /** Terminal step reports in stable plan order, independent of completion order. */\n steps: PipelineStepReport[];\n version: typeof RUN_MODEL_VERSION;\n}\n\n/** Versioned public record returned for one pipeline execution. */\nexport type PipelineRun<TResult = unknown> =\n | (PipelineRunRecord & {\n /** Finalization did not produce a result. Independent of terminal run status. */\n finalized: false;\n value?: undefined;\n })\n | (PipelineRunRecord & {\n /** Finalization produced a result. Independent of terminal run status. */\n finalized: true;\n value: TResult;\n });\n\n/**\n * Why a step did not run. Built-in structural reasons keep dependency semantics;\n * `\"policy\"` is an intentional skip from `step.skip()` (still unlocks dependents).\n */\nexport type PipelineStepSkipReason =\n | \"dry-run\"\n | \"failed-dependency\"\n | \"fail-fast\"\n | \"filtered\"\n | \"policy\"\n | \"unmet-dependency\";\n\n/**\n * Decision from an optional `skip` predicate.\n * - falsy / `false` → run the step\n * - non-empty string → skip with that message (`reason: \"policy\"`); the step's\n * published output is `undefined`\n * - `{ reason, value? }` → skip and optionally publish `value` for dependents\n * (`value` may be intentionally `undefined` if passed explicitly)\n *\n * Policy skips unlock required dependents. A bare-string skip (or a `{ reason }`\n * without `value`) makes dependents see `TOut | undefined`. When every skip\n * branch returns `{ reason, value }`, the step retains `TOut`; schema-backed\n * values use the schema input type and publish its transformed output type.\n */\nexport type StepSkipDecision<TOut = unknown> =\n | false\n | null\n | undefined\n | string\n | { reason: string; value?: TOut };\n\n/** One observable status in a step's planned → running → terminal lifecycle. */\nexport type PipelineStepStatus =\n | { pipelineId: string; status: \"planned\"; step: PipelinePlanStep }\n | {\n attemptId: string;\n pipelineId: string;\n progress?: PipelineStepProgress;\n status: \"running\";\n step: PipelinePlanStep;\n }\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCancelledReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepFailedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepSkippedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCompleteReport);\n\n/** Any planned, running, or terminal step lifecycle status. */\nexport type PipelineStepLifecycleStatus = PipelineStepStatus[\"status\"];\n\n/** Lifecycle event emitted when a step is planned. */\nexport type PipelineStepPlannedEvent = Extract<PipelineStepStatus, { status: \"planned\" }>;\ntype PipelineStepRunningStatus = Extract<PipelineStepStatus, { status: \"running\" }>;\n/** Lifecycle event emitted when a step begins running. */\nexport type PipelineStepStartEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress?: undefined;\n};\n/** Lifecycle event emitted when a running step reports progress. */\nexport type PipelineStepProgressEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress: PipelineStepProgress;\n};\n/** Lifecycle event emitted when a step is cancelled. */\nexport type PipelineStepCancelledEvent = Extract<PipelineStepStatus, { status: \"cancelled\" }>;\n/** Lifecycle event emitted when a step fails. */\nexport type PipelineStepFailedEvent = Extract<PipelineStepStatus, { status: \"failed\" }>;\n/** Lifecycle event emitted when a step is skipped. */\nexport type PipelineStepSkippedEvent = Extract<PipelineStepStatus, { status: \"skipped\" }>;\n/** Lifecycle event emitted when a step completes successfully. */\nexport type PipelineStepCompleteEvent = Extract<PipelineStepStatus, { status: \"completed\" }>;\n\n/**\n * Optional lifecycle callbacks, each receiving its own metadata snapshot.\n * Domain result values retain their identity; hooks must treat them as read-only.\n */\nexport interface PipelineHooks<TResult = unknown> {\n onFinalizeComplete?(event: { durationMs: number; pipelineId: string; value: TResult }): void;\n onFinalizeError?(event: { durationMs: number; error: PipelineError; pipelineId: string }): void;\n onFinalizeStart?(event: { pipelineId: string }): void;\n onPipelineComplete?(event: PipelineRun<TResult>): void;\n onPipelineStart?(event: PipelinePlan): void;\n onStepCancel?(event: PipelineStepCancelledEvent): void;\n onStepFail?(event: PipelineStepFailedEvent): void;\n onStepPlan?(event: PipelineStepPlannedEvent): void;\n onStepProgress?(event: PipelineStepProgressEvent): void;\n onStepSkip?(event: PipelineStepSkippedEvent): void;\n onStepStart?(event: PipelineStepStartEvent): void;\n onStepStatus?(event: PipelineStepStatus): void;\n onStepComplete?(event: PipelineStepCompleteEvent): void;\n}\n\n/** Machine-readable explanation of why a planned step was included or omitted. */\nexport type PipelineStepSelectionReason =\n | { kind: \"all\" }\n | { kind: \"exact\" }\n | { kind: \"target\"; targetId: string }\n | { dependentId: string; kind: \"required-dependency\"; targetId: string }\n | { dependentId: string; kind: \"failure-gate\"; targetId: string }\n | { dependentId: string; kind: \"optional-only\"; targetId: string }\n | { kind: \"outside-target-closure\" }\n | { kind: \"not-selected\" };\n\n/** Planned representation of one declared step and its selection state. */\nexport interface PipelinePlanStep {\n dependencies: string[];\n description?: string;\n /** How this step behaves when the pipeline is run with `dryRun: true`. */\n dryRun: \"custom\" | \"run\" | \"skip\";\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n /** Static child structure when this opaque step executes another pipeline. */\n nestedPipeline?: {\n /** One child execution or one child execution per runtime item. */\n mode: \"single\" | \"for-each\";\n identity?: PipelineDefinitionIdentity;\n concurrency?: number | \"dynamic\";\n pipelineId: string;\n /** All declared child step ids; runtime selection may execute only a subset. */\n stepIds: readonly string[];\n };\n /** Static remote adapter metadata when this opaque step calls an external engine. */\n remote?: {\n engine: string;\n target?: string;\n };\n optionalDependencies: string[];\n /** True when the step's runtime policy may elect not to run it. */\n runtimeSkipPossible: boolean;\n selected: boolean;\n /** Stable reasons for selection or omission; shared prerequisites can have several. */\n selectionReasons: readonly PipelineStepSelectionReason[];\n skipAfterFailureOf: string[];\n skipReason?: PipelineStepSkipReason;\n}\n\n/** Side-effect-free validation and selection result for a pipeline run. */\nexport interface PipelinePlan {\n definition?: PipelineDefinitionSnapshot;\n dryRun: boolean;\n errors: PipelineError[];\n ok: boolean;\n pipelineId: string;\n steps: PipelinePlanStep[];\n}\n\n/** Layout directions for generated Mermaid flowcharts. */\nexport const PIPELINE_MERMAID_DIRECTIONS = [\"BT\", \"LR\", \"RL\", \"TB\", \"TD\"] as const;\n/** Supported Mermaid flowchart direction. */\nexport type PipelineMermaidDirection = (typeof PIPELINE_MERMAID_DIRECTIONS)[number];\n\n/** Rendering options for a pipeline Mermaid flowchart. */\nexport interface PipelineMermaidOptions {\n /** Mermaid flowchart direction. Defaults to top-down (`TD`). */\n direction?: PipelineMermaidDirection;\n /** Append each operational description to its node label. Defaults to false. */\n includeDescriptions?: boolean;\n}\n\ntype PipelineRunArguments<\n TOptions,\n TStepId extends string,\n TTargetId extends string,\n> = {} extends TOptions\n ? [\n options?: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ]\n : [\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ];\n\n/** Compiled pipeline that can be planned, executed, and rendered as a graph. */\nexport interface Pipeline<\n TOptions extends object,\n TResult,\n TStepId extends string = string,\n TTargetId extends string = TStepId,\n TId extends string = string,\n> {\n readonly id: TId;\n /** Optional display name; stable identity remains `id`. */\n readonly name?: string;\n /** Human-readable purpose for command and discovery surfaces. */\n readonly description?: string;\n /** Compiled definition metadata. Absent only on externally implemented pipelines. */\n readonly definition?: PipelineDefinitionSnapshot;\n /** Runtime domain schema supplied to createSteps; CLI adapters can infer its input flags. */\n readonly optionsSchema?: StandardSchemaV1;\n /** Stable definition-order step ids for discovery surfaces such as CLI help. */\n readonly stepIds: readonly TStepId[];\n /** Stable declared goal ids that support dependency-aware target execution. */\n readonly targetIds: readonly TTargetId[];\n plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;\n /** Omitted options default to {} when the input type has no required fields. */\n run(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<PipelineRun<TResult>>;\n run(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<PipelineRun<TResult>>;\n runOrThrow(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<TResult>;\n runOrThrow(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<TResult>;\n /** Generate a static Mermaid flowchart without running or planning the pipeline. */\n toMermaid(options?: PipelineMermaidOptions): string;\n}\n\n/** Input accepted by a pipeline run before any options schema transformation. */\nexport type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Exclude<\n Parameters<TPipeline[\"run\"]>[0],\n undefined\n>;\n\n/** Successful result produced by a pipeline run. */\nexport type PipelineResult<TPipeline extends Pipeline<object, unknown>> = Awaited<\n ReturnType<TPipeline[\"runOrThrow\"]>\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline-types.js","sourceRoot":"","sources":["../../src/core/pipeline-types.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAgKlG,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAK9E,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAmVD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC","sourcesContent":["import type { ArtifactRecord } from \"../tracing/artifact-metadata.js\";\nimport type {\n PipelineDefinitionIdentityContract,\n PipelineDefinitionSnapshotContract,\n} from \"../tracing/tracing-schema.js\";\n\n/** Versioned graph identity, separate from the optional handler implementation version. */\nexport type PipelineDefinitionIdentity = Readonly<PipelineDefinitionIdentityContract>;\n/** Serializable compiled semantics; no handlers, inputs, or application imports. */\ntype ReadonlyDefinition<T> = T extends object\n ? { readonly [K in keyof T]: ReadonlyDefinition<T[K]> }\n : T;\n/** Immutable snapshot of the compiled pipeline definition recorded for inspection and tracing. */\nexport type PipelineDefinitionSnapshot = ReadonlyDefinition<PipelineDefinitionSnapshotContract>;\n\nimport type { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { PIPELINE_ERROR_CODES as PIPELINE_ERROR_CODE_VALUES } from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineErrorKindContract,\n PipelineErrorPhaseContract,\n} from \"../tracing/tracing-schema.js\";\nimport type {\n PipelineTraceAttributes,\n PipelineTraceContext,\n PipelineTracingOptions,\n} from \"../tracing/tracing-contracts.js\";\n\n/** Minimal logger used by pipeline execution, reporters, and CLI adapters. */\nexport interface PipelineLogger {\n error(message?: unknown, ...optionalParams: unknown[]): void;\n log(message?: unknown, ...optionalParams: unknown[]): void;\n warn(message?: unknown, ...optionalParams: unknown[]): void;\n}\n\n/** Caller-supplied services and metadata shared by one pipeline execution. */\nexport interface PipelineContext {\n /** Optional caller-owned identifier used to correlate separate executions. */\n correlationId?: string;\n cwd: string;\n /** Hook sets run in order and failures are isolated per set. */\n hooks?: PipelineHooks | readonly PipelineHooks[];\n log: PipelineLogger;\n /** Timestamp source for persisted run records. Defaults to `Date.now`. */\n now?: () => number;\n /** Optional package-generated execution identity of this run's parent. */\n parentRunId?: string;\n signal?: AbortSignal;\n sleep?: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n /** Optional structured lifecycle tracing configuration for this run. */\n tracing?: PipelineTracingOptions;\n}\n\n/** Built-in run controls. Choose targets or stepIds, or omit both to run every step. */\nexport type PipelineRunControls<\n TStepId extends string = string,\n TTargetId extends string = string,\n> = {\n /** Maximum simultaneous steps, including skip predicates and output validation. Defaults to 1. */\n maxConcurrency?: number;\n /** Continue eligible branches after failure; otherwise stop dispatch and drain active steps. */\n continueOnError?: boolean;\n dryRun?: boolean;\n} & (\n | {\n /**\n * Run only these steps, without adding prerequisites. Omit both stepIds and\n * targets to run every step. An empty array is invalid and fails planning.\n */\n stepIds?: readonly TStepId[];\n targets?: undefined;\n }\n | {\n stepIds?: undefined;\n /**\n * Run these declared targets and their required inputs and failure gates,\n * recursively; optional-only inputs are not included. Omit both targets\n * and stepIds to run every step; no target is selected automatically.\n */\n targets?: readonly TTargetId[];\n }\n);\n\n/** Resolved caller context. Core fills `now` and `sleep` before execution. */\nexport interface PipelineRuntime extends PipelineContext {\n now: () => number;\n sleep: (durationMs: number, signal?: AbortSignal) => Promise<void>;\n}\n\n/** Resolved execution context provided to pipeline handlers. */\nexport interface PipelineExecutionContext<TOptions extends object> extends PipelineRuntime {\n dryRun: boolean;\n options: TOptions;\n /** Stable identity for this execution, whether or not tracing is configured. */\n runId: string;\n /** Stable identities for this traced run; absent unless `context.tracing` is configured. */\n trace?: PipelineTraceContext;\n}\n\n/**\n * Lifecycle status displayed for an optional nested progress row.\n *\n * Detail rows are indented under a parent step's progress.\n * Domain-agnostic: mapped children, nested work units, per-file status, etc.\n */\nexport type PipelineStepProgressDetailStatus =\n | \"cancelled\"\n | \"completed\"\n | \"failed\"\n | \"pending\"\n | \"running\"\n | \"skipped\";\n\n/** One optional nested row in a step progress snapshot. */\nexport interface PipelineStepProgressDetail {\n /** Provenance of a supplied test output, independent of the row status. */\n outputSource?: \"override\";\n /** Stable identity for the row (item key, path, job id, …). */\n id: string;\n /** Optional display name; identity remains `id`. */\n name?: string;\n /** Indentation relative to direct child rows (0). Rows are in tree preorder. */\n depth?: number;\n /** Inner work counts, independent of the parent's lifecycle count. */\n completed?: number;\n total?: number;\n /** Short status text shown after the id. */\n label?: string;\n /** Controls the detail row symbol. Defaults to `running`. */\n status?: PipelineStepProgressDetailStatus;\n}\n\n/** Latest progress snapshot reported by a running step. */\nexport interface PipelineStepProgress {\n /** Work completed so far. Values outside the reported total are allowed but renderers may clamp them. */\n completed: number;\n /** Total work when known. Omit for indeterminate progress. */\n total?: number;\n /** Optional short status shown next to the step. Prefer one-line summaries. */\n message?: string;\n /**\n * Optional multi-line detail rows for capable reporters (interactive TTY).\n * Keep the parent `message` as a summary; put per-item status here so high\n * concurrency does not collapse onto one truncated line.\n */\n details?: readonly PipelineStepProgressDetail[];\n}\n\n/** Step execution context with attempt identity and progress reporting helpers. */\nexport interface PipelineStepContext<\n TOptions extends object,\n> extends PipelineExecutionContext<TOptions> {\n /** Stable identity for this execution of the current step. */\n attemptId: string;\n /** Record completed I/O without changing the step output. Calls after the handler settles are ignored. */\n recordArtifact(record: ArtifactRecord): void;\n /** Emit a retry/attempt trace event for this step when tracing is enabled. */\n reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;\n /** Publish the latest progress snapshot for this step. */\n reportProgress(progress: PipelineStepProgress): void;\n}\n\n/** Adapter that invokes one step on an external execution engine. */\nexport interface RemoteStepAdapter<TOptions extends object, TPayload, TResult> {\n /** Presentation only. The kernel never switches on this. */\n readonly engine: string;\n /** Function name, workflow type, URL, queue. Presentation only. */\n readonly target?: string;\n invoke(payload: TPayload, context: PipelineStepContext<TOptions>): Promise<TResult>;\n}\n\n/** Pipeline lifecycle phase in which an error occurred. */\nexport type PipelineErrorPhase = PipelineErrorPhaseContract;\n\n/** Broad category of a structured pipeline error. */\nexport type PipelineErrorKind = PipelineErrorKindContract;\n\n/** Ordered catalog of every stable package-owned pipeline error code. */\nexport const PIPELINE_ERROR_CODES = Object.freeze(PIPELINE_ERROR_CODE_VALUES);\n\n/** Stable package-owned code for a pipeline error. */\nexport type PipelineErrorCode = (typeof PIPELINE_ERROR_CODES)[number];\n\nconst pipelineErrorCodeSet: ReadonlySet<string> = new Set(PIPELINE_ERROR_CODES);\n\n/** Return whether an unknown value is a stable package-owned pipeline error code. */\nexport function isPipelineErrorCode(value: unknown): value is PipelineErrorCode {\n return typeof value === \"string\" && pipelineErrorCodeSet.has(value);\n}\n\n/** One dependency-free Standard Schema issue normalized for reports and traces. */\nexport interface PipelineValidationIssue {\n message: string;\n path?: readonly (number | string)[];\n}\n\n/** Bounded diagnostics for a failed or cancelled runtime fan-out. */\nexport interface PipelineFanOutFailure {\n /** Original input position, including when the key is truncated. */\n index: number;\n /** At most 1024 UTF-16 code units; do not rerun by key when keyTruncated is true. */\n key: string;\n keyTruncated: boolean;\n cancelled: boolean;\n error: PipelineErrorCause;\n}\n\n/** Bounded diagnostics collected from a failed or cancelled fan-out step. */\nexport interface PipelineFanOutDiagnostics {\n /** Failed started items, in input order; at most 32 entries. */\n failures: readonly PipelineFanOutFailure[];\n /** Total failed started items, including omitted diagnostics. */\n failureCount: number;\n omittedFailureCount: number;\n /** Scheduler failure is separate and never assigned an item key. */\n schedulerError?: PipelineErrorCause;\n}\n\n/** Structured, machine-readable error stored in plans, runs, and traces. */\nexport interface PipelineError {\n /** Present for aggregated fan-out failures; absent for setup errors. */\n fanOut?: PipelineFanOutDiagnostics;\n /** Bounded, JSON-safe snapshot of the thrown error's cause chain. */\n cause?: PipelineErrorCause;\n code: PipelineErrorCode;\n kind: PipelineErrorKind;\n message: string;\n phase: PipelineErrorPhase;\n /** Present when a Standard Schema rejected a boundary value. */\n issues?: readonly PipelineValidationIssue[];\n stepId?: string;\n /** Machine-readable code copied from the original thrown error, when present. */\n sourceCode?: string;\n stack?: string;\n}\n\n/** Dependency-free subset of the Standard Schema V1 protocol. */\nexport interface StandardSchemaV1<TInput = unknown, TOutput = TInput> {\n readonly \"~standard\": StandardSchemaV1Props<TInput, TOutput>;\n}\n\n/** Standard Schema V1 metadata and validation contract consumed by Tubeless. */\ninterface StandardSchemaV1Props<TInput = unknown, TOutput = TInput> {\n /** Optional Standard JSON Schema input converter, used to infer CLI flags. */\n readonly jsonSchema?: {\n readonly input: (options: { readonly target: \"draft-2020-12\" }) => Record<string, unknown>;\n };\n readonly types?: { readonly input: TInput; readonly output: TOutput };\n readonly validate: (\n value: unknown,\n options?: { readonly libraryOptions?: Record<string, unknown> }\n ) => StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>;\n readonly vendor: string;\n readonly version: 1;\n}\n\n/** Successful value or validation issues returned by a Standard Schema V1 validator. */\nexport type StandardSchemaV1Result<TOutput> =\n | { readonly issues?: undefined; readonly value: TOutput }\n | { readonly issues: readonly StandardSchemaV1Issue[] };\n\n/** Validation issue shape accepted from a Standard Schema V1 validator. */\nexport interface StandardSchemaV1Issue {\n readonly message: string;\n readonly path?: readonly (PropertyKey | { readonly key: PropertyKey })[];\n}\n\n/** Infer the accepted input type from a Standard Schema without importing its package. */\nexport type InferSchemaInput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"input\"];\n\n/** Infer the validated output type from a Standard Schema without importing its package. */\nexport type InferSchemaOutput<TSchema extends StandardSchemaV1> = NonNullable<\n TSchema[\"~standard\"][\"types\"]\n>[\"output\"];\n\n/** Bounded JSON-safe snapshot of a thrown value and its cause chain. */\nexport interface PipelineErrorCause {\n cause?: PipelineErrorCause;\n message: string;\n name?: string;\n /** Machine-readable code copied from this cause, when present. */\n sourceCode?: string;\n}\n\ninterface PipelineStepReportBase {\n /** Present once a supplied test output enters validation, including failed/cancelled attempts. */\n outputSource?: \"override\";\n /** Present when the step started an execution attempt. */\n attemptId?: string;\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n description?: string;\n /** Wall-clock time when this terminal report was recorded. */\n finishedAtMs: number;\n /** Wall-clock time when execution began; absent when the step never started. */\n startedAtMs?: number;\n}\n\n/** Terminal report for a successfully completed step. */\nexport interface PipelineStepCompleteReport extends PipelineStepReportBase {\n attemptId: string;\n startedAtMs: number;\n status: \"completed\";\n}\n\n/** Terminal report for a structurally or intentionally skipped step. */\nexport interface PipelineStepSkippedReport extends PipelineStepReportBase {\n /** Dependency that blocked this step, when applicable. */\n dependencyId?: string;\n /** Human-readable skip detail, especially for policy and fail-fast skips. */\n message?: string;\n reason: PipelineStepSkipReason;\n status: \"skipped\";\n}\n\n/** Terminal report for a cancelled step. */\nexport interface PipelineStepCancelledReport extends PipelineStepReportBase {\n error: PipelineError;\n status: \"cancelled\";\n}\n\n/** Terminal report for a failed step. */\nexport interface PipelineStepFailedReport extends PipelineStepReportBase {\n attemptId: string;\n error: PipelineError;\n startedAtMs: number;\n status: \"failed\";\n}\n\n/** Terminal state recorded for one step after a run. */\nexport type PipelineStepReport =\n | PipelineStepCancelledReport\n | PipelineStepFailedReport\n | PipelineStepSkippedReport\n | PipelineStepCompleteReport;\n\n/** Terminal status recorded in a step report. */\nexport type PipelineStepReportStatus = PipelineStepReport[\"status\"];\n\n/** Terminal disposition of a completed run record. */\nexport type PipelineRunStatus = \"cancelled\" | \"completed\" | \"failed\";\n\ninterface PipelineRunRecord {\n definitionIdentity?: PipelineDefinitionIdentity;\n /** Caller-owned identifier shared by related executions, when supplied. */\n correlationId?: string;\n pipelineId: string;\n dryRun: boolean;\n /** Run-level errors first, step errors in plan order, then finalization errors. */\n errors: PipelineError[];\n finishedAtMs: number;\n parentRunId?: string;\n runId: string;\n startedAtMs: number;\n status: PipelineRunStatus;\n /** Terminal step reports in stable plan order, independent of completion order. */\n steps: PipelineStepReport[];\n version: typeof RUN_MODEL_VERSION;\n}\n\n/** Versioned public record returned for one pipeline execution. */\nexport type PipelineRun<TResult = unknown> =\n | (PipelineRunRecord & {\n /** Finalization did not produce a result. Independent of terminal run status. */\n finalized: false;\n value?: undefined;\n })\n | (PipelineRunRecord & {\n /** Finalization produced a result. Independent of terminal run status. */\n finalized: true;\n value: TResult;\n });\n\n/**\n * Why a step did not run. Built-in structural reasons keep dependency semantics;\n * `\"policy\"` is an intentional skip from `step.skip()` (still unlocks dependents).\n */\nexport type PipelineStepSkipReason =\n | \"dry-run\"\n | \"failed-dependency\"\n | \"fail-fast\"\n | \"filtered\"\n | \"policy\"\n | \"unmet-dependency\";\n\n/**\n * Decision from an optional `skip` predicate.\n * - falsy / `false` → run the step\n * - non-empty string → skip with that message (`reason: \"policy\"`); the step's\n * published output is `undefined`\n * - `{ reason, value? }` → skip and optionally publish `value` for dependents\n * (`value` may be intentionally `undefined` if passed explicitly)\n *\n * Policy skips unlock required dependents. A bare-string skip (or a `{ reason }`\n * without `value`) makes dependents see `TOut | undefined`. When every skip\n * branch returns `{ reason, value }`, the step retains `TOut`; schema-backed\n * values use the schema input type and publish its transformed output type.\n */\nexport type StepSkipDecision<TOut = unknown> =\n | false\n | null\n | undefined\n | string\n | { reason: string; value?: TOut };\n\n/** One observable status in a step's planned → running → terminal lifecycle. */\nexport type PipelineStepStatus =\n | { pipelineId: string; status: \"planned\"; step: PipelinePlanStep }\n | {\n attemptId: string;\n pipelineId: string;\n /** Supplied test output; the normal step handler is not executing. */\n outputSource?: \"override\";\n progress?: PipelineStepProgress;\n status: \"running\";\n step: PipelinePlanStep;\n }\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCancelledReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepFailedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepSkippedReport)\n | ({ pipelineId: string; step: PipelinePlanStep } & PipelineStepCompleteReport);\n\n/** Any planned, running, or terminal step lifecycle status. */\nexport type PipelineStepLifecycleStatus = PipelineStepStatus[\"status\"];\n\n/** Lifecycle event emitted when a step is planned. */\nexport type PipelineStepPlannedEvent = Extract<PipelineStepStatus, { status: \"planned\" }>;\ntype PipelineStepRunningStatus = Extract<PipelineStepStatus, { status: \"running\" }>;\n/** Lifecycle event emitted when a step begins running. */\nexport type PipelineStepStartEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress?: undefined;\n};\n/** Lifecycle event emitted when a running step reports progress. */\nexport type PipelineStepProgressEvent = Omit<PipelineStepRunningStatus, \"progress\"> & {\n progress: PipelineStepProgress;\n};\n/** Lifecycle event emitted when a step is cancelled. */\nexport type PipelineStepCancelledEvent = Extract<PipelineStepStatus, { status: \"cancelled\" }>;\n/** Lifecycle event emitted when a step fails. */\nexport type PipelineStepFailedEvent = Extract<PipelineStepStatus, { status: \"failed\" }>;\n/** Lifecycle event emitted when a step is skipped. */\nexport type PipelineStepSkippedEvent = Extract<PipelineStepStatus, { status: \"skipped\" }>;\n/** Lifecycle event emitted when a step completes successfully. */\nexport type PipelineStepCompleteEvent = Extract<PipelineStepStatus, { status: \"completed\" }>;\n\n/**\n * Optional lifecycle callbacks, each receiving its own metadata snapshot.\n * Domain result values retain their identity; hooks must treat them as read-only.\n */\nexport interface PipelineHooks<TResult = unknown> {\n onFinalizeComplete?(event: { durationMs: number; pipelineId: string; value: TResult }): void;\n onFinalizeError?(event: { durationMs: number; error: PipelineError; pipelineId: string }): void;\n onFinalizeStart?(event: { pipelineId: string }): void;\n onPipelineComplete?(event: PipelineRun<TResult>): void;\n onPipelineStart?(event: PipelinePlan): void;\n onStepCancel?(event: PipelineStepCancelledEvent): void;\n onStepFail?(event: PipelineStepFailedEvent): void;\n onStepPlan?(event: PipelineStepPlannedEvent): void;\n onStepProgress?(event: PipelineStepProgressEvent): void;\n onStepSkip?(event: PipelineStepSkippedEvent): void;\n onStepStart?(event: PipelineStepStartEvent): void;\n onStepStatus?(event: PipelineStepStatus): void;\n onStepComplete?(event: PipelineStepCompleteEvent): void;\n}\n\n/** Machine-readable explanation of why a planned step was included or omitted. */\nexport type PipelineStepSelectionReason =\n | { kind: \"all\" }\n | { kind: \"exact\" }\n | { kind: \"target\"; targetId: string }\n | { dependentId: string; kind: \"required-dependency\"; targetId: string }\n | { dependentId: string; kind: \"failure-gate\"; targetId: string }\n | { dependentId: string; kind: \"optional-only\"; targetId: string }\n | { kind: \"outside-target-closure\" }\n | { kind: \"not-selected\" };\n\n/** Planned representation of one declared step and its selection state. */\nexport interface PipelinePlanStep {\n dependencies: string[];\n description?: string;\n /** How this step behaves when the pipeline is run with `dryRun: true`. */\n dryRun: \"custom\" | \"run\" | \"skip\";\n id: string;\n /** Optional human-facing display name. Stable machine identity remains `id`. */\n name?: string;\n /** Static child structure when this opaque step executes another pipeline. */\n nestedPipeline?: {\n /** One child, runtime fan-out, or bounded sequential iteration. */\n mode: \"single\" | \"for-each\" | \"iterate\";\n /** Upper bound for a dynamically repeated child. */\n maxIterations?: number;\n /** Static child controls, recorded for iteration identity and inspection. */\n controls?: PipelineRunControls;\n identity?: PipelineDefinitionIdentity;\n concurrency?: number | \"dynamic\";\n pipelineId: string;\n /** All declared child step ids; runtime selection may execute only a subset. */\n stepIds: readonly string[];\n };\n /** Static remote adapter metadata when this opaque step calls an external engine. */\n remote?: {\n engine: string;\n target?: string;\n };\n optionalDependencies: string[];\n /** True when the step's runtime policy may elect not to run it. */\n runtimeSkipPossible: boolean;\n selected: boolean;\n /** Stable reasons for selection or omission; shared prerequisites can have several. */\n selectionReasons: readonly PipelineStepSelectionReason[];\n skipAfterFailureOf: string[];\n skipReason?: PipelineStepSkipReason;\n}\n\n/** Side-effect-free validation and selection result for a pipeline run. */\nexport interface PipelinePlan {\n definition?: PipelineDefinitionSnapshot;\n dryRun: boolean;\n errors: PipelineError[];\n ok: boolean;\n pipelineId: string;\n steps: PipelinePlanStep[];\n}\n\n/** Layout directions for generated Mermaid flowcharts. */\nexport const PIPELINE_MERMAID_DIRECTIONS = [\"BT\", \"LR\", \"RL\", \"TB\", \"TD\"] as const;\n/** Supported Mermaid flowchart direction. */\nexport type PipelineMermaidDirection = (typeof PIPELINE_MERMAID_DIRECTIONS)[number];\n\n/** Rendering options for a pipeline Mermaid flowchart. */\nexport interface PipelineMermaidOptions {\n /** Mermaid flowchart direction. Defaults to top-down (`TD`). */\n direction?: PipelineMermaidDirection;\n /** Append each operational description to its node label. Defaults to false. */\n includeDescriptions?: boolean;\n}\n\ntype PipelineRunArguments<\n TOptions,\n TStepId extends string,\n TTargetId extends string,\n> = {} extends TOptions\n ? [\n options?: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ]\n : [\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>,\n ];\n\n/** Compiled pipeline that can be planned, executed, and rendered as a graph. */\nexport interface Pipeline<\n TOptions extends object,\n TResult,\n TStepId extends string = string,\n TTargetId extends string = TStepId,\n TId extends string = string,\n> {\n readonly id: TId;\n /** Optional display name; stable identity remains `id`. */\n readonly name?: string;\n /** Human-readable purpose for command and discovery surfaces. */\n readonly description?: string;\n /** Compiled definition metadata. Absent only on externally implemented pipelines. */\n readonly definition?: PipelineDefinitionSnapshot;\n /** Runtime domain schema supplied to createSteps; CLI adapters can infer its input flags. */\n readonly optionsSchema?: StandardSchemaV1;\n /** Stable definition-order step ids for discovery surfaces such as CLI help. */\n readonly stepIds: readonly TStepId[];\n /** Stable declared goal ids that support dependency-aware target execution. */\n readonly targetIds: readonly TTargetId[];\n plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;\n /** Omitted options default to {} when the input type has no required fields. */\n run(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<PipelineRun<TResult>>;\n run(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<PipelineRun<TResult>>;\n runOrThrow(\n options: TOptions,\n controls?: PipelineRunControls<TStepId, TTargetId>,\n context?: Partial<PipelineContext>\n ): Promise<TResult>;\n runOrThrow(...args: PipelineRunArguments<TOptions, TStepId, TTargetId>): Promise<TResult>;\n /** Generate a static Mermaid flowchart without running or planning the pipeline. */\n toMermaid(options?: PipelineMermaidOptions): string;\n}\n\n/** Input accepted by a pipeline run before any options schema transformation. */\nexport type PipelineInput<TPipeline extends Pipeline<object, unknown>> = Exclude<\n Parameters<TPipeline[\"run\"]>[0],\n undefined\n>;\n\n/** Successful result produced by a pipeline run. */\nexport type PipelineResult<TPipeline extends Pipeline<object, unknown>> = Awaited<\n ReturnType<TPipeline[\"runOrThrow\"]>\n>;\n"]}
|
package/dist/core/pipeline.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PipelineExecutionError } from "./pipeline-
|
|
1
|
+
import { PipelineExecutionError } from "./pipeline-execution-error.js";
|
|
2
2
|
import { RUN_MODEL_VERSION } from "./pipeline-ids.js";
|
|
3
3
|
import type { DefaultPipelineResult, DefaultPipelineTargets, PipelineDefinition, StepIds, StepsInputOptions, StepsOptionsSchema, TargetIds } from "./pipeline-definition.js";
|
|
4
4
|
import { PipelineDefinitionError } from "./pipeline-errors.js";
|
|
@@ -8,6 +8,7 @@ import type { InferSchemaOutput, Pipeline, PipelineDefinitionSnapshot, StandardS
|
|
|
8
8
|
export { PipelineExecutionError, RUN_MODEL_VERSION };
|
|
9
9
|
export { isPipelineErrorCode, PIPELINE_ERROR_CODES } from "./pipeline-types.js";
|
|
10
10
|
export { createSteps } from "./pipeline-steps.js";
|
|
11
|
+
export type { IterationDecision, IterationState } from "./iteration.js";
|
|
11
12
|
export { PipelineDefinitionError, requireOutputs };
|
|
12
13
|
export type { PipelineDefinitionIdentity, PipelineDefinitionSnapshot, PipelineLogger, PipelineContext, PipelineRunControls, PipelineExecutionContext, PipelineStepProgressDetailStatus, PipelineStepProgressDetail, PipelineStepProgress, PipelineStepContext, RemoteStepAdapter, PipelineErrorPhase, PipelineErrorKind, PipelineErrorCode, PipelineValidationIssue, PipelineError, PipelineFanOutDiagnostics, PipelineFanOutFailure, StandardSchemaV1, PipelineErrorCause, PipelineStepCompleteReport, PipelineStepSkippedReport, PipelineStepCancelledReport, PipelineStepFailedReport, PipelineStepReport, PipelineStepReportStatus, PipelineRunStatus, PipelineRun, PipelineStepSkipReason, StepSkipDecision, PipelineStepStatus, PipelineStepLifecycleStatus, PipelineStepPlannedEvent, PipelineStepStartEvent, PipelineStepProgressEvent, PipelineStepCancelledEvent, PipelineStepFailedEvent, PipelineStepSkippedEvent, PipelineStepCompleteEvent, PipelineHooks, PipelineStepSelectionReason, PipelinePlanStep, PipelinePlan, PipelineMermaidDirection, PipelineMermaidOptions, Pipeline, PipelineInput, PipelineResult, } from "./pipeline-types.js";
|
|
13
14
|
export type { PipelineDefinition } from "./pipeline-definition.js";
|
|
@@ -29,3 +30,5 @@ export declare function definePipeline<const TSteps extends readonly AnyStep[],
|
|
|
29
30
|
readonly definition: PipelineDefinitionSnapshot;
|
|
30
31
|
readonly optionsSchema: StepsOptionsSchema<TSteps>;
|
|
31
32
|
};
|
|
33
|
+
export type { ArtifactJsonValue, ArtifactMetadata, ArtifactRecord, } from "../tracing/artifact-metadata.js";
|
|
34
|
+
export type { ArtifactLoader, ArtifactSaver, ArtifactResult } from "./pipeline-artifacts.js";
|
package/dist/core/pipeline.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PipelineExecutionError } from "./pipeline-execution-error.js";
|
|
2
|
+
import { defaultPipelineContext, executePlannedRun, resolvePipelineRuntime, } from "./pipeline-execute.js";
|
|
2
3
|
import { RUN_MODEL_VERSION } from "./pipeline-ids.js";
|
|
3
4
|
import { compilePipeline } from "./pipeline-compiler.js";
|
|
4
5
|
import { PipelineDefinitionError } from "./pipeline-errors.js";
|
|
5
6
|
import { requireOutputs } from "./pipeline-finalizer.js";
|
|
6
|
-
import { brandCompiledPipeline, EXECUTE_COMPILED_RUN } from "./pipeline-identity.js";
|
|
7
|
+
import { brandCompiledPipeline, EXECUTE_COMPILED_RUN, EXECUTE_TEST_RUN, } from "./pipeline-identity.js";
|
|
7
8
|
import { renderPipelineMermaid } from "./pipeline-mermaid.js";
|
|
8
9
|
import { buildPipelinePlan } from "./pipeline-plan.js";
|
|
9
10
|
export { PipelineExecutionError, RUN_MODEL_VERSION };
|
|
@@ -50,13 +51,14 @@ export function definePipeline(definition) {
|
|
|
50
51
|
function toMermaid(options = {}) {
|
|
51
52
|
return renderPipelineMermaid(compiled.orderedSteps, options, compiled.stepGraph);
|
|
52
53
|
}
|
|
53
|
-
async function executeCompiled(runPlan, options, controls, context = defaultPipelineContext()) {
|
|
54
|
+
async function executeCompiled(runPlan, options, controls, context = defaultPipelineContext(), overrides) {
|
|
54
55
|
return executePlannedRun({
|
|
55
56
|
compiled,
|
|
56
57
|
controls,
|
|
57
58
|
domainOptions: options,
|
|
58
59
|
plan: runPlan,
|
|
59
60
|
runtime: resolvePipelineRuntime(context),
|
|
61
|
+
overrides,
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
async function run(options, controls = {}, context = defaultPipelineContext()) {
|
|
@@ -89,6 +91,19 @@ export function definePipeline(definition) {
|
|
|
89
91
|
toMermaid,
|
|
90
92
|
};
|
|
91
93
|
Object.defineProperty(pipeline, EXECUTE_COMPILED_RUN, { value: executeCompiled });
|
|
94
|
+
Object.defineProperty(pipeline, EXECUTE_TEST_RUN, {
|
|
95
|
+
value: (options, controls, context, overrides) => {
|
|
96
|
+
const resolved = new Map();
|
|
97
|
+
for (const [step, value] of overrides) {
|
|
98
|
+
const compiledStep = compiled.compiledByAuthorStep.get(step);
|
|
99
|
+
if (!compiledStep)
|
|
100
|
+
throw new TypeError(`Override step ${step.id} does not belong to pipeline ${compiled.id}`);
|
|
101
|
+
resolved.set(compiledStep, value);
|
|
102
|
+
}
|
|
103
|
+
const prepared = prepareRun(controls);
|
|
104
|
+
return executeCompiled(prepared.plan, options === undefined ? {} : options, prepared.controls, context, resolved);
|
|
105
|
+
},
|
|
106
|
+
});
|
|
92
107
|
brandCompiledPipeline(pipeline);
|
|
93
108
|
return pipeline;
|
|
94
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAcvD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC;AA+EnD,SAAS,oBAAoB,CAC3B,QAAiD;IAEjD,MAAM,EAAE,e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AC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QACnE,GAAG,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;QACxF,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,mFAAmF;QACnF,aAAa,EAAE,QAAQ,CAAC,aACQ;QAChC,OAAO;QACP,SAAS;QACT,IAAI;QACJ,GAAG;QACH,UAAU;QACV,SAAS;KACV,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;IAClF,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n defaultPipelineContext,\n executePlannedRun,\n PipelineExecutionError,\n resolvePipelineRuntime,\n} from \"./pipeline-execute.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { compilePipeline } from \"./pipeline-compiler.js\";\nimport type {\n DefaultPipelineResult,\n DefaultPipelineTargets,\n PipelineDefinition,\n StepIds,\n StepsInputOptions,\n StepsOptionsSchema,\n TargetIds,\n} from \"./pipeline-definition.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requireOutputs } from \"./pipeline-finalizer.js\";\nimport { brandCompiledPipeline, EXECUTE_COMPILED_RUN } from \"./pipeline-identity.js\";\nimport { renderPipelineMermaid } from \"./pipeline-mermaid.js\";\nimport { buildPipelinePlan } from \"./pipeline-plan.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaOutput,\n Pipeline,\n PipelineContext,\n PipelineDefinitionSnapshot,\n PipelineMermaidOptions,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\nexport { PipelineExecutionError, RUN_MODEL_VERSION };\nexport { isPipelineErrorCode, PIPELINE_ERROR_CODES } from \"./pipeline-types.js\";\nexport { createSteps } from \"./pipeline-steps.js\";\nexport { PipelineDefinitionError, requireOutputs };\nexport type {\n PipelineDefinitionIdentity,\n PipelineDefinitionSnapshot,\n PipelineLogger,\n PipelineContext,\n PipelineRunControls,\n PipelineExecutionContext,\n PipelineStepProgressDetailStatus,\n PipelineStepProgressDetail,\n PipelineStepProgress,\n PipelineStepContext,\n RemoteStepAdapter,\n PipelineErrorPhase,\n PipelineErrorKind,\n PipelineErrorCode,\n PipelineValidationIssue,\n PipelineError,\n PipelineFanOutDiagnostics,\n PipelineFanOutFailure,\n StandardSchemaV1,\n PipelineErrorCause,\n PipelineStepCompleteReport,\n PipelineStepSkippedReport,\n PipelineStepCancelledReport,\n PipelineStepFailedReport,\n PipelineStepReport,\n PipelineStepReportStatus,\n PipelineRunStatus,\n PipelineRun,\n PipelineStepSkipReason,\n StepSkipDecision,\n PipelineStepStatus,\n PipelineStepLifecycleStatus,\n PipelineStepPlannedEvent,\n PipelineStepStartEvent,\n PipelineStepProgressEvent,\n PipelineStepCancelledEvent,\n PipelineStepFailedEvent,\n PipelineStepSkippedEvent,\n PipelineStepCompleteEvent,\n PipelineHooks,\n PipelineStepSelectionReason,\n PipelinePlanStep,\n PipelinePlan,\n PipelineMermaidDirection,\n PipelineMermaidOptions,\n Pipeline,\n PipelineInput,\n PipelineResult,\n} from \"./pipeline-types.js\";\n\nexport type { PipelineDefinition } from \"./pipeline-definition.js\";\n\nexport type { Step, MappedChildProgressOptions } from \"./pipeline-steps.js\";\n\ntype DuplicateStepIds<\n TSteps extends readonly AnyStep[],\n TSeen extends string = never,\n> = TSteps extends readonly [infer THead, ...infer TTail]\n ? THead extends AnyStep\n ? TTail extends readonly AnyStep[]\n ? THead[\"id\"] extends TSeen\n ? THead[\"id\"] | DuplicateStepIds<TTail, TSeen>\n : DuplicateStepIds<TTail, TSeen | THead[\"id\"]>\n : never\n : never\n : never;\n\ntype CheckedStepTuple<TSteps extends readonly AnyStep[]> =\n string extends StepIds<TSteps>\n ? unknown\n : DuplicateStepIds<TSteps> extends never\n ? unknown\n : {\n /** Compile-time diagnostic: every literal step ID in a definition must be unique. */\n readonly __duplicateStepIds: DuplicateStepIds<TSteps>;\n };\n\nfunction normalizeRunControls<TStepId extends string, TTargetId extends string>(\n controls: PipelineRunControls<TStepId, TTargetId>\n): PipelineRunControls<TStepId, TTargetId> {\n const { continueOnError, dryRun, maxConcurrency, stepIds, targets } = controls;\n const snapshot: PipelineRunControls<TStepId, TTargetId> = {};\n if (continueOnError !== undefined) snapshot.continueOnError = continueOnError;\n if (dryRun !== undefined) snapshot.dryRun = dryRun;\n if (maxConcurrency !== undefined) snapshot.maxConcurrency = maxConcurrency;\n if (stepIds !== undefined) snapshot.stepIds = [...stepIds];\n if (targets !== undefined) snapshot.targets = [...targets];\n return snapshot;\n}\n\n/**\n * Compile a typed step graph into a validated, executable pipeline.\n * Prefer inferred type arguments to preserve the literal id. For an explicit\n * result contract, annotate the finalizer's return type; partially supplied type\n * arguments use defaults for remaining parameters, including the id's string type.\n */\nexport function definePipeline<\n const TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n const TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n const TResultSchema extends StandardSchemaV1 | undefined = undefined,\n const TId extends string = string,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema> &\n CheckedStepTuple<TSteps> & { readonly id: TId }\n): Pipeline<\n StepsInputOptions<TSteps>,\n TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult,\n StepIds<TSteps>,\n TargetIds<TTargets>,\n TId\n> & {\n readonly definition: PipelineDefinitionSnapshot;\n readonly optionsSchema: StepsOptionsSchema<TSteps>;\n} {\n const compiled = compilePipeline<TSteps, TResult, TTargets, TResultSchema>(definition);\n type TInputOptions = StepsInputOptions<TSteps>;\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TStepId = StepIds<TSteps>;\n type TTargetId = TargetIds<TTargets>;\n // SAFETY: each compiled step id is a string key of `TSteps`.\n const stepIds = compiled.stepIds as readonly TStepId[];\n // SAFETY: each compiled target id is a string key of `TTargets`.\n const targetIds = compiled.targetIds as readonly TTargetId[];\n\n function prepareRun(controls: PipelineRunControls<TStepId, TTargetId>): {\n controls: PipelineRunControls<TStepId, TTargetId>;\n plan: PipelinePlan;\n } {\n const normalizedControls = normalizeRunControls(controls);\n return {\n controls: normalizedControls,\n plan: buildPipelinePlan(compiled, normalizedControls),\n };\n }\n\n function plan(controls: PipelineRunControls<TStepId, TTargetId> = {}): PipelinePlan {\n return prepareRun(controls).plan;\n }\n\n function toMermaid(options: PipelineMermaidOptions = {}): string {\n return renderPipelineMermaid(compiled.orderedSteps, options, compiled.stepGraph);\n }\n\n async function executeCompiled(\n runPlan: PipelinePlan,\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId>,\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n return executePlannedRun({\n compiled,\n controls,\n domainOptions: options,\n plan: runPlan,\n runtime: resolvePipelineRuntime(context),\n });\n }\n\n async function run(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n const prepared = prepareRun(controls);\n // SAFETY: the public signature permits omission only when {} satisfies the\n // input type. Schemas still validate the default object during execution.\n const input = options === undefined ? ({} as TInputOptions) : options;\n return executeCompiled(prepared.plan, input, prepared.controls, context);\n }\n\n async function runOrThrow(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<TPipelineResult> {\n const result = await run(options, controls, context);\n if (result.status !== \"completed\") {\n throw new PipelineExecutionError(result);\n }\n // SAFETY: a completed run always carries its `TPipelineResult` value.\n return result.value as TPipelineResult;\n }\n\n const pipeline = {\n id: definition.id,\n ...(definition.name === undefined ? {} : { name: definition.name }),\n ...(definition.description === undefined ? {} : { description: definition.description }),\n definition: compiled.definition,\n // SAFETY: compilation verifies that every step belongs to the same options schema.\n optionsSchema: compiled.optionsSchema as StepsOptionsSchema<TSteps> &\n (StandardSchemaV1 | undefined),\n stepIds,\n targetIds,\n plan,\n run,\n runOrThrow,\n toMermaid,\n };\n Object.defineProperty(pipeline, EXECUTE_COMPILED_RUN, { value: executeCompiled });\n brandCompiledPipeline(pipeline);\n return pipeline;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAcvD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC;AA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,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,CAAC,QAAQ,EACjB,OAAO,EACP,QAAQ,CACT,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IACH,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { PipelineExecutionError } from \"./pipeline-execution-error.js\";\nimport {\n defaultPipelineContext,\n executePlannedRun,\n resolvePipelineRuntime,\n} from \"./pipeline-execute.js\";\nimport { RUN_MODEL_VERSION } from \"./pipeline-ids.js\";\nimport { compilePipeline } from \"./pipeline-compiler.js\";\nimport type {\n DefaultPipelineResult,\n DefaultPipelineTargets,\n PipelineDefinition,\n StepIds,\n StepsInputOptions,\n StepsOptionsSchema,\n TargetIds,\n} from \"./pipeline-definition.js\";\nimport { PipelineDefinitionError } from \"./pipeline-errors.js\";\nimport { requireOutputs } from \"./pipeline-finalizer.js\";\nimport {\n brandCompiledPipeline,\n EXECUTE_COMPILED_RUN,\n EXECUTE_TEST_RUN,\n} from \"./pipeline-identity.js\";\nimport { renderPipelineMermaid } from \"./pipeline-mermaid.js\";\nimport { buildPipelinePlan } from \"./pipeline-plan.js\";\nimport type { AnyStep } from \"./pipeline-steps.js\";\nimport type {\n InferSchemaOutput,\n Pipeline,\n PipelineContext,\n PipelineDefinitionSnapshot,\n PipelineMermaidOptions,\n PipelinePlan,\n PipelineRun,\n PipelineRunControls,\n StandardSchemaV1,\n} from \"./pipeline-types.js\";\n\nexport { PipelineExecutionError, RUN_MODEL_VERSION };\nexport { isPipelineErrorCode, PIPELINE_ERROR_CODES } from \"./pipeline-types.js\";\nexport { createSteps } from \"./pipeline-steps.js\";\nexport type { IterationDecision, IterationState } from \"./iteration.js\";\nexport { PipelineDefinitionError, requireOutputs };\nexport type {\n PipelineDefinitionIdentity,\n PipelineDefinitionSnapshot,\n PipelineLogger,\n PipelineContext,\n PipelineRunControls,\n PipelineExecutionContext,\n PipelineStepProgressDetailStatus,\n PipelineStepProgressDetail,\n PipelineStepProgress,\n PipelineStepContext,\n RemoteStepAdapter,\n PipelineErrorPhase,\n PipelineErrorKind,\n PipelineErrorCode,\n PipelineValidationIssue,\n PipelineError,\n PipelineFanOutDiagnostics,\n PipelineFanOutFailure,\n StandardSchemaV1,\n PipelineErrorCause,\n PipelineStepCompleteReport,\n PipelineStepSkippedReport,\n PipelineStepCancelledReport,\n PipelineStepFailedReport,\n PipelineStepReport,\n PipelineStepReportStatus,\n PipelineRunStatus,\n PipelineRun,\n PipelineStepSkipReason,\n StepSkipDecision,\n PipelineStepStatus,\n PipelineStepLifecycleStatus,\n PipelineStepPlannedEvent,\n PipelineStepStartEvent,\n PipelineStepProgressEvent,\n PipelineStepCancelledEvent,\n PipelineStepFailedEvent,\n PipelineStepSkippedEvent,\n PipelineStepCompleteEvent,\n PipelineHooks,\n PipelineStepSelectionReason,\n PipelinePlanStep,\n PipelinePlan,\n PipelineMermaidDirection,\n PipelineMermaidOptions,\n Pipeline,\n PipelineInput,\n PipelineResult,\n} from \"./pipeline-types.js\";\n\nexport type { PipelineDefinition } from \"./pipeline-definition.js\";\n\nexport type { Step, MappedChildProgressOptions } from \"./pipeline-steps.js\";\n\ntype DuplicateStepIds<\n TSteps extends readonly AnyStep[],\n TSeen extends string = never,\n> = TSteps extends readonly [infer THead, ...infer TTail]\n ? THead extends AnyStep\n ? TTail extends readonly AnyStep[]\n ? THead[\"id\"] extends TSeen\n ? THead[\"id\"] | DuplicateStepIds<TTail, TSeen>\n : DuplicateStepIds<TTail, TSeen | THead[\"id\"]>\n : never\n : never\n : never;\n\ntype CheckedStepTuple<TSteps extends readonly AnyStep[]> =\n string extends StepIds<TSteps>\n ? unknown\n : DuplicateStepIds<TSteps> extends never\n ? unknown\n : {\n /** Compile-time diagnostic: every literal step ID in a definition must be unique. */\n readonly __duplicateStepIds: DuplicateStepIds<TSteps>;\n };\n\nfunction normalizeRunControls<TStepId extends string, TTargetId extends string>(\n controls: PipelineRunControls<TStepId, TTargetId>\n): PipelineRunControls<TStepId, TTargetId> {\n const { continueOnError, dryRun, maxConcurrency, stepIds, targets } = controls;\n const snapshot: PipelineRunControls<TStepId, TTargetId> = {};\n if (continueOnError !== undefined) snapshot.continueOnError = continueOnError;\n if (dryRun !== undefined) snapshot.dryRun = dryRun;\n if (maxConcurrency !== undefined) snapshot.maxConcurrency = maxConcurrency;\n if (stepIds !== undefined) snapshot.stepIds = [...stepIds];\n if (targets !== undefined) snapshot.targets = [...targets];\n return snapshot;\n}\n\n/**\n * Compile a typed step graph into a validated, executable pipeline.\n * Prefer inferred type arguments to preserve the literal id. For an explicit\n * result contract, annotate the finalizer's return type; partially supplied type\n * arguments use defaults for remaining parameters, including the id's string type.\n */\nexport function definePipeline<\n const TSteps extends readonly AnyStep[],\n TResult = DefaultPipelineResult<TSteps>,\n const TTargets extends readonly TSteps[number][] = DefaultPipelineTargets<TSteps>,\n const TResultSchema extends StandardSchemaV1 | undefined = undefined,\n const TId extends string = string,\n>(\n definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema> &\n CheckedStepTuple<TSteps> & { readonly id: TId }\n): Pipeline<\n StepsInputOptions<TSteps>,\n TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult,\n StepIds<TSteps>,\n TargetIds<TTargets>,\n TId\n> & {\n readonly definition: PipelineDefinitionSnapshot;\n readonly optionsSchema: StepsOptionsSchema<TSteps>;\n} {\n const compiled = compilePipeline<TSteps, TResult, TTargets, TResultSchema>(definition);\n type TInputOptions = StepsInputOptions<TSteps>;\n type TPipelineResult = TResultSchema extends StandardSchemaV1\n ? InferSchemaOutput<TResultSchema>\n : TResult;\n type TStepId = StepIds<TSteps>;\n type TTargetId = TargetIds<TTargets>;\n // SAFETY: each compiled step id is a string key of `TSteps`.\n const stepIds = compiled.stepIds as readonly TStepId[];\n // SAFETY: each compiled target id is a string key of `TTargets`.\n const targetIds = compiled.targetIds as readonly TTargetId[];\n\n function prepareRun(controls: PipelineRunControls<TStepId, TTargetId>): {\n controls: PipelineRunControls<TStepId, TTargetId>;\n plan: PipelinePlan;\n } {\n const normalizedControls = normalizeRunControls(controls);\n return {\n controls: normalizedControls,\n plan: buildPipelinePlan(compiled, normalizedControls),\n };\n }\n\n function plan(controls: PipelineRunControls<TStepId, TTargetId> = {}): PipelinePlan {\n return prepareRun(controls).plan;\n }\n\n function toMermaid(options: PipelineMermaidOptions = {}): string {\n return renderPipelineMermaid(compiled.orderedSteps, options, compiled.stepGraph);\n }\n\n async function executeCompiled(\n runPlan: PipelinePlan,\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId>,\n context: Partial<PipelineContext> = defaultPipelineContext(),\n overrides?: ReadonlyMap<AnyStep, unknown>\n ): Promise<PipelineRun<TPipelineResult>> {\n return executePlannedRun({\n compiled,\n controls,\n domainOptions: options,\n plan: runPlan,\n runtime: resolvePipelineRuntime(context),\n overrides,\n });\n }\n\n async function run(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<PipelineRun<TPipelineResult>> {\n const prepared = prepareRun(controls);\n // SAFETY: the public signature permits omission only when {} satisfies the\n // input type. Schemas still validate the default object during execution.\n const input = options === undefined ? ({} as TInputOptions) : options;\n return executeCompiled(prepared.plan, input, prepared.controls, context);\n }\n\n async function runOrThrow(\n options?: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId> = {},\n context: Partial<PipelineContext> = defaultPipelineContext()\n ): Promise<TPipelineResult> {\n const result = await run(options, controls, context);\n if (result.status !== \"completed\") {\n throw new PipelineExecutionError(result);\n }\n // SAFETY: a completed run always carries its `TPipelineResult` value.\n return result.value as TPipelineResult;\n }\n\n const pipeline = {\n id: definition.id,\n ...(definition.name === undefined ? {} : { name: definition.name }),\n ...(definition.description === undefined ? {} : { description: definition.description }),\n definition: compiled.definition,\n // SAFETY: compilation verifies that every step belongs to the same options schema.\n optionsSchema: compiled.optionsSchema as StepsOptionsSchema<TSteps> &\n (StandardSchemaV1 | undefined),\n stepIds,\n targetIds,\n plan,\n run,\n runOrThrow,\n toMermaid,\n };\n Object.defineProperty(pipeline, EXECUTE_COMPILED_RUN, { value: executeCompiled });\n Object.defineProperty(pipeline, EXECUTE_TEST_RUN, {\n value: (\n options: TInputOptions,\n controls: PipelineRunControls<TStepId, TTargetId>,\n context: Partial<PipelineContext>,\n overrides: ReadonlyMap<AnyStep, unknown>\n ) => {\n const resolved = new Map<AnyStep, unknown>();\n for (const [step, value] of overrides) {\n const compiledStep = compiled.compiledByAuthorStep.get(step);\n if (!compiledStep)\n throw new TypeError(\n `Override step ${step.id} does not belong to pipeline ${compiled.id}`\n );\n resolved.set(compiledStep, value);\n }\n const prepared = prepareRun(controls);\n return executeCompiled(\n prepared.plan,\n options === undefined ? ({} as TInputOptions) : options,\n prepared.controls,\n context,\n resolved\n );\n },\n });\n brandCompiledPipeline(pipeline);\n return pipeline;\n}\n\nexport type {\n ArtifactJsonValue,\n ArtifactMetadata,\n ArtifactRecord,\n} from \"../tracing/artifact-metadata.js\";\nexport type { ArtifactLoader, ArtifactSaver, ArtifactResult } from \"./pipeline-artifacts.js\";\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Pipeline } from "../core/pipeline.js";
|
|
2
|
+
import { type ProjectRegistry } from "./project-registry.js";
|
|
2
3
|
import { PipelineDocumentError, type PipelineDocumentMetadata } from "./project-document.js";
|
|
3
4
|
export { PipelineDocumentError };
|
|
5
|
+
export type { ProjectRegistry } from "./project-registry.js";
|
|
4
6
|
/** Immutable compiled pipelines and descriptive metadata from a parsed document. */
|
|
5
7
|
export interface CompiledPipelineDocument {
|
|
6
8
|
readonly pipelines: readonly Pipeline<object, unknown>[];
|
|
@@ -8,36 +10,6 @@ export interface CompiledPipelineDocument {
|
|
|
8
10
|
/** Return the shared compiled instance, or throw if the document has no such id. */
|
|
9
11
|
get(id: string): Pipeline<object, unknown>;
|
|
10
12
|
}
|
|
11
|
-
/** Dependency values are checked at runtime rather than inferred from a project document. */
|
|
12
|
-
type PipelineDocumentHandler = (inputs: Record<string, unknown>, context: PipelineStepContext<object>) => unknown;
|
|
13
|
-
type PipelineDocumentFinalizer = (outputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => unknown;
|
|
14
|
-
type PipelineDocumentSkipPredicate = (inputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => StepSkipDecision | Promise<StepSkipDecision>;
|
|
15
|
-
/** Application-owned wiring for one declarative `fromPipeline` step. */
|
|
16
|
-
interface PipelineDocumentFromPipelineAdapter {
|
|
17
|
-
controls?: PipelineRunControls | ((inputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => PipelineRunControls);
|
|
18
|
-
mapOptions(inputs: Record<string, unknown>, context: PipelineExecutionContext<object>): object;
|
|
19
|
-
mapResult?(value: unknown, result: PipelineRun<unknown>, context: PipelineStepContext<object>): unknown;
|
|
20
|
-
}
|
|
21
|
-
/** Application-owned wiring for one declarative `forEachPipeline` step. */
|
|
22
|
-
interface PipelineDocumentForEachPipelineAdapter {
|
|
23
|
-
controls?: PipelineRunControls | ((item: unknown, index: number, inputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => PipelineRunControls);
|
|
24
|
-
items(inputs: Record<string, unknown>, context: PipelineExecutionContext<object>): readonly unknown[] | Promise<readonly unknown[]>;
|
|
25
|
-
key(item: unknown, index: number): string;
|
|
26
|
-
concurrency?: number | ((inputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => number);
|
|
27
|
-
progress?: MappedChildProgressOptions;
|
|
28
|
-
mapOptions(item: unknown, index: number, inputs: Record<string, unknown>, context: PipelineExecutionContext<object>): object;
|
|
29
|
-
mapResult?(value: unknown, result: PipelineRun<unknown>, item: unknown, index: number, context: PipelineStepContext<object>): unknown;
|
|
30
|
-
}
|
|
31
|
-
/** Only explicitly registered functions and schemas can be referenced by a document. */
|
|
32
|
-
export interface ProjectRegistry {
|
|
33
|
-
steps: Readonly<Record<string, PipelineDocumentHandler>>;
|
|
34
|
-
finalizers: Readonly<Record<string, PipelineDocumentFinalizer>>;
|
|
35
|
-
skipPredicates?: Readonly<Record<string, PipelineDocumentSkipPredicate>>;
|
|
36
|
-
fromPipelineAdapters?: Readonly<Record<string, PipelineDocumentFromPipelineAdapter>>;
|
|
37
|
-
forEachPipelineAdapters?: Readonly<Record<string, PipelineDocumentForEachPipelineAdapter>>;
|
|
38
|
-
optionsSchemas?: Readonly<Record<string, StandardSchemaV1<object, object>>>;
|
|
39
|
-
schemas?: Readonly<Record<string, StandardSchemaV1>>;
|
|
40
|
-
}
|
|
41
13
|
/**
|
|
42
14
|
* Compile parsed YAML or JSON into ordinary pipelines. Does not load modules,
|
|
43
15
|
* invoke handlers or schemas, or perform I/O. Graph validation belongs to core.
|
|
@@ -1,91 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { definePipeline, requireOutputs } from "../core/pipeline.js";
|
|
2
|
+
import { ProjectRegistryResolver } from "./project-registry.js";
|
|
3
|
+
import { compileDocumentSteps } from "./project-step-graph.js";
|
|
2
4
|
import { validatePipelineDocument, PipelineDocumentError, } from "./project-document.js";
|
|
3
5
|
export { PipelineDocumentError };
|
|
4
|
-
function resolve(registry, name, path) {
|
|
5
|
-
if (!registry || !Object.hasOwn(registry, name)) {
|
|
6
|
-
throw new PipelineDocumentError(path, `Unknown registered name ${JSON.stringify(name)}`);
|
|
7
|
-
}
|
|
8
|
-
return registry[name];
|
|
9
|
-
}
|
|
10
|
-
function handler(registry, name, path) {
|
|
11
|
-
const value = resolve(registry, name, path);
|
|
12
|
-
if (typeof value !== "function")
|
|
13
|
-
throw new PipelineDocumentError(path, "Expected a registered function");
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
|
-
function schema(registry, name, path) {
|
|
17
|
-
if (name === undefined)
|
|
18
|
-
return undefined;
|
|
19
|
-
const value = resolve(registry, name, path);
|
|
20
|
-
if (!value ||
|
|
21
|
-
value["~standard"]?.version !== 1 ||
|
|
22
|
-
typeof value["~standard"].validate !== "function") {
|
|
23
|
-
throw new PipelineDocumentError(path, "Expected a Standard Schema v1 schema");
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
function registeredObject(registry, name, path) {
|
|
28
|
-
const value = resolve(registry, name, path);
|
|
29
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
30
|
-
throw new PipelineDocumentError(path, "Expected a registered adapter object");
|
|
31
|
-
}
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
function fromPipelineAdapter(registry, name, path) {
|
|
35
|
-
const adapter = registeredObject(registry, name, path);
|
|
36
|
-
if (typeof adapter.mapOptions !== "function") {
|
|
37
|
-
throw new PipelineDocumentError(path, "Expected an adapter with mapOptions");
|
|
38
|
-
}
|
|
39
|
-
if (adapter.controls !== undefined &&
|
|
40
|
-
typeof adapter.controls !== "function" &&
|
|
41
|
-
(typeof adapter.controls !== "object" || adapter.controls === null)) {
|
|
42
|
-
throw new PipelineDocumentError(path, "Expected adapter controls to be an object or function");
|
|
43
|
-
}
|
|
44
|
-
if (adapter.mapResult !== undefined && typeof adapter.mapResult !== "function") {
|
|
45
|
-
throw new PipelineDocumentError(path, "Expected adapter mapResult to be a function");
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
controls: adapter.controls,
|
|
49
|
-
mapOptions: adapter.mapOptions,
|
|
50
|
-
mapResult: adapter.mapResult,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function forEachPipelineAdapter(registry, name, path) {
|
|
54
|
-
const adapter = registeredObject(registry, name, path);
|
|
55
|
-
if (typeof adapter.items !== "function" ||
|
|
56
|
-
typeof adapter.key !== "function" ||
|
|
57
|
-
typeof adapter.mapOptions !== "function") {
|
|
58
|
-
throw new PipelineDocumentError(path, "Expected an adapter with items, key, and mapOptions");
|
|
59
|
-
}
|
|
60
|
-
if (adapter.concurrency !== undefined &&
|
|
61
|
-
typeof adapter.concurrency !== "number" &&
|
|
62
|
-
typeof adapter.concurrency !== "function") {
|
|
63
|
-
throw new PipelineDocumentError(path, "Expected adapter concurrency to be a number or function");
|
|
64
|
-
}
|
|
65
|
-
if (adapter.controls !== undefined &&
|
|
66
|
-
typeof adapter.controls !== "function" &&
|
|
67
|
-
(typeof adapter.controls !== "object" || adapter.controls === null)) {
|
|
68
|
-
throw new PipelineDocumentError(path, "Expected adapter controls to be an object or function");
|
|
69
|
-
}
|
|
70
|
-
if (adapter.mapResult !== undefined && typeof adapter.mapResult !== "function") {
|
|
71
|
-
throw new PipelineDocumentError(path, "Expected adapter mapResult to be a function");
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
items: adapter.items,
|
|
75
|
-
key: adapter.key,
|
|
76
|
-
controls: adapter.controls,
|
|
77
|
-
concurrency: adapter.concurrency,
|
|
78
|
-
progress: adapter.progress,
|
|
79
|
-
mapOptions: adapter.mapOptions,
|
|
80
|
-
mapResult: adapter.mapResult,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
6
|
/**
|
|
84
7
|
* Compile parsed YAML or JSON into ordinary pipelines. Does not load modules,
|
|
85
8
|
* invoke handlers or schemas, or perform I/O. Graph validation belongs to core.
|
|
86
9
|
*/
|
|
87
10
|
export function compilePipelineDocument(document, registry) {
|
|
88
11
|
const parsed = validatePipelineDocument(document);
|
|
12
|
+
const resolvedRegistry = new ProjectRegistryResolver(registry);
|
|
89
13
|
const compiled = new Map();
|
|
90
14
|
const compiling = new Set();
|
|
91
15
|
const resolvePipeline = (id, path) => {
|
|
@@ -104,112 +28,19 @@ export function compilePipelineDocument(document, registry) {
|
|
|
104
28
|
const definition = parsed.pipelines[id];
|
|
105
29
|
const path = `$.pipelines[${JSON.stringify(id)}]`;
|
|
106
30
|
compiling.add(id);
|
|
107
|
-
const optionsSchema =
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const stepPath = `${path}.steps[${index}]`;
|
|
111
|
-
// Populate these arrays after all steps exist, allowing forward references
|
|
112
|
-
// and leaving cycle detection to the existing definition validator.
|
|
113
|
-
const dependsOn = [];
|
|
114
|
-
const optionalDependsOn = [];
|
|
115
|
-
const skipAfterFailureOf = [];
|
|
116
|
-
const dryRun = definition.dryRun === undefined || definition.dryRun === "skip"
|
|
117
|
-
? definition.dryRun
|
|
118
|
-
: handler(registry.steps, definition.dryRun.run, `${stepPath}.dryRun.run`);
|
|
119
|
-
const outputSchema = schema(registry.schemas, definition.outputSchema, `${stepPath}.outputSchema`);
|
|
120
|
-
const common = {
|
|
121
|
-
name: definition.name,
|
|
122
|
-
description: definition.description,
|
|
123
|
-
dependsOn,
|
|
124
|
-
optionalDependsOn,
|
|
125
|
-
skipAfterFailureOf,
|
|
126
|
-
};
|
|
127
|
-
const skip = definition.skip === undefined
|
|
128
|
-
? undefined
|
|
129
|
-
: handler(registry.skipPredicates ?? {}, definition.skip, `${stepPath}.skip`);
|
|
130
|
-
let built;
|
|
131
|
-
if (definition.run !== undefined) {
|
|
132
|
-
const config = {
|
|
133
|
-
...common,
|
|
134
|
-
dryRun,
|
|
135
|
-
run: handler(registry.steps, definition.run, `${stepPath}.run`),
|
|
136
|
-
skip,
|
|
137
|
-
};
|
|
138
|
-
built = outputSchema
|
|
139
|
-
? factory.step(definition.id, { ...config, outputSchema })
|
|
140
|
-
: factory.step(definition.id, config);
|
|
141
|
-
}
|
|
142
|
-
else if (definition.fromPipeline !== undefined) {
|
|
143
|
-
const reference = definition.fromPipeline;
|
|
144
|
-
const adapter = fromPipelineAdapter(registry.fromPipelineAdapters, reference.adapter, `${stepPath}.fromPipeline.adapter`);
|
|
145
|
-
const config = {
|
|
146
|
-
...common,
|
|
147
|
-
dryRun: definition.dryRun,
|
|
148
|
-
pipeline: resolvePipeline(reference.pipeline, `${stepPath}.fromPipeline.pipeline`),
|
|
149
|
-
controls: adapter.controls,
|
|
150
|
-
mapOptions: adapter.mapOptions,
|
|
151
|
-
skip,
|
|
152
|
-
};
|
|
153
|
-
built =
|
|
154
|
-
adapter.mapResult === undefined
|
|
155
|
-
? factory.fromPipeline(definition.id, config)
|
|
156
|
-
: factory.fromPipeline(definition.id, { ...config, mapResult: adapter.mapResult });
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
const reference = definition.forEachPipeline;
|
|
160
|
-
const adapter = forEachPipelineAdapter(registry.forEachPipelineAdapters, reference.adapter, `${stepPath}.forEachPipeline.adapter`);
|
|
161
|
-
// SAFETY: document pipelines publish unknown values. The fan-out builder
|
|
162
|
-
// still represents a valued skip as the complete unknown result array.
|
|
163
|
-
const fanOutSkip = skip;
|
|
164
|
-
const config = {
|
|
165
|
-
...common,
|
|
166
|
-
dryRun: definition.dryRun,
|
|
167
|
-
pipeline: resolvePipeline(reference.pipeline, `${stepPath}.forEachPipeline.pipeline`),
|
|
168
|
-
items: adapter.items,
|
|
169
|
-
key: adapter.key,
|
|
170
|
-
concurrency: adapter.concurrency,
|
|
171
|
-
controls: adapter.controls,
|
|
172
|
-
progress: adapter.progress,
|
|
173
|
-
mapOptions: adapter.mapOptions,
|
|
174
|
-
skip: fanOutSkip,
|
|
175
|
-
};
|
|
176
|
-
built =
|
|
177
|
-
adapter.mapResult === undefined
|
|
178
|
-
? factory.forEachPipeline(definition.id, config)
|
|
179
|
-
: factory.forEachPipeline(definition.id, { ...config, mapResult: adapter.mapResult });
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
definition,
|
|
183
|
-
path: stepPath,
|
|
184
|
-
dependsOn,
|
|
185
|
-
optionalDependsOn,
|
|
186
|
-
skipAfterFailureOf,
|
|
187
|
-
step: built,
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
const byId = new Map(entries.map((entry) => [entry.step.id, entry.step]));
|
|
191
|
-
const resolveSteps = (ids = [], fieldPath) => ids.map((stepId, index) => {
|
|
192
|
-
const found = byId.get(stepId);
|
|
193
|
-
if (!found)
|
|
194
|
-
throw new PipelineDocumentError(`${fieldPath}[${index}]`, `Unknown step ${JSON.stringify(stepId)}`);
|
|
195
|
-
return found;
|
|
196
|
-
});
|
|
197
|
-
for (const entry of entries) {
|
|
198
|
-
for (const field of ["dependsOn", "optionalDependsOn", "skipAfterFailureOf"]) {
|
|
199
|
-
entry[field].push(...resolveSteps(entry.definition[field], `${entry.path}.${field}`));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
const finalize = handler(registry.finalizers, definition.finalize.run, `${path}.finalize.run`);
|
|
31
|
+
const optionsSchema = resolvedRegistry.optionsSchema(definition.optionsSchema, `${path}.optionsSchema`);
|
|
32
|
+
const graph = compileDocumentSteps(definition.steps, optionsSchema, resolvedRegistry, resolvePipeline, path);
|
|
33
|
+
const finalize = resolvedRegistry.finalizer(definition.finalize.run, `${path}.finalize.run`);
|
|
203
34
|
const pipeline = definePipeline({
|
|
204
35
|
id,
|
|
205
36
|
name: definition.name,
|
|
206
37
|
description: definition.description,
|
|
207
|
-
steps:
|
|
208
|
-
targets:
|
|
209
|
-
resultSchema:
|
|
38
|
+
steps: graph.steps,
|
|
39
|
+
targets: graph.resolve(definition.targets, `${path}.targets`),
|
|
40
|
+
resultSchema: resolvedRegistry.outputSchema(definition.resultSchema, `${path}.resultSchema`),
|
|
210
41
|
finalize: definition.finalize.requireOutputs === undefined
|
|
211
42
|
? finalize
|
|
212
|
-
: requireOutputs(
|
|
43
|
+
: requireOutputs(graph.resolve(definition.finalize.requireOutputs, `${path}.finalize.requireOutputs`), finalize),
|
|
213
44
|
});
|
|
214
45
|
compiled.set(id, pipeline);
|
|
215
46
|
compiling.delete(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-compiler.js","sourceRoot":"","sources":["../../src/project/project-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,GASf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,E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AACL,CAAC","sourcesContent":["import {\n createSteps,\n definePipeline,\n requireOutputs,\n type MappedChildProgressOptions,\n type Pipeline,\n type PipelineExecutionContext,\n type PipelineRun,\n type PipelineRunControls,\n type PipelineStepContext,\n type StandardSchemaV1,\n type StepSkipDecision,\n} from \"../core/pipeline.js\";\nimport type { AnyStep } from \"../core/pipeline-steps.js\";\nimport {\n validatePipelineDocument,\n PipelineDocumentError,\n type PipelineDocumentMetadata,\n} from \"./project-document.js\";\n\nexport { PipelineDocumentError };\n\n/** Immutable compiled pipelines and descriptive metadata from a parsed document. */\nexport interface CompiledPipelineDocument {\n readonly pipelines: readonly Pipeline<object, unknown>[];\n readonly metadata?: PipelineDocumentMetadata;\n /** Return the shared compiled instance, or throw if the document has no such id. */\n get(id: string): Pipeline<object, unknown>;\n}\n\n/** Dependency values are checked at runtime rather than inferred from a project document. */\ntype PipelineDocumentHandler = (\n inputs: Record<string, unknown>,\n context: PipelineStepContext<object>\n) => unknown;\n\ntype PipelineDocumentFinalizer = (\n outputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n) => unknown;\n\ntype PipelineDocumentSkipPredicate = (\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n) => StepSkipDecision | Promise<StepSkipDecision>;\n\n/** Application-owned wiring for one declarative `fromPipeline` step. */\ninterface PipelineDocumentFromPipelineAdapter {\n controls?:\n | PipelineRunControls\n | ((\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n ) => PipelineRunControls);\n mapOptions(inputs: Record<string, unknown>, context: PipelineExecutionContext<object>): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n context: PipelineStepContext<object>\n ): unknown;\n}\n\n/** Application-owned wiring for one declarative `forEachPipeline` step. */\ninterface PipelineDocumentForEachPipelineAdapter {\n controls?:\n | PipelineRunControls\n | ((\n item: unknown,\n index: number,\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n ) => PipelineRunControls);\n items(\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n ): readonly unknown[] | Promise<readonly unknown[]>;\n key(item: unknown, index: number): string;\n concurrency?:\n | number\n | ((inputs: Record<string, unknown>, context: PipelineExecutionContext<object>) => number);\n progress?: MappedChildProgressOptions;\n mapOptions(\n item: unknown,\n index: number,\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n ): object;\n mapResult?(\n value: unknown,\n result: PipelineRun<unknown>,\n item: unknown,\n index: number,\n context: PipelineStepContext<object>\n ): unknown;\n}\n\n/** Only explicitly registered functions and schemas can be referenced by a document. */\nexport interface ProjectRegistry {\n steps: Readonly<Record<string, PipelineDocumentHandler>>;\n finalizers: Readonly<Record<string, PipelineDocumentFinalizer>>;\n skipPredicates?: Readonly<Record<string, PipelineDocumentSkipPredicate>>;\n fromPipelineAdapters?: Readonly<Record<string, PipelineDocumentFromPipelineAdapter>>;\n forEachPipelineAdapters?: Readonly<Record<string, PipelineDocumentForEachPipelineAdapter>>;\n optionsSchemas?: Readonly<Record<string, StandardSchemaV1<object, object>>>;\n schemas?: Readonly<Record<string, StandardSchemaV1>>;\n}\n\nfunction resolve<T>(\n registry: Readonly<Record<string, T>> | undefined,\n name: string,\n path: string\n): T {\n if (!registry || !Object.hasOwn(registry, name)) {\n throw new PipelineDocumentError(path, `Unknown registered name ${JSON.stringify(name)}`);\n }\n return registry[name];\n}\n\nfunction handler<T extends PipelineDocumentHandler | PipelineDocumentFinalizer>(\n registry: Readonly<Record<string, T>>,\n name: string,\n path: string\n): T {\n const value = resolve(registry, name, path);\n if (typeof value !== \"function\")\n throw new PipelineDocumentError(path, \"Expected a registered function\");\n return value;\n}\n\nfunction schema<T extends StandardSchemaV1>(\n registry: Readonly<Record<string, T>> | undefined,\n name: string | undefined,\n path: string\n): T | undefined {\n if (name === undefined) return undefined;\n const value = resolve(registry, name, path);\n if (\n !value ||\n value[\"~standard\"]?.version !== 1 ||\n typeof value[\"~standard\"].validate !== \"function\"\n ) {\n throw new PipelineDocumentError(path, \"Expected a Standard Schema v1 schema\");\n }\n return value;\n}\n\nfunction registeredObject<T extends object>(\n registry: Readonly<Record<string, T>> | undefined,\n name: string,\n path: string\n): T {\n const value = resolve(registry, name, path);\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new PipelineDocumentError(path, \"Expected a registered adapter object\");\n }\n return value;\n}\n\nfunction fromPipelineAdapter(\n registry: ProjectRegistry[\"fromPipelineAdapters\"],\n name: string,\n path: string\n): PipelineDocumentFromPipelineAdapter {\n const adapter = registeredObject(registry, name, path);\n if (typeof adapter.mapOptions !== \"function\") {\n throw new PipelineDocumentError(path, \"Expected an adapter with mapOptions\");\n }\n if (\n adapter.controls !== undefined &&\n typeof adapter.controls !== \"function\" &&\n (typeof adapter.controls !== \"object\" || adapter.controls === null)\n ) {\n throw new PipelineDocumentError(path, \"Expected adapter controls to be an object or function\");\n }\n if (adapter.mapResult !== undefined && typeof adapter.mapResult !== \"function\") {\n throw new PipelineDocumentError(path, \"Expected adapter mapResult to be a function\");\n }\n return {\n controls: adapter.controls,\n mapOptions: adapter.mapOptions,\n mapResult: adapter.mapResult,\n };\n}\n\nfunction forEachPipelineAdapter(\n registry: ProjectRegistry[\"forEachPipelineAdapters\"],\n name: string,\n path: string\n): PipelineDocumentForEachPipelineAdapter {\n const adapter = registeredObject(registry, name, path);\n if (\n typeof adapter.items !== \"function\" ||\n typeof adapter.key !== \"function\" ||\n typeof adapter.mapOptions !== \"function\"\n ) {\n throw new PipelineDocumentError(path, \"Expected an adapter with items, key, and mapOptions\");\n }\n if (\n adapter.concurrency !== undefined &&\n typeof adapter.concurrency !== \"number\" &&\n typeof adapter.concurrency !== \"function\"\n ) {\n throw new PipelineDocumentError(\n path,\n \"Expected adapter concurrency to be a number or function\"\n );\n }\n if (\n adapter.controls !== undefined &&\n typeof adapter.controls !== \"function\" &&\n (typeof adapter.controls !== \"object\" || adapter.controls === null)\n ) {\n throw new PipelineDocumentError(path, \"Expected adapter controls to be an object or function\");\n }\n if (adapter.mapResult !== undefined && typeof adapter.mapResult !== \"function\") {\n throw new PipelineDocumentError(path, \"Expected adapter mapResult to be a function\");\n }\n return {\n items: adapter.items,\n key: adapter.key,\n controls: adapter.controls,\n concurrency: adapter.concurrency,\n progress: adapter.progress,\n mapOptions: adapter.mapOptions,\n mapResult: adapter.mapResult,\n };\n}\n\n/**\n * Compile parsed YAML or JSON into ordinary pipelines. Does not load modules,\n * invoke handlers or schemas, or perform I/O. Graph validation belongs to core.\n */\nexport function compilePipelineDocument(\n document: unknown,\n registry: ProjectRegistry\n): CompiledPipelineDocument {\n const parsed = validatePipelineDocument(document);\n const compiled = new Map<string, Pipeline<object, unknown>>();\n const compiling = new Set<string>();\n\n const resolvePipeline = (id: string, path: string): Pipeline<object, unknown> => {\n if (!Object.hasOwn(parsed.pipelines, id)) {\n throw new PipelineDocumentError(path, `Unknown pipeline ${JSON.stringify(id)}`);\n }\n if (compiling.has(id)) {\n throw new PipelineDocumentError(\n path,\n `Pipeline composition cycle through ${JSON.stringify(id)}`\n );\n }\n return compile(id);\n };\n\n const compile = (id: string): Pipeline<object, unknown> => {\n const existing = compiled.get(id);\n if (existing) return existing;\n const definition = parsed.pipelines[id]!;\n const path = `$.pipelines[${JSON.stringify(id)}]`;\n compiling.add(id);\n const optionsSchema = schema(\n registry.optionsSchemas,\n definition.optionsSchema,\n `${path}.optionsSchema`\n );\n const factory = createSteps(optionsSchema);\n const entries = definition.steps.map((definition, index) => {\n const stepPath = `${path}.steps[${index}]`;\n // Populate these arrays after all steps exist, allowing forward references\n // and leaving cycle detection to the existing definition validator.\n const dependsOn: AnyStep[] = [];\n const optionalDependsOn: AnyStep[] = [];\n const skipAfterFailureOf: AnyStep[] = [];\n const dryRun =\n definition.dryRun === undefined || definition.dryRun === \"skip\"\n ? definition.dryRun\n : handler(registry.steps, definition.dryRun.run, `${stepPath}.dryRun.run`);\n const outputSchema = schema(\n registry.schemas,\n definition.outputSchema,\n `${stepPath}.outputSchema`\n );\n const common = {\n name: definition.name,\n description: definition.description,\n dependsOn,\n optionalDependsOn,\n skipAfterFailureOf,\n };\n const skip =\n definition.skip === undefined\n ? undefined\n : handler(registry.skipPredicates ?? {}, definition.skip, `${stepPath}.skip`);\n let built: AnyStep<object>;\n if (definition.run !== undefined) {\n const config = {\n ...common,\n dryRun,\n run: handler(registry.steps, definition.run, `${stepPath}.run`),\n skip,\n };\n built = outputSchema\n ? factory.step(definition.id, { ...config, outputSchema })\n : factory.step(definition.id, config);\n } else if (definition.fromPipeline !== undefined) {\n const reference = definition.fromPipeline;\n const adapter = fromPipelineAdapter(\n registry.fromPipelineAdapters,\n reference.adapter,\n `${stepPath}.fromPipeline.adapter`\n );\n const config = {\n ...common,\n dryRun: definition.dryRun,\n pipeline: resolvePipeline(reference.pipeline, `${stepPath}.fromPipeline.pipeline`),\n controls: adapter.controls,\n mapOptions: adapter.mapOptions,\n skip,\n };\n built =\n adapter.mapResult === undefined\n ? factory.fromPipeline(definition.id, config)\n : factory.fromPipeline(definition.id, { ...config, mapResult: adapter.mapResult });\n } else {\n const reference = definition.forEachPipeline;\n const adapter = forEachPipelineAdapter(\n registry.forEachPipelineAdapters,\n reference.adapter,\n `${stepPath}.forEachPipeline.adapter`\n );\n // SAFETY: document pipelines publish unknown values. The fan-out builder\n // still represents a valued skip as the complete unknown result array.\n const fanOutSkip = skip as\n | ((\n inputs: Record<string, unknown>,\n context: PipelineExecutionContext<object>\n ) =>\n | StepSkipDecision<readonly unknown[]>\n | Promise<StepSkipDecision<readonly unknown[]>>)\n | undefined;\n const config = {\n ...common,\n dryRun: definition.dryRun,\n pipeline: resolvePipeline(reference.pipeline, `${stepPath}.forEachPipeline.pipeline`),\n items: adapter.items,\n key: adapter.key,\n concurrency: adapter.concurrency,\n controls: adapter.controls,\n progress: adapter.progress,\n mapOptions: adapter.mapOptions,\n skip: fanOutSkip,\n };\n built =\n adapter.mapResult === undefined\n ? factory.forEachPipeline(definition.id, config)\n : factory.forEachPipeline(definition.id, { ...config, mapResult: adapter.mapResult });\n }\n return {\n definition,\n path: stepPath,\n dependsOn,\n optionalDependsOn,\n skipAfterFailureOf,\n step: built,\n };\n });\n const byId = new Map(entries.map((entry) => [entry.step.id, entry.step]));\n const resolveSteps = (ids: readonly string[] = [], fieldPath: string): AnyStep[] =>\n ids.map((stepId, index) => {\n const found = byId.get(stepId);\n if (!found)\n throw new PipelineDocumentError(\n `${fieldPath}[${index}]`,\n `Unknown step ${JSON.stringify(stepId)}`\n );\n return found;\n });\n for (const entry of entries) {\n for (const field of [\"dependsOn\", \"optionalDependsOn\", \"skipAfterFailureOf\"] as const) {\n entry[field].push(...resolveSteps(entry.definition[field], `${entry.path}.${field}`));\n }\n }\n const finalize = handler(registry.finalizers, definition.finalize.run, `${path}.finalize.run`);\n const pipeline = definePipeline({\n id,\n name: definition.name,\n description: definition.description,\n steps: entries.map((entry) => entry.step),\n targets: resolveSteps(definition.targets, `${path}.targets`),\n resultSchema: schema(registry.schemas, definition.resultSchema, `${path}.resultSchema`),\n finalize:\n definition.finalize.requireOutputs === undefined\n ? finalize\n : requireOutputs(\n resolveSteps(definition.finalize.requireOutputs, `${path}.finalize.requireOutputs`),\n finalize\n ),\n });\n compiled.set(id, pipeline);\n compiling.delete(id);\n return pipeline;\n };\n\n const pipelines = Object.freeze(Object.keys(parsed.pipelines).map(compile));\n const metadata =\n parsed.metadata === undefined\n ? undefined\n : Object.freeze({\n ...parsed.metadata,\n authors:\n parsed.metadata.authors === undefined\n ? undefined\n : Object.freeze([...parsed.metadata.authors]),\n });\n return Object.freeze({\n pipelines,\n ...(metadata === undefined ? {} : { metadata }),\n get(id: string): Pipeline<object, unknown> {\n const pipeline = compiled.get(id);\n if (!pipeline) {\n throw new Error(`Compiled document does not define pipeline ${JSON.stringify(id)}.`);\n }\n return pipeline;\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project-compiler.js","sourceRoot":"","sources":["../../src/project/project-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,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,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,MAAM,QAAQ,GACZ,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;YACZ,GAAG,MAAM,CAAC,QAAQ;YAClB,OAAO,EACL,MAAM,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS;gBACnC,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SAClD,CAAC,CAAC;IACT,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS;QACT,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC/C,GAAG,CAAC,EAAU;YACZ,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YACvF,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { definePipeline, requireOutputs, type Pipeline } from \"../core/pipeline.js\";\nimport { ProjectRegistryResolver, type ProjectRegistry } from \"./project-registry.js\";\nimport { compileDocumentSteps } from \"./project-step-graph.js\";\nimport {\n validatePipelineDocument,\n PipelineDocumentError,\n type PipelineDocumentMetadata,\n} from \"./project-document.js\";\n\nexport { PipelineDocumentError };\nexport type { ProjectRegistry } from \"./project-registry.js\";\n\n/** Immutable compiled pipelines and descriptive metadata from a parsed document. */\nexport interface CompiledPipelineDocument {\n readonly pipelines: readonly Pipeline<object, unknown>[];\n readonly metadata?: PipelineDocumentMetadata;\n /** Return the shared compiled instance, or throw if the document has no such id. */\n get(id: string): Pipeline<object, unknown>;\n}\n\n/**\n * Compile parsed YAML or JSON into ordinary pipelines. Does not load modules,\n * invoke handlers or schemas, or perform I/O. Graph validation belongs to core.\n */\nexport function compilePipelineDocument(\n document: unknown,\n registry: ProjectRegistry\n): CompiledPipelineDocument {\n const parsed = validatePipelineDocument(document);\n const resolvedRegistry = new ProjectRegistryResolver(registry);\n const compiled = new Map<string, Pipeline<object, unknown>>();\n const compiling = new Set<string>();\n\n const resolvePipeline = (id: string, path: string): Pipeline<object, unknown> => {\n if (!Object.hasOwn(parsed.pipelines, id)) {\n throw new PipelineDocumentError(path, `Unknown pipeline ${JSON.stringify(id)}`);\n }\n if (compiling.has(id)) {\n throw new PipelineDocumentError(\n path,\n `Pipeline composition cycle through ${JSON.stringify(id)}`\n );\n }\n return compile(id);\n };\n\n const compile = (id: string): Pipeline<object, unknown> => {\n const existing = compiled.get(id);\n if (existing) return existing;\n const definition = parsed.pipelines[id]!;\n const path = `$.pipelines[${JSON.stringify(id)}]`;\n compiling.add(id);\n const optionsSchema = resolvedRegistry.optionsSchema(\n definition.optionsSchema,\n `${path}.optionsSchema`\n );\n const graph = compileDocumentSteps(\n definition.steps,\n optionsSchema,\n resolvedRegistry,\n resolvePipeline,\n path\n );\n const finalize = resolvedRegistry.finalizer(definition.finalize.run, `${path}.finalize.run`);\n const pipeline = definePipeline({\n id,\n name: definition.name,\n description: definition.description,\n steps: graph.steps,\n targets: graph.resolve(definition.targets, `${path}.targets`),\n resultSchema: resolvedRegistry.outputSchema(definition.resultSchema, `${path}.resultSchema`),\n finalize:\n definition.finalize.requireOutputs === undefined\n ? finalize\n : requireOutputs(\n graph.resolve(definition.finalize.requireOutputs, `${path}.finalize.requireOutputs`),\n finalize\n ),\n });\n compiled.set(id, pipeline);\n compiling.delete(id);\n return pipeline;\n };\n\n const pipelines = Object.freeze(Object.keys(parsed.pipelines).map(compile));\n const metadata =\n parsed.metadata === undefined\n ? undefined\n : Object.freeze({\n ...parsed.metadata,\n authors:\n parsed.metadata.authors === undefined\n ? undefined\n : Object.freeze([...parsed.metadata.authors]),\n });\n return Object.freeze({\n pipelines,\n ...(metadata === undefined ? {} : { metadata }),\n get(id: string): Pipeline<object, unknown> {\n const pipeline = compiled.get(id);\n if (!pipeline) {\n throw new Error(`Compiled document does not define pipeline ${JSON.stringify(id)}.`);\n }\n return pipeline;\n },\n });\n}\n"]}
|