@powerhousedao/connect 6.0.0-dev.88 → 6.0.0-dev.89

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.
@@ -1 +1 @@
1
- {"version":3,"file":"InspectorModal.d.ts","sourceRoot":"","sources":["../../../../../../src/components/modal/modals/InspectorModal/InspectorModal.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAmClC,CAAC"}
1
+ {"version":3,"file":"InspectorModal.d.ts","sourceRoot":"","sources":["../../../../../../src/components/modal/modals/InspectorModal/InspectorModal.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAqClC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { IntegrityInspectorProps } from "@powerhousedao/design-system/connect";
2
+ export declare function useIntegrityInspector(): IntegrityInspectorProps | undefined;
3
+ //# sourceMappingURL=useIntegrityInspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntegrityInspector.d.ts","sourceRoot":"","sources":["../../../../../../src/components/modal/modals/InspectorModal/useIntegrityInspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAKpF,wBAAgB,qBAAqB,IAAI,uBAAuB,GAAG,SAAS,CAuD3E"}
@@ -37279,6 +37279,7 @@ import { isUndoRedo } from "document-model/core";
37279
37279
  import { deriveOperationId as deriveOperationId2 } from "document-model/core";
37280
37280
  import { ConsoleLogger } from "document-model/core";
37281
37281
  import { AbortError } from "document-drive/utils/errors";
37282
+ import { hashDocumentStateForScope } from "document-model/core";
37282
37283
  function createDocumentAction(input) {
37283
37284
  return {
37284
37285
  id: generateId(),
@@ -44573,6 +44574,10 @@ class RingBuffer {
44573
44574
  return this.size;
44574
44575
  }
44575
44576
  }
44577
+ function extractModuleVersion(doc) {
44578
+ const v2 = doc.state.document.version;
44579
+ return v2 === 0 ? undefined : v2;
44580
+ }
44576
44581
 
44577
44582
  class KyselyWriteCache {
44578
44583
  streams;
@@ -44737,7 +44742,7 @@ class KyselyWriteCache {
44737
44742
  throw new Error(`Failed to rebuild document ${documentId}: CREATE_DOCUMENT action missing model in input`);
44738
44743
  }
44739
44744
  document2 = createDocumentFromAction(documentCreateAction);
44740
- const docModule = this.registry.getModule(documentType);
44745
+ let docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44741
44746
  const docScopeOps = await this.operationStore.getSince(documentId, "document", branch, 0, undefined, undefined, signal);
44742
44747
  for (const operation of docScopeOps.results) {
44743
44748
  if (operation.index === 0) {
@@ -44746,6 +44751,7 @@ class KyselyWriteCache {
44746
44751
  if (operation.action.type === "UPGRADE_DOCUMENT") {
44747
44752
  const upgradeAction = operation.action;
44748
44753
  document2 = applyUpgradeDocumentAction(document2, upgradeAction);
44754
+ docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44749
44755
  } else if (operation.action.type === "DELETE_DOCUMENT") {
44750
44756
  applyDeleteDocumentAction(document2, operation.action);
44751
44757
  } else {
@@ -44757,7 +44763,7 @@ class KyselyWriteCache {
44757
44763
  }
44758
44764
  }
44759
44765
  }
44760
- const module = this.registry.getModule(documentType);
44766
+ const module = this.registry.getModule(documentType, extractModuleVersion(document2));
44761
44767
  let cursor = undefined;
44762
44768
  const pageSize = 100;
44763
44769
  let hasMorePages;
@@ -47195,6 +47201,25 @@ class KyselyKeyframeStore {
47195
47201
  document: row.document
47196
47202
  };
47197
47203
  }
47204
+ async listKeyframes(documentId, scope, branch, signal) {
47205
+ if (signal?.aborted) {
47206
+ throw new Error("Operation aborted");
47207
+ }
47208
+ let query = this.queryExecutor.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).orderBy("revision", "asc");
47209
+ if (scope !== undefined) {
47210
+ query = query.where("scope", "=", scope);
47211
+ }
47212
+ if (branch !== undefined) {
47213
+ query = query.where("branch", "=", branch);
47214
+ }
47215
+ const rows = await query.execute();
47216
+ return rows.map((row) => ({
47217
+ scope: row.scope,
47218
+ branch: row.branch,
47219
+ revision: row.revision,
47220
+ document: row.document
47221
+ }));
47222
+ }
47198
47223
  async deleteKeyframes(documentId, scope, branch, signal) {
47199
47224
  if (signal?.aborted) {
47200
47225
  throw new Error("Operation aborted");
@@ -51458,6 +51483,118 @@ function relationalDbToQueryBuilder(query) {
51458
51483
  withSchema: (schema) => relationalDbToQueryBuilder(query.withSchema(schema))
51459
51484
  };
51460
51485
  }
51486
+
51487
+ class DocumentIntegrityService {
51488
+ keyframeStore;
51489
+ operationStore;
51490
+ writeCache;
51491
+ documentView;
51492
+ documentModelRegistry;
51493
+ constructor(keyframeStore, operationStore, writeCache, documentView, documentModelRegistry) {
51494
+ this.keyframeStore = keyframeStore;
51495
+ this.operationStore = operationStore;
51496
+ this.writeCache = writeCache;
51497
+ this.documentView = documentView;
51498
+ this.documentModelRegistry = documentModelRegistry;
51499
+ }
51500
+ async validateDocument(documentId, branch = "main", signal) {
51501
+ const keyframeIssues = [];
51502
+ const snapshotIssues = [];
51503
+ const replayCache = new KyselyWriteCache(nullKeyframeStore, this.operationStore, this.documentModelRegistry, {
51504
+ maxDocuments: 1,
51505
+ ringBufferSize: 1,
51506
+ keyframeInterval: Number.MAX_SAFE_INTEGER
51507
+ });
51508
+ const keyframes = await this.keyframeStore.listKeyframes(documentId, undefined, branch, signal);
51509
+ for (const keyframe of keyframes) {
51510
+ if (signal?.aborted) {
51511
+ throw new Error("Operation aborted");
51512
+ }
51513
+ replayCache.invalidate(documentId, keyframe.scope, branch);
51514
+ const replayedDoc = await replayCache.getState(documentId, keyframe.scope, branch, keyframe.revision, signal);
51515
+ const kfHash = hashDocumentStateForScope(keyframe.document, keyframe.scope);
51516
+ const replayHash = hashDocumentStateForScope(replayedDoc, keyframe.scope);
51517
+ if (kfHash !== replayHash) {
51518
+ keyframeIssues.push({
51519
+ scope: keyframe.scope,
51520
+ branch,
51521
+ revision: keyframe.revision,
51522
+ keyframeHash: kfHash,
51523
+ replayedHash: replayHash
51524
+ });
51525
+ }
51526
+ }
51527
+ let currentDoc;
51528
+ try {
51529
+ currentDoc = await this.documentView.get(documentId);
51530
+ } catch {
51531
+ return {
51532
+ documentId,
51533
+ isConsistent: keyframeIssues.length === 0,
51534
+ keyframeIssues,
51535
+ snapshotIssues
51536
+ };
51537
+ }
51538
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51539
+ const allScopes = Object.keys(revisions.revision);
51540
+ for (const scope of allScopes) {
51541
+ if (scope === "document")
51542
+ continue;
51543
+ replayCache.invalidate(documentId, scope, branch);
51544
+ let replayedDoc;
51545
+ try {
51546
+ replayedDoc = await replayCache.getState(documentId, scope, branch, undefined, signal);
51547
+ } catch {
51548
+ if (signal?.aborted) {
51549
+ throw new Error("Operation aborted");
51550
+ }
51551
+ continue;
51552
+ }
51553
+ const snapshotHash = hashDocumentStateForScope(currentDoc, scope);
51554
+ const replayHash = hashDocumentStateForScope(replayedDoc, scope);
51555
+ if (snapshotHash !== replayHash) {
51556
+ snapshotIssues.push({
51557
+ scope,
51558
+ branch,
51559
+ snapshotHash,
51560
+ replayedHash: replayHash
51561
+ });
51562
+ }
51563
+ }
51564
+ return {
51565
+ documentId,
51566
+ isConsistent: keyframeIssues.length === 0 && snapshotIssues.length === 0,
51567
+ keyframeIssues,
51568
+ snapshotIssues
51569
+ };
51570
+ }
51571
+ async rebuildKeyframes(documentId, branch = "main", signal) {
51572
+ const deleted = await this.keyframeStore.deleteKeyframes(documentId, undefined, branch, signal);
51573
+ return {
51574
+ documentId,
51575
+ keyframesDeleted: deleted,
51576
+ scopesInvalidated: 0
51577
+ };
51578
+ }
51579
+ async rebuildSnapshots(documentId, branch = "main", signal) {
51580
+ const scopes = await this.discoverScopes(documentId, branch, signal);
51581
+ for (const scope of scopes) {
51582
+ if (signal?.aborted) {
51583
+ throw new Error("Operation aborted");
51584
+ }
51585
+ this.writeCache.invalidate(documentId, scope, branch);
51586
+ }
51587
+ return {
51588
+ documentId,
51589
+ keyframesDeleted: 0,
51590
+ scopesInvalidated: scopes.length
51591
+ };
51592
+ }
51593
+ async discoverScopes(documentId, branch, signal) {
51594
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51595
+ return Object.keys(revisions.revision);
51596
+ }
51597
+ }
51461
51598
  var __defProp2, __export2 = (target, all) => {
51462
51599
  for (var name in all)
51463
51600
  __defProp2(target, name, {
@@ -51600,7 +51737,7 @@ var __defProp2, __export2 = (target, all) => {
51600
51737
  }
51601
51738
  }
51602
51739
  return maxOrdinal;
51603
- }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor;
51740
+ }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor, nullKeyframeStore;
51604
51741
  var init_src = __esm(() => {
51605
51742
  __defProp2 = Object.defineProperty;
51606
51743
  byteToHex = [];
@@ -56860,6 +56997,12 @@ var init_src = __esm(() => {
56860
56997
  return relationalDbToQueryBuilder(this.relationalDb);
56861
56998
  }
56862
56999
  };
57000
+ nullKeyframeStore = {
57001
+ putKeyframe: () => Promise.resolve(),
57002
+ findNearestKeyframe: () => Promise.resolve(undefined),
57003
+ listKeyframes: () => Promise.resolve([]),
57004
+ deleteKeyframes: () => Promise.resolve(0)
57005
+ };
56863
57006
  });
56864
57007
 
56865
57008
  // ../../packages/reactor-browser/dist/src/index.js
@@ -57074,6 +57217,7 @@ __export(exports_src, {
57074
57217
  InMemoryQueue: () => InMemoryQueue,
57075
57218
  ISSUER_TYPE: () => ISSUER_TYPE,
57076
57219
  GqlRequestChannel: () => GqlRequestChannel,
57220
+ DocumentIntegrityService: () => DocumentIntegrityService,
57077
57221
  DocumentChangeType: () => DocumentChangeType,
57078
57222
  DocumentCache: () => DocumentCache,
57079
57223
  DisconnectIcon: () => DisconnectIcon,
@@ -93467,7 +93611,7 @@ var init_package = __esm(() => {
93467
93611
  package_default = {
93468
93612
  name: "@powerhousedao/connect",
93469
93613
  productName: "Powerhouse-Connect",
93470
- version: "6.0.0-dev.87",
93614
+ version: "6.0.0-dev.88",
93471
93615
  description: "Powerhouse Connect",
93472
93616
  main: "dist/index.html",
93473
93617
  type: "module",
@@ -37279,6 +37279,7 @@ import { isUndoRedo } from "document-model/core";
37279
37279
  import { deriveOperationId as deriveOperationId2 } from "document-model/core";
37280
37280
  import { ConsoleLogger } from "document-model/core";
37281
37281
  import { AbortError } from "document-drive/utils/errors";
37282
+ import { hashDocumentStateForScope } from "document-model/core";
37282
37283
  function createDocumentAction(input) {
37283
37284
  return {
37284
37285
  id: generateId(),
@@ -44573,6 +44574,10 @@ class RingBuffer {
44573
44574
  return this.size;
44574
44575
  }
44575
44576
  }
44577
+ function extractModuleVersion(doc) {
44578
+ const v2 = doc.state.document.version;
44579
+ return v2 === 0 ? undefined : v2;
44580
+ }
44576
44581
 
44577
44582
  class KyselyWriteCache {
44578
44583
  streams;
@@ -44737,7 +44742,7 @@ class KyselyWriteCache {
44737
44742
  throw new Error(`Failed to rebuild document ${documentId}: CREATE_DOCUMENT action missing model in input`);
44738
44743
  }
44739
44744
  document2 = createDocumentFromAction(documentCreateAction);
44740
- const docModule = this.registry.getModule(documentType);
44745
+ let docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44741
44746
  const docScopeOps = await this.operationStore.getSince(documentId, "document", branch, 0, undefined, undefined, signal);
44742
44747
  for (const operation of docScopeOps.results) {
44743
44748
  if (operation.index === 0) {
@@ -44746,6 +44751,7 @@ class KyselyWriteCache {
44746
44751
  if (operation.action.type === "UPGRADE_DOCUMENT") {
44747
44752
  const upgradeAction = operation.action;
44748
44753
  document2 = applyUpgradeDocumentAction(document2, upgradeAction);
44754
+ docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44749
44755
  } else if (operation.action.type === "DELETE_DOCUMENT") {
44750
44756
  applyDeleteDocumentAction(document2, operation.action);
44751
44757
  } else {
@@ -44757,7 +44763,7 @@ class KyselyWriteCache {
44757
44763
  }
44758
44764
  }
44759
44765
  }
44760
- const module = this.registry.getModule(documentType);
44766
+ const module = this.registry.getModule(documentType, extractModuleVersion(document2));
44761
44767
  let cursor = undefined;
44762
44768
  const pageSize = 100;
44763
44769
  let hasMorePages;
@@ -47195,6 +47201,25 @@ class KyselyKeyframeStore {
47195
47201
  document: row.document
47196
47202
  };
47197
47203
  }
47204
+ async listKeyframes(documentId, scope, branch, signal) {
47205
+ if (signal?.aborted) {
47206
+ throw new Error("Operation aborted");
47207
+ }
47208
+ let query = this.queryExecutor.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).orderBy("revision", "asc");
47209
+ if (scope !== undefined) {
47210
+ query = query.where("scope", "=", scope);
47211
+ }
47212
+ if (branch !== undefined) {
47213
+ query = query.where("branch", "=", branch);
47214
+ }
47215
+ const rows = await query.execute();
47216
+ return rows.map((row) => ({
47217
+ scope: row.scope,
47218
+ branch: row.branch,
47219
+ revision: row.revision,
47220
+ document: row.document
47221
+ }));
47222
+ }
47198
47223
  async deleteKeyframes(documentId, scope, branch, signal) {
47199
47224
  if (signal?.aborted) {
47200
47225
  throw new Error("Operation aborted");
@@ -51458,6 +51483,118 @@ function relationalDbToQueryBuilder(query) {
51458
51483
  withSchema: (schema) => relationalDbToQueryBuilder(query.withSchema(schema))
51459
51484
  };
51460
51485
  }
51486
+
51487
+ class DocumentIntegrityService {
51488
+ keyframeStore;
51489
+ operationStore;
51490
+ writeCache;
51491
+ documentView;
51492
+ documentModelRegistry;
51493
+ constructor(keyframeStore, operationStore, writeCache, documentView, documentModelRegistry) {
51494
+ this.keyframeStore = keyframeStore;
51495
+ this.operationStore = operationStore;
51496
+ this.writeCache = writeCache;
51497
+ this.documentView = documentView;
51498
+ this.documentModelRegistry = documentModelRegistry;
51499
+ }
51500
+ async validateDocument(documentId, branch = "main", signal) {
51501
+ const keyframeIssues = [];
51502
+ const snapshotIssues = [];
51503
+ const replayCache = new KyselyWriteCache(nullKeyframeStore, this.operationStore, this.documentModelRegistry, {
51504
+ maxDocuments: 1,
51505
+ ringBufferSize: 1,
51506
+ keyframeInterval: Number.MAX_SAFE_INTEGER
51507
+ });
51508
+ const keyframes = await this.keyframeStore.listKeyframes(documentId, undefined, branch, signal);
51509
+ for (const keyframe of keyframes) {
51510
+ if (signal?.aborted) {
51511
+ throw new Error("Operation aborted");
51512
+ }
51513
+ replayCache.invalidate(documentId, keyframe.scope, branch);
51514
+ const replayedDoc = await replayCache.getState(documentId, keyframe.scope, branch, keyframe.revision, signal);
51515
+ const kfHash = hashDocumentStateForScope(keyframe.document, keyframe.scope);
51516
+ const replayHash = hashDocumentStateForScope(replayedDoc, keyframe.scope);
51517
+ if (kfHash !== replayHash) {
51518
+ keyframeIssues.push({
51519
+ scope: keyframe.scope,
51520
+ branch,
51521
+ revision: keyframe.revision,
51522
+ keyframeHash: kfHash,
51523
+ replayedHash: replayHash
51524
+ });
51525
+ }
51526
+ }
51527
+ let currentDoc;
51528
+ try {
51529
+ currentDoc = await this.documentView.get(documentId);
51530
+ } catch {
51531
+ return {
51532
+ documentId,
51533
+ isConsistent: keyframeIssues.length === 0,
51534
+ keyframeIssues,
51535
+ snapshotIssues
51536
+ };
51537
+ }
51538
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51539
+ const allScopes = Object.keys(revisions.revision);
51540
+ for (const scope of allScopes) {
51541
+ if (scope === "document")
51542
+ continue;
51543
+ replayCache.invalidate(documentId, scope, branch);
51544
+ let replayedDoc;
51545
+ try {
51546
+ replayedDoc = await replayCache.getState(documentId, scope, branch, undefined, signal);
51547
+ } catch {
51548
+ if (signal?.aborted) {
51549
+ throw new Error("Operation aborted");
51550
+ }
51551
+ continue;
51552
+ }
51553
+ const snapshotHash = hashDocumentStateForScope(currentDoc, scope);
51554
+ const replayHash = hashDocumentStateForScope(replayedDoc, scope);
51555
+ if (snapshotHash !== replayHash) {
51556
+ snapshotIssues.push({
51557
+ scope,
51558
+ branch,
51559
+ snapshotHash,
51560
+ replayedHash: replayHash
51561
+ });
51562
+ }
51563
+ }
51564
+ return {
51565
+ documentId,
51566
+ isConsistent: keyframeIssues.length === 0 && snapshotIssues.length === 0,
51567
+ keyframeIssues,
51568
+ snapshotIssues
51569
+ };
51570
+ }
51571
+ async rebuildKeyframes(documentId, branch = "main", signal) {
51572
+ const deleted = await this.keyframeStore.deleteKeyframes(documentId, undefined, branch, signal);
51573
+ return {
51574
+ documentId,
51575
+ keyframesDeleted: deleted,
51576
+ scopesInvalidated: 0
51577
+ };
51578
+ }
51579
+ async rebuildSnapshots(documentId, branch = "main", signal) {
51580
+ const scopes = await this.discoverScopes(documentId, branch, signal);
51581
+ for (const scope of scopes) {
51582
+ if (signal?.aborted) {
51583
+ throw new Error("Operation aborted");
51584
+ }
51585
+ this.writeCache.invalidate(documentId, scope, branch);
51586
+ }
51587
+ return {
51588
+ documentId,
51589
+ keyframesDeleted: 0,
51590
+ scopesInvalidated: scopes.length
51591
+ };
51592
+ }
51593
+ async discoverScopes(documentId, branch, signal) {
51594
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51595
+ return Object.keys(revisions.revision);
51596
+ }
51597
+ }
51461
51598
  var __defProp2, __export2 = (target, all) => {
51462
51599
  for (var name in all)
51463
51600
  __defProp2(target, name, {
@@ -51600,7 +51737,7 @@ var __defProp2, __export2 = (target, all) => {
51600
51737
  }
51601
51738
  }
51602
51739
  return maxOrdinal;
51603
- }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor;
51740
+ }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor, nullKeyframeStore;
51604
51741
  var init_src = __esm(() => {
51605
51742
  __defProp2 = Object.defineProperty;
51606
51743
  byteToHex = [];
@@ -56860,6 +56997,12 @@ var init_src = __esm(() => {
56860
56997
  return relationalDbToQueryBuilder(this.relationalDb);
56861
56998
  }
56862
56999
  };
57000
+ nullKeyframeStore = {
57001
+ putKeyframe: () => Promise.resolve(),
57002
+ findNearestKeyframe: () => Promise.resolve(undefined),
57003
+ listKeyframes: () => Promise.resolve([]),
57004
+ deleteKeyframes: () => Promise.resolve(0)
57005
+ };
56863
57006
  });
56864
57007
 
56865
57008
  // ../../packages/reactor-browser/dist/src/index.js
@@ -57074,6 +57217,7 @@ __export(exports_src, {
57074
57217
  InMemoryQueue: () => InMemoryQueue,
57075
57218
  ISSUER_TYPE: () => ISSUER_TYPE,
57076
57219
  GqlRequestChannel: () => GqlRequestChannel,
57220
+ DocumentIntegrityService: () => DocumentIntegrityService,
57077
57221
  DocumentChangeType: () => DocumentChangeType,
57078
57222
  DocumentCache: () => DocumentCache,
57079
57223
  DisconnectIcon: () => DisconnectIcon,
@@ -93467,7 +93611,7 @@ var init_package = __esm(() => {
93467
93611
  package_default = {
93468
93612
  name: "@powerhousedao/connect",
93469
93613
  productName: "Powerhouse-Connect",
93470
- version: "6.0.0-dev.87",
93614
+ version: "6.0.0-dev.88",
93471
93615
  description: "Powerhouse Connect",
93472
93616
  main: "dist/index.html",
93473
93617
  type: "module",