transloadit 4.12.0 → 4.13.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 (135) hide show
  1. package/README.md +231 -23
  2. package/dist/Transloadit.d.ts +55 -1
  3. package/dist/Transloadit.d.ts.map +1 -1
  4. package/dist/Transloadit.js +143 -2
  5. package/dist/Transloadit.js.map +1 -1
  6. package/dist/alphalib/types/assemblyStatus.d.ts +574 -198
  7. package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -1
  8. package/dist/alphalib/types/assemblyStatus.js +17 -0
  9. package/dist/alphalib/types/assemblyStatus.js.map +1 -1
  10. package/dist/alphalib/types/robots/_index.d.ts +205 -93
  11. package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
  12. package/dist/alphalib/types/robots/_index.js +8 -0
  13. package/dist/alphalib/types/robots/_index.js.map +1 -1
  14. package/dist/alphalib/types/robots/_instructions-primitives.d.ts +4 -4
  15. package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
  16. package/dist/alphalib/types/robots/_instructions-primitives.js +2 -0
  17. package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
  18. package/dist/alphalib/types/robots/file-serve.d.ts +12 -0
  19. package/dist/alphalib/types/robots/file-serve.d.ts.map +1 -1
  20. package/dist/alphalib/types/robots/file-serve.js +9 -3
  21. package/dist/alphalib/types/robots/file-serve.js.map +1 -1
  22. package/dist/alphalib/types/robots/transloadit-import.d.ts +195 -0
  23. package/dist/alphalib/types/robots/transloadit-import.d.ts.map +1 -0
  24. package/dist/alphalib/types/robots/transloadit-import.js +108 -0
  25. package/dist/alphalib/types/robots/transloadit-import.js.map +1 -0
  26. package/dist/alphalib/types/robots/transloadit-store.d.ts +441 -0
  27. package/dist/alphalib/types/robots/transloadit-store.d.ts.map +1 -0
  28. package/dist/alphalib/types/robots/transloadit-store.js +69 -0
  29. package/dist/alphalib/types/robots/transloadit-store.js.map +1 -0
  30. package/dist/alphalib/types/robots/video-ondemand.d.ts +8 -8
  31. package/dist/alphalib/types/storageAsset.d.ts +226 -0
  32. package/dist/alphalib/types/storageAsset.d.ts.map +1 -0
  33. package/dist/alphalib/types/storageAsset.js +67 -0
  34. package/dist/alphalib/types/storageAsset.js.map +1 -0
  35. package/dist/alphalib/types/template.d.ts.map +1 -1
  36. package/dist/alphalib/types/template.js +5 -2
  37. package/dist/alphalib/types/template.js.map +1 -1
  38. package/dist/alphalib/types/templateCredential.d.ts +2 -2
  39. package/dist/cli/commands/BaseCommand.d.ts +3 -1
  40. package/dist/cli/commands/BaseCommand.d.ts.map +1 -1
  41. package/dist/cli/commands/BaseCommand.js +3 -2
  42. package/dist/cli/commands/BaseCommand.js.map +1 -1
  43. package/dist/cli/commands/assemblies.d.ts.map +1 -1
  44. package/dist/cli/commands/assemblies.js +9 -4
  45. package/dist/cli/commands/assemblies.js.map +1 -1
  46. package/dist/cli/commands/auth.d.ts +6 -0
  47. package/dist/cli/commands/auth.d.ts.map +1 -1
  48. package/dist/cli/commands/auth.js +21 -2
  49. package/dist/cli/commands/auth.js.map +1 -1
  50. package/dist/cli/commands/image.d.ts +15 -0
  51. package/dist/cli/commands/image.d.ts.map +1 -0
  52. package/dist/cli/commands/image.js +234 -0
  53. package/dist/cli/commands/image.js.map +1 -0
  54. package/dist/cli/commands/index.d.ts.map +1 -1
  55. package/dist/cli/commands/index.js +15 -1
  56. package/dist/cli/commands/index.js.map +1 -1
  57. package/dist/cli/commands/login.d.ts +24 -0
  58. package/dist/cli/commands/login.d.ts.map +1 -0
  59. package/dist/cli/commands/login.js +275 -0
  60. package/dist/cli/commands/login.js.map +1 -0
  61. package/dist/cli/commands/storage.d.ts +58 -0
  62. package/dist/cli/commands/storage.d.ts.map +1 -0
  63. package/dist/cli/commands/storage.js +589 -0
  64. package/dist/cli/commands/storage.js.map +1 -0
  65. package/dist/cli/commands/templates.d.ts.map +1 -1
  66. package/dist/cli/commands/templates.js +10 -6
  67. package/dist/cli/commands/templates.js.map +1 -1
  68. package/dist/cli/deviceLogin.d.ts +11 -0
  69. package/dist/cli/deviceLogin.d.ts.map +1 -0
  70. package/dist/cli/deviceLogin.js +187 -0
  71. package/dist/cli/deviceLogin.js.map +1 -0
  72. package/dist/cli/helpers.d.ts +23 -1
  73. package/dist/cli/helpers.d.ts.map +1 -1
  74. package/dist/cli/helpers.js +159 -25
  75. package/dist/cli/helpers.js.map +1 -1
  76. package/dist/cli/secretInput.d.ts +3 -0
  77. package/dist/cli/secretInput.d.ts.map +1 -0
  78. package/dist/cli/secretInput.js +11 -0
  79. package/dist/cli/secretInput.js.map +1 -0
  80. package/dist/cli/storageCatalog.d.ts +19 -0
  81. package/dist/cli/storageCatalog.d.ts.map +1 -0
  82. package/dist/cli/storageCatalog.js +129 -0
  83. package/dist/cli/storageCatalog.js.map +1 -0
  84. package/dist/cli/storagePublic.d.ts +3 -0
  85. package/dist/cli/storagePublic.d.ts.map +1 -0
  86. package/dist/cli/storagePublic.js +15 -0
  87. package/dist/cli/storagePublic.js.map +1 -0
  88. package/dist/cli/storageReceipts.d.ts +67 -0
  89. package/dist/cli/storageReceipts.d.ts.map +1 -0
  90. package/dist/cli/storageReceipts.js +242 -0
  91. package/dist/cli/storageReceipts.js.map +1 -0
  92. package/dist/cli/storageSnippets.d.ts +11 -0
  93. package/dist/cli/storageSnippets.d.ts.map +1 -0
  94. package/dist/cli/storageSnippets.js +89 -0
  95. package/dist/cli/storageSnippets.js.map +1 -0
  96. package/dist/storageImage.d.ts +40 -0
  97. package/dist/storageImage.d.ts.map +1 -0
  98. package/dist/storageImage.js +181 -0
  99. package/dist/storageImage.js.map +1 -0
  100. package/dist/storagePublicPrefixes.d.ts +62 -0
  101. package/dist/storagePublicPrefixes.d.ts.map +1 -0
  102. package/dist/storagePublicPrefixes.js +35 -0
  103. package/dist/storagePublicPrefixes.js.map +1 -0
  104. package/dist/storageResults.d.ts +31 -0
  105. package/dist/storageResults.d.ts.map +1 -0
  106. package/dist/storageResults.js +79 -0
  107. package/dist/storageResults.js.map +1 -0
  108. package/package.json +8 -3
  109. package/src/Transloadit.ts +251 -4
  110. package/src/alphalib/types/assemblyStatus.ts +17 -0
  111. package/src/alphalib/types/robots/_index.ts +28 -0
  112. package/src/alphalib/types/robots/_instructions-primitives.ts +2 -0
  113. package/src/alphalib/types/robots/file-serve.ts +11 -3
  114. package/src/alphalib/types/robots/transloadit-import.ts +154 -0
  115. package/src/alphalib/types/robots/transloadit-store.ts +98 -0
  116. package/src/alphalib/types/storageAsset.ts +88 -0
  117. package/src/alphalib/types/template.ts +3 -0
  118. package/src/cli/commands/BaseCommand.ts +4 -2
  119. package/src/cli/commands/assemblies.ts +13 -5
  120. package/src/cli/commands/auth.ts +26 -3
  121. package/src/cli/commands/image.ts +282 -0
  122. package/src/cli/commands/index.ts +27 -1
  123. package/src/cli/commands/login.ts +334 -0
  124. package/src/cli/commands/storage.ts +733 -0
  125. package/src/cli/commands/templates.ts +14 -7
  126. package/src/cli/deviceLogin.ts +226 -0
  127. package/src/cli/helpers.ts +204 -27
  128. package/src/cli/secretInput.ts +12 -0
  129. package/src/cli/storageCatalog.ts +192 -0
  130. package/src/cli/storagePublic.ts +15 -0
  131. package/src/cli/storageReceipts.ts +307 -0
  132. package/src/cli/storageSnippets.ts +96 -0
  133. package/src/storageImage.ts +266 -0
  134. package/src/storagePublicPrefixes.ts +39 -0
  135. package/src/storageResults.ts +119 -0
@@ -0,0 +1,62 @@
1
+ import { z } from 'zod';
2
+ /** Normalize a public directory, never implicit workspace-wide access. */
3
+ export declare function normalizeStoragePublicPrefix(prefix: string): string;
4
+ export declare const storagePublicPrefixesSchema: z.ZodObject<{
5
+ ok: z.ZodLiteral<"STORAGE_PUBLIC_PREFIXES_LISTED">;
6
+ public_prefixes: z.ZodArray<z.ZodObject<{
7
+ prefix: z.ZodEffects<z.ZodString, string, string>;
8
+ created_at: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ prefix: string;
11
+ created_at: string;
12
+ }, {
13
+ prefix: string;
14
+ created_at: string;
15
+ }>, "many">;
16
+ }, "strip", z.ZodTypeAny, {
17
+ ok: "STORAGE_PUBLIC_PREFIXES_LISTED";
18
+ public_prefixes: {
19
+ prefix: string;
20
+ created_at: string;
21
+ }[];
22
+ }, {
23
+ ok: "STORAGE_PUBLIC_PREFIXES_LISTED";
24
+ public_prefixes: {
25
+ prefix: string;
26
+ created_at: string;
27
+ }[];
28
+ }>;
29
+ export declare const storagePublicPrefixDeclaredSchema: z.ZodObject<{
30
+ prefix: z.ZodEffects<z.ZodString, string, string>;
31
+ created_at: z.ZodString;
32
+ } & {
33
+ ok: z.ZodLiteral<"STORAGE_PUBLIC_PREFIX_DECLARED">;
34
+ created: z.ZodBoolean;
35
+ }, "strip", z.ZodTypeAny, {
36
+ prefix: string;
37
+ ok: "STORAGE_PUBLIC_PREFIX_DECLARED";
38
+ created: boolean;
39
+ created_at: string;
40
+ }, {
41
+ prefix: string;
42
+ ok: "STORAGE_PUBLIC_PREFIX_DECLARED";
43
+ created: boolean;
44
+ created_at: string;
45
+ }>;
46
+ export declare const storagePublicPrefixRevokedSchema: z.ZodObject<{
47
+ ok: z.ZodLiteral<"STORAGE_PUBLIC_PREFIX_REVOKED">;
48
+ prefix: z.ZodEffects<z.ZodString, string, string>;
49
+ deleted: z.ZodBoolean;
50
+ }, "strip", z.ZodTypeAny, {
51
+ prefix: string;
52
+ ok: "STORAGE_PUBLIC_PREFIX_REVOKED";
53
+ deleted: boolean;
54
+ }, {
55
+ prefix: string;
56
+ ok: "STORAGE_PUBLIC_PREFIX_REVOKED";
57
+ deleted: boolean;
58
+ }>;
59
+ export type StoragePublicPrefixes = z.infer<typeof storagePublicPrefixesSchema>;
60
+ export type StoragePublicPrefixDeclared = z.infer<typeof storagePublicPrefixDeclaredSchema>;
61
+ export type StoragePublicPrefixRevoked = z.infer<typeof storagePublicPrefixRevokedSchema>;
62
+ //# sourceMappingURL=storagePublicPrefixes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storagePublicPrefixes.d.ts","sourceRoot":"","sources":["../src/storagePublicPrefixes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,0EAA0E;AAC1E,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQnE;AAUD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;EAGtC,CAAA;AACF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;EAG5C,CAAA;AACF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;EAI3C,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC/E,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAC3F,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { validateStoragePathPrefix } from '@transloadit/utils';
2
+ import { z } from 'zod';
3
+ /** Normalize a public directory, never implicit workspace-wide access. */
4
+ export function normalizeStoragePublicPrefix(prefix) {
5
+ if (typeof prefix !== 'string' || prefix === '' || prefix === '/')
6
+ throw new TypeError('A public prefix must name a non-root directory');
7
+ const normalized = prefix.endsWith('/') ? prefix : `${prefix}/`;
8
+ validateStoragePathPrefix(normalized, 0, 'public prefix');
9
+ if (new TextEncoder().encode(normalized).byteLength > 512)
10
+ throw new TypeError('A public prefix must be at most 512 UTF-8 bytes');
11
+ return normalized;
12
+ }
13
+ const prefixSchema = z.string().refine((prefix) => {
14
+ try {
15
+ return normalizeStoragePublicPrefix(prefix) === prefix;
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }, 'Expected a normalized public directory');
21
+ const publicPrefixSchema = z.object({ prefix: prefixSchema, created_at: z.string() });
22
+ export const storagePublicPrefixesSchema = z.object({
23
+ ok: z.literal('STORAGE_PUBLIC_PREFIXES_LISTED'),
24
+ public_prefixes: z.array(publicPrefixSchema),
25
+ });
26
+ export const storagePublicPrefixDeclaredSchema = publicPrefixSchema.extend({
27
+ ok: z.literal('STORAGE_PUBLIC_PREFIX_DECLARED'),
28
+ created: z.boolean(),
29
+ });
30
+ export const storagePublicPrefixRevokedSchema = z.object({
31
+ ok: z.literal('STORAGE_PUBLIC_PREFIX_REVOKED'),
32
+ prefix: prefixSchema,
33
+ deleted: z.boolean(),
34
+ });
35
+ //# sourceMappingURL=storagePublicPrefixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storagePublicPrefixes.js","sourceRoot":"","sources":["../src/storagePublicPrefixes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,0EAA0E;AAC1E,MAAM,UAAU,4BAA4B,CAAC,MAAc;IACzD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,EAAE,IAAI,MAAM,KAAK,GAAG;QAC/D,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAA;IACvE,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAA;IAC/D,yBAAyB,CAAC,UAAU,EAAE,CAAC,EAAE,eAAe,CAAC,CAAA;IACzD,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,GAAG,GAAG;QACvD,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAA;IACxE,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;IAChD,IAAI,CAAC;QACH,OAAO,4BAA4B,CAAC,MAAM,CAAC,KAAK,MAAM,CAAA;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,EAAE,wCAAwC,CAAC,CAAA;AAC5C,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACrF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAAC;IAC/C,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC7C,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,iCAAiC,GAAG,kBAAkB,CAAC,MAAM,CAAC;IACzE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,+BAA+B,CAAC;IAC9C,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAA"}
@@ -0,0 +1,31 @@
1
+ import type { StoredAsset } from './alphalib/types/storageAsset.ts';
2
+ import type { Transloadit } from './Transloadit.ts';
3
+ /** Original-byte delivery, not a preview or transcode; authorize the application's asset first. */
4
+ export interface StoredAssetUrlOptions {
5
+ /** True uses the receipt filename; a string supplies a different attachment filename. */
6
+ download?: boolean | string;
7
+ /** Maximum signed lifetime, from one second to 48 hours. Defaults to five minutes. */
8
+ lifetimeMs?: number;
9
+ }
10
+ /** Signs a retained original, including non-image media, without fetching or proxying its bytes. */
11
+ export declare function getStoredAssetUrl(client: Transloadit, input: StoredAsset, options?: StoredAssetUrlOptions): string;
12
+ /** Server-owned Assembly identity and expected Workspace, not values from an untrusted notification. */
13
+ export interface GetStoredAssemblyResultsOptions {
14
+ assemblyId: string;
15
+ workspace: string;
16
+ }
17
+ /** A canonical stored asset with the producing result's provenance; one input can have many outputs. */
18
+ export interface StoredAssemblyResult {
19
+ assembly_id: string;
20
+ step: string;
21
+ result_id: string;
22
+ original_id?: string | (string | null)[];
23
+ asset: StoredAsset;
24
+ }
25
+ /**
26
+ * Fetches a completed Assembly and verifies all retained results, including non-image media.
27
+ * The caller must first bind the Assembly to an authorized application upload. Register results
28
+ * idempotently by Assembly/step/result ID (or asset/version), not by filename or notification count.
29
+ */
30
+ export declare function getStoredAssemblyResults(client: Transloadit, options: GetStoredAssemblyResultsOptions): Promise<StoredAssemblyResult[]>;
31
+ //# sourceMappingURL=storageResults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageResults.d.ts","sourceRoot":"","sources":["../src/storageResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AASnD,mGAAmG;AACnG,MAAM,WAAW,qBAAqB;IACpC,yFAAyF;IACzF,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAC3B,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,oGAAoG;AACpG,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,qBAA0B,GAClC,MAAM,CAuBR;AAED,wGAAwG;AACxG,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,wGAAwG;AACxG,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACxC,KAAK,EAAE,WAAW,CAAA;CACnB;AAWD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAsCjC"}
@@ -0,0 +1,79 @@
1
+ import { z } from 'zod';
2
+ import { ApiError } from "./ApiError.js";
3
+ import { robotFileServeInstructionsSchema } from "./alphalib/types/robots/file-serve.js";
4
+ import { storedAssetSchema } from "./alphalib/types/storageAsset.js";
5
+ import InconsistentResponseError from "./InconsistentResponseError.js";
6
+ /** Signs a retained original, including non-image media, without fetching or proxying its bytes. */
7
+ export function getStoredAssetUrl(client, input, options = {}) {
8
+ const asset = storedAssetSchema.parse(input);
9
+ const lifetimeMs = options.lifetimeMs ?? 5 * 60_000;
10
+ if (!Number.isSafeInteger(lifetimeMs) || lifetimeMs < 1000 || lifetimeMs > 48 * 3600_000) {
11
+ throw new RangeError('lifetimeMs must be an integer between 1000 and 172800000');
12
+ }
13
+ const download = options.download === true ? asset.path.split('/').at(-1) : options.download;
14
+ if (download !== undefined && download !== false) {
15
+ robotFileServeInstructionsSchema.shape.download_name.unwrap().min(1).parse(download);
16
+ if (typeof download !== 'string' || /[\uD800-\uDFFF]/u.test(download))
17
+ throw new TypeError('download must contain a valid Unicode filename');
18
+ }
19
+ // Bunny includes the full query in its cache key. Rotate at most once a minute, never at
20
+ // the lifetime boundary where rounding could issue an almost-expired grant.
21
+ const rotationMs = Math.min(60_000, Math.floor(lifetimeMs / 2));
22
+ const expiresAt = Math.floor(Date.now() / rotationMs) * rotationMs + lifetimeMs;
23
+ return client.getSignedSmartCDNUrl({
24
+ workspace: asset.workspace,
25
+ template: 'builtin/storage-serve@0.0.3',
26
+ input: asset.asset_id,
27
+ urlParams: { v: asset.version_id, ...(typeof download === 'string' ? { download } : {}) },
28
+ expiresAt,
29
+ });
30
+ }
31
+ const requestSchema = z.object({
32
+ assemblyId: z.string().regex(/^[A-Za-z0-9_-]+$/),
33
+ workspace: z.string().min(1),
34
+ });
35
+ const resultSchema = storedAssetSchema.extend({
36
+ id: z.string().min(1),
37
+ original_id: z.union([z.string(), z.array(z.string().nullable())]).optional(),
38
+ });
39
+ /**
40
+ * Fetches a completed Assembly and verifies all retained results, including non-image media.
41
+ * The caller must first bind the Assembly to an authorized application upload. Register results
42
+ * idempotently by Assembly/step/result ID (or asset/version), not by filename or notification count.
43
+ */
44
+ export async function getStoredAssemblyResults(client, options) {
45
+ const { assemblyId, workspace } = requestSchema.parse(options);
46
+ const assembly = await client.getAssembly(assemblyId);
47
+ if (assembly.assembly_id !== assemblyId) {
48
+ throw new InconsistentResponseError('The response did not match the requested Assembly');
49
+ }
50
+ if (typeof assembly.error === 'string')
51
+ throw new ApiError({ body: assembly });
52
+ if (assembly.ok !== 'ASSEMBLY_COMPLETED') {
53
+ throw new InconsistentResponseError(`The Storage Assembly is not complete (${assembly.ok})`);
54
+ }
55
+ if (assembly.results === undefined) {
56
+ throw new InconsistentResponseError('The completed Assembly did not contain results');
57
+ }
58
+ const results = [];
59
+ for (const [step, files] of Object.entries(assembly.results)) {
60
+ for (const file of files) {
61
+ // Ordinary temporary/exported outputs are not Storage receipts. Partial Storage records
62
+ // must fail validation rather than disappearing from an otherwise successful batch.
63
+ if (file.asset_id === undefined &&
64
+ file.version_id === undefined &&
65
+ file.workspace === undefined)
66
+ continue;
67
+ const parsed = resultSchema.safeParse(file);
68
+ if (!parsed.success || parsed.data.workspace !== workspace) {
69
+ throw new InconsistentResponseError('The Assembly returned an invalid or cross-Workspace Storage result', {
70
+ cause: { assemblyId, step },
71
+ });
72
+ }
73
+ const { id, original_id, ...asset } = parsed.data;
74
+ results.push({ assembly_id: assemblyId, step, result_id: id, original_id, asset });
75
+ }
76
+ }
77
+ return results;
78
+ }
79
+ //# sourceMappingURL=storageResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageResults.js","sourceRoot":"","sources":["../src/storageResults.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transloadit",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
4
4
  "description": "Node.js SDK for Transloadit",
5
5
  "homepage": "https://github.com/transloadit/node-sdk/tree/main/packages/node",
6
6
  "bugs": {
@@ -29,15 +29,16 @@
29
29
  "author": "Tim Koschuetzki <tim@transloadit.com>",
30
30
  "packageManager": "yarn@4.12.0",
31
31
  "engines": {
32
- "node": ">= 20"
32
+ "node": ">= 20.10.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@transloadit/sev-logger": "^0.1.9",
36
- "@transloadit/utils": "^4.8.1",
36
+ "@transloadit/utils": "^4.9.0",
37
37
  "cacheable-lookup": "^7.0.0",
38
38
  "clipanion": "^4.0.0-rc.4",
39
39
  "debug": "^4.4.3",
40
40
  "dotenv": "^17.4.2",
41
+ "execa": "9.6.1",
41
42
  "form-data": "^4.0.5",
42
43
  "got": "14.6.6",
43
44
  "into-stream": "^9.1.0",
@@ -48,11 +49,15 @@
48
49
  "p-map": "^7.0.4",
49
50
  "p-queue": "^9.3.0",
50
51
  "recursive-readdir": "^2.2.3",
52
+ "thumbhash": "0.1.1",
51
53
  "tus-js-client": "^4.3.1",
52
54
  "typanion": "^3.14.0",
53
55
  "type-fest": "^5.6.0",
54
56
  "zod": "3.25.76"
55
57
  },
58
+ "optionalDependencies": {
59
+ "sharp": "0.35.4"
60
+ },
56
61
  "devDependencies": {
57
62
  "@types/debug": "^4.1.13",
58
63
  "@types/node": "^25.8.0",
@@ -4,7 +4,9 @@ import type {
4
4
  CompileAssemblyInstructionsOptions,
5
5
  CompileAssemblyInstructionsResult,
6
6
  } from '@transloadit/utils'
7
+ import type { SignatureAlgorithm } from '@transloadit/utils/node'
7
8
  import type { Delays, Headers, OptionsOfJSONResponseBody, RetryOptions } from 'got'
9
+ import type { Input as IntoStreamInput } from 'into-stream'
8
10
 
9
11
  import type { TransloaditErrorResponseBody } from './ApiError.ts'
10
12
  import type {
@@ -12,6 +14,13 @@ import type {
12
14
  AssemblyIndexItem,
13
15
  AssemblyStatus,
14
16
  } from './alphalib/types/assemblyStatus.ts'
17
+ import type {
18
+ GetStoredAssetOptions,
19
+ ListStoredAssetsOptions,
20
+ MoveStoredAssetOptions,
21
+ StoredAsset,
22
+ StoredAssetsPage,
23
+ } from './alphalib/types/storageAsset.ts'
15
24
  import type {
16
25
  BaseResponse,
17
26
  BillResponse,
@@ -38,6 +47,21 @@ import type {
38
47
  LintAssemblyInstructionsInput,
39
48
  LintAssemblyInstructionsResult,
40
49
  } from './lintAssemblyInstructions.ts'
50
+ import type {
51
+ GetStoredImageReceiptOptions,
52
+ StoredImageReceipt,
53
+ StoreImageOptions,
54
+ } from './storageImage.ts'
55
+ import type {
56
+ StoragePublicPrefixDeclared,
57
+ StoragePublicPrefixes,
58
+ StoragePublicPrefixRevoked,
59
+ } from './storagePublicPrefixes.ts'
60
+ import type {
61
+ GetStoredAssemblyResultsOptions,
62
+ StoredAssemblyResult,
63
+ StoredAssetUrlOptions,
64
+ } from './storageResults.ts'
41
65
  import type { Stream, UploadBehavior } from './tus.ts'
42
66
 
43
67
  import * as assert from 'node:assert'
@@ -52,19 +76,37 @@ import { getSignedSmartCdnUrl, signParamsSync } from '@transloadit/utils/node'
52
76
  import debug from 'debug'
53
77
  import FormData from 'form-data'
54
78
  import got, { HTTPError, RequestError } from 'got'
55
- import intoStream, { type Input as IntoStreamInput } from 'into-stream'
79
+ import intoStream from 'into-stream'
56
80
  import { isReadableStream, isStream } from 'is-stream'
57
81
  import pMap from 'p-map'
82
+ import { z } from 'zod'
58
83
 
59
84
  import packageJson from '../package.json' with { type: 'json' }
60
85
  import { ApiError } from './ApiError.ts'
61
86
  import { assemblyIndexSchema, assemblyStatusSchema } from './alphalib/types/assemblyStatus.ts'
87
+ import {
88
+ damAssetFoundResponseSchema,
89
+ damAssetGetOptionsSchema,
90
+ damAssetMoveOptionsSchema,
91
+ damAssetsListedResponseSchema,
92
+ damAssetsListOptionsSchema,
93
+ damIdSchema,
94
+ storedAssetSchema,
95
+ } from './alphalib/types/storageAsset.ts'
62
96
  import { zodParseWithContext } from './alphalib/zodParseWithContext.ts'
63
97
  import { mintBearerTokenWithCredentials } from './bearerToken.ts'
64
98
  import InconsistentResponseError from './InconsistentResponseError.ts'
65
99
  import { lintAssemblyInstructions as lintAssemblyInstructionsInternal } from './lintAssemblyInstructions.ts'
66
100
  import PaginationStream from './PaginationStream.ts'
67
101
  import PollingTimeoutError from './PollingTimeoutError.ts'
102
+ import { getStoredImageReceipt, storeImage } from './storageImage.ts'
103
+ import {
104
+ normalizeStoragePublicPrefix,
105
+ storagePublicPrefixDeclaredSchema,
106
+ storagePublicPrefixesSchema,
107
+ storagePublicPrefixRevokedSchema,
108
+ } from './storagePublicPrefixes.ts'
109
+ import { getStoredAssemblyResults, getStoredAssetUrl } from './storageResults.ts'
68
110
  import { sendTusRequest } from './tus.ts'
69
111
 
70
112
  export type {
@@ -76,6 +118,13 @@ export type {
76
118
  } from '@transloadit/utils'
77
119
 
78
120
  export type { AssemblyStatus } from './alphalib/types/assemblyStatus.ts'
121
+ export type {
122
+ GetStoredAssetOptions,
123
+ ListStoredAssetsOptions,
124
+ MoveStoredAssetOptions,
125
+ StoredAsset,
126
+ StoredAssetsPage,
127
+ } from './alphalib/types/storageAsset.ts'
79
128
  export type {
80
129
  Base64Strategy,
81
130
  InputFile,
@@ -93,6 +142,22 @@ export type {
93
142
  RobotListResult,
94
143
  RobotParamHelp,
95
144
  } from './robots.ts'
145
+ export type {
146
+ GetStoredImageReceiptOptions,
147
+ StoredImageExpectation,
148
+ StoredImageReceipt,
149
+ StoreImageOptions,
150
+ } from './storageImage.ts'
151
+ export type {
152
+ StoragePublicPrefixDeclared,
153
+ StoragePublicPrefixes,
154
+ StoragePublicPrefixRevoked,
155
+ } from './storagePublicPrefixes.ts'
156
+ export type {
157
+ GetStoredAssemblyResultsOptions,
158
+ StoredAssemblyResult,
159
+ StoredAssetUrlOptions,
160
+ } from './storageResults.ts'
96
161
 
97
162
  export {
98
163
  buildCompileAssemblyInstructionsSystemPrompt,
@@ -382,6 +447,8 @@ type AuthToken = {
382
447
  }
383
448
 
384
449
  type BaseOptions = {
450
+ /** Use signatureAlgorithm: 'sha256' for new combined Smart CDN/Assembly keys; legacy default: sha384. */
451
+ signatureAlgorithm?: SignatureAlgorithm
385
452
  endpoint?: string
386
453
  maxRetries?: number
387
454
  timeout?: number
@@ -393,6 +460,7 @@ type BaseOptions = {
393
460
  export type Options = BaseOptions & (AuthKeySecret | AuthToken)
394
461
 
395
462
  export class Transloadit {
463
+ #signatureAlgorithm: SignatureAlgorithm
396
464
  private _authKey: string
397
465
 
398
466
  private _authSecret: string
@@ -413,6 +481,7 @@ export class Transloadit {
413
481
 
414
482
  private _validateResponses = false
415
483
 
484
+ /** Create a client; new combined keys require signatureAlgorithm: 'sha256' explicitly. */
416
485
  constructor(opts: Options) {
417
486
  const rawToken = typeof opts?.authToken === 'string' ? opts.authToken.trim() : ''
418
487
  const hasToken = rawToken.length > 0
@@ -433,6 +502,7 @@ export class Transloadit {
433
502
 
434
503
  this._authKey = opts.authKey ?? ''
435
504
  this._authSecret = opts.authSecret ?? ''
505
+ this.#signatureAlgorithm = opts.signatureAlgorithm ?? 'sha384'
436
506
  this._authToken = hasToken ? rawToken : null
437
507
  this._endpoint = opts.endpoint || 'https://api2.transloadit.com'
438
508
  this._maxRetries = opts.maxRetries != null ? opts.maxRetries : 5
@@ -453,6 +523,126 @@ export class Transloadit {
453
523
  this._defaultTimeout = timeout
454
524
  }
455
525
 
526
+ /** Stores one local original at an explicit path and returns its verified image metadata. */
527
+ storeImage(filePath: string, options: StoreImageOptions): Promise<StoredImageReceipt> {
528
+ return storeImage(this, filePath, options)
529
+ }
530
+
531
+ /** Reconstructs a verified receipt from authoritative Assembly status and trusted upload facts. */
532
+ getStoredImageReceipt(options: GetStoredImageReceiptOptions): Promise<StoredImageReceipt> {
533
+ return getStoredImageReceipt(this, options)
534
+ }
535
+
536
+ /** Verifies a completed batch's retained media and preserves result/input provenance. */
537
+ getStoredAssemblyResults(
538
+ options: GetStoredAssemblyResultsOptions,
539
+ ): Promise<StoredAssemblyResult[]> {
540
+ return getStoredAssemblyResults(this, options)
541
+ }
542
+
543
+ /** Signs exact original bytes after your app authorizes the asset. Use a 307 for fresh request-time authorization. */
544
+ getStoredAssetUrl(asset: StoredAsset, options?: StoredAssetUrlOptions): string {
545
+ return getStoredAssetUrl(this, asset, options)
546
+ }
547
+
548
+ /** Reads a live asset's current version, or the exact retained version when version_id is set. */
549
+ async getStoredAsset(
550
+ assetId: string,
551
+ options: GetStoredAssetOptions & { signal?: AbortSignal } = {},
552
+ ): Promise<StoredAsset> {
553
+ const id = damIdSchema.parse(assetId)
554
+ const params = damAssetGetOptionsSchema.parse(options)
555
+ const result = await this._remoteJson<unknown, OptionalAuthParams & GetStoredAssetOptions>({
556
+ urlSuffix: `/dam/assets/${id}`,
557
+ method: 'get',
558
+ params,
559
+ signal: options.signal,
560
+ })
561
+ checkResult(result)
562
+ const { asset } = damAssetFoundResponseSchema.parse(result)
563
+ if (
564
+ asset.asset_id !== id ||
565
+ (params.version_id !== undefined && asset.version_id !== params.version_id)
566
+ ) {
567
+ throw new InconsistentResponseError(
568
+ 'The response did not match the requested Storage reference',
569
+ )
570
+ }
571
+ return asset
572
+ }
573
+
574
+ /** Reads one bounded catalog page without S3 credentials or a HEAD request per object. */
575
+ async listStoredAssets(
576
+ options: ListStoredAssetsOptions & { signal?: AbortSignal } = {},
577
+ ): Promise<StoredAssetsPage> {
578
+ const params = damAssetsListOptionsSchema.parse(options)
579
+ const result = await this._remoteJson<unknown, OptionalAuthParams & ListStoredAssetsOptions>({
580
+ urlSuffix: '/dam/assets',
581
+ method: 'get',
582
+ params,
583
+ signal: options.signal,
584
+ })
585
+ checkResult(result)
586
+ const page = damAssetsListedResponseSchema.parse(result)
587
+ if (page.assets.some((asset) => asset.workspace !== page.workspace)) {
588
+ throw new InconsistentResponseError('Storage catalog page contains a different Workspace')
589
+ }
590
+ return page
591
+ }
592
+
593
+ /** Moves or renames an asset natively, preserving asset and version identities. */
594
+ async moveStoredAsset(
595
+ assetId: string,
596
+ options: MoveStoredAssetOptions & { signal?: AbortSignal },
597
+ ): Promise<StoredAsset> {
598
+ const id = damIdSchema.parse(assetId)
599
+ const params = damAssetMoveOptionsSchema.parse(options)
600
+ if (params.filename === undefined && params.destination_folder_id === undefined) {
601
+ throw new TypeError('Provide filename or destination_folder_id for a Storage move')
602
+ }
603
+ const result = await this._remoteJson<unknown, OptionalAuthParams & MoveStoredAssetOptions>({
604
+ urlSuffix: `/dam/assets/${id}`,
605
+ method: 'patch',
606
+ params,
607
+ signal: options.signal,
608
+ })
609
+ checkResult(result)
610
+ const { asset } = z
611
+ .object({ ok: z.literal('DAM_ASSET_MOVED'), asset: storedAssetSchema })
612
+ .parse(result)
613
+ if (asset.asset_id !== id)
614
+ throw new InconsistentResponseError(
615
+ 'The response did not match the requested Storage reference',
616
+ )
617
+ return asset
618
+ }
619
+
620
+ /** Soft-deletes an asset by identity, making retained versions unavailable for new reads. */
621
+ async deleteStoredAsset(
622
+ assetId: string,
623
+ options: { signal?: AbortSignal } = {},
624
+ ): Promise<{ asset_id: string; deleted_at: string }> {
625
+ const id = damIdSchema.parse(assetId)
626
+ const result = await this._remoteJson<unknown, OptionalAuthParams>({
627
+ urlSuffix: `/dam/assets/${id}`,
628
+ method: 'delete',
629
+ signal: options.signal,
630
+ })
631
+ checkResult(result)
632
+ const receipt = z
633
+ .object({
634
+ ok: z.literal('DAM_ASSET_DELETED'),
635
+ asset_id: damIdSchema,
636
+ deleted_at: z.string().datetime(),
637
+ })
638
+ .parse(result)
639
+ if (receipt.asset_id !== id)
640
+ throw new InconsistentResponseError(
641
+ 'The response did not match the requested Storage reference',
642
+ )
643
+ return { asset_id: receipt.asset_id, deleted_at: receipt.deleted_at }
644
+ }
645
+
456
646
  /**
457
647
  * Create an Assembly
458
648
  *
@@ -1199,6 +1389,20 @@ export class Transloadit {
1199
1389
  })
1200
1390
  }
1201
1391
 
1392
+ /** Revoke the signing Auth Key itself, without granting access to other workspace keys. */
1393
+ async revokeOwnAuthKey(): Promise<void> {
1394
+ const result = await this._remoteJson<
1395
+ unknown,
1396
+ OptionalAuthParams & { action: 'revoke_auth_key' }
1397
+ >({
1398
+ urlSuffix: '/auth_keys/self',
1399
+ method: 'delete',
1400
+ params: { action: 'revoke_auth_key' },
1401
+ })
1402
+ checkResult(result)
1403
+ z.object({ ok: z.literal('AUTH_KEY_DELETED') }).parse(result)
1404
+ }
1405
+
1202
1406
  /**
1203
1407
  * Get an Assembly Template
1204
1408
  *
@@ -1232,6 +1436,49 @@ export class Transloadit {
1232
1436
  return new PaginationStream(async (page) => this.listTemplates({ ...params, page }))
1233
1437
  }
1234
1438
 
1439
+ /** Declare a directory public for unsigned Storage Built-ins. Requires dam:write scope. */
1440
+ async publishStoragePrefix(
1441
+ prefix: string,
1442
+ options?: { signal?: AbortSignal },
1443
+ ): Promise<StoragePublicPrefixDeclared> {
1444
+ const result = await this._remoteJson<unknown, OptionalAuthParams & { prefix: string }>({
1445
+ urlSuffix: '/storage/public_prefixes',
1446
+ method: 'post',
1447
+ params: { prefix: normalizeStoragePublicPrefix(prefix) },
1448
+ signal: options?.signal,
1449
+ })
1450
+ checkResult(result)
1451
+ return storagePublicPrefixDeclaredSchema.parse(result)
1452
+ }
1453
+
1454
+ /** Revoke origin access to a public directory; cached or downloaded bytes cannot be recalled. */
1455
+ async unpublishStoragePrefix(
1456
+ prefix: string,
1457
+ options?: { signal?: AbortSignal },
1458
+ ): Promise<StoragePublicPrefixRevoked> {
1459
+ const result = await this._remoteJson<unknown, OptionalAuthParams & { prefix: string }>({
1460
+ urlSuffix: '/storage/public_prefixes',
1461
+ method: 'delete',
1462
+ params: { prefix: normalizeStoragePublicPrefix(prefix) },
1463
+ signal: options?.signal,
1464
+ })
1465
+ checkResult(result)
1466
+ return storagePublicPrefixRevokedSchema.parse(result)
1467
+ }
1468
+
1469
+ /** List the workspace's explicitly public directories through the ordinary signed API. */
1470
+ async listPublicStoragePrefixes(options?: {
1471
+ signal?: AbortSignal
1472
+ }): Promise<StoragePublicPrefixes> {
1473
+ const result = await this._remoteJson({
1474
+ urlSuffix: '/storage/public_prefixes',
1475
+ method: 'get',
1476
+ signal: options?.signal,
1477
+ })
1478
+ checkResult(result)
1479
+ return storagePublicPrefixesSchema.parse(result)
1480
+ }
1481
+
1235
1482
  /**
1236
1483
  * Get account Billing details for a specific month
1237
1484
  *
@@ -1274,7 +1521,7 @@ export class Transloadit {
1274
1521
  })
1275
1522
  }
1276
1523
 
1277
- private _calcSignature(toSign: string, algorithm = 'sha384'): string {
1524
+ private _calcSignature(toSign: string, algorithm: string = this.#signatureAlgorithm): string {
1278
1525
  if (!this._authSecret) {
1279
1526
  throw new Error('Cannot sign params without authSecret.')
1280
1527
  }
@@ -1357,7 +1604,7 @@ export class Transloadit {
1357
1604
  url?: string
1358
1605
  isTrustedUrl?: boolean
1359
1606
  timeout?: Delays
1360
- method?: 'delete' | 'get' | 'post' | 'put'
1607
+ method?: 'delete' | 'get' | 'patch' | 'post' | 'put'
1361
1608
  params?: TParams
1362
1609
  fields?: Fields
1363
1610
  headers?: Headers
@@ -1397,7 +1644,7 @@ export class Transloadit {
1397
1644
  for (let retryCount = 0; ; retryCount++) {
1398
1645
  let form: FormData | undefined
1399
1646
 
1400
- if (method === 'post' || method === 'put' || method === 'delete') {
1647
+ if (method === 'post' || method === 'patch' || method === 'put' || method === 'delete') {
1401
1648
  form = new FormData()
1402
1649
  this._appendForm(form, params, fields)
1403
1650
  }