@edgestore/sdk 1.0.0-next.1 → 1.0.0-next.2

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 (59) hide show
  1. package/dist/errors.d.ts +17 -0
  2. package/dist/errors.d.ts.map +1 -1
  3. package/dist/errors.js +15 -1
  4. package/dist/generated/api-v2.d.ts +71 -26
  5. package/dist/generated/api-v2.d.ts.map +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/internal/managementUploadOperations.d.ts +64 -0
  10. package/dist/internal/managementUploadOperations.d.ts.map +1 -0
  11. package/dist/internal/managementUploadOperations.js +72 -0
  12. package/dist/internal/multipartUpload.d.ts +6 -6
  13. package/dist/internal/multipartUpload.d.ts.map +1 -1
  14. package/dist/internal/runtimeOperations.d.ts.map +1 -1
  15. package/dist/internal/transport.d.ts.map +1 -1
  16. package/dist/internal/transport.js +20 -7
  17. package/dist/internal/uploadLifecycle.d.ts +57 -0
  18. package/dist/internal/uploadLifecycle.d.ts.map +1 -0
  19. package/dist/internal/uploadLifecycle.js +91 -0
  20. package/dist/internal/uploadProcessing.d.ts +20 -0
  21. package/dist/internal/uploadProcessing.d.ts.map +1 -0
  22. package/dist/internal/uploadProcessing.js +25 -0
  23. package/dist/internal/uploadSource.d.ts +18 -0
  24. package/dist/internal/uploadSource.d.ts.map +1 -0
  25. package/dist/internal/uploadSource.js +75 -0
  26. package/dist/internal/uploadTransfer.js +15 -1
  27. package/dist/managementClient.d.ts +2 -1
  28. package/dist/managementClient.d.ts.map +1 -1
  29. package/dist/managementClient.js +2 -2
  30. package/dist/managementResources.d.ts +5 -1
  31. package/dist/managementResources.d.ts.map +1 -1
  32. package/dist/managementResources.js +14 -49
  33. package/dist/managementUpload.d.ts +36 -0
  34. package/dist/managementUpload.d.ts.map +1 -0
  35. package/dist/managementUpload.js +74 -0
  36. package/dist/sdk.js +1 -1
  37. package/dist/upload.d.ts.map +1 -1
  38. package/dist/upload.js +42 -189
  39. package/dist/version.d.ts +1 -1
  40. package/dist/version.js +1 -1
  41. package/package.json +2 -2
  42. package/src/errors.ts +28 -0
  43. package/src/generated/api-v2.ts +71 -26
  44. package/src/generated/openapi-v2.json +237 -16
  45. package/src/generated/source.ts +2 -2
  46. package/src/index.ts +6 -0
  47. package/src/internal/managementUploadOperations.ts +99 -0
  48. package/src/internal/multipartUpload.ts +8 -8
  49. package/src/internal/transport.ts +21 -12
  50. package/src/internal/uploadLifecycle.ts +154 -0
  51. package/src/internal/uploadProcessing.ts +48 -0
  52. package/src/internal/uploadSource.ts +104 -0
  53. package/src/internal/uploadTransfer.ts +20 -1
  54. package/src/managementClient.ts +6 -2
  55. package/src/managementResources.ts +21 -51
  56. package/src/managementUpload.ts +139 -0
  57. package/src/sdk.ts +1 -1
  58. package/src/upload.ts +49 -274
  59. package/src/version.ts +1 -1
@@ -1,9 +1,9 @@
1
1
  import { createManagementAccessClient } from './managementAccess.js';
2
2
  import { createManagementResourceClient } from './managementResources.js';
3
3
 
4
- function createManagementClient(transport) {
4
+ function createManagementClient(transport, uploadDefaults) {
5
5
  return {
6
- ...createManagementResourceClient(transport),
6
+ ...createManagementResourceClient(transport, uploadDefaults),
7
7
  ...createManagementAccessClient(transport),
8
8
  whoami: (options)=>transport.execute((client)=>client.GET('/whoami', {
9
9
  signal: options?.signal
@@ -1,5 +1,7 @@
1
1
  import type { OperationBody, OperationId, OperationQuery, OperationResult } from './internal/operationTypes.js';
2
2
  import type { Transport } from './internal/transport.js';
3
+ import { type ManagementUploadInput, type ManagementUploadResult } from './managementUpload.js';
4
+ import type { UploadDefaults } from './uploadTypes.js';
3
5
  type CallOptions = {
4
6
  /** Cancels the request. */
5
7
  signal?: AbortSignal;
@@ -70,6 +72,8 @@ export type ManagementResourceClient = {
70
72
  delete(input: ProjectInput & OperationBody<'v2.management.files.delete'> & CallOptions): Promise<Result<'v2.management.files.delete'>>;
71
73
  };
72
74
  uploads: {
75
+ /** Transfers a file and waits for server-side processing to complete. */
76
+ upload(input: ManagementUploadInput): Promise<ManagementUploadResult>;
73
77
  /** Requests signed upload destination(s) without transferring data. */
74
78
  request(input: BucketInput & OperationBody<'v2.management.uploads.request'> & CallOptions): Promise<Result<'v2.management.uploads.request'>>;
75
79
  /** Gets the current upload and processing state. */
@@ -82,6 +86,6 @@ export type ManagementResourceClient = {
82
86
  completeMultipart(input: UploadInput & OperationBody<'v2.management.uploads.multipart.complete'> & CallOptions): Promise<Result<'v2.management.uploads.multipart.complete'>>;
83
87
  };
84
88
  };
85
- export declare function createManagementResourceClient(transport: Transport): ManagementResourceClient;
89
+ export declare function createManagementResourceClient(transport: Transport, uploadDefaults?: UploadDefaults): ManagementResourceClient;
86
90
  export {};
87
91
  //# sourceMappingURL=managementResources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"managementResources.d.ts","sourceRoot":"","sources":["../src/managementResources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACd,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,WAAW,GAAG;IACjB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AACF,KAAK,YAAY,GAAG;IAClB,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,KAAK,YAAY,GAAG;IAClB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,KAAK,WAAW,GAAG,YAAY,GAAG;IAChC,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,KAAK,WAAW,GAAG,YAAY,GAAG;IAChC,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,KAAK,aAAa,GAAG,WAAW,GAAG;IACjC,2BAA2B;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C,GAC3C,WAAW,GACZ,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAAC;KAClD,CAAC;IACF,OAAO,EAAE;QACP,uEAAuE;QACvE,OAAO,CACL,KAAK,EAAE,WAAW,GAChB,aAAa,CAAC,+BAA+B,CAAC,GAC9C,WAAW,GACZ,OAAO,CAAC,MAAM,CAAC,+BAA+B,CAAC,CAAC,CAAC;QACpD,oDAAoD;QACpD,GAAG,CACD,KAAK,EAAE,WAAW,GAAG,WAAW,GAC/B,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC;QAChD,oCAAoC;QACpC,MAAM,CACJ,KAAK,EAAE,WAAW,GAAG,WAAW,GAC/B,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAAC;QACnD,kEAAkE;QAClE,WAAW,CACT,KAAK,EAAE,WAAW,GAChB,aAAa,CAAC,oCAAoC,CAAC,GACnD,WAAW,GACZ,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAC,CAAC;QACzD,wEAAwE;QACxE,iBAAiB,CACf,KAAK,EAAE,WAAW,GAChB,aAAa,CAAC,0CAA0C,CAAC,GACzD,WAAW,GACZ,OAAO,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC,CAAC;KAChE,CAAC;CACH,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,SAAS,GACnB,wBAAwB,CA4N1B"}
1
+ {"version":3,"file":"managementResources.d.ts","sourceRoot":"","sources":["../src/managementResources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,cAAc,EACd,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,e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wEAAwE;QACxE,iBAAiB,CACf,KAAK,EAAE,WAAW,GAChB,aAAa,CAAC,0CAA0C,CAAC,GACzD,WAAW,GACZ,OAAO,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC,CAAC;KAChE,CAAC;CACH,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,SAAS,EACpB,cAAc,GAAE,cAAmB,GAClC,wBAAwB,CAoL1B"}
@@ -1,4 +1,8 @@
1
- function createManagementResourceClient(transport) {
1
+ import { createManagementUploadOperations } from './internal/managementUploadOperations.js';
2
+ import { uploadManagementFile } from './managementUpload.js';
3
+
4
+ function createManagementResourceClient(transport, uploadDefaults = {}) {
5
+ const uploadOperations = createManagementUploadOperations(transport);
2
6
  return {
3
7
  projects: {
4
8
  list: ({ account, signal })=>transport.execute((client)=>client.GET('/management/accounts/{accountId}/projects', {
@@ -164,54 +168,15 @@ function createManagementResourceClient(transport) {
164
168
  }))
165
169
  },
166
170
  uploads: {
167
- request: ({ project, bucket, signal, ...body })=>transport.execute((client)=>client.POST('/management/projects/{projectRef}/buckets/{bucketName}/uploads', {
168
- params: {
169
- path: {
170
- projectRef: project,
171
- bucketName: bucket
172
- }
173
- },
174
- body,
175
- signal
176
- })),
177
- get: ({ project, uploadId, signal })=>transport.execute((client)=>client.GET('/management/projects/{projectRef}/uploads/{uploadId}', {
178
- params: {
179
- path: {
180
- projectRef: project,
181
- uploadId
182
- }
183
- },
184
- signal
185
- })),
186
- cancel: ({ project, uploadId, signal })=>transport.execute((client)=>client.DELETE('/management/projects/{projectRef}/uploads/{uploadId}', {
187
- params: {
188
- path: {
189
- projectRef: project,
190
- uploadId
191
- }
192
- },
193
- signal
194
- })),
195
- createParts: ({ project, uploadId, signal, ...body })=>transport.execute((client)=>client.POST('/management/projects/{projectRef}/uploads/{uploadId}/parts', {
196
- params: {
197
- path: {
198
- projectRef: project,
199
- uploadId
200
- }
201
- },
202
- body,
203
- signal
204
- })),
205
- completeMultipart: ({ project, uploadId, signal, ...body })=>transport.execute((client)=>client.POST('/management/projects/{projectRef}/uploads/{uploadId}/complete', {
206
- params: {
207
- path: {
208
- projectRef: project,
209
- uploadId
210
- }
211
- },
212
- body,
213
- signal
214
- }))
171
+ upload: (input)=>uploadManagementFile({
172
+ transport,
173
+ operations: uploadOperations
174
+ }, input, uploadDefaults),
175
+ request: uploadOperations.request,
176
+ get: uploadOperations.get,
177
+ cancel: uploadOperations.cancel,
178
+ createParts: uploadOperations.createParts,
179
+ completeMultipart: uploadOperations.completeMultipart
215
180
  }
216
181
  };
217
182
  }
@@ -0,0 +1,36 @@
1
+ import type { ManagementUploadOperations } from './internal/managementUploadOperations.js';
2
+ import type { OperationBody, OperationResult } from './internal/operationTypes.js';
3
+ import type { Transport } from './internal/transport.js';
4
+ import type { UploadDefaults, UploadMetadataValue, UploadProgress, UploadSource } from './uploadTypes.js';
5
+ type RequestBody = OperationBody<'v2.management.uploads.request'>;
6
+ type RequestResult = OperationResult<'v2.management.uploads.request'>;
7
+ type GetResult = OperationResult<'v2.management.uploads.get'>;
8
+ type CompletedUpload = Extract<GetResult, {
9
+ upload: {
10
+ status: 'completed';
11
+ };
12
+ }>;
13
+ /** Input for a complete administrative upload managed by the SDK. */
14
+ export type ManagementUploadInput = Omit<RequestBody, 'sizeBytes' | 'metadata' | 'multipart'> & {
15
+ project: string;
16
+ bucket: string;
17
+ source: UploadSource;
18
+ metadata?: Record<string, UploadMetadataValue>;
19
+ signal?: AbortSignal;
20
+ onProgress?: (progress: UploadProgress) => void;
21
+ multipart?: boolean | {
22
+ partSizeBytes?: number;
23
+ concurrency?: number;
24
+ };
25
+ processingTimeoutMs?: number;
26
+ };
27
+ /** Completed administrative file upload. */
28
+ export type ManagementUploadResult = CompletedUpload & {
29
+ signedReadUrl?: RequestResult['signedReadUrl'];
30
+ };
31
+ export declare function uploadManagementFile(context: {
32
+ transport: Transport;
33
+ operations: ManagementUploadOperations;
34
+ }, input: ManagementUploadInput, defaults?: UploadDefaults): Promise<ManagementUploadResult>;
35
+ export {};
36
+ //# sourceMappingURL=managementUpload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managementUpload.d.ts","sourceRoot":"","sources":["../src/managementUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAUtD,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,KAAK,WAAW,GAAG,aAAa,CAAC,+BAA+B,CAAC,CAAC;AAClE,KAAK,aAAa,GAAG,eAAe,CAAC,+BAA+B,CAAC,CAAC;AACtE,KAAK,SAAS,GAAG,eAAe,CAAC,2BAA2B,CAAC,CAAC;AAC9D,KAAK,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,MAAM,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC;AAE/E,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,WAAW,EACX,WAAW,GAAG,UAAU,GAAG,WAAW,CACvC,GAAG;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,SAAS,CAAC,EACN,OAAO,GACP;QACE,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACN,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG;IACrD,aAAa,CAAC,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAChD,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IACP,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,0BAA0B,CAAC;CACxC,EACD,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,GAAE,cAAmB,GAC5B,OAAO,CAAC,sBAAsB,CAAC,CAiFjC"}
@@ -0,0 +1,74 @@
1
+ import { executeUploadLifecycle } from './internal/uploadLifecycle.js';
2
+ import { throwIfAborted } from './internal/uploadRetry.js';
3
+ import { prepareUploadSource, reportUploadProgress, normalizeUploadMetadata } from './internal/uploadSource.js';
4
+ import { assertNonNegative } from './internal/uploadValidation.js';
5
+ import { planMultipartUpload } from './multipartPlan.js';
6
+ import { DEFAULT_PROCESSING_TIMEOUT_MS } from './uploadTypes.js';
7
+
8
+ async function uploadManagementFile(context, input, defaults = {}) {
9
+ const { transport, operations } = context;
10
+ const { project, bucket, source, metadata, signal, onProgress, multipart, processingTimeoutMs = defaults.processingTimeoutMs ?? DEFAULT_PROCESSING_TIMEOUT_MS, ...requestInput } = input;
11
+ const prepared = prepareUploadSource(source);
12
+ const totalBytes = prepared.sizeBytes;
13
+ assertNonNegative(processingTimeoutMs, 'processingTimeoutMs');
14
+ throwIfAborted(signal);
15
+ reportUploadProgress(onProgress, {
16
+ transferredBytes: 0,
17
+ totalBytes,
18
+ phase: 'preparing'
19
+ });
20
+ const multipartPlan = planMultipartUpload({
21
+ sizeBytes: totalBytes,
22
+ thresholdBytes: defaults.multipartThresholdBytes,
23
+ preferredPartSizeBytes: typeof multipart === 'object' ? multipart.partSizeBytes ?? defaults.multipartPartSizeBytes : defaults.multipartPartSizeBytes,
24
+ forceMultipart: prepared.kind === 'stream' || multipart === true || typeof multipart === 'object'
25
+ });
26
+ const requested = await operations.request({
27
+ project,
28
+ bucket,
29
+ signal,
30
+ ...requestInput,
31
+ fileName: requestInput.fileName ?? prepared.fileName,
32
+ mimeType: requestInput.mimeType ?? prepared.mimeType,
33
+ sizeBytes: totalBytes,
34
+ metadata: normalizeUploadMetadata(metadata),
35
+ multipart: multipartPlan ? {
36
+ partNumbers: multipartPlan.partNumbers
37
+ } : undefined
38
+ });
39
+ const completed = await executeUploadLifecycle({
40
+ transport,
41
+ requested,
42
+ prepared,
43
+ multipartPlan,
44
+ multipartConcurrency: typeof multipart === 'object' ? multipart.concurrency : defaults.multipartConcurrency,
45
+ defaultMultipartConcurrency: defaults.multipartConcurrency,
46
+ processingTimeoutMs,
47
+ signal,
48
+ onProgress,
49
+ operations: {
50
+ completeMultipart: ({ uploadId, parts, signal: requestSignal })=>operations.completeMultipart({
51
+ project,
52
+ uploadId,
53
+ parts,
54
+ signal: requestSignal
55
+ }),
56
+ get: ({ uploadId, signal: requestSignal })=>operations.getWithResponse({
57
+ project,
58
+ uploadId,
59
+ signal: requestSignal
60
+ }),
61
+ cancel: ({ uploadId })=>operations.cancel({
62
+ project,
63
+ uploadId
64
+ })
65
+ },
66
+ cleanupPolicy: 'report-failure'
67
+ });
68
+ return {
69
+ ...completed,
70
+ signedReadUrl: requested.signedReadUrl
71
+ };
72
+ }
73
+
74
+ export { uploadManagementFile };
package/dist/sdk.js CHANGED
@@ -13,7 +13,7 @@ function createEdgeStoreSdk(options) {
13
13
  const system = createSystemClient(transport);
14
14
  return credentials.kind === 'bearer' ? {
15
15
  runtime: createExplicitProjectRuntimeClient(transport, options.upload),
16
- management: createManagementClient(transport),
16
+ management: createManagementClient(transport, options.upload),
17
17
  system
18
18
  } : {
19
19
  runtime: createProjectRuntimeClient(transport, options.upload),
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,8BAA8B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nB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,GAAE,cAAmB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA2G9B;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,0BAA0B,EACjC,QAAQ,GAAE,cAAmB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAsE9B"}
package/dist/upload.js CHANGED
@@ -1,20 +1,20 @@
1
- import { EdgeStoreAbortError, EdgeStoreNetworkError, EdgeStoreUploadProcessingTimeoutError, EdgeStoreUploadCanceledError } from './errors.js';
2
- import { uploadStreamParts, uploadParts } from './internal/multipartUpload.js';
1
+ import { EdgeStoreAbortError, EdgeStoreNetworkError } from './errors.js';
3
2
  import { createGetUploadRequest } from './internal/runtimeOperations.js';
4
- import { isAbortError, throwIfAborted, retryOperation, getRetryAfterMs, sleep } from './internal/uploadRetry.js';
5
- import { putWithRetry } from './internal/uploadTransfer.js';
6
- import { assertNonNegative, getPositiveInteger } from './internal/uploadValidation.js';
3
+ import { executeUploadLifecycle } from './internal/uploadLifecycle.js';
4
+ import { isAbortError, throwIfAborted } from './internal/uploadRetry.js';
5
+ import { prepareUploadSource, reportUploadProgress, normalizeUploadMetadata } from './internal/uploadSource.js';
6
+ import { assertNonNegative } from './internal/uploadValidation.js';
7
7
  import { planMultipartUpload } from './multipartPlan.js';
8
- import { DEFAULT_PROCESSING_TIMEOUT_MS, DEFAULT_MULTIPART_CONCURRENCY } from './uploadTypes.js';
8
+ import { DEFAULT_PROCESSING_TIMEOUT_MS } from './uploadTypes.js';
9
9
 
10
10
  async function uploadRuntimeFile(context, input, defaults = {}) {
11
11
  const { transport, operations } = context;
12
12
  const { project, bucket, source, metadata, signal, onProgress, multipart, fileName, mimeType, temporary, path, extension, replaceTarget, signedReadUrl, processingTimeoutMs = defaults.processingTimeoutMs ?? DEFAULT_PROCESSING_TIMEOUT_MS } = input;
13
- const prepared = prepareSource(source);
13
+ const prepared = prepareUploadSource(source);
14
14
  const totalBytes = prepared.sizeBytes;
15
15
  assertNonNegative(processingTimeoutMs, 'processingTimeoutMs');
16
16
  throwIfAborted(signal);
17
- reportProgress(onProgress, {
17
+ reportUploadProgress(onProgress, {
18
18
  transferredBytes: 0,
19
19
  totalBytes,
20
20
  phase: 'preparing'
@@ -42,7 +42,7 @@ async function uploadRuntimeFile(context, input, defaults = {}) {
42
42
  temporary,
43
43
  path,
44
44
  extension,
45
- metadata: normalizeMetadata(metadata),
45
+ metadata: normalizeUploadMetadata(metadata),
46
46
  replaceTarget,
47
47
  multipart: partNumbers ? {
48
48
  partNumbers
@@ -50,77 +50,39 @@ async function uploadRuntimeFile(context, input, defaults = {}) {
50
50
  signedReadUrl,
51
51
  signal
52
52
  });
53
- const uploadId = requested.upload.id;
54
- try {
55
- reportProgress(onProgress, {
56
- transferredBytes: 0,
57
- totalBytes,
58
- phase: 'uploading'
59
- });
60
- if (prepared.kind === 'body' && requested.upload.kind === 'single') {
61
- await putWithRetry(transport, {
62
- uploadId,
63
- url: requested.upload.signedUrl,
64
- body: prepared.body,
65
- signal
66
- });
67
- reportProgress(onProgress, {
68
- transferredBytes: totalBytes,
69
- totalBytes,
70
- phase: 'uploading'
71
- });
72
- } else {
73
- if (requested.upload.kind !== 'multipart') {
74
- throw new TypeError('The API returned a single upload URL for a stream source.');
75
- }
76
- if (!multipartPlan) {
77
- throw new TypeError('The API returned a multipart upload for a single-upload request.');
78
- }
79
- const concurrency = getPositiveInteger(typeof multipart === 'object' ? multipart.concurrency : defaults.multipartConcurrency, defaults.multipartConcurrency ?? DEFAULT_MULTIPART_CONCURRENCY, 'multipart.concurrency');
80
- const transferOptions = {
81
- uploadId,
82
- parts: requested.upload.parts,
83
- partSizeBytes: multipartPlan.partSizeBytes,
84
- signal,
85
- onProgress
86
- };
87
- const completedParts = prepared.kind === 'stream' ? await uploadStreamParts(transport, {
88
- ...transferOptions,
89
- stream: prepared.stream,
90
- totalBytes
91
- }) : await uploadParts(transport, {
92
- ...transferOptions,
93
- body: prepared.body,
94
- concurrency
95
- });
96
- await operations.uploads.completeMultipart({
97
- project,
98
- uploadId,
99
- parts: completedParts,
100
- signal
101
- });
102
- }
103
- reportProgress(onProgress, {
104
- transferredBytes: totalBytes,
105
- totalBytes,
106
- phase: 'processing'
107
- });
108
- const completed = await waitForUpload(context, {
109
- project,
110
- uploadId,
111
- signal,
112
- timeoutMs: processingTimeoutMs
113
- });
114
- return {
115
- ...completed,
116
- signedReadUrl: requested.signedReadUrl
117
- };
118
- } catch (error) {
119
- if (!(error instanceof EdgeStoreUploadProcessingTimeoutError)) {
120
- await cancelUpload(operations, project, uploadId);
121
- }
122
- throw error;
123
- }
53
+ const completed = await executeUploadLifecycle({
54
+ transport,
55
+ requested,
56
+ prepared,
57
+ multipartPlan,
58
+ multipartConcurrency: typeof multipart === 'object' ? multipart.concurrency : defaults.multipartConcurrency,
59
+ defaultMultipartConcurrency: defaults.multipartConcurrency,
60
+ processingTimeoutMs,
61
+ signal,
62
+ onProgress,
63
+ operations: {
64
+ completeMultipart: ({ uploadId, parts, signal: requestSignal })=>operations.uploads.completeMultipart({
65
+ project,
66
+ uploadId,
67
+ parts,
68
+ signal: requestSignal
69
+ }),
70
+ get: ({ uploadId, signal: requestSignal })=>context.transport.executeWithResponse(createGetUploadRequest({
71
+ project,
72
+ uploadId,
73
+ signal: requestSignal
74
+ })),
75
+ cancel: ({ uploadId })=>operations.uploads.cancel({
76
+ project,
77
+ uploadId
78
+ })
79
+ },
80
+ cleanupPolicy: 'preserve-original'
81
+ });
82
+ return {
83
+ ...completed,
84
+ signedReadUrl: requested.signedReadUrl
85
+ };
124
86
  }
125
87
  async function uploadRuntimeFileFromUrl(context, input, defaults = {}) {
126
88
  const { transport } = context;
@@ -178,115 +140,6 @@ async function cancelResponseBody(body) {
178
140
  if (!body) return;
179
141
  await body.cancel().catch(()=>undefined);
180
142
  }
181
- async function waitForUpload(context, options) {
182
- const deadline = Date.now() + options.timeoutMs;
183
- const timeoutError = ()=>new EdgeStoreUploadProcessingTimeoutError('Timed out while EdgeStore was processing the upload.', options.uploadId);
184
- while(true){
185
- const { data, response } = await retryOperation((signal)=>context.transport.executeWithResponse(createGetUploadRequest({
186
- project: options.project,
187
- uploadId: options.uploadId,
188
- signal
189
- })), {
190
- signal: options.signal,
191
- deadline,
192
- timeoutError
193
- });
194
- if (data.upload.status === 'completed' && 'file' in data) return data;
195
- if (data.upload.status === 'canceled') {
196
- throw new EdgeStoreUploadCanceledError('The EdgeStore upload was canceled.', options.uploadId);
197
- }
198
- const delayMs = getRetryAfterMs(response) ?? 1000;
199
- if (Date.now() + delayMs > deadline) {
200
- throw timeoutError();
201
- }
202
- await sleep(delayMs, options.signal);
203
- }
204
- }
205
- async function cancelUpload(operations, project, uploadId) {
206
- try {
207
- await operations.uploads.cancel({
208
- project,
209
- uploadId
210
- });
211
- } catch {
212
- // Preserve the original upload failure.
213
- }
214
- }
215
- function normalizeMetadata(metadata) {
216
- if (!metadata) return undefined;
217
- const entries = Object.entries(metadata).flatMap(([key, value])=>value === null || value === undefined ? [] : [
218
- [
219
- key,
220
- String(value)
221
- ]
222
- ]);
223
- return entries.length ? Object.fromEntries(entries) : undefined;
224
- }
225
- function prepareSource(source) {
226
- if (typeof source === 'string') {
227
- const body = new Blob([
228
- source
229
- ], {
230
- type: 'text/plain'
231
- });
232
- return {
233
- kind: 'body',
234
- body,
235
- sizeBytes: body.size,
236
- mimeType: body.type
237
- };
238
- }
239
- if (isStreamSource(source)) {
240
- if (!Number.isSafeInteger(source.sizeBytes) || source.sizeBytes < 0) {
241
- throw new RangeError('source.sizeBytes must be a non-negative integer.');
242
- }
243
- return {
244
- kind: 'stream',
245
- stream: source.stream,
246
- sizeBytes: source.sizeBytes
247
- };
248
- }
249
- if (source instanceof Blob) {
250
- return {
251
- kind: 'body',
252
- body: source,
253
- sizeBytes: source.size,
254
- fileName: 'name' in source && typeof source.name === 'string' ? source.name : undefined,
255
- mimeType: source.type || undefined
256
- };
257
- }
258
- if (source instanceof ArrayBuffer) {
259
- const body = new Blob([
260
- source
261
- ]);
262
- return {
263
- kind: 'body',
264
- body,
265
- sizeBytes: body.size
266
- };
267
- }
268
- const body = new Blob([
269
- Uint8Array.from(new Uint8Array(source.buffer, source.byteOffset, source.byteLength))
270
- ]);
271
- return {
272
- kind: 'body',
273
- body,
274
- sizeBytes: body.size
275
- };
276
- }
277
- function isStreamSource(source) {
278
- const stream = typeof source === 'object' && source !== null && 'stream' in source ? Reflect.get(source, 'stream') : undefined;
279
- return typeof stream === 'object' && stream !== null && 'getReader' in stream && typeof Reflect.get(stream, 'getReader') === 'function';
280
- }
281
- function reportProgress(onProgress, progress) {
282
- const { transferredBytes, totalBytes, phase } = progress;
283
- onProgress?.({
284
- transferredBytes,
285
- totalBytes,
286
- percentage: totalBytes === 0 ? phase === 'preparing' ? 0 : 100 : Math.round(transferredBytes / totalBytes * 10000) / 100,
287
- phase
288
- });
289
- }
290
143
  function getFileNameFromUrl(url) {
291
144
  const name = new URL(url).pathname.split('/').filter(Boolean).at(-1);
292
145
  return name ? decodeURIComponent(name) : undefined;
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const EDGE_STORE_PACKAGE_NAME = "@edgestore/sdk";
2
- export declare const EDGE_STORE_PACKAGE_VERSION = "1.0.0-next.1";
2
+ export declare const EDGE_STORE_PACKAGE_VERSION = "1.0.0-next.2";
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  const EDGE_STORE_PACKAGE_NAME = '@edgestore/sdk';
2
- const EDGE_STORE_PACKAGE_VERSION = '1.0.0-next.1';
2
+ const EDGE_STORE_PACKAGE_VERSION = '1.0.0-next.2';
3
3
 
4
4
  export { EDGE_STORE_PACKAGE_NAME, EDGE_STORE_PACKAGE_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgestore/sdk",
3
- "version": "1.0.0-next.1",
3
+ "version": "1.0.0-next.2",
4
4
  "description": "Official low-level TypeScript SDK for the EdgeStore API",
5
5
  "homepage": "https://edgestore.dev",
6
6
  "license": "MIT",
@@ -60,7 +60,7 @@
60
60
  "build": "pnpm codegen:check && rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
61
61
  "dev": "pnpm build --watch",
62
62
  "codegen:api": "openapi-typescript ./src/generated/openapi-v2.json -o ./src/generated/api-v2.ts --export-type",
63
- "codegen:check": "pnpm codegen:api --check",
63
+ "codegen:check": "openapi-typescript ./src/generated/openapi-v2.json -o ./src/generated/api-v2.ts --export-type --check",
64
64
  "codegen:entrypoints": "tsx entrypoints.script.ts",
65
65
  "schema:sync": "node ./sync-openapi.mjs",
66
66
  "test": "vitest run",
package/src/errors.ts CHANGED
@@ -43,6 +43,15 @@ export class EdgeStoreNetworkError extends EdgeStoreError {
43
43
  }
44
44
  }
45
45
 
46
+ /** A control-plane request that exceeded the configured deadline. */
47
+ export class EdgeStoreTimeoutError extends EdgeStoreError {
48
+ override readonly name = 'EdgeStoreTimeoutError';
49
+
50
+ constructor(message: string, options?: ErrorOptions) {
51
+ super(message, options);
52
+ }
53
+ }
54
+
46
55
  /** A request or upload canceled through an `AbortSignal`. */
47
56
  export class EdgeStoreAbortError extends EdgeStoreError {
48
57
  override readonly name = 'EdgeStoreAbortError';
@@ -77,6 +86,25 @@ export class EdgeStoreUploadProcessingTimeoutError extends EdgeStoreUploadError
77
86
  override readonly name = 'EdgeStoreUploadProcessingTimeoutError';
78
87
  }
79
88
 
89
+ /** An upload failure whose automatic cancellation also failed. */
90
+ export class EdgeStoreUploadCleanupError extends EdgeStoreUploadError {
91
+ override readonly name = 'EdgeStoreUploadCleanupError';
92
+
93
+ readonly uploadCause: unknown;
94
+ readonly cleanupCause: unknown;
95
+
96
+ constructor(options: {
97
+ message: string;
98
+ uploadId: string;
99
+ uploadCause: unknown;
100
+ cleanupCause: unknown;
101
+ }) {
102
+ super(options.message, options.uploadId, { cause: options.uploadCause });
103
+ this.uploadCause = options.uploadCause;
104
+ this.cleanupCause = options.cleanupCause;
105
+ }
106
+ }
107
+
80
108
  /** Failure returned for a singular file mutation. */
81
109
  export class EdgeStoreFileMutationError<
82
110
  TFileReference = { id: string } | { key: string } | { url: string },