Skip to content

Commit de08fcd

Browse files
authored
Sync alphalib 2025 08 28 (#248)
* sync * Update coding-style.mdc
1 parent 7949a4c commit de08fcd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1413
-415
lines changed

.cursor/rules/coding-style.mdc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description:
33
globs:
44
alwaysApply: true
55
---
6-
76
Coding style:
87

98
- Favor `async run() {` over `run = async () => {` inside ES6 classes
@@ -15,6 +14,6 @@ Coding style:
1514
- Do not wrap each function body and function call in `try`/`catch` blocks. It pollutes the code. Assume we will always have an e.g. `main().catch((err) => { console.error(err); process.exit(1) })` to catch us. I repeat: Avoid over-use of try-catch such as `try { // foo } catch (err) { console.error('error while foo'); throw err }`, assume we catch errors on a higher level and do not need the extra explananation.
1615
- Before creating new files and new code, see if we can leverage existing work, maybe slighty adapt that without breaking BC, to keep things DRY.
1716
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting everything in positive conditions, creating christmas trees.
18-
- Use Biome with 100 char line width, single quotes for JS/TS, semi: false
17+
- Use Prettier with 100 char line width, single quotes for JS/TS, semi: false
1918
- Use descriptive names: PascalCase for components/types, camelCase for variables/methods/schemas
2019
- Alphabetize imports, group by source type (built-in/external/internal)

src/alphalib/types/robots/_instructions-primitives.ts

Lines changed: 233 additions & 76 deletions
Large diffs are not rendered by default.

src/alphalib/types/robots/audio-artwork.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ If you need the image in a different format, pipe the result of this <dfn>Robot<
5858
5959
The \`method\` parameter determines whether to extract or insert.
6060
`),
61-
method: z.enum(['extract', 'insert']).default('extract').describe(`
61+
method: z
62+
.enum(['extract', 'insert'])
63+
.default('extract')
64+
.describe(`
6265
What should be done with the audio file. A value of \`"extract"\` means audio artwork will be extracted. A value of \`"insert"\` means the provided image will be inserted as audio artwork.
6366
`),
64-
change_format_if_necessary: z.boolean().default(false).describe(`
67+
change_format_if_necessary: z
68+
.boolean()
69+
.default(false)
70+
.describe(`
6571
Whether the original file should be transcoded into a new format if there is an issue with the original file.
6672
`),
6773
})

src/alphalib/types/robots/audio-concat.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,18 @@ Bit rate of the resulting audio file, in bits per second. If not specified will
8484
sample_rate: sampleRateSchema.optional().describe(`
8585
Sample rate of the resulting audio file, in Hertz. If not specified will default to the sample rate of the input audio file.
8686
`),
87-
audio_fade_seconds: z.number().default(1).describe(`
87+
audio_fade_seconds: z
88+
.number()
89+
.default(1)
90+
.describe(`
8891
When used this adds an audio fade in and out effect between each section of your concatenated audio file. The float value is used, so if you want an audio delay effect of 500 milliseconds between each video section, you would select 0.5. Integer values can also be represented.
8992
9093
This parameter does not add an audio fade effect at the beginning or end of your result audio file. If you want to do so, create an additional [🤖/audio/encode](/docs/robots/audio-encode/) <dfn>Step</dfn> and use our \`ffmpeg\` parameter as shown in this [demo](/demos/audio-encoding/ffmpeg-fade-in-and-out/).
9194
`),
92-
crossfade: z.boolean().default(false).describe(`
95+
crossfade: z
96+
.boolean()
97+
.default(false)
98+
.describe(`
9399
When set to \`true\`, this parameter enables crossfading between concatenated audio files using FFmpeg's \`acrossfade\` filter. This creates a smooth transition where the end of one audio file overlaps and blends with the beginning of the next file.
94100
95101
The duration of the crossfade is controlled by the \`audio_fade_seconds\` parameter (defaults to 1 second if \`audio_fade_seconds\` is 0).

src/alphalib/types/robots/audio-loop.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ Bit rate of the resulting audio file, in bits per second. If not specified will
6262
sample_rate: sampleRateSchema.optional().describe(`
6363
Sample rate of the resulting audio file, in Hertz. If not specified will default to the sample rate of the input audio file.
6464
`),
65-
duration: z.number().default(60).describe(`
65+
duration: z
66+
.number()
67+
.default(60)
68+
.describe(`
6669
Target duration for the whole process in seconds. The <dfn>Robot</dfn> will loop the input audio file for as long as this target duration is not reached yet.
6770
`),
6871
})

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,22 @@ Bit rate of the resulting audio file, in bits per second. If not specified will
7979
sample_rate: sampleRateSchema.optional().describe(`
8080
Sample rate of the resulting audio file, in Hertz. If not specified will default to the sample rate of the input audio file.
8181
`),
82-
duration: z.enum(['first', 'longest', 'shortest']).default('longest').describe(`
82+
duration: z
83+
.enum(['first', 'longest', 'shortest'])
84+
.default('longest')
85+
.describe(`
8386
Duration of the output file compared to the duration of all merged audio files. Can be \`"first"\` (duration of the first input file), \`"shortest"\` (duration of the shortest audio file) or \`"longest"\` for the duration of the longest input file.
8487
`),
85-
loop: z.boolean().default(false).describe(`
88+
loop: z
89+
.boolean()
90+
.default(false)
91+
.describe(`
8692
Specifies if any input files that do not match the target duration should be looped to match it. Useful for audio merging where your overlay file is typically much shorter than the main audio file.
8793
`),
88-
volume: z.enum(['average', 'sum']).default('average').describe(`
94+
volume: z
95+
.enum(['average', 'sum'])
96+
.default('average')
97+
.describe(`
8998
Valid values are \`"average"\` and \`"sum"\` here. \`"average"\` means each input is scaled 1/n (n is the number of inputs) or \`"sum"\` which means each individual audio stays on the same volume, but since we merge tracks 'on top' of each other, this could result in very loud output.
9099
`),
91100
})

src/alphalib/types/robots/audio-waveform.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,38 @@ We recommend that you use an [🤖/audio/encode](/docs/robots/audio-encode/) <df
6666
6767
Similarly, if you need the output image in a different format, please pipe the result of this <dfn>Robot</dfn> into [🤖/image/resize](/docs/robots/image-resize/).
6868
`),
69-
format: z.enum(['image', 'json']).default('image').describe(`
69+
format: z
70+
.enum(['image', 'json'])
71+
.default('image')
72+
.describe(`
7073
The format of the result file. Can be \`"image"\` or \`"json"\`. If \`"image"\` is supplied, a PNG image will be created, otherwise a JSON file.
7174
`),
72-
width: z.number().int().min(1).default(256).describe(`
75+
width: z
76+
.number()
77+
.int()
78+
.min(1)
79+
.default(256)
80+
.describe(`
7381
The width of the resulting image if the format \`"image"\` was selected.
7482
`),
75-
height: z.number().int().min(1).default(64).describe(`
83+
height: z
84+
.number()
85+
.int()
86+
.min(1)
87+
.default(64)
88+
.describe(`
7689
The height of the resulting image if the format \`"image"\` was selected.
7790
`),
78-
style: z.union([z.literal(0), z.literal(1)]).default(0).describe(`
91+
style: z
92+
.union([z.literal(0), z.literal(1)])
93+
.default(0)
94+
.describe(`
7995
Either a value of \`0\` or \`1\`, corresponding to using either the legacy waveform tool, or the new tool respectively, with the new tool offering an improved style. Other Robot parameters still function as described, with either tool.
8096
`),
81-
antialiasing: z.union([z.literal(0), z.literal(1), z.boolean()]).default(0).describe(`
97+
antialiasing: z
98+
.union([z.literal(0), z.literal(1), z.boolean()])
99+
.default(0)
100+
.describe(`
82101
Either a value of \`0\` or \`1\`, or \`true\`/\`false\`, corresponding to if you want to enable antialiasing to achieve smoother edges in the waveform graph or not.
83102
`),
84103
background_color: color_with_alpha.default('#00000000').describe(`

src/alphalib/types/robots/azure-store.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,64 @@ export const robotAzureStoreInstructionsSchema = robotBase
4646
.merge(azureBase)
4747
.extend({
4848
robot: z.literal('/azure/store'),
49-
path: z.string().default('${unique_prefix}/${file.url_name}').describe(`
49+
path: z
50+
.string()
51+
.default('${unique_prefix}/${file.url_name}')
52+
.describe(`
5053
The path at which the file is to be stored. This may include any available [Assembly variables](/docs/topics/assembly-instructions/#assembly-variables).
5154
`),
52-
content_type: z.string().optional().describe(`
55+
content_type: z
56+
.string()
57+
.optional()
58+
.describe(`
5359
The content type with which to store the file. By default this will be guessed by Azure.
5460
`),
55-
content_encoding: z.string().optional().describe(`
61+
content_encoding: z
62+
.string()
63+
.optional()
64+
.describe(`
5665
The content encoding with which to store the file. By default this will be guessed by Azure.
5766
`),
58-
content_language: z.string().optional().describe(`
67+
content_language: z
68+
.string()
69+
.optional()
70+
.describe(`
5971
The content language with which to store the file. By default this will be guessed by Azure.
6072
`),
61-
content_disposition: z.string().optional().describe(`
73+
content_disposition: z
74+
.string()
75+
.optional()
76+
.describe(`
6277
The content disposition with which to store the file. By default this will be guessed by Azure.
6378
`),
64-
cache_control: z.string().optional().describe(`
79+
cache_control: z
80+
.string()
81+
.optional()
82+
.describe(`
6583
The cache control header with which to store the file.
6684
`),
6785
// TODO: verify if this is correct.
68-
metadata: z.record(z.string()).default({}).describe(`
86+
metadata: z
87+
.record(z.string())
88+
.default({})
89+
.describe(`
6990
A JavaScript object containing a list of metadata to be set for this file on Azure, such as \`{ FileURL: "\${file.url_name}" }\`. This can also include any available [Assembly variables](/docs/topics/assembly-instructions/#assembly-variables).
7091
`),
71-
sas_expires_in: z.number().int().min(0).optional().describe(`
92+
sas_expires_in: z
93+
.number()
94+
.int()
95+
.min(0)
96+
.optional()
97+
.describe(`
7298
Set this to a number to enable shared access signatures for your stored object. This reflects the number of seconds that the signature will be valid for once the object is stored. Enabling this will attach the shared access signature (SAS) to the result URL of your object.
7399
`),
74100
sas_permissions: z
75101
.string()
76102
.regex(/^[rdw]+$/)
77103
.min(0)
78104
.max(3)
79-
.optional().describe(`
105+
.optional()
106+
.describe(`
80107
Set this to a combination of \`r\` (read), \`w\` (write) and \`d\` (delete) for your shared access signatures (SAS) permissions.
81108
`),
82109
})

src/alphalib/types/robots/backblaze-import.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ Setting this to \`true\` will enable importing files from subdirectories and sub
7171
7272
Please use the pagination parameters \`start_file_name\` and \`files_per_page\` wisely here.
7373
`),
74-
start_file_name: z.string().default('').describe(`
74+
start_file_name: z
75+
.string()
76+
.default('')
77+
.describe(`
7578
The name of the last file from the previous paging call. This tells the <dfn>Robot</dfn> to ignore all files up to and including this file.
7679
`),
7780
files_per_page: files_per_page.describe(`

src/alphalib/types/robots/backblaze-store.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ export const robotBackblazeStoreInstructionsSchema = robotBase
5151
.merge(backblazeBase)
5252
.extend({
5353
robot: z.literal('/backblaze/store'),
54-
path: z.string().default('${unique_prefix}/${file.url_name}').describe(`
54+
path: z
55+
.string()
56+
.default('${unique_prefix}/${file.url_name}')
57+
.describe(`
5558
The path at which the file is to be stored. This may include any available [Assembly variables](/docs/topics/assembly-instructions/#assembly-variables).
5659
`),
57-
headers: z.record(z.string()).default({}).describe(`
60+
headers: z
61+
.record(z.string())
62+
.default({})
63+
.describe(`
5864
An object containing a list of headers to be set for this file on backblaze, such as \`{ FileURL: "\${file.url_name}" }\`. This can also include any available [Assembly Variables](/docs/topics/assembly-instructions/#assembly-variables).
5965
6066
[Here](https://www.backblaze.com/b2/docs/b2_upload_file.html) you can find a list of available headers.

0 commit comments

Comments
 (0)