@zixcel/projection-contracts 0.10.2 → 0.10.4
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 +1 -1
- package/package.json +16 -10
- package/src/canonical.d.mts +1 -0
- package/src/client.d.mts +2 -11
- package/src/client.mjs +16 -3
- package/src/contract.d.mts +28 -0
- package/src/contract.mjs +177 -55
- package/src/hash-browser.d.mts +1 -0
- package/src/hash-browser.mjs +11 -5
- package/src/hash-node.d.mts +1 -0
- package/src/hash-node.mjs +8 -2
- package/src/index.d.mts +5 -26
- package/src/index.mjs +20 -3
- package/src/produce.d.mts +3 -0
- package/src/producer.d.mts +4 -0
- package/src/producer.mjs +283 -166
- package/src/publication.d.mts +15 -0
- package/src/publication.mjs +58 -32
- package/src/recovery.d.mts +16 -0
- package/src/scene-actions.d.mts +2 -0
- package/src/scene-bindings.d.mts +6 -0
- package/src/scene.d.mts +4 -0
- package/src/seal.d.mts +6 -0
- package/src/snapshot.d.mts +2 -0
- package/src/source-items.d.mts +4 -0
- package/src/types/input.d.mts +54 -15
- package/src/types/publication.d.mts +16 -0
- package/src/types/snapshot.d.mts +102 -28
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ selected owner-visible source revisions. Deterministic lineage and publication
|
|
|
7
7
|
fences keep presentation tied to the accepted source without owning its meaning.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install @zixcel/projection-contracts
|
|
10
|
+
npm install @zixcel/projection-contracts
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zixcel/projection-contracts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Renderer-independent bounded projection, lineage and Scene contracts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,16 +33,12 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"ohash": "2.0.
|
|
36
|
+
"ohash": "2.0.12",
|
|
37
37
|
"@zixcel/interaction": "0.10.1"
|
|
38
38
|
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"test": "node --test test/*.test.mjs",
|
|
41
|
-
"typecheck": "tsc --noEmit --strict --module NodeNext --moduleResolution NodeNext --target ES2022 test/public-types.mts"
|
|
42
|
-
},
|
|
43
39
|
"repository": {
|
|
44
40
|
"type": "git",
|
|
45
|
-
"url": "git+https://github.com/zixcel/
|
|
41
|
+
"url": "git+https://github.com/zixcel/data-presentation.git",
|
|
46
42
|
"directory": "packages/projection-contracts"
|
|
47
43
|
},
|
|
48
44
|
"publishConfig": {
|
|
@@ -51,8 +47,18 @@
|
|
|
51
47
|
},
|
|
52
48
|
"types": "./src/index.d.mts",
|
|
53
49
|
"devDependencies": {
|
|
54
|
-
"typescript": "
|
|
50
|
+
"typescript": "7.0.2",
|
|
55
51
|
"@types/node": "24.12.0"
|
|
56
52
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
53
|
+
"keywords": [
|
|
54
|
+
"typed-contracts",
|
|
55
|
+
"schema-validation",
|
|
56
|
+
"data-presentation",
|
|
57
|
+
"javascript"
|
|
58
|
+
],
|
|
59
|
+
"scripts": {
|
|
60
|
+
"test": "node --test test/*.test.mts",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit && tsc --noEmit --strict --module NodeNext --moduleResolution NodeNext --target ES2022 test/public-types.mts",
|
|
62
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/build-projection-contracts.mts"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function canonical(value: unknown, maximum?: number): string;
|
package/src/client.d.mts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export { validateSnapshot } from './producer.mjs';
|
|
2
|
+
export { canonical, copy, frozen, shape, text, roles, ProjectionError, LIMITS } from './contract.mjs';
|
|
2
3
|
export type * from './types/snapshot.mjs';
|
|
3
|
-
import type { DataProjection, SceneProjection } from './types/snapshot.mjs';
|
|
4
|
-
export function validateSnapshot(value: unknown): DataProjection | SceneProjection;
|
|
5
|
-
export function canonical(value: unknown, maximum?: number): string;
|
|
6
|
-
export function copy<T>(value: T): T;
|
|
7
|
-
export function frozen<T>(value: T): Readonly<T>;
|
|
8
|
-
export function shape(value: unknown, required: string[], optional?: string[]): void;
|
|
9
|
-
export function text(value: unknown, maximum?: number): string;
|
|
10
|
-
export const roles: readonly import('./types/snapshot.mjs').RegionRole[];
|
|
11
|
-
export const LIMITS: Readonly<import('./types/input.mjs').ProjectionLimits>;
|
|
12
|
-
export class ProjectionError extends Error { readonly code: string; constructor(code: string) }
|
package/src/client.mjs
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Generated from canonical TypeScript; do not edit.
|
|
2
|
+
|
|
3
|
+
// implementation/client.mts
|
|
4
|
+
import { validateSnapshot } from "./producer.mjs";
|
|
5
|
+
import { canonical, copy, frozen, shape, text, roles, ProjectionError, LIMITS } from "./contract.mjs";
|
|
6
|
+
export {
|
|
7
|
+
LIMITS,
|
|
8
|
+
ProjectionError,
|
|
9
|
+
canonical,
|
|
10
|
+
copy,
|
|
11
|
+
frozen,
|
|
12
|
+
roles,
|
|
13
|
+
shape,
|
|
14
|
+
text,
|
|
15
|
+
validateSnapshot
|
|
16
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { canonical } from './canonical.mjs';
|
|
2
|
+
import type { Json, RegionRole, SourceRef } from './types/snapshot.mjs';
|
|
3
|
+
import type { ProjectionLimits, ProjectionRequest } from './types/input.mjs';
|
|
4
|
+
export { canonical };
|
|
5
|
+
export declare class ProjectionError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(code: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function fail(code: string): never;
|
|
10
|
+
export declare const LIMITS: Readonly<ProjectionLimits>;
|
|
11
|
+
export declare function shape(v: unknown, required: readonly string[], optional?: readonly string[]): asserts v is Record<string, unknown>;
|
|
12
|
+
export declare function record(v: unknown): Record<string, unknown>;
|
|
13
|
+
export declare function text(v: unknown, max?: number): string;
|
|
14
|
+
export declare function list(v: unknown, max: number): unknown[];
|
|
15
|
+
export declare const refs: (v: unknown, max?: number) => string[];
|
|
16
|
+
export declare function choice<const T extends readonly string[]>(value: unknown, values: T): T[number];
|
|
17
|
+
export declare function limits(input?: unknown): Readonly<ProjectionLimits>;
|
|
18
|
+
export declare const digest: (value: unknown) => string;
|
|
19
|
+
export declare function frozen<T>(value: T): Readonly<T>;
|
|
20
|
+
export declare const copy: <T>(v: T) => T;
|
|
21
|
+
export declare const json: (v: unknown) => Json;
|
|
22
|
+
export declare function sourceRef(v: unknown): SourceRef;
|
|
23
|
+
export declare const sourceKey: (v: unknown) => string;
|
|
24
|
+
export declare function unique<T>(values: T[], key?: (value: T) => unknown): T[];
|
|
25
|
+
export declare const roles: readonly RegionRole[];
|
|
26
|
+
export declare function request(v: unknown): ProjectionRequest & {
|
|
27
|
+
readonly limits: Readonly<ProjectionLimits>;
|
|
28
|
+
};
|
package/src/contract.mjs
CHANGED
|
@@ -1,59 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// Generated from canonical TypeScript; do not edit.
|
|
2
|
+
|
|
3
|
+
// implementation/contract.mts
|
|
4
|
+
import { sha256 } from "#hash";
|
|
5
|
+
|
|
6
|
+
// implementation/canonical.mts
|
|
7
|
+
var encoder = new TextEncoder();
|
|
8
|
+
var byteLength = (value) => encoder.encode(value).length;
|
|
9
|
+
function canonical(value, maximum = 2097152) {
|
|
10
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > 2097152) fail("ProjectionLimitExceeded");
|
|
11
|
+
let bytes = 0, nodes = 0;
|
|
12
|
+
const add = (n) => {
|
|
13
|
+
bytes += n;
|
|
14
|
+
if (bytes > maximum) fail("ProjectionLimitExceeded");
|
|
15
|
+
};
|
|
16
|
+
function walk(v, depth) {
|
|
17
|
+
if (++nodes > 32768 || depth > 16) fail("ProjectionLimitExceeded");
|
|
18
|
+
if (v === null || typeof v === "boolean") {
|
|
19
|
+
add(5);
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
if (typeof v === "number") {
|
|
23
|
+
if (!Number.isSafeInteger(v)) fail("InvalidProjection");
|
|
24
|
+
add(24);
|
|
25
|
+
return v;
|
|
26
|
+
}
|
|
27
|
+
if (typeof v === "string") {
|
|
28
|
+
if (v.length > maximum) fail("ProjectionLimitExceeded");
|
|
29
|
+
if (!v.isWellFormed()) fail("InvalidProjection");
|
|
30
|
+
add(byteLength(v) + 2);
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(v)) {
|
|
34
|
+
const count = v.length;
|
|
35
|
+
add(count + 2);
|
|
36
|
+
if (count > 4096) fail("ProjectionLimitExceeded");
|
|
37
|
+
if (Object.getPrototypeOf(v) !== Array.prototype || Object.getOwnPropertySymbols(v).length) fail("InvalidProjection");
|
|
38
|
+
if (Object.getOwnPropertyNames(v).length !== count + 1) fail("InvalidProjection");
|
|
39
|
+
const out2 = [];
|
|
40
|
+
for (let i = 0; i < count; i++) {
|
|
41
|
+
const d = Object.getOwnPropertyDescriptor(v, String(i));
|
|
42
|
+
if (!d || !d.enumerable || !("value" in d)) fail("InvalidProjection");
|
|
43
|
+
out2.push(walk(d.value, depth + 1));
|
|
44
|
+
}
|
|
45
|
+
return out2;
|
|
46
|
+
}
|
|
47
|
+
if (!v || typeof v !== "object" || Object.getPrototypeOf(v) !== Object.prototype) fail("InvalidProjection");
|
|
48
|
+
const keys = Object.getOwnPropertyNames(v);
|
|
49
|
+
if (keys.length > 1024 || Object.getOwnPropertySymbols(v).length) fail("ProjectionLimitExceeded");
|
|
50
|
+
const out = {};
|
|
51
|
+
add(keys.length + 2);
|
|
52
|
+
for (const k of keys.sort()) {
|
|
53
|
+
const d = Object.getOwnPropertyDescriptor(v, k);
|
|
54
|
+
if (!d || !d.enumerable || !("value" in d) || ["__proto__", "constructor", "prototype", "toJSON"].includes(k)) fail("InvalidProjection");
|
|
55
|
+
text(k, 512);
|
|
56
|
+
add(byteLength(k) + 3);
|
|
57
|
+
out[k] = walk(d.value, depth + 1);
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
const encoded = JSON.stringify(walk(value, 0));
|
|
62
|
+
if (byteLength(encoded) > maximum) fail("ProjectionLimitExceeded");
|
|
63
|
+
return encoded;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// implementation/contract.mts
|
|
67
|
+
var encoder2 = new TextEncoder();
|
|
68
|
+
var ProjectionError = class extends Error {
|
|
69
|
+
code;
|
|
70
|
+
constructor(code) {
|
|
71
|
+
super(code);
|
|
72
|
+
this.code = code;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function fail(code) {
|
|
76
|
+
throw new ProjectionError(code);
|
|
77
|
+
}
|
|
78
|
+
var LIMITS = Object.freeze({ sources: 8, items: 256, relations: 512, provenance: 512, unresolved: 64, regions: 16, actions: 64, snapshotBytes: 524288 });
|
|
79
|
+
function shape(v, required, optional = []) {
|
|
80
|
+
if (!v || typeof v !== "object" || Object.getPrototypeOf(v) !== Object.prototype || required.some((k) => !Object.hasOwn(v, k))) fail("InvalidProjection");
|
|
81
|
+
for (const k of Object.getOwnPropertyNames(v)) {
|
|
82
|
+
const d = Object.getOwnPropertyDescriptor(v, k);
|
|
83
|
+
if (!d || !d.enumerable || !("value" in d) || !required.includes(k) && !optional.includes(k)) fail("InvalidProjection");
|
|
84
|
+
}
|
|
85
|
+
if (Object.getOwnPropertySymbols(v).length) fail("InvalidProjection");
|
|
86
|
+
}
|
|
87
|
+
function record(v) {
|
|
88
|
+
if (!v || typeof v !== "object" || Object.getPrototypeOf(v) !== Object.prototype) fail("InvalidProjection");
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
function text(v, max = 512) {
|
|
92
|
+
if (typeof v !== "string" || !v.length || v.length > max || encoder2.encode(v).length > max || !v.isWellFormed() || /[\x00-\x1f\x7f]/u.test(v)) fail("InvalidProjection");
|
|
93
|
+
return v;
|
|
94
|
+
}
|
|
95
|
+
function list(v, max) {
|
|
96
|
+
if (!Array.isArray(v) || v.length > max) fail("ProjectionLimitExceeded");
|
|
97
|
+
return v;
|
|
98
|
+
}
|
|
99
|
+
var refs = (v, max = 32) => list(v, max).map((x) => text(x));
|
|
100
|
+
function choice(value, values) {
|
|
101
|
+
if (typeof value !== "string" || !values.includes(value)) fail("InvalidProjection");
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
function limits(input = {}) {
|
|
105
|
+
shape(input, [], Object.keys(LIMITS));
|
|
106
|
+
const result = { ...LIMITS };
|
|
107
|
+
for (const key of Object.keys(LIMITS)) {
|
|
108
|
+
const value = Object.hasOwn(input, key) ? input[key] : LIMITS[key];
|
|
109
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > LIMITS[key]) fail("ProjectionLimitExceeded");
|
|
110
|
+
result[key] = value;
|
|
17
111
|
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const out={};add(keys.length+2)
|
|
36
|
-
for(const k of keys.sort()){
|
|
37
|
-
const d=Object.getOwnPropertyDescriptor(v,k)
|
|
38
|
-
if(!d.enumerable||d.get||d.set||['__proto__','constructor','prototype','toJSON'].includes(k))fail('InvalidProjection')
|
|
39
|
-
text(k,512);add(byteLength(k)+3);out[k]=walk(v[k],depth+1)
|
|
112
|
+
return Object.freeze(result);
|
|
113
|
+
}
|
|
114
|
+
var digest = (value) => sha256(canonical(value));
|
|
115
|
+
function frozen(value) {
|
|
116
|
+
const pending = [{ value, depth: 0 }], seen = /* @__PURE__ */ new WeakSet();
|
|
117
|
+
let nodes = 0;
|
|
118
|
+
while (pending.length) {
|
|
119
|
+
const current = pending.pop();
|
|
120
|
+
if (++nodes > 32768 || current.depth > 20) fail("ProjectionLimitExceeded");
|
|
121
|
+
const v = current.value;
|
|
122
|
+
if (!v || typeof v !== "object" || seen.has(v)) continue;
|
|
123
|
+
seen.add(v);
|
|
124
|
+
for (const key of Object.keys(v)) {
|
|
125
|
+
const d = Object.getOwnPropertyDescriptor(v, key);
|
|
126
|
+
if (!d || !("value" in d)) fail("InvalidProjection");
|
|
127
|
+
pending.push({ value: d.value, depth: current.depth + 1 });
|
|
128
|
+
if (pending.length > 32768) fail("ProjectionLimitExceeded");
|
|
40
129
|
}
|
|
41
|
-
|
|
130
|
+
Object.freeze(v);
|
|
42
131
|
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
var copy = (v) => JSON.parse(canonical(v));
|
|
135
|
+
var json = (v) => JSON.parse(canonical(v));
|
|
136
|
+
function sourceRef(v) {
|
|
137
|
+
shape(v, ["owner", "ref", "revision", "kind"]);
|
|
138
|
+
return copy({ owner: text(v.owner), ref: text(v.ref), revision: text(v.revision), kind: text(v.kind) });
|
|
139
|
+
}
|
|
140
|
+
var sourceKey = (v) => canonical(sourceRef(v));
|
|
141
|
+
function unique(values, key = (x) => x) {
|
|
142
|
+
const ids = /* @__PURE__ */ new Set();
|
|
143
|
+
for (const v of values) {
|
|
144
|
+
const id = key(v);
|
|
145
|
+
if (ids.has(id)) fail("InvalidProjection");
|
|
146
|
+
ids.add(id);
|
|
147
|
+
}
|
|
148
|
+
return values;
|
|
149
|
+
}
|
|
150
|
+
var roles = Object.freeze(["Primary", "Context", "Interpretation", "Evidence", "Provenance", "Resolution", "Inspector", "Actions", "Activity"]);
|
|
151
|
+
function request(v) {
|
|
152
|
+
canonical(v);
|
|
153
|
+
shape(v, ["key", "producer", "sources", "focus", "purpose", "visibilityRef", "limits"]);
|
|
154
|
+
shape(v.producer, ["id", "version", "contract", "configuration"]);
|
|
155
|
+
const producer = { id: text(v.producer.id), version: text(v.producer.version), contract: text(v.producer.contract), configuration: text(v.producer.configuration) };
|
|
156
|
+
const l = limits(v.limits), sources = unique(list(v.sources, l.sources).map(sourceRef), (s) => canonical([s.owner, s.ref])).sort((a, b) => sourceKey(a) < sourceKey(b) ? -1 : 1);
|
|
157
|
+
if (!sources.length) fail("SourceUnavailable");
|
|
158
|
+
return frozen({ key: text(v.key), producer, sources, focus: text(v.focus), purpose: text(v.purpose), visibilityRef: text(v.visibilityRef), limits: l });
|
|
59
159
|
}
|
|
160
|
+
export {
|
|
161
|
+
LIMITS,
|
|
162
|
+
ProjectionError,
|
|
163
|
+
canonical,
|
|
164
|
+
choice,
|
|
165
|
+
copy,
|
|
166
|
+
digest,
|
|
167
|
+
fail,
|
|
168
|
+
frozen,
|
|
169
|
+
json,
|
|
170
|
+
limits,
|
|
171
|
+
list,
|
|
172
|
+
record,
|
|
173
|
+
refs,
|
|
174
|
+
request,
|
|
175
|
+
roles,
|
|
176
|
+
shape,
|
|
177
|
+
sourceKey,
|
|
178
|
+
sourceRef,
|
|
179
|
+
text,
|
|
180
|
+
unique
|
|
181
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sha256: (value: string) => string;
|
package/src/hash-browser.mjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// Generated from canonical TypeScript; do not edit.
|
|
2
|
+
|
|
3
|
+
// implementation/hash-browser.mts
|
|
4
|
+
import { digest } from "ohash/crypto";
|
|
5
|
+
var sha256 = (value) => Array.from(
|
|
6
|
+
atob(digest(value).replaceAll("-", "+").replaceAll("_", "/") + "="),
|
|
7
|
+
(c) => c.charCodeAt(0).toString(16).padStart(2, "0")
|
|
8
|
+
).join("");
|
|
9
|
+
export {
|
|
10
|
+
sha256
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sha256: (value: string) => string;
|
package/src/hash-node.mjs
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Generated from canonical TypeScript; do not edit.
|
|
2
|
+
|
|
3
|
+
// implementation/hash-node.mts
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
var sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
6
|
+
export {
|
|
7
|
+
sha256
|
|
8
|
+
};
|
package/src/index.d.mts
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
export { ProjectionError, LIMITS, canonical } from './
|
|
2
|
-
export
|
|
1
|
+
export { ProjectionError, LIMITS, canonical } from './contract.mjs';
|
|
2
|
+
export { produce, scene, validateSnapshot, rebuild, recovery, adoptSnapshot } from './producer.mjs';
|
|
3
|
+
export { ProjectionSlot, pendingRepair, repair } from './publication.mjs';
|
|
3
4
|
export type * from './types/input.mjs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type Snapshot = DataProjection | SceneProjection;
|
|
7
|
-
export interface PublicationTicket { readonly key: string; readonly expected: string }
|
|
8
|
-
export interface PublicationReceipt extends PublicationTicket { readonly publication: string; readonly revision: string }
|
|
9
|
-
export interface PendingRepair { readonly ticket: PublicationTicket; readonly request: ProjectionRequest; readonly failure: 'ProjectionUnavailable' | 'ProjectionLimitExceeded' }
|
|
10
|
-
/** Validate and deterministically seal explicitly selected owner-visible data. */
|
|
11
|
-
export function produce(input: ProjectionRequest, exactSources: readonly ExactSource[]): DataProjection;
|
|
12
|
-
export function scene(data: DataProjection, configuration: SceneConfiguration): SceneProjection;
|
|
13
|
-
export function validateSnapshot(value: unknown): Snapshot;
|
|
14
|
-
export function rebuild(input: ProjectionRequest, readExact: ReadExact): DataProjection;
|
|
15
|
-
export function recovery(snapshot: Snapshot, receiverRevision: string | null):
|
|
16
|
-
{ kind: 'NoChange'; revision: string } | { kind: 'Snapshot'; revision: string; payload: Uint8Array };
|
|
17
|
-
export function adoptSnapshot(snapshot: Snapshot, expected: { key: string; revision: string }): Readonly<Snapshot>;
|
|
18
|
-
/** Disposable in-memory publication fence; it does not survive process restart. */
|
|
19
|
-
export class ProjectionSlot {
|
|
20
|
-
constructor(key: string);
|
|
21
|
-
begin(): Readonly<PublicationTicket>;
|
|
22
|
-
publish(ticket: PublicationTicket, snapshot: Snapshot): Readonly<PublicationReceipt>;
|
|
23
|
-
read(): Readonly<Snapshot> | null;
|
|
24
|
-
dropCache(): void;
|
|
25
|
-
}
|
|
26
|
-
export function pendingRepair(ticket: PublicationTicket, input: ProjectionRequest, code: PendingRepair['failure']): Readonly<PendingRepair>;
|
|
27
|
-
export function repair(slot: ProjectionSlot, pending: PendingRepair, readExact: ReadExact): Readonly<PublicationReceipt>;
|
|
5
|
+
export type * from './types/snapshot.mjs';
|
|
6
|
+
export type * from './types/publication.mjs';
|
package/src/index.mjs
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Generated from canonical TypeScript; do not edit.
|
|
2
|
+
|
|
3
|
+
// implementation/index.mts
|
|
4
|
+
import { ProjectionError, LIMITS, canonical } from "./contract.mjs";
|
|
5
|
+
import { produce, scene, validateSnapshot, rebuild, recovery, adoptSnapshot } from "./producer.mjs";
|
|
6
|
+
import { ProjectionSlot, pendingRepair, repair } from "./publication.mjs";
|
|
7
|
+
export {
|
|
8
|
+
LIMITS,
|
|
9
|
+
ProjectionError,
|
|
10
|
+
ProjectionSlot,
|
|
11
|
+
adoptSnapshot,
|
|
12
|
+
canonical,
|
|
13
|
+
pendingRepair,
|
|
14
|
+
produce,
|
|
15
|
+
rebuild,
|
|
16
|
+
recovery,
|
|
17
|
+
repair,
|
|
18
|
+
scene,
|
|
19
|
+
validateSnapshot
|
|
20
|
+
};
|