@giveitsmaller/sdk 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/_audit.js CHANGED
@@ -54,4 +54,11 @@ export function _runAudit() {
54
54
  accept();
55
55
  accept();
56
56
  accept();
57
+ // SDK-3 (Wb6ebOMM) public-API surface for the 3 resume-support endpoints.
58
+ accept();
59
+ accept();
60
+ accept();
61
+ accept();
62
+ accept();
63
+ accept();
57
64
  }
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AudioWatermarkDecodeRequest, AudioWatermarkDecodeResponse, ExternalImportCreatedResponse, ExternalImportRequest, LoginUserRequest, LoginUser200ResponseData, ContactRequest, CreditsBalanceResponse, CreditsUsageResponse, UploadResponse, UploadProbeResponse, WorkflowCancelResponse, WorkflowCreateResponse, WorkflowResumeResponse, WorkflowStatusResponse, WorkflowDownloadResponse, MetadataResponse, RetryResponse } from '@giveitsmaller/contracts/openapi';
2
- import type { CreditsUsageOptions, GetSchemaOptions, GetSchemaResult, GislClientConfig, GislSseEvent, PreflightClipsResult, UploadOptions, WaitOptions, WorkflowCreatePayload } from './types.js';
2
+ import type { CreditsUsageOptions, GetSchemaOptions, GetSchemaResult, GislClientConfig, GislSseEvent, PreflightClipsResult, UploadOptions, WaitOptions, WorkflowCreatePayload, _Sdk3HandCodedKeepaliveResult, _Sdk3HandCodedMultipartStatusResult, _Sdk3HandCodedPresignPartsResult } from './types.js';
3
3
  export declare const MULTIPART_CONCURRENCY_DEFAULT: 4;
4
4
  export declare const DEFAULT_MULTIPART_FIRST_CHUNK_SIZE: number;
5
5
  export interface ValidationDetail {
@@ -45,6 +45,88 @@ export declare class GislClient {
45
45
  * post-upload metadata callers should use getMetadata(fileId).
46
46
  */
47
47
  private multipartUpload;
48
+ /**
49
+ * SDK-3 (Wb6ebOMM): resume an in-progress multipart upload.
50
+ *
51
+ * Skips `/multipart/initiate` entirely (the original initiate happened in a
52
+ * prior process). Walks `/status` for the authoritative list of recorded
53
+ * parts, re-presigns the missing ones in batches of <=100, PUTs only those,
54
+ * and finalises with `/complete`. Caller's `source` MUST be byte-identical
55
+ * to the originally-uploaded file at the same offsets (parts whose etags
56
+ * don't match server state will fail `/complete`).
57
+ *
58
+ * Re-runs the same `uploadId` / `chunkSize` / `totalParts` / plan-consistency
59
+ * guards as the fresh-upload path (`multipartUpload`), using the /status
60
+ * envelope as the equivalent of the initiate envelope. Reuses the same
61
+ * `failureController` sibling-wake + `drainResponseBody` cleanup discipline
62
+ * as the fresh-upload PUT loop. `onProgress` fires on entry seeded from
63
+ * (uploadedPartNumbers.length * chunkSize) and again after every successful
64
+ * PUT. `onCheckpoint` fires OUTSIDE the retry-scoped path after every
65
+ * successful PUT — a callback-throw must not trigger a duplicate PUT.
66
+ *
67
+ * TODO(HxUmVr3Y): replace inline hand-coded request body marshalling on regen.
68
+ */
69
+ private multipartResume;
70
+ /**
71
+ * Fetch the durable status of an in-progress multipart upload session.
72
+ *
73
+ * Walks every page of `GET /api/uploads/multipart/{uploadId}/status`
74
+ * (paginated via `next_part_number_marker` + `is_truncated`) and returns
75
+ * the aggregated state. Callers see the complete set of recorded parts
76
+ * across pages without driving the cursor themselves.
77
+ *
78
+ * Anonymous-initiated sessions return 403 → `GislMultipartSessionAuthRequiredError`.
79
+ * Non-existent / expired sessions return 404 → `GislMultipartSessionNotFoundError`.
80
+ * Authed-but-non-owning callers return 403 → `GislMultipartSessionOwnershipError`.
81
+ *
82
+ * TODO(HxUmVr3Y): replace hand-coded response shape on regen.
83
+ */
84
+ getUploadStatus(uploadId: string, opts?: {
85
+ signal?: AbortSignal;
86
+ }): Promise<_Sdk3HandCodedMultipartStatusResult>;
87
+ /**
88
+ * Re-presign a batch of missing part numbers on an in-progress multipart
89
+ * session.
90
+ *
91
+ * Validates client-side BEFORE the HTTP round-trip:
92
+ * - `partNumbers` non-empty
93
+ * - length <=100 (server raw-body cap is 8 KiB before json_decode)
94
+ * - every entry an integer in `[2, totalParts]` — part 1 is sealed at
95
+ * initiate (re-presigning it would break the etag recorded server-side
96
+ * for /complete)
97
+ * - entries unique
98
+ * - `totalParts` <=10 000 (S3 hard limit; mirrors the SDK-1 ceiling guard)
99
+ *
100
+ * TODO(HxUmVr3Y): replace hand-coded request/response shapes on regen.
101
+ */
102
+ presignParts(uploadId: string, partNumbers: readonly number[], totalParts: number, opts?: {
103
+ signal?: AbortSignal;
104
+ }): Promise<_Sdk3HandCodedPresignPartsResult>;
105
+ /**
106
+ * Extend the manifest TTL of an in-progress multipart upload session.
107
+ *
108
+ * The durable session manifest defaults to a 48 h TTL (decoupled from the
109
+ * shorter presigned-URL TTL). For a long-running resume that spans days
110
+ * (e.g. an upload paused overnight on flaky Wi-Fi), callers SHOULD invoke
111
+ * `keepaliveUpload` every **12-24 h** while resuming — the 12-24 h band
112
+ * leaves >=24 h of slack against the 48 h ceiling even with worst-case
113
+ * clock skew between client and server. The server atomically refreshes
114
+ * the Redis EXPIRE for the manifest key; the call is idempotent.
115
+ *
116
+ * TODO(HxUmVr3Y): replace hand-coded response shape on regen.
117
+ */
118
+ keepaliveUpload(uploadId: string, opts?: {
119
+ signal?: AbortSignal;
120
+ }): Promise<_Sdk3HandCodedKeepaliveResult>;
121
+ /**
122
+ * Private walk-pagination helper for /status. Aggregates every page into
123
+ * a single `_Sdk3HandCodedMultipartStatusResult`. AbortSignal short-circuits
124
+ * the loop between page fetches AND propagates into each fetch.
125
+ *
126
+ * Limit pinned to 1000 (max per page) so we make the minimum number of
127
+ * round-trips even for the worst-case ~10 pages on a 10 000-part upload.
128
+ */
129
+ private walkUploadStatus;
48
130
  /**
49
131
  * Create a new workflow.
50
132
  */
@@ -99,7 +181,9 @@ export declare class GislClient {
99
181
  /**
100
182
  * Stream SSE events for a workflow. Returns an async iterable.
101
183
  */
102
- streamEvents(workflowId: string): Promise<AsyncGenerator<GislSseEvent>>;
184
+ streamEvents(workflowId: string, opts?: {
185
+ signal?: AbortSignal;
186
+ }): Promise<AsyncGenerator<GislSseEvent>>;
103
187
  /**
104
188
  * Get metadata for an uploaded file.
105
189
  */