transloadit 4.12.0 → 4.13.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 +232 -23
- package/dist/Transloadit.d.ts +55 -1
- package/dist/Transloadit.d.ts.map +1 -1
- package/dist/Transloadit.js +143 -2
- package/dist/Transloadit.js.map +1 -1
- package/dist/alphalib/types/assemblyStatus.d.ts +574 -198
- package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -1
- package/dist/alphalib/types/assemblyStatus.js +17 -0
- package/dist/alphalib/types/assemblyStatus.js.map +1 -1
- package/dist/alphalib/types/robots/_index.d.ts +205 -93
- package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_index.js +8 -0
- package/dist/alphalib/types/robots/_index.js.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts +4 -4
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.js +2 -0
- package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
- package/dist/alphalib/types/robots/file-serve.d.ts +12 -0
- package/dist/alphalib/types/robots/file-serve.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-serve.js +9 -3
- package/dist/alphalib/types/robots/file-serve.js.map +1 -1
- package/dist/alphalib/types/robots/transloadit-import.d.ts +195 -0
- package/dist/alphalib/types/robots/transloadit-import.d.ts.map +1 -0
- package/dist/alphalib/types/robots/transloadit-import.js +108 -0
- package/dist/alphalib/types/robots/transloadit-import.js.map +1 -0
- package/dist/alphalib/types/robots/transloadit-store.d.ts +441 -0
- package/dist/alphalib/types/robots/transloadit-store.d.ts.map +1 -0
- package/dist/alphalib/types/robots/transloadit-store.js +69 -0
- package/dist/alphalib/types/robots/transloadit-store.js.map +1 -0
- package/dist/alphalib/types/robots/video-ondemand.d.ts +8 -8
- package/dist/alphalib/types/storageAsset.d.ts +226 -0
- package/dist/alphalib/types/storageAsset.d.ts.map +1 -0
- package/dist/alphalib/types/storageAsset.js +67 -0
- package/dist/alphalib/types/storageAsset.js.map +1 -0
- package/dist/alphalib/types/template.d.ts.map +1 -1
- package/dist/alphalib/types/template.js +5 -2
- package/dist/alphalib/types/template.js.map +1 -1
- package/dist/cli/commands/BaseCommand.d.ts +3 -1
- package/dist/cli/commands/BaseCommand.d.ts.map +1 -1
- package/dist/cli/commands/BaseCommand.js +3 -2
- package/dist/cli/commands/BaseCommand.js.map +1 -1
- package/dist/cli/commands/assemblies.d.ts.map +1 -1
- package/dist/cli/commands/assemblies.js +9 -4
- package/dist/cli/commands/assemblies.js.map +1 -1
- package/dist/cli/commands/auth.d.ts +6 -0
- package/dist/cli/commands/auth.d.ts.map +1 -1
- package/dist/cli/commands/auth.js +21 -2
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/image.d.ts +15 -0
- package/dist/cli/commands/image.d.ts.map +1 -0
- package/dist/cli/commands/image.js +234 -0
- package/dist/cli/commands/image.js.map +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +15 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/login.d.ts +24 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +275 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/storage.d.ts +58 -0
- package/dist/cli/commands/storage.d.ts.map +1 -0
- package/dist/cli/commands/storage.js +589 -0
- package/dist/cli/commands/storage.js.map +1 -0
- package/dist/cli/commands/templates.d.ts.map +1 -1
- package/dist/cli/commands/templates.js +10 -6
- package/dist/cli/commands/templates.js.map +1 -1
- package/dist/cli/deviceLogin.d.ts +11 -0
- package/dist/cli/deviceLogin.d.ts.map +1 -0
- package/dist/cli/deviceLogin.js +187 -0
- package/dist/cli/deviceLogin.js.map +1 -0
- package/dist/cli/helpers.d.ts +23 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/helpers.js +159 -25
- package/dist/cli/helpers.js.map +1 -1
- package/dist/cli/secretInput.d.ts +3 -0
- package/dist/cli/secretInput.d.ts.map +1 -0
- package/dist/cli/secretInput.js +11 -0
- package/dist/cli/secretInput.js.map +1 -0
- package/dist/cli/storageCatalog.d.ts +19 -0
- package/dist/cli/storageCatalog.d.ts.map +1 -0
- package/dist/cli/storageCatalog.js +129 -0
- package/dist/cli/storageCatalog.js.map +1 -0
- package/dist/cli/storagePublic.d.ts +3 -0
- package/dist/cli/storagePublic.d.ts.map +1 -0
- package/dist/cli/storagePublic.js +15 -0
- package/dist/cli/storagePublic.js.map +1 -0
- package/dist/cli/storageReceipts.d.ts +67 -0
- package/dist/cli/storageReceipts.d.ts.map +1 -0
- package/dist/cli/storageReceipts.js +242 -0
- package/dist/cli/storageReceipts.js.map +1 -0
- package/dist/cli/storageSnippets.d.ts +11 -0
- package/dist/cli/storageSnippets.d.ts.map +1 -0
- package/dist/cli/storageSnippets.js +89 -0
- package/dist/cli/storageSnippets.js.map +1 -0
- package/dist/storageImage.d.ts +40 -0
- package/dist/storageImage.d.ts.map +1 -0
- package/dist/storageImage.js +139 -0
- package/dist/storageImage.js.map +1 -0
- package/dist/storagePublicPrefixes.d.ts +62 -0
- package/dist/storagePublicPrefixes.d.ts.map +1 -0
- package/dist/storagePublicPrefixes.js +35 -0
- package/dist/storagePublicPrefixes.js.map +1 -0
- package/dist/storageResults.d.ts +31 -0
- package/dist/storageResults.d.ts.map +1 -0
- package/dist/storageResults.js +79 -0
- package/dist/storageResults.js.map +1 -0
- package/package.json +4 -3
- package/src/Transloadit.ts +251 -4
- package/src/alphalib/types/assemblyStatus.ts +17 -0
- package/src/alphalib/types/robots/_index.ts +28 -0
- package/src/alphalib/types/robots/_instructions-primitives.ts +2 -0
- package/src/alphalib/types/robots/file-serve.ts +11 -3
- package/src/alphalib/types/robots/transloadit-import.ts +154 -0
- package/src/alphalib/types/robots/transloadit-store.ts +98 -0
- package/src/alphalib/types/storageAsset.ts +88 -0
- package/src/alphalib/types/template.ts +3 -0
- package/src/cli/commands/BaseCommand.ts +4 -2
- package/src/cli/commands/assemblies.ts +13 -5
- package/src/cli/commands/auth.ts +26 -3
- package/src/cli/commands/image.ts +282 -0
- package/src/cli/commands/index.ts +27 -1
- package/src/cli/commands/login.ts +334 -0
- package/src/cli/commands/storage.ts +733 -0
- package/src/cli/commands/templates.ts +14 -7
- package/src/cli/deviceLogin.ts +226 -0
- package/src/cli/helpers.ts +204 -27
- package/src/cli/secretInput.ts +12 -0
- package/src/cli/storageCatalog.ts +192 -0
- package/src/cli/storagePublic.ts +15 -0
- package/src/cli/storageReceipts.ts +307 -0
- package/src/cli/storageSnippets.ts +96 -0
- package/src/storageImage.ts +222 -0
- package/src/storagePublicPrefixes.ts +39 -0
- package/src/storageResults.ts +119 -0
|
@@ -66,11 +66,11 @@ Also consider configuring caching headers and cache-control directives to contro
|
|
|
66
66
|
You can leverage [signed Smart CDN URLs](/docs/api/authentication/#smart-cdn) to avoid abuse of our encoding platform. Below is a quick Node.js example using our Node SDK, but there are [examples for other languages and SDKs](/docs/api/authentication/#example-code) as well.
|
|
67
67
|
|
|
68
68
|
\`\`\`javascript
|
|
69
|
-
// yarn add transloadit
|
|
69
|
+
// yarn add @transloadit/node
|
|
70
70
|
// or
|
|
71
|
-
// npm install --save transloadit
|
|
71
|
+
// npm install --save @transloadit/node
|
|
72
72
|
|
|
73
|
-
import { Transloadit } from 'transloadit'
|
|
73
|
+
import { Transloadit } from '@transloadit/node'
|
|
74
74
|
|
|
75
75
|
const transloadit = new Transloadit({
|
|
76
76
|
authKey: 'YOUR_TRANSLOADIT_KEY',
|
|
@@ -108,6 +108,14 @@ An optional duration in seconds that the served file should be cached. When set,
|
|
|
108
108
|
|
|
109
109
|
This is useful for controlling data retention in CDNs. For instance, if your temporary files are deleted after 24 hours, you can set \`cache_duration\` to \`86400\` to ensure cached copies also expire within that window.
|
|
110
110
|
`),
|
|
111
|
+
download_name: z
|
|
112
|
+
.string()
|
|
113
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: reject header-injection control characters, not literal text.
|
|
114
|
+
.regex(/^[^/\\\u0000-\u001f\u007f-\u009f]{0,255}$/u)
|
|
115
|
+
.optional()
|
|
116
|
+
.describe(
|
|
117
|
+
'Serve as an attachment using this Unicode filename. Empty or omitted keeps inline delivery. Overrides a Content-Disposition header without changing the bytes or Range support.',
|
|
118
|
+
),
|
|
111
119
|
headers: z
|
|
112
120
|
.record(z.string())
|
|
113
121
|
.default({
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { RobotMetaInput } from './_instructions-primitives.ts'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { damIdSchema } from '../storageAsset.ts'
|
|
6
|
+
import {
|
|
7
|
+
booleanStringSchema,
|
|
8
|
+
interpolateRobot,
|
|
9
|
+
interpolationSchemaFull,
|
|
10
|
+
recursive,
|
|
11
|
+
robotBase,
|
|
12
|
+
robotImport,
|
|
13
|
+
} from './_instructions-primitives.ts'
|
|
14
|
+
|
|
15
|
+
/** Cross-field validation runs after interpolation-aware parsing at the Assembly Step boundary. */
|
|
16
|
+
export function refineTransloaditImportSelector(
|
|
17
|
+
step: {
|
|
18
|
+
robot: string
|
|
19
|
+
path?: unknown
|
|
20
|
+
asset_id?: unknown
|
|
21
|
+
version_id?: unknown
|
|
22
|
+
recursive?: unknown
|
|
23
|
+
},
|
|
24
|
+
context: z.RefinementCtx,
|
|
25
|
+
): void {
|
|
26
|
+
if (step.robot !== '/transloadit/import') return
|
|
27
|
+
const hasPath = step.path !== undefined
|
|
28
|
+
const hasAsset = step.asset_id !== undefined
|
|
29
|
+
if (hasPath === hasAsset || (step.version_id !== undefined && !hasAsset)) {
|
|
30
|
+
context.addIssue({
|
|
31
|
+
code: z.ZodIssueCode.custom,
|
|
32
|
+
path: [step.version_id !== undefined && !hasAsset ? 'version_id' : 'asset_id'],
|
|
33
|
+
message: 'Select either path, or asset_id with an optional version_id.',
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
if (hasAsset && step.recursive === true) {
|
|
37
|
+
context.addIssue({
|
|
38
|
+
code: z.ZodIssueCode.custom,
|
|
39
|
+
path: ['recursive'],
|
|
40
|
+
message: 'Recursive imports require a path, not an asset_id.',
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const recursiveDescription = `
|
|
46
|
+
Whether to import files from subfolders and sub-subfolders when \`path\` is a folder. By default
|
|
47
|
+
only the folder's own files are imported.
|
|
48
|
+
`
|
|
49
|
+
|
|
50
|
+
export const meta: RobotMetaInput = {
|
|
51
|
+
bytescount: 10,
|
|
52
|
+
discount_factor: 0.1,
|
|
53
|
+
discount_pct: 90,
|
|
54
|
+
example_code: {
|
|
55
|
+
steps: {
|
|
56
|
+
imported: {
|
|
57
|
+
robot: '/transloadit/import',
|
|
58
|
+
path: 'photos/cat.jpg',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
example_code_description: 'Import a file from Transloadit Storage:',
|
|
63
|
+
has_small_icon: true,
|
|
64
|
+
isAllowedForUrlTransform: true,
|
|
65
|
+
isInternal: false,
|
|
66
|
+
minimum_charge: 0,
|
|
67
|
+
name: 'TransloaditImportRobot',
|
|
68
|
+
output_factor: 1,
|
|
69
|
+
override_lvl1: 'File Importing',
|
|
70
|
+
priceFactor: 10,
|
|
71
|
+
purpose_sentence: 'imports files from Transloadit Storage',
|
|
72
|
+
purpose_verb: 'import',
|
|
73
|
+
purpose_word: 'Transloadit Storage',
|
|
74
|
+
purpose_words: 'Import files from Transloadit Storage',
|
|
75
|
+
queueSlotCount: 10,
|
|
76
|
+
removeJobResultFilesFromDiskRightAfterStoringOnS3: true,
|
|
77
|
+
service_slug: 'file-importing',
|
|
78
|
+
slot_count: 10,
|
|
79
|
+
stage: 'beta',
|
|
80
|
+
title: 'Import files from Transloadit Storage',
|
|
81
|
+
typical_file_size_mb: 1.2,
|
|
82
|
+
typical_file_type: 'file',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const robotTransloaditImportInstructionsSchema = robotBase
|
|
86
|
+
.merge(robotImport)
|
|
87
|
+
.extend({
|
|
88
|
+
robot: z.literal('/transloadit/import').describe(`
|
|
89
|
+
Imports files from your Workspace's Transloadit Storage. Select a mutable location with
|
|
90
|
+
\`path\`, or a logical asset with \`asset_id\`. Add \`version_id\` to pin the exact stored bytes.
|
|
91
|
+
IDs remain subject to Workspace access and version retention.
|
|
92
|
+
`),
|
|
93
|
+
path: z
|
|
94
|
+
.string()
|
|
95
|
+
.optional()
|
|
96
|
+
.describe(`
|
|
97
|
+
The current file or folder location, for example \`photos/cat.jpg\`. Use either \`path\` or
|
|
98
|
+
\`asset_id\`, not both. Renaming makes an old path stale; overwriting changes what it imports.
|
|
99
|
+
`),
|
|
100
|
+
asset_id: damIdSchema.optional().describe(`
|
|
101
|
+
The stored asset's stable ID. Without \`version_id\`, imports its current version even after
|
|
102
|
+
renaming or moving it. Cannot be combined with \`path\` or recursive folder imports.
|
|
103
|
+
`),
|
|
104
|
+
version_id: damIdSchema.optional().describe(`
|
|
105
|
+
The exact retained version of \`asset_id\` to import. Requires \`asset_id\`; a missing or deleted
|
|
106
|
+
version never falls back to the current version.
|
|
107
|
+
`),
|
|
108
|
+
recursive: recursive.describe(recursiveDescription),
|
|
109
|
+
})
|
|
110
|
+
.strict()
|
|
111
|
+
|
|
112
|
+
export const robotTransloaditImportInstructionsWithHiddenFieldsSchema =
|
|
113
|
+
robotTransloaditImportInstructionsSchema.extend({
|
|
114
|
+
result: z
|
|
115
|
+
.union([z.literal('debug'), robotTransloaditImportInstructionsSchema.shape.result])
|
|
116
|
+
.optional(),
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
export type RobotTransloaditImportInstructions = z.infer<
|
|
120
|
+
typeof robotTransloaditImportInstructionsSchema
|
|
121
|
+
>
|
|
122
|
+
export type RobotTransloaditImportInstructionsWithHiddenFields = z.infer<
|
|
123
|
+
typeof robotTransloaditImportInstructionsWithHiddenFieldsSchema
|
|
124
|
+
>
|
|
125
|
+
|
|
126
|
+
export const interpolatableRobotTransloaditImportInstructionsSchema = interpolateRobot(
|
|
127
|
+
robotTransloaditImportInstructionsSchema,
|
|
128
|
+
).extend({
|
|
129
|
+
// The generic boolean interpolator changes literal false to true. Keep Storage's documented
|
|
130
|
+
// false default intact; unresolved variables are validated after uploader interpolation.
|
|
131
|
+
recursive: z
|
|
132
|
+
.union([
|
|
133
|
+
recursive,
|
|
134
|
+
booleanStringSchema.transform((value) => value === 'true'),
|
|
135
|
+
interpolationSchemaFull,
|
|
136
|
+
])
|
|
137
|
+
.describe(recursiveDescription),
|
|
138
|
+
})
|
|
139
|
+
export type InterpolatableRobotTransloaditImportInstructions =
|
|
140
|
+
InterpolatableRobotTransloaditImportInstructionsInput
|
|
141
|
+
|
|
142
|
+
export type InterpolatableRobotTransloaditImportInstructionsInput = z.input<
|
|
143
|
+
typeof interpolatableRobotTransloaditImportInstructionsSchema
|
|
144
|
+
>
|
|
145
|
+
|
|
146
|
+
export const interpolatableRobotTransloaditImportInstructionsWithHiddenFieldsSchema =
|
|
147
|
+
interpolateRobot(robotTransloaditImportInstructionsWithHiddenFieldsSchema).extend({
|
|
148
|
+
recursive: interpolatableRobotTransloaditImportInstructionsSchema.shape.recursive,
|
|
149
|
+
})
|
|
150
|
+
export type InterpolatableRobotTransloaditImportInstructionsWithHiddenFields =
|
|
151
|
+
InterpolatableRobotTransloaditImportInstructionsWithHiddenFieldsInput
|
|
152
|
+
export type InterpolatableRobotTransloaditImportInstructionsWithHiddenFieldsInput = z.input<
|
|
153
|
+
typeof interpolatableRobotTransloaditImportInstructionsWithHiddenFieldsSchema
|
|
154
|
+
>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { RobotMetaInput } from './_instructions-primitives.ts'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { interpolateRobot, robotBase, robotUse } from './_instructions-primitives.ts'
|
|
6
|
+
|
|
7
|
+
export const meta: RobotMetaInput = {
|
|
8
|
+
bytescount: 10,
|
|
9
|
+
discount_factor: 0.1,
|
|
10
|
+
discount_pct: 90,
|
|
11
|
+
example_code: {
|
|
12
|
+
steps: {
|
|
13
|
+
stored: {
|
|
14
|
+
robot: '/transloadit/store',
|
|
15
|
+
use: ':original',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
example_code_description: 'Store uploaded files in Transloadit Storage:',
|
|
20
|
+
has_small_icon: true,
|
|
21
|
+
isAllowedForUrlTransform: false,
|
|
22
|
+
isInternal: false,
|
|
23
|
+
minimum_charge: 0,
|
|
24
|
+
name: 'TransloaditStoreRobot',
|
|
25
|
+
output_factor: 1,
|
|
26
|
+
override_lvl1: 'File Exporting',
|
|
27
|
+
priceFactor: 10,
|
|
28
|
+
purpose_sentence: 'stores files privately in Transloadit Storage',
|
|
29
|
+
purpose_verb: 'export',
|
|
30
|
+
purpose_word: 'Transloadit Storage',
|
|
31
|
+
purpose_words: 'Store files in Transloadit Storage',
|
|
32
|
+
queueSlotCount: 2,
|
|
33
|
+
removeJobResultFilesFromDiskRightAfterStoringOnS3: false,
|
|
34
|
+
service_slug: 'file-exporting',
|
|
35
|
+
slot_count: 2,
|
|
36
|
+
stage: 'beta',
|
|
37
|
+
title: 'Store files in Transloadit Storage',
|
|
38
|
+
trackOutputFileSize: true,
|
|
39
|
+
typical_file_size_mb: 1.2,
|
|
40
|
+
typical_file_type: 'file',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const robotTransloaditStoreInstructionsSchema = robotBase
|
|
44
|
+
.merge(robotUse)
|
|
45
|
+
.extend({
|
|
46
|
+
robot: z.literal('/transloadit/store').describe(`
|
|
47
|
+
Stores each input privately in Transloadit Storage.
|
|
48
|
+
`),
|
|
49
|
+
conflict_strategy: z
|
|
50
|
+
.enum(['error', 'overwrite', 'rename'])
|
|
51
|
+
.default('error')
|
|
52
|
+
.describe(`
|
|
53
|
+
Chooses how to handle an existing destination. By default, an occupied path fails. Select
|
|
54
|
+
\`rename\` to allocate a different filename, or \`overwrite\` to create a new version of the
|
|
55
|
+
existing asset. Always save the returned asset identity, version and final path.
|
|
56
|
+
`),
|
|
57
|
+
path: z
|
|
58
|
+
.string()
|
|
59
|
+
.default('${file.url_name}')
|
|
60
|
+
.describe(`
|
|
61
|
+
Sets the destination path inside your Transloadit Storage workspace, relative to its root: a
|
|
62
|
+
filename, or folders and a filename such as \`website/hero.jpg\`. Folders that do not exist yet
|
|
63
|
+
are created.
|
|
64
|
+
`),
|
|
65
|
+
})
|
|
66
|
+
.strict()
|
|
67
|
+
|
|
68
|
+
export const robotTransloaditStoreInstructionsWithHiddenFieldsSchema =
|
|
69
|
+
robotTransloaditStoreInstructionsSchema.extend({
|
|
70
|
+
result: z
|
|
71
|
+
.union([z.literal('debug'), robotTransloaditStoreInstructionsSchema.shape.result])
|
|
72
|
+
.optional(),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
export type RobotTransloaditStoreInstructions = z.infer<
|
|
76
|
+
typeof robotTransloaditStoreInstructionsSchema
|
|
77
|
+
>
|
|
78
|
+
export type RobotTransloaditStoreInstructionsWithHiddenFields = z.infer<
|
|
79
|
+
typeof robotTransloaditStoreInstructionsWithHiddenFieldsSchema
|
|
80
|
+
>
|
|
81
|
+
|
|
82
|
+
export const interpolatableRobotTransloaditStoreInstructionsSchema = interpolateRobot(
|
|
83
|
+
robotTransloaditStoreInstructionsSchema,
|
|
84
|
+
)
|
|
85
|
+
export type InterpolatableRobotTransloaditStoreInstructions =
|
|
86
|
+
InterpolatableRobotTransloaditStoreInstructionsInput
|
|
87
|
+
|
|
88
|
+
export type InterpolatableRobotTransloaditStoreInstructionsInput = z.input<
|
|
89
|
+
typeof interpolatableRobotTransloaditStoreInstructionsSchema
|
|
90
|
+
>
|
|
91
|
+
|
|
92
|
+
export const interpolatableRobotTransloaditStoreInstructionsWithHiddenFieldsSchema =
|
|
93
|
+
interpolateRobot(robotTransloaditStoreInstructionsWithHiddenFieldsSchema)
|
|
94
|
+
export type InterpolatableRobotTransloaditStoreInstructionsWithHiddenFields =
|
|
95
|
+
InterpolatableRobotTransloaditStoreInstructionsWithHiddenFieldsInput
|
|
96
|
+
export type InterpolatableRobotTransloaditStoreInstructionsWithHiddenFieldsInput = z.input<
|
|
97
|
+
typeof interpolatableRobotTransloaditStoreInstructionsWithHiddenFieldsSchema
|
|
98
|
+
>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
/** Maximum normalized Storage path length supported by the catalog schema. */
|
|
4
|
+
export const damPathMaxCodePoints = 512
|
|
5
|
+
|
|
6
|
+
// A Unicode regexp counts code points and stays portable across the published Zod 3/4 schemas.
|
|
7
|
+
const boundedPathSchema = z.string().regex(new RegExp(`^[\\s\\S]{0,${damPathMaxCodePoints}}$`, 'u'))
|
|
8
|
+
|
|
9
|
+
/** Canonical path and JSON representation of a 128-bit Storage identifier. */
|
|
10
|
+
export const damIdPattern = /^[A-Za-z0-9_-]{21}[AQgw]$/u
|
|
11
|
+
|
|
12
|
+
/** Canonical public Storage asset, version and folder identifier. */
|
|
13
|
+
export const damIdSchema = z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(damIdPattern)
|
|
16
|
+
.describe('Case-sensitive, canonical 22-character Base64URL Storage identifier.')
|
|
17
|
+
|
|
18
|
+
/** A retained version of a live Workspace asset, independent of its mutable location. */
|
|
19
|
+
export const storedAssetSchema = z.object({
|
|
20
|
+
workspace: z.string().min(1),
|
|
21
|
+
asset_id: damIdSchema,
|
|
22
|
+
version_id: damIdSchema,
|
|
23
|
+
path: z.string().min(1),
|
|
24
|
+
size: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
25
|
+
mime: z.string().nullable(),
|
|
26
|
+
md5hash: z
|
|
27
|
+
.string()
|
|
28
|
+
.regex(/^[a-f0-9]{32}$/u)
|
|
29
|
+
.optional(),
|
|
30
|
+
sha256: z
|
|
31
|
+
.string()
|
|
32
|
+
.regex(/^[a-f0-9]{64}$/u)
|
|
33
|
+
.optional(),
|
|
34
|
+
width: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
35
|
+
height: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
/** Store, read and recovery share this shape; image clients may enrich it with placeholders. */
|
|
39
|
+
export type StoredAsset = z.infer<typeof storedAssetSchema>
|
|
40
|
+
|
|
41
|
+
/** Bounded metadata paging; cursors are the last returned, case-sensitive asset path. */
|
|
42
|
+
export const damAssetsListOptionsSchema = z.object({
|
|
43
|
+
prefix: boundedPathSchema.default(''),
|
|
44
|
+
cursor: boundedPathSchema.min(1).optional(),
|
|
45
|
+
limit: z.number().int().min(1).max(500).default(100),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
/** An omitted version selects the current version; an explicit version never falls back. */
|
|
49
|
+
export const damAssetGetOptionsSchema = z.object({ version_id: damIdSchema.optional() })
|
|
50
|
+
|
|
51
|
+
/** Omit the destination to rename in place; null moves to the Workspace root. */
|
|
52
|
+
export const damAssetMoveOptionsSchema = z.object({
|
|
53
|
+
destination_folder_id: damIdSchema.nullable().optional(),
|
|
54
|
+
filename: z
|
|
55
|
+
.string()
|
|
56
|
+
.regex(/^[^/\\\p{Cc}]{1,255}$/u)
|
|
57
|
+
.refine(
|
|
58
|
+
(name) => name.trim() === name && name !== '.' && name !== '..',
|
|
59
|
+
'Use a filename, not a path',
|
|
60
|
+
)
|
|
61
|
+
.optional(),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export type MoveStoredAssetOptions = z.input<typeof damAssetMoveOptionsSchema>
|
|
65
|
+
|
|
66
|
+
/** Native metadata is the same version-pinned shape returned by storing a file. */
|
|
67
|
+
export const damAssetFoundResponseSchema = z
|
|
68
|
+
.object({
|
|
69
|
+
message: z.string().min(1),
|
|
70
|
+
ok: z.literal('DAM_ASSET_FOUND'),
|
|
71
|
+
asset: storedAssetSchema,
|
|
72
|
+
})
|
|
73
|
+
.strict()
|
|
74
|
+
|
|
75
|
+
/** A bounded catalog page; null means there is no next page, even in an empty Workspace. */
|
|
76
|
+
export const damAssetsListedResponseSchema = z
|
|
77
|
+
.object({
|
|
78
|
+
workspace: storedAssetSchema.shape.workspace,
|
|
79
|
+
message: z.string().min(1),
|
|
80
|
+
ok: z.literal('DAM_ASSETS_LISTED'),
|
|
81
|
+
assets: z.array(storedAssetSchema),
|
|
82
|
+
next_cursor: z.string().nullable(),
|
|
83
|
+
})
|
|
84
|
+
.strict()
|
|
85
|
+
|
|
86
|
+
export type StoredAssetsPage = z.infer<typeof damAssetsListedResponseSchema>
|
|
87
|
+
export type ListStoredAssetsOptions = z.input<typeof damAssetsListOptionsSchema>
|
|
88
|
+
export type GetStoredAssetOptions = z.input<typeof damAssetGetOptionsSchema>
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
RobotsWithHiddenBotsAndFields,
|
|
10
10
|
} from './robots/_index.ts'
|
|
11
11
|
import type { RobotUse } from './robots/_instructions-primitives.ts'
|
|
12
|
+
import { refineTransloaditImportSelector } from './robots/transloadit-import.ts'
|
|
12
13
|
|
|
13
14
|
export type Step = RobotsSchema
|
|
14
15
|
export type StepInput = Step
|
|
@@ -24,6 +25,7 @@ export const stepSchema: z.ZodType<Step> = z
|
|
|
24
25
|
.describe('Identifier of the [robot](https://transloadit.com/docs/robots/) to execute'),
|
|
25
26
|
})
|
|
26
27
|
.and(robotsSchema)
|
|
28
|
+
.superRefine(refineTransloaditImportSelector)
|
|
27
29
|
export const stepsSchema: z.ZodType<Steps> = z
|
|
28
30
|
.record(stepSchema)
|
|
29
31
|
.describe('Contains Assembly Instructions.')
|
|
@@ -42,6 +44,7 @@ export const stepSchemaWithHiddenFields: z.ZodType<StepWithHiddenFields> = z
|
|
|
42
44
|
.describe('Identifier of the [robot](https://transloadit.com/docs/robots/) to execute'),
|
|
43
45
|
})
|
|
44
46
|
.and(robotsWithHiddenBotsAndFieldsSchema)
|
|
47
|
+
.superRefine(refineTransloaditImportSelector)
|
|
45
48
|
export const stepsSchemaWithHiddenFields: z.ZodType<StepsWithHiddenFields> = z
|
|
46
49
|
.record(stepSchemaWithHiddenFields)
|
|
47
50
|
.describe('Contains Assembly Instructions.')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResolvedCliConfig } from '../helpers.ts'
|
|
1
2
|
import type { IOutputCtl } from '../OutputCtl.ts'
|
|
2
3
|
|
|
3
4
|
import { Command, Option } from 'clipanion'
|
|
@@ -22,6 +23,7 @@ abstract class BaseCommand extends Command {
|
|
|
22
23
|
|
|
23
24
|
protected output!: IOutputCtl
|
|
24
25
|
protected client!: TransloaditClient
|
|
26
|
+
protected cliConfig!: ResolvedCliConfig
|
|
25
27
|
|
|
26
28
|
protected setupOutput(): void {
|
|
27
29
|
const logLevel = this.logLevelOption ? parseLogLevel(this.logLevelOption) : LOG_LEVEL_DEFAULT
|
|
@@ -31,8 +33,8 @@ abstract class BaseCommand extends Command {
|
|
|
31
33
|
})
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
protected setupClient(): boolean {
|
|
35
|
-
|
|
36
|
+
protected setupClient(config: ResolvedCliConfig = resolveCliConfig()): boolean {
|
|
37
|
+
this.cliConfig = config
|
|
36
38
|
if (config.auth == null) {
|
|
37
39
|
this.output.error(config.loadError ?? buildMissingAuthMessage())
|
|
38
40
|
return false
|
|
@@ -132,9 +132,11 @@ function parseTemplateFieldAssignments(
|
|
|
132
132
|
return fieldsMap
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const AssemblySchema = z
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const AssemblySchema = z
|
|
136
|
+
.object({
|
|
137
|
+
id: z.string(),
|
|
138
|
+
})
|
|
139
|
+
.passthrough()
|
|
138
140
|
|
|
139
141
|
// --- Business logic functions (from assemblies.ts) ---
|
|
140
142
|
|
|
@@ -163,8 +165,14 @@ export function list(
|
|
|
163
165
|
if (fields == null) {
|
|
164
166
|
output.print(parsed.data.id, assembly)
|
|
165
167
|
} else {
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
+
const record = parsed.data
|
|
169
|
+
const selected = fields.filter((field) => Object.hasOwn(record, field))
|
|
170
|
+
output.print(
|
|
171
|
+
fields
|
|
172
|
+
.map((field) => (Object.hasOwn(record, field) ? record[field] : undefined))
|
|
173
|
+
.join(' '),
|
|
174
|
+
Object.fromEntries(selected.map((field) => [field, record[field]])),
|
|
175
|
+
)
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
178
|
})
|
package/src/cli/commands/auth.ts
CHANGED
|
@@ -110,10 +110,10 @@ function parseJsonObject<TSchema extends z.ZodTypeAny>(
|
|
|
110
110
|
// Core logic for signature generation
|
|
111
111
|
function generateSignature(
|
|
112
112
|
input: string,
|
|
113
|
-
credentials:
|
|
113
|
+
credentials: CliKeySecretCredentials,
|
|
114
114
|
algorithm?: string,
|
|
115
115
|
): OutputResult {
|
|
116
|
-
const { authKey
|
|
116
|
+
const { authKey } = credentials
|
|
117
117
|
let params: CliSignatureParams
|
|
118
118
|
|
|
119
119
|
if (input === '') {
|
|
@@ -136,7 +136,7 @@ function generateSignature(
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const client = new Transloadit(
|
|
139
|
+
const client = new Transloadit(credentials)
|
|
140
140
|
try {
|
|
141
141
|
const signature = client.calcSignature(params as OptionalAuthParams, algorithm)
|
|
142
142
|
return { ok: true, output: JSON.stringify(signature) }
|
|
@@ -286,6 +286,29 @@ export async function runSmartSig(options: RunSmartSigOptions = {}): Promise<voi
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
/** Auth group help lists command definitions once while preserving every invocation alias. */
|
|
290
|
+
export class AuthHelpCommand extends Command {
|
|
291
|
+
// Explicit help paths avoid Clipanion's prefix matching, which lists each alias as a command.
|
|
292
|
+
static override paths = [['auth', '--help'], ['auth', '-h'], ['auth']]
|
|
293
|
+
|
|
294
|
+
override execute(): Promise<void> {
|
|
295
|
+
const commands = this.cli
|
|
296
|
+
.definitions()
|
|
297
|
+
.filter((command) => command.path.startsWith(`${this.cli.binaryName} auth `))
|
|
298
|
+
this.context.stdout.write(
|
|
299
|
+
[
|
|
300
|
+
'Authentication commands',
|
|
301
|
+
'',
|
|
302
|
+
...commands.map((command) => ` ${command.path}\n ${command.description ?? ''}`),
|
|
303
|
+
'',
|
|
304
|
+
'Use <command> --help for options.',
|
|
305
|
+
'',
|
|
306
|
+
].join('\n'),
|
|
307
|
+
)
|
|
308
|
+
return Promise.resolve()
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
289
312
|
/**
|
|
290
313
|
* Generate a signature for assembly params
|
|
291
314
|
*/
|