import { RecordsDataSource, RecordsConfig } from '../core/index.js'; import { TemplateSpec } from '../templates/index.js'; import { PgError } from '../core/index.js'; import '../field-IlJ97y8H.js'; import '../subscription-DSnIFqdB.js'; import '../rule-CMApHawk.js'; import '../types-aLlrbaFC.js'; type Json$1 = Record; /** One presented column, exactly as `platform.drill_describe(...).api.columns[]` says it. */ interface MemoryEntityColumn { api_name: string; name: string; /** "text" | "number" | "choice" | "date" | "datetime" | "checkbox" | … */ type: string; writable?: boolean; choices?: string[]; /** A column shown as the words another table holds (`replaces`: the id column itself). */ lookup?: { via: string; token: string; column: string; replaces: boolean; }; } interface MemoryEntitySpec { token: string; label: string; columns: MemoryEntityColumn[]; /** Rows as the door returns them: `id` plus api_name → value, lookups and choices in words. */ rows: Json$1[]; /** * The token's API fact `create_via` (`api.create_via`): `"insert"` lets `entity_row_write` with no * record id add a row (task and project since chairblk3_a); absent or `"refuse"` refuses, as live. */ create_via?: "insert" | "refuse"; } interface MemoryEntity extends MemoryEntitySpec { rows: Json$1[]; } type Answer = { data: unknown; error: null; } | { data: null; error: { code: string; message: string; details: null; hint: string | null; }; }; /** What `drill_describe` answers for a memory entity (dimensions from its choices, count + sums). */ declare function memoryEntityDescribe(e: MemoryEntity): Json$1; /** What `drill_rows` answers: one page, rows in words. */ declare function memoryEntityRows(e: MemoryEntity, question: Json$1): Json$1; /** * What `drill_ask` answers for a memory entity: one row per group of the asked Dimensions (a choice * or a lookup, both already words here), then the `total` row; `count`, `sum_` and ad hoc * `{op, of}` measures keyed `_` exactly as the live door keys them; `where` narrows first. */ declare function memoryEntityAsk(e: MemoryEntity, question: Json$1): Json$1[]; /** What `entity_row_write` does: a choice by its word (any case), refused in the door's words otherwise. */ declare function memoryEntityWrite(e: MemoryEntity, recordId: string, columns: Json$1): Answer; /** * What `entity_row_write` does with NO record id (chairblk3_a): a token whose `create_via` is * `"insert"` gets one new row in the organization the call names, from the writable columns only, * a name required where the token has one; every other token refuses in the live door's words. */ declare function memoryEntityCreate(e: MemoryEntity, organizationId: string | null, columns: Json$1): Answer; type Json = Record; /** The ids the store's kernel tables carry everywhere (custom.table_kernel_id() and its siblings). */ declare const MEMORY_KERNEL: { readonly table: "11111111-0000-4000-8000-000000000001"; readonly field: "11111111-0000-4000-8000-000000000002"; readonly person: "11111111-0000-4000-8000-000000000005"; readonly file: "11111111-0000-4000-8000-000000000006"; readonly rule: "11111111-0000-4000-8000-000000000003"; }; /** One stable uuid-shaped id per name (FNV-1a over the name, four lanes). */ declare function stableId(name: string): string; interface MemoryField { id: string; table_id: string; data: Json; } interface MemoryOption { id: string; key: string; label: string; color: string | null; } interface MemoryTable { id: string; token: string; /** The Table's declaration as the table kernel holds it. */ document: Json; fields: MemoryField[]; /** Field key → its choices, in order. */ options: Map; /** Record id → its stored document (choice cells hold the option KEY, relations hold record ids). */ rows: Map; /** Insertion order, which is the template's own row order. */ order: string[]; } interface MemoryView { view_id: string; token: string; table_id: string; name: string; definition: Json; filters: Json; } interface MemoryForm { form_id: string; token: string; table_id: string; title: string; questions: Json[]; presentation: Json; booking: Json | null; /** True once an anon_publish step opened it (a declared form is a draft until then). */ published?: boolean; } interface MemoryDashboard { dashboard_id: string; token: string; table_id: string; name: string; blocks: Json[]; } interface MemoryWorld { organization_id: string; user_id: string; /** The business's IANA zone. */ timezone: string; today: string; businessName: string; tables: MemoryTable[]; tableById: Map; views: MemoryView[]; forms: MemoryForm[]; dashboards: MemoryDashboard[]; /** Every record id → the table it belongs to. */ recordTable: Map; /** Table id → the field key that is its pipeline stage. */ stageField: Map; /** TEMPLATE-GAPS R3b: row templates (custom.row_template_declare), values as written (relative dates kept). */ rowTemplates?: Array<{ template_id: string; table_id: string; name: string; values: Json; body: Json | null; default: boolean; }>; /** Standard sources (`{ kind: "entity", token }`) this world answers — `withEntities`. */ entities?: Map; } interface TemplateWorldOptions { /** "YYYY-MM-DD" the template's relative dates resolve against. Default: today (UTC). */ today?: string; /** * TEMPLATE-FRESH: preview a fresh copy (custom.template_install_fresh): every table is named " · " * and every id is the copy's own, so two copies of one template never share a table, row or column. */ instance?: { title: string; no?: number; }; } /** * Walk the template's install plan into memory. Pure: the same spec and day give the same world. */ declare function templateWorld(spec: TemplateSpec, options?: TemplateWorldOptions): MemoryWorld; /** What a member chip names the preview's own viewer (the live store answers the installer's own name). */ declare const PREVIEW_VIEWER_NAME = "You"; /** What every write door answers in a preview. */ declare const PREVIEW_REFUSAL: PgError; /** The memory store, as the seam every records-ui screen reads through. */ declare function memoryDataSource(world: MemoryWorld): RecordsDataSource & { readonly world: MemoryWorld; }; /** Add standard sources (`{ kind: "entity", token }`) to a memory world, in the live doors' shapes. */ declare function withEntities(world: MemoryWorld, specs: MemoryEntitySpec[]): MemoryWorld; interface TemplatePreview { /** Mount this: `<RecordsMount config={preview.config}>` / `<RecordsProvider config={preview.config}>`. */ config: RecordsConfig; world: MemoryWorld; /** The template's tables in its own order: id (for `TablePage`), token, name. */ tables: Array<{ id: string; token: string; name: string; rows: number; }>; forms: Array<{ id: string; token: string; title: string; tableId: string; booking: boolean; }>; dashboards: Array<{ id: string; token: string; name: string; tableId: string; }>; } /** A template, installed into memory and ready to mount. Pure for a given spec and day. */ declare function templatePreview(spec: TemplateSpec, options?: TemplateWorldOptions): TemplatePreview; /** A memory store holding only standard sources — mount it like a template preview. */ declare function entityStore(specs: MemoryEntitySpec[], options?: { today?: string; }): { config: RecordsConfig; world: MemoryWorld; }; export { MEMORY_KERNEL, PREVIEW_REFUSAL, PREVIEW_VIEWER_NAME, entityStore, memoryDataSource, memoryEntityAsk, memoryEntityCreate, memoryEntityDescribe, memoryEntityRows, memoryEntityWrite, stableId, templatePreview, templateWorld, withEntities }; export type { MemoryDashboard, MemoryEntity, MemoryEntityColumn, MemoryEntitySpec, MemoryField, MemoryForm, MemoryOption, MemoryTable, MemoryView, MemoryWorld, TemplatePreview, TemplateWorldOptions };