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
@@ -59,7 +59,8 @@ Here is an example waveform image:
59
59
  stage: 'ga',
60
60
  }
61
61
 
62
- export const robotAudioWaveformInstructionsSchema = robotBase
62
+ // Base schema with common fields
63
+ const robotAudioWaveformInstructionsBaseSchema = robotBase
63
64
  .merge(robotUse)
64
65
  .merge(robotFFmpeg)
65
66
  .extend({
@@ -89,12 +90,6 @@ The width of the resulting image if the format \`"image"\` was selected.
89
90
  .default(64)
90
91
  .describe(`
91
92
  The height of the resulting image if the format \`"image"\` was selected.
92
- `),
93
- style: z
94
- .union([z.literal(0), z.literal(1)])
95
- .default(0)
96
- .describe(`
97
- Either a value of \`0\` or \`1\`, corresponding to using either the legacy waveform tool, or the new tool respectively, with the new tool offering an improved style. Other Robot parameters still function as described, with either tool.
98
93
  `),
99
94
  antialiasing: z
100
95
  .union([z.literal(0), z.literal(1), z.boolean()])
@@ -110,6 +105,142 @@ The color used in the center of the gradient. The format is "rrggbbaa" (red, gre
110
105
  `),
111
106
  outer_color: color_with_alpha.default('000000ff').describe(`
112
107
  The color used in the outer parts of the gradient. The format is "rrggbbaa" (red, green, blue, alpha).
108
+ `),
109
+ })
110
+
111
+ const styleSchema = z.preprocess(
112
+ (val) => {
113
+ // Backwards compatibility: historically this robot used numeric styles 0/1/2.
114
+ // The new API is `style: "v0" | "v1"`. Old v2 values are mapped to v1.
115
+ if (val === 'v1' || val === 1 || val === '1') return 'v1'
116
+ if (val === 'v0' || val === 0 || val === '0') return 'v0'
117
+ return val
118
+ },
119
+ z.enum(['v0', 'v1']).default('v0'),
120
+ )
121
+
122
+ // Unified schema: all parameters exist for both styles, but v1-only parameters only apply when
123
+ // `style` is `v1` (they are accepted for v0 but have no effect).
124
+ export const robotAudioWaveformInstructionsSchema = robotAudioWaveformInstructionsBaseSchema
125
+ .extend({
126
+ style: styleSchema.describe(`
127
+ Waveform style version.
128
+
129
+ - \`"v0"\`: Legacy waveform generation (default).
130
+ - \`"v1"\`: Advanced waveform generation with additional parameters.
131
+
132
+ For backwards compatibility, numeric values \`0\`, \`1\`, \`2\` are also accepted and mapped to \`"v0"\` (0) and \`"v1"\` (1/2).
133
+ `),
134
+
135
+ // v1-only parameters (accepted for v0 but have no effect)
136
+ split_channels: z
137
+ .boolean()
138
+ .optional()
139
+ .describe(`
140
+ Available when style is \`"v1"\`. If set to \`true\`, outputs multi-channel waveform data or image files, one per channel.
141
+ `),
142
+ zoom: z
143
+ .number()
144
+ .int()
145
+ .min(1)
146
+ .optional()
147
+ .describe(`
148
+ Available when style is \`"v1"\`. Zoom level in samples per pixel. This parameter cannot be used together with \`pixels_per_second\`.
149
+ `),
150
+ pixels_per_second: z
151
+ .number()
152
+ .positive()
153
+ .optional()
154
+ .describe(`
155
+ Available when style is \`"v1"\`. Zoom level in pixels per second. This parameter cannot be used together with \`zoom\`.
156
+ `),
157
+ bits: z
158
+ .union([z.literal(8), z.literal(16)])
159
+ .optional()
160
+ .describe(`
161
+ Available when style is \`"v1"\`. Bit depth for waveform data. Can be 8 or 16.
162
+ `),
163
+ start: z
164
+ .number()
165
+ .min(0)
166
+ .optional()
167
+ .describe(`
168
+ Available when style is \`"v1"\`. Start time in seconds.
169
+ `),
170
+ end: z
171
+ .number()
172
+ .min(0)
173
+ .optional()
174
+ .describe(`
175
+ Available when style is \`"v1"\`. End time in seconds (0 means end of audio).
176
+ `),
177
+ colors: z
178
+ .enum(['audition', 'audacity'])
179
+ .optional()
180
+ .describe(`
181
+ Available when style is \`"v1"\`. Color scheme to use. Can be "audition" or "audacity".
182
+ `),
183
+ border_color: color_with_alpha.optional().describe(`
184
+ Available when style is \`"v1"\`. Border color in "rrggbbaa" format.
185
+ `),
186
+ waveform_style: z
187
+ .enum(['normal', 'bars'])
188
+ .optional()
189
+ .describe(`
190
+ Available when style is \`"v1"\`. Waveform style. Can be "normal" or "bars".
191
+ `),
192
+ bar_width: z
193
+ .number()
194
+ .int()
195
+ .positive()
196
+ .optional()
197
+ .describe(`
198
+ Available when style is \`"v1"\`. Width of bars in pixels when waveform_style is "bars".
199
+ `),
200
+ bar_gap: z
201
+ .number()
202
+ .int()
203
+ .min(0)
204
+ .optional()
205
+ .describe(`
206
+ Available when style is \`"v1"\`. Gap between bars in pixels when waveform_style is "bars".
207
+ `),
208
+ bar_style: z
209
+ .enum(['square', 'rounded'])
210
+ .optional()
211
+ .describe(`
212
+ Available when style is \`"v1"\`. Bar style when waveform_style is "bars".
213
+ `),
214
+ axis_label_color: color_with_alpha.optional().describe(`
215
+ Available when style is \`"v1"\`. Color for axis labels in "rrggbbaa" format.
216
+ `),
217
+ no_axis_labels: z
218
+ .boolean()
219
+ .optional()
220
+ .describe(`
221
+ Available when style is \`"v1"\`. If set to \`true\`, renders waveform image without axis labels.
222
+ `),
223
+ with_axis_labels: z
224
+ .boolean()
225
+ .optional()
226
+ .describe(`
227
+ Available when style is \`"v1"\`. If set to \`true\`, renders waveform image with axis labels.
228
+ `),
229
+ amplitude_scale: z
230
+ .number()
231
+ .positive()
232
+ .optional()
233
+ .describe(`
234
+ Available when style is \`"v1"\`. Amplitude scale factor.
235
+ `),
236
+ compression: z
237
+ .number()
238
+ .int()
239
+ .min(-1)
240
+ .max(9)
241
+ .optional()
242
+ .describe(`
243
+ Available when style is \`"v1"\`. PNG compression level: 0 (none) to 9 (best), or -1 (default). Only applicable when format is "image".
113
244
  `),
114
245
  })
115
246
  .strict()
@@ -129,9 +260,10 @@ export type RobotAudioWaveformInstructionsWithHiddenFields = z.infer<
129
260
  export const interpolatableRobotAudioWaveformInstructionsSchema = interpolateRobot(
130
261
  robotAudioWaveformInstructionsSchema,
131
262
  )
132
- export type InterpolatableRobotAudioWaveformInstructions =
133
- InterpolatableRobotAudioWaveformInstructionsInput
134
263
 
264
+ export type InterpolatableRobotAudioWaveformInstructions = z.input<
265
+ typeof interpolatableRobotAudioWaveformInstructionsSchema
266
+ >
135
267
  export type InterpolatableRobotAudioWaveformInstructionsInput = z.input<
136
268
  typeof interpolatableRobotAudioWaveformInstructionsSchema
137
269
  >
@@ -139,6 +271,7 @@ export type InterpolatableRobotAudioWaveformInstructionsInput = z.input<
139
271
  export const interpolatableRobotAudioWaveformInstructionsWithHiddenFieldsSchema = interpolateRobot(
140
272
  robotAudioWaveformInstructionsWithHiddenFieldsSchema,
141
273
  )
274
+
142
275
  export type InterpolatableRobotAudioWaveformInstructionsWithHiddenFields = z.infer<
143
276
  typeof interpolatableRobotAudioWaveformInstructionsWithHiddenFieldsSchema
144
277
  >
@@ -53,6 +53,12 @@ export const robotImageBgremoveInstructionsSchema = robotBase
53
53
  .enum(['transloadit', 'replicate', 'fal'])
54
54
  .optional()
55
55
  .describe('Provider to use for removing the background.'),
56
+ model: z
57
+ .string()
58
+ .optional()
59
+ .describe(
60
+ 'Provider-specific model to use for removing the background. Mostly intended for testing and evaluation.',
61
+ ),
56
62
  })
57
63
  .strict()
58
64
 
@@ -34,10 +34,13 @@ export const robotImageGenerateInstructionsSchema = robotBase
34
34
  .merge(robotUse)
35
35
  .extend({
36
36
  robot: z.literal('/image/generate'),
37
- model: z.string(),
37
+ model: z
38
+ .string()
39
+ .optional()
40
+ .describe('The AI model to use for image generation. Defaults to google/nano-banana.'),
38
41
  prompt: z.string().describe('The prompt describing the desired image content.'),
39
42
  format: z
40
- .enum(['jpeg', 'png', 'gif', 'webp', 'svg'])
43
+ .enum(['jpeg', 'jpg', 'png', 'gif', 'webp', 'svg'])
41
44
  .optional()
42
45
  .describe('Format of the generated image.'),
43
46
  seed: z.number().optional().describe('Seed for the random number generator.'),
@@ -69,7 +72,7 @@ export type RobotImageGenerateInstructionsWithHiddenFields = z.infer<
69
72
  >
70
73
 
71
74
  export const interpolatableRobotImageGenerateInstructionsSchema = interpolateRobot(
72
- robotImageGenerateInstructionsSchema,
75
+ robotImageGenerateInstructionsWithHiddenFieldsSchema,
73
76
  )
74
77
  export type InterpolatableRobotImageGenerateInstructions =
75
78
  InterpolatableRobotImageGenerateInstructionsInput
@@ -53,8 +53,7 @@ export const robotMetaWriteInstructionsSchema = robotBase
53
53
  **Note:** This <dfn>Robot</dfn> currently accepts images, videos and audio files.
54
54
  `),
55
55
  data_to_write: z
56
- .object({})
57
- .passthrough()
56
+ .record(z.unknown())
58
57
  .default({})
59
58
  .describe(`
60
59
  A key/value map defining the metadata to write into the file.
@@ -20,6 +20,7 @@ export const templateCredentialsSchema = z
20
20
  ),
21
21
  type: z
22
22
  .enum([
23
+ 'ai',
23
24
  'azure',
24
25
  'backblaze',
25
26
  'cloudflare',
@@ -2,7 +2,7 @@
2
2
  * Log levels following syslog severity (https://en.wikipedia.org/wiki/Syslog#Severity_level)
3
3
  * Lower numbers = more severe, higher numbers = more verbose
4
4
  */
5
- export const LOG_LEVEL = {
5
+ const LOG_LEVEL = {
6
6
  ERR: 3, // Error conditions
7
7
  WARN: 4, // Warning conditions
8
8
  NOTICE: 5, // Normal but significant (default)
@@ -1,11 +1,12 @@
1
+ import 'dotenv/config'
1
2
  import process from 'node:process'
2
3
  import { Command, Option } from 'clipanion'
3
- import 'dotenv/config'
4
4
  import { Transloadit as TransloaditClient } from '../../Transloadit.ts'
5
+ import { getEnvCredentials } from '../helpers.ts'
5
6
  import type { IOutputCtl } from '../OutputCtl.ts'
6
7
  import OutputCtl, { LOG_LEVEL_DEFAULT, LOG_LEVEL_NAMES, parseLogLevel } from '../OutputCtl.ts'
7
8
 
8
- export abstract class BaseCommand extends Command {
9
+ abstract class BaseCommand extends Command {
9
10
  logLevelOption = Option.String('-l,--log-level', {
10
11
  description: `Log level: ${LOG_LEVEL_NAMES.join(', ')} or 3-8 (default: notice)`,
11
12
  })
@@ -31,7 +32,8 @@ export abstract class BaseCommand extends Command {
31
32
  }
32
33
 
33
34
  protected setupClient(): boolean {
34
- if (!process.env.TRANSLOADIT_KEY || !process.env.TRANSLOADIT_SECRET) {
35
+ const creds = getEnvCredentials()
36
+ if (!creds) {
35
37
  this.output.error(
36
38
  'Please provide API authentication in the environment variables TRANSLOADIT_KEY and TRANSLOADIT_SECRET',
37
39
  )
@@ -40,11 +42,7 @@ export abstract class BaseCommand extends Command {
40
42
 
41
43
  const endpoint = this.endpoint || process.env.TRANSLOADIT_ENDPOINT
42
44
 
43
- this.client = new TransloaditClient({
44
- authKey: process.env.TRANSLOADIT_KEY,
45
- authSecret: process.env.TRANSLOADIT_SECRET,
46
- ...(endpoint && { endpoint }),
47
- })
45
+ this.client = new TransloaditClient({ ...creds, ...(endpoint && { endpoint }) })
48
46
  return true
49
47
  }
50
48
 
@@ -36,7 +36,7 @@ export interface AssemblyGetOptions {
36
36
  assemblies: string[]
37
37
  }
38
38
 
39
- export interface AssemblyDeleteOptions {
39
+ interface AssemblyDeleteOptions {
40
40
  assemblies: string[]
41
41
  }
42
42
 
@@ -8,6 +8,7 @@ import {
8
8
  } from '../../alphalib/types/template.ts'
9
9
  import type { OptionalAuthParams } from '../../apiTypes.ts'
10
10
  import { Transloadit } from '../../Transloadit.ts'
11
+ import { getEnvCredentials } from '../helpers.ts'
11
12
  import { UnauthenticatedCommand } from './BaseCommand.ts'
12
13
 
13
14
  type UrlParamPrimitive = string | number | boolean
@@ -80,16 +81,7 @@ async function readStdin(): Promise<string> {
80
81
  return data
81
82
  }
82
83
 
83
- function getCredentials(): { authKey: string; authSecret: string } | null {
84
- const authKey = process.env.TRANSLOADIT_KEY || process.env.TRANSLOADIT_AUTH_KEY
85
- const authSecret = process.env.TRANSLOADIT_SECRET || process.env.TRANSLOADIT_AUTH_SECRET
86
-
87
- if (!authKey || !authSecret) {
88
- return null
89
- }
90
-
91
- return { authKey, authSecret }
92
- }
84
+ const getCredentials = getEnvCredentials
93
85
 
94
86
  // Result type for signature operations
95
87
  type SigResult = { ok: true; output: string } | { ok: false; error: string }
@@ -7,12 +7,12 @@ import { AuthenticatedCommand } from './BaseCommand.ts'
7
7
 
8
8
  // --- Types and business logic ---
9
9
 
10
- export interface NotificationsReplayOptions {
10
+ interface NotificationsReplayOptions {
11
11
  notify_url?: string
12
12
  assemblies: string[]
13
13
  }
14
14
 
15
- export async function replay(
15
+ async function replay(
16
16
  output: IOutputCtl,
17
17
  client: Transloadit,
18
18
  { notify_url, assemblies }: NotificationsReplayOptions,
@@ -33,11 +33,11 @@ export interface TemplateModifyOptions {
33
33
  file: string
34
34
  }
35
35
 
36
- export interface TemplateDeleteOptions {
36
+ interface TemplateDeleteOptions {
37
37
  templates: string[]
38
38
  }
39
39
 
40
- export interface TemplateListOptions {
40
+ interface TemplateListOptions {
41
41
  before?: string
42
42
  after?: string
43
43
  order?: 'asc' | 'desc'
@@ -162,7 +162,7 @@ const TemplateIdSchema = z.object({
162
162
  id: z.string(),
163
163
  })
164
164
 
165
- export function list(
165
+ function list(
166
166
  output: IOutputCtl,
167
167
  client: Transloadit,
168
168
  { before, after, order, sort, fields }: TemplateListOptions,
@@ -1,8 +1,16 @@
1
1
  import fs from 'node:fs'
2
2
  import type { Readable } from 'node:stream'
3
- import type { APIError } from './types.ts'
4
3
  import { isAPIError } from './types.ts'
5
4
 
5
+ export function getEnvCredentials(): { authKey: string; authSecret: string } | null {
6
+ const authKey = process.env.TRANSLOADIT_KEY ?? process.env.TRANSLOADIT_AUTH_KEY
7
+ const authSecret = process.env.TRANSLOADIT_SECRET ?? process.env.TRANSLOADIT_AUTH_SECRET
8
+
9
+ if (!authKey || !authSecret) return null
10
+
11
+ return { authKey, authSecret }
12
+ }
13
+
6
14
  export function createReadStream(file: string): Readable {
7
15
  if (file === '-') return process.stdin
8
16
  return fs.createReadStream(file)
@@ -26,8 +34,9 @@ export function formatAPIError(err: unknown): string {
26
34
  return String(err)
27
35
  }
28
36
 
29
- // Re-export APIError type for convenience
30
- export type { APIError }
37
+ // Re-export APIError type for CLI consumers relying on deep imports.
38
+ /** @public */
39
+ export type { APIError } from './types.ts'
31
40
 
32
41
  export function zip<A, B>(listA: A[], listB: B[]): [A, B][]
33
42
  export function zip<T>(...lists: T[][]): T[][]
package/src/cli/types.ts CHANGED
@@ -1,23 +1,15 @@
1
1
  import { z } from 'zod'
2
2
  import type { Steps } from '../alphalib/types/template.ts'
3
3
  import { optionalStepsSchema } from '../alphalib/types/template.ts'
4
- import type { BillResponse, ListedTemplate, TemplateResponse } from '../apiTypes.ts'
5
- import type { AssemblyStatus, Transloadit } from '../Transloadit.ts'
6
- import type { IOutputCtl } from './OutputCtl.ts'
7
-
8
- // Re-export transloadit types for CLI use
9
- export type { AssemblyStatus, BillResponse, ListedTemplate, TemplateResponse }
10
- export type { Transloadit }
11
- export type { CreateAssemblyOptions } from '../Transloadit.ts'
12
4
 
13
5
  // Zod schemas for runtime validation
14
- export const APIErrorSchema = z.object({
6
+ const APIErrorSchema = z.object({
15
7
  error: z.string(),
16
8
  message: z.string(),
17
9
  })
18
10
  export type APIError = z.infer<typeof APIErrorSchema>
19
11
 
20
- export const TransloaditAPIErrorSchema = z.object({
12
+ const TransloaditAPIErrorSchema = z.object({
21
13
  error: z.string().optional(),
22
14
  message: z.string(),
23
15
  code: z.string().optional(),
@@ -54,98 +46,6 @@ export interface TemplateFile {
54
46
  data: TemplateFileData
55
47
  }
56
48
 
57
- // Template list item (from API)
58
- export interface TemplateListItem {
59
- id: string
60
- modified: string
61
- name?: string
62
- }
63
-
64
- // CLI Invocation types
65
- export interface BaseInvocation {
66
- error?: boolean
67
- message?: string
68
- mode: string
69
- action?: string
70
- logLevel?: number
71
- jsonMode?: boolean
72
- }
73
-
74
- export interface AssemblyInvocation extends BaseInvocation {
75
- mode: 'assemblies'
76
- action?: 'create' | 'get' | 'list' | 'delete' | 'replay'
77
- inputs: string[]
78
- output?: string
79
- recursive?: boolean
80
- watch?: boolean
81
- del?: boolean
82
- reprocessStale?: boolean
83
- steps?: string
84
- template?: string
85
- fields?: Record<string, string>
86
- assemblies?: string[]
87
- before?: string
88
- after?: string
89
- keywords?: string[]
90
- notify_url?: string
91
- reparse?: boolean
92
- }
93
-
94
- export interface TemplateInvocation extends BaseInvocation {
95
- mode: 'templates'
96
- action?: 'create' | 'get' | 'list' | 'delete' | 'modify' | 'sync'
97
- templates?: string[]
98
- template?: string
99
- name?: string
100
- file?: string
101
- files?: string[]
102
- before?: string
103
- after?: string
104
- order?: 'asc' | 'desc'
105
- sort?: string
106
- fields?: string[]
107
- recursive?: boolean
108
- }
109
-
110
- export interface BillInvocation extends BaseInvocation {
111
- mode: 'bills'
112
- action?: 'get'
113
- months: string[]
114
- }
115
-
116
- export interface NotificationInvocation extends BaseInvocation {
117
- mode: 'assembly-notifications'
118
- action?: 'list' | 'replay'
119
- assemblies?: string[]
120
- notify_url?: string
121
- type?: string
122
- assembly_id?: string
123
- pagesize?: number
124
- }
125
-
126
- export interface HelpInvocation extends BaseInvocation {
127
- mode: 'help' | 'version' | 'register'
128
- }
129
-
130
- export type Invocation =
131
- | AssemblyInvocation
132
- | TemplateInvocation
133
- | BillInvocation
134
- | NotificationInvocation
135
- | HelpInvocation
136
-
137
- // Command handler type
138
- export type CommandHandler<T extends BaseInvocation = BaseInvocation> = (
139
- output: IOutputCtl,
140
- client: Transloadit | undefined,
141
- invocation: T,
142
- ) => void | Promise<void>
143
-
144
- // Type guard for Error
145
- export function isError(value: unknown): value is Error {
146
- return value instanceof Error
147
- }
148
-
149
49
  // Helper to ensure error is Error type
150
50
  export function ensureError(value: unknown): Error {
151
51
  if (value instanceof Error) {
@@ -168,16 +68,3 @@ export function isTransloaditAPIError(value: unknown): value is TransloaditAPIEr
168
68
  export function isErrnoException(value: unknown): value is NodeJS.ErrnoException {
169
69
  return value instanceof Error && 'code' in value
170
70
  }
171
-
172
- // Safe array access helper
173
- export function safeGet<T>(arr: T[], index: number): T | undefined {
174
- return arr[index]
175
- }
176
-
177
- // Assert defined helper
178
- export function assertDefined<T>(value: T | undefined | null, message: string): T {
179
- if (value === undefined || value === null) {
180
- throw new Error(message)
181
- }
182
- return value
183
- }