@giveitsmaller/sdk 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_audit.js +67 -0
- package/dist/builder.d.ts +406 -0
- package/dist/builder.js +706 -0
- package/dist/client.d.ts +96 -2
- package/dist/client.js +968 -33
- package/dist/credentials.d.ts +61 -0
- package/dist/credentials.js +200 -0
- package/dist/ergonomic/preset_resolver.d.ts +75 -0
- package/dist/ergonomic/preset_resolver.js +568 -0
- package/dist/ergonomic/presets/_translate.d.ts +11 -0
- package/dist/ergonomic/presets/_translate.js +35 -0
- package/dist/ergonomic/presets/audio_compress.d.ts +16 -0
- package/dist/ergonomic/presets/audio_compress.js +45 -0
- package/dist/ergonomic/presets/document_epub_compress.d.ts +14 -0
- package/dist/ergonomic/presets/document_epub_compress.js +34 -0
- package/dist/ergonomic/presets/document_odf_compress.d.ts +14 -0
- package/dist/ergonomic/presets/document_odf_compress.js +34 -0
- package/dist/ergonomic/presets/document_office_compress.d.ts +16 -0
- package/dist/ergonomic/presets/document_office_compress.js +40 -0
- package/dist/ergonomic/presets/document_pdf_compress.d.ts +14 -0
- package/dist/ergonomic/presets/document_pdf_compress.js +35 -0
- package/dist/ergonomic/presets/image_compress.d.ts +43 -0
- package/dist/ergonomic/presets/image_compress.js +95 -0
- package/dist/ergonomic/presets/index.d.ts +77 -0
- package/dist/ergonomic/presets/index.js +216 -0
- package/dist/ergonomic/presets/video_compress.d.ts +30 -0
- package/dist/ergonomic/presets/video_compress.js +83 -0
- package/dist/errors.d.ts +251 -1
- package/dist/errors.js +268 -0
- package/dist/generated/sdk_spec/enums.d.ts +195 -0
- package/dist/generated/sdk_spec/enums.js +127 -0
- package/dist/generated/sdk_spec/errors.d.ts +16 -0
- package/dist/generated/sdk_spec/errors.js +473 -0
- package/dist/generated/sdk_spec/index.d.ts +4 -0
- package/dist/generated/sdk_spec/index.js +7 -0
- package/dist/generated/sdk_spec/presets.d.ts +6 -0
- package/dist/generated/sdk_spec/presets.js +157 -0
- package/dist/generated/sdk_spec/version.d.ts +3 -0
- package/dist/generated/sdk_spec/version.js +6 -0
- package/dist/gisl.d.ts +112 -0
- package/dist/gisl.js +266 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.js +33 -3
- package/dist/merge.d.ts +142 -0
- package/dist/merge.js +411 -0
- package/dist/sse.d.ts +20 -1
- package/dist/sse.js +62 -3
- package/dist/types.d.ts +144 -14
- package/dist/types.js +18 -0
- package/package.json +2 -2
package/dist/_audit.js
CHANGED
|
@@ -54,4 +54,71 @@ export function _runAudit() {
|
|
|
54
54
|
accept();
|
|
55
55
|
accept();
|
|
56
56
|
accept();
|
|
57
|
+
accept();
|
|
58
|
+
accept();
|
|
59
|
+
// SDK-3 (Wb6ebOMM) public-API surface for the 3 resume-support endpoints.
|
|
60
|
+
accept();
|
|
61
|
+
accept();
|
|
62
|
+
accept();
|
|
63
|
+
accept();
|
|
64
|
+
accept();
|
|
65
|
+
accept();
|
|
66
|
+
// T1 / wVU4xHx3 — ergonomic-layer entry points.
|
|
67
|
+
accept();
|
|
68
|
+
accept();
|
|
69
|
+
// T2 / xVDTIm8C — operation-builder surface.
|
|
70
|
+
accept();
|
|
71
|
+
accept();
|
|
72
|
+
accept();
|
|
73
|
+
accept();
|
|
74
|
+
accept();
|
|
75
|
+
accept();
|
|
76
|
+
accept();
|
|
77
|
+
// T3 / cuecCmb5 — merge-compose surface.
|
|
78
|
+
accept();
|
|
79
|
+
accept();
|
|
80
|
+
accept();
|
|
81
|
+
accept();
|
|
82
|
+
accept();
|
|
83
|
+
accept();
|
|
84
|
+
// T6 / aDR1jnyZ — fan-out surface.
|
|
85
|
+
accept();
|
|
86
|
+
// T4a / VhIj4S7T — preset-defaults surface.
|
|
87
|
+
accept();
|
|
88
|
+
accept();
|
|
89
|
+
accept();
|
|
90
|
+
accept();
|
|
91
|
+
accept();
|
|
92
|
+
accept();
|
|
93
|
+
accept();
|
|
94
|
+
accept();
|
|
95
|
+
accept();
|
|
96
|
+
accept();
|
|
97
|
+
accept();
|
|
98
|
+
accept();
|
|
99
|
+
accept();
|
|
100
|
+
accept();
|
|
101
|
+
accept();
|
|
102
|
+
accept();
|
|
103
|
+
accept();
|
|
104
|
+
accept();
|
|
105
|
+
accept();
|
|
106
|
+
accept();
|
|
107
|
+
accept();
|
|
108
|
+
accept();
|
|
109
|
+
accept();
|
|
110
|
+
accept();
|
|
111
|
+
accept();
|
|
112
|
+
accept();
|
|
113
|
+
accept();
|
|
114
|
+
accept();
|
|
115
|
+
accept();
|
|
116
|
+
accept();
|
|
117
|
+
accept();
|
|
118
|
+
accept();
|
|
119
|
+
// T4b / 27rE1fZn — preset resolver public types.
|
|
120
|
+
accept();
|
|
121
|
+
accept();
|
|
122
|
+
accept();
|
|
123
|
+
accept();
|
|
57
124
|
}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operation-builder layer for the SDK ergonomic surface (T2 / xVDTIm8C).
|
|
3
|
+
*
|
|
4
|
+
* Composes `GislClient` — does NOT subclass. Each `client.<op>(input, options)`
|
|
5
|
+
* returns an `OperationBuilder`; calling `.run()` orchestrates the full
|
|
6
|
+
* upload → createWorkflow → wait → getWorkflowDownloads → flat `Result`
|
|
7
|
+
* projection chain. `.submit({webhook})` skips the wait + downloads steps
|
|
8
|
+
* and returns a lighter `Handle` instead.
|
|
9
|
+
*
|
|
10
|
+
* Wire-truth boundaries:
|
|
11
|
+
* - `Result.artifacts` is a FLAT projection of `WorkflowDownloadResponse`
|
|
12
|
+
* (`downloads[].files[]`) with `url` aliasing `downloadUrl`. Every other
|
|
13
|
+
* field is verbatim from `OperationDownload` (`generated/typescript/openapi/
|
|
14
|
+
* models/OperationDownload.ts`). A drift-assertion in `index.ts` fires at
|
|
15
|
+
* `tsc --noEmit` if a contracts regen renames or drops any projected field.
|
|
16
|
+
* - `onProgress` callbacks receive a **SDK-SYNTHESISED discriminated union**:
|
|
17
|
+
* `{phase: 'upload', uploadedBytes, totalBytes}` comes from
|
|
18
|
+
* `UploadOptions.onProgress` (byte-counter only, no wire field for it).
|
|
19
|
+
* `{phase: 'processing', status, progress, jobRef, ...}` projects
|
|
20
|
+
* `SseOperationProgressData`. The `phase` discriminator is SDK-added;
|
|
21
|
+
* `status` values pass through verbatim from `SseOperationProgressDataStatusEnum`.
|
|
22
|
+
* The wire does NOT carry a `phase` field — see karen reality-check 2026-05-23.
|
|
23
|
+
* - `.run()` requires `maxWait` (no default). The underlying `waitForWorkflow`
|
|
24
|
+
* has a 300s default for the poll fallback path; the ergonomic layer makes
|
|
25
|
+
* it MANDATORY in the type so callers consciously choose a deadline.
|
|
26
|
+
*/
|
|
27
|
+
import type { GislClient } from './client.js';
|
|
28
|
+
import type { OperationDownload, WorkflowStatusResponse, SseOperationProgressDataStatusEnum } from '@giveitsmaller/contracts/openapi';
|
|
29
|
+
import type { PresetDefaults, PresetMedia } from './ergonomic/presets/index.js';
|
|
30
|
+
/**
|
|
31
|
+
* Best-effort detection of the compress-operation media from the
|
|
32
|
+
* builder's input. T4b only resolves presets for compress; the wire's
|
|
33
|
+
* operation type union already narrows here (`compress_image`,
|
|
34
|
+
* `compress_video`, …) but the ergonomic builder takes a single
|
|
35
|
+
* `compress` op type and infers media from filename extension /
|
|
36
|
+
* content type at call time. Returns `undefined` when the input is
|
|
37
|
+
* unresolvable (e.g. raw `Blob` without `.type`) — caller then falls
|
|
38
|
+
* back to passthrough (no preset resolution).
|
|
39
|
+
*
|
|
40
|
+
* @internal — exported for tests + the preset resolver.
|
|
41
|
+
*/
|
|
42
|
+
export declare function _detectCompressMedia(input: string | Blob): PresetMedia | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Lightweight artifact reference passed to a `.mapEach(...)` fn. Mirrors
|
|
45
|
+
* the subset of `Artifact` a fan-out callback can use to construct the
|
|
46
|
+
* downstream operation (typically `art.url` + `art.jobId` / `art.ref` for
|
|
47
|
+
* provenance). Future chain methods will extend this with the artifact-
|
|
48
|
+
* backed input helpers (e.g. `art.compress(...)`).
|
|
49
|
+
*/
|
|
50
|
+
export interface ArtifactRef {
|
|
51
|
+
readonly url: string;
|
|
52
|
+
readonly filename: string;
|
|
53
|
+
readonly sizeBytes: number;
|
|
54
|
+
readonly operation: string;
|
|
55
|
+
readonly operationId: string;
|
|
56
|
+
readonly jobId: string;
|
|
57
|
+
readonly ref: string;
|
|
58
|
+
readonly pageIndex?: number;
|
|
59
|
+
readonly position?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A single deliverable output file. Flat projection of `OperationDownload`
|
|
63
|
+
* (`generated/typescript/openapi/models/OperationDownload.ts`) with `url`
|
|
64
|
+
* aliasing `downloadUrl` + the parent `JobDownload`'s `ref` + `jobId`
|
|
65
|
+
* carried in. Drift-asserted against the source type.
|
|
66
|
+
*/
|
|
67
|
+
export interface Artifact {
|
|
68
|
+
/** Pre-signed download URL (aliases `OperationDownload.downloadUrl`). */
|
|
69
|
+
readonly url: string;
|
|
70
|
+
/** Output filename. */
|
|
71
|
+
readonly filename: string;
|
|
72
|
+
/** Output file size in bytes. */
|
|
73
|
+
readonly sizeBytes: number;
|
|
74
|
+
/** Operation type that produced this file. */
|
|
75
|
+
readonly operation: string;
|
|
76
|
+
/** UUID v7 of the operation. */
|
|
77
|
+
readonly operationId: string;
|
|
78
|
+
/** Parent job UUID v7. */
|
|
79
|
+
readonly jobId: string;
|
|
80
|
+
/** Parent job reference label. */
|
|
81
|
+
readonly ref: string;
|
|
82
|
+
/** 1-based page number for PDF-page fan-out (mutually exclusive with `position`). */
|
|
83
|
+
readonly pageIndex?: number;
|
|
84
|
+
/** 0-based ordinal for non-PDF multi-output (mutually exclusive with `pageIndex`). */
|
|
85
|
+
readonly position?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Per-job operation status entry — failure diagnostics live HERE
|
|
89
|
+
* (`OperationResponse.errorCode`/`errorMessage`), NOT on the parent job.
|
|
90
|
+
* Codex r1 medium 5d098e0f135e — previous JobBreakdown shape lost failure
|
|
91
|
+
* details on `partially_failed` workflows.
|
|
92
|
+
*/
|
|
93
|
+
export interface OperationBreakdown {
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly type: string;
|
|
96
|
+
readonly status: string;
|
|
97
|
+
readonly progress?: number;
|
|
98
|
+
readonly errorCode?: string;
|
|
99
|
+
readonly errorMessage?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Per-job breakdown surfaced on `Result.jobs`. Used for inspecting partial
|
|
103
|
+
* failures: when `status === 'partially_failed'` inspect `operations[]` —
|
|
104
|
+
* each `OperationBreakdown` carries `errorCode`/`errorMessage`.
|
|
105
|
+
*/
|
|
106
|
+
export interface JobBreakdown {
|
|
107
|
+
readonly jobId: string;
|
|
108
|
+
readonly ref: string;
|
|
109
|
+
readonly status: string;
|
|
110
|
+
readonly operations: readonly OperationBreakdown[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Per-source field-name buckets surfaced on
|
|
114
|
+
* {@link ResolvedOptions.sources}. Each bucket lists the wire field
|
|
115
|
+
* names (snake_case) contributed by that layer of the preset resolver.
|
|
116
|
+
* Buckets are populated in resolver order (lowest precedence first);
|
|
117
|
+
* a field that appears in a higher-precedence bucket WAS NOT also
|
|
118
|
+
* present in a lower one (the resolver records winners, not all
|
|
119
|
+
* participants).
|
|
120
|
+
*
|
|
121
|
+
* `scopedDefault` is reserved for T4c (`ULAlOP6j`) — `withPresetDefaults`
|
|
122
|
+
* scoped derive. T4b populates it as `[]`.
|
|
123
|
+
*/
|
|
124
|
+
export interface ResolvedOptionsSources {
|
|
125
|
+
readonly sdkDefault: readonly string[];
|
|
126
|
+
readonly clientDefault: readonly string[];
|
|
127
|
+
readonly scopedDefault: readonly string[];
|
|
128
|
+
readonly callPresetOverride: readonly string[];
|
|
129
|
+
readonly explicit: readonly string[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Preset → resolved-options projection. Plan §11b normative shape with
|
|
133
|
+
* the T4b extension: `sources` (per-layer field-name buckets) +
|
|
134
|
+
* `presetConfigHash` (sha256 over caller-side deltas, present iff any
|
|
135
|
+
* non-SDK layer participated).
|
|
136
|
+
*
|
|
137
|
+
* `overrides: readonly string[]` is RETAINED for backward compat (T2
|
|
138
|
+
* surface; current callers may read it). It is now a duplicate of
|
|
139
|
+
* `sources.explicit` and will be removed in a future major. New code
|
|
140
|
+
* should read `sources` instead.
|
|
141
|
+
*/
|
|
142
|
+
export interface ResolvedOptions {
|
|
143
|
+
readonly preset: string | null;
|
|
144
|
+
readonly applied: Record<string, unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated Use {@link ResolvedOptions.sources}.explicit. Retained
|
|
147
|
+
* for backward compat with T2; mirrors `sources.explicit` exactly.
|
|
148
|
+
*/
|
|
149
|
+
readonly overrides: readonly string[];
|
|
150
|
+
readonly presetVersion: string;
|
|
151
|
+
/**
|
|
152
|
+
* Per-layer field-name buckets for the preset resolver. Populated by
|
|
153
|
+
* T4b (`27rE1fZn`); legacy placeholder rows emit empty buckets.
|
|
154
|
+
*/
|
|
155
|
+
readonly sources: ResolvedOptionsSources;
|
|
156
|
+
/**
|
|
157
|
+
* SHA-256 over the canonical JSON of `{clientDefault, scopedDefault,
|
|
158
|
+
* callPresetOverride}` (sorted keys, no whitespace), hex-encoded,
|
|
159
|
+
* prefix `sha256:`. ABSENT when only `sdkDefault` participated (or
|
|
160
|
+
* when no preset resolution ran at all — pre-T4b placeholder).
|
|
161
|
+
*/
|
|
162
|
+
readonly presetConfigHash?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Flat result projection. `Result.artifacts` is always an array (empty
|
|
166
|
+
* on failure); error info surfaces via `status === 'failed'` and
|
|
167
|
+
* per-job `errorCode`/`errorMessage` on `jobs`.
|
|
168
|
+
*/
|
|
169
|
+
export interface Result {
|
|
170
|
+
readonly workflowId: string;
|
|
171
|
+
readonly status: string;
|
|
172
|
+
readonly createdAt?: string;
|
|
173
|
+
readonly updatedAt?: string;
|
|
174
|
+
readonly artifacts: readonly Artifact[];
|
|
175
|
+
readonly jobs: readonly JobBreakdown[];
|
|
176
|
+
/** Sugar for `artifacts[0].url` when `artifacts.length === 1`; undefined otherwise. */
|
|
177
|
+
readonly url?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Preset-resolution introspection (placeholder until T4). Plain data
|
|
180
|
+
* property — populated eagerly so `JSON.stringify(result)` round-trips
|
|
181
|
+
* cleanly (codex-reviewer P1: method-valued fields silently drop on
|
|
182
|
+
* `JSON.stringify`).
|
|
183
|
+
*/
|
|
184
|
+
readonly resolvedOptions: ResolvedOptions;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Lighter return value from `.submit({webhook})` — no SSE/poll wait,
|
|
188
|
+
* caller reconciles completion via the webhook.
|
|
189
|
+
*/
|
|
190
|
+
export interface Handle {
|
|
191
|
+
readonly workflowId: string;
|
|
192
|
+
readonly webhookSecret?: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Upload-phase progress event. The byte counter comes from
|
|
196
|
+
* `UploadOptions.onProgress` — there is no `phase` field on the wire.
|
|
197
|
+
*/
|
|
198
|
+
export interface UploadProgressEvent {
|
|
199
|
+
readonly phase: 'upload';
|
|
200
|
+
readonly uploadedBytes: number;
|
|
201
|
+
readonly totalBytes: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Processing-phase progress event. Projects `SseOperationProgressData`
|
|
205
|
+
* verbatim with the `phase` discriminator added by the SDK.
|
|
206
|
+
* `status` passes through as-is from `SseOperationProgressDataStatusEnum`
|
|
207
|
+
* (`started | downloading | probing | decoding | processing | encoding | uploading`).
|
|
208
|
+
* Optional fields mirror the wire shape.
|
|
209
|
+
*/
|
|
210
|
+
export interface ProcessingProgressEvent {
|
|
211
|
+
readonly phase: 'processing';
|
|
212
|
+
readonly status?: SseOperationProgressDataStatusEnum;
|
|
213
|
+
readonly progress: number;
|
|
214
|
+
readonly jobRef: string;
|
|
215
|
+
readonly operationId: string;
|
|
216
|
+
readonly stage?: string;
|
|
217
|
+
/**
|
|
218
|
+
* 1-based index of the input currently being processed (e.g. "probing
|
|
219
|
+
* input 2/4" on long-form merges). Wire field: `phase_input_index` ->
|
|
220
|
+
* `phaseInputIndex` per codex r2 ed873d706d96.
|
|
221
|
+
*/
|
|
222
|
+
readonly phaseInputIndex?: number;
|
|
223
|
+
/** Total number of inputs in the current phase, paired with `phaseInputIndex`. */
|
|
224
|
+
readonly phaseTotalInputs?: number;
|
|
225
|
+
}
|
|
226
|
+
export type ProgressEvent = UploadProgressEvent | ProcessingProgressEvent;
|
|
227
|
+
export interface RunOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Wall-clock deadline for the entire run (upload + create + wait + downloads).
|
|
230
|
+
* MANDATORY — the SDK does NOT supply a default because the underlying
|
|
231
|
+
* `waitForWorkflow` poll path has a 300s default that would otherwise
|
|
232
|
+
* leak silently. Pass `'2h'` / `'30m'` / `'120s'` as a string suffix or
|
|
233
|
+
* a number of milliseconds.
|
|
234
|
+
*/
|
|
235
|
+
readonly maxWait: string | number;
|
|
236
|
+
/** Abort signal — terminates upload, SSE, and poll cleanly. */
|
|
237
|
+
readonly signal?: AbortSignal;
|
|
238
|
+
/** Progress callback receiving the SDK-synthesised discriminated union. */
|
|
239
|
+
readonly onProgress?: (event: ProgressEvent) => void;
|
|
240
|
+
/**
|
|
241
|
+
* Force the poll fallback instead of attempting SSE. Default `true`
|
|
242
|
+
* (SSE preferred; falls back to poll on connect failure). Set `false`
|
|
243
|
+
* to skip SSE entirely — useful for environments where SSE is blocked
|
|
244
|
+
* by an intermediary proxy.
|
|
245
|
+
*/
|
|
246
|
+
readonly useSSE?: boolean;
|
|
247
|
+
/** Override the poll interval used by the fallback (ms). */
|
|
248
|
+
readonly pollIntervalMs?: number;
|
|
249
|
+
}
|
|
250
|
+
export interface SubmitOptions {
|
|
251
|
+
/** Webhook URL — wired to `WorkflowCreateRequest.callback_url`. */
|
|
252
|
+
readonly webhook: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Captures the (op-type, input, options) tuple for one ergonomic-layer
|
|
256
|
+
* operation call. Holds a reference to the underlying `GislClient`;
|
|
257
|
+
* does NOT extend or subclass it. Calling `.run()` or `.submit()`
|
|
258
|
+
* triggers the orchestration; the builder itself is inert until then.
|
|
259
|
+
*/
|
|
260
|
+
export declare class OperationBuilder {
|
|
261
|
+
private readonly client;
|
|
262
|
+
private readonly opType;
|
|
263
|
+
private readonly input;
|
|
264
|
+
private readonly opOptions;
|
|
265
|
+
/**
|
|
266
|
+
* Client-scope preset defaults wired through `wrapErgonomic` from
|
|
267
|
+
* `gisl.create({ presetDefaults })` (T4b). When provided AND the
|
|
268
|
+
* op type is `compress`, `run()`/`submit()` walk the preset
|
|
269
|
+
* resolver before constructing the workflow payload. `undefined`
|
|
270
|
+
* preserves the pre-T4b behaviour: pass `opOptions` through
|
|
271
|
+
* verbatim.
|
|
272
|
+
*/
|
|
273
|
+
private readonly presetDefaults?;
|
|
274
|
+
/**
|
|
275
|
+
* Scoped preset defaults from `client.withPresetDefaults(...)`
|
|
276
|
+
* (T4c — `ULAlOP6j`). Layered between `presetDefaults` and per-call
|
|
277
|
+
* `presetOverrides` in the resolver chain. `undefined` on clients
|
|
278
|
+
* that haven't been through a `withPresetDefaults` call. The
|
|
279
|
+
* derived ergonomic client's Proxy closes over the merged stack
|
|
280
|
+
* (parent's scoped ⊕ new defaults via `PresetDefaults.merge`).
|
|
281
|
+
*/
|
|
282
|
+
private readonly scopedPresetDefaults?;
|
|
283
|
+
constructor(client: GislClient, opType: string, input: string | Blob, opOptions: Record<string, unknown>,
|
|
284
|
+
/**
|
|
285
|
+
* Client-scope preset defaults wired through `wrapErgonomic` from
|
|
286
|
+
* `gisl.create({ presetDefaults })` (T4b). When provided AND the
|
|
287
|
+
* op type is `compress`, `run()`/`submit()` walk the preset
|
|
288
|
+
* resolver before constructing the workflow payload. `undefined`
|
|
289
|
+
* preserves the pre-T4b behaviour: pass `opOptions` through
|
|
290
|
+
* verbatim.
|
|
291
|
+
*/
|
|
292
|
+
presetDefaults?: PresetDefaults | undefined,
|
|
293
|
+
/**
|
|
294
|
+
* Scoped preset defaults from `client.withPresetDefaults(...)`
|
|
295
|
+
* (T4c — `ULAlOP6j`). Layered between `presetDefaults` and per-call
|
|
296
|
+
* `presetOverrides` in the resolver chain. `undefined` on clients
|
|
297
|
+
* that haven't been through a `withPresetDefaults` call. The
|
|
298
|
+
* derived ergonomic client's Proxy closes over the merged stack
|
|
299
|
+
* (parent's scoped ⊕ new defaults via `PresetDefaults.merge`).
|
|
300
|
+
*/
|
|
301
|
+
scopedPresetDefaults?: PresetDefaults | undefined);
|
|
302
|
+
/**
|
|
303
|
+
* Run the preset resolver for compress operations and return the
|
|
304
|
+
* resolved `{wireOptions, resolvedOptions}` tuple. For non-compress
|
|
305
|
+
* operations (or when the op doesn't have a known compress media
|
|
306
|
+
* fingerprint), returns the legacy passthrough — `opOptions` direct
|
|
307
|
+
* to the wire, placeholder `ResolvedOptions`.
|
|
308
|
+
*
|
|
309
|
+
* Throws `GislConfigError` for invalid combos BEFORE any network
|
|
310
|
+
* round-trip — caller's signal is propagated, but we want fail-early
|
|
311
|
+
* before the upload too.
|
|
312
|
+
*/
|
|
313
|
+
private _resolve;
|
|
314
|
+
/**
|
|
315
|
+
* Execute the operation end-to-end. Uploads the input, creates the
|
|
316
|
+
* workflow, waits to a terminal status (via SSE with poll fallback),
|
|
317
|
+
* fetches downloads, and projects to a flat `Result`. Throws
|
|
318
|
+
* `GislTimeoutError` if `maxWait` elapses before terminal status.
|
|
319
|
+
*/
|
|
320
|
+
run(options: RunOptions): Promise<Result>;
|
|
321
|
+
/**
|
|
322
|
+
* Fire-and-forget: upload the input + create the workflow with a
|
|
323
|
+
* `callback_url` wired to the supplied `webhook`, then return a
|
|
324
|
+
* `Handle` (workflowId + webhookSecret) without waiting. The webhook
|
|
325
|
+
* receives completion + the `webhookSecret` is the verifier seed.
|
|
326
|
+
*/
|
|
327
|
+
submit(options: SubmitOptions): Promise<Handle>;
|
|
328
|
+
/**
|
|
329
|
+
* Fan-out chain: run this builder to completion, then for each artifact
|
|
330
|
+
* in the resulting `Result`, call `fn(artifactRef)` to construct a
|
|
331
|
+
* downstream `OperationBuilder`, run that, and collect the child results
|
|
332
|
+
* into a combined `Result`.
|
|
333
|
+
*
|
|
334
|
+
* **KNOWN LIMITATION (T6 — codex r1 HIGH 11cb690e12ae):** today the
|
|
335
|
+
* downstream `OperationBuilder` constructor still takes `string | Blob`
|
|
336
|
+
* inputs, NOT artifact URLs. Passing `art.url` into a child builder
|
|
337
|
+
* would have `uploadFile` treat it as a local filesystem path — the
|
|
338
|
+
* fan-out cannot actually consume parent artifacts without out-of-band
|
|
339
|
+
* prefetching the caller does themselves. The proper fix is an
|
|
340
|
+
* artifact-as-input path (chain via `JobOutputSource.from`) that
|
|
341
|
+
* tracks as a follow-up card. T6 ships the SCAFFOLD: the method, the
|
|
342
|
+
* `MapEachBuilder` class, the `GislChainCardinalityMismatchError`
|
|
343
|
+
* error type (dormant), and orchestration that fans out fn — this
|
|
344
|
+
* unblocks future work on the artifact-source feature without API
|
|
345
|
+
* churn. Use today only for callbacks that construct child builders
|
|
346
|
+
* from `string | Blob` inputs derived from the artifact (e.g. download +
|
|
347
|
+
* re-upload bridges).
|
|
348
|
+
*
|
|
349
|
+
* Single-output parents degrade gracefully (1 artifact = 1 fn call =
|
|
350
|
+
* 1 child run). Multi-output parents (PDF → N pages, future split ops)
|
|
351
|
+
* fan out N child runs. Each child shares the SAME maxWait deadline
|
|
352
|
+
* (subtracting elapsed); aborts propagate.
|
|
353
|
+
*
|
|
354
|
+
* `.submit()` is NOT supported on a `MapEachBuilder` — fan-out submit-
|
|
355
|
+
* with-webhook is a future card.
|
|
356
|
+
*/
|
|
357
|
+
mapEach(fn: (artifact: ArtifactRef) => OperationBuilder): MapEachBuilder;
|
|
358
|
+
private awaitTerminal;
|
|
359
|
+
}
|
|
360
|
+
export declare class MapEachBuilder {
|
|
361
|
+
private readonly parent;
|
|
362
|
+
private readonly fn;
|
|
363
|
+
constructor(parent: OperationBuilder, fn: (artifact: ArtifactRef) => OperationBuilder);
|
|
364
|
+
/**
|
|
365
|
+
* Run the parent builder to completion, then fan out the fn over each
|
|
366
|
+
* resulting artifact. The deadline (maxWait) covers the parent's full
|
|
367
|
+
* run + every child's full run — each child sees the REMAINING budget
|
|
368
|
+
* after the parent and prior children completed. Signal aborts cascade.
|
|
369
|
+
*/
|
|
370
|
+
run(options: RunOptions): Promise<Result>;
|
|
371
|
+
}
|
|
372
|
+
/** @internal — exported for reuse by `merge.ts` (T3) and future builders. */
|
|
373
|
+
export declare function _consumeSseToTerminal(client: GislClient, args: {
|
|
374
|
+
workflowId: string;
|
|
375
|
+
deadline: number;
|
|
376
|
+
signal: AbortSignal | undefined;
|
|
377
|
+
onProgress: ((event: ProgressEvent) => void) | undefined;
|
|
378
|
+
}): Promise<WorkflowStatusResponse>;
|
|
379
|
+
/** @internal — exported for reuse by `merge.ts` (T3) and future builders. */
|
|
380
|
+
export declare function _pollToTerminal(client: GislClient, args: {
|
|
381
|
+
workflowId: string;
|
|
382
|
+
deadline: number;
|
|
383
|
+
signal: AbortSignal | undefined;
|
|
384
|
+
pollIntervalMs?: number;
|
|
385
|
+
}): Promise<WorkflowStatusResponse>;
|
|
386
|
+
/** @internal — exported for reuse by `merge.ts` (T3) and future builders.
|
|
387
|
+
*
|
|
388
|
+
* T4b adds the optional `resolvedOptionsOverride` argument. When provided,
|
|
389
|
+
* it supplants the placeholder ResolvedOptions the projector would
|
|
390
|
+
* otherwise emit. `MergeBuilder` and other non-resolver builders omit
|
|
391
|
+
* this argument and receive the legacy placeholder shape unchanged
|
|
392
|
+
* (back-compat — merge does NOT go through the preset resolver in T4b).
|
|
393
|
+
*/
|
|
394
|
+
export declare function _projectResult(status: WorkflowStatusResponse, jobDownloads: readonly {
|
|
395
|
+
ref: string;
|
|
396
|
+
jobId: string;
|
|
397
|
+
files: readonly OperationDownload[];
|
|
398
|
+
}[], appliedOptions: Record<string, unknown>, resolvedOptionsOverride?: ResolvedOptions): Result;
|
|
399
|
+
/** @internal — exported for reuse by `merge.ts` (T3) and future builders. */
|
|
400
|
+
export declare function _checkAborted(signal: AbortSignal | undefined): void;
|
|
401
|
+
/**
|
|
402
|
+
* Parse a `maxWait` argument: number = milliseconds; string with suffix
|
|
403
|
+
* `ms` / `s` / `m` / `h`. Throws if the string is malformed.
|
|
404
|
+
*/
|
|
405
|
+
/** @internal — exported for reuse by `merge.ts` (T3) and future builders. */
|
|
406
|
+
export declare function _parseMaxWait(value: string | number): number;
|