@giveitsmaller/sdk 0.9.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 (42) hide show
  1. package/README.md +8 -0
  2. package/dist/_audit.js +0 -1
  3. package/dist/builder.js +65 -13
  4. package/dist/client.d.ts +38 -2
  5. package/dist/client.js +131 -7
  6. package/dist/credentials.js +4 -2
  7. package/dist/ergonomic/preset_resolver.js +4 -5
  8. package/dist/ergonomic/presets/image_compress.d.ts +1 -9
  9. package/dist/ergonomic/presets/image_compress.js +6 -25
  10. package/dist/ergonomic/presets/index.d.ts +1 -1
  11. package/dist/ergonomic/presets/index.js +1 -1
  12. package/dist/errors.d.ts +59 -1
  13. package/dist/errors.js +51 -0
  14. package/dist/file-first.d.ts +233 -0
  15. package/dist/file-first.js +585 -21
  16. package/dist/generated/sdk_spec/enums.d.ts +0 -11
  17. package/dist/generated/sdk_spec/enums.js +0 -7
  18. package/dist/generated/sdk_spec/errors.d.ts +1 -1
  19. package/dist/generated/sdk_spec/errors.js +26 -0
  20. package/dist/generated/sdk_spec/presets.js +0 -3
  21. package/dist/generated/sdk_spec/version.d.ts +2 -2
  22. package/dist/generated/sdk_spec/version.js +2 -2
  23. package/dist/handle.js +34 -14
  24. package/dist/index.browser.d.ts +1 -0
  25. package/dist/index.browser.js +14 -0
  26. package/dist/index.core.d.ts +35 -0
  27. package/dist/index.core.js +102 -0
  28. package/dist/index.d.ts +1 -32
  29. package/dist/index.js +9 -89
  30. package/dist/lazy-downloader.d.ts +19 -0
  31. package/dist/lazy-downloader.js +19 -0
  32. package/dist/merge.d.ts +11 -0
  33. package/dist/merge.js +144 -45
  34. package/dist/node-fs.browser.d.ts +17 -0
  35. package/dist/node-fs.browser.js +7 -0
  36. package/dist/node-fs.d.ts +14 -0
  37. package/dist/node-fs.js +14 -0
  38. package/dist/sha256.d.ts +20 -0
  39. package/dist/sha256.js +108 -0
  40. package/dist/types.d.ts +54 -2
  41. package/dist/types.js +2 -0
  42. package/package.json +15 -2
@@ -20,12 +20,6 @@ export declare const ImageFormat: {
20
20
  readonly Avif: "avif";
21
21
  };
22
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
23
  export declare const ImageMetadataPolicy: {
30
24
  readonly All: "all";
31
25
  readonly None: "none";
@@ -122,11 +116,6 @@ export declare const ERGONOMIC_ENUMS: {
122
116
  readonly Webp: "webp";
123
117
  readonly Avif: "avif";
124
118
  };
125
- readonly ImageFit: {
126
- readonly Max: "max";
127
- readonly Crop: "crop";
128
- readonly Scale: "scale";
129
- };
130
119
  readonly ImageMetadataPolicy: {
131
120
  readonly All: "all";
132
121
  readonly None: "none";
@@ -23,12 +23,6 @@ export const ImageFormat = {
23
23
  Webp: "webp",
24
24
  Avif: "avif",
25
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
26
  // Image metadata handling. Counter-intuitive wire naming:
33
27
  // All = strip everything (smallest file)
34
28
  // None = keep all EXIF/IPTC/XMP
@@ -113,7 +107,6 @@ export const ERGONOMIC_ENUMS = {
113
107
  OptimizeFor,
114
108
  ImageMode,
115
109
  ImageFormat,
116
- ImageFit,
117
110
  ImageMetadataPolicy,
118
111
  IccProfilePolicy,
119
112
  VideoCodec,
@@ -1,4 +1,4 @@
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" | "cyclic_workflow_edges" | "workflow_edge_references_unknown_job" | "reserved_job_id_pattern" | "cyclic_job_output_source_graph" | "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";
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" | "validation_error" | "cyclic_workflow_edges" | "workflow_edge_references_unknown_job" | "reserved_job_id_pattern" | "cyclic_job_output_source_graph" | "auth_failed" | "feature_tier_restricted" | "tier_restriction" | "multipart_session_ownership" | "multipart_session_auth_required" | "multipart_session_not_found" | "upload_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
2
  export type ErrorCategory = 'api' | 'config' | 'network' | 'auth' | 'validation' | 'chain';
3
3
  export type ErrorStatus = 'wired' | 'planned';
4
4
  export interface ErrorEntry {
@@ -150,6 +150,19 @@ export const ERROR_CODES = Object.freeze({
150
150
  "details": "array",
151
151
  }),
152
152
  }),
153
+ "validation_error": Object.freeze({
154
+ code: "validation_error",
155
+ category: "validation",
156
+ source: "error_type",
157
+ status: "wired",
158
+ httpStatus: 422,
159
+ retryable: false,
160
+ sdkClass: "GislValidationError",
161
+ description: "422 — `error_type` discriminator on `ValidationErrorEnvelope` (ADR-0018/0019); distinct from `validation_failed` (the `error` code), same `GislValidationError`. Carries `details[]`.",
162
+ metadataSchema: Object.freeze({
163
+ "details": "array",
164
+ }),
165
+ }),
153
166
  "cyclic_workflow_edges": Object.freeze({
154
167
  code: "cyclic_workflow_edges",
155
168
  category: "validation",
@@ -277,6 +290,17 @@ export const ERROR_CODES = Object.freeze({
277
290
  "uploadId": "string",
278
291
  }),
279
292
  }),
293
+ "upload_not_found": Object.freeze({
294
+ code: "upload_not_found",
295
+ category: "api",
296
+ source: "ErrorEnvelope.error",
297
+ status: "wired",
298
+ httpStatus: 404,
299
+ retryable: false,
300
+ sdkClass: "GislApiError",
301
+ description: "404 on POST /api/workflows — a referenced upload was not found, OR exists but is owned by a different identity (deliberate BOLA/IDOR existence-mask: reported as not-found, never 403, so the response does not reveal another user's upload exists). message_key upload.not_found. Wire token UPLOAD_NOT_FOUND keyed on the `error` field. Per ADR-0016 amendment.",
302
+ metadataSchema: Object.freeze({}),
303
+ }),
280
304
  "workflow_expired": Object.freeze({
281
305
  code: "workflow_expired",
282
306
  category: "api",
@@ -477,6 +501,7 @@ export const ERROR_CATEGORIES = Object.freeze({
477
501
  "feature_tier_restricted",
478
502
  "tier_restriction",
479
503
  "multipart_session_not_found",
504
+ "upload_not_found",
480
505
  "workflow_expired",
481
506
  "balance_exhausted",
482
507
  "feature_not_available",
@@ -504,6 +529,7 @@ export const ERROR_CATEGORIES = Object.freeze({
504
529
  "multipart_part_invalid",
505
530
  "multipart_part_count_exceeded",
506
531
  "validation_failed",
532
+ "validation_error",
507
533
  "cyclic_workflow_edges",
508
534
  "workflow_edge_references_unknown_job",
509
535
  "reserved_job_id_pattern",
@@ -8,7 +8,6 @@ export const PRESETS = Object.freeze({
8
8
  "quality": 65,
9
9
  "metadata": "All",
10
10
  "iccProfile": "Strip",
11
- "autoOrient": true,
12
11
  "progressive": true,
13
12
  "outputFormat": "Smallest",
14
13
  }),
@@ -17,7 +16,6 @@ export const PRESETS = Object.freeze({
17
16
  "quality": 80,
18
17
  "metadata": "Sensitive",
19
18
  "iccProfile": "Preserve",
20
- "autoOrient": true,
21
19
  "progressive": true,
22
20
  "outputFormat": "Auto",
23
21
  }),
@@ -25,7 +23,6 @@ export const PRESETS = Object.freeze({
25
23
  "mode": "Lossless",
26
24
  "metadata": "None",
27
25
  "iccProfile": "Preserve",
28
- "autoOrient": true,
29
26
  "progressive": true,
30
27
  "outputFormat": "Original",
31
28
  }),
@@ -1,3 +1,3 @@
1
- export declare const SDK_SPEC_VERSION: "1.2.0";
1
+ export declare const SDK_SPEC_VERSION: "1.5.0";
2
2
  export declare const PRESET_VERSION: "1.0";
3
- export declare const PRESET_CONFIG_HASH: "sha256:35aeb0b6b86edd9814ace5b75cfeef8a7b1432ecb8e4d5ee8b38d9187a0b45eb";
3
+ export declare const PRESET_CONFIG_HASH: "sha256:dc48f4d31f4037cc07fb0686519122c03a55b03a41f05fbfc2af54e54950a0d2";
@@ -1,6 +1,6 @@
1
1
  // CODE GENERATED — DO NOT EDIT.
2
2
  // Source: compression_contracts/sdk-spec/ (see sdk-spec/README.md).
3
3
  // Regenerate with: scripts/generate.py.
4
- export const SDK_SPEC_VERSION = "1.2.0";
4
+ export const SDK_SPEC_VERSION = "1.5.0";
5
5
  export const PRESET_VERSION = "1.0";
6
- export const PRESET_CONFIG_HASH = "sha256:35aeb0b6b86edd9814ace5b75cfeef8a7b1432ecb8e4d5ee8b38d9187a0b45eb";
6
+ export const PRESET_CONFIG_HASH = "sha256:dc48f4d31f4037cc07fb0686519122c03a55b03a41f05fbfc2af54e54950a0d2";
package/dist/handle.js CHANGED
@@ -32,10 +32,10 @@
32
32
  *
33
33
  * Mirrors the PHP `Gisl\Sdk\Ergonomic\Handle` + `Gisl\Sdk\Ergonomic\StatusSnapshot`.
34
34
  */
35
- import { GislApiError, GislConfigError, GislResultNotReadyError, GislTimeoutError, } from './errors.js';
35
+ import { GislConfigError, GislNetworkError, GislResultNotReadyError, GislTimeoutError, SseEndedWithoutTerminal, } from './errors.js';
36
36
  import { _consumeSseToTerminal, _pollToTerminal, _parseMaxWait, } from './builder.js';
37
- import { projectDownloadsToRunResult, projectMultiJobToRunResult, isFanoutStatus, } from './file-first.js';
38
- import { HttpDownloader } from './http-downloader.js';
37
+ import { projectDownloadsToRunResult, projectMultiJobToRunResult, isFanoutStatus, isMergeStatus, isArchiveStatus, } from './file-first.js';
38
+ import { LazyHttpDownloader } from './lazy-downloader.js';
39
39
  /**
40
40
  * The terminal workflow states. A status response in any of these states
41
41
  * will not change without caller action. Mirrors the `TERMINAL_STATUSES`
@@ -157,16 +157,14 @@ export class Handle {
157
157
  });
158
158
  }
159
159
  catch (err) {
160
- // Mirror Recipe.run(): only genuine SSE transport / clean-stream-end
161
- // failures fall through to poll. Caller-deadline, abort, and API errors
162
- // MUST propagate re-issuing the same doomed request via poll would mask
163
- // them.
164
- if (err instanceof GislTimeoutError)
165
- throw err;
166
- if (err instanceof DOMException && err.name === 'AbortError')
167
- throw err;
168
- if (err instanceof GislApiError)
160
+ // TDqmkWpX: mirror Recipe.run() poll-fallback ONLY on a clean SSE
161
+ // stream-end (SseEndedWithoutTerminal) or a typed transport error
162
+ // (GislNetworkError). Everything else (timeout, abort, API, an onProgress
163
+ // callback throw, anything unexpected) MUST propagate — re-issuing the same
164
+ // doomed request via poll would mask the real failure.
165
+ if (!(err instanceof SseEndedWithoutTerminal || err instanceof GislNetworkError)) {
169
166
  throw err;
167
+ }
170
168
  finalStatus = await _pollToTerminal(client, {
171
169
  workflowId: this.workflowId,
172
170
  deadline,
@@ -177,6 +175,11 @@ export class Handle {
177
175
  throw new GislTimeoutError(`Workflow ${this.workflowId} reached terminal status but maxWait elapsed before downloads could be fetched`);
178
176
  }
179
177
  const downloads = await client.getWorkflowDownloads(this.workflowId);
178
+ // TDqmkWpX: re-check AFTER the downloads fetch so a slow getWorkflowDownloads
179
+ // cannot return a success past the advertised maxWait.
180
+ if (Date.now() >= deadline) {
181
+ throw new GislTimeoutError(`Workflow ${this.workflowId} downloads fetch completed after maxWait elapsed`);
182
+ }
180
183
  return this.project(finalStatus, downloads.downloads);
181
184
  }
182
185
  /**
@@ -218,6 +221,22 @@ export class Handle {
218
221
  if (isFanoutStatus(finalStatus)) {
219
222
  return projectMultiJobToRunResult(this.workflowId, finalStatus, jobDownloads, new Map(), downloader);
220
223
  }
224
+ // A fluent `files([...]).merge(...)` combine — project ONLY the merged
225
+ // output, filtering the `src_*` passthrough plumbing (which re-exposes the
226
+ // raw inputs). Matches MergedRecipe.run()'s `ref === 'merge'` filter so a
227
+ // submitted/reattached merge handle never surfaces the input artifacts
228
+ // alongside the combined output (codex c1).
229
+ if (isMergeStatus(finalStatus)) {
230
+ const mergeDownloads = jobDownloads.filter((d) => d.ref === 'merge');
231
+ return projectDownloadsToRunResult(this.workflowId, finalStatus, mergeDownloads, null, downloader);
232
+ }
233
+ // A fluent `files([...]).archive(...)` bundle — project ONLY the archive
234
+ // output, filtering the `src_*` passthrough plumbing (mirror of the merge
235
+ // branch for archive).
236
+ if (isArchiveStatus(finalStatus)) {
237
+ const archiveDownloads = jobDownloads.filter((d) => d.ref === 'archive');
238
+ return projectDownloadsToRunResult(this.workflowId, finalStatus, archiveDownloads, null, downloader);
239
+ }
221
240
  return projectDownloadsToRunResult(this.workflowId, finalStatus, jobDownloads, this.#key, downloader);
222
241
  }
223
242
  /**
@@ -240,8 +259,9 @@ export class Handle {
240
259
  }
241
260
  makeDownloader() {
242
261
  // Download URLs from getWorkflowDownloads are pre-signed and require no SDK
243
- // auth, so the downloader issues a plain unauthenticated fetch.
244
- return new HttpDownloader();
262
+ // auth, so the downloader issues a plain unauthenticated fetch. Lazy so the
263
+ // node:fs-importing HttpDownloader stays out of the browser static graph.
264
+ return new LazyHttpDownloader();
245
265
  }
246
266
  requireClient() {
247
267
  if (this.#client === undefined) {
@@ -0,0 +1 @@
1
+ export * from './index.core.js';
@@ -0,0 +1,14 @@
1
+ // Browser entry point — selected by the `browser` exports condition in
2
+ // package.json (Vite / webpack / Rollup / esbuild / Parcel; Node ignores it).
3
+ //
4
+ // Re-exports ONLY the browser-safe shared surface (`index.core.ts`). It
5
+ // deliberately OMITS the Node-only `verifyWebhook` (node:crypto) and
6
+ // `HttpDownloader` (node:fs) that the Node entry (`index.ts`) adds — keeping
7
+ // `node:` built-ins out of the browser static import graph. A strict subset of
8
+ // the Node entry by construction, so it cannot silently drift.
9
+ //
10
+ // Output sinks (`RunResult.downloadTo()` / `toFile()`) are Node-only and throw
11
+ // `GislSinkError` in a browser by design — read `RunResult.artifacts[].url`
12
+ // (or `RunResult.url` for a single output) and fetch it in the browser. See
13
+ // docs/typescript/browser.md.
14
+ export * from './index.core.js';
@@ -0,0 +1,35 @@
1
+ export { GislClient, DEFAULT_MULTIPART_FIRST_CHUNK_SIZE } from './client.js';
2
+ export { parseSseStream } from './sse.js';
3
+ export type { CreditsUsageOptions, ListWorkflowsOptions, GetSchemaOptions, GetSchemaResult, PreflightClipError, PreflightClipsResult, GislClientConfig, GislSseEvent, UploadOptions, WaitOptions, WorkflowCreatePayload, OperationDef, WorkflowSourcePayload, MultiInputSourcePayload, UploadSourcePayload, JobOutputSourcePayload, ExternalImportSourcePayload, ConnectionSourcePayload, JobInputV2Payload, JobDefinitionPayload, ExternalDestinationPayload, DeliveryPayload, DeliveryModePayload, DeliveryBundleFormatPayload, DeliverySelectionPayload, DeliverySelectionTypePayload, DeliveryOutputRefPayload, WorkflowProcessingPayload, ProcessingClassHintPayload, MultipartCheckpointState, _Sdk3HandCodedUploadedPart, _Sdk3HandCodedMultipartStatusResult, _Sdk3HandCodedPresignedPart, _Sdk3HandCodedPresignPartsResult, _Sdk3HandCodedKeepaliveResult, } from './types.js';
4
+ export { uploadSource, jobOutputSource, externalImportSource, connectionSource, } from './types.js';
5
+ export type { GislConfigErrorMetadata } from './errors.js';
6
+ export { GislError, GislApiError, GislValidationError, GislBalanceExhaustedError, GislTierRestrictedError, GislFeatureTierRestrictedError, GislFeatureNotAvailableError, GislWorkflowExpiredError, GislProbePendingError, GislAuthError, GislUploadCapExceededError, GislMultipartPartError, GislMultipartPartCountError, GislMultipartSessionNotFoundError, GislMultipartSessionOwnershipError, GislMultipartSessionAuthRequiredError, GislTimeoutError, GislAbortError, GislNetworkError, GislConfigError, GislMissingCredentialsError, GislFeatureRequiresAuthError, GislUndeclaredAssetError, GislUnusedAssetError, GislPerInputOptionsNotSupportedError, GislChainCardinalityMismatchError, GislNoSuchKeyError, GislSinkError, GislResultNotReadyError, } from './errors.js';
7
+ export type { GislApiErrorOptions, GislUploadCapKind } from './errors.js';
8
+ export { RunResult } from './file-first.js';
9
+ export type { OutputFile, ItemResult, ItemFailure, Manifest, Downloader, } from './file-first.js';
10
+ export { Recipe, fileInput } from './file-first.js';
11
+ export type { FileInput } from './file-first.js';
12
+ export { FilesRecipe } from './file-first.js';
13
+ export { MergedRecipe } from './file-first.js';
14
+ export { ArchivedRecipe } from './file-first.js';
15
+ export type { ArchiveRecipeOptions } from './file-first.js';
16
+ export { Handle, StatusSnapshot } from './handle.js';
17
+ export { gisl, create } from './gisl.js';
18
+ export type { GislCreateOptions, Environment, ErgonomicClient } from './gisl.js';
19
+ export { presetDefaults, PresetDefaults, type PresetMedia, type PresetOp, type AnyPresetOptions, ImageCompressPresetOptions, type ImageCompressPresetOptionsInput, AudioCompressPresetOptions, type AudioCompressPresetOptionsInput, VideoCompressPresetOptions, type VideoCompressPresetOptionsInput, DocumentPdfCompressPresetOptions, type DocumentPdfCompressPresetOptionsInput, DocumentOfficeCompressPresetOptions, type DocumentOfficeCompressPresetOptionsInput, DocumentOdfCompressPresetOptions, type DocumentOdfCompressPresetOptionsInput, DocumentEpubCompressPresetOptions, type DocumentEpubCompressPresetOptionsInput, OptimizeFor, ImageMode, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from './ergonomic/presets/index.js';
20
+ export { OperationBuilder, MapEachBuilder } from './builder.js';
21
+ export { MergeBuilder, asset, handle, clip } from './merge.js';
22
+ export type { Asset, ClipEntry, ClipOptions, MergeMediaKind, MergeOptions, SequenceEntry, } from './merge.js';
23
+ export type { Artifact, ArtifactRef, JobBreakdown, OperationBreakdown, ProcessingProgressEvent, ProgressEvent, ResolvedOptions, ResolvedOptionsSources, Result, RunOptions, SubmitOptions, UploadProgressEvent, } from './builder.js';
24
+ export { PRESET_VERSION, resolveCompressOptions } from './ergonomic/preset_resolver.js';
25
+ export type { ResolveCompressOptionsInput, ResolveCompressOptionsOutput, } from './ergonomic/preset_resolver.js';
26
+ export type { AudioWatermarkDecodeRequest, AudioWatermarkDecodeResponse, ContactRequest, CreditsBalanceResponse, CreditsUsageResponse, CreditTransaction, ExternalImportCreatedResponse, ExternalImportRequest, LoginUserRequest, LoginUser200ResponseData, LoginUser200ResponseDataUser, WorkflowCancelResponse, WorkflowResumeResponse, WorkflowPausedDetail, WorkflowPausedDetailLinks, UploadResponse, UploadConstraintsApplied, UploadProbeResponse, UploadProbeMediaMetadata, MultipartInitiateRequestMetadataHint, WorkflowCreateResponse, WorkflowStatusResponse, WorkflowListResponse, WorkflowSummary, WorkflowDownloadResponse, MetadataResponse, MetadataResponseDimensions, MetadataResponseExif, MetadataResponseExifGps, OperationsSchemaResponse, OperationSchemaDefinition, MimeGroupSchema, OptionSchema, PerValueAvailabilityEntry, PerRoleCardinalityEntry, RetryResponse, JobDownload, OperationDownload, WebhookPayload, WebhookOperationContext, JobResponse, OperationResponse, OperationResult, OperationResultMetrics, ExternalDestination, Delivery, DeliveryPlan, DeliveryPlanOutput, WorkflowProcessing, ProcessingPlan, ProcessingPlanJob, WorkflowEdge, WorkflowWarning, JobInputV2, WorkflowSource, UploadSource, JobOutputSource, ConnectionSource, ExternalImportToken, BalanceExhaustedResponse, BalanceExhaustedResponseAllOfLinks, TierRestrictionResponse, FeatureTierRestrictedResponse, FeatureNotAvailableResponse, FeatureViolation, WorkflowExpiredResponse, ProbePendingResponse, AuthErrorResponse, } from '@giveitsmaller/contracts/openapi';
27
+ export { AudioWatermarkDecodeRequestMethodHintEnum, AudioWatermarkDecodeResponseMethodEnum, OperationInputModel, ExternalImportRequestProviderHintEnum, ContactSubject, CreditTransactionSourceBucket, UploadProbeStatus, UploadProbeProcessingClass, WorkflowCancelBillingEffect, WorkflowPauseRequiredAction, WorkflowStatus, WarningType, WorkflowWarningSeverity, OperationType, SseEventType, CallbackEventType, OperationStatus, JobStatus, JobInputV2RoleEnum, AuthErrorType, TierRestrictionKind, BalanceExhaustedResponseRequiredActionEnum, ProcessingClassReason, DeliveryPlanReason, UserTier, ProcessingClass, } from '@giveitsmaller/contracts/openapi';
28
+ export type { SseOperationProgressData, SseOperationCompletedData, SseOperationFailedData, SseJobCompletedData, SseJobFailedData, SseWorkflowTerminalData, } from '@giveitsmaller/contracts/openapi';
29
+ export type { MultiOutputCompletion, PageIndexed, PositionIndexed, Unindexed, } from '@giveitsmaller/contracts/asyncapi';
30
+ import type { MultiOutputCompletion as _MultiOutputCompletion } from '@giveitsmaller/contracts/asyncapi';
31
+ export type OperationResultOutputEntry = _MultiOutputCompletion['outputs'][number];
32
+ export type { CompressImageOptions, CompressVideoOptions, CompressAudioOptions, CompressDocumentPdfOptions, CompressDocumentOfficeOptions, CompressDocumentOdfOptions, CompressDocumentEpubOptions, ThumbnailImageOptions, ThumbnailVideoOptions, ThumbnailDocumentOptions, ConvertImageOptions, ConvertVideoOptions, ConvertAudioOptions, ConvertDocumentPdfOptions, MergeImageOptions, MergeVideoOptions, MergeVideoPerInputOptions, MergeAudioOptions, MergeAudioPerInputOptions, ArchiveOptions, ImageWatermarkImageOptions, ImageWatermarkImageGifOptions, TextWatermarkImageOptions, CustomLumaVideoOptions, AudioOverlayAudioOptions, AudioOverlayVideoOptions, AudioWatermarkAudioOptions, AudioWatermarkVideoOptions, AudioToVideoAudioOptions, VideoWatermarkVideoOptions, VideoTextWatermarkVideoOptions, SplitImageGifOptions, SplitDocumentPdfOptions, SplitAudioOptions, SplitVideoOptions, } from '@giveitsmaller/contracts/operations';
33
+ export { ImageWatermarkImageAnchor, ImageWatermarkImageGifAnchor, TextWatermarkImageAnchor, TextWatermarkImageFontFamily, TextWatermarkImageWatermarkMode, AudioOverlayAudioMode, AudioOverlayVideoMode, AudioOverlayVideoNoAudioTrackBehaviour, AudioWatermarkAudioMethod, AudioWatermarkAudioRobustness, AudioWatermarkAudioDensity, AudioWatermarkVideoMethod, AudioWatermarkVideoRobustness, AudioWatermarkVideoDensity, AudioToVideoAudioOutputResolution, AudioToVideoAudioImageFit, AudioToVideoAudioOutputFormat, VideoWatermarkVideoAnchor, VideoTextWatermarkVideoFontFamily, VideoTextWatermarkVideoWatermarkMode, VideoTextWatermarkVideoAnchor, SplitImageGifOutputFormat, SplitDocumentPdfMode, SplitAudioMode, SplitAudioPrecision, SplitVideoMode, SplitVideoPrecision, } from '@giveitsmaller/contracts/operations';
34
+ export { archiveMetadata, audioOverlayMetadata, audioWatermarkMetadata, compressMetadata, convertMetadata, customLumaMetadata, imageWatermarkMetadata, mergeMetadata, textWatermarkMetadata, thumbnailMetadata, audioToVideoMetadata, videoWatermarkMetadata, videoTextWatermarkMetadata, splitMetadata, } from '@giveitsmaller/contracts/operations';
35
+ export type { OperationMetadata, AvailabilityValue, AvailabilityEntry, FeatureEntry, MimeGroupMetadata, OptionMetadata, ProcessingClassConstraints, } from '@giveitsmaller/contracts/operations';
@@ -0,0 +1,102 @@
1
+ // Browser-safe shared surface. The Node-only entry (`index.ts`) re-exports
2
+ // everything here PLUS the Node-only symbols (`verifyWebhook`, `HttpDownloader`)
3
+ // that statically import node:crypto / node:fs; the browser entry
4
+ // (`index.browser.ts`) re-exports ONLY this core, so it is a strict subset by
5
+ // construction (no hand-maintained subset to drift). Keep this file free of any
6
+ // static `node:` import — see the bundle-gate test.
7
+ // SDK classes and functions
8
+ export { GislClient, DEFAULT_MULTIPART_FIRST_CHUNK_SIZE } from './client.js';
9
+ export { parseSseStream } from './sse.js';
10
+ export { uploadSource, jobOutputSource, externalImportSource, connectionSource, } from './types.js';
11
+ // Errors
12
+ export { GislError, GislApiError, GislValidationError, GislBalanceExhaustedError, GislTierRestrictedError, GislFeatureTierRestrictedError, GislFeatureNotAvailableError, GislWorkflowExpiredError, GislProbePendingError, GislAuthError, GislUploadCapExceededError, GislMultipartPartError, GislMultipartPartCountError,
13
+ // SDK-3 (Wb6ebOMM) — typed errors for the 3 resume-support endpoints.
14
+ GislMultipartSessionNotFoundError, GislMultipartSessionOwnershipError, GislMultipartSessionAuthRequiredError, GislTimeoutError, GislAbortError,
15
+ // FF2b / tywwynmN — transport-level failure (mirrors PHP GislNetworkError);
16
+ // raised by the file-first HttpDownloader when an output URL cannot be read.
17
+ GislNetworkError,
18
+ // T1 / wVU4xHx3 — local config-error tree (pre-I/O; sibling of GislApiError).
19
+ GislConfigError, GislMissingCredentialsError, GislFeatureRequiresAuthError,
20
+ // T3 / cuecCmb5 — merge-compose local validation errors.
21
+ GislUndeclaredAssetError, GislUnusedAssetError, GislPerInputOptionsNotSupportedError,
22
+ // T6 / aDR1jnyZ — chain-cardinality validation (dormant until chain
23
+ // methods on OperationBuilder ship; type + audit registration land
24
+ // here so the future chain-method PR is a pure addition).
25
+ GislChainCardinalityMismatchError,
26
+ // FF1 / 3BIxEnfR — file-first result sink errors.
27
+ GislNoSuchKeyError, GislSinkError,
28
+ // FF5a / Ao8RPVxD — thrown by the file-first Handle.result() when the
29
+ // workflow is not yet terminal (the non-blocking accessor).
30
+ GislResultNotReadyError, } from './errors.js';
31
+ // File-first result surface (FF1 / 3BIxEnfR) — coexists with the
32
+ // operation-first `Result`/`Artifact` until FF6 removes the old layer.
33
+ export { RunResult } from './file-first.js';
34
+ // File-first builder (FF2a / MfV0PDok) — `client.file(path).op()...` lowering.
35
+ export { Recipe, fileInput } from './file-first.js';
36
+ // File-first homogeneous fan-out (FF3a / u0hBt6fl) — `client.files([...]).op()...`
37
+ // applies one recipe to many inputs in one workflow; run() partitions per input.
38
+ // `projectMultiJobToRunResult` is intentionally NOT re-exported — it is the
39
+ // @internal per-job producer consumed only by FilesRecipe.run (codex).
40
+ export { FilesRecipe } from './file-first.js';
41
+ // File-first N→1 combine (FF3b / IE29x9QL) — `client.files([...]).merge(opts?)`
42
+ // returns a single-output MergedRecipe you chain post-combine ops on, then
43
+ // run()/submit(). Mirrors the operation-first `client.merge()` wire shape.
44
+ export { MergedRecipe } from './file-first.js';
45
+ // File-first N→1 bundle (FF3b) — `client.files([...]).archive(opts?)` returns a
46
+ // terminal ArchivedRecipe (zip / tar.gz; no post-bundle chain), then run()/submit().
47
+ export { ArchivedRecipe } from './file-first.js';
48
+ // `HttpDownloader` (Node streaming downloader) is re-exported from the Node-only
49
+ // entry `index.ts`, NOT here — it statically imports node:fs/node:stream.
50
+ // `projectDownloadsToRunResult` is intentionally NOT re-exported here — it is an
51
+ // @internal helper shared between `file-first.ts` (Recipe.run) and `handle.ts`
52
+ // (Handle.wait/result) via direct intra-package import, not public API (codex).
53
+ // File-first Handle + StatusSnapshot (FF5a / Ao8RPVxD) — method-bearing,
54
+ // client-bound value objects. `Handle` is the return of `submit()` (no client)
55
+ // AND `client.workflow(id)` (client-bound, reattach). Exported as VALUES (the
56
+ // prior `export type { Handle }` is replaced) because `Handle` is now a class.
57
+ export { Handle, StatusSnapshot } from './handle.js';
58
+ // Ergonomic-layer entrypoint (T1 / wVU4xHx3) — `gisl.create()` factory +
59
+ // credential-chain types. `gisl.anonymous()` (public export) lands once
60
+ // the anonymous-capable operation allowlist is non-empty (plan §12).
61
+ export { gisl, create } from './gisl.js';
62
+ // Ergonomic preset defaults (T4a / VhIj4S7T) — typed leaf DTOs + immutable
63
+ // `PresetDefaults` builder + `presetDefaults()` factory + ergonomic enum
64
+ // re-exports. Resolver wiring (T4b) consumes `PresetDefaults.cellFor()`.
65
+ export { presetDefaults, PresetDefaults, ImageCompressPresetOptions, AudioCompressPresetOptions, VideoCompressPresetOptions, DocumentPdfCompressPresetOptions, DocumentOfficeCompressPresetOptions, DocumentOdfCompressPresetOptions, DocumentEpubCompressPresetOptions, OptimizeFor, ImageMode, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from './ergonomic/presets/index.js';
66
+ // Operation-builder surface (T2 / xVDTIm8C) — `client.compress/convert/thumbnail`
67
+ // returns an `OperationBuilder`; `.run()` projects to a flat `Result` /
68
+ // `.submit({webhook})` returns a `Handle`. Progress events are the
69
+ // SDK-synthesised `{phase:'upload'|'processing', ...}` discriminated union.
70
+ export { OperationBuilder, MapEachBuilder } from './builder.js';
71
+ export { MergeBuilder, asset, handle, clip } from './merge.js';
72
+ // T4b — preset resolver public surface (PRESET_VERSION constant + types).
73
+ export { PRESET_VERSION, resolveCompressOptions } from './ergonomic/preset_resolver.js';
74
+ export { AudioWatermarkDecodeRequestMethodHintEnum, AudioWatermarkDecodeResponseMethodEnum,
75
+ // OperationInputModel — value-bearing enum (`single` | `multi`).
76
+ // Surfaced on OperationSchemaDefinition.inputModel so form-renderers
77
+ // can decide whether to render a single-file picker or a multi-file
78
+ // input list.
79
+ OperationInputModel, ExternalImportRequestProviderHintEnum, ContactSubject, CreditTransactionSourceBucket, UploadProbeStatus, UploadProbeProcessingClass, WorkflowCancelBillingEffect, WorkflowPauseRequiredAction, WorkflowStatus, WarningType, WorkflowWarningSeverity, OperationType, SseEventType, CallbackEventType, OperationStatus, JobStatus, JobInputV2RoleEnum,
80
+ // Error-payload discriminator enums — pair with the typed payload
81
+ // types above for narrowing inside `error instanceof Gisl<X>Error`
82
+ // branches.
83
+ AuthErrorType, TierRestrictionKind, BalanceExhaustedResponseRequiredActionEnum, ProcessingClassReason, DeliveryPlanReason,
84
+ // UserTier + ProcessingClass — value-bearing forms (typeof const +
85
+ // type alias). Sourced from openapi so consumers can do
86
+ // `Object.values(UserTier)` for tier dropdowns or
87
+ // `if (tier === UserTier.enterprise)` for narrowing typed error
88
+ // payloads. The operations metadata-types versions are pure type
89
+ // aliases (no runtime value); the openapi versions carry both the
90
+ // string-union type and a const map. Per audit follow-up.
91
+ UserTier, ProcessingClass, } from '@giveitsmaller/contracts/openapi';
92
+ export { ImageWatermarkImageAnchor, ImageWatermarkImageGifAnchor, TextWatermarkImageAnchor, TextWatermarkImageFontFamily, TextWatermarkImageWatermarkMode, AudioOverlayAudioMode, AudioOverlayVideoMode, AudioOverlayVideoNoAudioTrackBehaviour, AudioWatermarkAudioMethod, AudioWatermarkAudioRobustness, AudioWatermarkAudioDensity, AudioWatermarkVideoMethod, AudioWatermarkVideoRobustness, AudioWatermarkVideoDensity,
93
+ // New planned operation enums — contracts v2.15 (AJCLLGaG).
94
+ AudioToVideoAudioOutputResolution, AudioToVideoAudioImageFit, AudioToVideoAudioOutputFormat, VideoWatermarkVideoAnchor, VideoTextWatermarkVideoFontFamily, VideoTextWatermarkVideoWatermarkMode, VideoTextWatermarkVideoAnchor, SplitImageGifOutputFormat, SplitDocumentPdfMode, SplitAudioMode, SplitAudioPrecision, SplitVideoMode, SplitVideoPrecision, } from '@giveitsmaller/contracts/operations';
95
+ // Per-operation metadata sidecars. Inspect `availability`,
96
+ // `required_tier`, per-value gating, mime-group availability and
97
+ // per-feature flags before submitting a workflow — the API will
98
+ // otherwise reject planned ops with `feature_not_available` (422,
99
+ // surfaces as `GislFeatureNotAvailableError`).
100
+ export { archiveMetadata, audioOverlayMetadata, audioWatermarkMetadata, compressMetadata, convertMetadata, customLumaMetadata, imageWatermarkMetadata, mergeMetadata, textWatermarkMetadata, thumbnailMetadata,
101
+ // New planned operation metadata sidecars — contracts v2.15 (AJCLLGaG).
102
+ audioToVideoMetadata, videoWatermarkMetadata, videoTextWatermarkMetadata, splitMetadata, } from '@giveitsmaller/contracts/operations';
package/dist/index.d.ts CHANGED
@@ -1,34 +1,3 @@
1
- export { GislClient, DEFAULT_MULTIPART_FIRST_CHUNK_SIZE } from './client.js';
1
+ export * from './index.core.js';
2
2
  export { verifyWebhook } from './webhook.js';
3
- export { parseSseStream } from './sse.js';
4
- export type { CreditsUsageOptions, GetSchemaOptions, GetSchemaResult, PreflightClipError, PreflightClipsResult, GislClientConfig, GislSseEvent, UploadOptions, WaitOptions, WorkflowCreatePayload, OperationDef, WorkflowSourcePayload, UploadSourcePayload, JobOutputSourcePayload, ExternalImportSourcePayload, ConnectionSourcePayload, JobInputV2Payload, JobDefinitionPayload, ExternalDestinationPayload, DeliveryPayload, DeliveryModePayload, DeliveryBundleFormatPayload, DeliverySelectionPayload, DeliverySelectionTypePayload, DeliveryOutputRefPayload, WorkflowProcessingPayload, ProcessingClassHintPayload, MultipartCheckpointState, _Sdk3HandCodedUploadedPart, _Sdk3HandCodedMultipartStatusResult, _Sdk3HandCodedPresignedPart, _Sdk3HandCodedPresignPartsResult, _Sdk3HandCodedKeepaliveResult, } from './types.js';
5
- export { uploadSource, jobOutputSource, externalImportSource, connectionSource, } from './types.js';
6
- export type { GislConfigErrorMetadata } from './errors.js';
7
- export { GislError, GislApiError, GislValidationError, GislBalanceExhaustedError, GislTierRestrictedError, GislFeatureTierRestrictedError, GislFeatureNotAvailableError, GislWorkflowExpiredError, GislProbePendingError, GislAuthError, GislUploadCapExceededError, GislMultipartPartError, GislMultipartPartCountError, GislMultipartSessionNotFoundError, GislMultipartSessionOwnershipError, GislMultipartSessionAuthRequiredError, GislTimeoutError, GislAbortError, GislNetworkError, GislConfigError, GislMissingCredentialsError, GislFeatureRequiresAuthError, GislUndeclaredAssetError, GislUnusedAssetError, GislPerInputOptionsNotSupportedError, GislChainCardinalityMismatchError, GislNoSuchKeyError, GislSinkError, GislResultNotReadyError, } from './errors.js';
8
- export type { GislApiErrorOptions, GislUploadCapKind } from './errors.js';
9
- export { RunResult } from './file-first.js';
10
- export type { OutputFile, ItemResult, ItemFailure, Manifest, Downloader, } from './file-first.js';
11
- export { Recipe, fileInput } from './file-first.js';
12
- export type { FileInput } from './file-first.js';
13
- export { FilesRecipe } from './file-first.js';
14
3
  export { HttpDownloader } from './http-downloader.js';
15
- export { Handle, StatusSnapshot } from './handle.js';
16
- export { gisl, create } from './gisl.js';
17
- export type { GislCreateOptions, Environment, ErgonomicClient } from './gisl.js';
18
- export { presetDefaults, PresetDefaults, type PresetMedia, type PresetOp, type AnyPresetOptions, ImageCompressPresetOptions, type ImageCompressPresetOptionsInput, AudioCompressPresetOptions, type AudioCompressPresetOptionsInput, VideoCompressPresetOptions, type VideoCompressPresetOptionsInput, DocumentPdfCompressPresetOptions, type DocumentPdfCompressPresetOptionsInput, DocumentOfficeCompressPresetOptions, type DocumentOfficeCompressPresetOptionsInput, DocumentOdfCompressPresetOptions, type DocumentOdfCompressPresetOptionsInput, DocumentEpubCompressPresetOptions, type DocumentEpubCompressPresetOptionsInput, OptimizeFor, ImageMode, ImageFit, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from './ergonomic/presets/index.js';
19
- export { OperationBuilder, MapEachBuilder } from './builder.js';
20
- export { MergeBuilder, asset, handle, clip } from './merge.js';
21
- export type { Asset, ClipEntry, ClipOptions, MergeMediaKind, MergeOptions, SequenceEntry, } from './merge.js';
22
- export type { Artifact, ArtifactRef, JobBreakdown, OperationBreakdown, ProcessingProgressEvent, ProgressEvent, ResolvedOptions, ResolvedOptionsSources, Result, RunOptions, SubmitOptions, UploadProgressEvent, } from './builder.js';
23
- export { PRESET_VERSION, resolveCompressOptions } from './ergonomic/preset_resolver.js';
24
- export type { ResolveCompressOptionsInput, ResolveCompressOptionsOutput, } from './ergonomic/preset_resolver.js';
25
- export type { AudioWatermarkDecodeRequest, AudioWatermarkDecodeResponse, ContactRequest, CreditsBalanceResponse, CreditsUsageResponse, CreditTransaction, ExternalImportCreatedResponse, ExternalImportRequest, LoginUserRequest, LoginUser200ResponseData, LoginUser200ResponseDataUser, WorkflowCancelResponse, WorkflowResumeResponse, WorkflowPausedDetail, WorkflowPausedDetailLinks, UploadResponse, UploadConstraintsApplied, UploadProbeResponse, UploadProbeMediaMetadata, MultipartInitiateRequestMetadataHint, WorkflowCreateResponse, WorkflowStatusResponse, WorkflowDownloadResponse, MetadataResponse, MetadataResponseDimensions, MetadataResponseExif, MetadataResponseExifGps, OperationsSchemaResponse, OperationSchemaDefinition, MimeGroupSchema, OptionSchema, PerValueAvailabilityEntry, PerRoleCardinalityEntry, RetryResponse, JobDownload, OperationDownload, WebhookPayload, WebhookOperationContext, JobResponse, OperationResponse, OperationResult, OperationResultMetrics, ExternalDestination, Delivery, DeliveryPlan, DeliveryPlanOutput, WorkflowProcessing, ProcessingPlan, ProcessingPlanJob, WorkflowEdge, WorkflowWarning, JobInputV2, WorkflowSource, UploadSource, JobOutputSource, ConnectionSource, ExternalImportToken, BalanceExhaustedResponse, BalanceExhaustedResponseAllOfLinks, TierRestrictionResponse, FeatureTierRestrictedResponse, FeatureNotAvailableResponse, FeatureViolation, WorkflowExpiredResponse, ProbePendingResponse, AuthErrorResponse, } from '@giveitsmaller/contracts/openapi';
26
- export { AudioWatermarkDecodeRequestMethodHintEnum, AudioWatermarkDecodeResponseMethodEnum, OperationInputModel, ExternalImportRequestProviderHintEnum, ContactSubject, CreditTransactionSourceBucket, UploadProbeStatus, UploadProbeProcessingClass, WorkflowCancelBillingEffect, WorkflowPauseRequiredAction, WorkflowStatus, WarningType, WorkflowWarningSeverity, OperationType, SseEventType, CallbackEventType, OperationStatus, JobStatus, JobInputV2RoleEnum, AuthErrorType, TierRestrictionKind, BalanceExhaustedResponseRequiredActionEnum, ProcessingClassReason, DeliveryPlanReason, UserTier, ProcessingClass, } from '@giveitsmaller/contracts/openapi';
27
- export type { SseOperationProgressData, SseOperationCompletedData, SseOperationFailedData, SseJobCompletedData, SseJobFailedData, SseWorkflowTerminalData, } from '@giveitsmaller/contracts/openapi';
28
- export type { MultiOutputCompletion, PageIndexed, PositionIndexed, Unindexed, } from '@giveitsmaller/contracts/asyncapi';
29
- import type { MultiOutputCompletion as _MultiOutputCompletion } from '@giveitsmaller/contracts/asyncapi';
30
- export type OperationResultOutputEntry = _MultiOutputCompletion['outputs'][number];
31
- export type { CompressImageOptions, CompressVideoOptions, CompressAudioOptions, CompressDocumentPdfOptions, CompressDocumentOfficeOptions, CompressDocumentOdfOptions, CompressDocumentEpubOptions, ThumbnailImageOptions, ThumbnailVideoOptions, ThumbnailDocumentOptions, ConvertImageOptions, ConvertVideoOptions, ConvertAudioOptions, ConvertDocumentPdfOptions, MergeImageOptions, MergeVideoOptions, MergeVideoPerInputOptions, MergeAudioOptions, MergeAudioPerInputOptions, ArchiveOptions, ImageWatermarkImageOptions, ImageWatermarkImageGifOptions, TextWatermarkImageOptions, CustomLumaVideoOptions, AudioOverlayAudioOptions, AudioOverlayVideoOptions, AudioWatermarkAudioOptions, AudioWatermarkVideoOptions, AudioToVideoAudioOptions, VideoWatermarkVideoOptions, VideoTextWatermarkVideoOptions, SplitImageGifOptions, SplitDocumentPdfOptions, SplitAudioOptions, SplitVideoOptions, } from '@giveitsmaller/contracts/operations';
32
- export { ImageWatermarkImageAnchor, ImageWatermarkImageGifAnchor, TextWatermarkImageAnchor, TextWatermarkImageFontFamily, TextWatermarkImageWatermarkMode, AudioOverlayAudioMode, AudioOverlayVideoMode, AudioOverlayVideoNoAudioTrackBehaviour, AudioWatermarkAudioMethod, AudioWatermarkAudioRobustness, AudioWatermarkAudioDensity, AudioWatermarkVideoMethod, AudioWatermarkVideoRobustness, AudioWatermarkVideoDensity, AudioToVideoAudioOutputResolution, AudioToVideoAudioImageFit, AudioToVideoAudioOutputFormat, VideoWatermarkVideoAnchor, VideoTextWatermarkVideoFontFamily, VideoTextWatermarkVideoWatermarkMode, VideoTextWatermarkVideoAnchor, SplitImageGifOutputFormat, SplitDocumentPdfMode, SplitAudioMode, SplitAudioPrecision, SplitVideoMode, SplitVideoPrecision, } from '@giveitsmaller/contracts/operations';
33
- export { archiveMetadata, audioOverlayMetadata, audioWatermarkMetadata, compressMetadata, convertMetadata, customLumaMetadata, imageWatermarkMetadata, mergeMetadata, textWatermarkMetadata, thumbnailMetadata, audioToVideoMetadata, videoWatermarkMetadata, videoTextWatermarkMetadata, splitMetadata, } from '@giveitsmaller/contracts/operations';
34
- export type { OperationMetadata, AvailabilityValue, AvailabilityEntry, FeatureEntry, MimeGroupMetadata, OptionMetadata, ProcessingClassConstraints, } from '@giveitsmaller/contracts/operations';
package/dist/index.js CHANGED
@@ -1,91 +1,11 @@
1
- // SDK classes and functions
2
- export { GislClient, DEFAULT_MULTIPART_FIRST_CHUNK_SIZE } from './client.js';
1
+ // Node entry point — the package's `default` exports condition (and the
2
+ // historical single entry). Re-exports the browser-safe shared surface
3
+ // (`index.core.ts`) PLUS the Node-only symbols that statically import Node
4
+ // built-ins: `verifyWebhook` (node:crypto) and `HttpDownloader` (node:fs).
5
+ //
6
+ // The browser entry (`index.browser.ts`, selected by the `browser` exports
7
+ // condition) re-exports ONLY the core, omitting these two — so the browser
8
+ // surface is a strict subset of this one by construction and cannot drift.
9
+ export * from './index.core.js';
3
10
  export { verifyWebhook } from './webhook.js';
4
- export { parseSseStream } from './sse.js';
5
- export { uploadSource, jobOutputSource, externalImportSource, connectionSource, } from './types.js';
6
- // Errors
7
- export { GislError, GislApiError, GislValidationError, GislBalanceExhaustedError, GislTierRestrictedError, GislFeatureTierRestrictedError, GislFeatureNotAvailableError, GislWorkflowExpiredError, GislProbePendingError, GislAuthError, GislUploadCapExceededError, GislMultipartPartError, GislMultipartPartCountError,
8
- // SDK-3 (Wb6ebOMM) — typed errors for the 3 resume-support endpoints.
9
- GislMultipartSessionNotFoundError, GislMultipartSessionOwnershipError, GislMultipartSessionAuthRequiredError, GislTimeoutError, GislAbortError,
10
- // FF2b / tywwynmN — transport-level failure (mirrors PHP GislNetworkError);
11
- // raised by the file-first HttpDownloader when an output URL cannot be read.
12
- GislNetworkError,
13
- // T1 / wVU4xHx3 — local config-error tree (pre-I/O; sibling of GislApiError).
14
- GislConfigError, GislMissingCredentialsError, GislFeatureRequiresAuthError,
15
- // T3 / cuecCmb5 — merge-compose local validation errors.
16
- GislUndeclaredAssetError, GislUnusedAssetError, GislPerInputOptionsNotSupportedError,
17
- // T6 / aDR1jnyZ — chain-cardinality validation (dormant until chain
18
- // methods on OperationBuilder ship; type + audit registration land
19
- // here so the future chain-method PR is a pure addition).
20
- GislChainCardinalityMismatchError,
21
- // FF1 / 3BIxEnfR — file-first result sink errors.
22
- GislNoSuchKeyError, GislSinkError,
23
- // FF5a / Ao8RPVxD — thrown by the file-first Handle.result() when the
24
- // workflow is not yet terminal (the non-blocking accessor).
25
- GislResultNotReadyError, } from './errors.js';
26
- // File-first result surface (FF1 / 3BIxEnfR) — coexists with the
27
- // operation-first `Result`/`Artifact` until FF6 removes the old layer.
28
- export { RunResult } from './file-first.js';
29
- // File-first builder (FF2a / MfV0PDok) — `client.file(path).op()...` lowering.
30
- export { Recipe, fileInput } from './file-first.js';
31
- // File-first homogeneous fan-out (FF3a / u0hBt6fl) — `client.files([...]).op()...`
32
- // applies one recipe to many inputs in one workflow; run() partitions per input.
33
- // `projectMultiJobToRunResult` is intentionally NOT re-exported — it is the
34
- // @internal per-job producer consumed only by FilesRecipe.run (codex).
35
- export { FilesRecipe } from './file-first.js';
36
- // File-first execution (FF2b / MfV0PDok) — Node streaming downloader bound by
37
- // `Recipe.run()` to write pre-signed output URLs to disk.
38
11
  export { HttpDownloader } from './http-downloader.js';
39
- // `projectDownloadsToRunResult` is intentionally NOT re-exported here — it is an
40
- // @internal helper shared between `file-first.ts` (Recipe.run) and `handle.ts`
41
- // (Handle.wait/result) via direct intra-package import, not public API (codex).
42
- // File-first Handle + StatusSnapshot (FF5a / Ao8RPVxD) — method-bearing,
43
- // client-bound value objects. `Handle` is the return of `submit()` (no client)
44
- // AND `client.workflow(id)` (client-bound, reattach). Exported as VALUES (the
45
- // prior `export type { Handle }` is replaced) because `Handle` is now a class.
46
- export { Handle, StatusSnapshot } from './handle.js';
47
- // Ergonomic-layer entrypoint (T1 / wVU4xHx3) — `gisl.create()` factory +
48
- // credential-chain types. `gisl.anonymous()` (public export) lands once
49
- // the anonymous-capable operation allowlist is non-empty (plan §12).
50
- export { gisl, create } from './gisl.js';
51
- // Ergonomic preset defaults (T4a / VhIj4S7T) — typed leaf DTOs + immutable
52
- // `PresetDefaults` builder + `presetDefaults()` factory + ergonomic enum
53
- // re-exports. Resolver wiring (T4b) consumes `PresetDefaults.cellFor()`.
54
- export { presetDefaults, PresetDefaults, ImageCompressPresetOptions, AudioCompressPresetOptions, VideoCompressPresetOptions, DocumentPdfCompressPresetOptions, DocumentOfficeCompressPresetOptions, DocumentOdfCompressPresetOptions, DocumentEpubCompressPresetOptions, OptimizeFor, ImageMode, ImageFit, ImageMetadataPolicy, IccProfilePolicy, ImageFormat, VideoCodec, VideoPreset, VideoFit, AudioBitrate, AudioCodec, AudioSampleRate, PdfProfile, PdfColorspace, } from './ergonomic/presets/index.js';
55
- // Operation-builder surface (T2 / xVDTIm8C) — `client.compress/convert/thumbnail`
56
- // returns an `OperationBuilder`; `.run()` projects to a flat `Result` /
57
- // `.submit({webhook})` returns a `Handle`. Progress events are the
58
- // SDK-synthesised `{phase:'upload'|'processing', ...}` discriminated union.
59
- export { OperationBuilder, MapEachBuilder } from './builder.js';
60
- export { MergeBuilder, asset, handle, clip } from './merge.js';
61
- // T4b — preset resolver public surface (PRESET_VERSION constant + types).
62
- export { PRESET_VERSION, resolveCompressOptions } from './ergonomic/preset_resolver.js';
63
- export { AudioWatermarkDecodeRequestMethodHintEnum, AudioWatermarkDecodeResponseMethodEnum,
64
- // OperationInputModel — value-bearing enum (`single` | `multi`).
65
- // Surfaced on OperationSchemaDefinition.inputModel so form-renderers
66
- // can decide whether to render a single-file picker or a multi-file
67
- // input list.
68
- OperationInputModel, ExternalImportRequestProviderHintEnum, ContactSubject, CreditTransactionSourceBucket, UploadProbeStatus, UploadProbeProcessingClass, WorkflowCancelBillingEffect, WorkflowPauseRequiredAction, WorkflowStatus, WarningType, WorkflowWarningSeverity, OperationType, SseEventType, CallbackEventType, OperationStatus, JobStatus, JobInputV2RoleEnum,
69
- // Error-payload discriminator enums — pair with the typed payload
70
- // types above for narrowing inside `error instanceof Gisl<X>Error`
71
- // branches.
72
- AuthErrorType, TierRestrictionKind, BalanceExhaustedResponseRequiredActionEnum, ProcessingClassReason, DeliveryPlanReason,
73
- // UserTier + ProcessingClass — value-bearing forms (typeof const +
74
- // type alias). Sourced from openapi so consumers can do
75
- // `Object.values(UserTier)` for tier dropdowns or
76
- // `if (tier === UserTier.enterprise)` for narrowing typed error
77
- // payloads. The operations metadata-types versions are pure type
78
- // aliases (no runtime value); the openapi versions carry both the
79
- // string-union type and a const map. Per audit follow-up.
80
- UserTier, ProcessingClass, } from '@giveitsmaller/contracts/openapi';
81
- export { ImageWatermarkImageAnchor, ImageWatermarkImageGifAnchor, TextWatermarkImageAnchor, TextWatermarkImageFontFamily, TextWatermarkImageWatermarkMode, AudioOverlayAudioMode, AudioOverlayVideoMode, AudioOverlayVideoNoAudioTrackBehaviour, AudioWatermarkAudioMethod, AudioWatermarkAudioRobustness, AudioWatermarkAudioDensity, AudioWatermarkVideoMethod, AudioWatermarkVideoRobustness, AudioWatermarkVideoDensity,
82
- // New planned operation enums — contracts v2.15 (AJCLLGaG).
83
- AudioToVideoAudioOutputResolution, AudioToVideoAudioImageFit, AudioToVideoAudioOutputFormat, VideoWatermarkVideoAnchor, VideoTextWatermarkVideoFontFamily, VideoTextWatermarkVideoWatermarkMode, VideoTextWatermarkVideoAnchor, SplitImageGifOutputFormat, SplitDocumentPdfMode, SplitAudioMode, SplitAudioPrecision, SplitVideoMode, SplitVideoPrecision, } from '@giveitsmaller/contracts/operations';
84
- // Per-operation metadata sidecars. Inspect `availability`,
85
- // `required_tier`, per-value gating, mime-group availability and
86
- // per-feature flags before submitting a workflow — the API will
87
- // otherwise reject planned ops with `feature_not_available` (422,
88
- // surfaces as `GislFeatureNotAvailableError`).
89
- export { archiveMetadata, audioOverlayMetadata, audioWatermarkMetadata, compressMetadata, convertMetadata, customLumaMetadata, imageWatermarkMetadata, mergeMetadata, textWatermarkMetadata, thumbnailMetadata,
90
- // New planned operation metadata sidecars — contracts v2.15 (AJCLLGaG).
91
- audioToVideoMetadata, videoWatermarkMetadata, videoTextWatermarkMetadata, splitMetadata, } from '@giveitsmaller/contracts/operations';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Browser-safe {@link Downloader} that defers loading the Node-only
3
+ * {@link HttpDownloader} until a sink (`downloadTo` / `toFile`) actually runs.
4
+ *
5
+ * `HttpDownloader` statically imports `node:fs` / `node:stream`
6
+ * (`http-downloader.ts`). Binding it eagerly in `run()` would drag those
7
+ * built-ins into the ergonomic static import graph, breaking browser bundles
8
+ * even though the browser run path never writes to disk. This wrapper is what
9
+ * `run()` / `Handle` bind instead: it is constructed synchronously (no
10
+ * async ripple through the parity-pinned `RunResult` / `Handle`), and the
11
+ * `await import('./http-downloader.js')` only fires when a caller invokes a
12
+ * sink. A browser caller that reads `RunResult.artifacts[].url` never triggers
13
+ * the dynamic import, so `node:fs` stays out of the main browser chunk
14
+ * (bundlers code-split dynamic imports).
15
+ */
16
+ import type { Downloader } from './file-first.js';
17
+ export declare class LazyHttpDownloader implements Downloader {
18
+ downloadTo(url: string, destPath: string): Promise<void>;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { GislSinkError } from './errors.js';
2
+ export class LazyHttpDownloader {
3
+ async downloadTo(url, destPath) {
4
+ // In a browser there is no filesystem — fail with the same clean
5
+ // `downloader_unavailable` GislSinkError a downloader-less RunResult throws,
6
+ // rather than a confusing module-load error from importing node:fs. Output
7
+ // is reachable via RunResult.artifacts[].url; fetch it in the browser.
8
+ if (typeof process === 'undefined' || process.versions?.node === undefined) {
9
+ throw new GislSinkError('Output sinks (downloadTo/toFile) require Node.js. In a browser, read ' +
10
+ 'RunResult.url / RunResult.artifacts[].url and fetch it instead.', { reason: 'downloader_unavailable' });
11
+ }
12
+ // Magic comments keep bundlers (webpack/Vite) from pulling the Node-only
13
+ // http-downloader (node:fs/node:stream) into a browser build — they leave
14
+ // this as a literal runtime import that only Node ever reaches.
15
+ const { HttpDownloader } = await import(
16
+ /* webpackIgnore: true */ /* @vite-ignore */ './http-downloader.js');
17
+ return new HttpDownloader().downloadTo(url, destPath);
18
+ }
19
+ }
package/dist/merge.d.ts CHANGED
@@ -141,3 +141,14 @@ export declare class MergeBuilder {
141
141
  private opOptionsForResolved;
142
142
  private awaitTerminal;
143
143
  }
144
+ /**
145
+ * Project the merge-level {@link MergeOptions} into the per-media wire
146
+ * allowlist. Exported so the file-first `MergedRecipe`
147
+ * (`files([...]).merge(...)`) lowers identically to this operation-first
148
+ * `client.merge(...)` builder — one allowlist, no drift. Mirrors the PHP
149
+ * `MergeBuilder::wireMergeOptions()` public-static seam.
150
+ *
151
+ * @internal Not re-exported from `index.ts`; shared between the two merge
152
+ * surfaces only.
153
+ */
154
+ export declare function wireMergeOptions(opts: MergeOptions, mediaKind: MergeMediaKind): Record<string, unknown>;