@geonosis/document 0.7.0 → 0.9.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 +51 -0
- package/README.md +1 -1
- package/dist/{chunk-7P6FV2YX.js → chunk-A6ZU4QU3.js} +4 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/store.cjs +9 -5
- package/dist/store.d.cts +5 -9
- package/dist/store.d.ts +5 -9
- package/dist/store.js +6 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @geonosis/document
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 17e58a2: The runtime entries reach no Node API except AsyncLocalStorage, which Workers provides.
|
|
8
|
+
|
|
9
|
+
- **`@geonosis/db`**:
|
|
10
|
+
- `appRoleStatements` derives its SCRAM verifier with Web Crypto, so it now returns `Promise<string[]>`.
|
|
11
|
+
- `defineLog`'s `hash` may return a promise.
|
|
12
|
+
- Migrating moves to the node-only entry `@geonosis/db/migrate`: `migrateFolder(connection, folder, { table })`. `Driver` loses `migrate`, and `nodePostgresDriver` loses `migrationsTable`.
|
|
13
|
+
- **`@geonosis/document`**: `hashOf` is async (Web Crypto SHA-256). The hashes it produces are byte-identical.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [17e58a2]
|
|
18
|
+
- @geonosis/db@0.14.0
|
|
19
|
+
|
|
20
|
+
## 0.8.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 0f99e26: `ConformanceCase` and `CaseContext` move here — the shape `@geonosis/db`, `@geonosis/workflows` and
|
|
25
|
+
search's `SearchConformanceCase` each declared on their own, for the third time (#192's pattern,
|
|
26
|
+
this pass's row 743). Both floors and the domain re-export the same names unchanged; no consumer
|
|
27
|
+
import moves.
|
|
28
|
+
|
|
29
|
+
`@geonosis/document` stops restating `AggregateRow` and imports the one `@geonosis/db` already exports — same shape, one declaration. No consumer import moves.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 0f99e26: `canonicalOf` — the form `hashOf` and every stored chain are computed over — no longer depends on the machine's language: keys sort with the `en-US` collation every stored hash was written under, named rather than inherited, so a recomputation on a machine set to another locale (Estonian sorts `z` before `t`) agrees with the chain. It also reads a value as JSON writes it, so a `Date` is its ISO string rather than `{}`. Every hash computed in an `en-US` runtime is unchanged, held by golden hashes; a hash computed over an in-memory `Date` never matched the string it was stored as, and now does.
|
|
34
|
+
- Updated dependencies [0f99e26]
|
|
35
|
+
- Updated dependencies [0f99e26]
|
|
36
|
+
- Updated dependencies [0f99e26]
|
|
37
|
+
- Updated dependencies [0f99e26]
|
|
38
|
+
- Updated dependencies [0f99e26]
|
|
39
|
+
- Updated dependencies [0f99e26]
|
|
40
|
+
- Updated dependencies [0f99e26]
|
|
41
|
+
- Updated dependencies [0f99e26]
|
|
42
|
+
- Updated dependencies [0f99e26]
|
|
43
|
+
- Updated dependencies [0f99e26]
|
|
44
|
+
- Updated dependencies [0f99e26]
|
|
45
|
+
- Updated dependencies [0f99e26]
|
|
46
|
+
- Updated dependencies [0f99e26]
|
|
47
|
+
- Updated dependencies [0f99e26]
|
|
48
|
+
- Updated dependencies [0f99e26]
|
|
49
|
+
- Updated dependencies [0f99e26]
|
|
50
|
+
- Updated dependencies [0f99e26]
|
|
51
|
+
- @geonosis/workflows@0.6.0
|
|
52
|
+
- @geonosis/db@0.13.0
|
|
53
|
+
|
|
3
54
|
## 0.7.0
|
|
4
55
|
|
|
5
56
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ prose.
|
|
|
145
145
|
A revision carries `tenant, entity, ref, lineage, version, kind, body, actor, reason, at, prevHash,
|
|
146
146
|
hash` (`kind`: `'committed' | 'retired' | 'reinstated'`) plus `compensationOf` (nullable — the
|
|
147
147
|
version an undo compensates). `at` is the DATABASE clock, never the application's. Every revision's
|
|
148
|
-
`hash` is `hashOf` (`core/hash`, exported) over the canonical form of everything but
|
|
148
|
+
`hash` is `hashOf` (`core/hash`, exported; async, a Web Crypto SHA-256) over the canonical form of everything but
|
|
149
149
|
`compensationOf` — `prevHash` is null only at version 1 of a lineage, so the chain is tamper-evident
|
|
150
150
|
from the first write; a consumer's own archive recomputes the SAME `hashOf`/`canonicalOf`, the one
|
|
151
151
|
canonicaliser both sides use.
|
|
@@ -146,11 +146,14 @@ var documentEntities = (map) => {
|
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
// src/core/canonical.ts
|
|
149
|
+
var KEY_ORDER = new Intl.Collator("en-US");
|
|
149
150
|
var canonicalOf = (input) => {
|
|
150
151
|
if (input === null || typeof input !== "object") return input;
|
|
152
|
+
const { toJSON } = input;
|
|
153
|
+
if (typeof toJSON === "function") return canonicalOf(toJSON.call(input));
|
|
151
154
|
if (Array.isArray(input)) return input.map(canonicalOf);
|
|
152
155
|
return Object.fromEntries(
|
|
153
|
-
Object.entries(input).toSorted(([a], [b]) =>
|
|
156
|
+
Object.entries(input).toSorted(([a], [b]) => KEY_ORDER.compare(a, b)).map(([key, held]) => [key, canonicalOf(held)])
|
|
154
157
|
);
|
|
155
158
|
};
|
|
156
159
|
|
package/dist/index.cjs
CHANGED
|
@@ -346,11 +346,14 @@ var systemActor = (name) => `${SYSTEM_PREFIX}${name}`;
|
|
|
346
346
|
var isSystemActor = (actor) => actor.startsWith(SYSTEM_PREFIX);
|
|
347
347
|
|
|
348
348
|
// src/core/canonical.ts
|
|
349
|
+
var KEY_ORDER = new Intl.Collator("en-US");
|
|
349
350
|
var canonicalOf = (input) => {
|
|
350
351
|
if (input === null || typeof input !== "object") return input;
|
|
352
|
+
const { toJSON } = input;
|
|
353
|
+
if (typeof toJSON === "function") return canonicalOf(toJSON.call(input));
|
|
351
354
|
if (Array.isArray(input)) return input.map(canonicalOf);
|
|
352
355
|
return Object.fromEntries(
|
|
353
|
-
Object.entries(input).toSorted(([a], [b]) =>
|
|
356
|
+
Object.entries(input).toSorted(([a], [b]) => KEY_ORDER.compare(a, b)).map(([key, held]) => [key, canonicalOf(held)])
|
|
354
357
|
);
|
|
355
358
|
};
|
|
356
359
|
|
package/dist/index.d.cts
CHANGED
|
@@ -7,9 +7,8 @@ declare const systemActor: (name: string) => string;
|
|
|
7
7
|
declare const isSystemActor: (actor: string) => boolean;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Deep, key-order-independent
|
|
11
|
-
* canonicaliser both sides use — a consumer's archive recomputes `hashOf` over the identical form
|
|
12
|
-
* so a second implementation of this function is a second chain that silently stops agreeing.
|
|
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.
|
|
13
12
|
*/
|
|
14
13
|
declare const canonicalOf: (input: unknown) => unknown;
|
|
15
14
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,8 @@ declare const systemActor: (name: string) => string;
|
|
|
7
7
|
declare const isSystemActor: (actor: string) => boolean;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Deep, key-order-independent
|
|
11
|
-
* canonicaliser both sides use — a consumer's archive recomputes `hashOf` over the identical form
|
|
12
|
-
* so a second implementation of this function is a second chain that silently stops agreeing.
|
|
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.
|
|
13
12
|
*/
|
|
14
13
|
declare const canonicalOf: (input: unknown) => unknown;
|
|
15
14
|
|
package/dist/index.js
CHANGED
package/dist/store.cjs
CHANGED
|
@@ -35,20 +35,24 @@ __export(store_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(store_exports);
|
|
37
37
|
|
|
38
|
-
// src/store/hash.ts
|
|
39
|
-
var import_node_crypto = require("crypto");
|
|
40
|
-
|
|
41
38
|
// src/core/canonical.ts
|
|
39
|
+
var KEY_ORDER = new Intl.Collator("en-US");
|
|
42
40
|
var canonicalOf = (input) => {
|
|
43
41
|
if (input === null || typeof input !== "object") return input;
|
|
42
|
+
const { toJSON } = input;
|
|
43
|
+
if (typeof toJSON === "function") return canonicalOf(toJSON.call(input));
|
|
44
44
|
if (Array.isArray(input)) return input.map(canonicalOf);
|
|
45
45
|
return Object.fromEntries(
|
|
46
|
-
Object.entries(input).toSorted(([a], [b]) =>
|
|
46
|
+
Object.entries(input).toSorted(([a], [b]) => KEY_ORDER.compare(a, b)).map(([key, held]) => [key, canonicalOf(held)])
|
|
47
47
|
);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// src/store/hash.ts
|
|
51
|
-
var hashOf = (payload) =>
|
|
51
|
+
var hashOf = async (payload) => {
|
|
52
|
+
const bytes = new TextEncoder().encode(JSON.stringify(canonicalOf(payload)));
|
|
53
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
54
|
+
return Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
55
|
+
};
|
|
52
56
|
|
|
53
57
|
// src/core/document.ts
|
|
54
58
|
var fieldPatterns = {
|
package/dist/store.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
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
3
|
import { A as ArchivePort, S as SchemaAdapter } from './ports-C_OfflMQ.cjs';
|
|
4
|
-
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, SessionSeam } from '@geonosis/db';
|
|
5
|
-
export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
4
|
+
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, AggregateRow, SessionSeam } from '@geonosis/db';
|
|
5
|
+
export { AggregateRow, ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
6
6
|
|
|
7
7
|
/** sha256 hex over the canonical JSON of `payload` — no whitespace, keys sorted recursively. */
|
|
8
|
-
declare const hashOf: (payload: unknown) => string
|
|
8
|
+
declare const hashOf: (payload: unknown) => Promise<string>;
|
|
9
9
|
|
|
10
10
|
declare const DEFAULT_DOCUMENT_TABLE = "documents";
|
|
11
11
|
declare const DEFAULT_REVISIONS_TABLE = "document_revisions";
|
|
@@ -93,11 +93,7 @@ type AggregateBy = HeadField | 'entity' | {
|
|
|
93
93
|
of: 'dueDate' | 'issueDate';
|
|
94
94
|
};
|
|
95
95
|
type AggregateWhere = HeadsWhere;
|
|
96
|
-
|
|
97
|
-
by?: string;
|
|
98
|
-
count?: number;
|
|
99
|
-
sum?: string;
|
|
100
|
-
};
|
|
96
|
+
|
|
101
97
|
type AggregateArgs = {
|
|
102
98
|
by?: AggregateBy;
|
|
103
99
|
entities?: readonly string[];
|
|
@@ -278,4 +274,4 @@ type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentE
|
|
|
278
274
|
*/
|
|
279
275
|
declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DrizzleHandle = DrizzleHandle>(options: DocumentSurfaceOptions<Map, Key, Handle>) => SurfaceRow[];
|
|
280
276
|
|
|
281
|
-
export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type
|
|
277
|
+
export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type AggregateWhere, type AppendOnlyTablesOptions, type CommitOutput, DEFAULT_DOCUMENT_TABLE, DEFAULT_REVISIONS_TABLE, DEFAULT_REVISION_KIND_COLUMN, type DocumentColumns, type DocumentKind, type DocumentMigrationsOptions, type DocumentPhysicalColumns, type DocumentRevisionsOptions, type DocumentSortColumn, type DocumentStore, type DocumentStoreOptions, type DocumentSurfaceOptions, HEAD_FIELDS, type HeadColumn, type HeadField, type HeadRow, type HeadsArgs, type HeadsOrder, type HeadsWhere, type HistoryEntry, type PendingCall, type ReinstateOutput, type RetireOutput, type SurfaceCall, type SurfaceRow, type SurfaceSchemaAdapter, type SurfaceScope, type SurfaceVerb, type VerifyResult, appendOnlyTables, documentMigrations, documentRoleStatements, documentStore, documentSurface, hashOf, physicalColumnsOf };
|
package/dist/store.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
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
3
|
import { A as ArchivePort, S as SchemaAdapter } from './ports-C_OfflMQ.js';
|
|
4
|
-
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, SessionSeam } from '@geonosis/db';
|
|
5
|
-
export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
4
|
+
import { EntityColumns, EntityName, FreezeRegister, TenantPolicyNames, SessionSettings, EntityMigration, DrizzleHandle, Projection, Query, EntityListing, EntityPage, EntityUndo, AggregateRow, SessionSeam } from '@geonosis/db';
|
|
5
|
+
export { AggregateRow, ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS } from '@geonosis/db';
|
|
6
6
|
|
|
7
7
|
/** sha256 hex over the canonical JSON of `payload` — no whitespace, keys sorted recursively. */
|
|
8
|
-
declare const hashOf: (payload: unknown) => string
|
|
8
|
+
declare const hashOf: (payload: unknown) => Promise<string>;
|
|
9
9
|
|
|
10
10
|
declare const DEFAULT_DOCUMENT_TABLE = "documents";
|
|
11
11
|
declare const DEFAULT_REVISIONS_TABLE = "document_revisions";
|
|
@@ -93,11 +93,7 @@ type AggregateBy = HeadField | 'entity' | {
|
|
|
93
93
|
of: 'dueDate' | 'issueDate';
|
|
94
94
|
};
|
|
95
95
|
type AggregateWhere = HeadsWhere;
|
|
96
|
-
|
|
97
|
-
by?: string;
|
|
98
|
-
count?: number;
|
|
99
|
-
sum?: string;
|
|
100
|
-
};
|
|
96
|
+
|
|
101
97
|
type AggregateArgs = {
|
|
102
98
|
by?: AggregateBy;
|
|
103
99
|
entities?: readonly string[];
|
|
@@ -278,4 +274,4 @@ type DocumentSurfaceOptions<Map extends Readonly<Record<string, SurfaceDocumentE
|
|
|
278
274
|
*/
|
|
279
275
|
declare const documentSurface: <Map extends Readonly<Record<string, SurfaceDocumentEntity>>, Key extends string, Handle extends DrizzleHandle = DrizzleHandle>(options: DocumentSurfaceOptions<Map, Key, Handle>) => SurfaceRow[];
|
|
280
276
|
|
|
281
|
-
export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type
|
|
277
|
+
export { type AggregateArgs, type AggregateBy, type AggregateMeasure, type AggregateWhere, type AppendOnlyTablesOptions, type CommitOutput, DEFAULT_DOCUMENT_TABLE, DEFAULT_REVISIONS_TABLE, DEFAULT_REVISION_KIND_COLUMN, type DocumentColumns, type DocumentKind, type DocumentMigrationsOptions, type DocumentPhysicalColumns, type DocumentRevisionsOptions, type DocumentSortColumn, type DocumentStore, type DocumentStoreOptions, type DocumentSurfaceOptions, HEAD_FIELDS, type HeadColumn, type HeadField, type HeadRow, type HeadsArgs, type HeadsOrder, type HeadsWhere, type HistoryEntry, type PendingCall, type ReinstateOutput, type RetireOutput, type SurfaceCall, type SurfaceRow, type SurfaceSchemaAdapter, type SurfaceScope, type SurfaceVerb, type VerifyResult, appendOnlyTables, documentMigrations, documentRoleStatements, documentStore, documentSurface, hashOf, physicalColumnsOf };
|
package/dist/store.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
headFields,
|
|
5
5
|
migrateBody,
|
|
6
6
|
stampBody
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-A6ZU4QU3.js";
|
|
8
8
|
import {
|
|
9
9
|
arrayOf,
|
|
10
10
|
booleanSchema,
|
|
@@ -20,8 +20,11 @@ import {
|
|
|
20
20
|
} from "./chunk-NA3DLROL.js";
|
|
21
21
|
|
|
22
22
|
// src/store/hash.ts
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var hashOf = async (payload) => {
|
|
24
|
+
const bytes = new TextEncoder().encode(JSON.stringify(canonicalOf(payload)));
|
|
25
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
|
|
26
|
+
return Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
27
|
+
};
|
|
25
28
|
|
|
26
29
|
// src/surface/table.ts
|
|
27
30
|
var doorFor = (store, name) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geonosis/document",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"description": "The abstract Document: an entity-first base every kind of paper-trail record extends, a derived entity registry whose name union keeps every consumer map total, and per-entity body versioning — engine-free, SQL-free, the pure core the store, the workflows and the wire contract build on.",
|
|
6
6
|
"keywords": [
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@standard-schema/spec": "^1.1.0",
|
|
62
62
|
"better-result": "^3.0.0",
|
|
63
|
-
"@geonosis/db": "^0.
|
|
64
|
-
"@geonosis/workflows": "^0.
|
|
63
|
+
"@geonosis/db": "^0.14.0",
|
|
64
|
+
"@geonosis/workflows": "^0.6.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"drizzle-orm": ">=0.45.0"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"access": "public"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"build": "tsup",
|
|
88
|
+
"build": "tsx ../../tooling/build-step.ts tsup",
|
|
89
89
|
"typecheck": "tsc --noEmit",
|
|
90
90
|
"lint": "oxlint --config ../../.oxlintrc.json .",
|
|
91
91
|
"test:unit": "vitest run --project unit --root ../.. --passWithNoTests \"$PWD\"",
|