@transloadit/node 4.10.8 → 4.11.1
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.
- package/README.md +1 -1
- package/dist/Transloadit.d.ts +13 -0
- package/dist/Transloadit.d.ts.map +1 -1
- package/dist/Transloadit.js +70 -0
- package/dist/Transloadit.js.map +1 -1
- package/dist/alphalib/imagemagickDensity.d.ts +4 -0
- package/dist/alphalib/imagemagickDensity.d.ts.map +1 -0
- package/dist/alphalib/imagemagickDensity.js +10 -0
- package/dist/alphalib/imagemagickDensity.js.map +1 -0
- package/dist/alphalib/types/assemblyReplay.d.ts +308 -4
- package/dist/alphalib/types/assemblyReplay.d.ts.map +1 -1
- package/dist/alphalib/types/assemblyReplay.js +22 -2
- package/dist/alphalib/types/assemblyReplay.js.map +1 -1
- package/dist/alphalib/types/assemblyStatus.d.ts +11 -10
- package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -1
- package/dist/alphalib/types/assemblyStatus.js +25 -0
- package/dist/alphalib/types/assemblyStatus.js.map +1 -1
- package/dist/alphalib/types/robots/_index.d.ts +93 -0
- package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts +14 -2
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.js +36 -6
- package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.d.ts +13474 -1034
- package/dist/alphalib/types/robots/ai-chat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.js +303 -57
- package/dist/alphalib/types/robots/ai-chat.js.map +1 -1
- package/dist/alphalib/types/robots/audio-artwork.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-artwork.js +1 -0
- package/dist/alphalib/types/robots/audio-artwork.js.map +1 -1
- package/dist/alphalib/types/robots/audio-concat.d.ts +12 -0
- package/dist/alphalib/types/robots/audio-concat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-concat.js +3 -1
- package/dist/alphalib/types/robots/audio-concat.js.map +1 -1
- package/dist/alphalib/types/robots/audio-encode.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-encode.js +1 -0
- package/dist/alphalib/types/robots/audio-encode.js.map +1 -1
- package/dist/alphalib/types/robots/audio-loop.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-loop.js +1 -0
- package/dist/alphalib/types/robots/audio-loop.js.map +1 -1
- package/dist/alphalib/types/robots/audio-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-merge.js +1 -0
- package/dist/alphalib/types/robots/audio-merge.js.map +1 -1
- package/dist/alphalib/types/robots/audio-split.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-split.js +1 -0
- package/dist/alphalib/types/robots/audio-split.js.map +1 -1
- package/dist/alphalib/types/robots/audio-waveform.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-waveform.js +1 -0
- package/dist/alphalib/types/robots/audio-waveform.js.map +1 -1
- package/dist/alphalib/types/robots/azure-import.d.ts +12 -0
- package/dist/alphalib/types/robots/azure-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/backblaze-import.d.ts +12 -0
- package/dist/alphalib/types/robots/backblaze-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/box-import.d.ts +12 -0
- package/dist/alphalib/types/robots/box-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts +12 -0
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudflare-import.d.ts +12 -0
- package/dist/alphalib/types/robots/cloudflare-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/digitalocean-import.d.ts +12 -0
- package/dist/alphalib/types/robots/digitalocean-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-merge.d.ts +12 -0
- package/dist/alphalib/types/robots/document-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-merge.js +2 -1
- package/dist/alphalib/types/robots/document-merge.js.map +1 -1
- package/dist/alphalib/types/robots/document-ocr.d.ts +10 -10
- package/dist/alphalib/types/robots/document-ocr.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-ocr.js +4 -4
- package/dist/alphalib/types/robots/document-ocr.js.map +1 -1
- package/dist/alphalib/types/robots/dropbox-import.d.ts +12 -0
- package/dist/alphalib/types/robots/dropbox-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-preview.d.ts +12 -12
- package/dist/alphalib/types/robots/file-preview.js +2 -2
- package/dist/alphalib/types/robots/file-preview.js.map +1 -1
- package/dist/alphalib/types/robots/file-serve.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-serve.js +1 -0
- package/dist/alphalib/types/robots/file-serve.js.map +1 -1
- package/dist/alphalib/types/robots/file-verify.d.ts +12 -0
- package/dist/alphalib/types/robots/file-verify.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-verify.js +6 -0
- package/dist/alphalib/types/robots/file-verify.js.map +1 -1
- package/dist/alphalib/types/robots/ftp-import.d.ts +12 -0
- package/dist/alphalib/types/robots/ftp-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/google-import.d.ts +12 -0
- package/dist/alphalib/types/robots/google-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/http-import.d.ts +12 -12
- package/dist/alphalib/types/robots/http-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/http-import.js +0 -6
- package/dist/alphalib/types/robots/http-import.js.map +1 -1
- package/dist/alphalib/types/robots/image-bgremove.d.ts +10 -10
- package/dist/alphalib/types/robots/image-bgremove.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-bgremove.js +4 -4
- package/dist/alphalib/types/robots/image-bgremove.js.map +1 -1
- package/dist/alphalib/types/robots/image-describe.d.ts +10 -10
- package/dist/alphalib/types/robots/image-describe.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-describe.js +4 -4
- package/dist/alphalib/types/robots/image-describe.js.map +1 -1
- package/dist/alphalib/types/robots/image-facedetect.d.ts +10 -10
- package/dist/alphalib/types/robots/image-facedetect.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-facedetect.js +4 -4
- package/dist/alphalib/types/robots/image-facedetect.js.map +1 -1
- package/dist/alphalib/types/robots/image-generate.d.ts +6 -6
- package/dist/alphalib/types/robots/image-generate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-generate.js +2 -2
- package/dist/alphalib/types/robots/image-generate.js.map +1 -1
- package/dist/alphalib/types/robots/image-merge.d.ts +68 -8
- package/dist/alphalib/types/robots/image-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-merge.js +46 -3
- package/dist/alphalib/types/robots/image-merge.js.map +1 -1
- package/dist/alphalib/types/robots/image-ocr.d.ts +10 -10
- package/dist/alphalib/types/robots/image-ocr.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-ocr.js +4 -4
- package/dist/alphalib/types/robots/image-ocr.js.map +1 -1
- package/dist/alphalib/types/robots/image-resize.d.ts +9 -8
- package/dist/alphalib/types/robots/image-resize.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-resize.js +9 -8
- package/dist/alphalib/types/robots/image-resize.js.map +1 -1
- package/dist/alphalib/types/robots/image-upscale.d.ts +4 -4
- package/dist/alphalib/types/robots/image-upscale.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-upscale.js +2 -2
- package/dist/alphalib/types/robots/image-upscale.js.map +1 -1
- package/dist/alphalib/types/robots/mega-import.d.ts +12 -0
- package/dist/alphalib/types/robots/mega-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/minio-import.d.ts +12 -0
- package/dist/alphalib/types/robots/minio-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/s3-import.d.ts +12 -0
- package/dist/alphalib/types/robots/s3-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/sftp-import.d.ts +24 -0
- package/dist/alphalib/types/robots/sftp-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/sftp-import.js +6 -2
- package/dist/alphalib/types/robots/sftp-import.js.map +1 -1
- package/dist/alphalib/types/robots/speech-transcribe.d.ts +10 -10
- package/dist/alphalib/types/robots/speech-transcribe.d.ts.map +1 -1
- package/dist/alphalib/types/robots/speech-transcribe.js +9 -9
- package/dist/alphalib/types/robots/speech-transcribe.js.map +1 -1
- package/dist/alphalib/types/robots/supabase-import.d.ts +12 -0
- package/dist/alphalib/types/robots/supabase-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/swift-import.d.ts +12 -0
- package/dist/alphalib/types/robots/swift-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/text-speak.d.ts +10 -10
- package/dist/alphalib/types/robots/text-speak.d.ts.map +1 -1
- package/dist/alphalib/types/robots/text-speak.js +4 -4
- package/dist/alphalib/types/robots/text-speak.js.map +1 -1
- package/dist/alphalib/types/robots/text-translate.d.ts +10 -10
- package/dist/alphalib/types/robots/text-translate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/text-translate.js +4 -4
- package/dist/alphalib/types/robots/text-translate.js.map +1 -1
- package/dist/alphalib/types/robots/tigris-import.d.ts +12 -0
- package/dist/alphalib/types/robots/tigris-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tlcdn-deliver.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tlcdn-deliver.js +1 -0
- package/dist/alphalib/types/robots/tlcdn-deliver.js.map +1 -1
- package/dist/alphalib/types/robots/video-adaptive.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-adaptive.js +1 -0
- package/dist/alphalib/types/robots/video-adaptive.js.map +1 -1
- package/dist/alphalib/types/robots/video-artwork.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-artwork.js +1 -0
- package/dist/alphalib/types/robots/video-artwork.js.map +1 -1
- package/dist/alphalib/types/robots/video-concat.d.ts +12 -0
- package/dist/alphalib/types/robots/video-concat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-concat.js +3 -1
- package/dist/alphalib/types/robots/video-concat.js.map +1 -1
- package/dist/alphalib/types/robots/video-encode.d.ts +4 -4
- package/dist/alphalib/types/robots/video-encode.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-encode.js +1 -0
- package/dist/alphalib/types/robots/video-encode.js.map +1 -1
- package/dist/alphalib/types/robots/video-generate.d.ts +6 -6
- package/dist/alphalib/types/robots/video-generate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-generate.js +3 -2
- package/dist/alphalib/types/robots/video-generate.js.map +1 -1
- package/dist/alphalib/types/robots/video-merge.d.ts +12 -0
- package/dist/alphalib/types/robots/video-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-merge.js +4 -6
- package/dist/alphalib/types/robots/video-merge.js.map +1 -1
- package/dist/alphalib/types/robots/video-ondemand.d.ts +4 -4
- package/dist/alphalib/types/robots/video-ondemand.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-ondemand.js +1 -0
- package/dist/alphalib/types/robots/video-ondemand.js.map +1 -1
- package/dist/alphalib/types/robots/video-split.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-split.js +1 -0
- package/dist/alphalib/types/robots/video-split.js.map +1 -1
- package/dist/alphalib/types/robots/video-subtitle.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-subtitle.js +1 -0
- package/dist/alphalib/types/robots/video-subtitle.js.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.d.ts +24 -0
- package/dist/alphalib/types/robots/video-thumbs.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.js +29 -0
- package/dist/alphalib/types/robots/video-thumbs.js.map +1 -1
- package/dist/alphalib/types/robots/vimeo-import.d.ts +12 -0
- package/dist/alphalib/types/robots/vimeo-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/wasabi-import.d.ts +12 -0
- package/dist/alphalib/types/robots/wasabi-import.d.ts.map +1 -1
- package/dist/cli/commands/assemblies.d.ts +37 -0
- package/dist/cli/commands/assemblies.d.ts.map +1 -1
- package/dist/cli/commands/assemblies.js +173 -1
- package/dist/cli/commands/assemblies.js.map +1 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +4 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/semanticIntents/imageDescribe.d.ts +1 -1
- package/dist/cli/semanticIntents/imageDescribe.d.ts.map +1 -1
- package/dist/cli/semanticIntents/imageDescribe.js +2 -2
- package/dist/cli/semanticIntents/imageDescribe.js.map +1 -1
- package/package.json +2 -2
- package/src/Transloadit.ts +106 -0
- package/src/alphalib/imagemagickDensity.ts +15 -0
- package/src/alphalib/types/assemblyReplay.ts +31 -2
- package/src/alphalib/types/assemblyStatus.ts +29 -0
- package/src/alphalib/types/robots/_instructions-primitives.ts +39 -6
- package/src/alphalib/types/robots/ai-chat.ts +447 -57
- package/src/alphalib/types/robots/audio-artwork.ts +1 -0
- package/src/alphalib/types/robots/audio-concat.ts +3 -0
- package/src/alphalib/types/robots/audio-encode.ts +1 -0
- package/src/alphalib/types/robots/audio-loop.ts +1 -0
- package/src/alphalib/types/robots/audio-merge.ts +1 -0
- package/src/alphalib/types/robots/audio-split.ts +1 -0
- package/src/alphalib/types/robots/audio-waveform.ts +1 -0
- package/src/alphalib/types/robots/document-merge.ts +7 -1
- package/src/alphalib/types/robots/document-ocr.ts +5 -4
- package/src/alphalib/types/robots/file-preview.ts +2 -2
- package/src/alphalib/types/robots/file-serve.ts +1 -0
- package/src/alphalib/types/robots/file-verify.ts +6 -0
- package/src/alphalib/types/robots/http-import.ts +0 -6
- package/src/alphalib/types/robots/image-bgremove.ts +11 -4
- package/src/alphalib/types/robots/image-describe.ts +5 -4
- package/src/alphalib/types/robots/image-facedetect.ts +5 -4
- package/src/alphalib/types/robots/image-generate.ts +7 -2
- package/src/alphalib/types/robots/image-merge.ts +46 -2
- package/src/alphalib/types/robots/image-ocr.ts +5 -4
- package/src/alphalib/types/robots/image-resize.ts +11 -7
- package/src/alphalib/types/robots/image-upscale.ts +7 -2
- package/src/alphalib/types/robots/sftp-import.ts +12 -2
- package/src/alphalib/types/robots/speech-transcribe.ts +9 -8
- package/src/alphalib/types/robots/text-speak.ts +5 -4
- package/src/alphalib/types/robots/text-translate.ts +5 -4
- package/src/alphalib/types/robots/tlcdn-deliver.ts +1 -0
- package/src/alphalib/types/robots/video-adaptive.ts +1 -0
- package/src/alphalib/types/robots/video-artwork.ts +1 -0
- package/src/alphalib/types/robots/video-concat.ts +3 -0
- package/src/alphalib/types/robots/video-encode.ts +1 -0
- package/src/alphalib/types/robots/video-generate.ts +8 -2
- package/src/alphalib/types/robots/video-merge.ts +5 -5
- package/src/alphalib/types/robots/video-ondemand.ts +1 -0
- package/src/alphalib/types/robots/video-split.ts +1 -0
- package/src/alphalib/types/robots/video-subtitle.ts +1 -0
- package/src/alphalib/types/robots/video-thumbs.ts +29 -0
- package/src/cli/commands/assemblies.ts +244 -2
- package/src/cli/commands/index.ts +6 -0
- package/src/cli/semanticIntents/imageDescribe.ts +2 -3
package/src/Transloadit.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream'
|
|
2
2
|
|
|
3
|
+
import type {
|
|
4
|
+
CompileAssemblyInstructionsOptions,
|
|
5
|
+
CompileAssemblyInstructionsResult,
|
|
6
|
+
} from '@transloadit/utils'
|
|
3
7
|
import type { Delays, Headers, OptionsOfJSONResponseBody, RetryOptions } from 'got'
|
|
4
8
|
|
|
5
9
|
import type { TransloaditErrorResponseBody } from './ApiError.ts'
|
|
@@ -43,6 +47,7 @@ import { access, stat } from 'node:fs/promises'
|
|
|
43
47
|
import { basename } from 'node:path'
|
|
44
48
|
import { setTimeout as delay } from 'node:timers/promises'
|
|
45
49
|
|
|
50
|
+
import { compileAssemblyInstructionsFromPrompt } from '@transloadit/utils'
|
|
46
51
|
import { getSignedSmartCdnUrl, signParamsSync } from '@transloadit/utils/node'
|
|
47
52
|
import debug from 'debug'
|
|
48
53
|
import FormData from 'form-data'
|
|
@@ -62,6 +67,14 @@ import PaginationStream from './PaginationStream.ts'
|
|
|
62
67
|
import PollingTimeoutError from './PollingTimeoutError.ts'
|
|
63
68
|
import { sendTusRequest } from './tus.ts'
|
|
64
69
|
|
|
70
|
+
export type {
|
|
71
|
+
CompileAssemblyInstructionsAttempt,
|
|
72
|
+
CompileAssemblyInstructionsClient,
|
|
73
|
+
CompileAssemblyInstructionsLintIssue,
|
|
74
|
+
CompileAssemblyInstructionsMessage,
|
|
75
|
+
CompileAssemblyInstructionsResult,
|
|
76
|
+
} from '@transloadit/utils'
|
|
77
|
+
|
|
65
78
|
export type { AssemblyStatus } from './alphalib/types/assemblyStatus.ts'
|
|
66
79
|
export type {
|
|
67
80
|
Base64Strategy,
|
|
@@ -81,6 +94,11 @@ export type {
|
|
|
81
94
|
RobotParamHelp,
|
|
82
95
|
} from './robots.ts'
|
|
83
96
|
|
|
97
|
+
export {
|
|
98
|
+
buildCompileAssemblyInstructionsSystemPrompt,
|
|
99
|
+
CompileAssemblyInstructionsError,
|
|
100
|
+
parseCompileAssemblyInstructionsResponse,
|
|
101
|
+
} from '@transloadit/utils'
|
|
84
102
|
// See https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#errors
|
|
85
103
|
// Expose relevant errors
|
|
86
104
|
export {
|
|
@@ -274,6 +292,13 @@ export interface SmartCDNUrlOptions {
|
|
|
274
292
|
expiresAt?: number
|
|
275
293
|
}
|
|
276
294
|
|
|
295
|
+
export type CompileAssemblyInstructionsFromPromptOptions = Omit<
|
|
296
|
+
CompileAssemblyInstructionsOptions,
|
|
297
|
+
'client'
|
|
298
|
+
> & {
|
|
299
|
+
timeout?: number
|
|
300
|
+
}
|
|
301
|
+
|
|
277
302
|
export type Fields = Record<string, string | number>
|
|
278
303
|
|
|
279
304
|
// A special promise that lets the user immediately get the assembly ID (synchronously before the request is sent)
|
|
@@ -313,6 +338,37 @@ function checkResult<T>(result: T | { error: string }): asserts result is T {
|
|
|
313
338
|
}
|
|
314
339
|
}
|
|
315
340
|
|
|
341
|
+
function getResultBilledChargeUsd(result: unknown): number | undefined {
|
|
342
|
+
if (typeof result !== 'object' || result === null || Array.isArray(result)) {
|
|
343
|
+
return undefined
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (!('meta' in result)) {
|
|
347
|
+
return undefined
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const { meta } = result
|
|
351
|
+
if (typeof meta !== 'object' || meta === null || Array.isArray(meta)) {
|
|
352
|
+
return undefined
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (!('billed_charge_usd' in meta)) {
|
|
356
|
+
return undefined
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const { billed_charge_usd: billedChargeUsd } = meta
|
|
360
|
+
return typeof billedChargeUsd === 'number' ? billedChargeUsd : undefined
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
async function fetchJson(url: string): Promise<unknown> {
|
|
364
|
+
const response = await fetch(url)
|
|
365
|
+
if (!response.ok) {
|
|
366
|
+
throw new Error(`Failed to fetch AI response: ${response.status} ${response.statusText}`)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return await response.json()
|
|
370
|
+
}
|
|
371
|
+
|
|
316
372
|
type AuthKeySecret = {
|
|
317
373
|
authKey: string
|
|
318
374
|
authSecret: string
|
|
@@ -552,6 +608,56 @@ export class Transloadit {
|
|
|
552
608
|
})
|
|
553
609
|
}
|
|
554
610
|
|
|
611
|
+
/**
|
|
612
|
+
* Compile a natural-language prompt into validated Assembly Instructions.
|
|
613
|
+
*
|
|
614
|
+
* This creates a zero-upload /ai/chat Assembly, validates the structured response,
|
|
615
|
+
* and lints the generated instructions locally before returning them.
|
|
616
|
+
*/
|
|
617
|
+
async compileAssemblyInstructionsFromPrompt(
|
|
618
|
+
options: CompileAssemblyInstructionsFromPromptOptions,
|
|
619
|
+
): Promise<CompileAssemblyInstructionsResult> {
|
|
620
|
+
const timeout = options.timeout ?? 5 * 60 * 1000
|
|
621
|
+
|
|
622
|
+
return await compileAssemblyInstructionsFromPrompt({
|
|
623
|
+
...options,
|
|
624
|
+
mcpServerUrl: options.mcpServerUrl ?? `${this._endpoint}/mcp`,
|
|
625
|
+
client: {
|
|
626
|
+
runAssemblyInstructionsCompiler: async ({ aiStep }) => {
|
|
627
|
+
const assembly = await this.createAssembly({
|
|
628
|
+
params: {
|
|
629
|
+
steps: {
|
|
630
|
+
ai: aiStep,
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
waitForCompletion: true,
|
|
634
|
+
expectedUploads: 0,
|
|
635
|
+
timeout,
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
const result = assembly.results?.ai?.[0]
|
|
639
|
+
const resultUrl = result?.url
|
|
640
|
+
if (!resultUrl) {
|
|
641
|
+
throw new Error('No AI response in Assembly results.')
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return {
|
|
645
|
+
response: await fetchJson(resultUrl),
|
|
646
|
+
assemblyUrl: assembly.assembly_ssl_url ?? assembly.assembly_url ?? undefined,
|
|
647
|
+
billedChargeUsd: getResultBilledChargeUsd(result),
|
|
648
|
+
usageBytes: assembly.bytes_usage ?? undefined,
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
lintAssemblyInstructions: async (instructionsJson) => {
|
|
652
|
+
const lintResult = await this.lintAssemblyInstructions({
|
|
653
|
+
assemblyInstructions: instructionsJson,
|
|
654
|
+
})
|
|
655
|
+
return lintResult.issues
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
})
|
|
659
|
+
}
|
|
660
|
+
|
|
555
661
|
/**
|
|
556
662
|
* Mint a short-lived bearer token via POST /token.
|
|
557
663
|
*
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const positiveDecimalDensityPart = String.raw`(?:0*[1-9]\d*(?:\.\d+)?|0+\.\d*[1-9]\d*)`
|
|
2
|
+
|
|
3
|
+
const imagemagickDensityPattern = new RegExp(
|
|
4
|
+
`^${positiveDecimalDensityPart}(?:x${positiveDecimalDensityPart})?$`,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
function isValidImagemagickDensity(value: unknown): boolean {
|
|
8
|
+
if (typeof value === 'number') {
|
|
9
|
+
return Number.isFinite(value) && value > 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return typeof value === 'string' && imagemagickDensityPattern.test(value)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { imagemagickDensityPattern, isValidImagemagickDensity }
|
|
@@ -4,14 +4,43 @@ import {
|
|
|
4
4
|
assemblyAuthInstructionsSchema,
|
|
5
5
|
fieldsSchema,
|
|
6
6
|
notifyUrlSchema,
|
|
7
|
-
optionalStepsSchema,
|
|
8
7
|
templateIdSchema,
|
|
9
8
|
} from './template.ts'
|
|
10
9
|
|
|
10
|
+
export const assemblyReplayStepSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
field: z.unknown().optional(),
|
|
13
|
+
force_name: z.unknown().optional(),
|
|
14
|
+
force_original_id: z.unknown().optional(),
|
|
15
|
+
key: z.unknown().optional(),
|
|
16
|
+
output_meta: z.unknown().optional(),
|
|
17
|
+
password: z.unknown().optional(),
|
|
18
|
+
prompt: z.unknown().optional(),
|
|
19
|
+
robot: z.string().optional(),
|
|
20
|
+
secret: z.unknown().optional(),
|
|
21
|
+
url: z.unknown().optional(),
|
|
22
|
+
use: z.unknown().optional(),
|
|
23
|
+
})
|
|
24
|
+
.passthrough()
|
|
25
|
+
.describe(
|
|
26
|
+
'A full Assembly step or partial replay step override. Replay keeps this relaxed so credentials and missing robot properties can be merged back from the original Template before normal Assembly validation runs.',
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export const assemblyReplayStepsSchema = z
|
|
30
|
+
.union([z.record(assemblyReplayStepSchema), z.array(assemblyReplayStepSchema)])
|
|
31
|
+
.describe(
|
|
32
|
+
'Replay step overrides. Object-form steps are the normal Assembly shape; array-form steps are accepted for legacy replay compatibility and normalized before execution.',
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export const optionalAssemblyReplayStepsSchema = assemblyReplayStepsSchema.optional()
|
|
36
|
+
|
|
37
|
+
export type AssemblyReplayStep = z.infer<typeof assemblyReplayStepSchema>
|
|
38
|
+
export type AssemblyReplaySteps = z.infer<typeof assemblyReplayStepsSchema>
|
|
39
|
+
|
|
11
40
|
export const assemblyReplaySchema = z
|
|
12
41
|
.object({
|
|
13
42
|
auth: assemblyAuthInstructionsSchema,
|
|
14
|
-
steps:
|
|
43
|
+
steps: optionalAssemblyReplayStepsSchema,
|
|
15
44
|
template_id: templateIdSchema,
|
|
16
45
|
notify_url: notifyUrlSchema,
|
|
17
46
|
fields: fieldsSchema,
|
|
@@ -120,15 +120,20 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
120
120
|
'CLOUDFLARE_IMPORT_FAILURE',
|
|
121
121
|
'CLOUDFLARE_IMPORT_NOT_FOUND',
|
|
122
122
|
'CLOUDFLARE_IMPORT_VALIDATION',
|
|
123
|
+
'CLOUDFLARE_STORE_ACCESS_DENIED',
|
|
124
|
+
'CLOUDFLARE_STORE_NOT_FOUND',
|
|
123
125
|
'CLOUDFLARE_STORE_URL_VERIFICATION_FAILURE',
|
|
124
126
|
'CLOUDFLARE_STORE_VALIDATION',
|
|
127
|
+
'CLOUDFLARE_STORE_WRONG_REGION',
|
|
125
128
|
'CLOUD_AI_IMAGE_VALIDATION',
|
|
126
129
|
'DIGITALOCEAN_IMPORT_ACCESS_DENIED',
|
|
127
130
|
'DIGITALOCEAN_IMPORT_FAILURE',
|
|
128
131
|
'DIGITALOCEAN_IMPORT_NOT_FOUND',
|
|
129
132
|
'DIGITALOCEAN_IMPORT_VALIDATION',
|
|
130
133
|
'DIGITALOCEAN_STORE_ACCESS_DENIED',
|
|
134
|
+
'DIGITALOCEAN_STORE_NOT_FOUND',
|
|
131
135
|
'DIGITALOCEAN_STORE_VALIDATION',
|
|
136
|
+
'DIGITALOCEAN_STORE_WRONG_REGION',
|
|
132
137
|
'DOCUMENT_AUTOROTATE_VALIDATION',
|
|
133
138
|
'DOCUMENT_CONVERT_UNSUPPORTED_CONVERSION',
|
|
134
139
|
'DOCUMENT_CONVERT_VALIDATION',
|
|
@@ -236,13 +241,19 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
236
241
|
'MEGA_IMPORT_FAILURE',
|
|
237
242
|
'MEGA_IMPORT_NOT_FOUND',
|
|
238
243
|
'MEGA_IMPORT_VALIDATION',
|
|
244
|
+
'MEGA_STORE_ACCESS_DENIED',
|
|
245
|
+
'MEGA_STORE_NOT_FOUND',
|
|
239
246
|
'MEGA_STORE_VALIDATION',
|
|
247
|
+
'MEGA_STORE_WRONG_REGION',
|
|
240
248
|
'META_WRITE_VALIDATION',
|
|
241
249
|
'MINIO_IMPORT_ACCESS_DENIED',
|
|
242
250
|
'MINIO_IMPORT_FAILURE',
|
|
243
251
|
'MINIO_IMPORT_NOT_FOUND',
|
|
244
252
|
'MINIO_IMPORT_VALIDATION',
|
|
253
|
+
'MINIO_STORE_ACCESS_DENIED',
|
|
254
|
+
'MINIO_STORE_NOT_FOUND',
|
|
245
255
|
'MINIO_STORE_VALIDATION',
|
|
256
|
+
'MINIO_STORE_WRONG_REGION',
|
|
246
257
|
'NO_AUTH_EXPIRES_PARAMETER',
|
|
247
258
|
'NO_AUTH_KEY_PARAMETER',
|
|
248
259
|
'NO_AUTH_PARAMETER',
|
|
@@ -275,8 +286,10 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
275
286
|
'S3_NOT_FOUND',
|
|
276
287
|
'S3_STORE_ACCESS_DENIED',
|
|
277
288
|
'S3_STORE_FAILURE',
|
|
289
|
+
'S3_STORE_NOT_FOUND',
|
|
278
290
|
'S3_STORE_URL_VERIFICATION_FAILURE',
|
|
279
291
|
'S3_STORE_VALIDATION',
|
|
292
|
+
'S3_STORE_WRONG_REGION',
|
|
280
293
|
'SCRIPT_RUN_VALIDATION',
|
|
281
294
|
'SERVER_403',
|
|
282
295
|
'SERVER_404',
|
|
@@ -295,12 +308,18 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
295
308
|
'SUPABASE_IMPORT_FAILURE',
|
|
296
309
|
'SUPABASE_IMPORT_NOT_FOUND',
|
|
297
310
|
'SUPABASE_IMPORT_VALIDATION',
|
|
311
|
+
'SUPABASE_STORE_ACCESS_DENIED',
|
|
312
|
+
'SUPABASE_STORE_NOT_FOUND',
|
|
298
313
|
'SUPABASE_STORE_VALIDATION',
|
|
314
|
+
'SUPABASE_STORE_WRONG_REGION',
|
|
299
315
|
'SWIFT_IMPORT_ACCESS_DENIED',
|
|
300
316
|
'SWIFT_IMPORT_FAILURE',
|
|
301
317
|
'SWIFT_IMPORT_NOT_FOUND',
|
|
302
318
|
'SWIFT_IMPORT_VALIDATION',
|
|
319
|
+
'SWIFT_STORE_ACCESS_DENIED',
|
|
320
|
+
'SWIFT_STORE_NOT_FOUND',
|
|
303
321
|
'SWIFT_STORE_VALIDATION',
|
|
322
|
+
'SWIFT_STORE_WRONG_REGION',
|
|
304
323
|
'TEMPLATE_CREDENTIALS_INJECTION_ERROR',
|
|
305
324
|
'TEMPLATE_DB_ERROR',
|
|
306
325
|
'TEMPLATE_DENIES_STEPS_OVERRIDE',
|
|
@@ -312,7 +331,10 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
312
331
|
'TIGRIS_IMPORT_FAILURE',
|
|
313
332
|
'TIGRIS_IMPORT_NOT_FOUND',
|
|
314
333
|
'TIGRIS_IMPORT_VALIDATION',
|
|
334
|
+
'TIGRIS_STORE_ACCESS_DENIED',
|
|
335
|
+
'TIGRIS_STORE_NOT_FOUND',
|
|
315
336
|
'TIGRIS_STORE_VALIDATION',
|
|
337
|
+
'TIGRIS_STORE_WRONG_REGION',
|
|
316
338
|
'TMP_FILE_DOWNLOAD_ERROR',
|
|
317
339
|
'TOKEN_INVALID_CREDENTIALS',
|
|
318
340
|
'TUS_STORE_VALIDATION',
|
|
@@ -348,7 +370,10 @@ export const assemblyStatusErrCodeSchema = z.enum([
|
|
|
348
370
|
'WASABI_IMPORT_FAILURE',
|
|
349
371
|
'WASABI_IMPORT_NOT_FOUND',
|
|
350
372
|
'WASABI_IMPORT_VALIDATION',
|
|
373
|
+
'WASABI_STORE_ACCESS_DENIED',
|
|
374
|
+
'WASABI_STORE_NOT_FOUND',
|
|
351
375
|
'WASABI_STORE_VALIDATION',
|
|
376
|
+
'WASABI_STORE_WRONG_REGION',
|
|
352
377
|
'WORKER_JOB_ERROR',
|
|
353
378
|
'YOUTUBE_STORE_PROBLEM_SENDING_FILE',
|
|
354
379
|
'YOUTUBE_STORE_VALIDATION',
|
|
@@ -820,6 +845,10 @@ export const assemblyStatusBaseSchema = z.object({
|
|
|
820
845
|
ignored_error_count: z.number().optional(),
|
|
821
846
|
})
|
|
822
847
|
|
|
848
|
+
export type AssemblyStatusTusUpload = NonNullable<
|
|
849
|
+
z.infer<typeof assemblyStatusBaseSchema>['tus_uploads']
|
|
850
|
+
>[number]
|
|
851
|
+
|
|
823
852
|
export const assemblyStatusBusySchema = z
|
|
824
853
|
.object({
|
|
825
854
|
ok: assemblyBusyCodeSchema,
|
|
@@ -127,6 +127,7 @@ export const robotMetaSchema = z.object({
|
|
|
127
127
|
gcp: z.number(),
|
|
128
128
|
})
|
|
129
129
|
.optional(),
|
|
130
|
+
applyCommunityPlanMediaTrim: z.boolean().optional(),
|
|
130
131
|
isAllowedForUrlTransform: z.boolean(),
|
|
131
132
|
removeJobResultFilesFromDiskRightAfterStoringOnS3: z.boolean(),
|
|
132
133
|
lazyLoad: z.boolean().optional(),
|
|
@@ -251,6 +252,17 @@ export const interpolationSchemaPartial = z.custom<string>(
|
|
|
251
252
|
|
|
252
253
|
export const booleanStringSchema = z.enum(['true', 'false'])
|
|
253
254
|
|
|
255
|
+
export const inputSortBySchema = z
|
|
256
|
+
.enum(['auto', 'basename', 'import_order'])
|
|
257
|
+
.default('basename')
|
|
258
|
+
.describe(`
|
|
259
|
+
Controls how bundled inputs are ordered when no explicit numbered alias such as \`video_1\` or \`document_1\` is used.
|
|
260
|
+
|
|
261
|
+
The default \`"basename"\` keeps the legacy natural basename sorting behavior.
|
|
262
|
+
|
|
263
|
+
Set this to \`"import_order"\` to preserve the order of array-based import steps when all input files carry complete import order metadata. \`"auto"\` has the same import-order preference with natural basename sorting as fallback.
|
|
264
|
+
`)
|
|
265
|
+
|
|
254
266
|
type InterpolatableTuple<Schemas extends readonly z.ZodTypeAny[]> = Schemas extends readonly [
|
|
255
267
|
infer Head extends z.ZodTypeAny,
|
|
256
268
|
...infer Rest extends z.ZodTypeAny[],
|
|
@@ -503,15 +515,19 @@ Use field names such as \`path\`, or dotted paths such as \`ffmpeg.vf\` for nest
|
|
|
503
515
|
/**
|
|
504
516
|
* Fields that are shared by all Transloadit robots.
|
|
505
517
|
*/
|
|
518
|
+
export const robotOutputMetaSchema = z.union([
|
|
519
|
+
z.record(z.boolean()),
|
|
520
|
+
z.boolean(),
|
|
521
|
+
z.array(z.string()),
|
|
522
|
+
])
|
|
523
|
+
export type RobotOutputMeta = z.infer<typeof robotOutputMetaSchema>
|
|
524
|
+
|
|
506
525
|
export type RobotBase = z.infer<typeof robotBase>
|
|
507
526
|
export const robotBase = z
|
|
508
527
|
.object({
|
|
509
528
|
interpolate: robotInterpolateSchema.optional(),
|
|
510
529
|
|
|
511
|
-
output_meta:
|
|
512
|
-
.union([z.record(z.boolean()), z.boolean(), z.array(z.string())])
|
|
513
|
-
.optional()
|
|
514
|
-
.describe(`
|
|
530
|
+
output_meta: robotOutputMetaSchema.optional().describe(`
|
|
515
531
|
Allows you to specify a set of metadata that is more expensive on CPU power to calculate, and thus is disabled by default to keep your Assemblies processing fast.
|
|
516
532
|
|
|
517
533
|
For images, you can add \`"has_transparency": true\` in this object to extract if the image contains transparent parts and \`"dominant_colors": true\` to extract an array of hexadecimal color codes from the image.
|
|
@@ -1185,6 +1201,11 @@ export const positionSchema = z.enum([
|
|
|
1185
1201
|
|
|
1186
1202
|
export const percentageSchema = z.string().regex(/^\d+%$/)
|
|
1187
1203
|
|
|
1204
|
+
export const httpUrlSchema = z
|
|
1205
|
+
.string()
|
|
1206
|
+
.url()
|
|
1207
|
+
.regex(/^https?:\/\//i)
|
|
1208
|
+
|
|
1188
1209
|
export const color_with_alpha = z.string().regex(/^#?[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)
|
|
1189
1210
|
|
|
1190
1211
|
export const color_without_alpha = z.string().regex(/^#?[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/)
|
|
@@ -1295,7 +1316,13 @@ export const imageQualitySchema = z
|
|
|
1295
1316
|
Controls the image compression for JPG and PNG images. Please also take a look at [🤖/image/optimize](/docs/robots/image-optimize/).
|
|
1296
1317
|
`)
|
|
1297
1318
|
|
|
1298
|
-
export const
|
|
1319
|
+
export const autoProviderDescription = 'Chooses the best provider based on your request'
|
|
1320
|
+
|
|
1321
|
+
export const awsGcpAiProviderSchema = z.enum(['auto', 'aws', 'gcp']).default('auto')
|
|
1322
|
+
|
|
1323
|
+
export const aiProviderSchema = z
|
|
1324
|
+
.enum(['auto', 'aws', 'gcp', 'replicate', 'fal', 'transloadit'])
|
|
1325
|
+
.default('auto')
|
|
1299
1326
|
|
|
1300
1327
|
export const granularitySchema = z.enum(['full', 'list']).default('full')
|
|
1301
1328
|
|
|
@@ -1318,6 +1345,12 @@ export const robotImport = z
|
|
|
1318
1345
|
value === true ? ['meta', 'import', 'execute'] : value === false ? [] : value,
|
|
1319
1346
|
)
|
|
1320
1347
|
.default([]),
|
|
1348
|
+
import_on_errors: z
|
|
1349
|
+
.array(z.enum(['meta']))
|
|
1350
|
+
.default([])
|
|
1351
|
+
.describe(`
|
|
1352
|
+
Setting this to \`["meta"]\` will still import the file on metadata extraction errors. \`ignore_errors\` is similar, it also ignores the error and makes sure the Robot doesn't stop, but it doesn't import the file.
|
|
1353
|
+
`),
|
|
1321
1354
|
})
|
|
1322
1355
|
.strict()
|
|
1323
1356
|
|
|
@@ -1810,7 +1843,7 @@ Splits the video into multiple chunks so that each chunk can be encoded in paral
|
|
|
1810
1843
|
Allows you to specify the duration of each chunk when \`turbo\` is set to \`true\`. This means you can take advantage of that feature while using fewer <dfn>Priority Job Slots</dfn>. For instance, the longer each chunk is, the fewer <dfn>Encoding Jobs</dfn> will need to be used.
|
|
1811
1844
|
`),
|
|
1812
1845
|
watermark_url: z
|
|
1813
|
-
.
|
|
1846
|
+
.union([z.literal(''), httpUrlSchema])
|
|
1814
1847
|
.default('')
|
|
1815
1848
|
.describe(`
|
|
1816
1849
|
A URL indicating a PNG image to be overlaid above this image. You can also [supply the watermark via another Assembly Step](/docs/topics/use-parameter/#supplying-the-watermark-via-an-assembly-step).
|