mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
cbf9325e7e
- The element, spread, document, page operation and card unions carry a name of their own, so the declarations of every schema that holds them refer to them instead of spelling them out again. The shared declarations shrink from 9 to 5.5 MB and the server's typecheck from 4.4 to 2.9 GB, so the build fits the image's 4 GB again. - edit_book_page and revise_book_design take add by what the element is, with an id of its own; its look follows with style by that id in the same call, every look field described once. A change an assistant card kept with its look on add still reads and runs. - restore_book_page states what every element has once, then each kind's own fields and the type the five travel kinds share, without defaults; the page is read as a spread again before it goes back. - The theme links are explained once in the page edit's description, and style points a text's face, a shape's paint and outline and a photo's crop look at their one full description. - The lockup roles live in a module of their own, so the operation schemas no longer import the lockup engine, whose cycle left the operations unset in the shared tests. - The theme switches no longer fall through a comment, the newer document test follows the current revision, the line inspector names its stroke keys, a text's anchor reads no physical side, two shapes record the proportions they are drawn at, and the photo look and line tests follow the slider and the folded ornaments.
64 lines
2.8 KiB
TypeScript
64 lines
2.8 KiB
TypeScript
import { idSchema } from '../common/primitives.schema';
|
|
import { BOOK_LOCKUP_ROLES } from './book-lockup-roles';
|
|
import { BOOK_LOCKUPS } from './book-lockups.data';
|
|
import { BOOK_TEXT_EFFECT_FIELDS } from './book-text-effects.schema';
|
|
|
|
import { z } from 'zod';
|
|
|
|
/**
|
|
* The assistant's side of the text effects and the lockups: the effect fields
|
|
* a `style` or an `add` of a text may set, and the `add_lockup` operation.
|
|
* The values are the document's own (book-text-effects.schema.ts); only a line
|
|
* on what each means is added, since the tool schema is all a model reads.
|
|
*/
|
|
|
|
const f = BOOK_TEXT_EFFECT_FIELDS;
|
|
const hex = z.string().regex(/^#[0-9a-fA-F]{6}$/, 'expected #rrggbb');
|
|
|
|
/** The effect fields of a text's style, each left as it is when not named; null takes an effect off. */
|
|
export const TEXT_EFFECT_PROPS = {
|
|
transform: f.transform,
|
|
vAlign: f.vAlign,
|
|
outline: f.outline.describe('Width in mm outside the letters.'),
|
|
shadow: f.shadow.describe('Hard, never blurred; dx, dy in mm.'),
|
|
highlight: f.highlight.describe('A marker band behind each line; pads in mm.'),
|
|
curve: f.curve.describe('One line on an arc (bend > 0 arches up) or round a circle (start: degrees, 0 top).'),
|
|
fillPaint: f.fillPaint.describe('Replaces color: solid (alpha 0 is hollow, with an outline) or a gallery photo.'),
|
|
fit: f.fit.describe('shrink: the largest size up to size that holds the frame.'),
|
|
};
|
|
|
|
const lockupIds = BOOK_LOCKUPS.map((l) => l.id) as [string, ...string[]];
|
|
|
|
/** Every lockup by id; the ids say what each sets. */
|
|
export const bookLockupIdSchema = z
|
|
.enum(lockupIds)
|
|
.describe('A set title, badge, postmark, quote, caption or chapter mark.');
|
|
|
|
/** The words of a lockup, by the role each plays. */
|
|
export const bookLockupWordsSchema = z
|
|
.strictObject(Object.fromEntries(BOOK_LOCKUP_ROLES.map((r) => [r, z.string().max(200).optional()])))
|
|
.describe('Words by role (label as "Day"); a part without words is left out.');
|
|
|
|
/**
|
|
* Set a lockup: a title, badge, postmark, quote, caption or chapter mark made
|
|
* of a few texts and shapes that belong together. Placed in `box`, or at its
|
|
* own size centred on the page; every text in it fits its frame.
|
|
*/
|
|
export const bookAddLockupOpSchema = z.strictObject({
|
|
op: z.literal('add_lockup'),
|
|
lockup: bookLockupIdSchema,
|
|
words: bookLockupWordsSchema,
|
|
box: z
|
|
.strictObject({
|
|
x: z.number().finite().min(-10000).max(10000),
|
|
y: z.number().finite().min(-10000).max(10000),
|
|
w: z.number().finite().min(1).max(10000),
|
|
h: z.number().finite().min(1).max(10000),
|
|
})
|
|
.optional(),
|
|
ink: hex.optional(),
|
|
accent: hex.describe('Best taken from the photos.').optional(),
|
|
photoId: idSchema.describe('Fills the letters of photo-word.').optional(),
|
|
});
|
|
export type BookAddLockupOp = z.infer<typeof bookAddLockupOpSchema>;
|