transloadit 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +2 -2
  2. package/dist/Transloadit.d.ts.map +1 -1
  3. package/dist/Transloadit.js +5 -7
  4. package/dist/Transloadit.js.map +1 -1
  5. package/dist/alphalib/englishInteger.d.ts +3 -0
  6. package/dist/alphalib/englishInteger.d.ts.map +1 -0
  7. package/dist/alphalib/englishInteger.js +13 -0
  8. package/dist/alphalib/englishInteger.js.map +1 -0
  9. package/dist/alphalib/lib/zodInputSemantics.d.ts +3 -1
  10. package/dist/alphalib/lib/zodInputSemantics.d.ts.map +1 -1
  11. package/dist/alphalib/lib/zodInputSemantics.js +17 -0
  12. package/dist/alphalib/lib/zodInputSemantics.js.map +1 -1
  13. package/dist/alphalib/types/robots/_image-describe-output.d.ts +55 -0
  14. package/dist/alphalib/types/robots/_image-describe-output.d.ts.map +1 -0
  15. package/dist/alphalib/types/robots/_image-describe-output.js +16 -0
  16. package/dist/alphalib/types/robots/_image-describe-output.js.map +1 -0
  17. package/dist/alphalib/types/robots/_image-facedetect-output.d.ts +30 -0
  18. package/dist/alphalib/types/robots/_image-facedetect-output.d.ts.map +1 -0
  19. package/dist/alphalib/types/robots/_image-facedetect-output.js +15 -0
  20. package/dist/alphalib/types/robots/_image-facedetect-output.js.map +1 -0
  21. package/dist/alphalib/types/robots/_index.d.ts +582 -48
  22. package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
  23. package/dist/alphalib/types/robots/_index.js +84 -80
  24. package/dist/alphalib/types/robots/_index.js.map +1 -1
  25. package/dist/alphalib/types/robots/_instructions-primitives.d.ts +82 -0
  26. package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
  27. package/dist/alphalib/types/robots/_instructions-primitives.js +46 -2
  28. package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
  29. package/dist/alphalib/types/robots/_ocr-output.d.ts +75 -0
  30. package/dist/alphalib/types/robots/_ocr-output.d.ts.map +1 -0
  31. package/dist/alphalib/types/robots/_ocr-output.js +15 -0
  32. package/dist/alphalib/types/robots/_ocr-output.js.map +1 -0
  33. package/dist/alphalib/types/robots/ai-chat.d.ts +12 -12
  34. package/dist/alphalib/types/robots/audio-encode.d.ts.map +1 -1
  35. package/dist/alphalib/types/robots/audio-encode.js +8 -1
  36. package/dist/alphalib/types/robots/audio-encode.js.map +1 -1
  37. package/dist/alphalib/types/robots/audio-split.d.ts.map +1 -1
  38. package/dist/alphalib/types/robots/audio-split.js +2 -0
  39. package/dist/alphalib/types/robots/audio-split.js.map +1 -1
  40. package/dist/alphalib/types/robots/digitalocean-store.d.ts +4 -4
  41. package/dist/alphalib/types/robots/digitalocean-store.js +1 -1
  42. package/dist/alphalib/types/robots/digitalocean-store.js.map +1 -1
  43. package/dist/alphalib/types/robots/document-convert.d.ts +8 -6
  44. package/dist/alphalib/types/robots/document-convert.d.ts.map +1 -1
  45. package/dist/alphalib/types/robots/document-convert.js +5 -5
  46. package/dist/alphalib/types/robots/document-convert.js.map +1 -1
  47. package/dist/alphalib/types/robots/document-extract.d.ts +4 -4
  48. package/dist/alphalib/types/robots/document-ocr.d.ts +8 -8
  49. package/dist/alphalib/types/robots/google-store.d.ts +32 -8
  50. package/dist/alphalib/types/robots/google-store.d.ts.map +1 -1
  51. package/dist/alphalib/types/robots/google-store.js +10 -2
  52. package/dist/alphalib/types/robots/google-store.js.map +1 -1
  53. package/dist/alphalib/types/robots/image-bgremove.d.ts +16 -16
  54. package/dist/alphalib/types/robots/image-describe.d.ts +17 -17
  55. package/dist/alphalib/types/robots/image-describe.d.ts.map +1 -1
  56. package/dist/alphalib/types/robots/image-describe.js +2 -1
  57. package/dist/alphalib/types/robots/image-describe.js.map +1 -1
  58. package/dist/alphalib/types/robots/image-facedetect.d.ts +9 -35
  59. package/dist/alphalib/types/robots/image-facedetect.d.ts.map +1 -1
  60. package/dist/alphalib/types/robots/image-facedetect.js +1 -11
  61. package/dist/alphalib/types/robots/image-facedetect.js.map +1 -1
  62. package/dist/alphalib/types/robots/image-generate.d.ts +20 -20
  63. package/dist/alphalib/types/robots/image-generate.js +1 -1
  64. package/dist/alphalib/types/robots/image-generate.js.map +1 -1
  65. package/dist/alphalib/types/robots/image-ocr.d.ts +8 -8
  66. package/dist/alphalib/types/robots/image-upscale.d.ts +17 -12
  67. package/dist/alphalib/types/robots/image-upscale.d.ts.map +1 -1
  68. package/dist/alphalib/types/robots/image-upscale.js +14 -2
  69. package/dist/alphalib/types/robots/image-upscale.js.map +1 -1
  70. package/dist/alphalib/types/robots/mega-store.d.ts +4 -4
  71. package/dist/alphalib/types/robots/mega-store.js +1 -1
  72. package/dist/alphalib/types/robots/mega-store.js.map +1 -1
  73. package/dist/alphalib/types/robots/s3-store.d.ts +8 -8
  74. package/dist/alphalib/types/robots/s3-store.d.ts.map +1 -1
  75. package/dist/alphalib/types/robots/s3-store.js +14 -2
  76. package/dist/alphalib/types/robots/s3-store.js.map +1 -1
  77. package/dist/alphalib/types/robots/speech-transcribe.d.ts +12 -12
  78. package/dist/alphalib/types/robots/text-speak.d.ts +8 -8
  79. package/dist/alphalib/types/robots/text-translate.d.ts +8 -8
  80. package/dist/alphalib/types/robots/video-adaptive.d.ts +16 -19
  81. package/dist/alphalib/types/robots/video-adaptive.d.ts.map +1 -1
  82. package/dist/alphalib/types/robots/video-adaptive.js +37 -3
  83. package/dist/alphalib/types/robots/video-adaptive.js.map +1 -1
  84. package/dist/alphalib/types/robots/video-concat.d.ts.map +1 -1
  85. package/dist/alphalib/types/robots/video-concat.js +7 -3
  86. package/dist/alphalib/types/robots/video-concat.js.map +1 -1
  87. package/dist/alphalib/types/robots/video-encode.d.ts.map +1 -1
  88. package/dist/alphalib/types/robots/video-encode.js +6 -0
  89. package/dist/alphalib/types/robots/video-encode.js.map +1 -1
  90. package/dist/alphalib/types/robots/video-generate.d.ts +20 -20
  91. package/dist/alphalib/types/robots/video-generate.js +1 -1
  92. package/dist/alphalib/types/robots/video-generate.js.map +1 -1
  93. package/dist/alphalib/types/robots/video-merge.d.ts.map +1 -1
  94. package/dist/alphalib/types/robots/video-merge.js +15 -1
  95. package/dist/alphalib/types/robots/video-merge.js.map +1 -1
  96. package/dist/alphalib/types/robots/video-split.d.ts.map +1 -1
  97. package/dist/alphalib/types/robots/video-split.js +2 -0
  98. package/dist/alphalib/types/robots/video-split.js.map +1 -1
  99. package/dist/alphalib/types/robots/video-subtitle.d.ts +47 -4
  100. package/dist/alphalib/types/robots/video-subtitle.d.ts.map +1 -1
  101. package/dist/alphalib/types/robots/video-subtitle.js +59 -46
  102. package/dist/alphalib/types/robots/video-subtitle.js.map +1 -1
  103. package/dist/alphalib/types/robots/vimeo-import.d.ts.map +1 -1
  104. package/dist/alphalib/types/robots/vimeo-import.js +1 -1
  105. package/dist/alphalib/types/robots/vimeo-import.js.map +1 -1
  106. package/dist/alphalib/types/robots/youtube-store.d.ts +37 -20
  107. package/dist/alphalib/types/robots/youtube-store.d.ts.map +1 -1
  108. package/dist/alphalib/types/robots/youtube-store.js +17 -29
  109. package/dist/alphalib/types/robots/youtube-store.js.map +1 -1
  110. package/dist/alphalib/youtubeCategories.d.ts +20 -0
  111. package/dist/alphalib/youtubeCategories.d.ts.map +1 -0
  112. package/dist/alphalib/youtubeCategories.js +21 -0
  113. package/dist/alphalib/youtubeCategories.js.map +1 -0
  114. package/dist/apiTypes.d.ts +12 -1
  115. package/dist/apiTypes.d.ts.map +1 -1
  116. package/dist/robots.d.ts.map +1 -1
  117. package/dist/robots.js +6 -0
  118. package/dist/robots.js.map +1 -1
  119. package/package.json +1 -1
  120. package/src/Transloadit.ts +4 -6
  121. package/src/alphalib/englishInteger.ts +14 -0
  122. package/src/alphalib/lib/zodInputSemantics.ts +22 -1
  123. package/src/alphalib/types/robots/_image-describe-output.ts +20 -0
  124. package/src/alphalib/types/robots/_image-facedetect-output.ts +19 -0
  125. package/src/alphalib/types/robots/_index.ts +100 -82
  126. package/src/alphalib/types/robots/_instructions-primitives.ts +51 -2
  127. package/src/alphalib/types/robots/_ocr-output.ts +19 -0
  128. package/src/alphalib/types/robots/audio-encode.ts +8 -1
  129. package/src/alphalib/types/robots/audio-split.ts +2 -0
  130. package/src/alphalib/types/robots/digitalocean-store.ts +1 -1
  131. package/src/alphalib/types/robots/document-convert.ts +8 -5
  132. package/src/alphalib/types/robots/google-store.ts +15 -4
  133. package/src/alphalib/types/robots/image-describe.ts +8 -1
  134. package/src/alphalib/types/robots/image-facedetect.ts +4 -13
  135. package/src/alphalib/types/robots/image-generate.ts +1 -1
  136. package/src/alphalib/types/robots/image-upscale.ts +17 -2
  137. package/src/alphalib/types/robots/mega-store.ts +1 -1
  138. package/src/alphalib/types/robots/s3-store.ts +14 -2
  139. package/src/alphalib/types/robots/video-adaptive.ts +37 -3
  140. package/src/alphalib/types/robots/video-concat.ts +7 -3
  141. package/src/alphalib/types/robots/video-encode.ts +6 -0
  142. package/src/alphalib/types/robots/video-generate.ts +1 -1
  143. package/src/alphalib/types/robots/video-merge.ts +15 -1
  144. package/src/alphalib/types/robots/video-split.ts +2 -0
  145. package/src/alphalib/types/robots/video-subtitle.ts +61 -46
  146. package/src/alphalib/types/robots/vimeo-import.ts +3 -1
  147. package/src/alphalib/types/robots/youtube-store.ts +26 -41
  148. package/src/alphalib/youtubeCategories.ts +24 -0
  149. package/src/apiTypes.ts +12 -1
  150. package/src/robots.ts +7 -0
@@ -19,54 +19,47 @@ import {
19
19
  robotVideoEncodingMeta,
20
20
  } from './_instructions-primitives.ts'
21
21
 
22
+ const subtitleColorSchema = z.union([color_without_alpha, color_with_alpha])
23
+ const subtitleColorDescription = `Use \`"rgb"\`, \`"rrggbb"\`, or \`"aarrggbb"\` format, optionally prefixed with \`#\`. Three-digit colors are expanded to six digits. Colors without alpha are fully opaque. For eight-digit colors, the first two digits specify transparency (\`"00"\` is fully opaque, \`"ff"\` is fully transparent).`
24
+
25
+ /** Appearance defaults for the social caption preset, before customer overrides. */
26
+ export const videoSubtitleSocialStyle = {
27
+ // Static Poppins faces are included by API2's shared fontsConf google-fonts package.
28
+ font: 'Poppins',
29
+ // ASS includes the font's ascent and descent; Poppins capitals occupy about 40% of it.
30
+ font_size: 54,
31
+ bold: true,
32
+ outline_width: 2,
33
+ }
34
+
22
35
  export const meta: RobotMetaInput = {
23
36
  ...robotVideoEncodingMeta,
24
37
  example_code: {
25
38
  steps: {
26
- add_english_subtitles: {
27
- robot: '/video/subtitle',
28
- use: {
29
- steps: [
30
- {
31
- name: ':original',
32
- fields: 'input_video',
33
- as: 'video',
34
- },
35
- {
36
- name: ':original',
37
- fields: 'input_srt_en',
38
- as: 'subtitles',
39
- },
40
- ],
41
- },
42
- language: 'eng',
43
- name: 'English',
44
- ffmpeg_stack: stackVersions.ffmpeg.recommendedVersion,
39
+ transcript: {
40
+ robot: '/speech/transcribe',
41
+ use: ':original',
42
+ provider: 'aws',
43
+ format: 'json',
44
+ source_language: 'en-US',
45
45
  },
46
- add_german_subtitles: {
46
+ captioned: {
47
47
  robot: '/video/subtitle',
48
48
  use: {
49
49
  steps: [
50
- {
51
- name: 'add_english_subtitles',
52
- as: 'video',
53
- },
54
- {
55
- name: ':original',
56
- fields: 'input_srt_de',
57
- as: 'subtitles',
58
- },
50
+ { name: ':original', as: 'video' },
51
+ { name: 'transcript', as: 'subtitles' },
59
52
  ],
60
53
  },
61
- language: 'deu',
62
- name: 'Deutsch',
63
- keep_subtitles: true,
54
+ subtitles_type: 'burned',
55
+ preset: 'empty',
56
+ style: 'social',
64
57
  ffmpeg_stack: stackVersions.ffmpeg.recommendedVersion,
65
58
  },
66
59
  },
67
60
  },
68
61
  example_code_description:
69
- 'If you have file input fields in a form — one for a video and one for each subtitle language (named `input_video`, `input_srt_en`, and `input_srt_de` via the HTML `name` attribute) — here’s how to add multiple subtitle streams with language tags to the video. Chain multiple `/video/subtitle` Steps with `keep_subtitles` set to `true` so each new stream is added alongside existing ones:',
62
+ 'Transcribe an uploaded video into timestamped words, then burn in uppercase social captions with the spoken word highlighted. Captions normally contain up to three words, breaking at sentence endings and pauses longer than 0.4 seconds. A trailing function word can move to the next caption, allowing one extra word there:',
70
63
  purpose_sentence: 'adds subtitles and closed captions to videos',
71
64
  purpose_verb: 'subtitle',
72
65
  purpose_word: 'subtitle',
@@ -81,7 +74,9 @@ export const robotVideoSubtitleInstructionsSchema = robotBase
81
74
  .merge(robotFFmpegVideo)
82
75
  .extend({
83
76
  robot: z.literal('/video/subtitle').describe(`
84
- This <dfn>Robot</dfn> supports both SRT and VTT subtitle files.
77
+ This <dfn>Robot</dfn> supports SRT, VTT, ASS, and the timestamped JSON output of \`/speech/transcribe\` with \`"format": "json"\`. Pass the video as \`"video"\` and the transcript as \`"subtitles"\` in the \`use\` parameter. JSON words are grouped into captions and converted to ASS for burned word highlighting, or plain SRT cues for external subtitle streams. External JSON cues preserve casing and punctuation. Provider segments do not control caption breaks. SRT and VTT timing is preserved.
78
+
79
+ Without a \`preset\` or custom \`ffmpeg\` options, the legacy \`"flash"\` preset produces FLV output. With this default, burned subtitles use MP3 audio; external subtitles copy the input audio. Set \`"preset": "empty"\` to keep the input container, such as MP4 for an MP4 input.
85
80
  `),
86
81
  subtitles_type: zodInputPreservingTransform(z.enum(['burned', 'external', 'burn']), (val) =>
87
82
  val === 'burn' ? 'burned' : val,
@@ -89,6 +84,25 @@ This <dfn>Robot</dfn> supports both SRT and VTT subtitle files.
89
84
  .default('external')
90
85
  .describe(`
91
86
  Determines if subtitles are added as a separate stream to the video (value \`"external"\`) that then can be switched on and off in your video player, or if they should be burned directly into the video (value \`"burned"\` or \`"burn"\`) so that they become part of the video stream.
87
+ `),
88
+ style: z
89
+ .enum(['social'])
90
+ .optional()
91
+ .describe(`
92
+ Applies a ready-made appearance for burned subtitles: heavy Poppins text and a large font scaled with the video height. JSON captions render in uppercase in the lower third with a thick outline and a soft black shadow. Each caption grows from 85% to full size over 120 milliseconds, then its words stay in place while the highlight changes color. The transcript file is preserved. Existing styling parameters override the preset. ASS files retain their own styles. With timestamped JSON from \`/speech/transcribe\`, the active word is highlighted until the next word or caption starts; other words use \`font_color\`. Trailing commas and periods are omitted from social JSON captions; question marks and exclamation marks are preserved. Word highlighting and grouping require JSON input.
93
+ `),
94
+ highlight_color: subtitleColorSchema.default('FFD60A').describe(`
95
+ The accent color of the active word in JSON subtitles. Only applies to burned JSON subtitles. With \`"style": "social"\`, the previous word stays highlighted through short gaps until the next word or caption starts. Without the social style, gaps use \`font_color\` for the entire caption.
96
+
97
+ ${subtitleColorDescription}
98
+ `),
99
+ max_words_per_caption: z
100
+ .number()
101
+ .int()
102
+ .min(1)
103
+ .default(3)
104
+ .describe(`
105
+ The target maximum number of timestamped JSON words shown in a caption. Captions break earlier at sentence-ending punctuation or pauses longer than 0.4 seconds. With \`"style": "social"\`, a trailing English function word such as “by,” “to,” or “the” moves to the next caption when possible, allowing at most one extra word in that caption. Single-word captions are preserved when the limit is 1. A caption stays visible until the next caption starts when the pause is at most 0.4 seconds, and disappears at its last word’s end during longer pauses. Does not change SRT, VTT, or ASS cues.
92
106
  `),
93
107
  border_style: z
94
108
  .enum(['box', 'outline', 'shadow'])
@@ -96,23 +110,24 @@ Determines if subtitles are added as a separate stream to the video (value \`"ex
96
110
  .describe(`
97
111
  Specifies the style of the subtitle. Use the \`border_color\` parameter to specify the color of the border.
98
112
  `),
99
- border_color: color_with_alpha.default('40000000').describe(`
100
- The color for the subtitle border. The first two hex digits specify the alpha value of the color.
113
+ border_color: subtitleColorSchema.default('000000').describe(`
114
+ The color for the subtitle border. The default is opaque black. Only applies to burned subtitles.
115
+
116
+ ${subtitleColorDescription}
101
117
  `),
102
118
  // TODO: Make font an enum
103
119
  font: z
104
120
  .string()
105
121
  .default('Arial')
106
122
  .describe(`
107
- The font family to use. Also includes boldness and style of the font.
123
+ The font family to use. Also includes boldness and style of the font. With \`"style": "social"\`, the default is Poppins, using its ExtraBold weight for JSON captions. An explicit font overrides the style.
108
124
 
109
125
  [Here](/docs/supported-formats/fonts/) is a list of all supported fonts.
110
126
  `),
111
- font_color: z
112
- .union([color_without_alpha, color_with_alpha])
113
- .default('FFFFFF')
114
- .describe(`
115
- The color of the subtitle text in \`"rgb"\`, \`"rrggbb"\`, or \`"aarrggbb"\` format. If 8 hex digits are provided, the first two specify the alpha value of the color (\`"00"\` is fully opaque, \`"ff"\` is fully transparent).
127
+ font_color: subtitleColorSchema.default('FFFFFF').describe(`
128
+ The color of the subtitle text. Only applies to burned subtitles.
129
+
130
+ ${subtitleColorDescription}
116
131
  `),
117
132
  font_size: z
118
133
  .number()
@@ -120,13 +135,13 @@ The color of the subtitle text in \`"rgb"\`, \`"rrggbb"\`, or \`"aarrggbb"\` for
120
135
  .min(1)
121
136
  .default(16)
122
137
  .describe(`
123
- Specifies the size of the text.
138
+ Specifies the size of the text in the 288-pixel subtitle coordinate space, scaled with the video height. With \`"style": "social"\`, the default is 54. Poppins capital letters are about 7.5% of the video height at this size. An explicit value overrides the style.
124
139
  `),
125
140
  bold: z
126
141
  .boolean()
127
142
  .default(false)
128
143
  .describe(`
129
- Specifies whether the subtitle text should be bold. Only applies to burned subtitles.
144
+ Specifies whether the subtitle text should be bold. Only applies to burned subtitles. With \`"style": "social"\`, the default is \`true\`; an explicit \`false\` overrides the style.
130
145
  `),
131
146
  italic: z
132
147
  .boolean()
@@ -142,10 +157,10 @@ Specifies whether the subtitle text should be italic. Only applies to burned sub
142
157
  .optional()
143
158
  .nullable()
144
159
  .describe(`
145
- Specifies the width of the text outline in pixels. Only applies to burned subtitles with \`"outline"\` or \`"box"\` border styles. If not specified, the default width is used.
160
+ Specifies the width of the text outline in the 288-pixel subtitle coordinate space, scaled with the video height. Numeric strings such as \`"4"\` are also accepted. Only applies to burned subtitles with \`"outline"\` or \`"box"\` border styles. If omitted or \`null\`, the default width is used (2 with \`"style": "social"\`, about 3.7 pixels on a video 534 pixels high).
146
161
  `),
147
162
  position: positionSchema.default('bottom').describe(`
148
- Specifies the position of the subtitles.
163
+ Specifies the position of the subtitles. With \`"style": "social"\`, the default bottom position places JSON captions in the lower third. An explicit value overrides the style.
149
164
  `),
150
165
  language: z
151
166
  .string()
@@ -70,7 +70,9 @@ You can also use an array of path strings here to import multiple paths in the s
70
70
  rendition: z
71
71
  .enum(['240p', '360p', '540p', '720p', '1080p', 'source'])
72
72
  .default('720p')
73
- .describe('The quality of the video to import.'),
73
+ .describe(
74
+ 'The quality of the video to import. Use `source` for the original upload. Source availability depends on video permissions, your Vimeo account, the access token’s `video_files` scope, and whether Vimeo has retained the source file. The import fails with an error if the source file is unavailable.',
75
+ ),
74
76
  })
75
77
  .strict()
76
78
 
@@ -1,56 +1,28 @@
1
1
  import type {
2
- RobotDefinition,
2
+ RobotDefinitionWithHiddenFields,
3
3
  RobotMetaInput,
4
4
  RobotSchemaVariantTypes,
5
5
  } from './_instructions-primitives.ts'
6
6
 
7
7
  import { z } from 'zod'
8
8
 
9
- import { zodCodePointLength, zodWithJsonInputSchema } from '../../lib/zodInputSemantics.ts'
9
+ import { zodCaseInsensitiveEnum, zodCodePointLength } from '../../lib/zodInputSemantics.ts'
10
+ import { youtubeCategories } from '../../youtubeCategories.ts'
10
11
  import {
11
12
  createProcessingExample,
12
- defineRobot,
13
+ defineRobotWithHiddenFields,
13
14
  robotBase,
14
15
  robotStoreMeta,
15
16
  robotUse,
16
17
  } from './_instructions-primitives.ts'
17
18
 
18
- const youtubeCategories = [
19
- 'autos & vehicles',
20
- 'comedy',
21
- 'education',
22
- 'entertainment',
23
- 'film & animation',
24
- 'gaming',
25
- 'howto & style',
26
- 'music',
27
- 'news & politics',
28
- 'people & blogs',
29
- 'pets & animals',
30
- 'science & technology',
31
- 'sports',
32
- 'travel & events',
33
- ] as const
34
-
35
- function asciiCaseInsensitiveLiteral(value: string): string {
36
- return [...value]
37
- .map((character) =>
38
- character >= 'a' && character <= 'z' ? `[${character}${character.toUpperCase()}]` : character,
39
- )
40
- .join('')
41
- }
42
-
43
19
  const youtubeCategoryValueSchema = z.enum(youtubeCategories)
44
- const youtubeCategoryInputSchema = z
45
- .string()
46
- .regex(new RegExp(`^(?:${youtubeCategories.map(asciiCaseInsensitiveLiteral).join('|')})$`, 'u'))
47
- const youtubeCategorySchema = zodWithJsonInputSchema(
48
- z.preprocess(
49
- (value) => (typeof value === 'string' ? value.toLowerCase() : value),
50
- youtubeCategoryValueSchema,
51
- ),
52
- youtubeCategoryInputSchema,
53
- )
20
+ // Preserve the existing SDK input type for this already-preprocessed field.
21
+ const youtubeCategorySchema: z.ZodEffects<
22
+ typeof youtubeCategoryValueSchema,
23
+ z.output<typeof youtubeCategoryValueSchema>,
24
+ unknown
25
+ > = zodCaseInsensitiveEnum(youtubeCategoryValueSchema)
54
26
 
55
27
  export const meta: RobotMetaInput = {
56
28
  ...robotStoreMeta,
@@ -116,14 +88,27 @@ The category to which this video will be assigned.
116
88
  keywords: z.string().describe(`
117
89
  Tags used to describe the video, separated by commas. These tags will also be displayed on YouTube.
118
90
  `),
119
- visibility: z.enum(['public', 'private', 'unlisted']).describe(`
91
+ visibility: z
92
+ .enum(['public', 'private', 'unlisted'])
93
+ .default('public')
94
+ .describe(`
120
95
  Defines the visibility of the uploaded video.
121
96
  `),
122
97
  })
123
98
  .strict()
124
99
 
125
- export const robotDefinition: RobotDefinition<typeof robotYoutubeStoreInstructionsSchema.shape> =
126
- defineRobot(meta, robotYoutubeStoreInstructionsSchema)
100
+ // Credential alternatives stay optional while Templates and Assembly overrides are merged.
101
+ // YoutubeStoreRobot validates the resolved tokens after credential injection.
102
+ const hiddenFields = {
103
+ access_token: z.string().optional(),
104
+ credentials: robotYoutubeStoreInstructionsSchema.shape.credentials.optional(),
105
+ refresh_token: z.string().optional(),
106
+ }
107
+
108
+ export const robotDefinition: RobotDefinitionWithHiddenFields<
109
+ typeof robotYoutubeStoreInstructionsSchema.shape,
110
+ typeof hiddenFields
111
+ > = defineRobotWithHiddenFields(meta, robotYoutubeStoreInstructionsSchema, hiddenFields)
127
112
 
128
113
  export const {
129
114
  withHiddenFields: robotYoutubeStoreInstructionsWithHiddenFieldsSchema,
@@ -0,0 +1,24 @@
1
+ /** YouTube upload categories shared by authored instructions and execution. */
2
+ export const youtubeCategoryIds = {
3
+ 'autos & vehicles': '2',
4
+ comedy: '23',
5
+ education: '27',
6
+ entertainment: '24',
7
+ 'film & animation': '1',
8
+ gaming: '20',
9
+ 'howto & style': '26',
10
+ music: '10',
11
+ 'news & politics': '25',
12
+ 'people & blogs': '22',
13
+ 'pets & animals': '15',
14
+ 'science & technology': '28',
15
+ sports: '17',
16
+ 'travel & events': '19',
17
+ } satisfies Record<string, string>
18
+
19
+ /** Canonical category spellings; authoring and execution also accept case variants. */
20
+ // Object.keys loses literal keys and nonemptiness, both guaranteed by the map above.
21
+ export const youtubeCategories = Object.keys(youtubeCategoryIds) as [
22
+ keyof typeof youtubeCategoryIds,
23
+ ...(keyof typeof youtubeCategoryIds)[],
24
+ ]
package/src/apiTypes.ts CHANGED
@@ -36,11 +36,22 @@ export type CreateAssemblyParams = Omit<AssemblyInstructionsInput, 'auth'> & Opt
36
36
 
37
37
  export type ListAssembliesParams = OptionalAuthParams & {
38
38
  page?: number
39
+ /** At most 5000. */
39
40
  pagesize?: number
40
41
  type?: 'all' | 'uploading' | 'executing' | 'canceled' | 'completed' | 'failed' | 'request_aborted'
41
42
  fromdate?: string
42
43
  todate?: string
43
- keywords?: string[]
44
+ /**
45
+ * One search term of at least 3 characters. API2 stringifies the value, so an array only
46
+ * works with a single element.
47
+ */
48
+ keywords?: string | string[]
49
+ /** Only Assemblies created from this Template. */
50
+ template_id?: string
51
+ /** Only Assemblies that ran in this region, for example `us-east-1`. */
52
+ region?: string
53
+ sort?: 'created' | 'created_ts' | 'updated'
54
+ order?: 'asc' | 'desc'
44
55
  }
45
56
 
46
57
  export type ReplayAssemblyParams = Pick<
package/src/robots.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { z } from 'zod'
2
2
 
3
+ import { ZodEffects } from 'zod'
4
+
3
5
  import { getRobotSchemaOptions, robotsMeta } from './alphalib/types/robots/_index.ts'
4
6
 
5
7
  export type RobotListOptions = {
@@ -74,6 +76,11 @@ const unwrapSchema = (schema: z.ZodTypeAny): { base: z.ZodTypeAny; optional: boo
74
76
  let optional = typeof base.isOptional === 'function' ? base.isOptional() : false
75
77
 
76
78
  while (true) {
79
+ // Preprocessing changes accepted inputs, while help still needs the underlying choices.
80
+ if (base instanceof ZodEffects) {
81
+ base = base.innerType()
82
+ continue
83
+ }
77
84
  const def = getDef(base)
78
85
  const defType = getDefType(def)
79
86
  if (