Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .cursor/rules/coding-style.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description:
globs:
alwaysApply: true
---

Coding style:

- Favor `async run() {` over `run = async () => {` inside ES6 classes
Expand All @@ -11,9 +12,20 @@ Coding style:
- Favor using real paths (`../lib/schemas.ts`) over aliases (`@/app/lib/schemas`).
- Favor `for (const comment of comments) {` over `comments.forEach((comment) => {`
- Favor named exports over default exports, with the exception of Next.js pages
- 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.
- 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.
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting everything in positive conditions, creating christmas trees.
- 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.
- If you must use try/catch, for simple cases, favor `alphalib/tryCatch.ts`
(`const [err, data] = await tryCatch(promise)`) over
`let data; try { data = await promise } catch (err) { }`
- 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.
- Favor early exits, so quickly `continue`, `return false` (or `throw` if needed), over nesting
everything in positive conditions, creating christmas trees.
- Use Prettier with 100 char line width, single quotes for JS/TS, semi: false
- Use descriptive names: PascalCase for components/types, camelCase for variables/methods/schemas
- Alphabetize imports, group by source type (built-in/external/internal)
- Favor US English over UK English, so `summarizeError` over `summarise Error`
9 changes: 0 additions & 9 deletions src/alphalib/types/robots/file-decompress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ A possible array member is only \`"meta"\`.
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.

To keep backwards compatibility, setting this parameter to \`true\` will set it to \`["meta"]\` internally.
`),
stack: z
.enum(['v1', 'v2'])
.default('v1')
.describe(`
Temporary parameter for backwards compatibility while we roll out new underlying tooling for the robot.

- \`v1\` uses the old decompression.
- \`v2\` uses the new decompression with better support for unicode and nested archives.
`),
})
.strict()
Expand Down
7 changes: 7 additions & 0 deletions src/alphalib/types/robots/image-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export const robotImageGenerateInstructionsSchema = robotBase
height: z.number().optional().describe('Height of the generated image.'),
width: z.number().optional().describe('Width of the generated image.'),
style: z.string().optional().describe('Style of the generated image.'),
num_outputs: z
.number()
.int()
.min(1)
.max(10)
.optional()
.describe('Number of image variants to generate.'),
})
.strict()

Expand Down
8 changes: 8 additions & 0 deletions src/alphalib/types/robots/image-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ Increases or decreases the saturation of the image by using a multiplier. For ex
.default(100)
.describe(`
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.
`),
contrast: z
.number()
.min(0)
.max(2)
.default(1)
.describe(`
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.
`),
watermark_url: z
.string()
Expand Down
4 changes: 2 additions & 2 deletions src/alphalib/types/robots/s3-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export const meta: RobotMetaInput = {
purpose_word: 'Amazon S3',
purpose_words: 'Export files to Amazon S3',
service_slug: 'file-exporting',
slot_count: 10,
slot_count: 2,
title: 'Export files to Amazon S3',
typical_file_size_mb: 1.2,
typical_file_type: 'file',
name: 'S3StoreRobot',
priceFactor: 10,
queueSlotCount: 10,
queueSlotCount: 2,
isAllowedForUrlTransform: true,
trackOutputFileSize: false,
isInternal: false,
Expand Down