@geonosis/document 0.6.0 → 0.7.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 +44 -5
- package/dist/{chunk-WWP7MNI7.js → chunk-7P6FV2YX.js} +2 -14
- package/dist/chunk-NA3DLROL.js +171 -0
- package/dist/{ports-D0NtPwAO.d.cts → entities-DTNJMeVf.d.cts} +3 -31
- package/dist/{ports-D0NtPwAO.d.ts → entities-DTNJMeVf.d.ts} +3 -31
- package/dist/index.cjs +173 -2
- package/dist/index.d.cts +18 -10
- package/dist/index.d.ts +18 -10
- package/dist/index.js +35 -5
- package/dist/ports-C_OfflMQ.d.cts +66 -0
- package/dist/ports-C_OfflMQ.d.ts +66 -0
- package/dist/store.cjs +15 -5
- package/dist/store.d.cts +8 -12
- package/dist/store.d.ts +8 -12
- package/dist/store.js +15 -88
- package/dist/workflows.cjs +513 -0
- package/dist/workflows.d.cts +310 -0
- package/dist/workflows.d.ts +310 -0
- package/dist/workflows.js +386 -0
- package/package.json +14 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AnyDocumentEntity,
|
|
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';
|
|
2
3
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
4
|
|
|
4
5
|
/** An unattended write's principal — `systemActor('recurring.generate')` — never a bare `'system'`. */
|
|
@@ -12,14 +13,21 @@ declare const isSystemActor: (actor: string) => boolean;
|
|
|
12
13
|
*/
|
|
13
14
|
declare const canonicalOf: (input: unknown) => unknown;
|
|
14
15
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
/** `purchase-order` → `purchaseOrder`, at the type level and at runtime alike. */
|
|
17
|
+
type CamelOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelOf<Tail>>}` : Name;
|
|
18
|
+
type SnakeOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}_${SnakeOf<Tail>}` : Name;
|
|
19
|
+
/**
|
|
20
|
+
* Every spelling a surface needs, derived from one hyphenated entity name — as literal types, so
|
|
21
|
+
* a consumer keys a router map or a path table by them without a cast.
|
|
22
|
+
*/
|
|
23
|
+
type DocumentIdentifiers<Name extends string> = {
|
|
24
|
+
camel: CamelOf<Name>;
|
|
25
|
+
pascal: Capitalize<CamelOf<Name>>;
|
|
26
|
+
pluralCamel: `${CamelOf<Name>}s`;
|
|
27
|
+
snake: SnakeOf<Name>;
|
|
28
|
+
snakePlural: `${SnakeOf<Name>}s`;
|
|
29
|
+
path: `/${Name}s`;
|
|
23
30
|
};
|
|
31
|
+
declare const documentIdentifiers: <Name extends string>(name: Name) => DocumentIdentifiers<Name>;
|
|
24
32
|
|
|
25
|
-
export { canonicalOf, documentIdentifiers, isSystemActor, systemActor };
|
|
33
|
+
export { type CamelOf, type DocumentIdentifiers, canonicalOf, documentIdentifiers, isSystemActor, systemActor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AnyDocumentEntity,
|
|
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';
|
|
2
3
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
4
|
|
|
4
5
|
/** An unattended write's principal — `systemActor('recurring.generate')` — never a bare `'system'`. */
|
|
@@ -12,14 +13,21 @@ declare const isSystemActor: (actor: string) => boolean;
|
|
|
12
13
|
*/
|
|
13
14
|
declare const canonicalOf: (input: unknown) => unknown;
|
|
14
15
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
/** `purchase-order` → `purchaseOrder`, at the type level and at runtime alike. */
|
|
17
|
+
type CamelOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelOf<Tail>>}` : Name;
|
|
18
|
+
type SnakeOf<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Head}_${SnakeOf<Tail>}` : Name;
|
|
19
|
+
/**
|
|
20
|
+
* Every spelling a surface needs, derived from one hyphenated entity name — as literal types, so
|
|
21
|
+
* a consumer keys a router map or a path table by them without a cast.
|
|
22
|
+
*/
|
|
23
|
+
type DocumentIdentifiers<Name extends string> = {
|
|
24
|
+
camel: CamelOf<Name>;
|
|
25
|
+
pascal: Capitalize<CamelOf<Name>>;
|
|
26
|
+
pluralCamel: `${CamelOf<Name>}s`;
|
|
27
|
+
snake: SnakeOf<Name>;
|
|
28
|
+
snakePlural: `${SnakeOf<Name>}s`;
|
|
29
|
+
path: `/${Name}s`;
|
|
23
30
|
};
|
|
31
|
+
declare const documentIdentifiers: <Name extends string>(name: Name) => DocumentIdentifiers<Name>;
|
|
24
32
|
|
|
25
|
-
export { canonicalOf, documentIdentifiers, isSystemActor, systemActor };
|
|
33
|
+
export { type CamelOf, type DocumentIdentifiers, canonicalOf, documentIdentifiers, isSystemActor, systemActor };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BODY_VERSION_KEY,
|
|
3
3
|
Document,
|
|
4
|
-
canTransition,
|
|
5
4
|
canonicalOf,
|
|
6
5
|
documentBodyVersioning,
|
|
7
6
|
documentEntities,
|
|
8
7
|
fieldPatterns,
|
|
9
|
-
isSystemActor,
|
|
10
|
-
isTerminalStatus,
|
|
11
8
|
migrateBody,
|
|
12
9
|
stampBody,
|
|
13
|
-
systemActor,
|
|
14
10
|
validatorOf
|
|
15
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7P6FV2YX.js";
|
|
12
|
+
import {
|
|
13
|
+
arrayOf,
|
|
14
|
+
booleanSchema,
|
|
15
|
+
canTransition,
|
|
16
|
+
enumOf,
|
|
17
|
+
isSystemActor,
|
|
18
|
+
isTerminalStatus,
|
|
19
|
+
literalOf,
|
|
20
|
+
merge,
|
|
21
|
+
nonEmptyString,
|
|
22
|
+
nullable,
|
|
23
|
+
numberSchema,
|
|
24
|
+
objectOf,
|
|
25
|
+
optional,
|
|
26
|
+
positiveInt,
|
|
27
|
+
stringSchema,
|
|
28
|
+
systemActor,
|
|
29
|
+
unknownSchema,
|
|
30
|
+
validate
|
|
31
|
+
} from "./chunk-NA3DLROL.js";
|
|
16
32
|
|
|
17
33
|
// src/core/naming.ts
|
|
18
34
|
var camelOf = (name) => name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -30,16 +46,30 @@ var documentIdentifiers = (name) => {
|
|
|
30
46
|
export {
|
|
31
47
|
BODY_VERSION_KEY,
|
|
32
48
|
Document,
|
|
49
|
+
arrayOf,
|
|
50
|
+
booleanSchema,
|
|
33
51
|
canTransition,
|
|
34
52
|
canonicalOf,
|
|
35
53
|
documentBodyVersioning,
|
|
36
54
|
documentEntities,
|
|
37
55
|
documentIdentifiers,
|
|
56
|
+
enumOf,
|
|
38
57
|
fieldPatterns,
|
|
39
58
|
isSystemActor,
|
|
40
59
|
isTerminalStatus,
|
|
60
|
+
literalOf,
|
|
61
|
+
merge,
|
|
41
62
|
migrateBody,
|
|
63
|
+
nonEmptyString,
|
|
64
|
+
nullable,
|
|
65
|
+
numberSchema,
|
|
66
|
+
objectOf,
|
|
67
|
+
optional,
|
|
68
|
+
positiveInt,
|
|
42
69
|
stampBody,
|
|
70
|
+
stringSchema,
|
|
43
71
|
systemActor,
|
|
72
|
+
unknownSchema,
|
|
73
|
+
validate,
|
|
44
74
|
validatorOf
|
|
45
75
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The three builders a validator library supplies so the surface and the workflows stay library-free
|
|
5
|
+
* (#383) while the union/enum/object they derive are still real schemas of THAT library — the one
|
|
6
|
+
* place a consumer's zod enters `@geonosis/document` is through this adapter, never a dependency.
|
|
7
|
+
*/
|
|
8
|
+
type SchemaAdapter = {
|
|
9
|
+
enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
|
|
10
|
+
object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
|
|
11
|
+
union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
|
|
12
|
+
};
|
|
13
|
+
declare const stringSchema: StandardSchemaV1<unknown, string>;
|
|
14
|
+
declare const numberSchema: StandardSchemaV1<unknown, number>;
|
|
15
|
+
declare const booleanSchema: StandardSchemaV1<unknown, boolean>;
|
|
16
|
+
declare const literalOf: <Value extends boolean | string>(literal: Value) => StandardSchemaV1<unknown, Value>;
|
|
17
|
+
/** A passthrough for a shape this ticket declares but does not itself narrow further. */
|
|
18
|
+
declare const unknownSchema: StandardSchemaV1<unknown, unknown>;
|
|
19
|
+
declare const optional: <Output>(inner: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output | undefined>;
|
|
20
|
+
declare const nullable: <Output>(inner: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output | null>;
|
|
21
|
+
declare const arrayOf: <Output>(item: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output[]>;
|
|
22
|
+
/** Every schema's own issues, folded into one — the merged VALUE is every schema's fields, spread. */
|
|
23
|
+
declare const merge: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1<unknown, Readonly<Record<string, unknown>>>;
|
|
24
|
+
declare const nonEmptyString: StandardSchemaV1<unknown, string>;
|
|
25
|
+
declare const positiveInt: StandardSchemaV1<unknown, number>;
|
|
26
|
+
/** One value through one schema, whichever library wrote it; the issues are the refusal's text. */
|
|
27
|
+
declare const validate: <Output>(schema: StandardSchemaV1<unknown, Output>, input: unknown) => Promise<Output>;
|
|
28
|
+
declare const enumOf: <Value extends string>(values: readonly Value[]) => StandardSchemaV1<unknown, Value>;
|
|
29
|
+
/**
|
|
30
|
+
* An object of named fields, each through its own schema — the one builder a workflow input needs
|
|
31
|
+
* that the adapter is not asked for, since a run's input is refused by the engine and never rendered
|
|
32
|
+
* by a host's own library. Async when a field's schema is; unknown keys are dropped.
|
|
33
|
+
*/
|
|
34
|
+
declare const objectOf: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1<unknown, Record<string, unknown>>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The archive's own key convention: `<tenant>/<entity>/<lineage>/<version>.json` — one object per
|
|
38
|
+
* revision, named so a lineage's own history sits together and a new lineage (`succeed`) never
|
|
39
|
+
* collides with the one it replaced.
|
|
40
|
+
*/
|
|
41
|
+
type ArchivePort = {
|
|
42
|
+
head: (key: string) => Promise<{
|
|
43
|
+
hash: string;
|
|
44
|
+
} | null>;
|
|
45
|
+
put: (key: string, bytes: Uint8Array, meta: {
|
|
46
|
+
hash: string;
|
|
47
|
+
immutable: true;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
/** A trusted third party's timestamp over a hash — never implemented here, only declared. */
|
|
51
|
+
type TimestampPort = {
|
|
52
|
+
stamp: (hash: string) => Promise<{
|
|
53
|
+
at: number;
|
|
54
|
+
token: Uint8Array;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
type LinkVerifierPort = {
|
|
58
|
+
verify: (token: string) => Promise<{
|
|
59
|
+
entity: string;
|
|
60
|
+
exp: number;
|
|
61
|
+
org: string;
|
|
62
|
+
ref: string;
|
|
63
|
+
} | null>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { type ArchivePort as A, type LinkVerifierPort as L, type SchemaAdapter as S, type TimestampPort as T, arrayOf as a, booleanSchema as b, nullable as c, numberSchema as d, enumOf as e, optional as f, literalOf as l, merge as m, nonEmptyString as n, objectOf as o, positiveInt as p, stringSchema as s, unknownSchema as u, validate as v };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The three builders a validator library supplies so the surface and the workflows stay library-free
|
|
5
|
+
* (#383) while the union/enum/object they derive are still real schemas of THAT library — the one
|
|
6
|
+
* place a consumer's zod enters `@geonosis/document` is through this adapter, never a dependency.
|
|
7
|
+
*/
|
|
8
|
+
type SchemaAdapter = {
|
|
9
|
+
enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
|
|
10
|
+
object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
|
|
11
|
+
union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
|
|
12
|
+
};
|
|
13
|
+
declare const stringSchema: StandardSchemaV1<unknown, string>;
|
|
14
|
+
declare const numberSchema: StandardSchemaV1<unknown, number>;
|
|
15
|
+
declare const booleanSchema: StandardSchemaV1<unknown, boolean>;
|
|
16
|
+
declare const literalOf: <Value extends boolean | string>(literal: Value) => StandardSchemaV1<unknown, Value>;
|
|
17
|
+
/** A passthrough for a shape this ticket declares but does not itself narrow further. */
|
|
18
|
+
declare const unknownSchema: StandardSchemaV1<unknown, unknown>;
|
|
19
|
+
declare const optional: <Output>(inner: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output | undefined>;
|
|
20
|
+
declare const nullable: <Output>(inner: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output | null>;
|
|
21
|
+
declare const arrayOf: <Output>(item: StandardSchemaV1<unknown, Output>) => StandardSchemaV1<unknown, Output[]>;
|
|
22
|
+
/** Every schema's own issues, folded into one — the merged VALUE is every schema's fields, spread. */
|
|
23
|
+
declare const merge: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1<unknown, Readonly<Record<string, unknown>>>;
|
|
24
|
+
declare const nonEmptyString: StandardSchemaV1<unknown, string>;
|
|
25
|
+
declare const positiveInt: StandardSchemaV1<unknown, number>;
|
|
26
|
+
/** One value through one schema, whichever library wrote it; the issues are the refusal's text. */
|
|
27
|
+
declare const validate: <Output>(schema: StandardSchemaV1<unknown, Output>, input: unknown) => Promise<Output>;
|
|
28
|
+
declare const enumOf: <Value extends string>(values: readonly Value[]) => StandardSchemaV1<unknown, Value>;
|
|
29
|
+
/**
|
|
30
|
+
* An object of named fields, each through its own schema — the one builder a workflow input needs
|
|
31
|
+
* that the adapter is not asked for, since a run's input is refused by the engine and never rendered
|
|
32
|
+
* by a host's own library. Async when a field's schema is; unknown keys are dropped.
|
|
33
|
+
*/
|
|
34
|
+
declare const objectOf: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1<unknown, Record<string, unknown>>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The archive's own key convention: `<tenant>/<entity>/<lineage>/<version>.json` — one object per
|
|
38
|
+
* revision, named so a lineage's own history sits together and a new lineage (`succeed`) never
|
|
39
|
+
* collides with the one it replaced.
|
|
40
|
+
*/
|
|
41
|
+
type ArchivePort = {
|
|
42
|
+
head: (key: string) => Promise<{
|
|
43
|
+
hash: string;
|
|
44
|
+
} | null>;
|
|
45
|
+
put: (key: string, bytes: Uint8Array, meta: {
|
|
46
|
+
hash: string;
|
|
47
|
+
immutable: true;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
/** A trusted third party's timestamp over a hash — never implemented here, only declared. */
|
|
51
|
+
type TimestampPort = {
|
|
52
|
+
stamp: (hash: string) => Promise<{
|
|
53
|
+
at: number;
|
|
54
|
+
token: Uint8Array;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
type LinkVerifierPort = {
|
|
58
|
+
verify: (token: string) => Promise<{
|
|
59
|
+
entity: string;
|
|
60
|
+
exp: number;
|
|
61
|
+
org: string;
|
|
62
|
+
ref: string;
|
|
63
|
+
} | null>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { type ArchivePort as A, type LinkVerifierPort as L, type SchemaAdapter as S, type TimestampPort as T, arrayOf as a, booleanSchema as b, nullable as c, numberSchema as d, enumOf as e, optional as f, literalOf as l, merge as m, nonEmptyString as n, objectOf as o, positiveInt as p, stringSchema as s, unknownSchema as u, validate as v };
|
package/dist/store.cjs
CHANGED
|
@@ -141,11 +141,8 @@ var Document = {
|
|
|
141
141
|
})
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
// src/core/
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
// src/surface/table.ts
|
|
148
|
-
var VENDOR = "geonosis-document-surface";
|
|
144
|
+
// src/core/schema.ts
|
|
145
|
+
var VENDOR = "geonosis-document";
|
|
149
146
|
var isString = (value) => typeof value === "string";
|
|
150
147
|
var isNumber = (value) => typeof value === "number";
|
|
151
148
|
var scalar = (test, message) => ({
|
|
@@ -229,6 +226,19 @@ var merge = (schemas) => ({
|
|
|
229
226
|
version: 1
|
|
230
227
|
}
|
|
231
228
|
});
|
|
229
|
+
var nonEmptyString = scalar(
|
|
230
|
+
(value) => typeof value === "string" && value.length > 0,
|
|
231
|
+
"expected a non-empty string"
|
|
232
|
+
);
|
|
233
|
+
var positiveInt = scalar(
|
|
234
|
+
(value) => Number.isInteger(value) && value > 0,
|
|
235
|
+
"expected a positive integer"
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
// src/core/status.ts
|
|
239
|
+
var canTransition = (machine, from, to) => machine.transitions[from].includes(to);
|
|
240
|
+
|
|
241
|
+
// src/surface/table.ts
|
|
232
242
|
var doorFor = (store, name) => {
|
|
233
243
|
const door = store[name];
|
|
234
244
|
if (door === void 0) {
|
package/dist/store.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import {
|
|
2
|
+
import { f as DocumentHead, A as AnyDocumentEntity, b as DocumentBodyMigrations, g as DocumentInstance, o as documentEntities, j as DocumentStatusMachine } from './entities-DTNJMeVf.cjs';
|
|
3
|
+
import { A as ArchivePort, S as SchemaAdapter } from './ports-C_OfflMQ.cjs';
|
|
3
4
|
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, SessionSeam } from '@geonosis/db';
|
|
4
5
|
export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
5
6
|
|
|
@@ -63,7 +64,8 @@ type DocumentStoreOptions<Map extends Readonly<Record<string, StorableDocumentEn
|
|
|
63
64
|
seam: SessionSeam<Key, Handle>;
|
|
64
65
|
table?: string;
|
|
65
66
|
};
|
|
66
|
-
|
|
67
|
+
/** What a head projection may carry: the business head, the entity, the number, and the record's clocks. */
|
|
68
|
+
type HeadColumn = HeadField | 'createdAt' | 'entity' | 'number' | 'updatedAt';
|
|
67
69
|
type DocumentSortColumn = HeadField | 'createdAt' | 'number' | 'updatedAt';
|
|
68
70
|
type HeadsOrder = {
|
|
69
71
|
column: DocumentSortColumn | 'entity';
|
|
@@ -74,8 +76,10 @@ type HeadsWhere = Readonly<Partial<Record<HeadField | 'createdAt' | 'updatedAt',
|
|
|
74
76
|
to: unknown;
|
|
75
77
|
}>>>;
|
|
76
78
|
type HeadRow<Columns extends readonly HeadColumn[]> = Pick<DocumentHead & {
|
|
79
|
+
createdAt: number;
|
|
77
80
|
entity: string;
|
|
78
81
|
number: string;
|
|
82
|
+
updatedAt: number;
|
|
79
83
|
}, Columns[number]>;
|
|
80
84
|
type HeadsArgs<Columns extends readonly HeadColumn[] = readonly HeadColumn[]> = {
|
|
81
85
|
columns: Columns;
|
|
@@ -225,6 +229,8 @@ type PendingCall = {
|
|
|
225
229
|
* compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
|
|
226
230
|
*/
|
|
227
231
|
type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
|
|
232
|
+
/** The adapter as the surface first named it; the builders live in the core now. */
|
|
233
|
+
type SurfaceSchemaAdapter = SchemaAdapter;
|
|
228
234
|
type SurfaceRow = {
|
|
229
235
|
call: PendingCall | SurfaceCall;
|
|
230
236
|
input: StandardSchemaV1;
|
|
@@ -234,16 +240,6 @@ type SurfaceRow = {
|
|
|
234
240
|
scope: SurfaceScope;
|
|
235
241
|
verb: SurfaceVerb;
|
|
236
242
|
};
|
|
237
|
-
/**
|
|
238
|
-
* The three builders a validator library supplies so the table stays library-free (#383) while the
|
|
239
|
-
* union/enum/object it derives are still real schemas of THAT library — the one place a consumer's
|
|
240
|
-
* zod enters `@geonosis/document` is through this adapter, never a direct dependency.
|
|
241
|
-
*/
|
|
242
|
-
type SurfaceSchemaAdapter = {
|
|
243
|
-
enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
|
|
244
|
-
object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
|
|
245
|
-
union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
|
|
246
|
-
};
|
|
247
243
|
/**
|
|
248
244
|
* What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
|
|
249
245
|
* what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import {
|
|
2
|
+
import { f as DocumentHead, A as AnyDocumentEntity, b as DocumentBodyMigrations, g as DocumentInstance, o as documentEntities, j as DocumentStatusMachine } from './entities-DTNJMeVf.js';
|
|
3
|
+
import { A as ArchivePort, S as SchemaAdapter } from './ports-C_OfflMQ.js';
|
|
3
4
|
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, SessionSeam } from '@geonosis/db';
|
|
4
5
|
export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
5
6
|
|
|
@@ -63,7 +64,8 @@ type DocumentStoreOptions<Map extends Readonly<Record<string, StorableDocumentEn
|
|
|
63
64
|
seam: SessionSeam<Key, Handle>;
|
|
64
65
|
table?: string;
|
|
65
66
|
};
|
|
66
|
-
|
|
67
|
+
/** What a head projection may carry: the business head, the entity, the number, and the record's clocks. */
|
|
68
|
+
type HeadColumn = HeadField | 'createdAt' | 'entity' | 'number' | 'updatedAt';
|
|
67
69
|
type DocumentSortColumn = HeadField | 'createdAt' | 'number' | 'updatedAt';
|
|
68
70
|
type HeadsOrder = {
|
|
69
71
|
column: DocumentSortColumn | 'entity';
|
|
@@ -74,8 +76,10 @@ type HeadsWhere = Readonly<Partial<Record<HeadField | 'createdAt' | 'updatedAt',
|
|
|
74
76
|
to: unknown;
|
|
75
77
|
}>>>;
|
|
76
78
|
type HeadRow<Columns extends readonly HeadColumn[]> = Pick<DocumentHead & {
|
|
79
|
+
createdAt: number;
|
|
77
80
|
entity: string;
|
|
78
81
|
number: string;
|
|
82
|
+
updatedAt: number;
|
|
79
83
|
}, Columns[number]>;
|
|
80
84
|
type HeadsArgs<Columns extends readonly HeadColumn[] = readonly HeadColumn[]> = {
|
|
81
85
|
columns: Columns;
|
|
@@ -225,6 +229,8 @@ type PendingCall = {
|
|
|
225
229
|
* compiles (#325) but answers nothing, so a mounting adapter narrows before it reads.
|
|
226
230
|
*/
|
|
227
231
|
type SurfaceCall = (handle: never, params: never) => Promise<unknown>;
|
|
232
|
+
/** The adapter as the surface first named it; the builders live in the core now. */
|
|
233
|
+
type SurfaceSchemaAdapter = SchemaAdapter;
|
|
228
234
|
type SurfaceRow = {
|
|
229
235
|
call: PendingCall | SurfaceCall;
|
|
230
236
|
input: StandardSchemaV1;
|
|
@@ -234,16 +240,6 @@ type SurfaceRow = {
|
|
|
234
240
|
scope: SurfaceScope;
|
|
235
241
|
verb: SurfaceVerb;
|
|
236
242
|
};
|
|
237
|
-
/**
|
|
238
|
-
* The three builders a validator library supplies so the table stays library-free (#383) while the
|
|
239
|
-
* union/enum/object it derives are still real schemas of THAT library — the one place a consumer's
|
|
240
|
-
* zod enters `@geonosis/document` is through this adapter, never a direct dependency.
|
|
241
|
-
*/
|
|
242
|
-
type SurfaceSchemaAdapter = {
|
|
243
|
-
enum: (values: readonly string[]) => StandardSchemaV1<unknown, string>;
|
|
244
|
-
object: (shape: Readonly<Record<string, StandardSchemaV1>>) => StandardSchemaV1;
|
|
245
|
-
union: (schemas: readonly StandardSchemaV1[]) => StandardSchemaV1;
|
|
246
|
-
};
|
|
247
243
|
/**
|
|
248
244
|
* What the table needs off an entity beyond `documentEntities`'s own minimal bound — plus exactly
|
|
249
245
|
* what `documentStore`'s own `StorableDocumentEntity` needs, so `Map` satisfies both at once and a
|
package/dist/store.js
CHANGED
|
@@ -1,102 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Document,
|
|
3
|
-
canTransition,
|
|
4
3
|
canonicalOf,
|
|
5
4
|
headFields,
|
|
6
5
|
migrateBody,
|
|
7
|
-
stampBody
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
stampBody
|
|
7
|
+
} from "./chunk-7P6FV2YX.js";
|
|
8
|
+
import {
|
|
9
|
+
arrayOf,
|
|
10
|
+
booleanSchema,
|
|
11
|
+
canTransition,
|
|
12
|
+
literalOf,
|
|
13
|
+
merge,
|
|
14
|
+
nullable,
|
|
15
|
+
numberSchema,
|
|
16
|
+
optional,
|
|
17
|
+
stringSchema,
|
|
18
|
+
systemActor,
|
|
19
|
+
unknownSchema
|
|
20
|
+
} from "./chunk-NA3DLROL.js";
|
|
10
21
|
|
|
11
22
|
// src/store/hash.ts
|
|
12
23
|
import { createHash } from "crypto";
|
|
13
24
|
var hashOf = (payload) => createHash("sha256").update(JSON.stringify(canonicalOf(payload))).digest("hex");
|
|
14
25
|
|
|
15
26
|
// src/surface/table.ts
|
|
16
|
-
var VENDOR = "geonosis-document-surface";
|
|
17
|
-
var isString = (value) => typeof value === "string";
|
|
18
|
-
var isNumber = (value) => typeof value === "number";
|
|
19
|
-
var scalar = (test, message) => ({
|
|
20
|
-
"~standard": {
|
|
21
|
-
validate: (input) => test(input) ? { value: input } : { issues: [{ message }] },
|
|
22
|
-
vendor: VENDOR,
|
|
23
|
-
version: 1
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
var stringSchema = scalar(isString, "expected a string");
|
|
27
|
-
var numberSchema = scalar(isNumber, "expected a number");
|
|
28
|
-
var booleanSchema = scalar(
|
|
29
|
-
(value) => typeof value === "boolean",
|
|
30
|
-
"expected a boolean"
|
|
31
|
-
);
|
|
32
|
-
var literalOf = (literal) => scalar(
|
|
33
|
-
(value) => value === literal,
|
|
34
|
-
`expected exactly ${JSON.stringify(literal)}`
|
|
35
|
-
);
|
|
36
|
-
var unknownSchema = {
|
|
37
|
-
"~standard": { validate: (input) => ({ value: input }), vendor: VENDOR, version: 1 }
|
|
38
|
-
};
|
|
39
|
-
var syncResult = (schema, input) => {
|
|
40
|
-
const result = schema["~standard"].validate(input);
|
|
41
|
-
if (result instanceof Promise) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
"a document surface schema validates synchronously; an async Standard Schema cannot back a row"
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
var optional = (inner) => ({
|
|
49
|
-
"~standard": {
|
|
50
|
-
validate: (input) => input === void 0 ? { value: void 0 } : syncResult(inner, input),
|
|
51
|
-
vendor: VENDOR,
|
|
52
|
-
version: 1
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
var nullable = (inner) => ({
|
|
56
|
-
"~standard": {
|
|
57
|
-
validate: (input) => input === null ? { value: null } : syncResult(inner, input),
|
|
58
|
-
vendor: VENDOR,
|
|
59
|
-
version: 1
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
var arrayOf = (item) => ({
|
|
63
|
-
"~standard": {
|
|
64
|
-
validate: (input) => {
|
|
65
|
-
if (!Array.isArray(input)) return { issues: [{ message: "expected an array" }] };
|
|
66
|
-
const value = [];
|
|
67
|
-
const issues = [];
|
|
68
|
-
input.forEach((one, at) => {
|
|
69
|
-
const result = syncResult(item, one);
|
|
70
|
-
if (result.issues !== void 0) {
|
|
71
|
-
issues.push(
|
|
72
|
-
...result.issues.map((issue) => ({ ...issue, path: [at, ...issue.path ?? []] }))
|
|
73
|
-
);
|
|
74
|
-
} else {
|
|
75
|
-
value.push(result.value);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return issues.length > 0 ? { issues } : { value };
|
|
79
|
-
},
|
|
80
|
-
vendor: VENDOR,
|
|
81
|
-
version: 1
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
var merge = (schemas) => ({
|
|
85
|
-
"~standard": {
|
|
86
|
-
validate: (input) => {
|
|
87
|
-
let value = {};
|
|
88
|
-
const issues = [];
|
|
89
|
-
for (const schema of schemas) {
|
|
90
|
-
const result = syncResult(schema, input);
|
|
91
|
-
if (result.issues !== void 0) issues.push(...result.issues);
|
|
92
|
-
else value = { ...value, ...result.value };
|
|
93
|
-
}
|
|
94
|
-
return issues.length > 0 ? { issues } : { value };
|
|
95
|
-
},
|
|
96
|
-
vendor: VENDOR,
|
|
97
|
-
version: 1
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
27
|
var doorFor = (store, name) => {
|
|
101
28
|
const door = store[name];
|
|
102
29
|
if (door === void 0) {
|