From 499458f8b25494f7a12f27ce5fae755175f19404 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 22 Oct 2026 21:25:46 +0000 Subject: [PATCH] feat(assistant): book page changes show as cards with the page before and after A held book write is described with its findings, drawn as a thumbnail pair, bounced once when a severe finding is left, and undone in one step. --- .../cards/book/BookPageCard.test.tsx | 193 ++++++++ .../Assistant/cards/book/BookPageSlots.tsx | 122 +++++ .../Assistant/cards/book/BookPageThumbs.tsx | 85 ++++ .../cards/book/bookCardModel.test.ts | 121 +++++ .../Assistant/cards/book/bookCardModel.ts | 146 ++++++ .../Assistant/cards/book/bookLook.ts | 54 +++ .../Assistant/cards/book/bookViews.tsx | 19 + client/src/components/Studio/SpreadThumb.tsx | 62 +++ .../src/components/Studio/StudioSidebar.tsx | 33 +- client/tests/unit/studio/spreadThumb.test.tsx | 63 +++ .../src/nest/assistant/assistant-book-gate.ts | 146 ++++++ .../assistant/assistant-tools.constants.ts | 9 + .../nest/assistant/assistant-undo.helpers.ts | 39 +- .../nest/assistant/cards/book/book-change.ts | 231 ++++++++++ .../nest/assistant/cards/book/book-trial.ts | 285 ++++++++++++ .../nest/assistant/cards/book/book-undo.ts | 83 ++++ server/src/nest/assistant/cards/book/index.ts | 70 +++ .../e2e/assistant-book-cards.e2e.test.ts | 339 ++++++++++++++ .../assistant/assistant-book-gate.test.ts | 176 ++++++++ .../assistant/assistant-undo.helpers.test.ts | 14 +- .../assistant/cards/book/book-cards.test.ts | 424 ++++++++++++++++++ .../assistant/cards/book-page.card.spec.ts | 105 +++++ shared/src/assistant/cards/book-page.card.ts | 97 ++++ shared/src/assistant/cards/book.contract.ts | 23 + shared/src/i18n/ar/assistantBook.ts | 69 +++ shared/src/i18n/az/assistantBook.ts | 53 +++ shared/src/i18n/br/assistantBook.ts | 53 +++ shared/src/i18n/ca/assistantBook.ts | 53 +++ shared/src/i18n/cs/assistantBook.ts | 57 +++ shared/src/i18n/de/assistantBook.ts | 53 +++ shared/src/i18n/en/assistantBook.ts | 53 +++ shared/src/i18n/es/assistantBook.ts | 53 +++ shared/src/i18n/et/assistantBook.ts | 53 +++ shared/src/i18n/fr/assistantBook.ts | 53 +++ shared/src/i18n/gr/assistantBook.ts | 53 +++ shared/src/i18n/hu/assistantBook.ts | 53 +++ shared/src/i18n/id/assistantBook.ts | 49 ++ shared/src/i18n/it/assistantBook.ts | 53 +++ shared/src/i18n/ja/assistantBook.ts | 49 ++ shared/src/i18n/ko/assistantBook.ts | 49 ++ shared/src/i18n/nl/assistantBook.ts | 53 +++ shared/src/i18n/pl/assistantBook.ts | 61 +++ shared/src/i18n/ru/assistantBook.ts | 61 +++ shared/src/i18n/sk/assistantBook.ts | 57 +++ shared/src/i18n/sv/assistantBook.ts | 53 +++ shared/src/i18n/th/assistantBook.ts | 49 ++ shared/src/i18n/tr/assistantBook.ts | 53 +++ shared/src/i18n/uk/assistantBook.ts | 61 +++ shared/src/i18n/vi/assistantBook.ts | 49 ++ shared/src/i18n/zh-TW/assistantBook.ts | 49 ++ shared/src/i18n/zh/assistantBook.ts | 49 ++ 51 files changed, 4361 insertions(+), 29 deletions(-) create mode 100644 client/src/components/Assistant/cards/book/BookPageCard.test.tsx create mode 100644 client/src/components/Assistant/cards/book/BookPageSlots.tsx create mode 100644 client/src/components/Assistant/cards/book/BookPageThumbs.tsx create mode 100644 client/src/components/Assistant/cards/book/bookCardModel.test.ts create mode 100644 client/src/components/Assistant/cards/book/bookCardModel.ts create mode 100644 client/src/components/Assistant/cards/book/bookLook.ts create mode 100644 client/src/components/Assistant/cards/book/bookViews.tsx create mode 100644 client/src/components/Studio/SpreadThumb.tsx create mode 100644 client/tests/unit/studio/spreadThumb.test.tsx create mode 100644 server/src/nest/assistant/assistant-book-gate.ts create mode 100644 server/src/nest/assistant/cards/book/book-change.ts create mode 100644 server/src/nest/assistant/cards/book/book-trial.ts create mode 100644 server/src/nest/assistant/cards/book/book-undo.ts create mode 100644 server/src/nest/assistant/cards/book/index.ts create mode 100644 server/tests/e2e/assistant-book-cards.e2e.test.ts create mode 100644 server/tests/unit/nest/assistant/assistant-book-gate.test.ts create mode 100644 server/tests/unit/nest/assistant/cards/book/book-cards.test.ts create mode 100644 shared/src/assistant/cards/book-page.card.spec.ts create mode 100644 shared/src/assistant/cards/book-page.card.ts create mode 100644 shared/src/assistant/cards/book.contract.ts create mode 100644 shared/src/i18n/ar/assistantBook.ts create mode 100644 shared/src/i18n/az/assistantBook.ts create mode 100644 shared/src/i18n/br/assistantBook.ts create mode 100644 shared/src/i18n/ca/assistantBook.ts create mode 100644 shared/src/i18n/cs/assistantBook.ts create mode 100644 shared/src/i18n/de/assistantBook.ts create mode 100644 shared/src/i18n/en/assistantBook.ts create mode 100644 shared/src/i18n/es/assistantBook.ts create mode 100644 shared/src/i18n/et/assistantBook.ts create mode 100644 shared/src/i18n/fr/assistantBook.ts create mode 100644 shared/src/i18n/gr/assistantBook.ts create mode 100644 shared/src/i18n/hu/assistantBook.ts create mode 100644 shared/src/i18n/id/assistantBook.ts create mode 100644 shared/src/i18n/it/assistantBook.ts create mode 100644 shared/src/i18n/ja/assistantBook.ts create mode 100644 shared/src/i18n/ko/assistantBook.ts create mode 100644 shared/src/i18n/nl/assistantBook.ts create mode 100644 shared/src/i18n/pl/assistantBook.ts create mode 100644 shared/src/i18n/ru/assistantBook.ts create mode 100644 shared/src/i18n/sk/assistantBook.ts create mode 100644 shared/src/i18n/sv/assistantBook.ts create mode 100644 shared/src/i18n/th/assistantBook.ts create mode 100644 shared/src/i18n/tr/assistantBook.ts create mode 100644 shared/src/i18n/uk/assistantBook.ts create mode 100644 shared/src/i18n/vi/assistantBook.ts create mode 100644 shared/src/i18n/zh-TW/assistantBook.ts create mode 100644 shared/src/i18n/zh/assistantBook.ts diff --git a/client/src/components/Assistant/cards/book/BookPageCard.test.tsx b/client/src/components/Assistant/cards/book/BookPageCard.test.tsx new file mode 100644 index 000000000..d2b3a2c01 --- /dev/null +++ b/client/src/components/Assistant/cards/book/BookPageCard.test.tsx @@ -0,0 +1,193 @@ +/** + * FE-AI-BOOKPAGE-001 to FE-AI-BOOKPAGE-005 + * + * The photo book's change rows in the Studio's chat: the pages a change works + * on named as the Studio names them, its facts as badges (new pages, where a + * moved page lands, the layout, new photos, findings to check), the page + * before and after drawn from the book open in the Studio, a thumbnail that + * shows its page, each finding named once, and a receipt that opens the + * Studio on the page. + */ +import { type AssistantApplied, type AssistantChangePreview, blankBook, type BookPageCard } from '@trek/shared'; +import type { ReactNode } from 'react'; +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import { act, fireEvent, render, screen } from '../../../../../tests/helpers/render'; +import { useStudioStore } from '../../../../store/studioStore'; +import AssistantChangeCard from '../../AssistantChangeCard'; +import type { ChangeItem } from '../../assistantParts'; +import { type AssistantView, AssistantViewContext } from '../../assistantViewContext'; + +const STUDIO = useStudioStore.getState(); + +/** A blank book with readable ids: sp-1 the cover, sp-2 the first page, sp-3 its double page, sp-4 and sp-5. */ +function book() { + let seq = 0; + return blankBook({ title: 'Lisbon', newId: (prefix) => `${prefix}-${++seq}` }); +} + +function card(over: Partial = {}): BookPageCard { + return { + kind: 'bookPage', + journeyId: 3, + change: 'changed', + baseVersion: 4, + pages: [{ spreadId: 'sp-3', index: 2, role: 'inner', number: 1, photos: 0 }], + count: 0, + movedTo: null, + ops: [{ op: 'layout', template: 'two-up' }], + cover: null, + layout: { kind: 'template', id: 'two-up', name: null }, + photosAdded: 2, + findings: [ + { code: 'empty_frame', severity: 'severe' }, + { code: 'empty_frame', severity: 'severe' }, + { code: 'parked', severity: 'info' }, + ], + moreFindings: 1, + ...over, + }; +} + +function item(state: ChangeItem['state'], held: BookPageCard, verbKey: AssistantChangePreview['verbKey']): ChangeItem { + const preview: AssistantChangePreview = { + toolCallId: 'w1', + verbKey, + subject: '', + rows: [], + dayId: null, + placeIds: [], + undoable: true, + card: held, + }; + const receipt: AssistantApplied = { toolCallId: 'w1', entity: 'book_page', ids: [], dayId: null, undoUntil: null }; + return { toolCallId: 'w1', preview, applied: state === 'applied' ? receipt : null, state, card: held }; +} + +/** The chat of journey 3's Studio (its key is the negated journey id), the book every card here is about. */ +function inView(ui: ReactNode, view: Partial = {}) { + const value: AssistantView = { tripId: -3, variant: 'window', ...view }; + return render({ui}); +} + +afterEach(() => { + useStudioStore.setState(STUDIO, true); + vi.restoreAllMocks(); +}); + +describe('the book page card', () => { + it('FE-AI-BOOKPAGE-001: a waiting edit names its page and facts, and draws the page before and after from the Studio', async () => { + useStudioStore.setState({ doc: book(), activeSpread: 0 }); + inView(); + expect(screen.getByText('Double page 1')).toBeInTheDocument(); + expect(screen.getByText('Change the page')).toBeInTheDocument(); + expect(screen.getByText('Two full pages')).toBeInTheDocument(); + expect(screen.getByText('+2 photos')).toBeInTheDocument(); + // Two faults and one more past the card; the parked element is context, not counted. + expect(screen.getByText('3 things to check')).toBeInTheDocument(); + expect(screen.getAllByText('An empty photo frame')).toHaveLength(1); + expect(screen.getByText('Parked elements')).toBeInTheDocument(); + + expect(await screen.findByText('Before')).toBeInTheDocument(); + expect(screen.getByText('After')).toBeInTheDocument(); + const thumbs = screen.getAllByRole('button', { name: 'Show this page' }); + expect(thumbs).toHaveLength(2); + // The page after holds the two frames of the layout; the page before is blank. + const sheets = thumbs.map((thumb) => thumb.querySelectorAll('div').length); + expect(sheets[1]).toBeGreaterThan(sheets[0] ?? 0); + fireEvent.click(thumbs[1] as HTMLElement); + expect(useStudioStore.getState().activeSpread).toBe(2); + }); + + it('FE-AI-BOOKPAGE-002: a cover change draws the cover after it; a new book names itself and its pages, drawn by none', async () => { + useStudioStore.setState({ doc: book() }); + const cover = card({ + pages: [{ spreadId: 'sp-1', index: 0, role: 'cover', number: null, photos: 0 }], + ops: [], + cover: { template: 'cover-full', photoId: null, title: 'Portugal', subtitle: null }, + layout: { kind: 'template', id: 'cover-full', name: null }, + photosAdded: 0, + findings: [], + moreFindings: 0, + }); + const first = inView(); + expect(screen.getByText('Cover')).toBeInTheDocument(); + expect(screen.getByText('Change the cover')).toBeInTheDocument(); + expect(screen.getByText('Full bleed')).toBeInTheDocument(); + expect(await screen.findByText('After')).toBeInTheDocument(); + expect(screen.queryByText(/things? to check/)).toBeNull(); + first.unmount(); + + const fresh = card({ change: 'new', baseVersion: null, pages: [], count: 5, ops: [], layout: null }); + const quiet = { ...fresh, photosAdded: 0, findings: [], moreFindings: 0 }; + inView(); + expect(screen.getByText('New photo book')).toBeInTheDocument(); + expect(screen.getByText('5 new pages')).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'Show this page' })).toBeNull(); + }); + + it('FE-AI-BOOKPAGE-003: a move names where the page lands; a delete names every page it takes, each drawn alone', async () => { + useStudioStore.setState({ doc: book() }); + const moved = card({ change: 'moved', movedTo: 3, ops: [], layout: null, photosAdded: 0, findings: [] }); + const quiet = { ...moved, moreFindings: 0 }; + const first = inView(); + expect(screen.getAllByText('Double page 1')[0]).toBeInTheDocument(); + expect(screen.getByText('Double page 3')).toBeInTheDocument(); + expect(await screen.findAllByRole('button', { name: 'Show this page' })).toHaveLength(1); + expect(screen.queryByText('Before')).toBeNull(); + first.unmount(); + + const pages = [ + { spreadId: 'sp-3', index: 2, role: 'inner' as const, number: 1, photos: 0 }, + { spreadId: 'sp-9', index: 3, role: 'inner' as const, number: 2, photos: 1 }, + ]; + const gone = card({ change: 'willDelete', pages, count: 2, ops: [], layout: null, photosAdded: 0, findings: [] }); + inView(); + expect(screen.getByText('Double page 1, Double page 2')).toBeInTheDocument(); + expect(screen.getByText('Delete pages from the book')).toBeInTheDocument(); + }); + + it('FE-AI-BOOKPAGE-004: a receipt shows the page as it is now and opens the Studio on it; a deleted page opens the book', async () => { + useStudioStore.setState({ doc: book() }); + const onOpen = vi.fn(); + const first = inView(, { onOpen }); + expect(await screen.findAllByRole('button', { name: 'Show this page' })).toHaveLength(1); + expect(screen.queryByText('After')).toBeNull(); + fireEvent.click(screen.getByRole('button', { name: 'Show in the Studio' })); + expect(onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/journey/3/studio?page=sp-3' }); + first.unmount(); + + const gone = card({ change: 'willDelete', ops: [], layout: null, findings: [], moreFindings: 0 }); + inView(, { onOpen }); + fireEvent.click(screen.getByRole('button', { name: 'Show in the Studio' })); + expect(onOpen).toHaveBeenLastCalledWith({ kind: 'page', path: '/journey/3/studio' }); + }); + + it('FE-AI-BOOKPAGE-005: outside the Studio, or on another book, the card keeps its facts and draws no page', async () => { + const first = inView(); + expect(screen.getByText('Double page 1')).toBeInTheDocument(); + expect(screen.getByText('3 things to check')).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'Show this page' })).toBeNull(); + first.unmount(); + + // The Studio holds a book, but the chat is another journey's or a trip's: that book may not be this card's. + useStudioStore.setState({ doc: book() }); + const pending = ; + // The control first, which also loads the lazy thumbnails: journey 3's own chat draws the page before and after. + const own = inView(pending); + expect(await screen.findAllByRole('button', { name: 'Show this page' })).toHaveLength(2); + own.unmount(); + const drawsIn = async (tripId: number) => { + const other = inView(pending, { tripId }); + expect(screen.getByText('Double page 1')).toBeInTheDocument(); + await act(async () => { + await import('./BookPageThumbs'); + }); + const drawn = screen.queryAllByRole('button', { name: 'Show this page' }).length; + other.unmount(); + return drawn; + }; + expect(await drawsIn(-9)).toBe(0); + expect(await drawsIn(4)).toBe(0); + }); +}); diff --git a/client/src/components/Assistant/cards/book/BookPageSlots.tsx b/client/src/components/Assistant/cards/book/BookPageSlots.tsx new file mode 100644 index 000000000..4d642e94c --- /dev/null +++ b/client/src/components/Assistant/cards/book/BookPageSlots.tsx @@ -0,0 +1,122 @@ +import type { BookCardFinding, BookPageCard } from '@trek/shared'; +import { + CircleAlert, + FilePlus, + ImagePlus, + Info, + LayoutTemplate, + type LucideIcon, + MoveVertical, + TriangleAlert, +} from 'lucide-react'; +import { lazy, Suspense } from 'react'; + +import { useTranslation } from '../../../../i18n'; +import type { PillTone } from '../../../Planner/planParts'; +import type { ChangeItem } from '../../assistantParts'; +import { CardFacts, Fact, FactChange } from '../parts/CardFacts'; +import { distinctFindings, findingLabel, findingsToCheck, layoutLabel, pageLabel, subjectOf } from './bookCardModel'; + +/** + * What a change row of the photo book adds to the row it already is (its + * verb): the pages it works on as the subject, in the Studio's own words; on + * the faint line the pages it adds, where a moved page lands, the layout, the + * photos it brings and how many findings want a look; under the row the page + * before and after (BookPageThumbs) and what the server's check found. + */ + +interface SlotProps { + card: BookPageCard; + item: ChangeItem; +} + +const STRUCK: ReadonlySet = new Set(['discarded', 'expired']); + +const BookPageThumbs = lazy(() => import('./BookPageThumbs')); + +/** How each severity of finding looks. */ +const SEVERITY_LOOK = { + severe: { Icon: CircleAlert, tone: 'danger' }, + warn: { Icon: TriangleAlert, tone: 'warning' }, + info: { Icon: Info, tone: 'neutral' }, +} as const satisfies Record; + +/** The pages the change works on, in bold, struck through once it was discarded or ran out. */ +export function BookPageSubject({ card, item }: SlotProps) { + const { t } = useTranslation(); + const subject = subjectOf(card, t); + return ( + + {subject} + + ); +} + +/** The facts of the change: pages it adds, where a moved page lands, the layout, new photos, findings to check. */ +export function BookPageFacts({ card }: SlotProps) { + const { t } = useTranslation(); + const layout = layoutLabel(card.layout, t); + const check = findingsToCheck(card); + const moved = card.movedTo === null ? null : card.pages[0]; + return ( + <> + {card.change === 'new' && card.count > 0 && ( + + )} + {moved && ( + + )} + {layout && } + {card.photosAdded > 0 && ( + + )} + {check.count > 0 && ( + + )} + + ); +} + +/** + * The page before and after the change, or as it is now once applied, and + * each kind of finding once. The pages are drawn by the editor's own view, + * loaded with the first page card: the chat outside the Studio never needs it. + */ +export function BookPageBody({ card, item }: SlotProps) { + const { t } = useTranslation(); + const findings = distinctFindings(card); + return ( +
+ + + + {findings.length > 0 && ( + + {findings.map((finding) => ( + + ))} + + )} +
+ ); +} diff --git a/client/src/components/Assistant/cards/book/BookPageThumbs.tsx b/client/src/components/Assistant/cards/book/BookPageThumbs.tsx new file mode 100644 index 000000000..7aaae4005 --- /dev/null +++ b/client/src/components/Assistant/cards/book/BookPageThumbs.tsx @@ -0,0 +1,85 @@ +import type { BookPageCard, BookPageSetup, BookSpread } from '@trek/shared'; +import { useMemo } from 'react'; + +import { useTranslation } from '../../../../i18n'; +import { useStudioStore } from '../../../../store/studioStore'; +import { SpreadThumb } from '../../../Studio/SpreadThumb'; +import type { ChangeItem } from '../../assistantParts'; +import { useAssistantScope } from '../../assistantViewContext'; +import { pageViewOf } from './bookCardModel'; + +/** + * The page of a book change drawn small, from the book open in the Studio: + * while the change waits, the page as it is and as the change would leave it; + * once applied, the page as it is now. Each is the editor's own view under a + * scale, so the card can never look different from the page. Pressing one + * shows that page in the Studio. Nothing where the Studio does not hold the + * page, outside the Studio or on another book. + */ + +/** A thumbnail's height in pixels; its width follows the page. */ +const THUMB_HEIGHT = 72; + +/** One page drawn small; pressing it shows the page in the Studio. */ +function PageThumb({ + spread, + page, + caption, + onShow, +}: { + spread: BookSpread; + page: BookPageSetup; + caption: string | null; + onShow: () => void; +}) { + const { t } = useTranslation(); + const wide = spread.role === 'inner' ? page.pageWidth * 2 : page.pageWidth; + return ( + + ); +} + +export default function BookPageThumbs({ card, item }: { card: BookPageCard; item: ChangeItem }) { + const { t } = useTranslation(); + const scope = useAssistantScope(); + const doc = useStudioStore((s) => s.doc); + const setActiveSpread = useStudioStore((s) => s.setActiveSpread); + const view = useMemo(() => pageViewOf(card, doc, item.state), [card, doc, item.state]); + // The Studio's book is this card's only in this journey's chat; anywhere else it may be another or an old copy. + const ownBook = scope.kind === 'journey' && scope.journeyId === card.journeyId; + if (!ownBook || !view || !doc) return null; + const show = () => setActiveSpread(view.index); + return ( +
+ {view.before && ( + + )} + {view.after && ( + + )} +
+ ); +} diff --git a/client/src/components/Assistant/cards/book/bookCardModel.test.ts b/client/src/components/Assistant/cards/book/bookCardModel.test.ts new file mode 100644 index 000000000..0c9166095 --- /dev/null +++ b/client/src/components/Assistant/cards/book/bookCardModel.test.ts @@ -0,0 +1,121 @@ +/** + * FE-AI-BOOKPAGE-010 to FE-AI-BOOKPAGE-014 + * + * The pure side of the book's page card: a page named as the Studio names + * it, a layout and a finding by their words, the findings worth a look, the + * spreads the card draws from the book on screen for each state of a change, + * and where an applied change opens the Studio. + */ +import { blankBook, type BookCardPage, type BookPageCard } from '@trek/shared'; +import { describe, expect, it } from 'vitest'; + +import { + distinctFindings, + findingLabel, + findingsToCheck, + layoutLabel, + pageLabel, + pageViewOf, + subjectOf, +} from './bookCardModel'; +import { studioTarget } from './bookLook'; + +/** Echoes the key and its parameters, so each test reads which words were asked for. */ +const t = (key: string, params?: Record) => + params ? `${key} ${JSON.stringify(params)}` : key; + +function book() { + let seq = 0; + return blankBook({ title: 'Lisbon', newId: (prefix) => `${prefix}-${++seq}` }); +} + +const INNER: BookCardPage = { spreadId: 'sp-3', index: 2, role: 'inner', number: 1, photos: 0 }; + +function card(over: Partial = {}): BookPageCard { + return { + kind: 'bookPage', + journeyId: 3, + change: 'changed', + baseVersion: 4, + pages: [INNER], + count: 0, + movedTo: null, + ops: [{ op: 'layout', template: 'two-up' }], + cover: null, + layout: null, + photosAdded: 0, + findings: [], + moreFindings: 0, + ...over, + }; +} + +describe('bookCardModel', () => { + it('FE-AI-BOOKPAGE-010: a page is the cover, a single page or a numbered double page; a new book is named as one', () => { + expect(pageLabel(INNER, t)).toBe('assistant.card.book.spread {"page":1}'); + expect(pageLabel({ ...INNER, number: null }, t)).toBe('assistant.card.book.spreadAny'); + expect(pageLabel({ ...INNER, role: 'cover', number: null }, t)).toBe('assistant.card.book.cover'); + expect(pageLabel({ ...INNER, role: 'back', number: null }, t)).toBe('assistant.card.book.back'); + expect(subjectOf(card({ pages: [] }), t)).toBe('assistant.card.book.newBook'); + expect(subjectOf(card({ pages: [INNER, { ...INNER, role: 'last', number: null }] }), t)).toBe( + 'assistant.card.book.spread {"page":1}, assistant.card.book.last' + ); + }); + + it('FE-AI-BOOKPAGE-011: a layout is named by its template, its grid, its own name or as laid out again', () => { + expect(layoutLabel({ kind: 'template', id: 'two-up', name: null }, t)).toBe('journey.studio.tpl.twoUp'); + expect(layoutLabel({ kind: 'template', id: 'cover-full', name: null }, t)).toBe('journey.studio.tpl.coverFull'); + expect(layoutLabel({ kind: 'grid', id: 'two-across', name: null }, t)).toBe('assistant.card.book.grid {"count":2}'); + expect(layoutLabel({ kind: 'saved', id: 'lay-1', name: 'Mine' }, t)).toBe('Mine'); + expect(layoutLabel({ kind: 'saved', id: 'lay-1', name: null }, t)).toBe('lay-1'); + expect(layoutLabel({ kind: 'auto', id: 'auto', name: null }, t)).toBe('assistant.card.book.layoutAuto'); + expect(layoutLabel({ kind: 'template', id: 'from-a-later-build', name: null }, t)).toBeNull(); + expect(layoutLabel(null, t)).toBeNull(); + }); + + it('FE-AI-BOOKPAGE-012: faults and warnings are counted with those past the card, each finding named once', () => { + const findings: BookPageCard['findings'] = [ + { code: 'overlap', severity: 'severe' }, + { code: 'overlap', severity: 'severe' }, + { code: 'low_dpi', severity: 'warn' }, + { code: 'parked', severity: 'info' }, + ]; + expect(findingsToCheck(card({ findings, moreFindings: 2 }))).toEqual({ count: 5, severe: true }); + expect(findingsToCheck(card({ findings: [{ code: 'parked', severity: 'info' }] }))).toEqual({ + count: 0, + severe: false, + }); + const named = distinctFindings(card({ findings })); + expect(named.map((finding) => finding.code)).toEqual(['overlap', 'low_dpi', 'parked']); + expect(findingLabel({ code: 'low_dpi', severity: 'warn' }, t)).toBe('assistant.card.book.finding.low_dpi'); + }); + + it('FE-AI-BOOKPAGE-013: a waiting edit or cover draws before and after; a move alone; new pages, other books and failures none', () => { + const doc = book(); + const edit = pageViewOf(card(), doc, 'pending'); + expect(edit?.index).toBe(2); + expect(edit?.before?.elements).toEqual([]); + expect(edit?.after?.elements.filter((element) => element.kind === 'photo')).toHaveLength(2); + const cover = card({ + pages: [{ ...INNER, spreadId: 'sp-1', index: 0, role: 'cover', number: null }], + ops: [], + cover: { template: 'cover-full', photoId: null, title: 'Portugal', subtitle: null }, + }); + expect(pageViewOf(cover, doc, 'applying')?.after?.id).toBe('sp-1'); + expect(pageViewOf(card({ change: 'moved', ops: [], movedTo: 1 }), doc, 'pending')).toMatchObject({ after: null }); + expect(pageViewOf(card({ change: 'new' }), doc, 'pending')).toBeNull(); + expect(pageViewOf(card({ pages: [{ ...INNER, spreadId: 'sp-elsewhere' }] }), doc, 'pending')).toBeNull(); + expect(pageViewOf(card(), null, 'pending')).toBeNull(); + for (const state of ['failed', 'discarded', 'expired'] as const) expect(pageViewOf(card(), doc, state)).toBeNull(); + // An operation the book on screen refuses draws the page as it is, nothing after it. + const refused = card({ ops: [{ op: 'remove', elementIds: ['p-nowhere'], park: true }] }); + expect(pageViewOf(refused, doc, 'pending')).toMatchObject({ after: null }); + }); + + it('FE-AI-BOOKPAGE-014: once applied the page is drawn as it is now, and it opens the Studio on that page', () => { + const doc = book(); + expect(pageViewOf(card({ change: 'new' }), doc, 'applied')).toMatchObject({ before: null, after: { id: 'sp-3' } }); + expect(studioTarget(3, 'sp-3')).toEqual({ kind: 'page', path: '/journey/3/studio?page=sp-3' }); + expect(studioTarget(3, null)).toEqual({ kind: 'page', path: '/journey/3/studio' }); + }); +}); diff --git a/client/src/components/Assistant/cards/book/bookCardModel.ts b/client/src/components/Assistant/cards/book/bookCardModel.ts new file mode 100644 index 000000000..3f481799f --- /dev/null +++ b/client/src/components/Assistant/cards/book/bookCardModel.ts @@ -0,0 +1,146 @@ +import { + applyBookOps, + type BookCardCover, + type BookCardFinding, + type BookCardLayout, + type BookCardPage, + type BookDocument, + type BookFindingCode, + type BookPageCard, + type BookSpread, + findBookGrid, + findBookTemplate, + setBookCover, +} from '@trek/shared'; + +import type { ChangeState } from '../../assistantParts'; + +/** + * The pure side of the book's page card: how a page is named, what a layout + * and a finding are called, and which spreads the card draws. The page before + * and after a change comes from the Studio's own book with the shared engine, + * the one the server tried the change with, so the card shows what the change + * does to the page as it is on screen. + */ + +type Translate = (key: string, params?: Record) => string; + +/** The single pages by their role; a double page is named by its number. */ +const ROLE_LOOK = { + cover: { labelKey: 'assistant.card.book.cover' }, + first: { labelKey: 'assistant.card.book.first' }, + last: { labelKey: 'assistant.card.book.last' }, + back: { labelKey: 'assistant.card.book.back' }, +} as const satisfies Record, { labelKey: string }>; + +/** What each finding of the server's check is called. A table, so a new code fails to compile until it has words. */ +const FINDING_LOOK: Readonly> = { + overlap: { labelKey: 'assistant.card.book.finding.overlap' }, + fold: { labelKey: 'assistant.card.book.finding.fold' }, + trim: { labelKey: 'assistant.card.book.finding.trim' }, + empty_frame: { labelKey: 'assistant.card.book.finding.empty_frame' }, + low_dpi: { labelKey: 'assistant.card.book.finding.low_dpi' }, + focal_cut: { labelKey: 'assistant.card.book.finding.focal_cut' }, + text_overflow: { labelKey: 'assistant.card.book.finding.text_overflow' }, + parked: { labelKey: 'assistant.card.book.finding.parked' }, + hidden_photo: { labelKey: 'assistant.card.book.finding.hidden_photo' }, + not_in_gallery: { labelKey: 'assistant.card.book.finding.not_in_gallery' }, + text_on_busy: { labelKey: 'assistant.card.book.finding.text_on_busy' }, + contrast_low: { labelKey: 'assistant.card.book.finding.contrast_low' }, + small_text: { labelKey: 'assistant.card.book.finding.small_text' }, + crowded: { labelKey: 'assistant.card.book.finding.crowded' }, + off_grid: { labelKey: 'assistant.card.book.finding.off_grid' }, + font_mix: { labelKey: 'assistant.card.book.finding.font_mix' }, + palette_drift: { labelKey: 'assistant.card.book.finding.palette_drift' }, + repeat_layout: { labelKey: 'assistant.card.book.finding.repeat_layout' }, +}; + +/** A page as the Studio names it: the cover, the first page, double page 3. */ +export function pageLabel(page: BookCardPage, t: Translate): string { + if (page.role !== 'inner') return t(ROLE_LOOK[page.role].labelKey); + return page.number === null + ? t('assistant.card.book.spreadAny') + : t('assistant.card.book.spread', { page: page.number }); +} + +/** What the change is about: its pages, or a new book. */ +export function subjectOf(card: BookPageCard, t: Translate): string { + if (card.pages.length === 0) return t('assistant.card.book.newBook'); + return card.pages.map((page) => pageLabel(page, t)).join(', '); +} + +/** The name of the layout a change lays its page out on; null when there is none or this build does not know it. */ +export function layoutLabel(layout: BookCardLayout | null, t: Translate): string | null { + if (!layout) return null; + if (layout.kind === 'auto') return t('assistant.card.book.layoutAuto'); + if (layout.kind === 'saved') return layout.name ?? layout.id; + if (layout.kind === 'grid') { + const grid = findBookGrid(layout.id); + return grid ? t('assistant.card.book.grid', { count: grid.cells.length }) : null; + } + const template = findBookTemplate(layout.id); + return template ? t(template.labelKey) : null; +} + +/** The name of one finding. */ +export function findingLabel(finding: BookCardFinding, t: Translate): string { + return t(FINDING_LOOK[finding.code].labelKey); +} + +/** The findings worth a look (severe ones and warnings, those past the card counted), and whether one is a fault. */ +export function findingsToCheck(card: BookPageCard): { count: number; severe: boolean } { + const shown = card.findings.filter((finding) => finding.severity !== 'info').length; + const severe = card.findings.some((finding) => finding.severity === 'severe'); + return { count: shown + card.moreFindings, severe }; +} + +/** Each kind of finding once, the most severe first, as the server ordered them. */ +export function distinctFindings(card: BookPageCard): BookCardFinding[] { + const seen = new Set(); + return card.findings.filter((finding) => { + if (seen.has(finding.code)) return false; + seen.add(finding.code); + return true; + }); +} + +/** What a page card draws: where the page stands, and the page before the change and after it. */ +interface BookPageView { + index: number; + before: BookSpread | null; + after: BookSpread | null; +} + +const GONE: ReadonlySet = new Set(['failed', 'discarded', 'expired']); + +/** `set_book_cover`'s arguments from the card, without the parts it leaves as they are. */ +function coverArgs(cover: BookCardCover): Record { + return Object.fromEntries(Object.entries(cover).filter(([, value]) => value !== null)); +} + +/** The page as the change would leave it, run on the Studio's book; null when the card carries nothing to run. */ +function afterOf(card: BookPageCard, doc: BookDocument, spreadId: string): BookSpread | null { + let made: ReturnType | null = null; + if (card.cover) made = setBookCover(doc, coverArgs(card.cover)); + else if (card.ops.length > 0) made = applyBookOps(doc, { spreadId, ops: card.ops }); + if (!made || made.ok === false) return null; + return made.doc.spreads.find((spread) => spread.id === spreadId) ?? null; +} + +/** + * The spreads a page card draws from the Studio's book: while the change + * waits, its page as it is and as the change would leave it (a move and a + * delete show the page alone); once applied, the page as it is now. Nothing + * for new pages not made yet, for a change that did not run, or where the + * book on screen does not hold the page (another book, or none open). + */ +export function pageViewOf(card: BookPageCard, doc: BookDocument | null, state: ChangeState): BookPageView | null { + const spreadId = card.pages[0]?.spreadId; + if (!doc || !spreadId || GONE.has(state)) return null; + const index = doc.spreads.findIndex((spread) => spread.id === spreadId); + const current = doc.spreads[index]; + if (!current) return null; + if (state === 'applied') return { index, before: null, after: current }; + if (card.change === 'new') return null; + return { index, before: current, after: afterOf(card, doc, spreadId) }; +} diff --git a/client/src/components/Assistant/cards/book/bookLook.ts b/client/src/components/Assistant/cards/book/bookLook.ts new file mode 100644 index 000000000..51ea3057f --- /dev/null +++ b/client/src/components/Assistant/cards/book/bookLook.ts @@ -0,0 +1,54 @@ +import { BookImage, BookPlus, FilePen, FilePlus, FileX, MoveVertical } from 'lucide-react'; + +import type { EntityTarget, PackLook } from '../cardTypes'; + +/** + * What the photo book brings to the chat's pure look: the verbs of its + * changes, the reading steps of the Studio's tools, what an applied change + * opens and the look of its page card. A look stays pure, icons and literals + * only: the chat's main chunk reads every look, so whatever a look imports + * ships with it. + * + * An applied change opens the Studio on its page; the Studio is opened on top + * of the journey, so the journey stays where it was underneath. + */ + +/** The Studio of a journey, on one of its pages. */ +export function studioTarget(journeyId: number, spreadId: string | null): EntityTarget { + const page = spreadId ? `?page=${encodeURIComponent(spreadId)}` : ''; + return { kind: 'page', path: `/journey/${journeyId}/studio${page}` }; +} + +export const BOOK_LOOK = { + verbs: { + createBook: { Icon: BookPlus, tone: 'success', labelKey: 'assistant.change.verb.createBook' }, + addBookPages: { Icon: FilePlus, tone: 'success', labelKey: 'assistant.change.verb.addBookPages' }, + editBookPage: { Icon: FilePen, tone: 'info', labelKey: 'assistant.change.verb.editBookPage' }, + moveBookPage: { Icon: MoveVertical, tone: 'warning', labelKey: 'assistant.change.verb.moveBookPage' }, + removeBookPages: { Icon: FileX, tone: 'danger', labelKey: 'assistant.change.verb.removeBookPages' }, + setBookCover: { Icon: BookImage, tone: 'info', labelKey: 'assistant.change.verb.setBookCover' }, + }, + tools: {}, + steps: { + get_book: { stepKey: 'assistant.step.readingBook' }, + describe_book_page: { stepKey: 'assistant.step.lookingAtPage' }, + list_book_layouts: { stepKey: 'assistant.step.bookLayouts' }, + suggest_book_photos: { stepKey: 'assistant.step.choosingPhotos' }, + }, + entities: { + book_page: { + Icon: BookImage, + openLabelKey: 'assistant.card.book.open', + // A deleted page is gone: its receipt opens the book as it is. + open: (_applied, card) => { + if (card?.kind !== 'bookPage') return null; + return studioTarget(card.journeyId, card.change === 'willDelete' ? null : (card.pages[0]?.spreadId ?? null)); + }, + }, + }, + cards: { + bookPage: { + entity: () => 'book_page', + }, + }, +} satisfies PackLook<'bookPage'>; diff --git a/client/src/components/Assistant/cards/book/bookViews.tsx b/client/src/components/Assistant/cards/book/bookViews.tsx new file mode 100644 index 000000000..f941f5a0d --- /dev/null +++ b/client/src/components/Assistant/cards/book/bookViews.tsx @@ -0,0 +1,19 @@ +import type { CardView } from '../cardTypes'; +import { BookPageBody, BookPageFacts, BookPageSubject } from './BookPageSlots'; + +/** + * How the photo book's kind draws in the chat: a change row of a page with + * the pages it works on as its subject, its facts on the faint line and the + * page before and after under it. A page card is only ever a change, so it + * has no block of its own. This file only maps the kind to its view: the + * components live in a sibling file, since a file that exports anything + * besides components breaks fast refresh. + */ +export const BOOK_VIEWS = { + bookPage: { + ownsSubject: true, + Aside: BookPageSubject, + Facts: BookPageFacts, + Body: BookPageBody, + }, +} satisfies { [K in 'bookPage']: CardView }; diff --git a/client/src/components/Studio/SpreadThumb.tsx b/client/src/components/Studio/SpreadThumb.tsx new file mode 100644 index 000000000..5ada529c1 --- /dev/null +++ b/client/src/components/Studio/SpreadThumb.tsx @@ -0,0 +1,62 @@ +import type { BookPageSetup, BookSpread } from '@trek/shared'; + +import { SpreadFold, SpreadView } from './SpreadView'; + +/** CSS pixels in a millimetre: the size SpreadView's millimetre boxes are drawn at before the scale. */ +const PX_PER_MM = 96 / 25.4; + +interface SpreadThumbProps { + spread: BookSpread; + page: BookPageSetup; + /** The drawn width in CSS pixels; the height follows the page. */ + width: number; + /** The page numbers the spread carries, from foliosOf; none where the caller holds no book around it. */ + folios?: readonly number[]; + /** The crease of an open book down a double spread. */ + fold?: boolean; + /** The sheet's look: the page rail's `st-thumb-sheet`, a card's own classes. It must position its children. */ + className?: string; + /** Pixels per millimetre the caller draws at; CSS's own unless the caller zooms. */ + pxPerMm?: number; +} + +/** + * One spread at a small size: the editor's own SpreadView under a scale() + * rather than a second drawing of the page, so a thumbnail can never look + * different from the sheet. The page rail draws each page with it, and the + * Studio chat's page card draws a change before and after with it. + * + * A page is laid out in millimetres from its top left whatever the reading + * direction, so the sheet is always drawn left to right. + */ +export function SpreadThumb({ + spread, + page, + width, + folios, + fold = false, + className, + pxPerMm = PX_PER_MM, +}: SpreadThumbProps) { + const single = spread.role !== 'inner'; + const wMm = single ? page.pageWidth : page.pageWidth * 2; + const scale = width / (wMm * pxPerMm); + return ( +
+
+ +
+ {fold && !single && } +
+ ); +} diff --git a/client/src/components/Studio/StudioSidebar.tsx b/client/src/components/Studio/StudioSidebar.tsx index b0c32712f..ea6b215f9 100644 --- a/client/src/components/Studio/StudioSidebar.tsx +++ b/client/src/components/Studio/StudioSidebar.tsx @@ -8,15 +8,16 @@ import { useElementSize } from '../../hooks/useElementSize' import { useStudioStore } from '../../store/studioStore' import { formatDate } from '../../utils/formatters' import { useToast } from '../shared/Toast' -import { SpreadFold, SpreadView } from './SpreadView' +import { SpreadThumb } from './SpreadThumb' import { folioLabel, foliosOf } from './bookSheets' import { photoSrc } from './bookRender' import { BOOK_COVER_TEMPLATES as COVER_TEMPLATES, BOOK_TEMPLATES as TEMPLATES, applyBookTemplate as applyTemplate, bookElementId as uid, } from '@trek/shared' -import { formatBookCoords, formatBookDate, type CoordFormat } from './entryText' -import { coordValue } from './resolveBindings' +import { + bookCoordValue as coordValue, formatBookCoords, formatBookDate, type BookCoordFormat as CoordFormat, +} from '@trek/shared' import { MOOD_CONFIG, WEATHER_CONFIG } from '../../pages/journeyDetail/JourneyDetailPage.constants' import { PanelHead as Head } from './StudioPanelHead' import { StudioElementsPanel } from './StudioElementsPanel' @@ -189,11 +190,6 @@ function PagesPanel({
{spreads.map((sp, i) => { - const single = sp.role !== 'inner' - const wMm = single ? page.pageWidth : page.pageWidth * 2 - // The same component at a smaller scale, not a second drawing of the - // page — a spread can never look different here than on the sheet. - const scale = THUMB_W / (wMm * pxPerMm) const editable = canEditSpread(i) return (
@@ -201,18 +197,15 @@ function PagesPanel({ className={`st-thumb ${i === active ? 'is-active' : ''}`} onClick={() => setActive(i)} > -
-
- -
- {bookView && !single && } -
+ {sp.role === 'cover' ? t('journey.studio.cover') : sp.role === 'back' ? t('journey.studio.backCover') diff --git a/client/tests/unit/studio/spreadThumb.test.tsx b/client/tests/unit/studio/spreadThumb.test.tsx new file mode 100644 index 000000000..bbc3620cb --- /dev/null +++ b/client/tests/unit/studio/spreadThumb.test.tsx @@ -0,0 +1,63 @@ +import { bookPageSetupSchema, type BookPageSetup, type BookSpread } from '@trek/shared'; +import { describe, expect, it } from 'vitest'; + +import { SpreadThumb } from '../../../src/components/Studio/SpreadThumb'; +import { render } from '../../helpers/render'; + +/** + * FE-STUDIO-THUMB-001 to FE-STUDIO-THUMB-003 + * + * One spread drawn small: the editor's own SpreadView under a scale(), sized + * by the width it is given and the page, always left to right, with the + * crease only down an open double spread. The page rail and the Studio chat's + * page card both draw with it. + */ + +const page: BookPageSetup = bookPageSetupSchema.parse({ + preset: 'square-210', + pageWidth: 210, + pageHeight: 210, + bleed: 3, + safe: 5, +}); + +function spread(role: BookSpread['role']): BookSpread { + return { id: 'sp-1', role, background: '#f4efe6', elements: [], parked: [], entryId: null }; +} + +/** The sheet, the scaled page inside it and what else it holds. */ +function drawn(container: HTMLElement) { + const sheet = container.firstElementChild as HTMLElement; + const scaled = sheet.firstElementChild as HTMLElement; + return { sheet, scaled, children: sheet.children.length }; +} + +describe('SpreadThumb', () => { + it('FE-STUDIO-THUMB-001: a double spread is as wide as asked and as high as its page, scaled from millimetres', () => { + const { container } = render(); + const { sheet, scaled } = drawn(container); + expect(sheet.className).toBe('sheet'); + expect(sheet.style.width).toBe('200px'); + expect(parseFloat(sheet.style.height)).toBeCloseTo(100, 5); + expect(scaled.style.width).toBe('420mm'); + expect(scaled.style.transform).toBe(`scale(${200 / (420 * (96 / 25.4))})`); + expect(scaled.style.transformOrigin).toBe('top left'); + }); + + it('FE-STUDIO-THUMB-002: a single page is drawn at its own width, and every sheet reads left to right', () => { + const { container } = render(); + const { sheet, scaled } = drawn(container); + expect(sheet.getAttribute('dir')).toBe('ltr'); + expect(parseFloat(sheet.style.height)).toBeCloseTo(100, 5); + expect(scaled.style.width).toBe('210mm'); + }); + + it('FE-STUDIO-THUMB-003: the crease runs down an open double spread only', () => { + const open = render(); + expect(drawn(open.container).children).toBe(2); + const shut = render(); + expect(drawn(shut.container).children).toBe(1); + const cover = render(); + expect(drawn(cover.container).children).toBe(1); + }); +}); diff --git a/server/src/nest/assistant/assistant-book-gate.ts b/server/src/nest/assistant/assistant-book-gate.ts new file mode 100644 index 000000000..f662fbe3d --- /dev/null +++ b/server/src/nest/assistant/assistant-book-gate.ts @@ -0,0 +1,146 @@ +import { logWarn } from '../audit/audit-log.logger'; +import { withRequestContext } from '../database/request-context'; +import { JourneyBookEditService, type BookTrialBase } from '../journey/journey-book-edit.service'; +import type { AssistantToolSession, ToolRun } from './assistant-tools.service'; +import { + BOOK_TRIAL_READ, + BOOK_TRIAL_TOOLS, + tryBookChange, + type BookTrial, + type BookTrialInput, +} from './cards/book/book-trial'; +import type { ToolArgs } from './cards/card-types'; +import { readKey, recordOf } from './cards/card-values'; +import { MikroORM } from '@mikro-orm/core'; +import { Injectable } from '@nestjs/common'; +import type { BookFinding } from '@trek/shared'; + +/** + * The check a Studio turn runs on every book write the model proposes, before + * the user sees it (journey-studio.md 4.3). The call is tried on the stored + * book with the shared engine, as the tool would run it: what the engine + * refuses (an unknown or locked element, a photo outside the gallery, a + * protected page) goes back to the model as the call's error at once, and a + * change that would leave new severe faults on a page (overlapping photos, + * words past their frame, an empty frame, content in the fold) goes back once + * a turn per tool and page, with the findings. The same proposal made again is held + * like any other, its card showing the findings. Every model gets this check, + * whether it can see a page image or not. + * + * The change card reads the same trial through the turn's reader, so one call + * is tried once. + */ + +/** What a turn's cards read through: the session's own reads. */ +type TurnReads = Pick; + +/** A turn's check of held book writes, and the reads its cards make. */ +export interface BookTurnGate { + /** Why a held call goes back to the model instead of to the user; null when it is held as it is. */ + refusalOf(tool: string, args: ToolArgs): Promise; + /** The session's reads, with the trial of a book write answered beside them. */ + reader: TurnReads; +} + +/** A trip conversation's gate: it sends nothing back, and its cards read the session alone. */ +export function openGate(session: TurnReads): BookTurnGate { + return { refusalOf: () => Promise.resolve(null), reader: session }; +} + +/** Findings the bounce names at most; the rest are counted. */ +const BOUNCE_FINDINGS = 6; + +const BOUNCE_HEAD = + 'Not proposed yet: this change would leave faults on the page that it did not have before. ' + + 'Fix them and make the call again. The same call made again is shown to the user, with these findings on its card.'; + +/** The words a change with new faults goes back with: what is wrong, one finding a line. */ +export function bounceText(findings: readonly BookFinding[]): string { + const lines = findings.slice(0, BOUNCE_FINDINGS).map((finding) => `- ${finding.code}: ${finding.message}`); + const more = findings.length - BOUNCE_FINDINGS; + if (more > 0) lines.push(`- and ${more} more`); + return [BOUNCE_HEAD, ...lines].join('\n'); +} + +/** + * What a bounce is counted by: the tool and the pages it works on (its page, + * the page new ones follow, the pages it deletes), else the tool alone, as + * for the cover and a new book. Each goes back once a turn. + */ +function pageOf(tool: string, args: ToolArgs): string { + const page = args.spreadId ?? args.afterSpreadId; + if (typeof page === 'string') return `${tool}:${page}`; + const ids = Array.isArray(args.spreadIds) ? args.spreadIds.filter((id): id is string => typeof id === 'string') : []; + return ids.length > 0 ? `${tool}:${[...ids].sort().join(',')}` : tool; +} + +function reason(err: unknown): string { + return err instanceof Error ? err.message : String(err); +} + +/** Makes each turn's gate over the journey's book, read with the user's rights. */ +@Injectable() +export class AssistantBookGate { + constructor( + private readonly books: JourneyBookEditService, + private readonly orm: MikroORM, + ) {} + + /** + * The gate of one Studio turn. The book is read once, when the first call + * is tried (the turn's writes are held, so it stays as read), and each call + * with its arguments is tried once, whether the gate or a card asks first. + */ + forTurn(userId: number, journeyId: number, session: TurnReads): BookTurnGate { + let base: Promise | null = null; + const trials = new Map>(); + const bounced = new Set(); + const trial = (tool: string, args: ToolArgs): Promise => { + const key = readKey(tool, args); + const kept = trials.get(key); + if (kept) return kept; + base ??= this.baseOf(userId, journeyId); + const tried = base.then((input) => (input ? this.tried(tool, args, input) : null)); + trials.set(key, tried); + return tried; + }; + const refusalOf = async (tool: string, args: ToolArgs): Promise => { + if (!BOOK_TRIAL_TOOLS.includes(tool)) return null; + const tried = await trial(tool, args); + if (!tried) return null; + if (tried.ok === false) return tried.refusal; + const page = pageOf(tool, args); + if (tried.fresh.length === 0 || bounced.has(page)) return null; + bounced.add(page); + return bounceText(tried.fresh); + }; + const read = async (name: string, args: ToolArgs = {}): Promise => { + if (name !== BOOK_TRIAL_READ) return session.read(name, args); + const tool = typeof args.tool === 'string' ? args.tool : ''; + const tried = await trial(tool, recordOf(args.args)); + return tried ? { ok: true, value: tried } : { ok: false, value: 'No trial of this call.' }; + }; + return { refusalOf, reader: { read, hintOf: (name) => session.hintOf(name) } }; + } + + /** The book a turn's calls are tried on; null, and a log line, when it cannot be read. */ + private async baseOf(userId: number, journeyId: number): Promise { + try { + const base: BookTrialBase = await withRequestContext(this.orm, () => this.books.trialBase(journeyId, userId)); + return { journeyId, ...base }; + } catch (err) { + logWarn(`[assistant] the book of journey ${journeyId} could not be read for a trial: ${reason(err)}`); + return null; + } + } + + /** One call tried; a fault in the engine is logged and tries nothing, so the call is held as it is. */ + private tried(tool: string, args: ToolArgs, input: BookTrialInput): BookTrial | null { + try { + return tryBookChange(tool, args, input); + } catch (err) { + logWarn(`[assistant] the trial of ${tool} failed: ${reason(err)}`); + return null; + } + } +} diff --git a/server/src/nest/assistant/assistant-tools.constants.ts b/server/src/nest/assistant/assistant-tools.constants.ts index c76be2edc..ec4683e4a 100644 --- a/server/src/nest/assistant/assistant-tools.constants.ts +++ b/server/src/nest/assistant/assistant-tools.constants.ts @@ -134,6 +134,15 @@ export const TAKE_PROPOSAL_TOOL = 'take_proposal'; */ export const REMEMBER_TOOL = 'remember_for_trip'; +/** + * A Studio turn's look at one page, as it stands or as a proposed edit would + * leave it (journey-studio.md 4.3). It is no MCP tool: the server offers it to + * the model in a journey's turns (assistant-book-preview.ts) and answers it as + * a read, with the page's description, its findings and, for a model that + * reads images, the page as the Studio draws it. + */ +export const PREVIEW_BOOK_PAGE_TOOL = 'preview_book_page'; + /** The model's tools a found place is added through: a new place for the day, or one the trip has already. */ const FOUND_PLACE_VIA: ReadonlySet = new Set(['create_and_assign_place', 'assign_place_to_day']); diff --git a/server/src/nest/assistant/assistant-undo.helpers.ts b/server/src/nest/assistant/assistant-undo.helpers.ts index 4eda832cf..9d5680440 100644 --- a/server/src/nest/assistant/assistant-undo.helpers.ts +++ b/server/src/nest/assistant/assistant-undo.helpers.ts @@ -75,9 +75,26 @@ export function unchangedSinceApplied(toolName: string, result: unknown, snapsho return !!check && check(recordOf(result), { ...snapshot, reads: snapshot.reads ?? new Map() }); } -/** The tools an undo's session holds: the removing tool, the trip reads and what the change's package reads. */ -export function undoTargetsOf(undoTool: string, toolName: string, args: ToolArgs, result: unknown): Set { - return new Set([undoTool, ...TRIP_READS, ...undoReadsOf(toolName, args, result).map((read) => read.tool)]); +/** + * The tools an undo's session holds: the removing tool, the trip reads (on a + * trip, `tripReads`) and what the change's package reads. + */ +export function undoTargetsOf( + undoTool: string, + toolName: string, + args: ToolArgs, + result: unknown, + tripReads = true, +): Set { + const trip = tripReads ? TRIP_READS : []; + return new Set([undoTool, ...trip, ...undoReadsOf(toolName, args, result).map((read) => read.tool)]); +} + +/** What an undo's snapshot reads: a package's reads, and whether the trip is read too. */ +interface SnapshotReads { + reads?: ReturnType; + /** False in a Studio conversation: it is about a journey, there is no trip to read and the summary stays null. */ + tripReads?: boolean; } /** The trip as the undo checks it, read through the undo's session; null when a trip read failed. */ @@ -86,16 +103,22 @@ export async function undoSnapshotOf( toolName: string, args: ToolArgs, result: unknown, - reads = undoReadsOf(toolName, args, result), + { reads = undoReadsOf(toolName, args, result), tripReads = true }: SnapshotReads = {}, ): Promise { - const summary = await session.read('get_trip_summary'); - const places = await session.read('list_places'); - if (!summary.ok || !places.ok) return null; + const trip = tripReads ? await readTrip(session) : { summary: null, places: null }; + if (!trip) return null; const extra = await Promise.all( reads.map(async (read): Promise<[string, unknown]> => { const run = await session.read(read.tool, read.args); return [readKey(read.tool, read.args), run.ok ? run.value : null]; }), ); - return { summary: summary.value, places: places.value, reads: new Map(extra) }; + return { ...trip, reads: new Map(extra) }; +} + +/** The trip summary and its places as an undo reads them; null when either read failed. */ +async function readTrip(session: Pick): Promise | null> { + const summary = await session.read('get_trip_summary'); + const places = await session.read('list_places'); + return summary.ok && places.ok ? { summary: summary.value, places: places.value } : null; } diff --git a/server/src/nest/assistant/cards/book/book-change.ts b/server/src/nest/assistant/cards/book/book-change.ts new file mode 100644 index 000000000..b49798244 --- /dev/null +++ b/server/src/nest/assistant/cards/book/book-change.ts @@ -0,0 +1,231 @@ +import type { CardReader, Described, ToolArgs } from '../card-types'; +import { recordOf, type Row } from '../card-values'; +import { Rows, text } from '../preview-format'; +import { BOOK_TRIAL_READ, trialFrom, type BookTrialRan } from './book-trial'; +import { + BOOK_OP_LIMITS, + BOOK_PAGE_CARD_LIMITS, + bookCardFindingSchema, + bookCardPageSchema, + bookPageOpSchema, + setBookCoverArgs, + setBookCoverRequestSchema, + type AssistantChangePreview, + type BookCardCover, + type BookCardFinding, + type BookCardLayout, + type BookCardPage, + type BookPageCard, +} from '@trek/shared'; + +/** + * The change card of a held book write and its receipt. Both are built from + * the trial the turn's gate made of the call (book-trial.ts): the pages the + * change works on with their place in the book, what it lays them out on and + * brings onto them, and the findings on the pages it leaves. The card carries + * the operations, so the Studio draws the page after with the same engine. + * Once applied, the pages come from the tool's answer. + */ + +/** What describing a held book write looked up: the gate's trial of it, null when there was none. */ +export interface BookLoaded { + trial: BookTrialRan | null; +} + +/** What a change does to its pages, by tool. */ +const CHANGE_OF: Readonly> = { + create_book: 'new', + add_book_pages: 'new', + edit_book_page: 'changed', + set_book_cover: 'changed', + move_book_page: 'moved', + delete_book_pages: 'willDelete', +}; + +/** + * Operations past this weight are not carried: twenty texts of two thousand + * characters would push the card past MAX_CARD_CHARS and lose it whole, so + * such a card shows its facts and no page after. + */ +const MAX_OPS_CHARS = 12_000; + +/** The trial of `tool` with these arguments, through the turn's reader; null without one or for a refused call. */ +export async function loadBook(tool: string, args: ToolArgs, read: CardReader): Promise { + const trial = trialFrom(await read(BOOK_TRIAL_READ, { tool, args })); + return { trial: trial?.ok === true ? trial : null }; +} + +/** The change card's words: the page's first text as its subject, a move's places and a cover's title as rows. */ +export function describeBook(tool: string, args: ToolArgs, loaded: BookLoaded | null): Described { + const trial = loaded?.trial ?? null; + const rows = new Rows(); + const from = trial?.before[0]?.number; + const to = trial?.after[0]?.number; + if (tool === 'move_book_page' && from && to) rows.move('position', String(from), String(to)); + if (tool === 'set_book_cover') rows.add('name', text(args.title)); + return { subject: trial?.subject ?? '', rows, dayId: null, placeIds: [] }; +} + +/** `edit_book_page`'s operations as the card carries them; none for another tool, broken ones or too many words. */ +function opsOf(tool: string, args: ToolArgs): BookPageCard['ops'] { + if (tool !== 'edit_book_page') return []; + const parsed = bookPageOpSchema.array().max(BOOK_OP_LIMITS.opsPerCall).safeParse(args.ops); + if (!parsed.success || JSON.stringify(parsed.data).length > MAX_OPS_CHARS) return []; + return parsed.data; +} + +/** `set_book_cover`'s arguments, null where the call leaves a part of the cover as it is. */ +function coverOf(tool: string, args: ToolArgs): BookCardCover | null { + if (tool !== 'set_book_cover') return null; + const keys = Object.keys(setBookCoverArgs); + const parsed = setBookCoverRequestSchema.safeParse( + Object.fromEntries(Object.entries(args).filter(([key]) => keys.includes(key))), + ); + if (!parsed.success) return null; + const { template, photoId, title, subtitle } = parsed.data; + return { template: template ?? null, photoId: photoId ?? null, title: title ?? null, subtitle: subtitle ?? null }; +} + +/** The layout an operation names, a saved one by the name the book gives it. */ +function layoutOfOp(op: Row, savedName: string | null): BookCardLayout | null { + if (typeof op.template === 'string') return { kind: 'template', id: op.template, name: null }; + if (typeof op.grid === 'string') return { kind: 'grid', id: op.grid, name: null }; + if (typeof op.saved === 'string') return { kind: 'saved', id: op.saved, name: savedName }; + return op.auto === true ? { kind: 'auto', id: 'auto', name: null } : null; +} + +/** The layout a change lays its page out on: an edit's last layout operation, a new page's or the cover's template. */ +function layoutOf(tool: string, args: ToolArgs, trial: BookTrialRan): BookCardLayout | null { + if (tool === 'edit_book_page') { + const ops = Array.isArray(args.ops) ? args.ops.map(recordOf) : []; + const last = ops.filter((op) => op.op === 'layout').pop(); + return last ? layoutOfOp(last, trial.layoutName) : null; + } + if (tool === 'add_book_pages' || tool === 'set_book_cover') return layoutOfOp({ template: args.template }, null); + return null; +} + +/** The first findings as the card carries them, and how many severe ones and warnings come past them. */ +function findingsOf(findings: readonly BookCardFinding[]): Pick { + const shown = findings.slice(0, BOOK_PAGE_CARD_LIMITS.findings); + const past = findings.slice(shown.length).filter((finding) => finding.severity !== 'info'); + return { + findings: shown.map(({ code, severity }) => ({ code, severity })), + moreFindings: past.length, + }; +} + +/** How many pages a change adds (a new book: all of them) or deletes; none for any other change. */ +function countOf(change: BookPageCard['change'], trial: BookTrialRan): number { + if (change === 'new') return trial.after.length; + return change === 'willDelete' ? trial.before.length : 0; +} + +/** + * The card under a held book write: the pages it works on as they stand (the + * page edited, the cover, the page moved, the pages deleted, the page new ones + * follow), what it brings and what the check found. Null without a trial: a + * card needs the journey and the book as the server read them. + */ +export function bookChangeCard(tool: string, args: ToolArgs, loaded: BookLoaded | null): BookPageCard | null { + const trial = loaded?.trial ?? null; + const change = CHANGE_OF[tool]; + if (!trial || !change) return null; + return { + kind: 'bookPage', + journeyId: trial.journeyId, + change, + baseVersion: trial.version, + pages: trial.before.slice(0, BOOK_OP_LIMITS.pagesPerCall), + count: countOf(change, trial), + movedTo: tool === 'move_book_page' ? (trial.after[0]?.number ?? null) : null, + ops: opsOf(tool, args), + cover: coverOf(tool, args), + layout: layoutOf(tool, args, trial), + photosAdded: trial.photosAdded, + ...findingsOf(trial.findings), + }; +} + +/** A page of a write's answer (`get_book`'s row) as a card names it, numbered as the held card knew it. */ +function answeredPage(row: Row, number: (id: string) => number | null): BookCardPage | null { + const { id, index, role } = row; + if (typeof id !== 'string' || typeof index !== 'number') return null; + const photos = Array.isArray(row.photoIds) ? row.photoIds.length : 0; + const page = { spreadId: id, index, role, number: role === 'inner' ? number(id) : null, photos }; + const parsed = bookCardPageSchema.safeParse(page); + return parsed.success ? parsed.data : null; +} + +/** The double pages before the page new ones follow: its own number, none before the cover or the first page. */ +function innerBefore(anchor: BookCardPage | undefined): number | null { + if (!anchor) return null; + if (anchor.role === 'inner') return anchor.number; + return anchor.role === 'cover' || anchor.role === 'first' ? 0 : null; +} + +/** + * How a page of the answer is numbered among the double pages: as the held + * card numbered it (a moved page where it went), a page added after the + * anchor by its place among the new pages the answer lists (they stand + * together, right after it), and in a new book by its place among the pages + * the answer lists, which are all. + */ +function numberer(held: BookPageCard, rows: readonly Row[]) { + const known = held.movedTo === null ? held.pages : held.pages.map((page) => ({ ...page, number: held.movedTo })); + const before = held.change === 'new' && held.baseVersion !== null ? innerBefore(held.pages[0]) : null; + const inner = rows + .filter((row) => row.role === 'inner') + .sort((a, b) => Number(a.index) - Number(b.index)) + .map((row) => row.id); + return (id: string): number | null => { + const same = known.find((page) => page.spreadId === id)?.number; + if (same) return same; + const place = inner.indexOf(id) + 1; + if (place === 0) return null; + if (before !== null) return before + place; + return held.baseVersion === null ? place : null; + }; +} + +/** The findings of a write's answer that a card can name. */ +function answeredFindings(value: unknown): BookCardFinding[] { + const list: unknown[] = Array.isArray(value) ? value : []; + return list.flatMap((finding) => { + const parsed = bookCardFindingSchema.safeParse(finding); + return parsed.success ? [parsed.data] : []; + }); +} + +/** + * The findings of a write's answer as the receipt carries them. The answer + * lists at most BOOK_OP_LIMITS.findings; a full list may have left some out, + * so the count past the card is then no lower than the held card's. + */ +function receiptFindings(value: unknown, held: BookPageCard): Pick { + const answered = answeredFindings(value); + const own = findingsOf(answered); + if (answered.length < BOOK_OP_LIMITS.findings) return own; + return { ...own, moreFindings: Math.max(own.moreFindings, held.moreFindings) }; +} + +/** + * The receipt's card: the held card with the pages as the change left them + * (a deleted page as it was), the book's version after it and the findings + * its answer carries. Null when the held change had no card. + */ +export function bookAppliedCard(result: unknown, preview: AssistantChangePreview | null): BookPageCard | null { + const held = preview?.card?.kind === 'bookPage' ? preview.card : null; + if (!held) return null; + const answer = recordOf(result); + const rows = Array.isArray(answer.pages) ? answer.pages.map(recordOf) : []; + const number = numberer(held, rows); + const answered = rows.flatMap((row) => answeredPage(row, number) ?? []).slice(0, BOOK_OP_LIMITS.pagesPerCall); + const kept = held.change === 'willDelete' || answered.length === 0; + return { + ...held, + baseVersion: typeof answer.version === 'number' ? answer.version : held.baseVersion, + pages: kept ? held.pages : answered, + ...receiptFindings(answer.findings, held), + }; +} diff --git a/server/src/nest/assistant/cards/book/book-trial.ts b/server/src/nest/assistant/cards/book/book-trial.ts new file mode 100644 index 000000000..8a9f27411 --- /dev/null +++ b/server/src/nest/assistant/cards/book/book-trial.ts @@ -0,0 +1,285 @@ +import type { ToolArgs } from '../card-types'; +import { recordOf } from '../card-values'; +import { + addBookPages, + addBookPagesArgs, + applyBookOps, + blankBook, + createBookArgs, + createBookRequestSchema, + deleteBookPages, + deleteBookPagesArgs, + editBookPageArgs, + moveBookPage, + moveBookPageArgs, + setBookCover, + setBookCoverArgs, + spreadFindings, + summarizeSpread, + type BookCardPage, + type BookDocument, + type BookEditResult, + type BookFinding, + type BookOpsContext, + type BookSpread, +} from '@trek/shared'; + +/** + * A held book write tried on the stored book before the user sees its card: + * the same engine call the tool makes, on the same document, gallery and + * entries, without writing anything. What it gives is what the change card + * draws (the pages before and after, the photos it brings, the findings of + * the pages it leaves) and what the turn's gate refuses with: the engine's own + * refusal, or faults the change would bring onto a page. + */ + +/** The book a change is tried on: its journey, the stored document (null without a book), its version, the context. */ +export interface BookTrialInput { + journeyId: number; + doc: BookDocument | null; + version: number | null; + ctx: BookOpsContext; +} + +/** A change that would run, and what it would leave. */ +export interface BookTrialRan { + ok: true; + journeyId: number; + /** The version it was tried on; null for a journey without a book. */ + version: number | null; + /** The pages it works on, as they stand before it. */ + before: BookCardPage[]; + /** The pages it leaves, as they would stand. */ + after: BookCardPage[]; + /** The findings on the pages it leaves, the most severe first. */ + findings: BookFinding[]; + /** + * Severe findings the change brings onto a page that it did not have before: + * a fault naming an element no finding of its kind named before. An empty + * frame on a page the change makes is not one: a new page's template brings + * its frames empty, and placing photos is a later edit's work. + */ + fresh: BookFinding[]; + /** Photos it brings onto its pages that were not on them. */ + photosAdded: number; + /** The name of a saved layout it lays a page out on, as the book keeps it. */ + layoutName: string | null; + /** What the change is about in the book's own words: the first text of its page, a new book's title. */ + subject: string; +} + +/** A change the engine refuses, in the words a tool would answer. */ +interface BookTrialRefused { + ok: false; + refusal: string; +} + +export type BookTrial = BookTrialRan | BookTrialRefused; + +/** + * The read a book change's card makes for its trial. No tool has this name: + * the turn's gate answers it beside the session's own reads, so the card and + * the gate share one trial per call. + */ +export const BOOK_TRIAL_READ = 'trek_book_trial'; + +const NO_BOOK = 'This journey has no book yet: create_book makes one.'; +const HAS_BOOK = 'This journey has a book already: read it with get_book and change it instead.'; + +/** A book write the trial knows: the arguments its tool takes, and the engine call it makes on a stored book. */ +interface TrialTool { + keys: readonly string[]; + run(doc: BookDocument, args: ToolArgs, ctx: BookOpsContext): BookEditResult; +} + +const TRIAL_TOOLS: Readonly> = { + add_book_pages: { keys: Object.keys(addBookPagesArgs), run: (doc, args, ctx) => addBookPages(doc, args, ctx) }, + move_book_page: { keys: Object.keys(moveBookPageArgs), run: (doc, args) => moveBookPage(doc, args) }, + delete_book_pages: { keys: Object.keys(deleteBookPagesArgs), run: (doc, args) => deleteBookPages(doc, args) }, + edit_book_page: { + keys: Object.keys(editBookPageArgs), + run: (doc, args, ctx) => { + const ops = Array.isArray(args.ops) ? args.ops : []; + return applyBookOps(doc, { spreadId: typeof args.spreadId === 'string' ? args.spreadId : '', ops }, ctx); + }, + }, + set_book_cover: { keys: Object.keys(setBookCoverArgs), run: (doc, args, ctx) => setBookCover(doc, args, ctx) }, +}; + +/** The book writes a held call is tried for; `create_book` is tried apart, since it runs without a book. */ +export const BOOK_TRIAL_TOOLS: readonly string[] = ['create_book', ...Object.keys(TRIAL_TOOLS)]; + +/** The model's arguments as the tool takes them: the MCP layer drops a key the tool does not name, and so does this. */ +function known(args: ToolArgs, keys: readonly string[]): ToolArgs { + return Object.fromEntries(Object.entries(args).filter(([key]) => keys.includes(key))); +} + +/** The engine's refusal in the tool's words: which operation, from 0, and what to do. */ +function refusalOf(made: Extract): BookTrialRefused { + const { opIndex, message } = made.error; + return { ok: false, refusal: opIndex === null ? message : `ops[${opIndex}]: ${message}` }; +} + +/** Where a page stands among the double pages, from 1; null for a single page. */ +function numberOf(spreads: readonly BookSpread[], index: number): number | null { + if (spreads[index]?.role !== 'inner') return null; + return spreads.slice(0, index + 1).filter((spread) => spread.role === 'inner').length; +} + +/** The pages of `doc` with these ids, in book order, as a card names them. */ +function pagesOf(doc: BookDocument | null, ids: readonly string[]): BookCardPage[] { + if (!doc) return []; + return doc.spreads.flatMap((spread, index) => { + if (!ids.includes(spread.id)) return []; + const summary = summarizeSpread(spread, index); + const number = numberOf(doc.spreads, index); + return [{ spreadId: spread.id, index, role: spread.role, number, photos: summary.photoIds.length }]; + }); +} + +/** The pages a change works on before it runs: the page it names, the cover, the page new ones follow. */ +function targetIds(tool: string, args: ToolArgs, doc: BookDocument): string[] { + if (tool === 'set_book_cover') return doc.spreads.filter((spread) => spread.role === 'cover').map((s) => s.id); + if (tool === 'delete_book_pages') { + return Array.isArray(args.spreadIds) ? args.spreadIds.filter((id): id is string => typeof id === 'string') : []; + } + const id = tool === 'add_book_pages' ? args.afterSpreadId : args.spreadId; + return typeof id === 'string' ? [id] : []; +} + +const SEVERITY = { severe: 0, warn: 1, info: 2 } as const; + +/** The elements a finding names at most (book-findings.ts); a list this long may have left some out. */ +const LISTED_ELEMENTS = 8; + +/** The elements each kind of finding named on a page, and the kinds whose list may have left some out. */ +function namedBy(findings: readonly BookFinding[]): { named: Map>; full: Set } { + const named = new Map>(); + const full = new Set(); + for (const finding of findings) { + const ids = named.get(finding.code) ?? new Set(); + for (const id of finding.elementIds) ids.add(id); + named.set(finding.code, ids); + if (finding.elementIds.length >= LISTED_ELEMENTS) full.add(finding.code); + } + return { named, full }; +} + +/** + * The severe findings of a page after a change that it did not have before, + * element by element: filling one of three empty frames leaves a finding on + * the other two, which is not new. A finding naming no element is new only + * where its kind was not found before. + */ +function freshOn(was: readonly BookFinding[], now: readonly BookFinding[], created: boolean): BookFinding[] { + const { named, full } = namedBy(was); + return now.filter((finding) => { + if (finding.severity !== 'severe' || (created && finding.code === 'empty_frame')) return false; + const before = named.get(finding.code); + if (!before) return true; + return !full.has(finding.code) && finding.elementIds.some((id) => !before.has(id)); + }); +} + +/** Every finding on these pages of `doc`, by page. */ +function findingsOn(doc: BookDocument, ids: readonly string[], ctx: BookOpsContext): Map { + const found = new Map(); + for (const spread of doc.spreads) { + if (ids.includes(spread.id)) found.set(spread.id, spreadFindings(spread, doc.page, ctx.photos)); + } + return found; +} + +/** The photo ids on a page of `doc`, none for a page it does not hold. */ +function photosOn(doc: BookDocument | null, spreadId: string): Set { + const index = doc?.spreads.findIndex((spread) => spread.id === spreadId) ?? -1; + const spread = doc?.spreads[index]; + return new Set(spread ? summarizeSpread(spread, index).photoIds : []); +} + +/** The first words on the first of these pages of `doc`, for the change card's subject; empty when it has none. */ +function firstText(doc: BookDocument | null, ids: readonly string[]): string { + const index = doc?.spreads.findIndex((spread) => ids.includes(spread.id)) ?? -1; + const spread = doc?.spreads[index]; + return spread ? (summarizeSpread(spread, index).texts[0] ?? '') : ''; +} + +/** The name of the saved layout an edit's last layout operation applies, as the book keeps it. */ +function savedLayoutName(doc: BookDocument, args: ToolArgs): string | null { + const ops = Array.isArray(args.ops) ? args.ops.map(recordOf) : []; + const saved = ops.filter((op) => op.op === 'layout' && typeof op.saved === 'string').pop()?.saved; + return doc.layouts?.find((layout) => layout.id === saved)?.name ?? null; +} + +/** What a change that ran leaves: the pages before and after, their findings, the photos it brings. */ +function ranOf( + before: BookDocument | null, + made: Extract, + input: BookTrialInput, + targets: readonly string[], + layoutName: string | null, +): BookTrialRan { + const ids = made.spreadIds; + const was = before ? findingsOn(before, ids, input.ctx) : new Map(); + const now = findingsOn(made.doc, ids, input.ctx); + const created = new Set(made.created); + const findings = [...now.values()].flat().sort((a, b) => SEVERITY[a.severity] - SEVERITY[b.severity]); + const fresh = [...now].flatMap(([spreadId, list]) => freshOn(was.get(spreadId) ?? [], list, created.has(spreadId))); + const photosAdded = ids.reduce((sum, spreadId) => { + const prior = photosOn(before, spreadId); + return sum + [...photosOn(made.doc, spreadId)].filter((photoId) => !prior.has(photoId)).length; + }, 0); + return { + ok: true, + journeyId: input.journeyId, + version: input.version, + before: pagesOf(before, targets), + after: pagesOf(made.doc, ids), + findings, + fresh, + photosAdded, + layoutName, + subject: before ? firstText(before, targets) : made.doc.title, + }; +} + +/** A blank book as `create_book` would lay it down, or the refusal for a journey that has one. */ +function trialCreate(args: ToolArgs, input: BookTrialInput): BookTrial { + if (input.doc) return { ok: false, refusal: HAS_BOOK }; + const parsed = createBookRequestSchema.safeParse(known(args, Object.keys(createBookArgs))); + if (!parsed.success) { + const issue = parsed.error.issues[0]; + const what = issue ? `${issue.path.join('.')} ${issue.message}`.trim() : parsed.error.message; + return { ok: false, refusal: `Invalid arguments: ${what}` }; + } + const { title, preset } = parsed.data; + const book = blankBook({ title: title?.trim() || input.ctx.journey?.title || '', preset }); + const ids = book.spreads.map((spread) => spread.id); + return ranOf(null, { ok: true, doc: book, spreadIds: ids, created: ids, dropped: [] }, input, [], null); +} + +/** + * Tries one held book write on `input`; null for a tool the trial does not + * know. Arguments the engine refuses give its refusal, exactly as the tool + * would answer it once applied. + */ +export function tryBookChange(tool: string, args: ToolArgs, input: BookTrialInput): BookTrial | null { + if (tool === 'create_book') return trialCreate(args, input); + const entry = TRIAL_TOOLS[tool]; + if (!entry) return null; + const doc = input.doc; + if (!doc) return { ok: false, refusal: NO_BOOK }; + const given = known(args, entry.keys); + const made = entry.run(doc, given, input.ctx); + if (made.ok === false) return refusalOf(made); + const layoutName = tool === 'edit_book_page' ? savedLayoutName(doc, given) : null; + return ranOf(doc, made, input, targetIds(tool, given, doc), layoutName); +} + +/** A trial as the card's lookup gets it back from the reader; null for anything else. */ +export function trialFrom(value: unknown): BookTrial | null { + const record = recordOf(value); + if (record.ok === true && Array.isArray(record.after) && Array.isArray(record.findings)) return value as BookTrialRan; + if (record.ok === false && typeof record.refusal === 'string') return value as BookTrialRefused; + return null; +} diff --git a/server/src/nest/assistant/cards/book/book-undo.ts b/server/src/nest/assistant/cards/book/book-undo.ts new file mode 100644 index 000000000..4b84bc9dd --- /dev/null +++ b/server/src/nest/assistant/cards/book/book-undo.ts @@ -0,0 +1,83 @@ +import type { ToolArgs, ToolCards, UndoSnapshot } from '../card-types'; +import { readKey, recordOf } from '../card-values'; + +/** + * The way back from an applied book change. Edits, the cover and deleted + * pages go back with `restore_book_page`, which puts the pages the change + * answered under `previous_spreads` back as they were and only while the book + * is still at the version the change left: anything saved since makes it + * refuse, and the undo answers "changed since". New pages are deleted again + * and a moved page moved back, both only while `get_book` still reads the + * version the change left, and the call itself names that version, so a save + * landing between the check and the call is refused rather than overwritten. + * + * The version is the whole book's: an undo after any later save to the book + * answers "changed since", a page the save never touched included. "Undo + * all" over several book changes therefore takes back the newest one only, + * the older ones then being behind the version it left. + */ + +type BookUndo = NonNullable; + +/** The version a write's answer left the book at; null for an answer that names none. */ +function versionOf(result: unknown): number | null { + const version = recordOf(result).version; + return typeof version === 'number' && Number.isInteger(version) && version > 0 ? version : null; +} + +/** The pages a write kept as they were before it; none when it kept none. */ +function previousOf(result: unknown): unknown[] { + const pages = recordOf(result).previous_spreads; + return Array.isArray(pages) ? pages : []; +} + +/** The book as the undo reads it before it checks: its summary, whatever the change was. */ +const BOOK_READ = { tool: 'get_book', args: {} } as const; + +/** Nothing was saved to the book since the change: `get_book` still reads the version it left. */ +function bookUnmoved(result: unknown, snapshot: UndoSnapshot): boolean { + const left = versionOf(result); + return left !== null && versionOf(snapshot.reads.get(readKey(BOOK_READ.tool, BOOK_READ.args))) === left; +} + +/** + * Pages put back as the change found them. The restore itself refuses unless + * the book is still at the version the change left, so the check only asks + * that the answer holds what the restore needs. + */ +export const RESTORE_PREVIOUS: BookUndo = { + tool: 'restore_book_page', + args: (_args, result) => { + const pages = previousOf(result); + const expectedVersion = versionOf(result); + return pages.length > 0 && expectedVersion !== null ? { pages, expectedVersion } : null; + }, + unchanged: (result) => previousOf(result).length > 0 && versionOf(result) !== null, +}; + +/** New pages deleted again, while nothing was saved to the book since they were added. */ +export const DELETE_ADDED: BookUndo = { + tool: 'delete_book_pages', + args: (_args, result) => { + const ids = recordOf(result).spread_ids; + const spreadIds = Array.isArray(ids) ? ids.filter((id): id is string => typeof id === 'string') : []; + const expectedVersion = versionOf(result); + return spreadIds.length > 0 && expectedVersion !== null ? { spreadIds, expectedVersion } : null; + }, + reads: () => [BOOK_READ], + unchanged: bookUnmoved, +}; + +/** A moved page moved back to where it stood, while nothing was saved to the book since. */ +export const MOVE_BACK: BookUndo = { + tool: 'move_book_page', + args: (args: ToolArgs, result) => { + const from = recordOf(result).from_index; + const spreadId = args.spreadId; + const expectedVersion = versionOf(result); + if (typeof spreadId !== 'string' || typeof from !== 'number' || expectedVersion === null) return null; + return { spreadId, toIndex: from, expectedVersion }; + }, + reads: () => [BOOK_READ], + unchanged: bookUnmoved, +}; diff --git a/server/src/nest/assistant/cards/book/index.ts b/server/src/nest/assistant/cards/book/index.ts new file mode 100644 index 000000000..4605dec03 --- /dev/null +++ b/server/src/nest/assistant/cards/book/index.ts @@ -0,0 +1,70 @@ +import type { DomainCards, ToolCards } from '../card-types'; +import { recordOf } from '../card-values'; +import { bookAppliedCard, bookChangeCard, describeBook, loadBook, type BookLoaded } from './book-change'; +import { DELETE_ADDED, MOVE_BACK, RESTORE_PREVIOUS } from './book-undo'; +import type { AssistantChangeVerbKey } from '@trek/shared'; + +/** + * The photo book in the Studio's chat. A held book write shows the pages it + * works on, before and after, drawn in the Studio from the operations the + * card carries, with what it brings and what the server's check of the result + * found; once applied, the pages as it left them. Edits, the cover and + * deleted pages are taken back with `restore_book_page`, new pages deleted + * again, a moved page moved back, each only while nothing was saved since. + * + * The check itself is the turn's gate (assistant-book-gate.ts): it tries the + * call on the stored book, refuses what the engine refuses and sends a change + * with new faults back to the model once, and the card reads that same trial. + */ + +/** A write's answer as the model and the chat see it: without the pages it kept for its undo. */ +function withoutPrevious(value: unknown): unknown { + const answer = recordOf(value); + if (!('previous_spreads' in answer)) return value; + const { previous_spreads: _kept, ...rest } = answer; + return rest; +} + +/** A write whose answer keeps the pages as they were: forced on, never chosen by the model, never shown to it. */ +const KEEPS_PREVIOUS: ToolCards = { + argPolicy: { forced: { returnPrevious: true } }, + project: withoutPrevious, +}; + +/** The version an undo pins its call to (book-undo.ts): the server's to set, never the model's. */ +const UNDO_PINNED = ['expectedVersion'] as const; + +/** A book write's card entries: its verb, its trial, its words and its card while held and once applied. */ +function bookWrite( + tool: string, + verbKey: AssistantChangeVerbKey, + own: ToolCards = {}, +): ToolCards { + return { + write: { verbKey, entity: 'book_page' }, + load: (args, read) => loadBook(tool, args, read), + describe: (_ctx, args, loaded) => describeBook(tool, args, loaded), + change: (_ctx, args, loaded) => bookChangeCard(tool, args, loaded), + applied: ({ result, preview }) => bookAppliedCard(result, preview), + ...own, + }; +} + +export const BOOK_CARDS: DomainCards = { + id: 'book', + tools: { + create_book: bookWrite('create_book', 'createBook'), + add_book_pages: bookWrite('add_book_pages', 'addBookPages', { undo: DELETE_ADDED }), + move_book_page: bookWrite('move_book_page', 'moveBookPage', { + argPolicy: { stripped: UNDO_PINNED }, + undo: MOVE_BACK, + }), + delete_book_pages: bookWrite('delete_book_pages', 'removeBookPages', { + ...KEEPS_PREVIOUS, + argPolicy: { forced: { returnPrevious: true }, stripped: UNDO_PINNED }, + undo: RESTORE_PREVIOUS, + }), + edit_book_page: bookWrite('edit_book_page', 'editBookPage', { ...KEEPS_PREVIOUS, undo: RESTORE_PREVIOUS }), + set_book_cover: bookWrite('set_book_cover', 'setBookCover', { ...KEEPS_PREVIOUS, undo: RESTORE_PREVIOUS }), + }, +}; diff --git a/server/tests/e2e/assistant-book-cards.e2e.test.ts b/server/tests/e2e/assistant-book-cards.e2e.test.ts new file mode 100644 index 000000000..ab5147a2e --- /dev/null +++ b/server/tests/e2e/assistant-book-cards.e2e.test.ts @@ -0,0 +1,339 @@ +/** + * The book's change cards in TREK Studio, end to end: the whole app (buildApp, + * every global guard, the Zod pipe, the response contracts, the real MCP + * registry) with an instance connection of kind `custom` pointing at a fake + * OpenAI-compatible server on loopback, scripted per case. + * + * Covered: a page edit that would leave empty frames goes back to the model + * once, the same call made again is held with its page card (pages, the + * operations, the findings), applied with a receipt card, and taken back in + * one undo while nothing was saved since; an operation the engine refuses + * never reaches the user; new pages are not taken back once the book moved on, + * and neither is an edited page (the restore's version check refuses it). The + * version is the whole book's, so of two book changes applied together only + * the newer one can be taken back: a known limit, pinned here. A page is + * previewed with the ops of an edit before it is proposed, nothing saved; on + * this text-only model the preview is the page's description alone. + */ +import { buildApp } from '../../src/bootstrap'; +import { JourneyBookEditService } from '../../src/nest/journey/journey-book-edit.service'; +import { makeJourney } from '../helpers/factories/journeys'; +import { setAddonEnabled } from '../helpers/factories/settings'; +import { makeUser } from '../helpers/factories/users'; +import { resetRateLimits } from '../helpers/test-db'; +import { sessionCookie } from './harness'; +import { MikroORM } from '@mikro-orm/core'; +import type { INestApplication } from '@nestjs/common'; +import type { UiStreamChunk } from '@trek/shared'; + +import { createServer, type IncomingMessage, type Server as HttpServer, type ServerResponse } from 'node:http'; +import type { AddressInfo } from 'node:net'; +import request from 'supertest'; +import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; + +// ── The fake provider ───────────────────────────────────────────────────────── + +interface ChatBody { + model: string; + messages: Array<{ role: string; content: string | null; tool_call_id?: string }>; + tools?: Array<{ function: { name: string; parameters: { properties?: Record } } }>; +} + +type Step = (body: ChatBody) => { chunks: object[] }; + +const provider = { requests: [] as ChatBody[], script: [] as Step[] }; + +const say = + (text: string): Step => + () => ({ + chunks: [ + { choices: [{ index: 0, delta: { content: text } }] }, + { choices: [{ index: 0, delta: {}, finish_reason: 'stop' }] }, + { choices: [], usage: { prompt_tokens: 12, completion_tokens: 4 } }, + ], + }); + +const callTools = + (...calls: Array<{ id: string; name: string; args: Record }>): Step => + () => ({ + chunks: [ + { + choices: [ + { + index: 0, + delta: { + tool_calls: calls.map((call, index) => ({ + index, + id: call.id, + type: 'function', + function: { name: call.name, arguments: JSON.stringify(call.args) }, + })), + }, + }, + ], + }, + { choices: [{ index: 0, delta: {}, finish_reason: 'tool_calls' }] }, + ], + }); + +const callTool = (id: string, name: string, args: Record): Step => callTools({ id, name, args }); + +async function readBody(req: IncomingMessage): Promise { + let text = ''; + for await (const chunk of req) text += String(chunk); + return text; +} + +async function answer(req: IncomingMessage, res: ServerResponse): Promise { + if (req.method === 'GET' && req.url?.startsWith('/api/tags')) { + res.writeHead(200, { 'content-type': 'application/json' }); + res.end(JSON.stringify({ models: [{ name: 'fake-model', size: 1 }] })); + return; + } + if (req.method !== 'POST' || req.url !== '/v1/chat/completions') { + res.writeHead(404).end(); + return; + } + const body = JSON.parse(await readBody(req)) as ChatBody; + provider.requests.push(body); + const reply = (provider.script.shift() ?? say('Nothing more.'))(body); + if (res.destroyed) return; + res.writeHead(200, { 'content-type': 'text/event-stream' }); + for (const chunk of reply.chunks) res.write(`data: ${JSON.stringify(chunk)}\n\n`); + res.end('data: [DONE]\n\n'); +} + +// ── The app ────────────────────────────────────────────────────────────────── + +let nestApp: INestApplication; +let orm: MikroORM; +let fake: HttpServer; +let books: JourneyBookEditService; + +beforeAll(async () => { + fake = createServer((req, res) => { + answer(req, res).catch(() => res.destroy()); + }); + await new Promise((resolve) => fake.listen(0, '127.0.0.1', resolve)); + nestApp = await buildApp(); + orm = nestApp.get(MikroORM); + books = nestApp.get(JourneyBookEditService); + await setAddonEnabled(orm, 'ai_assistant', true); + await setAddonEnabled(orm, 'journey', true); + const adminId = (await makeUser(orm, { role: 'admin' })).user.id; + const { port } = fake.address() as AddressInfo; + const res = await request(nestApp.getHttpServer()) + .put('/api/admin/ai/connection') + .set('Cookie', sessionCookie(adminId)) + .send({ kind: 'custom', baseUrl: `http://127.0.0.1:${port}/v1`, model: 'fake-model' }); + expect(res.status).toBe(200); +}); + +beforeEach(async () => { + await resetRateLimits(nestApp); + provider.requests = []; + provider.script = []; +}); + +afterAll(async () => { + await nestApp.close(); + await new Promise((resolve) => fake.close(() => resolve())); +}); + +// ── Helpers ────────────────────────────────────────────────────────────────── + +const CTX = { locale: 'en', timeZone: 'Europe/Lisbon' }; + +async function stream(path: string, userId: number, body: object): Promise { + const res = await request(nestApp.getHttpServer()) + .post(path) + .set('Cookie', sessionCookie(userId)) + .send(body) + .buffer(true) + .parse((s, done) => { + let text = ''; + s.setEncoding('utf8'); + s.on('data', (chunk: string) => (text += chunk)); + s.on('end', () => done(null, text)); + }); + expect(res.status).toBe(200); + return (res.body as string) + .split('\n\n') + .filter((event) => event.startsWith('data: ') && event !== 'data: [DONE]') + .map((event) => JSON.parse(event.slice('data: '.length)) as UiStreamChunk); +} + +const ofType = (chunks: UiStreamChunk[], type: T) => + chunks.filter((chunk): chunk is Extract => chunk.type === type); + +/** A user with a journey of their own and a blank book in it: its double page is `inner`. */ +async function ownerWithBook() { + const { user } = await makeUser(orm); + const journey = await makeJourney(orm, user.id, { title: 'Portugal by train' }); + const created = await books.createBook(journey.id, user.id, {}); + const inner = created.pages.find((page) => page.role === 'inner')?.id ?? 'no inner page'; + return { userId: user.id, journeyId: journey.id, inner, base: `/api/journeys/${journey.id}/assistant` }; +} + +/** Approves held changes, in this order, and answers what the model says next. */ +function approve(base: string, userId: number, threadId: number, ...toolCallIds: string[]) { + provider.script = [say('Done.')]; + return stream(`${base}/threads/${threadId}/decisions`, userId, { + ...CTX, + decisions: toolCallIds.map((toolCallId) => ({ toolCallId, approved: true })), + }); +} + +/** One page's paper changed by the model: no fault, so the gate holds it at once. */ +const paper = (id: string, spreadId: string, color: string) => ({ + id, + name: 'edit_book_page', + args: { spreadId, ops: [{ op: 'background', color }] }, +}); + +function undo(base: string, userId: number, toolCallId: string) { + return request(nestApp.getHttpServer()) + .post(`${base}/tool-calls/${toolCallId}/undo`) + .set('Cookie', sessionCookie(userId)) + .send({}); +} + +const TWO_UP = [{ op: 'layout', template: 'two-up' }]; + +// ── Cases ──────────────────────────────────────────────────────────────────── + +describe('Studio book cards e2e', () => { + it('ASTBKE2E-001: a page left with empty frames goes back once, is held with its card, applied and taken back', async () => { + const j = await ownerWithBook(); + const edit = { spreadId: j.inner, ops: TWO_UP }; + provider.script = [callTool('call_1', 'edit_book_page', edit), callTool('call_2', 'edit_book_page', edit)]; + const turn = await stream(`${j.base}/chat`, j.userId, { ...CTX, threadId: null, text: 'Two photos here' }); + + const [bounced] = ofType(turn, 'tool-output-error'); + expect(bounced).toMatchObject({ toolCallId: 'call_1', errorText: expect.stringContaining('Not proposed yet') }); + expect(bounced?.errorText).toContain('empty_frame'); + const toModel = provider.requests[1]?.messages.find((message) => message.tool_call_id === 'call_1'); + expect(toModel?.content).toContain('Not proposed yet'); + + const [held] = ofType(turn, 'tool-approval-request'); + const [change] = ofType(turn, 'data-trek-change'); + expect(change?.data).toMatchObject({ verbKey: 'editBookPage', undoable: true }); + expect(change?.data.card).toMatchObject({ + kind: 'bookPage', + journeyId: j.journeyId, + change: 'changed', + baseVersion: 1, + pages: [{ spreadId: j.inner, role: 'inner', number: 1 }], + ops: [{ op: 'layout', template: 'two-up' }], + layout: { kind: 'template', id: 'two-up', name: null }, + }); + expect(change?.data.card?.kind === 'bookPage' && change.data.card.findings).toContainEqual({ + code: 'empty_frame', + severity: 'severe', + }); + const threadId = ofType(turn, 'data-trek-thread')[0]?.data.threadId ?? 0; + + const decided = await approve(j.base, j.userId, threadId, held?.toolCallId ?? ''); + const [receipt] = ofType(decided, 'data-trek-card'); + expect(receipt?.data).toMatchObject({ + toolCallId: held?.toolCallId, + card: { kind: 'bookPage', baseVersion: 2, pages: [{ spreadId: j.inner }] }, + }); + // The pages the answer kept for the undo never reach the model or the chat. + expect(JSON.stringify(ofType(decided, 'tool-output-available'))).not.toContain('previous_spreads'); + expect((await books.overview(j.journeyId, j.userId)).spreads[2]?.emptyFrames).toBe(2); + + const undone = await undo(j.base, j.userId, held?.toolCallId ?? ''); + expect(undone.status).toBe(200); + const after = await books.overview(j.journeyId, j.userId); + expect([after.version, after.spreads[2]?.elements]).toEqual([3, 0]); + expect((await undo(j.base, j.userId, held?.toolCallId ?? '')).body).toMatchObject({ code: 'stale' }); + }); + + it('ASTBKE2E-002: an operation the engine refuses goes back to the model at once and is never held', async () => { + const j = await ownerWithBook(); + const outside = { spreadId: j.inner, ops: [{ op: 'place_photo', photoId: 999_999, target: 'new' }] }; + provider.script = [callTool('call_out', 'edit_book_page', outside), say('That photo is not in the journey.')]; + const turn = await stream(`${j.base}/chat`, j.userId, { ...CTX, threadId: null, text: 'Use my best photo' }); + expect(ofType(turn, 'tool-output-error')).toEqual([ + { type: 'tool-output-error', toolCallId: 'call_out', errorText: expect.stringMatching(/^ops\[0\]: /) }, + ]); + expect(ofType(turn, 'tool-approval-request')).toHaveLength(0); + expect((await books.overview(j.journeyId, j.userId)).version).toBe(1); + }); + + it('ASTBKE2E-003: new pages are deleted again by undo, but not once the book was saved since', async () => { + const j = await ownerWithBook(); + const add = { afterSpreadId: j.inner, count: 2 }; + provider.script = [callTool('call_add', 'add_book_pages', add)]; + const first = await stream(`${j.base}/chat`, j.userId, { ...CTX, threadId: null, text: 'Two more pages' }); + const [held] = ofType(first, 'tool-approval-request'); + expect(ofType(first, 'data-trek-change')[0]?.data.card).toMatchObject({ change: 'new', count: 2 }); + const threadId = ofType(first, 'data-trek-thread')[0]?.data.threadId ?? 0; + await approve(j.base, j.userId, threadId, held?.toolCallId ?? ''); + expect((await books.overview(j.journeyId, j.userId)).spreads).toHaveLength(7); + + // Someone saves the book after the change: the undo would delete pages that are no longer just as added. + await books.editPage(j.journeyId, j.userId, { spreadId: j.inner, ops: [{ op: 'background', color: '#f4efe6' }] }); + const stale = await undo(j.base, j.userId, held?.toolCallId ?? ''); + expect(stale.status).toBe(409); + expect(stale.body).toMatchObject({ code: 'stale' }); + expect((await books.overview(j.journeyId, j.userId)).spreads).toHaveLength(7); + }); + + it('ASTBKE2E-004: an edited page is not put back once the book was saved since; the page keeps that save', async () => { + const j = await ownerWithBook(); + provider.script = [callTools(paper('call_bg', j.inner, '#f4efe6'))]; + const first = await stream(`${j.base}/chat`, j.userId, { ...CTX, threadId: null, text: 'Warmer paper' }); + const [held] = ofType(first, 'tool-approval-request'); + const threadId = ofType(first, 'data-trek-thread')[0]?.data.threadId ?? 0; + await approve(j.base, j.userId, threadId, held?.toolCallId ?? ''); + expect((await books.overview(j.journeyId, j.userId)).version).toBe(2); + + // The Studio saves a heading on the same page after the change. + const heading = [{ op: 'text', role: 'heading', text: 'Alfama' }]; + await books.editPage(j.journeyId, j.userId, { spreadId: j.inner, ops: heading }); + const stale = await undo(j.base, j.userId, held?.toolCallId ?? ''); + expect(stale.status).toBe(409); + expect(stale.body).toMatchObject({ code: 'stale' }); + const after = await books.overview(j.journeyId, j.userId); + expect([after.version, after.spreads[2]?.elements]).toEqual([3, 1]); + }); + + it('ASTBKE2E-005: of two book changes applied together, the newer is taken back and the older then answers stale', async () => { + const j = await ownerWithBook(); + provider.script = [callTools(paper('call_a', j.inner, '#f4efe6'), paper('call_b', j.inner, '#e6eef4'))]; + const first = await stream(`${j.base}/chat`, j.userId, { ...CTX, threadId: null, text: 'Try two papers' }); + const held = ofType(first, 'tool-approval-request').map((part) => part.toolCallId); + expect(held).toHaveLength(2); + const threadId = ofType(first, 'data-trek-thread')[0]?.data.threadId ?? 0; + await approve(j.base, j.userId, threadId, ...held); + expect((await books.overview(j.journeyId, j.userId)).version).toBe(3); + + // Newest first, as "undo all" runs: the newer change goes back, the older is behind the version that left. + expect((await undo(j.base, j.userId, held[1] ?? '')).status).toBe(200); + const older = await undo(j.base, j.userId, held[0] ?? ''); + expect(older.status).toBe(409); + expect(older.body).toMatchObject({ code: 'stale' }); + expect((await books.overview(j.journeyId, j.userId)).version).toBe(4); + }); + + it('ASTBKE2E-006: a preview shows a proposed page in words, saves nothing, asks a text model no image', async () => { + const j = await ownerWithBook(); + const edit = { spreadId: j.inner, ops: [{ op: 'background', color: '#f4efe6' }] }; + provider.script = [callTools({ id: 'call_look', name: 'preview_book_page', args: edit }), say('It reads well.')]; + const body = { ...CTX, threadId: null, text: 'Warmer paper?', renders: true }; + const turn = await stream(`${j.base}/chat`, j.userId, body); + + const offered = provider.requests[0]?.tools?.find((tool) => tool.function.name === 'preview_book_page'); + expect(Object.keys(offered?.function.parameters.properties ?? {})).toEqual(['spreadId', 'ops']); + expect(ofType(turn, 'tool-output-available').map((part) => part.toolCallId)).toEqual(['call_look']); + expect(ofType(turn, 'data-trek-render-request')).toEqual([]); + const [view] = ofType(turn, 'data-trek-page-view'); + expect(view?.data).toMatchObject({ spreadId: j.inner, bookVersion: 1, width: null, height: null, bytes: null }); + const answer = provider.requests[1]?.messages.find((message) => message.tool_call_id === 'call_look'); + expect(answer?.content).toContain('"proposed":true'); + expect(answer?.content).toContain('Findings'); + expect((await books.overview(j.journeyId, j.userId)).version).toBe(1); + }); +}); diff --git a/server/tests/unit/nest/assistant/assistant-book-gate.test.ts b/server/tests/unit/nest/assistant/assistant-book-gate.test.ts new file mode 100644 index 000000000..fb2f55609 --- /dev/null +++ b/server/tests/unit/nest/assistant/assistant-book-gate.test.ts @@ -0,0 +1,176 @@ +/** + * ASTBGATE-001 to ASTBGATE-007 + * + * The book check of a Studio turn: a held book write is tried on the stored + * book before the user sees it; what the engine refuses goes back to the + * model at once, every time, and a change that would leave new severe faults + * goes back once a turn per tool and page with its findings, after which the + * same call is held. Filling some of a page's empty frames and new pages laid + * out on a template are not new faults. The book is read once per turn and every call tried once, + * whether the gate or its change card asks first. A book that cannot be read + * holds every call as it is. + */ +import { AssistantBookGate, bounceText, openGate } from '../../../../src/nest/assistant/assistant-book-gate'; +import { BOOK_TRIAL_READ } from '../../../../src/nest/assistant/cards/book/book-trial'; +import type { JourneyBookEditService } from '../../../../src/nest/journey/journey-book-edit.service'; +import { createSnapshotTestDb } from '../../../helpers/db-mock'; +import { createTestOrm, type TestOrm } from '../../../helpers/test-orm'; +import { + addBookPages, + applyBookOps, + blankBook, + type BookDocument, + type BookEditResult, + type BookFinding, +} from '@trek/shared'; + +import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; + +const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() })); +vi.mock('../../../../src/nest/audit/audit-log.logger', () => logMock); + +const testDb = createSnapshotTestDb(); +let t: TestOrm; + +beforeAll(async () => { + t = await createTestOrm(testDb); +}); +afterAll(async () => { + await t.close(); + testDb.close(); +}); +beforeEach(() => vi.clearAllMocks()); + +/** sp-1 the cover, sp-2 the first page, sp-3 the double page, sp-4 the last page, sp-5 the back. */ +function base() { + let seq = 0; + const doc = blankBook({ title: 'Lisbon', newId: (prefix) => `${prefix}-${++seq}` }); + return { doc, version: 6, ctx: { photos: [{ photoId: 81 }], journey: { title: 'Lisbon' } } }; +} + +/** The base book changed by the engine; a change it refuses stops the test. */ +function changed(make: (doc: BookDocument) => BookEditResult) { + const found = base(); + const made = make(found.doc); + if (made.ok === false) throw new Error(`the fixture was refused: ${made.error.message}`); + return { found: { ...found, doc: made.doc }, spreadIds: made.spreadIds }; +} + +/** A gate over a book service that reads `found`, or fails when `found` is an error. */ +function gateOver(found: ReturnType | Error = base()) { + const books = { + trialBase: vi.fn(async () => { + if (found instanceof Error) throw found; + return found; + }), + }; + const session = { + read: vi.fn(async (name: string) => ({ ok: true, value: { from: name } })), + hintOf: vi.fn(() => null), + }; + const gate = new AssistantBookGate(books as unknown as JourneyBookEditService, t.orm); + return { books, session, turn: () => gate.forTurn(7, 4, session) }; +} + +const EMPTY_FRAMES = { spreadId: 'sp-3', ops: [{ op: 'layout', template: 'two-up' }] }; +const OUTSIDE = { spreadId: 'sp-3', ops: [{ op: 'place_photo', photoId: 999, target: 'new' }] }; + +describe('the book check of a Studio turn', () => { + it('ASTBGATE-001: what the engine refuses goes back at once, every time; other tools and clean changes pass', async () => { + const { turn } = gateOver(); + const gate = turn(); + expect(await gate.refusalOf('edit_book_page', OUTSIDE)).toMatch(/^ops\[0\]: /); + expect(await gate.refusalOf('edit_book_page', OUTSIDE)).toMatch(/^ops\[0\]: /); + expect(await gate.refusalOf('delete_book_pages', { spreadIds: ['sp-1'] })).toContain('cannot be deleted'); + expect(await gate.refusalOf('create_book', {})).toContain('has a book already'); + expect(await gate.refusalOf('update_journey_entry', { entryId: 3 })).toBeNull(); + const place = { op: 'place_photo', photoId: 81, target: 'new' }; + expect(await gate.refusalOf('edit_book_page', { spreadId: 'sp-3', ops: [place] })).toBeNull(); + }); + + it('ASTBGATE-002: new faults go back once per page and turn; the same call made again is held', async () => { + const newId = (prefix: string) => `${prefix}-x`; + const { found, spreadIds } = changed((doc) => addBookPages(doc, { afterSpreadId: 'sp-3' }, { newId })); + const { turn } = gateOver(found); + const gate = turn(); + const first = await gate.refusalOf('edit_book_page', EMPTY_FRAMES); + expect(first).toContain('Not proposed yet'); + expect(first).toContain('- empty_frame: '); + expect(await gate.refusalOf('edit_book_page', EMPTY_FRAMES)).toBeNull(); + // Another page has a bounce of its own. + const other = { ...EMPTY_FRAMES, spreadId: spreadIds[0] }; + expect(await gate.refusalOf('edit_book_page', other)).toContain('empty_frame'); + expect(await gate.refusalOf('edit_book_page', other)).toBeNull(); + // A new turn checks afresh. + expect(await turn().refusalOf('edit_book_page', EMPTY_FRAMES)).toContain('Not proposed yet'); + }); + + it('ASTBGATE-003: the book is read once a turn and each call tried once, for the gate and its card alike', async () => { + const { turn, books, session } = gateOver(); + const gate = turn(); + await gate.refusalOf('edit_book_page', EMPTY_FRAMES); + const run = await gate.reader.read(BOOK_TRIAL_READ, { tool: 'edit_book_page', args: EMPTY_FRAMES }); + expect(run).toMatchObject({ + ok: true, + value: { ok: true, journeyId: 4, version: 6, before: [{ spreadId: 'sp-3' }] }, + }); + const again = await gate.reader.read(BOOK_TRIAL_READ, { tool: 'edit_book_page', args: EMPTY_FRAMES }); + expect(again.value).toBe(run.value); + await gate.refusalOf('edit_book_page', OUTSIDE); + expect(books.trialBase).toHaveBeenCalledTimes(1); + expect(books.trialBase).toHaveBeenCalledWith(4, 7); + // Every other read is the session's own. + expect(await gate.reader.read('get_book', {})).toEqual({ ok: true, value: { from: 'get_book' } }); + expect(session.read).toHaveBeenCalledWith('get_book', {}); + gate.reader.hintOf('get_book'); + expect(session.hintOf).toHaveBeenCalledWith('get_book'); + expect(await gate.reader.read(BOOK_TRIAL_READ, { tool: 'get_book', args: {} })).toMatchObject({ ok: false }); + }); + + it('ASTBGATE-004: a book that cannot be read holds every call as it is, and says so in the log', async () => { + const { turn } = gateOver(new Error('Journey not found')); + const gate = turn(); + expect(await gate.refusalOf('edit_book_page', EMPTY_FRAMES)).toBeNull(); + expect(await gate.reader.read(BOOK_TRIAL_READ, { tool: 'edit_book_page', args: EMPTY_FRAMES })).toMatchObject({ + ok: false, + }); + expect(logMock.logWarn).toHaveBeenCalledWith(expect.stringContaining('Journey not found')); + }); + + it("ASTBGATE-005: a trip conversation's gate sends nothing back and its cards read the session itself", async () => { + const { session } = gateOver(); + const gate = openGate(session); + expect(await gate.refusalOf('edit_book_page', EMPTY_FRAMES)).toBeNull(); + expect(gate.reader).toBe(session); + }); + + it('ASTBGATE-007: filling some empty frames and new pages on a template are held; their findings stay on the card', async () => { + const { found } = changed((doc) => applyBookOps(doc, EMPTY_FRAMES)); + const { turn } = gateOver(found); + const gate = turn(); + // One of the two frames filled: the other is still empty, which is no new fault. + const fill = { spreadId: 'sp-3', ops: [{ op: 'place_photo', photoId: 81, target: { slot: 0 } }] }; + expect(await gate.refusalOf('edit_book_page', fill)).toBeNull(); + // A new page's template brings its frames empty; this tool cannot fill them, so nothing goes back. + const added = { afterSpreadId: 'sp-3', template: 'two-up' }; + expect(await gate.refusalOf('add_book_pages', added)).toBeNull(); + const card = await gate.reader.read(BOOK_TRIAL_READ, { tool: 'add_book_pages', args: added }); + expect(card).toMatchObject({ ok: true, value: { fresh: [] } }); + const findings = (card.value as { findings: BookFinding[] }).findings; + expect(findings.map((finding) => finding.code)).toContain('empty_frame'); + }); + + it('ASTBGATE-006: the bounce names at most six findings, one a line, and counts the rest', () => { + const finding = (n: number): BookFinding => ({ + code: 'overlap', + severity: 'severe', + elementIds: [`p-${n}`], + message: `photos ${n} overlap`, + }); + const text = bounceText(Array.from({ length: 8 }, (_, n) => finding(n))); + const lines = text.split('\n'); + expect(lines).toHaveLength(8); + expect(lines[1]).toBe('- overlap: photos 0 overlap'); + expect(lines[7]).toBe('- and 2 more'); + }); +}); diff --git a/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts b/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts index 790683bfe..cdb674bd8 100644 --- a/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts +++ b/server/tests/unit/nest/assistant/assistant-undo.helpers.test.ts @@ -218,7 +218,7 @@ describe('the undo session', () => { { tool: 'get_vacay_plan', args: { year: 2026 } }, { tool: 'list_vacay_entries', args: {} }, ]; - const snap = await undoSnapshotOf(session(['list_vacay_entries']), 'toggle_vacay', {}, {}, reads); + const snap = await undoSnapshotOf(session(['list_vacay_entries']), 'toggle_vacay', {}, {}, { reads }); expect(snap?.reads.get(readKey('get_vacay_plan', { year: 2026 }))).toEqual({ name: 'get_vacay_plan', args: { year: 2026 }, @@ -226,4 +226,16 @@ describe('the undo session', () => { expect(snap?.reads.get(readKey('list_vacay_entries'))).toBeNull(); expect(snap?.reads.size).toBe(2); }); + + it('ASTUND-022: a Studio undo reads no trip: it holds the removing tool and the book read, the summary stays empty', async () => { + expect([...undoTargetsOf('delete_book_pages', 'add_book_pages', {}, {}, false)]).toEqual([ + 'delete_book_pages', + 'get_book', + ]); + const studio = session(['get_trip_summary', 'list_places']); + const snap = await undoSnapshotOf(studio, 'add_book_pages', {}, {}, { tripReads: false }); + expect(snap).toMatchObject({ summary: null, places: null }); + expect(snap?.reads.get(readKey('get_book'))).toEqual({ name: 'get_book', args: {} }); + expect(studio.read).not.toHaveBeenCalledWith('get_trip_summary'); + }); }); diff --git a/server/tests/unit/nest/assistant/cards/book/book-cards.test.ts b/server/tests/unit/nest/assistant/cards/book/book-cards.test.ts new file mode 100644 index 000000000..c338a96c9 --- /dev/null +++ b/server/tests/unit/nest/assistant/cards/book/book-cards.test.ts @@ -0,0 +1,424 @@ +/** + * ASTCARD-BKPG-001 to ASTCARD-BKPG-011 + * + * The photo book's cards in the Studio's chat: a held book write tried on the + * stored book with the shared engine (the pages before and after, numbered + * among the double pages, the photos it brings, the findings it leaves and the + * new severe ones among them, the engine's refusal in the tool's words), the + * change card built from that trial and checked against the shared union, the + * receipt from the tool's answer, the change row's words, and the way back + * from every book write but a new book. Cards go through the registry's guard, + * as a turn builds them. + */ +import { buildTripCard } from '../../../../../../src/nest/assistant/assistant-context'; +import { toolOutputForProvider } from '../../../../../../src/nest/assistant/assistant-output'; +import { unchangedSinceApplied } from '../../../../../../src/nest/assistant/assistant-undo.helpers'; +import { + bookAppliedCard, + loadBook, + type BookLoaded, +} from '../../../../../../src/nest/assistant/cards/book/book-change'; +import { + BOOK_TRIAL_READ, + BOOK_TRIAL_TOOLS, + trialFrom, + tryBookChange, + type BookTrialInput, + type BookTrialRan, +} from '../../../../../../src/nest/assistant/cards/book/book-trial'; +import type { PreviewContext, UndoSnapshot } from '../../../../../../src/nest/assistant/cards/card-types'; +import { readKey } from '../../../../../../src/nest/assistant/cards/card-values'; +import { + appliedCardOf, + ASSISTANT_ARG_POLICY, + ASSISTANT_UNDO_MAP, + ASSISTANT_WRITE_TOOLS, + changeCardOf, + undoReadsOf, +} from '../../../../../../src/nest/assistant/cards/registry'; +import { describeToolCall } from '../../../../../../src/nest/assistant/tool-call-preview.helpers'; +import { + addBookPages, + applyBookOps, + blankBook, + bookPageCardSchema, + MAX_CARD_CHARS, + type AssistantChangePreview, + type BookDocument, + type BookEditResult, + type BookPageCard, +} from '@trek/shared'; + +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +const logMock = vi.hoisted(() => ({ logInfo: vi.fn(), logError: vi.fn(), logWarn: vi.fn(), logDebug: vi.fn() })); +vi.mock('../../../../../../src/nest/audit/audit-log.logger', () => logMock); + +beforeEach(() => vi.clearAllMocks()); + +const ctx: PreviewContext = { + card: buildTripCard(0, 7, null, null, null), + categories: new Map(), + locale: 'en', + today: '2026-10-22', + airport: () => null, +}; + +/** A blank book with readable ids: sp-1 the cover, sp-2 the first page, sp-3 its double page, sp-4 and sp-5. */ +function book(): BookDocument { + let seq = 0; + return blankBook({ title: 'Lisbon', newId: (prefix) => `${prefix}-${++seq}` }); +} + +function input(doc: BookDocument | null = book()): BookTrialInput { + let seq = 0; + return { + journeyId: 4, + doc, + version: 3, + ctx: { + photos: [{ photoId: 81 }, { photoId: 82 }], + journey: { title: 'Lisbon' }, + newId: (prefix) => `${prefix}-n${++seq}`, + }, + }; +} + +function ran(tool: string, args: Record, from: BookTrialInput = input()): BookTrialRan { + const trial = tryBookChange(tool, args, from); + if (trial?.ok !== true) throw new Error(`${tool} was refused: ${trial?.ok === false ? trial.refusal : 'no trial'}`); + return trial; +} + +const loaded = (trial: BookTrialRan): BookLoaded => ({ trial }); + +function cardOf(value: unknown): BookPageCard { + const parsed = bookPageCardSchema.safeParse(value); + if (!parsed.success) throw new Error(`not a book page card: ${parsed.error.message}`); + return parsed.data; +} + +const TWO_UP = { op: 'layout', template: 'two-up' }; + +/** A fixture book the engine made; one it refuses stops the test. */ +function edited(done: BookEditResult): BookDocument { + if (done.ok === false) throw new Error(`the fixture was refused: ${done.error.message}`); + return done.doc; +} + +/** The blank book with two more double pages after sp-3, sp-a1 and sp-a2. */ +function threeSpreads(): BookDocument { + let seq = 0; + return edited(addBookPages(book(), { afterSpreadId: 'sp-3', count: 2 }, { newId: (p) => `${p}-a${++seq}` })); +} + +describe('the trial of a held book write', () => { + it('ASTCARD-BKPG-001: an edit is run by the engine: the page before and after, its number, and the new faults', () => { + const trial = ran('edit_book_page', { spreadId: 'sp-3', ops: [TWO_UP] }); + expect(trial).toMatchObject({ journeyId: 4, version: 3, photosAdded: 0, layoutName: null, subject: '' }); + expect(trial.before).toEqual([{ spreadId: 'sp-3', index: 2, role: 'inner', number: 1, photos: 0 }]); + expect(trial.after).toEqual([{ spreadId: 'sp-3', index: 2, role: 'inner', number: 1, photos: 0 }]); + // Two empty frames: a fault the blank page did not have. + expect(trial.fresh.map((finding) => finding.code)).toEqual(['empty_frame']); + expect(trial.findings[0]?.severity).toBe('severe'); + + const place = { op: 'place_photo', photoId: 81, target: 'new' }; + const placed = ran('edit_book_page', { spreadId: 'sp-3', ops: [place] }); + expect(placed).toMatchObject({ photosAdded: 1, fresh: [] }); + expect(placed.after[0]?.photos).toBe(1); + + // Filling one of two empty frames leaves the other empty: not a new fault, so nothing goes back. + const twoUp = edited(applyBookOps(book(), { spreadId: 'sp-3', ops: [TWO_UP] })); + const fill = { op: 'place_photo', photoId: 81, target: { slot: 0 } }; + const half = ran('edit_book_page', { spreadId: 'sp-3', ops: [fill] }, input(twoUp)); + expect(half.fresh).toEqual([]); + expect(half.findings.map((finding) => finding.code)).toContain('empty_frame'); + }); + + it("ASTCARD-BKPG-002: what the engine refuses is refused in the tool's words, before anything is held", () => { + const outside = tryBookChange( + 'edit_book_page', + { spreadId: 'sp-3', ops: [{ op: 'place_photo', photoId: 999, target: 'new' }] }, + input(), + ); + expect(outside).toMatchObject({ ok: false, refusal: expect.stringMatching(/^ops\[0\]: /) }); + expect(tryBookChange('delete_book_pages', { spreadIds: ['sp-1'] }, input())).toMatchObject({ + ok: false, + refusal: expect.stringContaining('cannot be deleted'), + }); + expect(tryBookChange('edit_book_page', { spreadId: 'sp-3', ops: [TWO_UP] }, input(null))).toEqual({ + ok: false, + refusal: 'This journey has no book yet: create_book makes one.', + }); + expect(tryBookChange('create_book', {}, input())).toMatchObject({ ok: false }); + expect(tryBookChange('create_book', { preset: 'poster' }, input(null))).toMatchObject({ ok: false }); + expect(tryBookChange('get_book', {}, input())).toBeNull(); + expect(BOOK_TRIAL_TOOLS).toEqual( + expect.arrayContaining([ + 'create_book', + 'add_book_pages', + 'move_book_page', + 'delete_book_pages', + 'edit_book_page', + 'set_book_cover', + ]), + ); + }); + + it('ASTCARD-BKPG-003: new pages, a move, a delete, the cover and a new book each name the pages they work on', () => { + // A key the tool does not take is dropped, as the MCP layer drops it. + const added = ran('add_book_pages', { afterSpreadId: 'sp-3', count: 2, template: 'two-up', note: 'x' }); + expect(added.before.map((page) => page.spreadId)).toEqual(['sp-3']); + expect(added.after.map((page) => [page.index, page.number])).toEqual([ + [3, 2], + [4, 3], + ]); + // A new page's template brings its frames empty: shown on the card, never sent back. + expect(added.fresh).toEqual([]); + expect(added.findings.filter((finding) => finding.code === 'empty_frame')).toHaveLength(2); + + const deleted = ran('delete_book_pages', { spreadIds: ['sp-3'] }); + expect(deleted.before.map((page) => page.spreadId)).toEqual(['sp-3']); + expect(deleted.after).toEqual([]); + + const cover = ran('set_book_cover', { template: 'cover-full', photoId: 82, title: 'Portugal' }); + expect(cover.before).toEqual([{ spreadId: 'sp-1', index: 0, role: 'cover', number: null, photos: 0 }]); + expect(cover.photosAdded).toBe(1); + + const fresh = ran('create_book', { title: ' Porto ' }, input(null)); + expect(fresh).toMatchObject({ version: null, before: [], subject: 'Porto' }); + expect(fresh.after.map((page) => page.role)).toEqual(['cover', 'first', 'inner', 'last', 'back']); + expect(ran('create_book', {}, input(null)).subject).toBe('Lisbon'); + }); + + it('ASTCARD-BKPG-004: a move names where the page lands among the double pages; the cover stays', () => { + const moved = ran('move_book_page', { spreadId: 'sp-3', toIndex: 4 }, input(threeSpreads())); + expect(moved.before).toEqual([{ spreadId: 'sp-3', index: 2, role: 'inner', number: 1, photos: 0 }]); + expect(moved.after).toEqual([{ spreadId: 'sp-3', index: 4, role: 'inner', number: 3, photos: 0 }]); + expect(tryBookChange('move_book_page', { spreadId: 'sp-1', toIndex: 2 }, input())).toMatchObject({ ok: false }); + }); +}); + +describe('the change card', () => { + it('ASTCARD-BKPG-005: an edit carries its pages, operations, layout, photos and findings, valid and under the cap', () => { + const args = { spreadId: 'sp-3', ops: [TWO_UP, { op: 'place_photo', photoId: 81, target: { slot: 0 } }] }; + const card = cardOf(changeCardOf('edit_book_page', ctx, args, loaded(ran('edit_book_page', args)))); + expect(card).toMatchObject({ + kind: 'bookPage', + journeyId: 4, + change: 'changed', + baseVersion: 3, + pages: [{ spreadId: 'sp-3', number: 1 }], + count: 0, + movedTo: null, + cover: null, + layout: { kind: 'template', id: 'two-up', name: null }, + photosAdded: 1, + moreFindings: 0, + }); + expect(card.ops).toHaveLength(2); + expect(card.findings).toContainEqual({ code: 'empty_frame', severity: 'severe' }); + expect(changeCardOf('edit_book_page', ctx, args, null)).toBeNull(); + expect(changeCardOf('edit_book_page', ctx, args, { trial: null })).toBeNull(); + + // Twenty long texts would weigh past the card's cap: the card keeps its facts and drops the operations. + const words = Array.from({ length: 20 }, () => ({ op: 'text', role: 'body', text: 'w'.repeat(2000) })); + const heavy = { spreadId: 'sp-3', ops: words }; + const light = cardOf(changeCardOf('edit_book_page', ctx, heavy, loaded(ran('edit_book_page', heavy)))); + expect(light.ops).toEqual([]); + expect(JSON.stringify(light).length).toBeLessThan(MAX_CARD_CHARS); + }); + + it('ASTCARD-BKPG-006: new pages, a move, a delete, the cover and a new book each make their own card', () => { + const add = { afterSpreadId: 'sp-3', count: 2, template: 'two-up' }; + expect(cardOf(changeCardOf('add_book_pages', ctx, add, loaded(ran('add_book_pages', add))))).toMatchObject({ + change: 'new', + count: 2, + pages: [{ spreadId: 'sp-3' }], + layout: { kind: 'template', id: 'two-up' }, + ops: [], + }); + const gone = { spreadIds: ['sp-3'] }; + const deleting = cardOf(changeCardOf('delete_book_pages', ctx, gone, loaded(ran('delete_book_pages', gone)))); + expect(deleting).toMatchObject({ change: 'willDelete', count: 1, pages: [{ spreadId: 'sp-3' }] }); + const cover = { template: 'cover-full', photoId: 82, title: 'Portugal' }; + expect(cardOf(changeCardOf('set_book_cover', ctx, cover, loaded(ran('set_book_cover', cover))))).toMatchObject({ + change: 'changed', + cover: { template: 'cover-full', photoId: 82, title: 'Portugal', subtitle: null }, + layout: { kind: 'template', id: 'cover-full' }, + }); + const saved = { spreadId: 'sp-3', ops: [{ op: 'layout', auto: true }] }; + const fake = { ...ran('edit_book_page', { spreadId: 'sp-3', ops: [TWO_UP] }), layoutName: 'Mine' }; + expect(cardOf(changeCardOf('edit_book_page', ctx, saved, loaded(fake))).layout).toEqual({ + kind: 'auto', + id: 'auto', + name: null, + }); + const named = { spreadId: 'sp-3', ops: [{ op: 'layout', saved: 'lay-1' }] }; + expect(cardOf(changeCardOf('edit_book_page', ctx, named, loaded(fake))).layout).toEqual({ + kind: 'saved', + id: 'lay-1', + name: 'Mine', + }); + const fresh = cardOf(changeCardOf('create_book', ctx, {}, loaded(ran('create_book', {}, input(null))))); + expect(fresh).toMatchObject({ change: 'new', baseVersion: null, pages: [], count: 5 }); + }); + + it("ASTCARD-BKPG-007: the change row's words: the page's first text, a move's places, every book write a curated card", () => { + for (const tool of BOOK_TRIAL_TOOLS) { + expect(ASSISTANT_WRITE_TOOLS[tool]?.entity, tool).toBe('book_page'); + expect(describeToolCall(tool, 'c0', {}, ctx).verbKey).toBe(ASSISTANT_WRITE_TOOLS[tool]?.verbKey); + } + const heading = [{ op: 'text', role: 'heading', text: 'Alfama at dusk' }]; + const titled = edited(applyBookOps(book(), { spreadId: 'sp-3', ops: heading })); + const args = { spreadId: 'sp-3', ops: [TWO_UP] }; + const headed = ran('edit_book_page', args, input(titled)); + const preview = describeToolCall('edit_book_page', 'c1', args, ctx, loaded(headed)); + expect(preview).toMatchObject({ verbKey: 'editBookPage', subject: 'Alfama at dusk', undoable: true }); + expect(preview.card?.kind).toBe('bookPage'); + const move = { spreadId: 'sp-3', toIndex: 4 }; + const trial = ran('move_book_page', move, input(threeSpreads())); + const moved = describeToolCall('move_book_page', 'c2', move, ctx, loaded(trial)); + expect(moved.rows).toEqual([{ op: 'move', labelKey: 'position', before: '1', after: '3' }]); + expect(moved.card).toMatchObject({ change: 'moved', movedTo: 3 }); + expect(describeToolCall('create_book', 'c3', {}, ctx).undoable).toBe(false); + }); +}); + +describe('the receipt and the way back', () => { + const held = (card: BookPageCard): AssistantChangePreview => ({ + toolCallId: 'c1', + verbKey: 'editBookPage', + subject: '', + rows: [], + dayId: null, + placeIds: [], + undoable: true, + card, + }); + + it('ASTCARD-BKPG-008: the receipt names the pages as the answer left them, numbered as the held card knew them', () => { + const args = { spreadId: 'sp-3', ops: [TWO_UP] }; + const card = cardOf(changeCardOf('edit_book_page', ctx, args, loaded(ran('edit_book_page', args)))); + const answer = { + version: 4, + spread_ids: ['sp-3'], + pages: [{ index: 2, id: 'sp-3', role: 'inner', photoIds: [81] }], + findings: [{ code: 'overlap', severity: 'warn', elementIds: [], message: 'x' }, { code: 'made-up' }], + }; + const receipt = cardOf(appliedCardOf('edit_book_page', { args, result: answer, preview: held(card) })); + expect(receipt).toMatchObject({ baseVersion: 4, pages: [{ spreadId: 'sp-3', number: 1, photos: 1 }] }); + expect(receipt.findings).toEqual([{ code: 'overlap', severity: 'warn' }]); + expect(receipt.ops).toEqual(card.ops); + + const add = { afterSpreadId: 'sp-3', count: 2 }; + const pending = cardOf(changeCardOf('add_book_pages', ctx, add, loaded(ran('add_book_pages', add)))); + const made = bookAppliedCard( + { + version: 4, + pages: [ + { index: 3, id: 'sp-x', role: 'inner', photoIds: [] }, + { index: 4, id: 'sp-y', role: 'inner', photoIds: [] }, + ], + findings: [], + }, + held(pending), + ); + expect(made?.pages.map((page) => [page.spreadId, page.number])).toEqual([ + ['sp-x', 2], + ['sp-y', 3], + ]); + // Pages added after the first page are the first double pages. + const early = { afterSpreadId: 'sp-2', count: 2 }; + const front = cardOf(changeCardOf('add_book_pages', ctx, early, loaded(ran('add_book_pages', early)))); + const opened = bookAppliedCard( + { + version: 4, + pages: [ + { index: 3, id: 'sp-q', role: 'inner', photoIds: [] }, + { index: 2, id: 'sp-p', role: 'inner', photoIds: [] }, + ], + findings: [], + }, + held(front), + ); + expect(opened?.pages.map((page) => [page.spreadId, page.number])).toEqual([ + ['sp-q', 2], + ['sp-p', 1], + ]); + const gone = { spreadIds: ['sp-3'] }; + const deleting = cardOf(changeCardOf('delete_book_pages', ctx, gone, loaded(ran('delete_book_pages', gone)))); + expect(bookAppliedCard({ version: 4, pages: [], findings: [] }, held(deleting))?.pages).toEqual(deleting.pages); + expect(bookAppliedCard(answer, null)).toBeNull(); + }); + + it('ASTCARD-BKPG-011: findings past the card count severe ones and warnings only, and a full answer keeps the count', () => { + const args = { spreadId: 'sp-3', ops: [TWO_UP] }; + const card = cardOf(changeCardOf('edit_book_page', ctx, args, loaded(ran('edit_book_page', args)))); + const finding = (severity: string) => ({ code: 'overlap', severity, elementIds: [], message: 'x' }); + const seven = [...Array.from({ length: 7 }, () => finding('warn')), finding('info'), finding('info')]; + const receipt = (findings: unknown[], more: number) => + bookAppliedCard({ version: 4, pages: [], findings }, held({ ...card, moreFindings: more })); + // Six on the card, one warning past it; the two info findings are context, not counted. + expect(receipt(seven, 0)).toMatchObject({ moreFindings: 1 }); + expect(receipt(seven, 0)?.findings).toHaveLength(6); + // The answer lists 40 at most: a full list keeps the held card's count when that is higher. + const full = Array.from({ length: 40 }, () => finding('severe')); + expect(receipt(full, 50)).toMatchObject({ moreFindings: 50 }); + expect(receipt(full, 3)).toMatchObject({ moreFindings: 34 }); + }); + + it('ASTCARD-BKPG-009: edits, the cover and deletes go back by restore at their version; new pages and moves while unmoved', () => { + const previous = [{ index: 2, spread: book().spreads[2] }]; + const result = { version: 4, spread_ids: ['sp-3'], previous_spreads: previous }; + for (const tool of ['edit_book_page', 'set_book_cover', 'delete_book_pages']) { + expect(ASSISTANT_UNDO_MAP[tool]?.args({}, result, null), tool).toEqual({ + pages: previous, + expectedVersion: 4, + }); + expect(ASSISTANT_UNDO_MAP[tool]?.args({}, { version: 4 }, null)).toBeNull(); + expect(ASSISTANT_ARG_POLICY[tool]?.forced).toEqual({ returnPrevious: true }); + // The pages kept for the undo never reach the model or the chat. + expect(toolOutputForProvider(tool, result)).toEqual({ version: 4, spread_ids: ['sp-3'] }); + } + // The undo of new pages and of a move names the version the change left, so a save since refuses it. + expect(ASSISTANT_UNDO_MAP.add_book_pages?.args({}, { version: 4, spread_ids: ['sp-x', 'sp-y'] }, null)).toEqual({ + spreadIds: ['sp-x', 'sp-y'], + expectedVersion: 4, + }); + expect(ASSISTANT_UNDO_MAP.add_book_pages?.args({}, { spread_ids: ['sp-x'] }, null)).toBeNull(); + const back = ASSISTANT_UNDO_MAP.move_book_page?.args({ spreadId: 'sp-3' }, { version: 4, from_index: 2 }, null); + expect(back).toEqual({ spreadId: 'sp-3', toIndex: 2, expectedVersion: 4 }); + expect(ASSISTANT_UNDO_MAP.move_book_page?.args({ spreadId: 'sp-3' }, { from_index: 2 }, null)).toBeNull(); + // That version is the server's to set: the model never sees it. + for (const tool of ['move_book_page', 'delete_book_pages']) { + expect(ASSISTANT_ARG_POLICY[tool]?.stripped, tool).toEqual(['expectedVersion']); + } + expect(ASSISTANT_UNDO_MAP.create_book).toBeUndefined(); + expect(undoReadsOf('add_book_pages', {}, {})).toEqual([{ tool: 'get_book', args: {} }]); + + const snapshot = (version: number): UndoSnapshot => ({ + summary: null, + places: null, + reads: new Map([[readKey('get_book', {}), { exists: true, version }]]), + }); + const unchanged = (tool: string, answer: unknown, version: number) => + unchangedSinceApplied(tool, answer, snapshot(version)); + expect(unchanged('add_book_pages', { version: 4 }, 4)).toBe(true); + expect(unchanged('add_book_pages', { version: 4 }, 5)).toBe(false); + expect(unchanged('move_book_page', {}, 4)).toBe(false); + expect(unchanged('edit_book_page', result, 9)).toBe(true); + }); + + it('ASTCARD-BKPG-010: the lookup reads the trial through the turn reader; a refused or missing trial gives none', async () => { + const trial = ran('edit_book_page', { spreadId: 'sp-3', ops: [TWO_UP] }); + const read = vi.fn(async (tool: string) => (tool === BOOK_TRIAL_READ ? trial : null)); + const args = { spreadId: 'sp-3', ops: [TWO_UP] }; + expect(await loadBook('edit_book_page', args, read)).toEqual({ trial }); + expect(read).toHaveBeenCalledWith(BOOK_TRIAL_READ, { tool: 'edit_book_page', args }); + const refused = vi.fn(async () => ({ ok: false, refusal: 'no' })); + expect(await loadBook('edit_book_page', args, refused)).toEqual({ trial: null }); + expect(trialFrom({ ok: true })).toBeNull(); + expect(trialFrom('text')).toBeNull(); + }); +}); diff --git a/shared/src/assistant/cards/book-page.card.spec.ts b/shared/src/assistant/cards/book-page.card.spec.ts new file mode 100644 index 000000000..3c25f29a3 --- /dev/null +++ b/shared/src/assistant/cards/book-page.card.spec.ts @@ -0,0 +1,105 @@ +import { ASSISTANT_CHANGE_VERB_KEYS, assistantAppliedSchema, assistantChangePreviewSchema } from '../assistant.schema'; +import { BOOK_PAGE_CARD_LIMITS, bookPageCardSchema, type BookCardPage } from './book-page.card'; +import { storedTrekCardSchema, trekCardSchema } from './index'; + +import { describe, expect, it } from 'vitest'; + +// BOOKCARD-001 to BOOKCARD-006 + +function page(over: Partial = {}): BookCardPage { + return { spreadId: 'sp-lisbon', index: 2, role: 'inner', number: 1, photos: 3, ...over }; +} + +function card(over: Record = {}) { + return { + kind: 'bookPage', + journeyId: 4, + change: 'changed', + baseVersion: 7, + pages: [page()], + count: 0, + movedTo: null, + ops: [ + { op: 'layout', template: 'two-up' }, + { op: 'background', color: '#f4efe6' }, + ], + cover: null, + layout: { kind: 'template', id: 'two-up', name: null }, + photosAdded: 2, + findings: [{ code: 'overlap', severity: 'severe' }], + moreFindings: 0, + ...over, + }; +} + +describe('the book page card', () => { + it('BOOKCARD-001: reads a full card through the union, as itself, its operations parsed by the book engine', () => { + const parsed = trekCardSchema.parse(card()); + expect(parsed.kind).toBe('bookPage'); + const own = bookPageCardSchema.parse(parsed); + expect(own.ops).toHaveLength(2); + expect(own.ops[0]).toMatchObject({ op: 'layout', template: 'two-up' }); + }); + + it('BOOKCARD-002: a cover change carries its arguments, a new book no page and no version', () => { + const cover = { template: 'cover-full', photoId: 81, title: 'Portugal', subtitle: null }; + expect(bookPageCardSchema.safeParse(card({ ops: [], cover, layout: null })).success).toBe(true); + const fresh = card({ change: 'new', baseVersion: null, pages: [], count: 5, ops: [], layout: null, findings: [] }); + expect(bookPageCardSchema.safeParse(fresh).success).toBe(true); + }); + + it('BOOKCARD-003: an operation the engine refuses, an unknown template or a page past the cap reads as no card', () => { + expect(storedTrekCardSchema.parse(card({ ops: [{ op: 'explode' }] }))).toBeNull(); + const cover = { template: 'nope', photoId: null, title: null, subtitle: null }; + expect(storedTrekCardSchema.parse(card({ cover }))).toBeNull(); + const eleven = Array.from({ length: 11 }, (_, i) => page({ spreadId: `sp-${i}`, index: i })); + expect(storedTrekCardSchema.parse(card({ pages: eleven }))).toBeNull(); + expect(storedTrekCardSchema.parse(card({ pages: [page({ spreadId: 'not a page id' })] }))).toBeNull(); + }); + + it('BOOKCARD-004: holds at most six findings, each a known code and severity', () => { + const findings = Array.from({ length: BOOK_PAGE_CARD_LIMITS.findings + 1 }, () => ({ + code: 'empty_frame', + severity: 'warn', + })); + expect(bookPageCardSchema.safeParse(card({ findings })).success).toBe(false); + expect(bookPageCardSchema.safeParse(card({ findings: [{ code: 'ugly', severity: 'warn' }] })).success).toBe(false); + expect(bookPageCardSchema.safeParse(card({ findings: findings.slice(1), moreFindings: 3 })).success).toBe(true); + }); + + it('BOOKCARD-005: rides on a change preview', () => { + const preview = assistantChangePreviewSchema.parse({ + toolCallId: 'call_1', + verbKey: 'editBookPage', + subject: 'Lisbon', + rows: [], + dayId: null, + placeIds: [], + undoable: true, + card: card(), + }); + expect(preview.verbKey).toBe('editBookPage'); + expect(preview.card?.kind).toBe('bookPage'); + }); + + it('BOOKCARD-006: names its verbs and its entity in the shared enums', () => { + expect(ASSISTANT_CHANGE_VERB_KEYS).toEqual( + expect.arrayContaining([ + 'createBook', + 'addBookPages', + 'editBookPage', + 'moveBookPage', + 'removeBookPages', + 'setBookCover', + ]), + ); + const applied = assistantAppliedSchema.parse({ + toolCallId: 'call_1', + entity: 'book_page', + ids: [], + dayId: null, + undoUntil: null, + }); + expect(applied.entity).toBe('book_page'); + }); +}); diff --git a/shared/src/assistant/cards/book-page.card.ts b/shared/src/assistant/cards/book-page.card.ts new file mode 100644 index 000000000..8783a5b17 --- /dev/null +++ b/shared/src/assistant/cards/book-page.card.ts @@ -0,0 +1,97 @@ +import { + BOOK_FINDING_CODES, + BOOK_OP_LIMITS, + bookCoverTemplateIdSchema, + bookPageOpSchema, + bookSpreadIdSchema, +} from '../../book/book-ops.schema'; +import { bookSpreadSchema, MAX_BOOK_TITLE, MAX_SPREADS } from '../../book/book.schema'; +import { idSchema } from '../../common/primitives.schema'; +import { cardCountSchema, cardText } from './card-parts'; + +import { z } from 'zod'; + +/** + * A change to a journey's photo book as the Studio's chat shows it: the pages + * a held book write works on, what it lays them out on and brings onto them, + * and what the server's check of the result found. The card carries the + * page operations themselves, so the Studio draws the page before and after + * with the same engine and the same view the editor uses, never from an image. + * Once applied it names the pages as the change left them. + */ + +/** How much of a change a card carries; the server cuts to the same numbers. */ +export const BOOK_PAGE_CARD_LIMITS = { findings: 6, layout: 60 } as const; + +/** What the change does to its pages: makes them, changes them, moves one, or deletes them. */ +export const BOOK_PAGE_CARD_CHANGES = ['new', 'changed', 'moved', 'willDelete'] as const; + +/** One page as a card names it. */ +export const bookCardPageSchema = z.object({ + spreadId: bookSpreadIdSchema, + /** Where it stands in the book, the cover at 0. */ + index: z + .number() + .int() + .min(0) + .max(MAX_SPREADS - 1), + role: bookSpreadSchema.shape.role.unwrap(), + /** Its place among the double pages, from 1; null for a single page (the covers, the first and the last). */ + number: z.number().int().min(1).max(MAX_SPREADS).nullable(), + /** Photos placed on it. */ + photos: cardCountSchema, +}); +export type BookCardPage = z.infer; + +/** A finding of the server's check, by its code: the client names it in the user's language. */ +export const bookCardFindingSchema = z.object({ + code: z.enum(BOOK_FINDING_CODES), + severity: z.enum(['severe', 'warn', 'info']), +}); +export type BookCardFinding = z.infer; + +/** The layout a change lays a page out on. A saved layout carries its own name; the built-in ones the client names. */ +export const bookCardLayoutSchema = z.object({ + kind: z.enum(['template', 'grid', 'saved', 'auto']), + id: cardText(BOOK_PAGE_CARD_LIMITS.layout), + name: cardText(BOOK_PAGE_CARD_LIMITS.layout).nullable(), +}); +export type BookCardLayout = z.infer; + +/** `set_book_cover`'s arguments, null where the call leaves a part of the cover as it is. */ +export const bookCardCoverSchema = z.object({ + template: bookCoverTemplateIdSchema.nullable(), + photoId: idSchema.nullable(), + title: z.string().max(MAX_BOOK_TITLE).nullable(), + subtitle: z.string().max(MAX_BOOK_TITLE).nullable(), +}); +export type BookCardCover = z.infer; + +export const bookPageCardSchema = z.object({ + kind: z.literal('bookPage'), + journeyId: idSchema, + change: z.enum(BOOK_PAGE_CARD_CHANGES), + /** The book's version the change was checked against; null for a journey without a book. */ + baseVersion: cardCountSchema.nullable(), + /** + * The pages the change works on, as they stand before it: the page edited, + * the cover, the page moved, the pages deleted, the page new ones follow. + * Once applied, the pages as the change left them, new ones included. + */ + pages: z.array(bookCardPageSchema).max(BOOK_OP_LIMITS.pagesPerCall), + /** How many pages the change adds or deletes; for a new book, its pages. */ + count: cardCountSchema, + /** Where a moved page lands among the double pages, from 1. */ + movedTo: z.number().int().min(1).max(MAX_SPREADS).nullable(), + /** `edit_book_page`'s operations, to draw the page after; empty for another tool or when too long to carry. */ + ops: z.array(bookPageOpSchema).max(BOOK_OP_LIMITS.opsPerCall), + cover: bookCardCoverSchema.nullable(), + layout: bookCardLayoutSchema.nullable(), + /** Photos the change brings onto its pages that were not on them. */ + photosAdded: cardCountSchema, + /** The check's findings on the pages after the change, the most severe first. */ + findings: z.array(bookCardFindingSchema).max(BOOK_PAGE_CARD_LIMITS.findings), + /** Severe findings and warnings past those; the info ones past them are not counted. */ + moreFindings: cardCountSchema, +}); +export type BookPageCard = z.infer; diff --git a/shared/src/assistant/cards/book.contract.ts b/shared/src/assistant/cards/book.contract.ts new file mode 100644 index 000000000..46ec26d9f --- /dev/null +++ b/shared/src/assistant/cards/book.contract.ts @@ -0,0 +1,23 @@ +import { bookPageCardSchema } from './book-page.card'; + +export * from './book-page.card'; + +/** + * What the Studio's photo book brings to the assistant chat: the kind of card + * a held book write draws, the verbs of its change cards and what an applied + * one touches. cards/index.ts and assistant.schema.ts spread these into the + * card union and the shared enums, so a new kind, verb or entity is added + * here and nowhere else. + */ +export const BOOK_CARD_SCHEMAS = [bookPageCardSchema] as const; +/** A book laid down, pages added, changed, moved or deleted, the cover set. */ +export const BOOK_VERB_KEYS = [ + 'createBook', + 'addBookPages', + 'editBookPage', + 'moveBookPage', + 'removeBookPages', + 'setBookCover', +] as const; +/** A page of a journey's book; the receipt opens the Studio on it. Pages have string ids, so the card names them. */ +export const BOOK_APPLIED_ENTITIES = ['book_page'] as const; diff --git a/shared/src/i18n/ar/assistantBook.ts b/shared/src/i18n/ar/assistantBook.ts new file mode 100644 index 000000000..1c31de94d --- /dev/null +++ b/shared/src/i18n/ar/assistantBook.ts @@ -0,0 +1,69 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'إنشاء كتاب الصور', + 'assistant.change.verb.addBookPages': 'إضافة صفحات إلى الكتاب', + 'assistant.change.verb.editBookPage': 'تغيير الصفحة', + 'assistant.change.verb.moveBookPage': 'نقل الصفحة', + 'assistant.change.verb.removeBookPages': 'حذف صفحات من الكتاب', + 'assistant.change.verb.setBookCover': 'تغيير الغلاف', + 'assistant.step.readingBook': 'يقرأ الكتاب', + 'assistant.step.lookingAtPage': 'يفحص الصفحة', + 'assistant.step.bookLayouts': 'يتصفح التخطيطات', + 'assistant.step.choosingPhotos': 'يختار الصور', + 'assistant.card.book.open': 'عرض في الاستوديو', + 'assistant.card.book.showPage': 'عرض هذه الصفحة', + 'assistant.card.book.cover': 'الغلاف', + 'assistant.card.book.first': 'الصفحة الأولى', + 'assistant.card.book.last': 'الصفحة الأخيرة', + 'assistant.card.book.back': 'الغلاف الخلفي', + 'assistant.card.book.spread': 'الصفحة المزدوجة {page}', + 'assistant.card.book.spreadAny': 'صفحة مزدوجة', + 'assistant.card.book.newBook': 'كتاب صور جديد', + 'assistant.card.book.layoutAuto': 'أعيد تنسيقها من إدخالها', + 'assistant.card.book.before': 'قبل', + 'assistant.card.book.after': 'بعد', + 'assistant.card.book.pagesAdded': '{count} صفحة جديدة', + 'assistant.card.book.pagesAdded.zero': '{count} صفحات جديدة', + 'assistant.card.book.pagesAdded.one': '{count} صفحة جديدة', + 'assistant.card.book.pagesAdded.two': '{count} صفحتان جديدتان', + 'assistant.card.book.pagesAdded.few': '{count} صفحات جديدة', + 'assistant.card.book.pagesAdded.many': '{count} صفحة جديدة', + 'assistant.card.book.grid': 'شبكة من {count} صورة', + 'assistant.card.book.grid.zero': 'شبكة من {count} صور', + 'assistant.card.book.grid.one': 'شبكة من {count} صورة', + 'assistant.card.book.grid.two': 'شبكة من {count} صورتين', + 'assistant.card.book.grid.few': 'شبكة من {count} صور', + 'assistant.card.book.grid.many': 'شبكة من {count} صورة', + 'assistant.card.book.photosAdded': '+{count} صورة', + 'assistant.card.book.photosAdded.zero': '+{count} صور', + 'assistant.card.book.photosAdded.one': '+{count} صورة', + 'assistant.card.book.photosAdded.two': '+{count} صورتان', + 'assistant.card.book.photosAdded.few': '+{count} صور', + 'assistant.card.book.photosAdded.many': '+{count} صورة', + 'assistant.card.book.findings': '{count} نقطة للمراجعة', + 'assistant.card.book.findings.zero': '{count} نقاط للمراجعة', + 'assistant.card.book.findings.one': '{count} نقطة للمراجعة', + 'assistant.card.book.findings.two': '{count} نقطتان للمراجعة', + 'assistant.card.book.findings.few': '{count} نقاط للمراجعة', + 'assistant.card.book.findings.many': '{count} نقطة للمراجعة', + 'assistant.card.book.finding.overlap': 'عناصر متداخلة', + 'assistant.card.book.finding.fold': 'شيء يقع في الطيّة', + 'assistant.card.book.finding.trim': 'شيء يتجاوز الحافة', + 'assistant.card.book.finding.empty_frame': 'إطار صورة فارغ', + 'assistant.card.book.finding.low_dpi': 'قد تُطبع صورة غير واضحة', + 'assistant.card.book.finding.focal_cut': 'محور صورة مقطوع', + 'assistant.card.book.finding.text_overflow': 'النص يتجاوز إطاره', + 'assistant.card.book.finding.parked': 'عناصر مركونة', + 'assistant.card.book.finding.hidden_photo': 'صورة لمساهم آخر', + 'assistant.card.book.finding.not_in_gallery': 'صورة من خارج المعرض', + 'assistant.card.book.finding.text_on_busy': 'نص فوق جزء مزدحم من صورة', + 'assistant.card.book.finding.contrast_low': 'النص صعب القراءة', + 'assistant.card.book.finding.small_text': 'نص صغير جدًا', + 'assistant.card.book.finding.crowded': 'صفحة مزدحمة', + 'assistant.card.book.finding.off_grid': 'شيء غير محاذٍ قليلًا', + 'assistant.card.book.finding.font_mix': 'خطوط كثيرة جدًا', + 'assistant.card.book.finding.palette_drift': 'ألوان غير متناسقة', + 'assistant.card.book.finding.repeat_layout': 'التخطيط نفسه مرارًا', +}; +export default assistantBook; diff --git a/shared/src/i18n/az/assistantBook.ts b/shared/src/i18n/az/assistantBook.ts new file mode 100644 index 000000000..cfb9b364d --- /dev/null +++ b/shared/src/i18n/az/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Foto kitabı yarat', + 'assistant.change.verb.addBookPages': 'Kitaba səhifə əlavə et', + 'assistant.change.verb.editBookPage': 'Səhifəni dəyiş', + 'assistant.change.verb.moveBookPage': 'Səhifəni köçür', + 'assistant.change.verb.removeBookPages': 'Kitabdan səhifələri sil', + 'assistant.change.verb.setBookCover': 'Üzlüyü dəyiş', + 'assistant.step.readingBook': 'Kitab oxunur', + 'assistant.step.lookingAtPage': 'Səhifəyə baxılır', + 'assistant.step.bookLayouts': 'Düzənlərə baxılır', + 'assistant.step.choosingPhotos': 'Fotolar seçilir', + 'assistant.card.book.open': 'Studio-da göstər', + 'assistant.card.book.showPage': 'Bu səhifəni göstər', + 'assistant.card.book.cover': 'Üzlük', + 'assistant.card.book.first': 'İlk səhifə', + 'assistant.card.book.last': 'Son səhifə', + 'assistant.card.book.back': 'Arxa üzlük', + 'assistant.card.book.spread': 'İkiqat səhifə {page}', + 'assistant.card.book.spreadAny': 'İkiqat səhifə', + 'assistant.card.book.newBook': 'Yeni foto kitabı', + 'assistant.card.book.layoutAuto': 'Qeydinə görə yenidən düzülüb', + 'assistant.card.book.before': 'Əvvəl', + 'assistant.card.book.after': 'Sonra', + 'assistant.card.book.pagesAdded': '{count} yeni səhifə', + 'assistant.card.book.pagesAdded.one': '{count} yeni səhifə', + 'assistant.card.book.grid': '{count} fotoluq tor', + 'assistant.card.book.grid.one': '{count} fotoluq tor', + 'assistant.card.book.photosAdded': '+{count} foto', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': 'Yoxlanılacaq {count} məqam', + 'assistant.card.book.findings.one': 'Yoxlanılacaq {count} məqam', + 'assistant.card.book.finding.overlap': 'Elementlər üst-üstə düşür', + 'assistant.card.book.finding.fold': 'Nəsə qatlanma yerinə düşür', + 'assistant.card.book.finding.trim': 'Nəsə kənardan çıxır', + 'assistant.card.book.finding.empty_frame': 'Boş foto çərçivəsi', + 'assistant.card.book.finding.low_dpi': 'Foto bulanıq çap oluna bilər', + 'assistant.card.book.finding.focal_cut': 'Fotonun fokusu kəsilib', + 'assistant.card.book.finding.text_overflow': 'Mətn çərçivədən çıxır', + 'assistant.card.book.finding.parked': 'Kənara qoyulmuş elementlər', + 'assistant.card.book.finding.hidden_photo': 'Başqa iştirakçının fotosu', + 'assistant.card.book.finding.not_in_gallery': 'Qalereyadan kənar foto', + 'assistant.card.book.finding.text_on_busy': 'Fotonun sıx hissəsi üzərində mətn', + 'assistant.card.book.finding.contrast_low': 'Mətni oxumaq çətindir', + 'assistant.card.book.finding.small_text': 'Çox kiçik mətn', + 'assistant.card.book.finding.crowded': 'Sıx səhifə', + 'assistant.card.book.finding.off_grid': 'Nəsə bir az sırasından çıxıb', + 'assistant.card.book.finding.font_mix': 'Həddən çox şrift', + 'assistant.card.book.finding.palette_drift': 'Uyğun gəlməyən rənglər', + 'assistant.card.book.finding.repeat_layout': 'Təkrar-təkrar eyni düzən', +}; +export default assistantBook; diff --git a/shared/src/i18n/br/assistantBook.ts b/shared/src/i18n/br/assistantBook.ts new file mode 100644 index 000000000..cd224eb2c --- /dev/null +++ b/shared/src/i18n/br/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Criar o fotolivro', + 'assistant.change.verb.addBookPages': 'Adicionar páginas ao livro', + 'assistant.change.verb.editBookPage': 'Alterar a página', + 'assistant.change.verb.moveBookPage': 'Mover a página', + 'assistant.change.verb.removeBookPages': 'Excluir páginas do livro', + 'assistant.change.verb.setBookCover': 'Alterar a capa', + 'assistant.step.readingBook': 'Lendo o livro', + 'assistant.step.lookingAtPage': 'Olhando a página', + 'assistant.step.bookLayouts': 'Vendo os layouts', + 'assistant.step.choosingPhotos': 'Escolhendo fotos', + 'assistant.card.book.open': 'Mostrar no Studio', + 'assistant.card.book.showPage': 'Mostrar esta página', + 'assistant.card.book.cover': 'Capa', + 'assistant.card.book.first': 'Primeira página', + 'assistant.card.book.last': 'Última página', + 'assistant.card.book.back': 'Contracapa', + 'assistant.card.book.spread': 'Página dupla {page}', + 'assistant.card.book.spreadAny': 'Página dupla', + 'assistant.card.book.newBook': 'Novo fotolivro', + 'assistant.card.book.layoutAuto': 'Diagramada de novo a partir do registro', + 'assistant.card.book.before': 'Antes', + 'assistant.card.book.after': 'Depois', + 'assistant.card.book.pagesAdded': '{count} páginas novas', + 'assistant.card.book.pagesAdded.one': '{count} página nova', + 'assistant.card.book.grid': 'Grade de {count} fotos', + 'assistant.card.book.grid.one': 'Grade de {count} foto', + 'assistant.card.book.photosAdded': '+{count} fotos', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} pontos para verificar', + 'assistant.card.book.findings.one': '{count} ponto para verificar', + 'assistant.card.book.finding.overlap': 'Elementos sobrepostos', + 'assistant.card.book.finding.fold': 'Algo fica na dobra', + 'assistant.card.book.finding.trim': 'Algo passa da borda', + 'assistant.card.book.finding.empty_frame': 'Uma moldura de foto vazia', + 'assistant.card.book.finding.low_dpi': 'Uma foto pode sair borrada na impressão', + 'assistant.card.book.finding.focal_cut': 'O foco de uma foto foi cortado', + 'assistant.card.book.finding.text_overflow': 'O texto passa da moldura', + 'assistant.card.book.finding.parked': 'Elementos guardados', + 'assistant.card.book.finding.hidden_photo': 'Uma foto de outro colaborador', + 'assistant.card.book.finding.not_in_gallery': 'Uma foto fora da galeria', + 'assistant.card.book.finding.text_on_busy': 'Texto sobre uma área carregada da foto', + 'assistant.card.book.finding.contrast_low': 'Texto difícil de ler', + 'assistant.card.book.finding.small_text': 'Texto muito pequeno', + 'assistant.card.book.finding.crowded': 'Uma página cheia demais', + 'assistant.card.book.finding.off_grid': 'Algo está um pouco desalinhado', + 'assistant.card.book.finding.font_mix': 'Fontes demais', + 'assistant.card.book.finding.palette_drift': 'Cores que não combinam', + 'assistant.card.book.finding.repeat_layout': 'O mesmo layout de novo e de novo', +}; +export default assistantBook; diff --git a/shared/src/i18n/ca/assistantBook.ts b/shared/src/i18n/ca/assistantBook.ts new file mode 100644 index 000000000..13498228c --- /dev/null +++ b/shared/src/i18n/ca/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Crear el fotollibre', + 'assistant.change.verb.addBookPages': 'Afegir pàgines al llibre', + 'assistant.change.verb.editBookPage': 'Canviar la pàgina', + 'assistant.change.verb.moveBookPage': 'Moure la pàgina', + 'assistant.change.verb.removeBookPages': 'Eliminar pàgines del llibre', + 'assistant.change.verb.setBookCover': 'Canviar la portada', + 'assistant.step.readingBook': 'Llegint el llibre', + 'assistant.step.lookingAtPage': 'Mirant la pàgina', + 'assistant.step.bookLayouts': 'Revisant els dissenys', + 'assistant.step.choosingPhotos': 'Triant fotos', + 'assistant.card.book.open': 'Mostrar a Studio', + 'assistant.card.book.showPage': 'Mostrar aquesta pàgina', + 'assistant.card.book.cover': 'Portada', + 'assistant.card.book.first': 'Primera pàgina', + 'assistant.card.book.last': 'Última pàgina', + 'assistant.card.book.back': 'Contraportada', + 'assistant.card.book.spread': 'Doble pàgina {page}', + 'assistant.card.book.spreadAny': 'Doble pàgina', + 'assistant.card.book.newBook': 'Nou fotollibre', + 'assistant.card.book.layoutAuto': 'Maquetada de nou des de la seva entrada', + 'assistant.card.book.before': 'Abans', + 'assistant.card.book.after': 'Després', + 'assistant.card.book.pagesAdded': '{count} pàgines noves', + 'assistant.card.book.pagesAdded.one': '{count} pàgina nova', + 'assistant.card.book.grid': 'Graella de {count} fotos', + 'assistant.card.book.grid.one': 'Graella de {count} foto', + 'assistant.card.book.photosAdded': '+{count} fotos', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} coses per revisar', + 'assistant.card.book.findings.one': '{count} cosa per revisar', + 'assistant.card.book.finding.overlap': 'Hi ha elements superposats', + 'assistant.card.book.finding.fold': 'Alguna cosa queda al plec', + 'assistant.card.book.finding.trim': 'Alguna cosa sobresurt de la vora', + 'assistant.card.book.finding.empty_frame': 'Un marc de foto buit', + 'assistant.card.book.finding.low_dpi': 'Una foto es podria imprimir borrosa', + 'assistant.card.book.finding.focal_cut': 'El focus d’una foto queda tallat', + 'assistant.card.book.finding.text_overflow': 'El text surt del seu marc', + 'assistant.card.book.finding.parked': 'Elements apartats', + 'assistant.card.book.finding.hidden_photo': 'Una foto d’un altre col·laborador', + 'assistant.card.book.finding.not_in_gallery': 'Una foto fora de la galeria', + 'assistant.card.book.finding.text_on_busy': 'Text sobre una zona carregada de la foto', + 'assistant.card.book.finding.contrast_low': 'El text costa de llegir', + 'assistant.card.book.finding.small_text': 'Text molt petit', + 'assistant.card.book.finding.crowded': 'Una pàgina massa plena', + 'assistant.card.book.finding.off_grid': 'Alguna cosa està una mica desalineada', + 'assistant.card.book.finding.font_mix': 'Massa tipografies', + 'assistant.card.book.finding.palette_drift': 'Colors que no combinen', + 'assistant.card.book.finding.repeat_layout': 'El mateix disseny una vegada i una altra', +}; +export default assistantBook; diff --git a/shared/src/i18n/cs/assistantBook.ts b/shared/src/i18n/cs/assistantBook.ts new file mode 100644 index 000000000..ed2a549be --- /dev/null +++ b/shared/src/i18n/cs/assistantBook.ts @@ -0,0 +1,57 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Vytvořit fotoknihu', + 'assistant.change.verb.addBookPages': 'Přidat stránky do knihy', + 'assistant.change.verb.editBookPage': 'Změnit stránku', + 'assistant.change.verb.moveBookPage': 'Přesunout stránku', + 'assistant.change.verb.removeBookPages': 'Smazat stránky z knihy', + 'assistant.change.verb.setBookCover': 'Změnit obálku', + 'assistant.step.readingBook': 'Čte knihu', + 'assistant.step.lookingAtPage': 'Prohlíží stránku', + 'assistant.step.bookLayouts': 'Prochází rozvržení', + 'assistant.step.choosingPhotos': 'Vybírá fotky', + 'assistant.card.book.open': 'Zobrazit ve Studiu', + 'assistant.card.book.showPage': 'Zobrazit tuto stránku', + 'assistant.card.book.cover': 'Obálka', + 'assistant.card.book.first': 'První stránka', + 'assistant.card.book.last': 'Poslední stránka', + 'assistant.card.book.back': 'Zadní strana obálky', + 'assistant.card.book.spread': 'Dvoustrana {page}', + 'assistant.card.book.spreadAny': 'Dvoustrana', + 'assistant.card.book.newBook': 'Nová fotokniha', + 'assistant.card.book.layoutAuto': 'Znovu rozvrženo podle záznamu', + 'assistant.card.book.before': 'Předtím', + 'assistant.card.book.after': 'Potom', + 'assistant.card.book.pagesAdded': '{count} nových stránek', + 'assistant.card.book.pagesAdded.one': '{count} nová stránka', + 'assistant.card.book.pagesAdded.few': '{count} nové stránky', + 'assistant.card.book.grid': 'Mřížka s {count} fotkami', + 'assistant.card.book.grid.one': 'Mřížka s {count} fotkou', + 'assistant.card.book.grid.few': 'Mřížka s {count} fotkami', + 'assistant.card.book.photosAdded': '+{count} fotek', + 'assistant.card.book.photosAdded.one': '+{count} fotka', + 'assistant.card.book.photosAdded.few': '+{count} fotky', + 'assistant.card.book.findings': '{count} věcí ke kontrole', + 'assistant.card.book.findings.one': '{count} věc ke kontrole', + 'assistant.card.book.findings.few': '{count} věci ke kontrole', + 'assistant.card.book.finding.overlap': 'Prvky se překrývají', + 'assistant.card.book.finding.fold': 'Něco je v ohybu', + 'assistant.card.book.finding.trim': 'Něco přesahuje okraj', + 'assistant.card.book.finding.empty_frame': 'Prázdný rámeček na fotku', + 'assistant.card.book.finding.low_dpi': 'Fotka se může vytisknout rozmazaně', + 'assistant.card.book.finding.focal_cut': 'Ohnisko fotky je oříznuté', + 'assistant.card.book.finding.text_overflow': 'Text přesahuje svůj rámeček', + 'assistant.card.book.finding.parked': 'Odložené prvky', + 'assistant.card.book.finding.hidden_photo': 'Fotka jiného přispěvatele', + 'assistant.card.book.finding.not_in_gallery': 'Fotka mimo galerii', + 'assistant.card.book.finding.text_on_busy': 'Text přes rušnou část fotky', + 'assistant.card.book.finding.contrast_low': 'Text se špatně čte', + 'assistant.card.book.finding.small_text': 'Velmi malý text', + 'assistant.card.book.finding.crowded': 'Přeplněná stránka', + 'assistant.card.book.finding.off_grid': 'Něco je mírně mimo zarovnání', + 'assistant.card.book.finding.font_mix': 'Příliš mnoho písem', + 'assistant.card.book.finding.palette_drift': 'Barvy, které k sobě neladí', + 'assistant.card.book.finding.repeat_layout': 'Pořád stejné rozvržení', +}; +export default assistantBook; diff --git a/shared/src/i18n/de/assistantBook.ts b/shared/src/i18n/de/assistantBook.ts new file mode 100644 index 000000000..27174087c --- /dev/null +++ b/shared/src/i18n/de/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Fotobuch anlegen', + 'assistant.change.verb.addBookPages': 'Seiten zum Buch hinzufügen', + 'assistant.change.verb.editBookPage': 'Seite ändern', + 'assistant.change.verb.moveBookPage': 'Seite verschieben', + 'assistant.change.verb.removeBookPages': 'Seiten aus dem Buch löschen', + 'assistant.change.verb.setBookCover': 'Cover ändern', + 'assistant.step.readingBook': 'Liest das Buch', + 'assistant.step.lookingAtPage': 'Sieht sich die Seite an', + 'assistant.step.bookLayouts': 'Sieht die Layouts durch', + 'assistant.step.choosingPhotos': 'Wählt Fotos aus', + 'assistant.card.book.open': 'Im Studio zeigen', + 'assistant.card.book.showPage': 'Diese Seite zeigen', + 'assistant.card.book.cover': 'Cover', // same-as-en + 'assistant.card.book.first': 'Erste Seite', + 'assistant.card.book.last': 'Letzte Seite', + 'assistant.card.book.back': 'Rückseite', + 'assistant.card.book.spread': 'Doppelseite {page}', + 'assistant.card.book.spreadAny': 'Doppelseite', + 'assistant.card.book.newBook': 'Neues Fotobuch', + 'assistant.card.book.layoutAuto': 'Aus dem Eintrag neu gesetzt', + 'assistant.card.book.before': 'Vorher', + 'assistant.card.book.after': 'Nachher', + 'assistant.card.book.pagesAdded': '{count} neue Seiten', + 'assistant.card.book.pagesAdded.one': '{count} neue Seite', + 'assistant.card.book.grid': 'Raster mit {count} Fotos', + 'assistant.card.book.grid.one': 'Raster mit {count} Foto', + 'assistant.card.book.photosAdded': '+{count} Fotos', + 'assistant.card.book.photosAdded.one': '+{count} Foto', + 'assistant.card.book.findings': '{count} Punkte zum Prüfen', + 'assistant.card.book.findings.one': '{count} Punkt zum Prüfen', + 'assistant.card.book.finding.overlap': 'Elemente überlappen sich', + 'assistant.card.book.finding.fold': 'Etwas liegt im Falz', + 'assistant.card.book.finding.trim': 'Etwas ragt über den Rand', + 'assistant.card.book.finding.empty_frame': 'Ein leerer Fotorahmen', + 'assistant.card.book.finding.low_dpi': 'Ein Foto wird womöglich unscharf gedruckt', + 'assistant.card.book.finding.focal_cut': 'Der Fokus eines Fotos ist abgeschnitten', + 'assistant.card.book.finding.text_overflow': 'Text läuft über seinen Rahmen', + 'assistant.card.book.finding.parked': 'Geparkte Elemente', + 'assistant.card.book.finding.hidden_photo': 'Ein Foto einer anderen Person', + 'assistant.card.book.finding.not_in_gallery': 'Ein Foto außerhalb der Galerie', + 'assistant.card.book.finding.text_on_busy': 'Text über einer unruhigen Fotostelle', + 'assistant.card.book.finding.contrast_low': 'Text ist schwer lesbar', + 'assistant.card.book.finding.small_text': 'Sehr kleiner Text', + 'assistant.card.book.finding.crowded': 'Eine volle Seite', + 'assistant.card.book.finding.off_grid': 'Etwas steht leicht aus der Reihe', + 'assistant.card.book.finding.font_mix': 'Zu viele Schriften', + 'assistant.card.book.finding.palette_drift': 'Farben, die nicht zusammenpassen', + 'assistant.card.book.finding.repeat_layout': 'Immer wieder dasselbe Layout', +}; +export default assistantBook; diff --git a/shared/src/i18n/en/assistantBook.ts b/shared/src/i18n/en/assistantBook.ts new file mode 100644 index 000000000..bb2dd0fe8 --- /dev/null +++ b/shared/src/i18n/en/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Start the photo book', + 'assistant.change.verb.addBookPages': 'Add pages to the book', + 'assistant.change.verb.editBookPage': 'Change the page', + 'assistant.change.verb.moveBookPage': 'Move the page', + 'assistant.change.verb.removeBookPages': 'Delete pages from the book', + 'assistant.change.verb.setBookCover': 'Change the cover', + 'assistant.step.readingBook': 'Reading the book', + 'assistant.step.lookingAtPage': 'Looking at the page', + 'assistant.step.bookLayouts': 'Looking through the layouts', + 'assistant.step.choosingPhotos': 'Choosing photos', + 'assistant.card.book.open': 'Show in the Studio', + 'assistant.card.book.showPage': 'Show this page', + 'assistant.card.book.cover': 'Cover', + 'assistant.card.book.first': 'First page', + 'assistant.card.book.last': 'Last page', + 'assistant.card.book.back': 'Back cover', + 'assistant.card.book.spread': 'Double page {page}', + 'assistant.card.book.spreadAny': 'Double page', + 'assistant.card.book.newBook': 'New photo book', + 'assistant.card.book.layoutAuto': 'Laid out again from its entry', + 'assistant.card.book.before': 'Before', + 'assistant.card.book.after': 'After', + 'assistant.card.book.pagesAdded': '{count} new pages', + 'assistant.card.book.pagesAdded.one': '{count} new page', + 'assistant.card.book.grid': 'Grid of {count} photos', + 'assistant.card.book.grid.one': 'Grid of {count} photo', + 'assistant.card.book.photosAdded': '+{count} photos', + 'assistant.card.book.photosAdded.one': '+{count} photo', + 'assistant.card.book.findings': '{count} things to check', + 'assistant.card.book.findings.one': '{count} thing to check', + 'assistant.card.book.finding.overlap': 'Things overlap', + 'assistant.card.book.finding.fold': 'Something sits in the fold', + 'assistant.card.book.finding.trim': 'Something runs past the edge', + 'assistant.card.book.finding.empty_frame': 'An empty photo frame', + 'assistant.card.book.finding.low_dpi': 'A photo may print blurry', + 'assistant.card.book.finding.focal_cut': 'The focus of a photo is cut off', + 'assistant.card.book.finding.text_overflow': 'Text runs past its frame', + 'assistant.card.book.finding.parked': 'Parked elements', + 'assistant.card.book.finding.hidden_photo': 'A photo by another contributor', + 'assistant.card.book.finding.not_in_gallery': 'A photo outside the gallery', + 'assistant.card.book.finding.text_on_busy': 'Text over a busy part of a photo', + 'assistant.card.book.finding.contrast_low': 'Text is hard to read', + 'assistant.card.book.finding.small_text': 'Very small text', + 'assistant.card.book.finding.crowded': 'A crowded page', + 'assistant.card.book.finding.off_grid': 'Something is slightly out of line', + 'assistant.card.book.finding.font_mix': 'Too many typefaces', + 'assistant.card.book.finding.palette_drift': 'Colours that do not match', + 'assistant.card.book.finding.repeat_layout': 'The same layout again and again', +}; +export default assistantBook; diff --git a/shared/src/i18n/es/assistantBook.ts b/shared/src/i18n/es/assistantBook.ts new file mode 100644 index 000000000..b664e3628 --- /dev/null +++ b/shared/src/i18n/es/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Crear el fotolibro', + 'assistant.change.verb.addBookPages': 'Añadir páginas al libro', + 'assistant.change.verb.editBookPage': 'Cambiar la página', + 'assistant.change.verb.moveBookPage': 'Mover la página', + 'assistant.change.verb.removeBookPages': 'Eliminar páginas del libro', + 'assistant.change.verb.setBookCover': 'Cambiar la portada', + 'assistant.step.readingBook': 'Leyendo el libro', + 'assistant.step.lookingAtPage': 'Mirando la página', + 'assistant.step.bookLayouts': 'Revisando los diseños', + 'assistant.step.choosingPhotos': 'Eligiendo fotos', + 'assistant.card.book.open': 'Mostrar en el Studio', + 'assistant.card.book.showPage': 'Mostrar esta página', + 'assistant.card.book.cover': 'Portada', + 'assistant.card.book.first': 'Primera página', + 'assistant.card.book.last': 'Última página', + 'assistant.card.book.back': 'Contraportada', + 'assistant.card.book.spread': 'Doble página {page}', + 'assistant.card.book.spreadAny': 'Doble página', + 'assistant.card.book.newBook': 'Nuevo fotolibro', + 'assistant.card.book.layoutAuto': 'Maquetada de nuevo desde su entrada', + 'assistant.card.book.before': 'Antes', + 'assistant.card.book.after': 'Después', + 'assistant.card.book.pagesAdded': '{count} páginas nuevas', + 'assistant.card.book.pagesAdded.one': '{count} página nueva', + 'assistant.card.book.grid': 'Cuadrícula de {count} fotos', + 'assistant.card.book.grid.one': 'Cuadrícula de {count} foto', + 'assistant.card.book.photosAdded': '+{count} fotos', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} cosas que revisar', + 'assistant.card.book.findings.one': '{count} cosa que revisar', + 'assistant.card.book.finding.overlap': 'Hay elementos superpuestos', + 'assistant.card.book.finding.fold': 'Algo queda en el pliegue', + 'assistant.card.book.finding.trim': 'Algo sobresale del borde', + 'assistant.card.book.finding.empty_frame': 'Un marco de foto vacío', + 'assistant.card.book.finding.low_dpi': 'Una foto podría imprimirse borrosa', + 'assistant.card.book.finding.focal_cut': 'El foco de una foto queda cortado', + 'assistant.card.book.finding.text_overflow': 'El texto se sale de su marco', + 'assistant.card.book.finding.parked': 'Elementos apartados', + 'assistant.card.book.finding.hidden_photo': 'Una foto de otro colaborador', + 'assistant.card.book.finding.not_in_gallery': 'Una foto fuera de la galería', + 'assistant.card.book.finding.text_on_busy': 'Texto sobre una zona recargada de la foto', + 'assistant.card.book.finding.contrast_low': 'El texto se lee con dificultad', + 'assistant.card.book.finding.small_text': 'Texto muy pequeño', + 'assistant.card.book.finding.crowded': 'Una página recargada', + 'assistant.card.book.finding.off_grid': 'Algo está un poco desalineado', + 'assistant.card.book.finding.font_mix': 'Demasiadas tipografías', + 'assistant.card.book.finding.palette_drift': 'Colores que no combinan', + 'assistant.card.book.finding.repeat_layout': 'El mismo diseño una y otra vez', +}; +export default assistantBook; diff --git a/shared/src/i18n/et/assistantBook.ts b/shared/src/i18n/et/assistantBook.ts new file mode 100644 index 000000000..a311c1d2d --- /dev/null +++ b/shared/src/i18n/et/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Loo fotoraamat', + 'assistant.change.verb.addBookPages': 'Lisa raamatusse lehti', + 'assistant.change.verb.editBookPage': 'Muuda lehte', + 'assistant.change.verb.moveBookPage': 'Liiguta lehte', + 'assistant.change.verb.removeBookPages': 'Kustuta raamatust lehti', + 'assistant.change.verb.setBookCover': 'Muuda kaant', + 'assistant.step.readingBook': 'Loeb raamatut', + 'assistant.step.lookingAtPage': 'Vaatab lehte', + 'assistant.step.bookLayouts': 'Sirvib paigutusi', + 'assistant.step.choosingPhotos': 'Valib fotosid', + 'assistant.card.book.open': 'Näita Studios', + 'assistant.card.book.showPage': 'Näita seda lehte', + 'assistant.card.book.cover': 'Kaas', + 'assistant.card.book.first': 'Esimene leht', + 'assistant.card.book.last': 'Viimane leht', + 'assistant.card.book.back': 'Tagakaas', + 'assistant.card.book.spread': 'Kaksikleht {page}', + 'assistant.card.book.spreadAny': 'Kaksikleht', + 'assistant.card.book.newBook': 'Uus fotoraamat', + 'assistant.card.book.layoutAuto': 'Sissekande järgi uuesti paigutatud', + 'assistant.card.book.before': 'Enne', + 'assistant.card.book.after': 'Pärast', + 'assistant.card.book.pagesAdded': '{count} uut lehte', + 'assistant.card.book.pagesAdded.one': '{count} uus leht', + 'assistant.card.book.grid': 'Ruudustik {count} fotoga', + 'assistant.card.book.grid.one': 'Ruudustik {count} fotoga', + 'assistant.card.book.photosAdded': '+{count} fotot', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} asja kontrollimiseks', + 'assistant.card.book.findings.one': '{count} asi kontrollimiseks', + 'assistant.card.book.finding.overlap': 'Elemendid kattuvad', + 'assistant.card.book.finding.fold': 'Midagi jääb murdekohta', + 'assistant.card.book.finding.trim': 'Midagi ulatub üle serva', + 'assistant.card.book.finding.empty_frame': 'Tühi fotoraam', + 'assistant.card.book.finding.low_dpi': 'Foto võib trükis udune olla', + 'assistant.card.book.finding.focal_cut': 'Foto fookus on ära lõigatud', + 'assistant.card.book.finding.text_overflow': 'Tekst ulatub raamist välja', + 'assistant.card.book.finding.parked': 'Kõrvale pandud elemendid', + 'assistant.card.book.finding.hidden_photo': 'Teise kaasautori foto', + 'assistant.card.book.finding.not_in_gallery': 'Foto väljaspool galeriid', + 'assistant.card.book.finding.text_on_busy': 'Tekst foto kirju osa peal', + 'assistant.card.book.finding.contrast_low': 'Teksti on raske lugeda', + 'assistant.card.book.finding.small_text': 'Väga väike tekst', + 'assistant.card.book.finding.crowded': 'Liiga täis leht', + 'assistant.card.book.finding.off_grid': 'Miski on veidi joonest väljas', + 'assistant.card.book.finding.font_mix': 'Liiga palju kirjatüüpe', + 'assistant.card.book.finding.palette_drift': 'Omavahel sobimatud värvid', + 'assistant.card.book.finding.repeat_layout': 'Ikka ja jälle sama paigutus', +}; +export default assistantBook; diff --git a/shared/src/i18n/fr/assistantBook.ts b/shared/src/i18n/fr/assistantBook.ts new file mode 100644 index 000000000..0989e25a8 --- /dev/null +++ b/shared/src/i18n/fr/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Créer le livre photo', + 'assistant.change.verb.addBookPages': 'Ajouter des pages au livre', + 'assistant.change.verb.editBookPage': 'Modifier la page', + 'assistant.change.verb.moveBookPage': 'Déplacer la page', + 'assistant.change.verb.removeBookPages': 'Supprimer des pages du livre', + 'assistant.change.verb.setBookCover': 'Modifier la couverture', + 'assistant.step.readingBook': 'Lecture du livre', + 'assistant.step.lookingAtPage': 'Examen de la page', + 'assistant.step.bookLayouts': 'Parcours des mises en page', + 'assistant.step.choosingPhotos': 'Choix des photos', + 'assistant.card.book.open': 'Afficher dans le Studio', + 'assistant.card.book.showPage': 'Afficher cette page', + 'assistant.card.book.cover': 'Couverture', + 'assistant.card.book.first': 'Première page', + 'assistant.card.book.last': 'Dernière page', + 'assistant.card.book.back': 'Quatrième de couverture', + 'assistant.card.book.spread': 'Double-page {page}', + 'assistant.card.book.spreadAny': 'Double-page', + 'assistant.card.book.newBook': 'Nouveau livre photo', + 'assistant.card.book.layoutAuto': 'Remise en page depuis son entrée', + 'assistant.card.book.before': 'Avant', + 'assistant.card.book.after': 'Après', + 'assistant.card.book.pagesAdded': '{count} nouvelles pages', + 'assistant.card.book.pagesAdded.one': '{count} nouvelle page', + 'assistant.card.book.grid': 'Grille de {count} photos', + 'assistant.card.book.grid.one': 'Grille de {count} photo', + 'assistant.card.book.photosAdded': '+{count} photos', // same-as-en + 'assistant.card.book.photosAdded.one': '+{count} photo', // same-as-en + 'assistant.card.book.findings': '{count} points à vérifier', + 'assistant.card.book.findings.one': '{count} point à vérifier', + 'assistant.card.book.finding.overlap': 'Des éléments se chevauchent', + 'assistant.card.book.finding.fold': 'Quelque chose est dans le pli', + 'assistant.card.book.finding.trim': 'Quelque chose dépasse le bord', + 'assistant.card.book.finding.empty_frame': 'Un cadre photo vide', + 'assistant.card.book.finding.low_dpi': 'Une photo risque d’être floue à l’impression', + 'assistant.card.book.finding.focal_cut': 'Le sujet d’une photo est coupé', + 'assistant.card.book.finding.text_overflow': 'Le texte déborde de son cadre', + 'assistant.card.book.finding.parked': 'Éléments mis de côté', + 'assistant.card.book.finding.hidden_photo': 'Une photo d’un autre contributeur', + 'assistant.card.book.finding.not_in_gallery': 'Une photo hors de la galerie', + 'assistant.card.book.finding.text_on_busy': 'Texte sur une zone chargée de la photo', + 'assistant.card.book.finding.contrast_low': 'Texte difficile à lire', + 'assistant.card.book.finding.small_text': 'Texte très petit', + 'assistant.card.book.finding.crowded': 'Une page surchargée', + 'assistant.card.book.finding.off_grid': 'Un élément légèrement désaligné', + 'assistant.card.book.finding.font_mix': 'Trop de polices', + 'assistant.card.book.finding.palette_drift': 'Des couleurs qui ne s’accordent pas', + 'assistant.card.book.finding.repeat_layout': 'Toujours la même mise en page', +}; +export default assistantBook; diff --git a/shared/src/i18n/gr/assistantBook.ts b/shared/src/i18n/gr/assistantBook.ts new file mode 100644 index 000000000..ade787240 --- /dev/null +++ b/shared/src/i18n/gr/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Δημιουργία του φωτοβιβλίου', + 'assistant.change.verb.addBookPages': 'Προσθήκη σελίδων στο βιβλίο', + 'assistant.change.verb.editBookPage': 'Αλλαγή της σελίδας', + 'assistant.change.verb.moveBookPage': 'Μετακίνηση της σελίδας', + 'assistant.change.verb.removeBookPages': 'Διαγραφή σελίδων από το βιβλίο', + 'assistant.change.verb.setBookCover': 'Αλλαγή του εξωφύλλου', + 'assistant.step.readingBook': 'Διαβάζει το βιβλίο', + 'assistant.step.lookingAtPage': 'Εξετάζει τη σελίδα', + 'assistant.step.bookLayouts': 'Ψάχνει στις διατάξεις', + 'assistant.step.choosingPhotos': 'Επιλέγει φωτογραφίες', + 'assistant.card.book.open': 'Εμφάνιση στο Studio', + 'assistant.card.book.showPage': 'Εμφάνιση αυτής της σελίδας', + 'assistant.card.book.cover': 'Εξώφυλλο', + 'assistant.card.book.first': 'Πρώτη σελίδα', + 'assistant.card.book.last': 'Τελευταία σελίδα', + 'assistant.card.book.back': 'Οπισθόφυλλο', + 'assistant.card.book.spread': 'Δισέλιδο {page}', + 'assistant.card.book.spreadAny': 'Δισέλιδο', + 'assistant.card.book.newBook': 'Νέο φωτοβιβλίο', + 'assistant.card.book.layoutAuto': 'Νέα σελιδοποίηση από την καταχώρισή του', + 'assistant.card.book.before': 'Πριν', + 'assistant.card.book.after': 'Μετά', + 'assistant.card.book.pagesAdded': '{count} νέες σελίδες', + 'assistant.card.book.pagesAdded.one': '{count} νέα σελίδα', + 'assistant.card.book.grid': 'Πλέγμα {count} φωτογραφιών', + 'assistant.card.book.grid.one': 'Πλέγμα {count} φωτογραφίας', + 'assistant.card.book.photosAdded': '+{count} φωτογραφίες', + 'assistant.card.book.photosAdded.one': '+{count} φωτογραφία', + 'assistant.card.book.findings': '{count} σημεία για έλεγχο', + 'assistant.card.book.findings.one': '{count} σημείο για έλεγχο', + 'assistant.card.book.finding.overlap': 'Στοιχεία επικαλύπτονται', + 'assistant.card.book.finding.fold': 'Κάτι πέφτει στο δίπλωμα', + 'assistant.card.book.finding.trim': 'Κάτι βγαίνει έξω από την άκρη', + 'assistant.card.book.finding.empty_frame': 'Ένα άδειο πλαίσιο φωτογραφίας', + 'assistant.card.book.finding.low_dpi': 'Μια φωτογραφία ίσως τυπωθεί θολή', + 'assistant.card.book.finding.focal_cut': 'Το κέντρο μιας φωτογραφίας κόβεται', + 'assistant.card.book.finding.text_overflow': 'Το κείμενο ξεπερνά το πλαίσιό του', + 'assistant.card.book.finding.parked': 'Παρκαρισμένα στοιχεία', + 'assistant.card.book.finding.hidden_photo': 'Φωτογραφία άλλου συντελεστή', + 'assistant.card.book.finding.not_in_gallery': 'Φωτογραφία εκτός συλλογής', + 'assistant.card.book.finding.text_on_busy': 'Κείμενο πάνω σε φορτωμένο σημείο φωτογραφίας', + 'assistant.card.book.finding.contrast_low': 'Το κείμενο διαβάζεται δύσκολα', + 'assistant.card.book.finding.small_text': 'Πολύ μικρό κείμενο', + 'assistant.card.book.finding.crowded': 'Μια παραφορτωμένη σελίδα', + 'assistant.card.book.finding.off_grid': 'Κάτι είναι λίγο εκτός ευθυγράμμισης', + 'assistant.card.book.finding.font_mix': 'Πάρα πολλές γραμματοσειρές', + 'assistant.card.book.finding.palette_drift': 'Χρώματα που δεν ταιριάζουν', + 'assistant.card.book.finding.repeat_layout': 'Η ίδια διάταξη ξανά και ξανά', +}; +export default assistantBook; diff --git a/shared/src/i18n/hu/assistantBook.ts b/shared/src/i18n/hu/assistantBook.ts new file mode 100644 index 000000000..a215724fd --- /dev/null +++ b/shared/src/i18n/hu/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Fotókönyv létrehozása', + 'assistant.change.verb.addBookPages': 'Oldalak hozzáadása a könyvhöz', + 'assistant.change.verb.editBookPage': 'Oldal módosítása', + 'assistant.change.verb.moveBookPage': 'Oldal áthelyezése', + 'assistant.change.verb.removeBookPages': 'Oldalak törlése a könyvből', + 'assistant.change.verb.setBookCover': 'Borító módosítása', + 'assistant.step.readingBook': 'A könyv olvasása', + 'assistant.step.lookingAtPage': 'Az oldal megtekintése', + 'assistant.step.bookLayouts': 'Elrendezések átnézése', + 'assistant.step.choosingPhotos': 'Fotók kiválasztása', + 'assistant.card.book.open': 'Megnyitás a Studióban', + 'assistant.card.book.showPage': 'Oldal megjelenítése', + 'assistant.card.book.cover': 'Borító', + 'assistant.card.book.first': 'Első oldal', + 'assistant.card.book.last': 'Utolsó oldal', + 'assistant.card.book.back': 'Hátsó borító', + 'assistant.card.book.spread': '{page}. dupla oldal', + 'assistant.card.book.spreadAny': 'Dupla oldal', + 'assistant.card.book.newBook': 'Új fotókönyv', + 'assistant.card.book.layoutAuto': 'Újratördelve a bejegyzése alapján', + 'assistant.card.book.before': 'Előtte', + 'assistant.card.book.after': 'Utána', + 'assistant.card.book.pagesAdded': '{count} új oldal', + 'assistant.card.book.pagesAdded.one': '{count} új oldal', + 'assistant.card.book.grid': '{count} fotós rács', + 'assistant.card.book.grid.one': '{count} fotós rács', + 'assistant.card.book.photosAdded': '+{count} fotó', + 'assistant.card.book.photosAdded.one': '+{count} fotó', + 'assistant.card.book.findings': '{count} ellenőrizendő pont', + 'assistant.card.book.findings.one': '{count} ellenőrizendő pont', + 'assistant.card.book.finding.overlap': 'Elemek fedik egymást', + 'assistant.card.book.finding.fold': 'Valami a hajtásba esik', + 'assistant.card.book.finding.trim': 'Valami túllóg a szélén', + 'assistant.card.book.finding.empty_frame': 'Egy üres képkeret', + 'assistant.card.book.finding.low_dpi': 'Egy fotó elmosódottan nyomtatódhat', + 'assistant.card.book.finding.focal_cut': 'Egy fotó fókuszpontja levágódik', + 'assistant.card.book.finding.text_overflow': 'A szöveg kilóg a keretéből', + 'assistant.card.book.finding.parked': 'Félretett elemek', + 'assistant.card.book.finding.hidden_photo': 'Egy másik közreműködő fotója', + 'assistant.card.book.finding.not_in_gallery': 'Egy galérián kívüli fotó', + 'assistant.card.book.finding.text_on_busy': 'Szöveg a fotó zsúfolt részén', + 'assistant.card.book.finding.contrast_low': 'A szöveg nehezen olvasható', + 'assistant.card.book.finding.small_text': 'Nagyon kicsi szöveg', + 'assistant.card.book.finding.crowded': 'Zsúfolt oldal', + 'assistant.card.book.finding.off_grid': 'Valami kissé elcsúszott', + 'assistant.card.book.finding.font_mix': 'Túl sok betűtípus', + 'assistant.card.book.finding.palette_drift': 'Össze nem illő színek', + 'assistant.card.book.finding.repeat_layout': 'Újra és újra ugyanaz az elrendezés', +}; +export default assistantBook; diff --git a/shared/src/i18n/id/assistantBook.ts b/shared/src/i18n/id/assistantBook.ts new file mode 100644 index 000000000..a859f9260 --- /dev/null +++ b/shared/src/i18n/id/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Buat buku foto', + 'assistant.change.verb.addBookPages': 'Tambahkan halaman ke buku', + 'assistant.change.verb.editBookPage': 'Ubah halaman', + 'assistant.change.verb.moveBookPage': 'Pindahkan halaman', + 'assistant.change.verb.removeBookPages': 'Hapus halaman dari buku', + 'assistant.change.verb.setBookCover': 'Ubah sampul', + 'assistant.step.readingBook': 'Membaca buku', + 'assistant.step.lookingAtPage': 'Melihat halaman', + 'assistant.step.bookLayouts': 'Menelusuri tata letak', + 'assistant.step.choosingPhotos': 'Memilih foto', + 'assistant.card.book.open': 'Tampilkan di Studio', + 'assistant.card.book.showPage': 'Tampilkan halaman ini', + 'assistant.card.book.cover': 'Sampul', + 'assistant.card.book.first': 'Halaman pertama', + 'assistant.card.book.last': 'Halaman terakhir', + 'assistant.card.book.back': 'Sampul belakang', + 'assistant.card.book.spread': 'Halaman ganda {page}', + 'assistant.card.book.spreadAny': 'Halaman ganda', + 'assistant.card.book.newBook': 'Buku foto baru', + 'assistant.card.book.layoutAuto': 'Ditata ulang dari entrinya', + 'assistant.card.book.before': 'Sebelum', + 'assistant.card.book.after': 'Sesudah', + 'assistant.card.book.pagesAdded': '{count} halaman baru', + 'assistant.card.book.grid': 'Kisi {count} foto', + 'assistant.card.book.photosAdded': '+{count} foto', + 'assistant.card.book.findings': '{count} hal untuk diperiksa', + 'assistant.card.book.finding.overlap': 'Elemen saling bertumpuk', + 'assistant.card.book.finding.fold': 'Ada yang jatuh di lipatan', + 'assistant.card.book.finding.trim': 'Ada yang melewati tepi', + 'assistant.card.book.finding.empty_frame': 'Bingkai foto kosong', + 'assistant.card.book.finding.low_dpi': 'Foto mungkin tercetak buram', + 'assistant.card.book.finding.focal_cut': 'Titik fokus foto terpotong', + 'assistant.card.book.finding.text_overflow': 'Teks melewati bingkainya', + 'assistant.card.book.finding.parked': 'Elemen yang disisihkan', + 'assistant.card.book.finding.hidden_photo': 'Foto dari kontributor lain', + 'assistant.card.book.finding.not_in_gallery': 'Foto di luar galeri', + 'assistant.card.book.finding.text_on_busy': 'Teks di atas bagian foto yang ramai', + 'assistant.card.book.finding.contrast_low': 'Teks sulit dibaca', + 'assistant.card.book.finding.small_text': 'Teks sangat kecil', + 'assistant.card.book.finding.crowded': 'Halaman terlalu penuh', + 'assistant.card.book.finding.off_grid': 'Ada yang sedikit tidak sejajar', + 'assistant.card.book.finding.font_mix': 'Terlalu banyak jenis huruf', + 'assistant.card.book.finding.palette_drift': 'Warna yang tidak serasi', + 'assistant.card.book.finding.repeat_layout': 'Tata letak yang sama berulang-ulang', +}; +export default assistantBook; diff --git a/shared/src/i18n/it/assistantBook.ts b/shared/src/i18n/it/assistantBook.ts new file mode 100644 index 000000000..ba0191726 --- /dev/null +++ b/shared/src/i18n/it/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Crea il fotolibro', + 'assistant.change.verb.addBookPages': 'Aggiungi pagine al libro', + 'assistant.change.verb.editBookPage': 'Modifica la pagina', + 'assistant.change.verb.moveBookPage': 'Sposta la pagina', + 'assistant.change.verb.removeBookPages': 'Elimina pagine dal libro', + 'assistant.change.verb.setBookCover': 'Modifica la copertina', + 'assistant.step.readingBook': 'Lettura del libro', + 'assistant.step.lookingAtPage': 'Esame della pagina', + 'assistant.step.bookLayouts': 'Esame dei layout', + 'assistant.step.choosingPhotos': 'Scelta delle foto', + 'assistant.card.book.open': 'Mostra nello Studio', + 'assistant.card.book.showPage': 'Mostra questa pagina', + 'assistant.card.book.cover': 'Copertina', + 'assistant.card.book.first': 'Prima pagina', + 'assistant.card.book.last': 'Ultima pagina', + 'assistant.card.book.back': 'Retro di copertina', + 'assistant.card.book.spread': 'Doppia pagina {page}', + 'assistant.card.book.spreadAny': 'Doppia pagina', + 'assistant.card.book.newBook': 'Nuovo fotolibro', + 'assistant.card.book.layoutAuto': 'Reimpaginata dalla sua voce', + 'assistant.card.book.before': 'Prima', + 'assistant.card.book.after': 'Dopo', + 'assistant.card.book.pagesAdded': '{count} pagine nuove', + 'assistant.card.book.pagesAdded.one': '{count} pagina nuova', + 'assistant.card.book.grid': 'Griglia di {count} foto', + 'assistant.card.book.grid.one': 'Griglia di {count} foto', + 'assistant.card.book.photosAdded': '+{count} foto', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} cose da controllare', + 'assistant.card.book.findings.one': '{count} cosa da controllare', + 'assistant.card.book.finding.overlap': 'Elementi sovrapposti', + 'assistant.card.book.finding.fold': 'Qualcosa finisce nella piega', + 'assistant.card.book.finding.trim': 'Qualcosa supera il bordo', + 'assistant.card.book.finding.empty_frame': 'Una cornice foto vuota', + 'assistant.card.book.finding.low_dpi': 'Una foto potrebbe stamparsi sfocata', + 'assistant.card.book.finding.focal_cut': 'Il soggetto di una foto è tagliato', + 'assistant.card.book.finding.text_overflow': 'Il testo esce dalla sua cornice', + 'assistant.card.book.finding.parked': 'Elementi messi da parte', + 'assistant.card.book.finding.hidden_photo': 'Una foto di un altro collaboratore', + 'assistant.card.book.finding.not_in_gallery': 'Una foto fuori dalla galleria', + 'assistant.card.book.finding.text_on_busy': 'Testo su una zona movimentata della foto', + 'assistant.card.book.finding.contrast_low': 'Testo difficile da leggere', + 'assistant.card.book.finding.small_text': 'Testo molto piccolo', + 'assistant.card.book.finding.crowded': 'Una pagina affollata', + 'assistant.card.book.finding.off_grid': 'Qualcosa è leggermente fuori allineamento', + 'assistant.card.book.finding.font_mix': 'Troppi caratteri tipografici', + 'assistant.card.book.finding.palette_drift': 'Colori che non si accordano', + 'assistant.card.book.finding.repeat_layout': 'Sempre lo stesso layout', +}; +export default assistantBook; diff --git a/shared/src/i18n/ja/assistantBook.ts b/shared/src/i18n/ja/assistantBook.ts new file mode 100644 index 000000000..ced02acd6 --- /dev/null +++ b/shared/src/i18n/ja/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'フォトブックを作成', + 'assistant.change.verb.addBookPages': 'ブックにページを追加', + 'assistant.change.verb.editBookPage': 'ページを変更', + 'assistant.change.verb.moveBookPage': 'ページを移動', + 'assistant.change.verb.removeBookPages': 'ブックからページを削除', + 'assistant.change.verb.setBookCover': '表紙を変更', + 'assistant.step.readingBook': 'ブックを読み込み中', + 'assistant.step.lookingAtPage': 'ページを確認中', + 'assistant.step.bookLayouts': 'レイアウトを確認中', + 'assistant.step.choosingPhotos': '写真を選択中', + 'assistant.card.book.open': 'Studioで表示', + 'assistant.card.book.showPage': 'このページを表示', + 'assistant.card.book.cover': '表紙', + 'assistant.card.book.first': '最初のページ', + 'assistant.card.book.last': '最後のページ', + 'assistant.card.book.back': '裏表紙', + 'assistant.card.book.spread': '見開き {page}', + 'assistant.card.book.spreadAny': '見開き', + 'assistant.card.book.newBook': '新しいフォトブック', + 'assistant.card.book.layoutAuto': 'エントリーから再レイアウト', + 'assistant.card.book.before': '変更前', + 'assistant.card.book.after': '変更後', + 'assistant.card.book.pagesAdded': '{count} ページ追加', + 'assistant.card.book.grid': '写真 {count} 枚のグリッド', + 'assistant.card.book.photosAdded': '写真 +{count} 枚', + 'assistant.card.book.findings': '確認事項 {count} 件', + 'assistant.card.book.finding.overlap': '要素が重なっています', + 'assistant.card.book.finding.fold': '何かが綴じ目にかかっています', + 'assistant.card.book.finding.trim': '何かが端からはみ出しています', + 'assistant.card.book.finding.empty_frame': '空の写真フレーム', + 'assistant.card.book.finding.low_dpi': '写真がぼやけて印刷される可能性があります', + 'assistant.card.book.finding.focal_cut': '写真の焦点が切れています', + 'assistant.card.book.finding.text_overflow': 'テキストが枠からはみ出しています', + 'assistant.card.book.finding.parked': '退避中の要素', + 'assistant.card.book.finding.hidden_photo': '他の投稿者の写真', + 'assistant.card.book.finding.not_in_gallery': 'ギャラリー外の写真', + 'assistant.card.book.finding.text_on_busy': '写真の込み入った部分にテキスト', + 'assistant.card.book.finding.contrast_low': 'テキストが読みにくい', + 'assistant.card.book.finding.small_text': 'とても小さいテキスト', + 'assistant.card.book.finding.crowded': '要素が詰まったページ', + 'assistant.card.book.finding.off_grid': '少しずれている要素', + 'assistant.card.book.finding.font_mix': 'フォントが多すぎます', + 'assistant.card.book.finding.palette_drift': '合わない色', + 'assistant.card.book.finding.repeat_layout': '同じレイアウトの繰り返し', +}; +export default assistantBook; diff --git a/shared/src/i18n/ko/assistantBook.ts b/shared/src/i18n/ko/assistantBook.ts new file mode 100644 index 000000000..1cf8c6b06 --- /dev/null +++ b/shared/src/i18n/ko/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': '포토북 만들기', + 'assistant.change.verb.addBookPages': '책에 페이지 추가', + 'assistant.change.verb.editBookPage': '페이지 변경', + 'assistant.change.verb.moveBookPage': '페이지 이동', + 'assistant.change.verb.removeBookPages': '책에서 페이지 삭제', + 'assistant.change.verb.setBookCover': '표지 변경', + 'assistant.step.readingBook': '책을 읽는 중', + 'assistant.step.lookingAtPage': '페이지를 보는 중', + 'assistant.step.bookLayouts': '레이아웃을 살펴보는 중', + 'assistant.step.choosingPhotos': '사진을 고르는 중', + 'assistant.card.book.open': 'Studio에서 보기', + 'assistant.card.book.showPage': '이 페이지 보기', + 'assistant.card.book.cover': '표지', + 'assistant.card.book.first': '첫 페이지', + 'assistant.card.book.last': '마지막 페이지', + 'assistant.card.book.back': '뒤표지', + 'assistant.card.book.spread': '양면 페이지 {page}', + 'assistant.card.book.spreadAny': '양면 페이지', + 'assistant.card.book.newBook': '새 포토북', + 'assistant.card.book.layoutAuto': '기록을 바탕으로 다시 배치됨', + 'assistant.card.book.before': '이전', + 'assistant.card.book.after': '이후', + 'assistant.card.book.pagesAdded': '새 페이지 {count}개', + 'assistant.card.book.grid': '사진 {count}장 그리드', + 'assistant.card.book.photosAdded': '사진 +{count}장', + 'assistant.card.book.findings': '확인할 항목 {count}개', + 'assistant.card.book.finding.overlap': '요소가 겹칩니다', + 'assistant.card.book.finding.fold': '무언가가 접히는 부분에 있습니다', + 'assistant.card.book.finding.trim': '무언가가 가장자리를 넘어갑니다', + 'assistant.card.book.finding.empty_frame': '빈 사진 틀', + 'assistant.card.book.finding.low_dpi': '사진이 흐리게 인쇄될 수 있습니다', + 'assistant.card.book.finding.focal_cut': '사진의 초점이 잘렸습니다', + 'assistant.card.book.finding.text_overflow': '텍스트가 틀을 넘칩니다', + 'assistant.card.book.finding.parked': '보관된 요소', + 'assistant.card.book.finding.hidden_photo': '다른 기여자의 사진', + 'assistant.card.book.finding.not_in_gallery': '갤러리에 없는 사진', + 'assistant.card.book.finding.text_on_busy': '사진의 복잡한 부분 위 텍스트', + 'assistant.card.book.finding.contrast_low': '텍스트를 읽기 어렵습니다', + 'assistant.card.book.finding.small_text': '아주 작은 텍스트', + 'assistant.card.book.finding.crowded': '꽉 찬 페이지', + 'assistant.card.book.finding.off_grid': '살짝 어긋난 요소', + 'assistant.card.book.finding.font_mix': '글꼴이 너무 많습니다', + 'assistant.card.book.finding.palette_drift': '어울리지 않는 색', + 'assistant.card.book.finding.repeat_layout': '같은 레이아웃의 반복', +}; +export default assistantBook; diff --git a/shared/src/i18n/nl/assistantBook.ts b/shared/src/i18n/nl/assistantBook.ts new file mode 100644 index 000000000..983c9af11 --- /dev/null +++ b/shared/src/i18n/nl/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Fotoboek aanmaken', + 'assistant.change.verb.addBookPages': 'Pagina’s aan het boek toevoegen', + 'assistant.change.verb.editBookPage': 'Pagina wijzigen', + 'assistant.change.verb.moveBookPage': 'Pagina verplaatsen', + 'assistant.change.verb.removeBookPages': 'Pagina’s uit het boek verwijderen', + 'assistant.change.verb.setBookCover': 'Omslag wijzigen', + 'assistant.step.readingBook': 'Leest het boek', + 'assistant.step.lookingAtPage': 'Bekijkt de pagina', + 'assistant.step.bookLayouts': 'Bekijkt de lay-outs', + 'assistant.step.choosingPhotos': 'Kiest foto’s', + 'assistant.card.book.open': 'Tonen in de Studio', + 'assistant.card.book.showPage': 'Deze pagina tonen', + 'assistant.card.book.cover': 'Omslag', + 'assistant.card.book.first': 'Eerste pagina', + 'assistant.card.book.last': 'Laatste pagina', + 'assistant.card.book.back': 'Achterkant', + 'assistant.card.book.spread': 'Dubbele pagina {page}', + 'assistant.card.book.spreadAny': 'Dubbele pagina', + 'assistant.card.book.newBook': 'Nieuw fotoboek', + 'assistant.card.book.layoutAuto': 'Opnieuw opgemaakt vanuit de notitie', + 'assistant.card.book.before': 'Voor', + 'assistant.card.book.after': 'Na', + 'assistant.card.book.pagesAdded': '{count} nieuwe pagina’s', + 'assistant.card.book.pagesAdded.one': '{count} nieuwe pagina', + 'assistant.card.book.grid': 'Raster van {count} foto’s', + 'assistant.card.book.grid.one': 'Raster van {count} foto', + 'assistant.card.book.photosAdded': '+{count} foto’s', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} punten om te controleren', + 'assistant.card.book.findings.one': '{count} punt om te controleren', + 'assistant.card.book.finding.overlap': 'Elementen overlappen', + 'assistant.card.book.finding.fold': 'Iets zit in de vouw', + 'assistant.card.book.finding.trim': 'Iets steekt over de rand', + 'assistant.card.book.finding.empty_frame': 'Een lege fotolijst', + 'assistant.card.book.finding.low_dpi': 'Een foto wordt mogelijk onscherp gedrukt', + 'assistant.card.book.finding.focal_cut': 'Het onderwerp van een foto valt weg', + 'assistant.card.book.finding.text_overflow': 'Tekst loopt buiten het kader', + 'assistant.card.book.finding.parked': 'Geparkeerde elementen', + 'assistant.card.book.finding.hidden_photo': 'Een foto van een andere bijdrager', + 'assistant.card.book.finding.not_in_gallery': 'Een foto buiten de galerij', + 'assistant.card.book.finding.text_on_busy': 'Tekst op een drukke plek in een foto', + 'assistant.card.book.finding.contrast_low': 'Tekst is moeilijk leesbaar', + 'assistant.card.book.finding.small_text': 'Heel kleine tekst', + 'assistant.card.book.finding.crowded': 'Een volle pagina', + 'assistant.card.book.finding.off_grid': 'Iets staat net niet recht', + 'assistant.card.book.finding.font_mix': 'Te veel lettertypen', + 'assistant.card.book.finding.palette_drift': 'Kleuren die niet bij elkaar passen', + 'assistant.card.book.finding.repeat_layout': 'Steeds dezelfde lay-out', +}; +export default assistantBook; diff --git a/shared/src/i18n/pl/assistantBook.ts b/shared/src/i18n/pl/assistantBook.ts new file mode 100644 index 000000000..311c39875 --- /dev/null +++ b/shared/src/i18n/pl/assistantBook.ts @@ -0,0 +1,61 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Utwórz fotoksiążkę', + 'assistant.change.verb.addBookPages': 'Dodaj strony do książki', + 'assistant.change.verb.editBookPage': 'Zmień stronę', + 'assistant.change.verb.moveBookPage': 'Przenieś stronę', + 'assistant.change.verb.removeBookPages': 'Usuń strony z książki', + 'assistant.change.verb.setBookCover': 'Zmień okładkę', + 'assistant.step.readingBook': 'Czyta książkę', + 'assistant.step.lookingAtPage': 'Przegląda stronę', + 'assistant.step.bookLayouts': 'Przegląda układy', + 'assistant.step.choosingPhotos': 'Wybiera zdjęcia', + 'assistant.card.book.open': 'Pokaż w Studio', + 'assistant.card.book.showPage': 'Pokaż tę stronę', + 'assistant.card.book.cover': 'Okładka', + 'assistant.card.book.first': 'Pierwsza strona', + 'assistant.card.book.last': 'Ostatnia strona', + 'assistant.card.book.back': 'Tył okładki', + 'assistant.card.book.spread': 'Rozkładówka {page}', + 'assistant.card.book.spreadAny': 'Rozkładówka', + 'assistant.card.book.newBook': 'Nowa fotoksiążka', + 'assistant.card.book.layoutAuto': 'Ułożona na nowo według wpisu', + 'assistant.card.book.before': 'Przed', + 'assistant.card.book.after': 'Po', + 'assistant.card.book.pagesAdded': '{count} nowe strony', + 'assistant.card.book.pagesAdded.one': '{count} nowa strona', + 'assistant.card.book.pagesAdded.few': '{count} nowe strony', + 'assistant.card.book.pagesAdded.many': '{count} nowych stron', + 'assistant.card.book.grid': 'Siatka na {count} zdjęcia', + 'assistant.card.book.grid.one': 'Siatka na {count} zdjęcie', + 'assistant.card.book.grid.few': 'Siatka na {count} zdjęcia', + 'assistant.card.book.grid.many': 'Siatka na {count} zdjęć', + 'assistant.card.book.photosAdded': '+{count} zdjęcia', + 'assistant.card.book.photosAdded.one': '+{count} zdjęcie', + 'assistant.card.book.photosAdded.few': '+{count} zdjęcia', + 'assistant.card.book.photosAdded.many': '+{count} zdjęć', + 'assistant.card.book.findings': '{count} rzeczy do sprawdzenia', + 'assistant.card.book.findings.one': '{count} rzecz do sprawdzenia', + 'assistant.card.book.findings.few': '{count} rzeczy do sprawdzenia', + 'assistant.card.book.findings.many': '{count} rzeczy do sprawdzenia', + 'assistant.card.book.finding.overlap': 'Elementy na siebie zachodzą', + 'assistant.card.book.finding.fold': 'Coś wpada w zgięcie', + 'assistant.card.book.finding.trim': 'Coś wychodzi poza krawędź', + 'assistant.card.book.finding.empty_frame': 'Pusta ramka na zdjęcie', + 'assistant.card.book.finding.low_dpi': 'Zdjęcie może się wydrukować nieostro', + 'assistant.card.book.finding.focal_cut': 'Główny punkt zdjęcia jest ucięty', + 'assistant.card.book.finding.text_overflow': 'Tekst wychodzi poza ramkę', + 'assistant.card.book.finding.parked': 'Odłożone elementy', + 'assistant.card.book.finding.hidden_photo': 'Zdjęcie innego współautora', + 'assistant.card.book.finding.not_in_gallery': 'Zdjęcie spoza galerii', + 'assistant.card.book.finding.text_on_busy': 'Tekst na ruchliwej części zdjęcia', + 'assistant.card.book.finding.contrast_low': 'Tekst trudno przeczytać', + 'assistant.card.book.finding.small_text': 'Bardzo mały tekst', + 'assistant.card.book.finding.crowded': 'Przeładowana strona', + 'assistant.card.book.finding.off_grid': 'Coś jest lekko niewyrównane', + 'assistant.card.book.finding.font_mix': 'Zbyt wiele krojów pisma', + 'assistant.card.book.finding.palette_drift': 'Kolory, które do siebie nie pasują', + 'assistant.card.book.finding.repeat_layout': 'Ciągle ten sam układ', +}; +export default assistantBook; diff --git a/shared/src/i18n/ru/assistantBook.ts b/shared/src/i18n/ru/assistantBook.ts new file mode 100644 index 000000000..f303d9e93 --- /dev/null +++ b/shared/src/i18n/ru/assistantBook.ts @@ -0,0 +1,61 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Создать фотокнигу', + 'assistant.change.verb.addBookPages': 'Добавить страницы в книгу', + 'assistant.change.verb.editBookPage': 'Изменить страницу', + 'assistant.change.verb.moveBookPage': 'Переместить страницу', + 'assistant.change.verb.removeBookPages': 'Удалить страницы из книги', + 'assistant.change.verb.setBookCover': 'Изменить обложку', + 'assistant.step.readingBook': 'Читает книгу', + 'assistant.step.lookingAtPage': 'Смотрит страницу', + 'assistant.step.bookLayouts': 'Просматривает макеты', + 'assistant.step.choosingPhotos': 'Выбирает фото', + 'assistant.card.book.open': 'Показать в Studio', + 'assistant.card.book.showPage': 'Показать эту страницу', + 'assistant.card.book.cover': 'Обложка', + 'assistant.card.book.first': 'Первая страница', + 'assistant.card.book.last': 'Последняя страница', + 'assistant.card.book.back': 'Задняя обложка', + 'assistant.card.book.spread': 'Разворот {page}', + 'assistant.card.book.spreadAny': 'Разворот', + 'assistant.card.book.newBook': 'Новая фотокнига', + 'assistant.card.book.layoutAuto': 'Свёрстана заново по записи', + 'assistant.card.book.before': 'До', + 'assistant.card.book.after': 'После', + 'assistant.card.book.pagesAdded': '{count} новой страницы', + 'assistant.card.book.pagesAdded.one': '{count} новая страница', + 'assistant.card.book.pagesAdded.few': '{count} новые страницы', + 'assistant.card.book.pagesAdded.many': '{count} новых страниц', + 'assistant.card.book.grid': 'Сетка на {count} фото', + 'assistant.card.book.grid.one': 'Сетка на {count} фото', + 'assistant.card.book.grid.few': 'Сетка на {count} фото', + 'assistant.card.book.grid.many': 'Сетка на {count} фото', + 'assistant.card.book.photosAdded': '+{count} фото', + 'assistant.card.book.photosAdded.one': '+{count} фото', + 'assistant.card.book.photosAdded.few': '+{count} фото', + 'assistant.card.book.photosAdded.many': '+{count} фото', + 'assistant.card.book.findings': '{count} пункта для проверки', + 'assistant.card.book.findings.one': '{count} пункт для проверки', + 'assistant.card.book.findings.few': '{count} пункта для проверки', + 'assistant.card.book.findings.many': '{count} пунктов для проверки', + 'assistant.card.book.finding.overlap': 'Элементы перекрываются', + 'assistant.card.book.finding.fold': 'Что-то попадает в сгиб', + 'assistant.card.book.finding.trim': 'Что-то выходит за край', + 'assistant.card.book.finding.empty_frame': 'Пустая рамка для фото', + 'assistant.card.book.finding.low_dpi': 'Фото может напечататься размытым', + 'assistant.card.book.finding.focal_cut': 'Главное на фото обрезано', + 'assistant.card.book.finding.text_overflow': 'Текст выходит за рамку', + 'assistant.card.book.finding.parked': 'Отложенные элементы', + 'assistant.card.book.finding.hidden_photo': 'Фото другого участника', + 'assistant.card.book.finding.not_in_gallery': 'Фото не из галереи', + 'assistant.card.book.finding.text_on_busy': 'Текст на пёстрой части фото', + 'assistant.card.book.finding.contrast_low': 'Текст трудно читать', + 'assistant.card.book.finding.small_text': 'Очень мелкий текст', + 'assistant.card.book.finding.crowded': 'Перегруженная страница', + 'assistant.card.book.finding.off_grid': 'Что-то слегка не выровнено', + 'assistant.card.book.finding.font_mix': 'Слишком много шрифтов', + 'assistant.card.book.finding.palette_drift': 'Цвета, которые не сочетаются', + 'assistant.card.book.finding.repeat_layout': 'Снова и снова один и тот же макет', +}; +export default assistantBook; diff --git a/shared/src/i18n/sk/assistantBook.ts b/shared/src/i18n/sk/assistantBook.ts new file mode 100644 index 000000000..4ecda0772 --- /dev/null +++ b/shared/src/i18n/sk/assistantBook.ts @@ -0,0 +1,57 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Vytvoriť fotoknihu', + 'assistant.change.verb.addBookPages': 'Pridať strany do knihy', + 'assistant.change.verb.editBookPage': 'Zmeniť stranu', + 'assistant.change.verb.moveBookPage': 'Presunúť stranu', + 'assistant.change.verb.removeBookPages': 'Odstrániť strany z knihy', + 'assistant.change.verb.setBookCover': 'Zmeniť obal', + 'assistant.step.readingBook': 'Číta knihu', + 'assistant.step.lookingAtPage': 'Prezerá stranu', + 'assistant.step.bookLayouts': 'Prechádza rozloženia', + 'assistant.step.choosingPhotos': 'Vyberá fotky', + 'assistant.card.book.open': 'Zobraziť v Studiu', + 'assistant.card.book.showPage': 'Zobraziť túto stranu', + 'assistant.card.book.cover': 'Obal', + 'assistant.card.book.first': 'Prvá strana', + 'assistant.card.book.last': 'Posledná strana', + 'assistant.card.book.back': 'Zadný obal', + 'assistant.card.book.spread': 'Dvojstrana {page}', + 'assistant.card.book.spreadAny': 'Dvojstrana', + 'assistant.card.book.newBook': 'Nová fotokniha', + 'assistant.card.book.layoutAuto': 'Znova rozložené podľa záznamu', + 'assistant.card.book.before': 'Predtým', + 'assistant.card.book.after': 'Potom', + 'assistant.card.book.pagesAdded': '{count} nových strán', + 'assistant.card.book.pagesAdded.one': '{count} nová strana', + 'assistant.card.book.pagesAdded.few': '{count} nové strany', + 'assistant.card.book.grid': 'Mriežka s {count} fotkami', + 'assistant.card.book.grid.one': 'Mriežka s {count} fotkou', + 'assistant.card.book.grid.few': 'Mriežka s {count} fotkami', + 'assistant.card.book.photosAdded': '+{count} fotiek', + 'assistant.card.book.photosAdded.one': '+{count} fotka', + 'assistant.card.book.photosAdded.few': '+{count} fotky', + 'assistant.card.book.findings': '{count} vecí na kontrolu', + 'assistant.card.book.findings.one': '{count} vec na kontrolu', + 'assistant.card.book.findings.few': '{count} veci na kontrolu', + 'assistant.card.book.finding.overlap': 'Prvky sa prekrývajú', + 'assistant.card.book.finding.fold': 'Niečo je v ohybe', + 'assistant.card.book.finding.trim': 'Niečo prečnieva cez okraj', + 'assistant.card.book.finding.empty_frame': 'Prázdny rámček na fotku', + 'assistant.card.book.finding.low_dpi': 'Fotka sa môže vytlačiť rozmazane', + 'assistant.card.book.finding.focal_cut': 'Ohnisko fotky je orezané', + 'assistant.card.book.finding.text_overflow': 'Text presahuje svoj rámček', + 'assistant.card.book.finding.parked': 'Odložené prvky', + 'assistant.card.book.finding.hidden_photo': 'Fotka iného prispievateľa', + 'assistant.card.book.finding.not_in_gallery': 'Fotka mimo galérie', + 'assistant.card.book.finding.text_on_busy': 'Text cez rušnú časť fotky', + 'assistant.card.book.finding.contrast_low': 'Text sa zle číta', + 'assistant.card.book.finding.small_text': 'Veľmi malý text', + 'assistant.card.book.finding.crowded': 'Preplnená strana', + 'assistant.card.book.finding.off_grid': 'Niečo je mierne mimo zarovnania', + 'assistant.card.book.finding.font_mix': 'Priveľa písiem', + 'assistant.card.book.finding.palette_drift': 'Farby, ktoré k sebe neladia', + 'assistant.card.book.finding.repeat_layout': 'Stále rovnaké rozloženie', +}; +export default assistantBook; diff --git a/shared/src/i18n/sv/assistantBook.ts b/shared/src/i18n/sv/assistantBook.ts new file mode 100644 index 000000000..ff3b5d3e3 --- /dev/null +++ b/shared/src/i18n/sv/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Skapa fotoboken', + 'assistant.change.verb.addBookPages': 'Lägg till sidor i boken', + 'assistant.change.verb.editBookPage': 'Ändra sidan', + 'assistant.change.verb.moveBookPage': 'Flytta sidan', + 'assistant.change.verb.removeBookPages': 'Ta bort sidor ur boken', + 'assistant.change.verb.setBookCover': 'Ändra omslaget', + 'assistant.step.readingBook': 'Läser boken', + 'assistant.step.lookingAtPage': 'Tittar på sidan', + 'assistant.step.bookLayouts': 'Går igenom layouterna', + 'assistant.step.choosingPhotos': 'Väljer foton', + 'assistant.card.book.open': 'Visa i Studio', + 'assistant.card.book.showPage': 'Visa den här sidan', + 'assistant.card.book.cover': 'Omslag', + 'assistant.card.book.first': 'Första sidan', + 'assistant.card.book.last': 'Sista sidan', + 'assistant.card.book.back': 'Baksida', + 'assistant.card.book.spread': 'Uppslag {page}', + 'assistant.card.book.spreadAny': 'Uppslag', + 'assistant.card.book.newBook': 'Ny fotobok', + 'assistant.card.book.layoutAuto': 'Omgjord utifrån sitt inlägg', + 'assistant.card.book.before': 'Före', + 'assistant.card.book.after': 'Efter', + 'assistant.card.book.pagesAdded': '{count} nya sidor', + 'assistant.card.book.pagesAdded.one': '{count} ny sida', + 'assistant.card.book.grid': 'Rutnät med {count} foton', + 'assistant.card.book.grid.one': 'Rutnät med {count} foto', + 'assistant.card.book.photosAdded': '+{count} foton', + 'assistant.card.book.photosAdded.one': '+{count} foto', + 'assistant.card.book.findings': '{count} saker att kontrollera', + 'assistant.card.book.findings.one': '{count} sak att kontrollera', + 'assistant.card.book.finding.overlap': 'Element överlappar', + 'assistant.card.book.finding.fold': 'Något hamnar i falsen', + 'assistant.card.book.finding.trim': 'Något går utanför kanten', + 'assistant.card.book.finding.empty_frame': 'En tom fotoram', + 'assistant.card.book.finding.low_dpi': 'Ett foto kan bli suddigt i tryck', + 'assistant.card.book.finding.focal_cut': 'Motivet i ett foto är beskuret', + 'assistant.card.book.finding.text_overflow': 'Text går utanför sin ram', + 'assistant.card.book.finding.parked': 'Parkerade element', + 'assistant.card.book.finding.hidden_photo': 'Ett foto från en annan medverkande', + 'assistant.card.book.finding.not_in_gallery': 'Ett foto utanför galleriet', + 'assistant.card.book.finding.text_on_busy': 'Text över en rörig del av ett foto', + 'assistant.card.book.finding.contrast_low': 'Texten är svår att läsa', + 'assistant.card.book.finding.small_text': 'Mycket liten text', + 'assistant.card.book.finding.crowded': 'En full sida', + 'assistant.card.book.finding.off_grid': 'Något står lite snett', + 'assistant.card.book.finding.font_mix': 'För många typsnitt', + 'assistant.card.book.finding.palette_drift': 'Färger som inte passar ihop', + 'assistant.card.book.finding.repeat_layout': 'Samma layout om och om igen', +}; +export default assistantBook; diff --git a/shared/src/i18n/th/assistantBook.ts b/shared/src/i18n/th/assistantBook.ts new file mode 100644 index 000000000..3217fbbea --- /dev/null +++ b/shared/src/i18n/th/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'สร้างโฟโต้บุ๊ก', + 'assistant.change.verb.addBookPages': 'เพิ่มหน้าในหนังสือ', + 'assistant.change.verb.editBookPage': 'เปลี่ยนหน้า', + 'assistant.change.verb.moveBookPage': 'ย้ายหน้า', + 'assistant.change.verb.removeBookPages': 'ลบหน้าออกจากหนังสือ', + 'assistant.change.verb.setBookCover': 'เปลี่ยนปก', + 'assistant.step.readingBook': 'กำลังอ่านหนังสือ', + 'assistant.step.lookingAtPage': 'กำลังดูหน้า', + 'assistant.step.bookLayouts': 'กำลังดูเลย์เอาต์', + 'assistant.step.choosingPhotos': 'กำลังเลือกรูปภาพ', + 'assistant.card.book.open': 'แสดงใน Studio', + 'assistant.card.book.showPage': 'แสดงหน้านี้', + 'assistant.card.book.cover': 'ปกหน้า', + 'assistant.card.book.first': 'หน้าแรก', + 'assistant.card.book.last': 'หน้าสุดท้าย', + 'assistant.card.book.back': 'ปกหลัง', + 'assistant.card.book.spread': 'หน้าคู่ {page}', + 'assistant.card.book.spreadAny': 'หน้าคู่', + 'assistant.card.book.newBook': 'โฟโต้บุ๊กใหม่', + 'assistant.card.book.layoutAuto': 'จัดวางใหม่จากบันทึก', + 'assistant.card.book.before': 'ก่อน', + 'assistant.card.book.after': 'หลัง', + 'assistant.card.book.pagesAdded': 'หน้าใหม่ {count} หน้า', + 'assistant.card.book.grid': 'ตารางรูปภาพ {count} รูป', + 'assistant.card.book.photosAdded': 'รูปภาพ +{count} รูป', + 'assistant.card.book.findings': 'รายการที่ต้องตรวจ {count} รายการ', + 'assistant.card.book.finding.overlap': 'องค์ประกอบซ้อนทับกัน', + 'assistant.card.book.finding.fold': 'มีบางอย่างอยู่ในรอยพับ', + 'assistant.card.book.finding.trim': 'มีบางอย่างเกินขอบ', + 'assistant.card.book.finding.empty_frame': 'กรอบรูปว่าง', + 'assistant.card.book.finding.low_dpi': 'รูปภาพอาจพิมพ์ออกมาไม่คมชัด', + 'assistant.card.book.finding.focal_cut': 'จุดโฟกัสของรูปภาพถูกตัด', + 'assistant.card.book.finding.text_overflow': 'ข้อความล้นกรอบ', + 'assistant.card.book.finding.parked': 'องค์ประกอบที่พักไว้', + 'assistant.card.book.finding.hidden_photo': 'รูปภาพของผู้ร่วมสร้างคนอื่น', + 'assistant.card.book.finding.not_in_gallery': 'รูปภาพที่ไม่อยู่ในแกลเลอรี', + 'assistant.card.book.finding.text_on_busy': 'ข้อความบนส่วนที่รกของรูปภาพ', + 'assistant.card.book.finding.contrast_low': 'อ่านข้อความได้ยาก', + 'assistant.card.book.finding.small_text': 'ข้อความเล็กมาก', + 'assistant.card.book.finding.crowded': 'หน้าที่แน่นเกินไป', + 'assistant.card.book.finding.off_grid': 'มีบางอย่างไม่ตรงแนวเล็กน้อย', + 'assistant.card.book.finding.font_mix': 'ใช้ฟอนต์มากเกินไป', + 'assistant.card.book.finding.palette_drift': 'สีที่ไม่เข้ากัน', + 'assistant.card.book.finding.repeat_layout': 'เลย์เอาต์เดิมซ้ำไปซ้ำมา', +}; +export default assistantBook; diff --git a/shared/src/i18n/tr/assistantBook.ts b/shared/src/i18n/tr/assistantBook.ts new file mode 100644 index 000000000..2b1e667de --- /dev/null +++ b/shared/src/i18n/tr/assistantBook.ts @@ -0,0 +1,53 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Fotoğraf kitabını oluştur', + 'assistant.change.verb.addBookPages': 'Kitaba sayfa ekle', + 'assistant.change.verb.editBookPage': 'Sayfayı değiştir', + 'assistant.change.verb.moveBookPage': 'Sayfayı taşı', + 'assistant.change.verb.removeBookPages': 'Kitaptan sayfa sil', + 'assistant.change.verb.setBookCover': 'Kapağı değiştir', + 'assistant.step.readingBook': 'Kitap okunuyor', + 'assistant.step.lookingAtPage': 'Sayfaya bakılıyor', + 'assistant.step.bookLayouts': 'Düzenlere bakılıyor', + 'assistant.step.choosingPhotos': 'Fotoğraflar seçiliyor', + 'assistant.card.book.open': 'Studio’da göster', + 'assistant.card.book.showPage': 'Bu sayfayı göster', + 'assistant.card.book.cover': 'Kapak', + 'assistant.card.book.first': 'İlk sayfa', + 'assistant.card.book.last': 'Son sayfa', + 'assistant.card.book.back': 'Arka kapak', + 'assistant.card.book.spread': 'Çift sayfa {page}', + 'assistant.card.book.spreadAny': 'Çift sayfa', + 'assistant.card.book.newBook': 'Yeni fotoğraf kitabı', + 'assistant.card.book.layoutAuto': 'Kaydına göre yeniden düzenlendi', + 'assistant.card.book.before': 'Önce', + 'assistant.card.book.after': 'Sonra', + 'assistant.card.book.pagesAdded': '{count} yeni sayfa', + 'assistant.card.book.pagesAdded.one': '{count} yeni sayfa', + 'assistant.card.book.grid': '{count} fotoğraflık ızgara', + 'assistant.card.book.grid.one': '{count} fotoğraflık ızgara', + 'assistant.card.book.photosAdded': '+{count} fotoğraf', + 'assistant.card.book.photosAdded.one': '+{count} fotoğraf', + 'assistant.card.book.findings': 'Kontrol edilecek {count} şey', + 'assistant.card.book.findings.one': 'Kontrol edilecek {count} şey', + 'assistant.card.book.finding.overlap': 'Öğeler üst üste biniyor', + 'assistant.card.book.finding.fold': 'Bir şey cilt yerine denk geliyor', + 'assistant.card.book.finding.trim': 'Bir şey kenardan taşıyor', + 'assistant.card.book.finding.empty_frame': 'Boş bir fotoğraf çerçevesi', + 'assistant.card.book.finding.low_dpi': 'Bir fotoğraf bulanık basılabilir', + 'assistant.card.book.finding.focal_cut': 'Bir fotoğrafın odağı kesiliyor', + 'assistant.card.book.finding.text_overflow': 'Metin çerçevesinden taşıyor', + 'assistant.card.book.finding.parked': 'Kenara alınmış öğeler', + 'assistant.card.book.finding.hidden_photo': 'Başka bir katkıda bulunanın fotoğrafı', + 'assistant.card.book.finding.not_in_gallery': 'Galeri dışından bir fotoğraf', + 'assistant.card.book.finding.text_on_busy': 'Fotoğrafın kalabalık bir yerinde metin', + 'assistant.card.book.finding.contrast_low': 'Metin zor okunuyor', + 'assistant.card.book.finding.small_text': 'Çok küçük metin', + 'assistant.card.book.finding.crowded': 'Kalabalık bir sayfa', + 'assistant.card.book.finding.off_grid': 'Bir şey biraz hizadan kaymış', + 'assistant.card.book.finding.font_mix': 'Çok fazla yazı tipi', + 'assistant.card.book.finding.palette_drift': 'Uyumsuz renkler', + 'assistant.card.book.finding.repeat_layout': 'Hep aynı düzen', +}; +export default assistantBook; diff --git a/shared/src/i18n/uk/assistantBook.ts b/shared/src/i18n/uk/assistantBook.ts new file mode 100644 index 000000000..27348001e --- /dev/null +++ b/shared/src/i18n/uk/assistantBook.ts @@ -0,0 +1,61 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Створити фотокнигу', + 'assistant.change.verb.addBookPages': 'Додати сторінки до книги', + 'assistant.change.verb.editBookPage': 'Змінити сторінку', + 'assistant.change.verb.moveBookPage': 'Перемістити сторінку', + 'assistant.change.verb.removeBookPages': 'Видалити сторінки з книги', + 'assistant.change.verb.setBookCover': 'Змінити обкладинку', + 'assistant.step.readingBook': 'Читає книгу', + 'assistant.step.lookingAtPage': 'Переглядає сторінку', + 'assistant.step.bookLayouts': 'Переглядає макети', + 'assistant.step.choosingPhotos': 'Вибирає фото', + 'assistant.card.book.open': 'Показати в Studio', + 'assistant.card.book.showPage': 'Показати цю сторінку', + 'assistant.card.book.cover': 'Обкладинка', + 'assistant.card.book.first': 'Перша сторінка', + 'assistant.card.book.last': 'Остання сторінка', + 'assistant.card.book.back': 'Задня обкладинка', + 'assistant.card.book.spread': 'Розворот {page}', + 'assistant.card.book.spreadAny': 'Розворот', + 'assistant.card.book.newBook': 'Нова фотокнига', + 'assistant.card.book.layoutAuto': 'Зверстано заново за записом', + 'assistant.card.book.before': 'До', + 'assistant.card.book.after': 'Після', + 'assistant.card.book.pagesAdded': '{count} нової сторінки', + 'assistant.card.book.pagesAdded.one': '{count} нова сторінка', + 'assistant.card.book.pagesAdded.few': '{count} нові сторінки', + 'assistant.card.book.pagesAdded.many': '{count} нових сторінок', + 'assistant.card.book.grid': 'Сітка на {count} фото', + 'assistant.card.book.grid.one': 'Сітка на {count} фото', + 'assistant.card.book.grid.few': 'Сітка на {count} фото', + 'assistant.card.book.grid.many': 'Сітка на {count} фото', + 'assistant.card.book.photosAdded': '+{count} фото', + 'assistant.card.book.photosAdded.one': '+{count} фото', + 'assistant.card.book.photosAdded.few': '+{count} фото', + 'assistant.card.book.photosAdded.many': '+{count} фото', + 'assistant.card.book.findings': '{count} пункту для перевірки', + 'assistant.card.book.findings.one': '{count} пункт для перевірки', + 'assistant.card.book.findings.few': '{count} пункти для перевірки', + 'assistant.card.book.findings.many': '{count} пунктів для перевірки', + 'assistant.card.book.finding.overlap': 'Елементи накладаються', + 'assistant.card.book.finding.fold': 'Щось потрапляє в згин', + 'assistant.card.book.finding.trim': 'Щось виходить за край', + 'assistant.card.book.finding.empty_frame': 'Порожня рамка для фото', + 'assistant.card.book.finding.low_dpi': 'Фото може надрукуватися розмитим', + 'assistant.card.book.finding.focal_cut': 'Головне на фото обрізано', + 'assistant.card.book.finding.text_overflow': 'Текст виходить за рамку', + 'assistant.card.book.finding.parked': 'Відкладені елементи', + 'assistant.card.book.finding.hidden_photo': 'Фото іншого учасника', + 'assistant.card.book.finding.not_in_gallery': 'Фото не з галереї', + 'assistant.card.book.finding.text_on_busy': 'Текст на строкатій частині фото', + 'assistant.card.book.finding.contrast_low': 'Текст важко читати', + 'assistant.card.book.finding.small_text': 'Дуже дрібний текст', + 'assistant.card.book.finding.crowded': 'Перевантажена сторінка', + 'assistant.card.book.finding.off_grid': 'Щось трохи не вирівняно', + 'assistant.card.book.finding.font_mix': 'Забагато шрифтів', + 'assistant.card.book.finding.palette_drift': 'Кольори, що не пасують одне одному', + 'assistant.card.book.finding.repeat_layout': 'Знову і знову той самий макет', +}; +export default assistantBook; diff --git a/shared/src/i18n/vi/assistantBook.ts b/shared/src/i18n/vi/assistantBook.ts new file mode 100644 index 000000000..7287d909e --- /dev/null +++ b/shared/src/i18n/vi/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': 'Tạo sách ảnh', + 'assistant.change.verb.addBookPages': 'Thêm trang vào sách', + 'assistant.change.verb.editBookPage': 'Thay đổi trang', + 'assistant.change.verb.moveBookPage': 'Di chuyển trang', + 'assistant.change.verb.removeBookPages': 'Xóa trang khỏi sách', + 'assistant.change.verb.setBookCover': 'Thay đổi bìa', + 'assistant.step.readingBook': 'Đang đọc sách', + 'assistant.step.lookingAtPage': 'Đang xem trang', + 'assistant.step.bookLayouts': 'Đang xem các bố cục', + 'assistant.step.choosingPhotos': 'Đang chọn ảnh', + 'assistant.card.book.open': 'Hiển thị trong Studio', + 'assistant.card.book.showPage': 'Hiển thị trang này', + 'assistant.card.book.cover': 'Bìa trước', + 'assistant.card.book.first': 'Trang đầu', + 'assistant.card.book.last': 'Trang cuối', + 'assistant.card.book.back': 'Bìa sau', + 'assistant.card.book.spread': 'Trang đôi {page}', + 'assistant.card.book.spreadAny': 'Trang đôi', + 'assistant.card.book.newBook': 'Sách ảnh mới', + 'assistant.card.book.layoutAuto': 'Dàn trang lại từ mục nhật ký', + 'assistant.card.book.before': 'Trước', + 'assistant.card.book.after': 'Sau', + 'assistant.card.book.pagesAdded': '{count} trang mới', + 'assistant.card.book.grid': 'Lưới {count} ảnh', + 'assistant.card.book.photosAdded': '+{count} ảnh', + 'assistant.card.book.findings': '{count} điều cần kiểm tra', + 'assistant.card.book.finding.overlap': 'Các phần tử chồng lên nhau', + 'assistant.card.book.finding.fold': 'Có thứ nằm ở nếp gấp', + 'assistant.card.book.finding.trim': 'Có thứ vượt quá mép', + 'assistant.card.book.finding.empty_frame': 'Một khung ảnh trống', + 'assistant.card.book.finding.low_dpi': 'Một ảnh có thể in bị mờ', + 'assistant.card.book.finding.focal_cut': 'Tiêu điểm của ảnh bị cắt', + 'assistant.card.book.finding.text_overflow': 'Chữ tràn khỏi khung', + 'assistant.card.book.finding.parked': 'Phần tử đang để riêng', + 'assistant.card.book.finding.hidden_photo': 'Ảnh của người đóng góp khác', + 'assistant.card.book.finding.not_in_gallery': 'Ảnh ngoài thư viện', + 'assistant.card.book.finding.text_on_busy': 'Chữ trên vùng rối của ảnh', + 'assistant.card.book.finding.contrast_low': 'Chữ khó đọc', + 'assistant.card.book.finding.small_text': 'Chữ rất nhỏ', + 'assistant.card.book.finding.crowded': 'Trang quá chật', + 'assistant.card.book.finding.off_grid': 'Có thứ hơi lệch hàng', + 'assistant.card.book.finding.font_mix': 'Quá nhiều phông chữ', + 'assistant.card.book.finding.palette_drift': 'Màu sắc không hợp nhau', + 'assistant.card.book.finding.repeat_layout': 'Lặp lại cùng một bố cục', +}; +export default assistantBook; diff --git a/shared/src/i18n/zh-TW/assistantBook.ts b/shared/src/i18n/zh-TW/assistantBook.ts new file mode 100644 index 000000000..357606068 --- /dev/null +++ b/shared/src/i18n/zh-TW/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': '建立相片書', + 'assistant.change.verb.addBookPages': '在書中新增頁面', + 'assistant.change.verb.editBookPage': '修改頁面', + 'assistant.change.verb.moveBookPage': '移動頁面', + 'assistant.change.verb.removeBookPages': '從書中刪除頁面', + 'assistant.change.verb.setBookCover': '修改封面', + 'assistant.step.readingBook': '正在讀取書', + 'assistant.step.lookingAtPage': '正在檢視頁面', + 'assistant.step.bookLayouts': '正在瀏覽版面', + 'assistant.step.choosingPhotos': '正在挑選相片', + 'assistant.card.book.open': '在 Studio 中顯示', + 'assistant.card.book.showPage': '顯示此頁', + 'assistant.card.book.cover': '封面', + 'assistant.card.book.first': '首頁', + 'assistant.card.book.last': '末頁', + 'assistant.card.book.back': '封底', + 'assistant.card.book.spread': '跨頁 {page}', + 'assistant.card.book.spreadAny': '跨頁', + 'assistant.card.book.newBook': '新相片書', + 'assistant.card.book.layoutAuto': '已依其記事重新排版', + 'assistant.card.book.before': '修改前', + 'assistant.card.book.after': '修改後', + 'assistant.card.book.pagesAdded': '{count} 個新頁面', + 'assistant.card.book.grid': '{count} 張相片的網格', + 'assistant.card.book.photosAdded': '+{count} 張相片', + 'assistant.card.book.findings': '{count} 項待檢查', + 'assistant.card.book.finding.overlap': '元素彼此重疊', + 'assistant.card.book.finding.fold': '有內容落在裝訂處', + 'assistant.card.book.finding.trim': '有內容超出邊緣', + 'assistant.card.book.finding.empty_frame': '一個空的相片框', + 'assistant.card.book.finding.low_dpi': '相片印出來可能模糊', + 'assistant.card.book.finding.focal_cut': '相片的焦點被裁掉', + 'assistant.card.book.finding.text_overflow': '文字超出了文字框', + 'assistant.card.book.finding.parked': '暫放的元素', + 'assistant.card.book.finding.hidden_photo': '其他貢獻者的相片', + 'assistant.card.book.finding.not_in_gallery': '不在相簿中的相片', + 'assistant.card.book.finding.text_on_busy': '文字壓在相片的繁雜區域上', + 'assistant.card.book.finding.contrast_low': '文字難以閱讀', + 'assistant.card.book.finding.small_text': '文字非常小', + 'assistant.card.book.finding.crowded': '頁面過於擁擠', + 'assistant.card.book.finding.off_grid': '有元素略微沒對齊', + 'assistant.card.book.finding.font_mix': '字型過多', + 'assistant.card.book.finding.palette_drift': '顏色不協調', + 'assistant.card.book.finding.repeat_layout': '反覆使用同一版面', +}; +export default assistantBook; diff --git a/shared/src/i18n/zh/assistantBook.ts b/shared/src/i18n/zh/assistantBook.ts new file mode 100644 index 000000000..b58b24e8a --- /dev/null +++ b/shared/src/i18n/zh/assistantBook.ts @@ -0,0 +1,49 @@ +import type { TranslationStrings } from '../types'; + +const assistantBook: TranslationStrings = { + 'assistant.change.verb.createBook': '创建相册书', + 'assistant.change.verb.addBookPages': '向书中添加页面', + 'assistant.change.verb.editBookPage': '修改页面', + 'assistant.change.verb.moveBookPage': '移动页面', + 'assistant.change.verb.removeBookPages': '从书中删除页面', + 'assistant.change.verb.setBookCover': '修改封面', + 'assistant.step.readingBook': '正在读取书', + 'assistant.step.lookingAtPage': '正在查看页面', + 'assistant.step.bookLayouts': '正在浏览版式', + 'assistant.step.choosingPhotos': '正在挑选照片', + 'assistant.card.book.open': '在 Studio 中显示', + 'assistant.card.book.showPage': '显示此页', + 'assistant.card.book.cover': '封面', + 'assistant.card.book.first': '首页', + 'assistant.card.book.last': '末页', + 'assistant.card.book.back': '封底', + 'assistant.card.book.spread': '跨页 {page}', + 'assistant.card.book.spreadAny': '跨页', + 'assistant.card.book.newBook': '新相册书', + 'assistant.card.book.layoutAuto': '已根据其条目重新排版', + 'assistant.card.book.before': '修改前', + 'assistant.card.book.after': '修改后', + 'assistant.card.book.pagesAdded': '{count} 个新页面', + 'assistant.card.book.grid': '{count} 张照片的网格', + 'assistant.card.book.photosAdded': '+{count} 张照片', + 'assistant.card.book.findings': '{count} 项待检查', + 'assistant.card.book.finding.overlap': '元素相互重叠', + 'assistant.card.book.finding.fold': '有内容落在装订处', + 'assistant.card.book.finding.trim': '有内容超出边缘', + 'assistant.card.book.finding.empty_frame': '一个空的照片框', + 'assistant.card.book.finding.low_dpi': '照片打印可能模糊', + 'assistant.card.book.finding.focal_cut': '照片的焦点被裁掉', + 'assistant.card.book.finding.text_overflow': '文字超出了文本框', + 'assistant.card.book.finding.parked': '暂放的元素', + 'assistant.card.book.finding.hidden_photo': '其他贡献者的照片', + 'assistant.card.book.finding.not_in_gallery': '不在图库中的照片', + 'assistant.card.book.finding.text_on_busy': '文字压在照片的繁杂区域上', + 'assistant.card.book.finding.contrast_low': '文字难以阅读', + 'assistant.card.book.finding.small_text': '文字非常小', + 'assistant.card.book.finding.crowded': '页面过于拥挤', + 'assistant.card.book.finding.off_grid': '有元素略微没对齐', + 'assistant.card.book.finding.font_mix': '字体过多', + 'assistant.card.book.finding.palette_drift': '颜色不协调', + 'assistant.card.book.finding.repeat_layout': '反复使用同一版式', +}; +export default assistantBook;