transloadit 4.2.0 → 4.4.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 (91) hide show
  1. package/README.md +116 -1
  2. package/dist/Transloadit.d.ts +49 -4
  3. package/dist/Transloadit.d.ts.map +1 -1
  4. package/dist/Transloadit.js +106 -22
  5. package/dist/Transloadit.js.map +1 -1
  6. package/dist/alphalib/assembly-linter.d.ts +123 -0
  7. package/dist/alphalib/assembly-linter.d.ts.map +1 -0
  8. package/dist/alphalib/assembly-linter.js +1142 -0
  9. package/dist/alphalib/assembly-linter.js.map +1 -0
  10. package/dist/alphalib/assembly-linter.lang.en.d.ts +87 -0
  11. package/dist/alphalib/assembly-linter.lang.en.d.ts.map +1 -0
  12. package/dist/alphalib/assembly-linter.lang.en.js +326 -0
  13. package/dist/alphalib/assembly-linter.lang.en.js.map +1 -0
  14. package/dist/alphalib/goldenTemplates.d.ts +52 -0
  15. package/dist/alphalib/goldenTemplates.d.ts.map +1 -0
  16. package/dist/alphalib/goldenTemplates.js +46 -0
  17. package/dist/alphalib/goldenTemplates.js.map +1 -0
  18. package/dist/alphalib/object.d.ts +20 -0
  19. package/dist/alphalib/object.d.ts.map +1 -0
  20. package/dist/alphalib/object.js +23 -0
  21. package/dist/alphalib/object.js.map +1 -0
  22. package/dist/alphalib/stepParsing.d.ts +93 -0
  23. package/dist/alphalib/stepParsing.d.ts.map +1 -0
  24. package/dist/alphalib/stepParsing.js +1154 -0
  25. package/dist/alphalib/stepParsing.js.map +1 -0
  26. package/dist/alphalib/templateMerge.d.ts +4 -0
  27. package/dist/alphalib/templateMerge.d.ts.map +1 -0
  28. package/dist/alphalib/templateMerge.js +22 -0
  29. package/dist/alphalib/templateMerge.js.map +1 -0
  30. package/dist/cli/commands/assemblies.d.ts +20 -1
  31. package/dist/cli/commands/assemblies.d.ts.map +1 -1
  32. package/dist/cli/commands/assemblies.js +137 -2
  33. package/dist/cli/commands/assemblies.js.map +1 -1
  34. package/dist/cli/commands/auth.d.ts.map +1 -1
  35. package/dist/cli/commands/auth.js +19 -19
  36. package/dist/cli/commands/auth.js.map +1 -1
  37. package/dist/cli/commands/index.d.ts.map +1 -1
  38. package/dist/cli/commands/index.js +5 -1
  39. package/dist/cli/commands/index.js.map +1 -1
  40. package/dist/cli/commands/upload.d.ts +22 -0
  41. package/dist/cli/commands/upload.d.ts.map +1 -0
  42. package/dist/cli/commands/upload.js +95 -0
  43. package/dist/cli/commands/upload.js.map +1 -0
  44. package/dist/cli/docs/assemblyLintingExamples.d.ts +2 -0
  45. package/dist/cli/docs/assemblyLintingExamples.d.ts.map +1 -0
  46. package/dist/cli/docs/assemblyLintingExamples.js +10 -0
  47. package/dist/cli/docs/assemblyLintingExamples.js.map +1 -0
  48. package/dist/cli/helpers.d.ts +11 -0
  49. package/dist/cli/helpers.d.ts.map +1 -1
  50. package/dist/cli/helpers.js +29 -0
  51. package/dist/cli/helpers.js.map +1 -1
  52. package/dist/inputFiles.d.ts +41 -0
  53. package/dist/inputFiles.d.ts.map +1 -0
  54. package/dist/inputFiles.js +214 -0
  55. package/dist/inputFiles.js.map +1 -0
  56. package/dist/lintAssemblyInput.d.ts +10 -0
  57. package/dist/lintAssemblyInput.d.ts.map +1 -0
  58. package/dist/lintAssemblyInput.js +73 -0
  59. package/dist/lintAssemblyInput.js.map +1 -0
  60. package/dist/lintAssemblyInstructions.d.ts +29 -0
  61. package/dist/lintAssemblyInstructions.d.ts.map +1 -0
  62. package/dist/lintAssemblyInstructions.js +33 -0
  63. package/dist/lintAssemblyInstructions.js.map +1 -0
  64. package/dist/robots.d.ts +38 -0
  65. package/dist/robots.d.ts.map +1 -0
  66. package/dist/robots.js +230 -0
  67. package/dist/robots.js.map +1 -0
  68. package/dist/tus.d.ts +5 -1
  69. package/dist/tus.d.ts.map +1 -1
  70. package/dist/tus.js +80 -6
  71. package/dist/tus.js.map +1 -1
  72. package/package.json +6 -6
  73. package/src/Transloadit.ts +179 -27
  74. package/src/alphalib/assembly-linter.lang.en.ts +393 -0
  75. package/src/alphalib/assembly-linter.ts +1475 -0
  76. package/src/alphalib/goldenTemplates.ts +53 -0
  77. package/src/alphalib/object.ts +27 -0
  78. package/src/alphalib/stepParsing.ts +1465 -0
  79. package/src/alphalib/templateMerge.ts +32 -0
  80. package/src/alphalib/typings/json-to-ast.d.ts +34 -0
  81. package/src/cli/commands/assemblies.ts +161 -2
  82. package/src/cli/commands/auth.ts +19 -22
  83. package/src/cli/commands/index.ts +6 -0
  84. package/src/cli/commands/upload.ts +129 -0
  85. package/src/cli/docs/assemblyLintingExamples.ts +9 -0
  86. package/src/cli/helpers.ts +50 -0
  87. package/src/inputFiles.ts +278 -0
  88. package/src/lintAssemblyInput.ts +89 -0
  89. package/src/lintAssemblyInstructions.ts +72 -0
  90. package/src/robots.ts +317 -0
  91. package/src/tus.ts +91 -5
package/README.md CHANGED
@@ -109,6 +109,76 @@ npx transloadit assemblies replay --steps new-steps.json ASSEMBLY_ID
109
109
  npx transloadit assemblies replay --reparse-template ASSEMBLY_ID
110
110
  ```
111
111
 
112
+ ### Linting Assembly Instructions
113
+
114
+ Lint Assembly Instructions locally using the same linter as the API.
115
+
116
+ ```bash
117
+ # From a JSON file (full instructions or steps-only)
118
+ npx transloadit assemblies lint --steps steps.json
119
+
120
+ # From stdin
121
+ cat steps.json | npx transloadit assemblies lint
122
+
123
+ # Merge template content before linting
124
+ npx transloadit assemblies lint --template TEMPLATE_ID --steps steps.json
125
+
126
+ # Treat warnings as fatal; apply fixes (overwrites files / stdout for stdin)
127
+ npx transloadit assemblies lint --fatal warning --fix --steps steps.json
128
+ ```
129
+
130
+ When both `--template` and steps input are provided, Transloadit merges the template content with
131
+ the provided steps before linting, matching the API's runtime behavior. If the template sets
132
+ `allow_steps_override=false`, providing steps will fail with `TEMPLATE_DENIES_STEPS_OVERRIDE`.
133
+
134
+ ## SDK Helpers
135
+
136
+ ### prepareInputFiles
137
+
138
+ `prepareInputFiles()` converts mixed file inputs into `files`, `uploads`, and optional
139
+ `/http/import` steps so you can pass them directly into `createAssembly()` or
140
+ `resumeAssemblyUploads()`.
141
+
142
+ ```ts
143
+ import { prepareInputFiles } from '@transloadit/node'
144
+
145
+ const prepared = await prepareInputFiles({
146
+ inputFiles: [
147
+ { kind: 'path', field: 'video', path: '/tmp/video.mp4' },
148
+ { kind: 'base64', field: 'logo', filename: 'logo.png', base64: '...' },
149
+ { kind: 'url', field: 'remote', url: 'https://example.com/file.jpg' },
150
+ ],
151
+ params: {
152
+ steps: {
153
+ ':original': { robot: '/upload/handle' },
154
+ encode: { robot: '/video/encode', use: ':original' },
155
+ },
156
+ },
157
+ base64Strategy: 'tempfile',
158
+ urlStrategy: 'import-if-present',
159
+ maxBase64Bytes: 512_000,
160
+ allowPrivateUrls: true,
161
+ })
162
+
163
+ await client.createAssembly({
164
+ params: prepared.params,
165
+ files: prepared.files,
166
+ uploads: prepared.uploads,
167
+ })
168
+ ```
169
+
170
+ Options:
171
+
172
+ - `inputFiles` – Array of `{ kind, field, ... }` entries for `path`, `base64`, or `url` inputs.
173
+ - `params` – Assembly instructions; steps will be extended when URL imports are injected.
174
+ - `fields` – Extra form fields to merge into `params.fields`.
175
+ - `base64Strategy` – `'buffer'` (default) or `'tempfile'` for base64 inputs.
176
+ - `urlStrategy` – `'import'`, `'download'`, or `'import-if-present'` (default `'import'`).
177
+ - `maxBase64Bytes` – Optional size cap (decoded bytes). Overages throw before decoding.
178
+ - `allowPrivateUrls` – Allow downloading private/loopback URLs when using `urlStrategy: 'download'`
179
+ (default `true`). Hosted deployments should disable this.
180
+ - `tempDir` – Optional temp directory base when `base64Strategy: 'tempfile'`.
181
+
112
182
  ### Managing Templates
113
183
 
114
184
  ```bash
@@ -265,7 +335,8 @@ names stable and pass the same files. Only path-based inputs resume; Buffer/stri
265
335
  start a new tus upload automatically.
266
336
 
267
337
  You can pass the same upload and progress options as `createAssembly` (such as `chunkSize`,
268
- `uploadConcurrency`, `waitForCompletion`, `timeout`, `onUploadProgress`, and `onAssemblyProgress`).
338
+ `uploadConcurrency`, `uploadBehavior`, `waitForCompletion`, `timeout`, `onUploadProgress`, and
339
+ `onAssemblyProgress`).
269
340
  When `waitForCompletion` is `true`, the SDK will poll and resolve once the Assembly is finished.
270
341
 
271
342
  ```javascript
@@ -351,9 +422,17 @@ You can provide the following keys inside the `options` object:
351
422
  - `onAssemblyProgress` - Once the Assembly has started processing this will be periodically called with the _Assembly Execution Status_ (result of `getAssembly`) **only if `waitForCompletion` is `true`**.
352
423
  - `chunkSize` - (for uploads) a number indicating the maximum size of a tus `PATCH` request body in bytes. Default to `Infinity` for file uploads and 50MB for streams of unknown length. See [tus-js-client](https://github.com/tus/tus-js-client/blob/master/docs/api.md#chunksize).
353
424
  - `uploadConcurrency` - Maximum number of concurrent tus file uploads to occur at any given time (default 10.)
425
+ - `uploadBehavior` - Controls how uploads are handled:
426
+ - `await` (default) waits for all uploads to finish.
427
+ - `background` starts uploads and returns once upload URLs are created.
428
+ - `none` returns upload URLs without uploading any bytes.
429
+ - When `uploadBehavior` is not `await`, `waitForCompletion` is ignored.
354
430
 
355
431
  **NOTE**: Make sure the key in `files` and `uploads` is not one of `signature`, `params` or `max_size`.
356
432
 
433
+ When `uploadBehavior` is `background` or `none`, the resolved Assembly object includes
434
+ `upload_urls` with a map of field names to tus upload URLs.
435
+
357
436
  Example code showing all options:
358
437
 
359
438
  ```js
@@ -413,6 +492,42 @@ See also:
413
492
  - [API documentation](https://transloadit.com/docs/api/assemblies-post/)
414
493
  - Error codes and retry logic below
415
494
 
495
+ #### async lintAssemblyInstructions(options)
496
+
497
+ Lint Assembly Instructions locally using the same linter as the API.
498
+ If you provide a `templateId`, the template content is fetched and merged with your instructions
499
+ before linting (matching the API's runtime merge behavior). If the template sets
500
+ `allow_steps_override=false`, providing steps will throw `TEMPLATE_DENIES_STEPS_OVERRIDE`.
501
+
502
+ The `options` object accepts:
503
+
504
+ - `assemblyInstructions` - Assembly Instructions as a JSON string, a full instructions object, or a steps-only object.
505
+ If no `steps` property is present, the object is treated as steps.
506
+ - `templateId` - Optional template ID to merge before linting.
507
+ - `fatal` - `'error' | 'warning'` (default: `'error'`). When set to `'warning'`, warnings are treated as fatal.
508
+ - `fix` - Apply auto-fixes where possible. If `true`, the result includes `fixedInstructions`.
509
+
510
+ The method returns:
511
+
512
+ - `success` - `true` when no fatal issues are found.
513
+ - `issues` - Array of lint issues (each includes `code`, `type`, `row`, `column`, and `desc`).
514
+ - `fixedInstructions` - The fixed JSON string when `fix` is `true` (steps-only inputs return steps-only JSON).
515
+
516
+ Example:
517
+
518
+ ```js
519
+ const result = await transloadit.lintAssemblyInstructions({
520
+ assemblyInstructions: {
521
+ resize: { robot: '/image/resize', use: ':original', width: 100, height: 100 },
522
+ },
523
+ fatal: 'warning',
524
+ })
525
+
526
+ if (!result.success) {
527
+ console.log(result.issues)
528
+ }
529
+ ```
530
+
416
531
  #### async listAssemblies(params)
417
532
 
418
533
  Retrieve Assemblies according to the given `params`.
@@ -5,15 +5,28 @@ import { ApiError } from './ApiError.ts';
5
5
  import type { AssemblyIndexItem, AssemblyStatus } from './alphalib/types/assemblyStatus.ts';
6
6
  import type { BaseResponse, BillResponse, CreateAssemblyParams, CreateTemplateCredentialParams, CreateTemplateParams, EditTemplateParams, ListAssembliesParams, ListedTemplate, ListTemplateCredentialsParams, ListTemplatesParams, OptionalAuthParams, PaginationListWithCount, ReplayAssemblyNotificationParams, ReplayAssemblyNotificationResponse, ReplayAssemblyParams, ReplayAssemblyResponse, TemplateCredentialResponse, TemplateCredentialsResponse, TemplateResponse } from './apiTypes.ts';
7
7
  import InconsistentResponseError from './InconsistentResponseError.ts';
8
+ import type { LintAssemblyInstructionsInput, LintAssemblyInstructionsResult } from './lintAssemblyInstructions.ts';
8
9
  import PaginationStream from './PaginationStream.ts';
10
+ import type { UploadBehavior } from './tus.ts';
9
11
  export { HTTPError, MaxRedirectsError, ParseError, ReadError, RequestError, TimeoutError, UploadError, } from 'got';
12
+ export { goldenTemplates } from './alphalib/goldenTemplates.ts';
10
13
  export type { AssemblyStatus } from './alphalib/types/assemblyStatus.ts';
11
14
  export * from './apiTypes.ts';
12
15
  export { InconsistentResponseError, ApiError };
16
+ export { mergeTemplateContent } from './alphalib/templateMerge.ts';
17
+ export type { Base64Strategy, InputFile, PrepareInputFilesOptions, PrepareInputFilesResult, UploadInput, UrlStrategy, } from './inputFiles.ts';
18
+ export { prepareInputFiles } from './inputFiles.ts';
19
+ export type { LintAssemblyInstructionsResult, LintFatalLevel } from './lintAssemblyInstructions.ts';
20
+ export type { RobotHelp, RobotHelpOptions, RobotListItem, RobotListOptions, RobotListResult, RobotParamHelp, } from './robots.ts';
21
+ export { getRobotHelp, listRobots } from './robots.ts';
13
22
  export interface UploadProgress {
14
23
  uploadedBytes?: number | undefined;
15
24
  totalBytes?: number | undefined;
16
25
  }
26
+ export type { UploadBehavior };
27
+ export type AssemblyStatusWithUploadUrls = AssemblyStatus & {
28
+ upload_urls?: Record<string, string>;
29
+ };
17
30
  export type AssemblyProgress = (assembly: AssemblyStatus) => void;
18
31
  interface AssemblyUploadOptions {
19
32
  files?: {
@@ -22,6 +35,7 @@ interface AssemblyUploadOptions {
22
35
  uploads?: {
23
36
  [name: string]: Readable | IntoStreamInput;
24
37
  };
38
+ uploadBehavior?: UploadBehavior;
25
39
  waitForCompletion?: boolean;
26
40
  chunkSize?: number;
27
41
  uploadConcurrency?: number;
@@ -37,6 +51,10 @@ interface AssemblyUploadOptions {
37
51
  export interface CreateAssemblyOptions extends AssemblyUploadOptions {
38
52
  params?: CreateAssemblyParams;
39
53
  assemblyId?: string;
54
+ /**
55
+ * Expected number of tus uploads when files will be uploaded separately.
56
+ */
57
+ expectedUploads?: number;
40
58
  }
41
59
  export interface ResumeAssemblyUploadsOptions extends AssemblyUploadOptions {
42
60
  assemblyUrl: string;
@@ -63,6 +81,12 @@ export interface AwaitAssemblyCompletionOptions {
63
81
  */
64
82
  onPoll?: () => boolean | undefined;
65
83
  }
84
+ export interface LintAssemblyInstructionsOptions extends Omit<LintAssemblyInstructionsInput, 'template'> {
85
+ /**
86
+ * Template ID to merge with the provided instructions before linting.
87
+ */
88
+ templateId?: string;
89
+ }
66
90
  export interface SmartCDNUrlOptions {
67
91
  /**
68
92
  * Workspace slug
@@ -87,21 +111,31 @@ export interface SmartCDNUrlOptions {
87
111
  expiresAt?: number;
88
112
  }
89
113
  export type Fields = Record<string, string | number>;
90
- interface CreateAssemblyPromise extends Promise<AssemblyStatus> {
114
+ interface CreateAssemblyPromise extends Promise<AssemblyStatusWithUploadUrls> {
91
115
  assemblyId: string;
92
116
  }
93
- export interface Options {
117
+ type AuthKeySecret = {
94
118
  authKey: string;
95
119
  authSecret: string;
120
+ authToken?: undefined;
121
+ };
122
+ type AuthToken = {
123
+ authToken: string;
124
+ authKey?: string;
125
+ authSecret?: string;
126
+ };
127
+ type BaseOptions = {
96
128
  endpoint?: string;
97
129
  maxRetries?: number;
98
130
  timeout?: number;
99
131
  gotRetry?: Partial<RetryOptions>;
100
132
  validateResponses?: boolean;
101
- }
133
+ };
134
+ export type Options = BaseOptions & (AuthKeySecret | AuthToken);
102
135
  export declare class Transloadit {
103
136
  private _authKey;
104
137
  private _authSecret;
138
+ private _authToken;
105
139
  private _endpoint;
106
140
  private _maxRetries;
107
141
  private _defaultTimeout;
@@ -117,7 +151,18 @@ export declare class Transloadit {
117
151
  * @param opts assembly options
118
152
  */
119
153
  createAssembly(opts?: CreateAssemblyOptions): CreateAssemblyPromise;
120
- resumeAssemblyUploads(opts: ResumeAssemblyUploadsOptions): Promise<AssemblyStatus>;
154
+ /**
155
+ * Lint Assembly Instructions locally.
156
+ *
157
+ * If a templateId is provided, the template content is merged with the instructions,
158
+ * just like the API. When a template sets `allow_steps_override=false`, providing
159
+ * `steps` will throw a TEMPLATE_DENIES_STEPS_OVERRIDE error.
160
+ *
161
+ * The `assemblyInstructions` input may be a JSON string, a full instructions object,
162
+ * or a steps-only object (missing the `steps` property).
163
+ */
164
+ lintAssemblyInstructions(options: LintAssemblyInstructionsOptions): Promise<LintAssemblyInstructionsResult>;
165
+ resumeAssemblyUploads(opts: ResumeAssemblyUploadsOptions): Promise<AssemblyStatusWithUploadUrls>;
121
166
  awaitAssemblyCompletion(assemblyId: string, { onAssemblyProgress, timeout, startTimeMs, interval, assemblyUrl, signal, onPoll, }?: AwaitAssemblyCompletionOptions): Promise<AssemblyStatus>;
122
167
  maybeThrowInconsistentResponseError(message: string): void;
123
168
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Transloadit.d.ts","sourceRoot":"","sources":["../src/Transloadit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAA8C,YAAY,EAAE,MAAM,KAAK,CAAA;AAEnF,OAAmB,EAAE,KAAK,KAAK,IAAI,eAAe,EAAE,MAAM,aAAa,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAEV,iBAAiB,EACjB,cAAc,EACf,MAAM,oCAAoC,CAAA;AAG3C,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,gCAAgC,EAChC,kCAAkC,EAClC,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EACjB,MAAM,eAAe,CAAA;AACtB,OAAO,yBAAyB,MAAM,gCAAgC,CAAA;AACtE,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;AAOpD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,KAAK,CAAA;AAEZ,YAAY,EAAE,cAAc,EAA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AM,GACjB;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAUxC;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAWtD,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,eAAe;YAST,WAAW;CA8H1B"}
@@ -16,14 +16,19 @@ import { ApiError } from "./ApiError.js";
16
16
  import { assemblyIndexSchema, assemblyStatusSchema } from "./alphalib/types/assemblyStatus.js";
17
17
  import { zodParseWithContext } from "./alphalib/zodParseWithContext.js";
18
18
  import InconsistentResponseError from "./InconsistentResponseError.js";
19
+ import { lintAssemblyInstructions as lintAssemblyInstructionsInternal } from "./lintAssemblyInstructions.js";
19
20
  import PaginationStream from "./PaginationStream.js";
20
21
  import PollingTimeoutError from "./PollingTimeoutError.js";
21
22
  import { sendTusRequest } from "./tus.js";
22
23
  // See https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#errors
23
24
  // Expose relevant errors
24
25
  export { HTTPError, MaxRedirectsError, ParseError, ReadError, RequestError, TimeoutError, UploadError, } from 'got';
26
+ export { goldenTemplates } from "./alphalib/goldenTemplates.js";
25
27
  export * from "./apiTypes.js";
26
28
  export { InconsistentResponseError, ApiError };
29
+ export { mergeTemplateContent } from "./alphalib/templateMerge.js";
30
+ export { prepareInputFiles } from "./inputFiles.js";
31
+ export { getRobotHelp, listRobots } from "./robots.js";
27
32
  const log = debug('transloadit');
28
33
  const logWarn = debug('transloadit:warn');
29
34
  const { version } = packageJson;
@@ -105,6 +110,7 @@ function checkResult(result) {
105
110
  export class Transloadit {
106
111
  _authKey;
107
112
  _authSecret;
113
+ _authToken;
108
114
  _endpoint;
109
115
  _maxRetries;
110
116
  _defaultTimeout;
@@ -112,17 +118,22 @@ export class Transloadit {
112
118
  _lastUsedAssemblyUrl = '';
113
119
  _validateResponses = false;
114
120
  constructor(opts) {
115
- if (opts?.authKey == null) {
116
- throw new Error('Please provide an authKey');
117
- }
118
- if (opts.authSecret == null) {
119
- throw new Error('Please provide an authSecret');
120
- }
121
+ const rawToken = typeof opts?.authToken === 'string' ? opts.authToken.trim() : '';
122
+ const hasToken = rawToken.length > 0;
121
123
  if (opts.endpoint?.endsWith('/')) {
122
124
  throw new Error('Trailing slash in endpoint is not allowed');
123
125
  }
124
- this._authKey = opts.authKey;
125
- this._authSecret = opts.authSecret;
126
+ if (!hasToken) {
127
+ if (opts?.authKey == null) {
128
+ throw new Error('Please provide an authKey');
129
+ }
130
+ if (opts.authSecret == null) {
131
+ throw new Error('Please provide an authSecret');
132
+ }
133
+ }
134
+ this._authKey = opts.authKey ?? '';
135
+ this._authSecret = opts.authSecret ?? '';
136
+ this._authToken = hasToken ? rawToken : null;
126
137
  this._endpoint = opts.endpoint || 'https://api2.transloadit.com';
127
138
  this._maxRetries = opts.maxRetries != null ? opts.maxRetries : 5;
128
139
  this._defaultTimeout = opts.timeout != null ? opts.timeout : 60000;
@@ -144,7 +155,7 @@ export class Transloadit {
144
155
  */
145
156
  createAssembly(opts = {}) {
146
157
  const { params = {}, waitForCompletion = false, chunkSize: requestedChunkSize = Number.POSITIVE_INFINITY, uploadConcurrency = 10, timeout = 24 * 60 * 60 * 1000, // 1 day
147
- onUploadProgress = () => { }, onAssemblyProgress = () => { }, files = {}, uploads = {}, assemblyId, signal, } = opts;
158
+ onUploadProgress = () => { }, onAssemblyProgress = () => { }, files = {}, uploads = {}, assemblyId, expectedUploads, signal, uploadBehavior = 'await', } = opts;
148
159
  // Keep track of how long the request took
149
160
  const startTimeMs = getHrTimeMs();
150
161
  // Undocumented feature to allow specifying a custom assembly id from the client
@@ -186,28 +197,34 @@ export class Transloadit {
186
197
  // errors after the race is already won.
187
198
  const streamErrorPromise = createStreamErrorPromise(allStreamsMap);
188
199
  const createAssemblyAndUpload = async () => {
200
+ const totalExpectedUploads = expectedUploads == null ? allStreams.length : Math.max(expectedUploads, allStreams.length);
189
201
  const result = await this._remoteJson({
190
202
  urlSuffix,
191
203
  method: 'post',
192
204
  timeout: { request: timeout },
193
205
  params,
194
206
  fields: {
195
- tus_num_expected_upload_files: allStreams.length,
207
+ tus_num_expected_upload_files: totalExpectedUploads,
196
208
  },
197
209
  signal,
198
210
  });
199
211
  checkResult(result);
200
212
  if (Object.keys(allStreamsMap).length > 0) {
201
- await sendTusRequest({
213
+ const { uploadUrls } = await sendTusRequest({
202
214
  streamsMap: allStreamsMap,
203
215
  assembly: result,
204
216
  onProgress: onUploadProgress,
205
217
  requestedChunkSize,
206
218
  uploadConcurrency,
207
219
  signal,
220
+ uploadBehavior,
208
221
  });
222
+ if (uploadBehavior !== 'await' && Object.keys(uploadUrls).length > 0) {
223
+ result.upload_urls = uploadUrls;
224
+ }
209
225
  }
210
- if (!waitForCompletion)
226
+ const shouldWaitForCompletion = waitForCompletion && uploadBehavior === 'await';
227
+ if (!shouldWaitForCompletion)
211
228
  return result;
212
229
  if (result.assembly_id == null) {
213
230
  throw new InconsistentResponseError('Server returned an assembly response without an assembly_id after creation');
@@ -226,12 +243,36 @@ export class Transloadit {
226
243
  // This allows the user to use or log the assemblyId even before it has been created for easier debugging
227
244
  return Object.assign(promise, { assemblyId: effectiveAssemblyId });
228
245
  }
246
+ /**
247
+ * Lint Assembly Instructions locally.
248
+ *
249
+ * If a templateId is provided, the template content is merged with the instructions,
250
+ * just like the API. When a template sets `allow_steps_override=false`, providing
251
+ * `steps` will throw a TEMPLATE_DENIES_STEPS_OVERRIDE error.
252
+ *
253
+ * The `assemblyInstructions` input may be a JSON string, a full instructions object,
254
+ * or a steps-only object (missing the `steps` property).
255
+ */
256
+ async lintAssemblyInstructions(options) {
257
+ const { templateId, ...rest } = options;
258
+ if (!templateId) {
259
+ return await lintAssemblyInstructionsInternal(rest);
260
+ }
261
+ const template = await this.getTemplate(templateId);
262
+ return await lintAssemblyInstructionsInternal({
263
+ ...rest,
264
+ template: template.content,
265
+ });
266
+ }
229
267
  async resumeAssemblyUploads(opts) {
230
268
  const { assemblyUrl, files = {}, uploads = {}, chunkSize: requestedChunkSize = Number.POSITIVE_INFINITY, uploadConcurrency = 10, timeout = 24 * 60 * 60 * 1000, // 1 day
231
- waitForCompletion = false, onUploadProgress = () => { }, onAssemblyProgress = () => { }, signal, } = opts;
269
+ waitForCompletion = false, onUploadProgress = () => { }, onAssemblyProgress = () => { }, signal, uploadBehavior = 'await', } = opts;
232
270
  const startTimeMs = getHrTimeMs();
233
271
  getAssemblyIdFromUrl(assemblyUrl);
234
- const assembly = await this._fetchAssemblyStatus({ url: assemblyUrl, signal });
272
+ const assembly = await this._fetchAssemblyStatus({
273
+ url: assemblyUrl,
274
+ signal,
275
+ });
235
276
  const statusUrl = assembly.assembly_ssl_url ?? assembly.assembly_url ?? assemblyUrl;
236
277
  const finishedKeys = new Set();
237
278
  for (const upload of assembly.uploads ?? []) {
@@ -302,11 +343,23 @@ export class Transloadit {
302
343
  onProgress: onUploadProgress,
303
344
  signal,
304
345
  uploadUrls: uploadUrlsByLabel,
346
+ uploadBehavior,
305
347
  });
306
348
  await Promise.race([uploadPromise, streamErrorPromise]);
349
+ const { uploadUrls } = await uploadPromise;
350
+ if (uploadBehavior !== 'await' && Object.keys(uploadUrls).length > 0) {
351
+ assembly.upload_urls = uploadUrls;
352
+ }
353
+ }
354
+ const latestAssembly = await this._fetchAssemblyStatus({
355
+ url: statusUrl,
356
+ signal,
357
+ });
358
+ if (uploadBehavior !== 'await' && assembly.upload_urls) {
359
+ latestAssembly.upload_urls = assembly.upload_urls;
307
360
  }
308
- const latestAssembly = await this._fetchAssemblyStatus({ url: statusUrl, signal });
309
- if (!waitForCompletion)
361
+ const shouldWaitForCompletion = waitForCompletion && uploadBehavior === 'await';
362
+ if (!shouldWaitForCompletion)
310
363
  return latestAssembly;
311
364
  if (latestAssembly.assembly_id == null) {
312
365
  throw new InconsistentResponseError('Server returned an assembly response without an assembly_id after resuming uploads');
@@ -398,6 +451,7 @@ export class Transloadit {
398
451
  const { assembly_ssl_url: url } = await this.getAssembly(assemblyId);
399
452
  const rawResult = await this._remoteJson({
400
453
  url,
454
+ isTrustedUrl: true,
401
455
  method: 'delete',
402
456
  });
403
457
  const parsedResult = zodParseWithContext(assemblyStatusSchema, rawResult);
@@ -483,6 +537,7 @@ export class Transloadit {
483
537
  const rawResult = await this._remoteJson({
484
538
  url,
485
539
  urlSuffix: url ? undefined : `/assemblies/${assemblyId}`,
540
+ isTrustedUrl: Boolean(url),
486
541
  signal,
487
542
  });
488
543
  const parsedResult = zodParseWithContext(assemblyStatusSchema, rawResult);
@@ -644,6 +699,9 @@ export class Transloadit {
644
699
  });
645
700
  }
646
701
  calcSignature(params, algorithm) {
702
+ if (!this._authKey || !this._authSecret) {
703
+ throw new Error('Cannot sign params without authKey and authSecret.');
704
+ }
647
705
  const jsonParams = this._prepareParams(params);
648
706
  const signature = this._calcSignature(jsonParams, algorithm);
649
707
  return { signature, params: jsonParams };
@@ -652,6 +710,9 @@ export class Transloadit {
652
710
  * Construct a signed Smart CDN URL. See https://transloadit.com/docs/topics/signature-authentication/#smart-cdn.
653
711
  */
654
712
  getSignedSmartCDNUrl(opts) {
713
+ if (!this._authKey || !this._authSecret) {
714
+ throw new Error('authKey and authSecret are required to sign Smart CDN URLs.');
715
+ }
655
716
  return getSignedSmartCdnUrl({
656
717
  ...opts,
657
718
  authKey: this._authKey,
@@ -659,27 +720,42 @@ export class Transloadit {
659
720
  });
660
721
  }
661
722
  _calcSignature(toSign, algorithm = 'sha384') {
723
+ if (!this._authSecret) {
724
+ throw new Error('Cannot sign params without authSecret.');
725
+ }
662
726
  return signParamsSync(toSign, this._authSecret, algorithm);
663
727
  }
664
728
  // Sets the multipart/form-data for POST, PUT and DELETE requests, including
665
729
  // the streams, the signed params, and any additional fields.
666
730
  _appendForm(form, params, fields) {
667
- const sigData = this.calcSignature(params);
668
- const jsonParams = sigData.params;
669
- const { signature } = sigData;
731
+ const shouldSign = Boolean(this._authKey && this._authSecret);
732
+ let jsonParams = JSON.stringify(params ?? {});
733
+ let signature;
734
+ if (shouldSign) {
735
+ const sigData = this.calcSignature(params);
736
+ jsonParams = sigData.params;
737
+ signature = sigData.signature;
738
+ }
670
739
  form.append('params', jsonParams);
671
740
  if (fields != null) {
672
741
  for (const [key, val] of Object.entries(fields)) {
673
742
  form.append(key, val);
674
743
  }
675
744
  }
676
- form.append('signature', signature);
745
+ if (signature) {
746
+ form.append('signature', signature);
747
+ }
677
748
  }
678
749
  // Implements HTTP GET query params, handling the case where the url already
679
750
  // has params.
680
751
  _appendParamsToUrl(url, params) {
681
- const { signature, params: jsonParams } = this.calcSignature(params);
682
752
  const prefix = url.indexOf('?') === -1 ? '?' : '&';
753
+ const shouldSign = Boolean(this._authKey && this._authSecret);
754
+ if (!shouldSign) {
755
+ const jsonParams = JSON.stringify(params ?? {});
756
+ return `${url}${prefix}params=${encodeURIComponent(jsonParams)}`;
757
+ }
758
+ const { signature, params: jsonParams } = this.calcSignature(params);
683
759
  return `${url}${prefix}signature=${signature}&params=${encodeURIComponent(jsonParams)}`;
684
760
  }
685
761
  // Responsible for including auth parameters in all requests
@@ -709,11 +785,18 @@ export class Transloadit {
709
785
  // PUT or DELETE requests. Automatically adds signature parameters to all
710
786
  // requests. Also automatically parses the JSON response.
711
787
  async _remoteJson(opts) {
712
- const { urlSuffix, url: urlInput, timeout = { request: this._defaultTimeout }, method = 'get', params = {}, fields, headers, signal, } = opts;
788
+ const { urlSuffix, url: urlInput, isTrustedUrl = false, timeout = { request: this._defaultTimeout }, method = 'get', params = {}, fields, headers, signal, } = opts;
713
789
  // Allow providing either a `urlSuffix` or a full `url`
714
790
  if (!urlSuffix && !urlInput)
715
791
  throw new Error('No URL provided');
716
792
  let url = urlInput || `${this._endpoint}${urlSuffix}`;
793
+ if (urlInput && !isTrustedUrl) {
794
+ const allowed = new URL(this._endpoint);
795
+ const candidate = new URL(urlInput);
796
+ if (allowed.origin !== candidate.origin) {
797
+ throw new Error(`Untrusted URL: ${candidate.origin}`);
798
+ }
799
+ }
717
800
  if (method === 'get') {
718
801
  url = this._appendParamsToUrl(url, params);
719
802
  }
@@ -733,6 +816,7 @@ export class Transloadit {
733
816
  headers: {
734
817
  'Transloadit-Client': `node-sdk:${version}`,
735
818
  'User-Agent': undefined, // Remove got's user-agent
819
+ ...(this._authToken ? { Authorization: `Bearer ${this._authToken}` } : {}),
736
820
  ...headers,
737
821
  },
738
822
  responseType: 'json',