Skip to content

Commit 542ce00

Browse files
committed
Sync alphalib
1 parent 92ebdbf commit 542ce00

File tree

7 files changed

+202
-61
lines changed

7 files changed

+202
-61
lines changed

src/alphalib/types/robots/_index.ts

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ import { robotHtmlConvertInstructionsSchema } from './html-convert.ts'
4343
import { robotHttpImportInstructionsSchema } from './http-import.ts'
4444
import { robotImageDescribeInstructionsSchema } from './image-describe.ts'
4545
import { robotImageFacedetectInstructionsSchema } from './image-facedetect.ts'
46-
import { robotImageGenerateInstructionsSchema } from './image-generate.ts'
46+
import {
47+
robotImageGenerateInstructionsSchema,
48+
robotImageGenerateInstructionsWithHiddenFieldsSchema,
49+
} from './image-generate.ts'
4750
import { robotImageMergeInstructionsSchema } from './image-merge.ts'
4851
import { robotImageOcrInstructionsSchema } from './image-ocr.ts'
4952
import { robotImageOptimizeInstructionsSchema } from './image-optimize.ts'
@@ -59,7 +62,10 @@ import { robotS3StoreInstructionsSchema } from './s3-store.ts'
5962
import { robotScriptRunInstructionsSchema } from './script-run.ts'
6063
import { robotSftpImportInstructionsSchema } from './sftp-import.ts'
6164
import { robotSftpStoreInstructionsSchema } from './sftp-store.ts'
62-
import { robotSpeechTranscribeInstructionsSchema } from './speech-transcribe.ts'
65+
import {
66+
robotSpeechTranscribeInstructionsSchema,
67+
robotSpeechTranscribeInstructionsWithHiddenFieldsSchema,
68+
} from './speech-transcribe.ts'
6369
import { robotSupabaseImportInstructionsSchema } from './supabase-import.ts'
6470
import { robotSupabaseStoreInstructionsSchema } from './supabase-store.ts'
6571
import { robotSwiftImportInstructionsSchema } from './swift-import.ts'
@@ -158,21 +164,109 @@ const robotStepsInstructions = [
158164
robotYoutubeStoreInstructionsSchema,
159165
] as const
160166

167+
const robotStepsInstructionsWithHiddenFields = [
168+
robotAudioArtworkInstructionsSchema,
169+
robotAudioConcatInstructionsSchema,
170+
robotAudioEncodeInstructionsSchema,
171+
robotAudioLoopInstructionsSchema,
172+
robotAudioMergeInstructionsSchema,
173+
robotAudioWaveformInstructionsSchema,
174+
robotAzureImportInstructionsSchema,
175+
robotAzureStoreInstructionsSchema,
176+
robotBackblazeImportInstructionsSchema,
177+
robotBackblazeStoreInstructionsSchema,
178+
robotCloudfilesImportInstructionsSchema,
179+
robotCloudfilesStoreInstructionsSchema,
180+
robotCloudflareImportInstructionsSchema,
181+
robotCloudflareStoreInstructionsSchema,
182+
robotDigitaloceanImportInstructionsSchema,
183+
robotDigitaloceanStoreInstructionsSchema,
184+
robotDocumentAutorotateInstructionsSchema,
185+
robotDocumentConvertInstructionsSchema,
186+
robotDocumentMergeInstructionsSchema,
187+
robotDocumentOcrInstructionsSchema,
188+
robotFileReadInstructionsSchema,
189+
robotDocumentSplitInstructionsSchema,
190+
robotDocumentThumbsInstructionsSchema,
191+
robotDropboxImportInstructionsSchema,
192+
robotDropboxStoreInstructionsSchema,
193+
robotEdglyDeliverInstructionsSchema,
194+
robotFileCompressInstructionsSchema,
195+
robotFileDecompressInstructionsSchema,
196+
robotFileFilterInstructionsSchema,
197+
robotFileHashInstructionsSchema,
198+
robotFilePreviewInstructionsSchema,
199+
robotFileServeInstructionsSchema,
200+
robotFileVerifyInstructionsSchema,
201+
robotFileVirusscanInstructionsSchema,
202+
robotFtpImportInstructionsSchema,
203+
robotFtpStoreInstructionsSchema,
204+
robotGoogleImportInstructionsSchema,
205+
robotGoogleStoreInstructionsSchema,
206+
robotHtmlConvertInstructionsSchema,
207+
robotHttpImportInstructionsSchema,
208+
robotImageDescribeInstructionsSchema,
209+
robotImageFacedetectInstructionsSchema,
210+
robotImageMergeInstructionsSchema,
211+
robotImageOcrInstructionsSchema,
212+
robotImageOptimizeInstructionsSchema,
213+
robotImageResizeInstructionsSchema,
214+
robotMediaPlaylistInstructionsSchema,
215+
robotMetaWriteInstructionsSchema,
216+
robotMinioImportInstructionsSchema,
217+
robotMinioStoreInstructionsSchema,
218+
robotS3ImportInstructionsSchema,
219+
robotS3StoreInstructionsSchema,
220+
robotScriptRunInstructionsSchema,
221+
robotSftpImportInstructionsSchema,
222+
robotSftpStoreInstructionsSchema,
223+
robotSpeechTranscribeInstructionsWithHiddenFieldsSchema,
224+
robotSupabaseImportInstructionsSchema,
225+
robotSupabaseStoreInstructionsSchema,
226+
robotSwiftImportInstructionsSchema,
227+
robotSwiftStoreInstructionsSchema,
228+
robotTextSpeakInstructionsSchema,
229+
robotTextTranslateInstructionsSchema,
230+
robotTlcdnDeliverInstructionsSchema,
231+
robotTusStoreInstructionsSchema,
232+
robotUploadHandleInstructionsSchema,
233+
robotVideoAdaptiveInstructionsSchema,
234+
robotVideoConcatInstructionsSchema,
235+
robotVideoEncodeInstructionsSchema,
236+
robotVideoMergeInstructionsSchema,
237+
robotVideoSubtitleInstructionsSchema,
238+
robotVideoThumbsInstructionsSchema,
239+
robotVimeoStoreInstructionsSchema,
240+
robotWasabiImportInstructionsSchema,
241+
robotWasabiStoreInstructionsSchema,
242+
robotYoutubeStoreInstructionsSchema,
243+
] as const
244+
161245
/**
162246
* Public robot instructions
163247
*/
164-
export const robotStepsInstructionsSchema = z.discriminatedUnion('robot', [
165-
...robotStepsInstructions,
248+
export const robotsSchema = z.discriminatedUnion('robot', [...robotStepsInstructions])
249+
export const robotsWithHiddenFieldsSchema = z.discriminatedUnion('robot', [
250+
...robotStepsInstructionsWithHiddenFields,
166251
])
167252

168253
/**
169254
* All robot instructions, including private ones.
170255
*/
171-
export const robotAnyInstructionsSchema = z.discriminatedUnion('robot', [
256+
export const robotsWithHiddenBotsSchema = z.discriminatedUnion('robot', [
172257
...robotStepsInstructions,
173258
robotFileWatermarkInstructionsSchema,
174259
robotImageGenerateInstructionsSchema,
175260
robotImageRemoveBackgroundInstructionsSchema,
176261
robotProgressSimulateInstructionsSchema,
177262
])
178-
export type RobotAnyInstructions = z.infer<typeof robotAnyInstructionsSchema>
263+
export const robotsWithHiddenBotsAndFieldsSchema = z.discriminatedUnion('robot', [
264+
...robotStepsInstructionsWithHiddenFields,
265+
robotFileWatermarkInstructionsSchema,
266+
robotImageGenerateInstructionsWithHiddenFieldsSchema,
267+
robotImageRemoveBackgroundInstructionsSchema,
268+
robotProgressSimulateInstructionsSchema,
269+
])
270+
271+
export type RobotsWithHiddenBots = z.infer<typeof robotsWithHiddenBotsSchema>
272+
export type RobotsWithHiddenBotsAndFields = z.infer<typeof robotsWithHiddenBotsAndFieldsSchema>

src/alphalib/types/robots/image-generate.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const robotImageGenerateInstructionsSchema = z
1212
model: z.string(),
1313
prompt: z.string().describe('The prompt describing the desired image content.'),
1414
format: z
15-
.enum(['jpeg', 'png', 'gif', 'webp'])
15+
.enum(['jpeg', 'png', 'gif', 'webp', 'svg'])
1616
.optional()
1717
.describe('Format of the generated image.'),
1818
seed: z.number().optional().describe('Seed for the random number generator.'),
@@ -25,12 +25,13 @@ export const robotImageGenerateInstructionsSchema = z
2525
})
2626
.strict()
2727

28-
export const robotImageGenerateInstructionsWithHiddenFields =
28+
export const robotImageGenerateInstructionsWithHiddenFieldsSchema =
2929
robotImageGenerateInstructionsSchema.extend({
30+
result: z.union([z.literal('debug'), robotImageGenerateInstructionsSchema.shape.result]),
3031
provider: z.string().optional().describe('Provider for generating the image.'),
3132
})
3233

3334
export type RobotImageGenerateInstructions = z.infer<typeof robotImageGenerateInstructionsSchema>
3435
export type RobotImageGenerateInstructionsWithHiddenFields = z.infer<
35-
typeof robotImageGenerateInstructionsWithHiddenFields
36+
typeof robotImageGenerateInstructionsWithHiddenFieldsSchema
3637
>

src/alphalib/types/robots/speech-transcribe.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { z } from 'zod'
22

3-
import { aiProviderSchema, granularitySchema, useParamSchema } from './_instructions-primitives.ts'
3+
import {
4+
aiProviderSchema,
5+
granularitySchema,
6+
outputMetaParamSchema,
7+
useParamSchema,
8+
} from './_instructions-primitives.ts'
49
import type { RobotMeta } from './_instructions-primitives.ts'
510

611
export const meta: RobotMeta = {
@@ -66,15 +71,31 @@ Output format for the transcription.
6671
- \`"srt"\` and \`"webvtt"\` output subtitle files of those respective file types, which can be stored separately or used in other encoding <dfn>Steps</dfn>.
6772
- \`"meta"\` does not return a file, but stores the data inside Transloadit's file object (under \`\${file.meta.transcription.text}\`) that's passed around between encoding <dfn>Steps</dfn>, so that you can use the values to burn the data into videos, filter on them, etc.
6873
`),
74+
output_meta: outputMetaParamSchema.optional(),
6975
// TODO determine the list of languages
7076
source_language: z.string().default('en-US').describe(`
7177
The spoken language of the audio or video. This will also be the language of the transcribed text.
7278
7379
The language should be specified in the [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) format, such as \`"en-GB"\`, \`"de-DE"\` or \`"fr-FR"\`. Please also consult the list of supported languages for [the \`gcp\` provider](https://cloud.google.com/speech-to-text/docs/languages) and the [the \`aws\` provider](https://docs.aws.amazon.com/transcribe/latest/dg/what-is-transcribe.html).
7480
`),
81+
// TODO determine the list of languages
82+
target_language: z.string().default('en-US').describe(`
83+
This will also be the language of the written text.
84+
85+
The language should be specified in the [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) format, such as \`"en-GB"\`, \`"de-DE"\` or \`"fr-FR"\`. Please consult the list of supported languages and voices.
86+
`),
7587
})
7688
.strict()
7789

7890
export type RobotSpeechTranscribeInstructions = z.infer<
7991
typeof robotSpeechTranscribeInstructionsSchema
8092
>
93+
94+
export const robotSpeechTranscribeInstructionsWithHiddenFieldsSchema =
95+
robotSpeechTranscribeInstructionsSchema.extend({
96+
result: z.union([z.literal('debug'), robotSpeechTranscribeInstructionsSchema.shape.result]),
97+
})
98+
99+
export type RobotSpeechTranscribeInstructionsWithHiddenFields = z.infer<
100+
typeof robotSpeechTranscribeInstructionsWithHiddenFieldsSchema
101+
>

src/alphalib/types/robots/upload-handle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ There are **3 important constraints** when using this <dfn>Robot</dfn>:
5959
.strict()
6060

6161
export type RobotUploadHandleInstructions = z.infer<typeof robotUploadHandleInstructionsSchema>
62+
export type RobotUploadHandleInstructionsInput = z.input<typeof robotUploadHandleInstructionsSchema>

src/alphalib/types/robots/video-merge.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ If the given width/height parameters are bigger than the input image's dimension
6262
The background color of the resulting video the \`"rrggbbaa"\` format (red, green, blue, alpha) when used with the \`"pad"\` resize strategy. The default color is black.
6363
`),
6464
framerate: z
65-
.string()
66-
.regex(/^\d+\/\d+$/)
65+
.union([z.number().int().min(1), z.string().regex(/^\d+(?:\/\d+)?$/)])
6766
.default('1/5').describe(`
6867
When merging images to generate a video this is the input framerate. A value of "1/5" means each image is given 5 seconds before the next frame appears (the inverse of a framerate of "5"). Likewise for "1/10", "1/20", etc. A value of "5" means there are 5 frames per second.
6968
`),
@@ -80,6 +79,8 @@ When merging audio files and video files, the duration of the longest video or a
8079
audio_delay: z.number().default(0).describe(`
8180
When merging a video and an audio file, and when merging images and an audio file to generate a video, this is the desired delay in seconds for the audio file to start playing. Imagine you merge a video file without sound and an audio file, but you wish the audio to start playing after 5 seconds and not immediately, then this is the parameter to use.
8281
`),
82+
loop: z.boolean().default(false).describe(`
83+
Determines whether the shorter media file should be looped to match the duration of the longer one. For example, if you merge a 1-minute video with a 3-minute audio file and enable this option, the video will play three times in a row to match the audio length.`),
8384
replace_audio: z.boolean().default(false).describe(`
8485
Determines whether the audio of the video should be replaced with a provided audio file.
8586
`),

src/alphalib/types/template.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
import { z } from 'zod'
22

3-
import { robotStepsInstructionsSchema } from './robots/_index.ts'
3+
import { robotsWithHiddenBotsAndFieldsSchema, robotsSchema } from './robots/_index.ts'
44
import type { UseParamInput } from './robots/_instructions-primitives.ts'
55

66
export const stepSchema = z
77
.object({
88
// This is a hack to get nicer robot hover messages in editors.
99
robot: z.string().describe('The [robot](https://transloadit.com/docs/transcoding/) to use'),
1010
})
11-
.and(robotStepsInstructionsSchema)
11+
.and(robotsSchema)
12+
export const stepsSchema = z.record(stepSchema).describe('Contains Assembly Instructions.')
1213
export type Step = z.infer<typeof stepSchema>
1314
export type StepInput = z.input<typeof stepSchema>
1415
export type StepInputWithUse = StepInput & { use: UseParamInput }
15-
export const stepsSchema = z.record(stepSchema).describe('Contains Assembly Instructions.')
16-
1716
export type Steps = z.infer<typeof stepsSchema>
1817
export type StepsInput = z.input<typeof stepsSchema>
1918

19+
export const stepSchemaWithHiddenFields = z
20+
.object({
21+
// This is a hack to get nicer robot hover messages in editors.
22+
robot: z.string().describe('The [robot](https://transloadit.com/docs/transcoding/) to use'),
23+
})
24+
.and(robotsWithHiddenBotsAndFieldsSchema)
25+
export const stepsSchemaWithHiddenFields = z
26+
.record(stepSchemaWithHiddenFields)
27+
.describe('Contains Assembly Instructions.')
28+
export type StepWithHiddenFields = z.infer<typeof stepSchemaWithHiddenFields>
29+
export type StepWithHiddenFieldsInput = z.input<typeof stepSchemaWithHiddenFields>
30+
export type StepsWithHiddenFields = z.infer<typeof stepsSchemaWithHiddenFields>
31+
export type StepsWithHiddenFieldsInput = z.input<typeof stepsSchemaWithHiddenFields>
32+
2033
export const assemblyAuthInstructionsSchema = z.object({
2134
key: z.string().describe('The Transloadit API key to use'),
2235
secret: z.string().optional().describe('The Transloadit API secret to use'),
@@ -44,7 +57,7 @@ export const assemblyInstructionsSchema = z.object({
4457
.describe(
4558
'An object of string to string pairs (name -> value) that can be used as Assembly Variables, just like additional form fields can.',
4659
),
47-
quite: z
60+
quiet: z
4861
.boolean()
4962
.optional()
5063
.describe(

0 commit comments

Comments
 (0)