@geonosis/document 0.9.1 → 0.9.3
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 +18 -0
- package/dist/core/actor.cjs +48 -0
- package/dist/core/actor.d.cts +3 -0
- package/dist/core/actor.d.ts +3 -0
- package/dist/core/actor.js +8 -0
- package/dist/core/body-version.cjs +75 -0
- package/dist/core/body-version.d.cts +25 -0
- package/dist/core/body-version.d.ts +25 -0
- package/dist/core/body-version.js +35 -0
- package/dist/core/canonical.cjs +55 -0
- package/dist/core/canonical.d.cts +5 -0
- package/dist/core/canonical.d.ts +5 -0
- package/dist/core/canonical.js +15 -0
- package/dist/core/document.cjs +136 -0
- package/dist/core/document.d.cts +137 -0
- package/dist/core/document.d.ts +137 -0
- package/dist/core/document.js +96 -0
- package/dist/core/entities.cjs +68 -0
- package/dist/core/entities.d.cts +42 -0
- package/dist/core/entities.d.ts +42 -0
- package/dist/core/entities.js +28 -0
- package/dist/core/naming.cjs +56 -0
- package/dist/core/naming.d.cts +17 -0
- package/dist/core/naming.d.ts +17 -0
- package/dist/core/naming.js +16 -0
- package/dist/core/numbering.cjs +41 -0
- package/dist/core/numbering.d.cts +12 -0
- package/dist/core/numbering.d.ts +12 -0
- package/dist/core/numbering.js +0 -0
- package/dist/core/ports.cjs +41 -0
- package/dist/core/ports.d.cts +29 -0
- package/dist/core/ports.d.ts +29 -0
- package/dist/core/ports.js +0 -0
- package/dist/core/schema.cjs +173 -0
- package/dist/core/schema.d.cts +33 -0
- package/dist/core/schema.d.ts +33 -0
- package/dist/{chunk-NA3DLROL.js → core/schema.js} +34 -72
- package/dist/core/status.cjs +47 -0
- package/dist/core/status.d.cts +8 -0
- package/dist/core/status.d.ts +8 -0
- package/dist/core/status.js +7 -0
- package/dist/index.cjs +70 -398
- package/dist/index.d.cts +11 -32
- package/dist/index.d.ts +11 -32
- package/dist/index.js +13 -25
- package/dist/store/ddl.cjs +209 -0
- package/dist/store/ddl.d.cts +56 -0
- package/dist/store/ddl.d.ts +56 -0
- package/dist/store/ddl.js +175 -0
- package/dist/store/hash.cjs +50 -0
- package/dist/store/hash.d.cts +2 -0
- package/dist/store/hash.d.ts +2 -0
- package/dist/store/hash.js +10 -0
- package/dist/store/store.cjs +606 -0
- package/dist/store/store.d.cts +169 -0
- package/dist/store/store.d.ts +169 -0
- package/dist/store/store.js +578 -0
- package/dist/store.cjs +51 -1358
- package/dist/store.d.cts +4 -277
- package/dist/store.d.ts +4 -277
- package/dist/store.js +17 -1114
- package/dist/surface/table.cjs +326 -0
- package/dist/surface/table.d.cts +70 -0
- package/dist/surface/table.d.ts +70 -0
- package/dist/surface/table.js +296 -0
- package/dist/workflows/document-workflows.cjs +314 -0
- package/dist/workflows/document-workflows.d.cts +112 -0
- package/dist/workflows/document-workflows.d.ts +112 -0
- package/dist/workflows/document-workflows.js +281 -0
- package/dist/workflows/effects.cjs +41 -0
- package/dist/workflows/effects.d.cts +68 -0
- package/dist/workflows/effects.d.ts +68 -0
- package/dist/workflows/effects.js +0 -0
- package/dist/workflows/ports.cjs +50 -0
- package/dist/workflows/ports.d.cts +72 -0
- package/dist/workflows/ports.d.ts +72 -0
- package/dist/workflows/ports.js +10 -0
- package/dist/workflows/refusals.cjs +80 -0
- package/dist/workflows/refusals.d.cts +59 -0
- package/dist/workflows/refusals.d.ts +59 -0
- package/dist/workflows/refusals.js +40 -0
- package/dist/workflows.cjs +52 -504
- package/dist/workflows.d.cts +4 -310
- package/dist/workflows.d.ts +4 -310
- package/dist/workflows.js +21 -368
- package/package.json +8 -8
- package/dist/chunk-A6ZU4QU3.js +0 -171
- package/dist/entities-DTNJMeVf.d.cts +0 -205
- package/dist/entities-DTNJMeVf.d.ts +0 -205
- package/dist/ports-C_OfflMQ.d.cts +0 -66
- package/dist/ports-C_OfflMQ.d.ts +0 -66
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/surface/table.ts
|
|
40
|
+
var exports_table = {};
|
|
41
|
+
__export(exports_table, {
|
|
42
|
+
documentSurface: () => documentSurface
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(exports_table);
|
|
45
|
+
var import_document = require("../core/document.cjs");
|
|
46
|
+
var import_schema = require("../core/schema.cjs");
|
|
47
|
+
var import_status = require("../core/status.cjs");
|
|
48
|
+
var doorFor = (store, name) => {
|
|
49
|
+
const door = store[name];
|
|
50
|
+
if (door === undefined) {
|
|
51
|
+
throw new Error(`"${name}" names no store this table's registry can find — the table and the store must share one registry`);
|
|
52
|
+
}
|
|
53
|
+
return door;
|
|
54
|
+
};
|
|
55
|
+
var HEAD_COLUMNS = Object.keys(import_document.Document.headFields);
|
|
56
|
+
var SORT_COLUMNS = [...HEAD_COLUMNS, "number", "createdAt", "updatedAt"];
|
|
57
|
+
var rowsFor = (definition, store, schema) => {
|
|
58
|
+
const { name } = definition;
|
|
59
|
+
const door = doorFor(store, name);
|
|
60
|
+
const basePath = `/${definition.basePath}`;
|
|
61
|
+
const instanceSchema = import_schema.merge([
|
|
62
|
+
import_document.Document.head,
|
|
63
|
+
import_document.Document.record,
|
|
64
|
+
schema.object({ body: definition.view, entity: schema.enum([name]), number: import_schema.stringSchema })
|
|
65
|
+
]);
|
|
66
|
+
const commitOutput = schema.union([
|
|
67
|
+
schema.object({
|
|
68
|
+
committed: import_schema.literalOf(false),
|
|
69
|
+
lineage: import_schema.numberSchema,
|
|
70
|
+
ref: import_schema.stringSchema,
|
|
71
|
+
version: import_schema.numberSchema
|
|
72
|
+
}),
|
|
73
|
+
schema.object({
|
|
74
|
+
archived: import_schema.optional(import_schema.booleanSchema),
|
|
75
|
+
committed: import_schema.literalOf(true),
|
|
76
|
+
hash: import_schema.stringSchema,
|
|
77
|
+
lineage: import_schema.numberSchema,
|
|
78
|
+
previous: import_schema.nullable(schema.object({ hash: import_schema.stringSchema, version: import_schema.numberSchema })),
|
|
79
|
+
ref: import_schema.stringSchema,
|
|
80
|
+
version: import_schema.numberSchema
|
|
81
|
+
})
|
|
82
|
+
]);
|
|
83
|
+
const retireLikeOutput = schema.object({
|
|
84
|
+
hash: import_schema.stringSchema,
|
|
85
|
+
lineage: import_schema.numberSchema,
|
|
86
|
+
ref: import_schema.stringSchema,
|
|
87
|
+
version: import_schema.numberSchema
|
|
88
|
+
});
|
|
89
|
+
const verifyOutput = schema.union([
|
|
90
|
+
schema.object({ ok: import_schema.literalOf(true), versions: import_schema.numberSchema }),
|
|
91
|
+
schema.object({
|
|
92
|
+
brokenAt: import_schema.numberSchema,
|
|
93
|
+
expected: import_schema.stringSchema,
|
|
94
|
+
found: import_schema.stringSchema,
|
|
95
|
+
ok: import_schema.literalOf(false)
|
|
96
|
+
})
|
|
97
|
+
]);
|
|
98
|
+
const historyOutput = import_schema.arrayOf(schema.object({
|
|
99
|
+
actor: import_schema.stringSchema,
|
|
100
|
+
at: import_schema.numberSchema,
|
|
101
|
+
body: import_schema.unknownSchema,
|
|
102
|
+
hash: import_schema.stringSchema,
|
|
103
|
+
kind: schema.enum(["committed", "retired", "reinstated"]),
|
|
104
|
+
reason: import_schema.nullable(import_schema.stringSchema),
|
|
105
|
+
version: import_schema.numberSchema
|
|
106
|
+
}));
|
|
107
|
+
const listInput = schema.object({
|
|
108
|
+
cursor: import_schema.optional(import_schema.nullable(import_schema.stringSchema)),
|
|
109
|
+
filter: import_schema.optional(schema.object(Object.fromEntries(HEAD_COLUMNS.map((column) => [column, import_schema.optional(import_schema.stringSchema)])))),
|
|
110
|
+
limit: import_schema.optional(import_schema.numberSchema),
|
|
111
|
+
order: import_schema.optional(schema.object({
|
|
112
|
+
column: schema.enum(SORT_COLUMNS),
|
|
113
|
+
direction: import_schema.optional(schema.enum(["asc", "desc"]))
|
|
114
|
+
}))
|
|
115
|
+
});
|
|
116
|
+
const listOutput = schema.object({
|
|
117
|
+
items: import_schema.arrayOf(import_schema.merge([instanceSchema, schema.object({ card: definition.card.schema })])),
|
|
118
|
+
nextCursor: import_schema.nullable(import_schema.stringSchema)
|
|
119
|
+
});
|
|
120
|
+
const ackOutput = schema.object({ ref: import_schema.stringSchema });
|
|
121
|
+
return [
|
|
122
|
+
{
|
|
123
|
+
call: (handle, params) => door.get(handle, params),
|
|
124
|
+
input: schema.object({ ref: import_schema.stringSchema }),
|
|
125
|
+
name: `${name}.get`,
|
|
126
|
+
output: import_schema.nullable(instanceSchema),
|
|
127
|
+
path: `${basePath}/:ref`,
|
|
128
|
+
scope: "org",
|
|
129
|
+
verb: "query"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
call: async (handle, params) => {
|
|
133
|
+
const page = await door.list(handle, params);
|
|
134
|
+
return {
|
|
135
|
+
items: page.items.map((item) => ({
|
|
136
|
+
...item,
|
|
137
|
+
card: definition.card.of(item, { counterpartyName: "" })
|
|
138
|
+
})),
|
|
139
|
+
nextCursor: page.nextCursor
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
input: listInput,
|
|
143
|
+
name: `${name}.list`,
|
|
144
|
+
output: listOutput,
|
|
145
|
+
path: basePath,
|
|
146
|
+
scope: "org",
|
|
147
|
+
verb: "query"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
call: (handle, params) => door.history(handle, params),
|
|
151
|
+
input: schema.object({ lineage: import_schema.optional(import_schema.numberSchema), ref: import_schema.stringSchema }),
|
|
152
|
+
name: `${name}.history`,
|
|
153
|
+
output: historyOutput,
|
|
154
|
+
path: `${basePath}/:ref/history`,
|
|
155
|
+
scope: "org",
|
|
156
|
+
verb: "query"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
call: (handle, params) => door.verify(handle, params),
|
|
160
|
+
input: schema.object({ lineage: import_schema.optional(import_schema.numberSchema), ref: import_schema.stringSchema }),
|
|
161
|
+
name: `${name}.verify`,
|
|
162
|
+
output: verifyOutput,
|
|
163
|
+
path: `${basePath}/:ref/verify`,
|
|
164
|
+
scope: "org",
|
|
165
|
+
verb: "query"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
call: (handle, params) => door.commit(handle, params),
|
|
169
|
+
input: schema.object({
|
|
170
|
+
actor: import_schema.stringSchema,
|
|
171
|
+
body: definition.body,
|
|
172
|
+
reason: import_schema.optional(import_schema.stringSchema),
|
|
173
|
+
ref: import_schema.stringSchema
|
|
174
|
+
}),
|
|
175
|
+
name: `${name}.commit`,
|
|
176
|
+
output: commitOutput,
|
|
177
|
+
path: basePath,
|
|
178
|
+
scope: "org",
|
|
179
|
+
verb: "mutation"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
call: (handle, params) => door.retire(handle, params),
|
|
183
|
+
input: schema.object({
|
|
184
|
+
actor: import_schema.stringSchema,
|
|
185
|
+
reason: import_schema.optional(import_schema.stringSchema),
|
|
186
|
+
ref: import_schema.stringSchema
|
|
187
|
+
}),
|
|
188
|
+
name: `${name}.retire`,
|
|
189
|
+
output: retireLikeOutput,
|
|
190
|
+
path: `${basePath}/:ref/retire`,
|
|
191
|
+
scope: "org",
|
|
192
|
+
verb: "mutation"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
call: (handle, params) => door.reinstate(handle, params),
|
|
196
|
+
input: schema.object({
|
|
197
|
+
actor: import_schema.stringSchema,
|
|
198
|
+
reason: import_schema.optional(import_schema.stringSchema),
|
|
199
|
+
ref: import_schema.stringSchema
|
|
200
|
+
}),
|
|
201
|
+
name: `${name}.reinstate`,
|
|
202
|
+
output: retireLikeOutput,
|
|
203
|
+
path: `${basePath}/:ref/reinstate`,
|
|
204
|
+
scope: "org",
|
|
205
|
+
verb: "mutation"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
call: async (handle, params) => {
|
|
209
|
+
const asked = params;
|
|
210
|
+
const current = await door.get(handle, params);
|
|
211
|
+
if (current === null) {
|
|
212
|
+
throw new Error(`"${asked.ref}" (${name}) has no document to set a status on`);
|
|
213
|
+
}
|
|
214
|
+
const from = definition.statusOf(current.body);
|
|
215
|
+
if (!import_status.canTransition(definition.statuses, from, asked.status)) {
|
|
216
|
+
throw new Error(`"${name}" cannot move "${asked.ref}" from "${from}" to "${asked.status}": the status machine declares no such transition`);
|
|
217
|
+
}
|
|
218
|
+
const body = definition.withStatus(current.body, asked.status, new Date().toISOString());
|
|
219
|
+
return door.commit(handle, { ...asked, body });
|
|
220
|
+
},
|
|
221
|
+
input: schema.object({
|
|
222
|
+
actor: import_schema.stringSchema,
|
|
223
|
+
reason: import_schema.optional(import_schema.stringSchema),
|
|
224
|
+
ref: import_schema.stringSchema,
|
|
225
|
+
status: schema.enum(definition.statuses.statuses)
|
|
226
|
+
}),
|
|
227
|
+
name: `${name}.setStatus`,
|
|
228
|
+
output: commitOutput,
|
|
229
|
+
path: `${basePath}/:ref/status`,
|
|
230
|
+
scope: "org",
|
|
231
|
+
verb: "mutation"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
call: { pending: "T3", workflow: `${name}.create` },
|
|
235
|
+
input: schema.object({ draft: definition.draft }),
|
|
236
|
+
name: `${name}.create`,
|
|
237
|
+
output: commitOutput,
|
|
238
|
+
path: basePath,
|
|
239
|
+
scope: "org",
|
|
240
|
+
verb: "mutation"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
call: { pending: "T3", workflow: `${name}.send` },
|
|
244
|
+
input: schema.object({ ref: import_schema.stringSchema }),
|
|
245
|
+
name: `${name}.send`,
|
|
246
|
+
output: ackOutput,
|
|
247
|
+
path: `${basePath}/:ref/send`,
|
|
248
|
+
scope: "org",
|
|
249
|
+
verb: "mutation"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
call: { pending: "T3", workflow: `${name}.duplicate` },
|
|
253
|
+
input: schema.object({ ref: import_schema.stringSchema }),
|
|
254
|
+
name: `${name}.duplicate`,
|
|
255
|
+
output: commitOutput,
|
|
256
|
+
path: `${basePath}/:ref/duplicate`,
|
|
257
|
+
scope: "org",
|
|
258
|
+
verb: "mutation"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
call: { pending: "T3", workflow: `${name}.runStarted` },
|
|
262
|
+
input: schema.object({ ref: import_schema.stringSchema }),
|
|
263
|
+
name: `${name}.runStarted`,
|
|
264
|
+
output: ackOutput,
|
|
265
|
+
path: `${basePath}/:ref/run-started`,
|
|
266
|
+
scope: "org",
|
|
267
|
+
verb: "mutation"
|
|
268
|
+
}
|
|
269
|
+
];
|
|
270
|
+
};
|
|
271
|
+
var documentSurface = (options) => {
|
|
272
|
+
const { registry, schema, store } = options;
|
|
273
|
+
const headsColumns = [...HEAD_COLUMNS, "entity", "number"];
|
|
274
|
+
const headsInput = schema.object({
|
|
275
|
+
columns: import_schema.arrayOf(schema.enum(headsColumns)),
|
|
276
|
+
entity: import_schema.optional(schema.union([import_schema.stringSchema, import_schema.arrayOf(import_schema.stringSchema)])),
|
|
277
|
+
order: import_schema.arrayOf(schema.object({
|
|
278
|
+
column: schema.enum([...SORT_COLUMNS, "entity"]),
|
|
279
|
+
direction: import_schema.optional(schema.enum(["asc", "desc"]))
|
|
280
|
+
})),
|
|
281
|
+
where: import_schema.optional(import_schema.unknownSchema)
|
|
282
|
+
});
|
|
283
|
+
const aggregateInput = schema.object({
|
|
284
|
+
by: import_schema.optional(import_schema.unknownSchema),
|
|
285
|
+
entities: import_schema.optional(import_schema.arrayOf(import_schema.stringSchema)),
|
|
286
|
+
entity: import_schema.optional(import_schema.stringSchema),
|
|
287
|
+
measures: import_schema.arrayOf(schema.enum(["count", "sum:total"])),
|
|
288
|
+
where: import_schema.optional(import_schema.unknownSchema)
|
|
289
|
+
});
|
|
290
|
+
const aggregateOutput = import_schema.arrayOf(schema.object({
|
|
291
|
+
by: import_schema.optional(import_schema.stringSchema),
|
|
292
|
+
count: import_schema.optional(import_schema.numberSchema),
|
|
293
|
+
sum: import_schema.optional(import_schema.stringSchema)
|
|
294
|
+
}));
|
|
295
|
+
const sharedOutput = schema.union(registry.fold((entity) => schema.object({ entity: schema.enum([entity.name]), view: entity.view })));
|
|
296
|
+
return [
|
|
297
|
+
...registry.fold((entity) => rowsFor(entity, store, schema)).flat(),
|
|
298
|
+
{
|
|
299
|
+
call: (handle, params) => store.heads(handle, params),
|
|
300
|
+
input: headsInput,
|
|
301
|
+
name: "heads",
|
|
302
|
+
output: import_schema.arrayOf(import_schema.unknownSchema),
|
|
303
|
+
path: "/documents/heads",
|
|
304
|
+
scope: "org",
|
|
305
|
+
verb: "query"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
call: (handle, params) => store.aggregate(handle, params),
|
|
309
|
+
input: aggregateInput,
|
|
310
|
+
name: "aggregate",
|
|
311
|
+
output: aggregateOutput,
|
|
312
|
+
path: "/documents/aggregate",
|
|
313
|
+
scope: "org",
|
|
314
|
+
verb: "query"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
call: { pending: "T3", workflow: "document.shared" },
|
|
318
|
+
input: schema.object({ token: import_schema.stringSchema }),
|
|
319
|
+
name: "shared",
|
|
320
|
+
output: sharedOutput,
|
|
321
|
+
path: "/documents/shared",
|
|
322
|
+
scope: "token",
|
|
323
|
+
verb: "query"
|
|
324
|
+
}
|
|
325
|
+
];
|
|
326
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { DocumentBodyMigrations } from '../core/body-version.cjs';
|
|
3
|
+
import { type DocumentHead } from '../core/document.cjs';
|
|
4
|
+
import { documentEntities, type AnyDocumentEntity } from '../core/entities.cjs';
|
|
5
|
+
import { type SchemaAdapter } from '../core/schema.cjs';
|
|
6
|
+
import { type DocumentStatusMachine } from '../core/status.cjs';
|
|
7
|
+
import type { DocumentStore, DocumentStoreHandle } from '../store/store.cjs';
|
|
8
|
+
export type SurfaceVerb = 'query' | 'mutation';
|
|
9
|
+
export type SurfaceScope = 'org' | 'public' | 'token';
|
|
10
|
+
/** The row's own declaration of what a workflow (not yet landed) will bind it to. */
|
|
11
|
+
export type PendingCall = {
|
|
12
|
+
pending: 'T3';
|
|
13
|
+
workflow: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A row as a caller calls it — the entity's own signature (D-065's `ref`, never `number`) with a
|
|
17
|
+
* leading handle, the same convention `BoundQuery` already states in `@geonosis/workflows`, made
|
|
18
|
+
* explicit here since a row is DATA before it is a function: reading `params.ref` off `never`
|
|
19
|
+
* compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
|
|
20
|
+
*/
|
|
21
|
+
export type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
|
|
22
|
+
/** The adapter as the surface first named it; the builders live in the core now. */
|
|
23
|
+
export type SurfaceSchemaAdapter = SchemaAdapter;
|
|
24
|
+
export type SurfaceRow = {
|
|
25
|
+
call: PendingCall | SurfaceCall;
|
|
26
|
+
input: StandardSchemaV1;
|
|
27
|
+
name: string;
|
|
28
|
+
output: StandardSchemaV1;
|
|
29
|
+
path: string;
|
|
30
|
+
scope: SurfaceScope;
|
|
31
|
+
verb: SurfaceVerb;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
|
|
35
|
+
* what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
|
|
36
|
+
* caller never sees two overlapping bounds for the one registry it built.
|
|
37
|
+
*/
|
|
38
|
+
type SurfaceDocumentEntity = AnyDocumentEntity & {
|
|
39
|
+
basePath: string;
|
|
40
|
+
bodyVersion?: number;
|
|
41
|
+
card: {
|
|
42
|
+
of: (document: never, names: {
|
|
43
|
+
counterpartyName: string;
|
|
44
|
+
}) => unknown;
|
|
45
|
+
schema: StandardSchemaV1;
|
|
46
|
+
};
|
|
47
|
+
draft: StandardSchemaV1;
|
|
48
|
+
headOf: (body: never) => DocumentHead;
|
|
49
|
+
migrations?: DocumentBodyMigrations<Record<string, unknown>>;
|
|
50
|
+
prepare: (body: never) => unknown;
|
|
51
|
+
statusOf: (body: never) => string;
|
|
52
|
+
statuses: DocumentStatusMachine<string>;
|
|
53
|
+
withStatus: (body: never, status: string, at: string) => unknown;
|
|
54
|
+
};
|
|
55
|
+
type Registry<Map extends Readonly<Record<string, SurfaceDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
|
|
56
|
+
export type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DocumentStoreHandle = DocumentStoreHandle> = {
|
|
57
|
+
registry: Registry<Map>;
|
|
58
|
+
schema: SurfaceSchemaAdapter;
|
|
59
|
+
store: DocumentStore<Map, Key, Handle>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* `documentSurface({ registry, store, schema })`: the table every tRPC/REST/MCP mount is derived
|
|
63
|
+
* from — never authored by hand, and never a map a caller fills in per entity (#383). Reads and
|
|
64
|
+
* `commit`/`retire`/`reinstate`/`setStatus` bind `call` to the store already composed; the saga
|
|
65
|
+
* rows (`create`, `send`, `duplicate`, `run-started`) are declared with their own input/output and
|
|
66
|
+
* a `{ pending: 'T3', workflow }` in place of `call` — an adapter mounting the table refuses those
|
|
67
|
+
* BY NAME, never with a stub answer.
|
|
68
|
+
*/
|
|
69
|
+
export declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DocumentStoreHandle = DocumentStoreHandle>(options: DocumentSurfaceOptions<Map, Key, Handle>) => SurfaceRow[];
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { DocumentBodyMigrations } from '../core/body-version.js';
|
|
3
|
+
import { type DocumentHead } from '../core/document.js';
|
|
4
|
+
import { documentEntities, type AnyDocumentEntity } from '../core/entities.js';
|
|
5
|
+
import { type SchemaAdapter } from '../core/schema.js';
|
|
6
|
+
import { type DocumentStatusMachine } from '../core/status.js';
|
|
7
|
+
import type { DocumentStore, DocumentStoreHandle } from '../store/store.js';
|
|
8
|
+
export type SurfaceVerb = 'query' | 'mutation';
|
|
9
|
+
export type SurfaceScope = 'org' | 'public' | 'token';
|
|
10
|
+
/** The row's own declaration of what a workflow (not yet landed) will bind it to. */
|
|
11
|
+
export type PendingCall = {
|
|
12
|
+
pending: 'T3';
|
|
13
|
+
workflow: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A row as a caller calls it — the entity's own signature (D-065's `ref`, never `number`) with a
|
|
17
|
+
* leading handle, the same convention `BoundQuery` already states in `@geonosis/workflows`, made
|
|
18
|
+
* explicit here since a row is DATA before it is a function: reading `params.ref` off `never`
|
|
19
|
+
* compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
|
|
20
|
+
*/
|
|
21
|
+
export type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
|
|
22
|
+
/** The adapter as the surface first named it; the builders live in the core now. */
|
|
23
|
+
export type SurfaceSchemaAdapter = SchemaAdapter;
|
|
24
|
+
export type SurfaceRow = {
|
|
25
|
+
call: PendingCall | SurfaceCall;
|
|
26
|
+
input: StandardSchemaV1;
|
|
27
|
+
name: string;
|
|
28
|
+
output: StandardSchemaV1;
|
|
29
|
+
path: string;
|
|
30
|
+
scope: SurfaceScope;
|
|
31
|
+
verb: SurfaceVerb;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
|
|
35
|
+
* what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
|
|
36
|
+
* caller never sees two overlapping bounds for the one registry it built.
|
|
37
|
+
*/
|
|
38
|
+
type SurfaceDocumentEntity = AnyDocumentEntity & {
|
|
39
|
+
basePath: string;
|
|
40
|
+
bodyVersion?: number;
|
|
41
|
+
card: {
|
|
42
|
+
of: (document: never, names: {
|
|
43
|
+
counterpartyName: string;
|
|
44
|
+
}) => unknown;
|
|
45
|
+
schema: StandardSchemaV1;
|
|
46
|
+
};
|
|
47
|
+
draft: StandardSchemaV1;
|
|
48
|
+
headOf: (body: never) => DocumentHead;
|
|
49
|
+
migrations?: DocumentBodyMigrations<Record<string, unknown>>;
|
|
50
|
+
prepare: (body: never) => unknown;
|
|
51
|
+
statusOf: (body: never) => string;
|
|
52
|
+
statuses: DocumentStatusMachine<string>;
|
|
53
|
+
withStatus: (body: never, status: string, at: string) => unknown;
|
|
54
|
+
};
|
|
55
|
+
type Registry<Map extends Readonly<Record<string, SurfaceDocumentEntity>>> = ReturnType<typeof documentEntities<Map>>;
|
|
56
|
+
export type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DocumentStoreHandle = DocumentStoreHandle> = {
|
|
57
|
+
registry: Registry<Map>;
|
|
58
|
+
schema: SurfaceSchemaAdapter;
|
|
59
|
+
store: DocumentStore<Map, Key, Handle>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* `documentSurface({ registry, store, schema })`: the table every tRPC/REST/MCP mount is derived
|
|
63
|
+
* from — never authored by hand, and never a map a caller fills in per entity (#383). Reads and
|
|
64
|
+
* `commit`/`retire`/`reinstate`/`setStatus` bind `call` to the store already composed; the saga
|
|
65
|
+
* rows (`create`, `send`, `duplicate`, `run-started`) are declared with their own input/output and
|
|
66
|
+
* a `{ pending: 'T3', workflow }` in place of `call` — an adapter mounting the table refuses those
|
|
67
|
+
* BY NAME, never with a stub answer.
|
|
68
|
+
*/
|
|
69
|
+
export declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DocumentStoreHandle = DocumentStoreHandle>(options: DocumentSurfaceOptions<Map, Key, Handle>) => SurfaceRow[];
|
|
70
|
+
export {};
|