Skip to content

Commit a64e858

Browse files
authored
Sync alphalib 2025 11 05 (#266)
1 parent 678aa69 commit a64e858

File tree

5 files changed

+32
-14
lines changed

5 files changed

+32
-14
lines changed

.cursor/rules/coding-style.mdc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description:
33
globs:
44
alwaysApply: true
55
---
6+
67
Coding style:
78

89
- Favor `async run() {` over `run = async () => {` inside ES6 classes
@@ -11,9 +12,20 @@ Coding style:
1112
- Favor using real paths (`../lib/schemas.ts`) over aliases (`@/app/lib/schemas`).
1213
- Favor `for (const comment of comments) {` over `comments.forEach((comment) => {`
1314
- Favor named exports over default exports, with the exception of Next.js pages
14-
- 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.
15-
- 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.
16-
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting everything in positive conditions, creating christmas trees.
15+
- Do not wrap each function body and function call in `try`/`catch` blocks. It pollutes the code.
16+
Assume we will always have an e.g.
17+
`main().catch((err) => { console.error(err); process.exit(1) })` to catch us. I repeat: Avoid
18+
over-use of try-catch such as
19+
`try { // foo } catch (err) { console.error('error while foo'); throw err }`, assume we catch
20+
errors on a higher level and do not need the extra explananation.
21+
- If you must use try/catch, for simple cases, favor `alphalib/tryCatch.ts`
22+
(`const [err, data] = await tryCatch(promise)`) over
23+
`let data; try { data = await promise } catch (err) { }`
24+
- Before creating new files and new code, see if we can leverage existing work, maybe slighty adapt
25+
that without breaking BC, to keep things DRY.
26+
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting
27+
everything in positive conditions, creating christmas trees.
1728
- Use Prettier with 100 char line width, single quotes for JS/TS, semi: false
1829
- Use descriptive names: PascalCase for components/types, camelCase for variables/methods/schemas
1930
- Alphabetize imports, group by source type (built-in/external/internal)
31+
- Favor US English over UK English, so `summarizeError` over `summarise Error`

src/alphalib/types/robots/file-decompress.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,6 @@ A possible array member is only \`"meta"\`.
8787
You might see an error when trying to extract metadata from the files inside your archive. This happens, for example, for files with a size of zero bytes. Setting this to \`true\` will cause the <dfn>Robot</dfn> to not stop the file decompression (and the entire <dfn>Assembly</dfn>) when that happens.
8888
8989
To keep backwards compatibility, setting this parameter to \`true\` will set it to \`["meta"]\` internally.
90-
`),
91-
stack: z
92-
.enum(['v1', 'v2'])
93-
.default('v1')
94-
.describe(`
95-
Temporary parameter for backwards compatibility while we roll out new underlying tooling for the robot.
96-
97-
- \`v1\` uses the old decompression.
98-
- \`v2\` uses the new decompression with better support for unicode and nested archives.
9990
`),
10091
})
10192
.strict()

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ export const robotImageGenerateInstructionsSchema = robotBase
4444
height: z.number().optional().describe('Height of the generated image.'),
4545
width: z.number().optional().describe('Width of the generated image.'),
4646
style: z.string().optional().describe('Style of the generated image.'),
47+
num_outputs: z
48+
.number()
49+
.int()
50+
.min(1)
51+
.max(10)
52+
.optional()
53+
.describe('Number of image variants to generate.'),
4754
})
4855
.strict()
4956

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ Increases or decreases the saturation of the image by using a multiplier. For ex
416416
.default(100)
417417
.describe(`
418418
Changes the hue by rotating the color of the image. The value \`100\` would produce no change whereas \`0\` and \`200\` will negate the colors in the image.
419+
`),
420+
contrast: z
421+
.number()
422+
.min(0)
423+
.max(2)
424+
.default(1)
425+
.describe(`
426+
Adjusts the contrast of the image. A value of \`1\` produces no change. Values below \`1\` decrease contrast (with \`0\` being minimum contrast), and values above \`1\` increase contrast (with \`2\` being maximum contrast). This works like the \`brightness\` parameter.
419427
`),
420428
watermark_url: z
421429
.string()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export const meta: RobotMetaInput = {
2828
purpose_word: 'Amazon S3',
2929
purpose_words: 'Export files to Amazon S3',
3030
service_slug: 'file-exporting',
31-
slot_count: 10,
31+
slot_count: 2,
3232
title: 'Export files to Amazon S3',
3333
typical_file_size_mb: 1.2,
3434
typical_file_type: 'file',
3535
name: 'S3StoreRobot',
3636
priceFactor: 10,
37-
queueSlotCount: 10,
37+
queueSlotCount: 2,
3838
isAllowedForUrlTransform: true,
3939
trackOutputFileSize: false,
4040
isInternal: false,

0 commit comments

Comments
 (0)