@geonosis/document 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  export { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { EntityColumns, EntityName, SessionSettings, EntityMigration, Entity, Executor, Query, EntityUndo, SessionSeam } from '@geonosis/db';
3
+ import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, Projection, Executor, Query, EntityListing, EntityPage, EntityUndo, SessionSeam } from '@geonosis/db';
4
4
  export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
5
5
 
6
6
  declare const BODY_VERSION_KEY = "_v";
@@ -76,7 +76,7 @@ type DocumentRecord = {
76
76
  updatedAt: number;
77
77
  };
78
78
  /** What an entity decides when it extends `Document`; every side effect is written once over these. */
79
- type DocumentDefinition<Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string> = {
79
+ type DocumentDefinition<Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string, ViewSchema extends StandardSchemaV1 = BodySchema> = {
80
80
  name: Name;
81
81
  noun: string;
82
82
  basePath: Path;
@@ -108,6 +108,8 @@ type DocumentDefinition<Name extends string, BodySchema extends StandardSchemaV1
108
108
  counterpartyName: string;
109
109
  }) => StandardSchemaV1.InferOutput<CardSchema>;
110
110
  };
111
+ /** What a single-document read RENDERS — absent, the body a consumer already declared. */
112
+ view?: ViewSchema;
111
113
  };
112
114
  /** A stored document of one entity: the head every document has, the record's clocks, its body. */
113
115
  type DocumentInstance<Name extends string, Body> = DocumentHead & DocumentRecord & {
@@ -115,10 +117,11 @@ type DocumentInstance<Name extends string, Body> = DocumentHead & DocumentRecord
115
117
  number: string;
116
118
  body: Body;
117
119
  };
118
- type DocumentEntity<Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string> = DocumentDefinition<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path> & {
120
+ type DocumentEntity<Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string, ViewSchema extends StandardSchemaV1 = BodySchema> = DocumentDefinition<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path, ViewSchema> & {
119
121
  is: (document: {
120
122
  entity: string;
121
123
  }) => document is DocumentInstance<Name, StandardSchemaV1.InferOutput<BodySchema>>;
124
+ view: ViewSchema;
122
125
  };
123
126
  /**
124
127
  * The abstract Document. Never stored as itself — a consumer's entities extend it, and everything
@@ -141,15 +144,16 @@ declare const Document: {
141
144
  readonly createdAt: "int";
142
145
  readonly updatedAt: "int";
143
146
  };
144
- extend: <Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string>(definition: DocumentDefinition<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path>) => DocumentEntity<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path>;
147
+ extend: <Name extends string, BodySchema extends StandardSchemaV1, DraftSchema extends StandardSchemaV1, IncomingSchema extends StandardSchemaV1, Status extends string, CardSchema extends StandardSchemaV1, Path extends string, ViewSchema extends StandardSchemaV1 = BodySchema>(definition: DocumentDefinition<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path, ViewSchema>) => DocumentEntity<Name, BodySchema, DraftSchema, IncomingSchema, Status, CardSchema, Path, ViewSchema>;
145
148
  };
146
- type Parts<Entity> = Entity extends DocumentDefinition<infer Name, infer BodySchema, infer DraftSchema, infer IncomingSchema, infer Status, infer CardSchema, infer _Path> ? {
149
+ type Parts<Entity> = Entity extends DocumentDefinition<infer Name, infer BodySchema, infer DraftSchema, infer IncomingSchema, infer Status, infer CardSchema, infer _Path, infer ViewSchema> ? {
147
150
  name: Name;
148
151
  body: StandardSchemaV1.InferOutput<BodySchema>;
149
152
  draft: StandardSchemaV1.InferOutput<DraftSchema>;
150
153
  incoming: StandardSchemaV1.InferOutput<IncomingSchema>;
151
154
  status: Status;
152
155
  card: StandardSchemaV1.InferOutput<CardSchema>;
156
+ view: StandardSchemaV1.InferOutput<ViewSchema>;
153
157
  } : never;
154
158
  type NameOf<Entity> = Parts<Entity>['name'];
155
159
  type BodyOf<Entity> = Parts<Entity>['body'];
@@ -157,6 +161,7 @@ type DraftOf<Entity> = Parts<Entity>['draft'];
157
161
  type IncomingOf<Entity> = Parts<Entity>['incoming'];
158
162
  type StatusOf<Entity> = Parts<Entity>['status'];
159
163
  type CardOf<Entity> = Parts<Entity>['card'];
164
+ type ViewOf<Entity> = Parts<Entity>['view'];
160
165
  type InstanceOf<Entity> = DocumentInstance<NameOf<Entity>, BodyOf<Entity>>;
161
166
 
162
167
  /**
@@ -175,6 +180,7 @@ type AnyDocumentEntity = {
175
180
  schema: StandardSchemaV1;
176
181
  };
177
182
  name: string;
183
+ view: StandardSchemaV1;
178
184
  };
179
185
  /**
180
186
  * `documentEntities(map)`: every entity that extends `Document`, by the name its rows carry.
@@ -194,6 +200,7 @@ declare const documentEntities: <Map extends Readonly<Record<string, AnyDocument
194
200
  }) => DocumentInstance<Name, InstanceOf<Map[Name]>["body"]>;
195
201
  named: <Name extends keyof Map & string>(name: Name) => Map[Name];
196
202
  names: readonly (keyof Map & string)[];
203
+ views: StandardSchemaV1[];
197
204
  };
198
205
 
199
206
  /** An unattended write's principal — `systemActor('recurring.generate')` — never a bare `'system'`. */
@@ -240,129 +247,98 @@ type TimestampPort = {
240
247
  token: Uint8Array;
241
248
  }>;
242
249
  };
250
+ type LinkVerifierPort = {
251
+ verify: (token: string) => Promise<{
252
+ entity: string;
253
+ exp: number;
254
+ org: string;
255
+ ref: string;
256
+ } | null>;
257
+ };
243
258
 
244
259
  declare const DEFAULT_DOCUMENT_TABLE = "documents";
245
260
  declare const DEFAULT_REVISIONS_TABLE = "document_revisions";
246
261
  declare const DEFAULT_REVISION_KIND_COLUMN = "revision_kind";
262
+ type HeadField = keyof DocumentHead;
263
+ declare const HEAD_FIELDS: HeadField[];
247
264
  type DocumentColumns = EntityColumns & {
248
- /** The discriminator column two entities on one table disagree on. `'entity'` when unnamed. */
249
265
  entity?: string;
250
- /**
251
- * The log's own `committed | retired | reinstated` column. `'revision_kind'` when unnamed —
252
- * never `'kind'`, the name the kit's own docs use for `entity`, and a consumer who follows that
253
- * convention would otherwise declare one physical column twice (#407).
254
- */
266
+ heads?: Partial<Record<HeadField, EntityName>>;
255
267
  revisionKind?: string;
256
- /** The physical column `heads`/`aggregate` read `total` off. `'total'` when unnamed. */
257
268
  total?: EntityName;
258
269
  };
259
- /** The log — the append-only record of truth. `false` opts a consumer out of it entirely. */
270
+ type DocumentPhysicalColumns = Readonly<Record<HeadField, string>> & {
271
+ createdAt: string;
272
+ entity: string;
273
+ tenant: string;
274
+ updatedAt: string;
275
+ };
276
+ declare const physicalColumnsOf: (columns: DocumentColumns | undefined) => DocumentPhysicalColumns;
260
277
  type DocumentRevisionsOptions = {
261
278
  table?: string;
262
279
  };
263
280
  type DocumentMigrationsOptions = {
264
- /**
265
- * The role a consumer's application connects as — the log's `revoke update, delete` and its
266
- * trigger are rendered for THIS name, and nothing here can pick it: it belongs to whoever runs
267
- * the database (`@geonosis/db`'s own `appRoleStatements`, the same law). Required whenever the
268
- * log is on (the default); irrelevant when `revisions: false`.
269
- */
270
281
  appRole?: string;
271
282
  columns?: DocumentColumns;
272
- /** On by default (`document_revisions`); `false` renders none of it. */
283
+ freeze?: FreezeRegister;
284
+ names?: TenantPolicyNames;
273
285
  revisions?: DocumentRevisionsOptions | false;
274
286
  schema?: string;
275
287
  settings: SessionSettings;
276
288
  table?: string;
277
289
  };
278
290
  type AppendOnlyTablesOptions = {
279
- /** Shorthand for `revisions.table` — ignored once `revisions` also names one. */
280
291
  table?: string;
281
- /** On by default (`document_revisions`); `false` names nothing — nothing here is append-only. */
282
292
  revisions?: DocumentRevisionsOptions | false;
283
293
  };
284
- /**
285
- * The tables this domain declares append-only — the names `@geonosis/db`'s `appRoleStatements`
286
- * takes as `appendOnly` so its blanket grant excludes them, and `documentRoleStatements` below
287
- * takes the same way for a consumer that provisions its role by hand.
288
- */
289
294
  declare const appendOnlyTables: (options?: AppendOnlyTablesOptions) => string[];
290
- /**
291
- * The log's own wall, standalone — for a consumer that provisions its application role outside
292
- * `@geonosis/db`'s `appRoleStatements` (a hosted provider's own role, for instance). Run this AFTER
293
- * the role exists; the revoke targets a table `documentMigrations` must already have created.
294
- */
295
295
  declare const documentRoleStatements: (appRole: string, options?: AppendOnlyTablesOptions & {
296
296
  schema?: string;
297
297
  }) => string[];
298
- /**
299
- * `documentMigrations` = `entityMigrations` over the seven head columns, the constants column that
300
- * discriminates one document entity's rows from another's on the SAME table, and the version
301
- * column `UpsertOutput.replaced` reads. One extra index this table needs that no per-column
302
- * `sortable` index gives it: `(entity, issueDate)`, the predicate every read named in the brief
303
- * narrows by — STATUS BREAKDOWN, TIME SERIES, COUNT BY ENTITY, RECENT, HEADS FOR MATCHING all
304
- * start `kind = <entity> and issueDate between …`. The revisions table and its wall follow, unless
305
- * a consumer opts out.
306
- */
307
298
  declare const documentMigrations: (options: DocumentMigrationsOptions) => EntityMigration[];
308
299
 
309
- /**
310
- * What `documentStore` needs off an entity beyond `documentEntities`'s own minimal bound: the head
311
- * derivation, the write-time preparation, and the entity's own body versioning. The registry's
312
- * `AnyDocumentEntity` stays as narrow as `documentEntities` itself needs — this is the store's own
313
- * bound, never a widening of that one.
314
- */
315
300
  type StorableDocumentEntity = AnyDocumentEntity & {
316
301
  bodyVersion?: number;
317
302
  headOf: (body: never) => DocumentHead;
318
303
  migrations?: DocumentBodyMigrations<Record<string, unknown>>;
319
304
  prepare: (body: never) => unknown;
320
305
  };
321
- type Registry<Map extends Readonly<Record<string, StorableDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
306
+ type Registry$1<Map extends Readonly<Record<string, StorableDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
322
307
  type DocumentStoreOptions<Map extends Readonly<Record<string, StorableDocumentEntity>>, Key extends string> = {
323
- /**
324
- * Copied after `commit`'s own transaction has already committed — never inside it, so a failed
325
- * put is reported in the answer (`archived: false`) rather than rolling back a write the log
326
- * already has durably. The mirror workflow (a later ticket) is what retries it.
327
- */
328
308
  archive?: ArchivePort;
329
309
  columns?: DocumentColumns;
330
- registry: Registry<Map>;
331
- /** The append-only log. On by default (`document_revisions`); `false` opts out. */
310
+ registry: Registry$1<Map>;
332
311
  revisions?: DocumentRevisionsOptions | false;
333
312
  schema?: string;
334
313
  seam: SessionSeam<Key, Executor>;
335
314
  table?: string;
336
315
  };
337
- type HeadColumn = keyof DocumentHead | 'entity' | 'number';
316
+ type HeadColumn = HeadField | 'entity' | 'number';
317
+ type DocumentSortColumn = HeadField | 'createdAt' | 'number' | 'updatedAt';
338
318
  type HeadsOrder = {
339
- column: HeadColumn;
319
+ column: DocumentSortColumn | 'entity';
340
320
  direction?: 'asc' | 'desc';
341
321
  };
342
- type HeadsWhere = {
343
- createdAt?: readonly [number, number];
344
- status?: string;
345
- };
346
- type HeadsArgs = {
347
- columns: readonly HeadColumn[];
348
- /** One entity, or a set — RECENT's own read narrows `kind IN ($kinds)`, never one kind alone. */
322
+ type HeadsWhere = Readonly<Partial<Record<HeadField | 'createdAt' | 'updatedAt', unknown | readonly unknown[] | {
323
+ from: unknown;
324
+ to: unknown;
325
+ }>>>;
326
+ type HeadRow<Columns extends readonly HeadColumn[]> = Pick<DocumentHead & {
327
+ entity: string;
328
+ number: string;
329
+ }, Columns[number]>;
330
+ type HeadsArgs<Columns extends readonly HeadColumn[] = readonly HeadColumn[]> = {
331
+ columns: Columns;
349
332
  entity?: string | readonly string[];
350
- /** Every column a page is ordered by, the tie-break included — HEADS FOR MATCHING orders by `kind, number`. */
351
333
  order: readonly HeadsOrder[];
352
334
  where?: HeadsWhere;
353
335
  };
354
336
  type AggregateMeasure = 'count' | 'sum:total';
355
- type AggregateBy = 'entity' | 'status' | {
337
+ type AggregateBy = HeadField | 'entity' | {
356
338
  bucket: 'day' | 'month' | 'week';
357
- of: 'issueDate';
339
+ of: 'dueDate' | 'issueDate';
358
340
  };
359
- type AggregateWhere = {
360
- status?: string;
361
- } & ({
362
- createdAt: readonly [number, number];
363
- } | {
364
- issueDate: readonly [string, string];
365
- } | Record<string, never>);
341
+ type AggregateWhere = HeadsWhere;
366
342
  type AggregateRow = {
367
343
  by?: string;
368
344
  count?: number;
@@ -375,7 +351,6 @@ type AggregateArgs = {
375
351
  measures: readonly AggregateMeasure[];
376
352
  where?: AggregateWhere;
377
353
  };
378
- type SortableHeadColumn = keyof DocumentHead;
379
354
  type Item = DocumentInstance<string, unknown>;
380
355
  type DocumentKind = 'committed' | 'reinstated' | 'retired';
381
356
  type CommitOutput = {
@@ -387,7 +362,6 @@ type CommitOutput = {
387
362
  ref: string;
388
363
  version: number;
389
364
  } | {
390
- /** Present only when `documentStore({ archive })` names a port — absent, nothing tried. */
391
365
  archived?: boolean;
392
366
  committed: true;
393
367
  hash: string;
@@ -429,42 +403,36 @@ type VerifyResult = {
429
403
  ok: true;
430
404
  versions: number;
431
405
  };
432
- type DocumentEntityStore<Key extends string> = Pick<Entity<unknown, Item, Key, 'ref', Executor, SortableHeadColumn, SortableHeadColumn>, 'get' | 'list' | 'listAll'> & {
433
- /** The latest revision whose `at` is at or before the instant — the current lineage only. */
406
+ type DocumentEntityStore<Key extends string> = Pick<Projection<unknown, Item, Key, 'ref', Executor, string, string>, 'get' | 'listAll'> & {
434
407
  asOf: Query<Readonly<Record<Key, string>> & {
435
408
  at: number;
436
409
  ref: string;
437
410
  }, Item | null, Executor>;
438
- /** `ref`'s revision at that exact version — the current lineage only. */
439
411
  at: Query<Readonly<Record<Key, string>> & {
440
412
  ref: string;
441
413
  version: number;
442
414
  }, Item | null, Executor>;
443
- /** The ONE write verb: appends an immutable revision, updates the projection, one transaction. */
444
415
  commit: Query<Readonly<Record<Key, string>> & {
445
416
  actor: string;
446
417
  body: unknown;
447
418
  reason?: string;
448
419
  ref: string;
449
420
  }, CommitOutput, Executor>;
450
- /** Every revision of one lineage, by version — the archive's own read. */
451
421
  history: Query<Readonly<Record<Key, string>> & {
452
422
  lineage?: number;
453
423
  ref: string;
454
424
  }, HistoryEntry[], Executor>;
455
- /** Un-retires the SAME lineage — never a new one (`succeed` is that door). */
425
+ list: Query<Readonly<Record<Key, string>> & EntityListing<DocumentSortColumn, HeadField>, EntityPage<Item>, Executor>;
456
426
  reinstate: Query<Readonly<Record<Key, string>> & {
457
427
  actor: string;
458
428
  reason?: string;
459
429
  ref: string;
460
430
  }, ReinstateOutput, Executor>;
461
- /** `retire`: a commit of kind `retired` — refuses a document already retired. */
462
431
  retire: Query<Readonly<Record<Key, string>> & {
463
432
  actor: string;
464
433
  reason?: string;
465
434
  ref: string;
466
435
  }, RetireOutput, Executor>;
467
- /** Opens a NEW lineage for a `ref` whose document is dead — the old lineage stays in full. */
468
436
  succeed: Query<Readonly<Record<Key, string>> & {
469
437
  actor: string;
470
438
  body: unknown;
@@ -475,7 +443,6 @@ type DocumentEntityStore<Key extends string> = Pick<Entity<unknown, Item, Key, '
475
443
  commit: EntityUndo<CommitOutput, Executor>;
476
444
  retire: EntityUndo<RetireOutput, Executor>;
477
445
  };
478
- /** Recomputes every hash of one lineage from version 1 — tamper-evidence, on demand. */
479
446
  verify: Query<Readonly<Record<Key, string>> & {
480
447
  lineage?: number;
481
448
  ref: string;
@@ -485,22 +452,84 @@ type DocumentStore<Map extends Readonly<Record<string, StorableDocumentEntity>>,
485
452
  [Name in keyof Map & string]: DocumentEntityStore<Key>;
486
453
  } & {
487
454
  aggregate: Query<Readonly<Record<Key, string>> & AggregateArgs, AggregateRow[], Executor>;
488
- heads: Query<Readonly<Record<Key, string>> & HeadsArgs, Readonly<Record<string, unknown>>[], Executor>;
489
- /** Rewrites the projection from the log — an exam's own rebuild, and a consumer's repair tool. */
455
+ heads: <Columns extends readonly HeadColumn[]>(handle: Executor, params: Readonly<Record<Key, string>> & HeadsArgs<Columns>) => Promise<HeadRow<Columns>[]>;
490
456
  rebuild: Query<Readonly<Record<Key, string>> & {
491
457
  entity?: string;
492
458
  }, {
493
459
  rows: number;
494
460
  }, Executor>;
495
461
  };
462
+ declare const documentStore: <Map extends Readonly<Record<string, StorableDocumentEntity>>, Key extends string>(options: DocumentStoreOptions<Map, Key>) => DocumentStore<Map, Key>;
463
+
464
+ type SurfaceVerb = 'query' | 'mutation';
465
+ type SurfaceScope = 'org' | 'public' | 'token';
466
+ /** The row's own declaration of what a workflow (not yet landed) will bind it to. */
467
+ type PendingCall = {
468
+ pending: 'T3';
469
+ workflow: string;
470
+ };
496
471
  /**
497
- * `documentStore`: one physical table for every document entity, the log beside it, `heads` and
498
- * `aggregate` beside that.
499
- *
500
- * Every per-entity fact is read off the registry by `fold`/`named` — never a map this function
501
- * fills in itself. `heads`/`aggregate` are the only readers of the physical column names; a caller
502
- * reaches them by the vocabulary `Document.headFields` already gave it, `entity` and `ref` beside.
472
+ * A row as a caller calls it — the entity's own signature (D-065's `ref`, never `number`) with a
473
+ * leading handle, the same convention `BoundQuery` already states in `@geonosis/workflows`, made
474
+ * explicit here since a row is DATA before it is a function: reading `params.ref` off `never`
475
+ * compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
503
476
  */
504
- declare const documentStore: <Map extends Readonly<Record<string, StorableDocumentEntity>>, Key extends string>(options: DocumentStoreOptions<Map, Key>) => DocumentStore<Map, Key>;
477
+ type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
478
+ type SurfaceRow = {
479
+ call: PendingCall | SurfaceCall;
480
+ input: StandardSchemaV1;
481
+ name: string;
482
+ output: StandardSchemaV1;
483
+ path: string;
484
+ scope: SurfaceScope;
485
+ verb: SurfaceVerb;
486
+ };
487
+ /**
488
+ * The three builders a validator library supplies so the table stays library-free (#383) while the
489
+ * union/enum/object it derives are still real schemas of THAT library — the one place a consumer's
490
+ * zod enters `@geonosis/document` is through this adapter, never a direct dependency.
491
+ */
492
+ type SurfaceSchemaAdapter = {
493
+ enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
494
+ object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
495
+ union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
496
+ };
497
+ /**
498
+ * What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
499
+ * what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
500
+ * caller never sees two overlapping bounds for the one registry it built.
501
+ */
502
+ type SurfaceDocumentEntity = AnyDocumentEntity & {
503
+ basePath: string;
504
+ bodyVersion?: number;
505
+ card: {
506
+ of: (document: never, names: {
507
+ counterpartyName: string;
508
+ }) => unknown;
509
+ schema: StandardSchemaV1;
510
+ };
511
+ draft: StandardSchemaV1;
512
+ headOf: (body: never) => DocumentHead;
513
+ migrations?: DocumentBodyMigrations<Record<string, unknown>>;
514
+ prepare: (body: never) => unknown;
515
+ statusOf: (body: never) => string;
516
+ statuses: DocumentStatusMachine<string>;
517
+ withStatus: (body: never, status: string, at: string) => unknown;
518
+ };
519
+ type Registry<Map extends Readonly<Record<string, SurfaceDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
520
+ type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string> = {
521
+ registry: Registry<Map>;
522
+ schema: SurfaceSchemaAdapter;
523
+ store: DocumentStore<Map, Key>;
524
+ };
525
+ /**
526
+ * `documentSurface({ registry, store, schema })`: the table every tRPC/REST/MCP mount is derived
527
+ * from — never authored by hand, and never a map a caller fills in per entity (#383). Reads and
528
+ * `commit`/`retire`/`reinstate`/`setStatus` bind `call` to the store already composed; the saga
529
+ * rows (`create`, `send`, `duplicate`, `run-started`) are declared with their own input/output and
530
+ * a `{ pending: 'T3', workflow }` in place of `call` — an adapter mounting the table refuses those
531
+ * BY NAME, never with a stub answer.
532
+ */
533
+ declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string>(options: DocumentSurfaceOptions<Map, Key>) => SurfaceRow[];
505
534
 
506
- export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type AggregateRow, type AggregateWhere, type AnyDocumentEntity, type AppendOnlyTablesOptions, type ArchivePort, BODY_VERSION_KEY, type BodyOf, type CardOf, type CommitOutput, DEFAULT_DOCUMENT_TABLE, DEFAULT_REVISIONS_TABLE, DEFAULT_REVISION_KIND_COLUMN, Document, type DocumentBodyMigrations, type DocumentBodyVersion, type DocumentColumns, type DocumentDefinition, type DocumentEntity, type DocumentHead, type DocumentInstance, type DocumentKind, type DocumentMigrationsOptions, type DocumentNumbering, type DocumentRecord, type DocumentRevisionsOptions, type DocumentStatusMachine, type DocumentStore, type DocumentStoreOptions, type DraftOf, type FieldKind, type HeadColumn, type HeadsArgs, type HeadsOrder, type HeadsWhere, type HistoryEntry, type IncomingOf, type InstanceOf, type NameOf, type ReinstateOutput, type RetireOutput, type StatusOf, type TimestampPort, type VerifyResult, appendOnlyTables, canTransition, canonicalOf, documentBodyVersioning, documentEntities, documentIdentifiers, documentMigrations, documentRoleStatements, documentStore, fieldPatterns, hashOf, isSystemActor, isTerminalStatus, migrateBody, stampBody, systemActor, validatorOf };
535
+ export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type AggregateRow, type AggregateWhere, type AnyDocumentEntity, type AppendOnlyTablesOptions, type ArchivePort, BODY_VERSION_KEY, type BodyOf, type CardOf, type CommitOutput, DEFAULT_DOCUMENT_TABLE, DEFAULT_REVISIONS_TABLE, DEFAULT_REVISION_KIND_COLUMN, Document, type DocumentBodyMigrations, type DocumentBodyVersion, type DocumentColumns, type DocumentDefinition, type DocumentEntity, type DocumentHead, type DocumentInstance, type DocumentKind, type DocumentMigrationsOptions, type DocumentNumbering, type DocumentPhysicalColumns, type DocumentRecord, type DocumentRevisionsOptions, type DocumentSortColumn, type DocumentStatusMachine, type DocumentStore, type DocumentStoreOptions, type DocumentSurfaceOptions, type DraftOf, type FieldKind, HEAD_FIELDS, type HeadColumn, type HeadField, type HeadRow, type HeadsArgs, type HeadsOrder, type HeadsWhere, type HistoryEntry, type IncomingOf, type InstanceOf, type LinkVerifierPort, type NameOf, type PendingCall, type ReinstateOutput, type RetireOutput, type StatusOf, type SurfaceCall, type SurfaceRow, type SurfaceSchemaAdapter, type SurfaceScope, type SurfaceVerb, type TimestampPort, type VerifyResult, type ViewOf, appendOnlyTables, canTransition, canonicalOf, documentBodyVersioning, documentEntities, documentIdentifiers, documentMigrations, documentRoleStatements, documentStore, documentSurface, fieldPatterns, hashOf, isSystemActor, isTerminalStatus, migrateBody, physicalColumnsOf, stampBody, systemActor, validatorOf };