@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/types.d.ts CHANGED
@@ -94,21 +94,19 @@ export interface JobDefinitionPayload {
94
94
  operations: OperationDef[];
95
95
  /** Per-job hide-intermediates promotion flag per ADR-0003. */
96
96
  deliver?: boolean;
97
- /**
98
- * Per-job opt-out of the "compress required in every chain" gate.
99
- * When `true`, the server accepts a chain that doesn't terminate in a
100
- * `compress` operation — required for chains that observe multi-output
101
- * fan-out (e.g. convert PDF -> N images per ADR-0009 §D2) without
102
- * collapsing the N outputs through a trailing chained compress.
103
- *
104
- * Accepted by the API at `compression/src/Jobs/.../JobDefinition.php`
105
- * (`skipCompression`) and validated against the chain-ordering rule at
106
- * `Job::validateChainOrdering`. Currently undocumented in
107
- * `contracts/openapi/api.yaml` JobDefinition schema — spec follow-up
108
- * pending; the SDK exposes the field to unblock e2e A8-FLIP.
109
- */
110
- skip_compression?: boolean;
111
97
  }
98
+ /**
99
+ * Single source of truth for JobDefinitionPayload's top-level wire keys.
100
+ * Read by `contract-drift-fields.test.ts` to cross-check against the spec
101
+ * at `JobDefinition`. Not re-exported from `index.ts`; this is reachable
102
+ * only via deep imports and should not be treated as public API.
103
+ *
104
+ * The V1-only `skip_compression` field is deliberately absent (eQnUMW68);
105
+ * the runtime drift test will fail if the spec re-introduces it OR adds
106
+ * any other V1-leak field to the V2 JobDefinition schema.
107
+ * @internal
108
+ */
109
+ export declare const JOB_DEFINITION_PAYLOAD_KEYS: readonly ["id", "source", "inputs", "operations", "deliver"];
112
110
  export type ExternalDestinationPayload = {
113
111
  type: 'connection';
114
112
  connection_id: string;
@@ -284,4 +282,136 @@ export interface UploadOptions {
284
282
  * single FormData field on the multipart/initiate request.
285
283
  */
286
284
  metadataHint?: MultipartInitiateRequestMetadataHint;
285
+ /**
286
+ * Resume an in-progress multipart upload (SDK-3 / Wb6ebOMM).
287
+ *
288
+ * When set, `uploadFile()` skips `/multipart/initiate` entirely. Instead it
289
+ * walks `GET /api/uploads/multipart/{uploadId}/status` (paginated via
290
+ * `next_part_number_marker` / `is_truncated`), computes which parts are
291
+ * still missing, re-presigns them in batches of <=100 via
292
+ * `POST /api/uploads/multipart/{uploadId}/presign`, PUTs only the missing
293
+ * parts, then `POST /api/uploads/multipart/complete`.
294
+ *
295
+ * The caller's `file` argument MUST be byte-identical to the file used in
296
+ * the original initiate call (same byte content at the same offsets).
297
+ * Mismatched bytes will produce S3 etags that don't match the server's
298
+ * recorded state, and `/multipart/complete` will reject.
299
+ *
300
+ * Anonymous-initiated sessions cannot be resumed by an authed caller
301
+ * (server returns 403 → `GislMultipartSessionAuthRequiredError`); a
302
+ * non-existent or expired session returns 404 →
303
+ * `GislMultipartSessionNotFoundError`.
304
+ */
305
+ resumeUploadId?: string;
306
+ /**
307
+ * Called after every successful part PUT during fresh-upload AND resume
308
+ * paths. Receives a JSON-serialisable snapshot of the upload state — round-
309
+ * trippable via `JSON.stringify` for persistence across process restarts,
310
+ * so a future `uploadFile({ resumeUploadId: state.uploadId, ... })` can
311
+ * pick up where the prior process stopped.
312
+ *
313
+ * The callback is invoked OUTSIDE the per-part retry-scoped path: a throw
314
+ * here will fail the upload but NEVER trigger a duplicate PUT (mirrors the
315
+ * `onProgress` discipline at `client.ts:1195-1199`).
316
+ */
317
+ onCheckpoint?: (state: MultipartCheckpointState) => void;
318
+ }
319
+ /**
320
+ * JSON-serialisable snapshot of an in-progress multipart upload, emitted
321
+ * after every successful part PUT via `UploadOptions.onCheckpoint`. Designed
322
+ * to round-trip through `JSON.stringify` / `JSON.parse` so consumers can
323
+ * persist it across process restarts and resume via
324
+ * `uploadFile({ resumeUploadId: state.uploadId, ... })`.
325
+ *
326
+ * All fields are primitive: no `Date` (use the ISO-8601 string on
327
+ * `manifestExpiresAt`), no `Buffer`, no functions.
328
+ */
329
+ export interface MultipartCheckpointState {
330
+ /** The server-assigned `upload_id` (UUID) used as `resumeUploadId` later. */
331
+ readonly uploadId: string;
332
+ /** Total parts the server computed for this upload. <=10 000. */
333
+ readonly totalParts: number;
334
+ /**
335
+ * Part numbers (1-indexed) that have been successfully PUT to S3 so far.
336
+ * Includes part 1 (the initiate first chunk) once a part >= 2 lands. Sorted
337
+ * ascending. Excluded numbers in `[1, totalParts]` are the still-missing
338
+ * set a resume must re-PUT.
339
+ */
340
+ readonly uploadedPartNumbers: readonly number[];
341
+ /**
342
+ * ISO-8601 wall-clock instant at which the server's durable manifest for
343
+ * this `uploadId` expires (currently a 48h TTL per the API-2 contract). On
344
+ * resume, clients SHOULD call `keepaliveUpload(uploadId)` every 12-24h to
345
+ * extend this, leaving >=24h of slack against the 48h ceiling even with
346
+ * worst-case clock skew between client and server.
347
+ */
348
+ readonly manifestExpiresAt: string;
349
+ }
350
+ /**
351
+ * One entry in `_Sdk3HandCodedMultipartStatusResult.uploadedParts`. Aggregated
352
+ * across all pages of the underlying `GET /status` endpoint by the SDK's
353
+ * walk-pagination loop.
354
+ *
355
+ * TODO(HxUmVr3Y): replace hand-coded shape on regen.
356
+ */
357
+ export interface _Sdk3HandCodedUploadedPart {
358
+ readonly partNumber: number;
359
+ readonly etag: string;
360
+ readonly sizeBytes: number;
361
+ /** ISO-8601 last-modified instant of the S3 part. */
362
+ readonly lastModified: string;
363
+ }
364
+ /**
365
+ * Aggregated result of `getUploadStatus()` after the SDK has walked every
366
+ * page of the underlying `GET /api/uploads/multipart/{uploadId}/status`
367
+ * endpoint (paginated via `next_part_number_marker` / `is_truncated`).
368
+ * `uploadedParts` is the merged-and-sorted list of every part the server
369
+ * has recorded across all pages — callers see the complete state without
370
+ * needing to drive the pagination cursor themselves.
371
+ *
372
+ * TODO(HxUmVr3Y): replace hand-coded shape on regen.
373
+ */
374
+ export interface _Sdk3HandCodedMultipartStatusResult {
375
+ readonly uploadId: string;
376
+ readonly multipartUploadId: string;
377
+ readonly cloudKey: string;
378
+ readonly totalParts: number;
379
+ /** Sorted ascending by `partNumber`; complete across all server-side pages. */
380
+ readonly uploadedParts: readonly _Sdk3HandCodedUploadedPart[];
381
+ /** ISO-8601 wall-clock when the durable session manifest expires. */
382
+ readonly manifestExpiresAt: string;
383
+ /** Server-recommended chunk size in bytes (matches the initiate envelope). */
384
+ readonly recommendedChunkSize: number;
385
+ }
386
+ /**
387
+ * One entry in `_Sdk3HandCodedPresignPartsResult.presignedUrls`. Shape mirrors
388
+ * the contract-pinned `PresignedUrlPart` from the initiate envelope; kept
389
+ * hand-coded here so the resume path does not depend on the generator's name
390
+ * for that shape (decoupling for the HxUmVr3Y regen window).
391
+ *
392
+ * TODO(HxUmVr3Y): replace hand-coded shape on regen.
393
+ */
394
+ export interface _Sdk3HandCodedPresignedPart {
395
+ readonly partNumber: number;
396
+ readonly url: string;
397
+ readonly expiresAt: string;
398
+ }
399
+ /**
400
+ * Result of `presignParts()` — the server-issued presigned PUT URLs for the
401
+ * requested part numbers.
402
+ *
403
+ * TODO(HxUmVr3Y): replace hand-coded shape on regen.
404
+ */
405
+ export interface _Sdk3HandCodedPresignPartsResult {
406
+ readonly uploadId: string;
407
+ readonly presignedUrls: readonly _Sdk3HandCodedPresignedPart[];
408
+ }
409
+ /**
410
+ * Result of `keepaliveUpload()` — the refreshed manifest TTL expiry instant.
411
+ *
412
+ * TODO(HxUmVr3Y): replace hand-coded shape on regen.
413
+ */
414
+ export interface _Sdk3HandCodedKeepaliveResult {
415
+ readonly uploadId: string;
416
+ readonly manifestExpiresAt: string;
287
417
  }
package/dist/types.js CHANGED
@@ -15,6 +15,24 @@ export function externalImportSource(externalSourceId) {
15
15
  export function connectionSource(connectionId, path) {
16
16
  return { type: 'connection', connection_id: connectionId, path };
17
17
  }
18
+ /**
19
+ * Single source of truth for JobDefinitionPayload's top-level wire keys.
20
+ * Read by `contract-drift-fields.test.ts` to cross-check against the spec
21
+ * at `JobDefinition`. Not re-exported from `index.ts`; this is reachable
22
+ * only via deep imports and should not be treated as public API.
23
+ *
24
+ * The V1-only `skip_compression` field is deliberately absent (eQnUMW68);
25
+ * the runtime drift test will fail if the spec re-introduces it OR adds
26
+ * any other V1-leak field to the V2 JobDefinition schema.
27
+ * @internal
28
+ */
29
+ export const JOB_DEFINITION_PAYLOAD_KEYS = Object.freeze([
30
+ 'id',
31
+ 'source',
32
+ 'inputs',
33
+ 'operations',
34
+ 'deliver',
35
+ ]);
18
36
  /**
19
37
  * Single source of truth for WorkflowCreatePayload's top-level wire keys.
20
38
  * Read by `contract-drift-fields.test.ts` to cross-check against the spec at
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giveitsmaller/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.7.0",
4
4
  "description": "Node.js SDK for the GISL (Give It Smaller) file compression and processing API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "node": ">=18"
20
20
  },
21
21
  "dependencies": {
22
- "@giveitsmaller/contracts": "^0.3.0"
22
+ "@giveitsmaller/contracts": "^0.8.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^22",