@feltdb/core 0.12.1 → 0.12.2
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/build-identity.json +13 -4
- package/dist/cli/commands.js +88 -43
- package/dist/collection.d.ts +41 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +116 -47
- package/dist/composition.d.ts.map +1 -1
- package/dist/composition.js +11 -1
- package/dist/create/build-identity.json +13 -4
- package/dist/create/cli.js +3 -3
- package/dist/create/create.js +17 -19
- package/dist/create/package-versions.js +1 -1
- package/dist/create/server-source/Cargo.lock +18 -3
- package/dist/create/server-source/Cargo.toml +4 -2
- package/dist/create/server-source/crates/feltdb/Cargo.toml +20 -0
- package/dist/create/server-source/crates/feltdb/LICENSE +21 -0
- package/dist/create/server-source/crates/feltdb/README.md +75 -0
- package/dist/create/server-source/crates/feltdb/src/agent_state.rs +320 -0
- package/dist/create/server-source/crates/feltdb/src/agent_transition_contract.rs +1545 -0
- package/dist/create/server-source/crates/feltdb/src/authority.rs +145 -15
- package/dist/create/server-source/crates/feltdb/src/lib.rs +227 -23
- package/dist/create/server-source/crates/feltdb/src/state_model.rs +1 -5
- package/dist/create/server-source/crates/feltdb/tests/agent_state_native.rs +1188 -0
- package/dist/create/server-source/crates/feltdb/tests/agent_transition_contract_conformance.rs +2884 -0
- package/dist/create/server-source/crates/feltdb/tests/authority_transaction_identity.rs +534 -0
- package/dist/create/server-source/crates/feltdb/tests/fixtures/agent_transition_corpus.json +23340 -0
- package/dist/create/server-source/crates/feltdb-client/Cargo.toml +29 -0
- package/dist/create/server-source/crates/feltdb-client/LICENSE +21 -0
- package/dist/create/server-source/crates/feltdb-client/README.md +70 -0
- package/dist/create/server-source/crates/feltdb-client/src/application.rs +527 -0
- package/dist/create/server-source/crates/feltdb-client/src/authority.rs +679 -0
- package/dist/create/server-source/crates/feltdb-client/src/control.rs +292 -0
- package/dist/create/server-source/crates/feltdb-client/src/error.rs +227 -0
- package/dist/create/server-source/crates/feltdb-client/src/events.rs +146 -0
- package/dist/create/server-source/crates/feltdb-client/src/lib.rs +466 -0
- package/dist/create/server-source/crates/feltdb-client/tests/fixtures/README.md +4 -0
- package/dist/create/server-source/crates/feltdb-client/tests/fixtures/private-ca.pem +20 -0
- package/dist/create/server-source/crates/feltdb-client/tests/fixtures/server-key.pem +28 -0
- package/dist/create/server-source/crates/feltdb-client/tests/fixtures/server.pem +20 -0
- package/dist/create/server-source/crates/feltdb-client/tests/private_ca.rs +95 -0
- package/dist/create/server-source/crates/feltdb-server/Cargo.toml +20 -1
- package/dist/create/server-source/crates/feltdb-server/LICENSE +21 -0
- package/dist/create/server-source/crates/feltdb-server/README.md +12 -1
- package/dist/create/server-source/crates/feltdb-server/src/backup.rs +6 -2
- package/dist/create/server-source/crates/feltdb-server/src/lib.rs +20 -0
- package/dist/create/server-source/crates/feltdb-server/src/main.rs +1 -3
- package/dist/create/server-source/crates/feltdb-server/tests/rust_client.rs +683 -0
- package/dist/create/server-source/crates/feltdb-wasm/Cargo.toml +3 -1
- package/dist/create/template/default-project/README.md +12 -7
- package/dist/create/template/default-project/src/pages/Dashboard.tsx +1 -1
- package/dist/create/template/dot-feltdb-README.md +3 -3
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +43 -17
- package/dist/development-runtime-bridge.d.ts.map +1 -1
- package/dist/development-runtime-bridge.js +22 -1
- package/dist/embedded-transaction.d.ts +75 -8
- package/dist/embedded-transaction.d.ts.map +1 -1
- package/dist/embedded-transaction.js +124 -18
- package/dist/error-codes.d.ts +2 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +2 -0
- package/dist/feltdb.d.ts +1 -11
- package/dist/feltdb.d.ts.map +1 -1
- package/dist/file-db.d.ts +6 -0
- package/dist/file-db.d.ts.map +1 -1
- package/dist/file-db.js +43 -11
- package/dist/indexeddb-db.d.ts.map +1 -1
- package/dist/indexeddb-db.js +65 -41
- package/dist/memory-db.d.ts.map +1 -1
- package/dist/memory-db.js +29 -8
- package/dist/studio/{KeyManagementPanel-DZuSeWBK.js → KeyManagementPanel-D5FMvvU9.js} +1 -0
- package/dist/studio/app.d.ts.map +1 -1
- package/dist/studio/components/KeyManagementPanel.d.ts.map +1 -1
- package/dist/studio/components/KeyManagementPanel.js +1 -1
- package/dist/studio/components/RouteErrorBoundary.d.ts +5 -0
- package/dist/studio/components/RouteErrorBoundary.d.ts.map +1 -0
- package/dist/studio/components/index.js +2 -2
- package/dist/studio/{components-Bivm2lX6.js → components-B4eKIUN5.js} +1 -1
- package/dist/studio/control-plane/Agents.d.ts.map +1 -1
- package/dist/studio/control-plane/Data.d.ts.map +1 -1
- package/dist/studio/control-plane/Instance.d.ts.map +1 -1
- package/dist/studio/control-plane/Overview.d.ts.map +1 -1
- package/dist/studio/control-plane/Schema.d.ts.map +1 -1
- package/dist/studio/control-plane/context.d.ts +4 -1
- package/dist/studio/control-plane/context.d.ts.map +1 -1
- package/dist/studio/control-plane/index.js +2 -2
- package/dist/studio/control-plane/primitives.d.ts +8 -0
- package/dist/studio/control-plane/primitives.d.ts.map +1 -1
- package/dist/studio/{control-plane-CLm69XwX.js → control-plane-fxMcJn74.js} +1371 -1319
- package/dist/studio/index.js +146 -105
- package/dist/studio/utils/control-plane-api.d.ts.map +1 -1
- package/dist/studio/utils/control-plane-api.js +4 -3
- package/dist/studio/utils/service-api.d.ts.map +1 -1
- package/dist/studio/utils/service-api.js +5 -4
- package/dist/studio-app/assets/{feltdb_wasm-DACcD-zs.js → feltdb_wasm-BatwwogY.js} +1 -1
- package/dist/studio-app/assets/feltdb_wasm_bg-BX0newOr.wasm +0 -0
- package/dist/studio-app/assets/index-DoVvbIay.js +30 -0
- package/dist/studio-app/index.html +1 -1
- package/dist/telemetry.d.ts +1 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +4 -3
- package/dist/transaction-identity.d.ts +62 -0
- package/dist/transaction-identity.d.ts.map +1 -0
- package/dist/transaction-identity.js +138 -0
- package/dist/transaction.d.ts +50 -5
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +28 -0
- package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
- package/dist/wasm/package.json +1 -1
- package/package.json +1 -1
- package/dist/create/server-source/crates/feltdb-wasm/test.db +0 -0
- package/dist/studio-app/assets/feltdb_wasm_bg-BejThWID.wasm +0 -0
- package/dist/studio-app/assets/index-CoZaxnlm.js +0 -30
package/dist/error-codes.js
CHANGED
|
@@ -40,6 +40,8 @@ export var FeltDBErrorCode;
|
|
|
40
40
|
FeltDBErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
41
41
|
FeltDBErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
42
42
|
FeltDBErrorCode["IDEMPOTENCY_CONFLICT"] = "IDEMPOTENCY_CONFLICT";
|
|
43
|
+
/** The id exists but its recorded identity cannot be verified by this build. */
|
|
44
|
+
FeltDBErrorCode["IDEMPOTENCY_UNVERIFIABLE"] = "IDEMPOTENCY_UNVERIFIABLE";
|
|
43
45
|
/** Transport ended after a mutation may have reached the authority. Retry
|
|
44
46
|
* only with the same durable transaction/idempotency identity. */
|
|
45
47
|
FeltDBErrorCode["COMMIT_OUTCOME_UNKNOWN"] = "COMMIT_OUTCOME_UNKNOWN";
|
package/dist/feltdb.d.ts
CHANGED
|
@@ -185,17 +185,7 @@ export interface JsDb {
|
|
|
185
185
|
}>;
|
|
186
186
|
/** Read bases this runtime issued; re-evaluated inside the commit decision. */
|
|
187
187
|
fences?: import('./transaction.js').TransactionReadBasis[];
|
|
188
|
-
}): Promise<
|
|
189
|
-
transactionId: string;
|
|
190
|
-
duplicate: boolean;
|
|
191
|
-
operations: number;
|
|
192
|
-
stateBefore: number;
|
|
193
|
-
stateAfter: number;
|
|
194
|
-
baseRevision: number;
|
|
195
|
-
commitRevision: number;
|
|
196
|
-
revisionId: string;
|
|
197
|
-
operationIds: string[];
|
|
198
|
-
}>;
|
|
188
|
+
}): Promise<import('./transaction.js').AtomicTransactionResult>;
|
|
199
189
|
}
|
|
200
190
|
/**
|
|
201
191
|
* A row stored in the database
|
package/dist/feltdb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feltdb.d.ts","sourceRoot":"","sources":["../src/feltdb.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,GAAG,GAAG,GAAG,CAAC;IAEhC;;OAEG;IACH,SAAS,IAAI,GAAG,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAE/B;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;IAEvC;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnE;;OAEG;IACH,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IAEpE;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzC,iEAAiE;IACjE,eAAe,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAE3C,oDAAoD;IACpD,aAAa,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D,mEAAmE;IACnE,eAAe,CAAC,IAAI,IAAI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ACxB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/dist/file-db.d.ts
CHANGED
|
@@ -125,6 +125,12 @@ export declare class FileJsDb implements JsDb {
|
|
|
125
125
|
private refresh;
|
|
126
126
|
/** Apply newly committed journal records. False when a full load is required. */
|
|
127
127
|
private tailJournal;
|
|
128
|
+
/**
|
|
129
|
+
* The identities a snapshot must carry so that compaction forgets nothing
|
|
130
|
+
* the journal it replaces held: dropping them here would turn every
|
|
131
|
+
* verified id into a legacy one at the next compaction.
|
|
132
|
+
*/
|
|
133
|
+
private identitiesForSnapshot;
|
|
128
134
|
/** A commit body starting from the current sequence. */
|
|
129
135
|
private stage;
|
|
130
136
|
private stageRow;
|
package/dist/file-db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-db.d.ts","sourceRoot":"","sources":["../src/file-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EAG1B,MAAM,0BAA0B,CAAC;AAalC,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-db.d.ts","sourceRoot":"","sources":["../src/file-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EAG1B,MAAM,0BAA0B,CAAC;AA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E,MAAM;IAKvC,uBAAuB,CAAC,UAAU,EAAE,aAAa,EAAE;;;;IA4C7C,gBAAgB,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAiB7E,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAqCtF,cAAc,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAkEjF,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IA2FxF,GAAG,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IA0FzQ,KAAK,IAAI,IAAI;CAId"}
|
package/dist/file-db.js
CHANGED
|
@@ -2,8 +2,8 @@ import { validateOperationAdmissionInput, operationsConflict, generateOperationI
|
|
|
2
2
|
import { FeltDBErrorCode, FeltDBServiceError } from './error-codes.js';
|
|
3
3
|
import * as nodeFs from 'fs';
|
|
4
4
|
import * as nodePath from 'path';
|
|
5
|
-
import { normaliseReadSet } from './transaction.js';
|
|
6
|
-
import { decideTransaction, readBasisToken, scanRows, embeddedResult,
|
|
5
|
+
import { TransactionIdConflictError, TransactionIdUnverifiableError, normaliseReadSet } from './transaction.js';
|
|
6
|
+
import { decideTransaction, readBasisToken, scanRows, embeddedDuplicate, embeddedResult, prepareTransaction, refusalError, } from './embedded-transaction.js';
|
|
7
7
|
import { EmbeddedQueryEngine } from './embedded-query.js';
|
|
8
8
|
import { encodeRecord, scanJournal, JournalCorruptionError, PersistenceProfiler, } from './file-journal.js';
|
|
9
9
|
export { JournalCorruptionError } from './file-journal.js';
|
|
@@ -65,7 +65,7 @@ export class FileJsDb {
|
|
|
65
65
|
peers = new Set();
|
|
66
66
|
lockFd = null;
|
|
67
67
|
lockToken = null;
|
|
68
|
-
applied = new
|
|
68
|
+
applied = new Map();
|
|
69
69
|
queryEngine;
|
|
70
70
|
indexedSequence = -1;
|
|
71
71
|
profiler;
|
|
@@ -207,6 +207,7 @@ export class FileJsDb {
|
|
|
207
207
|
peers: snapshot.meta.peers ?? [],
|
|
208
208
|
sequences: snapshot.meta.sequences ?? {},
|
|
209
209
|
applied_transactions: snapshot.applied_transactions ?? [],
|
|
210
|
+
transaction_identities: snapshot.transaction_identities,
|
|
210
211
|
} : this.initializeState();
|
|
211
212
|
const view = {
|
|
212
213
|
snapshotKey,
|
|
@@ -300,8 +301,12 @@ export class FileJsDb {
|
|
|
300
301
|
for (const peer of state.peers)
|
|
301
302
|
this.peers.add(peer);
|
|
302
303
|
this.applied.clear();
|
|
303
|
-
for (const transactionId of state.applied_transactions ?? [])
|
|
304
|
-
|
|
304
|
+
for (const transactionId of state.applied_transactions ?? []) {
|
|
305
|
+
const identity = state.transaction_identities?.[transactionId];
|
|
306
|
+
this.applied.set(transactionId, identity
|
|
307
|
+
? { digest: identity.d, before: identity.b, after: identity.a }
|
|
308
|
+
: {});
|
|
309
|
+
}
|
|
305
310
|
}
|
|
306
311
|
/** Apply one commit to memory. The only way any mutation reaches memory. */
|
|
307
312
|
applyCommit(body, index) {
|
|
@@ -325,7 +330,11 @@ export class FileJsDb {
|
|
|
325
330
|
this.peers.add(peer);
|
|
326
331
|
}
|
|
327
332
|
if (body.t !== undefined && !this.applied.has(body.t)) {
|
|
328
|
-
this
|
|
333
|
+
// The original position is what the store held immediately before this
|
|
334
|
+
// record and what the record itself names: both are already in the
|
|
335
|
+
// journal, so recording them takes no extra field there. A legacy record
|
|
336
|
+
// (no `d`) still yields its position; only its digest is unknowable.
|
|
337
|
+
this.applied.set(body.t, { digest: body.d, before: this.state.sequence, after: body.s });
|
|
329
338
|
this.state.applied_transactions.push(body.t);
|
|
330
339
|
}
|
|
331
340
|
this.state.sequence = body.s;
|
|
@@ -415,6 +424,20 @@ export class FileJsDb {
|
|
|
415
424
|
/* ------------------------------------------------------------------------
|
|
416
425
|
* Commit protocol
|
|
417
426
|
* ---------------------------------------------------------------------- */
|
|
427
|
+
/**
|
|
428
|
+
* The identities a snapshot must carry so that compaction forgets nothing
|
|
429
|
+
* the journal it replaces held: dropping them here would turn every
|
|
430
|
+
* verified id into a legacy one at the next compaction.
|
|
431
|
+
*/
|
|
432
|
+
identitiesForSnapshot() {
|
|
433
|
+
const identities = {};
|
|
434
|
+
for (const [id, applied] of this.applied) {
|
|
435
|
+
if (applied.digest === undefined && applied.before === undefined)
|
|
436
|
+
continue;
|
|
437
|
+
identities[id] = { d: applied.digest, b: applied.before, a: applied.after };
|
|
438
|
+
}
|
|
439
|
+
return Object.keys(identities).length ? { transaction_identities: identities } : {};
|
|
440
|
+
}
|
|
418
441
|
/** A commit body starting from the current sequence. */
|
|
419
442
|
stage() {
|
|
420
443
|
return { s: this.state.sequence };
|
|
@@ -596,7 +619,8 @@ export class FileJsDb {
|
|
|
596
619
|
},
|
|
597
620
|
rows: this.state.rows,
|
|
598
621
|
events: this.state.events,
|
|
599
|
-
applied_transactions: [...this.applied],
|
|
622
|
+
applied_transactions: [...this.applied.keys()],
|
|
623
|
+
...this.identitiesForSnapshot(),
|
|
600
624
|
journal: { generation, commit },
|
|
601
625
|
};
|
|
602
626
|
// Compaction is profiled as one phase, so that it never inflates the
|
|
@@ -885,6 +909,9 @@ export class FileJsDb {
|
|
|
885
909
|
};
|
|
886
910
|
}
|
|
887
911
|
async commit_transaction(request) {
|
|
912
|
+
// Validity and identity need no stored state, so they are settled before
|
|
913
|
+
// the lock is taken and the lock is held only for the decision and commit.
|
|
914
|
+
const digest = prepareTransaction(request);
|
|
888
915
|
await this.acquireLockAsync();
|
|
889
916
|
const started = this.profiler.now();
|
|
890
917
|
try {
|
|
@@ -892,14 +919,18 @@ export class FileJsDb {
|
|
|
892
919
|
const before = this.state.sequence;
|
|
893
920
|
const plan = decideTransaction(request, {
|
|
894
921
|
exists: key => key in this.state.rows,
|
|
895
|
-
|
|
922
|
+
applied: transactionId => this.applied.get(transactionId),
|
|
896
923
|
read: key => this.state.rows[key],
|
|
897
924
|
scan: collections => scanRows(Object.entries(this.state.rows), collections),
|
|
898
|
-
});
|
|
925
|
+
}, digest);
|
|
899
926
|
if (plan.kind === 'duplicate')
|
|
900
|
-
return
|
|
927
|
+
return embeddedDuplicate(request, plan);
|
|
928
|
+
if (plan.kind === 'conflict')
|
|
929
|
+
throw new TransactionIdConflictError(request.transactionId);
|
|
930
|
+
if (plan.kind === 'unverifiable')
|
|
931
|
+
throw new TransactionIdUnverifiableError(request.transactionId);
|
|
901
932
|
if (plan.kind === 'reject')
|
|
902
|
-
throw
|
|
933
|
+
throw refusalError(plan);
|
|
903
934
|
const body = this.stage();
|
|
904
935
|
const timestamp = Date.now();
|
|
905
936
|
for (const mutation of plan.mutations) {
|
|
@@ -911,6 +942,7 @@ export class FileJsDb {
|
|
|
911
942
|
// whose identity did not survive a restart, and redelivery would then
|
|
912
943
|
// apply it a second time.
|
|
913
944
|
body.t = request.transactionId;
|
|
945
|
+
body.d = digest;
|
|
914
946
|
this.persist(body);
|
|
915
947
|
return embeddedResult(request, false, before, body.s);
|
|
916
948
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-db.d.ts","sourceR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,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IACjE,uBAAuB,CAAC,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAwBzG"}
|
package/dist/indexeddb-db.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FreshnessContractViolation } from './freshness.js';
|
|
2
|
-
import { normaliseReadSet } from './transaction.js';
|
|
3
|
-
import { decideTransaction, readBasisToken,
|
|
2
|
+
import { TransactionIdConflictError, TransactionIdUnverifiableError, normaliseReadSet } from './transaction.js';
|
|
3
|
+
import { decideTransaction, prepareTransaction, readBasisToken, refusalError, embeddedDuplicate, embeddedResult, } from './embedded-transaction.js';
|
|
4
4
|
import { EmbeddedQueryEngine } from './embedded-query.js';
|
|
5
5
|
/** Durable browser runtime. Every mutation resolves only after its IndexedDB transaction commits. */
|
|
6
6
|
export class IndexedDbJsDb {
|
|
@@ -102,27 +102,18 @@ export class IndexedDbJsDb {
|
|
|
102
102
|
*/
|
|
103
103
|
async commit_transaction(request) {
|
|
104
104
|
const db = await this.database;
|
|
105
|
-
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
throw new EmbeddedTransactionRejected(structural.reason, structural.failure);
|
|
118
|
-
}
|
|
119
|
-
// Applied transaction ids live in their own store so identity survives a
|
|
120
|
-
// page reload the same way records do.
|
|
121
|
-
const alreadyApplied = await this.request('transactions', store => store.get(request.transactionId));
|
|
122
|
-
if (alreadyApplied !== undefined) {
|
|
123
|
-
return embeddedResult(request, true, before, this.sequence);
|
|
124
|
-
}
|
|
125
|
-
const plan = await new Promise((resolve, reject) => {
|
|
105
|
+
// Validity and identity need no stored state, so they are settled here,
|
|
106
|
+
// before the IndexedDB transaction is opened: that transaction cannot be
|
|
107
|
+
// held open across other asynchronous work, and a malformed request must
|
|
108
|
+
// never reach (or be answered by) the stored identity.
|
|
109
|
+
const digest = prepareTransaction(request);
|
|
110
|
+
// Everything else is a question about stored state -- is this id already
|
|
111
|
+
// committed, and with which digest; does the record exist, what version
|
|
112
|
+
// does it hold -- and is answered inside the one read-write transaction
|
|
113
|
+
// that also writes. IndexedDB does not start a read-write transaction
|
|
114
|
+
// while another with an overlapping scope is active, across tabs and
|
|
115
|
+
// connections, so two attempts at one id cannot both see it as new.
|
|
116
|
+
const outcome = await new Promise((resolve, reject) => {
|
|
126
117
|
let transaction;
|
|
127
118
|
try {
|
|
128
119
|
transaction = db.transaction(['rows', 'changes', 'transactions'], 'readwrite', { durability: 'strict' });
|
|
@@ -155,27 +146,32 @@ export class IndexedDbJsDb {
|
|
|
155
146
|
// same transaction.
|
|
156
147
|
const ranges = [...new Set(fences.flatMap(fence => (fence.reads.predicates ?? []).map(predicate => predicate.collection)))];
|
|
157
148
|
const scanned = new Map();
|
|
158
|
-
|
|
149
|
+
// The identity lookup is one of the reads, issued first.
|
|
150
|
+
let pending = touched.length + ranges.length + 1;
|
|
151
|
+
let prior;
|
|
159
152
|
let decided = null;
|
|
160
153
|
const finish = () => {
|
|
161
154
|
const plan = decideTransaction(request, {
|
|
162
155
|
exists: key => records.get(key) !== undefined,
|
|
163
156
|
read: key => records.get(key),
|
|
164
157
|
scan: collections => new Map(collections.map(collection => [collection, scanned.get(collection) ?? []])),
|
|
165
|
-
|
|
166
|
-
});
|
|
167
|
-
decided = plan;
|
|
158
|
+
applied: () => prior,
|
|
159
|
+
}, digest);
|
|
160
|
+
decided = { plan };
|
|
168
161
|
if (plan.kind !== 'apply') {
|
|
169
162
|
transaction.abort();
|
|
170
163
|
return;
|
|
171
164
|
}
|
|
172
165
|
const timestamp = Date.now();
|
|
166
|
+
let outstanding = plan.mutations.length;
|
|
167
|
+
let first;
|
|
168
|
+
let last = 0;
|
|
173
169
|
for (const mutation of plan.mutations) {
|
|
174
170
|
if (mutation.value === undefined)
|
|
175
171
|
rows.delete(mutation.key);
|
|
176
172
|
else
|
|
177
173
|
rows.put(mutation.value, mutation.key);
|
|
178
|
-
changes.add({
|
|
174
|
+
const added = changes.add({
|
|
179
175
|
collection: mutation.collection,
|
|
180
176
|
key: mutation.key,
|
|
181
177
|
type: mutation.value === undefined ? 'delete' : 'put',
|
|
@@ -184,16 +180,41 @@ export class IndexedDbJsDb {
|
|
|
184
180
|
origin: this.origin,
|
|
185
181
|
id: `${this.origin}:${timestamp}:${Math.random().toString(36).slice(2)}`,
|
|
186
182
|
});
|
|
183
|
+
added.onsuccess = () => {
|
|
184
|
+
const position = Number(added.result);
|
|
185
|
+
first = first === undefined ? position : Math.min(first, position);
|
|
186
|
+
last = Math.max(last, position);
|
|
187
|
+
outstanding -= 1;
|
|
188
|
+
// The identity is written in this same transaction, once the
|
|
189
|
+
// commit's durable position -- the change log's own sequence, the
|
|
190
|
+
// same for every connection -- is known.
|
|
191
|
+
if (outstanding === 0) {
|
|
192
|
+
const before = (first ?? 1) - 1;
|
|
193
|
+
decided = { plan, before, after: last };
|
|
194
|
+
transactions.put({ transactionId: request.transactionId, committedAt: timestamp, digest, before, after: last }, request.transactionId);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
187
197
|
}
|
|
188
|
-
transactions.put({ transactionId: request.transactionId, committedAt: timestamp }, request.transactionId);
|
|
189
198
|
};
|
|
199
|
+
const settle = () => { pending -= 1; if (pending === 0)
|
|
200
|
+
finish(); };
|
|
201
|
+
const identity = transactions.get(request.transactionId);
|
|
202
|
+
identity.onsuccess = () => {
|
|
203
|
+
const stored = identity.result;
|
|
204
|
+
// An entry with no digest was written before digests existed.
|
|
205
|
+
prior = stored === undefined ? undefined : {
|
|
206
|
+
...(stored.digest === undefined ? {} : { digest: stored.digest }),
|
|
207
|
+
before: stored.before,
|
|
208
|
+
after: stored.after,
|
|
209
|
+
};
|
|
210
|
+
settle();
|
|
211
|
+
};
|
|
212
|
+
identity.onerror = () => reject(identity.error ?? new Error('IndexedDB read failed'));
|
|
190
213
|
for (const collection of ranges) {
|
|
191
214
|
const lookup = rows.getAll(IDBKeyRange.bound(`${collection}:`, `${collection}:\uffff`));
|
|
192
215
|
lookup.onsuccess = () => {
|
|
193
216
|
scanned.set(collection, lookup.result);
|
|
194
|
-
|
|
195
|
-
if (pending === 0)
|
|
196
|
-
finish();
|
|
217
|
+
settle();
|
|
197
218
|
};
|
|
198
219
|
lookup.onerror = () => reject(lookup.error ?? new Error('IndexedDB read failed'));
|
|
199
220
|
}
|
|
@@ -201,33 +222,36 @@ export class IndexedDbJsDb {
|
|
|
201
222
|
const lookup = rows.get(key);
|
|
202
223
|
lookup.onsuccess = () => {
|
|
203
224
|
records.set(key, lookup.result);
|
|
204
|
-
|
|
205
|
-
if (pending === 0)
|
|
206
|
-
finish();
|
|
225
|
+
settle();
|
|
207
226
|
};
|
|
208
227
|
lookup.onerror = () => reject(lookup.error ?? new Error('IndexedDB read failed'));
|
|
209
228
|
}
|
|
210
|
-
transaction.oncomplete = () => resolve(decided ?? { kind: 'reject', reason: 'transaction did not decide' });
|
|
229
|
+
transaction.oncomplete = () => resolve(decided ?? { plan: { kind: 'reject', reason: 'transaction did not decide' } });
|
|
211
230
|
transaction.onabort = () => {
|
|
212
|
-
if (decided && decided.kind !== 'apply')
|
|
231
|
+
if (decided && decided.plan.kind !== 'apply')
|
|
213
232
|
resolve(decided);
|
|
214
233
|
else
|
|
215
234
|
reject(transaction.error ?? new Error('IndexedDB transaction aborted'));
|
|
216
235
|
};
|
|
217
236
|
transaction.onerror = () => {
|
|
218
|
-
if (decided && decided.kind !== 'apply')
|
|
237
|
+
if (decided && decided.plan.kind !== 'apply')
|
|
219
238
|
return;
|
|
220
239
|
reject(transaction.error ?? new Error('IndexedDB transaction failed'));
|
|
221
240
|
};
|
|
222
241
|
});
|
|
242
|
+
const { plan } = outcome;
|
|
223
243
|
if (plan.kind === 'duplicate')
|
|
224
|
-
return
|
|
244
|
+
return embeddedDuplicate(request, plan);
|
|
245
|
+
if (plan.kind === 'conflict')
|
|
246
|
+
throw new TransactionIdConflictError(request.transactionId);
|
|
247
|
+
if (plan.kind === 'unverifiable')
|
|
248
|
+
throw new TransactionIdUnverifiableError(request.transactionId);
|
|
225
249
|
if (plan.kind === 'reject')
|
|
226
|
-
throw
|
|
250
|
+
throw refusalError(plan);
|
|
227
251
|
this.sequence += plan.mutations.length;
|
|
228
252
|
for (const mutation of plan.mutations)
|
|
229
253
|
this.announceLocalChange(mutation.collection, this.sequence);
|
|
230
|
-
return embeddedResult(request, false, before,
|
|
254
|
+
return embeddedResult(request, false, outcome.before ?? 0, outcome.after ?? 0);
|
|
231
255
|
}
|
|
232
256
|
/** Capture a read basis inside one readonly IndexedDB transaction. */
|
|
233
257
|
async read_basis(reads) {
|
package/dist/memory-db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-db.d.ts","sourceRoot":"","sources":["../src/memory-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAA8B,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-db.d.ts","sourceRoot":"","sources":["../src/memory-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAA8B,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAA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I,OAAO,CAAC,QAAQ,CAAC;IAQnC,YAAY;IACZ,iBAAiB,CAAC,aAAa,EAAE,MAAM;IACvC,uBAAuB,CAAC,UAAU,EAAE,aAAa,EAAE;;;;CAyBpD"}
|
package/dist/memory-db.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { FreshnessContractViolation } from './freshness.js';
|
|
2
|
-
import { normaliseReadSet } from './transaction.js';
|
|
3
|
-
import { decideTransaction, readBasisToken, scanRows,
|
|
2
|
+
import { TransactionIdConflictError, TransactionIdUnverifiableError, normaliseReadSet } from './transaction.js';
|
|
3
|
+
import { decideTransaction, prepareTransaction, readBasisToken, refusalError, scanRows, embeddedDuplicate, embeddedResult, } from './embedded-transaction.js';
|
|
4
4
|
import { EmbeddedQueryEngine } from './embedded-query.js';
|
|
5
5
|
const namespaces = new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Committed transaction identities, per namespace.
|
|
8
|
+
*
|
|
9
|
+
* The rows of a namespace are shared by every handle opened on it, so the
|
|
10
|
+
* identities of the transactions that wrote them must be shared too: otherwise
|
|
11
|
+
* two handles would each apply the same transaction id once.
|
|
12
|
+
*/
|
|
13
|
+
const appliedTransactions = new Map();
|
|
6
14
|
const revisions = new Map();
|
|
7
15
|
function namespaceRevision(namespace) {
|
|
8
16
|
let revision = revisions.get(namespace);
|
|
@@ -20,7 +28,7 @@ export class MemoryJsDb {
|
|
|
20
28
|
origin;
|
|
21
29
|
revisionState;
|
|
22
30
|
peers = new Set();
|
|
23
|
-
applied
|
|
31
|
+
applied;
|
|
24
32
|
queryEngine;
|
|
25
33
|
indexedRevision;
|
|
26
34
|
constructor(namespace) {
|
|
@@ -30,6 +38,12 @@ export class MemoryJsDb {
|
|
|
30
38
|
namespaces.set(namespace, rows);
|
|
31
39
|
}
|
|
32
40
|
this.rows = rows;
|
|
41
|
+
let applied = appliedTransactions.get(namespace);
|
|
42
|
+
if (!applied) {
|
|
43
|
+
applied = new Map();
|
|
44
|
+
appliedTransactions.set(namespace, applied);
|
|
45
|
+
}
|
|
46
|
+
this.applied = applied;
|
|
33
47
|
this.revisionState = namespaceRevision(namespace);
|
|
34
48
|
this.origin = `memory:${namespace}`;
|
|
35
49
|
this.queryEngine = new EmbeddedQueryEngine(() => this.rows.entries());
|
|
@@ -66,16 +80,21 @@ export class MemoryJsDb {
|
|
|
66
80
|
}
|
|
67
81
|
async commit_transaction(request) {
|
|
68
82
|
const before = this.sequence;
|
|
83
|
+
const digest = prepareTransaction(request);
|
|
69
84
|
const plan = decideTransaction(request, {
|
|
70
85
|
exists: key => this.rows.has(key),
|
|
71
|
-
|
|
86
|
+
applied: transactionId => this.applied.get(transactionId),
|
|
72
87
|
read: key => this.rows.get(key),
|
|
73
88
|
scan: collections => scanRows(this.rows, collections),
|
|
74
|
-
});
|
|
89
|
+
}, digest);
|
|
75
90
|
if (plan.kind === 'duplicate')
|
|
76
|
-
return
|
|
91
|
+
return embeddedDuplicate(request, plan);
|
|
92
|
+
if (plan.kind === 'conflict')
|
|
93
|
+
throw new TransactionIdConflictError(request.transactionId);
|
|
94
|
+
if (plan.kind === 'unverifiable')
|
|
95
|
+
throw new TransactionIdUnverifiableError(request.transactionId);
|
|
77
96
|
if (plan.kind === 'reject')
|
|
78
|
-
throw
|
|
97
|
+
throw refusalError(plan);
|
|
79
98
|
for (const mutation of plan.mutations) {
|
|
80
99
|
if (mutation.value === undefined) {
|
|
81
100
|
this.rows.delete(mutation.key);
|
|
@@ -86,7 +105,7 @@ export class MemoryJsDb {
|
|
|
86
105
|
this.event(mutation.collection, mutation.key, 'put', mutation.value);
|
|
87
106
|
}
|
|
88
107
|
}
|
|
89
|
-
this.applied.
|
|
108
|
+
this.applied.set(request.transactionId, { digest, before, after: this.sequence });
|
|
90
109
|
return embeddedResult(request, false, before, this.sequence);
|
|
91
110
|
}
|
|
92
111
|
insert(key, value) {
|
|
@@ -112,6 +131,8 @@ export class MemoryJsDb {
|
|
|
112
131
|
: { success: true, data: JSON.stringify(value) };
|
|
113
132
|
}
|
|
114
133
|
delete(key) {
|
|
134
|
+
if (!this.rows.has(key))
|
|
135
|
+
return { success: false, error: `Record ${key} not found` };
|
|
115
136
|
this.rows.delete(key);
|
|
116
137
|
this.event(key.split(':')[0], key, 'delete');
|
|
117
138
|
return { success: true, data: key };
|
|
@@ -65,6 +65,7 @@ var a = {
|
|
|
65
65
|
});
|
|
66
66
|
if (e.status === 401) throw Error("Unauthorized: Invalid or expired API token");
|
|
67
67
|
if (e.status === 403) throw Error("Forbidden: Your account does not have permission to manage API keys");
|
|
68
|
+
if (e.status === 404) throw Error("This authority does not offer API key management. The local development authority has no keys to list; a managed or self-hosted instance does.");
|
|
68
69
|
if (!e.ok) throw Error(`Failed to fetch keys: ${e.status} ${e.statusText}`);
|
|
69
70
|
let t = await e.json();
|
|
70
71
|
d(t.tokens || []);
|
package/dist/studio/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAsC,MAAM,OAAO,CAAC;AAS3D,OAA4B,EAAE,KAAK,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACzG,OAAO,EAAa,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAqBjF,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAI/E,OAAO,mCAAmC,CAAC;AAC3C,OAAO,yBAAyB,CAAC;AACjC,OAAO,WAAW,CAAC;AACnB,OAAO,mCAAmC,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB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,aAAkB,EAAE,WAA0B,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,cAAc,qBAgIjQ;AA+DD,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyManagementPanel.d.ts","sourceRoot":"","sources":["../../src/components/KeyManagementPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAWnD,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"KeyManagementPanel.d.ts","sourceRoot":"","sources":["../../src/components/KeyManagementPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAWnD,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAmUhE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../KeyManagementPanel-
|
|
1
|
+
import { t as e } from "../KeyManagementPanel-D5FMvvU9.js";
|
|
2
2
|
export { e as KeyManagementPanel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouteErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/components/RouteErrorBoundary.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AA+B1B,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAG7E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v, y } from "../components-
|
|
2
|
-
import { t as b } from "../KeyManagementPanel-
|
|
1
|
+
import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v, y } from "../components-B4eKIUN5.js";
|
|
2
|
+
import { t as b } from "../KeyManagementPanel-D5FMvvU9.js";
|
|
3
3
|
import { ManagedInstancePanel as x } from "./ManagedInstancePanel.js";
|
|
4
4
|
export { v as AgentExplorer, s as ApplicationDesigner, u as AskFeltDB, l as CapabilityExplorer, m as ConflictExplorer, _ as ContractInspector, n as ExecutionViewer, o as GlobalSearch, g as HealthCenter, b as KeyManagementPanel, x as ManagedInstancePanel, a as ModuleExplorer, t as OperationsExplorer, r as OverviewDashboard, c as PeerMap, p as ProposalBrowser, d as ProvenanceViewer, f as ReferenceExplorer, e as SettingsPanel, h as StateExplorer, y as WorkflowVisualizer, i as dataCollectionLocation };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ServiceApiError as e, StudioServiceApi as t, safeDisplayValue as n, serviceApiErrorMessage as r } from "./utils/service-api.js";
|
|
2
2
|
import { StudioProposalApi as i, proposalErrorMessage as a, proposalSections as o } from "./utils/proposal-api.js";
|
|
3
|
-
import "./KeyManagementPanel-
|
|
3
|
+
import "./KeyManagementPanel-D5FMvvU9.js";
|
|
4
4
|
import "./components/ManagedInstancePanel.js";
|
|
5
5
|
import s, { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
6
6
|
import { Link as p } from "react-router-dom";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agents.d.ts","sourceRoot":"","sources":["../../src/control-plane/Agents.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Agents.d.ts","sourceRoot":"","sources":["../../src/control-plane/Agents.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAkSxC,wBAAgB,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,qBA4DlG;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../src/control-plane/Data.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAA4B,MAAM,OAAO,CAAC;AA+PjD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../src/control-plane/Data.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAA4B,MAAM,OAAO,CAAC;AA+PjD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,qBAiSjI;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/control-plane/Instance.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,mBAAmB,GAAG,aAAa,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEvH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,uBAAuB,CAO1B;AAED,wBAAgB,4BAA4B,sBAQ3C;AAED,wBAAgB,WAAW,sBAoF1B;AAED,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/control-plane/Instance.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,mBAAmB,GAAG,aAAa,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEvH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,uBAAuB,CAO1B;AAED,wBAAgB,4BAA4B,sBAQ3C;AAED,wBAAgB,WAAW,sBAoF1B;AAED,wBAAgB,YAAY,sBA0C3B;AAED,wBAAgB,UAAU,sBAoCzB;AAED,wBAAgB,QAAQ,sBA0EvB;AAED,wBAAgB,SAAS,sBA8CxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Overview.d.ts","sourceRoot":"","sources":["../../src/control-plane/Overview.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"Overview.d.ts","sourceRoot":"","sources":["../../src/control-plane/Overview.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B,wBAAgB,gBAAgB,sBAwI/B;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/control-plane/Schema.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAMjD,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/control-plane/Schema.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAMjD,wBAAgB,cAAc,sBA8J7B;AAED,eAAe,cAAc,CAAC"}
|