@feltdb/core 0.11.8 → 0.11.9
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/dist/cli/index.js +0 -0
- package/dist/composition.d.ts +697 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +1218 -0
- package/dist/create/package-versions.js +1 -1
- package/dist/create/server-source/crates/feltdb/src/lib.rs +363 -2
- package/dist/create/server-source/crates/feltdb/src/read_basis.rs +257 -0
- package/dist/create/server-source/crates/feltdb/src/state_contract.rs +442 -73
- package/dist/create/server-source/crates/feltdb/src/workload_diagnostics.rs +18 -4
- package/dist/create/server-source/crates/feltdb-server/src/main.rs +198 -10
- package/dist/db.d.ts +12 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +19 -1
- package/dist/embedded-transaction.d.ts +21 -1
- package/dist/embedded-transaction.d.ts.map +1 -1
- package/dist/embedded-transaction.js +96 -0
- package/dist/feltdb.d.ts +8 -0
- package/dist/feltdb.d.ts.map +1 -1
- package/dist/file-db.d.ts +8 -1
- package/dist/file-db.d.ts.map +1 -1
- package/dist/file-db.js +20 -1
- package/dist/flowspec.d.ts +7 -0
- package/dist/flowspec.d.ts.map +1 -1
- package/dist/flowspec.js +13 -1
- package/dist/http-db.d.ts +7 -0
- package/dist/http-db.d.ts.map +1 -1
- package/dist/http-db.js +38 -6
- package/dist/index-core.d.ts +1 -0
- package/dist/index-core.d.ts.map +1 -1
- package/dist/index-core.js +1 -0
- package/dist/indexeddb-db.d.ts +3 -1
- package/dist/indexeddb-db.d.ts.map +1 -1
- package/dist/indexeddb-db.js +50 -2
- package/dist/intent.d.ts +4 -2
- package/dist/intent.d.ts.map +1 -1
- package/dist/memory-db.d.ts +2 -1
- package/dist/memory-db.d.ts.map +1 -1
- package/dist/memory-db.js +13 -1
- package/dist/proposal.d.ts +5 -0
- package/dist/proposal.d.ts.map +1 -1
- package/dist/proposal.js +6 -2
- package/dist/state-impact.d.ts +245 -0
- package/dist/state-impact.d.ts.map +1 -0
- package/dist/state-impact.js +404 -0
- package/dist/studio-app/assets/{feltdb_wasm-D58hv7aa.js → feltdb_wasm-DGGqm9GK.js} +1 -1
- package/dist/studio-app/assets/feltdb_wasm_bg-BYJo87WY.wasm +0 -0
- package/dist/studio-app/assets/index-qLeZcPW_.js +30 -0
- package/dist/studio-app/index.html +1 -1
- package/dist/transaction.d.ts +61 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +59 -0
- package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/create/server-source/crates/feltdb-wasm/test.db +0 -0
- package/dist/create/server-source/crates/feltdb-wasm/test_wasm.db.lock +0 -0
- package/dist/studio-app/assets/feltdb_wasm_bg-BgFXYOtc.wasm +0 -0
- package/dist/studio-app/assets/index-Ccecp6rc.js +0 -30
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Impact surface of a proposed state transition.
|
|
3
|
+
*
|
|
4
|
+
* proposal (operations against base snapshot N)
|
|
5
|
+
* │
|
|
6
|
+
* ▼
|
|
7
|
+
* computeImpactSurface(snapshot N, contract, operations) ← pure, no I/O
|
|
8
|
+
* │
|
|
9
|
+
* ▼
|
|
10
|
+
* direct │ dependent │ derived │ unknown
|
|
11
|
+
*
|
|
12
|
+
* This module is a pure function over an already materialized runtime
|
|
13
|
+
* snapshot. It reads nothing else: no database, no network, no filesystem, no
|
|
14
|
+
* model. The same snapshot and operations always produce the same surface and
|
|
15
|
+
* the same digest, which is what lets an analysis be re-derived at apply time
|
|
16
|
+
* and compared, rather than trusted.
|
|
17
|
+
*
|
|
18
|
+
* It reports structure, never meaning. It says "record X is connected to
|
|
19
|
+
* record Y by this declared edge", "collection C is observed by consumer K
|
|
20
|
+
* through capability P", "field F is opaque to the contract". It never says a
|
|
21
|
+
* change is safe, risky, important, or harmless. And it never turns the
|
|
22
|
+
* absence of a known dependency into the absence of a dependency: what the
|
|
23
|
+
* authoritative model cannot establish is listed under `unknown`.
|
|
24
|
+
*/
|
|
25
|
+
import { canonicalApplicationBytes } from './canonical-application.js';
|
|
26
|
+
/** Collections the composition substrate writes. Never contract state. */
|
|
27
|
+
export const FELTDB_COMPOSITION_CONTRACT_COLLECTION = '_feltdb.CompositionContract';
|
|
28
|
+
export const FELTDB_COMPOSITION_COLLECTION = '_feltdb.Composition';
|
|
29
|
+
export const FELTDB_COMPOSITION_VERSION_COLLECTION = '_feltdb.CompositionVersion';
|
|
30
|
+
export const FELTDB_COMPOSITION_TOPOLOGY_COLLECTION = '_feltdb.CompositionTopology';
|
|
31
|
+
export const FELTDB_STATE_OWNERSHIP_COLLECTION = '_feltdb.StateOwnership';
|
|
32
|
+
export const FELTDB_STATE_DEPENDENCY_COLLECTION = '_feltdb.StateDependency';
|
|
33
|
+
export const FELTDB_STATE_CHANGE_COLLECTION = '_feltdb.StateChange';
|
|
34
|
+
export const FELTDB_STATE_ATTRIBUTION_COLLECTION = '_feltdb.StateAttribution';
|
|
35
|
+
export const FELTDB_STATE_OBSERVATION_COLLECTION = '_feltdb.StateObservation';
|
|
36
|
+
export const FELTDB_STATE_PROPOSAL_COLLECTION = '_feltdb.StateProposal';
|
|
37
|
+
export const FELTDB_STATE_IMPACT_COLLECTION = '_feltdb.StateImpact';
|
|
38
|
+
/** Upper bound on `connects` hops followed from a directly changed record. */
|
|
39
|
+
export const IMPACT_MAX_DEPTH = 4;
|
|
40
|
+
/** Upper bound on items in any one section of a surface. */
|
|
41
|
+
export const IMPACT_MAX_ITEMS = 1_000;
|
|
42
|
+
const enc = encodeURIComponent;
|
|
43
|
+
export function stateUri(ref) {
|
|
44
|
+
return `flow://${enc(ref.contract)}/${enc(ref.collection)}${ref.record === undefined ? '' : `/${enc(ref.record)}`}`;
|
|
45
|
+
}
|
|
46
|
+
export function parseStateUri(uri) {
|
|
47
|
+
const match = /^flow:\/\/([^/]+)\/([^/]+)(?:\/([^/]+))?$/.exec(uri);
|
|
48
|
+
if (!match)
|
|
49
|
+
throw new Error(`${uri} is not a flow:// state reference`);
|
|
50
|
+
return {
|
|
51
|
+
contract: decodeURIComponent(match[1]),
|
|
52
|
+
collection: decodeURIComponent(match[2]),
|
|
53
|
+
...(match[3] === undefined ? {} : { record: decodeURIComponent(match[3]) }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export const consumerUri = (contract, consumer) => `consumer://${enc(contract)}/${enc(consumer)}`;
|
|
57
|
+
export const capabilityUri = (contract, capability) => `capability://${enc(contract)}/${enc(capability)}`;
|
|
58
|
+
export const projectionUri = (contract, consumer, name) => `projection://${enc(contract)}/${enc(consumer)}/${enc(name)}`;
|
|
59
|
+
export const workflowUri = (contract, workflow) => `workflow://${enc(contract)}/${enc(workflow)}`;
|
|
60
|
+
/** `sha256:` over FeltDB's canonical encoding. */
|
|
61
|
+
export async function canonicalDigest(value) {
|
|
62
|
+
const bytes = canonicalApplicationBytes(value);
|
|
63
|
+
const digest = await crypto.subtle.digest('SHA-256', bytes.slice().buffer);
|
|
64
|
+
return `sha256:${Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('')}`;
|
|
65
|
+
}
|
|
66
|
+
/** Record fields the storage boundary owns. They are not part of a value. */
|
|
67
|
+
export function recordValue(row) {
|
|
68
|
+
if (!row)
|
|
69
|
+
return null;
|
|
70
|
+
const { id: _id, __version: _version, ...value } = row;
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
export function recordVersion(row) {
|
|
74
|
+
if (!row)
|
|
75
|
+
return null;
|
|
76
|
+
return typeof row.__version === 'number' ? row.__version : 1;
|
|
77
|
+
}
|
|
78
|
+
export function changedFields(before, after) {
|
|
79
|
+
const encode = (value) => new TextDecoder().decode(canonicalApplicationBytes(value ?? null));
|
|
80
|
+
const keys = new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);
|
|
81
|
+
return [...keys].filter(key => encode(before?.[key]) !== encode(after?.[key])).sort();
|
|
82
|
+
}
|
|
83
|
+
export function emptyImpactReads() {
|
|
84
|
+
return { records: new Map(), predicates: new Map() };
|
|
85
|
+
}
|
|
86
|
+
/** The reads as a `TransactionReadSet`. */
|
|
87
|
+
export function impactReadSet(reads) {
|
|
88
|
+
return { records: [...reads.records.values()], predicates: [...reads.predicates.values()] };
|
|
89
|
+
}
|
|
90
|
+
/** The transition events a contract trigger can name for a collection. */
|
|
91
|
+
export const TRANSITION_EVENTS = { insert: 'created', update: 'updated', delete: 'deleted' };
|
|
92
|
+
const OPAQUE_TYPE = /^(json|object|map|array)\b/;
|
|
93
|
+
function sortBy(items, key) {
|
|
94
|
+
return items.sort((left, right) => (key(left) < key(right) ? -1 : key(left) > key(right) ? 1 : 0));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Compute the impact surface of `operations` against `basis`.
|
|
98
|
+
*
|
|
99
|
+
* Pure and deterministic. The output is sorted so that its canonical digest is
|
|
100
|
+
* a function of the snapshot and the operations alone.
|
|
101
|
+
*/
|
|
102
|
+
export async function computeImpactSurface(input) {
|
|
103
|
+
const { contract, basis, tenantId } = input;
|
|
104
|
+
const maxDepth = Math.min(Math.max(input.maxDepth ?? 3, 0), IMPACT_MAX_DEPTH);
|
|
105
|
+
const contractId = contract.contract_id;
|
|
106
|
+
const contractSource = `contract:${contract.contract_digest}`;
|
|
107
|
+
const inScope = (row) => row.tenant_id === tenantId && row.contract_id === contractId;
|
|
108
|
+
const has = (collection) => basis.collections.includes(collection);
|
|
109
|
+
const reads = input.reads;
|
|
110
|
+
const read = (collection, id) => {
|
|
111
|
+
reads?.records.set(`${collection}\u0000${id}`, { collection, id });
|
|
112
|
+
return basis.get(collection, id);
|
|
113
|
+
};
|
|
114
|
+
const scope = [{ field: 'tenant_id', eq: tenantId }, { field: 'contract_id', eq: contractId }];
|
|
115
|
+
const predicate = (collection, where) => {
|
|
116
|
+
reads?.predicates.set(`${collection}\u0000${JSON.stringify(where)}`, { collection, where });
|
|
117
|
+
};
|
|
118
|
+
predicate(FELTDB_COMPOSITION_COLLECTION, scope);
|
|
119
|
+
const compositions = (has(FELTDB_COMPOSITION_COLLECTION) ? basis.all(FELTDB_COMPOSITION_COLLECTION) : [])
|
|
120
|
+
.filter(row => inScope(row) && row.status === 'active');
|
|
121
|
+
const edges = (has(FELTDB_STATE_DEPENDENCY_COLLECTION) ? basis.all(FELTDB_STATE_DEPENDENCY_COLLECTION) : [])
|
|
122
|
+
.filter(inScope);
|
|
123
|
+
const attribution = new Map((has(FELTDB_STATE_ATTRIBUTION_COLLECTION) ? basis.all(FELTDB_STATE_ATTRIBUTION_COLLECTION) : [])
|
|
124
|
+
.filter(inScope).map(row => [row.subject, row]));
|
|
125
|
+
const direct = [];
|
|
126
|
+
const dependent = [];
|
|
127
|
+
const derived = [];
|
|
128
|
+
const unknown = [{
|
|
129
|
+
kind: 'unregistered_consumers',
|
|
130
|
+
reason: 'FeltDB enumerates only consumers that declared a composition. A client that reads or writes the '
|
|
131
|
+
+ 'authority without declaring one cannot be discovered from the authoritative model.',
|
|
132
|
+
}];
|
|
133
|
+
const seenDependent = new Set();
|
|
134
|
+
const addDependent = (item) => {
|
|
135
|
+
const key = `${item.node}|${item.relationship}|${item.from}`;
|
|
136
|
+
if (seenDependent.has(key) || dependent.length >= IMPACT_MAX_ITEMS)
|
|
137
|
+
return;
|
|
138
|
+
seenDependent.add(key);
|
|
139
|
+
dependent.push(item);
|
|
140
|
+
};
|
|
141
|
+
// Direct: exactly what the proposal writes, against the basis.
|
|
142
|
+
for (const operation of input.operations) {
|
|
143
|
+
const node = stateUri({ contract: contractId, collection: operation.collection, record: operation.id });
|
|
144
|
+
const baseRow = read(operation.collection, operation.id);
|
|
145
|
+
const base = recordValue(baseRow);
|
|
146
|
+
const proposed = 'delete' in operation ? null : operation.value;
|
|
147
|
+
const baseVersion = recordVersion(baseRow);
|
|
148
|
+
direct.push({
|
|
149
|
+
node,
|
|
150
|
+
collection: operation.collection,
|
|
151
|
+
record_id: operation.id,
|
|
152
|
+
operation: proposed === null ? 'delete' : base === null ? 'insert' : 'update',
|
|
153
|
+
base_version: baseVersion,
|
|
154
|
+
proposed_version: proposed === null ? null : (baseVersion ?? 0) + 1,
|
|
155
|
+
base_value_digest: base === null ? null : await canonicalDigest(base),
|
|
156
|
+
proposed_value_digest: proposed === null ? null : await canonicalDigest(proposed),
|
|
157
|
+
fields_changed: changedFields(base, proposed),
|
|
158
|
+
provenance: { basis: 'proposal', source: `state:${node}`, evidence: [] },
|
|
159
|
+
});
|
|
160
|
+
predicate(FELTDB_STATE_ATTRIBUTION_COLLECTION, [...scope, { field: 'subject', eq: node }]);
|
|
161
|
+
const head = attribution.get(node);
|
|
162
|
+
if (baseRow && (!head || head.record_version !== baseVersion)) {
|
|
163
|
+
unknown.push({
|
|
164
|
+
kind: 'unattributed_history', node,
|
|
165
|
+
reason: 'The record has versions written outside the attributed composition path; whatever depended on '
|
|
166
|
+
+ 'those writes was not declared here.',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const declared = contract.fields[operation.collection] ?? [];
|
|
170
|
+
for (const field of changedFields(base, proposed)) {
|
|
171
|
+
const type = declared.find(value => value.name === field)?.type;
|
|
172
|
+
if (type === undefined || OPAQUE_TYPE.test(type)) {
|
|
173
|
+
unknown.push({
|
|
174
|
+
kind: 'opaque_field', node, field,
|
|
175
|
+
reason: type === undefined
|
|
176
|
+
? 'The field is not declared by the contract, so any relationship it carries is undeclared.'
|
|
177
|
+
: `The field is ${type}; references inside it are not declared by the contract.`,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Dependent (declared connections): follow `connects` edges from every
|
|
183
|
+
// directly changed record, breadth first, to the depth bound.
|
|
184
|
+
const reachedRecords = new Map(direct.map(item => [item.node, 0]));
|
|
185
|
+
let frontier = direct.map(item => item.node);
|
|
186
|
+
for (let depth = 1; frontier.length; depth++) {
|
|
187
|
+
const next = [];
|
|
188
|
+
for (const from of frontier) {
|
|
189
|
+
predicate(FELTDB_STATE_DEPENDENCY_COLLECTION, [...scope, { field: 'from', eq: from }]);
|
|
190
|
+
for (const edge of edges.filter(value => value.from === from)) {
|
|
191
|
+
if (depth > maxDepth) {
|
|
192
|
+
unknown.push({ kind: 'traversal_bound', node: from, reason: `Declared connections beyond depth ${maxDepth} were not followed.` });
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
addDependent({
|
|
196
|
+
node: edge.to, kind: 'state', relationship: 'connects', from, depth,
|
|
197
|
+
declared_by: edge.declared_by,
|
|
198
|
+
...(edge.label ? { label: edge.label } : {}),
|
|
199
|
+
provenance: { basis: 'declared_dependency', source: `edge:${edge.edge_id}`, evidence: [...edge.evidence].sort() },
|
|
200
|
+
});
|
|
201
|
+
if (!reachedRecords.has(edge.to)) {
|
|
202
|
+
reachedRecords.set(edge.to, depth);
|
|
203
|
+
next.push(edge.to);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
frontier = next;
|
|
208
|
+
}
|
|
209
|
+
// Dependent (contract references): records that reference a changed record
|
|
210
|
+
// through a declared reference field.
|
|
211
|
+
for (const item of direct) {
|
|
212
|
+
for (const [collection, fields] of Object.entries(contract.fields)) {
|
|
213
|
+
for (const field of fields.filter(value => value.reference === item.collection)) {
|
|
214
|
+
if (!has(collection))
|
|
215
|
+
continue;
|
|
216
|
+
predicate(collection, [{ field: field.name, eq: item.record_id }]);
|
|
217
|
+
for (const row of basis.all(collection)) {
|
|
218
|
+
if (row[field.name] !== item.record_id)
|
|
219
|
+
continue;
|
|
220
|
+
const node = stateUri({ contract: contractId, collection, record: String(row.id) });
|
|
221
|
+
addDependent({
|
|
222
|
+
node, kind: 'state', relationship: 'references', from: item.node, depth: 1,
|
|
223
|
+
provenance: { basis: 'contract_reference', source: `${contractSource}#${collection}.${field.name}`, evidence: [] },
|
|
224
|
+
});
|
|
225
|
+
if (!reachedRecords.has(node))
|
|
226
|
+
reachedRecords.set(node, 1);
|
|
227
|
+
if (item.operation === 'delete') {
|
|
228
|
+
derived.push({
|
|
229
|
+
node, consequence: 'reference_to_removed_record', field: `${collection}.${field.name}`, before: item.record_id,
|
|
230
|
+
provenance: { basis: 'contract_reference', source: `${contractSource}#${collection}.${field.name}`, evidence: [] },
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Dependent (composition): consumers and projections over every collection
|
|
238
|
+
// holding a reached record.
|
|
239
|
+
const reachedCollections = new Map();
|
|
240
|
+
for (const node of reachedRecords.keys()) {
|
|
241
|
+
const collection = parseStateUri(node).collection;
|
|
242
|
+
if (!reachedCollections.has(collection))
|
|
243
|
+
reachedCollections.set(collection, node);
|
|
244
|
+
}
|
|
245
|
+
for (const [collection, via] of reachedCollections) {
|
|
246
|
+
const collectionNode = stateUri({ contract: contractId, collection });
|
|
247
|
+
for (const composition of compositions) {
|
|
248
|
+
const source = `composition:${composition.consumer}@${composition.version}`;
|
|
249
|
+
for (const access of composition.access.filter(value => value.collection === collection)) {
|
|
250
|
+
addDependent({
|
|
251
|
+
node: consumerUri(contractId, composition.consumer), kind: 'consumer',
|
|
252
|
+
relationship: access.mode === 'observe' ? 'observes' : access.mode === 'mutate' ? 'mutates' : 'owns',
|
|
253
|
+
from: collectionNode, depth: reachedRecords.get(via) ?? 0, capability: access.capability,
|
|
254
|
+
provenance: { basis: 'composition_declaration', source, evidence: [] },
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
for (const projection of composition.projections.filter(value => value.sources.includes(collection))) {
|
|
258
|
+
const node = projectionUri(contractId, composition.consumer, projection.name);
|
|
259
|
+
addDependent({
|
|
260
|
+
node, kind: 'projection', relationship: 'derived_from', from: collectionNode,
|
|
261
|
+
depth: reachedRecords.get(via) ?? 0, declared_by: composition.consumer,
|
|
262
|
+
provenance: { basis: 'composition_declaration', source, evidence: [] },
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Dependent (workflows): a trigger is reachable when its event names the
|
|
268
|
+
// transition a direct record undergoes — `<collection>.created|updated|deleted`.
|
|
269
|
+
// Other collections' triggers, and other transitions, are not fired by this
|
|
270
|
+
// proposal. What a trigger cannot be related to stays unknown.
|
|
271
|
+
const workflows = new Map(contract.workflows.map(value => [value.name, value]));
|
|
272
|
+
let external = 0;
|
|
273
|
+
for (const trigger of contract.triggers) {
|
|
274
|
+
const [subject, ...rest] = trigger.event.split('.');
|
|
275
|
+
if (!contract.collections.includes(subject)) {
|
|
276
|
+
external++;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const node = trigger.workflow ? workflowUri(contractId, trigger.workflow) : undefined;
|
|
280
|
+
const source = `${contractSource}#trigger:${trigger.name}`;
|
|
281
|
+
for (const item of direct.filter(value => value.collection === subject)) {
|
|
282
|
+
const verb = rest.join('.');
|
|
283
|
+
if (!Object.values(TRANSITION_EVENTS).includes(verb)) {
|
|
284
|
+
unknown.push({
|
|
285
|
+
kind: 'unrecognized_trigger_event', node: item.node, event: trigger.event,
|
|
286
|
+
reason: `The contract starts ${trigger.workflow || 'a workflow'} on ${trigger.event}, which is not a created/updated/deleted `
|
|
287
|
+
+ 'transition; whether this proposal fires it cannot be established.',
|
|
288
|
+
});
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (verb !== TRANSITION_EVENTS[item.operation])
|
|
292
|
+
continue;
|
|
293
|
+
const workflow = workflows.get(trigger.workflow);
|
|
294
|
+
if (!workflow) {
|
|
295
|
+
unknown.push({
|
|
296
|
+
kind: 'unresolved_workflow', node: item.node, event: trigger.event,
|
|
297
|
+
reason: trigger.workflow
|
|
298
|
+
? `${trigger.event} names workflow ${trigger.workflow}, which the contract does not declare.`
|
|
299
|
+
: `${trigger.event} names no workflow.`,
|
|
300
|
+
});
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
addDependent({
|
|
304
|
+
node: node, kind: 'workflow', relationship: 'triggered_by', from: item.node, depth: 0,
|
|
305
|
+
trigger: trigger.name, event: trigger.event, capabilities: [...workflow.capabilities].sort(),
|
|
306
|
+
provenance: { basis: 'contract_trigger', source, evidence: [`event:${trigger.event}`, `transition:${item.operation}`] },
|
|
307
|
+
});
|
|
308
|
+
unknown.push({
|
|
309
|
+
kind: 'workflow_effects', node,
|
|
310
|
+
reason: `The contract starts ${trigger.workflow} on ${trigger.event} but does not declare which state it writes.`,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (external) {
|
|
315
|
+
unknown.push({
|
|
316
|
+
kind: 'external_trigger_events', count: external,
|
|
317
|
+
reason: 'Some triggers start on events that are not transitions of this contract\'s collections; '
|
|
318
|
+
+ 'whether this proposal leads to those events cannot be established from the contract.',
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
// Derived: consequences that follow deterministically from the proposal and
|
|
322
|
+
// the model.
|
|
323
|
+
for (const item of direct) {
|
|
324
|
+
const model = { basis: 'contract_model', source: `${contractSource}#${item.collection}`, evidence: [] };
|
|
325
|
+
derived.push({
|
|
326
|
+
node: item.node,
|
|
327
|
+
consequence: item.operation === 'delete' ? 'record_removed' : item.operation === 'insert' ? 'record_created' : 'record_version_advances',
|
|
328
|
+
before: item.base_version, after: item.proposed_version, provenance: model,
|
|
329
|
+
});
|
|
330
|
+
const operation = input.operations.find(value => value.collection === item.collection && value.id === item.record_id);
|
|
331
|
+
const base = recordValue(basis.get(item.collection, item.record_id));
|
|
332
|
+
const proposed = 'delete' in operation ? null : operation.value;
|
|
333
|
+
for (const field of (contract.fields[item.collection] ?? []).filter(value => value.reference)) {
|
|
334
|
+
const before = base?.[field.name];
|
|
335
|
+
const after = proposed?.[field.name];
|
|
336
|
+
const target = field.reference;
|
|
337
|
+
const provenance = { basis: 'contract_reference', source: `${contractSource}#${item.collection}.${field.name}`, evidence: [] };
|
|
338
|
+
if (proposed !== null && before !== after) {
|
|
339
|
+
derived.push({ node: item.node, consequence: 'reference_retargeted', field: field.name, before: before ?? null, after: after ?? null, provenance });
|
|
340
|
+
}
|
|
341
|
+
if (typeof after !== 'string')
|
|
342
|
+
continue;
|
|
343
|
+
if (!contract.collections.includes(target)) {
|
|
344
|
+
unknown.push({ kind: 'external_reference', node: item.node, field: field.name, reason: `${target} is not a collection of this contract; its state is not visible here.` });
|
|
345
|
+
}
|
|
346
|
+
else if (!read(target, after) && !input.operations.some(value => value.collection === target && value.id === after && !('delete' in value))) {
|
|
347
|
+
derived.push({ node: stateUri({ contract: contractId, collection: target, record: after }), consequence: 'reference_target_absent', field: field.name, provenance });
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
for (const projection of dependent.filter(value => value.kind === 'projection')) {
|
|
352
|
+
const collection = parseStateUri(projection.from).collection;
|
|
353
|
+
if (direct.some(value => value.collection === collection)) {
|
|
354
|
+
derived.push({ node: projection.node, consequence: 'projection_source_changes', provenance: projection.provenance });
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (dependent.length >= IMPACT_MAX_ITEMS) {
|
|
358
|
+
unknown.push({ kind: 'traversal_bound', reason: `The dependent section reached ${IMPACT_MAX_ITEMS} items; further items were not listed.` });
|
|
359
|
+
}
|
|
360
|
+
const uniqueUnknown = [...new Map(unknown.map(value => [JSON.stringify(value), value])).values()];
|
|
361
|
+
return {
|
|
362
|
+
direct: sortBy(direct, value => value.node),
|
|
363
|
+
dependent: sortBy(dependent, value => `${value.depth}|${value.kind}|${value.node}|${value.relationship}|${value.from}`),
|
|
364
|
+
derived: sortBy(derived, value => `${value.node}|${value.consequence}|${value.field ?? ''}`),
|
|
365
|
+
unknown: sortBy(uniqueUnknown, value => `${value.kind}|${value.node ?? ''}|${value.field ?? ''}`),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/** Canonical digest of a surface, for comparing an analysis with a re-derivation. */
|
|
369
|
+
export function impactSurfaceDigest(surface) {
|
|
370
|
+
return canonicalDigest(surface);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The part of a surface a reader may see.
|
|
374
|
+
*
|
|
375
|
+
* The surface is computed by the authority over all state, so that its digest
|
|
376
|
+
* does not depend on who asked. A reader sees state nodes only in collections
|
|
377
|
+
* it may read; everything withheld is counted under `unknown` rather than
|
|
378
|
+
* silently dropped, because "you may not see it" is not "it is not there".
|
|
379
|
+
*/
|
|
380
|
+
export function redactImpactSurface(surface, readable) {
|
|
381
|
+
const withheld = new Map();
|
|
382
|
+
const visible = (node) => {
|
|
383
|
+
if (!node.startsWith('flow://'))
|
|
384
|
+
return true;
|
|
385
|
+
const { collection } = parseStateUri(node);
|
|
386
|
+
if (readable(collection))
|
|
387
|
+
return true;
|
|
388
|
+
withheld.set(collection, (withheld.get(collection) ?? 0) + 1);
|
|
389
|
+
return false;
|
|
390
|
+
};
|
|
391
|
+
const result = {
|
|
392
|
+
direct: surface.direct.filter(item => visible(item.node)),
|
|
393
|
+
dependent: surface.dependent.filter(item => visible(item.node) && visible(item.from)),
|
|
394
|
+
derived: surface.derived.filter(item => visible(item.node)),
|
|
395
|
+
unknown: [...surface.unknown],
|
|
396
|
+
};
|
|
397
|
+
for (const [collection, count] of [...withheld].sort()) {
|
|
398
|
+
result.unknown.push({
|
|
399
|
+
kind: 'not_authorized_to_inspect', collection, count,
|
|
400
|
+
reason: 'Items in this collection exist in the surface but this reader is not authorized to read the collection.',
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return result;
|
|
404
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,O.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,O.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_jsdb_free(e,0)}acknowledge_peer_operations(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=K.jsdb_acknowledge_peer_operations(this.__wbg_ptr,r,i,n);return t.__wrap(a)}add_sync_peer(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_add_sync_peer(this.__wbg_ptr,n,r);return t.__wrap(i)}delete(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_delete(this.__wbg_ptr,n,r);return t.__wrap(i)}execute_canonical_query(e,n,r,i){let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),u=G,d=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),f=G,p=K.jsdb_execute_canonical_query(this.__wbg_ptr,a,o,s,c,l,u,d,f);return t.__wrap(p)}execute_canonical_transaction(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_execute_canonical_transaction(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}execute_semantic_decision(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_execute_semantic_decision(this.__wbg_ptr,n,r);return t.__wrap(i)}get(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_get(this.__wbg_ptr,n,r);return t.__wrap(i)}get_capability_records(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_get_capability_records(this.__wbg_ptr,n,r);return t.__wrap(i)}get_pending_for_peer(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=K.jsdb_get_pending_for_peer(this.__wbg_ptr,r,i,n);return t.__wrap(a)}get_sequence(){let e=K.jsdb_get_sequence(this.__wbg_ptr);return BigInt.asUintN(64,e)}insert(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_insert(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}instance_id(){let e,t;try{let n=K.jsdb_instance_id(this.__wbg_ptr);return e=n[0],t=n[1],P(n[0],n[1])}finally{K.__wbindgen_free(e,t,1)}}is_auto_indexed(){return K.jsdb_is_auto_indexed(this.__wbg_ptr)!==0}query(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_query(this.__wbg_ptr,n,r);return t.__wrap(i)}remove_sync_peer(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_remove_sync_peer(this.__wbg_ptr,n,r);return t.__wrap(i)}sync_info(){let e=K.jsdb_sync_info(this.__wbg_ptr);return t.__wrap(e)}update(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_update(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}};Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);var t=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,k.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,k.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_jsresult_free(e,0)}get data(){let e=K.jsresult_data(this.__wbg_ptr),t;return e[0]!==0&&(t=P(e[0],e[1]),K.__wbindgen_free(e[0],e[1]*1,1)),t}get error(){let e=K.jsresult_error(this.__wbg_ptr),t;return e[0]!==0&&(t=P(e[0],e[1]),K.__wbindgen_free(e[0],e[1]*1,1)),t}get success(){return K.jsresult_success(this.__wbg_ptr)!==0}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);var n=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,A.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmanalytics_free(e,0)}generate_report(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.wasmanalytics_generate_report(this.__wbg_ptr,o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}get_all_metrics(){let e,t;try{let i=K.wasmanalytics_get_all_metrics(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_frequent_fields(e){let t,n;try{let a=K.wasmanalytics_get_frequent_fields(this.__wbg_ptr,e);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,z(a[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_index_metrics(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmanalytics_get_index_metrics(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_slowest_queries(e){let t,n;try{let a=K.wasmanalytics_get_slowest_queries(this.__wbg_ptr,e);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,z(a[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}constructor(){let e=K.wasmanalytics_new();return this.__wbg_ptr=e,A.register(this,this.__wbg_ptr,this),this}record_index_usage(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G;K.wasmanalytics_record_index_usage(this.__wbg_ptr,r,i,a,o,n)}record_query(e,t,n,r,i,a){let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G;var u=L(a)?0:R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G;let f=K.wasmanalytics_record_query(this.__wbg_ptr,o,s,c,l,n,r,i,u,d);if(f[1])throw z(f[0])}reset(){K.wasmanalytics_reset(this.__wbg_ptr)}};Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);var r=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,j.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmdistributedindexmanager_free(e,0)}create_replicated_index(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=K.wasmdistributedindexmanager_create_replicated_index(this.__wbg_ptr,r,i,a,o,s,c);if(l[1])throw z(l[0])}detect_conflicts(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_detect_conflicts(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_replication_status(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_get_replication_status(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_replication_targets(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_get_replication_targets(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_sync_status(){let e,t;try{let i=K.wasmdistributedindexmanager_get_sync_status(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}merge_versions(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmdistributedindexmanager_merge_versions(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}constructor(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmdistributedindexmanager_new(t,n);return this.__wbg_ptr=r,j.register(this,this.__wbg_ptr,this),this}register_peer(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G;K.wasmdistributedindexmanager_register_peer(this.__wbg_ptr,t,n)}set_peer_reachable(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G;K.wasmdistributedindexmanager_set_peer_reachable(this.__wbg_ptr,n,r,t)}};Symbol.dispose&&(r.prototype[Symbol.dispose]=r.prototype.free);var i=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,M.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmindexmanager_free(e,0)}create_index(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmindexmanager_create_index(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}get_stats(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmindexmanager_get_stats(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}list_indexes(){let e,t;try{let i=K.wasmindexmanager_list_indexes(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}constructor(){let e=K.wasmindexmanager_new();return this.__wbg_ptr=e,M.register(this,this.__wbg_ptr,this),this}query_index(e,t,n){let r,i;try{let s=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),u=G,d=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),f=G,p=K.wasmindexmanager_query_index(this.__wbg_ptr,s,c,l,u,d,f);var a=p[0],o=p[1];if(p[3])throw a=0,o=0,z(p[2]);return r=a,i=o,P(a,o)}finally{K.__wbindgen_free(r,i,1)}}update_record(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G;var a=L(t)?0:R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G;let s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=K.wasmindexmanager_update_record(this.__wbg_ptr,r,i,a,o,s,c);if(l[1])throw z(l[0])}};Symbol.dispose&&(i.prototype[Symbol.dispose]=i.prototype.free);var a=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,N.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmshardmanager_free(e,0)}detect_hotspots(){let e,t;try{let i=K.wasmshardmanager_detect_hotspots(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}generate_rebalance_ops(){let e,t;try{let i=K.wasmshardmanager_generate_rebalance_ops(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_all_metrics(){let e,t;try{let i=K.wasmshardmanager_get_all_metrics(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_distribution_summary(){let e,t;try{let i=K.wasmshardmanager_get_distribution_summary(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_shard_for_key(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmshardmanager_get_shard_for_key(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}initialize_shards(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmshardmanager_initialize_shards(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}constructor(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.wasmshardmanager_new(n,r,i,a);return this.__wbg_ptr=o,N.register(this,this.__wbg_ptr,this),this}record_shard_operation(e,t,n,r,i){let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G;K.wasmshardmanager_record_shard_operation(this.__wbg_ptr,a,o,s,c,n,r,i)}};Symbol.dispose&&(a.prototype[Symbol.dispose]=a.prototype.free);function o(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.apply_sync_result(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function s(e,t,n,r,i,a){let o,s;try{let u=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G,f=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),p=G,m=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),h=G,g=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),_=G,v=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),y=G,b=R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),x=G,S=K.authorize_offline(u,d,f,p,m,h,g,_,v,y,b,x);var c=S[0],l=S[1];if(S[3])throw c=0,l=0,z(S[2]);return o=c,s=l,P(c,l)}finally{K.__wbindgen_free(o,s,1)}}function c(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.canonical_bundle_hash(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function l(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.canonicalize_application_manifest(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function u(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.compare_state_schemas(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function d(e,t){let n,r;try{var i=L(e)?0:R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G;let c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.diff_application_revisions(i,a,c,l);var o=u[0],s=u[1];if(u[3])throw o=0,s=0,z(u[2]);return n=o,r=s,P(o,s)}finally{K.__wbindgen_free(n,r,1)}}function f(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.execute_semantic_decision(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function p(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.hash_application_manifest(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function m(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.hash_application_runtime(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function h(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.hash_state_schema(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function g(t){let n=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.open(n,r);if(i[2])throw z(i[1]);return e.__wrap(i[0])}function _(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.resolve_application_runtime(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function v(e,t,n,r){let i=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.validate_mesh_claim(i,a,o,s,c,l,r);if(u[1])throw z(u[0])}function y(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_semantic_decision_definition(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function b(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.validate_semantic_decision_result(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function x(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_state_schema(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function S(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_sync_operation(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function C(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.validate_worker_transition(n,r,i,a);if(o[2])throw z(o[1]);return o[0]!==0}function w(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.validate_workload_transition(n,r,i,a);if(o[2])throw z(o[1]);return o[0]!==0}function T(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.verify_bundle_integrity(t,n);if(r[2])throw z(r[1]);return r[0]!==0}function E(e,t,n,r,i,a){let o,s;try{let u=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G,f=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),p=G,m=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),h=G,g=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),_=G,v=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),y=G,b=R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),x=G,S=K.verify_signed_grant(u,d,f,p,m,h,g,_,v,y,b,x);var c=S[0],l=S[1];if(S[3])throw c=0,l=0,z(S[2]);return o=c,s=l,P(c,l)}finally{K.__wbindgen_free(o,s,1)}}function D(){return{__proto__:null,"./feltdb_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw Error(P(e,t))},__wbindgen_cast_0000000000000001:function(e,t){return P(e,t)},__wbindgen_init_externref_table:function(){let e=K.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}var O=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_jsdb_free(e,1)),k=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_jsresult_free(e,1)),A=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmanalytics_free(e,1)),j=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmdistributedindexmanager_free(e,1)),M=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmindexmanager_free(e,1)),N=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmshardmanager_free(e,1));function P(e,t){return U(e>>>0,t)}var F=null;function I(){return(F===null||F.byteLength===0)&&(F=new Uint8Array(K.memory.buffer)),F}function L(e){return e==null}function R(e,t,n){if(n===void 0){let n=W.encode(e),r=t(n.length,1)>>>0;return I().subarray(r,r+n.length).set(n),G=n.length,r}let r=e.length,i=t(r,1)>>>0,a=I(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=I().subarray(i+o,i+r),a=W.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return G=o,i}function z(e){let t=K.__wbindgen_externrefs.get(e);return K.__externref_table_dealloc(e),t}var B=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});B.decode();var V=2146435072,H=0;function U(e,t){return H+=t,H>=V&&(B=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),B.decode(),H=t),B.decode(I().subarray(e,e+t))}var W=new TextEncoder;`encodeInto`in W||(W.encodeInto=function(e,t){let n=W.encode(e);return t.set(n),{read:e.length,written:n.length}});var G=0,K;function q(e,t){return K=e.exports,F=null,K.__wbindgen_start(),K}async function J(e,t){if(typeof Response==`function`&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}function Y(e){if(K!==void 0)return K;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=D();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),q(new WebAssembly.Instance(e,t),e)}async function X(e){if(K!==void 0)return K;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`)),e===void 0&&(e=new URL(`/assets/feltdb_wasm_bg-BgFXYOtc.wasm`,``+import.meta.url));let t=D();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await J(await e,t);return q(n,r)}export{e as JsDb,t as JsResult,n as WasmAnalytics,r as WasmDistributedIndexManager,i as WasmIndexManager,a as WasmShardManager,o as apply_sync_result,s as authorize_offline,c as canonical_bundle_hash,l as canonicalize_application_manifest,u as compare_state_schemas,X as default,d as diff_application_revisions,f as execute_semantic_decision,p as hash_application_manifest,m as hash_application_runtime,h as hash_state_schema,Y as initSync,g as open,_ as resolve_application_runtime,v as validate_mesh_claim,y as validate_semantic_decision_definition,b as validate_semantic_decision_result,x as validate_state_schema,S as validate_sync_operation,C as validate_worker_transition,w as validate_workload_transition,T as verify_bundle_integrity,E as verify_signed_grant};
|
|
1
|
+
var e=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,O.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,O.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_jsdb_free(e,0)}acknowledge_peer_operations(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=K.jsdb_acknowledge_peer_operations(this.__wbg_ptr,r,i,n);return t.__wrap(a)}add_sync_peer(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_add_sync_peer(this.__wbg_ptr,n,r);return t.__wrap(i)}delete(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_delete(this.__wbg_ptr,n,r);return t.__wrap(i)}execute_canonical_query(e,n,r,i){let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),u=G,d=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),f=G,p=K.jsdb_execute_canonical_query(this.__wbg_ptr,a,o,s,c,l,u,d,f);return t.__wrap(p)}execute_canonical_transaction(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_execute_canonical_transaction(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}execute_semantic_decision(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_execute_semantic_decision(this.__wbg_ptr,n,r);return t.__wrap(i)}get(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_get(this.__wbg_ptr,n,r);return t.__wrap(i)}get_capability_records(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_get_capability_records(this.__wbg_ptr,n,r);return t.__wrap(i)}get_pending_for_peer(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=K.jsdb_get_pending_for_peer(this.__wbg_ptr,r,i,n);return t.__wrap(a)}get_sequence(){let e=K.jsdb_get_sequence(this.__wbg_ptr);return BigInt.asUintN(64,e)}insert(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_insert(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}instance_id(){let e,t;try{let n=K.jsdb_instance_id(this.__wbg_ptr);return e=n[0],t=n[1],P(n[0],n[1])}finally{K.__wbindgen_free(e,t,1)}}is_auto_indexed(){return K.jsdb_is_auto_indexed(this.__wbg_ptr)!==0}query(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_query(this.__wbg_ptr,n,r);return t.__wrap(i)}remove_sync_peer(e){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.jsdb_remove_sync_peer(this.__wbg_ptr,n,r);return t.__wrap(i)}sync_info(){let e=K.jsdb_sync_info(this.__wbg_ptr);return t.__wrap(e)}update(e,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.jsdb_update(this.__wbg_ptr,r,i,a,o);return t.__wrap(s)}};Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);var t=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,k.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,k.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_jsresult_free(e,0)}get data(){let e=K.jsresult_data(this.__wbg_ptr),t;return e[0]!==0&&(t=P(e[0],e[1]),K.__wbindgen_free(e[0],e[1]*1,1)),t}get error(){let e=K.jsresult_error(this.__wbg_ptr),t;return e[0]!==0&&(t=P(e[0],e[1]),K.__wbindgen_free(e[0],e[1]*1,1)),t}get success(){return K.jsresult_success(this.__wbg_ptr)!==0}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);var n=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,A.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmanalytics_free(e,0)}generate_report(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.wasmanalytics_generate_report(this.__wbg_ptr,o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}get_all_metrics(){let e,t;try{let i=K.wasmanalytics_get_all_metrics(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_frequent_fields(e){let t,n;try{let a=K.wasmanalytics_get_frequent_fields(this.__wbg_ptr,e);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,z(a[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_index_metrics(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmanalytics_get_index_metrics(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_slowest_queries(e){let t,n;try{let a=K.wasmanalytics_get_slowest_queries(this.__wbg_ptr,e);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,z(a[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}constructor(){let e=K.wasmanalytics_new();return this.__wbg_ptr=e,A.register(this,this.__wbg_ptr,this),this}record_index_usage(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G;K.wasmanalytics_record_index_usage(this.__wbg_ptr,r,i,a,o,n)}record_query(e,t,n,r,i,a){let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G;var u=L(a)?0:R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G;let f=K.wasmanalytics_record_query(this.__wbg_ptr,o,s,c,l,n,r,i,u,d);if(f[1])throw z(f[0])}reset(){K.wasmanalytics_reset(this.__wbg_ptr)}};Symbol.dispose&&(n.prototype[Symbol.dispose]=n.prototype.free);var r=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,j.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmdistributedindexmanager_free(e,0)}create_replicated_index(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G,a=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=K.wasmdistributedindexmanager_create_replicated_index(this.__wbg_ptr,r,i,a,o,s,c);if(l[1])throw z(l[0])}detect_conflicts(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_detect_conflicts(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_replication_status(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_get_replication_status(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_replication_targets(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmdistributedindexmanager_get_replication_targets(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}get_sync_status(){let e,t;try{let i=K.wasmdistributedindexmanager_get_sync_status(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}merge_versions(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmdistributedindexmanager_merge_versions(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}constructor(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmdistributedindexmanager_new(t,n);return this.__wbg_ptr=r,j.register(this,this.__wbg_ptr,this),this}register_peer(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G;K.wasmdistributedindexmanager_register_peer(this.__wbg_ptr,t,n)}set_peer_reachable(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G;K.wasmdistributedindexmanager_set_peer_reachable(this.__wbg_ptr,n,r,t)}};Symbol.dispose&&(r.prototype[Symbol.dispose]=r.prototype.free);var i=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,M.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmindexmanager_free(e,0)}create_index(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmindexmanager_create_index(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}get_stats(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmindexmanager_get_stats(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}list_indexes(){let e,t;try{let i=K.wasmindexmanager_list_indexes(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}constructor(){let e=K.wasmindexmanager_new();return this.__wbg_ptr=e,M.register(this,this.__wbg_ptr,this),this}query_index(e,t,n){let r,i;try{let s=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),u=G,d=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),f=G,p=K.wasmindexmanager_query_index(this.__wbg_ptr,s,c,l,u,d,f);var a=p[0],o=p[1];if(p[3])throw a=0,o=0,z(p[2]);return r=a,i=o,P(a,o)}finally{K.__wbindgen_free(r,i,1)}}update_record(e,t,n){let r=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),i=G;var a=L(t)?0:R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G;let s=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G,l=K.wasmindexmanager_update_record(this.__wbg_ptr,r,i,a,o,s,c);if(l[1])throw z(l[0])}};Symbol.dispose&&(i.prototype[Symbol.dispose]=i.prototype.free);var a=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,N.unregister(this),e}free(){let e=this.__destroy_into_raw();K.__wbg_wasmshardmanager_free(e,0)}detect_hotspots(){let e,t;try{let i=K.wasmshardmanager_detect_hotspots(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}generate_rebalance_ops(){let e,t;try{let i=K.wasmshardmanager_generate_rebalance_ops(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_all_metrics(){let e,t;try{let i=K.wasmshardmanager_get_all_metrics(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_distribution_summary(){let e,t;try{let i=K.wasmshardmanager_get_distribution_summary(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,z(i[2]);return e=n,t=r,P(n,r)}finally{K.__wbindgen_free(e,t,1)}}get_shard_for_key(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.wasmshardmanager_get_shard_for_key(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}initialize_shards(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.wasmshardmanager_initialize_shards(this.__wbg_ptr,t,n);if(r[1])throw z(r[0])}constructor(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.wasmshardmanager_new(n,r,i,a);return this.__wbg_ptr=o,N.register(this,this.__wbg_ptr,this),this}record_shard_operation(e,t,n,r,i){let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),c=G;K.wasmshardmanager_record_shard_operation(this.__wbg_ptr,a,o,s,c,n,r,i)}};Symbol.dispose&&(a.prototype[Symbol.dispose]=a.prototype.free);function o(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.apply_sync_result(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function s(e,t,n,r,i,a){let o,s;try{let u=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G,f=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),p=G,m=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),h=G,g=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),_=G,v=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),y=G,b=R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),x=G,S=K.authorize_offline(u,d,f,p,m,h,g,_,v,y,b,x);var c=S[0],l=S[1];if(S[3])throw c=0,l=0,z(S[2]);return o=c,s=l,P(c,l)}finally{K.__wbindgen_free(o,s,1)}}function c(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.canonical_bundle_hash(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function l(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.canonicalize_application_manifest(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function u(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.compare_state_schemas(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function d(e,t){let n,r;try{var i=L(e)?0:R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G;let c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.diff_application_revisions(i,a,c,l);var o=u[0],s=u[1];if(u[3])throw o=0,s=0,z(u[2]);return n=o,r=s,P(o,s)}finally{K.__wbindgen_free(n,r,1)}}function f(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.execute_semantic_decision(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function p(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.hash_application_manifest(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function m(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.hash_application_runtime(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function h(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.hash_state_schema(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function g(t){let n=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=K.open(n,r);if(i[2])throw z(i[1]);return e.__wrap(i[0])}function _(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.resolve_application_runtime(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function v(e,t,n,r){let i=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.validate_mesh_claim(i,a,o,s,c,l,r);if(u[1])throw z(u[0])}function y(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_semantic_decision_definition(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function b(e,t){let n,r;try{let o=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),s=G,c=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),l=G,u=K.validate_semantic_decision_result(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,z(u[2]);return n=i,r=a,P(i,a)}finally{K.__wbindgen_free(n,r,1)}}function x(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_state_schema(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function S(e){let t,n;try{let a=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),o=G,s=K.validate_sync_operation(a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,z(s[2]);return t=r,n=i,P(r,i)}finally{K.__wbindgen_free(t,n,1)}}function C(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.validate_worker_transition(n,r,i,a);if(o[2])throw z(o[1]);return o[0]!==0}function w(e,t){let n=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),r=G,i=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),a=G,o=K.validate_workload_transition(n,r,i,a);if(o[2])throw z(o[1]);return o[0]!==0}function T(e){let t=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),n=G,r=K.verify_bundle_integrity(t,n);if(r[2])throw z(r[1]);return r[0]!==0}function E(e,t,n,r,i,a){let o,s;try{let u=R(e,K.__wbindgen_malloc,K.__wbindgen_realloc),d=G,f=R(t,K.__wbindgen_malloc,K.__wbindgen_realloc),p=G,m=R(n,K.__wbindgen_malloc,K.__wbindgen_realloc),h=G,g=R(r,K.__wbindgen_malloc,K.__wbindgen_realloc),_=G,v=R(i,K.__wbindgen_malloc,K.__wbindgen_realloc),y=G,b=R(a,K.__wbindgen_malloc,K.__wbindgen_realloc),x=G,S=K.verify_signed_grant(u,d,f,p,m,h,g,_,v,y,b,x);var c=S[0],l=S[1];if(S[3])throw c=0,l=0,z(S[2]);return o=c,s=l,P(c,l)}finally{K.__wbindgen_free(o,s,1)}}function D(){return{__proto__:null,"./feltdb_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_bb96b2010945f0bc:function(e,t){throw Error(P(e,t))},__wbindgen_cast_0000000000000001:function(e,t){return P(e,t)},__wbindgen_init_externref_table:function(){let e=K.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}var O=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_jsdb_free(e,1)),k=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_jsresult_free(e,1)),A=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmanalytics_free(e,1)),j=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmdistributedindexmanager_free(e,1)),M=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmindexmanager_free(e,1)),N=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>K.__wbg_wasmshardmanager_free(e,1));function P(e,t){return U(e>>>0,t)}var F=null;function I(){return(F===null||F.byteLength===0)&&(F=new Uint8Array(K.memory.buffer)),F}function L(e){return e==null}function R(e,t,n){if(n===void 0){let n=W.encode(e),r=t(n.length,1)>>>0;return I().subarray(r,r+n.length).set(n),G=n.length,r}let r=e.length,i=t(r,1)>>>0,a=I(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=I().subarray(i+o,i+r),a=W.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return G=o,i}function z(e){let t=K.__wbindgen_externrefs.get(e);return K.__externref_table_dealloc(e),t}var B=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});B.decode();var V=2146435072,H=0;function U(e,t){return H+=t,H>=V&&(B=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),B.decode(),H=t),B.decode(I().subarray(e,e+t))}var W=new TextEncoder;`encodeInto`in W||(W.encodeInto=function(e,t){let n=W.encode(e);return t.set(n),{read:e.length,written:n.length}});var G=0,K;function q(e,t){return K=e.exports,F=null,K.__wbindgen_start(),K}async function J(e,t){if(typeof Response==`function`&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}function Y(e){if(K!==void 0)return K;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=D();return e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e)),q(new WebAssembly.Instance(e,t),e)}async function X(e){if(K!==void 0)return K;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`)),e===void 0&&(e=new URL(`/assets/feltdb_wasm_bg-BYJo87WY.wasm`,``+import.meta.url));let t=D();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await J(await e,t);return q(n,r)}export{e as JsDb,t as JsResult,n as WasmAnalytics,r as WasmDistributedIndexManager,i as WasmIndexManager,a as WasmShardManager,o as apply_sync_result,s as authorize_offline,c as canonical_bundle_hash,l as canonicalize_application_manifest,u as compare_state_schemas,X as default,d as diff_application_revisions,f as execute_semantic_decision,p as hash_application_manifest,m as hash_application_runtime,h as hash_state_schema,Y as initSync,g as open,_ as resolve_application_runtime,v as validate_mesh_claim,y as validate_semantic_decision_definition,b as validate_semantic_decision_result,x as validate_state_schema,S as validate_sync_operation,C as validate_worker_transition,w as validate_workload_transition,T as verify_bundle_integrity,E as verify_signed_grant};
|
|
Binary file
|