@sparkwing/sdk 0.0.0-stage → 0.68.3
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/README.md +187 -2
- package/dist/command.js +272 -0
- package/dist/command.js.map +1 -0
- package/dist/context.js +69 -0
- package/dist/context.js.map +1 -0
- package/dist/describe.js +70 -0
- package/dist/describe.js.map +1 -0
- package/dist/errors.js +88 -0
- package/dist/errors.js.map +1 -0
- package/dist/helpers/docker.js +267 -0
- package/dist/helpers/docker.js.map +1 -0
- package/dist/helpers/files.js +141 -0
- package/dist/helpers/files.js.map +1 -0
- package/dist/helpers/git.js +263 -0
- package/dist/helpers/git.js.map +1 -0
- package/dist/helpers/memo.js +29 -0
- package/dist/helpers/memo.js.map +1 -0
- package/dist/helpers/services.js +160 -0
- package/dist/helpers/services.js.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/json.js +27 -0
- package/dist/json.js.map +1 -0
- package/dist/log.js +42 -0
- package/dist/log.js.map +1 -0
- package/dist/main.js +69 -0
- package/dist/main.js.map +1 -0
- package/dist/plan-wire.js +2 -0
- package/dist/plan-wire.js.map +1 -0
- package/dist/plan.js +812 -0
- package/dist/plan.js.map +1 -0
- package/dist/protocol.js +209 -0
- package/dist/protocol.js.map +1 -0
- package/dist/routes.js +187 -0
- package/dist/routes.js.map +1 -0
- package/dist/runner.js +380 -0
- package/dist/runner.js.map +1 -0
- package/dist/scope.js +27 -0
- package/dist/scope.js.map +1 -0
- package/dist/step-state.js +53 -0
- package/dist/step-state.js.map +1 -0
- package/dist/transport.js +50 -0
- package/dist/transport.js.map +1 -0
- package/index.d.ts +390 -0
- package/native/win32-arm64/protocol.node +0 -0
- package/native/win32-arm64/verification.json +1 -0
- package/native/win32-x64/protocol.node +0 -0
- package/native/win32-x64/verification.json +1 -0
- package/package.json +47 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/** contract: Promise-compatible callbacks allow synchronous declarations and async work. */
|
|
2
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
/** contract: Args remain serialized strings; []string uses comma splitting, whitespace trimming and empty-item removal. */
|
|
4
|
+
export type Args = Readonly<Record<string, string>>;
|
|
5
|
+
/** contract: Omission preserves precedence; explicit zero never means unset. */
|
|
6
|
+
export interface ArgSpec { name: string; type: "string" | "bool" | "int" | "int64" | "float64" | "duration" | "[]string"; description?: string; short?: string; default?: string; required?: boolean; secret?: boolean; enum?: readonly string[]; }
|
|
7
|
+
/** safety: Describe declares names only; values are read lazily in bound processes. */
|
|
8
|
+
export interface SecretSpec { name: string; optional?: boolean; variable?: boolean; }
|
|
9
|
+
/** contract: Identity comes from hello, because process env can disagree with the claim. */
|
|
10
|
+
export interface RunnerInfo { readonly name: string; readonly type: string; readonly labels: readonly string[]; }
|
|
11
|
+
/** contract: Git facts come from the sealed invocation, not a fresh branch lookup. */
|
|
12
|
+
export interface GitInfo { readonly repo: string; readonly branch: string; readonly commit: string; readonly defaultBranch?: string; readonly repoURL?: string; }
|
|
13
|
+
/** contract: PR base and head facts remain fixed to the triggering event. */
|
|
14
|
+
export interface PullRequest { readonly number: number; readonly action?: string; readonly baseRef?: string; readonly baseSHA?: string; readonly headRef?: string; readonly headSHA?: string; }
|
|
15
|
+
/** contract: Trigger facts remain attached to retries of the same invocation. */
|
|
16
|
+
export interface Trigger { readonly source: string; readonly user?: string; readonly pullRequest?: PullRequest; }
|
|
17
|
+
/** contract: Planning uses the registered entrypoint and the invoked pipeline name separately. */
|
|
18
|
+
export interface RunContext { readonly id: string; readonly pipeline: string; readonly args: Args; readonly dryRun: boolean; readonly noMemo: boolean; readonly startedAt?: string; readonly runner: RunnerInfo; readonly git: Git; readonly trigger: Trigger; }
|
|
19
|
+
/** contract: Failure data supports recovery without parsing display text. */
|
|
20
|
+
export interface Failure { readonly job: string; readonly stage: string; readonly message: string; }
|
|
21
|
+
/** contract: Public outcomes use the same spelling as persisted results. */
|
|
22
|
+
export type Outcome = "success" | "failed" | "cancelled" | "skipped" | "superseded" | "memoized";
|
|
23
|
+
/** contract: Reasons preserve distinctions that do not warrant another outcome. */
|
|
24
|
+
export interface JobResult<T> { readonly outcome: Outcome; readonly reason?: string; readonly output?: T; readonly failure?: Failure; }
|
|
25
|
+
/** contract: Logs and annotations share level spelling. */
|
|
26
|
+
export type Level = "debug" | "info" | "warn" | "error";
|
|
27
|
+
/** contract: Structured attributes survive command and closure logging. */
|
|
28
|
+
export interface Logger { debug(message: string, attrs?: Record<string, unknown>): void; info(message: string, attrs?: Record<string, unknown>): void; warn(message: string, attrs?: Record<string, unknown>): void; error(message: string, attrs?: Record<string, unknown>): void; }
|
|
29
|
+
/** contract: File locations let consumers link a diagnostic to source. */
|
|
30
|
+
export interface Annotation { message: string; level?: Level; file?: string; line?: number; endLine?: number; column?: number; }
|
|
31
|
+
/** safety: Callers branch on code; unknown codes remain ordinary failures. */
|
|
32
|
+
export declare class SDKError extends Error { constructor(message: string, options?: { code: string; hint?: string; details?: Readonly<Record<string, unknown>> }); readonly code: string; readonly hint?: string; readonly details?: Readonly<Record<string, unknown>>; }
|
|
33
|
+
/** safety: Bound operations use the hello bearer in memory and never expose it here. */
|
|
34
|
+
export interface Context {
|
|
35
|
+
readonly run: RunContext;
|
|
36
|
+
readonly jobId: string;
|
|
37
|
+
readonly stepId?: string;
|
|
38
|
+
readonly args: Args;
|
|
39
|
+
readonly dryRun: boolean;
|
|
40
|
+
readonly runner: RunnerInfo;
|
|
41
|
+
readonly failure?: Failure;
|
|
42
|
+
readonly signal: AbortSignal;
|
|
43
|
+
readonly log: Logger;
|
|
44
|
+
/** safety: Undeclared reads fail; optional missing values return undefined. */
|
|
45
|
+
secret(name: string): Promise<string | undefined>;
|
|
46
|
+
variable(name: string): Promise<string | undefined>;
|
|
47
|
+
output<T>(job: Job<T> | string): Promise<T | undefined>;
|
|
48
|
+
stepOutput<T>(step: Step<T> | string): T | undefined;
|
|
49
|
+
annotate(annotation: Annotation): Promise<void>;
|
|
50
|
+
summary(markdown: string): Promise<void>;
|
|
51
|
+
/** safety: Resolution means the host registered the mask before subsequent logs. */
|
|
52
|
+
mask(value: string): Promise<void>;
|
|
53
|
+
oidcToken(audience: string): Promise<string>;
|
|
54
|
+
runPipeline<T, In extends object = Record<string, string | number | boolean | readonly string[]>>(pipeline: string, jobId: string, options?: ChildOptions<In>): Promise<T>;
|
|
55
|
+
latest<T>(reference: PipelineRef<T>): Promise<T>;
|
|
56
|
+
cleanup(spec: CleanupSpec): Promise<CleanupRegistration>;
|
|
57
|
+
exec(argv: readonly [string, ...string[]], options?: ExecOptions): Cmd;
|
|
58
|
+
bash(script: string, options?: ExecOptions): Cmd;
|
|
59
|
+
}
|
|
60
|
+
/** contract: Bodies return the job or step's JSON-serializable output. */
|
|
61
|
+
export type Body<T = unknown> = (ctx: Context) => Awaitable<T>;
|
|
62
|
+
/** contract: Predicates are eval closures and cannot alter topology. */
|
|
63
|
+
export type Predicate = (ctx: Context) => Awaitable<boolean>;
|
|
64
|
+
/** contract: Hooks participate in the host's ordered execution layers. */
|
|
65
|
+
export type Hook = (ctx: Context) => Awaitable<void>;
|
|
66
|
+
/** contract: Final hooks receive the attempt result even when its body failed. */
|
|
67
|
+
export type AfterRunFn = (ctx: Context, result: JobResult<unknown>) => Awaitable<void>;
|
|
68
|
+
/** contract: App retries retain the same claim and do not spend disruption allowance. */
|
|
69
|
+
export interface RetryOptions { backoffMs?: number; }
|
|
70
|
+
/** contract: Skip evaluation has a declared budget shared by every placement. */
|
|
71
|
+
export interface SkipOptions { budgetMs?: number; }
|
|
72
|
+
/** contract: Memo TTL is ceiling-checked at seal, never clamped. */
|
|
73
|
+
export interface MemoOptions { ttlMs?: number; }
|
|
74
|
+
/** contract: Scope is declarative; the host computes the actual coordination key. */
|
|
75
|
+
export type Scope = "run" | "box" | "global";
|
|
76
|
+
/** contract: Capacity behavior never implies result reuse. */
|
|
77
|
+
export type OnLimit = "queue" | "fail" | "skip" | "cancel_others";
|
|
78
|
+
/** contract: Optional fields distinguish inherited policy from explicit values. */
|
|
79
|
+
export interface ConcurrencyLimit { capacity?: number; scope?: Scope; onLimit?: OnLimit; queueTimeoutMs?: number; }
|
|
80
|
+
/** contract: One declaration lets all members share the same capacity policy. */
|
|
81
|
+
export declare class ConcurrencyGroup { constructor(name: string, limit?: ConcurrencyLimit); readonly name: string; readonly limit: Readonly<ConcurrencyLimit>; toString(): string; }
|
|
82
|
+
/** contract: Approval zero timeout preserves indefinite waits where the owner can wait. */
|
|
83
|
+
export interface ApprovalOptions { message?: string; timeoutMs?: number; onTimeout?: "fail" | "deny" | "approve"; }
|
|
84
|
+
/** contract: Approvals cannot declare concurrency groups; put them on the job after the approval. skipIf runs on the run's coordinator before requesting approval, holding no capacity, and true settles as skipped. */
|
|
85
|
+
export interface Approval { readonly id: string; skipIf(predicate: Predicate, options?: SkipOptions): this; needs(...jobs: readonly Dependency[]): this; needsIfPresent(...jobs: readonly Dependency[]): this; needsGenerated(...generators: readonly Generator<unknown>[]): this; optional(): this; continueOnError(): this; onFailure<T = unknown>(id: string, body: Body<T>): Job<T>; }
|
|
86
|
+
/** contract: Dependencies refer to declared jobs, approvals, groups or stable IDs. */
|
|
87
|
+
export type Dependency = Job<unknown> | Approval | JobGroup | string;
|
|
88
|
+
/** contract: Startup env is applied before interpreter initialization. */
|
|
89
|
+
export interface EnvOption { readonly phase: "startup"; }
|
|
90
|
+
/** safety: Startup values must not influence declarations; drift fails the attempt. */
|
|
91
|
+
export declare function startup(): EnvOption;
|
|
92
|
+
/** contract: Step policy is independent of optional job failure. */
|
|
93
|
+
export type FailurePolicy = "fail_fast" | "collect_all";
|
|
94
|
+
/** contract: Step handles retain output type across dependency reads. */
|
|
95
|
+
export declare class Step<T = unknown> {
|
|
96
|
+
private constructor();
|
|
97
|
+
readonly id: string;
|
|
98
|
+
needs(...steps: readonly (Step<unknown> | StepGroup | string)[]): this;
|
|
99
|
+
result(): this;
|
|
100
|
+
skipIf(predicate: Predicate): this;
|
|
101
|
+
finally(): this;
|
|
102
|
+
continueOnError(): this;
|
|
103
|
+
optional(): this;
|
|
104
|
+
dryRun(body: Body<T>): this;
|
|
105
|
+
safeWithoutDryRun(): this;
|
|
106
|
+
/** safety: Every host enforces risk labels before real work. */
|
|
107
|
+
risk(...labels: readonly string[]): this;
|
|
108
|
+
}
|
|
109
|
+
/** contract: Group dependencies expand to all members and modifiers apply to each member. */
|
|
110
|
+
export interface StepGroup {
|
|
111
|
+
readonly id: string;
|
|
112
|
+
readonly members: readonly Step<unknown>[];
|
|
113
|
+
needs(...steps: readonly (Step<unknown> | StepGroup | string)[]): this;
|
|
114
|
+
skipIf(predicate: Predicate): this;
|
|
115
|
+
}
|
|
116
|
+
/** contract: Display grouping can also name a set of job dependencies. */
|
|
117
|
+
export interface JobGroup {
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly members: readonly Job<unknown>[];
|
|
120
|
+
needs(...jobs: readonly Dependency[]): this;
|
|
121
|
+
needsIfPresent(...jobs: readonly Dependency[]): this;
|
|
122
|
+
needsGenerated(...generators: readonly Generator<unknown>[]): this;
|
|
123
|
+
retry(attempts: number, options?: RetryOptions): this;
|
|
124
|
+
timeout(ms: number): this;
|
|
125
|
+
noProgressTimeout(ms: number): this;
|
|
126
|
+
skipIf(predicate: Predicate, options?: SkipOptions): this;
|
|
127
|
+
beforeRun(hook: Hook): this;
|
|
128
|
+
verify(hook: Hook): this;
|
|
129
|
+
afterRun(hook: AfterRunFn): this;
|
|
130
|
+
memo(key: MemoInput | MemoKeyFn, options?: MemoOptions): this;
|
|
131
|
+
cache(...caches: readonly CacheSpec[]): this;
|
|
132
|
+
artifacts(...globs: readonly string[]): this;
|
|
133
|
+
consumes(producer: Job<unknown>, options?: { into?: string }): this;
|
|
134
|
+
concurrency(group: ConcurrencyGroup, cost?: number): this;
|
|
135
|
+
needsTools(...names: readonly string[]): this;
|
|
136
|
+
requires(...labels: readonly string[]): this;
|
|
137
|
+
prefers(...labels: readonly string[]): this;
|
|
138
|
+
inline(): this;
|
|
139
|
+
optional(): this;
|
|
140
|
+
continueOnError(): this;
|
|
141
|
+
env(name: string, value: string, option?: EnvOption): this;
|
|
142
|
+
}
|
|
143
|
+
/** contract: Output reads carry an explicit dependency or reference authorization edge. */
|
|
144
|
+
export interface Ref<T> {
|
|
145
|
+
readonly jobId: string;
|
|
146
|
+
get(ctx: Context): Promise<T>;
|
|
147
|
+
/** safety: Only genuine absence returns undefined; decode, transport and cancellation errors reject. */
|
|
148
|
+
tryGet(ctx: Context): Promise<T | undefined>;
|
|
149
|
+
}
|
|
150
|
+
/** contract: Latest references read successful verified default-branch runs unless fromAnyRun is set. */
|
|
151
|
+
export interface PipelineRef<T> extends Ref<T> { readonly pipeline: string; readonly jobId: string; readonly maxAgeMs?: number; readonly fromAnyRun?: boolean; }
|
|
152
|
+
/** contract: Max age bounds freshness; fromAnyRun permits output without verified default-branch provenance. */
|
|
153
|
+
export interface RefOptions { maxAgeMs?: number; fromAnyRun?: boolean; }
|
|
154
|
+
/** contract: A job output reference retains its declared result type. */
|
|
155
|
+
export declare function refTo<T>(job: Job<T>): Ref<T>;
|
|
156
|
+
/** contract: Declarative references let the host authorize cross-pipeline reads. */
|
|
157
|
+
export declare function refToLastRun<T>(pipeline: string, jobId: string, options?: RefOptions): PipelineRef<T>;
|
|
158
|
+
/** contract: Child inputs are explicit and are not inherited from the parent. */
|
|
159
|
+
export interface ChildOptions<In extends object = Record<string, string | number | boolean | readonly string[]>> {
|
|
160
|
+
args?: Args;
|
|
161
|
+
/** contract: Input property names are argument names; explicit args override overlapping inputs. */
|
|
162
|
+
inputs?: { readonly [K in keyof In]: In[K] extends string | number | boolean | readonly string[] ? In[K] : never };
|
|
163
|
+
/** contract: Omission inherits parent repo/SHA; an explicit repo selects fresh branch-tip source. */
|
|
164
|
+
repo?: string;
|
|
165
|
+
/** contract: Omission uses main for an explicit repo, otherwise the parent branch. */
|
|
166
|
+
branch?: string;
|
|
167
|
+
/** contract: Includes queue time; expiry stops waiting without cancelling the child. */
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
}
|
|
170
|
+
/** contract: Cleanup survives SDK process loss because the host records argv first. */
|
|
171
|
+
export interface CleanupSpec { argv: readonly [string, ...string[]]; description?: string; }
|
|
172
|
+
/** contract: Disarming removes a recorded cleanup after the resource was released. */
|
|
173
|
+
export interface CleanupRegistration { readonly id: string; unregister(): Promise<void>; }
|
|
174
|
+
/** contract: Exec inherits attempt env, including body env, without protocol credentials. */
|
|
175
|
+
export interface ExecOptions { cwd?: string; env?: Readonly<Record<string, string>>; }
|
|
176
|
+
/** contract: Command output and usage events share one execution helper. */
|
|
177
|
+
export interface ExecResult { readonly command: string; readonly stdout: string; readonly stderr: string; readonly exitCode: number; }
|
|
178
|
+
/** contract: Opaque cache descriptors prevent authors from selecting privileged ref scopes. */
|
|
179
|
+
export interface CacheSpec { readonly kind: "go_modules" | "npm" | "dir"; readonly path?: string; readonly keyFiles?: readonly string[]; }
|
|
180
|
+
/** contract: Go cache directories restore through the common depcache path. */
|
|
181
|
+
export declare function goModules(): CacheSpec;
|
|
182
|
+
/** contract: npm cache directories restore through the common depcache path. */
|
|
183
|
+
export declare function npm(): CacheSpec;
|
|
184
|
+
/** contract: Custom dependency files contribute to the directory cache key. */
|
|
185
|
+
export declare function dir(path: string, ...keyFiles: readonly string[]): CacheSpec;
|
|
186
|
+
/** contract: A memo miss sentinel keeps empty keys distinct from disabled reuse. */
|
|
187
|
+
export declare const noMemo: unique symbol;
|
|
188
|
+
/** contract: Author callbacks return JSON values for host hashing, or noMemo to bypass. */
|
|
189
|
+
export type MemoKeyFn = (ctx: Context) => Awaitable<unknown>;
|
|
190
|
+
/** contract: Built-in memo recipes are evaluated by the executing host. */
|
|
191
|
+
export type MemoInput =
|
|
192
|
+
| { readonly kind: "const"; readonly value: string }
|
|
193
|
+
| { readonly kind: "files" | "repo_files"; readonly patterns: readonly string[] }
|
|
194
|
+
| { readonly kind: "tree"; readonly root: string }
|
|
195
|
+
| { readonly kind: "env"; readonly names: readonly string[] }
|
|
196
|
+
| { readonly kind: "parts"; readonly parts: readonly unknown[] }
|
|
197
|
+
| { readonly kind: "compose"; readonly inputs: readonly MemoInput[] };
|
|
198
|
+
/** contract: Excludes matching tracked paths. */
|
|
199
|
+
export interface RepoFilesOption {
|
|
200
|
+
readonly ignore: readonly string[];
|
|
201
|
+
}
|
|
202
|
+
/** contract: Basenames match anywhere, trailing slashes match a root prefix, and ** spans segments. */
|
|
203
|
+
export declare function ignore(...patterns: readonly string[]): RepoFilesOption;
|
|
204
|
+
/** contract: Matching tracked files contribute to host-computed memo identity. */
|
|
205
|
+
export declare function files(...globs: readonly string[]): MemoInput;
|
|
206
|
+
/** contract: The effective job environment distinguishes unset from empty. */
|
|
207
|
+
export declare function env(...names: readonly string[]): MemoInput;
|
|
208
|
+
/** contract: Declares ordered JSON values for host hashing. */
|
|
209
|
+
export declare function parts(...values: readonly unknown[]): MemoInput;
|
|
210
|
+
/** contract: Declares a nonempty literal string, validated by the host. */
|
|
211
|
+
export declare function constant(value: string): MemoInput;
|
|
212
|
+
/** contract: Regular files contribute recursively inside the checkout, skipping symlinks; missing roots fail on the host. */
|
|
213
|
+
export declare function tree(path: string): MemoInput;
|
|
214
|
+
/** contract: Repository-relative selection includes all tracked files except declared exclusions. */
|
|
215
|
+
export declare function repoFiles(...options: readonly RepoFilesOption[]): MemoInput;
|
|
216
|
+
/** contract: Combines input recipes in order. */
|
|
217
|
+
export declare function compose(...inputs: readonly MemoInput[]): MemoInput;
|
|
218
|
+
/** contract: Collects ordered JSON parts for host hashing. */
|
|
219
|
+
export declare function memoKey(...parts: readonly unknown[]): readonly unknown[] | typeof noMemo;
|
|
220
|
+
/** contract: Generated topology is accepted once; replay only reconstructs code. */
|
|
221
|
+
export type GenerateFn<T> = (generated: Generated, output: T, ctx: Context) => Awaitable<void>;
|
|
222
|
+
/** contract: A generator handle names the settlement barrier consumed by dependencies. */
|
|
223
|
+
export interface Generator<T> { readonly id: string; readonly source: Job<T>; }
|
|
224
|
+
/** contract: Generated jobs use the same declaration surface and validator as static jobs. */
|
|
225
|
+
export interface Generated { job<T = unknown>(id: string, body?: Body<T>): Job<T>; approval(id: string, options?: ApprovalOptions): Approval; groupJobs(id: string, ...jobs: readonly Job<unknown>[]): JobGroup; }
|
|
226
|
+
/** contract: Jobs declare execution policy; hosts own placement, validation and persistence. */
|
|
227
|
+
export declare class Job<T = unknown> {
|
|
228
|
+
private constructor();
|
|
229
|
+
readonly id: string;
|
|
230
|
+
needs(...jobs: readonly Dependency[]): this;
|
|
231
|
+
needsIfPresent(...jobs: readonly Dependency[]): this;
|
|
232
|
+
needsGenerated(...generators: readonly Generator<unknown>[]): this;
|
|
233
|
+
references(...refs: readonly PipelineRef<unknown>[]): this;
|
|
234
|
+
withArgs(...args: readonly ArgSpec[]): this;
|
|
235
|
+
/** Declare child pipelines in the parent repository. Calls append targets. */
|
|
236
|
+
startsChildren(...pipelines: readonly string[]): this;
|
|
237
|
+
/** Declare child pipelines using a canonical repository key, such as gh:123. */
|
|
238
|
+
startsChildrenIn(repository: string, ...pipelines: readonly string[]): this;
|
|
239
|
+
step<U = unknown>(id: string, body: Body<U>): Step<U>;
|
|
240
|
+
groupSteps(id: string, ...steps: readonly Step<unknown>[]): StepGroup;
|
|
241
|
+
failurePolicy(policy: FailurePolicy): this;
|
|
242
|
+
retry(attempts: number, options?: RetryOptions): this;
|
|
243
|
+
timeout(ms: number): this;
|
|
244
|
+
noProgressTimeout(ms: number): this;
|
|
245
|
+
skipIf(predicate: Predicate, options?: SkipOptions): this;
|
|
246
|
+
beforeRun(hook: Hook): this;
|
|
247
|
+
verify(hook: Hook): this;
|
|
248
|
+
afterRun(hook: AfterRunFn): this;
|
|
249
|
+
memo(key: MemoInput | MemoKeyFn, options?: MemoOptions): this;
|
|
250
|
+
cache(...caches: readonly CacheSpec[]): this;
|
|
251
|
+
artifacts(...globs: readonly string[]): this;
|
|
252
|
+
consumes(producer: Dependency, options?: { into?: string }): this;
|
|
253
|
+
onFailure<U = unknown>(id: string, body: Body<U>): Job<U>;
|
|
254
|
+
concurrency(group: ConcurrencyGroup, cost?: number): this;
|
|
255
|
+
needsTools(...names: readonly string[]): this;
|
|
256
|
+
requires(...labels: readonly string[]): this;
|
|
257
|
+
prefers(...labels: readonly string[]): this;
|
|
258
|
+
inline(): this;
|
|
259
|
+
optional(): this;
|
|
260
|
+
continueOnError(): this;
|
|
261
|
+
env(name: string, value: string, option?: EnvOption): this;
|
|
262
|
+
generate(fn: GenerateFn<T>): Generator<T>;
|
|
263
|
+
}
|
|
264
|
+
/** contract: Checkout omission inherits source policy; fullHistory requests all history explicitly. */
|
|
265
|
+
export interface Checkout { depth?: number; fullHistory?: boolean; tags?: boolean; submodules?: boolean; lfs?: boolean; }
|
|
266
|
+
/** contract: Plan knobs are SDK-owned inputs resolved at the second seal point. */
|
|
267
|
+
export declare class Plan {
|
|
268
|
+
constructor();
|
|
269
|
+
job<T = unknown>(id: string, body?: Body<T>): Job<T>;
|
|
270
|
+
approval(id: string, options?: ApprovalOptions): Approval;
|
|
271
|
+
groupJobs(id: string, ...jobs: readonly Job<unknown>[]): JobGroup;
|
|
272
|
+
concurrency(group: ConcurrencyGroup, cost?: number): this;
|
|
273
|
+
priority(value: number): this;
|
|
274
|
+
claimWait(ms: number): this;
|
|
275
|
+
admissionClass(value: string): this;
|
|
276
|
+
checkout(options: Checkout): this;
|
|
277
|
+
}
|
|
278
|
+
/** contract: Names and secret declarations belong to describe, separate from plan documents. */
|
|
279
|
+
export interface PipelineDef { name: string; description?: string; short?: string; help?: string; examples?: readonly UsageExample[]; envVars?: readonly EnvironmentDescription[]; extra?: boolean; args?: readonly ArgSpec[]; secrets?: readonly SecretSpec[]; plan(plan: Plan, run: RunContext): Awaitable<void>; }
|
|
280
|
+
/** contract: Registration exposes one entrypoint for host-side YAML alias resolution. */
|
|
281
|
+
export declare function definePipeline(definition: PipelineDef): PipelineDef;
|
|
282
|
+
/** safety: Main negotiates hello before handling any operation or opening bound routes. */
|
|
283
|
+
export declare function main(): Promise<void>;
|
|
284
|
+
|
|
285
|
+
/** contract: Help examples preserve command text and its reason for running. */
|
|
286
|
+
export interface UsageExample { command: string; comment?: string; }
|
|
287
|
+
/** contract: Environment metadata documents author inputs, never transport credentials. */
|
|
288
|
+
export interface EnvironmentDescription { name: string; description?: string; default?: string; }
|
|
289
|
+
/** contract: Failed launch and signal termination both use -1, distinguished by ExecError.terminated. */
|
|
290
|
+
export declare const exitNotStarted: -1;
|
|
291
|
+
/** contract: Command failure preserves output and termination cause for diagnostics. */
|
|
292
|
+
export declare class ExecError extends Error { constructor(result: ExecResult, terminated?: "" | "cancellation" | "signal", cause?: unknown); readonly command: string; readonly stdout: string; readonly stderr: string; readonly exitCode: number; readonly cause?: unknown; readonly terminated: "" | "cancellation" | "signal"; }
|
|
293
|
+
/** contract: A command executes only when a result method is called. */
|
|
294
|
+
export interface Cmd {
|
|
295
|
+
dir(path: string): this;
|
|
296
|
+
env(name: string, value: string): this;
|
|
297
|
+
envMap(values: Readonly<Record<string, string>>): this;
|
|
298
|
+
run(): Promise<ExecResult>;
|
|
299
|
+
capture(): Promise<ExecResult>;
|
|
300
|
+
string(): Promise<string>;
|
|
301
|
+
lines(): Promise<string[]>;
|
|
302
|
+
json<T = unknown>(): Promise<T>;
|
|
303
|
+
mustBeEmpty(reason: string): Promise<void>;
|
|
304
|
+
}
|
|
305
|
+
/** contract: Root-relative paths match command cwd and file helper resolution. */
|
|
306
|
+
export declare function workDir(): string;
|
|
307
|
+
/** contract: Absolute-first joins work even without a discovered project. */
|
|
308
|
+
export declare function path(...parts: readonly string[]): string;
|
|
309
|
+
/** contract: Relative reads use the pipeline root rather than a command's temporary cwd. */
|
|
310
|
+
export declare function readFile(path: string): Promise<Uint8Array>;
|
|
311
|
+
/** contract: Writes create or truncate with mode 0644, matching the Go helper. */
|
|
312
|
+
export declare function writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
313
|
+
/** contract: Glob returns absolute matches for *, ? and character classes, without recursive **. */
|
|
314
|
+
export declare function glob(pattern: string): Promise<string[]>;
|
|
315
|
+
/** contract: Missing project roots are distinguishable from ordinary filesystem errors. */
|
|
316
|
+
export declare class NoProjectError extends Error {}
|
|
317
|
+
/** contract: Git snapshots stay sealed while live methods inspect the current working tree. */
|
|
318
|
+
export declare class Git implements GitInfo {
|
|
319
|
+
constructor(workDir: string, facts: GitInfo);
|
|
320
|
+
readonly repo: string; readonly branch: string; readonly commit: string;
|
|
321
|
+
readonly defaultBranch?: string; readonly repoURL?: string;
|
|
322
|
+
workDir(): string;
|
|
323
|
+
shortSHA(): string;
|
|
324
|
+
name(): string;
|
|
325
|
+
isDirty(ctx: Context): Promise<boolean>;
|
|
326
|
+
filesetHash(ctx: Context): Promise<string>;
|
|
327
|
+
changedFiles(ctx: Context, since: string): Promise<string[]>;
|
|
328
|
+
tagsAtHead(ctx: Context): Promise<string[]>;
|
|
329
|
+
latestTag(ctx: Context, prefix: string): Promise<string>;
|
|
330
|
+
pushTag(ctx: Context, tag: string, message: string): Promise<void>;
|
|
331
|
+
}
|
|
332
|
+
/** contract: Explicit tree discovery supports author-owned sibling checkouts. */
|
|
333
|
+
export declare function gitFromTree(ctx: Context, workDir: string): Promise<Git>;
|
|
334
|
+
/** contract: Slug parsing keeps owner/repo handling identical across helper packages. */
|
|
335
|
+
export declare function githubOwnerRepo(slug: string): { owner: string; repo: string };
|
|
336
|
+
/** contract: Git helpers use promptless direct git and never probe a removed cache service. */
|
|
337
|
+
export declare namespace git {
|
|
338
|
+
interface CloneOptions { depth?: number; }
|
|
339
|
+
function clone(ctx: Context, url: string, destDir: string, options?: CloneOptions): Promise<void>;
|
|
340
|
+
function fetch(ctx: Context, repoDir: string): Promise<void>;
|
|
341
|
+
function shortCommit(ctx: Context, repoDir: string): Promise<string>;
|
|
342
|
+
function currentSHA(ctx: Context, repoDir: string): Promise<string>;
|
|
343
|
+
function currentBranch(ctx: Context, repoDir: string): Promise<string>;
|
|
344
|
+
function defaultBranch(ctx: Context, repoDir: string): Promise<string>;
|
|
345
|
+
function remoteOriginURL(ctx: Context, repoDir: string): Promise<string>;
|
|
346
|
+
function isDirty(ctx: Context, repoDir: string): Promise<boolean>;
|
|
347
|
+
function filesetHash(ctx: Context, repoDir: string): Promise<string>;
|
|
348
|
+
function changedFiles(ctx: Context, repoDir: string, since: string): Promise<string[]>;
|
|
349
|
+
function tagsAtHead(ctx: Context, repoDir: string): Promise<string[]>;
|
|
350
|
+
function latestTag(ctx: Context, repoDir: string, prefix: string): Promise<string>;
|
|
351
|
+
function tagExistsOnRemote(ctx: Context, repoDir: string, tag: string): Promise<boolean>;
|
|
352
|
+
function pushTag(ctx: Context, repoDir: string, tag: string, message: string): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
/** contract: Docker helpers retain CLI behavior and host-registered cleanup under DinD. */
|
|
355
|
+
export declare namespace docker {
|
|
356
|
+
interface BuildConfig { image: string; dockerfile?: string; context?: string; platforms?: readonly string[]; registries?: readonly string[]; tags: readonly string[]; buildArgs?: Readonly<Record<string, string>>; labels?: Readonly<Record<string, string>>; }
|
|
357
|
+
interface BuildResult { readonly image: string; readonly digests: Readonly<Record<string, string>>; readonly registries: readonly string[]; }
|
|
358
|
+
interface RunOptions { image: string; cmd?: readonly string[]; workDir?: string; env?: Readonly<Record<string, string>>; user?: string; inputDir?: string; outputDir?: string; outputTo?: string; volumes?: Readonly<Record<string, string>>; stdout?: (bytes: Uint8Array) => void; stderr?: (bytes: Uint8Array) => void; }
|
|
359
|
+
interface ImageTag { readonly commit: string; readonly content: string; readonly branch: string; readonly dirty: boolean; deployTag(): string; prodTag(): string; all(): string[]; }
|
|
360
|
+
class DockerUnavailableError extends Error {}
|
|
361
|
+
class BuildxRequiredError extends Error {}
|
|
362
|
+
class PlatformUnsupportedError extends Error {}
|
|
363
|
+
function build(ctx: Context, config: BuildConfig): Promise<BuildResult>;
|
|
364
|
+
function buildAndPush(ctx: Context, config: BuildConfig): Promise<BuildResult>;
|
|
365
|
+
function push(ctx: Context, image: string, tags: readonly string[], registries: readonly string[]): Promise<void>;
|
|
366
|
+
function login(ctx: Context, registry: string, username: string, secret: string): Promise<void>;
|
|
367
|
+
function buildxPlatforms(ctx: Context): Promise<string[]>;
|
|
368
|
+
function filterBuildxPlatforms(ctx: Context, wish: readonly string[]): Promise<string[]>;
|
|
369
|
+
function run(ctx: Context, options: RunOptions): Promise<void>;
|
|
370
|
+
function computeTags(ctx: Context): Promise<ImageTag>;
|
|
371
|
+
function computeTagsIn(ctx: Context, repoDir: string): Promise<ImageTag>;
|
|
372
|
+
}
|
|
373
|
+
/** contract: Service scopes tear down owned containers on success, failure and cancellation. */
|
|
374
|
+
export declare namespace services {
|
|
375
|
+
const autoPort: -1;
|
|
376
|
+
const defaultReadyTimeoutMs: 30000;
|
|
377
|
+
interface Service { image: string; name?: string; port?: number; hostPort?: number; env?: Readonly<Record<string, string>>; readyCmd?: string; readyTimeoutMs?: number; }
|
|
378
|
+
interface Addr { readonly name: string; readonly hostPort: number; }
|
|
379
|
+
function withServices(ctx: Context, specs: readonly Service[], fn: (ctx: Context) => Awaitable<void>): Promise<void>;
|
|
380
|
+
function withServicesAddrs(ctx: Context, specs: readonly Service[], fn: (ctx: Context, addrs: readonly Addr[]) => Awaitable<void>): Promise<void>;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** contract: Context-level command env is inherited until explicit command options override it. */
|
|
384
|
+
export declare function withCommandEnv(ctx: Context, env: Readonly<Record<string, string>>): Context;
|
|
385
|
+
/** contract: Input errors distinguish invalid author arguments from execution failures. */
|
|
386
|
+
export declare class InputError extends Error { constructor(cause: unknown); readonly cause: unknown; }
|
|
387
|
+
/** contract: Verification errors preserve postcondition failure classification. */
|
|
388
|
+
export declare class VerifyError extends Error { constructor(cause: unknown); readonly cause: unknown; }
|
|
389
|
+
/** contract: Step errors preserve the failing step and its underlying failure. */
|
|
390
|
+
export declare class StepError extends Error { constructor(stepId: string, cause: unknown); readonly stepId: string; readonly cause: unknown; }
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"platform":"win32","arch":"arm64","version":"0.68.3","node":"v22.18.0","tests":["TestNativeProtocol","TestNativeConformance"],"source":"34c016b5ab7d0b993f3d5e9992451feba8f78c099dc7a4c992208bda8e7930fb","sha256":"09c6281e0f89c96307b424515a3306a6ce9d78cf22add894c7fb8b13f2c6ecc0"}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"platform":"win32","arch":"x64","version":"0.68.3","node":"v22.18.0","tests":["TestNativeProtocol","TestNativeConformance"],"source":"34c016b5ab7d0b993f3d5e9992451feba8f78c099dc7a4c992208bda8e7930fb","sha256":"39f3afda68e6605f851ac7f8d8cae4df1ebcbf0209d425821d5b461a2bd2791e"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkwing/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.68.3",
|
|
4
|
+
"description": "TypeScript SDK for Sparkwing pipelines",
|
|
5
|
+
"license": "Elastic-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/sparkwing-dev/sparkwing.git",
|
|
9
|
+
"directory": "sdk/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.18"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test \"test/**/*.test.ts\" \"test/**/*.test.mjs\"",
|
|
23
|
+
"test:native": "go test -p 4 ./test/nativehost -run TestNative",
|
|
24
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"prepack": "npm run build && node native/check-package.mjs",
|
|
27
|
+
"release:native": "node native/release.mjs bridge",
|
|
28
|
+
"pack:local": "node native/release.mjs local-pack",
|
|
29
|
+
"release:pack": "node native/release.mjs pack"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"typescript": "^5.8.0"
|
|
34
|
+
},
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"index.d.ts",
|
|
40
|
+
"README.md",
|
|
41
|
+
"native/win32-x64/protocol.node",
|
|
42
|
+
"native/win32-arm64/protocol.node",
|
|
43
|
+
"native/win32-x64/verification.json",
|
|
44
|
+
"native/win32-arm64/verification.json"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|