transloadit 5.2.0 → 6.0.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/dist/Transloadit.d.ts +1 -1
- package/dist/Transloadit.d.ts.map +1 -1
- package/dist/Transloadit.js +1 -0
- package/dist/Transloadit.js.map +1 -1
- package/dist/alphalib/aiMessages.d.ts +1 -1
- package/dist/alphalib/aiMessages.d.ts.map +1 -1
- package/dist/alphalib/aiMessages.js +1 -1
- package/dist/alphalib/aiMessages.js.map +1 -1
- package/dist/alphalib/types/assemblyStatus.d.ts +682 -682
- package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -1
- package/dist/alphalib/types/assemblyStatus.js +23 -14
- package/dist/alphalib/types/assemblyStatus.js.map +1 -1
- package/dist/alphalib/types/robots/_ai-models.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_ai-models.js +2 -0
- package/dist/alphalib/types/robots/_ai-models.js.map +1 -1
- package/dist/alphalib/types/robots/_google-image-seed.d.ts +8 -0
- package/dist/alphalib/types/robots/_google-image-seed.d.ts.map +1 -0
- package/dist/alphalib/types/robots/_google-image-seed.js +12 -0
- package/dist/alphalib/types/robots/_google-image-seed.js.map +1 -0
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts +2 -0
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.js +11 -14
- package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.d.ts +1 -1
- package/dist/alphalib/types/robots/ai-chat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.js.map +1 -1
- package/dist/alphalib/types/robots/google-import.d.ts +4 -6
- package/dist/alphalib/types/robots/google-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/google-import.js +5 -2
- package/dist/alphalib/types/robots/google-import.js.map +1 -1
- package/dist/alphalib/types/robots/google-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/google-store.js +5 -13
- package/dist/alphalib/types/robots/google-store.js.map +1 -1
- package/dist/alphalib/types/robots/http-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/http-import.js +4 -0
- package/dist/alphalib/types/robots/http-import.js.map +1 -1
- package/dist/alphalib/types/robots/image-generate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-generate.js +6 -1
- package/dist/alphalib/types/robots/image-generate.js.map +1 -1
- package/dist/alphalib/types/robots/image-resize.d.ts +4 -0
- package/dist/alphalib/types/robots/image-resize.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-resize.js +34 -6
- package/dist/alphalib/types/robots/image-resize.js.map +1 -1
- package/dist/alphalib/types/robots/s3-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/s3-store.js +21 -17
- package/dist/alphalib/types/robots/s3-store.js.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.d.ts +6 -0
- package/dist/alphalib/types/robots/video-thumbs.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.js +15 -5
- package/dist/alphalib/types/robots/video-thumbs.js.map +1 -1
- package/dist/alphalib/zodParseWithContext.d.ts +1 -1
- package/dist/alphalib/zodParseWithContext.d.ts.map +1 -1
- package/dist/bearerToken.d.ts +2 -0
- package/dist/bearerToken.d.ts.map +1 -1
- package/dist/bearerToken.js +2 -0
- package/dist/bearerToken.js.map +1 -1
- package/package.json +1 -1
- package/src/Transloadit.ts +2 -1
- package/src/alphalib/aiMessages.ts +1 -1
- package/src/alphalib/types/assemblyStatus.ts +24 -14
- package/src/alphalib/types/robots/_ai-models.ts +2 -0
- package/src/alphalib/types/robots/_google-image-seed.ts +14 -0
- package/src/alphalib/types/robots/_instructions-primitives.ts +13 -15
- package/src/alphalib/types/robots/ai-chat.ts +6 -7
- package/src/alphalib/types/robots/google-import.ts +7 -1
- package/src/alphalib/types/robots/google-store.ts +6 -11
- package/src/alphalib/types/robots/http-import.ts +4 -0
- package/src/alphalib/types/robots/image-generate.ts +8 -1
- package/src/alphalib/types/robots/image-resize.ts +36 -6
- package/src/alphalib/types/robots/s3-store.ts +21 -17
- package/src/alphalib/types/robots/video-thumbs.ts +19 -5
- package/src/alphalib/zodParseWithContext.ts +1 -1
- package/src/bearerToken.ts +5 -0
|
@@ -38,48 +38,54 @@ export const robotS3StoreInstructionsSchema = robotBase
|
|
|
38
38
|
.merge(robotUse)
|
|
39
39
|
.merge(s3Base)
|
|
40
40
|
.extend({
|
|
41
|
+
// URL rewriting does not fix bucket addressing, and custom paths need not use file.url_name.
|
|
42
|
+
// Keep the bucket warning separate from the old blanket filename-sanitization claim.
|
|
41
43
|
robot: z.literal('/s3/store').describe(`
|
|
42
44
|
If you are new to Amazon S3, see our tutorial on [using your own S3 bucket](/docs/faq/how-to-set-up-an-amazon-s3-bucket/).
|
|
43
45
|
|
|
44
|
-
The URL to the result file in your S3 bucket will be returned in the <dfn>Assembly Status JSON</dfn>. If your S3 bucket has versioning enabled, the version ID of the file will be returned within \`meta.version_id
|
|
46
|
+
The URL to the result file in your S3 bucket will be returned in the <dfn>Assembly Status JSON</dfn>. A returned URL does not make a private object public or grant read access. If your S3 bucket has versioning enabled, the version ID of the file will be returned within \`meta.version_id\`.
|
|
45
47
|
|
|
46
48
|
> [!Warning]
|
|
47
|
-
> **
|
|
49
|
+
> **Configure private buckets explicitly.** The Robot’s default \`acl\` is still \`"${s3StoreAclSchema.parse(undefined)}"\`. For a private bucket, set \`acl: "bucket-default"\` and do not supply ACL or grant headers. This omits the generated ACL header and works with [Bucket owner enforced Object Ownership](https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html), where ACLs are disabled. Keep S3 Block Public Access enabled. Setting \`acl: "private"\` still sends an ACL and is not equivalent to omitting it.
|
|
48
50
|
|
|
49
51
|
> [!Warning]
|
|
50
|
-
> **Use DNS-compliant bucket names.**
|
|
52
|
+
> **Use DNS-compliant bucket names.** Follow AWS’s [bucket naming rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html). The \`url_prefix\` parameter changes returned URLs; it does not change the bucket or its access permissions.
|
|
51
53
|
|
|
52
54
|
<span id="minimum-s3-iam-permissions" aria-hidden="true"></span>
|
|
53
55
|
|
|
54
56
|
## Limit access
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
Use a dedicated AWS identity with access limited to the destination bucket and object prefix. Do not use [AWS root access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/root-user-best-practices.html). Store its access key ID, secret access key, bucket name and region as \`key\`, \`secret\`, \`bucket\` and \`bucket_region\` in <dfn>Template Credentials</dfn>, then reference their name with \`credentials\`. Trusted backend integrations can instead supply those parameters directly; do not expose AWS secrets in browser instructions.
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
The following is an [identity-based IAM policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html), attached to that dedicated identity, not a bucket policy. It intentionally has no \`Principal\`. Replace \`{BUCKET_NAME}\` and use a Robot \`path\` beginning with \`uploads/\`, or adapt both the policy prefix and the path together.
|
|
61
|
+
|
|
62
|
+
This example covers uploads and failed multipart-upload cleanup with an explicit \`bucket_region\`, \`acl: "bucket-default"\`, no ACL/grant headers, no tags and S3-managed encryption (SSE-S3). Existing bucket policies, organization controls or endpoint policies can still deny access.
|
|
59
63
|
|
|
60
64
|
\`\`\`json
|
|
61
65
|
{
|
|
62
66
|
"Version": "2012-10-17",
|
|
63
67
|
"Statement": [
|
|
64
68
|
{
|
|
65
|
-
"Sid": "
|
|
69
|
+
"Sid": "UploadAndAbortWithinPrefix",
|
|
66
70
|
"Effect": "Allow",
|
|
67
|
-
"Action": ["s3:
|
|
68
|
-
"Resource":
|
|
71
|
+
"Action": ["s3:PutObject", "s3:AbortMultipartUpload"],
|
|
72
|
+
"Resource": "arn:aws:s3:::{BUCKET_NAME}/uploads/*"
|
|
69
73
|
}
|
|
70
74
|
]
|
|
71
75
|
}
|
|
72
76
|
\`\`\`
|
|
73
77
|
|
|
74
|
-
The \`
|
|
78
|
+
The uploader uses either \`PutObject\` or \`CreateMultipartUpload\`, \`UploadPart\` and \`CompleteMultipartUpload\`; failed multipart uploads can trigger \`AbortMultipartUpload\`. AWS maps the successful upload operations to \`s3:PutObject\`. Write access can **overwrite an existing object key**; it is not add-only. Choose unique object paths and consider versioning for recovery.
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
Add permissions only for features you use, following AWS’s [operation permission reference](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-policy-actions.html):
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
- Without an explicit \`bucket_region\`, region discovery can require \`s3:GetBucketLocation\` and fallback \`s3:ListBucket\` on the bucket ARN, \`arn:aws:s3:::{BUCKET_NAME}\`, without an object suffix. Supplying the correct region avoids these discovery requests.
|
|
83
|
+
- ACL or grant headers require \`s3:PutObjectAcl\`; tags require \`s3:PutObjectTagging\` on the allowed object prefix. \`bucket-default\` does not remove ACL/grant headers you supply in \`headers\`.
|
|
84
|
+
- Downloading private results requires separate read authorization. Even a URL generated with \`sign_urls_for\` needs the signing identity to have the appropriate read permissions.
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
S3 applies its [bucket encryption configuration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/default-bucket-encryption.html) when no encryption override is sent. You can request SSE-KMS through \`headers\`, using \`x-amz-server-side-encryption: aws:kms\` and \`x-amz-server-side-encryption-aws-kms-key-id\`. When either bucket default encryption or request headers select [SSE-KMS](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html), the uploading identity needs \`kms:GenerateDataKey\` on the relevant key, plus \`kms:Decrypt\` for multipart uploads. For a customer-managed key, grant these permissions with a compatible KMS key policy; the base S3 policy above does not include them. Do not add blanket \`kms:*\` or \`sts:*\` grants.
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
Short-lived AWS credentials are a matching set of \`key\`, \`secret\` and \`session_token\`. Have a trusted backend obtain and refresh all three, then supply them together when it creates the Assembly. It can pass them directly in Robot instructions or save and update them together through the [Template Credentials API](/docs/api/template-credentials-post/). Keep all three out of browser instructions; replacing only the session token does not refresh expired access keys. This Robot passes the supplied credentials to S3; it does not assume a role or refresh expired credentials. Keep temporary credentials valid for the upload.
|
|
83
89
|
`),
|
|
84
90
|
path: storeFilePath,
|
|
85
91
|
url_prefix: z
|
|
@@ -89,9 +95,7 @@ Please keep in mind that if you use bucket encryption you may also need to add \
|
|
|
89
95
|
The URL prefix used for the returned URL, such as \`"http://my.cdn.com/some/path/"\`.
|
|
90
96
|
`),
|
|
91
97
|
acl: s3StoreAclSchema.describe(`
|
|
92
|
-
The
|
|
93
|
-
|
|
94
|
-
Please keep in mind that the default value \`"${s3StoreAclSchema.parse(undefined)}"\` can lead to permission errors due to the \`"Block all public access"\` checkbox that is checked by default when creating a new Amazon S3 Bucket in the AWS console.
|
|
98
|
+
The ACL used for this file. The default remains \`"${s3StoreAclSchema.parse(undefined)}"\`, which can conflict with S3 Block Public Access and disabled ACLs. For modern private buckets, explicitly set \`"bucket-default"\` to omit the generated ACL header, and do not supply ACL/grant headers in \`headers\`. \`"private"\` still sends an ACL.
|
|
95
99
|
`),
|
|
96
100
|
check_integrity: z
|
|
97
101
|
.boolean()
|
|
@@ -139,7 +143,7 @@ This parameter provides signed URLs in the result JSON (in the \`signed_url\` an
|
|
|
139
143
|
.string()
|
|
140
144
|
.optional()
|
|
141
145
|
.describe(`
|
|
142
|
-
The session token to
|
|
146
|
+
The session token belonging to the temporary AWS access key ID and secret access key supplied for this upload. The Robot does not assume a role or refresh these credentials; they must remain valid for the upload.
|
|
143
147
|
`),
|
|
144
148
|
})
|
|
145
149
|
.strict()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MODEL_CAPABILITIES } from './_ai-models.ts'
|
|
1
2
|
import type {
|
|
2
3
|
RobotDefinition,
|
|
3
4
|
RobotMetaInput,
|
|
@@ -22,6 +23,15 @@ import {
|
|
|
22
23
|
/** Markup over the AI provider cost for smart thumbnail selection. */
|
|
23
24
|
export const smartThumbnailMarkupPercent = 50
|
|
24
25
|
|
|
26
|
+
/** Dedicated vision model so /ai/chat default upgrades do not change thumbnail analysis costs. */
|
|
27
|
+
export const smartThumbnailModel = 'openai/gpt-5.4-mini' satisfies keyof typeof MODEL_CAPABILITIES
|
|
28
|
+
|
|
29
|
+
/** Maximum long-side dimension of scoring previews; returned thumbnails keep their output size. */
|
|
30
|
+
export const smartThumbnailAnalysisMaxSize = 512
|
|
31
|
+
|
|
32
|
+
/** Frame ranking needs little reasoning compared with general-purpose chat. */
|
|
33
|
+
export const smartThumbnailReasoningEffort = 'low'
|
|
34
|
+
|
|
25
35
|
const thumbnailCountSchema = z.number().int().min(1).max(999).default(8)
|
|
26
36
|
const smartMaximumCandidatesSchema = z.number().int().min(2).max(100).default(20)
|
|
27
37
|
const defaultThumbnailCount = thumbnailCountSchema.parse(undefined)
|
|
@@ -58,13 +68,15 @@ export const robotVideoThumbsInstructionsSchema = robotBase
|
|
|
58
68
|
.merge(robotFFmpeg)
|
|
59
69
|
.extend({
|
|
60
70
|
robot: z.literal('/video/thumbs').describe(`
|
|
61
|
-
Set \`smart: true\` to select strong preview images with AI instead of taking frames only at regular intervals. The Robot scores candidate frames for clarity, brightness, composition, faces, expressions, action, and visual interest, then returns the best \`count\` frames in chronological order. Smart results include \`file.meta.smart_score\` and \`file.meta.smart_reasons\`. If AI scoring is unavailable, the Assembly continues with the candidate frames in fallback order. No AI credentials are required.
|
|
71
|
+
Set \`smart: true\` to select strong preview images with AI instead of taking frames only at regular intervals. The Robot scores candidate frames for clarity, brightness, composition, faces, expressions, action, and visual interest, then returns the best \`count\` frames in chronological order. Smart results include \`file.meta.smart_score\` and \`file.meta.smart_reasons\`. If AI scoring is unavailable, the Assembly continues with the candidate frames in fallback order and includes a warning. No AI credentials are required.
|
|
62
72
|
|
|
63
73
|
## AI pricing
|
|
64
74
|
|
|
65
|
-
Regular \`/video/thumbs\` processing charges still apply. AI frame analysis is billed separately at the underlying provider cost plus a ${smartThumbnailMarkupPercent}% Transloadit markup. The exact AI charge varies with the number of candidate frames
|
|
75
|
+
Regular \`/video/thumbs\` processing charges still apply. AI frame analysis is billed separately at the underlying provider cost plus a ${smartThumbnailMarkupPercent}% Transloadit markup. Smart selection uses the dedicated \`${smartThumbnailModel}\` vision model with \`${smartThumbnailReasoningEffort}\` reasoning, independently of the \`/ai/chat\` default. The exact AI charge varies with the number of candidate frames and provider pricing.
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
The AI scores preview copies capped at ${smartThumbnailAnalysisMaxSize} pixels on the long side, preserving aspect ratio and without enlarging smaller images. Returned thumbnails keep the requested output dimensions and format; larger outputs do not increase the scoring preview beyond this limit.
|
|
78
|
+
|
|
79
|
+
\`smart_max_candidates\` is the main cost and latency control. The Robot analyzes up to three candidates per requested thumbnail, capped by \`smart_max_candidates\`, but never fewer than \`count\`. With the defaults of \`count: ${defaultThumbnailCount}\` and \`smart_max_candidates: ${defaultSmartMaximumCandidates}\`, it analyzes ${getSmartThumbnailCandidateCount(defaultThumbnailCount, defaultSmartMaximumCandidates)} frames and returns the best ${defaultThumbnailCount}. Lower the candidate limit to reduce AI cost and latency. Raising it can enlarge the pool up to three times \`count\`; higher limits have no effect.
|
|
68
80
|
|
|
69
81
|
> [!Note]
|
|
70
82
|
> Use \`count\` with smart selection. To consistently extract exact timestamps with \`offsets\`, set \`smart: false\`.
|
|
@@ -146,17 +158,19 @@ The AI evaluates frames based on:
|
|
|
146
158
|
- Action and motion (avoiding transition frames)
|
|
147
159
|
- Overall visual interest
|
|
148
160
|
|
|
149
|
-
Regular \`/video/thumbs\` processing charges still apply. AI frame analysis is billed separately at the underlying provider cost plus a ${smartThumbnailMarkupPercent}% Transloadit markup. You do not need to provide AI credentials.
|
|
161
|
+
Regular \`/video/thumbs\` processing charges still apply. AI frame analysis uses a dedicated low-cost vision model with \`${smartThumbnailReasoningEffort}\` reasoning and preview copies capped at ${smartThumbnailAnalysisMaxSize} pixels on the long side. Returned thumbnails retain their requested dimensions and format. Analysis is billed separately at the underlying provider cost plus a ${smartThumbnailMarkupPercent}% Transloadit markup. You do not need to provide AI credentials.
|
|
150
162
|
|
|
151
163
|
Smart mode generates its own regularly spaced candidate timestamps; use \`smart: false\` with \`offsets\` when you need specified timestamps. Selected smart thumbnails are returned in chronological order, not score order. Inspect \`meta.thumb_offset\`, \`meta.smart_score\`, and \`meta.smart_reasons\` when evaluating the selection.
|
|
152
164
|
|
|
153
|
-
If AI scoring fails, the Robot selects
|
|
165
|
+
If AI scoring fails, the Robot selects extracted candidates in chronological order and records a fallback reason. With no candidates, it attempts standard extraction. Both fallbacks add an Assembly warning. A completed Assembly does not guarantee a representative or publication-safe poster; check that outputs exist and apply your application’s review policy.
|
|
154
166
|
`),
|
|
155
167
|
smart_max_candidates: smartMaximumCandidatesSchema.describe(`
|
|
156
168
|
The maximum size of the candidate pool when \`smart\` is \`true\`. The Robot analyzes up to three candidates per requested thumbnail, capped by this value, but it will never analyze fewer candidates than the requested \`count\`.
|
|
157
169
|
|
|
158
170
|
A higher number may yield better results but increases processing time and AI cost. With the defaults of \`count: ${defaultThumbnailCount}\` and \`smart_max_candidates: ${defaultSmartMaximumCandidates}\`, the Robot analyzes ${getSmartThumbnailCandidateCount(defaultThumbnailCount, defaultSmartMaximumCandidates)} frames and returns the best ${defaultThumbnailCount} in chronological order.
|
|
159
171
|
|
|
172
|
+
Raising this limit above three times \`count\` does not enlarge the pool. For example, \`count: 1\` analyzes at most three candidates.
|
|
173
|
+
|
|
160
174
|
This parameter is only used when \`smart\` is \`true\`.
|
|
161
175
|
`),
|
|
162
176
|
})
|
package/src/bearerToken.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
+
import packageJson from '../package.json' with { type: 'json' }
|
|
4
|
+
|
|
3
5
|
export type BearerTokenAudience = 'mcp' | 'api2' | (string & {})
|
|
4
6
|
|
|
5
7
|
export type BearerTokenResponse = {
|
|
@@ -11,6 +13,8 @@ export type BearerTokenResponse = {
|
|
|
11
13
|
|
|
12
14
|
export type MintBearerTokenOptions = {
|
|
13
15
|
allowProcessEnvEndpointFallback?: boolean
|
|
16
|
+
/** Client identity reported in the Transloadit-Client header. */
|
|
17
|
+
clientName?: string
|
|
14
18
|
endpoint?: string
|
|
15
19
|
aud?: BearerTokenAudience | string
|
|
16
20
|
/**
|
|
@@ -158,6 +162,7 @@ export async function mintBearerTokenWithCredentials(
|
|
|
158
162
|
Authorization: buildBasicAuthHeaderValue(credentials),
|
|
159
163
|
Accept: 'application/json',
|
|
160
164
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
165
|
+
'Transloadit-Client': options.clientName?.trim() || `node-sdk:${packageJson.version}`,
|
|
161
166
|
},
|
|
162
167
|
body: params.toString(),
|
|
163
168
|
})
|