@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.
Files changed (91) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/core/actor.cjs +48 -0
  3. package/dist/core/actor.d.cts +3 -0
  4. package/dist/core/actor.d.ts +3 -0
  5. package/dist/core/actor.js +8 -0
  6. package/dist/core/body-version.cjs +75 -0
  7. package/dist/core/body-version.d.cts +25 -0
  8. package/dist/core/body-version.d.ts +25 -0
  9. package/dist/core/body-version.js +35 -0
  10. package/dist/core/canonical.cjs +55 -0
  11. package/dist/core/canonical.d.cts +5 -0
  12. package/dist/core/canonical.d.ts +5 -0
  13. package/dist/core/canonical.js +15 -0
  14. package/dist/core/document.cjs +136 -0
  15. package/dist/core/document.d.cts +137 -0
  16. package/dist/core/document.d.ts +137 -0
  17. package/dist/core/document.js +96 -0
  18. package/dist/core/entities.cjs +68 -0
  19. package/dist/core/entities.d.cts +42 -0
  20. package/dist/core/entities.d.ts +42 -0
  21. package/dist/core/entities.js +28 -0
  22. package/dist/core/naming.cjs +56 -0
  23. package/dist/core/naming.d.cts +17 -0
  24. package/dist/core/naming.d.ts +17 -0
  25. package/dist/core/naming.js +16 -0
  26. package/dist/core/numbering.cjs +41 -0
  27. package/dist/core/numbering.d.cts +12 -0
  28. package/dist/core/numbering.d.ts +12 -0
  29. package/dist/core/numbering.js +0 -0
  30. package/dist/core/ports.cjs +41 -0
  31. package/dist/core/ports.d.cts +29 -0
  32. package/dist/core/ports.d.ts +29 -0
  33. package/dist/core/ports.js +0 -0
  34. package/dist/core/schema.cjs +173 -0
  35. package/dist/core/schema.d.cts +33 -0
  36. package/dist/core/schema.d.ts +33 -0
  37. package/dist/{chunk-NA3DLROL.js → core/schema.js} +34 -72
  38. package/dist/core/status.cjs +47 -0
  39. package/dist/core/status.d.cts +8 -0
  40. package/dist/core/status.d.ts +8 -0
  41. package/dist/core/status.js +7 -0
  42. package/dist/index.cjs +70 -398
  43. package/dist/index.d.cts +11 -32
  44. package/dist/index.d.ts +11 -32
  45. package/dist/index.js +13 -25
  46. package/dist/store/ddl.cjs +209 -0
  47. package/dist/store/ddl.d.cts +56 -0
  48. package/dist/store/ddl.d.ts +56 -0
  49. package/dist/store/ddl.js +175 -0
  50. package/dist/store/hash.cjs +50 -0
  51. package/dist/store/hash.d.cts +2 -0
  52. package/dist/store/hash.d.ts +2 -0
  53. package/dist/store/hash.js +10 -0
  54. package/dist/store/store.cjs +606 -0
  55. package/dist/store/store.d.cts +169 -0
  56. package/dist/store/store.d.ts +169 -0
  57. package/dist/store/store.js +578 -0
  58. package/dist/store.cjs +51 -1358
  59. package/dist/store.d.cts +4 -277
  60. package/dist/store.d.ts +4 -277
  61. package/dist/store.js +17 -1114
  62. package/dist/surface/table.cjs +326 -0
  63. package/dist/surface/table.d.cts +70 -0
  64. package/dist/surface/table.d.ts +70 -0
  65. package/dist/surface/table.js +296 -0
  66. package/dist/workflows/document-workflows.cjs +314 -0
  67. package/dist/workflows/document-workflows.d.cts +112 -0
  68. package/dist/workflows/document-workflows.d.ts +112 -0
  69. package/dist/workflows/document-workflows.js +281 -0
  70. package/dist/workflows/effects.cjs +41 -0
  71. package/dist/workflows/effects.d.cts +68 -0
  72. package/dist/workflows/effects.d.ts +68 -0
  73. package/dist/workflows/effects.js +0 -0
  74. package/dist/workflows/ports.cjs +50 -0
  75. package/dist/workflows/ports.d.cts +72 -0
  76. package/dist/workflows/ports.d.ts +72 -0
  77. package/dist/workflows/ports.js +10 -0
  78. package/dist/workflows/refusals.cjs +80 -0
  79. package/dist/workflows/refusals.d.cts +59 -0
  80. package/dist/workflows/refusals.d.ts +59 -0
  81. package/dist/workflows/refusals.js +40 -0
  82. package/dist/workflows.cjs +52 -504
  83. package/dist/workflows.d.cts +4 -310
  84. package/dist/workflows.d.ts +4 -310
  85. package/dist/workflows.js +21 -368
  86. package/package.json +8 -8
  87. package/dist/chunk-A6ZU4QU3.js +0 -171
  88. package/dist/entities-DTNJMeVf.d.cts +0 -205
  89. package/dist/entities-DTNJMeVf.d.ts +0 -205
  90. package/dist/ports-C_OfflMQ.d.cts +0 -66
  91. package/dist/ports-C_OfflMQ.d.ts +0 -66
package/dist/index.cjs CHANGED
@@ -1,407 +1,79 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
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 });
11
13
  if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
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
+ });
15
20
  }
16
- return to;
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
+ });
17
37
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
38
 
20
39
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- BODY_VERSION_KEY: () => BODY_VERSION_KEY,
24
- Document: () => Document,
25
- arrayOf: () => arrayOf,
26
- booleanSchema: () => booleanSchema,
27
- canTransition: () => canTransition,
28
- canonicalOf: () => canonicalOf,
29
- documentBodyVersioning: () => documentBodyVersioning,
30
- documentEntities: () => documentEntities,
31
- documentIdentifiers: () => documentIdentifiers,
32
- enumOf: () => enumOf,
33
- fieldPatterns: () => fieldPatterns,
34
- isSystemActor: () => isSystemActor,
35
- isTerminalStatus: () => isTerminalStatus,
36
- literalOf: () => literalOf,
37
- merge: () => merge,
38
- migrateBody: () => migrateBody,
39
- nonEmptyString: () => nonEmptyString,
40
- nullable: () => nullable,
41
- numberSchema: () => numberSchema,
42
- objectOf: () => objectOf,
43
- optional: () => optional,
44
- positiveInt: () => positiveInt,
45
- stampBody: () => stampBody,
46
- stringSchema: () => stringSchema,
47
- systemActor: () => systemActor,
48
- unknownSchema: () => unknownSchema,
49
- validate: () => validate,
50
- validatorOf: () => validatorOf
51
- });
52
- module.exports = __toCommonJS(index_exports);
53
-
54
- // src/core/body-version.ts
55
- var BODY_VERSION_KEY = "_v";
56
- var versionOf = (body) => {
57
- const stamped = body[BODY_VERSION_KEY];
58
- return typeof stamped === "number" && Number.isInteger(stamped) ? stamped : 1;
59
- };
60
- var migrateBody = (definition, stored) => {
61
- if (stored === null || typeof stored !== "object" || Array.isArray(stored)) return stored;
62
- const target = definition.bodyVersion ?? 1;
63
- const steps = definition.migrations ?? {};
64
- let body = stored;
65
- for (let version = versionOf(body); version < target; version += 1) {
66
- const step = steps[version];
67
- if (step === void 0) break;
68
- body = step(body);
69
- }
70
- const { [BODY_VERSION_KEY]: _stamp, ...withoutStamp } = body;
71
- return withoutStamp;
72
- };
73
- var stampBody = (definition, body) => ({
74
- ...body,
75
- [BODY_VERSION_KEY]: definition.bodyVersion ?? 1
76
- });
77
- var documentBodyVersioning = (definition) => ({
78
- migrate: (stored) => migrateBody(definition, stored),
79
- stamp: (body) => stampBody(definition, body)
80
- });
81
-
82
- // src/core/document.ts
83
- var fieldPatterns = {
84
- calendarDate: /^\d{4}-\d{2}-\d{2}$/,
85
- decimal: /^-?\d+(?:\.\d+)?$/
86
- };
87
- var FIELD_CHECKS = {
88
- calendarDate: {
89
- message: "a calendar date is `YYYY-MM-DD`, never prose",
90
- test: (value) => typeof value === "string" && fieldPatterns.calendarDate.test(value)
91
- },
92
- decimal: {
93
- message: "an amount is a decimal string, never a float",
94
- test: (value) => typeof value === "string" && fieldPatterns.decimal.test(value)
95
- },
96
- int: {
97
- message: "an integer",
98
- test: (value) => typeof value === "number" && Number.isInteger(value)
99
- },
100
- positiveInt: {
101
- message: "a positive integer",
102
- test: (value) => typeof value === "number" && Number.isInteger(value) && value > 0
103
- },
104
- text: { message: "a string", test: (value) => typeof value === "string" }
105
- };
106
- var validatorOf = (fields, options) => {
107
- const nullable2 = options?.nullable ?? false;
108
- return {
109
- "~standard": {
110
- validate: (input) => {
111
- if (input === null || typeof input !== "object") {
112
- return { issues: [{ message: "expected an object" }] };
113
- }
114
- const record = input;
115
- const issues = [];
116
- const value = {};
117
- for (const [key, kind] of Object.entries(fields)) {
118
- const held = record[key];
119
- value[key] = held;
120
- if (nullable2 && held === null) continue;
121
- if (!FIELD_CHECKS[kind].test(held)) {
122
- issues.push({ message: FIELD_CHECKS[kind].message, path: [{ key }] });
123
- }
124
- }
125
- return issues.length > 0 ? { issues } : { value };
126
- },
127
- vendor: "geonosis-document",
128
- version: 1
129
- }
130
- };
131
- };
132
- var parseWith = (schema, input) => {
133
- const result = schema["~standard"].validate(input);
134
- if (result instanceof Promise) {
135
- throw new Error(
136
- "Document.head and Document.record parse synchronously; an async Standard Schema cannot back them"
137
- );
138
- }
139
- if (result.issues !== void 0) {
140
- throw new Error(result.issues.map((issue) => issue.message).join("; "));
141
- }
142
- return result.value;
143
- };
144
- var headFields = {
145
- status: "text",
146
- issueDate: "calendarDate",
147
- dueDate: "calendarDate",
148
- counterparty: "text",
149
- externalRef: "text",
150
- revision: "text",
151
- total: "decimal"
152
- };
153
- var recordFields = {
154
- version: "positiveInt",
155
- createdAt: "int",
156
- updatedAt: "int"
157
- };
158
- var headValidator = validatorOf(headFields, { nullable: true });
159
- var recordValidator = validatorOf(recordFields);
160
- var Document = {
161
- head: headValidator,
162
- headFields,
163
- record: recordValidator,
164
- recordFields,
165
- extend: (definition) => ({
166
- ...definition,
167
- headOf: (body) => parseWith(headValidator, definition.headOf(body)),
168
- is: (document) => document.entity === definition.name,
169
- view: definition.view ?? definition.body
170
- })
171
- };
172
-
173
- // src/core/entities.ts
174
- var documentEntities = (map) => {
175
- for (const [key, entity] of Object.entries(map)) {
176
- if (entity.name !== key) {
177
- throw new Error(
178
- `documentEntities was handed "${key}" for an entity whose own name is "${entity.name}": the map's key is what a row's \`entity\` column carries, and a mismatch here is a row nothing can find again`
179
- );
180
- }
181
- }
182
- const names = Object.keys(map);
183
- const values = Object.values(map);
184
- const fold = (pick) => values.map(pick);
185
- const distinctBy = (pick) => [
186
- ...new Set(fold(pick))
187
- ];
188
- return {
189
- bodies: distinctBy((entity) => entity.body),
190
- cards: distinctBy((entity) => entity.card.schema),
191
- entities: map,
192
- fold,
193
- instance: (name, parts) => ({ ...parts, entity: name, body: parts.body }),
194
- keyed: (pick) => Object.fromEntries(names.map((name) => [name, pick(map[name], name)])),
195
- named: (name) => map[name],
196
- names,
197
- views: distinctBy((entity) => entity.view)
198
- };
199
- };
200
-
201
- // src/core/schema.ts
202
- var VENDOR = "geonosis-document";
203
- var isString = (value) => typeof value === "string";
204
- var isNumber = (value) => typeof value === "number";
205
- var scalar = (test, message) => ({
206
- "~standard": {
207
- validate: (input) => test(input) ? { value: input } : { issues: [{ message }] },
208
- vendor: VENDOR,
209
- version: 1
210
- }
211
- });
212
- var stringSchema = scalar(isString, "expected a string");
213
- var numberSchema = scalar(isNumber, "expected a number");
214
- var booleanSchema = scalar(
215
- (value) => typeof value === "boolean",
216
- "expected a boolean"
217
- );
218
- var literalOf = (literal) => scalar(
219
- (value) => value === literal,
220
- `expected exactly ${JSON.stringify(literal)}`
221
- );
222
- var unknownSchema = {
223
- "~standard": { validate: (input) => ({ value: input }), vendor: VENDOR, version: 1 }
224
- };
225
- var syncResult = (schema, input) => {
226
- const result = schema["~standard"].validate(input);
227
- if (result instanceof Promise) {
228
- throw new Error(
229
- "a document surface schema validates synchronously; an async Standard Schema cannot back a row"
230
- );
231
- }
232
- return result;
233
- };
234
- var optional = (inner) => ({
235
- "~standard": {
236
- validate: (input) => input === void 0 ? { value: void 0 } : syncResult(inner, input),
237
- vendor: VENDOR,
238
- version: 1
239
- }
240
- });
241
- var nullable = (inner) => ({
242
- "~standard": {
243
- validate: (input) => input === null ? { value: null } : syncResult(inner, input),
244
- vendor: VENDOR,
245
- version: 1
246
- }
247
- });
248
- var arrayOf = (item) => ({
249
- "~standard": {
250
- validate: (input) => {
251
- if (!Array.isArray(input)) return { issues: [{ message: "expected an array" }] };
252
- const value = [];
253
- const issues = [];
254
- input.forEach((one, at) => {
255
- const result = syncResult(item, one);
256
- if (result.issues !== void 0) {
257
- issues.push(
258
- ...result.issues.map((issue) => ({ ...issue, path: [at, ...issue.path ?? []] }))
259
- );
260
- } else {
261
- value.push(result.value);
262
- }
263
- });
264
- return issues.length > 0 ? { issues } : { value };
265
- },
266
- vendor: VENDOR,
267
- version: 1
268
- }
269
- });
270
- var merge = (schemas) => ({
271
- "~standard": {
272
- validate: (input) => {
273
- let value = {};
274
- const issues = [];
275
- for (const schema of schemas) {
276
- const result = syncResult(schema, input);
277
- if (result.issues !== void 0) issues.push(...result.issues);
278
- else value = { ...value, ...result.value };
279
- }
280
- return issues.length > 0 ? { issues } : { value };
281
- },
282
- vendor: VENDOR,
283
- version: 1
284
- }
285
- });
286
- var nonEmptyString = scalar(
287
- (value) => typeof value === "string" && value.length > 0,
288
- "expected a non-empty string"
289
- );
290
- var positiveInt = scalar(
291
- (value) => Number.isInteger(value) && value > 0,
292
- "expected a positive integer"
293
- );
294
- var validate = async (schema, input) => {
295
- const result = await schema["~standard"].validate(input);
296
- if (result.issues !== void 0) {
297
- throw new Error(
298
- result.issues.map((issue) => {
299
- const path = (issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".");
300
- return path === "" ? issue.message : `${path}: ${issue.message}`;
301
- }).join("; ")
302
- );
303
- }
304
- return result.value;
305
- };
306
- var enumOf = (values) => scalar(
307
- (value) => typeof value === "string" && values.includes(value),
308
- `expected one of ${values.map((value) => JSON.stringify(value)).join(", ")}`
309
- );
310
- var settle = (fields) => {
311
- const value = {};
312
- const issues = [];
313
- for (const [key, result] of fields) {
314
- if (result.issues !== void 0) {
315
- issues.push(
316
- ...result.issues.map((issue) => ({ ...issue, path: [key, ...issue.path ?? []] }))
317
- );
318
- } else if (result.value !== void 0) {
319
- value[key] = result.value;
320
- }
321
- }
322
- return issues.length > 0 ? { issues } : { value };
323
- };
324
- var objectOf = (shape) => ({
325
- "~standard": {
326
- validate: (input) => {
327
- if (input === null || typeof input !== "object") {
328
- return { issues: [{ message: "expected an object" }] };
329
- }
330
- const record = input;
331
- const fields = Object.entries(shape).map(
332
- ([key, schema]) => [key, schema["~standard"].validate(record[key])]
333
- );
334
- return fields.some(([, result]) => result instanceof Promise) ? Promise.all(fields.map(async ([key, result]) => [key, await result])).then(
335
- settle
336
- ) : settle(fields);
337
- },
338
- vendor: VENDOR,
339
- version: 1
340
- }
341
- });
342
-
343
- // src/core/actor.ts
344
- var SYSTEM_PREFIX = "system:";
345
- var systemActor = (name) => `${SYSTEM_PREFIX}${name}`;
346
- var isSystemActor = (actor) => actor.startsWith(SYSTEM_PREFIX);
347
-
348
- // src/core/canonical.ts
349
- var KEY_ORDER = new Intl.Collator("en-US");
350
- var canonicalOf = (input) => {
351
- if (input === null || typeof input !== "object") return input;
352
- const { toJSON } = input;
353
- if (typeof toJSON === "function") return canonicalOf(toJSON.call(input));
354
- if (Array.isArray(input)) return input.map(canonicalOf);
355
- return Object.fromEntries(
356
- Object.entries(input).toSorted(([a], [b]) => KEY_ORDER.compare(a, b)).map(([key, held]) => [key, canonicalOf(held)])
357
- );
358
- };
359
-
360
- // src/core/naming.ts
361
- var camelOf = (name) => name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
362
- var documentIdentifiers = (name) => {
363
- const camel = camelOf(name);
364
- return {
365
- camel,
366
- pascal: `${camel[0]?.toUpperCase() ?? ""}${camel.slice(1)}`,
367
- pluralCamel: `${camel}s`,
368
- snake: name.replaceAll("-", "_"),
369
- snakePlural: `${name.replaceAll("-", "_")}s`,
370
- path: `/${name}s`
371
- };
372
- };
373
-
374
- // src/core/status.ts
375
- var canTransition = (machine, from, to) => machine.transitions[from].includes(to);
376
- var isTerminalStatus = (machine, status) => machine.transitions[status].length === 0;
377
- // Annotate the CommonJS export names for ESM import in node:
378
- 0 && (module.exports = {
379
- BODY_VERSION_KEY,
380
- Document,
381
- arrayOf,
382
- booleanSchema,
383
- canTransition,
384
- canonicalOf,
385
- documentBodyVersioning,
386
- documentEntities,
387
- documentIdentifiers,
388
- enumOf,
389
- fieldPatterns,
390
- isSystemActor,
391
- isTerminalStatus,
392
- literalOf,
393
- merge,
394
- migrateBody,
395
- nonEmptyString,
396
- nullable,
397
- numberSchema,
398
- objectOf,
399
- optional,
400
- positiveInt,
401
- stampBody,
402
- stringSchema,
403
- systemActor,
404
- unknownSchema,
405
- validate,
406
- validatorOf
40
+ var exports_src = {};
41
+ __export(exports_src, {
42
+ BODY_VERSION_KEY: () => import_body_version.BODY_VERSION_KEY,
43
+ Document: () => import_document.Document,
44
+ arrayOf: () => import_schema.arrayOf,
45
+ booleanSchema: () => import_schema.booleanSchema,
46
+ canTransition: () => import_status.canTransition,
47
+ canonicalOf: () => import_canonical.canonicalOf,
48
+ documentBodyVersioning: () => import_body_version.documentBodyVersioning,
49
+ documentEntities: () => import_entities.documentEntities,
50
+ documentIdentifiers: () => import_naming.documentIdentifiers,
51
+ enumOf: () => import_schema.enumOf,
52
+ fieldPatterns: () => import_document.fieldPatterns,
53
+ isSystemActor: () => import_actor.isSystemActor,
54
+ isTerminalStatus: () => import_status.isTerminalStatus,
55
+ literalOf: () => import_schema.literalOf,
56
+ merge: () => import_schema.merge,
57
+ migrateBody: () => import_body_version.migrateBody,
58
+ nonEmptyString: () => import_schema.nonEmptyString,
59
+ nullable: () => import_schema.nullable,
60
+ numberSchema: () => import_schema.numberSchema,
61
+ objectOf: () => import_schema.objectOf,
62
+ optional: () => import_schema.optional,
63
+ positiveInt: () => import_schema.positiveInt,
64
+ stampBody: () => import_body_version.stampBody,
65
+ stringSchema: () => import_schema.stringSchema,
66
+ systemActor: () => import_actor.systemActor,
67
+ unknownSchema: () => import_schema.unknownSchema,
68
+ validate: () => import_schema.validate,
69
+ validatorOf: () => import_document.validatorOf
407
70
  });
71
+ module.exports = __toCommonJS(exports_src);
72
+ var import_body_version = require("./core/body-version.cjs");
73
+ var import_document = require("./core/document.cjs");
74
+ var import_entities = require("./core/entities.cjs");
75
+ var import_schema = require("./core/schema.cjs");
76
+ var import_actor = require("./core/actor.cjs");
77
+ var import_canonical = require("./core/canonical.cjs");
78
+ var import_naming = require("./core/naming.cjs");
79
+ var import_status = require("./core/status.cjs");
package/dist/index.d.cts CHANGED
@@ -1,32 +1,11 @@
1
- export { A as AnyDocumentEntity, B as BODY_VERSION_KEY, a as BodyOf, C as CardOf, D as Document, b as DocumentBodyMigrations, c as DocumentBodyVersion, d as DocumentDefinition, e as DocumentEntity, f as DocumentHead, g as DocumentInstance, h as DocumentNumbering, i as DocumentRecord, j as DocumentStatusMachine, k as DraftOf, F as FieldKind, I as IncomingOf, l as InstanceOf, N as NameOf, S as StatusOf, V as ViewOf, m as canTransition, n as documentBodyVersioning, o as documentEntities, p as fieldPatterns, q as isTerminalStatus, r as migrateBody, s as stampBody, v as validatorOf } from './entities-DTNJMeVf.cjs';
2
- export { A as ArchivePort, L as LinkVerifierPort, S as SchemaAdapter, T as TimestampPort, a as arrayOf, b as booleanSchema, e as enumOf, l as literalOf, m as merge, n as nonEmptyString, c as nullable, d as numberSchema, o as objectOf, f as optional, p as positiveInt, s as stringSchema, u as unknownSchema, v as validate } from './ports-C_OfflMQ.cjs';
3
- export { StandardSchemaV1 } from '@standard-schema/spec';
4
-
5
- /** An unattended write's principal — `systemActor('recurring.generate')` — never a bare `'system'`. */
6
- declare const systemActor: (name: string) => string;
7
- declare const isSystemActor: (actor: string) => boolean;
8
-
9
- /**
10
- * Deep, key-order-independent, and read as JSON writes it (a `Date` is its ISO string). The ONE
11
- * canonicaliser both sides use — a consumer's archive recomputes `hashOf` over the identical form.
12
- */
13
- declare const canonicalOf: (input: unknown) => unknown;
14
-
15
- /** `purchase-order` → `purchaseOrder`, at the type level and at runtime alike. */
16
- type CamelOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelOf<Tail>>}` : Name;
17
- type SnakeOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}_${SnakeOf<Tail>}` : Name;
18
- /**
19
- * Every spelling a surface needs, derived from one hyphenated entity name — as literal types, so
20
- * a consumer keys a router map or a path table by them without a cast.
21
- */
22
- type DocumentIdentifiers<Name extends string> = {
23
- camel: CamelOf<Name>;
24
- pascal: Capitalize<CamelOf<Name>>;
25
- pluralCamel: `${CamelOf<Name>}s`;
26
- snake: SnakeOf<Name>;
27
- snakePlural: `${SnakeOf<Name>}s`;
28
- path: `/${Name}s`;
29
- };
30
- declare const documentIdentifiers: <Name extends string>(name: Name) => DocumentIdentifiers<Name>;
31
-
32
- export { type CamelOf, type DocumentIdentifiers, canonicalOf, documentIdentifiers, isSystemActor, systemActor };
1
+ export { BODY_VERSION_KEY, documentBodyVersioning, migrateBody, stampBody, type DocumentBodyMigrations, type DocumentBodyVersion } from './core/body-version.cjs';
2
+ export { Document, fieldPatterns, validatorOf, type BodyOf, type CardOf, type DocumentDefinition, type DocumentEntity, type DocumentHead, type DocumentInstance, type DocumentRecord, type DraftOf, type FieldKind, type IncomingOf, type InstanceOf, type NameOf, type StatusOf, type ViewOf } from './core/document.cjs';
3
+ export { documentEntities, type AnyDocumentEntity } from './core/entities.cjs';
4
+ export { arrayOf, booleanSchema, enumOf, literalOf, merge, nonEmptyString, nullable, numberSchema, objectOf, optional, positiveInt, type SchemaAdapter, stringSchema, unknownSchema, validate } from './core/schema.cjs';
5
+ export { isSystemActor, systemActor } from './core/actor.cjs';
6
+ export { canonicalOf } from './core/canonical.cjs';
7
+ export { type CamelOf, type DocumentIdentifiers, documentIdentifiers } from './core/naming.cjs';
8
+ export type { DocumentNumbering } from './core/numbering.cjs';
9
+ export type { ArchivePort, LinkVerifierPort, TimestampPort } from './core/ports.cjs';
10
+ export { canTransition, isTerminalStatus, type DocumentStatusMachine } from './core/status.cjs';
11
+ export type { StandardSchemaV1 } from '@standard-schema/spec';
package/dist/index.d.ts CHANGED
@@ -1,32 +1,11 @@
1
- export { A as AnyDocumentEntity, B as BODY_VERSION_KEY, a as BodyOf, C as CardOf, D as Document, b as DocumentBodyMigrations, c as DocumentBodyVersion, d as DocumentDefinition, e as DocumentEntity, f as DocumentHead, g as DocumentInstance, h as DocumentNumbering, i as DocumentRecord, j as DocumentStatusMachine, k as DraftOf, F as FieldKind, I as IncomingOf, l as InstanceOf, N as NameOf, S as StatusOf, V as ViewOf, m as canTransition, n as documentBodyVersioning, o as documentEntities, p as fieldPatterns, q as isTerminalStatus, r as migrateBody, s as stampBody, v as validatorOf } from './entities-DTNJMeVf.js';
2
- export { A as ArchivePort, L as LinkVerifierPort, S as SchemaAdapter, T as TimestampPort, a as arrayOf, b as booleanSchema, e as enumOf, l as literalOf, m as merge, n as nonEmptyString, c as nullable, d as numberSchema, o as objectOf, f as optional, p as positiveInt, s as stringSchema, u as unknownSchema, v as validate } from './ports-C_OfflMQ.js';
3
- export { StandardSchemaV1 } from '@standard-schema/spec';
4
-
5
- /** An unattended write's principal — `systemActor('recurring.generate')` — never a bare `'system'`. */
6
- declare const systemActor: (name: string) => string;
7
- declare const isSystemActor: (actor: string) => boolean;
8
-
9
- /**
10
- * Deep, key-order-independent, and read as JSON writes it (a `Date` is its ISO string). The ONE
11
- * canonicaliser both sides use — a consumer's archive recomputes `hashOf` over the identical form.
12
- */
13
- declare const canonicalOf: (input: unknown) => unknown;
14
-
15
- /** `purchase-order` → `purchaseOrder`, at the type level and at runtime alike. */
16
- type CamelOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelOf<Tail>>}` : Name;
17
- type SnakeOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}_${SnakeOf<Tail>}` : Name;
18
- /**
19
- * Every spelling a surface needs, derived from one hyphenated entity name — as literal types, so
20
- * a consumer keys a router map or a path table by them without a cast.
21
- */
22
- type DocumentIdentifiers<Name extends string> = {
23
- camel: CamelOf<Name>;
24
- pascal: Capitalize<CamelOf<Name>>;
25
- pluralCamel: `${CamelOf<Name>}s`;
26
- snake: SnakeOf<Name>;
27
- snakePlural: `${SnakeOf<Name>}s`;
28
- path: `/${Name}s`;
29
- };
30
- declare const documentIdentifiers: <Name extends string>(name: Name) => DocumentIdentifiers<Name>;
31
-
32
- export { type CamelOf, type DocumentIdentifiers, canonicalOf, documentIdentifiers, isSystemActor, systemActor };
1
+ export { BODY_VERSION_KEY, documentBodyVersioning, migrateBody, stampBody, type DocumentBodyMigrations, type DocumentBodyVersion } from './core/body-version.js';
2
+ export { Document, fieldPatterns, validatorOf, type BodyOf, type CardOf, type DocumentDefinition, type DocumentEntity, type DocumentHead, type DocumentInstance, type DocumentRecord, type DraftOf, type FieldKind, type IncomingOf, type InstanceOf, type NameOf, type StatusOf, type ViewOf } from './core/document.js';
3
+ export { documentEntities, type AnyDocumentEntity } from './core/entities.js';
4
+ export { arrayOf, booleanSchema, enumOf, literalOf, merge, nonEmptyString, nullable, numberSchema, objectOf, optional, positiveInt, type SchemaAdapter, stringSchema, unknownSchema, validate } from './core/schema.js';
5
+ export { isSystemActor, systemActor } from './core/actor.js';
6
+ export { canonicalOf } from './core/canonical.js';
7
+ export { type CamelOf, type DocumentIdentifiers, documentIdentifiers } from './core/naming.js';
8
+ export type { DocumentNumbering } from './core/numbering.js';
9
+ export type { ArchivePort, LinkVerifierPort, TimestampPort } from './core/ports.js';
10
+ export { canTransition, isTerminalStatus, type DocumentStatusMachine } from './core/status.js';
11
+ export type { StandardSchemaV1 } from '@standard-schema/spec';
package/dist/index.js CHANGED
@@ -1,21 +1,20 @@
1
+ // src/index.ts
1
2
  import {
2
3
  BODY_VERSION_KEY,
3
- Document,
4
- canonicalOf,
5
4
  documentBodyVersioning,
6
- documentEntities,
7
- fieldPatterns,
8
5
  migrateBody,
9
- stampBody,
6
+ stampBody
7
+ } from "./core/body-version.js";
8
+ import {
9
+ Document,
10
+ fieldPatterns,
10
11
  validatorOf
11
- } from "./chunk-A6ZU4QU3.js";
12
+ } from "./core/document.js";
13
+ import { documentEntities } from "./core/entities.js";
12
14
  import {
13
15
  arrayOf,
14
16
  booleanSchema,
15
- canTransition,
16
17
  enumOf,
17
- isSystemActor,
18
- isTerminalStatus,
19
18
  literalOf,
20
19
  merge,
21
20
  nonEmptyString,
@@ -25,24 +24,13 @@ import {
25
24
  optional,
26
25
  positiveInt,
27
26
  stringSchema,
28
- systemActor,
29
27
  unknownSchema,
30
28
  validate
31
- } from "./chunk-NA3DLROL.js";
32
-
33
- // src/core/naming.ts
34
- var camelOf = (name) => name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
35
- var documentIdentifiers = (name) => {
36
- const camel = camelOf(name);
37
- return {
38
- camel,
39
- pascal: `${camel[0]?.toUpperCase() ?? ""}${camel.slice(1)}`,
40
- pluralCamel: `${camel}s`,
41
- snake: name.replaceAll("-", "_"),
42
- snakePlural: `${name.replaceAll("-", "_")}s`,
43
- path: `/${name}s`
44
- };
45
- };
29
+ } from "./core/schema.js";
30
+ import { isSystemActor, systemActor } from "./core/actor.js";
31
+ import { canonicalOf } from "./core/canonical.js";
32
+ import { documentIdentifiers } from "./core/naming.js";
33
+ import { canTransition, isTerminalStatus } from "./core/status.js";
46
34
  export {
47
35
  BODY_VERSION_KEY,
48
36
  Document,