transloadit 4.1.0 → 4.1.3

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 (172) hide show
  1. package/dist/alphalib/mcache.d.ts +2 -2
  2. package/dist/alphalib/mcache.d.ts.map +1 -1
  3. package/dist/alphalib/mcache.js.map +1 -1
  4. package/dist/alphalib/types/assembliesGet.d.ts +4 -4
  5. package/dist/alphalib/types/assemblyReplay.d.ts +392 -178
  6. package/dist/alphalib/types/assemblyReplay.d.ts.map +1 -1
  7. package/dist/alphalib/types/assemblyReplayNotification.d.ts +392 -178
  8. package/dist/alphalib/types/assemblyReplayNotification.d.ts.map +1 -1
  9. package/dist/alphalib/types/assemblyStatus.d.ts +102 -102
  10. package/dist/alphalib/types/bill.d.ts +4 -4
  11. package/dist/alphalib/types/robots/_index.d.ts +3277 -932
  12. package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
  13. package/dist/alphalib/types/robots/_index.js +4 -0
  14. package/dist/alphalib/types/robots/_index.js.map +1 -1
  15. package/dist/alphalib/types/robots/_instructions-primitives.d.ts +27 -16
  16. package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
  17. package/dist/alphalib/types/robots/_instructions-primitives.js +1 -0
  18. package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
  19. package/dist/alphalib/types/robots/ai-chat.d.ts +2096 -0
  20. package/dist/alphalib/types/robots/ai-chat.d.ts.map +1 -0
  21. package/dist/alphalib/types/robots/ai-chat.js +223 -0
  22. package/dist/alphalib/types/robots/ai-chat.js.map +1 -0
  23. package/dist/alphalib/types/robots/assembly-savejson.d.ts +4 -4
  24. package/dist/alphalib/types/robots/audio-artwork.d.ts +16 -16
  25. package/dist/alphalib/types/robots/audio-concat.d.ts +16 -16
  26. package/dist/alphalib/types/robots/audio-encode.d.ts +16 -16
  27. package/dist/alphalib/types/robots/audio-loop.d.ts +16 -16
  28. package/dist/alphalib/types/robots/audio-merge.d.ts +16 -16
  29. package/dist/alphalib/types/robots/audio-waveform.d.ts +226 -21
  30. package/dist/alphalib/types/robots/audio-waveform.d.ts.map +1 -1
  31. package/dist/alphalib/types/robots/audio-waveform.js +134 -7
  32. package/dist/alphalib/types/robots/audio-waveform.js.map +1 -1
  33. package/dist/alphalib/types/robots/azure-import.d.ts +8 -8
  34. package/dist/alphalib/types/robots/azure-store.d.ts +8 -8
  35. package/dist/alphalib/types/robots/backblaze-import.d.ts +8 -8
  36. package/dist/alphalib/types/robots/backblaze-store.d.ts +8 -8
  37. package/dist/alphalib/types/robots/cloudfiles-import.d.ts +8 -8
  38. package/dist/alphalib/types/robots/cloudfiles-store.d.ts +8 -8
  39. package/dist/alphalib/types/robots/cloudflare-import.d.ts +8 -8
  40. package/dist/alphalib/types/robots/cloudflare-store.d.ts +8 -8
  41. package/dist/alphalib/types/robots/digitalocean-import.d.ts +8 -8
  42. package/dist/alphalib/types/robots/digitalocean-store.d.ts +8 -8
  43. package/dist/alphalib/types/robots/document-autorotate.d.ts +8 -8
  44. package/dist/alphalib/types/robots/document-convert.d.ts +8 -8
  45. package/dist/alphalib/types/robots/document-merge.d.ts +8 -8
  46. package/dist/alphalib/types/robots/document-ocr.d.ts +8 -8
  47. package/dist/alphalib/types/robots/document-split.d.ts +8 -8
  48. package/dist/alphalib/types/robots/document-thumbs.d.ts +8 -8
  49. package/dist/alphalib/types/robots/dropbox-import.d.ts +8 -8
  50. package/dist/alphalib/types/robots/dropbox-store.d.ts +8 -8
  51. package/dist/alphalib/types/robots/edgly-deliver.d.ts +8 -8
  52. package/dist/alphalib/types/robots/file-compress.d.ts +12 -12
  53. package/dist/alphalib/types/robots/file-decompress.d.ts +8 -8
  54. package/dist/alphalib/types/robots/file-filter.d.ts +12 -12
  55. package/dist/alphalib/types/robots/file-hash.d.ts +8 -8
  56. package/dist/alphalib/types/robots/file-preview.d.ts +8 -8
  57. package/dist/alphalib/types/robots/file-read.d.ts +8 -8
  58. package/dist/alphalib/types/robots/file-serve.d.ts +8 -8
  59. package/dist/alphalib/types/robots/file-verify.d.ts +8 -8
  60. package/dist/alphalib/types/robots/file-virusscan.d.ts +8 -8
  61. package/dist/alphalib/types/robots/file-watermark.d.ts +8 -8
  62. package/dist/alphalib/types/robots/ftp-import.d.ts +8 -8
  63. package/dist/alphalib/types/robots/ftp-store.d.ts +8 -8
  64. package/dist/alphalib/types/robots/google-import.d.ts +8 -8
  65. package/dist/alphalib/types/robots/google-store.d.ts +8 -8
  66. package/dist/alphalib/types/robots/html-convert.d.ts +8 -8
  67. package/dist/alphalib/types/robots/http-import.d.ts +8 -8
  68. package/dist/alphalib/types/robots/image-bgremove.d.ts +20 -8
  69. package/dist/alphalib/types/robots/image-bgremove.d.ts.map +1 -1
  70. package/dist/alphalib/types/robots/image-bgremove.js +4 -0
  71. package/dist/alphalib/types/robots/image-bgremove.js.map +1 -1
  72. package/dist/alphalib/types/robots/image-describe.d.ts +8 -8
  73. package/dist/alphalib/types/robots/image-facedetect.d.ts +8 -8
  74. package/dist/alphalib/types/robots/image-generate.d.ts +32 -29
  75. package/dist/alphalib/types/robots/image-generate.d.ts.map +1 -1
  76. package/dist/alphalib/types/robots/image-generate.js +6 -3
  77. package/dist/alphalib/types/robots/image-generate.js.map +1 -1
  78. package/dist/alphalib/types/robots/image-merge.d.ts +8 -8
  79. package/dist/alphalib/types/robots/image-ocr.d.ts +8 -8
  80. package/dist/alphalib/types/robots/image-optimize.d.ts +16 -16
  81. package/dist/alphalib/types/robots/image-resize.d.ts +16 -16
  82. package/dist/alphalib/types/robots/meta-read.d.ts +8 -8
  83. package/dist/alphalib/types/robots/meta-write.d.ts +20 -24
  84. package/dist/alphalib/types/robots/meta-write.d.ts.map +1 -1
  85. package/dist/alphalib/types/robots/meta-write.js +1 -2
  86. package/dist/alphalib/types/robots/meta-write.js.map +1 -1
  87. package/dist/alphalib/types/robots/minio-import.d.ts +8 -8
  88. package/dist/alphalib/types/robots/minio-store.d.ts +8 -8
  89. package/dist/alphalib/types/robots/progress-simulate.d.ts +4 -4
  90. package/dist/alphalib/types/robots/s3-import.d.ts +16 -16
  91. package/dist/alphalib/types/robots/s3-store.d.ts +12 -12
  92. package/dist/alphalib/types/robots/script-run.d.ts +8 -8
  93. package/dist/alphalib/types/robots/sftp-import.d.ts +8 -8
  94. package/dist/alphalib/types/robots/sftp-store.d.ts +8 -8
  95. package/dist/alphalib/types/robots/speech-transcribe.d.ts +8 -8
  96. package/dist/alphalib/types/robots/supabase-import.d.ts +8 -8
  97. package/dist/alphalib/types/robots/supabase-store.d.ts +8 -8
  98. package/dist/alphalib/types/robots/swift-import.d.ts +8 -8
  99. package/dist/alphalib/types/robots/swift-store.d.ts +8 -8
  100. package/dist/alphalib/types/robots/text-speak.d.ts +8 -8
  101. package/dist/alphalib/types/robots/text-translate.d.ts +16 -16
  102. package/dist/alphalib/types/robots/tigris-import.d.ts +8 -8
  103. package/dist/alphalib/types/robots/tigris-store.d.ts +8 -8
  104. package/dist/alphalib/types/robots/tlcdn-deliver.d.ts +8 -8
  105. package/dist/alphalib/types/robots/tus-store.d.ts +8 -8
  106. package/dist/alphalib/types/robots/upload-handle.d.ts +8 -8
  107. package/dist/alphalib/types/robots/video-adaptive.d.ts +16 -16
  108. package/dist/alphalib/types/robots/video-concat.d.ts +16 -16
  109. package/dist/alphalib/types/robots/video-encode.d.ts +16 -16
  110. package/dist/alphalib/types/robots/video-merge.d.ts +16 -16
  111. package/dist/alphalib/types/robots/video-ondemand.d.ts +20 -20
  112. package/dist/alphalib/types/robots/video-subtitle.d.ts +24 -24
  113. package/dist/alphalib/types/robots/video-thumbs.d.ts +8 -8
  114. package/dist/alphalib/types/robots/vimeo-import.d.ts +8 -8
  115. package/dist/alphalib/types/robots/vimeo-store.d.ts +8 -8
  116. package/dist/alphalib/types/robots/wasabi-import.d.ts +8 -8
  117. package/dist/alphalib/types/robots/wasabi-store.d.ts +8 -8
  118. package/dist/alphalib/types/robots/youtube-store.d.ts +12 -12
  119. package/dist/alphalib/types/template.d.ts +6183 -2096
  120. package/dist/alphalib/types/template.d.ts.map +1 -1
  121. package/dist/alphalib/types/templateCredential.d.ts +11 -11
  122. package/dist/alphalib/types/templateCredential.d.ts.map +1 -1
  123. package/dist/alphalib/types/templateCredential.js +1 -0
  124. package/dist/alphalib/types/templateCredential.js.map +1 -1
  125. package/dist/cli/OutputCtl.d.ts +2 -1
  126. package/dist/cli/OutputCtl.d.ts.map +1 -1
  127. package/dist/cli/OutputCtl.js +1 -1
  128. package/dist/cli/OutputCtl.js.map +1 -1
  129. package/dist/cli/commands/BaseCommand.d.ts +3 -2
  130. package/dist/cli/commands/BaseCommand.d.ts.map +1 -1
  131. package/dist/cli/commands/BaseCommand.js +6 -8
  132. package/dist/cli/commands/BaseCommand.js.map +1 -1
  133. package/dist/cli/commands/assemblies.d.ts +1 -1
  134. package/dist/cli/commands/assemblies.d.ts.map +1 -1
  135. package/dist/cli/commands/auth.d.ts.map +1 -1
  136. package/dist/cli/commands/auth.js +2 -8
  137. package/dist/cli/commands/auth.js.map +1 -1
  138. package/dist/cli/commands/notifications.d.ts +0 -7
  139. package/dist/cli/commands/notifications.d.ts.map +1 -1
  140. package/dist/cli/commands/notifications.js +1 -1
  141. package/dist/cli/commands/notifications.js.map +1 -1
  142. package/dist/cli/commands/templates.d.ts +1 -9
  143. package/dist/cli/commands/templates.d.ts.map +1 -1
  144. package/dist/cli/commands/templates.js +1 -1
  145. package/dist/cli/commands/templates.js.map +1 -1
  146. package/dist/cli/helpers.d.ts +6 -2
  147. package/dist/cli/helpers.d.ts.map +1 -1
  148. package/dist/cli/helpers.js +7 -0
  149. package/dist/cli/helpers.js.map +1 -1
  150. package/dist/cli/types.d.ts +3 -77
  151. package/dist/cli/types.d.ts.map +1 -1
  152. package/dist/cli/types.js +2 -17
  153. package/dist/cli/types.js.map +1 -1
  154. package/package.json +16 -22
  155. package/src/alphalib/mcache.ts +4 -4
  156. package/src/alphalib/types/robots/_index.ts +14 -1
  157. package/src/alphalib/types/robots/_instructions-primitives.ts +21 -15
  158. package/src/alphalib/types/robots/ai-chat.ts +278 -0
  159. package/src/alphalib/types/robots/audio-waveform.ts +142 -9
  160. package/src/alphalib/types/robots/image-bgremove.ts +6 -0
  161. package/src/alphalib/types/robots/image-generate.ts +6 -3
  162. package/src/alphalib/types/robots/meta-write.ts +1 -2
  163. package/src/alphalib/types/templateCredential.ts +1 -0
  164. package/src/cli/OutputCtl.ts +1 -1
  165. package/src/cli/commands/BaseCommand.ts +6 -8
  166. package/src/cli/commands/assemblies.ts +1 -1
  167. package/src/cli/commands/auth.ts +2 -10
  168. package/src/cli/commands/notifications.ts +2 -2
  169. package/src/cli/commands/templates.ts +3 -3
  170. package/src/cli/helpers.ts +12 -3
  171. package/src/cli/types.ts +2 -115
  172. package/CHANGELOG.md +0 -240
@@ -1,12 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import type { Steps } from '../alphalib/types/template.ts';
3
- import type { BillResponse, ListedTemplate, TemplateResponse } from '../apiTypes.ts';
4
- import type { AssemblyStatus, Transloadit } from '../Transloadit.ts';
5
- import type { IOutputCtl } from './OutputCtl.ts';
6
- export type { AssemblyStatus, BillResponse, ListedTemplate, TemplateResponse };
7
- export type { Transloadit };
8
- export type { CreateAssemblyOptions } from '../Transloadit.ts';
9
- export declare const APIErrorSchema: z.ZodObject<{
3
+ declare const APIErrorSchema: z.ZodObject<{
10
4
  error: z.ZodString;
11
5
  message: z.ZodString;
12
6
  }, "strip", z.ZodTypeAny, {
@@ -17,7 +11,7 @@ export declare const APIErrorSchema: z.ZodObject<{
17
11
  message: string;
18
12
  }>;
19
13
  export type APIError = z.infer<typeof APIErrorSchema>;
20
- export declare const TransloaditAPIErrorSchema: z.ZodObject<{
14
+ declare const TransloaditAPIErrorSchema: z.ZodObject<{
21
15
  error: z.ZodOptional<z.ZodString>;
22
16
  message: z.ZodString;
23
17
  code: z.ZodOptional<z.ZodString>;
@@ -76,77 +70,9 @@ export interface TemplateFile {
76
70
  file: string;
77
71
  data: TemplateFileData;
78
72
  }
79
- export interface TemplateListItem {
80
- id: string;
81
- modified: string;
82
- name?: string;
83
- }
84
- export interface BaseInvocation {
85
- error?: boolean;
86
- message?: string;
87
- mode: string;
88
- action?: string;
89
- logLevel?: number;
90
- jsonMode?: boolean;
91
- }
92
- export interface AssemblyInvocation extends BaseInvocation {
93
- mode: 'assemblies';
94
- action?: 'create' | 'get' | 'list' | 'delete' | 'replay';
95
- inputs: string[];
96
- output?: string;
97
- recursive?: boolean;
98
- watch?: boolean;
99
- del?: boolean;
100
- reprocessStale?: boolean;
101
- steps?: string;
102
- template?: string;
103
- fields?: Record<string, string>;
104
- assemblies?: string[];
105
- before?: string;
106
- after?: string;
107
- keywords?: string[];
108
- notify_url?: string;
109
- reparse?: boolean;
110
- }
111
- export interface TemplateInvocation extends BaseInvocation {
112
- mode: 'templates';
113
- action?: 'create' | 'get' | 'list' | 'delete' | 'modify' | 'sync';
114
- templates?: string[];
115
- template?: string;
116
- name?: string;
117
- file?: string;
118
- files?: string[];
119
- before?: string;
120
- after?: string;
121
- order?: 'asc' | 'desc';
122
- sort?: string;
123
- fields?: string[];
124
- recursive?: boolean;
125
- }
126
- export interface BillInvocation extends BaseInvocation {
127
- mode: 'bills';
128
- action?: 'get';
129
- months: string[];
130
- }
131
- export interface NotificationInvocation extends BaseInvocation {
132
- mode: 'assembly-notifications';
133
- action?: 'list' | 'replay';
134
- assemblies?: string[];
135
- notify_url?: string;
136
- type?: string;
137
- assembly_id?: string;
138
- pagesize?: number;
139
- }
140
- export interface HelpInvocation extends BaseInvocation {
141
- mode: 'help' | 'version' | 'register';
142
- }
143
- export type Invocation = AssemblyInvocation | TemplateInvocation | BillInvocation | NotificationInvocation | HelpInvocation;
144
- export type CommandHandler<T extends BaseInvocation = BaseInvocation> = (output: IOutputCtl, client: Transloadit | undefined, invocation: T) => void | Promise<void>;
145
- export declare function isError(value: unknown): value is Error;
146
73
  export declare function ensureError(value: unknown): Error;
147
74
  export declare function isAPIError(value: unknown): value is APIError;
148
75
  export declare function isTransloaditAPIError(value: unknown): value is TransloaditAPIError;
149
76
  export declare function isErrnoException(value: unknown): value is NodeJS.ErrnoException;
150
- export declare function safeGet<T>(arr: T[], index: number): T | undefined;
151
- export declare function assertDefined<T>(value: T | undefined | null, message: string): T;
77
+ export {};
152
78
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAA;AAC9E,YAAY,EAAE,WAAW,EAAE,CAAA;AAC3B,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAG9D,eAAO,MAAM,cAAc;;;;;;;;;EAGzB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAErD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAepC,CAAA;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAG3E,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAA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B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe7B,CAAA;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAG3E,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAKhB,CAAA;AAE/C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,gBAAgB,CAAA;CACvB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAKjD;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAGD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAElF;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,CAE/E"}
package/dist/cli/types.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { optionalStepsSchema } from "../alphalib/types/template.js";
3
3
  // Zod schemas for runtime validation
4
- export const APIErrorSchema = z.object({
4
+ const APIErrorSchema = z.object({
5
5
  error: z.string(),
6
6
  message: z.string(),
7
7
  });
8
- export const TransloaditAPIErrorSchema = z.object({
8
+ const TransloaditAPIErrorSchema = z.object({
9
9
  error: z.string().optional(),
10
10
  message: z.string(),
11
11
  code: z.string().optional(),
@@ -27,10 +27,6 @@ export const TemplateFileDataSchema = z
27
27
  steps: optionalStepsSchema,
28
28
  })
29
29
  .passthrough();
30
- // Type guard for Error
31
- export function isError(value) {
32
- return value instanceof Error;
33
- }
34
30
  // Helper to ensure error is Error type
35
31
  export function ensureError(value) {
36
32
  if (value instanceof Error) {
@@ -50,15 +46,4 @@ export function isTransloaditAPIError(value) {
50
46
  export function isErrnoException(value) {
51
47
  return value instanceof Error && 'code' in value;
52
48
  }
53
- // Safe array access helper
54
- export function safeGet(arr, index) {
55
- return arr[index];
56
- }
57
- // Assert defined helper
58
- export function assertDefined(value, message) {
59
- if (value === undefined || value === null) {
60
- throw new Error(message);
61
- }
62
- return value;
63
- }
64
49
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAUnE,qCAAqC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC;QACN,IAAI,EAAE,CAAC;aACJ,MAAM,CAAC;YACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC;aACD,QAAQ,EAAE;QACb,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAA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KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAC5D,CAAC;AAED,0BAA0B;AAC1B,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAA;AAChD,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,yBAAyB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAA;AAC3D,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAA;AAClD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "transloadit",
3
- "version": "4.1.0",
3
+ "version": "4.1.3",
4
4
  "description": "Node.js SDK for Transloadit",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -32,26 +32,16 @@
32
32
  "p-queue": "^9.0.1",
33
33
  "recursive-readdir": "^2.2.3",
34
34
  "tus-js-client": "^4.3.1",
35
+ "typanion": "^3.14.0",
35
36
  "type-fest": "^4.41.0",
36
37
  "zod": "3.25.76"
37
38
  },
38
39
  "devDependencies": {
39
- "@biomejs/biome": "^2.2.4",
40
40
  "@types/debug": "^4.1.12",
41
+ "@types/minimist": "^1.2.5",
42
+ "@types/node": "^24.10.3",
41
43
  "@types/recursive-readdir": "^2.2.4",
42
- "@types/temp": "^0.9.4",
43
- "@vitest/coverage-v8": "^3.2.4",
44
- "badge-maker": "^5.0.2",
45
- "execa": "9.6.0",
46
- "image-size": "^2.0.2",
47
- "nock": "^14.0.10",
48
- "npm-run-all": "^4.1.5",
49
- "p-retry": "^7.0.0",
50
- "rimraf": "^6.1.2",
51
- "temp": "^0.9.4",
52
- "tsx": "4.20.5",
53
- "typescript": "5.9.2",
54
- "vitest": "^3.2.4"
44
+ "minimatch": "^10.1.1"
55
45
  },
56
46
  "repository": {
57
47
  "type": "git",
@@ -63,15 +53,17 @@
63
53
  "scripts": {
64
54
  "check": "yarn lint:ts && yarn fix && yarn test:unit",
65
55
  "fix:js": "biome check --write .",
66
- "lint:ts": "tsc --build",
56
+ "lint:ts": "yarn --cwd ../.. tsc:node",
67
57
  "fix:js:unsafe": "biome check --write . --unsafe",
68
58
  "lint:js": "biome check .",
69
59
  "lint": "npm-run-all --parallel 'lint:js'",
70
60
  "fix": "npm-run-all --serial 'fix:js'",
71
- "prepack": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && tsc --build tsconfig.build.json",
72
- "test:unit": "vitest run --coverage ./test/unit",
73
- "test:e2e": "vitest run ./test/e2e",
74
- "test": "vitest run --coverage"
61
+ "lint:deps": "knip --dependencies --no-progress",
62
+ "fix:deps": "knip --dependencies --no-progress --fix",
63
+ "prepack": "node ../../scripts/prepare-transloadit.ts",
64
+ "test:unit": "../../node_modules/.bin/vitest run --coverage ./test/unit",
65
+ "test:e2e": "../../node_modules/.bin/vitest run ./test/e2e",
66
+ "test": "../../node_modules/.bin/vitest run --coverage"
75
67
  },
76
68
  "license": "MIT",
77
69
  "main": "./dist/Transloadit.js",
@@ -83,5 +75,7 @@
83
75
  "dist",
84
76
  "src"
85
77
  ],
86
- "bin": "./dist/cli.js"
87
- }
78
+ "bin": {
79
+ "transloadit": "./dist/cli.js"
80
+ }
81
+ }
@@ -1,7 +1,7 @@
1
1
  import type { SevLogger } from '@transloadit/sev-logger'
2
2
  import type { Schema } from 'zod'
3
3
 
4
- export interface McacheOpts<T> {
4
+ export interface McacheOpts {
5
5
  ttlMs?: number
6
6
  zodSchema?: Schema
7
7
  logger?: SevLogger
@@ -37,10 +37,10 @@ interface CacheEntry<T> {
37
37
  */
38
38
  export class Mcache<T> {
39
39
  #cache: Map<string, CacheEntry<T>>
40
- #opts: Required<Omit<McacheOpts<T>, 'logger' | 'zodSchema' | 'keyFn'>> &
41
- Pick<McacheOpts<T>, 'logger' | 'zodSchema' | 'keyFn'>
40
+ #opts: Required<Omit<McacheOpts, 'logger' | 'zodSchema' | 'keyFn'>> &
41
+ Pick<McacheOpts, 'logger' | 'zodSchema' | 'keyFn'>
42
42
 
43
- constructor(opts: McacheOpts<T> = {}) {
43
+ constructor(opts: McacheOpts = {}) {
44
44
  this.#cache = new Map()
45
45
  this.#opts = {
46
46
  ttlMs: opts.ttlMs ?? Number.POSITIVE_INFINITY,
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod'
2
-
2
+ import {
3
+ meta as aiChatMeta,
4
+ interpolatableRobotAiChatInstructionsSchema,
5
+ interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema,
6
+ } from './ai-chat.ts'
3
7
  import {
4
8
  meta as audioArtworkMeta,
5
9
  interpolatableRobotAudioArtworkInstructionsSchema,
@@ -474,6 +478,7 @@ const robotStepsInstructions = [
474
478
  interpolatableRobotSwiftStoreInstructionsSchema,
475
479
  interpolatableRobotTextSpeakInstructionsSchema,
476
480
  interpolatableRobotTextTranslateInstructionsSchema,
481
+ interpolatableRobotAiChatInstructionsSchema,
477
482
  interpolatableRobotTigrisImportInstructionsSchema,
478
483
  interpolatableRobotTigrisStoreInstructionsSchema,
479
484
  interpolatableRobotTlcdnDeliverInstructionsSchema,
@@ -558,6 +563,7 @@ const robotStepsInstructionsWithHiddenFields = [
558
563
  interpolatableRobotSwiftStoreInstructionsWithHiddenFieldsSchema,
559
564
  interpolatableRobotTextSpeakInstructionsWithHiddenFieldsSchema,
560
565
  interpolatableRobotTextTranslateInstructionsWithHiddenFieldsSchema,
566
+ interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema,
561
567
  interpolatableRobotTigrisImportInstructionsWithHiddenFieldsSchema,
562
568
  interpolatableRobotTigrisStoreInstructionsWithHiddenFieldsSchema,
563
569
  interpolatableRobotTlcdnDeliverInstructionsWithHiddenFieldsSchema,
@@ -605,6 +611,7 @@ export type RobotsWithHiddenBots = z.infer<typeof robotsWithHiddenBotsSchema>
605
611
  export type RobotsWithHiddenBotsAndFields = z.infer<typeof robotsWithHiddenBotsAndFieldsSchema>
606
612
 
607
613
  export const robotsMeta = {
614
+ aiChatMeta,
608
615
  audioArtworkMeta,
609
616
  audioConcatMeta,
610
617
  audioEncodeMeta,
@@ -687,6 +694,12 @@ export const robotsMeta = {
687
694
  youtubeStoreMeta,
688
695
  }
689
696
 
697
+ export type {
698
+ InterpolatableRobotAiChatInstructions,
699
+ InterpolatableRobotAiChatInstructionsInput,
700
+ InterpolatableRobotAiChatInstructionsWithHiddenFields,
701
+ InterpolatableRobotAiChatInstructionsWithHiddenFieldsInput,
702
+ } from './ai-chat.ts'
690
703
  export type {
691
704
  InterpolatableRobotAssemblySavejsonInstructions,
692
705
  InterpolatableRobotAssemblySavejsonInstructionsInput,
@@ -4,6 +4,7 @@ import { z } from 'zod'
4
4
  import { stackVersions } from '../stackVersions.ts'
5
5
 
6
6
  export const robotNames = z.enum([
7
+ 'AiChatRobot',
7
8
  'UploadHandleRobot',
8
9
  'FileServeRobot',
9
10
  'FileWatermarkRobot',
@@ -395,21 +396,18 @@ export function interpolateRecursive<Schema extends z.ZodFirstPartySchemaTypes>(
395
396
  */
396
397
  const uninterpolatableKeys = ['robot', 'use'] as const
397
398
 
398
- type InterpolatableRobot<Schema extends z.ZodObject<z.ZodRawShape>> = Schema extends z.ZodObject<
399
- infer T,
400
- infer UnknownKeys,
401
- infer Catchall
402
- >
403
- ? z.ZodObject<
404
- {
405
- [Key in keyof T]: Key extends (typeof uninterpolatableKeys)[number]
406
- ? T[Key]
407
- : InterpolatableSchema<T[Key]>
408
- },
409
- UnknownKeys,
410
- Catchall
411
- >
412
- : never
399
+ type InterpolatableRobot<Schema extends z.ZodObject<z.ZodRawShape>> =
400
+ Schema extends z.ZodObject<infer T, infer UnknownKeys, infer Catchall>
401
+ ? z.ZodObject<
402
+ {
403
+ [Key in keyof T]: Key extends (typeof uninterpolatableKeys)[number]
404
+ ? T[Key]
405
+ : InterpolatableSchema<T[Key]>
406
+ },
407
+ UnknownKeys,
408
+ Catchall
409
+ >
410
+ : never
413
411
 
414
412
  export function interpolateRobot<Schema extends z.ZodObject<z.ZodRawShape>>(
415
413
  schema: Schema,
@@ -1762,3 +1760,11 @@ Delta to apply to segment duration. This is optional and allows fine-tuning of s
1762
1760
  `),
1763
1761
  })
1764
1762
  .strict()
1763
+
1764
+ /**
1765
+ * Type for the normalized use parameter from AssemblyNormalizer
1766
+ * The steps array can contain either strings or objects with name property
1767
+ */
1768
+ export interface NormalizedUse {
1769
+ steps: Array<{ name: string; as?: string; fields?: string }>
1770
+ }
@@ -0,0 +1,278 @@
1
+ import { z } from 'zod'
2
+ import type { RobotMetaInput } from './_instructions-primitives.ts'
3
+ import { interpolateRobot, robotBase, robotUse } from './_instructions-primitives.ts'
4
+
5
+ // We duplicate coreMessageSchema (and its related types) from structuredAiVercel.ts here
6
+ // so that we do not need to distribute structuredAiVercel.ts to for instance
7
+ // the node-sdk, which does rely on this ai-chat file to determine
8
+ // support Robot parameters.
9
+
10
+ // Define JSONValue schema for proper type matching with AI SDK
11
+ const jsonValueSchema: z.ZodType = z.lazy(() =>
12
+ z.union([
13
+ z.string(),
14
+ z.number(),
15
+ z.boolean(),
16
+ z.null(),
17
+ z.array(jsonValueSchema),
18
+ z.record(jsonValueSchema),
19
+ ]),
20
+ )
21
+
22
+ // Define provider metadata schema to match the AI SDK v5
23
+ const providerMetadataSchema = z.record(z.record(jsonValueSchema)).optional()
24
+
25
+ const textPartSchema = z.object({
26
+ type: z.literal('text'),
27
+ text: z.string(),
28
+ experimental_providerMetadata: providerMetadataSchema,
29
+ })
30
+ const imagePartSchema = z.object({
31
+ type: z.literal('image'),
32
+ image: z.union([
33
+ z.string(),
34
+ z.instanceof(Uint8Array),
35
+ z.instanceof(ArrayBuffer),
36
+ // Note: Buffer is not included here since it's Node.js-only and this code runs in browsers.
37
+ // Node.js Buffer extends Uint8Array, so Uint8Array validation handles Buffer values too.
38
+ z.instanceof(URL),
39
+ ]),
40
+ mimeType: z.string().optional(),
41
+ experimental_providerMetadata: providerMetadataSchema,
42
+ })
43
+ const filePartSchema = z.object({
44
+ type: z.literal('file'),
45
+ data: z.union([
46
+ z.string(),
47
+ z.instanceof(Uint8Array),
48
+ z.instanceof(ArrayBuffer),
49
+ // Note: Buffer is not included here since it's Node.js-only and this code runs in browsers.
50
+ // Node.js Buffer extends Uint8Array, so Uint8Array validation handles Buffer values too.
51
+ z.instanceof(URL),
52
+ ]),
53
+ mediaType: z.string(),
54
+ experimental_providerMetadata: providerMetadataSchema,
55
+ })
56
+ const toolCallPartSchema = z.object({
57
+ type: z.literal('tool-call'),
58
+ toolCallId: z.string(),
59
+ toolName: z.string(),
60
+ args: z.record(jsonValueSchema),
61
+ experimental_providerMetadata: providerMetadataSchema,
62
+ })
63
+ const toolResultPartSchema = z.object({
64
+ type: z.literal('tool-result'),
65
+ toolCallId: z.string(),
66
+ toolName: z.string(),
67
+ result: z.unknown(),
68
+ experimental_content: z
69
+ .array(
70
+ z.union([
71
+ z.object({
72
+ type: z.literal('text'),
73
+ text: z.string(),
74
+ }),
75
+ z.object({
76
+ type: z.literal('image'),
77
+ data: z.string(),
78
+ mimeType: z.string().optional(),
79
+ }),
80
+ ]),
81
+ )
82
+ .optional(),
83
+ isError: z.boolean().optional(),
84
+ experimental_providerMetadata: providerMetadataSchema,
85
+ })
86
+ const coreSystemMessageSchema = z.object({
87
+ role: z.literal('system'),
88
+ content: z.string(),
89
+ experimental_providerMetadata: providerMetadataSchema,
90
+ })
91
+ const coreUserMessageSchema = z.object({
92
+ role: z.literal('user'),
93
+ content: z.union([
94
+ z.string(),
95
+ z.array(z.union([textPartSchema, imagePartSchema, filePartSchema])),
96
+ ]),
97
+ experimental_providerMetadata: providerMetadataSchema,
98
+ })
99
+ const coreAssistantMessageSchema = z.object({
100
+ role: z.literal('assistant'),
101
+ content: z.union([z.string(), z.array(z.union([textPartSchema, toolCallPartSchema]))]),
102
+ experimental_providerMetadata: providerMetadataSchema,
103
+ })
104
+ const coreToolMessageSchema = z.object({
105
+ role: z.literal('tool'),
106
+ content: z.array(toolResultPartSchema),
107
+ experimental_providerMetadata: providerMetadataSchema,
108
+ })
109
+ const coreMessageSchema = z.discriminatedUnion('role', [
110
+ coreSystemMessageSchema,
111
+ coreUserMessageSchema,
112
+ coreAssistantMessageSchema,
113
+ coreToolMessageSchema,
114
+ ])
115
+
116
+ export const meta: RobotMetaInput = {
117
+ name: 'AiChatRobot',
118
+ allowed_for_url_transform: true,
119
+ bytescount: 1,
120
+ discount_factor: 1,
121
+ discount_pct: 0,
122
+ minimum_charge: 0,
123
+ output_factor: 0.6,
124
+ purpose_sentence: 'generates AI chat responses from prompts',
125
+ purpose_verb: 'generate',
126
+ purpose_word: 'generate',
127
+ purpose_words: 'Generate AI chat responses',
128
+ service_slug: 'artificial-intelligence',
129
+ slot_count: 10,
130
+ title: 'Generate AI chat responses',
131
+ typical_file_size_mb: 0.01,
132
+ typical_file_type: 'document',
133
+ priceFactor: 1,
134
+ queueSlotCount: 10,
135
+ // Is this a sensbile minimum charge? What if the customer supplies their own keys? Is it low enough for these cases?
136
+ minimumChargeUsd: 0.06,
137
+ isAllowedForUrlTransform: true,
138
+ trackOutputFileSize: true,
139
+ isInternal: false,
140
+ removeJobResultFilesFromDiskRightAfterStoringOnS3: false,
141
+ stage: 'alpha',
142
+ }
143
+
144
+ export const vendorModelSchema = z
145
+ .string()
146
+ .regex(/^[a-z]+\/[a-z0-9.-]+$/, 'Must be in format "vendor/model"')
147
+ .refine(
148
+ (val) => {
149
+ const [vendor, model] = val.split('/')
150
+ if (vendor === 'anthropic') {
151
+ return model === 'claude-4-sonnet-20250514' || model === 'claude-4-opus-20250514'
152
+ }
153
+ if (vendor === 'openai') {
154
+ return (
155
+ model === 'gpt-4.1-2025-04-14' ||
156
+ model === 'chatgpt-4o-latest' ||
157
+ model === 'o3-2025-04-16' ||
158
+ model === 'gpt-4o-audio-preview'
159
+ )
160
+ }
161
+ if (vendor === 'google') {
162
+ return model === 'gemini-2.5-pro'
163
+ }
164
+ if (vendor === 'moonshot') {
165
+ return model === 'kimi-k2'
166
+ }
167
+ return false
168
+ },
169
+ {
170
+ message:
171
+ 'Invalid vendor/model combination. Supported: anthropic/claude-4-sonnet-20250514, anthropic/claude-4-opus-20250514, openai/gpt-4.1-2025-04-14, openai/chatgpt-4o-latest, openai/o3-2025-04-16, openai/gpt-4o-audio-preview, google/gemini-2.5-pro, moonshot/kimi-k2',
172
+ },
173
+ )
174
+
175
+ export type VendorModel = z.infer<typeof vendorModelSchema>
176
+
177
+ /**
178
+ * Model capabilities for /ai/chat. This centralizes which models support which input types.
179
+ * Key format: 'vendor/model'
180
+ */
181
+ export const MODEL_CAPABILITIES: Record<string, { pdf: boolean; image: boolean }> = {
182
+ 'anthropic/claude-4-sonnet-20250514': { pdf: true, image: true },
183
+ 'anthropic/claude-4-opus-20250514': { pdf: true, image: true },
184
+ 'google/gemini-2.5-pro': { pdf: true, image: true },
185
+ 'openai/gpt-4.1-2025-04-14': { pdf: false, image: true },
186
+ 'openai/chatgpt-4o-latest': { pdf: false, image: true },
187
+ 'openai/o3-2025-04-16': { pdf: false, image: true },
188
+ 'openai/gpt-4o-audio-preview': { pdf: false, image: false },
189
+ 'moonshot/kimi-k2': { pdf: false, image: false },
190
+ }
191
+
192
+ export const robotAiChatInstructionsSchema = robotBase
193
+ .merge(robotUse)
194
+ .extend({
195
+ robot: z.literal('/ai/chat'),
196
+ // TODO: Is the auto mode yet implemented?
197
+ model: z
198
+ .union([vendorModelSchema, z.literal('auto')])
199
+ .default('auto')
200
+ .describe(
201
+ 'The model to use. Transloadit can pick the best model for the job if you set this to "auto".',
202
+ ),
203
+ format: z.enum(['json', 'text', 'meta']).default('json'),
204
+ return_messages: z.enum(['all', 'last']).default('last'),
205
+ schema: z.string().optional().describe('The JSON Schema that the LLM should output'),
206
+ messages: z
207
+ .union([z.string(), z.array(coreMessageSchema)])
208
+ .describe('The prompt, or message history to send to the LLM.'),
209
+ system_message: z
210
+ .string()
211
+ .optional()
212
+ .describe('Set the system/developer prompt, if the model allows it'),
213
+ credentials: z
214
+ .union([z.string(), z.array(z.string())])
215
+ .optional()
216
+ .describe('Names of template credentials to make available to the robot.'),
217
+ mcp_servers: z
218
+ .array(
219
+ z.object({
220
+ type: z.enum(['sse', 'http']),
221
+ url: z.string(),
222
+ headers: z.record(z.string()).optional(),
223
+ }),
224
+ )
225
+ .optional()
226
+ .describe('The MCP servers to use. This is used to call tools from the LLM.'),
227
+ })
228
+ .strict()
229
+
230
+ export const robotAiChatInstructionsWithHiddenFieldsSchema = robotAiChatInstructionsSchema.extend({
231
+ result: z.union([z.literal('debug'), robotAiChatInstructionsSchema.shape.result]),
232
+ provider: z
233
+ .string()
234
+ .optional()
235
+ .describe(
236
+ 'Where to run the model. By the default, it is the vendor. For instance, anthropic:claude* runs on the Anthropic API. But, Claude could also be run on AWS Bedrock. This is a hidden placeholder for now, but will be used in the future to allow for more flexibility in where to run models. ',
237
+ ),
238
+ // These are listed here because we don't have these properties in the public documentation.
239
+ // They should set these keys using template credentials.
240
+ openai_api_key: z.string().optional().describe('The API key to use for the OpenAI API.'),
241
+ anthropic_api_key: z.string().optional().describe('The API key to use for the Anthropic API.'),
242
+ deepseek_api_key: z.string().optional().describe('The API key to use for the DeepSeek API.'),
243
+ google_generative_ai_api_key: z
244
+ .string()
245
+ .optional()
246
+ .describe('The API key to use for the Google Generative AI API.'),
247
+ xai_api_key: z.string().optional().describe('The API key to use for the xAI API.'),
248
+ })
249
+
250
+ export type RobotAiChatInstructions = z.infer<typeof robotAiChatInstructionsSchema>
251
+
252
+ export type RobotAiChatInstructionsWithHiddenFields = z.infer<
253
+ typeof robotAiChatInstructionsWithHiddenFieldsSchema
254
+ >
255
+
256
+ export type RobotAiChatInstructionsWithHiddenFieldsInput = z.input<
257
+ typeof robotAiChatInstructionsWithHiddenFieldsSchema
258
+ >
259
+
260
+ export const interpolatableRobotAiChatInstructionsSchema = interpolateRobot(
261
+ robotAiChatInstructionsSchema,
262
+ )
263
+ export type InterpolatableRobotAiChatInstructions = z.infer<
264
+ typeof interpolatableRobotAiChatInstructionsSchema
265
+ >
266
+ export type InterpolatableRobotAiChatInstructionsInput = z.input<
267
+ typeof interpolatableRobotAiChatInstructionsSchema
268
+ >
269
+
270
+ export const interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema = interpolateRobot(
271
+ robotAiChatInstructionsWithHiddenFieldsSchema,
272
+ )
273
+ export type InterpolatableRobotAiChatInstructionsWithHiddenFields = z.infer<
274
+ typeof interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema
275
+ >
276
+ export type InterpolatableRobotAiChatInstructionsWithHiddenFieldsInput = z.input<
277
+ typeof interpolatableRobotAiChatInstructionsWithHiddenFieldsSchema
278
+ >