@read-frog/api-contract 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +407 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/contracts/speech.ts +20 -0
- package/src/schemas/speech.ts +23 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cardStateSchema","scheduleStatusSchema"],"sources":["../src/schemas/app-locale.ts","../src/schemas/billing.ts","../src/schemas/hosted-ai.ts","../src/schemas/pdf-translation.ts","../src/public-errors.ts","../src/contracts/billing.ts","../src/contracts/shared.ts","../src/schemas/pagination.ts","../src/schemas/resource-mutation.ts","../src/schemas/card.ts","../src/contracts/card.ts","../src/contracts/card-template.ts","../src/schemas/ebook.ts","../src/contracts/ebook.ts","../src/schemas/email-preferences.ts","../src/contracts/email-preferences.ts","../src/schemas/feature-access.ts","../src/contracts/feature-access.ts","../src/contracts/hosted-ai.ts","../src/schemas/mastery-goal.ts","../src/contracts/mastery-goal.ts","../src/schemas/mcp-connection.ts","../src/contracts/mcp-connection.ts","../src/schemas/media.ts","../src/contracts/media.ts","../src/schemas/notebase-column.ts","../src/schemas/notebase-row.ts","../src/schemas/notebase-view.ts","../src/schemas/notebase.ts","../src/contracts/notebase.ts","../src/contracts/notebase-column.ts","../src/contracts/notebase-row.ts","../src/contracts/pdf-translation.ts","../src/schemas/speech.ts","../src/contracts/speech.ts","../src/schemas/timezone.ts","../src/schemas/srs.ts","../src/contracts/srs.ts","../src/schemas/notebase-stats.ts","../src/schemas/srs-stats.ts","../src/schemas/stats.ts","../src/contracts/stats.ts","../src/schemas/web-sync.ts","../src/contracts/telemetry.ts","../src/schemas/user.ts","../src/contracts/user.ts","../src/schemas/video-transcript.ts","../src/contracts/video-transcript.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * The languages the website is in (`project.inlang/settings.json`; a test in\n * apps/www keeps the two in step). Used wherever the server writes for a\n * person: Stripe pages, emails, and the account's `locale`.\n */\nexport const appLocaleSchema = z.enum([\"en\", \"es\", \"ja\", \"ko\", \"ru\", \"tr\", \"vi\", \"zh\", \"zh-TW\"]);\nexport type AppLocale = z.infer<typeof appLocaleSchema>;\n","import type { AppLocale } from \"./app-locale\";\nimport { z } from \"zod\";\nimport { checkoutAttributionInputSchema } from \"@read-frog/definitions\";\nimport { appLocaleSchema } from \"./app-locale\";\n\nexport const billingIntervalSchema = z.enum([\"month\", \"year\"]);\nexport type BillingInterval = z.infer<typeof billingIntervalSchema>;\n\nexport const billingSubscriptionStatusSchema = z.enum([\n \"incomplete\",\n \"incomplete_expired\",\n \"trialing\",\n \"active\",\n \"past_due\",\n \"canceled\",\n \"unpaid\",\n \"paused\",\n]);\nexport type BillingSubscriptionStatus = z.infer<typeof billingSubscriptionStatusSchema>;\n\nexport const billingPlanSchema = z.enum([\"free\", \"pro\", \"ultra\"]);\nexport type BillingPlan = z.infer<typeof billingPlanSchema>;\n\n/**\n * How many MCP tool calls each plan may make in a day (24 hours from the first\n * one); `null` is no limit. Each `tools/call` counts once, whatever the tool.\n *\n * Read by the MCP server's gate AND by the website's copy, so the pages cannot\n * promise calls the server refuses.\n *\n * Companion edit when this changes: the MCP docs under\n * `apps/www/content/docs/mcp/` and `account-and-plans`, which state the numbers.\n */\nexport const MCP_DAILY_CALL_LIMITS = {\n free: 10,\n pro: 50,\n ultra: null,\n} as const satisfies Record<BillingPlan, number | null>;\n\n/**\n * How many ebooks each plan may keep at once. Free keeps one, so it reads one\n * book at a time; deleting a book frees its place for the next.\n *\n * Read by the API's upload gate AND by the website's copy (the pricing page),\n * so the pages cannot promise books the server refuses.\n *\n * Companion edit when this changes: `account-and-plans` under\n * `apps/www/content/docs/`, which states the numbers.\n */\nexport const EBOOK_LIMIT_BY_PLAN = {\n free: 1,\n pro: 10,\n ultra: 80,\n} as const satisfies Record<BillingPlan, number>;\n\n// Plans a user can actively check out into (the free tier has no price).\nexport const billingCheckoutPlanSchema = z.enum([\"pro\", \"ultra\"]);\nexport type BillingCheckoutPlan = z.infer<typeof billingCheckoutPlanSchema>;\n\nexport const billingCurrencySchema = z.enum([\"usd\", \"cad\", \"cny\"]);\nexport type BillingCurrency = z.infer<typeof billingCurrencySchema>;\n\n// The billing name of `appLocaleSchema`, which it was before the account had a\n// locale of its own; kept so existing imports keep working.\nexport const billingLocaleSchema = appLocaleSchema;\nexport type BillingLocale = AppLocale;\n\nexport const billingAccessSourceSchema = z.enum([\"subscription\", \"pass\"]);\nexport type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>;\n\nexport const billingScheduledChangeSchema = z\n .object({\n plan: billingCheckoutPlanSchema,\n interval: billingIntervalSchema,\n effectiveAt: z.coerce.date(),\n })\n .strict();\nexport type BillingScheduledChange = z.infer<typeof billingScheduledChangeSchema>;\n\n/**\n * The zone a payment deadline is shown in, as a date with no time. UTC−12 is\n * the last zone to finish a day, and `dueBy` is the end of a day there, so the\n * date it shows stays open in every customer's zone until their own midnight.\n */\nexport const BILLING_PAYMENT_DUE_TIME_ZONE = \"Etc/GMT+12\";\n\n/**\n * A renewal whose payment failed. The plan stays until `dueBy`; paying the\n * invoice before then (or later, until the subscription is canceled) restores\n * the subscription as if the payment had gone through.\n */\nexport const billingPaymentDueSchema = z\n .object({\n /** The last instant of the plan; show it in BILLING_PAYMENT_DUE_TIME_ZONE. */\n dueBy: z.coerce.date(),\n /**\n * The plan the payment keeps. Not `BillingStatus.plan`: past `dueBy` that\n * already reads \"free\" while the invoice is still payable.\n */\n plan: billingCheckoutPlanSchema,\n /** The Stripe-hosted page that pays the invoice; null if Stripe gave none. */\n url: z.url().nullable(),\n })\n .strict();\nexport type BillingPaymentDue = z.infer<typeof billingPaymentDueSchema>;\n\nexport const billingStatusSchema = z\n .object({\n plan: billingPlanSchema,\n status: billingSubscriptionStatusSchema.nullable(),\n interval: billingIntervalSchema.nullable(),\n currentPeriodEnd: z.coerce.date().nullable(),\n /**\n * When the subscription terminates, or null if it renews. Replaces the\n * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the\n * Customer Portal no longer sets it, and the termination date is not always\n * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.\n */\n cancelAt: z.coerce.date().nullable(),\n accessSource: billingAccessSourceSchema.nullable(),\n scheduledChange: billingScheduledChangeSchema.nullable(),\n paymentDue: billingPaymentDueSchema.nullable(),\n unlimitedNotebaseNotes: z.boolean(),\n notebaseNoteLimit: z.number().int().positive(),\n notebaseNoteCount: z.number().int().min(0),\n })\n .strict();\nexport type BillingStatus = z.infer<typeof billingStatusSchema>;\n\nexport const billingCreateCheckoutSessionInputSchema = z\n .object({\n currency: billingCurrencySchema,\n interval: billingIntervalSchema,\n locale: appLocaleSchema,\n plan: billingCheckoutPlanSchema.default(\"pro\"),\n requestId: z.uuid().optional(),\n attribution: checkoutAttributionInputSchema.optional(),\n })\n .strict();\nexport type BillingCreateCheckoutSessionInput = z.infer<\n typeof billingCreateCheckoutSessionInputSchema\n>;\n\nexport const billingCreateCustomerPortalSessionInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type BillingCreateCustomerPortalSessionInput = z.infer<\n typeof billingCreateCustomerPortalSessionInputSchema\n>;\n\nexport const billingSessionUrlOutputSchema = z\n .object({\n url: z.url(),\n })\n .strict();\nexport type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>;\n\nexport const billingCancelScheduledChangeOutputSchema = z\n .object({\n success: z.literal(true),\n })\n .strict();\nexport type BillingCancelScheduledChangeOutput = z.infer<\n typeof billingCancelScheduledChangeOutputSchema\n>;\n","import { z } from \"zod\";\nimport { billingPlanSchema } from \"./billing\";\n\nexport const HostedAiOutputFieldTypeSchema = z.enum([\"string\", \"number\"]);\n\nexport const HostedAiOutputFieldSchema = z.strictObject({\n name: z.string().trim().min(1).max(80),\n type: HostedAiOutputFieldTypeSchema,\n});\n\nconst HostedAiInstructionsSchema = z.string().trim().min(1).max(16000);\n\n/**\n * Which hosted model a request runs on. Deliberately NOT named after a billing\n * plan: which plans may reach which tier is policy (see `access-policy.ts`),\n * not identity, so a future plan can be sold with any tier without a rename.\n */\nexport const HostedAiModelTierSchema = z.enum([\"normal\", \"advance\"]);\n/**\n * The billing/access subject of a hosted request, not a route id. Sub-calls\n * bill against the feature they serve: the page summary is `pageTranslation`,\n * and the video summary and subtitle segmentation are `videoSubtitles`.\n *\n * Appended last on purpose: the db pgEnum mirrors this order, and appending\n * keeps drizzle from emitting the ADD VALUE ... BEFORE variant.\n */\nexport const HostedAiFeatureSchema = z.enum([\n \"pageTranslation\",\n \"customAction\",\n \"noteSuggestion\",\n \"selectionTranslation\",\n \"videoSubtitles\",\n \"inputTranslation\",\n \"languageDetection\",\n // Charged by the PDF worker's proxy, not called by clients; `status`\n // leaves it out (see the router's HOSTED_AI_FEATURES).\n \"pdfTranslation\",\n]);\nexport const HostedAiRequestIdSchema = z.uuid();\n\nconst HostedAiRequestMetadataSchema = {\n /**\n * Optional on the wire, always present after parsing: these endpoints shipped\n * before tiers existed, so every installed extension below 1.46.0 sends no\n * `modelTier` at all, and the input objects are strict. Defaulting here keeps\n * those clients working while giving handlers a single source of truth\n * instead of a `?? \"normal\"` at every call site.\n *\n * TODO(2026-11-01): Drop the default and make this required once extensions\n * below 1.46.0 have drained from the store.\n */\n modelTier: HostedAiModelTierSchema.default(\"normal\"),\n requestId: HostedAiRequestIdSchema.optional(),\n};\n\nexport const HostedAiStreamTextInputSchema = z.strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n temperature: z.number().min(0).max(2).optional(),\n});\n\nexport const HostedAiStreamStructuredObjectInputSchema = z\n .strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n outputSchema: z.array(HostedAiOutputFieldSchema).min(1).max(32),\n temperature: z.number().min(0).max(2).optional(),\n })\n .superRefine((input, ctx) => {\n const fieldNames = new Set<string>();\n\n input.outputSchema.forEach((field, index) => {\n if (fieldNames.has(field.name)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate output schema name \"${field.name}\".`,\n path: [\"outputSchema\", index, \"name\"],\n });\n return;\n }\n\n fieldNames.add(field.name);\n });\n });\n\nexport const HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES = 2;\nexport const HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS = 16;\n\nexport const HostedAiNoteSuggestionStreamInputSchema = z.strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n temperature: z.number().min(0).max(2).optional(),\n});\n\n/**\n * Fixed structured-output schema for hosted note suggestions. Must stay\n * strict-structured-outputs-safe: strict objects only, no records, no\n * `.optional()` (nullable-only), unions limited to primitives. If the upstream\n * deployment rejects `maxItems`/`maxLength` constraint keywords, strip the\n * `.max()` calls from the model-facing copy only — clients still validate\n * against this schema.\n */\nexport const HostedAiNoteSuggestionObjectSchema = z.strictObject({\n action: z.strictObject({\n createNewDictionaryAction: z.boolean(),\n targetActionId: z.string().max(128).nullable(),\n /**\n * Name of the chosen schema's field whose value best works as a one-line\n * explanation of the term in UI (usually a definition/meaning field);\n * null when no field fits. Purely a display hint — clients sanitize it\n * and fall back to their own ordering when invalid.\n */\n summaryFieldName: z.string().max(80).nullable(),\n }),\n notes: z\n .array(\n z.strictObject({\n fields: z\n .array(\n z.strictObject({\n name: z.string().max(80),\n value: z.union([z.string(), z.number()]).nullable(),\n }),\n )\n .max(HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS),\n }),\n )\n .max(HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES),\n});\n\nexport const HostedAiStreamPartSchema = z.looseObject({\n type: z.string().trim().min(1),\n});\n\n/**\n * The only stream part types this API emits. Every other part the AI SDK\n * produces (`start-step`, `finish-step`, `text-start`, ...) carries upstream\n * metadata — provider model id, response headers, request body — and is dropped\n * server-side so it never reaches a client.\n *\n * The consumer switch lives in the extension's background stream reader. Adding\n * a type here without teaching that switch about it is a no-op; removing one\n * breaks rendering. `error` is absent on purpose: it is converted into a thrown\n * error before it can be yielded.\n */\nexport const HOSTED_AI_CLIENT_STREAM_PART_TYPES = [\n \"text-delta\",\n \"reasoning-start\",\n \"reasoning-delta\",\n \"reasoning-end\",\n \"reasoning-file\",\n \"finish\",\n] as const;\n\n/**\n * Status is per-identity, not per-feature: one call reports every feature and\n * every pool, so a client caches a single response instead of one per feature.\n * Non-strict so a client still sending the retired `feature` argument gets a\n * useful response rather than a validation error.\n */\nexport const HostedAiStatusInputSchema = z.object({});\n\n/**\n * `pro_required` means the Pro plan or any plan above it; `ultra_required`\n * means Ultra. Appended last, so a client that predates a value falls back on\n * its own default instead of misreading it.\n */\nexport const HostedAiUnavailableReasonSchema = z.enum([\n \"authentication_required\",\n \"ultra_required\",\n \"quota_exhausted\",\n \"service_unavailable\",\n \"pro_required\",\n]);\n\n/**\n * The cheapest plan an account would need to buy for something it cannot use\n * now. Any plan above it works too, so `pro` reads as \"Pro or Ultra\".\n */\nexport const HostedAiUpgradePlanSchema = billingPlanSchema.exclude([\"free\"]);\n\nexport const HostedAiCreditPolicyIdSchema = z.enum([\n \"custom-action-guest-daily-v1\",\n \"custom-action-user-daily-v1\",\n // Retired: Pro draws on a weekly pool now. Kept because the database still\n // holds pools under it.\n \"custom-action-pro-daily-v1\",\n \"ultra-weekly-v1\",\n // Retired: Pro's weekly pool in UTC calendar weeks. Kept for the same reason.\n \"pro-weekly-v1\",\n // Pro's weekly pool, in weeks that run from when the plan started, as Ultra's do.\n \"pro-weekly-v2\",\n]);\n\nexport const HostedAiCreditPeriodKindSchema = z.enum([\"daily\", \"weekly\"]);\n\nexport const HostedAiQuotaScopeSchema = z.enum([\"guest\", \"user\"]);\n\n/**\n * Data payload of the TOO_MANY_REQUESTS error every hosted AI guard emits.\n * The code itself is ORPC's own rather than a PUBLIC_APP_ERROR_DEFS entry, so\n * this schema is the only contract tying the server's construction to the\n * extension's parsing of it.\n *\n * Deliberately NOT strict: installed extensions parse this payload at runtime\n * and lag server deploys by weeks, so rejecting unknown keys would turn any\n * additive server-side field into a fleet-wide parse failure that silently\n * drops retryAfterMs (queue backoff timing) and quotaScope (guest sign-in\n * prompt). Unknown keys are stripped; the required fields keep drift\n * protection.\n */\nexport const HostedAiRateLimitErrorDataSchema = z.object({\n retryAfterMs: z.number().int().min(0),\n quotaScope: HostedAiQuotaScopeSchema,\n});\n\n/**\n * A recurring pool: the plan's credit for a day or a week, which refills at\n * `resetAt`.\n *\n * Deliberately free of dollar amounts and of the versioned policy id. Clients\n * render a consumption bar and a reset time, so a percentage and a period kind\n * are all they need, and neither leaks what a call costs us. `usedPercent`\n * counts settled spend only: including in-flight reservations would make the\n * bar jump forward and then back as each stream settles.\n */\nexport const HostedAiRecurringCreditStatusSchema = z.strictObject({\n periodKind: HostedAiCreditPeriodKindSchema,\n usedPercent: z.number().min(0).max(100),\n resetAt: z.iso.datetime().nullable(),\n /**\n * Every feature drawing on this pool. Ultra shares one weekly pool across all\n * three, so the grouping lives here rather than inlined per feature — that way\n * a client can tell one shared pool from several separate ones.\n */\n features: z.array(HostedAiFeatureSchema).min(1),\n});\n\n/**\n * A one-time pool, such as credit from a campaign or from support. It never\n * refills: once spent or past `expiresAt` it is gone, so a client shows the\n * expiry, not a reset. It is drawn on only after the plan's own pool for a\n * feature is spent, or for a feature the plan does not fund. Listed until it\n * expires, even when spent. Same fields as a recurring pool otherwise.\n */\nexport const HostedAiOneTimeCreditStatusSchema = z.strictObject({\n periodKind: z.literal(\"once\"),\n usedPercent: z.number().min(0).max(100),\n expiresAt: z.iso.datetime(),\n features: z.array(HostedAiFeatureSchema).min(1),\n});\n\n/**\n * One pool that can pay for Built-in AI, told apart by `periodKind`: a\n * recurring `daily` or `weekly` pool refills at `resetAt`, a one-time (`once`)\n * pool ends at `expiresAt`. Narrow on `periodKind` before reading either.\n */\nexport const HostedAiCreditPoolStatusSchema = z.discriminatedUnion(\"periodKind\", [\n HostedAiRecurringCreditStatusSchema,\n HostedAiOneTimeCreditStatusSchema,\n]);\n\n/** Feature-scoped credit display, separate from the legacy extension status shape. */\nexport const HostedAiCreditPoolsInputSchema = z.strictObject({ feature: HostedAiFeatureSchema });\nexport const HostedAiCreditPoolsOutputSchema = z.strictObject({\n pools: z.array(HostedAiCreditPoolStatusSchema),\n});\n\nexport const HostedAiTierStatusSchema = z.strictObject({\n accessAllowed: z.boolean(),\n available: z.boolean(),\n unavailableReason: HostedAiUnavailableReasonSchema.nullable(),\n /**\n * The cheapest plan this account would need to use the tier, or null when it\n * needs none: its plan or a one-time pool already covers it, or the tier is\n * open to every signed-in account. For a guest it is the plan needed after\n * signing in. Clients badge an option with it and offer that plan.\n */\n upgradeTo: HostedAiUpgradePlanSchema.nullable(),\n /**\n * @deprecated Read `upgradeTo`. Viewer-independent product fact: no\n * non-Ultra account can ever use this feature/tier. Extensions released\n * before `upgradeTo` badge options with it, including for Ultra accounts.\n *\n * TODO(2026-11-21): remove once those extensions have drained (#710).\n */\n requiresUltra: z.boolean(),\n modelRevision: z.string().trim().min(1),\n});\n\nexport const HostedAiFeatureStatusSchema = z.strictObject({\n normal: HostedAiTierStatusSchema,\n advance: HostedAiTierStatusSchema,\n});\n\nexport const HostedAiStatusOutputSchema = z.strictObject({\n /**\n * @deprecated Read `pools`. This lists the recurring pools only, never a\n * one-time one: extensions released before mengxi-ream/read-frog#2395 look\n * up a label for every entry's `periodKind`, and one they do not know\n * crashes their usage page. They also throw if the field is missing.\n *\n * TODO(2026-11-07): remove once those extensions have drained (#710).\n */\n credits: z.array(HostedAiRecurringCreditStatusSchema),\n /**\n * Everything that can pay for a feature, in the order the server draws on it:\n * the plan's recurring pools first, then one-time pools by soonest expiry. A\n * feature can appear in several entries.\n */\n pools: z.array(HostedAiCreditPoolStatusSchema),\n features: z.strictObject({\n pageTranslation: HostedAiFeatureStatusSchema,\n customAction: HostedAiFeatureStatusSchema,\n noteSuggestion: HostedAiFeatureStatusSchema,\n selectionTranslation: HostedAiFeatureStatusSchema,\n videoSubtitles: HostedAiFeatureStatusSchema,\n inputTranslation: HostedAiFeatureStatusSchema,\n languageDetection: HostedAiFeatureStatusSchema,\n }),\n});\n\nexport type HostedAiOutputFieldType = z.infer<typeof HostedAiOutputFieldTypeSchema>;\nexport type HostedAiOutputField = z.infer<typeof HostedAiOutputFieldSchema>;\nexport type HostedAiModelTier = z.infer<typeof HostedAiModelTierSchema>;\nexport type HostedAiFeature = z.infer<typeof HostedAiFeatureSchema>;\nexport type HostedAiStreamTextInput = z.infer<typeof HostedAiStreamTextInputSchema>;\nexport type HostedAiStreamStructuredObjectInput = z.infer<\n typeof HostedAiStreamStructuredObjectInputSchema\n>;\nexport type HostedAiNoteSuggestionStreamInput = z.infer<\n typeof HostedAiNoteSuggestionStreamInputSchema\n>;\nexport type HostedAiNoteSuggestionObject = z.infer<typeof HostedAiNoteSuggestionObjectSchema>;\nexport type HostedAiStreamPart = z.infer<typeof HostedAiStreamPartSchema>;\nexport type HostedAiStatusInput = z.infer<typeof HostedAiStatusInputSchema>;\nexport type HostedAiUnavailableReason = z.infer<typeof HostedAiUnavailableReasonSchema>;\nexport type HostedAiUpgradePlan = z.infer<typeof HostedAiUpgradePlanSchema>;\nexport type HostedAiCreditPolicyId = z.infer<typeof HostedAiCreditPolicyIdSchema>;\nexport type HostedAiCreditPeriodKind = z.infer<typeof HostedAiCreditPeriodKindSchema>;\nexport type HostedAiQuotaScope = z.infer<typeof HostedAiQuotaScopeSchema>;\nexport type HostedAiRateLimitErrorData = z.infer<typeof HostedAiRateLimitErrorDataSchema>;\nexport type HostedAiRecurringCreditStatus = z.infer<typeof HostedAiRecurringCreditStatusSchema>;\nexport type HostedAiOneTimeCreditStatus = z.infer<typeof HostedAiOneTimeCreditStatusSchema>;\nexport type HostedAiCreditPoolStatus = z.infer<typeof HostedAiCreditPoolStatusSchema>;\nexport type HostedAiTierStatus = z.infer<typeof HostedAiTierStatusSchema>;\nexport type HostedAiFeatureStatus = z.infer<typeof HostedAiFeatureStatusSchema>;\nexport type HostedAiStatusOutput = z.infer<typeof HostedAiStatusOutputSchema>;\n","import { PDF_TRANSLATION_MAX_BATCH_FILES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { HostedAiModelTierSchema } from \"./hosted-ai\";\n\nexport const pdfTranslationJobStatusSchema = z.enum([\n \"queued\",\n \"running\",\n \"cancel_requested\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n // Succeeded, but the translation is past its retention and gone.\n \"expired\",\n]);\nexport type PdfTranslationJobStatus = z.infer<typeof pdfTranslationJobStatusSchema>;\n\n/**\n * The two PDFs one translation makes: the translation alone, with the\n * original's layout, and the original and translated pages side by side.\n */\nexport const pdfTranslationOutputVariantSchema = z.enum([\"translated\", \"bilingual\"]);\nexport type PdfTranslationOutputVariant = z.infer<typeof pdfTranslationOutputVariantSchema>;\n\nconst languageSchema = z\n .string()\n .min(2)\n .max(40)\n .regex(/^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i);\n\nexport const pdfTranslationRequestUploadInputSchema = z\n .object({\n fileName: z\n .string()\n .trim()\n .min(1)\n .max(255)\n .refine((fileName) => fileName.toLowerCase().endsWith(\".pdf\"), {\n message: \"fileName must end with .pdf\",\n }),\n // The exact size: the upload is signed for it, and storage refuses any other file.\n fileByteSize: z.number().int().min(1),\n })\n .strict();\nexport type PdfTranslationRequestUploadInput = z.infer<\n typeof pdfTranslationRequestUploadInputSchema\n>;\n\nexport const pdfTranslationRequestUploadOutputSchema = z\n .object({\n uploadId: z.uuid(),\n // A PUT of the file to `url` with exactly these headers.\n upload: z\n .object({\n url: z.url(),\n headers: z.record(z.string(), z.string()),\n })\n .strict(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type PdfTranslationRequestUploadOutput = z.infer<\n typeof pdfTranslationRequestUploadOutputSchema\n>;\n\nexport const pdfTranslationSubmitInputSchema = z\n .object({\n // The PDFs to translate with the same settings, in the order they run.\n uploadIds: z\n .array(z.uuid())\n .min(1)\n .max(PDF_TRANSLATION_MAX_BATCH_FILES)\n .refine((ids) => new Set(ids).size === ids.length, {\n message: \"uploadIds must not repeat\",\n }),\n // A retry with the same key returns the jobs the first request made.\n idempotencyKey: z.string().trim().min(1).max(200),\n // Only the target: the model works out the PDF's own language from its text.\n targetLanguage: languageSchema,\n // Under the same rules as every Built-in AI feature: advance is Ultra's.\n modelTier: HostedAiModelTierSchema,\n })\n .strict();\nexport type PdfTranslationSubmitInput = z.infer<typeof pdfTranslationSubmitInputSchema>;\n\nexport const pdfTranslationJobIdInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type PdfTranslationJobIdInput = z.infer<typeof pdfTranslationJobIdInputSchema>;\n\nexport const pdfTranslationOutputInputSchema = z\n .object({\n id: z.uuid(),\n variant: pdfTranslationOutputVariantSchema,\n })\n .strict();\nexport type PdfTranslationOutputInput = z.infer<typeof pdfTranslationOutputInputSchema>;\n\nexport const pdfTranslationListInputSchema = z.object({}).strict();\nexport type PdfTranslationListInput = z.infer<typeof pdfTranslationListInputSchema>;\n\nexport const pdfTranslationJobResourceSchema = z\n .object({\n id: z.uuid(),\n status: pdfTranslationJobStatusSchema,\n sourceFileName: z.string(),\n targetLanguage: z.string(),\n modelTier: HostedAiModelTierSchema,\n // The PDFs submitted together, which run one at a time in this order.\n batchId: z.uuid(),\n batchPosition: z.number().int().min(0),\n // How many of the account's translations run before a queued one: null\n // once it has started, or when it never will.\n waitingAhead: z.number().int().min(0).nullable(),\n // A Free account's one translation, which it can read here but not download.\n freeTrial: z.boolean(),\n // Which PDFs a succeeded job has. A job translated before both were made\n // has only the one it asked for; any other job has neither.\n outputs: z\n .object({\n translated: z.boolean(),\n bilingual: z.boolean(),\n })\n .strict(),\n pageCount: z.number().int().min(1),\n progressStage: z.string().nullable(),\n progressPercent: z.number().min(0).max(100),\n // Built-in AI credit, in billionths of a US dollar: what admission\n // expected, and what the model calls have used so far.\n estimatedCostNanoUsd: z.number().int().min(0),\n chargedCostNanoUsd: z.number().int().min(0),\n error: z\n .object({\n category: z.string(),\n message: z.string(),\n })\n .strict()\n .nullable(),\n // The worker version that last ran the job, for support.\n workerRelease: z.string().nullable(),\n createdAt: z.coerce.date(),\n startedAt: z.coerce.date().nullable(),\n completedAt: z.coerce.date().nullable(),\n // When a succeeded job's translation stops being downloadable.\n outputExpiresAt: z.coerce.date().nullable(),\n })\n .strict();\nexport type PdfTranslationJobResource = z.infer<typeof pdfTranslationJobResourceSchema>;\n\nexport const pdfTranslationListOutputSchema = z\n .object({\n items: z.array(pdfTranslationJobResourceSchema),\n })\n .strict();\nexport type PdfTranslationListOutput = z.infer<typeof pdfTranslationListOutputSchema>;\n\n/** What a submission made: its batch, and one job per PDF in their order. */\nexport const pdfTranslationSubmitOutputSchema = z\n .object({\n batchId: z.uuid(),\n jobs: z.array(pdfTranslationJobResourceSchema).min(1),\n })\n .strict();\nexport type PdfTranslationSubmitOutput = z.infer<typeof pdfTranslationSubmitOutputSchema>;\n\n/** A job, and every job of its batch in their order (itself included). */\nexport const pdfTranslationGetOutputSchema = z\n .object({\n job: pdfTranslationJobResourceSchema,\n batch: z.array(pdfTranslationJobResourceSchema).min(1),\n })\n .strict();\nexport type PdfTranslationGetOutput = z.infer<typeof pdfTranslationGetOutputSchema>;\n\nexport const pdfTranslationStatusInputSchema = z.object({}).strict();\nexport type PdfTranslationStatusInput = z.infer<typeof pdfTranslationStatusInputSchema>;\n\nexport const pdfTranslationStatusOutputSchema = z\n .object({\n // An account nothing funds translates one PDF, once, on the normal tier:\n // 1 until it has, and always 0 for a funded account.\n freeTrialsRemaining: z.number().int().min(0),\n /**\n * Whether Built-in AI credit pays for PDF translation on the normal tier:\n * a paid plan, or credit the account was given for every feature. Only a\n * funded account submits more than one PDF or downloads a translation.\n */\n funded: z.boolean(),\n })\n .strict();\nexport type PdfTranslationStatusOutput = z.infer<typeof pdfTranslationStatusOutputSchema>;\n\nexport const pdfTranslationDownloadOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type PdfTranslationDownloadOutput = z.infer<typeof pdfTranslationDownloadOutputSchema>;\n\nexport const pdfTranslationPreviewOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n /**\n * Whether the URL opens the free translation's copy with the Read Frog\n * watermark, which an account nothing funds reads: upgrading opens the\n * PDF itself.\n */\n watermarked: z.boolean(),\n })\n .strict();\nexport type PdfTranslationPreviewOutput = z.infer<typeof pdfTranslationPreviewOutputSchema>;\n\nexport const pdfTranslationDeleteOutputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type PdfTranslationDeleteOutput = z.infer<typeof pdfTranslationDeleteOutputSchema>;\n\nexport const PdfTranslationInsufficientCreditDataSchema = z.strictObject({\n estimatedCostNanoUsd: z.number().int().min(0),\n remainingNanoUsd: z.number().int().min(0),\n resetAt: z.iso.datetime().nullable(),\n});\nexport type PdfTranslationInsufficientCreditData = z.infer<\n typeof PdfTranslationInsufficientCreditDataSchema\n>;\n\n/**\n * Which of a submission's PDFs a refusal is about, so the page can point at\n * it. For an upload an earlier request used up, also the translation it made.\n */\nexport const PdfTranslationUploadErrorDataSchema = z.strictObject({\n uploadId: z.uuid(),\n jobId: z.uuid().optional(),\n});\nexport type PdfTranslationUploadErrorData = z.infer<typeof PdfTranslationUploadErrorDataSchema>;\n","import type { ErrorMap } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport {\n HostedAiCreditPolicyIdSchema,\n HostedAiModelTierSchema,\n HostedAiUpgradePlanSchema,\n} from \"./schemas/hosted-ai\";\nimport {\n PdfTranslationInsufficientCreditDataSchema,\n PdfTranslationUploadErrorDataSchema,\n} from \"./schemas/pdf-translation\";\n\ninterface PublicAppErrorDefinition {\n data?: z.ZodTypeAny;\n message: string;\n status: number;\n}\n\nexport const CellValidationFailureReasonSchema = z.enum([\n \"unknown_notebase_column\",\n \"type_mismatch\",\n \"invalid_select_option\",\n \"invalid_date_format\",\n // A cloze deletion with a blank answer; receivedValue is the deletion as\n // written (`{{c1::}}`).\n \"empty_cloze_answer\",\n // A cloze opening that never closes (unpaired braces, or no `}}`);\n // receivedValue is the opening as written (`{{c1::`).\n \"unclosed_cloze\",\n // A cloze deletion whose ordinal list names no group (`{{c0::a}}`);\n // receivedValue is the deletion as written.\n \"invalid_cloze_ordinal\",\n // A cloze deletion that cuts across a formula's delimiters (`\\(a{{c1::b\\) c}}`);\n // receivedValue is the deletion as written.\n \"cloze_crosses_math\",\n // A cloze deletion in a formula that holds half of a `\\left`/`\\right` or\n // `\\begin`/`\\end` pair; receivedValue is the deletion as written.\n \"cloze_splits_math_pair\",\n // More cloze groups in one note than CLOZE_MAX_GROUPS; receivedValue is\n // the note's group count.\n \"too_many_cloze_groups\",\n]);\nexport type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>;\n\nexport const CellValidationFailureDetailsSchema = z\n .object({\n expectedFormat: z.string().optional(),\n expectedType: z.string().optional(),\n receivedType: z.string().optional(),\n receivedValue: z.unknown().optional(),\n validOptions: z.array(z.string()).optional(),\n })\n .strict();\nexport type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>;\n\nexport const CellValidationFailedDataSchema = z\n .object({\n notebaseColumnId: z.string(),\n details: CellValidationFailureDetailsSchema,\n reason: CellValidationFailureReasonSchema,\n /** Index of the failing row within a batch input (createMany / updateMany / initialRows). */\n rowIndex: z.number().int().min(0).optional(),\n /** The failing note, when the check ran over stored notes (a column type change). */\n notebaseRowId: z.string().optional(),\n })\n .strict();\nexport type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>;\n\nexport const CardTemplateInvalidColumnsDataSchema = z\n .object({\n notebaseColumnIds: z.array(z.string()),\n })\n .strict();\nexport type CardTemplateInvalidColumnsData = z.infer<typeof CardTemplateInvalidColumnsDataSchema>;\n\nexport const CardTemplateInvalidLayoutDataSchema = z\n .object({\n errors: z.array(\n z\n .object({\n side: z.enum([\"front\", \"back\"]),\n message: z.string(),\n // UTF-16 offsets into that face's layout, when the parser knows them.\n from: z.number().int().min(0).optional(),\n to: z.number().int().min(0).optional(),\n })\n .strict(),\n ),\n })\n .strict();\nexport type CardTemplateInvalidLayoutData = z.infer<typeof CardTemplateInvalidLayoutDataSchema>;\n\n// The templates that use the column, which keep it from being deleted.\nexport const CardTemplateNotebaseColumnInUseDataSchema = z\n .object({\n templates: z.array(z.object({ id: z.uuid(), name: z.string() }).strict()),\n })\n .strict();\nexport type CardTemplateNotebaseColumnInUseData = z.infer<\n typeof CardTemplateNotebaseColumnInUseDataSchema\n>;\n\nexport const HostedAiTierRestrictedDataSchema = z.strictObject({\n modelTier: HostedAiModelTierSchema,\n /** The cheapest plan that unlocks it; a client offers \"Pro or Ultra\" for `pro`. */\n upgradeTo: HostedAiUpgradePlanSchema,\n});\n\nexport const HostedAiQuotaExhaustedDataSchema = z.strictObject({\n modelTier: HostedAiModelTierSchema,\n // Reuses the credit-status enum rather than restating it: these two always\n // describe the same set of policy ids, and a second copy silently drifts —\n // the error payload is `strictObject`, so a policy missing only here fails\n // output validation at exactly the moment a user runs out of credit.\n policyId: HostedAiCreditPolicyIdSchema,\n usedPercent: z.number().min(0).max(100),\n resetAt: z.iso.datetime().nullable(),\n});\n\nexport const SpeechDailyLimitReachedDataSchema = z.strictObject({\n limit: z.number().int().min(0),\n resetAt: z.iso.datetime(),\n});\n\nexport const PUBLIC_APP_ERROR_DEFS = {\n CARD_DELETE_UNSUPPORTED: {\n message: \"This card cannot be deleted independently of its note.\",\n status: 400,\n },\n RESOURCE_UPDATE_CONFLICT: {\n message: \"The resource changed. Read it again before updating.\",\n status: 409,\n },\n RESOURCE_ALREADY_EXISTS: { message: \"A resource with this ID already exists.\", status: 409 },\n FIELD_TYPE_CHANGE_UNSUPPORTED: {\n message: \"This operation cannot change the field type.\",\n status: 400,\n },\n HOSTED_AI_TIER_RESTRICTED: {\n data: HostedAiTierRestrictedDataSchema,\n message: \"This Built-in AI tier is not available for this account\",\n status: 403,\n },\n HOSTED_AI_QUOTA_EXHAUSTED: {\n data: HostedAiQuotaExhaustedDataSchema,\n message: \"Built-in AI credit exhausted\",\n status: 429,\n },\n NOTEBASE_NOT_FOUND: {\n message: \"Notebase not found\",\n status: 404,\n },\n VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED: {\n message: \"AI subtitles require a Pro or Ultra subscription\",\n status: 403,\n },\n // Dunning (`past_due` / `paused`), not cancellation: the account keeps\n // reading subtitles it already paid to generate, but cannot start new work\n // that spends upstream money until the payment method is fixed. Distinct\n // from SUBSCRIPTION_REQUIRED so the client can say \"update your card\"\n // instead of \"subscribe\".\n VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED: {\n message: \"Update your payment method to generate new AI subtitles\",\n status: 402,\n },\n VIDEO_TRANSCRIPT_NOT_FOUND: {\n message: \"Video transcript not found\",\n status: 404,\n },\n VIDEO_TRANSCRIPT_NOT_READY: {\n message: \"Video transcript is not ready yet\",\n status: 409,\n },\n VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED: {\n message: \"Monthly transcription quota exceeded\",\n status: 429,\n },\n // A property of the video, not of the account: upgrading or waiting for the\n // quota to reset changes nothing. Kept apart from QUOTA_EXCEEDED so the\n // client does not answer it with an upgrade wall.\n VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH: {\n message: \"This video is longer than AI subtitles support\",\n status: 422,\n },\n // The day's read-aloud requests are used up (`SPEECH_DAILY_REQUEST_LIMITS`).\n SPEECH_DAILY_LIMIT_REACHED: {\n data: SpeechDailyLimitReachedDataSchema,\n message: \"Today's read-aloud limit is reached\",\n status: 429,\n },\n // No voice service to read with right now: not configured, or failing.\n SPEECH_UNAVAILABLE: {\n message: \"Reading aloud is unavailable right now\",\n status: 503,\n },\n NOTEBASE_COLUMN_NOT_FOUND: {\n message: \"Notebase column not found\",\n status: 404,\n },\n NOTEBASE_ROW_NOT_FOUND: {\n message: \"Notebase row not found\",\n status: 404,\n },\n CARD_NOT_FOUND: {\n message: \"Card not found\",\n status: 404,\n },\n CARD_TEMPLATE_NOT_FOUND: {\n message: \"Card template not found\",\n status: 404,\n },\n CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS: {\n data: CardTemplateInvalidColumnsDataSchema,\n message: \"Card template references unknown notebase columns\",\n status: 422,\n },\n CARD_TEMPLATE_INVALID_LAYOUT: {\n data: CardTemplateInvalidLayoutDataSchema,\n message: \"Card template layout does not parse\",\n status: 422,\n },\n CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE: {\n data: CardTemplateNotebaseColumnInUseDataSchema,\n message: \"Notebase column is used by a card template\",\n status: 409,\n },\n NOTE_LIMIT_EXCEEDED: {\n message: \"Upgrade is required to create more Notebase notes\",\n status: 403,\n },\n BILLING_NOT_CONFIGURED: {\n message: \"Billing is not configured\",\n status: 503,\n },\n BILLING_CUSTOMER_NOT_FOUND: {\n message: \"Billing customer not found\",\n status: 404,\n },\n BILLING_PASS_ACTIVE: {\n message: \"An active Pro pass already covers this account\",\n status: 409,\n },\n BILLING_CHANGE_SCHEDULED: {\n message: \"A subscription change is already scheduled\",\n status: 409,\n },\n BILLING_CHECKOUT_CONFLICT: {\n message: \"Please start a new checkout from the pricing page\",\n status: 409,\n },\n CARD_NOT_REVIEWABLE: {\n message: \"Card cannot be reviewed in its current state\",\n status: 409,\n },\n CARD_REVIEW_STATE_STALE: {\n message: \"Card review state is stale\",\n status: 409,\n },\n CARD_REVIEW_ROLLBACK_UNAVAILABLE: {\n message: \"Card review cannot be rolled back\",\n status: 409,\n },\n CARD_ALREADY_BURIED: {\n message: \"Card is already buried\",\n status: 409,\n },\n CARD_NOT_BURIED: {\n message: \"Card is not buried\",\n status: 409,\n },\n CARD_ALREADY_SUSPENDED: {\n message: \"Card is already suspended\",\n status: 409,\n },\n CARD_NOT_SUSPENDED: {\n message: \"Card is not suspended\",\n status: 409,\n },\n CARD_STATUS_CHANGE_UNAVAILABLE: {\n message: \"Card status change is unavailable\",\n status: 409,\n },\n RESCHEDULE_PLAN_EXPIRED: {\n message: \"The reschedule plan has expired; preview it again\",\n status: 409,\n },\n RESCHEDULE_STALE: {\n message: \"Cards changed after the reschedule preview; preview it again\",\n status: 409,\n },\n RESCHEDULE_PREVIEW_TIMEOUT: {\n message: \"Planning the reschedule took too long\",\n status: 503,\n },\n RESCHEDULE_DAILY_LIMIT_INVALID: {\n message: \"The daily limit is outside the range a reschedule may suggest\",\n status: 422,\n },\n NOTEBASE_VIEW_NOT_FOUND: {\n message: \"Notebase view not found\",\n status: 404,\n },\n CELL_VALIDATION_FAILED: {\n data: CellValidationFailedDataSchema,\n message: \"Cell validation failed\",\n status: 422,\n },\n PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED: {\n message: \"Cannot delete primary notebase column\",\n status: 400,\n },\n CONCURRENT_POSITION_CONFLICT: {\n message: \"Concurrent position conflict, please retry\",\n status: 409,\n },\n EBOOK_NOT_FOUND: {\n message: \"Ebook not found\",\n status: 404,\n },\n EBOOK_LIMIT_EXCEEDED: {\n message: \"Upgrade is required to upload more ebooks\",\n status: 403,\n },\n EBOOK_FILE_TOO_LARGE: {\n message: \"Ebook file exceeds the maximum allowed size\",\n status: 413,\n },\n EBOOK_UPLOAD_NOT_COMPLETED: {\n message: \"Ebook upload has not been completed\",\n status: 409,\n },\n MEDIA_BETA_RESTRICTED: {\n message: \"Media uploads are currently in beta for selected accounts\",\n status: 403,\n },\n MEDIA_NOT_FOUND: {\n message: \"Media file not found\",\n status: 404,\n },\n MEDIA_FILE_TOO_LARGE: {\n message: \"Media file exceeds the maximum allowed size\",\n status: 413,\n },\n MEDIA_QUOTA_EXCEEDED: {\n message: \"Not enough media storage space left on your plan\",\n status: 403,\n },\n MEDIA_UPLOAD_NOT_COMPLETED: {\n message: \"Media upload has not been completed\",\n status: 409,\n },\n // An email's unsubscribe or preferences link that does not verify, or whose\n // account no longer exists. The page asks the reader to sign in instead.\n EMAIL_LINK_INVALID: {\n message: \"This email link is not valid\",\n status: 400,\n },\n // The deployment has no worker to run translations (no Batch job\n // definition or PDF bucket configured).\n PDF_TRANSLATION_UNAVAILABLE: {\n message: \"PDF translation is not available right now\",\n status: 503,\n },\n PDF_TRANSLATION_NOT_FOUND: {\n message: \"PDF translation not found\",\n status: 404,\n },\n PDF_TRANSLATION_UPLOAD_NOT_FOUND: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"PDF upload not found\",\n status: 404,\n },\n PDF_TRANSLATION_UPLOAD_EXPIRED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF upload has expired; upload the file again\",\n status: 410,\n },\n PDF_TRANSLATION_UPLOAD_NOT_COMPLETED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF upload has not been completed\",\n status: 409,\n },\n PDF_TRANSLATION_FILE_TOO_LARGE: {\n message: \"The PDF exceeds the maximum allowed size\",\n status: 413,\n },\n PDF_TRANSLATION_INVALID_PDF: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The file is not a readable PDF\",\n status: 422,\n },\n // Every PDF a translation delivers is marked as one, and none is translated\n // again.\n PDF_TRANSLATION_ALREADY_TRANSLATED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"This PDF is already a translation; upload the original instead\",\n status: 422,\n },\n PDF_TRANSLATION_PAGE_LIMIT_EXCEEDED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF has more pages than one translation allows\",\n status: 422,\n },\n // An account's unfinished translations run one at a time, and no more than\n // PDF_TRANSLATION_MAX_BATCH_FILES of them wait at once.\n PDF_TRANSLATION_QUEUE_FULL: {\n message: \"Too many PDF translations are waiting; try again when some have finished\",\n status: 409,\n },\n PDF_TRANSLATION_IDEMPOTENCY_CONFLICT: {\n message: \"This idempotency key was already used for a different PDF translation\",\n status: 409,\n },\n // The estimate is over what is left of the Built-in AI credit window.\n // Running out midway stops the job instead (its error category is\n // quota_exhausted).\n PDF_TRANSLATION_INSUFFICIENT_CREDIT: {\n data: PdfTranslationInsufficientCreditDataSchema,\n message: \"Not enough Built-in AI credit left to translate this PDF\",\n status: 429,\n },\n PDF_TRANSLATION_NOT_CANCELLABLE: {\n message: \"This PDF translation has already finished\",\n status: 409,\n },\n PDF_TRANSLATION_NOT_READY: {\n message: \"The translated PDF is not available\",\n status: 409,\n },\n // A Free account reads its one translation online; downloading it, as any\n // translated PDF, needs a paid plan.\n PDF_TRANSLATION_DOWNLOAD_RESTRICTED: {\n message: \"Downloading a translated PDF needs a Pro or Ultra plan\",\n status: 403,\n },\n PDF_TRANSLATION_NOT_DELETABLE: {\n message: \"Cancel this PDF translation before deleting it\",\n status: 409,\n },\n} as const satisfies Record<string, PublicAppErrorDefinition>;\n\nexport type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS;\n\nexport type PublicAppErrorData<TCode extends PublicAppErrorCode> =\n (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }\n ? z.output<TSchema>\n : undefined;\n\nexport function isPublicAppErrorCode(code: string | undefined): code is PublicAppErrorCode {\n return code !== undefined && code in PUBLIC_APP_ERROR_DEFS;\n}\n\nexport function getPublicErrorDefinition<TCode extends PublicAppErrorCode>(code: TCode) {\n return PUBLIC_APP_ERROR_DEFS[code];\n}\n\nexport function pickPublicErrorMap<const TCodes extends readonly PublicAppErrorCode[]>(\n ...codes: TCodes\n) {\n return Object.fromEntries(\n codes.map((code) => {\n const definition = PUBLIC_APP_ERROR_DEFS[code];\n\n if (\"data\" in definition) {\n return [\n code,\n {\n data: definition.data,\n message: definition.message,\n status: definition.status,\n },\n ];\n }\n\n return [\n code,\n {\n message: definition.message,\n status: definition.status,\n },\n ];\n }),\n ) as Pick<ErrorMap, TCodes[number]>;\n}\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n billingCancelScheduledChangeOutputSchema,\n billingCreateCheckoutSessionInputSchema,\n billingCreateCustomerPortalSessionInputSchema,\n billingSessionUrlOutputSchema,\n billingStatusSchema,\n} from \"#/schemas/billing\";\n\nconst billingProcedure = oc.errors(\n pickPublicErrorMap(\n \"BILLING_NOT_CONFIGURED\",\n \"BILLING_CUSTOMER_NOT_FOUND\",\n \"BILLING_PASS_ACTIVE\",\n \"BILLING_CHANGE_SCHEDULED\",\n \"BILLING_CHECKOUT_CONFLICT\",\n ),\n);\n\nexport const billingContract = {\n status: billingProcedure\n .route({\n method: \"GET\",\n path: \"/billing/status\",\n summary: \"Get authenticated user's billing status\",\n tags: [\"Billing\"],\n })\n .output(billingStatusSchema),\n createCheckoutSession: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/checkout-sessions\",\n summary: \"Create a localized Stripe Checkout Session for a subscription\",\n tags: [\"Billing\"],\n })\n .input(billingCreateCheckoutSessionInputSchema)\n .output(billingSessionUrlOutputSchema),\n createCustomerPortalSession: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/customer-portal-sessions\",\n summary: \"Create a Stripe Customer Portal Session\",\n tags: [\"Billing\"],\n })\n .input(billingCreateCustomerPortalSessionInputSchema)\n .output(billingSessionUrlOutputSchema),\n cancelScheduledChange: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/scheduled-change/cancel\",\n summary: \"Cancel a scheduled subscription change\",\n tags: [\"Billing\"],\n })\n .output(billingCancelScheduledChangeOutputSchema),\n};\n","import type { Route } from \"@orpc/contract\";\nimport { oc } from \"@orpc/contract\";\n\n/**\n * A documented business route shared by OpenAPI and agent-facing adapters.\n * Both prose fields are required so adapters can reuse them without a second\n * copy or an undefined fallback.\n */\nexport type AgentRoute = Route & { summary: string; description: string };\n\n/**\n * Declares a procedure that is exposed to agents as an MCP tool, not only to\n * the REST/OpenAPI surface.\n *\n * oRPC types `~orpc.route` as the widened `Route`, so `route.summary` reads back\n * as `string | undefined` whatever is passed in. `$meta` is the only channel it\n * keeps generic, so the prose is mirrored there and stays a required `string`\n * for tool definitions. OpenAPI keeps reading `route`.\n */\nexport function defineAgentProcedure(route: AgentRoute) {\n return oc.$meta({ summary: route.summary, description: route.description }).route(route);\n}\n","import { z } from \"zod\";\nexport const paginationShape = {\n // Existing callers omit pagination to read all matching records.\n limit: z.number().int().min(1).max(500).optional(),\n offset: z.number().int().min(0).optional(),\n};\nexport function pageSchema<T extends z.ZodType>(itemSchema: T) {\n return z.object({ items: z.array(itemSchema), hasMore: z.boolean() });\n}\n","import { z } from \"zod\";\nexport const expectedUpdatedAtSchema = z.iso.datetime({ offset: true });\nexport const deletionResultSchema = z.object({\n id: z.uuid(),\n txid: z.number(),\n});\n","import { paginationShape, pageSchema } from \"./pagination\";\nimport { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n cardIdentityShape,\n cardMemoryStateShape,\n cardStateSchema,\n cardTemplateConfigSchema,\n cardTemplateCreatedBySchema,\n scheduleStatusSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport { cardStateSchema, scheduleStatusSchema };\nexport type { CardState, ScheduleStatus } from \"@read-frog/definitions\";\n\nexport const cardTemplateSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n name: z.string(),\n config: cardTemplateConfigSchema,\n createdBy: cardTemplateCreatedBySchema.describe(\n 'Who made the template: \"user\", or \"system\" for the default template Read Frog gives a notebase whose fields fit one.',\n ),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type CardTemplate = z.infer<typeof cardTemplateSchema>;\n\nexport const CardTemplateListInputSchema = z.object({\n ...paginationShape,\n notebaseId: z.uuid().optional(),\n});\nexport type CardTemplateListInput = z.infer<typeof CardTemplateListInputSchema>;\n\nexport const CardTemplateListOutputSchema = pageSchema(cardTemplateSchema);\nexport type CardTemplateListOutput = z.infer<typeof CardTemplateListOutputSchema>;\n\nexport const CardTemplateGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardTemplateGetInput = z.infer<typeof CardTemplateGetInputSchema>;\n\nexport const CardTemplateGetOutputSchema = cardTemplateSchema;\nexport type CardTemplateGetOutput = z.infer<typeof CardTemplateGetOutputSchema>;\n\nexport const CardTemplateCreateInputSchema = z\n .object({\n id: z.uuid().optional(),\n notebaseId: z.uuid(),\n name: z.string().min(1),\n config: cardTemplateConfigSchema,\n })\n .strict();\nexport type CardTemplateCreateInput = z.infer<typeof CardTemplateCreateInputSchema>;\n\nexport const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({\n txid: z.number(),\n});\nexport type CardTemplateCreateOutput = z.infer<typeof CardTemplateCreateOutputSchema>;\n\nexport const CardTemplateUpdateInputSchema = z\n .object({\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n id: z.uuid(),\n name: z.string().min(1).optional(),\n config: cardTemplateConfigSchema.optional(),\n })\n .strict();\nexport type CardTemplateUpdateInput = z.infer<typeof CardTemplateUpdateInputSchema>;\n\nexport const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({\n txid: z.number(),\n});\nexport type CardTemplateUpdateOutput = z.infer<typeof CardTemplateUpdateOutputSchema>;\n\nexport const CardTemplateDeleteInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardTemplateDeleteInput = z.infer<typeof CardTemplateDeleteInputSchema>;\n\nexport const CardTemplateDeleteOutputSchema = deletionResultSchema;\nexport type CardTemplateDeleteOutput = z.infer<typeof CardTemplateDeleteOutputSchema>;\n\nexport const cardSchema = z.object({\n ...cardIdentityShape,\n ...cardMemoryStateShape,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type Card = z.infer<typeof cardSchema>;\n\nexport const renderedCardSchema = cardSchema.extend({\n front: z.string(),\n back: z.string(),\n});\nexport type RenderedCard = z.infer<typeof renderedCardSchema>;\n\nexport const CardListInputSchema = z.object({\n notebaseId: z.uuid().optional(),\n templateId: z.uuid().optional(),\n scheduleStatus: scheduleStatusSchema.optional(),\n ...paginationShape,\n});\nexport type CardListInput = z.infer<typeof CardListInputSchema>;\n\nexport const CardListOutputSchema = pageSchema(renderedCardSchema);\nexport type CardListOutput = z.infer<typeof CardListOutputSchema>;\n\nexport const CardGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardGetInput = z.infer<typeof CardGetInputSchema>;\n\nexport const CardGetOutputSchema = renderedCardSchema;\nexport type CardGetOutput = z.infer<typeof CardGetOutputSchema>;\n\nexport const CardDeleteInputSchema = z.strictObject({\n id: z.uuid(),\n expectedVariantKey: z.string().min(1),\n expectedRowUpdatedAt: expectedUpdatedAtSchema,\n});\nexport type CardDeleteInput = z.infer<typeof CardDeleteInputSchema>;\n\nexport const CardDeleteOutputSchema = z.object({ txid: z.number() });\nexport type CardDeleteOutput = z.infer<typeof CardDeleteOutputSchema>;\n\nexport const CardGenerateInputSchema = z.object({\n notebaseId: z.uuid(),\n templateId: z.uuid().optional(),\n});\nexport type CardGenerateInput = z.infer<typeof CardGenerateInputSchema>;\n\nexport const CardGenerateOutputSchema = z.object({\n created: z.number().int().min(0),\n txid: z.number(),\n});\nexport type CardGenerateOutput = z.infer<typeof CardGenerateOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n CardDeleteInputSchema,\n CardDeleteOutputSchema,\n CardGenerateInputSchema,\n CardGenerateOutputSchema,\n CardGetInputSchema,\n CardGetOutputSchema,\n CardListInputSchema,\n CardListOutputSchema,\n} from \"#/schemas/card\";\n\nexport const cardContract = {\n delete: oc\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"NOTEBASE_NOT_FOUND\",\n \"CARD_DELETE_UNSUPPORTED\",\n \"RESOURCE_UPDATE_CONFLICT\",\n \"CELL_VALIDATION_FAILED\",\n ),\n )\n .route({ method: \"DELETE\", path: \"/cards/{id}\", summary: \"Delete card\", tags: [\"Cards\"] })\n .input(CardDeleteInputSchema)\n .output(CardDeleteOutputSchema),\n\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/cards\",\n summary: \"List cards\",\n description:\n \"Browse owned cards with rendered fronts, backs, source IDs and learning state. Optionally filter by notebase, template or scheduleStatus. Supports limit and offset pagination.\",\n tags: [\"Cards\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(CardListInputSchema)\n .output(CardListOutputSchema),\n\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/cards/{id}\",\n summary: \"Get card\",\n description:\n \"Read one owned card with its rendered front, back, source IDs and learning state.\",\n tags: [\"Cards\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\"))\n .input(CardGetInputSchema)\n .output(CardGetOutputSchema),\n\n generate: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CARD_TEMPLATE_NOT_FOUND\"))\n .route({\n method: \"POST\",\n path: \"/cards/generate\",\n summary: \"Generate missing cards\",\n tags: [\"Cards\"],\n })\n .input(CardGenerateInputSchema)\n .output(CardGenerateOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n CardTemplateCreateInputSchema,\n CardTemplateCreateOutputSchema,\n CardTemplateDeleteInputSchema,\n CardTemplateDeleteOutputSchema,\n CardTemplateGetInputSchema,\n CardTemplateGetOutputSchema,\n CardTemplateListInputSchema,\n CardTemplateListOutputSchema,\n CardTemplateUpdateInputSchema,\n CardTemplateUpdateOutputSchema,\n} from \"#/schemas/card\";\n\nexport const cardTemplateContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/card-templates\",\n summary: \"List card templates\",\n description:\n \"List owned card templates, optionally filtered by notebase. Supports limit and offset pagination.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(CardTemplateListInputSchema)\n .output(CardTemplateListOutputSchema),\n\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/card-templates/{id}\",\n summary: \"Get card template\",\n description: \"Read the complete definition and updatedAt timestamp of an owned card template.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"CARD_TEMPLATE_NOT_FOUND\"))\n .input(CardTemplateGetInputSchema)\n .output(CardTemplateGetOutputSchema),\n\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/card-templates\",\n summary: \"Create card template\",\n description:\n 'Create a template in an owned notebase; it generates a card for every existing note. Each face (front, back) is either { columns: [column IDs], style }, those columns in a built-in style that stays editable in the website\\'s simple mode, or { layout: \"<HTML + Liquid>\" } for a custom design that references a column as {{ [\"<column id>\"] }}. Prefer columns faces. Get column IDs from the notebase schema.',\n tags: [\"Card Templates\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS\",\n \"CARD_TEMPLATE_INVALID_LAYOUT\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(CardTemplateCreateInputSchema)\n .output(CardTemplateCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/card-templates/{id}\",\n summary: \"Update card template\",\n description:\n \"Change an owned template name or faces (see creating a template for the face shapes). Rendered cards reflect the saved template. expectedUpdatedAt guards against editing stale data.\",\n tags: [\"Card Templates\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_TEMPLATE_NOT_FOUND\",\n \"CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS\",\n \"CARD_TEMPLATE_INVALID_LAYOUT\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(CardTemplateUpdateInputSchema)\n .output(CardTemplateUpdateOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/card-templates/{id}\",\n summary: \"Delete card template\",\n description:\n \"Permanently delete an owned template and its generated cards and review records. Source notes are preserved.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"CARD_TEMPLATE_NOT_FOUND\"))\n .input(CardTemplateDeleteInputSchema)\n .output(CardTemplateDeleteOutputSchema),\n};\n","import { EBOOK_ALLOWED_COVER_CONTENT_TYPES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const ebookStatusSchema = z.enum([\"pending\", \"ready\"]);\nexport type EbookStatus = z.infer<typeof ebookStatusSchema>;\n\nexport const ebookCoverContentTypeSchema = z.enum(EBOOK_ALLOWED_COVER_CONTENT_TYPES);\nexport type EbookCoverContentType = z.infer<typeof ebookCoverContentTypeSchema>;\n\nexport const ebookListItemSchema = z\n .object({\n id: z.uuid(),\n title: z.string(),\n author: z.string().nullable(),\n language: z.string().nullable(),\n fileByteSize: z.number().int(),\n status: ebookStatusSchema,\n progressFraction: z.number(),\n lastReadAt: z.coerce.date().nullable(),\n coverUrl: z.url().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type EbookListItem = z.infer<typeof ebookListItemSchema>;\n\nexport const ebookDetailSchema = ebookListItemSchema.extend({\n progressCfi: z.string().nullable(),\n});\nexport type EbookDetail = z.infer<typeof ebookDetailSchema>;\n\nexport const ebookQuotaSchema = z\n .object({\n count: z.number().int().min(0),\n // 0 is a valid limit: uploading is a paid feature, so free plans get no quota.\n limit: z.number().int().min(0),\n })\n .strict();\nexport type EbookQuota = z.infer<typeof ebookQuotaSchema>;\n\nexport const ebookListInputSchema = z.object({}).strict();\nexport type EbookListInput = z.infer<typeof ebookListInputSchema>;\n\nexport const ebookListOutputSchema = z\n .object({\n items: z.array(ebookListItemSchema),\n quota: ebookQuotaSchema,\n })\n .strict();\nexport type EbookListOutput = z.infer<typeof ebookListOutputSchema>;\n\nexport const ebookGetInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookGetInput = z.infer<typeof ebookGetInputSchema>;\n\nexport const ebookGetOutputSchema = z\n .object({\n ebook: ebookDetailSchema,\n })\n .strict();\nexport type EbookGetOutput = z.infer<typeof ebookGetOutputSchema>;\n\nexport const ebookRequestUploadInputSchema = z\n .object({\n title: z.string().min(1).max(500),\n author: z.string().max(500).optional(),\n language: z.string().max(35).optional(),\n // Exact sizes: each upload is signed for them, and storage refuses any other file.\n fileByteSize: z.number().int().min(1),\n cover: z\n .object({\n contentType: ebookCoverContentTypeSchema,\n byteSize: z.number().int().min(1),\n })\n .strict()\n .optional(),\n /**\n * The client's key for this upload. Asking again with the same key, after\n * an answer that never arrived or for a retry, returns the same pending\n * book with fresh targets instead of reserving another place in the\n * library's allowance.\n */\n uploadKey: z.uuid().optional(),\n })\n .strict();\nexport type EbookRequestUploadInput = z.infer<typeof ebookRequestUploadInputSchema>;\n\n/**\n * A signed PUT: send the file to `url` with exactly `headers`. The signature\n * covers the file's type and exact size, so storage refuses any other file.\n */\nexport const ebookPresignedUploadSchema = z\n .object({\n url: z.url(),\n headers: z.record(z.string(), z.string()),\n })\n .strict();\nexport type EbookPresignedUpload = z.infer<typeof ebookPresignedUploadSchema>;\n\nexport const ebookRequestUploadOutputSchema = z\n .object({\n ebookId: z.uuid(),\n upload: ebookPresignedUploadSchema,\n coverUpload: ebookPresignedUploadSchema.nullable(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type EbookRequestUploadOutput = z.infer<typeof ebookRequestUploadOutputSchema>;\n\nexport const ebookFinalizeUploadInputSchema = z\n .object({\n ebookId: z.uuid(),\n })\n .strict();\nexport type EbookFinalizeUploadInput = z.infer<typeof ebookFinalizeUploadInputSchema>;\n\nexport const ebookFinalizeUploadOutputSchema = z\n .object({\n ebook: ebookListItemSchema,\n })\n .strict();\nexport type EbookFinalizeUploadOutput = z.infer<typeof ebookFinalizeUploadOutputSchema>;\n\nexport const ebookGetDownloadUrlInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookGetDownloadUrlInput = z.infer<typeof ebookGetDownloadUrlInputSchema>;\n\nexport const ebookGetDownloadUrlOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type EbookGetDownloadUrlOutput = z.infer<typeof ebookGetDownloadUrlOutputSchema>;\n\nexport const ebookUpdateProgressDataSchema = z\n .object({\n cfi: z.string().max(2000),\n fraction: z.number().min(0).max(1),\n })\n .strict();\nexport type EbookUpdateProgressData = z.infer<typeof ebookUpdateProgressDataSchema>;\n\nexport const ebookUpdateProgressInputSchema = ebookUpdateProgressDataSchema.extend({\n id: z.uuid(),\n});\nexport type EbookUpdateProgressInput = z.infer<typeof ebookUpdateProgressInputSchema>;\n\nexport const ebookUpdateProgressOutputSchema = z\n .object({\n lastReadAt: z.coerce.date(),\n })\n .strict();\nexport type EbookUpdateProgressOutput = z.infer<typeof ebookUpdateProgressOutputSchema>;\n\nexport const ebookRenameDataSchema = z\n .object({\n title: z.string().min(1).max(500),\n author: z.string().max(500).nullable().optional(),\n })\n .strict();\nexport type EbookRenameData = z.infer<typeof ebookRenameDataSchema>;\n\nexport const ebookRenameInputSchema = ebookRenameDataSchema.extend({\n id: z.uuid(),\n});\nexport type EbookRenameInput = z.infer<typeof ebookRenameInputSchema>;\n\nexport const ebookRenameOutputSchema = z\n .object({\n ebook: ebookListItemSchema,\n })\n .strict();\nexport type EbookRenameOutput = z.infer<typeof ebookRenameOutputSchema>;\n\nexport const ebookDeleteInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookDeleteInput = z.infer<typeof ebookDeleteInputSchema>;\n\nexport const ebookDeleteOutputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookDeleteOutput = z.infer<typeof ebookDeleteOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n ebookDeleteInputSchema,\n ebookDeleteOutputSchema,\n ebookFinalizeUploadInputSchema,\n ebookFinalizeUploadOutputSchema,\n ebookGetDownloadUrlInputSchema,\n ebookGetDownloadUrlOutputSchema,\n ebookGetInputSchema,\n ebookGetOutputSchema,\n ebookListInputSchema,\n ebookListOutputSchema,\n ebookRenameInputSchema,\n ebookRenameOutputSchema,\n ebookRequestUploadInputSchema,\n ebookRequestUploadOutputSchema,\n ebookUpdateProgressInputSchema,\n ebookUpdateProgressOutputSchema,\n} from \"#/schemas/ebook\";\n\nconst ebookProcedure = oc;\n\nexport const ebookContract = {\n list: ebookProcedure\n .route({\n method: \"GET\",\n path: \"/ebooks\",\n summary: \"List ebooks with quota\",\n tags: [\"Ebooks\"],\n })\n .input(ebookListInputSchema)\n .output(ebookListOutputSchema),\n\n get: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/ebooks/{id}\",\n summary: \"Get an ebook with reading progress\",\n tags: [\"Ebooks\"],\n })\n .input(ebookGetInputSchema)\n .output(ebookGetOutputSchema),\n\n requestUpload: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_LIMIT_EXCEEDED\", \"EBOOK_FILE_TOO_LARGE\"))\n .route({\n method: \"POST\",\n path: \"/ebooks/uploads\",\n summary: \"Request presigned upload URLs for a new ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookRequestUploadInputSchema)\n .output(ebookRequestUploadOutputSchema),\n\n finalizeUpload: ebookProcedure\n .errors(\n pickPublicErrorMap(\"EBOOK_NOT_FOUND\", \"EBOOK_UPLOAD_NOT_COMPLETED\", \"EBOOK_FILE_TOO_LARGE\"),\n )\n .route({\n method: \"POST\",\n path: \"/ebooks/{ebookId}/finalize\",\n summary: \"Finalize an ebook upload\",\n tags: [\"Ebooks\"],\n })\n .input(ebookFinalizeUploadInputSchema)\n .output(ebookFinalizeUploadOutputSchema),\n\n getDownloadUrl: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/ebooks/{id}/download-url\",\n summary: \"Get a presigned download URL for an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookGetDownloadUrlInputSchema)\n .output(ebookGetDownloadUrlOutputSchema),\n\n updateProgress: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"PATCH\",\n path: \"/ebooks/{id}/progress\",\n summary: \"Update ebook reading progress\",\n tags: [\"Ebooks\"],\n })\n .input(ebookUpdateProgressInputSchema)\n .output(ebookUpdateProgressOutputSchema),\n\n rename: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"PATCH\",\n path: \"/ebooks/{id}\",\n summary: \"Rename an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookRenameInputSchema)\n .output(ebookRenameOutputSchema),\n\n delete: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"DELETE\",\n path: \"/ebooks/{id}\",\n summary: \"Delete an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookDeleteInputSchema)\n .output(ebookDeleteOutputSchema),\n};\n","import { z } from \"zod\";\nimport { appLocaleSchema } from \"./app-locale\";\n\n// Which marketing and lifecycle emails a user gets, by category. Read and\n// changed signed in (the settings page), or through the signed token in an\n// email's unsubscribe link (the unsubscribe page that link opens, which needs\n// no sign-in). Category names come from the server in the requested locale.\n\n/** A category's key, such as `promotions`. */\nexport const emailCategoryKeySchema = z\n .string()\n .max(64)\n .regex(/^[a-z][a-z0-9_]*$/);\nexport type EmailCategoryKey = z.infer<typeof emailCategoryKeySchema>;\n\n/** The token in an email's unsubscribe link. */\nexport const emailLinkTokenSchema = z.string().min(1).max(1024);\n\nexport const emailCategoryStateSchema = z\n .object({\n key: z.string(),\n // In the requested locale, or English when the category has none for it.\n name: z.string(),\n description: z.string().nullable(),\n // Promotional mail.\n commercial: z.boolean(),\n // Notices about the account and the service, which nobody can unsubscribe\n // from: always subscribed, \"unsubscribe from all\" included, and a change\n // to it is ignored. Show it on, without a way to turn it off.\n required: z.boolean(),\n // Whether the user gets this category now, \"unsubscribe from all\" included.\n subscribed: z.boolean(),\n })\n .strict();\nexport type EmailCategoryState = z.infer<typeof emailCategoryStateSchema>;\n\n/**\n * The category whose emails a person can time: Practice reminders, seeded as\n * `practice` (packages/db's migration 0067). The settings page shows the\n * time under its switch.\n */\nexport const PRACTICE_REMINDER_CATEGORY_KEY = \"practice\";\n\n/**\n * When practice reminders reach someone who never chose a time: 18:00 in\n * their own time zone. The page shows it as the choice until one is made;\n * Ribbit's reminder automation sets the same as its own time, for people\n * without one (docs/ribbit/phase-3-automations.md).\n */\nexport const PRACTICE_REMINDER_DEFAULT_TIME = \"18:00\";\n\n/** A time of day on the hour, `HH:00`: Ribbit takes people into a schedule once an hour. */\nexport const practiceReminderTimeSchema = z\n .string()\n .regex(/^([01]\\d|2[0-3]):00$/, \"Choose a time on the hour.\");\nexport type PracticeReminderTime = z.infer<typeof practiceReminderTimeSchema>;\n\n/** The times the page offers: every hour of the day. */\nexport const PRACTICE_REMINDER_TIMES: readonly PracticeReminderTime[] = Array.from(\n { length: 24 },\n (_, hour) => `${String(hour).padStart(2, \"0\")}:00`,\n);\n\n/**\n * The reminders area of `user_preferences`, as the database holds it: what\n * is not there, or no longer reads, is the default. `practiceTime` is the\n * practice reminder's time of day, in the person's own zone; null until they\n * choose one.\n */\nexport const remindersPreferencesSchema = z.object({\n practiceTime: practiceReminderTimeSchema.nullable().catch(null).default(null),\n});\nexport type RemindersPreferences = z.infer<typeof remindersPreferencesSchema>;\n\nexport const emailPreferencesStateSchema = z\n .object({\n // In display order; archived categories are left out.\n categories: z.array(emailCategoryStateSchema),\n unsubscribedAll: z.boolean(),\n // When practice reminders reach them, in their own time zone; null while\n // they never chose one (the page then shows PRACTICE_REMINDER_DEFAULT_TIME).\n practiceReminderTime: practiceReminderTimeSchema.nullable(),\n })\n .strict();\nexport type EmailPreferencesState = z.infer<typeof emailPreferencesStateSchema>;\n\n/**\n * What the page a link opens shows on top of the state: whose preferences they\n * are, without the full address, and the category the link was for, if any.\n */\nexport const emailPreferencesByTokenStateSchema = z\n .object({\n ...emailPreferencesStateSchema.shape,\n maskedEmail: z.string(),\n // The link's category, when it is one the user can unsubscribe from: null\n // for a link without one, or for an archived, required or unknown one.\n highlightCategory: z.string().nullable(),\n })\n .strict();\nexport type EmailPreferencesByTokenState = z.infer<typeof emailPreferencesByTokenStateSchema>;\n\nconst emailPreferencesChangesShape = {\n // Subscribes (true) or unsubscribes (false) the categories it names, and\n // leaves the rest alone. Subscribing to one after \"unsubscribe from all\"\n // ends it, and every other category stays unsubscribed. A required category\n // is ignored.\n categories: z.record(emailCategoryKeySchema, z.boolean()).optional(),\n // true unsubscribes from every category but the required ones, including\n // categories added later; false ends that and leaves each category as it was\n // before.\n unsubscribedAll: z.boolean().optional(),\n // Sets when practice reminders reach them (null: back to the default); left\n // out, it stays as it is.\n practiceReminderTime: practiceReminderTimeSchema.nullable().optional(),\n};\n\nexport const emailPreferencesGetInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type EmailPreferencesGetInput = z.infer<typeof emailPreferencesGetInputSchema>;\n\nexport const emailPreferencesUpdateInputSchema = z\n .object({\n locale: appLocaleSchema,\n ...emailPreferencesChangesShape,\n })\n .strict();\nexport type EmailPreferencesUpdateInput = z.infer<typeof emailPreferencesUpdateInputSchema>;\n\nexport const emailPreferencesGetByTokenInputSchema = z\n .object({\n token: emailLinkTokenSchema,\n locale: appLocaleSchema,\n })\n .strict();\nexport type EmailPreferencesGetByTokenInput = z.infer<typeof emailPreferencesGetByTokenInputSchema>;\n\nexport const emailPreferencesUpdateByTokenInputSchema = z\n .object({\n token: emailLinkTokenSchema,\n locale: appLocaleSchema,\n ...emailPreferencesChangesShape,\n })\n .strict();\nexport type EmailPreferencesUpdateByTokenInput = z.infer<\n typeof emailPreferencesUpdateByTokenInputSchema\n>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n emailPreferencesByTokenStateSchema,\n emailPreferencesGetByTokenInputSchema,\n emailPreferencesGetInputSchema,\n emailPreferencesStateSchema,\n emailPreferencesUpdateByTokenInputSchema,\n emailPreferencesUpdateInputSchema,\n} from \"#/schemas/email-preferences\";\n\n// Every write returns the whole state, so a client can update optimistically\n// and then take the server's answer.\nexport const emailPreferencesContract = {\n get: oc\n .route({\n method: \"GET\",\n path: \"/users/me/email-preferences\",\n summary: \"Get which emails the authenticated user receives\",\n tags: [\"Email preferences\"],\n })\n .input(emailPreferencesGetInputSchema)\n .output(emailPreferencesStateSchema),\n update: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/email-preferences\",\n summary: \"Change which emails the authenticated user receives\",\n tags: [\"Email preferences\"],\n })\n .input(emailPreferencesUpdateInputSchema)\n .output(emailPreferencesStateSchema),\n // Public: the token in an email's link stands in for signing in. POST keeps\n // the token out of URLs and logs.\n getByToken: oc\n .route({\n method: \"POST\",\n path: \"/email-preferences/by-token\",\n summary: \"Get the email preferences an email link is for\",\n tags: [\"Email preferences\"],\n })\n .errors(pickPublicErrorMap(\"EMAIL_LINK_INVALID\"))\n .input(emailPreferencesGetByTokenInputSchema)\n .output(emailPreferencesByTokenStateSchema),\n updateByToken: oc\n .route({\n method: \"POST\",\n path: \"/email-preferences/by-token/update\",\n summary: \"Change the email preferences an email link is for\",\n tags: [\"Email preferences\"],\n })\n .errors(pickPublicErrorMap(\"EMAIL_LINK_INVALID\"))\n .input(emailPreferencesUpdateByTokenInputSchema)\n .output(emailPreferencesByTokenStateSchema),\n};\n","import { GATED_FEATURE_KEYS } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const GatedFeatureKeySchema = z.enum(GATED_FEATURE_KEYS);\nexport type GatedFeatureKey = z.infer<typeof GatedFeatureKeySchema>;\n\nexport const FeatureAccessStatusInputSchema = z\n .object({\n featureKey: GatedFeatureKeySchema,\n })\n .strict();\nexport type FeatureAccessStatusInput = z.infer<typeof FeatureAccessStatusInputSchema>;\n\nexport const FeatureAccessStatusOutputSchema = z.object({\n featureKey: GatedFeatureKeySchema,\n allowed: z.boolean(),\n});\nexport type FeatureAccessStatusOutput = z.infer<typeof FeatureAccessStatusOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport {\n FeatureAccessStatusInputSchema,\n FeatureAccessStatusOutputSchema,\n} from \"#/schemas/feature-access\";\n\nexport const featureAccessContract = {\n status: oc\n .route({\n method: \"GET\",\n path: \"/feature-access/status\",\n summary: \"Get whether the caller can use a gated feature\",\n tags: [\"Feature Access\"],\n })\n .input(FeatureAccessStatusInputSchema)\n .output(FeatureAccessStatusOutputSchema),\n};\n","import { eventIterator, oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n HostedAiCreditPoolsInputSchema,\n HostedAiCreditPoolsOutputSchema,\n HostedAiNoteSuggestionStreamInputSchema,\n HostedAiStatusInputSchema,\n HostedAiStatusOutputSchema,\n HostedAiStreamPartSchema,\n HostedAiStreamStructuredObjectInputSchema,\n HostedAiStreamTextInputSchema,\n} from \"#/schemas/hosted-ai\";\n\nconst hostedAiStreamErrors = pickPublicErrorMap(\n \"HOSTED_AI_TIER_RESTRICTED\",\n \"HOSTED_AI_QUOTA_EXHAUSTED\",\n);\n\nexport const hostedAiContract = {\n pools: oc\n .route({\n method: \"GET\",\n path: \"/hosted-ai/pools\",\n summary: \"Get shared Built-in AI credit pools for a feature\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiCreditPoolsInputSchema)\n .output(HostedAiCreditPoolsOutputSchema),\n status: oc\n .route({\n method: \"GET\",\n path: \"/hosted-ai/status\",\n summary: \"Get Built-in AI availability and quota status\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStatusInputSchema)\n .output(HostedAiStatusOutputSchema),\n translate: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/translate/stream-text\",\n summary: \"Stream hosted translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n selectionTranslation: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/selection-translation/stream-text\",\n summary: \"Stream hosted selection translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n videoSubtitles: {\n // Subtitle lines and the video summary share this route: both are short\n // text and both bill against `videoSubtitles`.\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/video-subtitles/stream-text\",\n summary: \"Stream hosted subtitle translation or video summary text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n /**\n * Segmentation shares the `videoSubtitles` feature but not its route,\n * because `endpointMaxOutputTokens` sizes the credit reservation: emitting\n * a WebVTT block needs several times a subtitle line's budget, and folding\n * both into one route would make every line reserve — and, near the end of\n * a credit window, fail to afford — what only segmentation needs.\n */\n streamSegmentation: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/video-subtitles/stream-segmentation\",\n summary: \"Stream hosted subtitle segmentation output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n inputTranslation: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/input-translation/stream-text\",\n summary: \"Stream hosted input box translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n languageDetection: {\n // Detection wants one short string back, not a stream, but the quota\n // reserve/settle path is stream-shaped end to end. Reusing it keeps one\n // metering implementation; the client collects the deltas.\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/language-detection/stream-text\",\n summary: \"Stream hosted language detection output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n customAction: {\n streamStructuredObject: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/custom-actions/stream-structured-object\",\n summary: \"Stream hosted custom action structured output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamStructuredObjectInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n noteSuggestion: {\n streamStructuredObject: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/note-suggestions/stream-structured-object\",\n summary: \"Stream hosted note suggestion structured output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiNoteSuggestionStreamInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n};\n","import { z } from \"zod\";\n\nexport const MASTERY_GOAL_TARGET_MAX = 1_000_000;\n\n/** How many mastered cards to aim for: the cards `stats.srsMemoryGrowth` counts. */\nexport const masteryGoalTargetSchema = z.number().int().min(1).max(MASTERY_GOAL_TARGET_MAX);\nexport type MasteryGoalTarget = z.infer<typeof masteryGoalTargetSchema>;\n\n/** `null` clears the goal. */\nexport const masteryGoalUpdateInputSchema = z\n .object({\n target: masteryGoalTargetSchema.nullable(),\n })\n .strict();\nexport type MasteryGoalUpdateInput = z.infer<typeof masteryGoalUpdateInputSchema>;\n\n/** The goal's target, or `null` while none is set. */\nexport const masteryGoalOutputSchema = z\n .object({\n target: masteryGoalTargetSchema.nullable(),\n })\n .strict();\nexport type MasteryGoalOutput = z.infer<typeof masteryGoalOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { masteryGoalOutputSchema, masteryGoalUpdateInputSchema } from \"#/schemas/mastery-goal\";\n\nexport const masteryGoalContract = {\n get: oc\n .route({\n method: \"GET\",\n path: \"/mastery-goal\",\n summary: \"Get the authenticated user's mastered-cards goal\",\n tags: [\"Goals\"],\n })\n .output(masteryGoalOutputSchema),\n update: oc\n .route({\n method: \"PUT\",\n path: \"/mastery-goal\",\n summary: \"Set or clear the authenticated user's mastered-cards goal\",\n tags: [\"Goals\"],\n })\n .input(masteryGoalUpdateInputSchema)\n .output(masteryGoalOutputSchema),\n};\n","import { z } from \"zod\";\n\nexport const mcpConnectionSchema = z\n .object({\n /** OAuth client identifier. For a CIMD client this is an https URL. */\n clientId: z.string(),\n /** The client's registered display name, absent when it never gave one. */\n clientName: z.string().nullable(),\n scopes: z.array(z.string()),\n requestedUserInfoClaims: z.array(z.string()),\n grantedAt: z.date().nullable(),\n updatedAt: z.date().nullable(),\n /**\n * When this client last obtained an access token — the closest honest\n * proxy for \"last used\" the OAuth tables record. A token is issued on\n * connect and on every refresh, so an idle client's value stops advancing.\n */\n lastAuthorizedAt: z.date().nullable(),\n })\n .strict();\nexport type McpConnection = z.infer<typeof mcpConnectionSchema>;\n\nexport const mcpConnectionListOutputSchema = z.array(mcpConnectionSchema);\n\nexport const mcpConnectionRevokeInputSchema = z.object({ clientId: z.string().min(1) }).strict();\nexport type McpConnectionRevokeInput = z.infer<typeof mcpConnectionRevokeInputSchema>;\n\nexport const mcpConnectionRevokeOutputSchema = z.object({ clientId: z.string() }).strict();\n\n/**\n * How many MCP tool calls the caller has used of their plan's\n * `MCP_DAILY_CALL_LIMITS`, read without counting one. The window is 24 hours\n * from the first call in it, not a calendar day.\n */\nexport const mcpCallUsageSchema = z\n .object({\n /** Calls used in the current window, at most `limit`. */\n usedCalls: z.number().int().min(0),\n /** null: the plan has no daily limit. */\n limit: z.number().int().positive().nullable(),\n /** When the current 24-hour window ends; null when no window is open or there is no limit. */\n resetAt: z.iso.datetime().nullable(),\n })\n .strict();\nexport type McpCallUsage = z.infer<typeof mcpCallUsageSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport {\n mcpCallUsageSchema,\n mcpConnectionListOutputSchema,\n mcpConnectionRevokeInputSchema,\n mcpConnectionRevokeOutputSchema,\n} from \"#/schemas/mcp-connection\";\n\nexport const mcpConnectionContract = {\n list: oc\n .route({\n method: \"GET\",\n path: \"/mcp-connections\",\n summary: \"List the OAuth clients the caller has authorized\",\n tags: [\"MCP Connections\"],\n })\n .output(mcpConnectionListOutputSchema),\n revoke: oc\n .route({\n method: \"POST\",\n path: \"/mcp-connections/revoke\",\n summary: \"Withdraw a client's authorization and revoke its tokens\",\n tags: [\"MCP Connections\"],\n })\n .input(mcpConnectionRevokeInputSchema)\n .output(mcpConnectionRevokeOutputSchema),\n usage: oc\n .route({\n method: \"GET\",\n path: \"/mcp-connections/usage\",\n summary: \"Get the MCP tool calls the caller has used of their plan's daily limit\",\n tags: [\"MCP Connections\"],\n })\n .input(z.object({}).strict())\n .output(mcpCallUsageSchema),\n};\n","import { MEDIA_ASSET_STATUS_VALUES, MEDIA_CONTENT_TYPES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const mediaContentTypeSchema = z.enum(MEDIA_CONTENT_TYPES);\nexport type MediaContentType = z.infer<typeof mediaContentTypeSchema>;\n\nexport const mediaAssetStatusSchema = z.enum(MEDIA_ASSET_STATUS_VALUES);\nexport type MediaAssetStatus = z.infer<typeof mediaAssetStatusSchema>;\n\n/** Why the worker rejected an upload. */\nexport const mediaFailureCodeSchema = z.enum([\n \"unsupported_format\",\n \"invalid_file\",\n \"file_too_large\",\n \"image_too_large\",\n \"audio_too_long\",\n \"quota_exceeded\",\n \"processing_failed\",\n]);\nexport type MediaFailureCode = z.infer<typeof mediaFailureCodeSchema>;\n\nexport const mediaAssetMetadataSchema = z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"image\"), width: z.number().int(), height: z.number().int() })\n .strict(),\n z.object({ kind: z.literal(\"audio\"), durationMs: z.number().int() }).strict(),\n]);\n\nexport const mediaAssetSchema = z\n .object({\n id: z.uuid(),\n /** What a cell stores to reference the asset; null until it is ready. */\n uri: z.string().nullable(),\n status: mediaAssetStatusSchema,\n contentType: z.string().nullable(),\n fileByteSize: z.number().int(),\n metadata: mediaAssetMetadataSchema.nullable(),\n failureCode: mediaFailureCodeSchema.nullable(),\n createdAt: z.coerce.date(),\n })\n .strict();\nexport type MediaAsset = z.infer<typeof mediaAssetSchema>;\n\nexport const mediaRequestUploadInputSchema = z\n .object({\n contentType: mediaContentTypeSchema,\n // The exact size: the upload is signed for it, and storage refuses any other file.\n byteSize: z.number().int().min(1),\n })\n .strict();\nexport type MediaRequestUploadInput = z.infer<typeof mediaRequestUploadInputSchema>;\n\nexport const mediaRequestUploadOutputSchema = z\n .object({\n assetId: z.uuid(),\n /** A signed PUT: send the file to `url` with exactly `headers`. */\n upload: z.object({ url: z.url(), headers: z.record(z.string(), z.string()) }).strict(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type MediaRequestUploadOutput = z.infer<typeof mediaRequestUploadOutputSchema>;\n\nexport const mediaAssetIdInputSchema = z.object({ id: z.uuid() }).strict();\nexport type MediaAssetIdInput = z.infer<typeof mediaAssetIdInputSchema>;\n\nexport const mediaAssetOutputSchema = z.object({ asset: mediaAssetSchema }).strict();\nexport type MediaAssetOutput = z.infer<typeof mediaAssetOutputSchema>;\n\nexport const mediaUsageOutputSchema = z\n .object({\n usedBytes: z.number().int().min(0),\n /** Held by uploads that are not done yet. */\n reservedBytes: z.number().int().min(0),\n limitBytes: z.number().int().min(0),\n })\n .strict();\nexport type MediaUsageOutput = z.infer<typeof mediaUsageOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n mediaAssetIdInputSchema,\n mediaAssetOutputSchema,\n mediaRequestUploadInputSchema,\n mediaRequestUploadOutputSchema,\n mediaUsageOutputSchema,\n} from \"#/schemas/media\";\n\nexport const mediaContract = {\n requestUpload: oc\n .errors(\n pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_FILE_TOO_LARGE\", \"MEDIA_QUOTA_EXCEEDED\"),\n )\n .route({\n method: \"POST\",\n path: \"/media/uploads\",\n summary: \"Reserve space and get a signed upload URL for a media file\",\n tags: [\"Media\"],\n })\n .input(mediaRequestUploadInputSchema)\n .output(mediaRequestUploadOutputSchema),\n\n completeUpload: oc\n .errors(\n pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_NOT_FOUND\", \"MEDIA_UPLOAD_NOT_COMPLETED\"),\n )\n .route({\n method: \"POST\",\n path: \"/media/{id}/complete\",\n summary: \"Queue an uploaded media file for validation\",\n tags: [\"Media\"],\n })\n .input(mediaAssetIdInputSchema)\n .output(mediaAssetOutputSchema),\n\n get: oc\n .errors(pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/media/{id}\",\n summary: \"Get a media asset and its upload status\",\n tags: [\"Media\"],\n })\n .input(mediaAssetIdInputSchema)\n .output(mediaAssetOutputSchema),\n\n usage: oc\n .errors(pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\"))\n .route({\n method: \"GET\",\n path: \"/media/usage\",\n summary: \"Get the media space used, reserved and allowed\",\n tags: [\"Media\"],\n })\n .input(z.object({}).strict())\n .output(mediaUsageOutputSchema),\n};\n","import { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n NOTEBASE_COLUMN_MAX_WIDTH,\n NOTEBASE_COLUMN_MIN_WIDTH,\n notebaseColumnConfigSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const notebaseColumnWidthSchema = z\n .number()\n .int()\n .min(NOTEBASE_COLUMN_MIN_WIDTH)\n .max(NOTEBASE_COLUMN_MAX_WIDTH);\n\nexport const notebaseColumnSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n name: z.string(),\n config: notebaseColumnConfigSchema,\n position: z.number(),\n isPrimary: z.boolean(),\n width: z.number().nullable(),\n wrap: z.boolean(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseColumn = z.infer<typeof notebaseColumnSchema>;\n\nexport const notebaseColumnCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n config: notebaseColumnConfigSchema,\n })\n .strict();\nexport type NotebaseColumnCreateData = z.infer<typeof notebaseColumnCreateDataSchema>;\n\nexport const notebaseColumnUpdateDataSchema = z\n .object({\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n name: z.string().min(1).optional(),\n config: notebaseColumnConfigSchema.optional(),\n width: notebaseColumnWidthSchema.nullable().optional(),\n wrap: z.boolean().optional(),\n })\n .strict();\nexport type NotebaseColumnUpdateData = z.infer<typeof notebaseColumnUpdateDataSchema>;\n\nexport const NotebaseColumnCreateInputSchema = z.object({\n notebaseId: z.uuid(),\n data: notebaseColumnCreateDataSchema,\n});\nexport type NotebaseColumnCreateInput = z.infer<typeof NotebaseColumnCreateInputSchema>;\n\nexport const NotebaseColumnCreateOutputSchema = z.object({\n field: notebaseColumnSchema,\n txid: z.number(),\n});\nexport type NotebaseColumnCreateOutput = z.infer<typeof NotebaseColumnCreateOutputSchema>;\n\nexport const NotebaseColumnUpdateInputSchema = z.object({\n notebaseColumnId: z.uuid(),\n data: notebaseColumnUpdateDataSchema,\n});\nexport type NotebaseColumnUpdateInput = z.infer<typeof NotebaseColumnUpdateInputSchema>;\n\nexport const NotebaseColumnUpdateOutputSchema = z.object({\n field: notebaseColumnSchema,\n txid: z.number(),\n});\nexport type NotebaseColumnUpdateOutput = z.infer<typeof NotebaseColumnUpdateOutputSchema>;\n\nexport const NotebaseColumnDeleteInputSchema = z.object({\n notebaseColumnId: z.uuid(),\n});\nexport type NotebaseColumnDeleteInput = z.infer<typeof NotebaseColumnDeleteInputSchema>;\n\nexport const NotebaseColumnDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseColumnDeleteOutput = z.infer<typeof NotebaseColumnDeleteOutputSchema>;\n\nexport const NotebaseColumnReorderInputSchema = z.object({\n notebaseId: z.uuid(),\n ids: z.array(z.uuid()),\n});\nexport type NotebaseColumnReorderInput = z.infer<typeof NotebaseColumnReorderInputSchema>;\n\nexport const NotebaseColumnReorderOutputSchema = z.object({\n txid: z.number(),\n});\nexport type NotebaseColumnReorderOutput = z.infer<typeof NotebaseColumnReorderOutputSchema>;\n","import { paginationShape, pageSchema } from \"./pagination\";\nimport { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n noteCreatedViaSchema,\n noteOriginInputSchema,\n noteOriginSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const notebaseRowCellsSchema = z.record(z.string(), z.unknown());\n\nexport const notebaseRowSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n cells: notebaseRowCellsSchema,\n position: z.number(),\n origin: noteOriginSchema\n .nullish()\n .describe(\n \"Where the note's content came from, set when it was created: a web page (url, title), a book on the user's shelf (ebookId, its title then, and cfi, the EPUB location of the selection), or a video (url, title, seconds into it). Null when it has none, or when it was created before this was recorded.\",\n ),\n createdVia: noteCreatedViaSchema\n .nullish()\n .describe(\n 'Which client created the note: \"web\", \"extension\", \"mobile\", \"mcp\" (with the MCP client\\'s id and the name it registered under) or \"unknown\". Null for notes created before this was recorded.',\n ),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseRow = z.infer<typeof notebaseRowSchema>;\n\n/**\n * Where a new note's content came from; see `noteOriginInputSchema`. Optional\n * metadata never costs the note: an origin that does not parse is dropped and\n * the note is saved without one.\n */\nexport const notebaseRowOriginInputSchema = noteOriginInputSchema\n .optional()\n .catch(undefined)\n .describe(\n \"Where the note's content came from: a web page or video by its http(s) URL, or a book on the user's shelf by its id. Stored once and never edited. Optional: an origin that cannot be used is left out and the note is still saved.\",\n );\n\nexport const notebaseRowCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n cells: notebaseRowCellsSchema.optional(),\n origin: notebaseRowOriginInputSchema,\n })\n .strict();\nexport type NotebaseRowCreateData = z.infer<typeof notebaseRowCreateDataSchema>;\n\nexport const notebaseRowUpdateDataSchema = z\n .object({\n cells: notebaseRowCellsSchema.optional(),\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n })\n .strict();\nexport type NotebaseRowUpdateData = z.infer<typeof notebaseRowUpdateDataSchema>;\n\nexport const NotebaseRowCreateInputSchema = z.object({\n notebaseId: z.uuid(),\n data: notebaseRowCreateDataSchema,\n});\nexport type NotebaseRowCreateInput = z.infer<typeof NotebaseRowCreateInputSchema>;\n\nexport const NotebaseRowCreateOutputSchema = z.object({\n note: notebaseRowSchema,\n txid: z.number(),\n});\nexport type NotebaseRowCreateOutput = z.infer<typeof NotebaseRowCreateOutputSchema>;\n\nexport const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowCreateManyInputSchema = z\n .object({\n notebaseId: z.uuid(),\n rows: z.array(notebaseRowCreateDataSchema).min(1).max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n\n input.rows.forEach((row, index) => {\n if (row.id === undefined) {\n return;\n }\n\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"rows\", index, \"id\"],\n });\n return;\n }\n\n seenIds.add(row.id);\n });\n });\nexport type NotebaseRowCreateManyInput = z.infer<typeof NotebaseRowCreateManyInputSchema>;\n\nexport const NotebaseRowCreateManyOutputSchema = z.object({\n items: z.array(notebaseRowSchema),\n txid: z.number(),\n});\nexport type NotebaseRowCreateManyOutput = z.infer<typeof NotebaseRowCreateManyOutputSchema>;\n\nexport const NotebaseRowUpdateInputSchema = z.object({\n notebaseRowId: z.uuid(),\n data: notebaseRowUpdateDataSchema,\n});\nexport type NotebaseRowUpdateInput = z.infer<typeof NotebaseRowUpdateInputSchema>;\n\nexport const NotebaseRowUpdateOutputSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n cells: notebaseRowCellsSchema,\n position: z.number().int(),\n origin: notebaseRowSchema.shape.origin,\n createdVia: notebaseRowSchema.shape.createdVia,\n createdAt: z.date(),\n updatedAt: z.date(),\n txid: z.number(),\n});\nexport type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>;\n\nexport const NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowUpdateManyInputSchema = z\n .object({\n notebaseId: z.uuid(),\n rows: z\n .array(\n z.object({\n id: z.uuid(),\n data: notebaseRowUpdateDataSchema,\n }),\n )\n .min(1)\n .max(NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n input.rows.forEach((row, index) => {\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"rows\", index, \"id\"],\n });\n }\n seenIds.add(row.id);\n });\n });\nexport type NotebaseRowUpdateManyInput = z.infer<typeof NotebaseRowUpdateManyInputSchema>;\n\nexport const NotebaseRowUpdateManyOutputSchema = z.object({\n items: z.array(notebaseRowSchema),\n txid: z.number(),\n});\nexport type NotebaseRowUpdateManyOutput = z.infer<typeof NotebaseRowUpdateManyOutputSchema>;\n\nexport const NotebaseRowDeleteInputSchema = z.object({\n notebaseRowId: z.uuid(),\n});\nexport type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema>;\n\nexport const NotebaseRowDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>;\n\nexport const NOTEBASE_ROW_DELETE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowDeleteManyInputSchema = z\n .object({\n ids: z.array(z.uuid()).min(1).max(NOTEBASE_ROW_DELETE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n input.ids.forEach((id, index) => {\n if (seenIds.has(id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${id}\".`,\n path: [\"ids\", index],\n });\n }\n seenIds.add(id);\n });\n });\nexport type NotebaseRowDeleteManyInput = z.infer<typeof NotebaseRowDeleteManyInputSchema>;\n\nexport const NotebaseRowDeleteManyOutputSchema = z.object({ ids: z.array(z.uuid()) });\nexport type NotebaseRowDeleteManyOutput = z.infer<typeof NotebaseRowDeleteManyOutputSchema>;\n\nexport const NotebaseRowReorderInputSchema = z.object({\n notebaseId: z.uuid(),\n ids: z.array(z.uuid()),\n});\nexport type NotebaseRowReorderInput = z.infer<typeof NotebaseRowReorderInputSchema>;\n\nexport const NotebaseRowReorderOutputSchema = z.object({\n txid: z.number(),\n});\nexport type NotebaseRowReorderOutput = z.infer<typeof NotebaseRowReorderOutputSchema>;\n\nexport const NotebaseRowListInputSchema = z\n .object({\n notebaseId: z.uuid().optional(),\n // Two characters is already a meaningful CJK query; one matches nearly\n // every note while costing the same full scan, so the floor is a cost\n // control rather than an ergonomic preference.\n query: z.string().trim().min(2).max(200).optional(),\n ...paginationShape,\n })\n // Listing without a notebase is a plain indexed read. Searching is not: it\n // expands every candidate row's cells and cannot use an index, so it stays\n // scoped to one notebase, where `notebase_rows_notebase_id_idx` bounds the\n // candidate set. Searching everything means iterating over notebases.\n .refine((input) => input.query === undefined || input.notebaseId !== undefined, {\n error: \"notebaseId is required when query is set\",\n path: [\"notebaseId\"],\n });\nexport type NotebaseRowListInput = z.infer<typeof NotebaseRowListInputSchema>;\nexport const NotebaseRowListOutputSchema = pageSchema(notebaseRowSchema);\nexport const NotebaseRowGetInputSchema = z.object({ id: z.uuid() });\nexport const NotebaseRowGetOutputSchema = notebaseRowSchema;\n","import { z } from \"zod\";\n\nexport const notebaseViewTypeSchema = z.enum([\"table\", \"kanban\", \"gallery\"]);\nexport type NotebaseViewType = z.infer<typeof notebaseViewTypeSchema>;\n\nexport const notebaseViewConfigSchema = z\n .object({\n notebaseColumnWidths: z.record(z.string(), z.number()).optional(),\n hiddenNotebaseColumns: z.array(z.string()).optional(),\n groupByNotebaseColumnId: z.string().optional(),\n })\n .catchall(z.unknown());\nexport type NotebaseViewConfig = z.infer<typeof notebaseViewConfigSchema>;\n\nexport const notebaseViewFilterSchema = z\n .object({\n notebaseColumnId: z.string(),\n operator: z.string(),\n value: z.unknown(),\n })\n .strict();\nexport type NotebaseViewFilter = z.infer<typeof notebaseViewFilterSchema>;\n\nexport const notebaseViewFiltersSchema = z.array(notebaseViewFilterSchema);\n\nexport const notebaseViewSortSchema = z\n .object({\n notebaseColumnId: z.string(),\n direction: z.enum([\"asc\", \"desc\"]),\n })\n .strict();\nexport type NotebaseViewSort = z.infer<typeof notebaseViewSortSchema>;\n\nexport const notebaseViewSortsSchema = z.array(notebaseViewSortSchema);\n\nexport const notebaseViewCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n type: notebaseViewTypeSchema,\n config: notebaseViewConfigSchema.optional(),\n filters: notebaseViewFiltersSchema.optional(),\n sorts: notebaseViewSortsSchema.optional(),\n })\n .strict();\nexport type NotebaseViewCreateData = z.infer<typeof notebaseViewCreateDataSchema>;\n\nexport const notebaseViewUpdateDataSchema = z\n .object({\n name: z.string().min(1).optional(),\n type: notebaseViewTypeSchema.optional(),\n config: notebaseViewConfigSchema.optional(),\n filters: notebaseViewFiltersSchema.optional(),\n sorts: notebaseViewSortsSchema.optional(),\n })\n .strict();\nexport type NotebaseViewUpdateData = z.infer<typeof notebaseViewUpdateDataSchema>;\n\nexport const notebaseViewSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n name: z.string(),\n type: notebaseViewTypeSchema,\n config: notebaseViewConfigSchema.nullable(),\n filters: z.array(z.unknown()).nullable(),\n sorts: z.array(z.unknown()).nullable(),\n position: z.number(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseView = z.infer<typeof notebaseViewSchema>;\n","import { deletionResultSchema } from \"./resource-mutation\";\nimport {\n notebaseColumnConfigSchema,\n schedulingParamsShape,\n srsModelVersionSchema,\n srsSleepSourceSchema,\n srsWeightsSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { notebaseColumnSchema } from \"./notebase-column\";\nimport {\n NOTEBASE_ROW_CREATE_MANY_MAX_ROWS,\n notebaseRowOriginInputSchema,\n notebaseRowSchema,\n} from \"./notebase-row\";\nimport { notebaseViewSchema } from \"./notebase-view\";\n\nexport const NotebaseListInputSchema = z.object({});\nexport type NotebaseListInput = z.infer<typeof NotebaseListInputSchema>;\n\nexport const notebaseSummarySchema = z.object({\n id: z.string(),\n name: z.string(),\n});\nexport type NotebaseSummary = z.infer<typeof notebaseSummarySchema>;\n\nexport const NotebaseListItemSchema = notebaseSummarySchema;\nexport type NotebaseListItem = z.infer<typeof NotebaseListItemSchema>;\n\nexport const NotebaseListOutputSchema = z.array(NotebaseListItemSchema);\nexport type NotebaseListOutput = z.infer<typeof NotebaseListOutputSchema>;\n\nexport const notebaseSchema = z.object({\n id: z.string(),\n userId: z.string(),\n name: z.string(),\n srsNewPerDay: schedulingParamsShape.newPerDay,\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,\n srsDesiredRetention: schedulingParamsShape.desiredRetention,\n srsEnableShortTerm: schedulingParamsShape.enableShortTerm,\n srsMaximumInterval: schedulingParamsShape.maximumInterval,\n srsLearningSteps: schedulingParamsShape.learningSteps,\n srsRelearningSteps: schedulingParamsShape.relearningSteps,\n srsLeechThreshold: schedulingParamsShape.leechThreshold,\n srsEnableFuzz: schedulingParamsShape.enableFuzz,\n srsWeights: srsWeightsSchema.nullable(),\n // Selects the scheduler/curve; read-only, changed only by the FSRS-7 migration.\n srsModelVersion: srsModelVersionSchema,\n // Null = awake; set = excluded from the combined review. Written by notebase.setSleep and auto sleep.\n srsSleepingAt: z.date().nullable(),\n // Who put it to sleep; null exactly when awake.\n srsSleepSource: srsSleepSourceSchema.nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\nexport type Notebase = z.infer<typeof notebaseSchema>;\n\nconst notebaseInitialRowSchema = z\n .object({\n id: z.uuid().optional(),\n cells: z.record(z.string(), z.unknown()),\n origin: notebaseRowOriginInputSchema,\n })\n .strict();\n\nexport const notebaseCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n options: z\n .object({\n initialColumns: z\n .array(\n z\n .object({\n id: z.uuid(),\n name: z.string().min(1),\n config: notebaseColumnConfigSchema,\n })\n .strict(),\n )\n .min(1),\n initialRow: notebaseInitialRowSchema.optional(),\n initialRows: z\n .array(notebaseInitialRowSchema)\n .min(1)\n .max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS)\n .optional(),\n })\n .strict()\n .superRefine((options, ctx) => {\n if (options.initialRow && options.initialRows) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Provide either initialRow or initialRows, not both.\",\n path: [\"initialRows\"],\n });\n }\n\n if (!options.initialRows) {\n return;\n }\n\n const seenIds = new Set<string>();\n options.initialRows.forEach((row, index) => {\n if (row.id === undefined) {\n return;\n }\n\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"initialRows\", index, \"id\"],\n });\n return;\n }\n\n seenIds.add(row.id);\n });\n })\n .optional(),\n })\n .strict();\nexport type NotebaseCreateData = z.infer<typeof notebaseCreateDataSchema>;\n\nexport const NotebaseCreateInputSchema = notebaseCreateDataSchema;\nexport type NotebaseCreateInput = z.infer<typeof NotebaseCreateInputSchema>;\n\nexport const NotebaseCreateOutputSchema = z.object({\n notebase: notebaseSchema,\n txid: z.number(),\n});\nexport type NotebaseCreateOutput = z.infer<typeof NotebaseCreateOutputSchema>;\n\nexport const notebaseUpdateDataSchema = z\n .object({\n name: z.string().min(1).optional(),\n srsNewPerDay: schedulingParamsShape.newPerDay.optional(),\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay.optional(),\n srsDesiredRetention: schedulingParamsShape.desiredRetention.optional(),\n })\n .strict();\nexport type NotebaseUpdateData = z.infer<typeof notebaseUpdateDataSchema>;\n\nexport const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({\n id: z.uuid(),\n});\nexport type NotebaseUpdateInput = z.infer<typeof NotebaseUpdateInputSchema>;\n\nexport const NotebaseUpdateOutputSchema = z.object({\n notebase: notebaseSchema,\n txid: z.number(),\n});\nexport type NotebaseUpdateOutput = z.infer<typeof NotebaseUpdateOutputSchema>;\n\nexport const NotebaseSetSleepInputSchema = z\n .object({\n id: z.uuid(),\n enabled: z.boolean(),\n })\n .strict();\nexport type NotebaseSetSleepInput = z.infer<typeof NotebaseSetSleepInputSchema>;\n\n// txid is null when the notebase was already in the requested state: nothing to wait for.\nexport const NotebaseSetSleepOutputSchema = z.object({\n txid: z.number().nullable(),\n});\nexport type NotebaseSetSleepOutput = z.infer<typeof NotebaseSetSleepOutputSchema>;\n\nexport const NotebaseDeleteInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseDeleteInput = z.infer<typeof NotebaseDeleteInputSchema>;\n\nexport const NotebaseDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseDeleteOutput = z.infer<typeof NotebaseDeleteOutputSchema>;\n\n// Get endpoint schemas\nexport const NotebaseGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetInput = z.infer<typeof NotebaseGetInputSchema>;\n\nexport const NotebaseGetSummaryInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetSummaryInput = z.infer<typeof NotebaseGetSummaryInputSchema>;\n\nexport const NotebaseGetSummaryOutputSchema = notebaseSummarySchema.extend({\n srsNewPerDay: schedulingParamsShape.newPerDay,\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,\n srsDesiredRetention: schedulingParamsShape.desiredRetention,\n noteCount: z.number().int().nonnegative(),\n});\nexport type NotebaseGetSummaryOutput = z.infer<typeof NotebaseGetSummaryOutputSchema>;\n\nexport const NotebaseGetSchemaInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetSchemaInput = z.infer<typeof NotebaseGetSchemaInputSchema>;\n\nexport const NotebaseGetOutputSchema = notebaseSchema.extend({\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n notebaseColumns: z.array(notebaseColumnSchema),\n notebaseRows: z.array(notebaseRowSchema),\n notebaseViews: z.array(notebaseViewSchema),\n});\nexport type NotebaseGetOutput = z.infer<typeof NotebaseGetOutputSchema>;\n\nexport const NotebaseGetSchemaOutputSchema = z.object({\n id: z.string(),\n name: z.string(),\n updatedAt: z.coerce.date(),\n notebaseColumns: z.array(notebaseColumnSchema),\n});\nexport type NotebaseGetSchemaOutput = z.infer<typeof NotebaseGetSchemaOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseCreateInputSchema,\n NotebaseCreateOutputSchema,\n NotebaseDeleteInputSchema,\n NotebaseDeleteOutputSchema,\n NotebaseGetInputSchema,\n NotebaseGetOutputSchema,\n NotebaseGetSchemaInputSchema,\n NotebaseGetSchemaOutputSchema,\n NotebaseGetSummaryInputSchema,\n NotebaseGetSummaryOutputSchema,\n NotebaseListInputSchema,\n NotebaseListOutputSchema,\n NotebaseSetSleepInputSchema,\n NotebaseSetSleepOutputSchema,\n NotebaseUpdateInputSchema,\n NotebaseUpdateOutputSchema,\n} from \"#/schemas/notebase\";\nimport { defineAgentProcedure } from \"./shared\";\n\nexport const notebaseContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases\",\n summary: \"List notebases\",\n description: \"List the notebases (word books) owned by the current user.\",\n tags: [\"Notebases\"],\n })\n .input(NotebaseListInputSchema)\n .output(NotebaseListOutputSchema),\n\n getSummary: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases/{id}/summary\",\n summary: \"Get notebase summary\",\n description:\n \"Read the name, public study settings and note count of an owned notebase without loading note content.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseGetSummaryInputSchema)\n .output(NotebaseGetSummaryOutputSchema),\n\n get: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/notebases/{id}\",\n summary: \"Get notebase with notebase columns, rows, and views\",\n tags: [\"Notebases\"],\n })\n .input(NotebaseGetInputSchema)\n .output(NotebaseGetOutputSchema),\n\n getSchema: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases/{id}/schema\",\n summary: \"Get notebase schema\",\n description:\n \"Read an owned notebase name and field definitions, including field IDs, types and updatedAt timestamps. Does not return note content.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseGetSchemaInputSchema)\n .output(NotebaseGetSchemaOutputSchema),\n\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebases\",\n summary: \"Create notebase\",\n description:\n \"Create an owned notebase with optional initial fields and notes. Client-provided entity IDs are supported; duplicate IDs produce a conflict.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTE_LIMIT_EXCEEDED\", \"CELL_VALIDATION_FAILED\"))\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseCreateInputSchema)\n .output(NotebaseCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PUT\",\n path: \"/notebases/{id}\",\n summary: \"Update notebase\",\n description:\n \"Update the supplied name or public study settings of an owned notebase, preserving omitted properties.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseUpdateInputSchema)\n .output(NotebaseUpdateOutputSchema),\n\n setSleep: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebases/{id}/sleep\",\n summary: \"Set notebase sleep\",\n description:\n \"Put an owned notebase to sleep (enabled=true) or wake it (enabled=false). A sleeping notebase is left out of the combined review; its cards, memory states and review history are unchanged and it can still be reviewed directly. A request matching the current state succeeds without a change.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseSetSleepInputSchema)\n .output(NotebaseSetSleepOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebases/{id}\",\n summary: \"Delete notebase\",\n description:\n \"Permanently delete an owned notebase and its fields, notes, templates, cards and review records. Return the deleted notebase ID.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseDeleteInputSchema)\n .output(NotebaseDeleteOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseColumnCreateInputSchema,\n NotebaseColumnCreateOutputSchema,\n NotebaseColumnDeleteInputSchema,\n NotebaseColumnDeleteOutputSchema,\n NotebaseColumnReorderInputSchema,\n NotebaseColumnReorderOutputSchema,\n NotebaseColumnUpdateInputSchema,\n NotebaseColumnUpdateOutputSchema,\n} from \"#/schemas/notebase-column\";\n\nexport const notebaseColumnContract = {\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-columns\",\n summary: \"Create notebase field\",\n description:\n \"Create a field in an owned notebase. The returned field ID is used as a key in note cells.\",\n tags: [\"Notebase Columns\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseColumnCreateInputSchema)\n .output(NotebaseColumnCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-columns/{notebaseColumnId}\",\n summary: \"Update notebase field\",\n description:\n \"Update an owned field without changing its type. Removing select options clears affected note values. expectedUpdatedAt guards against editing stale data.\",\n tags: [\"Notebase Columns\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_COLUMN_NOT_FOUND\"))\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\", \"FIELD_TYPE_CHANGE_UNSUPPORTED\"))\n .input(NotebaseColumnUpdateInputSchema)\n .output(NotebaseColumnUpdateOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebase-columns/{notebaseColumnId}\",\n summary: \"Delete notebase field\",\n description:\n 'Delete an owned field and remove its values from notes. Primary fields cannot be deleted, nor can a field a template references: one a columns face lists, or a layout face names as {{ [\"<column id>\"] }}. A layout that loops over ctx.fields, as the default dictionary template\\'s back does to show every other filled field, references none of them, so those can be deleted and simply leave the card.',\n tags: [\"Notebase Columns\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_COLUMN_NOT_FOUND\",\n \"PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED\",\n \"CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE\",\n \"CONCURRENT_POSITION_CONFLICT\",\n ),\n )\n .input(NotebaseColumnDeleteInputSchema)\n .output(NotebaseColumnDeleteOutputSchema),\n\n reorder: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/notebase-columns/reorder\",\n summary: \"Reorder notebase columns\",\n tags: [\"Notebase Columns\"],\n })\n .input(NotebaseColumnReorderInputSchema)\n .output(NotebaseColumnReorderOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport {\n NotebaseRowListInputSchema,\n NotebaseRowListOutputSchema,\n NotebaseRowGetInputSchema,\n NotebaseRowGetOutputSchema,\n} from \"#/schemas/notebase-row\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseRowCreateInputSchema,\n NotebaseRowCreateManyInputSchema,\n NotebaseRowCreateManyOutputSchema,\n NotebaseRowCreateOutputSchema,\n NotebaseRowDeleteInputSchema,\n NotebaseRowDeleteManyInputSchema,\n NotebaseRowDeleteManyOutputSchema,\n NotebaseRowDeleteOutputSchema,\n NotebaseRowReorderInputSchema,\n NotebaseRowReorderOutputSchema,\n NotebaseRowUpdateInputSchema,\n NotebaseRowUpdateManyInputSchema,\n NotebaseRowUpdateManyOutputSchema,\n NotebaseRowUpdateOutputSchema,\n} from \"#/schemas/notebase-row\";\n\nexport const notebaseRowContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebase-rows\",\n summary: \"List or search notes\",\n description:\n \"List or search owned notes, optionally within one notebase. Supply query to search; omit it to browse, which returns every note in scope rather than a filtered set. Searching requires notebaseId and covers that one notebase, so cover several by listing them first and calling this once per notebase. The query filter is at least two characters, matches a literal case-insensitive substring, and only searches fields of type string, so values in number, boolean, date and select fields are never matched. Supports limit and offset pagination.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseRowListInputSchema)\n .output(NotebaseRowListOutputSchema),\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebase-rows/{id}\",\n summary: \"Get note\",\n description:\n \"Read one owned note with field-ID values and the updatedAt timestamp used for modification checks.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\"))\n .input(NotebaseRowGetInputSchema)\n .output(NotebaseRowGetOutputSchema),\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows\",\n summary: \"Create note\",\n description:\n \"Create a note in an owned notebase using field IDs and their declared value types. Existing templates generate cards. A duplicate entity ID produces a conflict.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CELL_VALIDATION_FAILED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n \"NOTE_LIMIT_EXCEEDED\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseRowCreateInputSchema)\n .output(NotebaseRowCreateOutputSchema),\n\n createMany: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows/batch\",\n summary: \"Create notes\",\n description:\n \"Create 1–50 notes atomically in one owned notebase. Cells use field IDs and declared value types. Existing templates generate cards. Duplicate entity IDs roll back the whole batch.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CELL_VALIDATION_FAILED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n \"NOTE_LIMIT_EXCEEDED\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseRowCreateManyInputSchema)\n .output(NotebaseRowCreateManyOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-rows/{notebaseRowId}\",\n summary: \"Update note\",\n description:\n \"Merge supplied fields into an owned note, preserving omitted fields. Use null to clear a field. expectedUpdatedAt guards against editing stale data; reread on a modification conflict. In a cloze field, a deletion's number ({{c1::…}}) is its card's identity: keep the numbers of the deletions you keep, and leave any gaps for the save to close. Renumbering them yourself hands a card's review history to other text, and can delete it.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CELL_VALIDATION_FAILED\"))\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(NotebaseRowUpdateInputSchema)\n .output(NotebaseRowUpdateOutputSchema),\n\n updateMany: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-rows/batch\",\n summary: \"Update notes\",\n description:\n \"Update 1–50 notes atomically in one owned notebase. Each row supplies its ID and fields to merge; omitted fields are preserved and null clears a field. Supply each note's expectedUpdatedAt to guard against stale edits. A missing row, invalid field or modification conflict rolls back the whole batch. Items are returned in input order. In a cloze field, a deletion's number ({{c1::…}}) is its card's identity: keep the numbers of the deletions you keep, and leave any gaps for the save to close. Renumbering them yourself hands a card's review history to other text, and can delete it.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"NOTEBASE_ROW_NOT_FOUND\", \"CELL_VALIDATION_FAILED\"),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(NotebaseRowUpdateManyInputSchema)\n .output(NotebaseRowUpdateManyOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebase-rows/{notebaseRowId}\",\n summary: \"Delete note\",\n description:\n \"Permanently delete an owned note and its derived cards and review records. Return the deleted note ID.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .input(NotebaseRowDeleteInputSchema)\n .output(NotebaseRowDeleteOutputSchema),\n\n deleteMany: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows/batch/delete\",\n summary: \"Delete notes\",\n description:\n \"Permanently delete 1–50 owned notes atomically, including their derived cards and review records. Notes may belong to different notebases. If any ID is missing or inaccessible, nothing is deleted. Return deleted IDs in input order.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .input(NotebaseRowDeleteManyInputSchema)\n .output(NotebaseRowDeleteManyOutputSchema),\n\n reorder: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/notebase-rows/reorder\",\n summary: \"Reorder notebase rows\",\n tags: [\"Notebase Rows\"],\n })\n .input(NotebaseRowReorderInputSchema)\n .output(NotebaseRowReorderOutputSchema),\n};\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n pdfTranslationDeleteOutputSchema,\n pdfTranslationDownloadOutputSchema,\n pdfTranslationGetOutputSchema,\n pdfTranslationJobIdInputSchema,\n pdfTranslationJobResourceSchema,\n pdfTranslationListInputSchema,\n pdfTranslationListOutputSchema,\n pdfTranslationOutputInputSchema,\n pdfTranslationPreviewOutputSchema,\n pdfTranslationRequestUploadInputSchema,\n pdfTranslationRequestUploadOutputSchema,\n pdfTranslationStatusInputSchema,\n pdfTranslationStatusOutputSchema,\n pdfTranslationSubmitInputSchema,\n pdfTranslationSubmitOutputSchema,\n} from \"#/schemas/pdf-translation\";\n\nconst pdfTranslationProcedure = oc.errors(pickPublicErrorMap(\"PDF_TRANSLATION_UNAVAILABLE\"));\n\nexport const pdfTranslationContract = {\n status: pdfTranslationProcedure\n .route({\n method: \"GET\",\n path: \"/pdf-translations/status\",\n summary: \"How many free PDF translations the account has left\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationStatusInputSchema)\n .output(pdfTranslationStatusOutputSchema),\n\n list: pdfTranslationProcedure\n .route({\n method: \"GET\",\n path: \"/pdf-translations\",\n summary: \"List recent PDF translations\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationListInputSchema)\n .output(pdfTranslationListOutputSchema),\n\n requestUpload: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_FILE_TOO_LARGE\"))\n .route({\n method: \"POST\",\n path: \"/pdf-translations/uploads\",\n summary: \"Request a signed upload for a PDF to translate\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationRequestUploadInputSchema)\n .output(pdfTranslationRequestUploadOutputSchema),\n\n submit: pdfTranslationProcedure\n .errors(\n pickPublicErrorMap(\n \"HOSTED_AI_TIER_RESTRICTED\",\n \"PDF_TRANSLATION_UPLOAD_NOT_FOUND\",\n \"PDF_TRANSLATION_UPLOAD_EXPIRED\",\n \"PDF_TRANSLATION_UPLOAD_NOT_COMPLETED\",\n \"PDF_TRANSLATION_FILE_TOO_LARGE\",\n \"PDF_TRANSLATION_INVALID_PDF\",\n \"PDF_TRANSLATION_ALREADY_TRANSLATED\",\n \"PDF_TRANSLATION_PAGE_LIMIT_EXCEEDED\",\n \"PDF_TRANSLATION_QUEUE_FULL\",\n \"PDF_TRANSLATION_IDEMPOTENCY_CONFLICT\",\n \"PDF_TRANSLATION_INSUFFICIENT_CREDIT\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/pdf-translations\",\n summary: \"Translate uploaded PDFs\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationSubmitInputSchema)\n .output(pdfTranslationSubmitOutputSchema),\n\n get: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}\",\n summary: \"Get a PDF translation's status, with the others submitted with it\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationGetOutputSchema),\n\n cancel: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_CANCELLABLE\"))\n .route({\n method: \"POST\",\n path: \"/pdf-translations/{id}/cancel\",\n summary: \"Cancel a PDF translation\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationJobResourceSchema),\n\n getPreviewUrl: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_READY\"))\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}/preview-url\",\n summary: \"Get a short-lived URL to read a translated PDF in the browser\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationOutputInputSchema)\n .output(pdfTranslationPreviewOutputSchema),\n\n getDownloadUrl: pdfTranslationProcedure\n .errors(\n pickPublicErrorMap(\n \"PDF_TRANSLATION_NOT_FOUND\",\n \"PDF_TRANSLATION_NOT_READY\",\n \"PDF_TRANSLATION_DOWNLOAD_RESTRICTED\",\n ),\n )\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}/download-url\",\n summary: \"Get a download URL for a translated PDF\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationOutputInputSchema)\n .output(pdfTranslationDownloadOutputSchema),\n\n delete: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_DELETABLE\"))\n .route({\n method: \"DELETE\",\n path: \"/pdf-translations/{id}\",\n summary: \"Delete a finished PDF translation and its files\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationDeleteOutputSchema),\n};\n","import type { BillingPlan } from \"./billing\";\nimport { langCodeISO6393Schema } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\n// Reading text aloud in the account's voices: the reader's settings, the\n// voices to choose from, and the request that turns a text into audio.\n\n/** The longest text one request reads aloud. */\nexport const SPEECH_TEXT_MAX_LENGTH = 500;\n\n/**\n * How many texts each plan may have read aloud in a day (24 hours from the\n * first one). Generous enough that reviewing never runs into it; the cap is\n * there to keep the voices from being used as a free speech service.\n */\nexport const SPEECH_DAILY_REQUEST_LIMITS = {\n free: 200,\n pro: 5000,\n ultra: 5000,\n} as const satisfies Record<BillingPlan, number>;\n\n/** A voice by its short name: its locale, then the voice (`en-US-AndrewMultilingualNeural`). */\nexport const speechVoiceNameSchema = z\n .string()\n .max(100)\n .regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]+)+(?::[A-Za-z0-9]+)?$/);\nexport type SpeechVoiceName = z.infer<typeof speechVoiceNameSchema>;\n\nexport const SPEECH_RATE_MIN = -50;\nexport const SPEECH_RATE_MAX = 100;\n\n/** Reading speed: percent faster (+) or slower (−) than normal. */\nexport const speechRateSchema = z.number().int().min(SPEECH_RATE_MIN).max(SPEECH_RATE_MAX);\n\n/**\n * How the account reads aloud. A language left out of `languageVoices`, and a\n * `null` `multilingualVoice`, read in the default voice (`speech.listVoices`\n * names them).\n */\nexport const speechPreferencesSchema = z\n .object({\n languageVoices: z.partialRecord(langCodeISO6393Schema, speechVoiceNameSchema),\n // Reads text whose language is not known, working the language out itself.\n multilingualVoice: speechVoiceNameSchema.nullable(),\n rate: speechRateSchema,\n })\n .strict();\nexport type SpeechPreferences = z.infer<typeof speechPreferencesSchema>;\n\nexport const DEFAULT_SPEECH_PREFERENCES: SpeechPreferences = {\n languageVoices: {},\n multilingualVoice: null,\n rate: 0,\n};\n\n/**\n * Changes some settings and keeps the rest. `languageVoices` changes only the\n * languages it names; `null` puts a language back on its default voice.\n */\nexport const speechPreferencesUpdateInputSchema = z\n .object({\n languageVoices: z\n .partialRecord(langCodeISO6393Schema, speechVoiceNameSchema.nullable())\n .optional(),\n multilingualVoice: speechVoiceNameSchema.nullable().optional(),\n rate: speechRateSchema.optional(),\n })\n .strict();\nexport type SpeechPreferencesUpdateInput = z.infer<typeof speechPreferencesUpdateInputSchema>;\n\nexport const speechVoiceGenderSchema = z.enum([\"female\", \"male\", \"neutral\"]);\nexport type SpeechVoiceGender = z.infer<typeof speechVoiceGenderSchema>;\n\nexport const speechVoiceSchema = z\n .object({\n name: speechVoiceNameSchema,\n // The voice's name for people, such as \"Andrew Multilingual\".\n displayName: z.string(),\n locale: z.string(),\n // The language the voice is for; null for one this list has no code for.\n language: langCodeISO6393Schema.nullable(),\n gender: speechVoiceGenderSchema,\n // Reads many languages, working out the text's language itself.\n multilingual: z.boolean(),\n })\n .strict();\nexport type SpeechVoice = z.infer<typeof speechVoiceSchema>;\n\nexport const speechVoicesOutputSchema = z\n .object({\n voices: z.array(speechVoiceSchema),\n // The voice each language reads in until the reader picks one.\n defaultVoices: z.partialRecord(langCodeISO6393Schema, speechVoiceNameSchema),\n defaultMultilingualVoice: speechVoiceNameSchema,\n })\n .strict();\nexport type SpeechVoicesOutput = z.infer<typeof speechVoicesOutputSchema>;\n\nexport const speechSynthesizeInputSchema = z\n .object({\n text: z.string().trim().min(1).max(SPEECH_TEXT_MAX_LENGTH),\n // The text's language, when the caller knows it; without one, a\n // multilingual voice works it out.\n language: langCodeISO6393Schema.optional(),\n // Reads in this voice instead of the account's, such as one the reader is\n // trying out in the settings.\n voice: speechVoiceNameSchema.optional(),\n })\n .strict();\nexport type SpeechSynthesizeInput = z.infer<typeof speechSynthesizeInputSchema>;\n\n/**\n * Where to download the audio, an MP3: a link to fetch at once, which stops\n * working at `expiresAt`.\n */\nexport const speechSynthesizeOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type SpeechSynthesizeOutput = z.infer<typeof speechSynthesizeOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport {\n speechPreferencesSchema,\n speechPreferencesUpdateInputSchema,\n speechSynthesizeInputSchema,\n speechSynthesizeOutputSchema,\n speechVoicesOutputSchema,\n} from \"#/schemas/speech\";\n\nexport const speechContract = {\n getPreferences: oc\n .route({\n method: \"GET\",\n path: \"/speech/preferences\",\n summary: \"Get how the authenticated user's text is read aloud\",\n tags: [\"Speech\"],\n })\n .output(speechPreferencesSchema),\n updatePreferences: oc\n .route({\n method: \"PATCH\",\n path: \"/speech/preferences\",\n summary: \"Change how the authenticated user's text is read aloud\",\n tags: [\"Speech\"],\n })\n .input(speechPreferencesUpdateInputSchema)\n .output(speechPreferencesSchema),\n listVoices: oc\n .route({\n method: \"GET\",\n path: \"/speech/voices\",\n summary: \"List the voices text can be read aloud in, and each language's default\",\n tags: [\"Speech\"],\n })\n .output(speechVoicesOutputSchema),\n synthesize: oc\n .route({\n method: \"POST\",\n path: \"/speech/synthesize\",\n summary: \"Read a text aloud, and link to its MP3 audio\",\n tags: [\"Speech\"],\n })\n .input(speechSynthesizeInputSchema)\n .output(speechSynthesizeOutputSchema),\n};\n","import { canonicalTimeZone } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\n// @ref https://zenn.dev/herp_inc/articles/js-intl-date-time-format-performance\n// Keyed by the lowercased id, because Intl matches ids case-insensitively: raw\n// keys would let every casing of a zone pin its own entry for the life of the\n// process. Links (Asia/Kolkata) share their canonical zone's formatter (~30 KB\n// of ICU memory each), so the map holds one key per IANA name. Offset zones\n// (\"+08:00\") are valid but stay uncached, because there are ~2.9k of them.\nconst timezoneFormatters = new Map<string, Intl.DateTimeFormat>();\n\n// ASCII only, as Intl does: toLowerCase() would also fold look-alikes such as\n// the Kelvin sign onto \"k\", letting an id Intl rejects hit a cached zone.\nfunction toCacheKey(timezone: string) {\n return timezone.replace(/[A-Z]/g, (letter) => letter.toLowerCase());\n}\n\nfunction getTimezoneFormatter(timezone: string): Intl.DateTimeFormat {\n const key = toCacheKey(timezone);\n const cached = timezoneFormatters.get(key);\n if (cached) {\n return cached;\n }\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n const canonical = formatter.resolvedOptions().timeZone;\n if (canonical.startsWith(\"+\") || canonical.startsWith(\"-\")) {\n return formatter;\n }\n\n const canonicalKey = toCacheKey(canonical);\n const shared = timezoneFormatters.get(canonicalKey) ?? formatter;\n timezoneFormatters.set(canonicalKey, shared).set(key, shared);\n return shared;\n}\n\nexport const timezoneSchema = z\n .string()\n .trim()\n .min(1)\n .refine((timezone) => {\n try {\n getTimezoneFormatter(timezone).format(new Date());\n return true;\n } catch {\n return false;\n }\n }, \"Invalid timezone\");\nexport type Timezone = z.infer<typeof timezoneSchema>;\n\n/**\n * The zone a call reckons days in, under the name an account's zone is stored\n * under (`canonicalTimeZone`): \"Asia/Calcutta\" arrives as \"Asia/Kolkata\" and\n * \"CST\" as \"America/Chicago\", names that Temporal and a Debian Postgres both\n * read. A fixed offset (\"+08:00\") is refused, as Postgres reads it with the\n * opposite sign and would put the call's days on the wrong side of UTC.\n */\nexport const canonicalTimezoneSchema = timezoneSchema.transform((timezone, ctx) => {\n const name = canonicalTimeZone(timezone);\n if (!name) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Use an IANA time zone identifier instead of a fixed UTC offset. See https://www.iana.org/time-zones\",\n });\n return z.NEVER;\n }\n return name;\n});\n","import { paginationShape } from \"./pagination\";\nimport {\n activeScheduleStatusSchema,\n cardStateSchema,\n fsrsReviewLogSnapshotSchema,\n fsrsMemoryStateSchema,\n POSTPONE_DAMAGE_THRESHOLD,\n reviewRatingSchema,\n scheduleStatusSchema,\n schedulingParamsShape,\n schedulingParamsSchema,\n SRS_REVIEW_DURATION_MS_MAX,\n srsStepSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { cardSchema } from \"./card\";\nimport { notebaseSummarySchema } from \"./notebase\";\nimport { canonicalTimezoneSchema } from \"./timezone\";\n\nexport { reviewRatingSchema, schedulingParamsSchema, SRS_REVIEW_DURATION_MS_MAX };\nexport { timezoneSchema } from \"./timezone\";\nexport type { Timezone } from \"./timezone\";\nexport type { ReviewRating, SchedulingParams } from \"@read-frog/definitions\";\n\nexport const stepSchema = srsStepSchema;\nexport type Step = z.infer<typeof stepSchema>;\n\nexport const SRS_REVIEW_CLIENT_ID_NAMESPACE = \"6ba7b811-9dad-11d1-80b4-00c04fd430c8\";\nconst srsReviewClientIdNamePrefix = \"readfrog:srs-review\";\nconst nullLastReviewTimeSentinel = \"null\";\n\nexport interface SrsReviewClientIdCard {\n id: string;\n lastReviewTime: Date | string | null;\n}\n\nexport async function createSrsReviewClientId(card: SrsReviewClientIdCard) {\n return uuidV5(\n `${srsReviewClientIdNamePrefix}:${card.id}:${formatLastReviewTime(card.lastReviewTime)}`,\n SRS_REVIEW_CLIENT_ID_NAMESPACE,\n );\n}\n\nexport const srsReviewInputSchema = z\n .object({\n cardId: z.uuid(),\n id: z.uuid().optional(),\n rating: reviewRatingSchema,\n durationMs: z.number().int().min(0).max(SRS_REVIEW_DURATION_MS_MAX),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsReviewInput = z.infer<typeof srsReviewInputSchema>;\n\nexport const srsRollbackReviewInputSchema = z\n .object({\n expectedReviewId: z.uuid().optional(),\n cardId: z.uuid(),\n })\n .strict();\nexport type SrsRollbackReviewInput = z.infer<typeof srsRollbackReviewInputSchema>;\n\nexport const srsScheduleStatusStatsSchema = z.record(\n activeScheduleStatusSchema,\n z.number().int().min(0),\n);\nexport type SrsScheduleStatusStats = z.infer<typeof srsScheduleStatusStatsSchema>;\n\nexport const srsScheduleStatusStatsInputSchema = z\n .object({\n notebaseIds: z.array(z.uuid()).optional(),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsScheduleStatusStatsInput = z.infer<typeof srsScheduleStatusStatsInputSchema>;\n\nexport const srsScheduleStatusStatsOutputSchema = z.record(z.uuid(), srsScheduleStatusStatsSchema);\nexport type SrsScheduleStatusStatsOutput = z.infer<typeof srsScheduleStatusStatsOutputSchema>;\n\nexport const srsRecentNotebaseScheduleStatusStatsInputSchema = z\n .object({\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsRecentNotebaseScheduleStatusStatsInput = z.infer<\n typeof srsRecentNotebaseScheduleStatusStatsInputSchema\n>;\n\n/** Null when the user has no notebase yet. */\nexport const srsRecentNotebaseScheduleStatusStatsOutputSchema = z\n .object({\n notebase: notebaseSummarySchema,\n stats: srsScheduleStatusStatsSchema,\n })\n .nullable();\nexport type SrsRecentNotebaseScheduleStatusStatsOutput = z.infer<\n typeof srsRecentNotebaseScheduleStatusStatsOutputSchema\n>;\n\nexport const srsManualCardStatusInputSchema = z\n .object({\n cardId: z.uuid(),\n enabled: z.boolean(),\n })\n .strict();\nexport type SrsManualCardStatusInput = z.infer<typeof srsManualCardStatusInputSchema>;\n\nexport const srsSetCardBuriedInputSchema = srsManualCardStatusInputSchema;\nexport type SrsSetCardBuriedInput = SrsManualCardStatusInput;\n\nexport const srsSetCardSuspendedInputSchema = srsManualCardStatusInputSchema;\nexport type SrsSetCardSuspendedInput = SrsManualCardStatusInput;\n\nexport const srsRevlogSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n cardId: z.uuid(),\n rating: reviewRatingSchema,\n state: cardStateSchema,\n stability: z.number(),\n afterScheduleStatus: scheduleStatusSchema,\n afterMemoryState: fsrsMemoryStateSchema,\n retentionDays90: z.number().nonnegative(),\n afterRetentionDays90: z.number().nonnegative(),\n reviewedAt: z.coerce.date(),\n durationMs: z.number().int(),\n fsrsReviewLogSnapshot: fsrsReviewLogSnapshotSchema,\n createdAt: z.coerce.date(),\n});\nexport type SrsRevlog = z.infer<typeof srsRevlogSchema>;\n\nexport const srsRevlogWithoutSnapshotSchema = srsRevlogSchema.omit({\n fsrsReviewLogSnapshot: true,\n});\nexport type SrsRevlogWithoutSnapshot = z.infer<typeof srsRevlogWithoutSnapshotSchema>;\n\nexport const srsListCardRevlogsInputSchema = z\n .object({\n ...paginationShape,\n notebaseId: z.uuid().optional(),\n cardId: z.uuid().optional(),\n })\n .strict();\nexport type SrsListCardRevlogsInput = z.infer<typeof srsListCardRevlogsInputSchema>;\n\nexport const srsListCardRevlogsOutputSchema = z\n .object({\n items: z.array(srsRevlogWithoutSnapshotSchema),\n hasMore: z.boolean(),\n })\n .strict();\nexport type SrsListCardRevlogsOutput = z.infer<typeof srsListCardRevlogsOutputSchema>;\n\nexport const srsReviewOutputSchema = z.object({\n card: cardSchema,\n revlog: srsRevlogSchema,\n // Null for an idempotent replay: it writes nothing, so no shape ever carries\n // its transaction. Wait for the returned card and revlog instead.\n txid: z.number().nullable(),\n // False when an idempotent replay returned an existing revlog instead of creating one.\n created: z.boolean(),\n});\nexport type SrsReviewOutput = z.infer<typeof srsReviewOutputSchema>;\n\nexport const srsRollbackReviewOutputSchema = z.object({\n card: cardSchema,\n rolledBackRevlogId: z.uuid(),\n txid: z.number(),\n});\nexport type SrsRollbackReviewOutput = z.infer<typeof srsRollbackReviewOutputSchema>;\n\nexport const srsTxidOutputSchema = z.object({\n txid: z.number(),\n});\nexport type SrsTxidOutput = z.infer<typeof srsTxidOutputSchema>;\n\nexport const srsSetCardBuriedOutputSchema = srsTxidOutputSchema;\nexport type SrsSetCardBuriedOutput = SrsTxidOutput;\n\nexport const srsSetCardSuspendedOutputSchema = srsTxidOutputSchema;\nexport type SrsSetCardSuspendedOutput = SrsTxidOutput;\n\nexport const srsListUnreadOptimizerResultsInputSchema = z.object({}).strict();\n\nexport const srsOptimizerUnreadResultSchema = z\n .object({\n runId: z.uuid(),\n notebaseName: z.string().min(1),\n revlogCount: z.number().int().positive(),\n improvement: z.number().nonnegative().nullable(),\n })\n .strict();\nexport type SrsOptimizerUnreadResult = z.infer<typeof srsOptimizerUnreadResultSchema>;\n\nexport const srsListUnreadOptimizerResultsOutputSchema = z.array(srsOptimizerUnreadResultSchema);\nexport type SrsListUnreadOptimizerResultsOutput = z.infer<\n typeof srsListUnreadOptimizerResultsOutputSchema\n>;\n\nexport const srsAcknowledgeOptimizerResultsInputSchema = z\n .object({\n runIds: z.array(z.uuid()).min(1),\n })\n .strict();\nexport type SrsAcknowledgeOptimizerResultsInput = z.infer<\n typeof srsAcknowledgeOptimizerResultsInputSchema\n>;\n\nexport const srsAcknowledgeOptimizerResultsOutputSchema = z\n .object({\n acknowledgedCount: z.number().int().nonnegative(),\n })\n .strict();\nexport type SrsAcknowledgeOptimizerResultsOutput = z.infer<\n typeof srsAcknowledgeOptimizerResultsOutputSchema\n>;\n\nfunction formatLastReviewTime(lastReviewTime: Date | string | null) {\n return lastReviewTime ? new Date(lastReviewTime).toISOString() : nullLastReviewTimeSentinel;\n}\n\nasync function uuidV5(name: string, namespace: string) {\n const namespaceBytes = uuidToBytes(namespace);\n const nameBytes = new TextEncoder().encode(name);\n const input = new Uint8Array(namespaceBytes.length + nameBytes.length);\n input.set(namespaceBytes);\n input.set(nameBytes, namespaceBytes.length);\n\n const hash = new Uint8Array(await crypto.subtle.digest(\"SHA-1\", input));\n const bytes = hash.slice(0, 16);\n const versionByte = bytes[6];\n const variantByte = bytes[8];\n if (versionByte === undefined || variantByte === undefined) {\n throw new Error(\"SHA-1 digest was too short\");\n }\n bytes[6] = (versionByte & 0x0f) | 0x50;\n bytes[8] = (variantByte & 0x3f) | 0x80;\n\n return bytesToUuid(bytes);\n}\n\nfunction uuidToBytes(uuid: string) {\n const hex = uuid.replaceAll(\"-\", \"\").toLowerCase();\n /* v8 ignore next 3 -- SRS_REVIEW_CLIENT_ID_NAMESPACE is a fixed valid UUID. */\n if (!/^[0-9a-f]{32}$/.test(hex)) {\n throw new Error(\"Invalid UUID namespace\");\n }\n\n return new Uint8Array(\n Array.from({ length: 16 }, (_, index) =>\n Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16),\n ),\n );\n}\n\nfunction bytesToUuid(bytes: Uint8Array) {\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n return [\n hex.slice(0, 4).join(\"\"),\n hex.slice(4, 6).join(\"\"),\n hex.slice(6, 8).join(\"\"),\n hex.slice(8, 10).join(\"\"),\n hex.slice(10, 16).join(\"\"),\n ].join(\"-\");\n}\n\nconst count = z.number().int().nonnegative();\n\nexport const srsBacklogStatsInputSchema = z\n .object({\n notebaseIds: z.array(z.uuid()).optional(),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsBacklogStatsInput = z.infer<typeof srsBacklogStatsInputSchema>;\n\n/**\n * An Awake notebase with a positive daily review limit whose overdue reviews\n * fill at least `BACKLOG_PROMPT_DAYS.badge` days.\n */\nexport const srsBacklogStatsSchema = z.object({\n overdueReviewCount: count.describe(\n \"Review cards whose due date is before the start of today's study day.\",\n ),\n dailyLimit: z\n .number()\n .int()\n .positive()\n .describe(\n \"The notebase's own daily review limit, which the backlog is measured against. Always positive: a notebase with no daily reviews (0) or an unlimited limit (-1) is never listed.\",\n ),\n backlogDays: z\n .number()\n .nonnegative()\n .describe(\"Days of reviews the backlog fills at that limit: overdueReviewCount / dailyLimit.\"),\n});\nexport type SrsBacklogStats = z.infer<typeof srsBacklogStatsSchema>;\n\n/** Only the notebases that get the badge; the rest are absent. */\nexport const srsBacklogStatsOutputSchema = z.record(z.uuid(), srsBacklogStatsSchema);\nexport type SrsBacklogStatsOutput = z.infer<typeof srsBacklogStatsOutputSchema>;\n\nconst rescheduleDailyLimitSchema = z.number().int().positive();\n\nexport const srsPreviewPostponeInputSchema = z\n .object({\n notebaseId: z.uuid(),\n timezone: canonicalTimezoneSchema,\n dailyLimit: rescheduleDailyLimitSchema.optional(),\n flattenFullRange: z\n .boolean()\n .optional()\n .describe(\"Flatten levels every plannable day (180) instead of only the chart days.\"),\n })\n .strict();\nexport type SrsPreviewPostponeInput = z.infer<typeof srsPreviewPostponeInputSchema>;\n\nconst postponeThresholdSchema = z\n .number()\n .min(POSTPONE_DAMAGE_THRESHOLD.min)\n .max(POSTPONE_DAMAGE_THRESHOLD.max);\n\nconst postponeDaySchema = z.object({\n day: z.number().int().positive(),\n postponed: count,\n rSum: z.number(),\n});\n\nconst rescheduleBaselineDaySchema = z.object({\n day: z.number().int().positive(),\n scheduled: count,\n rSum: z.number().nullable(),\n});\nexport type RescheduleBaselineDay = z.infer<typeof rescheduleBaselineDaySchema>;\n\nexport const spreadDaySchema = z.object({\n day: count,\n scheduled: count,\n backlog: count,\n backlogRSum: z.number(),\n surplusIn: count,\n surplusRSum: z.number(),\n surplusStay: count,\n surplusOut: count,\n});\nexport type SpreadDay = z.infer<typeof spreadDaySchema>;\n\nconst spreadKeptSchema = z.object({\n stuck: count,\n noRoom: count,\n});\n\nexport const flattenStepSchema = z.object({\n checked: z.boolean(),\n fromToday: count,\n fromFuture: count,\n fromDays: count,\n kept: spreadKeptSchema,\n qSuggest: count,\n meanRAfter: z.number(),\n days: z.array(spreadDaySchema),\n /** Cards Postpone already moved that this Flatten moves again, and their R under Postpone. */\n postponedAgain: z.object({ count, rSum: z.number() }),\n});\nexport type FlattenStep = z.infer<typeof flattenStepSchema>;\n\n/** One threshold's Postpone alone, before its Flatten option is attached. */\nexport const postponeSummarySchema = z.object({\n threshold: postponeThresholdSchema,\n moved: count,\n overflowToday: count,\n meanRiBefore: z.number(),\n meanRAfter: z.number(),\n days: z.array(postponeDaySchema),\n});\nexport type PostponeSummary = z.infer<typeof postponeSummarySchema>;\n\nexport const postponeStepSchema = postponeSummarySchema.extend({\n flatten: flattenStepSchema.nullable(),\n});\nexport type PostponeStep = z.infer<typeof postponeStepSchema>;\n\nexport const postponePlanSchema = z.object({\n planId: z.string(),\n limit: z.number().int().positive(),\n steps: z.array(postponeStepSchema),\n skipped: z.object({\n belowFloor: count,\n maxInterval: count,\n invalid: count,\n }),\n});\nexport type PostponePlanSummary = z.infer<typeof postponePlanSchema>;\n\nconst rescheduleReadySchema = z.object({\n status: z.literal(\"ready\"),\n expiresAt: z.date(),\n q: z.number().int().positive(),\n qConfigured: schedulingParamsShape.reviewsPerDay,\n qMax: z.number().int().positive(),\n overdueReviewCount: count,\n dueTodayReviewCount: count,\n usedToday: count,\n});\n\nexport const srsPreviewPostponeOutputSchema = z.discriminatedUnion(\"status\", [\n rescheduleReadySchema.extend({\n plan: postponePlanSchema,\n suggested: postponePlanSchema.nullable(),\n baseline: z.array(rescheduleBaselineDaySchema),\n }),\n z.object({ status: z.literal(\"quotaZero\") }),\n z.object({ status: z.literal(\"invalidWeights\") }),\n]);\nexport type SrsPreviewPostponeOutput = z.infer<typeof srsPreviewPostponeOutputSchema>;\n\nconst rescheduleApplyInputSchema = z.object({\n notebaseId: z.uuid(),\n planId: z.string().min(1),\n unlimited: z.boolean().optional(),\n});\n\nexport const srsApplyPostponeInputSchema = rescheduleApplyInputSchema\n .extend({\n threshold: postponeThresholdSchema,\n flatten: z.boolean().optional(),\n })\n .strict();\nexport type SrsApplyPostponeInput = z.infer<typeof srsApplyPostponeInputSchema>;\n\nexport const srsRescheduleApplyOutputSchema = z.object({\n moved: count,\n txid: z.number().nullable(),\n reviewsPerDay: schedulingParamsShape.reviewsPerDay,\n});\nexport type SrsRescheduleApplyOutput = z.infer<typeof srsRescheduleApplyOutputSchema>;\nexport const srsApplyPostponeOutputSchema = srsRescheduleApplyOutputSchema;\nexport type SrsApplyPostponeOutput = z.infer<typeof srsApplyPostponeOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n srsAcknowledgeOptimizerResultsInputSchema,\n srsAcknowledgeOptimizerResultsOutputSchema,\n srsListCardRevlogsInputSchema,\n srsListCardRevlogsOutputSchema,\n srsListUnreadOptimizerResultsInputSchema,\n srsListUnreadOptimizerResultsOutputSchema,\n srsRecentNotebaseScheduleStatusStatsInputSchema,\n srsRecentNotebaseScheduleStatusStatsOutputSchema,\n srsReviewInputSchema,\n srsReviewOutputSchema,\n srsRollbackReviewInputSchema,\n srsRollbackReviewOutputSchema,\n srsScheduleStatusStatsInputSchema,\n srsScheduleStatusStatsOutputSchema,\n srsSetCardBuriedInputSchema,\n srsSetCardBuriedOutputSchema,\n srsSetCardSuspendedInputSchema,\n srsSetCardSuspendedOutputSchema,\n srsApplyPostponeInputSchema,\n srsApplyPostponeOutputSchema,\n srsPreviewPostponeInputSchema,\n srsPreviewPostponeOutputSchema,\n} from \"#/schemas/srs\";\n\nexport const srsContract = {\n scheduleStatusStats: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/schedule-status-stats\",\n summary: \"Get study statistics\",\n description:\n \"Read existing study queue counts for owned notebases in the supplied timezone. Does not return note content or card faces.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(srsScheduleStatusStatsInputSchema)\n .output(srsScheduleStatusStatsOutputSchema),\n recentNotebaseScheduleStatusStats: oc\n .route({\n method: \"GET\",\n path: \"/srs/schedule-status-stats/recent\",\n summary: \"Get study queue counts of the most recently used notebase\",\n description:\n \"Picks the owned notebase with the latest review or content edit (notes, fields or templates) and returns its study queue counts in the supplied timezone.\",\n tags: [\"SRS\"],\n })\n .input(srsRecentNotebaseScheduleStatusStatsInputSchema)\n .output(srsRecentNotebaseScheduleStatusStatsOutputSchema),\n listUnreadOptimizerResults: oc\n .route({\n method: \"GET\",\n path: \"/srs/optimizer-results/unread\",\n summary: \"List unread applied SRS optimizer results\",\n tags: [\"SRS\"],\n })\n .input(srsListUnreadOptimizerResultsInputSchema)\n .output(srsListUnreadOptimizerResultsOutputSchema),\n\n acknowledgeOptimizerResults: oc\n .route({\n method: \"POST\",\n path: \"/srs/optimizer-results/acknowledge\",\n summary: \"Acknowledge current SRS optimizer results\",\n tags: [\"SRS\"],\n })\n .input(srsAcknowledgeOptimizerResultsInputSchema)\n .output(srsAcknowledgeOptimizerResultsOutputSchema),\n\n listCardRevlogs: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/revlogs\",\n summary: \"List review history\",\n description:\n \"Read owned review records, optionally filtered by notebase or card. Supports limit and offset pagination. Note content, card faces and rollback snapshots are excluded.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\", \"NOTEBASE_NOT_FOUND\"))\n .input(srsListCardRevlogsInputSchema)\n .output(srsListCardRevlogsOutputSchema),\n\n review: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/review\",\n summary: \"Record review\",\n description:\n \"Submit one rating for a known owned card without a queue, session or prerequisite read. Existing SRS eligibility, scheduling and sibling rules apply. The optional id is the existing state-derived review ID, not an arbitrary UUID; calls without a stable id are not guaranteed to deduplicate.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\", \"CARD_NOT_REVIEWABLE\", \"CARD_REVIEW_STATE_STALE\"))\n .input(srsReviewInputSchema)\n .output(srsReviewOutputSchema),\n rollbackReview: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/review/rollback\",\n summary: \"Undo review\",\n description:\n \"Undo the latest eligible review of one owned card, preserving existing SRS restrictions and sibling restoration. expectedReviewId guards against undoing an earlier review on a retry.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_REVIEW_ROLLBACK_UNAVAILABLE\",\n \"CARD_REVIEW_STATE_STALE\",\n ),\n )\n .input(srsRollbackReviewInputSchema)\n .output(srsRollbackReviewOutputSchema),\n setCardBuried: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/card/bury\",\n summary: \"Set card buried\",\n description:\n \"Bury or unbury one owned card. enabled=true buries and enabled=false unburies it. Existing state-change rules apply.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_ALREADY_BURIED\",\n \"CARD_NOT_BURIED\",\n \"CARD_STATUS_CHANGE_UNAVAILABLE\",\n ),\n )\n .input(srsSetCardBuriedInputSchema)\n .output(srsSetCardBuriedOutputSchema),\n setCardSuspended: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/card/suspend\",\n summary: \"Set card suspended\",\n description:\n \"Suspend or resume one owned card. enabled=true suspends and enabled=false resumes it. Existing state-change rules apply.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_ALREADY_SUSPENDED\",\n \"CARD_NOT_SUSPENDED\",\n \"CARD_STATUS_CHANGE_UNAVAILABLE\",\n ),\n )\n .input(srsSetCardSuspendedInputSchema)\n .output(srsSetCardSuspendedOutputSchema),\n\n previewPostpone: oc\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"RESCHEDULE_PREVIEW_TIMEOUT\",\n \"RESCHEDULE_DAILY_LIMIT_INVALID\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/srs/postpone/preview\",\n summary: \"Preview postpone\",\n tags: [\"SRS\"],\n })\n .input(srsPreviewPostponeInputSchema)\n .output(srsPreviewPostponeOutputSchema),\n\n applyPostpone: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"RESCHEDULE_PLAN_EXPIRED\", \"RESCHEDULE_STALE\"))\n .route({\n method: \"POST\",\n path: \"/srs/postpone\",\n summary: \"Apply postpone\",\n tags: [\"SRS\"],\n })\n .input(srsApplyPostponeInputSchema)\n .output(srsApplyPostponeOutputSchema),\n};\n","import { z } from \"zod\";\n\nexport const notebaseActivityStatsItemSchema = z\n .object({\n date: z.iso.date(),\n notes: z.number().int().nonnegative(),\n })\n .strict();\nexport type NotebaseActivityStatsItem = z.infer<typeof notebaseActivityStatsItemSchema>;\n\nexport const notebaseActivityStatsOutputSchema = z\n .object({\n daily: z.array(notebaseActivityStatsItemSchema),\n })\n .strict();\nexport type NotebaseActivityStatsOutput = z.infer<typeof notebaseActivityStatsOutputSchema>;\n\nexport const notebaseRowGrowthStatsItemSchema = z\n .object({\n date: z.iso.date(),\n delta: z.number().int(),\n })\n .strict();\nexport type NotebaseRowGrowthStatsItem = z.infer<typeof notebaseRowGrowthStatsItemSchema>;\n\nexport const notebaseRowGrowthStatsOutputSchema = z\n .object({\n baseTotal: z.number().int().nonnegative(),\n daily: z.array(notebaseRowGrowthStatsItemSchema),\n })\n .strict();\nexport type NotebaseRowGrowthStatsOutput = z.infer<typeof notebaseRowGrowthStatsOutputSchema>;\n","import { z } from \"zod\";\n\nexport const srsActivityStatsItemSchema = z\n .object({\n date: z.iso.date(),\n answers: z.number().int().nonnegative(),\n durationMs: z.number().int().nonnegative(),\n })\n .strict();\nexport type SrsActivityStatsItem = z.infer<typeof srsActivityStatsItemSchema>;\n\nexport const srsActivityStatsOutputSchema = z\n .object({\n learnedCards: z.number().int().nonnegative(),\n daily: z.array(srsActivityStatsItemSchema),\n })\n .strict();\nexport type SrsActivityStatsOutput = z.infer<typeof srsActivityStatsOutputSchema>;\n\nexport const srsMemoryGrowthStatsItemSchema = z\n .object({\n date: z.iso.date(),\n delta: z.number().int(),\n })\n .strict();\nexport type SrsMemoryGrowthStatsItem = z.infer<typeof srsMemoryGrowthStatsItemSchema>;\n\nexport const srsMemoryGrowthStatsOutputSchema = z\n .object({\n baseTotal: z.number().int().nonnegative(),\n daily: z.array(srsMemoryGrowthStatsItemSchema),\n })\n .strict();\nexport type SrsMemoryGrowthStatsOutput = z.infer<typeof srsMemoryGrowthStatsOutputSchema>;\n","import { z } from \"zod\";\nimport { notebaseActivityStatsOutputSchema } from \"./notebase-stats\";\nimport { srsActivityStatsOutputSchema } from \"./srs-stats\";\nimport { canonicalTimezoneSchema } from \"./timezone\";\n\nconst statsNotebaseIdsSchema = z\n .array(z.uuid())\n .min(1)\n .transform((ids) => Array.from(new Set(ids)));\n\nexport const statsInputSchema = z\n .object({\n notebaseIds: statsNotebaseIdsSchema.optional(),\n from: z.iso.date().optional(),\n to: z.iso.date(),\n timezone: canonicalTimezoneSchema,\n })\n .strict()\n .refine((input) => !input.from || input.from <= input.to, {\n message: \"from must be before or equal to to\",\n path: [\"from\"],\n });\nexport type StatsInput = z.infer<typeof statsInputSchema>;\n\nexport const activityStatsOutputSchema = z\n .object({\n srs: srsActivityStatsOutputSchema,\n notebase: notebaseActivityStatsOutputSchema,\n })\n .strict();\nexport type ActivityStatsOutput = z.infer<typeof activityStatsOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport { notebaseRowGrowthStatsOutputSchema } from \"#/schemas/notebase-stats\";\nimport { srsBacklogStatsInputSchema, srsBacklogStatsOutputSchema } from \"#/schemas/srs\";\nimport { srsMemoryGrowthStatsOutputSchema } from \"#/schemas/srs-stats\";\nimport { activityStatsOutputSchema, statsInputSchema } from \"#/schemas/stats\";\n\nexport const statsContract = {\n activity: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/stats/activity\",\n summary: \"Get SRS and notebase activity statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(activityStatsOutputSchema),\n\n srsMemoryGrowth: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/srs/stats/memory-growth\",\n summary: \"Get SRS long-term memory growth statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(srsMemoryGrowthStatsOutputSchema),\n\n notebaseRowGrowth: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/notebases/stats/row-growth\",\n summary: \"Get notebase row growth statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(notebaseRowGrowthStatsOutputSchema),\n\n // A statistic like the rest, so reviews, which invalidate every `stats` query,\n // mark it stale too.\n backlogStats: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/stats/backlog\",\n summary: \"Get review backlogs\",\n description:\n \"Read overdue review backlogs for owned awake notebases in the supplied timezone. Only a notebase whose overdue reviews fill two or more days of its daily review limit is listed; the rest are left out. A notebase whose daily review limit is 0 or unlimited (-1) never returns anything, even when its ID is requested. Does not return note content or card faces.\",\n tags: [\"Statistics\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(srsBacklogStatsInputSchema)\n .output(srsBacklogStatsOutputSchema),\n};\n","import { z } from \"zod\";\n\n// What the web app reports about keeping its Electric data live. Every field is\n// an enum, so each label the API counts them under has a fixed set of values.\n\n/** The shapes the web app syncs, by their names in `@repo/electric-contract`. */\nexport const webSyncShapeSchema = z.enum([\n \"notebases\",\n \"notebaseColumns\",\n \"notebaseRows\",\n \"cardTemplates\",\n \"cards\",\n \"revlogs\",\n \"mediaAssets\",\n]);\nexport type WebSyncShape = z.infer<typeof webSyncShapeSchema>;\n\n/** The write whose change the page waited to see come back over Electric. */\nexport const webSyncOperationSchema = z.enum([\n // The review session's own writes.\n \"review\",\n // A review the server had already recorded: it waits for that review's card\n // and revlog, as its own transaction wrote nothing.\n \"reviewReplay\",\n \"undo\",\n \"bury\",\n \"suspend\",\n \"deleteNote\",\n \"deleteCard\",\n // A synced collection's own mutation handlers.\n \"insert\",\n \"update\",\n \"delete\",\n // Other writes that wait for their change.\n \"setSleep\",\n \"srsSettings\",\n \"cardStatus\",\n \"createTemplate\",\n \"updateTemplate\",\n]);\nexport type WebSyncOperation = z.infer<typeof webSyncOperationSchema>;\n\n/** How the shape that lagged was receiving live changes. */\nexport const webSyncTransportSchema = z.enum([\"sse\", \"longPoll\"]);\nexport type WebSyncTransport = z.infer<typeof webSyncTransportSchema>;\n\n/**\n * A write wait is only reported once its first wait ran out: `recovered` when\n * reconnecting the lagging shapes brought the change, `failed` when the page\n * gave up on it.\n */\nexport const webSyncWriteOutcomeSchema = z.enum([\"recovered\", \"failed\"]);\nexport type WebSyncWriteOutcome = z.infer<typeof webSyncWriteOutcomeSchema>;\n\nexport const webSyncStreamErrorTypeSchema = z.enum([\n // 401: the session ended.\n \"unauthorized\",\n // 403: the notebase was deleted, or is someone else's.\n \"forbidden\",\n // 400 and any other 4xx.\n \"badRequest\",\n \"clientError\",\n // A response without Electric's headers: a proxy or CORS in the way.\n \"missingHeaders\",\n // Anything that is not an HTTP status: an unreadable body, a parse error.\n \"unexpected\",\n]);\nexport type WebSyncStreamErrorType = z.infer<typeof webSyncStreamErrorTypeSchema>;\n\n/** `initial` before the shape first loaded, when the page shows the error at once. */\nexport const webSyncStreamPhaseSchema = z.enum([\"initial\", \"live\"]);\nexport type WebSyncStreamPhase = z.infer<typeof webSyncStreamPhaseSchema>;\n\nexport const webSyncPageSchema = z.enum([\"reviewCombined\", \"reviewNotebase\"]);\nexport type WebSyncPage = z.infer<typeof webSyncPageSchema>;\n\nexport const webSyncUnavailableReasonSchema = z.enum([\n // A write's change never came back, even after reconnecting.\n \"syncTimeout\",\n // A shape stream stopped.\n \"streamFailed\",\n // The notebase is gone: its shapes answer 403.\n \"notebaseGone\",\n]);\nexport type WebSyncUnavailableReason = z.infer<typeof webSyncUnavailableReasonSchema>;\n\nexport const webSyncEventSchema = z.discriminatedUnion(\"type\", [\n z\n .object({\n type: z.literal(\"writeWait\"),\n operation: webSyncOperationSchema,\n outcome: webSyncWriteOutcomeSchema,\n transport: webSyncTransportSchema,\n })\n .strict(),\n z\n .object({\n type: z.literal(\"streamError\"),\n shape: webSyncShapeSchema,\n errorType: webSyncStreamErrorTypeSchema,\n phase: webSyncStreamPhaseSchema,\n })\n .strict(),\n z\n .object({\n type: z.literal(\"unavailable\"),\n page: webSyncPageSchema,\n reason: webSyncUnavailableReasonSchema,\n })\n .strict(),\n]);\nexport type WebSyncEvent = z.infer<typeof webSyncEventSchema>;\n\n/** A page sends what happened within a second or so as one batch. */\nexport const WEB_SYNC_REPORT_MAX_EVENTS = 20;\n\nexport const reportWebSyncInputSchema = z\n .object({\n events: z.array(webSyncEventSchema).min(1).max(WEB_SYNC_REPORT_MAX_EVENTS),\n })\n .strict();\nexport type ReportWebSyncInput = z.infer<typeof reportWebSyncInputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport { reportWebSyncInputSchema } from \"#/schemas/web-sync\";\n\nexport const telemetryContract = {\n // Public: a page whose session ended still reports the streams that failed\n // because of it.\n reportWebSync: oc\n .route({\n method: \"POST\",\n path: \"/telemetry/web-sync\",\n summary: \"Report problems the web app had keeping its synced data live\",\n tags: [\"Telemetry\"],\n })\n .input(reportWebSyncInputSchema)\n .output(z.void()),\n};\n","import { z } from \"zod\";\nimport { appLocaleSchema } from \"./app-locale\";\nimport { timezoneSchema } from \"./timezone\";\n\nexport const userEnsureTimezoneInputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserEnsureTimezoneInput = z.infer<typeof userEnsureTimezoneInputSchema>;\n\nexport const userEnsureTimezoneOutputSchema = z\n .object({\n timezone: timezoneSchema,\n updated: z.boolean(),\n })\n .strict();\nexport type UserEnsureTimezoneOutput = z.infer<typeof userEnsureTimezoneOutputSchema>;\n\nexport const userUpdateTimezoneInputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserUpdateTimezoneInput = z.infer<typeof userUpdateTimezoneInputSchema>;\n\nexport const userUpdateTimezoneOutputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserUpdateTimezoneOutput = z.infer<typeof userUpdateTimezoneOutputSchema>;\n\n// The account's language, which emails are written in. `ensureLocale` only\n// fills it in when it is empty (the language www is showing on a signed-in\n// visit); `updateLocale` is the user choosing a language.\nexport const userEnsureLocaleInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserEnsureLocaleInput = z.infer<typeof userEnsureLocaleInputSchema>;\n\nexport const userEnsureLocaleOutputSchema = z\n .object({\n locale: appLocaleSchema,\n updated: z.boolean(),\n })\n .strict();\nexport type UserEnsureLocaleOutput = z.infer<typeof userEnsureLocaleOutputSchema>;\n\nexport const userUpdateLocaleInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserUpdateLocaleInput = z.infer<typeof userUpdateLocaleInputSchema>;\n\nexport const userUpdateLocaleOutputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserUpdateLocaleOutput = z.infer<typeof userUpdateLocaleOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport {\n userEnsureLocaleInputSchema,\n userEnsureLocaleOutputSchema,\n userEnsureTimezoneInputSchema,\n userEnsureTimezoneOutputSchema,\n userUpdateLocaleInputSchema,\n userUpdateLocaleOutputSchema,\n userUpdateTimezoneInputSchema,\n userUpdateTimezoneOutputSchema,\n} from \"#/schemas/user\";\n\nexport const userContract = {\n ensureTimezone: oc\n .route({\n method: \"POST\",\n path: \"/users/me/timezone/ensure\",\n summary: \"Ensure the authenticated user has a timezone\",\n tags: [\"Users\"],\n })\n .input(userEnsureTimezoneInputSchema)\n .output(userEnsureTimezoneOutputSchema),\n updateTimezone: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/timezone\",\n summary: \"Update the authenticated user's timezone\",\n tags: [\"Users\"],\n })\n .input(userUpdateTimezoneInputSchema)\n .output(userUpdateTimezoneOutputSchema),\n ensureLocale: oc\n .route({\n method: \"POST\",\n path: \"/users/me/locale/ensure\",\n summary: \"Ensure the authenticated user has a locale\",\n tags: [\"Users\"],\n })\n .input(userEnsureLocaleInputSchema)\n .output(userEnsureLocaleOutputSchema),\n updateLocale: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/locale\",\n summary: \"Update the authenticated user's locale\",\n tags: [\"Users\"],\n })\n .input(userUpdateLocaleInputSchema)\n .output(userUpdateLocaleOutputSchema),\n};\n","import { getVideoIdFromUrl, transcriptSegmentSchema } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { billingPlanSchema } from \"./billing\";\n\nexport const videoTranscriptStatusSchema = z.enum([\"pending\", \"processing\", \"completed\", \"failed\"]);\nexport type VideoTranscriptStatus = z.infer<typeof videoTranscriptStatusSchema>;\n\n// The transcript \"job\" resource: status + metadata, without the (heavy) segments payload.\nexport const videoTranscriptResourceSchema = z.object({\n id: z.string(),\n platform: z.string(),\n videoId: z.string(),\n url: z.string(),\n status: videoTranscriptStatusSchema,\n title: z.string().nullable(),\n durationSec: z.number().nullable(),\n detectedLanguage: z.string().nullable(),\n error: z.string().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\nexport type VideoTranscriptResource = z.infer<typeof videoTranscriptResourceSchema>;\n\n// The subtitles sub-resource: the segments + model-detected language, only available once completed.\nexport const videoTranscriptSubtitlesSchema = z.object({\n id: z.string(),\n detectedLanguage: z.string().nullable(),\n segments: z.array(transcriptSegmentSchema),\n});\nexport type VideoTranscriptSubtitles = z.infer<typeof videoTranscriptSubtitlesSchema>;\n\nexport const videoTranscriptCreateInputSchema = z\n .object({\n url: z.url().refine((url) => getVideoIdFromUrl(url) !== null, {\n message: \"url must be a supported video URL\",\n }),\n // The player's own duration, read from the media element. REQUIRED, and an\n // untrusted UX hint only: admission uses it to reject an over-quota request\n // instantly, but every reservation and charge is made against the\n // server-measured duration in the worker — lying here changes nothing about\n // what gets billed.\n durationSec: z.number().int().positive(),\n })\n .strict();\nexport type VideoTranscriptCreateInput = z.infer<typeof videoTranscriptCreateInputSchema>;\n\nexport const videoTranscriptGetInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type VideoTranscriptGetInput = z.infer<typeof videoTranscriptGetInputSchema>;\n\n// One quota pool as shown to the user. `resetAt` is null for a one-time grant\n// (it never resets); `expiresAt` is null for a monthly pool (its end is the\n// reset). Minutes are display units: `usedMinutes` rounds up and\n// `limitMinutes` rounds down, so the UI can never show headroom that\n// admission (which compares raw seconds) would deny.\nexport const videoTranscriptUsagePoolSchema = z.object({\n id: z.string(),\n usedMinutes: z.number().int(),\n limitMinutes: z.number().int(),\n remainingMinutes: z.number().int(),\n resetAt: z.iso.datetime().nullable(),\n expiresAt: z.iso.datetime().nullable(),\n});\nexport type VideoTranscriptUsagePool = z.infer<typeof videoTranscriptUsagePoolSchema>;\n\n// The caller's transcription quota usage. Totals aggregate across pools;\n// `remainingMinutes` nets out in-flight reservations (committed), while each\n// pool's `usedMinutes` shows settled spend only, so a progress bar cannot run\n// forward and then backwards when a job is released. Deliberately a non-strict\n// object: old clients strip the keys they don't know.\nexport const videoTranscriptUsageSchema = z.object({\n usedMinutes: z.number().int(),\n limitMinutes: z.number().int(),\n remainingMinutes: z.number().int(),\n plan: billingPlanSchema,\n pools: z.array(videoTranscriptUsagePoolSchema),\n});\nexport type VideoTranscriptUsage = z.infer<typeof videoTranscriptUsageSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n videoTranscriptCreateInputSchema,\n videoTranscriptGetInputSchema,\n videoTranscriptResourceSchema,\n videoTranscriptSubtitlesSchema,\n videoTranscriptUsageSchema,\n} from \"#/schemas/video-transcript\";\n\nexport const videoTranscriptContract = {\n create: oc\n .errors(\n pickPublicErrorMap(\n \"VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED\",\n \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\",\n \"VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED\",\n \"VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/video-transcripts\",\n summary: \"Create or reuse a video transcription job\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptCreateInputSchema)\n .output(videoTranscriptResourceSchema),\n getUsage: oc\n .route({\n method: \"GET\",\n path: \"/video-transcripts/usage\",\n summary: \"Get the caller's monthly transcription quota usage\",\n tags: [\"Video Transcription\"],\n })\n .output(videoTranscriptUsageSchema),\n get: oc\n .errors(\n pickPublicErrorMap(\"VIDEO_TRANSCRIPT_NOT_FOUND\", \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\"),\n )\n .route({\n method: \"GET\",\n path: \"/video-transcripts/{id}\",\n summary: \"Get a video transcription job's status\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptGetInputSchema)\n .output(videoTranscriptResourceSchema),\n getSubtitles: oc\n .errors(\n pickPublicErrorMap(\n \"VIDEO_TRANSCRIPT_NOT_FOUND\",\n \"VIDEO_TRANSCRIPT_NOT_READY\",\n \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\",\n ),\n )\n .route({\n method: \"GET\",\n path: \"/video-transcripts/{id}/subtitles\",\n summary: \"Get a completed video transcript's subtitles\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptGetInputSchema)\n .output(videoTranscriptSubtitlesSchema),\n};\n","import type { ContractRouterClient } from \"@orpc/contract\";\nimport { billingContract } from \"./contracts/billing\";\nimport { cardContract } from \"./contracts/card\";\nimport { cardTemplateContract } from \"./contracts/card-template\";\nimport { ebookContract } from \"./contracts/ebook\";\nimport { emailPreferencesContract } from \"./contracts/email-preferences\";\nimport { featureAccessContract } from \"./contracts/feature-access\";\nimport { hostedAiContract } from \"./contracts/hosted-ai\";\nimport { masteryGoalContract } from \"./contracts/mastery-goal\";\nimport { mcpConnectionContract } from \"./contracts/mcp-connection\";\nimport { mediaContract } from \"./contracts/media\";\nimport { notebaseContract } from \"./contracts/notebase\";\nimport { notebaseColumnContract } from \"./contracts/notebase-column\";\nimport { notebaseRowContract } from \"./contracts/notebase-row\";\nimport { pdfTranslationContract } from \"./contracts/pdf-translation\";\nimport { speechContract } from \"./contracts/speech\";\nimport { srsContract } from \"./contracts/srs\";\nimport { statsContract } from \"./contracts/stats\";\nimport { telemetryContract } from \"./contracts/telemetry\";\nimport { userContract } from \"./contracts/user\";\nimport { videoTranscriptContract } from \"./contracts/video-transcript\";\n\nexport const contract = {\n billing: billingContract,\n card: cardContract,\n cardTemplate: cardTemplateContract,\n ebook: ebookContract,\n emailPreferences: emailPreferencesContract,\n featureAccess: featureAccessContract,\n hostedAi: hostedAiContract,\n masteryGoal: masteryGoalContract,\n mcpConnection: mcpConnectionContract,\n media: mediaContract,\n notebase: notebaseContract,\n notebaseColumn: notebaseColumnContract,\n notebaseRow: notebaseRowContract,\n pdfTranslation: pdfTranslationContract,\n speech: speechContract,\n srs: srsContract,\n stats: statsContract,\n telemetry: telemetryContract,\n user: userContract,\n videoTranscript: videoTranscriptContract,\n};\n\nexport type ORPCRouterClient = ContractRouterClient<typeof contract>;\n\nexport { type AgentRoute, defineAgentProcedure } from \"./contracts/shared\";\nexport * from \"./public-errors\";\nexport * from \"./schemas/app-locale\";\nexport * from \"./schemas/billing\";\nexport * from \"./schemas/card\";\nexport * from \"./schemas/ebook\";\nexport * from \"./schemas/email-preferences\";\nexport * from \"./schemas/feature-access\";\nexport * from \"./schemas/hosted-ai\";\nexport * from \"./schemas/media\";\nexport * from \"./schemas/mastery-goal\";\nexport * from \"./schemas/mcp-connection\";\nexport * from \"./schemas/notebase\";\nexport * from \"./schemas/notebase-column\";\nexport * from \"./schemas/notebase-row\";\nexport * from \"./schemas/notebase-stats\";\nexport * from \"./schemas/notebase-view\";\nexport * from \"./schemas/pdf-translation\";\nexport * from \"./schemas/speech\";\nexport * from \"./schemas/srs\";\nexport * from \"./schemas/srs-stats\";\nexport * from \"./schemas/stats\";\nexport * from \"./schemas/timezone\";\nexport * from \"./schemas/user\";\nexport * from \"./schemas/video-transcript\";\nexport * from \"./schemas/web-sync\";\n\nexport * from \"./schemas/pagination\";\nexport * from \"./schemas/resource-mutation\";\n"],"mappings":";;;;;;;;;AAOA,MAAa,kBAAkB,EAAE,KAAK;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;CAAM;AAAO,CAAC;;ACF/F,MAAa,wBAAwB,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;AAG7D,MAAa,kCAAkC,EAAE,KAAK;CACpD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAQ;CAAO;AAAO,CAAC;;;;;;;;;;;AAahE,MAAa,wBAAwB;CACnC,MAAM;CACN,KAAK;CACL,OAAO;AACT;;;;;;;;;;;AAYA,MAAa,sBAAsB;CACjC,MAAM;CACN,KAAK;CACL,OAAO;AACT;AAGA,MAAa,4BAA4B,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC;AAGhE,MAAa,wBAAwB,EAAE,KAAK;CAAC;CAAO;CAAO;AAAK,CAAC;AAKjE,MAAa,sBAAsB;AAGnC,MAAa,4BAA4B,EAAE,KAAK,CAAC,gBAAgB,MAAM,CAAC;AAGxE,MAAa,+BAA+B,EACzC,OAAO;CACN,MAAM;CACN,UAAU;CACV,aAAa,EAAE,OAAO,KAAK;AAC7B,CAAC,CAAC,CACD,OAAO;;;;;;AAQV,MAAa,gCAAgC;;;;;;AAO7C,MAAa,0BAA0B,EACpC,OAAO;;CAEN,OAAO,EAAE,OAAO,KAAK;;;;;CAKrB,MAAM;;CAEN,KAAK,EAAE,IAAI,CAAC,CAAC,SAAS;AACxB,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,sBAAsB,EAChC,OAAO;CACN,MAAM;CACN,QAAQ,gCAAgC,SAAS;CACjD,UAAU,sBAAsB,SAAS;CACzC,kBAAkB,EAAE,OAAO,KAAK,CAAC,CAAC,SAAS;;;;;;;CAO3C,UAAU,EAAE,OAAO,KAAK,C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CACA,wCACA,wCACF,CACF,CAAC,CACA,MAAM;GACL,QAAQ;GACR,MAAM;GACN,SAAS;GACT,MAAM,CAAC,qBAAqB;EAC9B,CAAC,CAAC,CACD,MAAM,gCAAgC,CAAC,CACvC,OAAO,6BAA6B;EACvC,UAAU,GACP,MAAM;GACL,QAAQ;GACR,MAAM;GACN,SAAS;GACT,MAAM,CAAC,qBAAqB;EAC9B,CAAC,CAAC,CACD,OAAO,0BAA0B;EACpC,KAAK,GACF,OACC,mBAAmB,8BAA8B,2CAA2C,CAC9F,CAAC,CACA,MAAM;GACL,QAAQ;GACR,MAAM;GACN,SAAS;GACT,MAAM,CAAC,qBAAqB;EAC9B,CAAC,CAAC,CACD,MAAM,6BAA6B,CAAC,CACpC,OAAO,6BAA6B;EACvC,cAAc,GACX,OACC,mBACE,8BACA,8BACA,2CACF,CACF,CAAC,CACA,MAAM;GACL,QAAQ;GACR,MAAM;GACN,SAAS;GACT,MAAM,CAAC,qBAAqB;EAC9B,CAAC,CAAC,CACD,MAAM,6BAA6B,CAAC,CACpC,OAAO,8BAA8B;CCrBvB;AACnB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["cardStateSchema","scheduleStatusSchema"],"sources":["../src/schemas/app-locale.ts","../src/schemas/billing.ts","../src/schemas/hosted-ai.ts","../src/schemas/pdf-translation.ts","../src/public-errors.ts","../src/contracts/billing.ts","../src/contracts/shared.ts","../src/schemas/pagination.ts","../src/schemas/resource-mutation.ts","../src/schemas/card.ts","../src/contracts/card.ts","../src/contracts/card-template.ts","../src/schemas/ebook.ts","../src/contracts/ebook.ts","../src/schemas/email-preferences.ts","../src/contracts/email-preferences.ts","../src/schemas/feature-access.ts","../src/contracts/feature-access.ts","../src/contracts/hosted-ai.ts","../src/schemas/mastery-goal.ts","../src/contracts/mastery-goal.ts","../src/schemas/mcp-connection.ts","../src/contracts/mcp-connection.ts","../src/schemas/media.ts","../src/contracts/media.ts","../src/schemas/notebase-column.ts","../src/schemas/notebase-row.ts","../src/schemas/notebase-view.ts","../src/schemas/notebase.ts","../src/contracts/notebase.ts","../src/contracts/notebase-column.ts","../src/contracts/notebase-row.ts","../src/contracts/pdf-translation.ts","../src/schemas/speech.ts","../src/contracts/speech.ts","../src/schemas/timezone.ts","../src/schemas/srs.ts","../src/contracts/srs.ts","../src/schemas/notebase-stats.ts","../src/schemas/srs-stats.ts","../src/schemas/stats.ts","../src/contracts/stats.ts","../src/schemas/web-sync.ts","../src/contracts/telemetry.ts","../src/schemas/user.ts","../src/contracts/user.ts","../src/schemas/video-transcript.ts","../src/contracts/video-transcript.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * The languages the website is in (`project.inlang/settings.json`; a test in\n * apps/www keeps the two in step). Used wherever the server writes for a\n * person: Stripe pages, emails, and the account's `locale`.\n */\nexport const appLocaleSchema = z.enum([\"en\", \"es\", \"ja\", \"ko\", \"ru\", \"tr\", \"vi\", \"zh\", \"zh-TW\"]);\nexport type AppLocale = z.infer<typeof appLocaleSchema>;\n","import type { AppLocale } from \"./app-locale\";\nimport { z } from \"zod\";\nimport { checkoutAttributionInputSchema } from \"@read-frog/definitions\";\nimport { appLocaleSchema } from \"./app-locale\";\n\nexport const billingIntervalSchema = z.enum([\"month\", \"year\"]);\nexport type BillingInterval = z.infer<typeof billingIntervalSchema>;\n\nexport const billingSubscriptionStatusSchema = z.enum([\n \"incomplete\",\n \"incomplete_expired\",\n \"trialing\",\n \"active\",\n \"past_due\",\n \"canceled\",\n \"unpaid\",\n \"paused\",\n]);\nexport type BillingSubscriptionStatus = z.infer<typeof billingSubscriptionStatusSchema>;\n\nexport const billingPlanSchema = z.enum([\"free\", \"pro\", \"ultra\"]);\nexport type BillingPlan = z.infer<typeof billingPlanSchema>;\n\n/**\n * How many MCP tool calls each plan may make in a day (24 hours from the first\n * one); `null` is no limit. Each `tools/call` counts once, whatever the tool.\n *\n * Read by the MCP server's gate AND by the website's copy, so the pages cannot\n * promise calls the server refuses.\n *\n * Companion edit when this changes: the MCP docs under\n * `apps/www/content/docs/mcp/` and `account-and-plans`, which state the numbers.\n */\nexport const MCP_DAILY_CALL_LIMITS = {\n free: 10,\n pro: 50,\n ultra: null,\n} as const satisfies Record<BillingPlan, number | null>;\n\n/**\n * How many ebooks each plan may keep at once. Free keeps one, so it reads one\n * book at a time; deleting a book frees its place for the next.\n *\n * Read by the API's upload gate AND by the website's copy (the pricing page),\n * so the pages cannot promise books the server refuses.\n *\n * Companion edit when this changes: `account-and-plans` under\n * `apps/www/content/docs/`, which states the numbers.\n */\nexport const EBOOK_LIMIT_BY_PLAN = {\n free: 1,\n pro: 10,\n ultra: 80,\n} as const satisfies Record<BillingPlan, number>;\n\n// Plans a user can actively check out into (the free tier has no price).\nexport const billingCheckoutPlanSchema = z.enum([\"pro\", \"ultra\"]);\nexport type BillingCheckoutPlan = z.infer<typeof billingCheckoutPlanSchema>;\n\nexport const billingCurrencySchema = z.enum([\"usd\", \"cad\", \"cny\"]);\nexport type BillingCurrency = z.infer<typeof billingCurrencySchema>;\n\n// The billing name of `appLocaleSchema`, which it was before the account had a\n// locale of its own; kept so existing imports keep working.\nexport const billingLocaleSchema = appLocaleSchema;\nexport type BillingLocale = AppLocale;\n\nexport const billingAccessSourceSchema = z.enum([\"subscription\", \"pass\"]);\nexport type BillingAccessSource = z.infer<typeof billingAccessSourceSchema>;\n\nexport const billingScheduledChangeSchema = z\n .object({\n plan: billingCheckoutPlanSchema,\n interval: billingIntervalSchema,\n effectiveAt: z.coerce.date(),\n })\n .strict();\nexport type BillingScheduledChange = z.infer<typeof billingScheduledChangeSchema>;\n\n/**\n * The zone a payment deadline is shown in, as a date with no time. UTC−12 is\n * the last zone to finish a day, and `dueBy` is the end of a day there, so the\n * date it shows stays open in every customer's zone until their own midnight.\n */\nexport const BILLING_PAYMENT_DUE_TIME_ZONE = \"Etc/GMT+12\";\n\n/**\n * A renewal whose payment failed. The plan stays until `dueBy`; paying the\n * invoice before then (or later, until the subscription is canceled) restores\n * the subscription as if the payment had gone through.\n */\nexport const billingPaymentDueSchema = z\n .object({\n /** The last instant of the plan; show it in BILLING_PAYMENT_DUE_TIME_ZONE. */\n dueBy: z.coerce.date(),\n /**\n * The plan the payment keeps. Not `BillingStatus.plan`: past `dueBy` that\n * already reads \"free\" while the invoice is still payable.\n */\n plan: billingCheckoutPlanSchema,\n /** The Stripe-hosted page that pays the invoice; null if Stripe gave none. */\n url: z.url().nullable(),\n })\n .strict();\nexport type BillingPaymentDue = z.infer<typeof billingPaymentDueSchema>;\n\nexport const billingStatusSchema = z\n .object({\n plan: billingPlanSchema,\n status: billingSubscriptionStatusSchema.nullable(),\n interval: billingIntervalSchema.nullable(),\n currentPeriodEnd: z.coerce.date().nullable(),\n /**\n * When the subscription terminates, or null if it renews. Replaces the\n * `cancelAtPeriodEnd` boolean: Stripe deprecated its counterpart and the\n * Customer Portal no longer sets it, and the termination date is not always\n * `currentPeriodEnd` — a stacked pass pushes that past the cancellation.\n */\n cancelAt: z.coerce.date().nullable(),\n accessSource: billingAccessSourceSchema.nullable(),\n scheduledChange: billingScheduledChangeSchema.nullable(),\n paymentDue: billingPaymentDueSchema.nullable(),\n unlimitedNotebaseNotes: z.boolean(),\n notebaseNoteLimit: z.number().int().positive(),\n notebaseNoteCount: z.number().int().min(0),\n })\n .strict();\nexport type BillingStatus = z.infer<typeof billingStatusSchema>;\n\nexport const billingCreateCheckoutSessionInputSchema = z\n .object({\n currency: billingCurrencySchema,\n interval: billingIntervalSchema,\n locale: appLocaleSchema,\n plan: billingCheckoutPlanSchema.default(\"pro\"),\n requestId: z.uuid().optional(),\n attribution: checkoutAttributionInputSchema.optional(),\n })\n .strict();\nexport type BillingCreateCheckoutSessionInput = z.infer<\n typeof billingCreateCheckoutSessionInputSchema\n>;\n\nexport const billingCreateCustomerPortalSessionInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type BillingCreateCustomerPortalSessionInput = z.infer<\n typeof billingCreateCustomerPortalSessionInputSchema\n>;\n\nexport const billingSessionUrlOutputSchema = z\n .object({\n url: z.url(),\n })\n .strict();\nexport type BillingSessionUrlOutput = z.infer<typeof billingSessionUrlOutputSchema>;\n\nexport const billingCancelScheduledChangeOutputSchema = z\n .object({\n success: z.literal(true),\n })\n .strict();\nexport type BillingCancelScheduledChangeOutput = z.infer<\n typeof billingCancelScheduledChangeOutputSchema\n>;\n","import { z } from \"zod\";\nimport { billingPlanSchema } from \"./billing\";\n\nexport const HostedAiOutputFieldTypeSchema = z.enum([\"string\", \"number\"]);\n\nexport const HostedAiOutputFieldSchema = z.strictObject({\n name: z.string().trim().min(1).max(80),\n type: HostedAiOutputFieldTypeSchema,\n});\n\nconst HostedAiInstructionsSchema = z.string().trim().min(1).max(16000);\n\n/**\n * Which hosted model a request runs on. Deliberately NOT named after a billing\n * plan: which plans may reach which tier is policy (see `access-policy.ts`),\n * not identity, so a future plan can be sold with any tier without a rename.\n */\nexport const HostedAiModelTierSchema = z.enum([\"normal\", \"advance\"]);\n/**\n * The billing/access subject of a hosted request, not a route id. Sub-calls\n * bill against the feature they serve: the page summary is `pageTranslation`,\n * and the video summary and subtitle segmentation are `videoSubtitles`.\n *\n * Appended last on purpose: the db pgEnum mirrors this order, and appending\n * keeps drizzle from emitting the ADD VALUE ... BEFORE variant.\n */\nexport const HostedAiFeatureSchema = z.enum([\n \"pageTranslation\",\n \"customAction\",\n \"noteSuggestion\",\n \"selectionTranslation\",\n \"videoSubtitles\",\n \"inputTranslation\",\n \"languageDetection\",\n // Charged by the PDF worker's proxy, not called by clients; `status`\n // leaves it out (see the router's HOSTED_AI_FEATURES).\n \"pdfTranslation\",\n]);\nexport const HostedAiRequestIdSchema = z.uuid();\n\nconst HostedAiRequestMetadataSchema = {\n /**\n * Optional on the wire, always present after parsing: these endpoints shipped\n * before tiers existed, so every installed extension below 1.46.0 sends no\n * `modelTier` at all, and the input objects are strict. Defaulting here keeps\n * those clients working while giving handlers a single source of truth\n * instead of a `?? \"normal\"` at every call site.\n *\n * TODO(2026-11-01): Drop the default and make this required once extensions\n * below 1.46.0 have drained from the store.\n */\n modelTier: HostedAiModelTierSchema.default(\"normal\"),\n requestId: HostedAiRequestIdSchema.optional(),\n};\n\nexport const HostedAiStreamTextInputSchema = z.strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n temperature: z.number().min(0).max(2).optional(),\n});\n\nexport const HostedAiStreamStructuredObjectInputSchema = z\n .strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n outputSchema: z.array(HostedAiOutputFieldSchema).min(1).max(32),\n temperature: z.number().min(0).max(2).optional(),\n })\n .superRefine((input, ctx) => {\n const fieldNames = new Set<string>();\n\n input.outputSchema.forEach((field, index) => {\n if (fieldNames.has(field.name)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate output schema name \"${field.name}\".`,\n path: [\"outputSchema\", index, \"name\"],\n });\n return;\n }\n\n fieldNames.add(field.name);\n });\n });\n\nexport const HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES = 2;\nexport const HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS = 16;\n\nexport const HostedAiNoteSuggestionStreamInputSchema = z.strictObject({\n ...HostedAiRequestMetadataSchema,\n instructions: HostedAiInstructionsSchema,\n prompt: z.string().trim().min(1).max(32000),\n temperature: z.number().min(0).max(2).optional(),\n});\n\n/**\n * Fixed structured-output schema for hosted note suggestions. Must stay\n * strict-structured-outputs-safe: strict objects only, no records, no\n * `.optional()` (nullable-only), unions limited to primitives. If the upstream\n * deployment rejects `maxItems`/`maxLength` constraint keywords, strip the\n * `.max()` calls from the model-facing copy only — clients still validate\n * against this schema.\n */\nexport const HostedAiNoteSuggestionObjectSchema = z.strictObject({\n action: z.strictObject({\n createNewDictionaryAction: z.boolean(),\n targetActionId: z.string().max(128).nullable(),\n /**\n * Name of the chosen schema's field whose value best works as a one-line\n * explanation of the term in UI (usually a definition/meaning field);\n * null when no field fits. Purely a display hint — clients sanitize it\n * and fall back to their own ordering when invalid.\n */\n summaryFieldName: z.string().max(80).nullable(),\n }),\n notes: z\n .array(\n z.strictObject({\n fields: z\n .array(\n z.strictObject({\n name: z.string().max(80),\n value: z.union([z.string(), z.number()]).nullable(),\n }),\n )\n .max(HOSTED_AI_NOTE_SUGGESTION_MAX_NOTE_FIELDS),\n }),\n )\n .max(HOSTED_AI_NOTE_SUGGESTION_MAX_NOTES),\n});\n\nexport const HostedAiStreamPartSchema = z.looseObject({\n type: z.string().trim().min(1),\n});\n\n/**\n * The only stream part types this API emits. Every other part the AI SDK\n * produces (`start-step`, `finish-step`, `text-start`, ...) carries upstream\n * metadata — provider model id, response headers, request body — and is dropped\n * server-side so it never reaches a client.\n *\n * The consumer switch lives in the extension's background stream reader. Adding\n * a type here without teaching that switch about it is a no-op; removing one\n * breaks rendering. `error` is absent on purpose: it is converted into a thrown\n * error before it can be yielded.\n */\nexport const HOSTED_AI_CLIENT_STREAM_PART_TYPES = [\n \"text-delta\",\n \"reasoning-start\",\n \"reasoning-delta\",\n \"reasoning-end\",\n \"reasoning-file\",\n \"finish\",\n] as const;\n\n/**\n * Status is per-identity, not per-feature: one call reports every feature and\n * every pool, so a client caches a single response instead of one per feature.\n * Non-strict so a client still sending the retired `feature` argument gets a\n * useful response rather than a validation error.\n */\nexport const HostedAiStatusInputSchema = z.object({});\n\n/**\n * `pro_required` means the Pro plan or any plan above it; `ultra_required`\n * means Ultra. Appended last, so a client that predates a value falls back on\n * its own default instead of misreading it.\n */\nexport const HostedAiUnavailableReasonSchema = z.enum([\n \"authentication_required\",\n \"ultra_required\",\n \"quota_exhausted\",\n \"service_unavailable\",\n \"pro_required\",\n]);\n\n/**\n * The cheapest plan an account would need to buy for something it cannot use\n * now. Any plan above it works too, so `pro` reads as \"Pro or Ultra\".\n */\nexport const HostedAiUpgradePlanSchema = billingPlanSchema.exclude([\"free\"]);\n\nexport const HostedAiCreditPolicyIdSchema = z.enum([\n \"custom-action-guest-daily-v1\",\n \"custom-action-user-daily-v1\",\n // Retired: Pro draws on a weekly pool now. Kept because the database still\n // holds pools under it.\n \"custom-action-pro-daily-v1\",\n \"ultra-weekly-v1\",\n // Retired: Pro's weekly pool in UTC calendar weeks. Kept for the same reason.\n \"pro-weekly-v1\",\n // Pro's weekly pool, in weeks that run from when the plan started, as Ultra's do.\n \"pro-weekly-v2\",\n]);\n\nexport const HostedAiCreditPeriodKindSchema = z.enum([\"daily\", \"weekly\"]);\n\nexport const HostedAiQuotaScopeSchema = z.enum([\"guest\", \"user\"]);\n\n/**\n * Data payload of the TOO_MANY_REQUESTS error every hosted AI guard emits.\n * The code itself is ORPC's own rather than a PUBLIC_APP_ERROR_DEFS entry, so\n * this schema is the only contract tying the server's construction to the\n * extension's parsing of it.\n *\n * Deliberately NOT strict: installed extensions parse this payload at runtime\n * and lag server deploys by weeks, so rejecting unknown keys would turn any\n * additive server-side field into a fleet-wide parse failure that silently\n * drops retryAfterMs (queue backoff timing) and quotaScope (guest sign-in\n * prompt). Unknown keys are stripped; the required fields keep drift\n * protection.\n */\nexport const HostedAiRateLimitErrorDataSchema = z.object({\n retryAfterMs: z.number().int().min(0),\n quotaScope: HostedAiQuotaScopeSchema,\n});\n\n/**\n * A recurring pool: the plan's credit for a day or a week, which refills at\n * `resetAt`.\n *\n * Deliberately free of dollar amounts and of the versioned policy id. Clients\n * render a consumption bar and a reset time, so a percentage and a period kind\n * are all they need, and neither leaks what a call costs us. `usedPercent`\n * counts settled spend only: including in-flight reservations would make the\n * bar jump forward and then back as each stream settles.\n */\nexport const HostedAiRecurringCreditStatusSchema = z.strictObject({\n periodKind: HostedAiCreditPeriodKindSchema,\n usedPercent: z.number().min(0).max(100),\n resetAt: z.iso.datetime().nullable(),\n /**\n * Every feature drawing on this pool. Ultra shares one weekly pool across all\n * three, so the grouping lives here rather than inlined per feature — that way\n * a client can tell one shared pool from several separate ones.\n */\n features: z.array(HostedAiFeatureSchema).min(1),\n});\n\n/**\n * A one-time pool, such as credit from a campaign or from support. It never\n * refills: once spent or past `expiresAt` it is gone, so a client shows the\n * expiry, not a reset. It is drawn on only after the plan's own pool for a\n * feature is spent, or for a feature the plan does not fund. Listed until it\n * expires, even when spent. Same fields as a recurring pool otherwise.\n */\nexport const HostedAiOneTimeCreditStatusSchema = z.strictObject({\n periodKind: z.literal(\"once\"),\n usedPercent: z.number().min(0).max(100),\n expiresAt: z.iso.datetime(),\n features: z.array(HostedAiFeatureSchema).min(1),\n});\n\n/**\n * One pool that can pay for Built-in AI, told apart by `periodKind`: a\n * recurring `daily` or `weekly` pool refills at `resetAt`, a one-time (`once`)\n * pool ends at `expiresAt`. Narrow on `periodKind` before reading either.\n */\nexport const HostedAiCreditPoolStatusSchema = z.discriminatedUnion(\"periodKind\", [\n HostedAiRecurringCreditStatusSchema,\n HostedAiOneTimeCreditStatusSchema,\n]);\n\n/** Feature-scoped credit display, separate from the legacy extension status shape. */\nexport const HostedAiCreditPoolsInputSchema = z.strictObject({ feature: HostedAiFeatureSchema });\nexport const HostedAiCreditPoolsOutputSchema = z.strictObject({\n pools: z.array(HostedAiCreditPoolStatusSchema),\n});\n\nexport const HostedAiTierStatusSchema = z.strictObject({\n accessAllowed: z.boolean(),\n available: z.boolean(),\n unavailableReason: HostedAiUnavailableReasonSchema.nullable(),\n /**\n * The cheapest plan this account would need to use the tier, or null when it\n * needs none: its plan or a one-time pool already covers it, or the tier is\n * open to every signed-in account. For a guest it is the plan needed after\n * signing in. Clients badge an option with it and offer that plan.\n */\n upgradeTo: HostedAiUpgradePlanSchema.nullable(),\n /**\n * @deprecated Read `upgradeTo`. Viewer-independent product fact: no\n * non-Ultra account can ever use this feature/tier. Extensions released\n * before `upgradeTo` badge options with it, including for Ultra accounts.\n *\n * TODO(2026-11-21): remove once those extensions have drained (#710).\n */\n requiresUltra: z.boolean(),\n modelRevision: z.string().trim().min(1),\n});\n\nexport const HostedAiFeatureStatusSchema = z.strictObject({\n normal: HostedAiTierStatusSchema,\n advance: HostedAiTierStatusSchema,\n});\n\nexport const HostedAiStatusOutputSchema = z.strictObject({\n /**\n * @deprecated Read `pools`. This lists the recurring pools only, never a\n * one-time one: extensions released before mengxi-ream/read-frog#2395 look\n * up a label for every entry's `periodKind`, and one they do not know\n * crashes their usage page. They also throw if the field is missing.\n *\n * TODO(2026-11-07): remove once those extensions have drained (#710).\n */\n credits: z.array(HostedAiRecurringCreditStatusSchema),\n /**\n * Everything that can pay for a feature, in the order the server draws on it:\n * the plan's recurring pools first, then one-time pools by soonest expiry. A\n * feature can appear in several entries.\n */\n pools: z.array(HostedAiCreditPoolStatusSchema),\n features: z.strictObject({\n pageTranslation: HostedAiFeatureStatusSchema,\n customAction: HostedAiFeatureStatusSchema,\n noteSuggestion: HostedAiFeatureStatusSchema,\n selectionTranslation: HostedAiFeatureStatusSchema,\n videoSubtitles: HostedAiFeatureStatusSchema,\n inputTranslation: HostedAiFeatureStatusSchema,\n languageDetection: HostedAiFeatureStatusSchema,\n }),\n});\n\nexport type HostedAiOutputFieldType = z.infer<typeof HostedAiOutputFieldTypeSchema>;\nexport type HostedAiOutputField = z.infer<typeof HostedAiOutputFieldSchema>;\nexport type HostedAiModelTier = z.infer<typeof HostedAiModelTierSchema>;\nexport type HostedAiFeature = z.infer<typeof HostedAiFeatureSchema>;\nexport type HostedAiStreamTextInput = z.infer<typeof HostedAiStreamTextInputSchema>;\nexport type HostedAiStreamStructuredObjectInput = z.infer<\n typeof HostedAiStreamStructuredObjectInputSchema\n>;\nexport type HostedAiNoteSuggestionStreamInput = z.infer<\n typeof HostedAiNoteSuggestionStreamInputSchema\n>;\nexport type HostedAiNoteSuggestionObject = z.infer<typeof HostedAiNoteSuggestionObjectSchema>;\nexport type HostedAiStreamPart = z.infer<typeof HostedAiStreamPartSchema>;\nexport type HostedAiStatusInput = z.infer<typeof HostedAiStatusInputSchema>;\nexport type HostedAiUnavailableReason = z.infer<typeof HostedAiUnavailableReasonSchema>;\nexport type HostedAiUpgradePlan = z.infer<typeof HostedAiUpgradePlanSchema>;\nexport type HostedAiCreditPolicyId = z.infer<typeof HostedAiCreditPolicyIdSchema>;\nexport type HostedAiCreditPeriodKind = z.infer<typeof HostedAiCreditPeriodKindSchema>;\nexport type HostedAiQuotaScope = z.infer<typeof HostedAiQuotaScopeSchema>;\nexport type HostedAiRateLimitErrorData = z.infer<typeof HostedAiRateLimitErrorDataSchema>;\nexport type HostedAiRecurringCreditStatus = z.infer<typeof HostedAiRecurringCreditStatusSchema>;\nexport type HostedAiOneTimeCreditStatus = z.infer<typeof HostedAiOneTimeCreditStatusSchema>;\nexport type HostedAiCreditPoolStatus = z.infer<typeof HostedAiCreditPoolStatusSchema>;\nexport type HostedAiTierStatus = z.infer<typeof HostedAiTierStatusSchema>;\nexport type HostedAiFeatureStatus = z.infer<typeof HostedAiFeatureStatusSchema>;\nexport type HostedAiStatusOutput = z.infer<typeof HostedAiStatusOutputSchema>;\n","import { PDF_TRANSLATION_MAX_BATCH_FILES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { HostedAiModelTierSchema } from \"./hosted-ai\";\n\nexport const pdfTranslationJobStatusSchema = z.enum([\n \"queued\",\n \"running\",\n \"cancel_requested\",\n \"succeeded\",\n \"failed\",\n \"cancelled\",\n // Succeeded, but the translation is past its retention and gone.\n \"expired\",\n]);\nexport type PdfTranslationJobStatus = z.infer<typeof pdfTranslationJobStatusSchema>;\n\n/**\n * The two PDFs one translation makes: the translation alone, with the\n * original's layout, and the original and translated pages side by side.\n */\nexport const pdfTranslationOutputVariantSchema = z.enum([\"translated\", \"bilingual\"]);\nexport type PdfTranslationOutputVariant = z.infer<typeof pdfTranslationOutputVariantSchema>;\n\nconst languageSchema = z\n .string()\n .min(2)\n .max(40)\n .regex(/^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i);\n\nexport const pdfTranslationRequestUploadInputSchema = z\n .object({\n fileName: z\n .string()\n .trim()\n .min(1)\n .max(255)\n .refine((fileName) => fileName.toLowerCase().endsWith(\".pdf\"), {\n message: \"fileName must end with .pdf\",\n }),\n // The exact size: the upload is signed for it, and storage refuses any other file.\n fileByteSize: z.number().int().min(1),\n })\n .strict();\nexport type PdfTranslationRequestUploadInput = z.infer<\n typeof pdfTranslationRequestUploadInputSchema\n>;\n\nexport const pdfTranslationRequestUploadOutputSchema = z\n .object({\n uploadId: z.uuid(),\n // A PUT of the file to `url` with exactly these headers.\n upload: z\n .object({\n url: z.url(),\n headers: z.record(z.string(), z.string()),\n })\n .strict(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type PdfTranslationRequestUploadOutput = z.infer<\n typeof pdfTranslationRequestUploadOutputSchema\n>;\n\nexport const pdfTranslationSubmitInputSchema = z\n .object({\n // The PDFs to translate with the same settings, in the order they run.\n uploadIds: z\n .array(z.uuid())\n .min(1)\n .max(PDF_TRANSLATION_MAX_BATCH_FILES)\n .refine((ids) => new Set(ids).size === ids.length, {\n message: \"uploadIds must not repeat\",\n }),\n // A retry with the same key returns the jobs the first request made.\n idempotencyKey: z.string().trim().min(1).max(200),\n // Only the target: the model works out the PDF's own language from its text.\n targetLanguage: languageSchema,\n // Under the same rules as every Built-in AI feature: advance is Ultra's.\n modelTier: HostedAiModelTierSchema,\n })\n .strict();\nexport type PdfTranslationSubmitInput = z.infer<typeof pdfTranslationSubmitInputSchema>;\n\nexport const pdfTranslationJobIdInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type PdfTranslationJobIdInput = z.infer<typeof pdfTranslationJobIdInputSchema>;\n\nexport const pdfTranslationOutputInputSchema = z\n .object({\n id: z.uuid(),\n variant: pdfTranslationOutputVariantSchema,\n })\n .strict();\nexport type PdfTranslationOutputInput = z.infer<typeof pdfTranslationOutputInputSchema>;\n\nexport const pdfTranslationListInputSchema = z.object({}).strict();\nexport type PdfTranslationListInput = z.infer<typeof pdfTranslationListInputSchema>;\n\nexport const pdfTranslationJobResourceSchema = z\n .object({\n id: z.uuid(),\n status: pdfTranslationJobStatusSchema,\n sourceFileName: z.string(),\n targetLanguage: z.string(),\n modelTier: HostedAiModelTierSchema,\n // The PDFs submitted together, which run one at a time in this order.\n batchId: z.uuid(),\n batchPosition: z.number().int().min(0),\n // How many of the account's translations run before a queued one: null\n // once it has started, or when it never will.\n waitingAhead: z.number().int().min(0).nullable(),\n // A Free account's one translation, which it can read here but not download.\n freeTrial: z.boolean(),\n // Which PDFs a succeeded job has. A job translated before both were made\n // has only the one it asked for; any other job has neither.\n outputs: z\n .object({\n translated: z.boolean(),\n bilingual: z.boolean(),\n })\n .strict(),\n pageCount: z.number().int().min(1),\n progressStage: z.string().nullable(),\n progressPercent: z.number().min(0).max(100),\n // Built-in AI credit, in billionths of a US dollar: what admission\n // expected, and what the model calls have used so far.\n estimatedCostNanoUsd: z.number().int().min(0),\n chargedCostNanoUsd: z.number().int().min(0),\n error: z\n .object({\n category: z.string(),\n message: z.string(),\n })\n .strict()\n .nullable(),\n // The worker version that last ran the job, for support.\n workerRelease: z.string().nullable(),\n createdAt: z.coerce.date(),\n startedAt: z.coerce.date().nullable(),\n completedAt: z.coerce.date().nullable(),\n // When a succeeded job's translation stops being downloadable.\n outputExpiresAt: z.coerce.date().nullable(),\n })\n .strict();\nexport type PdfTranslationJobResource = z.infer<typeof pdfTranslationJobResourceSchema>;\n\nexport const pdfTranslationListOutputSchema = z\n .object({\n items: z.array(pdfTranslationJobResourceSchema),\n })\n .strict();\nexport type PdfTranslationListOutput = z.infer<typeof pdfTranslationListOutputSchema>;\n\n/** What a submission made: its batch, and one job per PDF in their order. */\nexport const pdfTranslationSubmitOutputSchema = z\n .object({\n batchId: z.uuid(),\n jobs: z.array(pdfTranslationJobResourceSchema).min(1),\n })\n .strict();\nexport type PdfTranslationSubmitOutput = z.infer<typeof pdfTranslationSubmitOutputSchema>;\n\n/** A job, and every job of its batch in their order (itself included). */\nexport const pdfTranslationGetOutputSchema = z\n .object({\n job: pdfTranslationJobResourceSchema,\n batch: z.array(pdfTranslationJobResourceSchema).min(1),\n })\n .strict();\nexport type PdfTranslationGetOutput = z.infer<typeof pdfTranslationGetOutputSchema>;\n\nexport const pdfTranslationStatusInputSchema = z.object({}).strict();\nexport type PdfTranslationStatusInput = z.infer<typeof pdfTranslationStatusInputSchema>;\n\nexport const pdfTranslationStatusOutputSchema = z\n .object({\n // An account nothing funds translates one PDF, once, on the normal tier:\n // 1 until it has, and always 0 for a funded account.\n freeTrialsRemaining: z.number().int().min(0),\n /**\n * Whether Built-in AI credit pays for PDF translation on the normal tier:\n * a paid plan, or credit the account was given for every feature. Only a\n * funded account submits more than one PDF or downloads a translation.\n */\n funded: z.boolean(),\n })\n .strict();\nexport type PdfTranslationStatusOutput = z.infer<typeof pdfTranslationStatusOutputSchema>;\n\nexport const pdfTranslationDownloadOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type PdfTranslationDownloadOutput = z.infer<typeof pdfTranslationDownloadOutputSchema>;\n\nexport const pdfTranslationPreviewOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n /**\n * Whether the URL opens the free translation's copy with the Read Frog\n * watermark, which an account nothing funds reads: upgrading opens the\n * PDF itself.\n */\n watermarked: z.boolean(),\n })\n .strict();\nexport type PdfTranslationPreviewOutput = z.infer<typeof pdfTranslationPreviewOutputSchema>;\n\nexport const pdfTranslationDeleteOutputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type PdfTranslationDeleteOutput = z.infer<typeof pdfTranslationDeleteOutputSchema>;\n\nexport const PdfTranslationInsufficientCreditDataSchema = z.strictObject({\n estimatedCostNanoUsd: z.number().int().min(0),\n remainingNanoUsd: z.number().int().min(0),\n resetAt: z.iso.datetime().nullable(),\n});\nexport type PdfTranslationInsufficientCreditData = z.infer<\n typeof PdfTranslationInsufficientCreditDataSchema\n>;\n\n/**\n * Which of a submission's PDFs a refusal is about, so the page can point at\n * it. For an upload an earlier request used up, also the translation it made.\n */\nexport const PdfTranslationUploadErrorDataSchema = z.strictObject({\n uploadId: z.uuid(),\n jobId: z.uuid().optional(),\n});\nexport type PdfTranslationUploadErrorData = z.infer<typeof PdfTranslationUploadErrorDataSchema>;\n","import type { ErrorMap } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport {\n HostedAiCreditPolicyIdSchema,\n HostedAiModelTierSchema,\n HostedAiUpgradePlanSchema,\n} from \"./schemas/hosted-ai\";\nimport {\n PdfTranslationInsufficientCreditDataSchema,\n PdfTranslationUploadErrorDataSchema,\n} from \"./schemas/pdf-translation\";\n\ninterface PublicAppErrorDefinition {\n data?: z.ZodTypeAny;\n message: string;\n status: number;\n}\n\nexport const CellValidationFailureReasonSchema = z.enum([\n \"unknown_notebase_column\",\n \"type_mismatch\",\n \"invalid_select_option\",\n \"invalid_date_format\",\n // A cloze deletion with a blank answer; receivedValue is the deletion as\n // written (`{{c1::}}`).\n \"empty_cloze_answer\",\n // A cloze opening that never closes (unpaired braces, or no `}}`);\n // receivedValue is the opening as written (`{{c1::`).\n \"unclosed_cloze\",\n // A cloze deletion whose ordinal list names no group (`{{c0::a}}`);\n // receivedValue is the deletion as written.\n \"invalid_cloze_ordinal\",\n // A cloze deletion that cuts across a formula's delimiters (`\\(a{{c1::b\\) c}}`);\n // receivedValue is the deletion as written.\n \"cloze_crosses_math\",\n // A cloze deletion in a formula that holds half of a `\\left`/`\\right` or\n // `\\begin`/`\\end` pair; receivedValue is the deletion as written.\n \"cloze_splits_math_pair\",\n // More cloze groups in one note than CLOZE_MAX_GROUPS; receivedValue is\n // the note's group count.\n \"too_many_cloze_groups\",\n]);\nexport type CellValidationFailureReason = z.infer<typeof CellValidationFailureReasonSchema>;\n\nexport const CellValidationFailureDetailsSchema = z\n .object({\n expectedFormat: z.string().optional(),\n expectedType: z.string().optional(),\n receivedType: z.string().optional(),\n receivedValue: z.unknown().optional(),\n validOptions: z.array(z.string()).optional(),\n })\n .strict();\nexport type CellValidationFailureDetails = z.infer<typeof CellValidationFailureDetailsSchema>;\n\nexport const CellValidationFailedDataSchema = z\n .object({\n notebaseColumnId: z.string(),\n details: CellValidationFailureDetailsSchema,\n reason: CellValidationFailureReasonSchema,\n /** Index of the failing row within a batch input (createMany / updateMany / initialRows). */\n rowIndex: z.number().int().min(0).optional(),\n /** The failing note, when the check ran over stored notes (a column type change). */\n notebaseRowId: z.string().optional(),\n })\n .strict();\nexport type CellValidationFailedData = z.infer<typeof CellValidationFailedDataSchema>;\n\nexport const CardTemplateInvalidColumnsDataSchema = z\n .object({\n notebaseColumnIds: z.array(z.string()),\n })\n .strict();\nexport type CardTemplateInvalidColumnsData = z.infer<typeof CardTemplateInvalidColumnsDataSchema>;\n\nexport const CardTemplateInvalidLayoutDataSchema = z\n .object({\n errors: z.array(\n z\n .object({\n side: z.enum([\"front\", \"back\"]),\n message: z.string(),\n // UTF-16 offsets into that face's layout, when the parser knows them.\n from: z.number().int().min(0).optional(),\n to: z.number().int().min(0).optional(),\n })\n .strict(),\n ),\n })\n .strict();\nexport type CardTemplateInvalidLayoutData = z.infer<typeof CardTemplateInvalidLayoutDataSchema>;\n\n// The templates that use the column, which keep it from being deleted.\nexport const CardTemplateNotebaseColumnInUseDataSchema = z\n .object({\n templates: z.array(z.object({ id: z.uuid(), name: z.string() }).strict()),\n })\n .strict();\nexport type CardTemplateNotebaseColumnInUseData = z.infer<\n typeof CardTemplateNotebaseColumnInUseDataSchema\n>;\n\nexport const HostedAiTierRestrictedDataSchema = z.strictObject({\n modelTier: HostedAiModelTierSchema,\n /** The cheapest plan that unlocks it; a client offers \"Pro or Ultra\" for `pro`. */\n upgradeTo: HostedAiUpgradePlanSchema,\n});\n\nexport const HostedAiQuotaExhaustedDataSchema = z.strictObject({\n modelTier: HostedAiModelTierSchema,\n // Reuses the credit-status enum rather than restating it: these two always\n // describe the same set of policy ids, and a second copy silently drifts —\n // the error payload is `strictObject`, so a policy missing only here fails\n // output validation at exactly the moment a user runs out of credit.\n policyId: HostedAiCreditPolicyIdSchema,\n usedPercent: z.number().min(0).max(100),\n resetAt: z.iso.datetime().nullable(),\n});\n\nexport const SpeechDailyLimitReachedDataSchema = z.strictObject({\n limit: z.number().int().min(0),\n resetAt: z.iso.datetime(),\n});\n\nexport const PUBLIC_APP_ERROR_DEFS = {\n CARD_DELETE_UNSUPPORTED: {\n message: \"This card cannot be deleted independently of its note.\",\n status: 400,\n },\n RESOURCE_UPDATE_CONFLICT: {\n message: \"The resource changed. Read it again before updating.\",\n status: 409,\n },\n RESOURCE_ALREADY_EXISTS: { message: \"A resource with this ID already exists.\", status: 409 },\n FIELD_TYPE_CHANGE_UNSUPPORTED: {\n message: \"This operation cannot change the field type.\",\n status: 400,\n },\n HOSTED_AI_TIER_RESTRICTED: {\n data: HostedAiTierRestrictedDataSchema,\n message: \"This Built-in AI tier is not available for this account\",\n status: 403,\n },\n HOSTED_AI_QUOTA_EXHAUSTED: {\n data: HostedAiQuotaExhaustedDataSchema,\n message: \"Built-in AI credit exhausted\",\n status: 429,\n },\n NOTEBASE_NOT_FOUND: {\n message: \"Notebase not found\",\n status: 404,\n },\n VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED: {\n message: \"AI subtitles require a Pro or Ultra subscription\",\n status: 403,\n },\n // Dunning (`past_due` / `paused`), not cancellation: the account keeps\n // reading subtitles it already paid to generate, but cannot start new work\n // that spends upstream money until the payment method is fixed. Distinct\n // from SUBSCRIPTION_REQUIRED so the client can say \"update your card\"\n // instead of \"subscribe\".\n VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED: {\n message: \"Update your payment method to generate new AI subtitles\",\n status: 402,\n },\n VIDEO_TRANSCRIPT_NOT_FOUND: {\n message: \"Video transcript not found\",\n status: 404,\n },\n VIDEO_TRANSCRIPT_NOT_READY: {\n message: \"Video transcript is not ready yet\",\n status: 409,\n },\n VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED: {\n message: \"Monthly transcription quota exceeded\",\n status: 429,\n },\n // A property of the video, not of the account: upgrading or waiting for the\n // quota to reset changes nothing. Kept apart from QUOTA_EXCEEDED so the\n // client does not answer it with an upgrade wall.\n VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH: {\n message: \"This video is longer than AI subtitles support\",\n status: 422,\n },\n // The day's read-aloud requests are used up (`SPEECH_DAILY_REQUEST_LIMITS`).\n SPEECH_DAILY_LIMIT_REACHED: {\n data: SpeechDailyLimitReachedDataSchema,\n message: \"Today's read-aloud limit is reached\",\n status: 429,\n },\n // No voice service to read with right now: not configured, or failing.\n SPEECH_UNAVAILABLE: {\n message: \"Reading aloud is unavailable right now\",\n status: 503,\n },\n NOTEBASE_COLUMN_NOT_FOUND: {\n message: \"Notebase column not found\",\n status: 404,\n },\n NOTEBASE_ROW_NOT_FOUND: {\n message: \"Notebase row not found\",\n status: 404,\n },\n CARD_NOT_FOUND: {\n message: \"Card not found\",\n status: 404,\n },\n CARD_TEMPLATE_NOT_FOUND: {\n message: \"Card template not found\",\n status: 404,\n },\n CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS: {\n data: CardTemplateInvalidColumnsDataSchema,\n message: \"Card template references unknown notebase columns\",\n status: 422,\n },\n CARD_TEMPLATE_INVALID_LAYOUT: {\n data: CardTemplateInvalidLayoutDataSchema,\n message: \"Card template layout does not parse\",\n status: 422,\n },\n CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE: {\n data: CardTemplateNotebaseColumnInUseDataSchema,\n message: \"Notebase column is used by a card template\",\n status: 409,\n },\n NOTE_LIMIT_EXCEEDED: {\n message: \"Upgrade is required to create more Notebase notes\",\n status: 403,\n },\n BILLING_NOT_CONFIGURED: {\n message: \"Billing is not configured\",\n status: 503,\n },\n BILLING_CUSTOMER_NOT_FOUND: {\n message: \"Billing customer not found\",\n status: 404,\n },\n BILLING_PASS_ACTIVE: {\n message: \"An active Pro pass already covers this account\",\n status: 409,\n },\n BILLING_CHANGE_SCHEDULED: {\n message: \"A subscription change is already scheduled\",\n status: 409,\n },\n BILLING_CHECKOUT_CONFLICT: {\n message: \"Please start a new checkout from the pricing page\",\n status: 409,\n },\n CARD_NOT_REVIEWABLE: {\n message: \"Card cannot be reviewed in its current state\",\n status: 409,\n },\n CARD_REVIEW_STATE_STALE: {\n message: \"Card review state is stale\",\n status: 409,\n },\n CARD_REVIEW_ROLLBACK_UNAVAILABLE: {\n message: \"Card review cannot be rolled back\",\n status: 409,\n },\n CARD_ALREADY_BURIED: {\n message: \"Card is already buried\",\n status: 409,\n },\n CARD_NOT_BURIED: {\n message: \"Card is not buried\",\n status: 409,\n },\n CARD_ALREADY_SUSPENDED: {\n message: \"Card is already suspended\",\n status: 409,\n },\n CARD_NOT_SUSPENDED: {\n message: \"Card is not suspended\",\n status: 409,\n },\n CARD_STATUS_CHANGE_UNAVAILABLE: {\n message: \"Card status change is unavailable\",\n status: 409,\n },\n RESCHEDULE_PLAN_EXPIRED: {\n message: \"The reschedule plan has expired; preview it again\",\n status: 409,\n },\n RESCHEDULE_STALE: {\n message: \"Cards changed after the reschedule preview; preview it again\",\n status: 409,\n },\n RESCHEDULE_PREVIEW_TIMEOUT: {\n message: \"Planning the reschedule took too long\",\n status: 503,\n },\n RESCHEDULE_DAILY_LIMIT_INVALID: {\n message: \"The daily limit is outside the range a reschedule may suggest\",\n status: 422,\n },\n NOTEBASE_VIEW_NOT_FOUND: {\n message: \"Notebase view not found\",\n status: 404,\n },\n CELL_VALIDATION_FAILED: {\n data: CellValidationFailedDataSchema,\n message: \"Cell validation failed\",\n status: 422,\n },\n PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED: {\n message: \"Cannot delete primary notebase column\",\n status: 400,\n },\n CONCURRENT_POSITION_CONFLICT: {\n message: \"Concurrent position conflict, please retry\",\n status: 409,\n },\n EBOOK_NOT_FOUND: {\n message: \"Ebook not found\",\n status: 404,\n },\n EBOOK_LIMIT_EXCEEDED: {\n message: \"Upgrade is required to upload more ebooks\",\n status: 403,\n },\n EBOOK_FILE_TOO_LARGE: {\n message: \"Ebook file exceeds the maximum allowed size\",\n status: 413,\n },\n EBOOK_UPLOAD_NOT_COMPLETED: {\n message: \"Ebook upload has not been completed\",\n status: 409,\n },\n MEDIA_BETA_RESTRICTED: {\n message: \"Media uploads are currently in beta for selected accounts\",\n status: 403,\n },\n MEDIA_NOT_FOUND: {\n message: \"Media file not found\",\n status: 404,\n },\n MEDIA_FILE_TOO_LARGE: {\n message: \"Media file exceeds the maximum allowed size\",\n status: 413,\n },\n MEDIA_QUOTA_EXCEEDED: {\n message: \"Not enough media storage space left on your plan\",\n status: 403,\n },\n MEDIA_UPLOAD_NOT_COMPLETED: {\n message: \"Media upload has not been completed\",\n status: 409,\n },\n // An email's unsubscribe or preferences link that does not verify, or whose\n // account no longer exists. The page asks the reader to sign in instead.\n EMAIL_LINK_INVALID: {\n message: \"This email link is not valid\",\n status: 400,\n },\n // The deployment has no worker to run translations (no Batch job\n // definition or PDF bucket configured).\n PDF_TRANSLATION_UNAVAILABLE: {\n message: \"PDF translation is not available right now\",\n status: 503,\n },\n PDF_TRANSLATION_NOT_FOUND: {\n message: \"PDF translation not found\",\n status: 404,\n },\n PDF_TRANSLATION_UPLOAD_NOT_FOUND: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"PDF upload not found\",\n status: 404,\n },\n PDF_TRANSLATION_UPLOAD_EXPIRED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF upload has expired; upload the file again\",\n status: 410,\n },\n PDF_TRANSLATION_UPLOAD_NOT_COMPLETED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF upload has not been completed\",\n status: 409,\n },\n PDF_TRANSLATION_FILE_TOO_LARGE: {\n message: \"The PDF exceeds the maximum allowed size\",\n status: 413,\n },\n PDF_TRANSLATION_INVALID_PDF: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The file is not a readable PDF\",\n status: 422,\n },\n // Every PDF a translation delivers is marked as one, and none is translated\n // again.\n PDF_TRANSLATION_ALREADY_TRANSLATED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"This PDF is already a translation; upload the original instead\",\n status: 422,\n },\n PDF_TRANSLATION_PAGE_LIMIT_EXCEEDED: {\n data: PdfTranslationUploadErrorDataSchema,\n message: \"The PDF has more pages than one translation allows\",\n status: 422,\n },\n // An account's unfinished translations run one at a time, and no more than\n // PDF_TRANSLATION_MAX_BATCH_FILES of them wait at once.\n PDF_TRANSLATION_QUEUE_FULL: {\n message: \"Too many PDF translations are waiting; try again when some have finished\",\n status: 409,\n },\n PDF_TRANSLATION_IDEMPOTENCY_CONFLICT: {\n message: \"This idempotency key was already used for a different PDF translation\",\n status: 409,\n },\n // The estimate is over what is left of the Built-in AI credit window.\n // Running out midway stops the job instead (its error category is\n // quota_exhausted).\n PDF_TRANSLATION_INSUFFICIENT_CREDIT: {\n data: PdfTranslationInsufficientCreditDataSchema,\n message: \"Not enough Built-in AI credit left to translate this PDF\",\n status: 429,\n },\n PDF_TRANSLATION_NOT_CANCELLABLE: {\n message: \"This PDF translation has already finished\",\n status: 409,\n },\n PDF_TRANSLATION_NOT_READY: {\n message: \"The translated PDF is not available\",\n status: 409,\n },\n // A Free account reads its one translation online; downloading it, as any\n // translated PDF, needs a paid plan.\n PDF_TRANSLATION_DOWNLOAD_RESTRICTED: {\n message: \"Downloading a translated PDF needs a Pro or Ultra plan\",\n status: 403,\n },\n PDF_TRANSLATION_NOT_DELETABLE: {\n message: \"Cancel this PDF translation before deleting it\",\n status: 409,\n },\n} as const satisfies Record<string, PublicAppErrorDefinition>;\n\nexport type PublicAppErrorCode = keyof typeof PUBLIC_APP_ERROR_DEFS;\n\nexport type PublicAppErrorData<TCode extends PublicAppErrorCode> =\n (typeof PUBLIC_APP_ERROR_DEFS)[TCode] extends { data: infer TSchema extends z.ZodTypeAny }\n ? z.output<TSchema>\n : undefined;\n\nexport function isPublicAppErrorCode(code: string | undefined): code is PublicAppErrorCode {\n return code !== undefined && code in PUBLIC_APP_ERROR_DEFS;\n}\n\nexport function getPublicErrorDefinition<TCode extends PublicAppErrorCode>(code: TCode) {\n return PUBLIC_APP_ERROR_DEFS[code];\n}\n\nexport function pickPublicErrorMap<const TCodes extends readonly PublicAppErrorCode[]>(\n ...codes: TCodes\n) {\n return Object.fromEntries(\n codes.map((code) => {\n const definition = PUBLIC_APP_ERROR_DEFS[code];\n\n if (\"data\" in definition) {\n return [\n code,\n {\n data: definition.data,\n message: definition.message,\n status: definition.status,\n },\n ];\n }\n\n return [\n code,\n {\n message: definition.message,\n status: definition.status,\n },\n ];\n }),\n ) as Pick<ErrorMap, TCodes[number]>;\n}\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n billingCancelScheduledChangeOutputSchema,\n billingCreateCheckoutSessionInputSchema,\n billingCreateCustomerPortalSessionInputSchema,\n billingSessionUrlOutputSchema,\n billingStatusSchema,\n} from \"#/schemas/billing\";\n\nconst billingProcedure = oc.errors(\n pickPublicErrorMap(\n \"BILLING_NOT_CONFIGURED\",\n \"BILLING_CUSTOMER_NOT_FOUND\",\n \"BILLING_PASS_ACTIVE\",\n \"BILLING_CHANGE_SCHEDULED\",\n \"BILLING_CHECKOUT_CONFLICT\",\n ),\n);\n\nexport const billingContract = {\n status: billingProcedure\n .route({\n method: \"GET\",\n path: \"/billing/status\",\n summary: \"Get authenticated user's billing status\",\n tags: [\"Billing\"],\n })\n .output(billingStatusSchema),\n createCheckoutSession: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/checkout-sessions\",\n summary: \"Create a localized Stripe Checkout Session for a subscription\",\n tags: [\"Billing\"],\n })\n .input(billingCreateCheckoutSessionInputSchema)\n .output(billingSessionUrlOutputSchema),\n createCustomerPortalSession: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/customer-portal-sessions\",\n summary: \"Create a Stripe Customer Portal Session\",\n tags: [\"Billing\"],\n })\n .input(billingCreateCustomerPortalSessionInputSchema)\n .output(billingSessionUrlOutputSchema),\n cancelScheduledChange: billingProcedure\n .route({\n method: \"POST\",\n path: \"/billing/scheduled-change/cancel\",\n summary: \"Cancel a scheduled subscription change\",\n tags: [\"Billing\"],\n })\n .output(billingCancelScheduledChangeOutputSchema),\n};\n","import type { Route } from \"@orpc/contract\";\nimport { oc } from \"@orpc/contract\";\n\n/**\n * A documented business route shared by OpenAPI and agent-facing adapters.\n * Both prose fields are required so adapters can reuse them without a second\n * copy or an undefined fallback.\n */\nexport type AgentRoute = Route & { summary: string; description: string };\n\n/**\n * Declares a procedure that is exposed to agents as an MCP tool, not only to\n * the REST/OpenAPI surface.\n *\n * oRPC types `~orpc.route` as the widened `Route`, so `route.summary` reads back\n * as `string | undefined` whatever is passed in. `$meta` is the only channel it\n * keeps generic, so the prose is mirrored there and stays a required `string`\n * for tool definitions. OpenAPI keeps reading `route`.\n */\nexport function defineAgentProcedure(route: AgentRoute) {\n return oc.$meta({ summary: route.summary, description: route.description }).route(route);\n}\n","import { z } from \"zod\";\nexport const paginationShape = {\n // Existing callers omit pagination to read all matching records.\n limit: z.number().int().min(1).max(500).optional(),\n offset: z.number().int().min(0).optional(),\n};\nexport function pageSchema<T extends z.ZodType>(itemSchema: T) {\n return z.object({ items: z.array(itemSchema), hasMore: z.boolean() });\n}\n","import { z } from \"zod\";\nexport const expectedUpdatedAtSchema = z.iso.datetime({ offset: true });\nexport const deletionResultSchema = z.object({\n id: z.uuid(),\n txid: z.number(),\n});\n","import { paginationShape, pageSchema } from \"./pagination\";\nimport { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n cardIdentityShape,\n cardMemoryStateShape,\n cardStateSchema,\n cardTemplateConfigSchema,\n cardTemplateCreatedBySchema,\n scheduleStatusSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport { cardStateSchema, scheduleStatusSchema };\nexport type { CardState, ScheduleStatus } from \"@read-frog/definitions\";\n\nexport const cardTemplateSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n name: z.string(),\n config: cardTemplateConfigSchema,\n createdBy: cardTemplateCreatedBySchema.describe(\n 'Who made the template: \"user\", or \"system\" for the default template Read Frog gives a notebase whose fields fit one.',\n ),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type CardTemplate = z.infer<typeof cardTemplateSchema>;\n\nexport const CardTemplateListInputSchema = z.object({\n ...paginationShape,\n notebaseId: z.uuid().optional(),\n});\nexport type CardTemplateListInput = z.infer<typeof CardTemplateListInputSchema>;\n\nexport const CardTemplateListOutputSchema = pageSchema(cardTemplateSchema);\nexport type CardTemplateListOutput = z.infer<typeof CardTemplateListOutputSchema>;\n\nexport const CardTemplateGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardTemplateGetInput = z.infer<typeof CardTemplateGetInputSchema>;\n\nexport const CardTemplateGetOutputSchema = cardTemplateSchema;\nexport type CardTemplateGetOutput = z.infer<typeof CardTemplateGetOutputSchema>;\n\nexport const CardTemplateCreateInputSchema = z\n .object({\n id: z.uuid().optional(),\n notebaseId: z.uuid(),\n name: z.string().min(1),\n config: cardTemplateConfigSchema,\n })\n .strict();\nexport type CardTemplateCreateInput = z.infer<typeof CardTemplateCreateInputSchema>;\n\nexport const CardTemplateCreateOutputSchema = cardTemplateSchema.extend({\n txid: z.number(),\n});\nexport type CardTemplateCreateOutput = z.infer<typeof CardTemplateCreateOutputSchema>;\n\nexport const CardTemplateUpdateInputSchema = z\n .object({\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n id: z.uuid(),\n name: z.string().min(1).optional(),\n config: cardTemplateConfigSchema.optional(),\n })\n .strict();\nexport type CardTemplateUpdateInput = z.infer<typeof CardTemplateUpdateInputSchema>;\n\nexport const CardTemplateUpdateOutputSchema = cardTemplateSchema.extend({\n txid: z.number(),\n});\nexport type CardTemplateUpdateOutput = z.infer<typeof CardTemplateUpdateOutputSchema>;\n\nexport const CardTemplateDeleteInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardTemplateDeleteInput = z.infer<typeof CardTemplateDeleteInputSchema>;\n\nexport const CardTemplateDeleteOutputSchema = deletionResultSchema;\nexport type CardTemplateDeleteOutput = z.infer<typeof CardTemplateDeleteOutputSchema>;\n\nexport const cardSchema = z.object({\n ...cardIdentityShape,\n ...cardMemoryStateShape,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type Card = z.infer<typeof cardSchema>;\n\nexport const renderedCardSchema = cardSchema.extend({\n front: z.string(),\n back: z.string(),\n});\nexport type RenderedCard = z.infer<typeof renderedCardSchema>;\n\nexport const CardListInputSchema = z.object({\n notebaseId: z.uuid().optional(),\n templateId: z.uuid().optional(),\n scheduleStatus: scheduleStatusSchema.optional(),\n ...paginationShape,\n});\nexport type CardListInput = z.infer<typeof CardListInputSchema>;\n\nexport const CardListOutputSchema = pageSchema(renderedCardSchema);\nexport type CardListOutput = z.infer<typeof CardListOutputSchema>;\n\nexport const CardGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type CardGetInput = z.infer<typeof CardGetInputSchema>;\n\nexport const CardGetOutputSchema = renderedCardSchema;\nexport type CardGetOutput = z.infer<typeof CardGetOutputSchema>;\n\nexport const CardDeleteInputSchema = z.strictObject({\n id: z.uuid(),\n expectedVariantKey: z.string().min(1),\n expectedRowUpdatedAt: expectedUpdatedAtSchema,\n});\nexport type CardDeleteInput = z.infer<typeof CardDeleteInputSchema>;\n\nexport const CardDeleteOutputSchema = z.object({ txid: z.number() });\nexport type CardDeleteOutput = z.infer<typeof CardDeleteOutputSchema>;\n\nexport const CardGenerateInputSchema = z.object({\n notebaseId: z.uuid(),\n templateId: z.uuid().optional(),\n});\nexport type CardGenerateInput = z.infer<typeof CardGenerateInputSchema>;\n\nexport const CardGenerateOutputSchema = z.object({\n created: z.number().int().min(0),\n txid: z.number(),\n});\nexport type CardGenerateOutput = z.infer<typeof CardGenerateOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n CardDeleteInputSchema,\n CardDeleteOutputSchema,\n CardGenerateInputSchema,\n CardGenerateOutputSchema,\n CardGetInputSchema,\n CardGetOutputSchema,\n CardListInputSchema,\n CardListOutputSchema,\n} from \"#/schemas/card\";\n\nexport const cardContract = {\n delete: oc\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"NOTEBASE_NOT_FOUND\",\n \"CARD_DELETE_UNSUPPORTED\",\n \"RESOURCE_UPDATE_CONFLICT\",\n \"CELL_VALIDATION_FAILED\",\n ),\n )\n .route({ method: \"DELETE\", path: \"/cards/{id}\", summary: \"Delete card\", tags: [\"Cards\"] })\n .input(CardDeleteInputSchema)\n .output(CardDeleteOutputSchema),\n\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/cards\",\n summary: \"List cards\",\n description:\n \"Browse owned cards with rendered fronts, backs, source IDs and learning state. Optionally filter by notebase, template or scheduleStatus. Supports limit and offset pagination.\",\n tags: [\"Cards\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(CardListInputSchema)\n .output(CardListOutputSchema),\n\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/cards/{id}\",\n summary: \"Get card\",\n description:\n \"Read one owned card with its rendered front, back, source IDs and learning state.\",\n tags: [\"Cards\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\"))\n .input(CardGetInputSchema)\n .output(CardGetOutputSchema),\n\n generate: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CARD_TEMPLATE_NOT_FOUND\"))\n .route({\n method: \"POST\",\n path: \"/cards/generate\",\n summary: \"Generate missing cards\",\n tags: [\"Cards\"],\n })\n .input(CardGenerateInputSchema)\n .output(CardGenerateOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n CardTemplateCreateInputSchema,\n CardTemplateCreateOutputSchema,\n CardTemplateDeleteInputSchema,\n CardTemplateDeleteOutputSchema,\n CardTemplateGetInputSchema,\n CardTemplateGetOutputSchema,\n CardTemplateListInputSchema,\n CardTemplateListOutputSchema,\n CardTemplateUpdateInputSchema,\n CardTemplateUpdateOutputSchema,\n} from \"#/schemas/card\";\n\nexport const cardTemplateContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/card-templates\",\n summary: \"List card templates\",\n description:\n \"List owned card templates, optionally filtered by notebase. Supports limit and offset pagination.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(CardTemplateListInputSchema)\n .output(CardTemplateListOutputSchema),\n\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/card-templates/{id}\",\n summary: \"Get card template\",\n description: \"Read the complete definition and updatedAt timestamp of an owned card template.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"CARD_TEMPLATE_NOT_FOUND\"))\n .input(CardTemplateGetInputSchema)\n .output(CardTemplateGetOutputSchema),\n\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/card-templates\",\n summary: \"Create card template\",\n description:\n 'Create a template in an owned notebase; it generates a card for every existing note. Each face (front, back) is either { columns: [column IDs], style }, those columns in a built-in style that stays editable in the website\\'s simple mode, or { layout: \"<HTML + Liquid>\" } for a custom design that references a column as {{ [\"<column id>\"] }}. Prefer columns faces. Get column IDs from the notebase schema.',\n tags: [\"Card Templates\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS\",\n \"CARD_TEMPLATE_INVALID_LAYOUT\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(CardTemplateCreateInputSchema)\n .output(CardTemplateCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/card-templates/{id}\",\n summary: \"Update card template\",\n description:\n \"Change an owned template name or faces (see creating a template for the face shapes). Rendered cards reflect the saved template. expectedUpdatedAt guards against editing stale data.\",\n tags: [\"Card Templates\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_TEMPLATE_NOT_FOUND\",\n \"CARD_TEMPLATE_INVALID_NOTEBASE_COLUMNS\",\n \"CARD_TEMPLATE_INVALID_LAYOUT\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(CardTemplateUpdateInputSchema)\n .output(CardTemplateUpdateOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/card-templates/{id}\",\n summary: \"Delete card template\",\n description:\n \"Permanently delete an owned template and its generated cards and review records. Source notes are preserved.\",\n tags: [\"Card Templates\"],\n })\n .errors(pickPublicErrorMap(\"CARD_TEMPLATE_NOT_FOUND\"))\n .input(CardTemplateDeleteInputSchema)\n .output(CardTemplateDeleteOutputSchema),\n};\n","import { EBOOK_ALLOWED_COVER_CONTENT_TYPES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const ebookStatusSchema = z.enum([\"pending\", \"ready\"]);\nexport type EbookStatus = z.infer<typeof ebookStatusSchema>;\n\nexport const ebookCoverContentTypeSchema = z.enum(EBOOK_ALLOWED_COVER_CONTENT_TYPES);\nexport type EbookCoverContentType = z.infer<typeof ebookCoverContentTypeSchema>;\n\nexport const ebookListItemSchema = z\n .object({\n id: z.uuid(),\n title: z.string(),\n author: z.string().nullable(),\n language: z.string().nullable(),\n fileByteSize: z.number().int(),\n status: ebookStatusSchema,\n progressFraction: z.number(),\n lastReadAt: z.coerce.date().nullable(),\n coverUrl: z.url().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type EbookListItem = z.infer<typeof ebookListItemSchema>;\n\nexport const ebookDetailSchema = ebookListItemSchema.extend({\n progressCfi: z.string().nullable(),\n});\nexport type EbookDetail = z.infer<typeof ebookDetailSchema>;\n\nexport const ebookQuotaSchema = z\n .object({\n count: z.number().int().min(0),\n // 0 is a valid limit: uploading is a paid feature, so free plans get no quota.\n limit: z.number().int().min(0),\n })\n .strict();\nexport type EbookQuota = z.infer<typeof ebookQuotaSchema>;\n\nexport const ebookListInputSchema = z.object({}).strict();\nexport type EbookListInput = z.infer<typeof ebookListInputSchema>;\n\nexport const ebookListOutputSchema = z\n .object({\n items: z.array(ebookListItemSchema),\n quota: ebookQuotaSchema,\n })\n .strict();\nexport type EbookListOutput = z.infer<typeof ebookListOutputSchema>;\n\nexport const ebookGetInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookGetInput = z.infer<typeof ebookGetInputSchema>;\n\nexport const ebookGetOutputSchema = z\n .object({\n ebook: ebookDetailSchema,\n })\n .strict();\nexport type EbookGetOutput = z.infer<typeof ebookGetOutputSchema>;\n\nexport const ebookRequestUploadInputSchema = z\n .object({\n title: z.string().min(1).max(500),\n author: z.string().max(500).optional(),\n language: z.string().max(35).optional(),\n // Exact sizes: each upload is signed for them, and storage refuses any other file.\n fileByteSize: z.number().int().min(1),\n cover: z\n .object({\n contentType: ebookCoverContentTypeSchema,\n byteSize: z.number().int().min(1),\n })\n .strict()\n .optional(),\n /**\n * The client's key for this upload. Asking again with the same key, after\n * an answer that never arrived or for a retry, returns the same pending\n * book with fresh targets instead of reserving another place in the\n * library's allowance.\n */\n uploadKey: z.uuid().optional(),\n })\n .strict();\nexport type EbookRequestUploadInput = z.infer<typeof ebookRequestUploadInputSchema>;\n\n/**\n * A signed PUT: send the file to `url` with exactly `headers`. The signature\n * covers the file's type and exact size, so storage refuses any other file.\n */\nexport const ebookPresignedUploadSchema = z\n .object({\n url: z.url(),\n headers: z.record(z.string(), z.string()),\n })\n .strict();\nexport type EbookPresignedUpload = z.infer<typeof ebookPresignedUploadSchema>;\n\nexport const ebookRequestUploadOutputSchema = z\n .object({\n ebookId: z.uuid(),\n upload: ebookPresignedUploadSchema,\n coverUpload: ebookPresignedUploadSchema.nullable(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type EbookRequestUploadOutput = z.infer<typeof ebookRequestUploadOutputSchema>;\n\nexport const ebookFinalizeUploadInputSchema = z\n .object({\n ebookId: z.uuid(),\n })\n .strict();\nexport type EbookFinalizeUploadInput = z.infer<typeof ebookFinalizeUploadInputSchema>;\n\nexport const ebookFinalizeUploadOutputSchema = z\n .object({\n ebook: ebookListItemSchema,\n })\n .strict();\nexport type EbookFinalizeUploadOutput = z.infer<typeof ebookFinalizeUploadOutputSchema>;\n\nexport const ebookGetDownloadUrlInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookGetDownloadUrlInput = z.infer<typeof ebookGetDownloadUrlInputSchema>;\n\nexport const ebookGetDownloadUrlOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type EbookGetDownloadUrlOutput = z.infer<typeof ebookGetDownloadUrlOutputSchema>;\n\nexport const ebookUpdateProgressDataSchema = z\n .object({\n cfi: z.string().max(2000),\n fraction: z.number().min(0).max(1),\n })\n .strict();\nexport type EbookUpdateProgressData = z.infer<typeof ebookUpdateProgressDataSchema>;\n\nexport const ebookUpdateProgressInputSchema = ebookUpdateProgressDataSchema.extend({\n id: z.uuid(),\n});\nexport type EbookUpdateProgressInput = z.infer<typeof ebookUpdateProgressInputSchema>;\n\nexport const ebookUpdateProgressOutputSchema = z\n .object({\n lastReadAt: z.coerce.date(),\n })\n .strict();\nexport type EbookUpdateProgressOutput = z.infer<typeof ebookUpdateProgressOutputSchema>;\n\nexport const ebookRenameDataSchema = z\n .object({\n title: z.string().min(1).max(500),\n author: z.string().max(500).nullable().optional(),\n })\n .strict();\nexport type EbookRenameData = z.infer<typeof ebookRenameDataSchema>;\n\nexport const ebookRenameInputSchema = ebookRenameDataSchema.extend({\n id: z.uuid(),\n});\nexport type EbookRenameInput = z.infer<typeof ebookRenameInputSchema>;\n\nexport const ebookRenameOutputSchema = z\n .object({\n ebook: ebookListItemSchema,\n })\n .strict();\nexport type EbookRenameOutput = z.infer<typeof ebookRenameOutputSchema>;\n\nexport const ebookDeleteInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookDeleteInput = z.infer<typeof ebookDeleteInputSchema>;\n\nexport const ebookDeleteOutputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type EbookDeleteOutput = z.infer<typeof ebookDeleteOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n ebookDeleteInputSchema,\n ebookDeleteOutputSchema,\n ebookFinalizeUploadInputSchema,\n ebookFinalizeUploadOutputSchema,\n ebookGetDownloadUrlInputSchema,\n ebookGetDownloadUrlOutputSchema,\n ebookGetInputSchema,\n ebookGetOutputSchema,\n ebookListInputSchema,\n ebookListOutputSchema,\n ebookRenameInputSchema,\n ebookRenameOutputSchema,\n ebookRequestUploadInputSchema,\n ebookRequestUploadOutputSchema,\n ebookUpdateProgressInputSchema,\n ebookUpdateProgressOutputSchema,\n} from \"#/schemas/ebook\";\n\nconst ebookProcedure = oc;\n\nexport const ebookContract = {\n list: ebookProcedure\n .route({\n method: \"GET\",\n path: \"/ebooks\",\n summary: \"List ebooks with quota\",\n tags: [\"Ebooks\"],\n })\n .input(ebookListInputSchema)\n .output(ebookListOutputSchema),\n\n get: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/ebooks/{id}\",\n summary: \"Get an ebook with reading progress\",\n tags: [\"Ebooks\"],\n })\n .input(ebookGetInputSchema)\n .output(ebookGetOutputSchema),\n\n requestUpload: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_LIMIT_EXCEEDED\", \"EBOOK_FILE_TOO_LARGE\"))\n .route({\n method: \"POST\",\n path: \"/ebooks/uploads\",\n summary: \"Request presigned upload URLs for a new ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookRequestUploadInputSchema)\n .output(ebookRequestUploadOutputSchema),\n\n finalizeUpload: ebookProcedure\n .errors(\n pickPublicErrorMap(\"EBOOK_NOT_FOUND\", \"EBOOK_UPLOAD_NOT_COMPLETED\", \"EBOOK_FILE_TOO_LARGE\"),\n )\n .route({\n method: \"POST\",\n path: \"/ebooks/{ebookId}/finalize\",\n summary: \"Finalize an ebook upload\",\n tags: [\"Ebooks\"],\n })\n .input(ebookFinalizeUploadInputSchema)\n .output(ebookFinalizeUploadOutputSchema),\n\n getDownloadUrl: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/ebooks/{id}/download-url\",\n summary: \"Get a presigned download URL for an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookGetDownloadUrlInputSchema)\n .output(ebookGetDownloadUrlOutputSchema),\n\n updateProgress: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"PATCH\",\n path: \"/ebooks/{id}/progress\",\n summary: \"Update ebook reading progress\",\n tags: [\"Ebooks\"],\n })\n .input(ebookUpdateProgressInputSchema)\n .output(ebookUpdateProgressOutputSchema),\n\n rename: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"PATCH\",\n path: \"/ebooks/{id}\",\n summary: \"Rename an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookRenameInputSchema)\n .output(ebookRenameOutputSchema),\n\n delete: ebookProcedure\n .errors(pickPublicErrorMap(\"EBOOK_NOT_FOUND\"))\n .route({\n method: \"DELETE\",\n path: \"/ebooks/{id}\",\n summary: \"Delete an ebook\",\n tags: [\"Ebooks\"],\n })\n .input(ebookDeleteInputSchema)\n .output(ebookDeleteOutputSchema),\n};\n","import { z } from \"zod\";\nimport { appLocaleSchema } from \"./app-locale\";\n\n// Which marketing and lifecycle emails a user gets, by category. Read and\n// changed signed in (the settings page), or through the signed token in an\n// email's unsubscribe link (the unsubscribe page that link opens, which needs\n// no sign-in). Category names come from the server in the requested locale.\n\n/** A category's key, such as `promotions`. */\nexport const emailCategoryKeySchema = z\n .string()\n .max(64)\n .regex(/^[a-z][a-z0-9_]*$/);\nexport type EmailCategoryKey = z.infer<typeof emailCategoryKeySchema>;\n\n/** The token in an email's unsubscribe link. */\nexport const emailLinkTokenSchema = z.string().min(1).max(1024);\n\nexport const emailCategoryStateSchema = z\n .object({\n key: z.string(),\n // In the requested locale, or English when the category has none for it.\n name: z.string(),\n description: z.string().nullable(),\n // Promotional mail.\n commercial: z.boolean(),\n // Notices about the account and the service, which nobody can unsubscribe\n // from: always subscribed, \"unsubscribe from all\" included, and a change\n // to it is ignored. Show it on, without a way to turn it off.\n required: z.boolean(),\n // Whether the user gets this category now, \"unsubscribe from all\" included.\n subscribed: z.boolean(),\n })\n .strict();\nexport type EmailCategoryState = z.infer<typeof emailCategoryStateSchema>;\n\n/**\n * The category whose emails a person can time: Practice reminders, seeded as\n * `practice` (packages/db's migration 0067). The settings page shows the\n * time under its switch.\n */\nexport const PRACTICE_REMINDER_CATEGORY_KEY = \"practice\";\n\n/**\n * When practice reminders reach someone who never chose a time: 18:00 in\n * their own time zone. The page shows it as the choice until one is made;\n * Ribbit's reminder automation sets the same as its own time, for people\n * without one (docs/ribbit/phase-3-automations.md).\n */\nexport const PRACTICE_REMINDER_DEFAULT_TIME = \"18:00\";\n\n/** A time of day on the hour, `HH:00`: Ribbit takes people into a schedule once an hour. */\nexport const practiceReminderTimeSchema = z\n .string()\n .regex(/^([01]\\d|2[0-3]):00$/, \"Choose a time on the hour.\");\nexport type PracticeReminderTime = z.infer<typeof practiceReminderTimeSchema>;\n\n/** The times the page offers: every hour of the day. */\nexport const PRACTICE_REMINDER_TIMES: readonly PracticeReminderTime[] = Array.from(\n { length: 24 },\n (_, hour) => `${String(hour).padStart(2, \"0\")}:00`,\n);\n\n/**\n * The reminders area of `user_preferences`, as the database holds it: what\n * is not there, or no longer reads, is the default. `practiceTime` is the\n * practice reminder's time of day, in the person's own zone; null until they\n * choose one.\n */\nexport const remindersPreferencesSchema = z.object({\n practiceTime: practiceReminderTimeSchema.nullable().catch(null).default(null),\n});\nexport type RemindersPreferences = z.infer<typeof remindersPreferencesSchema>;\n\nexport const emailPreferencesStateSchema = z\n .object({\n // In display order; archived categories are left out.\n categories: z.array(emailCategoryStateSchema),\n unsubscribedAll: z.boolean(),\n // When practice reminders reach them, in their own time zone; null while\n // they never chose one (the page then shows PRACTICE_REMINDER_DEFAULT_TIME).\n practiceReminderTime: practiceReminderTimeSchema.nullable(),\n })\n .strict();\nexport type EmailPreferencesState = z.infer<typeof emailPreferencesStateSchema>;\n\n/**\n * What the page a link opens shows on top of the state: whose preferences they\n * are, without the full address, and the category the link was for, if any.\n */\nexport const emailPreferencesByTokenStateSchema = z\n .object({\n ...emailPreferencesStateSchema.shape,\n maskedEmail: z.string(),\n // The link's category, when it is one the user can unsubscribe from: null\n // for a link without one, or for an archived, required or unknown one.\n highlightCategory: z.string().nullable(),\n })\n .strict();\nexport type EmailPreferencesByTokenState = z.infer<typeof emailPreferencesByTokenStateSchema>;\n\nconst emailPreferencesChangesShape = {\n // Subscribes (true) or unsubscribes (false) the categories it names, and\n // leaves the rest alone. Subscribing to one after \"unsubscribe from all\"\n // ends it, and every other category stays unsubscribed. A required category\n // is ignored.\n categories: z.record(emailCategoryKeySchema, z.boolean()).optional(),\n // true unsubscribes from every category but the required ones, including\n // categories added later; false ends that and leaves each category as it was\n // before.\n unsubscribedAll: z.boolean().optional(),\n // Sets when practice reminders reach them (null: back to the default); left\n // out, it stays as it is.\n practiceReminderTime: practiceReminderTimeSchema.nullable().optional(),\n};\n\nexport const emailPreferencesGetInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type EmailPreferencesGetInput = z.infer<typeof emailPreferencesGetInputSchema>;\n\nexport const emailPreferencesUpdateInputSchema = z\n .object({\n locale: appLocaleSchema,\n ...emailPreferencesChangesShape,\n })\n .strict();\nexport type EmailPreferencesUpdateInput = z.infer<typeof emailPreferencesUpdateInputSchema>;\n\nexport const emailPreferencesGetByTokenInputSchema = z\n .object({\n token: emailLinkTokenSchema,\n locale: appLocaleSchema,\n })\n .strict();\nexport type EmailPreferencesGetByTokenInput = z.infer<typeof emailPreferencesGetByTokenInputSchema>;\n\nexport const emailPreferencesUpdateByTokenInputSchema = z\n .object({\n token: emailLinkTokenSchema,\n locale: appLocaleSchema,\n ...emailPreferencesChangesShape,\n })\n .strict();\nexport type EmailPreferencesUpdateByTokenInput = z.infer<\n typeof emailPreferencesUpdateByTokenInputSchema\n>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n emailPreferencesByTokenStateSchema,\n emailPreferencesGetByTokenInputSchema,\n emailPreferencesGetInputSchema,\n emailPreferencesStateSchema,\n emailPreferencesUpdateByTokenInputSchema,\n emailPreferencesUpdateInputSchema,\n} from \"#/schemas/email-preferences\";\n\n// Every write returns the whole state, so a client can update optimistically\n// and then take the server's answer.\nexport const emailPreferencesContract = {\n get: oc\n .route({\n method: \"GET\",\n path: \"/users/me/email-preferences\",\n summary: \"Get which emails the authenticated user receives\",\n tags: [\"Email preferences\"],\n })\n .input(emailPreferencesGetInputSchema)\n .output(emailPreferencesStateSchema),\n update: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/email-preferences\",\n summary: \"Change which emails the authenticated user receives\",\n tags: [\"Email preferences\"],\n })\n .input(emailPreferencesUpdateInputSchema)\n .output(emailPreferencesStateSchema),\n // Public: the token in an email's link stands in for signing in. POST keeps\n // the token out of URLs and logs.\n getByToken: oc\n .route({\n method: \"POST\",\n path: \"/email-preferences/by-token\",\n summary: \"Get the email preferences an email link is for\",\n tags: [\"Email preferences\"],\n })\n .errors(pickPublicErrorMap(\"EMAIL_LINK_INVALID\"))\n .input(emailPreferencesGetByTokenInputSchema)\n .output(emailPreferencesByTokenStateSchema),\n updateByToken: oc\n .route({\n method: \"POST\",\n path: \"/email-preferences/by-token/update\",\n summary: \"Change the email preferences an email link is for\",\n tags: [\"Email preferences\"],\n })\n .errors(pickPublicErrorMap(\"EMAIL_LINK_INVALID\"))\n .input(emailPreferencesUpdateByTokenInputSchema)\n .output(emailPreferencesByTokenStateSchema),\n};\n","import { GATED_FEATURE_KEYS } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const GatedFeatureKeySchema = z.enum(GATED_FEATURE_KEYS);\nexport type GatedFeatureKey = z.infer<typeof GatedFeatureKeySchema>;\n\nexport const FeatureAccessStatusInputSchema = z\n .object({\n featureKey: GatedFeatureKeySchema,\n })\n .strict();\nexport type FeatureAccessStatusInput = z.infer<typeof FeatureAccessStatusInputSchema>;\n\nexport const FeatureAccessStatusOutputSchema = z.object({\n featureKey: GatedFeatureKeySchema,\n allowed: z.boolean(),\n});\nexport type FeatureAccessStatusOutput = z.infer<typeof FeatureAccessStatusOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport {\n FeatureAccessStatusInputSchema,\n FeatureAccessStatusOutputSchema,\n} from \"#/schemas/feature-access\";\n\nexport const featureAccessContract = {\n status: oc\n .route({\n method: \"GET\",\n path: \"/feature-access/status\",\n summary: \"Get whether the caller can use a gated feature\",\n tags: [\"Feature Access\"],\n })\n .input(FeatureAccessStatusInputSchema)\n .output(FeatureAccessStatusOutputSchema),\n};\n","import { eventIterator, oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n HostedAiCreditPoolsInputSchema,\n HostedAiCreditPoolsOutputSchema,\n HostedAiNoteSuggestionStreamInputSchema,\n HostedAiStatusInputSchema,\n HostedAiStatusOutputSchema,\n HostedAiStreamPartSchema,\n HostedAiStreamStructuredObjectInputSchema,\n HostedAiStreamTextInputSchema,\n} from \"#/schemas/hosted-ai\";\n\nconst hostedAiStreamErrors = pickPublicErrorMap(\n \"HOSTED_AI_TIER_RESTRICTED\",\n \"HOSTED_AI_QUOTA_EXHAUSTED\",\n);\n\nexport const hostedAiContract = {\n pools: oc\n .route({\n method: \"GET\",\n path: \"/hosted-ai/pools\",\n summary: \"Get shared Built-in AI credit pools for a feature\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiCreditPoolsInputSchema)\n .output(HostedAiCreditPoolsOutputSchema),\n status: oc\n .route({\n method: \"GET\",\n path: \"/hosted-ai/status\",\n summary: \"Get Built-in AI availability and quota status\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStatusInputSchema)\n .output(HostedAiStatusOutputSchema),\n translate: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/translate/stream-text\",\n summary: \"Stream hosted translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n selectionTranslation: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/selection-translation/stream-text\",\n summary: \"Stream hosted selection translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n videoSubtitles: {\n // Subtitle lines and the video summary share this route: both are short\n // text and both bill against `videoSubtitles`.\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/video-subtitles/stream-text\",\n summary: \"Stream hosted subtitle translation or video summary text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n /**\n * Segmentation shares the `videoSubtitles` feature but not its route,\n * because `endpointMaxOutputTokens` sizes the credit reservation: emitting\n * a WebVTT block needs several times a subtitle line's budget, and folding\n * both into one route would make every line reserve — and, near the end of\n * a credit window, fail to afford — what only segmentation needs.\n */\n streamSegmentation: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/video-subtitles/stream-segmentation\",\n summary: \"Stream hosted subtitle segmentation output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n inputTranslation: {\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/input-translation/stream-text\",\n summary: \"Stream hosted input box translation text output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n languageDetection: {\n // Detection wants one short string back, not a stream, but the quota\n // reserve/settle path is stream-shaped end to end. Reusing it keeps one\n // metering implementation; the client collects the deltas.\n streamText: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/language-detection/stream-text\",\n summary: \"Stream hosted language detection output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamTextInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n customAction: {\n streamStructuredObject: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/custom-actions/stream-structured-object\",\n summary: \"Stream hosted custom action structured output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiStreamStructuredObjectInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n noteSuggestion: {\n streamStructuredObject: oc\n .route({\n method: \"POST\",\n path: \"/hosted-ai/note-suggestions/stream-structured-object\",\n summary: \"Stream hosted note suggestion structured output\",\n tags: [\"Hosted AI\"],\n })\n .input(HostedAiNoteSuggestionStreamInputSchema)\n .output(eventIterator(HostedAiStreamPartSchema))\n .errors(hostedAiStreamErrors),\n },\n};\n","import { z } from \"zod\";\n\nexport const MASTERY_GOAL_TARGET_MAX = 1_000_000;\n\n/** How many mastered cards to aim for: the cards `stats.srsMemoryGrowth` counts. */\nexport const masteryGoalTargetSchema = z.number().int().min(1).max(MASTERY_GOAL_TARGET_MAX);\nexport type MasteryGoalTarget = z.infer<typeof masteryGoalTargetSchema>;\n\n/** `null` clears the goal. */\nexport const masteryGoalUpdateInputSchema = z\n .object({\n target: masteryGoalTargetSchema.nullable(),\n })\n .strict();\nexport type MasteryGoalUpdateInput = z.infer<typeof masteryGoalUpdateInputSchema>;\n\n/** The goal's target, or `null` while none is set. */\nexport const masteryGoalOutputSchema = z\n .object({\n target: masteryGoalTargetSchema.nullable(),\n })\n .strict();\nexport type MasteryGoalOutput = z.infer<typeof masteryGoalOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { masteryGoalOutputSchema, masteryGoalUpdateInputSchema } from \"#/schemas/mastery-goal\";\n\nexport const masteryGoalContract = {\n get: oc\n .route({\n method: \"GET\",\n path: \"/mastery-goal\",\n summary: \"Get the authenticated user's mastered-cards goal\",\n tags: [\"Goals\"],\n })\n .output(masteryGoalOutputSchema),\n update: oc\n .route({\n method: \"PUT\",\n path: \"/mastery-goal\",\n summary: \"Set or clear the authenticated user's mastered-cards goal\",\n tags: [\"Goals\"],\n })\n .input(masteryGoalUpdateInputSchema)\n .output(masteryGoalOutputSchema),\n};\n","import { z } from \"zod\";\n\nexport const mcpConnectionSchema = z\n .object({\n /** OAuth client identifier. For a CIMD client this is an https URL. */\n clientId: z.string(),\n /** The client's registered display name, absent when it never gave one. */\n clientName: z.string().nullable(),\n scopes: z.array(z.string()),\n requestedUserInfoClaims: z.array(z.string()),\n grantedAt: z.date().nullable(),\n updatedAt: z.date().nullable(),\n /**\n * When this client last obtained an access token — the closest honest\n * proxy for \"last used\" the OAuth tables record. A token is issued on\n * connect and on every refresh, so an idle client's value stops advancing.\n */\n lastAuthorizedAt: z.date().nullable(),\n })\n .strict();\nexport type McpConnection = z.infer<typeof mcpConnectionSchema>;\n\nexport const mcpConnectionListOutputSchema = z.array(mcpConnectionSchema);\n\nexport const mcpConnectionRevokeInputSchema = z.object({ clientId: z.string().min(1) }).strict();\nexport type McpConnectionRevokeInput = z.infer<typeof mcpConnectionRevokeInputSchema>;\n\nexport const mcpConnectionRevokeOutputSchema = z.object({ clientId: z.string() }).strict();\n\n/**\n * How many MCP tool calls the caller has used of their plan's\n * `MCP_DAILY_CALL_LIMITS`, read without counting one. The window is 24 hours\n * from the first call in it, not a calendar day.\n */\nexport const mcpCallUsageSchema = z\n .object({\n /** Calls used in the current window, at most `limit`. */\n usedCalls: z.number().int().min(0),\n /** null: the plan has no daily limit. */\n limit: z.number().int().positive().nullable(),\n /** When the current 24-hour window ends; null when no window is open or there is no limit. */\n resetAt: z.iso.datetime().nullable(),\n })\n .strict();\nexport type McpCallUsage = z.infer<typeof mcpCallUsageSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport {\n mcpCallUsageSchema,\n mcpConnectionListOutputSchema,\n mcpConnectionRevokeInputSchema,\n mcpConnectionRevokeOutputSchema,\n} from \"#/schemas/mcp-connection\";\n\nexport const mcpConnectionContract = {\n list: oc\n .route({\n method: \"GET\",\n path: \"/mcp-connections\",\n summary: \"List the OAuth clients the caller has authorized\",\n tags: [\"MCP Connections\"],\n })\n .output(mcpConnectionListOutputSchema),\n revoke: oc\n .route({\n method: \"POST\",\n path: \"/mcp-connections/revoke\",\n summary: \"Withdraw a client's authorization and revoke its tokens\",\n tags: [\"MCP Connections\"],\n })\n .input(mcpConnectionRevokeInputSchema)\n .output(mcpConnectionRevokeOutputSchema),\n usage: oc\n .route({\n method: \"GET\",\n path: \"/mcp-connections/usage\",\n summary: \"Get the MCP tool calls the caller has used of their plan's daily limit\",\n tags: [\"MCP Connections\"],\n })\n .input(z.object({}).strict())\n .output(mcpCallUsageSchema),\n};\n","import { MEDIA_ASSET_STATUS_VALUES, MEDIA_CONTENT_TYPES } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const mediaContentTypeSchema = z.enum(MEDIA_CONTENT_TYPES);\nexport type MediaContentType = z.infer<typeof mediaContentTypeSchema>;\n\nexport const mediaAssetStatusSchema = z.enum(MEDIA_ASSET_STATUS_VALUES);\nexport type MediaAssetStatus = z.infer<typeof mediaAssetStatusSchema>;\n\n/** Why the worker rejected an upload. */\nexport const mediaFailureCodeSchema = z.enum([\n \"unsupported_format\",\n \"invalid_file\",\n \"file_too_large\",\n \"image_too_large\",\n \"audio_too_long\",\n \"quota_exceeded\",\n \"processing_failed\",\n]);\nexport type MediaFailureCode = z.infer<typeof mediaFailureCodeSchema>;\n\nexport const mediaAssetMetadataSchema = z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"image\"), width: z.number().int(), height: z.number().int() })\n .strict(),\n z.object({ kind: z.literal(\"audio\"), durationMs: z.number().int() }).strict(),\n]);\n\nexport const mediaAssetSchema = z\n .object({\n id: z.uuid(),\n /** What a cell stores to reference the asset; null until it is ready. */\n uri: z.string().nullable(),\n status: mediaAssetStatusSchema,\n contentType: z.string().nullable(),\n fileByteSize: z.number().int(),\n metadata: mediaAssetMetadataSchema.nullable(),\n failureCode: mediaFailureCodeSchema.nullable(),\n createdAt: z.coerce.date(),\n })\n .strict();\nexport type MediaAsset = z.infer<typeof mediaAssetSchema>;\n\nexport const mediaRequestUploadInputSchema = z\n .object({\n contentType: mediaContentTypeSchema,\n // The exact size: the upload is signed for it, and storage refuses any other file.\n byteSize: z.number().int().min(1),\n })\n .strict();\nexport type MediaRequestUploadInput = z.infer<typeof mediaRequestUploadInputSchema>;\n\nexport const mediaRequestUploadOutputSchema = z\n .object({\n assetId: z.uuid(),\n /** A signed PUT: send the file to `url` with exactly `headers`. */\n upload: z.object({ url: z.url(), headers: z.record(z.string(), z.string()) }).strict(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type MediaRequestUploadOutput = z.infer<typeof mediaRequestUploadOutputSchema>;\n\nexport const mediaAssetIdInputSchema = z.object({ id: z.uuid() }).strict();\nexport type MediaAssetIdInput = z.infer<typeof mediaAssetIdInputSchema>;\n\nexport const mediaAssetOutputSchema = z.object({ asset: mediaAssetSchema }).strict();\nexport type MediaAssetOutput = z.infer<typeof mediaAssetOutputSchema>;\n\nexport const mediaUsageOutputSchema = z\n .object({\n usedBytes: z.number().int().min(0),\n /** Held by uploads that are not done yet. */\n reservedBytes: z.number().int().min(0),\n limitBytes: z.number().int().min(0),\n })\n .strict();\nexport type MediaUsageOutput = z.infer<typeof mediaUsageOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n mediaAssetIdInputSchema,\n mediaAssetOutputSchema,\n mediaRequestUploadInputSchema,\n mediaRequestUploadOutputSchema,\n mediaUsageOutputSchema,\n} from \"#/schemas/media\";\n\nexport const mediaContract = {\n requestUpload: oc\n .errors(\n pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_FILE_TOO_LARGE\", \"MEDIA_QUOTA_EXCEEDED\"),\n )\n .route({\n method: \"POST\",\n path: \"/media/uploads\",\n summary: \"Reserve space and get a signed upload URL for a media file\",\n tags: [\"Media\"],\n })\n .input(mediaRequestUploadInputSchema)\n .output(mediaRequestUploadOutputSchema),\n\n completeUpload: oc\n .errors(\n pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_NOT_FOUND\", \"MEDIA_UPLOAD_NOT_COMPLETED\"),\n )\n .route({\n method: \"POST\",\n path: \"/media/{id}/complete\",\n summary: \"Queue an uploaded media file for validation\",\n tags: [\"Media\"],\n })\n .input(mediaAssetIdInputSchema)\n .output(mediaAssetOutputSchema),\n\n get: oc\n .errors(pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\", \"MEDIA_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/media/{id}\",\n summary: \"Get a media asset and its upload status\",\n tags: [\"Media\"],\n })\n .input(mediaAssetIdInputSchema)\n .output(mediaAssetOutputSchema),\n\n usage: oc\n .errors(pickPublicErrorMap(\"MEDIA_BETA_RESTRICTED\"))\n .route({\n method: \"GET\",\n path: \"/media/usage\",\n summary: \"Get the media space used, reserved and allowed\",\n tags: [\"Media\"],\n })\n .input(z.object({}).strict())\n .output(mediaUsageOutputSchema),\n};\n","import { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n NOTEBASE_COLUMN_MAX_WIDTH,\n NOTEBASE_COLUMN_MIN_WIDTH,\n notebaseColumnConfigSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const notebaseColumnWidthSchema = z\n .number()\n .int()\n .min(NOTEBASE_COLUMN_MIN_WIDTH)\n .max(NOTEBASE_COLUMN_MAX_WIDTH);\n\nexport const notebaseColumnSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n name: z.string(),\n config: notebaseColumnConfigSchema,\n position: z.number(),\n isPrimary: z.boolean(),\n width: z.number().nullable(),\n wrap: z.boolean(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseColumn = z.infer<typeof notebaseColumnSchema>;\n\nexport const notebaseColumnCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n config: notebaseColumnConfigSchema,\n })\n .strict();\nexport type NotebaseColumnCreateData = z.infer<typeof notebaseColumnCreateDataSchema>;\n\nexport const notebaseColumnUpdateDataSchema = z\n .object({\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n name: z.string().min(1).optional(),\n config: notebaseColumnConfigSchema.optional(),\n width: notebaseColumnWidthSchema.nullable().optional(),\n wrap: z.boolean().optional(),\n })\n .strict();\nexport type NotebaseColumnUpdateData = z.infer<typeof notebaseColumnUpdateDataSchema>;\n\nexport const NotebaseColumnCreateInputSchema = z.object({\n notebaseId: z.uuid(),\n data: notebaseColumnCreateDataSchema,\n});\nexport type NotebaseColumnCreateInput = z.infer<typeof NotebaseColumnCreateInputSchema>;\n\nexport const NotebaseColumnCreateOutputSchema = z.object({\n field: notebaseColumnSchema,\n txid: z.number(),\n});\nexport type NotebaseColumnCreateOutput = z.infer<typeof NotebaseColumnCreateOutputSchema>;\n\nexport const NotebaseColumnUpdateInputSchema = z.object({\n notebaseColumnId: z.uuid(),\n data: notebaseColumnUpdateDataSchema,\n});\nexport type NotebaseColumnUpdateInput = z.infer<typeof NotebaseColumnUpdateInputSchema>;\n\nexport const NotebaseColumnUpdateOutputSchema = z.object({\n field: notebaseColumnSchema,\n txid: z.number(),\n});\nexport type NotebaseColumnUpdateOutput = z.infer<typeof NotebaseColumnUpdateOutputSchema>;\n\nexport const NotebaseColumnDeleteInputSchema = z.object({\n notebaseColumnId: z.uuid(),\n});\nexport type NotebaseColumnDeleteInput = z.infer<typeof NotebaseColumnDeleteInputSchema>;\n\nexport const NotebaseColumnDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseColumnDeleteOutput = z.infer<typeof NotebaseColumnDeleteOutputSchema>;\n\nexport const NotebaseColumnReorderInputSchema = z.object({\n notebaseId: z.uuid(),\n ids: z.array(z.uuid()),\n});\nexport type NotebaseColumnReorderInput = z.infer<typeof NotebaseColumnReorderInputSchema>;\n\nexport const NotebaseColumnReorderOutputSchema = z.object({\n txid: z.number(),\n});\nexport type NotebaseColumnReorderOutput = z.infer<typeof NotebaseColumnReorderOutputSchema>;\n","import { paginationShape, pageSchema } from \"./pagination\";\nimport { deletionResultSchema, expectedUpdatedAtSchema } from \"./resource-mutation\";\nimport {\n noteCreatedViaSchema,\n noteOriginInputSchema,\n noteOriginSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\nexport const notebaseRowCellsSchema = z.record(z.string(), z.unknown());\n\nexport const notebaseRowSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n cells: notebaseRowCellsSchema,\n position: z.number(),\n origin: noteOriginSchema\n .nullish()\n .describe(\n \"Where the note's content came from, set when it was created: a web page (url, title), a book on the user's shelf (ebookId, its title then, and cfi, the EPUB location of the selection), or a video (url, title, seconds into it). Null when it has none, or when it was created before this was recorded.\",\n ),\n createdVia: noteCreatedViaSchema\n .nullish()\n .describe(\n 'Which client created the note: \"web\", \"extension\", \"mobile\", \"mcp\" (with the MCP client\\'s id and the name it registered under) or \"unknown\". Null for notes created before this was recorded.',\n ),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseRow = z.infer<typeof notebaseRowSchema>;\n\n/**\n * Where a new note's content came from; see `noteOriginInputSchema`. Optional\n * metadata never costs the note: an origin that does not parse is dropped and\n * the note is saved without one.\n */\nexport const notebaseRowOriginInputSchema = noteOriginInputSchema\n .optional()\n .catch(undefined)\n .describe(\n \"Where the note's content came from: a web page or video by its http(s) URL, or a book on the user's shelf by its id. Stored once and never edited. Optional: an origin that cannot be used is left out and the note is still saved.\",\n );\n\nexport const notebaseRowCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n cells: notebaseRowCellsSchema.optional(),\n origin: notebaseRowOriginInputSchema,\n })\n .strict();\nexport type NotebaseRowCreateData = z.infer<typeof notebaseRowCreateDataSchema>;\n\nexport const notebaseRowUpdateDataSchema = z\n .object({\n cells: notebaseRowCellsSchema.optional(),\n expectedUpdatedAt: expectedUpdatedAtSchema.optional(),\n })\n .strict();\nexport type NotebaseRowUpdateData = z.infer<typeof notebaseRowUpdateDataSchema>;\n\nexport const NotebaseRowCreateInputSchema = z.object({\n notebaseId: z.uuid(),\n data: notebaseRowCreateDataSchema,\n});\nexport type NotebaseRowCreateInput = z.infer<typeof NotebaseRowCreateInputSchema>;\n\nexport const NotebaseRowCreateOutputSchema = z.object({\n note: notebaseRowSchema,\n txid: z.number(),\n});\nexport type NotebaseRowCreateOutput = z.infer<typeof NotebaseRowCreateOutputSchema>;\n\nexport const NOTEBASE_ROW_CREATE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowCreateManyInputSchema = z\n .object({\n notebaseId: z.uuid(),\n rows: z.array(notebaseRowCreateDataSchema).min(1).max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n\n input.rows.forEach((row, index) => {\n if (row.id === undefined) {\n return;\n }\n\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"rows\", index, \"id\"],\n });\n return;\n }\n\n seenIds.add(row.id);\n });\n });\nexport type NotebaseRowCreateManyInput = z.infer<typeof NotebaseRowCreateManyInputSchema>;\n\nexport const NotebaseRowCreateManyOutputSchema = z.object({\n items: z.array(notebaseRowSchema),\n txid: z.number(),\n});\nexport type NotebaseRowCreateManyOutput = z.infer<typeof NotebaseRowCreateManyOutputSchema>;\n\nexport const NotebaseRowUpdateInputSchema = z.object({\n notebaseRowId: z.uuid(),\n data: notebaseRowUpdateDataSchema,\n});\nexport type NotebaseRowUpdateInput = z.infer<typeof NotebaseRowUpdateInputSchema>;\n\nexport const NotebaseRowUpdateOutputSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n cells: notebaseRowCellsSchema,\n position: z.number().int(),\n origin: notebaseRowSchema.shape.origin,\n createdVia: notebaseRowSchema.shape.createdVia,\n createdAt: z.date(),\n updatedAt: z.date(),\n txid: z.number(),\n});\nexport type NotebaseRowUpdateOutput = z.infer<typeof NotebaseRowUpdateOutputSchema>;\n\nexport const NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowUpdateManyInputSchema = z\n .object({\n notebaseId: z.uuid(),\n rows: z\n .array(\n z.object({\n id: z.uuid(),\n data: notebaseRowUpdateDataSchema,\n }),\n )\n .min(1)\n .max(NOTEBASE_ROW_UPDATE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n input.rows.forEach((row, index) => {\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"rows\", index, \"id\"],\n });\n }\n seenIds.add(row.id);\n });\n });\nexport type NotebaseRowUpdateManyInput = z.infer<typeof NotebaseRowUpdateManyInputSchema>;\n\nexport const NotebaseRowUpdateManyOutputSchema = z.object({\n items: z.array(notebaseRowSchema),\n txid: z.number(),\n});\nexport type NotebaseRowUpdateManyOutput = z.infer<typeof NotebaseRowUpdateManyOutputSchema>;\n\nexport const NotebaseRowDeleteInputSchema = z.object({\n notebaseRowId: z.uuid(),\n});\nexport type NotebaseRowDeleteInput = z.infer<typeof NotebaseRowDeleteInputSchema>;\n\nexport const NotebaseRowDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseRowDeleteOutput = z.infer<typeof NotebaseRowDeleteOutputSchema>;\n\nexport const NOTEBASE_ROW_DELETE_MANY_MAX_ROWS = 50;\n\nexport const NotebaseRowDeleteManyInputSchema = z\n .object({\n ids: z.array(z.uuid()).min(1).max(NOTEBASE_ROW_DELETE_MANY_MAX_ROWS),\n })\n .superRefine((input, ctx) => {\n const seenIds = new Set<string>();\n input.ids.forEach((id, index) => {\n if (seenIds.has(id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${id}\".`,\n path: [\"ids\", index],\n });\n }\n seenIds.add(id);\n });\n });\nexport type NotebaseRowDeleteManyInput = z.infer<typeof NotebaseRowDeleteManyInputSchema>;\n\nexport const NotebaseRowDeleteManyOutputSchema = z.object({ ids: z.array(z.uuid()) });\nexport type NotebaseRowDeleteManyOutput = z.infer<typeof NotebaseRowDeleteManyOutputSchema>;\n\nexport const NotebaseRowReorderInputSchema = z.object({\n notebaseId: z.uuid(),\n ids: z.array(z.uuid()),\n});\nexport type NotebaseRowReorderInput = z.infer<typeof NotebaseRowReorderInputSchema>;\n\nexport const NotebaseRowReorderOutputSchema = z.object({\n txid: z.number(),\n});\nexport type NotebaseRowReorderOutput = z.infer<typeof NotebaseRowReorderOutputSchema>;\n\nexport const NotebaseRowListInputSchema = z\n .object({\n notebaseId: z.uuid().optional(),\n // Two characters is already a meaningful CJK query; one matches nearly\n // every note while costing the same full scan, so the floor is a cost\n // control rather than an ergonomic preference.\n query: z.string().trim().min(2).max(200).optional(),\n ...paginationShape,\n })\n // Listing without a notebase is a plain indexed read. Searching is not: it\n // expands every candidate row's cells and cannot use an index, so it stays\n // scoped to one notebase, where `notebase_rows_notebase_id_idx` bounds the\n // candidate set. Searching everything means iterating over notebases.\n .refine((input) => input.query === undefined || input.notebaseId !== undefined, {\n error: \"notebaseId is required when query is set\",\n path: [\"notebaseId\"],\n });\nexport type NotebaseRowListInput = z.infer<typeof NotebaseRowListInputSchema>;\nexport const NotebaseRowListOutputSchema = pageSchema(notebaseRowSchema);\nexport const NotebaseRowGetInputSchema = z.object({ id: z.uuid() });\nexport const NotebaseRowGetOutputSchema = notebaseRowSchema;\n","import { z } from \"zod\";\n\nexport const notebaseViewTypeSchema = z.enum([\"table\", \"kanban\", \"gallery\"]);\nexport type NotebaseViewType = z.infer<typeof notebaseViewTypeSchema>;\n\nexport const notebaseViewConfigSchema = z\n .object({\n notebaseColumnWidths: z.record(z.string(), z.number()).optional(),\n hiddenNotebaseColumns: z.array(z.string()).optional(),\n groupByNotebaseColumnId: z.string().optional(),\n })\n .catchall(z.unknown());\nexport type NotebaseViewConfig = z.infer<typeof notebaseViewConfigSchema>;\n\nexport const notebaseViewFilterSchema = z\n .object({\n notebaseColumnId: z.string(),\n operator: z.string(),\n value: z.unknown(),\n })\n .strict();\nexport type NotebaseViewFilter = z.infer<typeof notebaseViewFilterSchema>;\n\nexport const notebaseViewFiltersSchema = z.array(notebaseViewFilterSchema);\n\nexport const notebaseViewSortSchema = z\n .object({\n notebaseColumnId: z.string(),\n direction: z.enum([\"asc\", \"desc\"]),\n })\n .strict();\nexport type NotebaseViewSort = z.infer<typeof notebaseViewSortSchema>;\n\nexport const notebaseViewSortsSchema = z.array(notebaseViewSortSchema);\n\nexport const notebaseViewCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n type: notebaseViewTypeSchema,\n config: notebaseViewConfigSchema.optional(),\n filters: notebaseViewFiltersSchema.optional(),\n sorts: notebaseViewSortsSchema.optional(),\n })\n .strict();\nexport type NotebaseViewCreateData = z.infer<typeof notebaseViewCreateDataSchema>;\n\nexport const notebaseViewUpdateDataSchema = z\n .object({\n name: z.string().min(1).optional(),\n type: notebaseViewTypeSchema.optional(),\n config: notebaseViewConfigSchema.optional(),\n filters: notebaseViewFiltersSchema.optional(),\n sorts: notebaseViewSortsSchema.optional(),\n })\n .strict();\nexport type NotebaseViewUpdateData = z.infer<typeof notebaseViewUpdateDataSchema>;\n\nexport const notebaseViewSchema = z.object({\n id: z.string(),\n notebaseId: z.string(),\n name: z.string(),\n type: notebaseViewTypeSchema,\n config: notebaseViewConfigSchema.nullable(),\n filters: z.array(z.unknown()).nullable(),\n sorts: z.array(z.unknown()).nullable(),\n position: z.number(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n});\nexport type NotebaseView = z.infer<typeof notebaseViewSchema>;\n","import { deletionResultSchema } from \"./resource-mutation\";\nimport {\n notebaseColumnConfigSchema,\n schedulingParamsShape,\n srsModelVersionSchema,\n srsSleepSourceSchema,\n srsWeightsSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { notebaseColumnSchema } from \"./notebase-column\";\nimport {\n NOTEBASE_ROW_CREATE_MANY_MAX_ROWS,\n notebaseRowOriginInputSchema,\n notebaseRowSchema,\n} from \"./notebase-row\";\nimport { notebaseViewSchema } from \"./notebase-view\";\n\nexport const NotebaseListInputSchema = z.object({});\nexport type NotebaseListInput = z.infer<typeof NotebaseListInputSchema>;\n\nexport const notebaseSummarySchema = z.object({\n id: z.string(),\n name: z.string(),\n});\nexport type NotebaseSummary = z.infer<typeof notebaseSummarySchema>;\n\nexport const NotebaseListItemSchema = notebaseSummarySchema;\nexport type NotebaseListItem = z.infer<typeof NotebaseListItemSchema>;\n\nexport const NotebaseListOutputSchema = z.array(NotebaseListItemSchema);\nexport type NotebaseListOutput = z.infer<typeof NotebaseListOutputSchema>;\n\nexport const notebaseSchema = z.object({\n id: z.string(),\n userId: z.string(),\n name: z.string(),\n srsNewPerDay: schedulingParamsShape.newPerDay,\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,\n srsDesiredRetention: schedulingParamsShape.desiredRetention,\n srsEnableShortTerm: schedulingParamsShape.enableShortTerm,\n srsMaximumInterval: schedulingParamsShape.maximumInterval,\n srsLearningSteps: schedulingParamsShape.learningSteps,\n srsRelearningSteps: schedulingParamsShape.relearningSteps,\n srsLeechThreshold: schedulingParamsShape.leechThreshold,\n srsEnableFuzz: schedulingParamsShape.enableFuzz,\n srsWeights: srsWeightsSchema.nullable(),\n // Selects the scheduler/curve; read-only, changed only by the FSRS-7 migration.\n srsModelVersion: srsModelVersionSchema,\n // Null = awake; set = excluded from the combined review. Written by notebase.setSleep and auto sleep.\n srsSleepingAt: z.date().nullable(),\n // Who put it to sleep; null exactly when awake.\n srsSleepSource: srsSleepSourceSchema.nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\nexport type Notebase = z.infer<typeof notebaseSchema>;\n\nconst notebaseInitialRowSchema = z\n .object({\n id: z.uuid().optional(),\n cells: z.record(z.string(), z.unknown()),\n origin: notebaseRowOriginInputSchema,\n })\n .strict();\n\nexport const notebaseCreateDataSchema = z\n .object({\n id: z.uuid().optional(),\n name: z.string().min(1),\n options: z\n .object({\n initialColumns: z\n .array(\n z\n .object({\n id: z.uuid(),\n name: z.string().min(1),\n config: notebaseColumnConfigSchema,\n })\n .strict(),\n )\n .min(1),\n initialRow: notebaseInitialRowSchema.optional(),\n initialRows: z\n .array(notebaseInitialRowSchema)\n .min(1)\n .max(NOTEBASE_ROW_CREATE_MANY_MAX_ROWS)\n .optional(),\n })\n .strict()\n .superRefine((options, ctx) => {\n if (options.initialRow && options.initialRows) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Provide either initialRow or initialRows, not both.\",\n path: [\"initialRows\"],\n });\n }\n\n if (!options.initialRows) {\n return;\n }\n\n const seenIds = new Set<string>();\n options.initialRows.forEach((row, index) => {\n if (row.id === undefined) {\n return;\n }\n\n if (seenIds.has(row.id)) {\n ctx.addIssue({\n code: \"custom\",\n message: `Duplicate row id \"${row.id}\".`,\n path: [\"initialRows\", index, \"id\"],\n });\n return;\n }\n\n seenIds.add(row.id);\n });\n })\n .optional(),\n })\n .strict();\nexport type NotebaseCreateData = z.infer<typeof notebaseCreateDataSchema>;\n\nexport const NotebaseCreateInputSchema = notebaseCreateDataSchema;\nexport type NotebaseCreateInput = z.infer<typeof NotebaseCreateInputSchema>;\n\nexport const NotebaseCreateOutputSchema = z.object({\n notebase: notebaseSchema,\n txid: z.number(),\n});\nexport type NotebaseCreateOutput = z.infer<typeof NotebaseCreateOutputSchema>;\n\nexport const notebaseUpdateDataSchema = z\n .object({\n name: z.string().min(1).optional(),\n srsNewPerDay: schedulingParamsShape.newPerDay.optional(),\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay.optional(),\n srsDesiredRetention: schedulingParamsShape.desiredRetention.optional(),\n })\n .strict();\nexport type NotebaseUpdateData = z.infer<typeof notebaseUpdateDataSchema>;\n\nexport const NotebaseUpdateInputSchema = notebaseUpdateDataSchema.extend({\n id: z.uuid(),\n});\nexport type NotebaseUpdateInput = z.infer<typeof NotebaseUpdateInputSchema>;\n\nexport const NotebaseUpdateOutputSchema = z.object({\n notebase: notebaseSchema,\n txid: z.number(),\n});\nexport type NotebaseUpdateOutput = z.infer<typeof NotebaseUpdateOutputSchema>;\n\nexport const NotebaseSetSleepInputSchema = z\n .object({\n id: z.uuid(),\n enabled: z.boolean(),\n })\n .strict();\nexport type NotebaseSetSleepInput = z.infer<typeof NotebaseSetSleepInputSchema>;\n\n// txid is null when the notebase was already in the requested state: nothing to wait for.\nexport const NotebaseSetSleepOutputSchema = z.object({\n txid: z.number().nullable(),\n});\nexport type NotebaseSetSleepOutput = z.infer<typeof NotebaseSetSleepOutputSchema>;\n\nexport const NotebaseDeleteInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseDeleteInput = z.infer<typeof NotebaseDeleteInputSchema>;\n\nexport const NotebaseDeleteOutputSchema = deletionResultSchema;\nexport type NotebaseDeleteOutput = z.infer<typeof NotebaseDeleteOutputSchema>;\n\n// Get endpoint schemas\nexport const NotebaseGetInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetInput = z.infer<typeof NotebaseGetInputSchema>;\n\nexport const NotebaseGetSummaryInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetSummaryInput = z.infer<typeof NotebaseGetSummaryInputSchema>;\n\nexport const NotebaseGetSummaryOutputSchema = notebaseSummarySchema.extend({\n srsNewPerDay: schedulingParamsShape.newPerDay,\n srsReviewsPerDay: schedulingParamsShape.reviewsPerDay,\n srsDesiredRetention: schedulingParamsShape.desiredRetention,\n noteCount: z.number().int().nonnegative(),\n});\nexport type NotebaseGetSummaryOutput = z.infer<typeof NotebaseGetSummaryOutputSchema>;\n\nexport const NotebaseGetSchemaInputSchema = z.object({\n id: z.uuid(),\n});\nexport type NotebaseGetSchemaInput = z.infer<typeof NotebaseGetSchemaInputSchema>;\n\nexport const NotebaseGetOutputSchema = notebaseSchema.extend({\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n notebaseColumns: z.array(notebaseColumnSchema),\n notebaseRows: z.array(notebaseRowSchema),\n notebaseViews: z.array(notebaseViewSchema),\n});\nexport type NotebaseGetOutput = z.infer<typeof NotebaseGetOutputSchema>;\n\nexport const NotebaseGetSchemaOutputSchema = z.object({\n id: z.string(),\n name: z.string(),\n updatedAt: z.coerce.date(),\n notebaseColumns: z.array(notebaseColumnSchema),\n});\nexport type NotebaseGetSchemaOutput = z.infer<typeof NotebaseGetSchemaOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseCreateInputSchema,\n NotebaseCreateOutputSchema,\n NotebaseDeleteInputSchema,\n NotebaseDeleteOutputSchema,\n NotebaseGetInputSchema,\n NotebaseGetOutputSchema,\n NotebaseGetSchemaInputSchema,\n NotebaseGetSchemaOutputSchema,\n NotebaseGetSummaryInputSchema,\n NotebaseGetSummaryOutputSchema,\n NotebaseListInputSchema,\n NotebaseListOutputSchema,\n NotebaseSetSleepInputSchema,\n NotebaseSetSleepOutputSchema,\n NotebaseUpdateInputSchema,\n NotebaseUpdateOutputSchema,\n} from \"#/schemas/notebase\";\nimport { defineAgentProcedure } from \"./shared\";\n\nexport const notebaseContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases\",\n summary: \"List notebases\",\n description: \"List the notebases (word books) owned by the current user.\",\n tags: [\"Notebases\"],\n })\n .input(NotebaseListInputSchema)\n .output(NotebaseListOutputSchema),\n\n getSummary: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases/{id}/summary\",\n summary: \"Get notebase summary\",\n description:\n \"Read the name, public study settings and note count of an owned notebase without loading note content.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseGetSummaryInputSchema)\n .output(NotebaseGetSummaryOutputSchema),\n\n get: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/notebases/{id}\",\n summary: \"Get notebase with notebase columns, rows, and views\",\n tags: [\"Notebases\"],\n })\n .input(NotebaseGetInputSchema)\n .output(NotebaseGetOutputSchema),\n\n getSchema: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebases/{id}/schema\",\n summary: \"Get notebase schema\",\n description:\n \"Read an owned notebase name and field definitions, including field IDs, types and updatedAt timestamps. Does not return note content.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseGetSchemaInputSchema)\n .output(NotebaseGetSchemaOutputSchema),\n\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebases\",\n summary: \"Create notebase\",\n description:\n \"Create an owned notebase with optional initial fields and notes. Client-provided entity IDs are supported; duplicate IDs produce a conflict.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTE_LIMIT_EXCEEDED\", \"CELL_VALIDATION_FAILED\"))\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseCreateInputSchema)\n .output(NotebaseCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PUT\",\n path: \"/notebases/{id}\",\n summary: \"Update notebase\",\n description:\n \"Update the supplied name or public study settings of an owned notebase, preserving omitted properties.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseUpdateInputSchema)\n .output(NotebaseUpdateOutputSchema),\n\n setSleep: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebases/{id}/sleep\",\n summary: \"Set notebase sleep\",\n description:\n \"Put an owned notebase to sleep (enabled=true) or wake it (enabled=false). A sleeping notebase is left out of the combined review; its cards, memory states and review history are unchanged and it can still be reviewed directly. A request matching the current state succeeds without a change.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseSetSleepInputSchema)\n .output(NotebaseSetSleepOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebases/{id}\",\n summary: \"Delete notebase\",\n description:\n \"Permanently delete an owned notebase and its fields, notes, templates, cards and review records. Return the deleted notebase ID.\",\n tags: [\"Notebases\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseDeleteInputSchema)\n .output(NotebaseDeleteOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseColumnCreateInputSchema,\n NotebaseColumnCreateOutputSchema,\n NotebaseColumnDeleteInputSchema,\n NotebaseColumnDeleteOutputSchema,\n NotebaseColumnReorderInputSchema,\n NotebaseColumnReorderOutputSchema,\n NotebaseColumnUpdateInputSchema,\n NotebaseColumnUpdateOutputSchema,\n} from \"#/schemas/notebase-column\";\n\nexport const notebaseColumnContract = {\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-columns\",\n summary: \"Create notebase field\",\n description:\n \"Create a field in an owned notebase. The returned field ID is used as a key in note cells.\",\n tags: [\"Notebase Columns\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseColumnCreateInputSchema)\n .output(NotebaseColumnCreateOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-columns/{notebaseColumnId}\",\n summary: \"Update notebase field\",\n description:\n \"Update an owned field without changing its type. Removing select options clears affected note values. expectedUpdatedAt guards against editing stale data.\",\n tags: [\"Notebase Columns\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_COLUMN_NOT_FOUND\"))\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\", \"FIELD_TYPE_CHANGE_UNSUPPORTED\"))\n .input(NotebaseColumnUpdateInputSchema)\n .output(NotebaseColumnUpdateOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebase-columns/{notebaseColumnId}\",\n summary: \"Delete notebase field\",\n description:\n 'Delete an owned field and remove its values from notes. Primary fields cannot be deleted, nor can a field a template references: one a columns face lists, or a layout face names as {{ [\"<column id>\"] }}. A layout that loops over ctx.fields, as the default dictionary template\\'s back does to show every other filled field, references none of them, so those can be deleted and simply leave the card.',\n tags: [\"Notebase Columns\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_COLUMN_NOT_FOUND\",\n \"PRIMARY_NOTEBASE_COLUMN_DELETE_NOT_ALLOWED\",\n \"CARD_TEMPLATE_NOTEBASE_COLUMN_IN_USE\",\n \"CONCURRENT_POSITION_CONFLICT\",\n ),\n )\n .input(NotebaseColumnDeleteInputSchema)\n .output(NotebaseColumnDeleteOutputSchema),\n\n reorder: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/notebase-columns/reorder\",\n summary: \"Reorder notebase columns\",\n tags: [\"Notebase Columns\"],\n })\n .input(NotebaseColumnReorderInputSchema)\n .output(NotebaseColumnReorderOutputSchema),\n};\n","import { defineAgentProcedure } from \"./shared\";\nimport {\n NotebaseRowListInputSchema,\n NotebaseRowListOutputSchema,\n NotebaseRowGetInputSchema,\n NotebaseRowGetOutputSchema,\n} from \"#/schemas/notebase-row\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n NotebaseRowCreateInputSchema,\n NotebaseRowCreateManyInputSchema,\n NotebaseRowCreateManyOutputSchema,\n NotebaseRowCreateOutputSchema,\n NotebaseRowDeleteInputSchema,\n NotebaseRowDeleteManyInputSchema,\n NotebaseRowDeleteManyOutputSchema,\n NotebaseRowDeleteOutputSchema,\n NotebaseRowReorderInputSchema,\n NotebaseRowReorderOutputSchema,\n NotebaseRowUpdateInputSchema,\n NotebaseRowUpdateManyInputSchema,\n NotebaseRowUpdateManyOutputSchema,\n NotebaseRowUpdateOutputSchema,\n} from \"#/schemas/notebase-row\";\n\nexport const notebaseRowContract = {\n list: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebase-rows\",\n summary: \"List or search notes\",\n description:\n \"List or search owned notes, optionally within one notebase. Supply query to search; omit it to browse, which returns every note in scope rather than a filtered set. Searching requires notebaseId and covers that one notebase, so cover several by listing them first and calling this once per notebase. The query filter is at least two characters, matches a literal case-insensitive substring, and only searches fields of type string, so values in number, boolean, date and select fields are never matched. Supports limit and offset pagination.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(NotebaseRowListInputSchema)\n .output(NotebaseRowListOutputSchema),\n get: defineAgentProcedure({\n method: \"GET\",\n path: \"/notebase-rows/{id}\",\n summary: \"Get note\",\n description:\n \"Read one owned note with field-ID values and the updatedAt timestamp used for modification checks.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\"))\n .input(NotebaseRowGetInputSchema)\n .output(NotebaseRowGetOutputSchema),\n create: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows\",\n summary: \"Create note\",\n description:\n \"Create a note in an owned notebase using field IDs and their declared value types. Existing templates generate cards. A duplicate entity ID produces a conflict.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CELL_VALIDATION_FAILED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n \"NOTE_LIMIT_EXCEEDED\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseRowCreateInputSchema)\n .output(NotebaseRowCreateOutputSchema),\n\n createMany: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows/batch\",\n summary: \"Create notes\",\n description:\n \"Create 1–50 notes atomically in one owned notebase. Cells use field IDs and declared value types. Existing templates generate cards. Duplicate entity IDs roll back the whole batch.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"CELL_VALIDATION_FAILED\",\n \"CONCURRENT_POSITION_CONFLICT\",\n \"NOTE_LIMIT_EXCEEDED\",\n ),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_ALREADY_EXISTS\"))\n .input(NotebaseRowCreateManyInputSchema)\n .output(NotebaseRowCreateManyOutputSchema),\n\n update: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-rows/{notebaseRowId}\",\n summary: \"Update note\",\n description:\n \"Merge supplied fields into an owned note, preserving omitted fields. Use null to clear a field. expectedUpdatedAt guards against editing stale data; reread on a modification conflict. In a cloze field, a deletion's number ({{c1::…}}) is its card's identity: keep the numbers of the deletions you keep, and leave any gaps for the save to close. Renumbering them yourself hands a card's review history to other text, and can delete it.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CELL_VALIDATION_FAILED\"))\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(NotebaseRowUpdateInputSchema)\n .output(NotebaseRowUpdateOutputSchema),\n\n updateMany: defineAgentProcedure({\n method: \"PATCH\",\n path: \"/notebase-rows/batch\",\n summary: \"Update notes\",\n description:\n \"Update 1–50 notes atomically in one owned notebase. Each row supplies its ID and fields to merge; omitted fields are preserved and null clears a field. Supply each note's expectedUpdatedAt to guard against stale edits. A missing row, invalid field or modification conflict rolls back the whole batch. Items are returned in input order. In a cloze field, a deletion's number ({{c1::…}}) is its card's identity: keep the numbers of the deletions you keep, and leave any gaps for the save to close. Renumbering them yourself hands a card's review history to other text, and can delete it.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(\n pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"NOTEBASE_ROW_NOT_FOUND\", \"CELL_VALIDATION_FAILED\"),\n )\n .errors(pickPublicErrorMap(\"RESOURCE_UPDATE_CONFLICT\"))\n .input(NotebaseRowUpdateManyInputSchema)\n .output(NotebaseRowUpdateManyOutputSchema),\n\n delete: defineAgentProcedure({\n method: \"DELETE\",\n path: \"/notebase-rows/{notebaseRowId}\",\n summary: \"Delete note\",\n description:\n \"Permanently delete an owned note and its derived cards and review records. Return the deleted note ID.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .input(NotebaseRowDeleteInputSchema)\n .output(NotebaseRowDeleteOutputSchema),\n\n deleteMany: defineAgentProcedure({\n method: \"POST\",\n path: \"/notebase-rows/batch/delete\",\n summary: \"Delete notes\",\n description:\n \"Permanently delete 1–50 owned notes atomically, including their derived cards and review records. Notes may belong to different notebases. If any ID is missing or inaccessible, nothing is deleted. Return deleted IDs in input order.\",\n tags: [\"Notebase Rows\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_ROW_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .input(NotebaseRowDeleteManyInputSchema)\n .output(NotebaseRowDeleteManyOutputSchema),\n\n reorder: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"CONCURRENT_POSITION_CONFLICT\"))\n .route({\n method: \"POST\",\n path: \"/notebase-rows/reorder\",\n summary: \"Reorder notebase rows\",\n tags: [\"Notebase Rows\"],\n })\n .input(NotebaseRowReorderInputSchema)\n .output(NotebaseRowReorderOutputSchema),\n};\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n pdfTranslationDeleteOutputSchema,\n pdfTranslationDownloadOutputSchema,\n pdfTranslationGetOutputSchema,\n pdfTranslationJobIdInputSchema,\n pdfTranslationJobResourceSchema,\n pdfTranslationListInputSchema,\n pdfTranslationListOutputSchema,\n pdfTranslationOutputInputSchema,\n pdfTranslationPreviewOutputSchema,\n pdfTranslationRequestUploadInputSchema,\n pdfTranslationRequestUploadOutputSchema,\n pdfTranslationStatusInputSchema,\n pdfTranslationStatusOutputSchema,\n pdfTranslationSubmitInputSchema,\n pdfTranslationSubmitOutputSchema,\n} from \"#/schemas/pdf-translation\";\n\nconst pdfTranslationProcedure = oc.errors(pickPublicErrorMap(\"PDF_TRANSLATION_UNAVAILABLE\"));\n\nexport const pdfTranslationContract = {\n status: pdfTranslationProcedure\n .route({\n method: \"GET\",\n path: \"/pdf-translations/status\",\n summary: \"How many free PDF translations the account has left\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationStatusInputSchema)\n .output(pdfTranslationStatusOutputSchema),\n\n list: pdfTranslationProcedure\n .route({\n method: \"GET\",\n path: \"/pdf-translations\",\n summary: \"List recent PDF translations\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationListInputSchema)\n .output(pdfTranslationListOutputSchema),\n\n requestUpload: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_FILE_TOO_LARGE\"))\n .route({\n method: \"POST\",\n path: \"/pdf-translations/uploads\",\n summary: \"Request a signed upload for a PDF to translate\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationRequestUploadInputSchema)\n .output(pdfTranslationRequestUploadOutputSchema),\n\n submit: pdfTranslationProcedure\n .errors(\n pickPublicErrorMap(\n \"HOSTED_AI_TIER_RESTRICTED\",\n \"PDF_TRANSLATION_UPLOAD_NOT_FOUND\",\n \"PDF_TRANSLATION_UPLOAD_EXPIRED\",\n \"PDF_TRANSLATION_UPLOAD_NOT_COMPLETED\",\n \"PDF_TRANSLATION_FILE_TOO_LARGE\",\n \"PDF_TRANSLATION_INVALID_PDF\",\n \"PDF_TRANSLATION_ALREADY_TRANSLATED\",\n \"PDF_TRANSLATION_PAGE_LIMIT_EXCEEDED\",\n \"PDF_TRANSLATION_QUEUE_FULL\",\n \"PDF_TRANSLATION_IDEMPOTENCY_CONFLICT\",\n \"PDF_TRANSLATION_INSUFFICIENT_CREDIT\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/pdf-translations\",\n summary: \"Translate uploaded PDFs\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationSubmitInputSchema)\n .output(pdfTranslationSubmitOutputSchema),\n\n get: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}\",\n summary: \"Get a PDF translation's status, with the others submitted with it\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationGetOutputSchema),\n\n cancel: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_CANCELLABLE\"))\n .route({\n method: \"POST\",\n path: \"/pdf-translations/{id}/cancel\",\n summary: \"Cancel a PDF translation\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationJobResourceSchema),\n\n getPreviewUrl: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_READY\"))\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}/preview-url\",\n summary: \"Get a short-lived URL to read a translated PDF in the browser\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationOutputInputSchema)\n .output(pdfTranslationPreviewOutputSchema),\n\n getDownloadUrl: pdfTranslationProcedure\n .errors(\n pickPublicErrorMap(\n \"PDF_TRANSLATION_NOT_FOUND\",\n \"PDF_TRANSLATION_NOT_READY\",\n \"PDF_TRANSLATION_DOWNLOAD_RESTRICTED\",\n ),\n )\n .route({\n method: \"GET\",\n path: \"/pdf-translations/{id}/download-url\",\n summary: \"Get a download URL for a translated PDF\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationOutputInputSchema)\n .output(pdfTranslationDownloadOutputSchema),\n\n delete: pdfTranslationProcedure\n .errors(pickPublicErrorMap(\"PDF_TRANSLATION_NOT_FOUND\", \"PDF_TRANSLATION_NOT_DELETABLE\"))\n .route({\n method: \"DELETE\",\n path: \"/pdf-translations/{id}\",\n summary: \"Delete a finished PDF translation and its files\",\n tags: [\"PDF Translation\"],\n })\n .input(pdfTranslationJobIdInputSchema)\n .output(pdfTranslationDeleteOutputSchema),\n};\n","import type { BillingPlan } from \"./billing\";\nimport { langCodeISO6393Schema } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\n// Reading text aloud in the account's voices: the reader's settings, the\n// voices to choose from, and the request that turns a text into audio.\n\n/** The longest text one request reads aloud. */\nexport const SPEECH_TEXT_MAX_LENGTH = 500;\n\n/**\n * How many texts each plan may have read aloud in a day (24 hours from the\n * first one). Generous enough that reviewing never runs into it; the cap is\n * there to keep the voices from being used as a free speech service.\n */\nexport const SPEECH_DAILY_REQUEST_LIMITS = {\n free: 200,\n pro: 5000,\n ultra: 5000,\n} as const satisfies Record<BillingPlan, number>;\n\n/** A voice by its short name: its locale, then the voice (`en-US-AndrewMultilingualNeural`). */\nexport const speechVoiceNameSchema = z\n .string()\n .max(100)\n .regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]+)+(?::[A-Za-z0-9]+)?$/);\nexport type SpeechVoiceName = z.infer<typeof speechVoiceNameSchema>;\n\nexport const SPEECH_RATE_MIN = -50;\nexport const SPEECH_RATE_MAX = 100;\n\n/** Reading speed: percent faster (+) or slower (−) than normal. */\nexport const speechRateSchema = z.number().int().min(SPEECH_RATE_MIN).max(SPEECH_RATE_MAX);\n\n/**\n * How the account reads aloud. A language left out of `languageVoices`, and a\n * `null` `multilingualVoice`, read in the default voice (`speech.listVoices`\n * names them).\n */\nexport const speechPreferencesSchema = z\n .object({\n languageVoices: z.partialRecord(langCodeISO6393Schema, speechVoiceNameSchema),\n // Reads text whose language is not known, working the language out itself.\n multilingualVoice: speechVoiceNameSchema.nullable(),\n rate: speechRateSchema,\n })\n .strict();\nexport type SpeechPreferences = z.infer<typeof speechPreferencesSchema>;\n\nexport const DEFAULT_SPEECH_PREFERENCES: SpeechPreferences = {\n languageVoices: {},\n multilingualVoice: null,\n rate: 0,\n};\n\n/**\n * Changes some settings and keeps the rest. `languageVoices` changes only the\n * languages it names; `null` puts a language back on its default voice.\n */\nexport const speechPreferencesUpdateInputSchema = z\n .object({\n languageVoices: z\n .partialRecord(langCodeISO6393Schema, speechVoiceNameSchema.nullable())\n .optional(),\n multilingualVoice: speechVoiceNameSchema.nullable().optional(),\n rate: speechRateSchema.optional(),\n })\n .strict();\nexport type SpeechPreferencesUpdateInput = z.infer<typeof speechPreferencesUpdateInputSchema>;\n\nexport const speechVoiceGenderSchema = z.enum([\"female\", \"male\", \"neutral\"]);\nexport type SpeechVoiceGender = z.infer<typeof speechVoiceGenderSchema>;\n\nexport const speechVoiceSchema = z\n .object({\n name: speechVoiceNameSchema,\n // The voice's name for people, such as \"Andrew Multilingual\".\n displayName: z.string(),\n locale: z.string(),\n // The language the voice is for; null for one this list has no code for.\n language: langCodeISO6393Schema.nullable(),\n gender: speechVoiceGenderSchema,\n // Reads many languages, working out the text's language itself.\n multilingual: z.boolean(),\n })\n .strict();\nexport type SpeechVoice = z.infer<typeof speechVoiceSchema>;\n\nexport const speechVoicesOutputSchema = z\n .object({\n voices: z.array(speechVoiceSchema),\n // The voice each language reads in until the reader picks one.\n defaultVoices: z.partialRecord(langCodeISO6393Schema, speechVoiceNameSchema),\n defaultMultilingualVoice: speechVoiceNameSchema,\n })\n .strict();\nexport type SpeechVoicesOutput = z.infer<typeof speechVoicesOutputSchema>;\n\nexport const speechSynthesizeInputSchema = z\n .object({\n text: z.string().trim().min(1).max(SPEECH_TEXT_MAX_LENGTH),\n // The text's language, when the caller knows it; without one, a\n // multilingual voice works it out.\n language: langCodeISO6393Schema.optional(),\n // Reads in this voice instead of the account's, such as one the reader is\n // trying out in the settings.\n voice: speechVoiceNameSchema.optional(),\n })\n .strict();\nexport type SpeechSynthesizeInput = z.infer<typeof speechSynthesizeInputSchema>;\n\n/** The most texts one request forgets the audio of. */\nexport const SPEECH_DELETE_AUDIO_MAX_TEXTS = 50;\n\n/**\n * Texts whose kept audio to forget, each as it is asked to be read aloud\n * (`speech.synthesize`): the next time one is, it is read anew. Audio for a\n * text that has none kept is no error.\n */\nexport const speechDeleteAudioInputSchema = z\n .object({\n texts: z.array(speechSynthesizeInputSchema).min(1).max(SPEECH_DELETE_AUDIO_MAX_TEXTS),\n })\n .strict();\nexport type SpeechDeleteAudioInput = z.infer<typeof speechDeleteAudioInputSchema>;\n\nexport const speechDeleteAllAudioOutputSchema = z\n .object({\n // How many audio files there were.\n deleted: z.number().int().nonnegative(),\n })\n .strict();\nexport type SpeechDeleteAllAudioOutput = z.infer<typeof speechDeleteAllAudioOutputSchema>;\n\n/**\n * Where to download the audio, an MP3: a link to fetch at once, which stops\n * working at `expiresAt`.\n */\nexport const speechSynthesizeOutputSchema = z\n .object({\n url: z.url(),\n expiresAt: z.coerce.date(),\n })\n .strict();\nexport type SpeechSynthesizeOutput = z.infer<typeof speechSynthesizeOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport {\n speechDeleteAllAudioOutputSchema,\n speechDeleteAudioInputSchema,\n speechPreferencesSchema,\n speechPreferencesUpdateInputSchema,\n speechSynthesizeInputSchema,\n speechSynthesizeOutputSchema,\n speechVoicesOutputSchema,\n} from \"#/schemas/speech\";\n\nexport const speechContract = {\n getPreferences: oc\n .route({\n method: \"GET\",\n path: \"/speech/preferences\",\n summary: \"Get how the authenticated user's text is read aloud\",\n tags: [\"Speech\"],\n })\n .output(speechPreferencesSchema),\n updatePreferences: oc\n .route({\n method: \"PATCH\",\n path: \"/speech/preferences\",\n summary: \"Change how the authenticated user's text is read aloud\",\n tags: [\"Speech\"],\n })\n .input(speechPreferencesUpdateInputSchema)\n .output(speechPreferencesSchema),\n listVoices: oc\n .route({\n method: \"GET\",\n path: \"/speech/voices\",\n summary: \"List the voices text can be read aloud in, and each language's default\",\n tags: [\"Speech\"],\n })\n .output(speechVoicesOutputSchema),\n synthesize: oc\n .route({\n method: \"POST\",\n path: \"/speech/synthesize\",\n summary: \"Read a text aloud, and link to its MP3 audio\",\n tags: [\"Speech\"],\n })\n .input(speechSynthesizeInputSchema)\n .output(speechSynthesizeOutputSchema),\n deleteAudio: oc\n .route({\n method: \"POST\",\n path: \"/speech/audio/delete\",\n summary: \"Forget the audio kept for some texts, so each is read anew next time\",\n tags: [\"Speech\"],\n })\n .input(speechDeleteAudioInputSchema)\n .output(z.void()),\n deleteAllAudio: oc\n .route({\n method: \"DELETE\",\n path: \"/speech/audio\",\n summary: \"Forget all the audio kept for the authenticated user's texts\",\n tags: [\"Speech\"],\n })\n .output(speechDeleteAllAudioOutputSchema),\n};\n","import { canonicalTimeZone } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\n\n// @ref https://zenn.dev/herp_inc/articles/js-intl-date-time-format-performance\n// Keyed by the lowercased id, because Intl matches ids case-insensitively: raw\n// keys would let every casing of a zone pin its own entry for the life of the\n// process. Links (Asia/Kolkata) share their canonical zone's formatter (~30 KB\n// of ICU memory each), so the map holds one key per IANA name. Offset zones\n// (\"+08:00\") are valid but stay uncached, because there are ~2.9k of them.\nconst timezoneFormatters = new Map<string, Intl.DateTimeFormat>();\n\n// ASCII only, as Intl does: toLowerCase() would also fold look-alikes such as\n// the Kelvin sign onto \"k\", letting an id Intl rejects hit a cached zone.\nfunction toCacheKey(timezone: string) {\n return timezone.replace(/[A-Z]/g, (letter) => letter.toLowerCase());\n}\n\nfunction getTimezoneFormatter(timezone: string): Intl.DateTimeFormat {\n const key = toCacheKey(timezone);\n const cached = timezoneFormatters.get(key);\n if (cached) {\n return cached;\n }\n\n const formatter = new Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n const canonical = formatter.resolvedOptions().timeZone;\n if (canonical.startsWith(\"+\") || canonical.startsWith(\"-\")) {\n return formatter;\n }\n\n const canonicalKey = toCacheKey(canonical);\n const shared = timezoneFormatters.get(canonicalKey) ?? formatter;\n timezoneFormatters.set(canonicalKey, shared).set(key, shared);\n return shared;\n}\n\nexport const timezoneSchema = z\n .string()\n .trim()\n .min(1)\n .refine((timezone) => {\n try {\n getTimezoneFormatter(timezone).format(new Date());\n return true;\n } catch {\n return false;\n }\n }, \"Invalid timezone\");\nexport type Timezone = z.infer<typeof timezoneSchema>;\n\n/**\n * The zone a call reckons days in, under the name an account's zone is stored\n * under (`canonicalTimeZone`): \"Asia/Calcutta\" arrives as \"Asia/Kolkata\" and\n * \"CST\" as \"America/Chicago\", names that Temporal and a Debian Postgres both\n * read. A fixed offset (\"+08:00\") is refused, as Postgres reads it with the\n * opposite sign and would put the call's days on the wrong side of UTC.\n */\nexport const canonicalTimezoneSchema = timezoneSchema.transform((timezone, ctx) => {\n const name = canonicalTimeZone(timezone);\n if (!name) {\n ctx.addIssue({\n code: \"custom\",\n message:\n \"Use an IANA time zone identifier instead of a fixed UTC offset. See https://www.iana.org/time-zones\",\n });\n return z.NEVER;\n }\n return name;\n});\n","import { paginationShape } from \"./pagination\";\nimport {\n activeScheduleStatusSchema,\n cardStateSchema,\n fsrsReviewLogSnapshotSchema,\n fsrsMemoryStateSchema,\n POSTPONE_DAMAGE_THRESHOLD,\n reviewRatingSchema,\n scheduleStatusSchema,\n schedulingParamsShape,\n schedulingParamsSchema,\n SRS_REVIEW_DURATION_MS_MAX,\n srsStepSchema,\n} from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { cardSchema } from \"./card\";\nimport { notebaseSummarySchema } from \"./notebase\";\nimport { canonicalTimezoneSchema } from \"./timezone\";\n\nexport { reviewRatingSchema, schedulingParamsSchema, SRS_REVIEW_DURATION_MS_MAX };\nexport { timezoneSchema } from \"./timezone\";\nexport type { Timezone } from \"./timezone\";\nexport type { ReviewRating, SchedulingParams } from \"@read-frog/definitions\";\n\nexport const stepSchema = srsStepSchema;\nexport type Step = z.infer<typeof stepSchema>;\n\nexport const SRS_REVIEW_CLIENT_ID_NAMESPACE = \"6ba7b811-9dad-11d1-80b4-00c04fd430c8\";\nconst srsReviewClientIdNamePrefix = \"readfrog:srs-review\";\nconst nullLastReviewTimeSentinel = \"null\";\n\nexport interface SrsReviewClientIdCard {\n id: string;\n lastReviewTime: Date | string | null;\n}\n\nexport async function createSrsReviewClientId(card: SrsReviewClientIdCard) {\n return uuidV5(\n `${srsReviewClientIdNamePrefix}:${card.id}:${formatLastReviewTime(card.lastReviewTime)}`,\n SRS_REVIEW_CLIENT_ID_NAMESPACE,\n );\n}\n\nexport const srsReviewInputSchema = z\n .object({\n cardId: z.uuid(),\n id: z.uuid().optional(),\n rating: reviewRatingSchema,\n durationMs: z.number().int().min(0).max(SRS_REVIEW_DURATION_MS_MAX),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsReviewInput = z.infer<typeof srsReviewInputSchema>;\n\nexport const srsRollbackReviewInputSchema = z\n .object({\n expectedReviewId: z.uuid().optional(),\n cardId: z.uuid(),\n })\n .strict();\nexport type SrsRollbackReviewInput = z.infer<typeof srsRollbackReviewInputSchema>;\n\nexport const srsScheduleStatusStatsSchema = z.record(\n activeScheduleStatusSchema,\n z.number().int().min(0),\n);\nexport type SrsScheduleStatusStats = z.infer<typeof srsScheduleStatusStatsSchema>;\n\nexport const srsScheduleStatusStatsInputSchema = z\n .object({\n notebaseIds: z.array(z.uuid()).optional(),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsScheduleStatusStatsInput = z.infer<typeof srsScheduleStatusStatsInputSchema>;\n\nexport const srsScheduleStatusStatsOutputSchema = z.record(z.uuid(), srsScheduleStatusStatsSchema);\nexport type SrsScheduleStatusStatsOutput = z.infer<typeof srsScheduleStatusStatsOutputSchema>;\n\nexport const srsRecentNotebaseScheduleStatusStatsInputSchema = z\n .object({\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsRecentNotebaseScheduleStatusStatsInput = z.infer<\n typeof srsRecentNotebaseScheduleStatusStatsInputSchema\n>;\n\n/** Null when the user has no notebase yet. */\nexport const srsRecentNotebaseScheduleStatusStatsOutputSchema = z\n .object({\n notebase: notebaseSummarySchema,\n stats: srsScheduleStatusStatsSchema,\n })\n .nullable();\nexport type SrsRecentNotebaseScheduleStatusStatsOutput = z.infer<\n typeof srsRecentNotebaseScheduleStatusStatsOutputSchema\n>;\n\nexport const srsManualCardStatusInputSchema = z\n .object({\n cardId: z.uuid(),\n enabled: z.boolean(),\n })\n .strict();\nexport type SrsManualCardStatusInput = z.infer<typeof srsManualCardStatusInputSchema>;\n\nexport const srsSetCardBuriedInputSchema = srsManualCardStatusInputSchema;\nexport type SrsSetCardBuriedInput = SrsManualCardStatusInput;\n\nexport const srsSetCardSuspendedInputSchema = srsManualCardStatusInputSchema;\nexport type SrsSetCardSuspendedInput = SrsManualCardStatusInput;\n\nexport const srsRevlogSchema = z.object({\n id: z.uuid(),\n notebaseId: z.uuid(),\n cardId: z.uuid(),\n rating: reviewRatingSchema,\n state: cardStateSchema,\n stability: z.number(),\n afterScheduleStatus: scheduleStatusSchema,\n afterMemoryState: fsrsMemoryStateSchema,\n retentionDays90: z.number().nonnegative(),\n afterRetentionDays90: z.number().nonnegative(),\n reviewedAt: z.coerce.date(),\n durationMs: z.number().int(),\n fsrsReviewLogSnapshot: fsrsReviewLogSnapshotSchema,\n createdAt: z.coerce.date(),\n});\nexport type SrsRevlog = z.infer<typeof srsRevlogSchema>;\n\nexport const srsRevlogWithoutSnapshotSchema = srsRevlogSchema.omit({\n fsrsReviewLogSnapshot: true,\n});\nexport type SrsRevlogWithoutSnapshot = z.infer<typeof srsRevlogWithoutSnapshotSchema>;\n\nexport const srsListCardRevlogsInputSchema = z\n .object({\n ...paginationShape,\n notebaseId: z.uuid().optional(),\n cardId: z.uuid().optional(),\n })\n .strict();\nexport type SrsListCardRevlogsInput = z.infer<typeof srsListCardRevlogsInputSchema>;\n\nexport const srsListCardRevlogsOutputSchema = z\n .object({\n items: z.array(srsRevlogWithoutSnapshotSchema),\n hasMore: z.boolean(),\n })\n .strict();\nexport type SrsListCardRevlogsOutput = z.infer<typeof srsListCardRevlogsOutputSchema>;\n\nexport const srsReviewOutputSchema = z.object({\n card: cardSchema,\n revlog: srsRevlogSchema,\n // Null for an idempotent replay: it writes nothing, so no shape ever carries\n // its transaction. Wait for the returned card and revlog instead.\n txid: z.number().nullable(),\n // False when an idempotent replay returned an existing revlog instead of creating one.\n created: z.boolean(),\n});\nexport type SrsReviewOutput = z.infer<typeof srsReviewOutputSchema>;\n\nexport const srsRollbackReviewOutputSchema = z.object({\n card: cardSchema,\n rolledBackRevlogId: z.uuid(),\n txid: z.number(),\n});\nexport type SrsRollbackReviewOutput = z.infer<typeof srsRollbackReviewOutputSchema>;\n\nexport const srsTxidOutputSchema = z.object({\n txid: z.number(),\n});\nexport type SrsTxidOutput = z.infer<typeof srsTxidOutputSchema>;\n\nexport const srsSetCardBuriedOutputSchema = srsTxidOutputSchema;\nexport type SrsSetCardBuriedOutput = SrsTxidOutput;\n\nexport const srsSetCardSuspendedOutputSchema = srsTxidOutputSchema;\nexport type SrsSetCardSuspendedOutput = SrsTxidOutput;\n\nexport const srsListUnreadOptimizerResultsInputSchema = z.object({}).strict();\n\nexport const srsOptimizerUnreadResultSchema = z\n .object({\n runId: z.uuid(),\n notebaseName: z.string().min(1),\n revlogCount: z.number().int().positive(),\n improvement: z.number().nonnegative().nullable(),\n })\n .strict();\nexport type SrsOptimizerUnreadResult = z.infer<typeof srsOptimizerUnreadResultSchema>;\n\nexport const srsListUnreadOptimizerResultsOutputSchema = z.array(srsOptimizerUnreadResultSchema);\nexport type SrsListUnreadOptimizerResultsOutput = z.infer<\n typeof srsListUnreadOptimizerResultsOutputSchema\n>;\n\nexport const srsAcknowledgeOptimizerResultsInputSchema = z\n .object({\n runIds: z.array(z.uuid()).min(1),\n })\n .strict();\nexport type SrsAcknowledgeOptimizerResultsInput = z.infer<\n typeof srsAcknowledgeOptimizerResultsInputSchema\n>;\n\nexport const srsAcknowledgeOptimizerResultsOutputSchema = z\n .object({\n acknowledgedCount: z.number().int().nonnegative(),\n })\n .strict();\nexport type SrsAcknowledgeOptimizerResultsOutput = z.infer<\n typeof srsAcknowledgeOptimizerResultsOutputSchema\n>;\n\nfunction formatLastReviewTime(lastReviewTime: Date | string | null) {\n return lastReviewTime ? new Date(lastReviewTime).toISOString() : nullLastReviewTimeSentinel;\n}\n\nasync function uuidV5(name: string, namespace: string) {\n const namespaceBytes = uuidToBytes(namespace);\n const nameBytes = new TextEncoder().encode(name);\n const input = new Uint8Array(namespaceBytes.length + nameBytes.length);\n input.set(namespaceBytes);\n input.set(nameBytes, namespaceBytes.length);\n\n const hash = new Uint8Array(await crypto.subtle.digest(\"SHA-1\", input));\n const bytes = hash.slice(0, 16);\n const versionByte = bytes[6];\n const variantByte = bytes[8];\n if (versionByte === undefined || variantByte === undefined) {\n throw new Error(\"SHA-1 digest was too short\");\n }\n bytes[6] = (versionByte & 0x0f) | 0x50;\n bytes[8] = (variantByte & 0x3f) | 0x80;\n\n return bytesToUuid(bytes);\n}\n\nfunction uuidToBytes(uuid: string) {\n const hex = uuid.replaceAll(\"-\", \"\").toLowerCase();\n /* v8 ignore next 3 -- SRS_REVIEW_CLIENT_ID_NAMESPACE is a fixed valid UUID. */\n if (!/^[0-9a-f]{32}$/.test(hex)) {\n throw new Error(\"Invalid UUID namespace\");\n }\n\n return new Uint8Array(\n Array.from({ length: 16 }, (_, index) =>\n Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16),\n ),\n );\n}\n\nfunction bytesToUuid(bytes: Uint8Array) {\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\"));\n return [\n hex.slice(0, 4).join(\"\"),\n hex.slice(4, 6).join(\"\"),\n hex.slice(6, 8).join(\"\"),\n hex.slice(8, 10).join(\"\"),\n hex.slice(10, 16).join(\"\"),\n ].join(\"-\");\n}\n\nconst count = z.number().int().nonnegative();\n\nexport const srsBacklogStatsInputSchema = z\n .object({\n notebaseIds: z.array(z.uuid()).optional(),\n timezone: canonicalTimezoneSchema,\n })\n .strict();\nexport type SrsBacklogStatsInput = z.infer<typeof srsBacklogStatsInputSchema>;\n\n/**\n * An Awake notebase with a positive daily review limit whose overdue reviews\n * fill at least `BACKLOG_PROMPT_DAYS.badge` days.\n */\nexport const srsBacklogStatsSchema = z.object({\n overdueReviewCount: count.describe(\n \"Review cards whose due date is before the start of today's study day.\",\n ),\n dailyLimit: z\n .number()\n .int()\n .positive()\n .describe(\n \"The notebase's own daily review limit, which the backlog is measured against. Always positive: a notebase with no daily reviews (0) or an unlimited limit (-1) is never listed.\",\n ),\n backlogDays: z\n .number()\n .nonnegative()\n .describe(\"Days of reviews the backlog fills at that limit: overdueReviewCount / dailyLimit.\"),\n});\nexport type SrsBacklogStats = z.infer<typeof srsBacklogStatsSchema>;\n\n/** Only the notebases that get the badge; the rest are absent. */\nexport const srsBacklogStatsOutputSchema = z.record(z.uuid(), srsBacklogStatsSchema);\nexport type SrsBacklogStatsOutput = z.infer<typeof srsBacklogStatsOutputSchema>;\n\nconst rescheduleDailyLimitSchema = z.number().int().positive();\n\nexport const srsPreviewPostponeInputSchema = z\n .object({\n notebaseId: z.uuid(),\n timezone: canonicalTimezoneSchema,\n dailyLimit: rescheduleDailyLimitSchema.optional(),\n flattenFullRange: z\n .boolean()\n .optional()\n .describe(\"Flatten levels every plannable day (180) instead of only the chart days.\"),\n })\n .strict();\nexport type SrsPreviewPostponeInput = z.infer<typeof srsPreviewPostponeInputSchema>;\n\nconst postponeThresholdSchema = z\n .number()\n .min(POSTPONE_DAMAGE_THRESHOLD.min)\n .max(POSTPONE_DAMAGE_THRESHOLD.max);\n\nconst postponeDaySchema = z.object({\n day: z.number().int().positive(),\n postponed: count,\n rSum: z.number(),\n});\n\nconst rescheduleBaselineDaySchema = z.object({\n day: z.number().int().positive(),\n scheduled: count,\n rSum: z.number().nullable(),\n});\nexport type RescheduleBaselineDay = z.infer<typeof rescheduleBaselineDaySchema>;\n\nexport const spreadDaySchema = z.object({\n day: count,\n scheduled: count,\n backlog: count,\n backlogRSum: z.number(),\n surplusIn: count,\n surplusRSum: z.number(),\n surplusStay: count,\n surplusOut: count,\n});\nexport type SpreadDay = z.infer<typeof spreadDaySchema>;\n\nconst spreadKeptSchema = z.object({\n stuck: count,\n noRoom: count,\n});\n\nexport const flattenStepSchema = z.object({\n checked: z.boolean(),\n fromToday: count,\n fromFuture: count,\n fromDays: count,\n kept: spreadKeptSchema,\n qSuggest: count,\n meanRAfter: z.number(),\n days: z.array(spreadDaySchema),\n /** Cards Postpone already moved that this Flatten moves again, and their R under Postpone. */\n postponedAgain: z.object({ count, rSum: z.number() }),\n});\nexport type FlattenStep = z.infer<typeof flattenStepSchema>;\n\n/** One threshold's Postpone alone, before its Flatten option is attached. */\nexport const postponeSummarySchema = z.object({\n threshold: postponeThresholdSchema,\n moved: count,\n overflowToday: count,\n meanRiBefore: z.number(),\n meanRAfter: z.number(),\n days: z.array(postponeDaySchema),\n});\nexport type PostponeSummary = z.infer<typeof postponeSummarySchema>;\n\nexport const postponeStepSchema = postponeSummarySchema.extend({\n flatten: flattenStepSchema.nullable(),\n});\nexport type PostponeStep = z.infer<typeof postponeStepSchema>;\n\nexport const postponePlanSchema = z.object({\n planId: z.string(),\n limit: z.number().int().positive(),\n steps: z.array(postponeStepSchema),\n skipped: z.object({\n belowFloor: count,\n maxInterval: count,\n invalid: count,\n }),\n});\nexport type PostponePlanSummary = z.infer<typeof postponePlanSchema>;\n\nconst rescheduleReadySchema = z.object({\n status: z.literal(\"ready\"),\n expiresAt: z.date(),\n q: z.number().int().positive(),\n qConfigured: schedulingParamsShape.reviewsPerDay,\n qMax: z.number().int().positive(),\n overdueReviewCount: count,\n dueTodayReviewCount: count,\n usedToday: count,\n});\n\nexport const srsPreviewPostponeOutputSchema = z.discriminatedUnion(\"status\", [\n rescheduleReadySchema.extend({\n plan: postponePlanSchema,\n suggested: postponePlanSchema.nullable(),\n baseline: z.array(rescheduleBaselineDaySchema),\n }),\n z.object({ status: z.literal(\"quotaZero\") }),\n z.object({ status: z.literal(\"invalidWeights\") }),\n]);\nexport type SrsPreviewPostponeOutput = z.infer<typeof srsPreviewPostponeOutputSchema>;\n\nconst rescheduleApplyInputSchema = z.object({\n notebaseId: z.uuid(),\n planId: z.string().min(1),\n unlimited: z.boolean().optional(),\n});\n\nexport const srsApplyPostponeInputSchema = rescheduleApplyInputSchema\n .extend({\n threshold: postponeThresholdSchema,\n flatten: z.boolean().optional(),\n })\n .strict();\nexport type SrsApplyPostponeInput = z.infer<typeof srsApplyPostponeInputSchema>;\n\nexport const srsRescheduleApplyOutputSchema = z.object({\n moved: count,\n txid: z.number().nullable(),\n reviewsPerDay: schedulingParamsShape.reviewsPerDay,\n});\nexport type SrsRescheduleApplyOutput = z.infer<typeof srsRescheduleApplyOutputSchema>;\nexport const srsApplyPostponeOutputSchema = srsRescheduleApplyOutputSchema;\nexport type SrsApplyPostponeOutput = z.infer<typeof srsApplyPostponeOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n srsAcknowledgeOptimizerResultsInputSchema,\n srsAcknowledgeOptimizerResultsOutputSchema,\n srsListCardRevlogsInputSchema,\n srsListCardRevlogsOutputSchema,\n srsListUnreadOptimizerResultsInputSchema,\n srsListUnreadOptimizerResultsOutputSchema,\n srsRecentNotebaseScheduleStatusStatsInputSchema,\n srsRecentNotebaseScheduleStatusStatsOutputSchema,\n srsReviewInputSchema,\n srsReviewOutputSchema,\n srsRollbackReviewInputSchema,\n srsRollbackReviewOutputSchema,\n srsScheduleStatusStatsInputSchema,\n srsScheduleStatusStatsOutputSchema,\n srsSetCardBuriedInputSchema,\n srsSetCardBuriedOutputSchema,\n srsSetCardSuspendedInputSchema,\n srsSetCardSuspendedOutputSchema,\n srsApplyPostponeInputSchema,\n srsApplyPostponeOutputSchema,\n srsPreviewPostponeInputSchema,\n srsPreviewPostponeOutputSchema,\n} from \"#/schemas/srs\";\n\nexport const srsContract = {\n scheduleStatusStats: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/schedule-status-stats\",\n summary: \"Get study statistics\",\n description:\n \"Read existing study queue counts for owned notebases in the supplied timezone. Does not return note content or card faces.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(srsScheduleStatusStatsInputSchema)\n .output(srsScheduleStatusStatsOutputSchema),\n recentNotebaseScheduleStatusStats: oc\n .route({\n method: \"GET\",\n path: \"/srs/schedule-status-stats/recent\",\n summary: \"Get study queue counts of the most recently used notebase\",\n description:\n \"Picks the owned notebase with the latest review or content edit (notes, fields or templates) and returns its study queue counts in the supplied timezone.\",\n tags: [\"SRS\"],\n })\n .input(srsRecentNotebaseScheduleStatusStatsInputSchema)\n .output(srsRecentNotebaseScheduleStatusStatsOutputSchema),\n listUnreadOptimizerResults: oc\n .route({\n method: \"GET\",\n path: \"/srs/optimizer-results/unread\",\n summary: \"List unread applied SRS optimizer results\",\n tags: [\"SRS\"],\n })\n .input(srsListUnreadOptimizerResultsInputSchema)\n .output(srsListUnreadOptimizerResultsOutputSchema),\n\n acknowledgeOptimizerResults: oc\n .route({\n method: \"POST\",\n path: \"/srs/optimizer-results/acknowledge\",\n summary: \"Acknowledge current SRS optimizer results\",\n tags: [\"SRS\"],\n })\n .input(srsAcknowledgeOptimizerResultsInputSchema)\n .output(srsAcknowledgeOptimizerResultsOutputSchema),\n\n listCardRevlogs: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/revlogs\",\n summary: \"List review history\",\n description:\n \"Read owned review records, optionally filtered by notebase or card. Supports limit and offset pagination. Note content, card faces and rollback snapshots are excluded.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\", \"NOTEBASE_NOT_FOUND\"))\n .input(srsListCardRevlogsInputSchema)\n .output(srsListCardRevlogsOutputSchema),\n\n review: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/review\",\n summary: \"Record review\",\n description:\n \"Submit one rating for a known owned card without a queue, session or prerequisite read. Existing SRS eligibility, scheduling and sibling rules apply. The optional id is the existing state-derived review ID, not an arbitrary UUID; calls without a stable id are not guaranteed to deduplicate.\",\n tags: [\"SRS\"],\n })\n .errors(pickPublicErrorMap(\"CARD_NOT_FOUND\", \"CARD_NOT_REVIEWABLE\", \"CARD_REVIEW_STATE_STALE\"))\n .input(srsReviewInputSchema)\n .output(srsReviewOutputSchema),\n rollbackReview: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/review/rollback\",\n summary: \"Undo review\",\n description:\n \"Undo the latest eligible review of one owned card, preserving existing SRS restrictions and sibling restoration. expectedReviewId guards against undoing an earlier review on a retry.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_REVIEW_ROLLBACK_UNAVAILABLE\",\n \"CARD_REVIEW_STATE_STALE\",\n ),\n )\n .input(srsRollbackReviewInputSchema)\n .output(srsRollbackReviewOutputSchema),\n setCardBuried: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/card/bury\",\n summary: \"Set card buried\",\n description:\n \"Bury or unbury one owned card. enabled=true buries and enabled=false unburies it. Existing state-change rules apply.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_ALREADY_BURIED\",\n \"CARD_NOT_BURIED\",\n \"CARD_STATUS_CHANGE_UNAVAILABLE\",\n ),\n )\n .input(srsSetCardBuriedInputSchema)\n .output(srsSetCardBuriedOutputSchema),\n setCardSuspended: defineAgentProcedure({\n method: \"POST\",\n path: \"/srs/card/suspend\",\n summary: \"Set card suspended\",\n description:\n \"Suspend or resume one owned card. enabled=true suspends and enabled=false resumes it. Existing state-change rules apply.\",\n tags: [\"SRS\"],\n })\n .errors(\n pickPublicErrorMap(\n \"CARD_NOT_FOUND\",\n \"CARD_ALREADY_SUSPENDED\",\n \"CARD_NOT_SUSPENDED\",\n \"CARD_STATUS_CHANGE_UNAVAILABLE\",\n ),\n )\n .input(srsSetCardSuspendedInputSchema)\n .output(srsSetCardSuspendedOutputSchema),\n\n previewPostpone: oc\n .errors(\n pickPublicErrorMap(\n \"NOTEBASE_NOT_FOUND\",\n \"RESCHEDULE_PREVIEW_TIMEOUT\",\n \"RESCHEDULE_DAILY_LIMIT_INVALID\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/srs/postpone/preview\",\n summary: \"Preview postpone\",\n tags: [\"SRS\"],\n })\n .input(srsPreviewPostponeInputSchema)\n .output(srsPreviewPostponeOutputSchema),\n\n applyPostpone: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\", \"RESCHEDULE_PLAN_EXPIRED\", \"RESCHEDULE_STALE\"))\n .route({\n method: \"POST\",\n path: \"/srs/postpone\",\n summary: \"Apply postpone\",\n tags: [\"SRS\"],\n })\n .input(srsApplyPostponeInputSchema)\n .output(srsApplyPostponeOutputSchema),\n};\n","import { z } from \"zod\";\n\nexport const notebaseActivityStatsItemSchema = z\n .object({\n date: z.iso.date(),\n notes: z.number().int().nonnegative(),\n })\n .strict();\nexport type NotebaseActivityStatsItem = z.infer<typeof notebaseActivityStatsItemSchema>;\n\nexport const notebaseActivityStatsOutputSchema = z\n .object({\n daily: z.array(notebaseActivityStatsItemSchema),\n })\n .strict();\nexport type NotebaseActivityStatsOutput = z.infer<typeof notebaseActivityStatsOutputSchema>;\n\nexport const notebaseRowGrowthStatsItemSchema = z\n .object({\n date: z.iso.date(),\n delta: z.number().int(),\n })\n .strict();\nexport type NotebaseRowGrowthStatsItem = z.infer<typeof notebaseRowGrowthStatsItemSchema>;\n\nexport const notebaseRowGrowthStatsOutputSchema = z\n .object({\n baseTotal: z.number().int().nonnegative(),\n daily: z.array(notebaseRowGrowthStatsItemSchema),\n })\n .strict();\nexport type NotebaseRowGrowthStatsOutput = z.infer<typeof notebaseRowGrowthStatsOutputSchema>;\n","import { z } from \"zod\";\n\nexport const srsActivityStatsItemSchema = z\n .object({\n date: z.iso.date(),\n answers: z.number().int().nonnegative(),\n durationMs: z.number().int().nonnegative(),\n })\n .strict();\nexport type SrsActivityStatsItem = z.infer<typeof srsActivityStatsItemSchema>;\n\nexport const srsActivityStatsOutputSchema = z\n .object({\n learnedCards: z.number().int().nonnegative(),\n daily: z.array(srsActivityStatsItemSchema),\n })\n .strict();\nexport type SrsActivityStatsOutput = z.infer<typeof srsActivityStatsOutputSchema>;\n\nexport const srsMemoryGrowthStatsItemSchema = z\n .object({\n date: z.iso.date(),\n delta: z.number().int(),\n })\n .strict();\nexport type SrsMemoryGrowthStatsItem = z.infer<typeof srsMemoryGrowthStatsItemSchema>;\n\nexport const srsMemoryGrowthStatsOutputSchema = z\n .object({\n baseTotal: z.number().int().nonnegative(),\n daily: z.array(srsMemoryGrowthStatsItemSchema),\n })\n .strict();\nexport type SrsMemoryGrowthStatsOutput = z.infer<typeof srsMemoryGrowthStatsOutputSchema>;\n","import { z } from \"zod\";\nimport { notebaseActivityStatsOutputSchema } from \"./notebase-stats\";\nimport { srsActivityStatsOutputSchema } from \"./srs-stats\";\nimport { canonicalTimezoneSchema } from \"./timezone\";\n\nconst statsNotebaseIdsSchema = z\n .array(z.uuid())\n .min(1)\n .transform((ids) => Array.from(new Set(ids)));\n\nexport const statsInputSchema = z\n .object({\n notebaseIds: statsNotebaseIdsSchema.optional(),\n from: z.iso.date().optional(),\n to: z.iso.date(),\n timezone: canonicalTimezoneSchema,\n })\n .strict()\n .refine((input) => !input.from || input.from <= input.to, {\n message: \"from must be before or equal to to\",\n path: [\"from\"],\n });\nexport type StatsInput = z.infer<typeof statsInputSchema>;\n\nexport const activityStatsOutputSchema = z\n .object({\n srs: srsActivityStatsOutputSchema,\n notebase: notebaseActivityStatsOutputSchema,\n })\n .strict();\nexport type ActivityStatsOutput = z.infer<typeof activityStatsOutputSchema>;\n","import { defineAgentProcedure } from \"./shared\";\nimport { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport { notebaseRowGrowthStatsOutputSchema } from \"#/schemas/notebase-stats\";\nimport { srsBacklogStatsInputSchema, srsBacklogStatsOutputSchema } from \"#/schemas/srs\";\nimport { srsMemoryGrowthStatsOutputSchema } from \"#/schemas/srs-stats\";\nimport { activityStatsOutputSchema, statsInputSchema } from \"#/schemas/stats\";\n\nexport const statsContract = {\n activity: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/stats/activity\",\n summary: \"Get SRS and notebase activity statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(activityStatsOutputSchema),\n\n srsMemoryGrowth: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/srs/stats/memory-growth\",\n summary: \"Get SRS long-term memory growth statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(srsMemoryGrowthStatsOutputSchema),\n\n notebaseRowGrowth: oc\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .route({\n method: \"GET\",\n path: \"/notebases/stats/row-growth\",\n summary: \"Get notebase row growth statistics\",\n tags: [\"Statistics\"],\n })\n .input(statsInputSchema)\n .output(notebaseRowGrowthStatsOutputSchema),\n\n // A statistic like the rest, so reviews, which invalidate every `stats` query,\n // mark it stale too.\n backlogStats: defineAgentProcedure({\n method: \"GET\",\n path: \"/srs/stats/backlog\",\n summary: \"Get review backlogs\",\n description:\n \"Read overdue review backlogs for owned awake notebases in the supplied timezone. Only a notebase whose overdue reviews fill two or more days of its daily review limit is listed; the rest are left out. A notebase whose daily review limit is 0 or unlimited (-1) never returns anything, even when its ID is requested. Does not return note content or card faces.\",\n tags: [\"Statistics\"],\n })\n .errors(pickPublicErrorMap(\"NOTEBASE_NOT_FOUND\"))\n .input(srsBacklogStatsInputSchema)\n .output(srsBacklogStatsOutputSchema),\n};\n","import { z } from \"zod\";\n\n// What the web app reports about keeping its Electric data live. Every field is\n// an enum, so each label the API counts them under has a fixed set of values.\n\n/** The shapes the web app syncs, by their names in `@repo/electric-contract`. */\nexport const webSyncShapeSchema = z.enum([\n \"notebases\",\n \"notebaseColumns\",\n \"notebaseRows\",\n \"cardTemplates\",\n \"cards\",\n \"revlogs\",\n \"mediaAssets\",\n]);\nexport type WebSyncShape = z.infer<typeof webSyncShapeSchema>;\n\n/** The write whose change the page waited to see come back over Electric. */\nexport const webSyncOperationSchema = z.enum([\n // The review session's own writes.\n \"review\",\n // A review the server had already recorded: it waits for that review's card\n // and revlog, as its own transaction wrote nothing.\n \"reviewReplay\",\n \"undo\",\n \"bury\",\n \"suspend\",\n \"deleteNote\",\n \"deleteCard\",\n // A synced collection's own mutation handlers.\n \"insert\",\n \"update\",\n \"delete\",\n // Other writes that wait for their change.\n \"setSleep\",\n \"srsSettings\",\n \"cardStatus\",\n \"createTemplate\",\n \"updateTemplate\",\n]);\nexport type WebSyncOperation = z.infer<typeof webSyncOperationSchema>;\n\n/** How the shape that lagged was receiving live changes. */\nexport const webSyncTransportSchema = z.enum([\"sse\", \"longPoll\"]);\nexport type WebSyncTransport = z.infer<typeof webSyncTransportSchema>;\n\n/**\n * A write wait is only reported once its first wait ran out: `recovered` when\n * reconnecting the lagging shapes brought the change, `failed` when the page\n * gave up on it.\n */\nexport const webSyncWriteOutcomeSchema = z.enum([\"recovered\", \"failed\"]);\nexport type WebSyncWriteOutcome = z.infer<typeof webSyncWriteOutcomeSchema>;\n\nexport const webSyncStreamErrorTypeSchema = z.enum([\n // 401: the session ended.\n \"unauthorized\",\n // 403: the notebase was deleted, or is someone else's.\n \"forbidden\",\n // 400 and any other 4xx.\n \"badRequest\",\n \"clientError\",\n // A response without Electric's headers: a proxy or CORS in the way.\n \"missingHeaders\",\n // Anything that is not an HTTP status: an unreadable body, a parse error.\n \"unexpected\",\n]);\nexport type WebSyncStreamErrorType = z.infer<typeof webSyncStreamErrorTypeSchema>;\n\n/** `initial` before the shape first loaded, when the page shows the error at once. */\nexport const webSyncStreamPhaseSchema = z.enum([\"initial\", \"live\"]);\nexport type WebSyncStreamPhase = z.infer<typeof webSyncStreamPhaseSchema>;\n\nexport const webSyncPageSchema = z.enum([\"reviewCombined\", \"reviewNotebase\"]);\nexport type WebSyncPage = z.infer<typeof webSyncPageSchema>;\n\nexport const webSyncUnavailableReasonSchema = z.enum([\n // A write's change never came back, even after reconnecting.\n \"syncTimeout\",\n // A shape stream stopped.\n \"streamFailed\",\n // The notebase is gone: its shapes answer 403.\n \"notebaseGone\",\n]);\nexport type WebSyncUnavailableReason = z.infer<typeof webSyncUnavailableReasonSchema>;\n\nexport const webSyncEventSchema = z.discriminatedUnion(\"type\", [\n z\n .object({\n type: z.literal(\"writeWait\"),\n operation: webSyncOperationSchema,\n outcome: webSyncWriteOutcomeSchema,\n transport: webSyncTransportSchema,\n })\n .strict(),\n z\n .object({\n type: z.literal(\"streamError\"),\n shape: webSyncShapeSchema,\n errorType: webSyncStreamErrorTypeSchema,\n phase: webSyncStreamPhaseSchema,\n })\n .strict(),\n z\n .object({\n type: z.literal(\"unavailable\"),\n page: webSyncPageSchema,\n reason: webSyncUnavailableReasonSchema,\n })\n .strict(),\n]);\nexport type WebSyncEvent = z.infer<typeof webSyncEventSchema>;\n\n/** A page sends what happened within a second or so as one batch. */\nexport const WEB_SYNC_REPORT_MAX_EVENTS = 20;\n\nexport const reportWebSyncInputSchema = z\n .object({\n events: z.array(webSyncEventSchema).min(1).max(WEB_SYNC_REPORT_MAX_EVENTS),\n })\n .strict();\nexport type ReportWebSyncInput = z.infer<typeof reportWebSyncInputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { z } from \"zod\";\nimport { reportWebSyncInputSchema } from \"#/schemas/web-sync\";\n\nexport const telemetryContract = {\n // Public: a page whose session ended still reports the streams that failed\n // because of it.\n reportWebSync: oc\n .route({\n method: \"POST\",\n path: \"/telemetry/web-sync\",\n summary: \"Report problems the web app had keeping its synced data live\",\n tags: [\"Telemetry\"],\n })\n .input(reportWebSyncInputSchema)\n .output(z.void()),\n};\n","import { z } from \"zod\";\nimport { appLocaleSchema } from \"./app-locale\";\nimport { timezoneSchema } from \"./timezone\";\n\nexport const userEnsureTimezoneInputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserEnsureTimezoneInput = z.infer<typeof userEnsureTimezoneInputSchema>;\n\nexport const userEnsureTimezoneOutputSchema = z\n .object({\n timezone: timezoneSchema,\n updated: z.boolean(),\n })\n .strict();\nexport type UserEnsureTimezoneOutput = z.infer<typeof userEnsureTimezoneOutputSchema>;\n\nexport const userUpdateTimezoneInputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserUpdateTimezoneInput = z.infer<typeof userUpdateTimezoneInputSchema>;\n\nexport const userUpdateTimezoneOutputSchema = z\n .object({\n timezone: timezoneSchema,\n })\n .strict();\nexport type UserUpdateTimezoneOutput = z.infer<typeof userUpdateTimezoneOutputSchema>;\n\n// The account's language, which emails are written in. `ensureLocale` only\n// fills it in when it is empty (the language www is showing on a signed-in\n// visit); `updateLocale` is the user choosing a language.\nexport const userEnsureLocaleInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserEnsureLocaleInput = z.infer<typeof userEnsureLocaleInputSchema>;\n\nexport const userEnsureLocaleOutputSchema = z\n .object({\n locale: appLocaleSchema,\n updated: z.boolean(),\n })\n .strict();\nexport type UserEnsureLocaleOutput = z.infer<typeof userEnsureLocaleOutputSchema>;\n\nexport const userUpdateLocaleInputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserUpdateLocaleInput = z.infer<typeof userUpdateLocaleInputSchema>;\n\nexport const userUpdateLocaleOutputSchema = z\n .object({\n locale: appLocaleSchema,\n })\n .strict();\nexport type UserUpdateLocaleOutput = z.infer<typeof userUpdateLocaleOutputSchema>;\n","import { oc } from \"@orpc/contract\";\nimport {\n userEnsureLocaleInputSchema,\n userEnsureLocaleOutputSchema,\n userEnsureTimezoneInputSchema,\n userEnsureTimezoneOutputSchema,\n userUpdateLocaleInputSchema,\n userUpdateLocaleOutputSchema,\n userUpdateTimezoneInputSchema,\n userUpdateTimezoneOutputSchema,\n} from \"#/schemas/user\";\n\nexport const userContract = {\n ensureTimezone: oc\n .route({\n method: \"POST\",\n path: \"/users/me/timezone/ensure\",\n summary: \"Ensure the authenticated user has a timezone\",\n tags: [\"Users\"],\n })\n .input(userEnsureTimezoneInputSchema)\n .output(userEnsureTimezoneOutputSchema),\n updateTimezone: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/timezone\",\n summary: \"Update the authenticated user's timezone\",\n tags: [\"Users\"],\n })\n .input(userUpdateTimezoneInputSchema)\n .output(userUpdateTimezoneOutputSchema),\n ensureLocale: oc\n .route({\n method: \"POST\",\n path: \"/users/me/locale/ensure\",\n summary: \"Ensure the authenticated user has a locale\",\n tags: [\"Users\"],\n })\n .input(userEnsureLocaleInputSchema)\n .output(userEnsureLocaleOutputSchema),\n updateLocale: oc\n .route({\n method: \"PATCH\",\n path: \"/users/me/locale\",\n summary: \"Update the authenticated user's locale\",\n tags: [\"Users\"],\n })\n .input(userUpdateLocaleInputSchema)\n .output(userUpdateLocaleOutputSchema),\n};\n","import { getVideoIdFromUrl, transcriptSegmentSchema } from \"@read-frog/definitions\";\nimport { z } from \"zod\";\nimport { billingPlanSchema } from \"./billing\";\n\nexport const videoTranscriptStatusSchema = z.enum([\"pending\", \"processing\", \"completed\", \"failed\"]);\nexport type VideoTranscriptStatus = z.infer<typeof videoTranscriptStatusSchema>;\n\n// The transcript \"job\" resource: status + metadata, without the (heavy) segments payload.\nexport const videoTranscriptResourceSchema = z.object({\n id: z.string(),\n platform: z.string(),\n videoId: z.string(),\n url: z.string(),\n status: videoTranscriptStatusSchema,\n title: z.string().nullable(),\n durationSec: z.number().nullable(),\n detectedLanguage: z.string().nullable(),\n error: z.string().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\nexport type VideoTranscriptResource = z.infer<typeof videoTranscriptResourceSchema>;\n\n// The subtitles sub-resource: the segments + model-detected language, only available once completed.\nexport const videoTranscriptSubtitlesSchema = z.object({\n id: z.string(),\n detectedLanguage: z.string().nullable(),\n segments: z.array(transcriptSegmentSchema),\n});\nexport type VideoTranscriptSubtitles = z.infer<typeof videoTranscriptSubtitlesSchema>;\n\nexport const videoTranscriptCreateInputSchema = z\n .object({\n url: z.url().refine((url) => getVideoIdFromUrl(url) !== null, {\n message: \"url must be a supported video URL\",\n }),\n // The player's own duration, read from the media element. REQUIRED, and an\n // untrusted UX hint only: admission uses it to reject an over-quota request\n // instantly, but every reservation and charge is made against the\n // server-measured duration in the worker — lying here changes nothing about\n // what gets billed.\n durationSec: z.number().int().positive(),\n })\n .strict();\nexport type VideoTranscriptCreateInput = z.infer<typeof videoTranscriptCreateInputSchema>;\n\nexport const videoTranscriptGetInputSchema = z\n .object({\n id: z.uuid(),\n })\n .strict();\nexport type VideoTranscriptGetInput = z.infer<typeof videoTranscriptGetInputSchema>;\n\n// One quota pool as shown to the user. `resetAt` is null for a one-time grant\n// (it never resets); `expiresAt` is null for a monthly pool (its end is the\n// reset). Minutes are display units: `usedMinutes` rounds up and\n// `limitMinutes` rounds down, so the UI can never show headroom that\n// admission (which compares raw seconds) would deny.\nexport const videoTranscriptUsagePoolSchema = z.object({\n id: z.string(),\n usedMinutes: z.number().int(),\n limitMinutes: z.number().int(),\n remainingMinutes: z.number().int(),\n resetAt: z.iso.datetime().nullable(),\n expiresAt: z.iso.datetime().nullable(),\n});\nexport type VideoTranscriptUsagePool = z.infer<typeof videoTranscriptUsagePoolSchema>;\n\n// The caller's transcription quota usage. Totals aggregate across pools;\n// `remainingMinutes` nets out in-flight reservations (committed), while each\n// pool's `usedMinutes` shows settled spend only, so a progress bar cannot run\n// forward and then backwards when a job is released. Deliberately a non-strict\n// object: old clients strip the keys they don't know.\nexport const videoTranscriptUsageSchema = z.object({\n usedMinutes: z.number().int(),\n limitMinutes: z.number().int(),\n remainingMinutes: z.number().int(),\n plan: billingPlanSchema,\n pools: z.array(videoTranscriptUsagePoolSchema),\n});\nexport type VideoTranscriptUsage = z.infer<typeof videoTranscriptUsageSchema>;\n","import { oc } from \"@orpc/contract\";\nimport { pickPublicErrorMap } from \"#/public-errors\";\nimport {\n videoTranscriptCreateInputSchema,\n videoTranscriptGetInputSchema,\n videoTranscriptResourceSchema,\n videoTranscriptSubtitlesSchema,\n videoTranscriptUsageSchema,\n} from \"#/schemas/video-transcript\";\n\nexport const videoTranscriptContract = {\n create: oc\n .errors(\n pickPublicErrorMap(\n \"VIDEO_TRANSCRIPTION_QUOTA_EXCEEDED\",\n \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\",\n \"VIDEO_TRANSCRIPTION_PAYMENT_REQUIRED\",\n \"VIDEO_TRANSCRIPTION_UNSUPPORTED_LENGTH\",\n ),\n )\n .route({\n method: \"POST\",\n path: \"/video-transcripts\",\n summary: \"Create or reuse a video transcription job\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptCreateInputSchema)\n .output(videoTranscriptResourceSchema),\n getUsage: oc\n .route({\n method: \"GET\",\n path: \"/video-transcripts/usage\",\n summary: \"Get the caller's monthly transcription quota usage\",\n tags: [\"Video Transcription\"],\n })\n .output(videoTranscriptUsageSchema),\n get: oc\n .errors(\n pickPublicErrorMap(\"VIDEO_TRANSCRIPT_NOT_FOUND\", \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\"),\n )\n .route({\n method: \"GET\",\n path: \"/video-transcripts/{id}\",\n summary: \"Get a video transcription job's status\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptGetInputSchema)\n .output(videoTranscriptResourceSchema),\n getSubtitles: oc\n .errors(\n pickPublicErrorMap(\n \"VIDEO_TRANSCRIPT_NOT_FOUND\",\n \"VIDEO_TRANSCRIPT_NOT_READY\",\n \"VIDEO_TRANSCRIPTION_SUBSCRIPTION_REQUIRED\",\n ),\n )\n .route({\n method: \"GET\",\n path: \"/video-transcripts/{id}/subtitles\",\n summary: \"Get a completed video transcript's subtitles\",\n tags: [\"Video Transcription\"],\n })\n .input(videoTranscriptGetInputSchema)\n .output(videoTranscriptSubtitlesSchema),\n};\n","import type { ContractRouterClient } from \"@orpc/contract\";\nimport { billingContract } from \"./contracts/billing\";\nimport { cardContract } from \"./contracts/card\";\nimport { cardTemplateContract } from \"./contracts/card-template\";\nimport { ebookContract } from \"./contracts/ebook\";\nimport { emailPreferencesContract } from \"./contracts/email-preferences\";\nimport { featureAccessContract } from \"./contracts/feature-access\";\nimport { hostedAiContract } from \"./contracts/hosted-ai\";\nimport { masteryGoalContract } from \"./contracts/mastery-goal\";\nimport { mcpConnectionContract } from \"./contracts/mcp-connection\";\nimport { mediaContract } from \"./contracts/media\";\nimport { notebaseContract } from \"./contracts/notebase\";\nimport { notebaseColumnContract } from \"./contracts/notebase-column\";\nimport { notebaseRowContract } from \"./contracts/notebase-row\";\nimport { pdfTranslationContract } from \"./contracts/pdf-translation\";\nimport { speechContract } from \"./contracts/speech\";\nimport { srsContract } from \"./contracts/srs\";\nimport { statsContract } from \"./contracts/stats\";\nimport { telemetryContract } from \"./contracts/telemetry\";\nimport { userContract } from \"./contracts/user\";\nimport { videoTranscriptContract } from \"./contracts/video-transcript\";\n\nexport const contract = {\n billing: billingContract,\n card: cardContract,\n cardTemplate: cardTemplateContract,\n ebook: ebookContract,\n emailPreferences: emailPreferencesContract,\n featureAccess: featureAccessContract,\n hostedAi: hostedAiContract,\n masteryGoal: masteryGoalContract,\n mcpConnection: mcpConnectionContract,\n media: mediaContract,\n notebase: notebaseContract,\n notebaseColumn: notebaseColumnContract,\n notebaseRow: notebaseRowContract,\n pdfTranslation: pdfTranslationContract,\n speech: speechContract,\n srs: srsContract,\n stats: statsContract,\n telemetry: telemetryContract,\n user: userContract,\n videoTranscript: videoTranscriptContract,\n};\n\nexport type ORPCRouterClient = ContractRouterClient<typeof contract>;\n\nexport { type AgentRoute, defineAgentProcedure } from \"./contracts/shared\";\nexport * from \"./public-errors\";\nexport * from \"./schemas/app-locale\";\nexport * from \"./schemas/billing\";\nexport * from \"./schemas/card\";\nexport * from \"./schemas/ebook\";\nexport * from \"./schemas/email-preferences\";\nexport * from \"./schemas/feature-access\";\nexport * from \"./schemas/hosted-ai\";\nexport * from \"./schemas/media\";\nexport * from \"./schemas/mastery-goal\";\nexport * from \"./schemas/mcp-connection\";\nexport * from \"./schemas/notebase\";\nexport * from \"./schemas/notebase-column\";\nexport * from \"./schemas/notebase-row\";\nexport * from \"./schemas/notebase-stats\";\nexport * from \"./schemas/notebase-view\";\nexport * from \"./schemas/pdf-translation\";\nexport * from \"./schemas/speech\";\nexport * from \"./schemas/srs\";\nexport * from \"./schemas/srs-stats\";\nexport * from \"./schemas/stats\";\nexport * from \"./schemas/timezone\";\nexport * from \"./schemas/user\";\nexport * from \"./schemas/video-transcript\";\nexport * from \"./schemas/web-sync\";\n\nexport * from \"./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