@geonosis/document 0.5.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.
@@ -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 };