@graview/core 0.1.0 → 0.1.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/README.md +7 -0
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js.map +1 -1
- package/dist/arrange.d.ts +3 -2
- package/dist/arrange.d.ts.map +1 -1
- package/dist/arrange.js +19 -2
- package/dist/arrange.js.map +1 -1
- package/dist/beginning.d.ts +5 -2
- package/dist/beginning.d.ts.map +1 -1
- package/dist/beginning.js +28 -0
- package/dist/beginning.js.map +1 -1
- package/dist/capabilities.d.ts +32 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +31 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cli/check/index.d.ts +1 -0
- package/dist/cli/check/index.d.ts.map +1 -1
- package/dist/cli/check/index.js +1 -0
- package/dist/cli/check/index.js.map +1 -1
- package/dist/cli/check/lenses.d.ts.map +1 -1
- package/dist/cli/check/lenses.js +25 -0
- package/dist/cli/check/lenses.js.map +1 -1
- package/dist/cli/check/policy.d.ts.map +1 -1
- package/dist/cli/check/policy.js +35 -0
- package/dist/cli/check/policy.js.map +1 -1
- package/dist/cli/check/relations.d.ts.map +1 -1
- package/dist/cli/check/relations.js +31 -0
- package/dist/cli/check/relations.js.map +1 -1
- package/dist/cli/check/views.d.ts +14 -0
- package/dist/cli/check/views.d.ts.map +1 -0
- package/dist/cli/check/views.js +27 -0
- package/dist/cli/check/views.js.map +1 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +2 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/create.d.ts +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +63 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.d.ts +18 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +66 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/conformance/fixtures.d.ts +41 -0
- package/dist/conformance/fixtures.d.ts.map +1 -0
- package/dist/conformance/fixtures.js +950 -0
- package/dist/conformance/fixtures.js.map +1 -0
- package/dist/conformance/index.d.ts +54 -0
- package/dist/conformance/index.d.ts.map +1 -0
- package/dist/conformance/index.js +81 -0
- package/dist/conformance/index.js.map +1 -0
- package/dist/document/canonical.d.ts +4 -0
- package/dist/document/canonical.d.ts.map +1 -0
- package/dist/document/canonical.js +29 -0
- package/dist/document/canonical.js.map +1 -0
- package/dist/document/compile.d.ts +43 -0
- package/dist/document/compile.d.ts.map +1 -0
- package/dist/document/compile.js +807 -0
- package/dist/document/compile.js.map +1 -0
- package/dist/document/diff.d.ts +32 -0
- package/dist/document/diff.d.ts.map +1 -0
- package/dist/document/diff.js +148 -0
- package/dist/document/diff.js.map +1 -0
- package/dist/document/edit.d.ts +63 -0
- package/dist/document/edit.d.ts.map +1 -0
- package/dist/document/edit.js +1432 -0
- package/dist/document/edit.js.map +1 -0
- package/dist/document/expr/analyze.d.ts +14 -0
- package/dist/document/expr/analyze.d.ts.map +1 -0
- package/dist/document/expr/analyze.js +52 -0
- package/dist/document/expr/analyze.js.map +1 -0
- package/dist/document/expr/evaluate.d.ts +36 -0
- package/dist/document/expr/evaluate.d.ts.map +1 -0
- package/dist/document/expr/evaluate.js +344 -0
- package/dist/document/expr/evaluate.js.map +1 -0
- package/dist/document/expr/index.d.ts +8 -0
- package/dist/document/expr/index.d.ts.map +1 -0
- package/dist/document/expr/index.js +5 -0
- package/dist/document/expr/index.js.map +1 -0
- package/dist/document/expr/parse.d.ts +50 -0
- package/dist/document/expr/parse.d.ts.map +1 -0
- package/dist/document/expr/parse.js +240 -0
- package/dist/document/expr/parse.js.map +1 -0
- package/dist/document/expr/print.d.ts +4 -0
- package/dist/document/expr/print.d.ts.map +1 -0
- package/dist/document/expr/print.js +81 -0
- package/dist/document/expr/print.js.map +1 -0
- package/dist/document/findings.d.ts +15 -0
- package/dist/document/findings.d.ts.map +1 -0
- package/dist/document/findings.js +30 -0
- package/dist/document/findings.js.map +1 -0
- package/dist/document/graview-template.d.ts +148 -0
- package/dist/document/graview-template.d.ts.map +1 -0
- package/dist/document/graview-template.js +450 -0
- package/dist/document/graview-template.js.map +1 -0
- package/dist/document/index.d.ts +27 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +16 -0
- package/dist/document/index.js.map +1 -0
- package/dist/document/migrate.d.ts +41 -0
- package/dist/document/migrate.d.ts.map +1 -0
- package/dist/document/migrate.js +252 -0
- package/dist/document/migrate.js.map +1 -0
- package/dist/document/patch.d.ts +16 -0
- package/dist/document/patch.d.ts.map +1 -0
- package/dist/document/patch.js +79 -0
- package/dist/document/patch.js.map +1 -0
- package/dist/document/rules.d.ts +40 -0
- package/dist/document/rules.d.ts.map +1 -0
- package/dist/document/rules.js +88 -0
- package/dist/document/rules.js.map +1 -0
- package/dist/document/schema.d.ts +461 -0
- package/dist/document/schema.d.ts.map +1 -0
- package/dist/document/schema.js +199 -0
- package/dist/document/schema.js.map +1 -0
- package/dist/document/template.d.ts +28 -0
- package/dist/document/template.d.ts.map +1 -0
- package/dist/document/template.js +117 -0
- package/dist/document/template.js.map +1 -0
- package/dist/document/to-document.d.ts +34 -0
- package/dist/document/to-document.d.ts.map +1 -0
- package/dist/document/to-document.js +186 -0
- package/dist/document/to-document.js.map +1 -0
- package/dist/document/upgrade.d.ts +9 -0
- package/dist/document/upgrade.d.ts.map +1 -0
- package/dist/document/upgrade.js +19 -0
- package/dist/document/upgrade.js.map +1 -0
- package/dist/document/views.d.ts +65 -0
- package/dist/document/views.d.ts.map +1 -0
- package/dist/document/views.js +264 -0
- package/dist/document/views.js.map +1 -0
- package/dist/formats.d.ts +50 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +75 -0
- package/dist/formats.js.map +1 -0
- package/dist/graph/graph.d.ts +61 -3
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +187 -20
- package/dist/graph/graph.js.map +1 -1
- package/dist/index.d.ts +43 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/integrity.d.ts +46 -0
- package/dist/integrity.d.ts.map +1 -0
- package/dist/integrity.js +179 -0
- package/dist/integrity.js.map +1 -0
- package/dist/invariants/engine.d.ts +8 -0
- package/dist/invariants/engine.d.ts.map +1 -1
- package/dist/invariants/engine.js +40 -2
- package/dist/invariants/engine.js.map +1 -1
- package/dist/invariants/types.d.ts +19 -0
- package/dist/invariants/types.d.ts.map +1 -1
- package/dist/labels.d.ts +65 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +123 -0
- package/dist/labels.js.map +1 -0
- package/dist/mutations/define-mutation.d.ts.map +1 -1
- package/dist/mutations/define-mutation.js +5 -6
- package/dist/mutations/define-mutation.js.map +1 -1
- package/dist/mutations/derive-edits.d.ts.map +1 -1
- package/dist/mutations/derive-edits.js +20 -1
- package/dist/mutations/derive-edits.js.map +1 -1
- package/dist/mutations/form.d.ts +9 -0
- package/dist/mutations/form.d.ts.map +1 -1
- package/dist/mutations/form.js +20 -0
- package/dist/mutations/form.js.map +1 -1
- package/dist/mutations/node-ref.d.ts +6 -0
- package/dist/mutations/node-ref.d.ts.map +1 -1
- package/dist/mutations/node-ref.js +22 -8
- package/dist/mutations/node-ref.js.map +1 -1
- package/dist/mutations/types.d.ts +8 -0
- package/dist/mutations/types.d.ts.map +1 -1
- package/dist/mutations/words.d.ts +49 -0
- package/dist/mutations/words.d.ts.map +1 -0
- package/dist/mutations/words.js +61 -0
- package/dist/mutations/words.js.map +1 -0
- package/dist/ops/log.d.ts +156 -4
- package/dist/ops/log.d.ts.map +1 -1
- package/dist/ops/log.js +234 -51
- package/dist/ops/log.js.map +1 -1
- package/dist/ops/revisions.d.ts +66 -0
- package/dist/ops/revisions.d.ts.map +1 -0
- package/dist/ops/revisions.js +97 -0
- package/dist/ops/revisions.js.map +1 -0
- package/dist/ops/types.d.ts +49 -1
- package/dist/ops/types.d.ts.map +1 -1
- package/dist/ops/undo.d.ts +29 -2
- package/dist/ops/undo.d.ts.map +1 -1
- package/dist/ops/undo.js +110 -1
- package/dist/ops/undo.js.map +1 -1
- package/dist/ops/withheld.d.ts +37 -0
- package/dist/ops/withheld.d.ts.map +1 -0
- package/dist/ops/withheld.js +84 -0
- package/dist/ops/withheld.js.map +1 -0
- package/dist/permissions/policy.d.ts +15 -0
- package/dist/permissions/policy.d.ts.map +1 -1
- package/dist/permissions/policy.js +28 -1
- package/dist/permissions/policy.js.map +1 -1
- package/dist/permissions/sight.d.ts +66 -0
- package/dist/permissions/sight.d.ts.map +1 -0
- package/dist/permissions/sight.js +131 -0
- package/dist/permissions/sight.js.map +1 -0
- package/dist/permissions/types.d.ts +26 -0
- package/dist/permissions/types.d.ts.map +1 -1
- package/dist/permissions/types.js.map +1 -1
- package/dist/persistence/memory.d.ts.map +1 -1
- package/dist/persistence/memory.js +25 -0
- package/dist/persistence/memory.js.map +1 -1
- package/dist/persistence/sql.d.ts +43 -0
- package/dist/persistence/sql.d.ts.map +1 -0
- package/dist/persistence/sql.js +154 -0
- package/dist/persistence/sql.js.map +1 -0
- package/dist/persistence/sqlite.d.ts +17 -3
- package/dist/persistence/sqlite.d.ts.map +1 -1
- package/dist/persistence/sqlite.js +32 -96
- package/dist/persistence/sqlite.js.map +1 -1
- package/dist/persistence/types.d.ts +19 -0
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/presence.d.ts +56 -0
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +62 -2
- package/dist/presence.js.map +1 -1
- package/dist/refusal.d.ts +34 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +40 -0
- package/dist/refusal.js.map +1 -0
- package/dist/scaffold/from-template.d.ts +16 -0
- package/dist/scaffold/from-template.d.ts.map +1 -0
- package/dist/scaffold/from-template.js +157 -0
- package/dist/scaffold/from-template.js.map +1 -0
- package/dist/scaffold/index.d.ts +10 -1
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +35 -7
- package/dist/scaffold/index.js.map +1 -1
- package/dist/scaffold/names.d.ts +4 -0
- package/dist/scaffold/names.d.ts.map +1 -1
- package/dist/scaffold/names.js.map +1 -1
- package/dist/scaffold/project.d.ts +1 -1
- package/dist/scaffold/project.d.ts.map +1 -1
- package/dist/scaffold/project.js +44 -13
- package/dist/scaffold/project.js.map +1 -1
- package/dist/scaffold/ui.d.ts.map +1 -1
- package/dist/scaffold/ui.js +19 -10
- package/dist/scaffold/ui.js.map +1 -1
- package/dist/schema/define-node.d.ts +20 -0
- package/dist/schema/define-node.d.ts.map +1 -1
- package/dist/schema/define-node.js +27 -2
- package/dist/schema/define-node.js.map +1 -1
- package/dist/schema/path.d.ts +19 -0
- package/dist/schema/path.d.ts.map +1 -0
- package/dist/schema/path.js +34 -0
- package/dist/schema/path.js.map +1 -0
- package/dist/schema/types.d.ts +17 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/seen.d.ts +64 -0
- package/dist/seen.d.ts.map +1 -0
- package/dist/seen.js +200 -0
- package/dist/seen.js.map +1 -0
- package/dist/store.d.ts +378 -8
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +801 -41
- package/dist/store.js.map +1 -1
- package/dist/testing.d.ts +6 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/theme/palettes.d.ts.map +1 -1
- package/dist/theme/palettes.js +4 -0
- package/dist/theme/palettes.js.map +1 -1
- package/dist/theme/types.d.ts +9 -0
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/types.js +4 -0
- package/dist/theme/types.js.map +1 -1
- package/dist/validate-graph.d.ts +84 -0
- package/dist/validate-graph.d.ts.map +1 -0
- package/dist/validate-graph.js +295 -0
- package/dist/validate-graph.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/views/types.d.ts +8 -0
- package/dist/views/types.d.ts.map +1 -1
- package/dist/views/types.js +5 -0
- package/dist/views/types.js.map +1 -1
- package/dist/watched.d.ts +39 -0
- package/dist/watched.d.ts.map +1 -1
- package/dist/watched.js +94 -1
- package/dist/watched.js.map +1 -1
- package/dist/who.d.ts +24 -1
- package/dist/who.d.ts.map +1 -1
- package/dist/who.js +49 -2
- package/dist/who.js.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../../src/persistence/sql.ts"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAI,EAAW,EAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,aAAa,CAAC;IACrD,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,aAAa,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC;IACjD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,gBAAgB,CAAC;IAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,qBAAqB,CAAC;IACnE,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,IAAI,cAAc,CAAC;IACpD,MAAM,IAAI,GAAG,CAAI,SAAiB,EAAE,GAAG,MAAiB,EAAO,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,CAAQ,CAAC;IAC7G,MAAM,GAAG,GAAG,CAAC,SAAiB,EAAE,GAAG,MAAiB,EAAQ,EAAE;QAC5D,iEAAiE;QACjE,KAAK,MAAM,CAA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SqlAdapter } from "./sql.js";
|
|
4
|
+
export type { SqlAdapterOptions, SqlExec } from "./sql.js";
|
|
2
5
|
/**
|
|
3
6
|
* The slice of better-sqlite3 this adapter needs. Typed structurally so the
|
|
4
7
|
* package never has to import the native module, and so a Drizzle app can
|
|
5
8
|
* hand over its underlying client (`db.$client`) with no wrapper.
|
|
6
9
|
*/
|
|
7
10
|
export interface SqliteStatement {
|
|
11
|
+
/** Whether the statement returns rows; better-sqlite3 says, and a statement that does not is `run`. */
|
|
12
|
+
readonly reader?: boolean;
|
|
8
13
|
all(...params: unknown[]): unknown[];
|
|
9
14
|
run(...params: unknown[]): unknown;
|
|
10
15
|
}
|
|
@@ -51,9 +56,18 @@ export declare const SQLITE_TABLE_SHAPE: {
|
|
|
51
56
|
};
|
|
52
57
|
/**
|
|
53
58
|
* Reads and writes an app's existing `graph_nodes` / `graph_edges` tables —
|
|
54
|
-
* the shape the household example already stores
|
|
55
|
-
*
|
|
56
|
-
*
|
|
59
|
+
* the shape the household example already stores — through better-sqlite3.
|
|
60
|
+
* The SQL adapter over `sqlFromDatabase(database)`: one implementation, so
|
|
61
|
+
* what holds here holds over a Durable Object's storage too (FR-09).
|
|
57
62
|
*/
|
|
58
63
|
export declare function createSqliteAdapter(options: SqliteAdapterOptions): PersistenceAdapter<string>;
|
|
64
|
+
/**
|
|
65
|
+
* better-sqlite3 as the SQL adapter's `exec`, with its own transaction.
|
|
66
|
+
* Each statement is prepared once and kept, and a statement that reads
|
|
67
|
+
* nothing is `run` rather than asked for rows (better-sqlite3 refuses that).
|
|
68
|
+
*/
|
|
69
|
+
export declare function sqlFromDatabase(database: SqliteDatabase): {
|
|
70
|
+
readonly sql: SqlExec;
|
|
71
|
+
readonly transaction: <T>(fn: () => T) => T;
|
|
72
|
+
};
|
|
59
73
|
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/persistence/sqlite.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;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAG7F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;CAAE,CAsBhI"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createSqlAdapter } from "./sql.js";
|
|
2
|
+
export { createSqlAdapter } from "./sql.js";
|
|
1
3
|
/**
|
|
2
4
|
* The Drizzle/SQLite table shapes this adapter reads and writes, for an app
|
|
3
5
|
* that wants to declare them in its own Drizzle schema:
|
|
@@ -25,107 +27,41 @@ export const SQLITE_TABLE_SHAPE = {
|
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* Reads and writes an app's existing `graph_nodes` / `graph_edges` tables —
|
|
28
|
-
* the shape the household example already stores
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* the shape the household example already stores — through better-sqlite3.
|
|
31
|
+
* The SQL adapter over `sqlFromDatabase(database)`: one implementation, so
|
|
32
|
+
* what holds here holds over a Durable Object's storage too (FR-09).
|
|
31
33
|
*/
|
|
32
34
|
export function createSqliteAdapter(options) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
PRIMARY KEY (${scope}, position)
|
|
49
|
-
);
|
|
50
|
-
CREATE TABLE IF NOT EXISTS ${opTable} (
|
|
51
|
-
${scope} TEXT NOT NULL, seq INTEGER NOT NULL, data TEXT NOT NULL,
|
|
52
|
-
PRIMARY KEY (${scope}, seq)
|
|
53
|
-
);
|
|
54
|
-
`);
|
|
55
|
-
}
|
|
56
|
-
const selectNodes = db.prepare(`SELECT id, kind, data FROM ${nodeTable} WHERE ${scope} = ?`);
|
|
57
|
-
const selectEdges = db.prepare(`SELECT kind, from_id, to_id FROM ${edgeTable} WHERE ${scope} = ? ORDER BY position ASC`);
|
|
58
|
-
const deleteNodes = db.prepare(`DELETE FROM ${nodeTable} WHERE ${scope} = ?`);
|
|
59
|
-
const deleteEdges = db.prepare(`DELETE FROM ${edgeTable} WHERE ${scope} = ?`);
|
|
60
|
-
const insertNode = db.prepare(`INSERT INTO ${nodeTable} (${scope}, id, kind, data) VALUES (?, ?, ?, ?)`);
|
|
61
|
-
const insertEdge = db.prepare(`INSERT INTO ${edgeTable} (${scope}, position, kind, from_id, to_id) VALUES (?, ?, ?, ?, ?)`);
|
|
62
|
-
/**
|
|
63
|
-
* The op table is the framework's own, not the app's, so it is created on
|
|
64
|
-
* demand. The node and edge tables are the app's and are never touched
|
|
65
|
-
* unless `createTables` explicitly asks for them.
|
|
66
|
-
*/
|
|
67
|
-
let opTableReady = false;
|
|
68
|
-
function ensureOpTable() {
|
|
69
|
-
if (opTableReady)
|
|
70
|
-
return;
|
|
71
|
-
db.exec(`CREATE TABLE IF NOT EXISTS ${opTable} (
|
|
72
|
-
${scope} TEXT NOT NULL, seq INTEGER NOT NULL, data TEXT NOT NULL,
|
|
73
|
-
PRIMARY KEY (${scope}, seq)
|
|
74
|
-
)`);
|
|
75
|
-
opTableReady = true;
|
|
76
|
-
}
|
|
77
|
-
const write = db.transaction(((key, snapshot) => {
|
|
78
|
-
deleteEdges.run(key);
|
|
79
|
-
deleteNodes.run(key);
|
|
80
|
-
for (const node of snapshot.nodes) {
|
|
81
|
-
insertNode.run(key, node.id, node.kind, JSON.stringify(node));
|
|
35
|
+
const { database, ...tables } = options;
|
|
36
|
+
return createSqlAdapter({ ...sqlFromDatabase(database), ...tables });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* better-sqlite3 as the SQL adapter's `exec`, with its own transaction.
|
|
40
|
+
* Each statement is prepared once and kept, and a statement that reads
|
|
41
|
+
* nothing is `run` rather than asked for rows (better-sqlite3 refuses that).
|
|
42
|
+
*/
|
|
43
|
+
export function sqlFromDatabase(database) {
|
|
44
|
+
const prepared = new Map();
|
|
45
|
+
const statement = (sql) => {
|
|
46
|
+
let found = prepared.get(sql);
|
|
47
|
+
if (!found) {
|
|
48
|
+
found = database.prepare(sql);
|
|
49
|
+
prepared.set(sql, found);
|
|
82
50
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
}));
|
|
51
|
+
return found;
|
|
52
|
+
};
|
|
87
53
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// columns win so a row is never internally inconsistent.
|
|
98
|
-
return { ...parsed, id: row.id, kind: row.kind };
|
|
99
|
-
});
|
|
100
|
-
const edges = edgeRows.map((row) => ({
|
|
101
|
-
kind: row.kind,
|
|
102
|
-
from: row.from_id,
|
|
103
|
-
to: row.to_id,
|
|
104
|
-
}));
|
|
105
|
-
return { nodes, edges };
|
|
106
|
-
},
|
|
107
|
-
async save(key, snapshot) {
|
|
108
|
-
write(key, snapshot);
|
|
109
|
-
},
|
|
110
|
-
async delete(key) {
|
|
111
|
-
deleteEdges.run(key);
|
|
112
|
-
deleteNodes.run(key);
|
|
113
|
-
},
|
|
114
|
-
async loadLog(key) {
|
|
115
|
-
ensureOpTable();
|
|
116
|
-
const rows = db
|
|
117
|
-
.prepare(`SELECT data FROM ${opTable} WHERE ${scope} = ? ORDER BY seq ASC`)
|
|
118
|
-
.all(key);
|
|
119
|
-
return rows.map((row) => JSON.parse(row.data));
|
|
120
|
-
},
|
|
121
|
-
async appendOps(key, ops) {
|
|
122
|
-
if (ops.length === 0)
|
|
123
|
-
return;
|
|
124
|
-
ensureOpTable();
|
|
125
|
-
const insert = db.prepare(`INSERT OR REPLACE INTO ${opTable} (${scope}, seq, data) VALUES (?, ?, ?)`);
|
|
126
|
-
for (const op of ops)
|
|
127
|
-
insert.run(key, op.seq, JSON.stringify(op));
|
|
54
|
+
sql: {
|
|
55
|
+
exec(sql, ...params) {
|
|
56
|
+
const prepared = statement(sql);
|
|
57
|
+
const reads = prepared.reader ?? /^\s*(SELECT|WITH|PRAGMA|VALUES)\b/i.test(sql);
|
|
58
|
+
if (reads)
|
|
59
|
+
return prepared.all(...params);
|
|
60
|
+
prepared.run(...params);
|
|
61
|
+
return [];
|
|
62
|
+
},
|
|
128
63
|
},
|
|
64
|
+
transaction: (fn) => database.transaction(fn)(),
|
|
129
65
|
};
|
|
130
66
|
}
|
|
131
67
|
//# sourceMappingURL=sqlite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../src/persistence/sqlite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../../src/persistence/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,UAAU,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAgC5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC;IACtC,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAChD,CAAC;AAEX;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;IACxC,OAAO,gBAAgB,CAAC,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IACpD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAmB,EAAE;QACjD,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9B,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IACF,OAAO;QACL,GAAG,EAAE;YACH,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM;gBACjB,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;gBAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,IAAI,oCAAoC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAChF,IAAI,KAAK;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;gBAC1C,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;gBACxB,OAAO,EAAE,CAAC;YACZ,CAAC;SACF;QACD,WAAW,EAAE,CAAI,EAAW,EAAK,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAa,CAAC,EAAO;KAC/E,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphSnapshot } from "../graph/types.js";
|
|
2
|
+
import type { Epoch, LogArchive } from "../ops/log.js";
|
|
2
3
|
import type { Operation } from "../ops/types.js";
|
|
3
4
|
/**
|
|
4
5
|
* The framework owns the reactive graph, invariants, diff and undo;
|
|
@@ -18,5 +19,23 @@ export interface PersistenceAdapter<Scope = string> {
|
|
|
18
19
|
/** Optional: adapters that keep history append the log too. */
|
|
19
20
|
loadLog?(scope: Scope): Promise<Operation[]>;
|
|
20
21
|
appendOps?(scope: Scope, ops: readonly Operation[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional: the epochs the log folds from (FR-27), kept beside it. An
|
|
24
|
+
* adapter without them reopens a store with none recorded, and ship has
|
|
25
|
+
* it adopt what it holds as its first epoch on each open.
|
|
26
|
+
*/
|
|
27
|
+
loadEpochs?(scope: Scope): Promise<Epoch[]>;
|
|
28
|
+
saveEpochs?(scope: Scope, epochs: readonly Epoch[]): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Optional (FR-23): compaction behind an undo horizon. Moves the ops
|
|
31
|
+
* before `checkpoint.seq`, and the epochs before it, into the archive,
|
|
32
|
+
* and makes `checkpoint` the first epoch. From then on `loadLog` returns
|
|
33
|
+
* the ops from its seq on and `loadEpochs` the checkpoint and what came
|
|
34
|
+
* after it, so a normal open loads nothing older; `loadArchive` returns
|
|
35
|
+
* what was moved, oldest first, for a full export. Nothing is deleted.
|
|
36
|
+
* An adapter that keeps no epochs keeps no checkpoint, and has neither.
|
|
37
|
+
*/
|
|
38
|
+
compact?(scope: Scope, checkpoint: Epoch): Promise<void>;
|
|
39
|
+
loadArchive?(scope: Scope): Promise<LogArchive>;
|
|
21
40
|
}
|
|
22
41
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/persistence/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,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AK,EAAE,KAAK,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC7C,SAAS,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE;;;;OAIG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5C,UAAU,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE;;;;;;;;OAQG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACjD"}
|
package/dist/presence.d.ts
CHANGED
|
@@ -6,8 +6,14 @@ export interface PresenceRobot {
|
|
|
6
6
|
export interface Presence {
|
|
7
7
|
/** `kind:id:session` — the op log's own reading of an author, so a figure and its edits agree. */
|
|
8
8
|
readonly participant: string;
|
|
9
|
+
/** What they are: a person, an agent, a rule, a system. A server says it from the seat (FR-47); absent from an older word, read the key. */
|
|
10
|
+
readonly kind?: Participant["kind"];
|
|
9
11
|
/** What to call them. Absent for an anonymous viewer, who is counted rather than drawn. */
|
|
10
12
|
readonly name?: string;
|
|
13
|
+
/** The id of the person an agent acts for (FR-47), from its seat — never from what a client claims. */
|
|
14
|
+
readonly onBehalfOf?: string;
|
|
15
|
+
/** What to call that person: "Claude, for Ada". Withheld with `onBehalfOf` from a seat that may not see them. */
|
|
16
|
+
readonly onBehalfOfName?: string;
|
|
11
17
|
readonly hue: number;
|
|
12
18
|
/** Where they are: `toUrl(view)`, the complete answer. */
|
|
13
19
|
readonly stop: string;
|
|
@@ -17,6 +23,12 @@ export interface Presence {
|
|
|
17
23
|
readonly robot?: PresenceRobot;
|
|
18
24
|
/** When they last said so, ISO. */
|
|
19
25
|
readonly at: string;
|
|
26
|
+
/**
|
|
27
|
+
* When an ANNOUNCED visitor goes, ISO (FR-47): an agent acting over MCP or
|
|
28
|
+
* an RPC, a polling tab — somebody without a socket, stamped by a host.
|
|
29
|
+
* Until then they stand without a heartbeat; after it, they are gone.
|
|
30
|
+
*/
|
|
31
|
+
readonly until?: string;
|
|
20
32
|
}
|
|
21
33
|
export interface PresenceChannel {
|
|
22
34
|
/** Say where you are. Called on every change and on every heartbeat. */
|
|
@@ -28,6 +40,50 @@ export interface PresenceChannel {
|
|
|
28
40
|
}
|
|
29
41
|
/** How long a presence stands after its last word: three missed heartbeats at the poll's own pace. */
|
|
30
42
|
export declare const PRESENCE_TTL_MS = 2500;
|
|
43
|
+
/**
|
|
44
|
+
* HOW LONG A PRESENCE FROM SOMEWHERE ELSE STANDS (FR-13). A list that came
|
|
45
|
+
* over a wire was stamped by a server's clock and read by a browser's, and
|
|
46
|
+
* it arrives at the poll's pace rather than the heartbeat's, so it is given
|
|
47
|
+
* four times a tab's own grace. Past it a participant is gone whether or
|
|
48
|
+
* not the channel ever said so: a host's channel that forgets to drop
|
|
49
|
+
* somebody does not keep them on the map.
|
|
50
|
+
*/
|
|
51
|
+
export declare const REMOTE_PRESENCE_TTL_MS: number;
|
|
52
|
+
/**
|
|
53
|
+
* HOW LONG AN ANNOUNCED VISITOR STANDS (FR-47) when a host does not say:
|
|
54
|
+
* an agent between two calls is thinking, not gone.
|
|
55
|
+
*/
|
|
56
|
+
export declare const VISITOR_PRESENCE_TTL_MS = 30000;
|
|
57
|
+
/**
|
|
58
|
+
* WHAT TO CALL THEM, in a room: "Claude, for Ada" for an agent whose
|
|
59
|
+
* person may be named, the name alone otherwise, and "" for an anonymous
|
|
60
|
+
* viewer, who is counted rather than drawn.
|
|
61
|
+
*/
|
|
62
|
+
export declare function presenceName(presence: Presence): string;
|
|
63
|
+
/** Whether a presence still stands at `now`: until its announced time, or within the TTL of its last word. */
|
|
64
|
+
export declare function presenceStands(presence: Presence, now: number, ttlMs?: number): boolean;
|
|
65
|
+
/** The parts of a participant key: who, and which tab of theirs. */
|
|
66
|
+
export interface Participant {
|
|
67
|
+
readonly kind: "human" | "agent" | "rule" | "system";
|
|
68
|
+
readonly id?: string;
|
|
69
|
+
readonly session?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* THE ONE DIALECT. A participant is `kind:id:session`: the op log's own
|
|
73
|
+
* reading of an author (`Author.kind`, `.id`, `.session`), a figure's key on
|
|
74
|
+
* the map, and what the wire's presence routes carry, so a figure and its
|
|
75
|
+
* edits are the same person by construction. A host that says who is here
|
|
76
|
+
* from its own server writes this, and only this.
|
|
77
|
+
*/
|
|
78
|
+
export declare function participantKey(participant: Participant): string;
|
|
79
|
+
/**
|
|
80
|
+
* A participant key read back. The kind is everything before the first
|
|
81
|
+
* colon and the session everything after the last, so an id that holds a
|
|
82
|
+
* colon (`mcp:claude`) survives. Null for anything that is not a key.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseParticipant(key: string): (Participant & {
|
|
85
|
+
readonly session: string;
|
|
86
|
+
}) | null;
|
|
31
87
|
/**
|
|
32
88
|
* The others as they are now: what arrived, minus what has gone quiet, minus
|
|
33
89
|
* yourself. Pure, so a test can ask what a viewer sees without a channel.
|
package/dist/presence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,kGAAkG;IAClG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2FAA2F;IAC3F,QA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M,EAAE,QAAQ,CAAC,EACpC,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,MAAwB,EAC/B,IAAI,CAAC,EAAE,MAAM,GACZ,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAevB;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAetF"}
|
package/dist/presence.js
CHANGED
|
@@ -12,6 +12,62 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** How long a presence stands after its last word: three missed heartbeats at the poll's own pace. */
|
|
14
14
|
export const PRESENCE_TTL_MS = 2500;
|
|
15
|
+
/**
|
|
16
|
+
* HOW LONG A PRESENCE FROM SOMEWHERE ELSE STANDS (FR-13). A list that came
|
|
17
|
+
* over a wire was stamped by a server's clock and read by a browser's, and
|
|
18
|
+
* it arrives at the poll's pace rather than the heartbeat's, so it is given
|
|
19
|
+
* four times a tab's own grace. Past it a participant is gone whether or
|
|
20
|
+
* not the channel ever said so: a host's channel that forgets to drop
|
|
21
|
+
* somebody does not keep them on the map.
|
|
22
|
+
*/
|
|
23
|
+
export const REMOTE_PRESENCE_TTL_MS = PRESENCE_TTL_MS * 4;
|
|
24
|
+
/**
|
|
25
|
+
* HOW LONG AN ANNOUNCED VISITOR STANDS (FR-47) when a host does not say:
|
|
26
|
+
* an agent between two calls is thinking, not gone.
|
|
27
|
+
*/
|
|
28
|
+
export const VISITOR_PRESENCE_TTL_MS = 30_000;
|
|
29
|
+
/**
|
|
30
|
+
* WHAT TO CALL THEM, in a room: "Claude, for Ada" for an agent whose
|
|
31
|
+
* person may be named, the name alone otherwise, and "" for an anonymous
|
|
32
|
+
* viewer, who is counted rather than drawn.
|
|
33
|
+
*/
|
|
34
|
+
export function presenceName(presence) {
|
|
35
|
+
const name = presence.name ?? "";
|
|
36
|
+
return name && presence.onBehalfOfName ? `${name}, for ${presence.onBehalfOfName}` : name;
|
|
37
|
+
}
|
|
38
|
+
/** Whether a presence still stands at `now`: until its announced time, or within the TTL of its last word. */
|
|
39
|
+
export function presenceStands(presence, now, ttlMs = PRESENCE_TTL_MS) {
|
|
40
|
+
if (presence.until !== undefined)
|
|
41
|
+
return now < Date.parse(presence.until);
|
|
42
|
+
return now - Date.parse(presence.at) < ttlMs;
|
|
43
|
+
}
|
|
44
|
+
const PARTICIPANT_KINDS = new Set(["human", "agent", "rule", "system"]);
|
|
45
|
+
/**
|
|
46
|
+
* THE ONE DIALECT. A participant is `kind:id:session`: the op log's own
|
|
47
|
+
* reading of an author (`Author.kind`, `.id`, `.session`), a figure's key on
|
|
48
|
+
* the map, and what the wire's presence routes carry, so a figure and its
|
|
49
|
+
* edits are the same person by construction. A host that says who is here
|
|
50
|
+
* from its own server writes this, and only this.
|
|
51
|
+
*/
|
|
52
|
+
export function participantKey(participant) {
|
|
53
|
+
return `${participant.kind}:${participant.id ?? ""}:${participant.session ?? ""}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A participant key read back. The kind is everything before the first
|
|
57
|
+
* colon and the session everything after the last, so an id that holds a
|
|
58
|
+
* colon (`mcp:claude`) survives. Null for anything that is not a key.
|
|
59
|
+
*/
|
|
60
|
+
export function parseParticipant(key) {
|
|
61
|
+
const first = key.indexOf(":");
|
|
62
|
+
const last = key.lastIndexOf(":");
|
|
63
|
+
if (first < 0 || last === first)
|
|
64
|
+
return null;
|
|
65
|
+
const kind = key.slice(0, first);
|
|
66
|
+
if (!PARTICIPANT_KINDS.has(kind))
|
|
67
|
+
return null;
|
|
68
|
+
const id = key.slice(first + 1, last);
|
|
69
|
+
return { kind: kind, ...(id ? { id } : {}), session: key.slice(last + 1) };
|
|
70
|
+
}
|
|
15
71
|
/**
|
|
16
72
|
* The others as they are now: what arrived, minus what has gone quiet, minus
|
|
17
73
|
* yourself. Pure, so a test can ask what a viewer sees without a channel.
|
|
@@ -19,11 +75,11 @@ export const PRESENCE_TTL_MS = 2500;
|
|
|
19
75
|
export function foldPresence(known, arrived, now, ttlMs = PRESENCE_TTL_MS, self) {
|
|
20
76
|
const next = new Map();
|
|
21
77
|
for (const [participant, presence] of known) {
|
|
22
|
-
if (
|
|
78
|
+
if (presenceStands(presence, now, ttlMs))
|
|
23
79
|
next.set(participant, presence);
|
|
24
80
|
}
|
|
25
81
|
for (const presence of arrived) {
|
|
26
|
-
if (
|
|
82
|
+
if (!presenceStands(presence, now, ttlMs)) {
|
|
27
83
|
next.delete(presence.participant);
|
|
28
84
|
continue;
|
|
29
85
|
}
|
|
@@ -40,7 +96,11 @@ export function samePresence(a, b) {
|
|
|
40
96
|
if (!a || !b)
|
|
41
97
|
return a === b;
|
|
42
98
|
return (a.participant === b.participant &&
|
|
99
|
+
a.kind === b.kind &&
|
|
43
100
|
a.name === b.name &&
|
|
101
|
+
a.onBehalfOf === b.onBehalfOf &&
|
|
102
|
+
a.onBehalfOfName === b.onBehalfOfName &&
|
|
103
|
+
a.until === b.until &&
|
|
44
104
|
a.hue === b.hue &&
|
|
45
105
|
a.stop === b.stop &&
|
|
46
106
|
(a.over ?? null) === (b.over ?? null) &&
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6CH,sGAAsG;AACtG,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,GAAG,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,YAAY,C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AI,KAAK,SAAS;QAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,CAAuB,EAAE,CAAuB;IAC3E,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,CACL,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;QAC/B,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAC7B,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC,cAAc;QACrC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACnB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG;QACf,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC;QACrC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,IAAI,IAAI,CAAC;QAC/C,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHY A CHANGE WAS REFUSED, AS A CODE A PROGRAM CAN BRANCH ON (FR-46).
|
|
3
|
+
*
|
|
4
|
+
* A refusal reached a client as a sentence and nothing else, so an MCP tool
|
|
5
|
+
* and an interface told "you may not" from "it is gone" by matching words.
|
|
6
|
+
* The set is closed and on the stability surface (docs/stability.md): a
|
|
7
|
+
* code never changes meaning, and a new one is a new protocol.
|
|
8
|
+
*
|
|
9
|
+
* forbidden the seat may not: the policy, a sight, an agent's `may`, a module turned off
|
|
10
|
+
* missing what the call names is not there: a record, or a batch to take back
|
|
11
|
+
* invalid the call as asked does not fit: its arguments, the kind, a rule, the order things happened in
|
|
12
|
+
* limit the host's hard cap: the call can never succeed as asked, however long the caller waits
|
|
13
|
+
*
|
|
14
|
+
* `limit` is the host's to say; nothing in the store says it. It is not
|
|
15
|
+
* `busy`: busy is "not now", and the client keeps the change and sends it
|
|
16
|
+
* again (FR-45). A refusal of any reason is final, and the change is taken
|
|
17
|
+
* back.
|
|
18
|
+
*/
|
|
19
|
+
export declare const REFUSAL_REASONS: readonly ["forbidden", "missing", "invalid", "limit"];
|
|
20
|
+
export type RefusalReason = (typeof REFUSAL_REASONS)[number];
|
|
21
|
+
/** A refusal as the wire carries it: the code, the sentence a person reads, and who could. */
|
|
22
|
+
export interface WireRefusal {
|
|
23
|
+
readonly reason: RefusalReason;
|
|
24
|
+
readonly sentence: string;
|
|
25
|
+
/** The roles that would be allowed, when the policy knows them. Absent when it names none. */
|
|
26
|
+
readonly wouldNeed?: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* THE STORE'S OWN ERRORS, READ INTO A REASON. Anything that is not one of
|
|
30
|
+
* the store's refusals — a mutation's own throw, an invariant, an id that
|
|
31
|
+
* is taken — is `invalid`, in its own words.
|
|
32
|
+
*/
|
|
33
|
+
export declare function refusalOf(error: unknown): WireRefusal;
|
|
34
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,uDAAwD,CAAC;AAErF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CASrD"}
|
package/dist/refusal.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MissingRecordError } from "./graph/graph.js";
|
|
2
|
+
import { UndoBlockedError } from "./ops/undo.js";
|
|
3
|
+
import { PermissionDeniedError } from "./permissions/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* WHY A CHANGE WAS REFUSED, AS A CODE A PROGRAM CAN BRANCH ON (FR-46).
|
|
6
|
+
*
|
|
7
|
+
* A refusal reached a client as a sentence and nothing else, so an MCP tool
|
|
8
|
+
* and an interface told "you may not" from "it is gone" by matching words.
|
|
9
|
+
* The set is closed and on the stability surface (docs/stability.md): a
|
|
10
|
+
* code never changes meaning, and a new one is a new protocol.
|
|
11
|
+
*
|
|
12
|
+
* forbidden the seat may not: the policy, a sight, an agent's `may`, a module turned off
|
|
13
|
+
* missing what the call names is not there: a record, or a batch to take back
|
|
14
|
+
* invalid the call as asked does not fit: its arguments, the kind, a rule, the order things happened in
|
|
15
|
+
* limit the host's hard cap: the call can never succeed as asked, however long the caller waits
|
|
16
|
+
*
|
|
17
|
+
* `limit` is the host's to say; nothing in the store says it. It is not
|
|
18
|
+
* `busy`: busy is "not now", and the client keeps the change and sends it
|
|
19
|
+
* again (FR-45). A refusal of any reason is final, and the change is taken
|
|
20
|
+
* back.
|
|
21
|
+
*/
|
|
22
|
+
export const REFUSAL_REASONS = ["forbidden", "missing", "invalid", "limit"];
|
|
23
|
+
/**
|
|
24
|
+
* THE STORE'S OWN ERRORS, READ INTO A REASON. Anything that is not one of
|
|
25
|
+
* the store's refusals — a mutation's own throw, an invariant, an id that
|
|
26
|
+
* is taken — is `invalid`, in its own words.
|
|
27
|
+
*/
|
|
28
|
+
export function refusalOf(error) {
|
|
29
|
+
const sentence = error instanceof Error ? error.message : String(error);
|
|
30
|
+
if (error instanceof PermissionDeniedError) {
|
|
31
|
+
const roles = error.refusal.wouldNeed;
|
|
32
|
+
return { reason: "forbidden", sentence, ...(roles.length > 0 ? { wouldNeed: [...roles] } : {}) };
|
|
33
|
+
}
|
|
34
|
+
if (error instanceof MissingRecordError)
|
|
35
|
+
return { reason: "missing", sentence };
|
|
36
|
+
if (error instanceof UndoBlockedError)
|
|
37
|
+
return { reason: error.check.reason ?? "invalid", sentence };
|
|
38
|
+
return { reason: "invalid", sentence };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=refusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAYrF;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,KAAK,YAAY,qBAAqB,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACtC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACnG,CAAC;IACD,IAAI,KAAK,YAAY,kBAAkB;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IAChF,IAAI,KAAK,YAAY,gBAAgB;QAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,QAAQ,EAAE,CAAC;IACpG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GraviewTemplate } from "../document/graview-template.js";
|
|
2
|
+
import { type Ids } from "./names.js";
|
|
3
|
+
/** The kind a project's UI leads with, and the act its seat is gated on: the first kind something creates. */
|
|
4
|
+
export declare function templateKind(template: GraviewTemplate): {
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
readonly plural: string;
|
|
7
|
+
readonly gate: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function documentJson(template: GraviewTemplate): string;
|
|
10
|
+
export declare function templateJson(template: GraviewTemplate): string;
|
|
11
|
+
export declare function documentAppTs(ids: Ids): string;
|
|
12
|
+
export declare function documentSchemaTs(ids: Ids): string;
|
|
13
|
+
export declare function documentBrandTs(ids: Ids): string;
|
|
14
|
+
export declare function documentTest(ids: Ids): string;
|
|
15
|
+
export declare function documentReadmeLayout(ids: Ids, run: string): string;
|
|
16
|
+
//# sourceMappingURL=from-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-template.d.ts","sourceRoot":"","sources":["../../src/scaffold/from-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,KAAK,GAAG,EAAyB,MAAM,YAAY,CAAC;AAmB7D,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAQjI;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAE9D;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAE9D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAkC9C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAOjD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAiBhD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CA+C7C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAalE"}
|