@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.
Files changed (50) hide show
  1. package/dist/_audit.js +67 -0
  2. package/dist/builder.d.ts +406 -0
  3. package/dist/builder.js +706 -0
  4. package/dist/client.d.ts +96 -2
  5. package/dist/client.js +968 -33
  6. package/dist/credentials.d.ts +61 -0
  7. package/dist/credentials.js +200 -0
  8. package/dist/ergonomic/preset_resolver.d.ts +75 -0
  9. package/dist/ergonomic/preset_resolver.js +568 -0
  10. package/dist/ergonomic/presets/_translate.d.ts +11 -0
  11. package/dist/ergonomic/presets/_translate.js +35 -0
  12. package/dist/ergonomic/presets/audio_compress.d.ts +16 -0
  13. package/dist/ergonomic/presets/audio_compress.js +45 -0
  14. package/dist/ergonomic/presets/document_epub_compress.d.ts +14 -0
  15. package/dist/ergonomic/presets/document_epub_compress.js +34 -0
  16. package/dist/ergonomic/presets/document_odf_compress.d.ts +14 -0
  17. package/dist/ergonomic/presets/document_odf_compress.js +34 -0
  18. package/dist/ergonomic/presets/document_office_compress.d.ts +16 -0
  19. package/dist/ergonomic/presets/document_office_compress.js +40 -0
  20. package/dist/ergonomic/presets/document_pdf_compress.d.ts +14 -0
  21. package/dist/ergonomic/presets/document_pdf_compress.js +35 -0
  22. package/dist/ergonomic/presets/image_compress.d.ts +43 -0
  23. package/dist/ergonomic/presets/image_compress.js +95 -0
  24. package/dist/ergonomic/presets/index.d.ts +77 -0
  25. package/dist/ergonomic/presets/index.js +216 -0
  26. package/dist/ergonomic/presets/video_compress.d.ts +30 -0
  27. package/dist/ergonomic/presets/video_compress.js +83 -0
  28. package/dist/errors.d.ts +251 -1
  29. package/dist/errors.js +268 -0
  30. package/dist/generated/sdk_spec/enums.d.ts +195 -0
  31. package/dist/generated/sdk_spec/enums.js +127 -0
  32. package/dist/generated/sdk_spec/errors.d.ts +16 -0
  33. package/dist/generated/sdk_spec/errors.js +473 -0
  34. package/dist/generated/sdk_spec/index.d.ts +4 -0
  35. package/dist/generated/sdk_spec/index.js +7 -0
  36. package/dist/generated/sdk_spec/presets.d.ts +6 -0
  37. package/dist/generated/sdk_spec/presets.js +157 -0
  38. package/dist/generated/sdk_spec/version.d.ts +3 -0
  39. package/dist/generated/sdk_spec/version.js +6 -0
  40. package/dist/gisl.d.ts +112 -0
  41. package/dist/gisl.js +266 -0
  42. package/dist/index.d.ts +17 -7
  43. package/dist/index.js +33 -3
  44. package/dist/merge.d.ts +142 -0
  45. package/dist/merge.js +411 -0
  46. package/dist/sse.d.ts +20 -1
  47. package/dist/sse.js +62 -3
  48. package/dist/types.d.ts +144 -14
  49. package/dist/types.js +18 -0
  50. package/package.json +2 -2
package/dist/errors.js CHANGED
@@ -67,6 +67,39 @@ export class GislFeatureNotAvailableError extends GislApiError {
67
67
  this.name = 'GislFeatureNotAvailableError';
68
68
  }
69
69
  }
70
+ /**
71
+ * 422 response on `POST /api/workflows` when a job references an upload
72
+ * whose server-side probe hasn't completed at workflow-create time. The
73
+ * server rejects rather than silently routing as `short_form` (which
74
+ * hard-fails long video clips).
75
+ *
76
+ * **Recovery contract** (per contracts ProbePendingResponse docblock):
77
+ * poll `POST /api/uploads/{id}/probe` for the pending upload until
78
+ * `probe_status` is terminal (`ok` → re-`POST /api/workflows` the same
79
+ * request; `corrupt` / `unsupported_codec` → surface the probe error).
80
+ * The `Retry-After` response header (when present) suggests a delay
81
+ * in seconds before the next poll/retry.
82
+ *
83
+ * `payload.jobRef` identifies which job in the multi-job request triggered
84
+ * the probe-pending rejection.
85
+ *
86
+ * @example
87
+ * try {
88
+ * await client.createWorkflow({ jobs });
89
+ * } catch (e) {
90
+ * if (e instanceof GislProbePendingError) {
91
+ * await waitForProbe(e.payload.jobRef);
92
+ * // retry...
93
+ * }
94
+ * throw e;
95
+ * }
96
+ */
97
+ export class GislProbePendingError extends GislApiError {
98
+ constructor(statusCode, errorMessage, payload, path, extra) {
99
+ super(statusCode, errorMessage, path, undefined, buildOptionsWithPayload(payload, extra));
100
+ this.name = 'GislProbePendingError';
101
+ }
102
+ }
70
103
  export class GislWorkflowExpiredError extends GislApiError {
71
104
  constructor(statusCode, errorMessage, payload, path, extra) {
72
105
  super(statusCode, errorMessage, path, undefined, buildOptionsWithPayload(payload, extra));
@@ -79,6 +112,208 @@ export class GislAuthError extends GislApiError {
79
112
  this.name = 'GislAuthError';
80
113
  }
81
114
  }
115
+ /**
116
+ * A single class covering all three "upload exceeds a size/duration cap"
117
+ * responses (422 size-tier, 422 duration-tier, 413 absolute).
118
+ *
119
+ * CONSCIOUS DEVIATION from the one-typed-payload-per-class invariant that the
120
+ * other structured subclasses follow (`GislBalanceExhaustedError`,
121
+ * `GislWorkflowExpiredError`, …). Justification: the card mandates this single
122
+ * `GislUploadCapExceededError` name and SDK-3 / E2E-1 are blocked-on it, so
123
+ * splitting into size/duration subclasses would break a cross-ticket naming
124
+ * contract; and 413 carries no typed envelope at all (plain `ErrorEnvelope`),
125
+ * so a one-payload-per-class split could not cover it uniformly anyway. The
126
+ * `kind` discriminant + a union-typed (possibly absent) `payload` is the
127
+ * deliberate trade-off. This is the only structured error in the tree that
128
+ * does not bind exactly one payload type — documented here in the same spirit
129
+ * as the inline PHP↔TS divergence notes.
130
+ *
131
+ * The two multipart-part errors below are deliberately NOT folded in with a
132
+ * `kind`: they carry different fields (`partNumber`/`uploadId` for an instance
133
+ * PUT failure vs `requiredParts`/`maxParts` for the count-ceiling guard) and
134
+ * are thrown from the multipart path, not the response handler.
135
+ */
136
+ export class GislUploadCapExceededError extends GislApiError {
137
+ kind;
138
+ constructor(statusCode, errorMessage, kind, payload, path, extra) {
139
+ super(statusCode, errorMessage, path, undefined, buildOptionsWithPayload(payload, extra));
140
+ this.name = 'GislUploadCapExceededError';
141
+ this.kind = kind;
142
+ }
143
+ }
144
+ /**
145
+ * 404 `MULTIPART_SESSION_NOT_FOUND` — the durable multipart session referenced
146
+ * by a resume / status / presign / keepalive call cannot be located (expired
147
+ * past its 48h manifest TTL, deleted, or never existed). Thrown by the SDK-3
148
+ * resume-support endpoints (`getUploadStatus`, `presignParts`,
149
+ * `keepaliveUpload`, and the resume branch of `uploadFile`).
150
+ *
151
+ * Carries no typed structured payload — the contract for the 3 resume-support
152
+ * endpoints models this code as a plain `ErrorEnvelope`. Consumers should
153
+ * detect via `instanceof` and abandon the resume; a fresh `uploadFile()` call
154
+ * (without `resumeUploadId`) will start a new session.
155
+ */
156
+ export class GislMultipartSessionNotFoundError extends GislApiError {
157
+ constructor(statusCode, errorMessage, path, options) {
158
+ super(statusCode, errorMessage, path, undefined, options);
159
+ this.name = 'GislMultipartSessionNotFoundError';
160
+ }
161
+ }
162
+ /**
163
+ * 403 `MULTIPART_SESSION_OWNERSHIP` — the caller is authenticated but the
164
+ * multipart session belongs to a different user. Thrown by the SDK-3
165
+ * resume-support endpoints. The session itself exists (otherwise the server
166
+ * would return 404 NOT_FOUND); the caller's identity simply doesn't match
167
+ * `manifest.userId`. Consumers should abandon the resume.
168
+ */
169
+ export class GislMultipartSessionOwnershipError extends GislApiError {
170
+ constructor(statusCode, errorMessage, path, options) {
171
+ super(statusCode, errorMessage, path, undefined, options);
172
+ this.name = 'GislMultipartSessionOwnershipError';
173
+ }
174
+ }
175
+ /**
176
+ * 403 `MULTIPART_SESSION_AUTH_REQUIRED` — the multipart session was initiated
177
+ * anonymously (no `manifest.userId`) and the SDK-3 resume-support endpoints
178
+ * refuse to serve it on an authed caller. There is no "claim" workflow today
179
+ * to bind an authed identity to an anonymously-started session; that is the
180
+ * future flip tracked at upstream ticket 8LABloaz. Consumers hitting this on
181
+ * resume should abandon and re-upload from scratch under the authed identity.
182
+ */
183
+ export class GislMultipartSessionAuthRequiredError extends GislApiError {
184
+ constructor(statusCode, errorMessage, path, options) {
185
+ super(statusCode, errorMessage, path, undefined, options);
186
+ this.name = 'GislMultipartSessionAuthRequiredError';
187
+ }
188
+ }
189
+ /**
190
+ * Root of the LOCAL config-error tree — thrown before any HTTP/file I/O.
191
+ * Sibling of `GislApiError` (which represents server-side error envelopes).
192
+ * Reserve for fail-early errors raised by the ergonomic-layer factory or
193
+ * credential-chain resolver when the caller hasn't supplied something the
194
+ * SDK needs to make a request. Never carries an HTTP status code.
195
+ *
196
+ * Optional `metadata` (T4b — `27rE1fZn`) carries structured fields used
197
+ * by the preset resolver and other ergonomic-layer validators. Existing
198
+ * call sites that pass `(message)` keep working — metadata is purely
199
+ * additive and defaults to `undefined`.
200
+ */
201
+ export class GislConfigError extends GislError {
202
+ reason;
203
+ conflictingFields;
204
+ resolvedSnapshot;
205
+ suggestion;
206
+ constructor(message, metadata) {
207
+ super(message);
208
+ this.name = 'GislConfigError';
209
+ if (metadata !== undefined) {
210
+ if (metadata.reason !== undefined)
211
+ this.reason = metadata.reason;
212
+ if (metadata.conflictingFields !== undefined) {
213
+ this.conflictingFields = metadata.conflictingFields;
214
+ }
215
+ if (metadata.resolvedSnapshot !== undefined) {
216
+ this.resolvedSnapshot = metadata.resolvedSnapshot;
217
+ }
218
+ if (metadata.suggestion !== undefined)
219
+ this.suggestion = metadata.suggestion;
220
+ }
221
+ }
222
+ }
223
+ /**
224
+ * The ergonomic-layer factory `gisl.create()` could not resolve an API key
225
+ * from any of explicit arg, `GISL_API_KEY` env, or shared-config profile,
226
+ * AND the caller did not opt into anonymous or cookie-mode. Thrown BEFORE
227
+ * any file read or HTTP request — calls to `client.compress(...)`, `.run()`,
228
+ * etc., synchronously fail with this error.
229
+ */
230
+ export class GislMissingCredentialsError extends GislConfigError {
231
+ constructor(message) {
232
+ super(message);
233
+ this.name = 'GislMissingCredentialsError';
234
+ }
235
+ }
236
+ /**
237
+ * The caller used `gisl.anonymous()` and then invoked an operation that is
238
+ * not in the anonymous-capable allowlist. Local-only — thrown before any I/O.
239
+ * Distinct from server-side `GislAuthError` (401/403 on the wire).
240
+ */
241
+ export class GislFeatureRequiresAuthError extends GislConfigError {
242
+ operation;
243
+ constructor(operation, message) {
244
+ super(message);
245
+ this.name = 'GislFeatureRequiresAuthError';
246
+ this.operation = operation;
247
+ }
248
+ }
249
+ /**
250
+ * `MergeBuilder.sequence(...)` referenced an asset that wasn't declared in
251
+ * the prior `client.merge(...)` call. Local validation runs BEFORE upload
252
+ * so the caller fails fast on the typo without burning bandwidth.
253
+ */
254
+ export class GislUndeclaredAssetError extends GislConfigError {
255
+ assetId;
256
+ declaredAssets;
257
+ constructor(assetId, declaredAssets) {
258
+ super(`Sequence references asset '${assetId}' but it wasn't declared in merge(...). ` +
259
+ `Declared assets: [${declaredAssets.join(', ')}]. ` +
260
+ `Either pass it to merge(...) before sequencing, or remove the reference.`);
261
+ this.name = 'GislUndeclaredAssetError';
262
+ this.assetId = assetId;
263
+ this.declaredAssets = declaredAssets;
264
+ }
265
+ }
266
+ /**
267
+ * `MergeBuilder.sequence(...)` was called but at least one declared asset
268
+ * wasn't referenced. Almost always a bug (wasted upload). Escape via
269
+ * `allowUnusedAssets: true` on the merge options.
270
+ */
271
+ export class GislUnusedAssetError extends GislConfigError {
272
+ unusedAssets;
273
+ constructor(unusedAssets) {
274
+ super(`Assets [${unusedAssets.join(', ')}] were declared in merge(...) but never sequenced. ` +
275
+ `Reference them in .sequence(...), remove them from the declaration, ` +
276
+ `or pass {allowUnusedAssets: true} to opt out of this check.`);
277
+ this.name = 'GislUnusedAssetError';
278
+ this.unusedAssets = unusedAssets;
279
+ }
280
+ }
281
+ /**
282
+ * `MergeBuilder.sequence(...)` on an image merge was given a `clip(ref, opts)`
283
+ * entry. Image merges have NO per-input options in the wire today — `transition`
284
+ * applies at the merge level and is uniform across all joins.
285
+ */
286
+ export class GislPerInputOptionsNotSupportedError extends GislConfigError {
287
+ mediaKind;
288
+ constructor(mediaKind) {
289
+ super(`${mediaKind} merge has no per-input options today; set 'transition' at the ` +
290
+ `.merge(...) level instead — it applies to every join.`);
291
+ this.name = 'GislPerInputOptionsNotSupportedError';
292
+ this.mediaKind = mediaKind;
293
+ }
294
+ }
295
+ /**
296
+ * Thrown by future chain methods (`.compress()` / `.thumbnail()` /
297
+ * `.convert()` on an `OperationBuilder`) when the previous step produces
298
+ * MULTIPLE artifacts and the caller didn't explicitly call `.mapEach(...)`
299
+ * to opt into per-artifact fan-out. T6 ships the error class + the
300
+ * `.mapEach(...)` method; the chain methods themselves are a separate
301
+ * follow-up card, so this error is currently dormant — but the type +
302
+ * audit-gate registration land here so the future chain-method PR is a
303
+ * pure addition with no public-API churn.
304
+ */
305
+ export class GislChainCardinalityMismatchError extends GislConfigError {
306
+ previousOperation;
307
+ attemptedOperation;
308
+ constructor(previousOperation, attemptedOperation) {
309
+ super(`Previous step (${previousOperation}) produces multiple artifacts; ` +
310
+ `use .mapEach(art => art.${attemptedOperation}(...)) to apply the chain per-artifact, ` +
311
+ `or branch to a single artifact first.`);
312
+ this.name = 'GislChainCardinalityMismatchError';
313
+ this.previousOperation = previousOperation;
314
+ this.attemptedOperation = attemptedOperation;
315
+ }
316
+ }
82
317
  export class GislTimeoutError extends GislError {
83
318
  constructor(message) {
84
319
  super(message);
@@ -91,3 +326,36 @@ export class GislAbortError extends GislError {
91
326
  this.name = 'GislAbortError';
92
327
  }
93
328
  }
329
+ /**
330
+ * A single S3 multipart part PUT failed terminally (after the configured
331
+ * retry attempts) or could not be read. Subclasses `GislError` — NOT
332
+ * `GislApiError` — because it carries no contract error envelope and is
333
+ * thrown from the multipart upload path, never from the response handler.
334
+ * Mirrors the `GislAbortError` shape, plus the failing part's identifiers.
335
+ */
336
+ export class GislMultipartPartError extends GislError {
337
+ partNumber;
338
+ uploadId;
339
+ constructor(message, partNumber, uploadId) {
340
+ super(message);
341
+ this.name = 'GislMultipartPartError';
342
+ this.partNumber = partNumber;
343
+ this.uploadId = uploadId;
344
+ }
345
+ }
346
+ /**
347
+ * The upload would require more than the S3 hard limit of 10 000 multipart
348
+ * parts at the server-provided chunk size. Client-side guard (Model A: the
349
+ * server computes the part plan; the SDK asserts the ceiling). Subclasses
350
+ * `GislError` for the same reason as `GislMultipartPartError`.
351
+ */
352
+ export class GislMultipartPartCountError extends GislError {
353
+ requiredParts;
354
+ maxParts;
355
+ constructor(message, requiredParts, maxParts) {
356
+ super(message);
357
+ this.name = 'GislMultipartPartCountError';
358
+ this.requiredParts = requiredParts;
359
+ this.maxParts = maxParts;
360
+ }
361
+ }
@@ -0,0 +1,195 @@
1
+ export declare const OptimizeFor: {
2
+ readonly Size: "Size";
3
+ readonly Balanced: "Balanced";
4
+ readonly Quality: "Quality";
5
+ };
6
+ export type OptimizeFor = typeof OptimizeFor[keyof typeof OptimizeFor];
7
+ export declare const ImageMode: {
8
+ readonly Lossy: "lossy";
9
+ readonly Lossless: "lossless";
10
+ readonly Auto: "auto";
11
+ };
12
+ export type ImageMode = typeof ImageMode[keyof typeof ImageMode];
13
+ export declare const ImageFormat: {
14
+ readonly Original: "original";
15
+ readonly Auto: "auto";
16
+ readonly Smallest: "smallest";
17
+ readonly Jpeg: "jpeg";
18
+ readonly Png: "png";
19
+ readonly Webp: "webp";
20
+ readonly Avif: "avif";
21
+ };
22
+ export type ImageFormat = typeof ImageFormat[keyof typeof ImageFormat];
23
+ export declare const ImageFit: {
24
+ readonly Max: "max";
25
+ readonly Crop: "crop";
26
+ readonly Scale: "scale";
27
+ };
28
+ export type ImageFit = typeof ImageFit[keyof typeof ImageFit];
29
+ export declare const ImageMetadataPolicy: {
30
+ readonly All: "all";
31
+ readonly None: "none";
32
+ readonly Copyright: "copyright";
33
+ readonly Sensitive: "sensitive";
34
+ };
35
+ export type ImageMetadataPolicy = typeof ImageMetadataPolicy[keyof typeof ImageMetadataPolicy];
36
+ export declare const IccProfilePolicy: {
37
+ readonly Preserve: "preserve";
38
+ readonly Strip: "strip";
39
+ readonly Srgb: "srgb";
40
+ };
41
+ export type IccProfilePolicy = typeof IccProfilePolicy[keyof typeof IccProfilePolicy];
42
+ export declare const VideoCodec: {
43
+ readonly H264: "h264";
44
+ readonly H265: "h265";
45
+ readonly Vp9: "vp9";
46
+ readonly Av1: "av1";
47
+ };
48
+ export type VideoCodec = typeof VideoCodec[keyof typeof VideoCodec];
49
+ export declare const VideoPreset: {
50
+ readonly Ultrafast: "ultrafast";
51
+ readonly Superfast: "superfast";
52
+ readonly Veryfast: "veryfast";
53
+ readonly Faster: "faster";
54
+ readonly Fast: "fast";
55
+ readonly Medium: "medium";
56
+ readonly Slow: "slow";
57
+ readonly Slower: "slower";
58
+ readonly Veryslow: "veryslow";
59
+ };
60
+ export type VideoPreset = typeof VideoPreset[keyof typeof VideoPreset];
61
+ export declare const VideoFit: {
62
+ readonly Max: "max";
63
+ readonly Crop: "crop";
64
+ readonly Scale: "scale";
65
+ readonly Pad: "pad";
66
+ };
67
+ export type VideoFit = typeof VideoFit[keyof typeof VideoFit];
68
+ export declare const AudioBitrate: {
69
+ readonly _64: 64;
70
+ readonly _96: 96;
71
+ readonly _128: 128;
72
+ readonly _192: 192;
73
+ readonly _256: 256;
74
+ readonly _320: 320;
75
+ };
76
+ export type AudioBitrate = typeof AudioBitrate[keyof typeof AudioBitrate];
77
+ export declare const AudioCodec: {
78
+ readonly Aac: "aac";
79
+ readonly Opus: "opus";
80
+ readonly Vorbis: "vorbis";
81
+ readonly Copy: "copy";
82
+ };
83
+ export type AudioCodec = typeof AudioCodec[keyof typeof AudioCodec];
84
+ export declare const AudioSampleRate: {
85
+ readonly _22050: 22050;
86
+ readonly _44100: 44100;
87
+ readonly _48000: 48000;
88
+ };
89
+ export type AudioSampleRate = typeof AudioSampleRate[keyof typeof AudioSampleRate];
90
+ export declare const PdfProfile: {
91
+ readonly Web: "web";
92
+ readonly Print: "print";
93
+ readonly Archive: "archive";
94
+ readonly Max: "max";
95
+ };
96
+ export type PdfProfile = typeof PdfProfile[keyof typeof PdfProfile];
97
+ export declare const PdfColorspace: {
98
+ readonly Unchanged: "unchanged";
99
+ readonly Rgb: "rgb";
100
+ readonly Cmyk: "cmyk";
101
+ readonly Grayscale: "grayscale";
102
+ };
103
+ export type PdfColorspace = typeof PdfColorspace[keyof typeof PdfColorspace];
104
+ /** Catalog of every ergonomic enum (canonicalName → wire). */
105
+ export declare const ERGONOMIC_ENUMS: {
106
+ readonly OptimizeFor: {
107
+ readonly Size: "Size";
108
+ readonly Balanced: "Balanced";
109
+ readonly Quality: "Quality";
110
+ };
111
+ readonly ImageMode: {
112
+ readonly Lossy: "lossy";
113
+ readonly Lossless: "lossless";
114
+ readonly Auto: "auto";
115
+ };
116
+ readonly ImageFormat: {
117
+ readonly Original: "original";
118
+ readonly Auto: "auto";
119
+ readonly Smallest: "smallest";
120
+ readonly Jpeg: "jpeg";
121
+ readonly Png: "png";
122
+ readonly Webp: "webp";
123
+ readonly Avif: "avif";
124
+ };
125
+ readonly ImageFit: {
126
+ readonly Max: "max";
127
+ readonly Crop: "crop";
128
+ readonly Scale: "scale";
129
+ };
130
+ readonly ImageMetadataPolicy: {
131
+ readonly All: "all";
132
+ readonly None: "none";
133
+ readonly Copyright: "copyright";
134
+ readonly Sensitive: "sensitive";
135
+ };
136
+ readonly IccProfilePolicy: {
137
+ readonly Preserve: "preserve";
138
+ readonly Strip: "strip";
139
+ readonly Srgb: "srgb";
140
+ };
141
+ readonly VideoCodec: {
142
+ readonly H264: "h264";
143
+ readonly H265: "h265";
144
+ readonly Vp9: "vp9";
145
+ readonly Av1: "av1";
146
+ };
147
+ readonly VideoPreset: {
148
+ readonly Ultrafast: "ultrafast";
149
+ readonly Superfast: "superfast";
150
+ readonly Veryfast: "veryfast";
151
+ readonly Faster: "faster";
152
+ readonly Fast: "fast";
153
+ readonly Medium: "medium";
154
+ readonly Slow: "slow";
155
+ readonly Slower: "slower";
156
+ readonly Veryslow: "veryslow";
157
+ };
158
+ readonly VideoFit: {
159
+ readonly Max: "max";
160
+ readonly Crop: "crop";
161
+ readonly Scale: "scale";
162
+ readonly Pad: "pad";
163
+ };
164
+ readonly AudioBitrate: {
165
+ readonly _64: 64;
166
+ readonly _96: 96;
167
+ readonly _128: 128;
168
+ readonly _192: 192;
169
+ readonly _256: 256;
170
+ readonly _320: 320;
171
+ };
172
+ readonly AudioCodec: {
173
+ readonly Aac: "aac";
174
+ readonly Opus: "opus";
175
+ readonly Vorbis: "vorbis";
176
+ readonly Copy: "copy";
177
+ };
178
+ readonly AudioSampleRate: {
179
+ readonly _22050: 22050;
180
+ readonly _44100: 44100;
181
+ readonly _48000: 48000;
182
+ };
183
+ readonly PdfProfile: {
184
+ readonly Web: "web";
185
+ readonly Print: "print";
186
+ readonly Archive: "archive";
187
+ readonly Max: "max";
188
+ };
189
+ readonly PdfColorspace: {
190
+ readonly Unchanged: "unchanged";
191
+ readonly Rgb: "rgb";
192
+ readonly Cmyk: "cmyk";
193
+ readonly Grayscale: "grayscale";
194
+ };
195
+ };
@@ -0,0 +1,127 @@
1
+ // CODE GENERATED — DO NOT EDIT.
2
+ // Source: compression_contracts/sdk-spec/ (see sdk-spec/README.md).
3
+ // Regenerate with: scripts/generate.py.
4
+ // Top-level preset selector. Resolved client-side to concrete wire fields per presets.yaml.
5
+ export const OptimizeFor = {
6
+ Size: "Size",
7
+ Balanced: "Balanced",
8
+ Quality: "Quality",
9
+ };
10
+ // Image compression algorithm. lossy = smaller file; lossless = no quality loss; auto = format-best.
11
+ export const ImageMode = {
12
+ Lossy: "lossy",
13
+ Lossless: "lossless",
14
+ Auto: "auto",
15
+ };
16
+ // Image output format selection. Original keeps input; Auto picks best per browser support; Smallest tries all and returns smallest.
17
+ export const ImageFormat = {
18
+ Original: "original",
19
+ Auto: "auto",
20
+ Smallest: "smallest",
21
+ Jpeg: "jpeg",
22
+ Png: "png",
23
+ Webp: "webp",
24
+ Avif: "avif",
25
+ };
26
+ // Image resize mode. Only applies when width or height is set (depends_on width/height in compress.yaml).
27
+ export const ImageFit = {
28
+ Max: "max",
29
+ Crop: "crop",
30
+ Scale: "scale",
31
+ };
32
+ // Image metadata handling. Counter-intuitive wire naming:
33
+ // All = strip everything (smallest file)
34
+ // None = keep all EXIF/IPTC/XMP
35
+ // Copyright = keep only copyright/author fields
36
+ // Sensitive = keep EXIF but strip GPS/location (GDPR-friendly)
37
+ export const ImageMetadataPolicy = {
38
+ All: "all",
39
+ None: "none",
40
+ Copyright: "copyright",
41
+ Sensitive: "sensitive",
42
+ };
43
+ // ICC color profile handling.
44
+ export const IccProfilePolicy = {
45
+ Preserve: "preserve",
46
+ Strip: "strip",
47
+ Srgb: "srgb",
48
+ };
49
+ // Video codec. H264 = widest compatibility; H265/Av1 = better compression but slower.
50
+ export const VideoCodec = {
51
+ H264: "h264",
52
+ H265: "h265",
53
+ Vp9: "vp9",
54
+ Av1: "av1",
55
+ };
56
+ // Encoding speed vs compression ratio trade-off (FFmpeg-style x264/x265 preset names).
57
+ export const VideoPreset = {
58
+ Ultrafast: "ultrafast",
59
+ Superfast: "superfast",
60
+ Veryfast: "veryfast",
61
+ Faster: "faster",
62
+ Fast: "fast",
63
+ Medium: "medium",
64
+ Slow: "slow",
65
+ Slower: "slower",
66
+ Veryslow: "veryslow",
67
+ };
68
+ // Video resize mode. Only applies when width or height is set. Pad is video-only (image fit lacks pad).
69
+ export const VideoFit = {
70
+ Max: "max",
71
+ Crop: "crop",
72
+ Scale: "scale",
73
+ Pad: "pad",
74
+ };
75
+ // Audio output bitrate in kbps. Shared between compress (audio + video.audioBitrate) cells.
76
+ export const AudioBitrate = {
77
+ _64: 64,
78
+ _96: 96,
79
+ _128: 128,
80
+ _192: 192,
81
+ _256: 256,
82
+ _320: 320,
83
+ };
84
+ // Audio codec. Aac = widest compatibility; Opus = best quality/size; Copy = passthrough (no re-encode).
85
+ export const AudioCodec = {
86
+ Aac: "aac",
87
+ Opus: "opus",
88
+ Vorbis: "vorbis",
89
+ Copy: "copy",
90
+ };
91
+ // Audio sample rate in Hz.
92
+ export const AudioSampleRate = {
93
+ _22050: 22050,
94
+ _44100: 44100,
95
+ _48000: 48000,
96
+ };
97
+ // PDF optimization profile. Web = aggressive; Print = preserve quality; Archive = PDF/A; Max = smallest.
98
+ export const PdfProfile = {
99
+ Web: "web",
100
+ Print: "print",
101
+ Archive: "archive",
102
+ Max: "max",
103
+ };
104
+ // PDF output color space.
105
+ export const PdfColorspace = {
106
+ Unchanged: "unchanged",
107
+ Rgb: "rgb",
108
+ Cmyk: "cmyk",
109
+ Grayscale: "grayscale",
110
+ };
111
+ /** Catalog of every ergonomic enum (canonicalName → wire). */
112
+ export const ERGONOMIC_ENUMS = {
113
+ OptimizeFor,
114
+ ImageMode,
115
+ ImageFormat,
116
+ ImageFit,
117
+ ImageMetadataPolicy,
118
+ IccProfilePolicy,
119
+ VideoCodec,
120
+ VideoPreset,
121
+ VideoFit,
122
+ AudioBitrate,
123
+ AudioCodec,
124
+ AudioSampleRate,
125
+ PdfProfile,
126
+ PdfColorspace,
127
+ };
@@ -0,0 +1,16 @@
1
+ export type ErrorCode = "missing_credentials" | "feature_requires_auth" | "undeclared_asset" | "unused_asset" | "per_input_options_not_supported" | "chain_cardinality_mismatch" | "multipart_part_invalid" | "multipart_part_count_exceeded" | "timeout" | "aborted" | "validation_failed" | "auth_failed" | "feature_tier_restricted" | "tier_restriction" | "multipart_session_ownership" | "multipart_session_auth_required" | "multipart_session_not_found" | "workflow_expired" | "balance_exhausted" | "feature_not_available" | "upload_size_exceeds_tier" | "upload_duration_exceeds_tier" | "probe_pending" | "requires_reencode" | "invalid_options" | "invalid_combination" | "missing_dependency" | "unsupported_value" | "type_mismatch" | "upload_failed" | "workflow_failed";
2
+ export type ErrorCategory = 'api' | 'config' | 'network' | 'auth' | 'validation' | 'chain';
3
+ export type ErrorStatus = 'wired' | 'planned';
4
+ export interface ErrorEntry {
5
+ readonly code: ErrorCode;
6
+ readonly category: ErrorCategory;
7
+ readonly source: string;
8
+ readonly status: ErrorStatus;
9
+ readonly httpStatus: number | null;
10
+ readonly retryable: boolean;
11
+ readonly sdkClass: string;
12
+ readonly description: string;
13
+ readonly metadataSchema: Readonly<Record<string, string>>;
14
+ }
15
+ export declare const ERROR_CODES: Readonly<Record<ErrorCode, ErrorEntry>>;
16
+ export declare const ERROR_CATEGORIES: Readonly<Record<ErrorCategory, readonly ErrorCode[]>>;