import { DEFAULT_SEO_KEYS, ResolveSeoContext, SEO_COMPONENT_ID, SEO_FIELD_IDS, SeoDefaults, SeoKeys, SeoLocaleDefaults, SeoLocaleDefaults as SeoLocaleDefaults$1, applyTitleTemplate, resolveSeo, seoDefaultsForLocale } from "@shapio/schema/seo"; import { ChangeSummary, ClassifiedChange, DataType, DefinitionCategory, DefinitionInput, ExportedDefinition, LensEffect, LocaleDefinition, LockFile, MEDIA_KINDS, PlannedChange, SchemaDefinition, SyncDecision, ValidationIssue } from "@shapio/schema"; //#region src/nextCache.d.ts /** * Next.js data-cache support for delivery reads. Under Next (`process.env.NEXT_RUNTIME` is set) or when the * client is given a `next` option, every delivery read passes `next: { tags }` to `fetch`, so a website can * refresh exactly what changed with `revalidateTag`. The cache mode is only set when asked for, except that a * read pinned to a publication snapshot is immutable and always `force-cache`, and a drafts-mode read is never * cached or tagged (`no-store`). Elsewhere nothing is added. */ /** Next's `fetch` cache modes the client passes through. */ type NextCacheMode = 'force-cache' | 'no-store'; type NextCacheOptions = { /** Next's `fetch` `cache` option. Unset: Next's own default, except pinned snapshot reads (`force-cache`). */ cache?: NextCacheMode; /** Seconds a cached response stays fresh (`next.revalidate`); `false` keeps it until a tag is revalidated. */ revalidate?: number | false; }; /** The last argument of every delivery read: overrides the client's `next` option; `false` adds nothing. */ type DeliveryReadOptions = { next?: NextCacheOptions | false; }; /** What a delivery read adds to its `fetch` init. */ type NextFetchInit = { cache?: NextCacheMode; next?: { tags: string[]; revalidate?: number | false; }; }; /** * The cache tags delivery reads carry (`revalidateTag(shapioTags.entry('articles', id), { expire: 0 })`). * Models are named by their route key: a collection's plural API ID, a singleton's API ID, and for a type that * extends another its ancestors' plural API IDs and its own joined by `/` (`posts/guides`). */ declare const shapioTags: { /** Every delivery read of the workspace; `shapio:site` when the client names no workspace. */ readonly workspace: (workspaceKey?: string) => string; /** The older name of `workspace` (the same tags). */ readonly site: (workspaceKey?: string) => string; /** Every read of one model (lists, singletons and its entries). */ readonly model: (routeKey: string) => string; /** Reads of one entry by its ID. */ readonly entry: (routeKey: string, entryId: string) => string; /** * Everything to revalidate when an entry of `routeKey` changes (a webhook's or a snapshot diff's * `routeKey`): the model and entry tags of its route key and of every ancestor's, since a Guide is also * in the Posts list and readable as `posts/`. `shapioTags.changed('posts/guides', id)` gives * `shapio:posts`, `shapio:posts:`, `shapio:posts/guides` and `shapio:posts/guides:`. Without an * entry ID, the model tags only. `interfaces` (a webhook's `interfaces`: the plural API IDs of the interfaces * the entry's type implements) adds each interface list's tags the same way, since the entry is also in * `/api/content/featurables` and readable as `featurables/`. */ readonly changed: (routeKey: string, entryId?: string, interfaces?: readonly string[]) => string[]; }; /** What every delivery read needs to tag itself: the client's workspace, `next` option and drafts mode. */ type DeliveryCacheContext = { site: string | undefined; next: NextCacheOptions | false | undefined; /** Drafts mode (`drafts: true`): reads ask for drafts, which are never cached. */ drafts: boolean; }; //#endregion //#region src/request.d.ts /** Fetch's `credentials` mode (spelled out: the DOM lib type is not available to Node consumers). */ type FetchCredentials = 'omit' | 'same-origin' | 'include'; type RequestOptions = { method?: string; body?: unknown; signal?: AbortSignal; } & NextFetchInit; type RequestFn = (path: string, options?: RequestOptions) => Promise; //#endregion //#region src/admin/contentTypes.d.ts /** * Admin content API shapes (package E, `apps/api/src/routes/admin/content/**` and * `routes/schemas/content.ts`). Entry `data` is keyed by API keys; its shape is the model's, known only at * runtime. Dates are ISO-8601 strings. */ /** `modified`: published, and the draft has changed since (or holds autosaved work). */ type EntryStatus = 'draft' | 'published' | 'modified'; /** Field values keyed by API key. Admin reads return media fields as asset views; writes take asset IDs. */ type EntryData = Record; type EntryLocaleState = { locale: string; /** The draft version: send it back as `expectedVersion` when saving this locale. */ version: number; status: EntryStatus; publishedAt: string | null; /** The published version's shared (non-localized) fields are older than the draft's (ADR 0004). */ sharedOutdated: boolean; }; /** One entry's draft in one locale, with every locale's status. */ type AdminEntry = { id: string; /** The model's API key. */ model: string; locale: string; version: number; revisionId: string; status: EntryStatus; /** Saved without full validation (autosave or duplicate): Save or Publish validates it. */ autosaved: boolean; createdAt: string; updatedAt: string; publishedAt: string | null; data: EntryData; /** Locales that have a draft of this entry. */ locales: EntryLocaleState[]; /** Other published locales whose live shared values are older than their drafts. */ sharedOutdatedLocales: string[]; }; /** The admin who created an entry (null for entries created by API tokens, app users or imports). */ type EntryAuthor = { id: string; name: string; }; /** One locale's status of a list item (localized models). */ type EntryLocaleStatus = { locale: string; status: EntryStatus; }; type AdminEntryListItem = { id: string; /** * The entry's own model (its singular API ID). A type's list holds its kinds' entries too, so a row may * belong to a kind of the model the list was read for. */ model: string; locale: string; version: number; status: EntryStatus; autosaved: boolean; createdAt: string; updatedAt: string; data: EntryData; author: EntryAuthor | null; /** Localized models only: every locale the entry has a version in, with its status. */ locales?: EntryLocaleStatus[]; }; type ContentPagination = { page: number; pageSize: number; total: number; pageCount: number; }; type AdminEntryPage = { items: AdminEntryListItem[]; pagination: ContentPagination; /** The locale the list was read in. */ locale: string; }; /** Operators of the content query compiler (`apps/api/src/content/compiler/types.ts`). */ type ContentFilterOperator = '$eq' | '$ne' | '$in' | '$nin' | '$lt' | '$lte' | '$gt' | '$gte' | '$contains' | '$notContains' | '$containsi' | '$startsWith' | '$endsWith' | '$null' | '$notNull'; /** A scalar operand; `$in`/`$nin` take a list, `$null`/`$notNull` take `true`. */ type ContentFilterValue = string | number | boolean | ReadonlyArray; /** * A filter tree, serialized with brackets: `{ title: { $eq: 'A' } }` → `filters[title][$eq]=A`. Field keys are * API keys (or `id`, `createdAt`, `updatedAt`); `$and`/`$or` take lists of trees, `$not` one tree. */ type ContentFilter = { [key: string]: Partial> | ContentFilterValue | ContentFilter | readonly ContentFilter[]; }; type ContentSort = { field: string; direction: 'asc' | 'desc'; }; type ContentListQuery = { filters?: ContentFilter; sort?: readonly ContentSort[]; page?: number; pageSize?: number; /** Free-text search over the model's title field. */ q?: string; locale?: string; /** Top-level fields to return (API keys); all readable fields when absent. */ fields?: readonly string[]; /** Relation paths to expand, e.g. `author` or `author.company`. */ populate?: readonly string[]; /** Admin list only: entries in this status (in the locale the list is read in). */ status?: EntryStatus; /** Admin list only: entries created by this admin user (ID). */ author?: string; }; type CreateEntryInput = { locale?: string; data?: EntryData; /** Publish the new entry's locale in the same transaction. */ publish?: boolean; }; type UpdateEntryInput = { locale?: string; /** The draft version the editor loaded; null creates the entry's version in this locale. */ expectedVersion: number | null; /** Changed fields only: a field set to null is cleared, absent fields are kept. */ data?: EntryData; /** Autosave: moves the draft head only (no revision) and does not enforce `required`. */ autosave?: boolean; }; /** * Moves an entry to another kind of its family (any member, the root included). Values of fields the target * lacks are dropped, so a change that drops any must acknowledge it; `expectedVersion` is the draft version * the editor saw, of `locale`'s draft (the default locale's when absent). */ type ChangeEntryKindInput = { /** The target kind's API ID (singular). */ targetModelKey: string; expectedVersion: number; locale?: string; /** Required on a change that drops fields; optional on a dry run. */ acknowledgeDroppedFields?: true; }; /** A field whose values a kind change drops (the source has it, the target doesn't). */ type DroppedField = { id: string; apiKey: string; label: string; }; /** * A kind change's answer: the fields whose values it drops and the kind the entry becomes; `entry` is the * entry under its new kind (absent on a dry run, `?dryRun=1`). */ type EntryKindChange = { droppedFields: DroppedField[]; target: { modelId: string; modelKey: string; routeKey: string; }; entry?: AdminEntry; }; /** Publish or unpublish these locales atomically (the request's default locale when omitted). */ type EntryLocalesInput = { locales?: string[]; }; /** * Publish these locales, optionally guarded by the draft version(s) you saw (409 CONTENT_VERSION_CONFLICT when * one moved): `expectedVersion` for a publish of one locale, `expectedVersions` (per locale) for several. */ type EntryPublishInput = EntryLocalesInput & { expectedVersion?: number; expectedVersions?: Record; }; type RevisionSummary = { id: string; locale: string; /** Why the revision exists: `create`, `save`, `restore`, `localize`, `publish`... */ reason: string; schemaRevisionId: string; authorType: string; authorId: string | null; parentRevisionId: string | null; createdAt: string; }; type RevisionDetail = RevisionSummary & { data: EntryData; }; /** One live period of an entry's locale: who published it and how, and whether it is still live. */ type EntryPublication = { /** The revision that went live. */ revisionId: string; locale: string; publishedAt: string; publishedBy: string | null; /** How it went live when not by a plain Publish: on schedule, or with a change set (`changeSetTitle`). */ via: 'schedule' | 'changeSet' | null; changeSetTitle: string | null; live: boolean; /** Set when it stopped being live without another publication of the locale replacing it. */ unpublishedAt: string | null; unpublishedBy: string | null; }; /** An entry's history: revisions with who made them, and its publications (both newest first). */ type EntryHistory = { items: Array; publications: EntryPublication[]; }; /** One problem with a content value (422 CONTENT_INVALID `details.issues`). */ type ContentIssue = { path: string; code: string; message: string; }; /** An entry that still points at the one being deleted (409 ENTRY_REFERENCED `details.referrers`). */ type EntryReferrer = { entryId: string; modelId: string; locale: string; state: string; }; /** A custom field editor module the server serves (from the project's `shapio.config` and `extensions/editors`). */ type EditorManifestItem = { /** File name in `extensions/editors/`, e.g. `star-rating.js`. */ file: string; /** Path to import the module from, relative to the server's base URL. */ path: string; /** Content hash: changes whenever the file changes (cache busting). */ hash: string; }; type EditorManifest = { items: EditorManifestItem[]; }; /** An admin color theme a project declares in `shapio.config` (its CSS is served as `themes.css`). */ type ExtensionTheme = { key: string; name: string; description?: string; /** The variants it defines; one means it ignores the light/dark setting. */ variants: Array<'light' | 'dark'>; }; type ExtensionThemeList = { items: ExtensionTheme[]; }; /** * `GET /api/admin/content-targets`: what a relation field to an interface or to any entry may point at * (plan interfaces). Keyed by the relation field (top level or inside a component; field IDs are global): the * server resolves its target and the models the caller may read. */ type ContentTargetsQuery = { /** The relation field's stable ID. */ field: string; /** Narrow to these models (singular API IDs); default every readable one. Ignored with `ids`. */ types?: readonly string[]; /** Searched on each model's own title field; models whose title the caller may not search are skipped. */ q?: string; page?: number; pageSize?: number; locale?: string; /** * Exactly these entries (at most 100), whatever their model, among the readable ones: labels a stored value. * `q`, `types` and paging are ignored; `total` is the number of items returned. */ ids?: readonly string[]; }; /** What the relation targets: its kind, and the label to show ("Featurable", "Any entry"; null for any). */ type ContentTargetKind = { kind: 'model' | 'interface' | 'any'; label: string | null; }; /** A model the field may point at that the caller may read: the type filter's choices. */ type ContentTargetMember = { apiKey: string; label: string; }; type ContentTargetItem = { id: string; /** The entry's model (singular API ID). */ model: string; /** The entry's title in its model's own title field; null when it has none or the caller may not read it. */ title: string | null; status: EntryStatus; locale: string; updatedAt: string; }; type ContentTargets = { target: ContentTargetKind; members: ContentTargetMember[]; items: ContentTargetItem[]; total: number; }; //#endregion //#region src/schemaVersion.d.ts /** * Schema versions (server 0.9.0 or later). A client names the schema version it was built against, the * `SCHEMA_VERSION` token `shapio types generate` writes (`:`, opaque to the client), and * every read answers in that version's shape, even after the schema has moved on. */ /** The request header that names the client's schema version (every request except delivery reads). */ declare const SCHEMA_VERSION_HEADER = "shapio-schema-version"; /** The query parameter that names the client's schema version on delivery reads. */ declare const SCHEMA_VERSION_QUERY_PARAMETER = "schemaVersion"; /** The response header every delivery response carries: the instance's current schema version token. */ declare const SCHEMA_VERSION_CURRENT_HEADER = "shapio-schema-version-current"; /** What a response read through a schema version says about it (`meta.schemaVersion`). */ type SchemaVersionMeta = { /** The token the request named. */ requested: string; /** The instance's current schema version token. */ current: string; }; //#endregion //#region src/deliveryTypes.d.ts /** * The delivery API (`/api/content/:routeKey`): published content as websites and apps read it. `routeKey` is a * collection's plural API ID (`articles`) or a singleton's API ID (`homepage`); a type that extends another is * nested under its ancestors' plural API IDs (`posts/guides`). */ /** * How rich-text fields come back: `json` (the server's default) the stored document `{ format, version, doc }`, * `html` `{ format, version, html }` with sanitized HTML rendered on the server, `both` the document and `html`. */ type RichTextMode = 'json' | 'html' | 'both'; /** * How SEO fields come back: `raw` (the default) as stored, `resolved` merged with the workspace's SEO defaults * (`SeoResolved`). `resolved` needs an SEO field on the model; a pinned snapshot uses today's defaults. */ type SeoMode = 'raw' | 'resolved'; type DeliveryListQuery = Omit & { /** Read the publication snapshot N (`GET /api/snapshots/current` gives the newest) instead of now. */ snapshot?: number; /** The shape of rich-text fields (`json` when absent). */ richText?: RichTextMode; /** SEO fields as stored or with the workspace's defaults (`raw` when absent). */ seo?: SeoMode; }; type DeliveryGetQuery = Pick; type DeliveryMeta = { locale: string; /** The publication snapshot this response reflects; null in drafts mode, which cannot be pinned. */ snapshot: number | null; /** Drafts mode reads only (`publicationState=draft`); published responses carry no such member. */ publicationState?: 'draft'; /** * Reads through a schema version only (the client's `schemaVersion`, server 0.9.0 or later): the version * the response is shaped as and the instance's current one. Absent when no version was named. */ schemaVersion?: SchemaVersionMeta; }; type DeliveryPagination = { page: number; pageSize: number; total: number; pageCount: number; }; /** * What every delivery entry carries besides its fields. `__model` is the singular API ID of the entry's own * model: in a parent's list (`/api/content/posts`) each row is one kind (`post`, `guide`) in its * own shape, so switch on `__model` the way a dynamic zone item is read by `__component`. `__kinds` is its * lineage, root first and its own kind last (`['product', 'physical', 'apparel']`), so a row can be matched * to any level of the family. */ type DeliveryEntryAttributes = { __model: string; __kinds: readonly string[]; }; /** * What every component item carries besides its fields (server 0.9.0 or later): `id`, its stable ID. A single * component, each item of a repeatable component, and each item of a dynamic zone have one, and an unchanged * item has the same `id` in the draft and the published version. On a write, send back the `id` of each item * you read so the server pairs it with the item it continues; leave it out for a new item. */ type DeliveryComponentAttributes = { id: string; }; /** A component item as delivery returns it: the caller's type with its `id`. */ type DeliveryComponent> = T & DeliveryComponentAttributes; /** A dynamic zone item: a component item plus its component's API ID in `__component`. */ type DeliveryZoneItem> = DeliveryComponent & { __component: string; }; /** One kind of a family list (`meta.kinds`): its API ID, label, parent's API ID and route key. */ type DeliveryKind = { apiKey: string; label: string; parent: string | null; routeKey: string; }; /** * One member of an interface list (`meta.members`): a type that implements the interface and the caller may * read, with its API ID, label and route key. */ type DeliveryMember = { apiKey: string; label: string; routeKey: string; }; /** A delivery entry: the caller's type with the attributes every entry carries. */ type DeliveryEntry> = T & DeliveryEntryAttributes; type DeliveryList> = { data: Array>; /** * `kinds`: present when the listed type has kinds; those the caller may read, in tree order. `members`: * present on an interface's list (`/api/content/featurables`); the member types the caller may read. */ meta: DeliveryMeta & { pagination: DeliveryPagination; kinds?: DeliveryKind[]; members?: DeliveryMember[]; }; }; type DeliveryItem> = { data: DeliveryEntry; meta: DeliveryMeta; }; //#endregion //#region src/seoTypes.d.ts /** A media asset as the delivery API returns it (media fields, the workspace's default image). */ type DeliveryAsset = { id: string; filename: string; mimeType: string; sizeBytes: number; width: number | null; height: number | null; alt: string | null; caption: string | null; focalPoint: { x: number; y: number; } | null; url: string; /** Null for public assets (always, for the workspace's default image). */ urlExpiresAt: string | null; variants: Array<{ name: string; width: number | null; height: number | null; format: string; mimeType: string; url: string; }>; }; /** The built-in SEO component as delivered by default (`?seo=raw`): what the entry stores. */ type SeoFields = { /** * The stored instance's item ID (server 0.9.0 or later). `?seo=resolved` keeps it; a value made only from the * workspace's defaults has none. */ id?: string; title: string | null; description: string | null; image: DeliveryAsset | null; canonical: string | null; noindex: boolean | null; }; /** * The same field with `?seo=resolved` (or `resolveSeo`): the title through the workspace's template (the * entry's own title when the SEO title is empty), description and image from the workspace's defaults when * empty, `noindex` a boolean. `canonical` stays the entry's value or null: the website builds its own from its * URL. */ type SeoResolved = Omit & { noindex: boolean; }; /** `GET /api/site`: the request's workspace and its SEO defaults (texts per locale, the default image). */ type DeliverySite = { key: string; name: string; seo: { locales: Record; twitterHandle: string | null; image: DeliveryAsset | null; }; }; /** The workspace name of `DeliverySite` (the same type). */ type DeliveryWorkspace = DeliverySite; //#endregion //#region src/admin/approvalTypes.d.ts /** * Approval workflows (plan approval-workflows): the stages a change set goes through before it may ship, the * instance default every workspace inherits, and a workspace's own choice. Mirrors * apps/api/src/routes/schemas/approvalWorkflow.ts and the workspace and network route schemas. */ type ApprovalStage = { /** Stable; assigned by the server when a stage is saved without one. */ id: string; name: string; /** Admin role IDs; empty: anyone who may approve on the workspace. */ roleIds: string[]; /** Distinct sign-offs the stage needs (1 to 20). */ required: number; }; type ApprovalWorkflow = { /** One to ten stages, in order. */ stages: ApprovalStage[]; /** Whether the set's creator or requester may sign off. */ selfApproval: boolean; }; /** A workflow as sent: new stages have no ID yet; `selfApproval` defaults to false. */ type ApprovalWorkflowInput = { stages: Array & { id?: string; }>; selfApproval?: boolean; }; declare const APPROVAL_MODES: readonly ["inherit", "off", "custom"]; /** A workspace inherits the instance default, switches approval off, or keeps its own workflow. */ type ApprovalMode = (typeof APPROVAL_MODES)[number]; /** `GET /api/admin/site/change-sets`: the request's workspace's approval settings. */ type SiteChangeSets = { /** The workspace version an update must name. */ version: number; mode: ApprovalMode; /** The workspace's own workflow, kept while another mode is chosen. */ workflow: ApprovalWorkflow | null; /** The instance default this workspace would inherit. */ inherited: ApprovalWorkflow | null; /** What applies now; null: change sets ship without approval. */ effective: ApprovalWorkflow | null; /** Role IDs these workflows name that are no longer admin roles. */ unknownRoleIds: string[]; }; /** `PUT /api/admin/site/change-sets` (`site.settings`): without `workflow` the stored one is kept. */ type UpdateSiteChangeSetsInput = { expectedVersion: number; mode: ApprovalMode; workflow?: ApprovalWorkflowInput; }; /** The workspace names of `SiteChangeSets` and `UpdateSiteChangeSetsInput` (the same types). */ type WorkspaceChangeSets = SiteChangeSets; type UpdateWorkspaceChangeSetsInput = UpdateSiteChangeSetsInput; /** * `GET /api/admin/network/approval` (`sites.manage`): the instance default and the workspaces that follow it. */ type NetworkApproval = { /** The version an update must name (0: never saved). */ version: number; /** `custom`: inheriting workspaces follow the workflow; `off`: they ship without approval. */ mode: 'off' | 'custom'; /** The stored workflow, kept while the default is off; null until one is saved. */ workflow: ApprovalWorkflow | null; unknownRoleIds: string[]; sites: { inheriting: number; custom: Array<{ id: string; name: string; }>; off: Array<{ id: string; name: string; }>; }; }; /** Without `workflow` the stored one is kept; `custom` needs one stored or sent. */ type UpdateNetworkApprovalInput = { expectedVersion: number; mode: 'off' | 'custom'; workflow?: ApprovalWorkflowInput; }; //#endregion //#region src/admin/sitesTypes.d.ts /** A workspace: the tenant of content, media, tokens, change sets and snapshots (sites plan §H). */ type Site = { id: string; /** Lower case, starts with a letter; fixed once created. Sent as `Shapio-Site` or `?site=`. */ key: string; name: string; /** Requests that name no workspace go to the primary workspace. Exactly one; it cannot be deleted. */ isPrimary: boolean; /** * Ships and schedules approved change sets only: the workspace has an effective approval workflow (its own or * the inherited default; plan approval-workflows). Read-only; see `admin.workspace.changeSets`. */ requireApproval: boolean; version: number; createdAt: string; updatedAt: string; }; type SiteSummary = Pick; /** A workspace as webhook payloads and views name it. */ type SiteRef = Pick; type CreateSiteInput = { key: string; name: string; }; /** Only the name changes; `expectedVersion` guards against concurrent edits (409 `VERSION_CONFLICT`). */ type UpdateSiteInput = { expectedVersion: number; name: string; }; /** * The app roles a workspace binds: `public` applies to anonymous callers, `authenticated` to every signed-in * app user of the workspace. A new workspace binds nothing (deny by default). */ type SiteAppRoles = { siteId: string; public: string[]; authenticated: string[]; }; type SetSiteAppRolesInput = { public: string[]; authenticated: string[]; }; type Workspace = Site; type WorkspaceSummary = SiteSummary; type WorkspaceRef = SiteRef; type CreateWorkspaceInput = CreateSiteInput; type UpdateWorkspaceInput = UpdateSiteInput; type WorkspaceAppRoles = SiteAppRoles; type SetWorkspaceAppRolesInput = SetSiteAppRolesInput; //#endregion //#region src/admin/usageTypes.d.ts /** Field usage from delivery traffic (`GET /api/admin/usage/fields`, apps/api/src/routes/admin/usage). */ type UsageSelection = 'explicit' | 'implicit'; type FieldUsageQuery = { modelId: string; /** Days counted, today included (default 7; capped at USAGE_RETENTION_DAYS). */ days?: number; }; type FieldPrincipalUsage = { /** `token:`, `app_users` or `anonymous`. */ principalKey: string; /** The API token's name (tokens only, while the token exists). */ tokenName?: string; reads: number; lastReadAt: string; /** `implicit`: every read asked for the whole model (no field selection). */ selection: UsageSelection; }; type ModelFieldUsage = { /** A field ID, or `.` for a populated relation's field. */ fieldPath: string; /** API keys along the path in the current schema (`author.name`); null when a field no longer exists. */ apiKeyPath: string | null; reads: number; lastReadAt: string; principals: FieldPrincipalUsage[]; }; type PrincipalUsageSummary = { principalKey: string; tokenName?: string; /** Delivery requests over all models in the window. */ requests: number; lastReadAt: string; /** The snapshot this principal last pinned with `snapshot`; null when it reads live content. */ lastSnapshot: number | null; }; type FieldUsageResponse = { /** False when USAGE_TRACKING is off (nothing new is counted). */ tracking: boolean; modelId: string; days: number; /** First day counted (UTC, `YYYY-MM-DD`). */ since: string; fields: ModelFieldUsage[]; principals: PrincipalUsageSummary[]; }; /** `GET /api/admin/usage/schema-versions` (plan schema-lenses; needs `tokens.manage`). */ type SchemaVersionReader = { /** `token:`, `app_users` or `anonymous`. */ principalKey: string; tokenName?: string; /** The schema version the reader's latest request was served at: one it named, or its token's pin. */ schemaVersion: number; /** The version is the token's pin, not one the client sends. */ pinned: boolean; lastReadAt: string; }; type SchemaVersionsResponse = { /** False when USAGE_TRACKING is off (nothing new is counted). */ tracking: boolean; /** Readers on the workspace whose latest request named a schema version, most recent first. */ principals: SchemaVersionReader[]; }; type OlderClientReader = { /** The workspace the reads were made on. */ site: SiteRef; /** `token:`, `app_users` or `anonymous`. */ principalKey: string; /** The token's name; null for app users, anonymous readers and deleted tokens. */ label: string | null; /** The version is the token's pin, not one the client sends. */ pinned: boolean; /** A network token: listed on each workspace the change reaches, read there or not. */ network: boolean; /** Null: a token pinned to the version that has not read since (a declared older client). */ lastReadAt: string | null; }; type OlderClientDefinition = { definitionId: string; /** The definition's API ID in the client's version. */ apiKey: string; /** `unavailable`: no record of the definition at that version (reads of it answer 409). */ status: 'available' | 'unavailable'; /** The worst effect over its fields; null when unavailable. */ effect: LensEffect | null; /** The oldest version reads of it work from, when unavailable. */ oldestVersion: number | null; /** The client's fields that do not keep working unchanged; every other field reads as before. */ fields: OlderClientField[]; /** Too many changes since the version to check what they did to stored values: `effect` is the shape's. */ historyTruncated: boolean; }; type OlderClientField = { fieldId: string; /** The field's API ID in the client's version. */ apiKey: string; /** What the client sees once the change is live: shape and every step's effect on stored values. */ effect: LensEffect; /** The proposed change's own part: what it makes worse than today. */ proposedEffect: LensEffect; /** What the client already sees today (shape since its version, values activations dropped or cut). */ pastEffect: LensEffect; /** The schema version since which `pastEffect` holds; null when transparent or not datable. */ pastSince: number | null; }; type OlderClientVersion = { schemaVersion: number; /** Readers on that version; null when the viewer may not see token names (needs `tokens.manage`). */ readers: OlderClientReader[] | null; /** Readers on that version the viewer sees in detail (with or without names). */ readerCount: number; /** Readers on workspaces the viewer does not see in detail; null when it sees every workspace. */ otherSites: { consumers: number; } | null; definitions: OlderClientDefinition[]; }; /** * Readers on older schema versions and what they see once a proposed change is live (change set review and * plan preview): per version readers are on now, the composite effect from that version to the proposal. */ type OlderClients = { /** Most recently used first; at most a fixed number of versions. */ versions: OlderClientVersion[]; /** More versions are in use than the review compiled. */ truncated: boolean; }; //#endregion //#region src/admin/publishingTypes.d.ts type Page = { items: T[]; nextCursor: string | null; }; declare const JOB_STATUSES: readonly ["pending", "running", "succeeded", "dead"]; type JobStatus = (typeof JOB_STATUSES)[number]; type Job = { id: string; type: string; status: JobStatus; attempts: number; maxAttempts: number; /** When it runs next (pending) or ran last. */ runAt: string; idempotencyKey: string | null; lockedBy: string | null; lockedUntil: string | null; /** Payload and result with secret-looking values replaced by `[redacted]`. */ payload: unknown; result: unknown; /** Progress a long job saved (e.g. an import's phase and counts); null when it saved none. */ progress: unknown; lastError: string | null; createdAt: string; updatedAt: string; finishedAt: string | null; }; type JobQuery = { status?: JobStatus; type?: string; cursor?: string; limit?: number; }; type JobSummary = { counts: Record; types: string[]; }; declare const PUBLICATION_ACTIONS: readonly ["publish", "unpublish"]; type PublicationAction = (typeof PUBLICATION_ACTIONS)[number]; declare const SCHEDULE_STATUSES: readonly ["scheduled", "done", "failed", "canceled"]; type ScheduleStatus = (typeof SCHEDULE_STATUSES)[number]; type ScheduledPublication = { id: string; entryId: string; modelId: string; /** Null when the model no longer exists. */ modelKey: string | null; locale: string; action: PublicationAction; runAt: string; status: ScheduleStatus; error: string | null; /** Publication sequence the change was published at (once done). */ snapshot: number | null; createdBy: string | null; createdAt: string; executedAt: string | null; }; type ScheduleQuery = { status?: ScheduleStatus; entryId?: string; cursor?: string; limit?: number; }; type CreateScheduleInput = { modelKey: string; entryId: string; /** Omit for non-localized models (and for the default locale). */ locale?: string; action: PublicationAction; runAt: string; }; type WebhookEventType = { type: string; group: string; }; type WebhookDeliveryStatus = 'pending' | 'retrying' | 'succeeded' | 'dead'; type Webhook = { id: string; name: string; url: string; /** Event types or `group.*` patterns. */ events: string[]; enabled: boolean; allowPrivateNetwork: boolean; maxAttempts: number; /** The workspace whose events it receives; null for a network-wide webhook (every workspace's events). */ site: SiteRef | null; lastDelivery: { status: WebhookDeliveryStatus; at: string; } | null; createdBy: string | null; createdAt: string; updatedAt: string; version: number; /** The stored signing secret cannot be decrypted (SESSION_SECRET changed): rotate it to repair the webhook. */ secretsUnreadable: boolean; }; type CreateWebhookInput = { name: string; url: string; events: string[]; enabled?: boolean; allowPrivateNetwork?: boolean; maxAttempts?: number; /** A network-wide webhook (every workspace's events); otherwise it belongs to the request's workspace. */ network?: boolean; }; /** A webhook's workspace is fixed once created. */ type UpdateWebhookInput = Partial> & { expectedVersion: number; }; /** The JSON body every webhook delivery sends (signed; verify it with `verifyWebhookSignature`). */ type WebhookEventBody = { id: string; type: string; createdAt: string; /** The workspace the event is about; null for events about no workspace (network-wide). */ site: SiteRef | null; data: unknown; }; /** `secret` is shown once: on creation and after rotation. */ type WebhookWithSecret = { webhook: Webhook; secret: string; }; type WebhookAttempt = { attempt: number; at: string; durationMs: number; request: { method: string; url: string; headers: Record; }; /** Null when no response arrived (refused, timeout, blocked by the network policy). */ response: { status: number; headers: Record; body: string; truncated: boolean; } | null; error: string | null; }; type WebhookDelivery = { id: string; webhookId: string; eventId: string | null; eventType: string; isTest: boolean; status: WebhookDeliveryStatus; attempts: number; lastResponseStatus: number | null; lastError: string | null; payload: unknown; attemptLog: WebhookAttempt[]; createdAt: string; updatedAt: string; deliveredAt: string | null; }; declare const DEPLOYMENT_PROVIDERS: readonly ["generic_webhook", "cloudflare_pages", "vercel", "netlify", "github"]; type DeploymentProvider = (typeof DEPLOYMENT_PROVIDERS)[number]; declare const DEPLOYMENT_TRIGGERS: readonly ["publish", "change_set", "schema", "manual"]; type DeploymentTriggerPolicy = (typeof DEPLOYMENT_TRIGGERS)[number]; declare const DEPLOYMENT_RUN_STATUSES: readonly ["queued", "triggered", "building", "deployed", "failed", "unknown"]; type DeploymentRunStatus = (typeof DEPLOYMENT_RUN_STATUSES)[number]; type DeploymentRunTrigger = 'publish' | 'change_set' | 'schema' | 'manual' | 'retry'; /** * Provider settings (not secret). Generic: `{ url }`. Cloudflare Pages: `{ accountId, projectName }`. * GitHub: `{ owner, repo, branch, mode: 'commit' | 'pull_request', directory }`. */ type DeploymentSettings = Record; /** * Secret names per provider. Generic: `signingSecret` (generated when omitted). Cloudflare Pages: * `deployHookUrl`, `apiToken`. GitHub: `token`. Values are write-only. A value of `${ENV:VAR_NAME}` * makes the server read the secret from that environment variable instead of storing it. */ type DeploymentSecretsInput = Record; /** Which secrets are set; values never leave the server. `envVar`: read from this environment variable. */ type DeploymentSecretState = Record; type DeploymentTimelineEvent = { status: DeploymentRunStatus; at: string; source: 'shapio' | 'callback' | 'provider'; message: string | null; }; type DeploymentRun = { id: string; connectionId: string; connectionName: string; provider: DeploymentProvider; status: DeploymentRunStatus; trigger: DeploymentRunTrigger; /** Publication sequence the run was triggered at (`?snapshot=` on delivery). */ snapshot: number | null; schemaVersion: number | null; retryOf: string | null; providerRef: string | null; logUrl: string | null; siteUrl: string | null; error: string | null; /** False for providers that cannot report completion without callbacks (shown as "completion unknown"). */ completionReported: boolean; timeline: DeploymentTimelineEvent[]; triggeredAt: string | null; finishedAt: string | null; createdAt: string; updatedAt: string; }; type DeploymentConnection = { id: string; name: string; provider: DeploymentProvider; settings: DeploymentSettings; secrets: DeploymentSecretState; previewUrlTemplate: string | null; /** Preview tokens issued for this connection show exactly what this delivery role reads. */ deliveryRoleId: string | null; triggerPolicy: DeploymentTriggerPolicy[]; debounceSeconds: number; allowPrivateNetwork: boolean; enabled: boolean; /** Where the website posts signed build callbacks (generic webhook connections). */ callbackUrl: string; latestRun: DeploymentRun | null; /** The newest deployed run by snapshot: what the website is serving, as far as Shapio knows. */ currentRun: DeploymentRun | null; createdBy: string | null; createdAt: string; updatedAt: string; version: number; /** * The stored secrets cannot be decrypted (the server's SESSION_SECRET changed): every literal secret reads * as not set until it is entered again; secrets read from the environment are unaffected. */ secretsUnreadable: boolean; }; /** * A connection as someone who may trigger deployments but not manage them sees it (`deployments.trigger`): * its state, triggers and runs, so they can deploy. No settings, secrets, URLs or other configuration. */ type DeploymentConnectionSummary = Pick; type CreateDeploymentConnectionInput = { name: string; provider: DeploymentProvider; settings: DeploymentSettings; secrets: DeploymentSecretsInput; previewUrlTemplate?: string | null; triggerPolicy: DeploymentTriggerPolicy[]; debounceSeconds?: number; allowPrivateNetwork?: boolean; enabled?: boolean; deliveryRoleId?: string | null; }; type UpdateDeploymentConnectionInput = Partial> & { expectedVersion: number; }; /** `generatedSecrets` holds secrets Shapio generated (the generic signing secret), shown once. */ type DeploymentConnectionCreated = { connection: DeploymentConnection; generatedSecrets: Record; }; /** An update's result: `generatedSecrets` holds a secret Shapio minted to replace an unreadable one, shown once. */ type DeploymentConnectionUpdated = DeploymentConnection & { generatedSecrets?: Record; }; type ConnectionTestResult = { ok: boolean; checks: Array<{ name: string; ok: boolean; message: string; }>; }; type DeploymentRunQuery = { connectionId?: string; cursor?: string; limit?: number; }; type PreviewToken = { id: string; tokenPrefix: string; modelId: string; modelKey: string | null; entryId: string | null; locale: string | null; connectionId: string | null; /** Fields follow this delivery role (within the creator's access); null = the public fields. */ deliveryRoleId: string | null; createdBy: string; expiresAt: string; revokedAt: string | null; lastUsedAt: string | null; createdAt: string; }; type CreatePreviewTokenInput = { modelKey: string; entryId?: string; locale?: string; /** Default 1 hour, at most 30 days. */ ttlSeconds?: number; connectionId?: string; /** Defaults to the connection's delivery role. */ deliveryRoleId?: string; }; /** `token` is shown once. `url` is rendered from the connection's preview URL template (null without one). */ type PreviewTokenCreated = { token: string; previewToken: PreviewToken; url: string | null; }; type OpenPreviewInput = { modelKey: string; entryId: string; locale?: string; /** Defaults to the first enabled connection with a preview URL template. */ connectionId?: string; }; /** What the entry form's Preview button opens. `apiUrl` is the preview read endpoint for this entry. */ type OpenPreviewResult = { /** The token's ID (revoke it when the preview closes). */ id: string; url: string | null; apiUrl: string; token: string; expiresAt: string; connectionId: string | null; }; /** A connection the workspace's previews open on (names and origins only). */ type PreviewTarget = { connectionId: string; name: string; /** null when the preview URL template's origin depends on a variable. */ origin: string | null; /** Whether the admin can show it in its preview frame. */ framable: boolean; }; //#endregion //#region src/admin/schemaTypes.d.ts /** Where a definition lives: one workspace (`site`), or shared with every workspace (`network`). */ type DefinitionScope = 'network' | 'site'; type ActiveDefinition = { definition: SchemaDefinition; scope: DefinitionScope; /** The workspace a `site` definition belongs to; null when shared. */ siteId: string | null; /** Per-definition version: send it back as `expectedVersion` when changing the definition. */ version: number; hash: string; revisionId: string; activatedAt: string; }; /** A list item: the active definition and the change still running for it, if any. */ type DefinitionListItem = ActiveDefinition & { pendingChange: { id: string; status: SchemaChangeStatus; } | null; }; type SchemaChangeStatus = 'pending' | 'running' | 'activated' | 'failed' | 'canceled'; /** A planned change whose prerequisites run as jobs before the new revision activates. */ /** Entry versions without a value for a field a change made required (listed in the Inbox until filled in). */ type RequiredGap = { step: string; /** The definition that declares the field (a model, or a component its value lives in). */ ownerId: string; fieldId: string; fieldApiKey?: string; /** Entry versions (draft and published, per locale) without a value. */ versions: number; /** The distinct entries they belong to. */ entries: number; sampleEntryIds: string[]; }; /** What an activated change left to do. */ type SchemaChangeResult = { requiredGaps: RequiredGap[]; }; type SchemaChangeJob = { id: string; targetType: string; targetId: string; status: SchemaChangeStatus; fromRevisionId: string | null; toRevisionId: string | null; jobId: string | null; /** Why a failed change failed, e.g. `{ reason, invalidCount, sampleEntryIds }`. */ error: unknown; /** What an activated change left to do (entries without a value for a field it made required); else null. */ outcome: SchemaChangeResult | null; createdAt: string; updatedAt: string; finishedAt: string | null; }; type DefinitionDetail = ActiveDefinition & { pendingChange: SchemaChangeJob | null; }; /** A prerequisite or follow-up step of a plan (see apps/api/src/schema/planner/steps.ts). */ type PlanStep = { kind: string; fieldId?: string; modelId?: string; ownerId?: string; } & Record; type ChangePlan = { definitionId: string; kind: SchemaDefinition['kind']; apiKey: string; operation: 'create' | 'update' | 'delete'; /** The definition's workspace after the change; null when shared. */ siteId?: string | null; fromVersion: number | null; changes: ClassifiedChange[]; summary: ChangeSummary; affectedModelIds: string[]; prerequisites: PlanStep[]; followUps: PlanStep[]; issues: ValidationIssue[]; }; type PlanStepImpact = { key: string; kind: string; affectedHeads: number; invalidHeads?: number; /** The distinct entries those failing heads (entry versions) belong to. */ invalidEntries?: number; /** * On a `validateRequired` step for a model's own field: entry versions (and entries) that will have no * value. They don't block the change; they're listed in the Inbox afterwards. */ missingHeads?: number; missingEntries?: number; /** On a `convert` step of a type change Shapio cannot convert: live entries that lose their value. */ droppedEntries?: number; }; type PlanImpact = { /** Entry heads (every locale and state) of the affected models. */ affectedHeads: number; steps: PlanStepImpact[]; }; type PlanPreview = { plan: ChangePlan; impact: PlanImpact; /** Per change of `plan.changes`, in order: what a client on the schema version before it sees. */ olderClientsEffects: LensEffect[]; /** Readers on older schema versions and what they see once the change is live (plan schema-lenses). */ olderClients: OlderClients; }; type ChangeOutcome = { status: 'activated' | 'unchanged' | 'pending'; definitionId: string; version?: number | null; schemaVersion?: number; /** Set when `status` is `pending`: poll `schema.change(changeId)`. */ changeId?: string; toVersion?: number | null; }; /** What the definition endpoints accept: authored input, or a normalized definition (always valid input). */ type DefinitionPayload = DefinitionInput | SchemaDefinition; type Acknowledgement = { acknowledgeBreaking?: boolean; acknowledgeDestructive?: boolean; }; type CreateDefinitionInput = { definition: DefinitionPayload; /** * Default `site`: the request's workspace. `network` shares it with all workspaces (schema.create on every * workspace). */ scope?: DefinitionScope; } & Acknowledgement; /** `PUT /api/admin/{models,components}/:id/scope`: share with all workspaces, or keep on one. */ type ChangeScopeInput = { scope: DefinitionScope; /** For `site`: the workspace to keep it on (default: the request's workspace). */ siteId?: string; /** The definition's active version (409 SCHEMA_VERSION_CONFLICT when it moved). */ version: number; }; type ChangeScopeOutcome = { status: 'activated' | 'unchanged'; definitionId: string; scope: DefinitionScope; siteId: string | null; version: number; schemaVersion: number; }; type UpdateDefinitionInput = { definition: DefinitionPayload; expectedVersion: number; } & Acknowledgement; type PlanUpdateInput = { definition: DefinitionPayload; expectedVersion: number; }; type DefinitionRevision = { id: string; version: number; hash: string; parentRevisionId: string | null; createdByType: string; createdById: string | null; createdAt: string; /** The change that wrote this version: `failed` and `canceled` versions never went live. */ status: SchemaChangeStatus; /** The version the model serves now. */ active: boolean; }; /** One revision of a definition with its body. */ type DefinitionRevisionDetail = DefinitionRevision & { definition: SchemaDefinition; }; type SchemaSummaryItem = { id: string; kind: SchemaDefinition['kind']; apiKey: string; label: string; version: number; hash: string; /** The key of the workspace the definition belongs to; null when shared. */ site: string | null; }; type SchemaSummary = { schemaVersion: number; defaultLocale: string; definitions: SchemaSummaryItem[]; }; /** The opt-in read-only lock (ADR 0002): when on, only `shapio schema apply` changes the schema. */ type SchemaSettings = { readOnly: boolean; readOnlyReason: string | null; updatedAt: string; }; type UpdateSchemaSettingsInput = { readOnly: boolean; readOnlyReason?: string | null; }; type Locale = LocaleDefinition; type CreateLocaleInput = { code: string; label: string; fallbacks?: string[]; }; type UpdateLocaleInput = { label: string; fallbacks?: string[]; }; type SetDefaultLocaleResult = { code: string; changed: boolean; }; type DeleteLocaleResult = { code: string; /** Heads of localized models in the locale, purged. */ affectedHeads: number; /** Entries that existed only in the locale, deleted. */ deletedEntries: number; /** Entries of non-localized models stored in the locale, moved to the default locale. */ movedEntries: number; }; //#endregion //#region src/admin/changeSetTypes.d.ts /** * Change sets and snapshots (developer-face plan §5), mirroring the TypeBox route schemas in * apps/api/src/routes/admin/{changeSets,snapshots}/schemas.ts. Dates are ISO-8601 strings. */ declare const CHANGE_SET_STATUSES: readonly ["open", "scheduled", "shipping", "shipped", "failed", "discarded"]; type ChangeSetStatus = (typeof CHANGE_SET_STATUSES)[number]; /** While `shipping`: preparing (prerequisite dry runs, index builds) or activating (the final transaction). */ type ShipPhase = 'preparing' | 'activating'; type ChangeSetSource = 'manual' | 'release' | 'restore' | 'builder' | 'assist'; type ChangeSetItemStatus = 'pending' | 'done' | 'failed'; type SchemaOperation = 'create' | 'update' | 'delete'; type ChangeSetActor = { type: 'admin' | 'token' | 'system'; id: string | null; name: string | null; }; /** Why a ship failed, and the item that stopped it (null when not tied to one item). */ type ChangeSetError = { code: string; message: string; itemId: string | null; details?: unknown; }; type ChangeSetEntryItem = { id: string; kind: 'entry'; position: number; entryId: string; modelId: string; modelKey: string | null; title: string | null; locale: string; action: PublicationAction; /** Restore items publish this exact revision instead of the current draft. */ sourceRevisionId: string | null; status: ChangeSetItemStatus; error: string | null; }; type ChangeSetSchemaItem = { id: string; kind: 'schema'; position: number; draftId: string; definitionId: string; category: DefinitionCategory; apiKey: string; operation: SchemaOperation; /** The active version the draft was based on; null for a new definition. */ baseVersion: number | null; draftVersion: number; status: ChangeSetItemStatus; error: string | null; /** After shipping: what the change left to do (entries without a value for a field it made required). */ outcome: SchemaChangeResult | null; }; type ChangeSetItem = ChangeSetEntryItem | ChangeSetSchemaItem; declare const APPROVAL_STATUSES: readonly ["none", "requested", "approved", "changes_requested"]; /** Approval (plan approval-workflows): not asked, in review, approved, or sent back with a note. */ type ApprovalStatus = (typeof APPROVAL_STATUSES)[number]; /** Why the caller may not approve now (`signed` and `outdated` still allow requesting changes). */ type ApprovalIneligibleReason = 'rolesDeleted' | 'role' | 'self' | 'signed' | 'outdated'; /** The stage a set in review is at. */ type ApprovalStageState = { index: number; id: string; name: string; required: number; /** Distinct approvers so far in this round. */ signed: number; }; /** The approval summary on list rows. */ type ChangeSetApprovalSummary = { status: ApprovalStatus; /** The request's note, or what to change once changes were requested. */ note: string; /** The review round (each request starts a new one); 0 before the first request. */ round: number; requestedBy: ChangeSetActor | null; requestedAt: string | null; /** The set changed after this round's first sign-off or after approval: ask for approval again. */ outdated: boolean; /** Whether the approval was current when the set shipped; null until it ships. */ approvedAtShip: boolean | null; /** The caller may approve at the current stage now. */ eligible: boolean; /** Why not, while the set is in review; null when eligible or not in review. */ eligibleReason: ApprovalIneligibleReason | null; stage: ApprovalStageState | null; }; type ApprovalSignoff = { round: number; stageIndex: number; stageId: string; stageName: string | null; decision: 'approve' | 'request_changes'; by: ChangeSetActor; at: string; note: string; /** It counts: given in the current round, and the set has not changed since. */ current: boolean; }; /** The approval block of one set: the summary, the frozen workflow and every sign-off. */ type ChangeSetApproval = ChangeSetApprovalSummary & { /** The workflow frozen when review started (null before the first request). */ workflow: { stages: Array; selfApproval: boolean; } | null; signoffs: ApprovalSignoff[]; /** The last sign-off of the final stage, once approved. */ approvedBy: ChangeSetActor | null; approvedAt: string | null; }; type ChangeSetSummary = { id: string; title: string; description: string; status: ChangeSetStatus; shipPhase: ShipPhase | null; source: ChangeSetSource; restoreOfSnapshot: number | null; scheduledFor: string | null; /** Connection whose deploy is triggered (pinned to the shipped snapshot) after the set ships. */ deploymentConnectionId: string | null; deploymentRunId: string | null; shippedAt: string | null; /** The publication snapshot the set went live in. */ shippedSnapshot: number | null; schemaVersionAfter: number | null; error: ChangeSetError | null; entryItemCount: number; schemaItemCount: number; createdBy: ChangeSetActor; createdAt: string; updatedAt: string; version: number; approval: ChangeSetApprovalSummary; }; type ChangeSet = Omit & { approval: ChangeSetApproval; items: ChangeSetItem[]; /** Who shipped the set (the snapshot ledger's actor); null until it ships. */ shippedBy: ChangeSetActor | null; }; type ChangeSetQuery = { /** Comma-separated statuses; default: everything except `discarded`. */ status?: string; /** Comma-separated approval states (`none`, `requested`, `approved`, `changes_requested`). */ approval?: string; /** Only sets in review the caller can sign off now; a page can be short and still have a next cursor. */ awaitingMe?: boolean; cursor?: string; limit?: number; }; /** `approval/request` and `approval/approve`: an optional note. */ type ApprovalNoteInput = { note?: string; }; /** `approval/request-changes`: what to change. */ type RequestChangesInput = { note: string; }; type CreateChangeSetInput = { title: string; description?: string; /** `builder`: a one-item set the model builder ships at once ("Review & ship now"). Default `manual`. */ source?: 'manual' | 'builder'; }; type UpdateChangeSetInput = { title?: string; description?: string; deploymentConnectionId?: string | null; expectedVersion: number; }; type AddChangeSetEntryInput = { modelKey: string; entryId: string; /** Omit for non-localized models (and for the default locale). */ locale?: string; action: PublicationAction; }; type SchemaDraft = { id: string; changeSetId: string; definitionId: string; category: DefinitionCategory; operation: SchemaOperation; baseVersion: number | null; /** Null when the draft deletes the definition. */ definition: SchemaDefinition | null; /** A new definition the draft creates shared with all workspaces (otherwise it belongs to the set's workspace). */ shared: boolean; version: number; updatedBy: ChangeSetActor; createdAt: string; updatedAt: string; }; type PutSchemaDraftInput = { category: DefinitionCategory; /** The whole proposed definition, or null to delete the definition when the set ships. */ definition: DefinitionPayload | null; /** The active version the edit is based on (null: a new definition). */ baseVersion: number | null; /** For a new definition: create it shared with all workspaces (default false: the set's workspace). */ shared?: boolean; /** The draft row version the caller saw; omit when creating the draft. */ expectedDraftVersion?: number; }; /** * One changed field. `summary` is the server's readable form of each side (rich text as its text, media as * filenames, relations as titles, components as labeled items); null when that side is empty. */ type FieldDiff = { fieldId: string; apiKey: string; label: string; type: DataType; before: unknown; after: unknown; summary: { before: string | null; after: string | null; }; }; type ReviewIssue = { path: string; code: string; message: string; }; type ReviewEntryItem = { itemId: string; entryId: string; modelId: string; modelKey: string | null; title: string | null; locale: string; action: PublicationAction; sourceRevisionId: string | null; /** Send back in `ship.itemVersions` (strict ship). Null when the item does not publish the draft. */ draftVersion: number | null; liveState: 'unpublished' | 'published' | 'modified' | 'missing'; fields: FieldDiff[]; issues: ReviewIssue[]; }; type ReviewSchemaItem = { itemId: string; draftId: string; definitionId: string; category: DefinitionCategory; apiKey: string; operation: SchemaOperation; baseVersion: number | null; activeVersion: number | null; /** The active version moved since the draft was based on it: shipping refuses until it is rebased. */ stale: boolean; plan: ChangePlan | null; /** Per change of `plan.changes`, in order: what a client on the schema version before it sees. */ olderClientsEffects: LensEffect[]; impact: PlanImpact | null; /** * Entries of the affected models per workspace (a shared definition converts every workspace's content). */ affectedEntriesBySite: Array<{ site: SiteRef; entries: number; }>; issues: ReviewIssue[]; alsoChangedIn: Array<{ id: string; title: string; }>; /** A shipped set: the revision the draft replaced (null for a new definition, and for unshipped sets). */ beforeRevisionId: string | null; }; declare const NOT_RESTORABLE_REASONS: readonly ["entry_deleted", "model_missing", "publishing_disabled", "localization_changed", "locale_missing", "invalid", "unique_conflict", "kind_changed"]; type NotRestorableReason = (typeof NOT_RESTORABLE_REASONS)[number]; type NotRestorable = { entryId: string; modelId: string; modelKey: string | null; locale: string; reason: NotRestorableReason; detail: string; }; type FieldConsumer = { /** The workspace the reads were made on. */ site: SiteRef; /** `token:`, `app_users` or `anonymous`. */ principalKey: string; label: string | null; reads: number; lastReadAt: string | null; /** `implicit`: the reader requested the whole model (no field selection). */ selection: 'explicit' | 'implicit'; }; type FieldConsumers = { modelId: string; fieldId: string; apiKey: string; consumers: FieldConsumer[]; /** * Readers on other workspaces, as totals, when the viewer holds no role on every workspace; null when the * viewer sees every workspace's readers in `consumers`. */ otherSites: { consumers: number; reads: number; } | null; }; type ChangeSetReview = { changeSet: ChangeSet; entries: ReviewEntryItem[]; schema: ReviewSchemaItem[]; notRestorable: NotRestorable[]; consumers: FieldConsumers[]; usageDays: number; /** Readers on older schema versions and what they see once the set ships; null for a shipped set. */ olderClients: OlderClients | null; checks: { breaking: boolean; destructive: boolean; blocking: ReviewIssue[]; warnings: ReviewIssue[]; }; /** Fixed notices, e.g. `NEW_FIELDS_AFTER_SHIP`. */ notices: string[]; }; type ShipChangeSetInput = { expectedVersion: number; acknowledgeBreaking?: boolean; acknowledgeDestructive?: boolean; /** Draft versions the review showed; a moved draft makes the ship refuse with 409 CHANGE_SET_STALE. */ itemVersions?: Array<{ itemId: string; draftVersion: number; }>; }; type ScheduleChangeSetInput = { at: string; expectedVersion: number; acknowledgeBreaking?: boolean; acknowledgeDestructive?: boolean; }; type ChangeSetTimelineEvent = { at: string; kind: string; actor: ChangeSetActor | null; message: string | null; snapshot: number | null; deploymentRunId: string | null; /** `item.changedAfterReview`: the entry whose draft moved between review and a scheduled ship. */ item: { entryId: string; locale: string; fromVersion: number; toVersion: number; } | null; /** Approval rows: the round, the stage and, for a sign-off, k of required. */ approval: { round: number | null; stage: string | null; signed: number | null; required: number | null; } | null; }; type UnassignedEntry = { entryId: string; modelId: string; modelKey: string | null; title: string | null; locale: string; status: 'draft' | 'modified'; updatedAt: string; }; declare const SNAPSHOT_SOURCES: readonly ["publish", "unpublish", "delete", "schedule", "change_set", "schema", "conversion", "import", "kind_change", "legacy"]; type SnapshotSource = (typeof SNAPSHOT_SOURCES)[number]; type Snapshot = { seq: number; schemaVersion: number | null; source: SnapshotSource; changeSetId: string | null; changeSetTitle: string | null; /** `name`: the admin's or token's name; null for the system, or once the admin or token is deleted. */ actor: { type: string; id: string | null; name: string | null; }; changedEntries: number; deploymentRuns: Array<{ id: string; connectionId: string; status: DeploymentRunStatus; }>; createdAt: string; }; type SnapshotPage = Page & { current: number; }; type SnapshotQuery = { cursor?: string; limit?: number; }; //#endregion //#region src/admin/types.d.ts /** * Admin identity API shapes (package B, build plan §4.B), mirroring the TypeBox route schemas in * apps/api/src/routes/admin/** and routes/schemas/adminIdentity.ts. JSON is camelCase; timestamps are ISO-8601. */ type AdminUserStatus = 'active' | 'disabled'; /** A role held on one workspace, or on every workspace (`siteId` null). */ type RoleAssignment = { roleId: string; siteId: string | null; }; type AdminUser = { id: string; email: string; name: string; status: AdminUserStatus; /** Where each role applies. */ assignments: RoleAssignment[]; /** Deprecated: the distinct roles of `assignments`, on any workspace. */ roleIds: string[]; lastLoginAt: string | null; createdAt: string; updatedAt: string; /** Usable API tokens this admin created: refused while the account is disabled, revoked when it is deleted. */ apiTokens: AdminUserApiToken[]; }; /** An API token listed with the admin who created it. */ type AdminUserApiToken = { id: string; name: string; siteId: string | null; }; declare const CONTENT_ACTIONS: readonly ["read", "create", "update", "delete", "publish", "schemaManage"]; type ContentAction = (typeof CONTENT_ACTIONS)[number]; /** * What a delivery role grants: `read`, and `readDrafts` (drafts mode: the token's workspace may read drafts with * `publicationState=draft`). `readDrafts` always covers every model and is never granted to admin roles. */ declare const DELIVERY_ACTIONS: readonly ["read", "readDrafts"]; type DeliveryAction = (typeof DELIVERY_ACTIONS)[number]; /** * Network actions: about the whole instance. Only roles assigned on every workspace grant them, so a role * held on one workspace never reaches the network. */ declare const NETWORK_ACTIONS: readonly ["schema.create", "users.manage", "roles.manage", "audit.read", "sites.manage"]; type NetworkAction = (typeof NETWORK_ACTIONS)[number]; /** Workspace actions: about one workspace's library, tokens and publishing. */ declare const SITE_ACTIONS: readonly ["tokens.manage", "media.read", "media.write", "media.manage", "publishing.manage", "webhooks.manage", "deployments.manage", "deployments.trigger", "changes.manage", "changes.ship", "changes.approve"]; type SiteAction = (typeof SITE_ACTIONS)[number]; /** Actions not scoped to a model: network actions and workspace actions. */ declare const GLOBAL_ACTIONS: readonly ["schema.create", "users.manage", "roles.manage", "tokens.manage", "audit.read", "sites.manage", "media.read", "media.write", "media.manage", "publishing.manage", "webhooks.manage", "deployments.manage", "deployments.trigger", "changes.manage", "changes.ship", "changes.approve", "site.settings"]; type GlobalAction = (typeof GLOBAL_ACTIONS)[number]; type PermissionAction = ContentAction | DeliveryAction | GlobalAction; type RoleSummary = { id: string; key: string; name: string; }; /** Returned whenever a session starts (setup, login, accepting an invitation). */ type SessionStarted = { user: AdminUser; csrfToken: string; }; type MeResponse = { user: AdminUser; roles: RoleSummary[]; /** The workspace this response is about: the request's `Shapio-Site`, else the primary workspace. */ site: SiteSummary; /** Every workspace this admin holds a role on (all of them for a role assigned on every workspace). */ sites: SiteSummary[]; /** * Workspaces on this instance (whether or not the admin holds a role on them); scope is shown only above 1. */ siteCount: number; /** Network actions (roles assigned on every workspace only). */ networkPermissions: NetworkAction[]; /** * Workspace actions on the request's workspace, plus `schema.create` when a role on the workspace grants it * for the workspace's own definitions (`networkPermissions` lists it when shared definitions may be created too). */ sitePermissions: Array; /** `networkPermissions` and `sitePermissions` together. */ globalPermissions: GlobalAction[]; /** Content actions per model ID on the request's site (models without any action are left out). */ modelPermissions: Record; /** How the server sends email: `console` writes it to the server log (no real delivery is set up). */ emailDelivery: EmailDelivery; csrfToken: string; }; type EmailDelivery = 'console' | 'smtp'; type SetupStatusResponse = { /** No admin exists yet. */ required: boolean; /** SETUP_REQUIRE_TOKEN is set: setup also needs the one-time token from the server log. */ requiresToken: boolean; }; /** * `token` is needed only when the server requires it (`requiresToken`); otherwise it is ignored. `workspaceName` * names the built-in workspace (server 0.8.2 or later; its key stays `default`); absent leaves its name. */ type SetupInput = { token?: string; email: string; name: string; password: string; workspaceName?: string; }; type LoginInput = { email: string; password: string; }; type CsrfResponse = { csrfToken: string; }; type UpdateProfileInput = { name: string; }; type ChangePasswordInput = { currentPassword: string; newPassword: string; }; type PasswordResetRequestInput = { email: string; }; type PasswordResetConfirmInput = { token: string; password: string; }; type AcceptInvitationInput = { token: string; name: string; password: string; }; type InspectInvitationResponse = { email: string; expiresAt: string; }; type AdminSession = { id: string; current: boolean; ip: string | null; userAgent: string | null; createdAt: string; lastSeenAt: string; expiresAt: string; }; type Invitation = { id: string; email: string; /** The role assignments the invitee gets on accepting. */ assignments: RoleAssignment[]; /** Deprecated: the distinct roles of `assignments`. */ roleIds: string[]; invitedBy: string | null; expiresAt: string; createdAt: string; }; /** A fresh accept link, shown once; issuing it makes earlier links (emailed or copied) stop working. */ type InvitationLink = { acceptUrl: string; expiresAt: string; }; /** * Either `assignments` or (deprecated) `roleIds`, meaning those roles on every workspace; never both. Updating * either replaces every assignment. */ type AssignmentsInput = { assignments: RoleAssignment[]; roleIds?: never; } | { roleIds: string[]; assignments?: never; }; type InviteUserInput = { email: string; } & AssignmentsInput; type UpdateAdminUserInput = { name?: string; status?: AdminUserStatus; } & (AssignmentsInput | { assignments?: never; roleIds?: never; }); type RoleKind = 'admin' | 'delivery'; type RoleCondition = 'ownedByPrincipal'; type RolePermission = { action: PermissionAction; /** `null` grants the action on every model (and is required for global actions). */ modelId: string | null; condition: RoleCondition | null; /** `null` = every field; otherwise only these stable field IDs. */ fieldIds: string[] | null; }; type Role = { id: string; key: string; name: string; description: string; kind: RoleKind; isSystem: boolean; /** Optimistic-concurrency version: send it back as `expectedVersion` on update. */ version: number; permissions: RolePermission[]; createdAt: string; updatedAt: string; }; type CreateRoleInput = { key: string; name: string; description?: string; kind?: RoleKind; permissions: RolePermission[]; }; type UpdateRoleInput = { expectedVersion: number; name?: string; description?: string; permissions?: RolePermission[]; }; type ApiToken = { id: string; name: string; /** First characters of the token (`shp_` + 6), for telling tokens apart. */ tokenPrefix: string; roleId: string; scope: RoleKind; /** The token's workspace; null for a network admin token (its role applies on every workspace). */ siteId: string | null; createdBy: string | null; /** The creator's account is disabled: the token is refused until it is enabled again. */ creatorDisabled: boolean; expiresAt: string | null; lastUsedAt: string | null; revokedAt: string | null; createdAt: string; /** * The schema version the token is pinned to: a request made with it that names no schema version is served * as if it had named this one (a version the request names wins). Null: today's shape. */ pinnedSchemaVersion: number | null; /** False when the history does not reach the pin for some model: reads of it answer 409. */ pinnedSchemaVersionAvailable: boolean; }; type CreateApiTokenInput = { name: string; roleId: string; expiresAt?: string | null; /** * A network admin token (every workspace and network actions; needs `users.manage`). Omitted: a network * token when the creator may create one, else a token of the request's workspace. Delivery tokens are * always per workspace. */ network?: boolean; /** A schema version from 1 to the current one to pin the token to; omitted or null: no pin. */ pinnedSchemaVersion?: number | null; }; type UpdateApiTokenInput = { /** A schema version from 1 to the current one to pin the token to; null clears the pin. */ pinnedSchemaVersion: number | null; }; /** `token` is the plain secret, returned once at creation and never again. */ type CreatedApiToken = { token: string; apiToken: ApiToken; }; type AuditActorType = 'admin' | 'app_user' | 'token' | 'anonymous' | 'system'; type AuditEvent = { id: string; occurredAt: string; actorType: AuditActorType; actorId: string | null; /** The acting admin's (or app user's) display name, when the actor is a known account. */ actorName: string | null; actorEmail: string | null; action: string; targetType: string | null; targetId: string | null; outcome: 'success' | 'failure'; requestId: string | null; ip: string | null; metadata: unknown; }; /** Newest first, cursor-paginated. */ type AuditQuery = { cursor?: string; limit?: number; actorType?: AuditActorType; actorId?: string; action?: string; actionPrefix?: string; targetType?: string; targetId?: string; outcome?: 'success' | 'failure'; from?: string; to?: string; }; type AuditPage = { items: AuditEvent[]; nextCursor: string | null; }; //#endregion //#region src/admin/appUsersTypes.d.ts type AdminAppUser = { id: string; email: string; name: string; confirmed: boolean; blocked: boolean; /** False for accounts that only sign in with an OAuth provider. */ hasPassword: boolean; /** OAuth providers linked to the account (`google`, `github`). */ providers: string[]; /** Custom app roles; `authenticated` applies to every app user implicitly. */ roleIds: string[]; lastLoginAt: string | null; createdAt: string; updatedAt: string; }; /** Newest first, cursor-paginated; `search` matches email or name. */ type AppUserQuery = { search?: string; cursor?: string; limit?: number; }; type AppUserPage = { items: AdminAppUser[]; nextCursor: string | null; }; type UpdateAppUserInput = { blocked?: boolean; roleIds?: string[]; }; /** What app roles may grant: content actions only. */ declare const APP_CONTENT_ACTIONS: readonly ["read", "create", "update", "delete", "publish"]; type AppContentAction = (typeof APP_CONTENT_ACTIONS)[number]; /** Built-in app role keys: `public` applies to anonymous callers, `authenticated` to every app user. */ declare const BUILT_IN_APP_ROLE_KEYS: readonly ["public", "authenticated"]; type AppRolePermission = { action: AppContentAction; /** `null` grants the action on every model, including ones created later. */ modelId: string | null; condition: RoleCondition | null; /** `null` = every public field; otherwise exactly these stable field IDs (non-public ones included). */ fieldIds: string[] | null; }; type AppRole = { id: string; key: string; name: string; description: string; isSystem: boolean; version: number; permissions: AppRolePermission[]; userCount: number; createdAt: string; updatedAt: string; }; type CreateAppRoleInput = { key: string; name: string; description?: string; permissions: AppRolePermission[]; }; /** Built-in roles accept `permissions` only. */ type UpdateAppRoleInput = { expectedVersion: number; name?: string; description?: string; permissions?: AppRolePermission[]; }; //#endregion //#region src/admin/mediaTypes.d.ts type MediaVisibility = 'public' | 'private'; type MediaAssetStatus = 'processing' | 'ready' | 'failed'; type MediaVariantStatus = 'pending' | 'ready' | 'failed'; type MediaStorageDriver = 'local' | 's3'; type MediaFocalPoint = { x: number; y: number; }; type MediaVariant = { name: string; width: number | null; height: number | null; format: string; mimeType: string; sizeBytes: number | null; status: MediaVariantStatus; /** Present once the variant is ready. */ url: string | null; }; type MediaAsset = { id: string; folderId: string | null; filename: string; mimeType: string; sizeBytes: number; width: number | null; height: number | null; checksumSha256: string | null; alt: string; caption: string; focalPoint: MediaFocalPoint | null; visibility: MediaVisibility; /** `processing` until the checksum, dimensions and variants are done. */ status: MediaAssetStatus; processingError: string | null; storageDriver: MediaStorageDriver; /** Stable for public assets; signed and expiring (`urlExpiresAt`) for private ones. */ url: string; urlExpiresAt: string | null; variants: MediaVariant[]; createdBy: string | null; createdAt: string; updatedAt: string; version: number; }; type MediaAssetQuery = { /** A folder ID, or `root` for assets in no folder. Omit for every folder. */ folder?: string; /** An exact type such as `application/pdf`; `image/*` also works, but prefer `kind` for a family. */ mimeType?: string; /** * A media kind, by the same rules as a media field's allowed kinds. Use it rather than a `type/*` pattern: * firewalls in front of a server can read `/*` in a query string as SQL injection. */ kind?: (typeof MEDIA_KINDS)[number]; search?: string; cursor?: string; limit?: number; }; type MediaAssetPage = { items: MediaAsset[]; nextCursor: string | null; }; type UpdateMediaAssetInput = { expectedVersion: number; alt?: string; caption?: string; filename?: string; focalPoint?: MediaFocalPoint | null; folderId?: string | null; /** Needs `media.manage`. */ visibility?: MediaVisibility; }; type MoveMediaAssetsInput = { assetIds: string[]; folderId: string | null; }; type MoveMediaAssetsResult = { moved: string[]; skipped: string[]; }; type MediaUsage = { entryId: string; modelId: string; fieldId: string; locale: string; state: 'draft' | 'published'; since: string; /** The entry's title; null when it has none or you may not read it (model, row, or field). */ title: string | null; }; type MediaUsagePage = { items: MediaUsage[]; total: number; }; type MediaFolder = { id: string; parentId: string | null; name: string; assetCount: number; version: number; createdAt: string; updatedAt: string; }; type CreateMediaFolderInput = { name: string; parentId?: string | null; }; type UpdateMediaFolderInput = { expectedVersion: number; name?: string; parentId?: string | null; }; type CreateUploadInput = { filename: string; mimeType: string; sizeBytes: number; folderId?: string | null; visibility?: MediaVisibility; }; type ReplaceUploadInput = { filename: string; mimeType: string; sizeBytes: number; }; /** * Step 1 of an upload. Send the file as `multipart/form-data` to `upload.url`: every entry of `fields` * first, then the file as `fileField` (see `buildUploadForm`). The same for every storage driver: the URL * is either the bucket (presigned POST) or Shapio's own upload route. Then call `uploads.confirm`. */ type UploadGrant = { grantId: string; assetId: string; expiresAt: string; maxSizeBytes: number; upload: { method: 'POST'; url: string; fields: Record; fileField: 'file'; }; }; //#endregion //#region src/admin/schemaSyncTypes.d.ts /** * Schema sync (`/api/admin/schema/export|apply`, ADR 0002): the pull format `shapio schema pull` writes and * the three-way apply `shapio schema apply` sends. Shared by the CLI and @shapio/mcp. */ type SchemaExport = { schemaVersion: number; /** The workspace whose view this is (shared definitions and its own); null on a network request. */ site: { id: string; key: string; } | null; /** Each with its scope: `site` is the workspace key, null when shared. */ definitions: ExportedDefinition[]; }; type SchemaSyncResult = { definitionId: string; apiKey: string; kind: SchemaDefinition['kind']; decision: SyncDecision; /** Each classified by the server; older servers send no `dropsValues`. */ changes: PlannedChange[]; outcome?: 'activated' | 'pending' | 'skipped'; version?: number | null; changeId?: string; plan?: { summary?: { breaking?: boolean; destructive?: boolean; prerequisites?: string[]; }; }; }; type SchemaApplyResult = { schemaVersion: number; dryRun: boolean; results: SchemaSyncResult[]; }; type SchemaApplyInput = { /** Definition files as read (untrusted JSON; the server parses and validates them). */ definitions: unknown[]; /** * Each file's scope, parallel to `definitions` (its folder: `models/` → network, `sites//` → * that workspace). Omit for a tree without workspace folders: every file is shared. Only creates use it. */ scopes?: DefinitionScope[]; /** The lock file the files came from: the versions the local copy is based on. */ base: LockFile; prune: boolean; dryRun: boolean; acknowledgeBreaking: boolean; acknowledgeDestructive: boolean; }; //#endregion //#region src/snapshotTypes.d.ts /** Publication snapshots for delivery callers (`/api/snapshots`, apps/api/src/routes/snapshots). */ type SnapshotChangeKind = 'published' | 'updated' | 'unpublished'; /** Pass exactly one of `from` and `recent`. */ type SnapshotChangesQuery = { /** The snapshot to compare from (your last build's). */ from?: number; /** * Instead of `from`: start where the diff covers the last N entries (1–100) you may read that went live or * were updated and are still live; the page's `from` says where that was. */ recent?: number; /** Defaults to the current snapshot. */ to?: number; /** `nextCursor` of the previous page. */ after?: string; /** Entries per page (default 100, at most 500). */ limit?: number; }; type SnapshotChange = { id: string; modelId: string; /** The model's API ID. */ modelKey: string; /** The delivery route key (`/api/content/`). */ routeKey: string; /** From the revision live at `to` (at `from` when unpublished); null without a readable title. */ title: string | null; /** The cover image's media asset ID, when the model has a readable cover. */ coverMediaId: string | null; /** The plurals of the interfaces the entry's type implements, inherited ones included (`[]` when none). */ interfaces: string[]; locales: Array<{ locale: string; change: SnapshotChangeKind; /** The revision live at `to`, or at `from` for `unpublished`. */ revisionId: string | null; }>; }; type SnapshotChangesPage = { from: number; to: number; /** Schema version recorded with each end; when they differ, rebuild the affected models. */ schemaVersions: { from: number | null; to: number | null; }; items: SnapshotChange[]; nextCursor: string | null; }; type CurrentSnapshot = { snapshot: number; schemaVersion: number; /** * The current schema version as the token a client names (`:`, the client's * `schemaVersion` option). Server 0.9.0 or later; absent from older servers. */ schemaVersionToken?: string; publishedAt: string | null; }; //#endregion //#region src/types.d.ts type HealthResponse = { status: 'ok'; }; type CheckStatus = 'ok' | 'failing'; type ReadyResponse = { status: 'ready'; checks: { database: CheckStatus; migrations: CheckStatus; }; }; type VersionResponse = { name: 'shapio'; version: string; node: string; }; //#endregion //#region src/client.d.ts type ShapioClientOptions = { /** Base URL of the Shapio server including any BASE_PATH, e.g. `https://cms.example.com/cms`. */ baseUrl: string; /** API token sent as a bearer token. */ token?: string; /** Defaults to the global fetch; injectable for tests and custom agents. */ fetch?: typeof globalThis.fetch; /** Fetch credentials mode. The admin uses `same-origin` so its session cookie is sent. */ credentials?: FetchCredentials; /** Extra headers computed per request (the admin's CSRF token). */ headers?: () => Readonly>; /** * The workspace key (instances with several workspaces). Delivery reads send it as `?site=`, every other * request as the `Shapio-Site` header (the spellings every server version reads). Leave it out to use the * token's workspace, else the primary workspace. A workspace token only ever reads its own workspace: * naming another one is refused (403 `SITE_MISMATCH`). */ workspace?: string; /** The older name of `workspace`. Both set to different keys throws. */ site?: string; /** * Next.js data-cache options for delivery reads (`delivery.*`, `site.get`), e.g. `{ cache: 'force-cache' }`. * Under Next the reads are tagged for `revalidateTag` whether or not this is set; the cache mode is only * passed when asked for, and reads pinned to a snapshot are always `force-cache`. Set it outside Next to send * the same fetch options; `false` sends none. A read's own `next` option overrides this one. */ next?: NextCacheOptions | false; /** * Drafts mode, for a website's development server: every delivery read asks for drafts * (`publicationState=draft`) instead of published content, and under Next is never cached or tagged. Needs * a delivery token whose role grants Read drafts (the server refuses others with 403 `DRAFTS_FORBIDDEN`); * never set it on a production build. Reads pinned to a `snapshot` are refused. `snapshots` is unaffected. */ drafts?: boolean; /** * The schema version this client was built against: the `SCHEMA_VERSION` token `shapio types generate` * writes next to the types (`:`). Every read then answers in that version's shape (its * route keys, API IDs, and field types) after the schema moves on; fields removed since read `null` (`[]` * for lists). Delivery reads send it as `?schemaVersion=`, every other request as the * `Shapio-Schema-Version` header. Leave it out to read today's schema. * * Needs server 0.9.0 or later: an older server refuses the query parameter with 400 (an unknown query * parameter), on purpose, so a client never silently gets a shape it was not built for. The server may * answer 400 `SCHEMA_VERSION_INVALID`, `SCHEMA_VERSION_FOREIGN` (a token from another instance), * `SCHEMA_VERSION_AHEAD`, or `LENS_QUERY_UNSUPPORTED` (a filter or sort on a field whose storage changed); * 409 `SCHEMA_VERSION_UNAVAILABLE` or `LENS_UNCOVERED`; 422 `LENS_WRITE_UNSUPPORTED` on a write (GraphQL * mutations: the same code in `extensions.code`). */ schemaVersion?: string; }; declare const createClient: ({ baseUrl, token, fetch, credentials, headers, workspace, site: siteOption, next, drafts, schemaVersion }: ShapioClientOptions) => { /** * Any Shapio route, e.g. the delivery API. Delivery paths use the model's route key: a collection's * plural API ID (`request('/api/content/articles')`, `/api/content/articles/`), a singleton's API ID * (`/api/content/homepage`). The admin API (`admin.*`) always uses the singular API ID. */ request: RequestFn; system: { health: (signal?: AbortSignal) => Promise; ready: (signal?: AbortSignal) => Promise; version: (signal?: AbortSignal) => Promise; }; /** Published content (the delivery API), typed by the caller. */ delivery: { list: >(routeKey: string, query?: DeliveryListQuery, options?: DeliveryReadOptions) => Promise>; singleton: >(apiKey: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; get: >(routeKey: string, id: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; }; /** The workspace as delivery sees it: key, name and SEO defaults (`GET /api/site`). */ workspace: { get: ({ next }?: DeliveryReadOptions) => Promise; }; /** The older name of `workspace`. */ site: { get: ({ next }?: DeliveryReadOptions) => Promise; }; admin: { assist: { status: () => Promise; altText: (body: AltTextInput) => Promise; summarize: (body: SummarizeInput) => Promise; translate: (body: TranslateInput) => Promise; rewrite: (body: RewriteInput) => Promise; write: (body: WriteInput) => Promise; suggest: (body: SuggestInput) => Promise; schemaDraft: (body: SchemaDraftInput) => Promise; proposeContentOps: (body: ContentOpsInput) => Promise<{ runId: string; }>; contentOpsRun: (runId: string) => Promise; acceptContentOps: (runId: string, body: AcceptContentOpsInput) => Promise; }; workspace: { changeSets: { get: () => Promise; update: (body: UpdateSiteChangeSetsInput) => Promise; }; }; site: { changeSets: { get: () => Promise; update: (body: UpdateSiteChangeSetsInput) => Promise; }; }; network: { approval: { get: () => Promise; update: (body: UpdateNetworkApprovalInput) => Promise; }; }; workspaces: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateSiteInput) => Promise; update: (id: string, body: UpdateSiteInput) => Promise; remove: (id: string) => Promise; makePrimary: (id: string) => Promise; appRoles: { get: (id: string) => Promise; set: (id: string, body: SetSiteAppRolesInput) => Promise; }; }; sites: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateSiteInput) => Promise; update: (id: string, body: UpdateSiteInput) => Promise; remove: (id: string) => Promise; makePrimary: (id: string) => Promise; appRoles: { get: (id: string) => Promise; set: (id: string, body: SetSiteAppRolesInput) => Promise; }; }; usage: { fields: (query: FieldUsageQuery) => Promise; schemaVersions: () => Promise; }; changeSets: { list: (query?: ChangeSetQuery) => Promise>; get: (id: string) => Promise; create: (body: CreateChangeSetInput) => Promise; update: (id: string, body: UpdateChangeSetInput) => Promise; discard: (id: string) => Promise; addEntry: (id: string, body: AddChangeSetEntryInput) => Promise; removeItem: (id: string, itemId: string) => Promise; getSchemaDraft: (id: string, definitionId: string) => Promise; putSchemaDraft: (id: string, definitionId: string, body: PutSchemaDraftInput) => Promise; removeSchemaDraft: (id: string, definitionId: string) => Promise; review: (id: string) => Promise; ship: (id: string, body: ShipChangeSetInput) => Promise; schedule: (id: string, body: ScheduleChangeSetInput) => Promise; unschedule: (id: string) => Promise; requestApproval: (id: string, body?: ApprovalNoteInput) => Promise; approve: (id: string, body?: ApprovalNoteInput) => Promise; requestChanges: (id: string, body: RequestChangesInput) => Promise; clearApproval: (id: string) => Promise; timeline: (id: string) => Promise; unassigned: (query?: { cursor?: string; limit?: number; }) => Promise>; }; snapshots: { list: (query?: SnapshotQuery) => Promise; get: (seq: number) => Promise; restore: (seq: number) => Promise; }; appUsers: { list: (query?: AppUserQuery) => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateAppUserInput) => Promise; remove: (id: string) => Promise; resendConfirmation: (id: string) => Promise; }; appRoles: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateAppRoleInput) => Promise; update: (id: string, body: UpdateAppRoleInput) => Promise; remove: (id: string) => Promise; }; jobs: { list: (query?: JobQuery) => Promise>; summary: () => Promise; get: (id: string) => Promise; retry: (id: string) => Promise; }; schedules: { list: (query?: ScheduleQuery) => Promise>; create: (body: CreateScheduleInput) => Promise; cancel: (id: string) => Promise; }; webhooks: { list: () => Promise; events: () => Promise; get: (id: string) => Promise; create: (body: CreateWebhookInput) => Promise; update: (id: string, body: UpdateWebhookInput) => Promise; remove: (id: string) => Promise; rotateSecret: (id: string) => Promise; test: (id: string) => Promise; deliveries: (id: string, query?: { cursor?: string; limit?: number; }) => Promise>; redeliver: (id: string, deliveryId: string) => Promise; }; deployments: { connectionSummaries: { list: () => Promise; get: (id: string) => Promise; }; connections: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateDeploymentConnectionInput) => Promise; update: (id: string, body: UpdateDeploymentConnectionInput) => Promise; remove: (id: string) => Promise; test: (id: string) => Promise; trigger: (id: string) => Promise; }; runs: { list: (query?: DeploymentRunQuery) => Promise>; get: (id: string) => Promise; retry: (id: string) => Promise; }; }; preview: { tokens: { list: (query?: { entryId?: string; }) => Promise; create: (body: CreatePreviewTokenInput) => Promise; revoke: (id: string) => Promise; }; targets: () => Promise; open: (body: OpenPreviewInput) => Promise; }; preflight: { run: (modelKey: string, id: string, body?: PreflightInput) => Promise; }; contentHealth: { list: (query?: ContentHealthQuery) => Promise; summary: () => Promise; }; presence: { heartbeat: (modelKey: string, id: string, body: PresenceHeartbeatInput) => Promise; entry: (modelKey: string, id: string) => Promise; model: (modelKey: string) => Promise; leave: (modelKey: string, id: string, tabId: string) => Promise; }; contentCounts: { list: () => Promise; }; content: { list: (modelKey: string, query?: ContentListQuery) => Promise; get: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; create: (modelKey: string, body: CreateEntryInput) => Promise; update: (modelKey: string, id: string, body: UpdateEntryInput) => Promise; remove: (modelKey: string, id: string) => Promise; duplicate: (modelKey: string, id: string) => Promise; publish: (modelKey: string, id: string, body?: EntryPublishInput) => Promise; unpublish: (modelKey: string, id: string, body?: EntryLocalesInput) => Promise; previewKindChange: (modelKey: string, id: string, body: ChangeEntryKindInput) => Promise; changeKind: (modelKey: string, id: string, body: ChangeEntryKindInput) => Promise; revisions: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; history: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; revision: (modelKey: string, id: string, revisionId: string) => Promise; restore: (modelKey: string, id: string, revisionId: string, expectedVersion: number) => Promise; targets: ({ types, ids, ...query }: ContentTargetsQuery) => Promise; }; extensions: { editors: () => Promise; themes: () => Promise; }; media: { folders: { list: () => Promise; create: (body: CreateMediaFolderInput) => Promise; update: (id: string, body: UpdateMediaFolderInput) => Promise; remove: (id: string) => Promise; }; assets: { list: (query?: MediaAssetQuery) => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateMediaAssetInput) => Promise; remove: (id: string, { force }?: { force?: boolean; }) => Promise; move: (body: MoveMediaAssetsInput) => Promise; usage: (id: string) => Promise; replace: (id: string, body: ReplaceUploadInput) => Promise; }; uploads: { create: (body: CreateUploadInput) => Promise; confirm: (grantId: string) => Promise; }; }; models: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; components: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; interfaces: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; schema: { summary: () => Promise; change: (changeId: string) => Promise; export: (options?: { scope?: DefinitionScope; }) => Promise; apply: (body: SchemaApplyInput) => Promise; settings: () => Promise; updateSettings: (body: UpdateSchemaSettingsInput) => Promise; }; locales: { list: () => Promise; create: (body: CreateLocaleInput) => Promise; update: (code: string, body: UpdateLocaleInput) => Promise; setDefault: (code: string, acknowledgeBreaking: boolean) => Promise; remove: (code: string, acknowledgeDestructive: boolean) => Promise; }; setup: { status: () => Promise; complete: (body: SetupInput) => Promise; }; auth: { csrf: () => Promise; login: (body: LoginInput) => Promise; logout: () => Promise; me: () => Promise; updateProfile: (body: UpdateProfileInput) => Promise; changePassword: (body: ChangePasswordInput) => Promise; requestPasswordReset: (body: PasswordResetRequestInput) => Promise; confirmPasswordReset: (body: PasswordResetConfirmInput) => Promise; }; sessions: { list: () => Promise; revoke: (id: string) => Promise; }; users: { list: () => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateAdminUserInput) => Promise; remove: (id: string) => Promise; revokeSessions: (id: string) => Promise; }; invitations: { list: () => Promise; create: (body: InviteUserInput) => Promise; revoke: (id: string) => Promise; link: (id: string) => Promise; inspect: (token: string) => Promise; accept: (body: AcceptInvitationInput) => Promise; }; roles: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateRoleInput) => Promise; update: (id: string, body: UpdateRoleInput) => Promise; remove: (id: string) => Promise; }; tokens: { list: () => Promise; create: (body: CreateApiTokenInput) => Promise; update: (id: string, body: UpdateApiTokenInput) => Promise; revoke: (id: string) => Promise; }; audit: { list: (query?: AuditQuery) => Promise; }; }; /** Publication snapshots and the diff between two (incremental builds). */ snapshots: { current: () => Promise; changes: (query: SnapshotChangesQuery) => Promise; allChanges: (query: Omit) => Promise<{ from: number; to: number; schemaVersions: { from: number | null; to: number | null; }; items: SnapshotChange[]; }>; }; /** End users of your websites and apps: sign-up, sign-in, tokens, OAuth. */ appAuth: { register: (body: AppRegisterInput) => Promise; login: (body: AppLoginInput) => Promise; refresh: (refreshToken: string) => Promise; logout: (refreshToken: string) => Promise; me: () => Promise; updateMe: (body: { name: string; }) => Promise; changePassword: (body: AppChangePasswordInput) => Promise; deleteMe: (body?: { password?: string; }) => Promise; confirmEmail: (token: string) => Promise; resendConfirmation: (email: string) => Promise; requestPasswordReset: (email: string) => Promise; confirmPasswordReset: (body: { token: string; password: string; }) => Promise; providers: () => Promise; oauthStartUrl: (provider: AppOAuthProvider, redirectTo: string, codeChallenge: string) => string; exchangeCode: (code: string, codeVerifier: string) => Promise; }; }; type ShapioClient = ReturnType; //#endregion //#region src/errors.d.ts /** The body every Shapio endpoint returns on failure. */ type ShapioErrorBody = { error: { code: string; message: string; details?: unknown; }; }; /** Thrown for any non-2xx response. `code` is Shapio's error code, or `HTTP_` if the body had none. */ declare class ShapioApiError extends Error { readonly status: number; readonly code: string; readonly details: unknown; constructor(status: number, body: unknown); } //#endregion //#region src/admin/assistTypes.d.ts /** Editor assists (plan agentic-ecosystem §A0). Agents propose, people ship: nothing here publishes. */ type AssistProvider = 'anthropic' | 'openai' | 'openai-compatible'; type AssistUsage = { month: string; runs: number; inputTokens: number; outputTokens: number; }; /** `usage` only for admins with `changes.manage`; provider and model only while assist is on. */ type AssistStatus = { enabled: boolean; provider?: AssistProvider; model?: string; usage?: AssistUsage; }; type AltTextInput = { assetId: string; locale?: string; }; type AltTextResult = { alt: string; model: string; }; /** A model-written text; `truncated` when it was cut to the field's or the request's limit. */ type AssistTextResult = { text: string; truncated: boolean; model: string; }; type SummarizeInput = { modelKey: string; entryId: string; locale?: string; fieldApiKey: string; }; type TranslateInput = { modelKey: string; entryId: string; from: string; to: string; }; type AssistIssue = { path: string; code: string; message: string; }; /** `data` is in the editor's save format: save it as the `to` locale's draft. */ type TranslateResult = { data: Record; issues: AssistIssue[]; model: string; }; type RewriteInput = { text: string; instruction: string; maxLength?: number; }; /** * Text written into a rich-text document at the editor's cursor. The caller sends the context: `before` is the * text up to the insertion point (its last 12,000 characters), `after` what follows it (up to 2,000). * `section` needs an instruction; `continue` takes one as an optional steer. */ type WriteContext = { before: string; after?: string; title?: string; fieldLabel?: string; locale?: string; }; type WriteInput = (WriteContext & { kind: 'section'; instruction: string; }) | (WriteContext & { kind: 'continue'; instruction?: string; }); /** Markdown (headings, paragraphs, lists, quotes, bold, italic, inline code) for the editor to review. */ type WriteResult = { markdown: string; model: string; }; /** `fieldPath` is a JSON pointer in API IDs: a top-level field (`/keywords`) or a single component's field (`/seo/title`). */ type SuggestInput = { modelKey: string; entryId: string; locale?: string; fieldPath: string; }; /** A string, or for an enum the stored value (a string, or a list of strings when it allows several). */ type SuggestedValue = string | string[]; type SuggestResult = { value: SuggestedValue; truncated: boolean; model: string; }; type SchemaDraftInput = { description: string; }; /** New definitions with new stable IDs, in save order (references first). Nothing is written. */ type SchemaDraftResult = { definitions: SchemaDefinition[]; model: string; }; declare const CONTENT_OPS_RULES: readonly ["altMissing", "localeMissing", "requiredEmpty", "fieldEmpty"]; type ContentOpsRule = (typeof CONTENT_OPS_RULES)[number]; /** * `modelKey` narrows `altMissing`, `localeMissing` and `requiredEmpty` to one content type and is required for * `fieldEmpty`, with `fieldPath` (JSON pointer in API IDs) and an optional `locale` (default: the default * locale). `fromLocale` is the source of `localeMissing` translations. */ type ContentOpsInput = { rule: ContentOpsRule; modelKey?: string; fromLocale?: string; fieldPath?: string; locale?: string; }; type ContentOpsStatus = 'queued' | 'running' | 'succeeded' | 'failed'; /** One library asset's proposed alt text; apply it with the media update at `assetVersion`. */ type AltProposal = { assetId: string; filename: string; currentAlt: string | null; proposedAlt: string; assetVersion: number; findingCount: number; }; /** A finding the run left alone, and why (an error code or a reason such as `publishesOnSave`). */ type ContentOpsSkip = { key: string; entryId?: string; assetId?: string; locale?: string; reason: string; detail?: unknown; }; type ContentOpsWritten = { entryId: string; modelKey: string; locale: string; version: number; }; type AltMissingResult = { rule: 'altMissing'; proposals: AltProposal[]; skipped: ContentOpsSkip[]; }; /** The drafts were written into the change set `changeSetId` (null when nothing was written). */ type LocaleMissingResult = { rule: 'localeMissing'; changeSetId: string | null; fromLocale: string; written: ContentOpsWritten[]; skipped: ContentOpsSkip[]; }; type FillFieldType = 'string' | 'text' | 'enum'; /** * A proposed value for an empty field of an entry's draft (`requiredEmpty`, `fieldEmpty`). Nothing is written * until it is accepted. `options` and `multiple` describe an enum; `maxLength` a string or text. */ type FieldProposal = { /** `entry:{entryId}:{locale}:{fieldPath}`; accept by this key. */ key: string; entryId: string; modelKey: string; entryTitle: string | null; locale: string; fieldPath: string; fieldLabel: string; fieldType: FillFieldType; proposedValue: SuggestedValue; /** The draft version the value was proposed from (informational: accept guards the field, not the version). */ entryVersion: number; maxLength?: number; multiple?: boolean; options?: { value: string; label: string; }[]; }; /** `scanCapped`: a component field's fill stopped after reading 2,000 entries; run it again for more. */ type FieldFillResult = { rule: 'requiredEmpty' | 'fieldEmpty'; proposals: FieldProposal[]; skipped: ContentOpsSkip[]; scanCapped: boolean; }; type ContentOpsResult = AltMissingResult | LocaleMissingResult | FieldFillResult; /** The proposals to accept, all of one entry and locale, with the values to save (edited or as proposed). */ type AcceptContentOpsInput = { items: { key: string; value: SuggestedValue; }[]; }; /** * The values were saved into the entry's draft. The entry locale is in the run's change set when `added`; it is * left out when its draft held unpublished changes before the accept, or was never published, so shipping the * set never publishes more than the fill. */ type AcceptContentOpsResult = { entryId: string; modelKey: string; locale: string; version: number; changeSet: { added: true; id: string; } | { added: false; id: string | null; reason: 'unpublishedChanges' | 'neverPublished'; }; }; type ContentOpsRun = { runId: string; rule: ContentOpsRule; status: ContentOpsStatus; model: string; createdAt: string; finishedAt: string | null; error: { code: string; } | null; /** Once succeeded (null before, or partial progress while running). */ result: ContentOpsResult | null; }; //#endregion //#region src/admin/editingTypes.d.ts /** * Shapes of the entry document's endpoints (editor experience, E0b): publish pre-flight, content health * findings, presence and per-model counts. Sentences are never sent: the admin builds them from `rule` and * `params` with its translations. */ /** Health rules evaluated per entry (`apps/api/src/services/contentHealth.ts`). */ declare const HEALTH_RULES: readonly ["requiredEmpty", "altMissing", "localeMissing", "relationMissing", "mediaMissing", "relationUnpublished", "uniqueConflict", "staleDraft", "unpublishedChanges"]; type HealthRule = (typeof HEALTH_RULES)[number]; /** Pre-flight adds the publish checks that are not health rules: validator issues. */ type PreflightRule = HealthRule | 'invalid'; type CheckSeverity = 'error' | 'warning'; /** Values a sentence needs (field ID, asset ID, locale, counts…). */ type CheckParams = Record; type PreflightCheck = { rule: PreflightRule; /** Errors block publishing; warnings are informational. */ severity: CheckSeverity; /** JSON pointer (API keys) of the value to fix, e.g. `/body` or `/sections/2/title`. */ path?: string; /** The validator's issue code, for `invalid` and `requiredEmpty` errors. */ code?: string; params: CheckParams; }; type PreflightLocale = { locale: string; /** No error-severity check: publishing this locale is expected to succeed. */ ready: boolean; checks: PreflightCheck[]; }; type PreflightInput = { locales?: string[]; }; type PreflightResponse = { locales: PreflightLocale[]; /** Checks about the entry as a whole, not one locale (e.g. a configured locale not started yet). */ entry: PreflightCheck[]; }; /** A finding of the health engine, open until its rule passes again. */ type ContentHealthFinding = { id: string; entryId: string; modelId: string; modelKey: string; /** The entry's title in the finding's locale (or the default locale), when readable. */ entryTitle: string | null; /** `*` for a finding about the entry as a whole. */ locale: string; rule: HealthRule; /** Distinguishes several findings of one rule on one entry (e.g. two images without alt text). */ subject: string; severity: CheckSeverity; path?: string; params: CheckParams; /** * A relation finding's linked entry's title (`params.targetEntryId`), only when the caller may read it. */ targetTitle?: string; firstSeenAt: string; lastSeenAt: string; }; type ContentHealthQuery = { rule?: HealthRule; modelKey?: string; cursor?: string; limit?: number; }; type ContentHealthPage = { items: ContentHealthFinding[]; nextCursor: string | null; }; type ContentHealthSummary = { rules: { rule: HealthRule; count: number; }[]; }; /** Someone with the entry open. */ type PresencePerson = { userId: string; name: string; /** The locale they are editing, when the model is localized. */ locale: string | null; /** When this tab started editing. */ since: string; /** The caller's own other tab (the calling tab itself is never listed). */ you: boolean; }; type PresenceHeartbeatInput = { /** A random ID per browser tab, so two tabs of one person are counted apart. */ tabId: string; locale?: string | null; }; type EntryPresence = { people: PresencePerson[]; }; /** A locale's draft as the server has it: an open document compares `version` with the one it shows. */ type DraftState = { locale: string; version: number; /** When the draft last moved (a save, an autosave, or publishing autosaved work). */ savedAt: string; /** Who saved it; null when that isn't known reliably (an autosave, a token, a schedule). */ savedBy: { name: string; you: boolean; } | null; }; /** The heartbeat's answer: who else has the entry open, and every locale's current draft version. */ type EntryHeartbeat = EntryPresence & { drafts: DraftState[]; }; type ModelPresence = { entries: { entryId: string; people: PresencePerson[]; }[]; }; type ContentCount = { modelId: string; modelKey: string; total: number; }; type ContentCounts = { counts: ContentCount[]; }; //#endregion //#region src/admin/paths.d.ts /** Every admin route the client calls (packages B, D, F and G, `apps/api/src/routes/admin/**`). */ declare const ADMIN_PATHS: { readonly setup: "/api/admin/setup"; readonly csrf: "/api/admin/auth/csrf"; readonly login: "/api/admin/auth/login"; readonly logout: "/api/admin/auth/logout"; readonly me: "/api/admin/auth/me"; readonly password: "/api/admin/auth/me/password"; readonly sessions: "/api/admin/auth/sessions"; readonly passwordReset: "/api/admin/auth/password-reset"; readonly passwordResetConfirm: "/api/admin/auth/password-reset/confirm"; readonly users: "/api/admin/users"; readonly invitations: "/api/admin/invitations"; readonly inspectInvitation: "/api/admin/invitations/inspect"; readonly acceptInvitation: "/api/admin/invitations/accept"; readonly roles: "/api/admin/roles"; readonly tokens: "/api/admin/tokens"; readonly audit: "/api/admin/audit"; readonly models: "/api/admin/models"; readonly components: "/api/admin/components"; readonly interfaces: "/api/admin/interfaces"; readonly schema: "/api/admin/schema"; readonly schemaChanges: "/api/admin/schema/changes"; readonly schemaExport: "/api/admin/schema/export"; readonly schemaApply: "/api/admin/schema/apply"; readonly schemaSettings: "/api/admin/schema/settings"; readonly locales: "/api/admin/locales"; readonly mediaFolders: "/api/admin/media/folders"; readonly mediaAssets: "/api/admin/media/assets"; readonly mediaUploads: "/api/admin/media/uploads"; readonly appUsers: "/api/admin/app-users"; readonly appRoles: "/api/admin/app-roles"; readonly content: "/api/admin/content"; readonly contentTargets: "/api/admin/content-targets"; readonly contentCounts: "/api/admin/content-counts"; readonly contentHealth: "/api/admin/content-health"; readonly presence: "/api/admin/presence"; readonly editorManifest: "/api/admin/extensions/editors"; readonly extensionThemes: "/api/admin/extensions/themes"; readonly jobs: "/api/admin/jobs"; readonly schedules: "/api/admin/publishing/schedules"; readonly changeSets: "/api/admin/change-sets"; readonly snapshots: "/api/admin/snapshots"; readonly webhooks: "/api/admin/webhooks"; readonly deploymentConnections: "/api/admin/deployments/connections"; readonly deploymentConnectionSummaries: "/api/admin/deployments/connection-summaries"; readonly deploymentRuns: "/api/admin/deployments/runs"; readonly preview: "/api/admin/preview"; readonly previewTokens: "/api/admin/preview/tokens"; }; //#endregion //#region src/admin/approval.d.ts declare const APPROVAL_PATHS: { readonly siteChangeSets: "/api/admin/site/change-sets"; readonly networkApproval: "/api/admin/network/approval"; }; //#endregion //#region src/admin/sites.d.ts declare const SITES_PATHS: { readonly sites: "/api/admin/sites"; }; /** * The header that names the workspace a workspace-scoped request is about (default: the primary workspace). * Every server version reads it, so the client sends it. */ declare const SITE_HEADER = "shapio-site"; /** * The newer spelling of `SITE_HEADER`, for callers who build raw requests (server 0.8.2 or later; * `Shapio-Site` works on every version). The client itself still sends `Shapio-Site`. */ declare const WORKSPACE_HEADER = "shapio-workspace"; //#endregion //#region src/admin/contentQuery.d.ts declare const toContentQueryString: (query?: ContentListQuery) => string; //#endregion //#region src/admin/media.d.ts /** The form for step 2 of an upload: the grant's fields in order, then the file. */ declare const buildUploadForm: (grant: UploadGrant, file: Blob, filename: string) => FormData; /** * Where to send a grant's bytes. Shapio's own upload route (local storage) is addressed through the base URL * the caller already talks to, which keeps it reachable when PUBLIC_URL differs from that address (the * admin's dev server, a proxy, a container network). Bucket URLs (presigned POST) are used as given. */ declare const resolveUploadUrl: (grant: UploadGrant, apiBaseUrl: string) => string; //#endregion //#region src/admin/assist.d.ts declare const ASSIST_PATHS: { readonly status: "/api/admin/assist/status"; readonly altText: "/api/admin/assist/alt-text"; readonly summarize: "/api/admin/assist/summarize"; readonly translate: "/api/admin/assist/translate"; readonly rewrite: "/api/admin/assist/rewrite"; readonly write: "/api/admin/assist/write"; readonly suggest: "/api/admin/assist/suggest"; readonly schemaDraft: "/api/admin/assist/schema/draft"; readonly contentOpsPropose: "/api/admin/assist/content-ops/propose"; readonly contentOps: "/api/admin/assist/content-ops"; }; //#endregion //#region src/admin/index.d.ts /** * Admin endpoints: identity (setup, auth, sessions, users, invitations, roles, tokens, audit) and the schema * registry (models, components, schema, locales), the media library and content. */ declare const createAdminApi: (request: RequestFn) => { assist: { status: () => Promise; altText: (body: AltTextInput) => Promise; summarize: (body: SummarizeInput) => Promise; translate: (body: TranslateInput) => Promise; rewrite: (body: RewriteInput) => Promise; write: (body: WriteInput) => Promise; suggest: (body: SuggestInput) => Promise; schemaDraft: (body: SchemaDraftInput) => Promise; proposeContentOps: (body: ContentOpsInput) => Promise<{ runId: string; }>; contentOpsRun: (runId: string) => Promise; acceptContentOps: (runId: string, body: AcceptContentOpsInput) => Promise; }; workspace: { changeSets: { get: () => Promise; update: (body: UpdateSiteChangeSetsInput) => Promise; }; }; site: { changeSets: { get: () => Promise; update: (body: UpdateSiteChangeSetsInput) => Promise; }; }; network: { approval: { get: () => Promise; update: (body: UpdateNetworkApprovalInput) => Promise; }; }; workspaces: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateSiteInput) => Promise; update: (id: string, body: UpdateSiteInput) => Promise; remove: (id: string) => Promise; makePrimary: (id: string) => Promise; appRoles: { get: (id: string) => Promise; set: (id: string, body: SetSiteAppRolesInput) => Promise; }; }; sites: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateSiteInput) => Promise; update: (id: string, body: UpdateSiteInput) => Promise; remove: (id: string) => Promise; makePrimary: (id: string) => Promise; appRoles: { get: (id: string) => Promise; set: (id: string, body: SetSiteAppRolesInput) => Promise; }; }; usage: { fields: (query: FieldUsageQuery) => Promise; schemaVersions: () => Promise; }; changeSets: { list: (query?: ChangeSetQuery) => Promise>; get: (id: string) => Promise; create: (body: CreateChangeSetInput) => Promise; update: (id: string, body: UpdateChangeSetInput) => Promise; discard: (id: string) => Promise; addEntry: (id: string, body: AddChangeSetEntryInput) => Promise; removeItem: (id: string, itemId: string) => Promise; getSchemaDraft: (id: string, definitionId: string) => Promise; putSchemaDraft: (id: string, definitionId: string, body: PutSchemaDraftInput) => Promise; removeSchemaDraft: (id: string, definitionId: string) => Promise; review: (id: string) => Promise; ship: (id: string, body: ShipChangeSetInput) => Promise; schedule: (id: string, body: ScheduleChangeSetInput) => Promise; unschedule: (id: string) => Promise; requestApproval: (id: string, body?: ApprovalNoteInput) => Promise; approve: (id: string, body?: ApprovalNoteInput) => Promise; requestChanges: (id: string, body: RequestChangesInput) => Promise; clearApproval: (id: string) => Promise; timeline: (id: string) => Promise; unassigned: (query?: { cursor?: string; limit?: number; }) => Promise>; }; snapshots: { list: (query?: SnapshotQuery) => Promise; get: (seq: number) => Promise; restore: (seq: number) => Promise; }; appUsers: { list: (query?: AppUserQuery) => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateAppUserInput) => Promise; remove: (id: string) => Promise; resendConfirmation: (id: string) => Promise; }; appRoles: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateAppRoleInput) => Promise; update: (id: string, body: UpdateAppRoleInput) => Promise; remove: (id: string) => Promise; }; jobs: { list: (query?: JobQuery) => Promise>; summary: () => Promise; get: (id: string) => Promise; retry: (id: string) => Promise; }; schedules: { list: (query?: ScheduleQuery) => Promise>; create: (body: CreateScheduleInput) => Promise; cancel: (id: string) => Promise; }; webhooks: { list: () => Promise; events: () => Promise; get: (id: string) => Promise; create: (body: CreateWebhookInput) => Promise; update: (id: string, body: UpdateWebhookInput) => Promise; remove: (id: string) => Promise; rotateSecret: (id: string) => Promise; test: (id: string) => Promise; deliveries: (id: string, query?: { cursor?: string; limit?: number; }) => Promise>; redeliver: (id: string, deliveryId: string) => Promise; }; deployments: { connectionSummaries: { list: () => Promise; get: (id: string) => Promise; }; connections: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateDeploymentConnectionInput) => Promise; update: (id: string, body: UpdateDeploymentConnectionInput) => Promise; remove: (id: string) => Promise; test: (id: string) => Promise; trigger: (id: string) => Promise; }; runs: { list: (query?: DeploymentRunQuery) => Promise>; get: (id: string) => Promise; retry: (id: string) => Promise; }; }; preview: { tokens: { list: (query?: { entryId?: string; }) => Promise; create: (body: CreatePreviewTokenInput) => Promise; revoke: (id: string) => Promise; }; targets: () => Promise; open: (body: OpenPreviewInput) => Promise; }; preflight: { run: (modelKey: string, id: string, body?: PreflightInput) => Promise; }; contentHealth: { list: (query?: ContentHealthQuery) => Promise; summary: () => Promise; }; presence: { heartbeat: (modelKey: string, id: string, body: PresenceHeartbeatInput) => Promise; entry: (modelKey: string, id: string) => Promise; model: (modelKey: string) => Promise; leave: (modelKey: string, id: string, tabId: string) => Promise; }; contentCounts: { list: () => Promise; }; content: { list: (modelKey: string, query?: ContentListQuery) => Promise; get: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; create: (modelKey: string, body: CreateEntryInput) => Promise; update: (modelKey: string, id: string, body: UpdateEntryInput) => Promise; remove: (modelKey: string, id: string) => Promise; duplicate: (modelKey: string, id: string) => Promise; publish: (modelKey: string, id: string, body?: EntryPublishInput) => Promise; unpublish: (modelKey: string, id: string, body?: EntryLocalesInput) => Promise; previewKindChange: (modelKey: string, id: string, body: ChangeEntryKindInput) => Promise; changeKind: (modelKey: string, id: string, body: ChangeEntryKindInput) => Promise; revisions: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; history: (modelKey: string, id: string, { locale }?: { locale?: string; }) => Promise; revision: (modelKey: string, id: string, revisionId: string) => Promise; restore: (modelKey: string, id: string, revisionId: string, expectedVersion: number) => Promise; targets: ({ types, ids, ...query }: ContentTargetsQuery) => Promise; }; extensions: { editors: () => Promise; themes: () => Promise; }; media: { folders: { list: () => Promise; create: (body: CreateMediaFolderInput) => Promise; update: (id: string, body: UpdateMediaFolderInput) => Promise; remove: (id: string) => Promise; }; assets: { list: (query?: MediaAssetQuery) => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateMediaAssetInput) => Promise; remove: (id: string, { force }?: { force?: boolean; }) => Promise; move: (body: MoveMediaAssetsInput) => Promise; usage: (id: string) => Promise; replace: (id: string, body: ReplaceUploadInput) => Promise; }; uploads: { create: (body: CreateUploadInput) => Promise; confirm: (grantId: string) => Promise; }; }; models: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; components: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; interfaces: { list: (options?: { scope?: DefinitionScope; }) => Promise; get: (id: string) => Promise; create: (body: CreateDefinitionInput) => Promise; planCreate: (definition: DefinitionPayload, scope?: DefinitionScope) => Promise; changeScope: (id: string, body: ChangeScopeInput) => Promise; update: (id: string, body: UpdateDefinitionInput) => Promise; planUpdate: (id: string, body: PlanUpdateInput) => Promise; remove: (id: string, expectedVersion: number, options?: { acknowledgeBreaking?: boolean; }) => Promise; revisions: (id: string) => Promise; revision: (id: string, revisionId: string) => Promise; changes: (id: string) => Promise; }; schema: { summary: () => Promise; change: (changeId: string) => Promise; export: (options?: { scope?: DefinitionScope; }) => Promise; apply: (body: SchemaApplyInput) => Promise; settings: () => Promise; updateSettings: (body: UpdateSchemaSettingsInput) => Promise; }; locales: { list: () => Promise; create: (body: CreateLocaleInput) => Promise; update: (code: string, body: UpdateLocaleInput) => Promise; setDefault: (code: string, acknowledgeBreaking: boolean) => Promise; remove: (code: string, acknowledgeDestructive: boolean) => Promise; }; setup: { status: () => Promise; complete: (body: SetupInput) => Promise; }; auth: { csrf: () => Promise; login: (body: LoginInput) => Promise; logout: () => Promise; me: () => Promise; updateProfile: (body: UpdateProfileInput) => Promise; /** The session is rotated: the response carries the new session's CSRF token. */ changePassword: (body: ChangePasswordInput) => Promise; requestPasswordReset: (body: PasswordResetRequestInput) => Promise; confirmPasswordReset: (body: PasswordResetConfirmInput) => Promise; }; sessions: { list: () => Promise; revoke: (id: string) => Promise; }; users: { list: () => Promise; get: (id: string) => Promise; update: (id: string, body: UpdateAdminUserInput) => Promise; remove: (id: string) => Promise; revokeSessions: (id: string) => Promise; }; invitations: { list: () => Promise; create: (body: InviteUserInput) => Promise; revoke: (id: string) => Promise; /** A fresh link to send by hand; any earlier link for this invitation stops working. */ link: (id: string) => Promise; /** Public: the token travels in the body, never in a URL the server logs. */ inspect: (token: string) => Promise; accept: (body: AcceptInvitationInput) => Promise; }; roles: { list: () => Promise; get: (id: string) => Promise; create: (body: CreateRoleInput) => Promise; update: (id: string, body: UpdateRoleInput) => Promise; remove: (id: string) => Promise; }; tokens: { list: () => Promise; create: (body: CreateApiTokenInput) => Promise; update: (id: string, body: UpdateApiTokenInput) => Promise; revoke: (id: string) => Promise; }; audit: { list: (query?: AuditQuery) => Promise; }; }; type AdminApi = ReturnType; //#endregion //#region src/delivery.d.ts declare const DELIVERY_PATH = "/api/content"; /** * Published content, typed by the caller (`delivery.list
('articles', { locale: 'fr', snapshot })`). * A collection is read with `list` (a page) and `get` (one entry); a singleton with `singleton`. A type that * extends another is read by its nested route key (`delivery.list('posts/guides')`); a parent's list * holds every kind, each entry naming its own in `__model`. Each read * takes Next.js cache options last and is tagged for `revalidateTag` (nextCache.ts): lists and singletons with * the workspace and model tags, `get` with the entry's tag too. In drafts mode (`drafts: true`) every read asks for * drafts (`publicationState=draft`), is never cached or tagged under Next, and refuses a pinned snapshot. */ declare const createDeliveryApi: (request: RequestFn, cacheContext: DeliveryCacheContext) => { list: >(routeKey: string, query?: DeliveryListQuery, options?: DeliveryReadOptions) => Promise>; singleton: >(apiKey: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; get: >(routeKey: string, id: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; }; type DeliveryApi = ReturnType; //#endregion //#region src/deliveryClient.d.ts type DeliveryClientOptions = { /** * The workspace key the reads are tagged with (`shapioTags.workspace`); the transport names the workspace * itself. Same as `site`; both set to different keys throws. */ workspace?: string; /** The older name of `workspace`. */ site?: string; /** Next.js data-cache options, as `createClient`'s `next` option. */ next?: NextCacheOptions | false; /** Drafts mode, as `createClient`'s `drafts` option. */ drafts?: boolean; /** * The schema version token every read names, as `createClient`'s `schemaVersion` option: added to each path * as `?schemaVersion=` (every read here is a delivery read), so the transport receives it in the path. Leave * it out when the transport names the version itself (`createClient` does). */ schemaVersion?: string; }; /** * The read side of the client over any transport: published content (`delivery`), the workspace (`workspace`, * also as `site`) and publication snapshots (`snapshots`). `createClient` builds it over HTTP; `@shapio/local` * over the delivery API running in the same process. The transport receives exactly the paths the HTTP client * sends. */ declare const createDeliveryClient: (request: RequestFn, { workspace, site, next, drafts, schemaVersion }?: DeliveryClientOptions) => { /** Published content (the delivery API; drafts in drafts mode), typed by the caller. */ delivery: { list: >(routeKey: string, query?: DeliveryListQuery, options?: DeliveryReadOptions) => Promise>; singleton: >(apiKey: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; get: >(routeKey: string, id: string, query?: DeliveryGetQuery, options?: DeliveryReadOptions) => Promise>; }; /** The workspace as delivery sees it: key, name and SEO defaults (`GET /api/site`). */ workspace: { get: ({ next }?: DeliveryReadOptions) => Promise; }; /** The older name of `workspace`. */ site: { get: ({ next }?: DeliveryReadOptions) => Promise; }; /** Publication snapshots and the diff between two (incremental builds). */ snapshots: { current: () => Promise; changes: (query: SnapshotChangesQuery) => Promise; allChanges: (query: Omit) => Promise<{ from: number; to: number; schemaVersions: { from: number | null; to: number | null; }; items: SnapshotChange[]; }>; }; }; type ShapioDeliveryClient = ReturnType; //#endregion //#region src/site.d.ts /** * Delivery reads name their workspace with `?site=`; everything else with the `Shapio-Site` header. Every * server version reads this spelling, so the client sends it. */ declare const SITE_QUERY_PARAMETER = "site"; /** * The newer spelling of `SITE_QUERY_PARAMETER`, for callers who build raw requests (server 0.8.2 or later; * `?site=` works on every version). The client itself still sends `?site=`. */ declare const WORKSPACE_QUERY_PARAMETER = "workspace"; /** The two spellings of the workspace option (`site` is the older one). */ type WorkspaceOption = { workspace?: string | undefined; site?: string | undefined; }; /** * The workspace key a client names, from its `workspace` option or the older `site` one. Both set to * different keys is a mistake the caller must fix, so it throws (`toError` picks the error class). */ declare const resolveWorkspaceOption: ({ workspace, site }: WorkspaceOption, caller: string, toError?: (message: string) => Error) => string | undefined; //#endregion //#region src/siteDelivery.d.ts /** The workspace as delivery sees it. Every server version serves this path, so the client reads it. */ declare const DELIVERY_SITE_PATH = "/api/site"; /** * The request's workspace as delivery sees it (key, name, SEO defaults), with the client's token and * workspace. Under Next.js the read carries the workspace tag (nextCache.ts); in drafts mode it is `no-store` * and untagged instead (the workspace has no draft state, so no `publicationState` is sent). */ declare const createSiteApi: (request: RequestFn, cacheContext: DeliveryCacheContext) => { get: ({ next }?: DeliveryReadOptions) => Promise; }; type SiteApi = ReturnType; /** The workspace delivery API (`client.workspace`); the same as `SiteApi`. */ type WorkspaceApi = SiteApi; //#endregion //#region src/webhooks.d.ts /** * Verifying Shapio's signed webhooks and deploy triggers on the receiving side (a website's revalidate route, * a build hook). The scheme is the server's (`apps/api/src/publishing/signature.ts`): * `X-Shapio-Signature: v1=.")>` with * `X-Shapio-Timestamp: `; several comma-separated `v1=` values are accepted (secret rotation). * Uses Web Crypto, so it runs in Node, edge runtimes and browsers alike. */ declare const WEBHOOK_SIGNATURE_HEADER = "x-shapio-signature"; declare const WEBHOOK_TIMESTAMP_HEADER = "x-shapio-timestamp"; declare const WEBHOOK_EVENT_HEADER = "x-shapio-event"; /** Requests signed further from now than this are rejected (replay protection). */ declare const WEBHOOK_TOLERANCE_SECONDS = 300; type WebhookSignatureInput = { /** The webhook's or connection's signing secret. */ secret: string; /** The `X-Shapio-Signature` header. */ signature: string | null | undefined; /** The `X-Shapio-Timestamp` header. */ timestamp: string | null | undefined; /** The raw request body, exactly as received (not re-serialized JSON). */ body: string; /** Defaults to the current time. */ now?: Date; /** Defaults to WEBHOOK_TOLERANCE_SECONDS. */ toleranceSeconds?: number; }; type WebhookSignatureCheck = { ok: true; } | { ok: false; reason: string; }; /** Checks a Shapio signature; `{ ok: false, reason }` says why it was refused (never throws for bad input). */ declare const verifyWebhookSignature: ({ secret, signature, timestamp, body, now, toleranceSeconds }: WebhookSignatureInput) => Promise; //#endregion //#region src/appAuth/types.d.ts /** * App-user authentication (package I), mirroring apps/api/src/routes/app-auth/schemas.ts. For the websites and * apps built on Shapio: their end users sign up, sign in and manage their accounts here. */ type AppUser = { id: string; email: string; name: string; confirmed: boolean; hasPassword: boolean; providers: string[]; createdAt: string; lastLoginAt: string | null; }; /** Send `accessToken` as `Authorization: Bearer …`; trade `refreshToken` for a new pair before it expires. */ type AppSession = { user: AppUser; accessToken: string; tokenType: 'Bearer'; /** Access-token lifetime in seconds. */ expiresIn: number; /** Single use: each refresh returns the next one. Presenting a used one signs the session out. */ refreshToken: string; refreshTokenExpiresAt: string; }; type AppRegisterInput = { email: string; password: string; name?: string; }; /** * Signed in at once (HTTP 201), or, when the instance requires a confirmed email, `{ confirmationRequired: * true }` (HTTP 202): "check your email". That answer is the same whether or not the address already had an * account, so it never reveals who is registered. */ type AppRegisterResult = { confirmationRequired: false; user: AppUser; session: AppSession; } | { confirmationRequired: true; }; type AppLoginInput = { email: string; password: string; }; type AppChangePasswordInput = { currentPassword?: string; newPassword: string; }; type AppOAuthProvider = 'google' | 'github'; //#endregion //#region src/appAuth/index.d.ts declare const APP_AUTH_PATHS: { readonly register: "/api/app-auth/register"; readonly login: "/api/app-auth/login"; readonly refresh: "/api/app-auth/refresh"; readonly logout: "/api/app-auth/logout"; readonly me: "/api/app-auth/me"; readonly password: "/api/app-auth/me/password"; readonly confirmEmail: "/api/app-auth/confirm-email"; readonly resendConfirmation: "/api/app-auth/confirm-email/resend"; readonly passwordReset: "/api/app-auth/password-reset"; readonly passwordResetConfirm: "/api/app-auth/password-reset/confirm"; readonly providers: "/api/app-auth/providers"; readonly oauthExchange: "/api/app-auth/oauth/exchange"; }; /** * App-user endpoints. Calls that act as the signed-in user need a client created with `token: accessToken`. * `baseUrl` is the client's base URL, used to build the OAuth start link the browser navigates to. */ declare const createAppAuthApi: (request: RequestFn, baseUrl: string) => { register: (body: AppRegisterInput) => Promise; login: (body: AppLoginInput) => Promise; refresh: (refreshToken: string) => Promise; /** * Signs the account out everywhere: this login's refresh tokens are revoked, and every access token the * account holds (on any device) is refused from the next request. Other logins recover with their own * refresh token. */ logout: (refreshToken: string) => Promise; /** The signed-in user. Answers 401 once the account logged out anywhere, changed its password or was blocked. */ me: () => Promise; updateMe: (body: { name: string; }) => Promise; /** Returns a new session; every other sign-in of the account is revoked. */ changePassword: (body: AppChangePasswordInput) => Promise; deleteMe: (body?: { password?: string; }) => Promise; /** The token from the `#token=` fragment of the confirmation link. */ confirmEmail: (token: string) => Promise; resendConfirmation: (email: string) => Promise; requestPasswordReset: (email: string) => Promise; confirmPasswordReset: (body: { token: string; password: string; }) => Promise; providers: () => Promise; /** * Where to send the browser to sign in with a provider. `codeChallenge` comes from `createPkcePair()`; * keep its `codeVerifier` until the browser returns. It comes back to `redirectTo` (an allowed return URL, * by default an origin listed in CORS_ORIGINS) with `?code=` (pass it to `exchangeCode`) or `?error=`. */ oauthStartUrl: (provider: AppOAuthProvider, redirectTo: string, codeChallenge: string) => string; /** Trades the one-time code for a session. A wrong verifier spends the code: start the sign-in again. */ exchangeCode: (code: string, codeVerifier: string) => Promise; }; type AppAuthApi = ReturnType; //#endregion //#region src/appAuth/pkce.d.ts /** * PKCE (RFC 7636) for the app side of Shapio's OAuth sign-in: the app keeps the verifier (e.g. in * sessionStorage) and sends the S256 challenge with the start link; the one-time code it gets back is only * exchanged together with that verifier. Uses Web Crypto, so it works in browsers and Node alike. */ type AppPkcePair = { codeVerifier: string; codeChallenge: string; }; /** The S256 challenge of a verifier: base64url(SHA-256(verifier)). */ declare const codeChallengeOf: (codeVerifier: string) => Promise; /** A fresh verifier (32 random bytes, 43 characters) and its S256 challenge. */ declare const createPkcePair: () => Promise; //#endregion export { CheckSeverity as $, UpdateDeploymentConnectionInput as $a, PlanPreview as $i, ApiToken as $n, DeliveryComponentAttributes as $o, ChangeSetApprovalSummary as $r, RequestFn as $s, ShapioApiError as $t, DELIVERY_SITE_PATH as A, DeploymentRunTrigger as Aa, SnapshotPage as Ai, MediaVisibility as An, UpdateSiteInput as Ao, RoleKind as Ar, ContentTargetMember as As, CONTENT_OPS_RULES as At, DELIVERY_PATH as B, JobSummary as Ba, ChangeScopeOutcome as Bi, AppRole as Bn, ApprovalWorkflowInput as Bo, UpdateProfileInput as Br, EntryKindChange as Bs, FillFieldType as Bt, WEBHOOK_EVENT_HEADER as C, DeploymentConnectionCreated as Ca, SNAPSHOT_SOURCES as Ci, MediaFocalPoint as Cn, CreateWorkspaceInput as Co, NetworkAction as Cr, ContentFilterValue as Cs, AltTextInput as Ct, WebhookSignatureCheck as D, DeploymentRun as Da, ShipChangeSetInput as Di, MediaUsagePage as Dn, SiteAppRoles as Do, Role as Dr, ContentSort as Ds, AssistStatus as Dt, WEBHOOK_TOLERANCE_SECONDS as E, DeploymentProvider as Ea, SchemaOperation as Ei, MediaUsage as En, Site as Eo, PermissionAction as Er, ContentPagination as Es, AssistProvider as Et, WorkspaceOption as F, DeploymentTriggerPolicy as Fa, Acknowledgement as Fi, UpdateMediaFolderInput as Fn, WorkspaceSummary as Fo, SetupInput as Fr, EditorManifest as Fs, ContentOpsSkip as Ft, resolveUploadUrl as G, PreviewTarget as Ga, DefinitionListItem as Gi, CreateAppRoleInput as Gn, UpdateWorkspaceChangeSetsInput as Go, ApprovalNoteInput as Gr, EntryPublishInput as Gs, SuggestInput as Gt, AdminApi as H, OpenPreviewResult as Ha, CreateLocaleInput as Hi, AppUserPage as Hn, SiteChangeSets as Ho, APPROVAL_STATUSES as Hr, EntryLocaleStatus as Hs, RewriteInput as Ht, resolveWorkspaceOption as I, JOB_STATUSES as Ia, ActiveDefinition as Ii, UploadGrant as In, APPROVAL_MODES as Io, SetupStatusResponse as Ir, EditorManifestItem as Is, ContentOpsStatus as It, SITE_HEADER as J, PublicationAction as Ja, DefinitionRevisionDetail as Ji, AcceptInvitationInput as Jn, DeliverySite as Jo, ApprovalStatus as Jr, ExtensionTheme as Js, SummarizeInput as Jt, toContentQueryString as K, PreviewToken as Ka, DefinitionPayload as Ki, UpdateAppRoleInput as Kn, WorkspaceChangeSets as Ko, ApprovalSignoff as Kr, EntryReferrer as Ks, SuggestResult as Kt, DeliveryClientOptions as L, Job as La, ChangeOutcome as Li, APP_CONTENT_ACTIONS as Ln, ApprovalMode as Lo, SiteAction as Lr, EntryAuthor as Ls, ContentOpsWritten as Lt, WorkspaceApi as M, DeploymentSecretsInput as Ma, SnapshotSource as Mi, MoveMediaAssetsResult as Mn, Workspace as Mo, RoleSummary as Mr, ContentTargetsQuery as Ms, ContentOpsResult as Mt, SITE_QUERY_PARAMETER as N, DeploymentSettings as Na, UnassignedEntry as Ni, ReplaceUploadInput as Nn, WorkspaceAppRoles as No, SITE_ACTIONS as Nr, CreateEntryInput as Ns, ContentOpsRule as Nt, WebhookSignatureInput as O, DeploymentRunQuery as Oa, ShipPhase as Oi, MediaVariant as On, SiteRef as Oo, RoleAssignment as Or, ContentTargetItem as Os, AssistTextResult as Ot, WORKSPACE_QUERY_PARAMETER as P, DeploymentTimelineEvent as Pa, UpdateChangeSetInput as Pi, UpdateMediaAssetInput as Pn, WorkspaceRef as Po, SessionStarted as Pr, DroppedField as Ps, ContentOpsRun as Pt, CheckParams as Q, ScheduledPublication as Qa, PlanImpact as Qi, AdminUserStatus as Qn, DeliveryComponent as Qo, ChangeSetApproval as Qr, UpdateEntryInput as Qs, WriteResult as Qt, ShapioDeliveryClient as R, JobQuery as Ra, ChangePlan as Ri, AdminAppUser as Rn, ApprovalStage as Ro, UpdateAdminUserInput as Rr, EntryData as Rs, FieldFillResult as Rt, AppUser as S, DeploymentConnection as Sa, ReviewSchemaItem as Si, MediaAssetStatus as Sn, CreateSiteInput as So, NETWORK_ACTIONS as Sr, ContentFilterOperator as Ss, AltProposal as St, WEBHOOK_TIMESTAMP_HEADER as T, DeploymentConnectionUpdated as Ta, SchemaDraft as Ti, MediaStorageDriver as Tn, SetWorkspaceAppRolesInput as To, PasswordResetRequestInput as Tr, ContentListQuery as Ts, AssistIssue as Tt, ASSIST_PATHS as U, PUBLICATION_ACTIONS as Ua, DefinitionCategory as Ui, AppUserQuery as Un, UpdateNetworkApprovalInput as Uo, AddChangeSetEntryInput as Ur, EntryLocalesInput as Us, SchemaDraftInput as Ut, DeliveryApi as V, OpenPreviewInput as Va, CreateDefinitionInput as Vi, AppRolePermission as Vn, NetworkApproval as Vo, UpdateRoleInput as Vr, EntryLocaleState as Vs, LocaleMissingResult as Vt, buildUploadForm as W, Page as Wa, DefinitionDetail as Wi, BUILT_IN_APP_ROLE_KEYS as Wn, UpdateSiteChangeSetsInput as Wo, ApprovalIneligibleReason as Wr, EntryPublication as Ws, SchemaDraftResult as Wt, APPROVAL_PATHS as X, ScheduleQuery as Xa, DeleteLocaleResult as Xi, AdminUser as Xn, SeoFields as Xo, ChangeSet as Xr, RevisionDetail as Xs, TranslateResult as Xt, WORKSPACE_HEADER as Y, SCHEDULE_STATUSES as Ya, DefinitionScope as Yi, AdminSession as Yn, DeliveryWorkspace as Yo, CHANGE_SET_STATUSES as Yr, ExtensionThemeList as Ys, TranslateInput as Yt, ADMIN_PATHS as Z, ScheduleStatus as Za, Locale as Zi, AdminUserApiToken as Zn, SeoResolved as Zo, ChangeSetActor as Zr, RevisionSummary as Zs, WriteInput as Zt, AppLoginInput as _, CreateScheduleInput as _a, NotRestorableReason as _i, CreateMediaFolderInput as _n, OlderClients as _o, Invitation as _r, AdminEntry as _s, PresenceHeartbeatInput as _t, SeoDefaults as a, SchemaChangeResult as aa, ChangeSetReview as ai, HealthResponse as an, WebhookEventBody as ao, ChangePasswordInput as ar, DeliveryList as as, ContentHealthSummary as at, AppRegisterResult as b, DEPLOYMENT_RUN_STATUSES as ba, ReviewEntryItem as bi, MediaAssetPage as bn, SchemaVersionsResponse as bo, LoginInput as br, ChangeEntryKindInput as bs, AcceptContentOpsResult as bt, applyTitleTemplate as c, SchemaSummary as ca, ChangeSetStatus as ci, CurrentSnapshot as cn, FieldPrincipalUsage as co, CreateRoleInput as cr, DeliveryMeta as cs, EntryPresence as ct, AppPkcePair as d, UpdateDefinitionInput as da, CreateChangeSetInput as di, SnapshotChangesPage as dn, LensEffect as do, DELIVERY_ACTIONS as dr, RichTextMode as ds, ModelPresence as dt, PlanStep as ea, RequestOptions as ec, ChangeSetEntryItem as ei, ShapioErrorBody as en, UpdateWebhookInput as eo, AuditActorType as er, DeliveryEntry as es, ContentCount as et, codeChallengeOf as f, UpdateLocaleInput as fa, FieldConsumer as fi, SnapshotChangesQuery as fn, ModelFieldUsage as fo, DeliveryAction as fr, SeoMode as fs, PreflightCheck as ft, AppChangePasswordInput as g, CreatePreviewTokenInput as ga, NotRestorable as gi, SchemaSyncResult as gn, OlderClientVersion as go, InspectInvitationResponse as gr, SchemaVersionMeta as gs, PreflightRule as gt, AppAuthApi as h, CreateDeploymentConnectionInput as ha, NOT_RESTORABLE_REASONS as hi, SchemaExport as hn, OlderClientReader as ho, GlobalAction as hr, SCHEMA_VERSION_QUERY_PARAMETER as hs, PreflightResponse as ht, SEO_FIELD_IDS as i, SchemaChangeJob as ia, shapioTags as ic, ChangeSetQuery as ii, CheckStatus as in, WebhookDeliveryStatus as io, CONTENT_ACTIONS as ir, DeliveryKind as is, ContentHealthQuery as it, SiteApi as j, DeploymentSecretState as ja, SnapshotQuery as ji, MoveMediaAssetsInput as jn, UpdateWorkspaceInput as jo, RolePermission as jr, ContentTargets as js, ContentOpsInput as jt, verifyWebhookSignature as k, DeploymentRunStatus as ka, Snapshot as ki, MediaVariantStatus as kn, SiteSummary as ko, RoleCondition as kr, ContentTargetKind as ks, AssistUsage as kt, resolveSeo as l, SchemaSummaryItem as la, ChangeSetSummary as li, SnapshotChange as ln, FieldUsageQuery as lo, CreatedApiToken as lr, DeliveryPagination as ls, HEALTH_RULES as lt, APP_AUTH_PATHS as m, ConnectionTestResult as ma, FieldDiff as mi, SchemaApplyResult as mn, OlderClientField as mo, GLOBAL_ACTIONS as mr, SCHEMA_VERSION_HEADER as ms, PreflightLocale as mt, ResolveSeoContext as n, PlanUpdateInput as na, NextCacheMode as nc, ChangeSetItem as ni, ShapioClientOptions as nn, WebhookAttempt as no, AuditPage as nr, DeliveryGetQuery as ns, ContentHealthFinding as nt, SeoKeys as o, SchemaChangeStatus as oa, ChangeSetSchemaItem as oi, ReadyResponse as on, WebhookEventType as oo, ContentAction as or, DeliveryListQuery as os, DraftState as ot, createPkcePair as p, UpdateSchemaSettingsInput as pa, FieldConsumers as pi, SchemaApplyInput as pn, OlderClientDefinition as po, EmailDelivery as pr, SCHEMA_VERSION_CURRENT_HEADER as ps, PreflightInput as pt, SITES_PATHS as q, PreviewTokenCreated as qa, DefinitionRevision as qi, UpdateAppUserInput as qn, DeliveryAsset as qo, ApprovalStageState as qr, EntryStatus as qs, SuggestedValue as qt, SEO_COMPONENT_ID as r, RequiredGap as ra, NextCacheOptions as rc, ChangeSetItemStatus as ri, createClient as rn, WebhookDelivery as ro, AuditQuery as rr, DeliveryItem as rs, ContentHealthPage as rt, SeoLocaleDefaults$1 as s, SchemaSettings as sa, ChangeSetSource as si, VersionResponse as sn, WebhookWithSecret as so, CreateApiTokenInput as sr, DeliveryMember as ss, EntryHeartbeat as st, DEFAULT_SEO_KEYS as t, PlanStepImpact as ta, DeliveryReadOptions as tc, ChangeSetError as ti, ShapioClient as tn, Webhook as to, AuditEvent as tr, DeliveryEntryAttributes as ts, ContentCounts as tt, seoDefaultsForLocale as u, SetDefaultLocaleResult as ua, ChangeSetTimelineEvent as ui, SnapshotChangeKind as un, FieldUsageResponse as uo, CsrfResponse as ur, DeliveryZoneItem as us, HealthRule as ut, AppOAuthProvider as v, CreateWebhookInput as va, PutSchemaDraftInput as vi, CreateUploadInput as vn, PrincipalUsageSummary as vo, InvitationLink as vr, AdminEntryListItem as vs, PresencePerson as vt, WEBHOOK_SIGNATURE_HEADER as w, DeploymentConnectionSummary as wa, ScheduleChangeSetInput as wi, MediaFolder as wn, SetSiteAppRolesInput as wo, PasswordResetConfirmInput as wr, ContentIssue as ws, AltTextResult as wt, AppSession as x, DEPLOYMENT_TRIGGERS as xa, ReviewIssue as xi, MediaAssetQuery as xn, UsageSelection as xo, MeResponse as xr, ContentFilter as xs, AltMissingResult as xt, AppRegisterInput as y, DEPLOYMENT_PROVIDERS as ya, RequestChangesInput as yi, MediaAsset as yn, SchemaVersionReader as yo, InviteUserInput as yr, AdminEntryPage as ys, AcceptContentOpsInput as yt, createDeliveryClient as z, JobStatus as za, ChangeScopeInput as zi, AppContentAction as zn, ApprovalWorkflow as zo, UpdateApiTokenInput as zr, EntryHistory as zs, FieldProposal as zt }; //# sourceMappingURL=index-CK_22ZPr.d.ts.map