@geonosis/document 0.2.0 → 0.3.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/CHANGELOG.md +39 -0
- package/README.md +63 -27
- package/dist/index.cjs +743 -727
- package/dist/index.d.cts +94 -76
- package/dist/index.d.ts +94 -76
- package/dist/index.js +746 -729
- package/migrations/0001_documents.sql +2 -2
- package/migrations/0003_document_revisions.sql +4 -5
- package/package.json +2 -3
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,
|
|
3
|
+
import { EntityColumns, EntityName, SessionSettings, EntityMigration, Projection, Executor, Query, 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,95 +247,55 @@ 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";
|
|
247
262
|
type DocumentColumns = EntityColumns & {
|
|
248
|
-
/** The discriminator column two entities on one table disagree on. `'entity'` when unnamed. */
|
|
249
263
|
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
|
-
*/
|
|
255
264
|
revisionKind?: string;
|
|
256
|
-
/** The physical column `heads`/`aggregate` read `total` off. `'total'` when unnamed. */
|
|
257
265
|
total?: EntityName;
|
|
258
266
|
};
|
|
259
|
-
/** The log — the append-only record of truth. `false` opts a consumer out of it entirely. */
|
|
260
267
|
type DocumentRevisionsOptions = {
|
|
261
268
|
table?: string;
|
|
262
269
|
};
|
|
263
270
|
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
271
|
appRole?: string;
|
|
271
272
|
columns?: DocumentColumns;
|
|
272
|
-
/** On by default (`document_revisions`); `false` renders none of it. */
|
|
273
273
|
revisions?: DocumentRevisionsOptions | false;
|
|
274
274
|
schema?: string;
|
|
275
275
|
settings: SessionSettings;
|
|
276
276
|
table?: string;
|
|
277
277
|
};
|
|
278
278
|
type AppendOnlyTablesOptions = {
|
|
279
|
-
/** Shorthand for `revisions.table` — ignored once `revisions` also names one. */
|
|
280
279
|
table?: string;
|
|
281
|
-
/** On by default (`document_revisions`); `false` names nothing — nothing here is append-only. */
|
|
282
280
|
revisions?: DocumentRevisionsOptions | false;
|
|
283
281
|
};
|
|
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
282
|
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
283
|
declare const documentRoleStatements: (appRole: string, options?: AppendOnlyTablesOptions & {
|
|
296
284
|
schema?: string;
|
|
297
285
|
}) => 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
286
|
declare const documentMigrations: (options: DocumentMigrationsOptions) => EntityMigration[];
|
|
308
287
|
|
|
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
288
|
type StorableDocumentEntity = AnyDocumentEntity & {
|
|
316
289
|
bodyVersion?: number;
|
|
317
290
|
headOf: (body: never) => DocumentHead;
|
|
318
291
|
migrations?: DocumentBodyMigrations<Record<string, unknown>>;
|
|
319
292
|
prepare: (body: never) => unknown;
|
|
320
293
|
};
|
|
321
|
-
type Registry<Map extends Readonly<Record<string, StorableDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
|
|
294
|
+
type Registry$1<Map extends Readonly<Record<string, StorableDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
|
|
322
295
|
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
296
|
archive?: ArchivePort;
|
|
329
297
|
columns?: DocumentColumns;
|
|
330
|
-
registry: Registry<Map>;
|
|
331
|
-
/** The append-only log. On by default (`document_revisions`); `false` opts out. */
|
|
298
|
+
registry: Registry$1<Map>;
|
|
332
299
|
revisions?: DocumentRevisionsOptions | false;
|
|
333
300
|
schema?: string;
|
|
334
301
|
seam: SessionSeam<Key, Executor>;
|
|
@@ -345,9 +312,7 @@ type HeadsWhere = {
|
|
|
345
312
|
};
|
|
346
313
|
type HeadsArgs = {
|
|
347
314
|
columns: readonly HeadColumn[];
|
|
348
|
-
/** One entity, or a set — RECENT's own read narrows `kind IN ($kinds)`, never one kind alone. */
|
|
349
315
|
entity?: string | readonly string[];
|
|
350
|
-
/** Every column a page is ordered by, the tie-break included — HEADS FOR MATCHING orders by `kind, number`. */
|
|
351
316
|
order: readonly HeadsOrder[];
|
|
352
317
|
where?: HeadsWhere;
|
|
353
318
|
};
|
|
@@ -387,7 +352,6 @@ type CommitOutput = {
|
|
|
387
352
|
ref: string;
|
|
388
353
|
version: number;
|
|
389
354
|
} | {
|
|
390
|
-
/** Present only when `documentStore({ archive })` names a port — absent, nothing tried. */
|
|
391
355
|
archived?: boolean;
|
|
392
356
|
committed: true;
|
|
393
357
|
hash: string;
|
|
@@ -429,42 +393,35 @@ type VerifyResult = {
|
|
|
429
393
|
ok: true;
|
|
430
394
|
versions: number;
|
|
431
395
|
};
|
|
432
|
-
type DocumentEntityStore<Key extends string> = Pick<
|
|
433
|
-
/** The latest revision whose `at` is at or before the instant — the current lineage only. */
|
|
396
|
+
type DocumentEntityStore<Key extends string> = Pick<Projection<unknown, Item, Key, 'ref', Executor, SortableHeadColumn, SortableHeadColumn>, 'get' | 'list' | 'listAll'> & {
|
|
434
397
|
asOf: Query<Readonly<Record<Key, string>> & {
|
|
435
398
|
at: number;
|
|
436
399
|
ref: string;
|
|
437
400
|
}, Item | null, Executor>;
|
|
438
|
-
/** `ref`'s revision at that exact version — the current lineage only. */
|
|
439
401
|
at: Query<Readonly<Record<Key, string>> & {
|
|
440
402
|
ref: string;
|
|
441
403
|
version: number;
|
|
442
404
|
}, Item | null, Executor>;
|
|
443
|
-
/** The ONE write verb: appends an immutable revision, updates the projection, one transaction. */
|
|
444
405
|
commit: Query<Readonly<Record<Key, string>> & {
|
|
445
406
|
actor: string;
|
|
446
407
|
body: unknown;
|
|
447
408
|
reason?: string;
|
|
448
409
|
ref: string;
|
|
449
410
|
}, CommitOutput, Executor>;
|
|
450
|
-
/** Every revision of one lineage, by version — the archive's own read. */
|
|
451
411
|
history: Query<Readonly<Record<Key, string>> & {
|
|
452
412
|
lineage?: number;
|
|
453
413
|
ref: string;
|
|
454
414
|
}, HistoryEntry[], Executor>;
|
|
455
|
-
/** Un-retires the SAME lineage — never a new one (`succeed` is that door). */
|
|
456
415
|
reinstate: Query<Readonly<Record<Key, string>> & {
|
|
457
416
|
actor: string;
|
|
458
417
|
reason?: string;
|
|
459
418
|
ref: string;
|
|
460
419
|
}, ReinstateOutput, Executor>;
|
|
461
|
-
/** `retire`: a commit of kind `retired` — refuses a document already retired. */
|
|
462
420
|
retire: Query<Readonly<Record<Key, string>> & {
|
|
463
421
|
actor: string;
|
|
464
422
|
reason?: string;
|
|
465
423
|
ref: string;
|
|
466
424
|
}, RetireOutput, Executor>;
|
|
467
|
-
/** Opens a NEW lineage for a `ref` whose document is dead — the old lineage stays in full. */
|
|
468
425
|
succeed: Query<Readonly<Record<Key, string>> & {
|
|
469
426
|
actor: string;
|
|
470
427
|
body: unknown;
|
|
@@ -475,7 +432,6 @@ type DocumentEntityStore<Key extends string> = Pick<Entity<unknown, Item, Key, '
|
|
|
475
432
|
commit: EntityUndo<CommitOutput, Executor>;
|
|
476
433
|
retire: EntityUndo<RetireOutput, Executor>;
|
|
477
434
|
};
|
|
478
|
-
/** Recomputes every hash of one lineage from version 1 — tamper-evidence, on demand. */
|
|
479
435
|
verify: Query<Readonly<Record<Key, string>> & {
|
|
480
436
|
lineage?: number;
|
|
481
437
|
ref: string;
|
|
@@ -486,21 +442,83 @@ type DocumentStore<Map extends Readonly<Record<string, StorableDocumentEntity>>,
|
|
|
486
442
|
} & {
|
|
487
443
|
aggregate: Query<Readonly<Record<Key, string>> & AggregateArgs, AggregateRow[], Executor>;
|
|
488
444
|
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. */
|
|
490
445
|
rebuild: Query<Readonly<Record<Key, string>> & {
|
|
491
446
|
entity?: string;
|
|
492
447
|
}, {
|
|
493
448
|
rows: number;
|
|
494
449
|
}, Executor>;
|
|
495
450
|
};
|
|
451
|
+
declare const documentStore: <Map extends Readonly<Record<string, StorableDocumentEntity>>, Key extends string>(options: DocumentStoreOptions<Map, Key>) => DocumentStore<Map, Key>;
|
|
452
|
+
|
|
453
|
+
type SurfaceVerb = 'query' | 'mutation';
|
|
454
|
+
type SurfaceScope = 'org' | 'public' | 'token';
|
|
455
|
+
/** The row's own declaration of what a workflow (not yet landed) will bind it to. */
|
|
456
|
+
type PendingCall = {
|
|
457
|
+
pending: 'T3';
|
|
458
|
+
workflow: string;
|
|
459
|
+
};
|
|
496
460
|
/**
|
|
497
|
-
*
|
|
498
|
-
* `
|
|
499
|
-
*
|
|
500
|
-
*
|
|
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.
|
|
461
|
+
* A row as a caller calls it — the entity's own signature (D-065's `ref`, never `number`) with a
|
|
462
|
+
* leading handle, the same convention `BoundQuery` already states in `@geonosis/workflows`, made
|
|
463
|
+
* explicit here since a row is DATA before it is a function: reading `params.ref` off `never`
|
|
464
|
+
* compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
|
|
503
465
|
*/
|
|
504
|
-
|
|
466
|
+
type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
|
|
467
|
+
type SurfaceRow = {
|
|
468
|
+
call: PendingCall | SurfaceCall;
|
|
469
|
+
input: StandardSchemaV1;
|
|
470
|
+
name: string;
|
|
471
|
+
output: StandardSchemaV1;
|
|
472
|
+
path: string;
|
|
473
|
+
scope: SurfaceScope;
|
|
474
|
+
verb: SurfaceVerb;
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* The three builders a validator library supplies so the table stays library-free (#383) while the
|
|
478
|
+
* union/enum/object it derives are still real schemas of THAT library — the one place a consumer's
|
|
479
|
+
* zod enters `@geonosis/document` is through this adapter, never a direct dependency.
|
|
480
|
+
*/
|
|
481
|
+
type SurfaceSchemaAdapter = {
|
|
482
|
+
enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
|
|
483
|
+
object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
|
|
484
|
+
union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
|
|
488
|
+
* what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
|
|
489
|
+
* caller never sees two overlapping bounds for the one registry it built.
|
|
490
|
+
*/
|
|
491
|
+
type SurfaceDocumentEntity = AnyDocumentEntity & {
|
|
492
|
+
basePath: string;
|
|
493
|
+
bodyVersion?: number;
|
|
494
|
+
card: {
|
|
495
|
+
of: (document: never, names: {
|
|
496
|
+
counterpartyName: string;
|
|
497
|
+
}) => unknown;
|
|
498
|
+
schema: StandardSchemaV1;
|
|
499
|
+
};
|
|
500
|
+
draft: StandardSchemaV1;
|
|
501
|
+
headOf: (body: never) => DocumentHead;
|
|
502
|
+
migrations?: DocumentBodyMigrations<Record<string, unknown>>;
|
|
503
|
+
prepare: (body: never) => unknown;
|
|
504
|
+
statusOf: (body: never) => string;
|
|
505
|
+
statuses: DocumentStatusMachine<string>;
|
|
506
|
+
withStatus: (body: never, status: string, at: string) => unknown;
|
|
507
|
+
};
|
|
508
|
+
type Registry<Map extends Readonly<Record<string, SurfaceDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
|
|
509
|
+
type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string> = {
|
|
510
|
+
registry: Registry<Map>;
|
|
511
|
+
schema: SurfaceSchemaAdapter;
|
|
512
|
+
store: DocumentStore<Map, Key>;
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* `documentSurface({ registry, store, schema })`: the table every tRPC/REST/MCP mount is derived
|
|
516
|
+
* from — never authored by hand, and never a map a caller fills in per entity (#383). Reads and
|
|
517
|
+
* `commit`/`retire`/`reinstate`/`setStatus` bind `call` to the store already composed; the saga
|
|
518
|
+
* rows (`create`, `send`, `duplicate`, `run-started`) are declared with their own input/output and
|
|
519
|
+
* a `{ pending: 'T3', workflow }` in place of `call` — an adapter mounting the table refuses those
|
|
520
|
+
* BY NAME, never with a stub answer.
|
|
521
|
+
*/
|
|
522
|
+
declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string>(options: DocumentSurfaceOptions<Map, Key>) => SurfaceRow[];
|
|
505
523
|
|
|
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 };
|
|
524
|
+
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 DocumentSurfaceOptions, type DraftOf, type FieldKind, type HeadColumn, 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, stampBody, systemActor, validatorOf };
|