@giveitsmaller/sdk 0.8.0 → 0.10.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 (46) hide show
  1. package/README.md +8 -0
  2. package/dist/_audit.js +5 -1
  3. package/dist/builder.d.ts +1 -8
  4. package/dist/builder.js +72 -18
  5. package/dist/client.d.ts +38 -2
  6. package/dist/client.js +131 -7
  7. package/dist/credentials.js +4 -2
  8. package/dist/ergonomic/preset_resolver.js +4 -5
  9. package/dist/ergonomic/presets/image_compress.d.ts +1 -9
  10. package/dist/ergonomic/presets/image_compress.js +6 -25
  11. package/dist/ergonomic/presets/index.d.ts +1 -1
  12. package/dist/ergonomic/presets/index.js +1 -1
  13. package/dist/errors.d.ts +75 -1
  14. package/dist/errors.js +73 -0
  15. package/dist/file-first.d.ts +456 -4
  16. package/dist/file-first.js +1042 -83
  17. package/dist/generated/sdk_spec/enums.d.ts +0 -11
  18. package/dist/generated/sdk_spec/enums.js +0 -7
  19. package/dist/generated/sdk_spec/errors.d.ts +1 -1
  20. package/dist/generated/sdk_spec/errors.js +26 -0
  21. package/dist/generated/sdk_spec/presets.js +0 -3
  22. package/dist/generated/sdk_spec/version.d.ts +2 -2
  23. package/dist/generated/sdk_spec/version.js +2 -2
  24. package/dist/gisl.d.ts +22 -1
  25. package/dist/gisl.js +31 -1
  26. package/dist/handle.d.ts +153 -0
  27. package/dist/handle.js +273 -0
  28. package/dist/index.browser.d.ts +1 -0
  29. package/dist/index.browser.js +14 -0
  30. package/dist/index.core.d.ts +35 -0
  31. package/dist/index.core.js +102 -0
  32. package/dist/index.d.ts +1 -30
  33. package/dist/index.js +9 -73
  34. package/dist/lazy-downloader.d.ts +19 -0
  35. package/dist/lazy-downloader.js +19 -0
  36. package/dist/merge.d.ts +13 -1
  37. package/dist/merge.js +186 -55
  38. package/dist/node-fs.browser.d.ts +17 -0
  39. package/dist/node-fs.browser.js +7 -0
  40. package/dist/node-fs.d.ts +14 -0
  41. package/dist/node-fs.js +14 -0
  42. package/dist/sha256.d.ts +20 -0
  43. package/dist/sha256.js +108 -0
  44. package/dist/types.d.ts +54 -2
  45. package/dist/types.js +2 -0
  46. package/package.json +15 -2
@@ -41,7 +41,7 @@ export { DocumentOfficeCompressPresetOptions, } from './document_office_compress
41
41
  export { DocumentOdfCompressPresetOptions, } from './document_odf_compress.js';
42
42
  export { DocumentEpubCompressPresetOptions, } from './document_epub_compress.js';
43
43
  // Re-export ergonomic enums for callers (single canonical path).
44
- export { OptimizeFor, ImageMode, ImageFit, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from '../../generated/sdk_spec/enums.js';
44
+ export { OptimizeFor, ImageMode, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from '../../generated/sdk_spec/enums.js';
45
45
  function cellKeyOf(media, op) {
46
46
  return `${media}_${op}`;
47
47
  }
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AuthErrorResponse, BalanceExhaustedResponse, FeatureNotAvailableResponse, FeatureTierRestrictedResponse, ProbePendingResponse, TierRestrictionResponse, UploadDurationExceedsTierResponse, UploadSizeExceedsTierResponse, WorkflowExpiredResponse } from '@giveitsmaller/contracts/openapi';
1
+ import type { AuthErrorResponse, AuthRejectionEnvelope, AuthRejectionEnvelopeErrorTypeEnum, BalanceExhaustedResponse, FeatureNotAvailableResponse, FeatureTierRestrictedResponse, ProbePendingResponse, TierRestrictionResponse, UploadDurationExceedsTierResponse, UploadSizeExceedsTierResponse, WorkflowExpiredResponse } from '@giveitsmaller/contracts/openapi';
2
2
  export declare class GislError extends Error {
3
3
  constructor(message: string);
4
4
  }
@@ -14,6 +14,21 @@ export interface GislApiErrorOptions {
14
14
  readonly locale?: string;
15
15
  readonly messageParams?: Record<string, unknown>;
16
16
  readonly payload?: unknown;
17
+ /**
18
+ * The response headers from the HTTP response that produced this error.
19
+ * Keys are LOWERCASED (HTTP header names are case-insensitive per RFC 9110,
20
+ * and `Headers.forEach` yields lowercased keys). Multi-value headers (e.g.
21
+ * `set-cookie`) are collapsed to a single comma-joined string — do NOT rely
22
+ * on this map for cookies.
23
+ */
24
+ readonly responseHeaders?: Record<string, string>;
25
+ /**
26
+ * The resolved language the server reported via the `Content-Language`
27
+ * response header. DISTINCT from `locale`, which is the body-envelope
28
+ * localisation tag (the I26 `ErrorEnvelope.locale` field); `contentLanguage`
29
+ * is the transport-level header the server echoes for content negotiation.
30
+ */
31
+ readonly contentLanguage?: string;
17
32
  }
18
33
  export declare class GislApiError extends GislError {
19
34
  readonly statusCode: number;
@@ -24,6 +39,19 @@ export declare class GislApiError extends GislError {
24
39
  readonly locale?: string;
25
40
  readonly messageParams?: Record<string, unknown>;
26
41
  readonly payload?: unknown;
42
+ /**
43
+ * Response headers from the HTTP response that produced this error, with
44
+ * LOWERCASED keys (RFC 9110 case-insensitive). Multi-value headers such as
45
+ * `set-cookie` are collapsed into a single comma-joined string — don't rely
46
+ * on this map for cookies.
47
+ */
48
+ readonly responseHeaders?: Record<string, string>;
49
+ /**
50
+ * The `Content-Language` response header value (the language the server
51
+ * actually resolved). DISTINCT from `locale`, which is the body-envelope
52
+ * localisation tag.
53
+ */
54
+ readonly contentLanguage?: string;
27
55
  constructor(statusCode: number, errorMessage: string, path?: string, details?: unknown, options?: GislApiErrorOptions);
28
56
  }
29
57
  /**
@@ -101,6 +129,23 @@ export declare class GislAuthError extends GislApiError {
101
129
  readonly payload: AuthErrorResponse;
102
130
  constructor(statusCode: number, errorMessage: string, payload: AuthErrorResponse, path?: string, extra?: Omit<GislApiErrorOptions, 'payload'>);
103
131
  }
132
+ /**
133
+ * 422 Unprocessable Entity — domain rejection on auth side-effect endpoints
134
+ * (register / verify-email / api-keys duplicate-or-invalid; profile PATCH email
135
+ * unchanged). Flat `AuthRejectionEnvelope`, no `details[]`. Mirrors the PHP
136
+ * `Gisl\Sdk\Errors\GislAuthRejectionError`.
137
+ *
138
+ * `payload.errorType` is the auth-422 `oneOf` discriminator
139
+ * (`unprocessable_entity` or `email_same`); `errorType` re-exposes it directly
140
+ * for caller-side narrowing without unwrapping the typed payload. Distinct from
141
+ * `GislValidationError` (the `validation_error` branch of the same `oneOf`,
142
+ * which carries `details[]`).
143
+ */
144
+ export declare class GislAuthRejectionError extends GislApiError {
145
+ readonly payload: AuthRejectionEnvelope;
146
+ readonly errorType: AuthRejectionEnvelopeErrorTypeEnum;
147
+ constructor(statusCode: number, errorMessage: string, payload: AuthRejectionEnvelope, path?: string, extra?: Omit<GislApiErrorOptions, 'payload'>);
148
+ }
104
149
  /**
105
150
  * Discriminates the four upload-too-big shapes the server can return:
106
151
  * - `size_tier` — 422 `upload_size_exceeds_tier` (typed payload present)
@@ -312,6 +357,19 @@ export declare class GislTimeoutError extends GislError {
312
357
  export declare class GislNetworkError extends GislError {
313
358
  constructor(message: string);
314
359
  }
360
+ /**
361
+ * Internal control-flow marker (TDqmkWpX): the SSE event stream closed cleanly
362
+ * WITHOUT a terminal (`workflow_completed`/`failed`/`partially_failed`) event.
363
+ * Raised by {@link _consumeSseToTerminal} so the await-terminal callers can
364
+ * distinguish a benign server-side stream close (→ fall back to polling) from a
365
+ * genuine failure that must propagate (an `onProgress` callback throw, an API
366
+ * error, a caller abort). Mirrors the PHP `SseStreamEndedWithoutTerminal`
367
+ * sealed marker. Not part of the public error contract — never surfaced to a
368
+ * caller (the await-terminal path catches it internally and polls).
369
+ */
370
+ export declare class SseEndedWithoutTerminal extends GislError {
371
+ constructor(message?: string);
372
+ }
315
373
  export declare class GislAbortError extends GislError {
316
374
  constructor(message: string);
317
375
  }
@@ -348,6 +406,22 @@ export declare class GislMultipartPartCountError extends GislError {
348
406
  export declare class GislNoSuchKeyError extends GislError {
349
407
  constructor(message: string);
350
408
  }
409
+ /**
410
+ * Thrown by the file-first `Handle.result()` (FF5a) when the workflow has not
411
+ * yet reached a terminal state. `result()` is the NON-blocking accessor: it
412
+ * fetches the current status once and, if the workflow is still
413
+ * `pending`/`in_progress`, throws this rather than waiting. Use `Handle.wait()`
414
+ * to block until terminal instead.
415
+ *
416
+ * Carries the `workflowId` and the current (non-terminal) `state`.
417
+ *
418
+ * Mirrors the PHP `Gisl\Sdk\Errors\GislResultNotReadyError`.
419
+ */
420
+ export declare class GislResultNotReadyError extends GislError {
421
+ readonly workflowId: string;
422
+ readonly state: string;
423
+ constructor(workflowId: string, state: string);
424
+ }
351
425
  /** Machine-readable cause carried by {@link GislSinkError}. */
352
426
  export type GislSinkErrorReason = 'not_single_output' | 'downloader_unavailable' | 'partial_failure' | 'duplicate_filename' | 'invalid_directory' | 'write_failed';
353
427
  /**
package/dist/errors.js CHANGED
@@ -13,6 +13,19 @@ export class GislApiError extends GislError {
13
13
  locale;
14
14
  messageParams;
15
15
  payload;
16
+ /**
17
+ * Response headers from the HTTP response that produced this error, with
18
+ * LOWERCASED keys (RFC 9110 case-insensitive). Multi-value headers such as
19
+ * `set-cookie` are collapsed into a single comma-joined string — don't rely
20
+ * on this map for cookies.
21
+ */
22
+ responseHeaders;
23
+ /**
24
+ * The `Content-Language` response header value (the language the server
25
+ * actually resolved). DISTINCT from `locale`, which is the body-envelope
26
+ * localisation tag.
27
+ */
28
+ contentLanguage;
16
29
  constructor(statusCode, errorMessage, path, details, options) {
17
30
  const prefix = path
18
31
  ? `API error ${statusCode} at ${path}`
@@ -28,6 +41,8 @@ export class GislApiError extends GislError {
28
41
  this.locale = options.locale;
29
42
  this.messageParams = options.messageParams;
30
43
  this.payload = options.payload;
44
+ this.responseHeaders = options.responseHeaders;
45
+ this.contentLanguage = options.contentLanguage;
31
46
  }
32
47
  }
33
48
  }
@@ -112,6 +127,26 @@ export class GislAuthError extends GislApiError {
112
127
  this.name = 'GislAuthError';
113
128
  }
114
129
  }
130
+ /**
131
+ * 422 Unprocessable Entity — domain rejection on auth side-effect endpoints
132
+ * (register / verify-email / api-keys duplicate-or-invalid; profile PATCH email
133
+ * unchanged). Flat `AuthRejectionEnvelope`, no `details[]`. Mirrors the PHP
134
+ * `Gisl\Sdk\Errors\GislAuthRejectionError`.
135
+ *
136
+ * `payload.errorType` is the auth-422 `oneOf` discriminator
137
+ * (`unprocessable_entity` or `email_same`); `errorType` re-exposes it directly
138
+ * for caller-side narrowing without unwrapping the typed payload. Distinct from
139
+ * `GislValidationError` (the `validation_error` branch of the same `oneOf`,
140
+ * which carries `details[]`).
141
+ */
142
+ export class GislAuthRejectionError extends GislApiError {
143
+ errorType;
144
+ constructor(statusCode, errorMessage, payload, path, extra) {
145
+ super(statusCode, errorMessage, path, undefined, buildOptionsWithPayload(payload, extra));
146
+ this.name = 'GislAuthRejectionError';
147
+ this.errorType = payload.errorType;
148
+ }
149
+ }
115
150
  /**
116
151
  * A single class covering all three "upload exceeds a size/duration cap"
117
152
  * responses (422 size-tier, 422 duration-tier, 413 absolute).
@@ -335,6 +370,22 @@ export class GislNetworkError extends GislError {
335
370
  this.name = 'GislNetworkError';
336
371
  }
337
372
  }
373
+ /**
374
+ * Internal control-flow marker (TDqmkWpX): the SSE event stream closed cleanly
375
+ * WITHOUT a terminal (`workflow_completed`/`failed`/`partially_failed`) event.
376
+ * Raised by {@link _consumeSseToTerminal} so the await-terminal callers can
377
+ * distinguish a benign server-side stream close (→ fall back to polling) from a
378
+ * genuine failure that must propagate (an `onProgress` callback throw, an API
379
+ * error, a caller abort). Mirrors the PHP `SseStreamEndedWithoutTerminal`
380
+ * sealed marker. Not part of the public error contract — never surfaced to a
381
+ * caller (the await-terminal path catches it internally and polls).
382
+ */
383
+ export class SseEndedWithoutTerminal extends GislError {
384
+ constructor(message = 'SSE stream ended without a terminal event') {
385
+ super(message);
386
+ this.name = 'SseEndedWithoutTerminal';
387
+ }
388
+ }
338
389
  export class GislAbortError extends GislError {
339
390
  constructor(message) {
340
391
  super(message);
@@ -387,6 +438,28 @@ export class GislNoSuchKeyError extends GislError {
387
438
  this.name = 'GislNoSuchKeyError';
388
439
  }
389
440
  }
441
+ /**
442
+ * Thrown by the file-first `Handle.result()` (FF5a) when the workflow has not
443
+ * yet reached a terminal state. `result()` is the NON-blocking accessor: it
444
+ * fetches the current status once and, if the workflow is still
445
+ * `pending`/`in_progress`, throws this rather than waiting. Use `Handle.wait()`
446
+ * to block until terminal instead.
447
+ *
448
+ * Carries the `workflowId` and the current (non-terminal) `state`.
449
+ *
450
+ * Mirrors the PHP `Gisl\Sdk\Errors\GislResultNotReadyError`.
451
+ */
452
+ export class GislResultNotReadyError extends GislError {
453
+ workflowId;
454
+ state;
455
+ constructor(workflowId, state) {
456
+ super(`Workflow ${workflowId} is not ready (state '${state}'); its result is not available yet. ` +
457
+ 'Call wait() to block until it reaches a terminal state, or poll result() again later.');
458
+ this.name = 'GislResultNotReadyError';
459
+ this.workflowId = workflowId;
460
+ this.state = state;
461
+ }
462
+ }
390
463
  /**
391
464
  * Thrown by the file-first `RunResult` sinks (`toFile()` / `downloadTo()`,
392
465
  * FF1) when they cannot deliver. The machine-readable `reason` discriminates