@seedprotocol/sdk 0.7.4 → 0.7.5-next.871.g8788c94

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.
Files changed (135) hide show
  1. package/README.md +99 -0
  2. package/dist/{BasePathResolver-DrzGVH9L.js → BasePathResolver-B-fK7_N_.js} +142 -8
  3. package/dist/BasePathResolver-B-fK7_N_.js.map +1 -0
  4. package/dist/{ClientManager-Dfu4jcgm.js → ClientManager-C7VkO5Hg.js} +342 -206
  5. package/dist/ClientManager-C7VkO5Hg.js.map +1 -0
  6. package/dist/{Item-BUUFuywT.js → Item-BDmsdNTQ.js} +234 -163
  7. package/dist/Item-BDmsdNTQ.js.map +1 -0
  8. package/dist/{ModelProperty-B6cnRvIz.js → ModelProperty-Cqw6yn7y.js} +37 -37
  9. package/dist/{ModelProperty-B6cnRvIz.js.map → ModelProperty-Cqw6yn7y.js.map} +1 -1
  10. package/dist/{Schema-Bf-jOLq0.js → Schema-BJLYOUgp.js} +57 -37
  11. package/dist/Schema-BJLYOUgp.js.map +1 -0
  12. package/dist/{SchemaValidationService-BNYMacsx.js → SchemaValidationService-CzybXLiS.js} +6 -6
  13. package/dist/{SchemaValidationService-BNYMacsx.js.map → SchemaValidationService-CzybXLiS.js.map} +1 -1
  14. package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js → backfillMetadataPropertyIds-DAsETfD_.js} +3 -3
  15. package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js.map → backfillMetadataPropertyIds-DAsETfD_.js.map} +1 -1
  16. package/dist/{configurePlatform-BzfirKuM.js → configurePlatform-CFQF_i1T.js} +2 -2
  17. package/dist/{configurePlatform-BzfirKuM.js.map → configurePlatform-CFQF_i1T.js.map} +1 -1
  18. package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js → detachRowsBeforeDelete-D4gxxk46.js} +2 -2
  19. package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js.map → detachRowsBeforeDelete-D4gxxk46.js.map} +1 -1
  20. package/dist/discardNewDraft-g8w3uHFM.js +78 -0
  21. package/dist/discardNewDraft-g8w3uHFM.js.map +1 -0
  22. package/dist/{eas-Dq5Kx_Nd.js → eas-BcXZ2hIn.js} +25 -12
  23. package/dist/eas-BcXZ2hIn.js.map +1 -0
  24. package/dist/{errors-DdWbxb_n.js → errors-CCMxedOB.js} +43 -38
  25. package/dist/errors-CCMxedOB.js.map +1 -0
  26. package/dist/{getItem-9bYSErSj.js → getItem-BUs1Xa48.js} +4 -4
  27. package/dist/{getItem-9bYSErSj.js.map → getItem-BUs1Xa48.js.map} +1 -1
  28. package/dist/{getPublishPayload-DPy-uMrR.js → getPublishPayload-CwNOhnir.js} +25 -15
  29. package/dist/getPublishPayload-CwNOhnir.js.map +1 -0
  30. package/dist/{getPublishUploads-J-143iSV.js → getPublishUploads-pEOrXJbF.js} +506 -45
  31. package/dist/getPublishUploads-pEOrXJbF.js.map +1 -0
  32. package/dist/{index-7y2f_iQz.js → index-BQSK-r_A.js} +2 -2
  33. package/dist/index-BQSK-r_A.js.map +1 -0
  34. package/dist/{index-C61Rxy0F.js → index-zAs84LDi.js} +8 -8
  35. package/dist/index-zAs84LDi.js.map +1 -0
  36. package/dist/{index.browser-C1pisOEa.js → index.browser-irwaBIj0.js} +11 -11
  37. package/dist/{index.browser-C1pisOEa.js.map → index.browser-irwaBIj0.js.map} +1 -1
  38. package/dist/{index.node-BAlST8pD.js → index.node-BYkndQN7.js} +6 -6
  39. package/dist/{index.node-BAlST8pD.js.map → index.node-BYkndQN7.js.map} +1 -1
  40. package/dist/main.js +91 -504
  41. package/dist/main.js.map +1 -1
  42. package/dist/{mimeTypes-DHAHC4eZ.js → mimeTypes-C9r76DCH.js} +7 -2
  43. package/dist/{mimeTypes-DHAHC4eZ.js.map → mimeTypes-C9r76DCH.js.map} +1 -1
  44. package/dist/node.js +10 -10
  45. package/dist/platform.browser.js +6 -6
  46. package/dist/platform.node.js +4 -4
  47. package/dist/{property-zFPMtR3T.js → property-5AD2naVS.js} +7 -7
  48. package/dist/{property-zFPMtR3T.js.map → property-5AD2naVS.js.map} +1 -1
  49. package/dist/{propertyValidationRules-CeFVhdQg.js → propertyValidationRules-Bdgz0Nrr.js} +10 -10
  50. package/dist/{propertyValidationRules-CeFVhdQg.js.map → propertyValidationRules-Bdgz0Nrr.js.map} +1 -1
  51. package/dist/{publishDraftGraph-CuVq6iAR.js → publishDraftGraph-DGhC9ifI.js} +6 -6
  52. package/dist/{publishDraftGraph-CuVq6iAR.js.map → publishDraftGraph-DGhC9ifI.js.map} +1 -1
  53. package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js → resetAmbiguousLegacyItemData-HSB77N9c.js} +2 -2
  54. package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js.map → resetAmbiguousLegacyItemData-HSB77N9c.js.map} +1 -1
  55. package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js → resolveModelForSyncedSeed-CAKAJgr6.js} +2 -2
  56. package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js.map → resolveModelForSyncedSeed-CAKAJgr6.js.map} +1 -1
  57. package/dist/src/Item/Item.d.ts +4 -1
  58. package/dist/src/Item/Item.d.ts.map +1 -1
  59. package/dist/src/Item/errors.d.ts +3 -1
  60. package/dist/src/Item/errors.d.ts.map +1 -1
  61. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  62. package/dist/src/Model/Model.d.ts +2 -1
  63. package/dist/src/Model/Model.d.ts.map +1 -1
  64. package/dist/src/Schema/Schema.d.ts.map +1 -1
  65. package/dist/src/Schema/service/schemaMachine.d.ts +3 -0
  66. package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
  67. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  68. package/dist/src/db/alignRowPublishers.d.ts +25 -0
  69. package/dist/src/db/alignRowPublishers.d.ts.map +1 -0
  70. package/dist/src/db/canonicalizeModelTypes.d.ts +2 -2
  71. package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -1
  72. package/dist/src/db/read/getModelSchemas.d.ts +3 -2
  73. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  74. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  75. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  76. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  77. package/dist/src/db/read/getSeedPublisher.d.ts +7 -0
  78. package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -0
  79. package/dist/src/db/read/nameMatchLevels.d.ts +64 -0
  80. package/dist/src/db/read/nameMatchLevels.d.ts.map +1 -0
  81. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  82. package/dist/src/db/read/summarizePublishWork.d.ts +2 -0
  83. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  84. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +5 -3
  85. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
  86. package/dist/src/db/write/claimUnpublishedDrafts.d.ts +4 -2
  87. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
  88. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  89. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  90. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  91. package/dist/src/db/write/createVersion.d.ts.map +1 -1
  92. package/dist/src/db/write/discardNewDraft.d.ts +8 -0
  93. package/dist/src/db/write/discardNewDraft.d.ts.map +1 -0
  94. package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts +18 -0
  95. package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -0
  96. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  97. package/dist/src/eas.d.ts.map +1 -1
  98. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  99. package/dist/src/helpers/constants.d.ts.map +1 -1
  100. package/dist/src/helpers/db.d.ts.map +1 -1
  101. package/dist/src/helpers/easValueTypes.d.ts +16 -0
  102. package/dist/src/helpers/easValueTypes.d.ts.map +1 -0
  103. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +13 -2
  104. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
  105. package/dist/src/helpers/ownership.d.ts +9 -12
  106. package/dist/src/helpers/ownership.d.ts.map +1 -1
  107. package/dist/src/helpers/publishConfig.d.ts +9 -4
  108. package/dist/src/helpers/publishConfig.d.ts.map +1 -1
  109. package/dist/src/imports/index.d.ts +1 -1
  110. package/dist/src/imports/index.d.ts.map +1 -1
  111. package/dist/src/imports/json.d.ts.map +1 -1
  112. package/dist/src/index.d.ts +2 -1
  113. package/dist/src/index.d.ts.map +1 -1
  114. package/dist/src/types/import.d.ts +20 -0
  115. package/dist/src/types/import.d.ts.map +1 -1
  116. package/dist/{syncDbWithEas-CRpnkq00.js → syncDbWithEas-BmJXqfgN.js} +92 -22
  117. package/dist/syncDbWithEas-BmJXqfgN.js.map +1 -0
  118. package/dist/{tabEvents-nBUq_1u1.js → tabEvents-DXun7vdK.js} +4 -4
  119. package/dist/{tabEvents-nBUq_1u1.js.map → tabEvents-DXun7vdK.js.map} +1 -1
  120. package/dist/{tolerantWebAccess-DIt3R8_u.js → tolerantWebAccess-DXxgX2x7.js} +7 -7
  121. package/dist/{tolerantWebAccess-DIt3R8_u.js.map → tolerantWebAccess-DXxgX2x7.js.map} +1 -1
  122. package/dist/{updateSeedRevokedAt-DtTPSzpM.js → updateSeedRevokedAt-DkLSDwUX.js} +3 -3
  123. package/dist/{updateSeedRevokedAt-DtTPSzpM.js.map → updateSeedRevokedAt-DkLSDwUX.js.map} +1 -1
  124. package/package.json +9 -5
  125. package/dist/BasePathResolver-DrzGVH9L.js.map +0 -1
  126. package/dist/ClientManager-Dfu4jcgm.js.map +0 -1
  127. package/dist/Item-BUUFuywT.js.map +0 -1
  128. package/dist/Schema-Bf-jOLq0.js.map +0 -1
  129. package/dist/eas-Dq5Kx_Nd.js.map +0 -1
  130. package/dist/errors-DdWbxb_n.js.map +0 -1
  131. package/dist/getPublishPayload-DPy-uMrR.js.map +0 -1
  132. package/dist/getPublishUploads-J-143iSV.js.map +0 -1
  133. package/dist/index-7y2f_iQz.js.map +0 -1
  134. package/dist/index-C61Rxy0F.js.map +0 -1
  135. package/dist/syncDbWithEas-CRpnkq00.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  import { startCase, isEqual } from 'lodash-es';
2
- import { E as BaseDb, l as easSyncProcesses, H as eventEmitter, ab as isNode, ak as isBrowser, I as BasePathResolver, aD as normalizeAddressConfig, h as appState, aO as downloadAllFilesRequestHandler, aP as downloadAllFilesBinaryRequestHandler, J as BaseFileManager, s as models$1, r as modelUids, A as seeds, aE as normalizeAddressList, z as schemas, aN as loadModelsFromDbForSchema, aL as addSchemaToDb, aI as isInternalSchema, aQ as INTERNAL_SCHEMA_IDS, $ as generateId, aR as linkModelToSchema, n as normalizeDataType, a2 as easPropertyNameForPublish, at as SEED_PROTOCOL_SCHEMA_NAME, q as modelSchemas, m as metadata$1, u as properties, L as resolveItemModelFileId, C as versions, o as htmlEmbeddedImageCoPublish, j as arweaveL1FinalizeJobs, y as publishProcesses, X as normalizePublisher, aS as getWatchedAddressesFromDb, aT as getOwnedAddressesFromDb, aU as CLIENT_NOT_INITIALIZED } from './BasePathResolver-DrzGVH9L.js';
2
+ import { B as BaseDb, o as easSyncProcesses, I as eventEmitter, a4 as isNode, af as isBrowser, K as BasePathResolver, aF as normalizeAddressConfig, j as appState, aS as downloadAllFilesRequestHandler, aT as downloadAllFilesBinaryRequestHandler, h as BaseFileManager, t as models$1, s as modelUids, C as seeds, aG as normalizeAddressList, A as schemas, aQ as loadModelsFromDbForSchema, aN as addSchemaToDb, aK as isInternalSchema, aU as warnOnInvalidNameMatch, aV as INTERNAL_SCHEMA_IDS, al as generateId, aW as linkModelToSchema, aR as clearNameMatchLevels, n as normalizeDataType, ae as easPropertyNameForPublish, av as SEED_PROTOCOL_SCHEMA_NAME, r as modelSchemas, m as metadata$1, v as properties, N as resolveItemModelFileId, F as versions, ah as normalizePublisher, aj as loadNameMatchLevels, p as htmlEmbeddedImageCoPublish, k as arweaveL1FinalizeJobs, z as publishProcesses, aX as getWatchedAddressesFromDb, aY as getOwnedAddressesFromDb, aZ as CLIENT_NOT_INITIALIZED } from './BasePathResolver-B-fK7_N_.js';
3
3
  import debug from 'debug';
4
4
  import { createActor, setup, assign, fromPromise, fromCallback, waitFor } from 'xstate';
5
- import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, c as compareMetadataRowsLatestFirst, w as writeInBatches, C as ClientManagerState, a4 as resolvePublisherFromSeedRow, G as isLocalUnsealedDraft, I as Item } from './Item-BUUFuywT.js';
5
+ import { u as MachineIds, a0 as ClientManagerEvents, a1 as withLockedItemStorageRow, a2 as getItemStorageFilePath, a3 as writeItemStorageFile, e as compareMetadataRowsLatestFirst, w as writeInBatches, a4 as resolvePublisherFromSeedRow, C as ClientManagerState, G as isLocalUnsealedDraft, s as selectInBatches, I as Item } from './Item-BDmsdNTQ.js';
6
6
  import { eq, inArray, and, isNotNull, ne, desc, countDistinct, isNull, or, sql, like } from 'drizzle-orm';
7
- import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-nBUq_1u1.js';
7
+ import { a as withDbTabLock, i as isLeaderTab, c as postTabMessage, o as onTabMessage, w as whenLeaderTab, l as listenForOtherTabsEvents, s as startTabCoordination, b as withSeedDbLock, e as emitAcrossTabs, A as ADDRESSES_PERSISTED_EVENT, p as parseAddressesPersistedPayload, L as LOCAL_COPIES_REMOVED_EVENT } from './tabEvents-DXun7vdK.js';
8
8
  import { seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, BaseArweaveClient, ensureReadGatewaySelected, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
9
- import { configureEasReadChain, easName, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, localNamesInBestMatchTier, isValidEasAttestationUid } from '@seedprotocol/eas';
9
+ import { configureEasReadChain, easName, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, isPlaceholderUid, localNamesInBestMatchTier, isValidEasAttestationUid } from '@seedprotocol/eas';
10
10
  import 'pluralize';
11
11
  import { sha3_256 } from '@noble/hashes/sha3';
12
12
  import { utf8ToBytes, bytesToHex } from '@noble/hashes/utils';
@@ -212,7 +212,7 @@ function toRunSyncArg(options) {
212
212
  return undefined;
213
213
  }
214
214
  const runEasSync = fromPromise(async ({ input, }) => {
215
- const { runSyncFromEas } = await import('./syncDbWithEas-CRpnkq00.js');
215
+ const { runSyncFromEas } = await import('./syncDbWithEas-BmJXqfgN.js');
216
216
  // Sync checks for rows and then inserts the rest (no unique index on uids), so syncs in
217
217
  // different tabs take turns. A sync can run for minutes, so wait without a timeout.
218
218
  await withDbTabLock('eas-sync', async () => {
@@ -422,7 +422,7 @@ function newCorrelationId() {
422
422
  return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
423
423
  }
424
424
  /** Requests deferred in this tab until it leads, by source; each runs once on takeover. */
425
- const deferredUntilLeader$3 = new Set();
425
+ const deferredUntilLeader$4 = new Set();
426
426
  /**
427
427
  * Automatic syncs run in the leader tab only (docs/MULTI_TAB.md). A tab that skips one runs it if
428
428
  * it later becomes leader, so closing the leader doesn't lose the catch-up sync.
@@ -433,11 +433,11 @@ function runInLeaderTab(source, request) {
433
433
  return;
434
434
  }
435
435
  log(`${source} sync skipped: another tab leads`);
436
- if (deferredUntilLeader$3.has(source))
436
+ if (deferredUntilLeader$4.has(source))
437
437
  return;
438
- deferredUntilLeader$3.add(source);
438
+ deferredUntilLeader$4.add(source);
439
439
  void whenLeaderTab().then(() => {
440
- deferredUntilLeader$3.delete(source);
440
+ deferredUntilLeader$4.delete(source);
441
441
  request();
442
442
  });
443
443
  }
@@ -511,10 +511,10 @@ var easSyncManager = /*#__PURE__*/Object.freeze({
511
511
  startEasSyncActor: startEasSyncActor
512
512
  });
513
513
 
514
- const logger$e = debug('seedSdk:services:events');
514
+ const logger$f = debug('seedSdk:services:events');
515
515
  const handleServiceSaveState = (event) => {
516
516
  const { state, serviceId } = event;
517
- logger$e(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
517
+ logger$f(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
518
518
  // TODO: This is called from Node as well. Do we need it? If so, need to generalize this to all platforms.
519
519
  // localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state))
520
520
  };
@@ -565,7 +565,7 @@ function normalizeSeedConfigEndpoints(config) {
565
565
  return { ...config, endpoints: next };
566
566
  }
567
567
 
568
- const logger$d = debug('seedSdk:ClientManager:initialize');
568
+ const logger$e = debug('seedSdk:ClientManager:initialize');
569
569
  /**
570
570
  * Whether a relative filesDir already names the .seed directory or a path inside
571
571
  * it ('.seed', '.seed/files', './.seed/files'). '.seed-alt/x' is not: it is
@@ -576,7 +576,7 @@ function isUnderDotSeed(relativePath) {
576
576
  return firstSegment === '.seed';
577
577
  }
578
578
  const platformClassesInit = fromCallback(({ sendBack, input: { context, event } }) => {
579
- logger$d('initialize from ClientManager');
579
+ logger$e('initialize from ClientManager');
580
580
  const { isInitialized } = context;
581
581
  if (!event || !('options' in event)) {
582
582
  throw new Error('Initialize event must include options');
@@ -609,7 +609,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
609
609
  }
610
610
  // Prefer the condition-resolved factory when available; fall back to explicit
611
611
  // platform imports so source/vitest resolution stays reliable.
612
- const { configurePlatform } = await import('./configurePlatform-BzfirKuM.js');
612
+ const { configurePlatform } = await import('./configurePlatform-CFQF_i1T.js');
613
613
  if (isBrowser()) {
614
614
  const { createPlatformServices } = await import('./platform.browser.js');
615
615
  configurePlatform(createPlatformServices());
@@ -749,7 +749,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
749
749
  };
750
750
  });
751
751
 
752
- const logger$c = debug('seedSdk:client:writeToDb');
752
+ const logger$d = debug('seedSdk:client:writeToDb');
753
753
  const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
754
754
  const _saveAppState = async () => {
755
755
  try {
@@ -757,7 +757,7 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
757
757
  if (!appDb) {
758
758
  // In test environments, continue anyway
759
759
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
760
- logger$c('[client/actors] [saveAppState] App DB not found, but continuing in test environment');
760
+ logger$d('[client/actors] [saveAppState] App DB not found, but continuing in test environment');
761
761
  return;
762
762
  }
763
763
  throw new Error('App DB not found');
@@ -773,13 +773,13 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
773
773
  value: JSON.stringify(value),
774
774
  },
775
775
  });
776
- logger$c('result', result);
776
+ logger$d('result', result);
777
777
  }
778
778
  catch (error) {
779
- logger$c('[client/actors] [saveAppState] Error saving app state:', error);
779
+ logger$d('[client/actors] [saveAppState] Error saving app state:', error);
780
780
  // In test environments, continue anyway
781
781
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
782
- logger$c('[client/actors] [saveAppState] Continuing despite error in test environment');
782
+ logger$d('[client/actors] [saveAppState] Continuing despite error in test environment');
783
783
  return;
784
784
  }
785
785
  throw error;
@@ -794,10 +794,10 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
794
794
  });
795
795
  })
796
796
  .catch((error) => {
797
- logger$c('[client/actors] [saveAppState] Error in promise chain:', error);
797
+ logger$d('[client/actors] [saveAppState] Error in promise chain:', error);
798
798
  // In test environments, still send success to allow state machine to progress
799
799
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
800
- logger$c('[client/actors] [saveAppState] Sending success despite error in test environment');
800
+ logger$d('[client/actors] [saveAppState] Sending success despite error in test environment');
801
801
  sendBack({
802
802
  type: 'saveAppStateSuccess',
803
803
  key,
@@ -867,7 +867,7 @@ const fileSystemInit = fromCallback(({ sendBack, input: { context }, }) => {
867
867
  };
868
868
  });
869
869
 
870
- const logger$b = debug('seedSdk:client:actors:dbInit');
870
+ const logger$c = debug('seedSdk:client:actors:dbInit');
871
871
  const dbInit = fromCallback(({ sendBack, input: { context } }) => {
872
872
  const _dbInit = async () => {
873
873
  const { filesDir, dbConfig } = context;
@@ -881,14 +881,14 @@ const dbInit = fromCallback(({ sendBack, input: { context } }) => {
881
881
  if (!appDb) {
882
882
  throw new Error('Database not available after preparation');
883
883
  }
884
- logger$b('[client/actors] [dbInit] Database prepared and ready');
884
+ logger$c('[client/actors] [dbInit] Database prepared and ready');
885
885
  };
886
886
  _dbInit()
887
887
  .then(() => {
888
888
  sendBack({ type: ClientManagerEvents.DB_READY });
889
889
  })
890
890
  .catch((error) => {
891
- logger$b('Error in dbInit:', error);
891
+ logger$c('Error in dbInit:', error);
892
892
  sendBack({
893
893
  type: 'error',
894
894
  error: error instanceof Error ? error : new Error(String(error))
@@ -896,7 +896,7 @@ const dbInit = fromCallback(({ sendBack, input: { context } }) => {
896
896
  });
897
897
  });
898
898
 
899
- const logger$a = debug('seedSdk:client:actors:addModelsToStore');
899
+ const logger$b = debug('seedSdk:client:actors:addModelsToStore');
900
900
  const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
901
901
  const _addModelsToStore = async () => {
902
902
  let { models } = context;
@@ -910,7 +910,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
910
910
  // Models are now Model instances, no registration needed
911
911
  // They should be created via Model.create() and are accessible via Model static methods
912
912
  for (const [key] of Object.entries(allModels)) {
913
- logger$a('model available:', key);
913
+ logger$b('model available:', key);
914
914
  }
915
915
  };
916
916
  _addModelsToStore()
@@ -918,7 +918,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
918
918
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_STORE_SUCCESS });
919
919
  })
920
920
  .catch((error) => {
921
- logger$a('[client/actors] [addModelsToStore] Error:', error);
921
+ logger$b('[client/actors] [addModelsToStore] Error:', error);
922
922
  sendBack({
923
923
  type: 'error',
924
924
  error: error instanceof Error ? error : new Error(String(error)),
@@ -926,7 +926,7 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
926
926
  });
927
927
  });
928
928
 
929
- const logger$9 = debug('seedSdk:client:actors:addModelsToDb');
929
+ const logger$a = debug('seedSdk:client:actors:addModelsToDb');
930
930
  /**
931
931
  * Returns every `models` row named in `modelNames`, inserting a null-schemaFileId stub for each name
932
932
  * with no row yet (the schema import adopts stubs via findOrCreateModelRecord). Check-then-insert:
@@ -949,7 +949,7 @@ async function ensureModelStubs(appDb, modelNames, filesDir) {
949
949
  .returning({ id: models$1.id, name: models$1.name, schemaFileId: models$1.schemaFileId }));
950
950
  rows.push(...newlyInserted);
951
951
  for (const name of modelsToInsert) {
952
- logger$9('[client/actors] [addModelsToDb] inserted model:', name);
952
+ logger$a('[client/actors] [addModelsToDb] inserted model:', name);
953
953
  }
954
954
  }
955
955
  return rows;
@@ -989,7 +989,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
989
989
  for (const modelName of modelNames) {
990
990
  const foundModel = rowFor(modelName);
991
991
  if (!foundModel) {
992
- logger$9('[client/actors] [addModelsToDb] Warning: Could not find or create model:', modelName);
992
+ logger$a('[client/actors] [addModelsToDb] Warning: Could not find or create model:', modelName);
993
993
  hasModelsInDb = false;
994
994
  continue;
995
995
  }
@@ -1001,7 +1001,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
1001
1001
  }
1002
1002
  // If we have no models to process, still send success (empty models is valid)
1003
1003
  if (schemaDefsByModelName.size === 0) {
1004
- logger$9('[client/actors] [addModelsToDb] No models to process, but continuing');
1004
+ logger$a('[client/actors] [addModelsToDb] No models to process, but continuing');
1005
1005
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
1006
1006
  return;
1007
1007
  }
@@ -1049,15 +1049,15 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
1049
1049
  requestEasSyncFromModelsInit();
1050
1050
  }
1051
1051
  else {
1052
- logger$9('[client/actors] [addModelsToDb] No schemas found from EAS, but continuing');
1052
+ logger$a('[client/actors] [addModelsToDb] No schemas found from EAS, but continuing');
1053
1053
  }
1054
1054
  }
1055
1055
  catch (error) {
1056
1056
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
1057
- logger$9('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
1057
+ logger$a('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
1058
1058
  }
1059
1059
  else {
1060
- logger$9('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
1060
+ logger$a('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
1061
1061
  }
1062
1062
  // Probably offline: the startup sync waits for this lookup, so try again.
1063
1063
  modelUidsRetry.schedule();
@@ -1073,10 +1073,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
1073
1073
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
1074
1074
  })
1075
1075
  .catch((error) => {
1076
- logger$9('[client/actors] [addModelsToDb] Error:', error);
1076
+ logger$a('[client/actors] [addModelsToDb] Error:', error);
1077
1077
  // In test environments, still send success to allow initialization to complete
1078
1078
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
1079
- logger$9('[client/actors] [addModelsToDb] Continuing despite error in test environment');
1079
+ logger$a('[client/actors] [addModelsToDb] Continuing despite error in test environment');
1080
1080
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
1081
1081
  }
1082
1082
  else {
@@ -1089,7 +1089,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
1089
1089
  return () => { };
1090
1090
  });
1091
1091
 
1092
- const logger$8 = debug('seedSdk:helpers:localDbChain');
1092
+ const logger$9 = debug('seedSdk:helpers:localDbChain');
1093
1093
  /** appState key recording which EAS chain the local database holds attestations from. */
1094
1094
  const EAS_CHAIN_ID_APP_STATE_KEY = 'easChainId';
1095
1095
  /**
@@ -1159,7 +1159,7 @@ async function loadLocalDbChain() {
1159
1159
  const localChainId = await resolveLocalDbChainId(appDb);
1160
1160
  if (localChainId !== undefined) {
1161
1161
  configureEasReadChain('localDb', { chainId: localChainId });
1162
- logger$8('local DB holds chain %d', localChainId);
1162
+ logger$9('local DB holds chain %d', localChainId);
1163
1163
  return;
1164
1164
  }
1165
1165
  if (isEasReadChainConfigured()) {
@@ -1185,7 +1185,7 @@ async function assertLocalDbChain() {
1185
1185
  configureEasReadChain('localDb', { chainId: localChainId ?? chainId });
1186
1186
  }
1187
1187
 
1188
- const logger$7 = debug('seedSdk:client:actors:saveConfig');
1188
+ const logger$8 = debug('seedSdk:client:actors:saveConfig');
1189
1189
  let warnedKeptStoredAddresses = false;
1190
1190
  /**
1191
1191
  * Saves the addresses passed to init.
@@ -1226,13 +1226,13 @@ async function persistInitAddresses(appDb, { addresses, addressesProvided, owned
1226
1226
  emitAcrossTabs(ADDRESSES_PERSISTED_EVENT, { owned, watched });
1227
1227
  }
1228
1228
  const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
1229
- logger$7('saveConfig starting');
1229
+ logger$8('saveConfig starting');
1230
1230
  const { endpoints, addresses, addressesProvided, ownedAddresses, watchedAddresses, arweaveDomain, uploadApiBaseUrl, gatewayTransport, gatewayHyperKey, gatewaySidecarHost, gatewaySidecarPort, gatewayProxyBaseUrl, } = context;
1231
1231
  // Validate endpoints - required for proper initialization
1232
1232
  // If endpoints are missing or invalid, initialization should fail
1233
1233
  if (!endpoints || !endpoints.filePaths || !endpoints.files) {
1234
1234
  const error = new Error('saveConfig called with invalid endpoints: endpoints must include both filePaths and files');
1235
- logger$7('[internal/actors] [saveConfig] Invalid endpoints:', { endpoints });
1235
+ logger$8('[internal/actors] [saveConfig] Invalid endpoints:', { endpoints });
1236
1236
  throw error;
1237
1237
  }
1238
1238
  const _saveConfig = async () => {
@@ -1241,7 +1241,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
1241
1241
  if (!appDb) {
1242
1242
  // In test environments, continue anyway
1243
1243
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
1244
- logger$7('[internal/actors] [saveConfig] App DB not found, but continuing in test environment');
1244
+ logger$8('[internal/actors] [saveConfig] App DB not found, but continuing in test environment');
1245
1245
  return;
1246
1246
  }
1247
1247
  throw new Error('App DB not found');
@@ -1296,10 +1296,10 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
1296
1296
  await loadLocalDbChain();
1297
1297
  }
1298
1298
  catch (error) {
1299
- logger$7('[internal/actors] [saveConfig] Error saving config:', error);
1299
+ logger$8('[internal/actors] [saveConfig] Error saving config:', error);
1300
1300
  // In test environments, continue anyway
1301
1301
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
1302
- logger$7('[internal/actors] [saveConfig] Continuing despite error in test environment');
1302
+ logger$8('[internal/actors] [saveConfig] Continuing despite error in test environment');
1303
1303
  return;
1304
1304
  }
1305
1305
  throw error;
@@ -1308,14 +1308,14 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
1308
1308
  // Init writes run one tab at a time (docs/MULTI_TAB.md).
1309
1309
  withSeedDbLock('init', context.filesDir, _saveConfig)
1310
1310
  .then(() => {
1311
- logger$7('[internal/actors] [saveConfig] saveConfig success');
1311
+ logger$8('[internal/actors] [saveConfig] saveConfig success');
1312
1312
  return sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
1313
1313
  })
1314
1314
  .catch((error) => {
1315
- logger$7('[internal/actors] [saveConfig] Error in saveConfig promise chain:', error);
1315
+ logger$8('[internal/actors] [saveConfig] Error in saveConfig promise chain:', error);
1316
1316
  // In test environments, still send success to allow state machine to progress
1317
1317
  if (process.env.NODE_ENV === 'test' || process.env.IS_SEED_DEV) {
1318
- logger$7('[internal/actors] [saveConfig] Sending success despite error in test environment');
1318
+ logger$8('[internal/actors] [saveConfig] Sending success despite error in test environment');
1319
1319
  sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
1320
1320
  }
1321
1321
  else {
@@ -1328,7 +1328,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
1328
1328
  return () => { };
1329
1329
  });
1330
1330
 
1331
- const logger$6 = debug('seedSdk:helpers:schema');
1331
+ const logger$7 = debug('seedSdk:helpers:schema');
1332
1332
  /**
1333
1333
  * Sanitize a schema name to be filesystem-safe
1334
1334
  * Replaces all special characters (except alphanumeric, hyphens, underscores) with underscores
@@ -1524,7 +1524,7 @@ async function listCompleteSchemaFiles() {
1524
1524
  const dirExists = await BaseFileManager.pathExists(workingDir);
1525
1525
  if (!dirExists) {
1526
1526
  // Directory doesn't exist yet - return empty array (not an error condition)
1527
- logger$6(`Working directory does not exist yet: ${workingDir}, returning empty schema list`);
1527
+ logger$7(`Working directory does not exist yet: ${workingDir}, returning empty schema list`);
1528
1528
  return [];
1529
1529
  }
1530
1530
  const files = await fs.promises.readdir(workingDir);
@@ -1661,7 +1661,7 @@ async function loadAllSchemasFromDb() {
1661
1661
  }
1662
1662
  catch (error) {
1663
1663
  // If we can't list schema files (e.g., directory doesn't exist yet), continue without file-based loading
1664
- logger$6(`Error listing complete schema files (continuing with DB data): ${error instanceof Error ? error.message : String(error)}`);
1664
+ logger$7(`Error listing complete schema files (continuing with DB data): ${error instanceof Error ? error.message : String(error)}`);
1665
1665
  completeSchemaFiles = [];
1666
1666
  }
1667
1667
  }
@@ -1714,7 +1714,7 @@ async function loadAllSchemasFromDb() {
1714
1714
  continue;
1715
1715
  }
1716
1716
  catch (error) {
1717
- logger$6(`Error parsing schemaData for ${schemaName}:`, error);
1717
+ logger$7(`Error parsing schemaData for ${schemaName}:`, error);
1718
1718
  // Fall through to file-based loading
1719
1719
  }
1720
1720
  }
@@ -1756,7 +1756,7 @@ async function loadAllSchemasFromDb() {
1756
1756
  continue;
1757
1757
  }
1758
1758
  catch (error) {
1759
- logger$6(`Error loading schema file for ${schemaName}:`, error);
1759
+ logger$7(`Error loading schema file for ${schemaName}:`, error);
1760
1760
  // Fall through to try loading from schemaData if available
1761
1761
  }
1762
1762
  }
@@ -1800,7 +1800,7 @@ async function loadAllSchemasFromDb() {
1800
1800
  continue;
1801
1801
  }
1802
1802
  catch (error) {
1803
- logger$6(`Error parsing schemaData for ${schemaName}:`, error);
1803
+ logger$7(`Error parsing schemaData for ${schemaName}:`, error);
1804
1804
  }
1805
1805
  }
1806
1806
  }
@@ -1811,11 +1811,11 @@ async function loadAllSchemasFromDb() {
1811
1811
  // Only process if not already in result
1812
1812
  if (!processedSchemaNames.has(schemaFileInfo.name)) {
1813
1813
  if (isInternalSchema(schemaFileInfo.name, schemaFileInfo.schemaFileId)) {
1814
- logger$6(`STEP 3: skipping internal schema file: ${schemaFileInfo.filePath}`);
1814
+ logger$7(`STEP 3: skipping internal schema file: ${schemaFileInfo.filePath}`);
1815
1815
  continue;
1816
1816
  }
1817
1817
  try {
1818
- logger$6(`STEP 3: processing schema file: ${schemaFileInfo.name} from ${schemaFileInfo.filePath}`);
1818
+ logger$7(`STEP 3: processing schema file: ${schemaFileInfo.name} from ${schemaFileInfo.filePath}`);
1819
1819
  const content = await BaseFileManager.readFileAsString(schemaFileInfo.filePath);
1820
1820
  const schemaFile = JSON.parse(content);
1821
1821
  // Import this schema to database (mark as non-draft since it's in a file)
@@ -1835,7 +1835,7 @@ async function loadAllSchemasFromDb() {
1835
1835
  processedSchemaNames.add(schemaFileInfo.name);
1836
1836
  }
1837
1837
  catch (error) {
1838
- logger$6(`Error loading schema file ${schemaFileInfo.filePath}:`, error);
1838
+ logger$7(`Error loading schema file ${schemaFileInfo.filePath}:`, error);
1839
1839
  }
1840
1840
  }
1841
1841
  }
@@ -1852,7 +1852,7 @@ async function migrateFileSchemasToDb() {
1852
1852
  if (!db) {
1853
1853
  throw new Error('Database not found');
1854
1854
  }
1855
- logger$6('Starting migration of file-based schemas to database');
1855
+ logger$7('Starting migration of file-based schemas to database');
1856
1856
  // Get all complete schema files
1857
1857
  const completeSchemas = await listCompleteSchemaFiles();
1858
1858
  let migratedCount = 0;
@@ -1862,7 +1862,7 @@ async function migrateFileSchemasToDb() {
1862
1862
  const content = await BaseFileManager.readFileAsString(schemaFileInfo.filePath);
1863
1863
  const schemaFile = JSON.parse(content);
1864
1864
  if (!schemaFile.$schema || !schemaFile.metadata?.name) {
1865
- logger$6(`Skipping invalid schema file: ${schemaFileInfo.filePath}`);
1865
+ logger$7(`Skipping invalid schema file: ${schemaFileInfo.filePath}`);
1866
1866
  continue;
1867
1867
  }
1868
1868
  const schemaName = schemaFile.metadata.name;
@@ -1884,17 +1884,17 @@ async function migrateFileSchemasToDb() {
1884
1884
  JSON.stringify(schemaFile, null, 2), // schemaData
1885
1885
  false);
1886
1886
  migratedCount++;
1887
- logger$6(`Migrated schema: ${schemaName} v${schemaFile.version}`);
1887
+ logger$7(`Migrated schema: ${schemaName} v${schemaFile.version}`);
1888
1888
  }
1889
1889
  else {
1890
- logger$6(`Schema ${schemaName} already exists in database, skipping`);
1890
+ logger$7(`Schema ${schemaName} already exists in database, skipping`);
1891
1891
  }
1892
1892
  }
1893
1893
  catch (error) {
1894
- logger$6(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
1894
+ logger$7(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
1895
1895
  }
1896
1896
  }
1897
- logger$6(`Migration complete: ${migratedCount} schemas migrated`);
1897
+ logger$7(`Migration complete: ${migratedCount} schemas migrated`);
1898
1898
  return migratedCount;
1899
1899
  }
1900
1900
  /**
@@ -1947,7 +1947,7 @@ const getDeterministicIdsWithPrefix = (prefix) => {
1947
1947
  return (suffix) => bytesToHex(prefixHash.clone().update(utf8ToBytes(suffix)).digest()).slice(0, 10);
1948
1948
  };
1949
1949
 
1950
- const logger$5 = debug('seedSdk:imports:json');
1950
+ const logger$6 = debug('seedSdk:imports:json');
1951
1951
  /**
1952
1952
  * Get refValueType from a property object with case-insensitive key lookup.
1953
1953
  * Handles refValueType, refvaluetype, ref_value_type, elementType, and legacy items.type / items.Type.
@@ -2025,8 +2025,8 @@ function getRefValueType(prop) {
2025
2025
  * @returns Promise that resolves when properties are found, or rejects if not found after max retries
2026
2026
  */
2027
2027
  const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
2028
- const _mod_0 = await import('./BasePathResolver-DrzGVH9L.js');
2029
- const _ns_0 = _mod_0.b6;
2028
+ const _mod_0 = await import('./BasePathResolver-B-fK7_N_.js');
2029
+ const _ns_0 = _mod_0.bb;
2030
2030
  const modelSchemaMod = _ns_0;
2031
2031
  const { properties: propertiesTable } = modelSchemaMod;
2032
2032
  const drizzleMod = await import('drizzle-orm');
@@ -2038,11 +2038,11 @@ const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10
2038
2038
  .where(eq(propertiesTable.modelId, modelId))
2039
2039
  .limit(1);
2040
2040
  if (props.length > 0) {
2041
- logger$5(`Verified properties exist for model "${modelName}" (modelId: ${modelId}) after ${attempt + 1} attempt(s)`);
2041
+ logger$6(`Verified properties exist for model "${modelName}" (modelId: ${modelId}) after ${attempt + 1} attempt(s)`);
2042
2042
  return;
2043
2043
  }
2044
2044
  if (attempt < maxRetries - 1) {
2045
- logger$5(`Properties not yet visible for model "${modelName}" (modelId: ${modelId}), retrying in ${retryDelay}ms (attempt ${attempt + 1}/${maxRetries})`);
2045
+ logger$6(`Properties not yet visible for model "${modelName}" (modelId: ${modelId}), retrying in ${retryDelay}ms (attempt ${attempt + 1}/${maxRetries})`);
2046
2046
  await new Promise(resolve => setTimeout(resolve, retryDelay));
2047
2047
  }
2048
2048
  }
@@ -2137,6 +2137,7 @@ function getSchemaContentForComparison(schema) {
2137
2137
  version: schema.version,
2138
2138
  models: {},
2139
2139
  enums: schema.enums || {},
2140
+ nameMatch: schema.nameMatch,
2140
2141
  };
2141
2142
  for (const modelName of Object.keys(schema.models || {}).sort()) {
2142
2143
  const model = schema.models[modelName];
@@ -2150,10 +2151,12 @@ function getSchemaContentForComparison(schema) {
2150
2151
  refValueType: prop.refValueType ?? items?.type,
2151
2152
  model: prop.model ?? items?.model,
2152
2153
  storage: prop.storage,
2154
+ nameMatch: prop.nameMatch,
2153
2155
  };
2154
2156
  }
2155
2157
  normalized.models[modelName] = {
2156
2158
  description: model.description,
2159
+ nameMatch: model.nameMatch,
2157
2160
  properties: props,
2158
2161
  };
2159
2162
  }
@@ -2215,6 +2218,7 @@ const transformImportToSchemaFile = (importData, version = 1) => {
2215
2218
  $schema: 'https://seedprotocol.org/schemas/data-model/v1',
2216
2219
  version,
2217
2220
  id: schemaId,
2221
+ ...(importData.nameMatch !== undefined && { nameMatch: importData.nameMatch }),
2218
2222
  metadata: {
2219
2223
  name: importData.name,
2220
2224
  createdAt: now,
@@ -2262,6 +2266,7 @@ const parseJsonImportContent = (content) => {
2262
2266
  const models = normalizeSchemaModels(data.models);
2263
2267
  return {
2264
2268
  name: schemaName,
2269
+ ...(data.nameMatch !== undefined && { nameMatch: data.nameMatch }),
2265
2270
  models,
2266
2271
  };
2267
2272
  }
@@ -2388,7 +2393,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2388
2393
  if (parsed.$schema && parsed.metadata) {
2389
2394
  // It's already a complete schema format - preserve it (id may be missing, will be generated)
2390
2395
  originalSchemaFile = parsed;
2391
- logger$5(`Input is complete schema format (${originalSchemaFile.id ? `preserving ID: ${originalSchemaFile.id}` : 'id will be generated'})`);
2396
+ logger$6(`Input is complete schema format (${originalSchemaFile.id ? `preserving ID: ${originalSchemaFile.id}` : 'id will be generated'})`);
2392
2397
  }
2393
2398
  }
2394
2399
  catch {
@@ -2413,8 +2418,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2413
2418
  // Check DB for existing schema by name+version (same as minimal path)
2414
2419
  const db = BaseDb.getAppDb();
2415
2420
  if (db) {
2416
- const _mod_1 = await import('./BasePathResolver-DrzGVH9L.js');
2417
- const _ns_1 = _mod_1.b8;
2421
+ const _mod_1 = await import('./BasePathResolver-B-fK7_N_.js');
2422
+ const _ns_1 = _mod_1.bd;
2418
2423
  const schemaSchemaMod = _ns_1;
2419
2424
  const { schemas: schemasTable } = schemaSchemaMod;
2420
2425
  const drizzleMod = await import('drizzle-orm');
@@ -2427,16 +2432,16 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2427
2432
  .limit(1);
2428
2433
  if (existingByName.length > 0 && existingByName[0].schemaData) {
2429
2434
  const existing = existingByName[0];
2430
- logger$5(`Idempotency: found existing schema by name+version: ${schemaFile.metadata.name} v${schemaFile.version ?? version}`);
2435
+ logger$6(`Idempotency: found existing schema by name+version: ${schemaFile.metadata.name} v${schemaFile.version ?? version}`);
2431
2436
  const existingSchema = JSON.parse(existing.schemaData);
2432
2437
  const contentMatches = compareSchemaContent(schemaFile, existingSchema);
2433
- logger$5(`Idempotency: compareSchemaContent=${contentMatches} for ${schemaFile.metadata.name}`);
2438
+ logger$6(`Idempotency: compareSchemaContent=${contentMatches} for ${schemaFile.metadata.name}`);
2434
2439
  if (contentMatches) {
2435
2440
  if (existing.schemaFileId) {
2436
2441
  const workingDir = BaseFileManager.getWorkingDir();
2437
2442
  const existingFilePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, schemaFile.version ?? version, existing.schemaFileId);
2438
2443
  if (await BaseFileManager.pathExists(existingFilePath)) {
2439
- logger$5(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content, loading existing file`);
2444
+ logger$6(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content, loading existing file`);
2440
2445
  return await loadSchemaFromFile(existingFilePath);
2441
2446
  }
2442
2447
  await BaseFileManager.createDirIfNotExists(workingDir);
@@ -2444,7 +2449,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2444
2449
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2445
2450
  return await loadSchemaFromFile(existingFilePath);
2446
2451
  }
2447
- logger$5(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content (no schemaFileId), using DB`);
2452
+ logger$6(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content (no schemaFileId), using DB`);
2448
2453
  return '';
2449
2454
  }
2450
2455
  }
@@ -2460,7 +2465,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2460
2465
  // processSchemaFiles runs multiple times (React StrictMode, app restarts).
2461
2466
  if (!schemaFile.id) {
2462
2467
  schemaFile.id = await getDeterministicSchemaFileId(schemaFile);
2463
- logger$5(`Generated deterministic schema ID for ${schemaFile.metadata.name}:`, schemaFile.id);
2468
+ logger$6(`Generated deterministic schema ID for ${schemaFile.metadata.name}:`, schemaFile.id);
2464
2469
  }
2465
2470
  // Before generating IDs, check if a file already exists with this schemaFileId
2466
2471
  // This handles the case where the schema was already loaded via loadSchemaFromFile
@@ -2470,7 +2475,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2470
2475
  const existingFileExists = await BaseFileManager.pathExists(existingFilePath);
2471
2476
  if (existingFileExists) {
2472
2477
  // File already exists with this schemaFileId - just load it instead of creating a new one
2473
- logger$5(`Schema file already exists with schemaFileId ${schemaFile.id}, loading it instead of creating new file`);
2478
+ logger$6(`Schema file already exists with schemaFileId ${schemaFile.id}, loading it instead of creating new file`);
2474
2479
  return await loadSchemaFromFile(existingFilePath);
2475
2480
  }
2476
2481
  // Generate missing model and property IDs.
@@ -2481,12 +2486,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2481
2486
  for (const [modelName, model] of Object.entries(schemaFile.models || {})) {
2482
2487
  if (!model.id) {
2483
2488
  model.id = getDeterministicId(modelName);
2484
- logger$5(`Generated deterministic model ID for ${modelName}:`, model.id);
2489
+ logger$6(`Generated deterministic model ID for ${modelName}:`, model.id);
2485
2490
  }
2486
2491
  for (const [propName, prop] of Object.entries(model.properties || {})) {
2487
2492
  if (!prop.id) {
2488
2493
  prop.id = getDeterministicId(modelName + propName);
2489
- logger$5(`Generated deterministic property ID for ${modelName}.${propName}:`, prop.id);
2494
+ logger$6(`Generated deterministic property ID for ${modelName}.${propName}:`, prop.id);
2490
2495
  }
2491
2496
  }
2492
2497
  }
@@ -2498,8 +2503,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2498
2503
  // For minimal imports: check DB for existing schema before creating new file
2499
2504
  const db = BaseDb.getAppDb();
2500
2505
  if (db) {
2501
- const _mod_2 = await import('./BasePathResolver-DrzGVH9L.js');
2502
- const _ns_2 = _mod_2.b8;
2506
+ const _mod_2 = await import('./BasePathResolver-B-fK7_N_.js');
2507
+ const _ns_2 = _mod_2.bd;
2503
2508
  const schemaSchemaMod = _ns_2;
2504
2509
  const { schemas: schemasTable } = schemaSchemaMod;
2505
2510
  const drizzleMod = await import('drizzle-orm');
@@ -2522,14 +2527,14 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2522
2527
  const workingDir = BaseFileManager.getWorkingDir();
2523
2528
  const existingFilePath = getSchemaFilePath(workingDir, importData.name, version, existing.schemaFileId);
2524
2529
  if (await BaseFileManager.pathExists(existingFilePath)) {
2525
- logger$5(`Schema ${importData.name} v${version} already exists with same content, loading existing file`);
2530
+ logger$6(`Schema ${importData.name} v${version} already exists with same content, loading existing file`);
2526
2531
  return await loadSchemaFromFile(existingFilePath);
2527
2532
  }
2528
2533
  // File missing but schemaData exists - restore file from schemaData
2529
2534
  await BaseFileManager.createDirIfNotExists(workingDir);
2530
2535
  await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
2531
2536
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2532
- logger$5(`Restored schema file from schemaData for ${importData.name} v${version}`);
2537
+ logger$6(`Restored schema file from schemaData for ${importData.name} v${version}`);
2533
2538
  return await loadSchemaFromFile(existingFilePath);
2534
2539
  }
2535
2540
  // No schemaFileId - restore file from schemaData using id from parsed schema
@@ -2540,10 +2545,10 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2540
2545
  await BaseFileManager.createDirIfNotExists(workingDir);
2541
2546
  await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
2542
2547
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2543
- logger$5(`Restored schema file from schemaData for ${importData.name} v${version}`);
2548
+ logger$6(`Restored schema file from schemaData for ${importData.name} v${version}`);
2544
2549
  return await loadSchemaFromFile(existingFilePath);
2545
2550
  }
2546
- logger$5(`Schema ${importData.name} v${version} already exists with same content (no id), using DB`);
2551
+ logger$6(`Schema ${importData.name} v${version} already exists with same content (no id), using DB`);
2547
2552
  return '';
2548
2553
  }
2549
2554
  // Content differs - create new version
@@ -2554,7 +2559,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2554
2559
  .orderBy(desc(schemasTable.version))
2555
2560
  .limit(1);
2556
2561
  const newVersion = latestVersionRows.length > 0 ? latestVersionRows[0].version + 1 : version;
2557
- logger$5(`Schema ${importData.name} content changed, creating new version v${newVersion}`);
2562
+ logger$6(`Schema ${importData.name} content changed, creating new version v${newVersion}`);
2558
2563
  schemaFile = transformImportToSchemaFile(importData, newVersion);
2559
2564
  version = newVersion;
2560
2565
  }
@@ -2576,10 +2581,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2576
2581
  }
2577
2582
  }
2578
2583
  warnOnEasNameCollisions(schemaFile);
2584
+ warnOnInvalidNameMatch(schemaFile);
2579
2585
  // Check if this is an internal SDK schema (should not create files in app directory)
2580
2586
  const isInternal = isInternalSchema(schemaFile.metadata.name, schemaFile.id);
2581
2587
  if (isInternal) {
2582
- logger$5(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
2588
+ logger$6(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
2583
2589
  // For internal schemas, just load to database and store, don't create file
2584
2590
  // Extract schema name and version
2585
2591
  const schemaName = schemaFile.metadata?.name;
@@ -2636,7 +2642,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2636
2642
  // Use fixed internal schema ID if missing (never generate for internal)
2637
2643
  if (!schemaFile.id) {
2638
2644
  schemaFile.id = INTERNAL_SCHEMA_IDS[0];
2639
- logger$5('Using fixed internal schema ID:', schemaFile.id);
2645
+ logger$6('Using fixed internal schema ID:', schemaFile.id);
2640
2646
  }
2641
2647
  // Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
2642
2648
  // This ensures Model instances are created with correct IDs
@@ -2646,7 +2652,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2646
2652
  // Generate model ID if missing
2647
2653
  if (!model.id) {
2648
2654
  model.id = generateId();
2649
- logger$5(`Generated model ID for ${modelName}:`, model.id);
2655
+ logger$6(`Generated model ID for ${modelName}:`, model.id);
2650
2656
  // Update the schemaFile object so it's included in schemaData
2651
2657
  schemaFile.models[modelName].id = model.id;
2652
2658
  }
@@ -2656,7 +2662,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2656
2662
  // Generate property ID if missing
2657
2663
  if (!prop.id) {
2658
2664
  prop.id = generateId();
2659
- logger$5(`Generated property ID for ${modelName}.${propName}:`, prop.id);
2665
+ logger$6(`Generated property ID for ${modelName}.${propName}:`, prop.id);
2660
2666
  // Update the schemaFile object so it's included in schemaData
2661
2667
  schemaFile.models[modelName].properties[propName].id = prop.id;
2662
2668
  }
@@ -2668,7 +2674,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2668
2674
  }
2669
2675
  // Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
2670
2676
  const modelDefinitions = await createModelsFromJson(importDataForInternal, modelFileIds, propertyFileIds);
2671
- logger$5('loadSchemaFromFile (internal) - modelDefinitions length:', Object.keys(modelDefinitions).length);
2677
+ logger$6('loadSchemaFromFile (internal) - modelDefinitions length:', Object.keys(modelDefinitions).length);
2672
2678
  // Convert schema file metadata to schema input for database
2673
2679
  const schemaInput = {
2674
2680
  name: schemaName,
@@ -2678,8 +2684,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2678
2684
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2679
2685
  };
2680
2686
  // Use dynamic import to break circular dependency
2681
- const _mod_3 = await import('./BasePathResolver-DrzGVH9L.js');
2682
- const _ns_3 = _mod_3.bb;
2687
+ const _mod_3 = await import('./BasePathResolver-B-fK7_N_.js');
2688
+ const _ns_3 = _mod_3.bg;
2683
2689
  const dbMod = _ns_3;
2684
2690
  const { addSchemaToDb, addModelsToDb } = dbMod;
2685
2691
  // Try to add schema and models to database if database is available
@@ -2700,12 +2706,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2700
2706
  });
2701
2707
  // Verify expected models are linked (single attempt - addModelsToDb already confirmed)
2702
2708
  const expectedModelNames = Object.keys(schemaFile.models || {});
2703
- const _mod_4 = await import('./BasePathResolver-DrzGVH9L.js');
2704
- const _ns_4 = _mod_4.b9;
2709
+ const _mod_4 = await import('./BasePathResolver-B-fK7_N_.js');
2710
+ const _ns_4 = _mod_4.be;
2705
2711
  const modelSchemaSchemaMod = _ns_4;
2706
2712
  const { modelSchemas } = modelSchemaSchemaMod;
2707
- const _mod_5 = await import('./BasePathResolver-DrzGVH9L.js');
2708
- const _ns_5 = _mod_5.b6;
2713
+ const _mod_5 = await import('./BasePathResolver-B-fK7_N_.js');
2714
+ const _ns_5 = _mod_5.bb;
2709
2715
  const modelSchemaMod = _ns_5;
2710
2716
  const { models: modelsTable } = modelSchemaMod;
2711
2717
  const drizzleMod = await import('drizzle-orm');
@@ -2794,12 +2800,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2794
2800
  }
2795
2801
  catch (dbError) {
2796
2802
  // Database not available - log warning but continue
2797
- logger$5('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
2803
+ logger$6('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
2798
2804
  }
2799
2805
  // Models are now Model instances, no registration needed
2800
2806
  // They should be created via Model.create() and are accessible via Model static methods
2801
2807
  for (const [modelName] of Object.entries(modelDefinitions)) {
2802
- logger$5('loadSchemaFromFile (internal) - model available:', modelName);
2808
+ logger$6('loadSchemaFromFile (internal) - model available:', modelName);
2803
2809
  }
2804
2810
  // Schema is now saved to database
2805
2811
  // useSchemas hook will pick it up via database queries
@@ -2810,7 +2816,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2810
2816
  // Ensure schema ID is defined (should always be set by this point, but check for safety)
2811
2817
  if (!schemaFile.id) {
2812
2818
  schemaFile.id = generateId();
2813
- logger$5('Generated schema ID before file path creation:', schemaFile.id);
2819
+ logger$6('Generated schema ID before file path creation:', schemaFile.id);
2814
2820
  }
2815
2821
  // Get the target file path using ID-based naming (preferred)
2816
2822
  const filePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, version, schemaFile.id);
@@ -2829,7 +2835,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2829
2835
  const data = JSON.parse(content);
2830
2836
  if (data.$schema) {
2831
2837
  // File is already a complete schema, just load it
2832
- logger$5(`Schema file ${filePath} already exists and is complete, loading it`);
2838
+ logger$6(`Schema file ${filePath} already exists and is complete, loading it`);
2833
2839
  return await loadSchemaFromFile(filePath);
2834
2840
  }
2835
2841
  }
@@ -2847,7 +2853,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2847
2853
  // Compare schemas structurally
2848
2854
  if (compareSchemasStructurally(schemaFile, existingSchema)) {
2849
2855
  // Schemas match - just load the existing file
2850
- logger$5(`Schema ${schemaFile.metadata.name} v${version} already exists with matching content, loading it`);
2856
+ logger$6(`Schema ${schemaFile.metadata.name} v${version} already exists with matching content, loading it`);
2851
2857
  return await loadSchemaFromFile(filePath);
2852
2858
  }
2853
2859
  else {
@@ -2903,14 +2909,15 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
2903
2909
  createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
2904
2910
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2905
2911
  };
2906
- const _mod_6 = await import('./BasePathResolver-DrzGVH9L.js');
2907
- const _ns_6 = _mod_6.bb;
2912
+ const _mod_6 = await import('./BasePathResolver-B-fK7_N_.js');
2913
+ const _ns_6 = _mod_6.bg;
2908
2914
  const dbMod = _ns_6;
2909
2915
  const { addSchemaToDb, addModelsToDb } = dbMod;
2910
2916
  const db = BaseDb.getAppDb();
2911
2917
  if (!db) {
2912
2918
  throw new Error('Database not found');
2913
2919
  }
2920
+ warnOnInvalidNameMatch(schemaFile);
2914
2921
  const schemaData = JSON.stringify(schemaFile, null, 2);
2915
2922
  const schemaRecord = await addSchemaToDb(schemaInput, schemaFile.id, schemaData, false);
2916
2923
  if (Object.keys(modelDefinitions).length > 0) {
@@ -3025,7 +3032,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3025
3032
  // Generate schema ID if missing (before creating schemaInput)
3026
3033
  if (!schemaFile.id) {
3027
3034
  schemaFile.id = generateId();
3028
- logger$5('Generated schema ID for schema file:', schemaFile.id);
3035
+ logger$6('Generated schema ID for schema file:', schemaFile.id);
3029
3036
  }
3030
3037
  // Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
3031
3038
  // This ensures Model instances are created with correct IDs
@@ -3035,7 +3042,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3035
3042
  // Generate model ID if missing
3036
3043
  if (!model.id) {
3037
3044
  model.id = generateId();
3038
- logger$5(`Generated model ID for ${modelName}:`, model.id);
3045
+ logger$6(`Generated model ID for ${modelName}:`, model.id);
3039
3046
  // Update the schemaFile object so it's included in schemaData
3040
3047
  schemaFile.models[modelName].id = model.id;
3041
3048
  }
@@ -3045,7 +3052,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3045
3052
  // Generate property ID if missing
3046
3053
  if (!prop.id) {
3047
3054
  prop.id = generateId();
3048
- logger$5(`Generated property ID for ${modelName}.${propName}:`, prop.id);
3055
+ logger$6(`Generated property ID for ${modelName}.${propName}:`, prop.id);
3049
3056
  // Update the schemaFile object so it's included in schemaData
3050
3057
  schemaFile.models[modelName].properties[propName].id = prop.id;
3051
3058
  }
@@ -3057,7 +3064,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3057
3064
  }
3058
3065
  // Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
3059
3066
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3060
- logger$5('loadSchemaFromFile - modelDefinitions length:', Object.keys(modelDefinitions).length);
3067
+ logger$6('loadSchemaFromFile - modelDefinitions length:', Object.keys(modelDefinitions).length);
3061
3068
  // Try to add schema and models to database if database is available
3062
3069
  try {
3063
3070
  const db = BaseDb.getAppDb();
@@ -3071,12 +3078,12 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3071
3078
  ]));
3072
3079
  const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds, propertyDefinitions);
3073
3080
  // Query the database to get model IDs that were just created
3074
- const _mod_7 = await import('./BasePathResolver-DrzGVH9L.js');
3075
- const _ns_7 = _mod_7.b9;
3081
+ const _mod_7 = await import('./BasePathResolver-B-fK7_N_.js');
3082
+ const _ns_7 = _mod_7.be;
3076
3083
  const modelSchemaSchemaMod = _ns_7;
3077
3084
  const { modelSchemas } = modelSchemaSchemaMod;
3078
- const _mod_8 = await import('./BasePathResolver-DrzGVH9L.js');
3079
- const _ns_8 = _mod_8.b6;
3085
+ const _mod_8 = await import('./BasePathResolver-B-fK7_N_.js');
3086
+ const _ns_8 = _mod_8.bb;
3080
3087
  const modelSchemaMod = _ns_8;
3081
3088
  const { models: modelsTable } = modelSchemaMod;
3082
3089
  const drizzleMod = await import('drizzle-orm');
@@ -3123,17 +3130,17 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3123
3130
  await new Promise(resolve => setTimeout(resolve, 100));
3124
3131
  }
3125
3132
  }
3126
- logger$5(`Verifying properties: found ${modelLinks.length} model links for schema ${schemaName} (id: ${schemaRecord.id})`);
3133
+ logger$6(`Verifying properties: found ${modelLinks.length} model links for schema ${schemaName} (id: ${schemaRecord.id})`);
3127
3134
  // If we didn't verify via direct lookup, verify via join table
3128
3135
  if (!seedModelId || (seedModel.length === 0 || !seedModel[0].id)) {
3129
3136
  const seedModelLink = modelLinks.find((link) => link.modelName === 'Seed');
3130
3137
  if (seedModelLink && seedModelLink.modelId) {
3131
- logger$5(`Verifying properties for Seed model via join table (modelId: ${seedModelLink.modelId})`);
3138
+ logger$6(`Verifying properties for Seed model via join table (modelId: ${seedModelLink.modelId})`);
3132
3139
  await verifyPropertiesPersisted(db, seedModelLink.modelId, 'Seed', 10, 100);
3133
3140
  }
3134
3141
  else if (modelLinks.length > 0 && modelLinks[0].modelId) {
3135
3142
  // Fallback to first model if Seed not found
3136
- logger$5(`Verifying properties for ${modelLinks[0].modelName} model via join table (modelId: ${modelLinks[0].modelId})`);
3143
+ logger$6(`Verifying properties for ${modelLinks[0].modelName} model via join table (modelId: ${modelLinks[0].modelId})`);
3137
3144
  await verifyPropertiesPersisted(db, modelLinks[0].modelId, modelLinks[0].modelName || 'unknown', 10, 100);
3138
3145
  }
3139
3146
  }
@@ -3141,8 +3148,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3141
3148
  // After properties are created (file path), ensure schemaFile has the correct IDs from database
3142
3149
  // Query the database to get the actual schemaFileId values that were used
3143
3150
  // This ensures schemaData matches what's actually in the database
3144
- const _mod_9 = await import('./BasePathResolver-DrzGVH9L.js');
3145
- const _ns_9 = _mod_9.b6;
3151
+ const _mod_9 = await import('./BasePathResolver-B-fK7_N_.js');
3152
+ const _ns_9 = _mod_9.bb;
3146
3153
  const modelSchemaMod2 = _ns_9;
3147
3154
  const { properties: propertiesTable } = modelSchemaMod2;
3148
3155
  let schemaFileUpdated = false;
@@ -3166,7 +3173,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3166
3173
  const currentId = schemaFile.models[modelName].properties[propRecord.name].id;
3167
3174
  if (currentId !== propRecord.schemaFileId) {
3168
3175
  schemaFile.models[modelName].properties[propRecord.name].id = propRecord.schemaFileId;
3169
- logger$5(`Updated schemaFile property ID for ${modelName}.${propRecord.name} from ${currentId} to ${propRecord.schemaFileId}`);
3176
+ logger$6(`Updated schemaFile property ID for ${modelName}.${propRecord.name} from ${currentId} to ${propRecord.schemaFileId}`);
3170
3177
  schemaFileUpdated = true;
3171
3178
  }
3172
3179
  }
@@ -3177,30 +3184,31 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3177
3184
  // This is important even if nothing changed, to ensure consistency
3178
3185
  const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
3179
3186
  // Update the schema record in the database with current schemaData
3180
- const _mod_10 = await import('./BasePathResolver-DrzGVH9L.js');
3181
- const _ns_10 = _mod_10.b8;
3187
+ const _mod_10 = await import('./BasePathResolver-B-fK7_N_.js');
3188
+ const _ns_10 = _mod_10.bd;
3182
3189
  const schemaSchemaMod = _ns_10;
3183
3190
  const { schemas: schemasTable } = schemaSchemaMod;
3184
3191
  await db
3185
3192
  .update(schemasTable)
3186
3193
  .set({ schemaData: updatedSchemaData })
3187
3194
  .where(eq(schemasTable.id, schemaRecord.id));
3195
+ clearNameMatchLevels();
3188
3196
  if (schemaFileUpdated) {
3189
- logger$5(`Updated schemaData in database with actual property IDs for schema "${schemaName}"`);
3197
+ logger$6(`Updated schemaData in database with actual property IDs for schema "${schemaName}"`);
3190
3198
  }
3191
3199
  else {
3192
- logger$5(`Verified schemaData in database matches schemaFile for schema "${schemaName}"`);
3200
+ logger$6(`Verified schemaData in database matches schemaFile for schema "${schemaName}"`);
3193
3201
  }
3194
3202
  }
3195
3203
  }
3196
3204
  catch (dbError) {
3197
3205
  // Database not available - log warning but continue
3198
- logger$5('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
3206
+ logger$6('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
3199
3207
  }
3200
3208
  // Models are now Model instances, no registration needed
3201
3209
  // They should be created via Model.create() and are accessible via Model static methods
3202
3210
  for (const [modelName] of Object.entries(modelDefinitions)) {
3203
- logger$5('loadSchemaFromFile - model available:', modelName);
3211
+ logger$6('loadSchemaFromFile - model available:', modelName);
3204
3212
  }
3205
3213
  return schemaFilePath;
3206
3214
  }
@@ -3287,7 +3295,7 @@ const jsonPropertiesToSchemaProperties = (modelName, modelDef, propertyFileIds)
3287
3295
  */
3288
3296
  const createModelFromJson = async (modelName, modelDef, schemaName, modelFileId, // Optional modelFileId from JSON file
3289
3297
  propertyFileIds) => {
3290
- const _mod_11 = await import('./errors-DdWbxb_n.js');
3298
+ const _mod_11 = await import('./errors-CCMxedOB.js');
3291
3299
  const _ns_11 = _mod_11.h;
3292
3300
  const modelMod = _ns_11;
3293
3301
  const { Model } = modelMod;
@@ -3296,10 +3304,10 @@ propertyFileIds) => {
3296
3304
  // Pass id (schemaFileId) if provided to ensure Model instance uses correct ID
3297
3305
  // Note: indexes and description are ignored - they remain in JSON for schema file format compliance but are not used by Model instances
3298
3306
  if (modelFileId) {
3299
- logger$5(`Creating schema model "${modelName}" with modelFileId: ${modelFileId}`);
3307
+ logger$6(`Creating schema model "${modelName}" with modelFileId: ${modelFileId}`);
3300
3308
  }
3301
3309
  else {
3302
- logger$5(`Warning: Creating schema model "${modelName}" without modelFileId - it will be renamed if duplicates exist`);
3310
+ logger$6(`Warning: Creating schema model "${modelName}" without modelFileId - it will be renamed if duplicates exist`);
3303
3311
  }
3304
3312
  const modelInstance = Model.create(modelName, schemaName, {
3305
3313
  modelFileId: modelFileId, // Pass modelFileId (preferred) as id (schemaFileId) from JSON file
@@ -3325,7 +3333,7 @@ const createModelsFromJson = async (importData, modelFileIds, propertyFileIds) =
3325
3333
  // Use modelFileId from map (no fallback to modelDef.id as JsonImportSchema doesn't have id property)
3326
3334
  const finalModelFileId = modelFileId;
3327
3335
  if (!finalModelFileId) {
3328
- logger$5(`Warning: No modelFileId found for model "${modelName}" - model will be created without ID`);
3336
+ logger$6(`Warning: No modelFileId found for model "${modelName}" - model will be created without ID`);
3329
3337
  }
3330
3338
  // Get propertyFileIds for this model if available
3331
3339
  const modelPropertyFileIds = propertyFileIds?.get(modelName);
@@ -3515,7 +3523,7 @@ var SEEDPROTOCOL_Seed_Protocol_v1 = /*#__PURE__*/Object.freeze({
3515
3523
  version: version
3516
3524
  });
3517
3525
 
3518
- const logger$4 = debug('seedSdk:client:actors:processSchemaFiles');
3526
+ const logger$5 = debug('seedSdk:client:actors:processSchemaFiles');
3519
3527
  let processSchemaFilesChain = Promise.resolve();
3520
3528
  function resolveSchemaFilePath(schemaFile) {
3521
3529
  const path = BaseFileManager.getPathModule();
@@ -3543,7 +3551,7 @@ async function resolveSchemaNameFromSource(source) {
3543
3551
  }
3544
3552
  }
3545
3553
  catch (error) {
3546
- logger$4('Could not resolve schema name from path:', source, error);
3554
+ logger$5('Could not resolve schema name from path:', source, error);
3547
3555
  }
3548
3556
  }
3549
3557
  return null;
@@ -3558,7 +3566,7 @@ function userSchemaLoadError(option, source, error) {
3558
3566
  // Schema processing can be slow with syncSchemaFromSource, loadAllSchemasFromDb, and OPFS file I/O
3559
3567
  const PROCESS_SCHEMA_FILES_TIMEOUT_MS = 120000;
3560
3568
  const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3561
- logger$4('processSchemaFiles started');
3569
+ logger$5('processSchemaFiles started');
3562
3570
  let hasResponded = false;
3563
3571
  let timeoutId = null;
3564
3572
  const reportError = (error) => {
@@ -3568,7 +3576,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3568
3576
  clearTimeout(timeoutId);
3569
3577
  timeoutId = null;
3570
3578
  }
3571
- logger$4('processSchemaFiles error:', error);
3579
+ logger$5('processSchemaFiles error:', error);
3572
3580
  sendBack({
3573
3581
  type: 'error',
3574
3582
  error: error instanceof Error ? error : new Error(String(error))
@@ -3582,7 +3590,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3582
3590
  clearTimeout(timeoutId);
3583
3591
  timeoutId = null;
3584
3592
  }
3585
- logger$4('processSchemaFiles completed');
3593
+ logger$5('processSchemaFiles completed');
3586
3594
  sendBack({ type: ClientManagerEvents.PROCESS_SCHEMA_FILES_SUCCESS });
3587
3595
  }
3588
3596
  };
@@ -3594,7 +3602,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3594
3602
  // Schemas written (or confirmed present) this run — skip redundant loadSchemaFromFile later
3595
3603
  const schemasWrittenThisRun = new Set();
3596
3604
  // First, load the internal seed-protocol schema
3597
- logger$4('Loading internal seed-protocol schema');
3605
+ logger$5('Loading internal seed-protocol schema');
3598
3606
  const internalSchemaData = internalSchema;
3599
3607
  const db = BaseDb.getAppDb();
3600
3608
  const internalSchemaExists = db
@@ -3603,21 +3611,21 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3603
3611
  // Always mark internal schema as written so the DB/file loop does not re-apply it
3604
3612
  schemasWrittenThisRun.add(SEED_PROTOCOL_SCHEMA_NAME);
3605
3613
  if (internalSchemaExists) {
3606
- logger$4('Internal seed-protocol schema already in DB, skipping import');
3614
+ logger$5('Internal seed-protocol schema already in DB, skipping import');
3607
3615
  }
3608
3616
  else {
3609
3617
  try {
3610
3618
  // Import the internal schema to database (will create models and add to store)
3611
3619
  await importJsonSchema({ contents: JSON.stringify(internalSchemaData) }, internalSchemaData.version);
3612
- logger$4(`Loaded internal seed-protocol schema v${internalSchemaData.version}`);
3620
+ logger$5(`Loaded internal seed-protocol schema v${internalSchemaData.version}`);
3613
3621
  }
3614
3622
  catch (error) {
3615
3623
  // If schema already exists, that's fine - it means it was already loaded
3616
3624
  if (error?.message?.includes('already exists')) {
3617
- logger$4('Internal seed-protocol schema already loaded');
3625
+ logger$5('Internal seed-protocol schema already loaded');
3618
3626
  }
3619
3627
  else {
3620
- logger$4('Error loading internal seed-protocol schema:', error);
3628
+ logger$5('Error loading internal seed-protocol schema:', error);
3621
3629
  // Don't fail if internal schema can't be loaded - it might already be in DB
3622
3630
  }
3623
3631
  }
@@ -3630,7 +3638,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3630
3638
  : '';
3631
3639
  const schemaId = typeof context.schema === 'object' && context.schema?.id ? String(context.schema.id) : undefined;
3632
3640
  if (isInternalSchema(schemaName, schemaId)) {
3633
- logger$4('Schema is internal (Seed Protocol), already loaded - skipping syncSchemaFromSource');
3641
+ logger$5('Schema is internal (Seed Protocol), already loaded - skipping syncSchemaFromSource');
3634
3642
  }
3635
3643
  else {
3636
3644
  try {
@@ -3639,7 +3647,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3639
3647
  if (syncedName) {
3640
3648
  schemasWrittenThisRun.add(syncedName);
3641
3649
  }
3642
- logger$4(`Synced canonical schema from ${typeof context.schema === 'string' ? context.schema : 'object'}`);
3650
+ logger$5(`Synced canonical schema from ${typeof context.schema === 'string' ? context.schema : 'object'}`);
3643
3651
  }
3644
3652
  catch (error) {
3645
3653
  // A schema the app passed in failed (missing file, bad JSON, DB write). Re-running an
@@ -3658,7 +3666,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3658
3666
  if (parsed?.metadata?.name) {
3659
3667
  schemasWrittenThisRun.add(String(parsed.metadata.name));
3660
3668
  }
3661
- logger$4(`Loaded schema from ${resolvedPath}`);
3669
+ logger$5(`Loaded schema from ${resolvedPath}`);
3662
3670
  }
3663
3671
  catch (error) {
3664
3672
  throw userSchemaLoadError('schemaFile', context.schemaFile, error);
@@ -3666,14 +3674,14 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3666
3674
  }
3667
3675
  // Process minimal import files (files without $schema) - skip when canonical schema is set
3668
3676
  if (!context.schema) {
3669
- logger$4('Listing schema files');
3677
+ logger$5('Listing schema files');
3670
3678
  let schemaFiles = [];
3671
3679
  try {
3672
3680
  schemaFiles = await listSchemaFiles();
3673
- logger$4(`Found ${schemaFiles.length} schema files to process`);
3681
+ logger$5(`Found ${schemaFiles.length} schema files to process`);
3674
3682
  }
3675
3683
  catch (error) {
3676
- logger$4('Error listing schema files (continuing anyway):', error);
3684
+ logger$5('Error listing schema files (continuing anyway):', error);
3677
3685
  schemaFiles = [];
3678
3686
  }
3679
3687
  for (const schemaFile of schemaFiles) {
@@ -3684,19 +3692,19 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3684
3692
  }
3685
3693
  }
3686
3694
  catch (error) {
3687
- logger$4(`Error importing schema file ${schemaFile.filePath}:`, error);
3695
+ logger$5(`Error importing schema file ${schemaFile.filePath}:`, error);
3688
3696
  }
3689
3697
  }
3690
3698
  }
3691
3699
  // Then, load all schemas using the unified database-first approach
3692
- logger$4('Loading schemas from database and files');
3700
+ logger$5('Loading schemas from database and files');
3693
3701
  let allSchemasData = [];
3694
3702
  try {
3695
3703
  allSchemasData = await loadAllSchemasFromDb();
3696
- logger$4(`Loaded ${allSchemasData.length} schemas (${allSchemasData.filter(s => s.isDraft).length} drafts, ${allSchemasData.filter(s => !s.isDraft).length} published)`);
3704
+ logger$5(`Loaded ${allSchemasData.length} schemas (${allSchemasData.filter(s => s.isDraft).length} drafts, ${allSchemasData.filter(s => !s.isDraft).length} published)`);
3697
3705
  }
3698
3706
  catch (error) {
3699
- logger$4('Error loading schemas from database (continuing anyway):', error);
3707
+ logger$5('Error loading schemas from database (continuing anyway):', error);
3700
3708
  // Continue with empty array - this is not critical for initialization
3701
3709
  // Schemas can be loaded on-demand later
3702
3710
  allSchemasData = [];
@@ -3717,13 +3725,13 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3717
3725
  }
3718
3726
  }
3719
3727
  catch (error) {
3720
- logger$4('Error counting linked models (re-applying all schema files):', error);
3728
+ logger$5('Error counting linked models (re-applying all schema files):', error);
3721
3729
  }
3722
3730
  }
3723
3731
  for (const schemaData of allSchemasData) {
3724
3732
  const schema = schemaData.schema;
3725
3733
  const schemaName = schema.metadata?.name || 'unknown';
3726
- logger$4(`Processing schema: ${schemaName} v${schema.version} (${schemaData.isDraft ? 'draft' : 'published'}, source: ${schemaData.source})`);
3734
+ logger$5(`Processing schema: ${schemaName} v${schema.version} (${schemaData.isDraft ? 'draft' : 'published'}, source: ${schemaData.source})`);
3727
3735
  // For published schemas (not drafts), load models from file if available
3728
3736
  if (!schemaData.isDraft && schema.id) {
3729
3737
  // loadAllSchemasFromDb already picked the latest file for this schema (and read it)
@@ -3753,7 +3761,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3753
3761
  }
3754
3762
  }
3755
3763
  catch (error) {
3756
- logger$4(`Error loading schema file for ${schemaName}:`, error);
3764
+ logger$5(`Error loading schema file for ${schemaName}:`, error);
3757
3765
  }
3758
3766
  }
3759
3767
  else {
@@ -3802,11 +3810,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3802
3810
  };
3803
3811
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3804
3812
  Object.assign(allModels, modelDefinitions);
3805
- logger$4(`Loaded ${Object.keys(modelDefinitions).length} models from schema data for ${schemaName}`);
3813
+ logger$5(`Loaded ${Object.keys(modelDefinitions).length} models from schema data for ${schemaName}`);
3806
3814
  }
3807
3815
  }
3808
3816
  catch (error) {
3809
- logger$4(`Error creating models from schema data for ${schemaName}:`, error);
3817
+ logger$5(`Error creating models from schema data for ${schemaName}:`, error);
3810
3818
  }
3811
3819
  }
3812
3820
  }
@@ -3856,11 +3864,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3856
3864
  };
3857
3865
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3858
3866
  Object.assign(allModels, modelDefinitions);
3859
- logger$4(`Loaded ${Object.keys(modelDefinitions).length} models from draft schema ${schemaName}`);
3867
+ logger$5(`Loaded ${Object.keys(modelDefinitions).length} models from draft schema ${schemaName}`);
3860
3868
  }
3861
3869
  }
3862
3870
  catch (error) {
3863
- logger$4(`Error creating models from draft schema ${schemaName}:`, error);
3871
+ logger$5(`Error creating models from draft schema ${schemaName}:`, error);
3864
3872
  }
3865
3873
  }
3866
3874
  // Schemas are now loaded on-demand via database queries (useSchemas hook uses loadAllSchemasFromDb)
@@ -3957,7 +3965,7 @@ const convertVerbatimItemStorageRow = async (localId, storage = {}) => {
3957
3965
  });
3958
3966
  };
3959
3967
 
3960
- const logger$3 = debug('seedSdk:db:migrateLegacyItemStorageRows');
3968
+ const logger$4 = debug('seedSdk:db:migrateLegacyItemStorageRows');
3961
3969
  /** appState key recording that legacy ItemStorage rows have been written to their files. */
3962
3970
  const LEGACY_ITEM_STORAGE_MIGRATION_KEY = 'legacyItemStorageFiles:v1';
3963
3971
  /** Runs in a row that left rows unconverted because a file write failed, before giving up. */
@@ -4111,7 +4119,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
4111
4119
  });
4112
4120
  if (converted) {
4113
4121
  result.converted++;
4114
- logger$3(`wrote ${row.propertyName} of ${row.seedLocalId} to ${converted.filePath}`);
4122
+ logger$4(`wrote ${row.propertyName} of ${row.seedLocalId} to ${converted.filePath}`);
4115
4123
  }
4116
4124
  else {
4117
4125
  result.skipped++;
@@ -4119,7 +4127,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
4119
4127
  }
4120
4128
  catch (error) {
4121
4129
  result.failed++;
4122
- logger$3(`converting ${row.propertyName} of ${row.seedLocalId} (${row.localId}) failed; left as is`, error);
4130
+ logger$4(`converting ${row.propertyName} of ${row.seedLocalId} (${row.localId}) failed; left as is`, error);
4123
4131
  }
4124
4132
  }
4125
4133
  const attempts = previousAttempts + 1;
@@ -4131,24 +4139,24 @@ async function migrateLegacyItemStorageRows(options = {}) {
4131
4139
  at: Date.now(),
4132
4140
  });
4133
4141
  if (result.candidates > 0) {
4134
- logger$3(`legacy ItemStorage rows: ${result.converted} converted, ${result.failed} failed, ` +
4142
+ logger$4(`legacy ItemStorage rows: ${result.converted} converted, ${result.failed} failed, ` +
4135
4143
  `${result.skipped} skipped of ${result.candidates}`);
4136
4144
  }
4137
4145
  return result;
4138
4146
  }
4139
- let running$2;
4140
- let deferredUntilLeader$2 = false;
4141
- const runInBackground$2 = () => {
4142
- running$2 ?? (running$2 = withDbTabLock('item-storage-migration', () => migrateLegacyItemStorageRows())
4147
+ let running$3;
4148
+ let deferredUntilLeader$3 = false;
4149
+ const runInBackground$3 = () => {
4150
+ running$3 ?? (running$3 = withDbTabLock('item-storage-migration', () => migrateLegacyItemStorageRows())
4143
4151
  .then(() => undefined)
4144
4152
  .catch((error) => {
4145
4153
  // Never fails init: rows stay as they were and publish converts them lazily.
4146
- logger$3('legacy ItemStorage migration failed', error);
4154
+ logger$4('legacy ItemStorage migration failed', error);
4147
4155
  })
4148
4156
  .finally(() => {
4149
- running$2 = undefined;
4157
+ running$3 = undefined;
4150
4158
  }));
4151
- return running$2;
4159
+ return running$3;
4152
4160
  };
4153
4161
  /**
4154
4162
  * Starts {@link migrateLegacyItemStorageRows} in the background once client init has finished
@@ -4158,19 +4166,19 @@ const runInBackground$2 = () => {
4158
4166
  */
4159
4167
  function startLegacyItemStorageMigration() {
4160
4168
  if (isLeaderTab()) {
4161
- void runInBackground$2();
4169
+ void runInBackground$3();
4162
4170
  return;
4163
4171
  }
4164
- if (deferredUntilLeader$2)
4172
+ if (deferredUntilLeader$3)
4165
4173
  return;
4166
- deferredUntilLeader$2 = true;
4174
+ deferredUntilLeader$3 = true;
4167
4175
  void whenLeaderTab().then(() => {
4168
- deferredUntilLeader$2 = false;
4169
- void runInBackground$2();
4176
+ deferredUntilLeader$3 = false;
4177
+ void runInBackground$3();
4170
4178
  });
4171
4179
  }
4172
4180
 
4173
- const logger$2 = debug('seedSdk:db:removeForeignAttestationRows');
4181
+ const logger$3 = debug('seedSdk:db:removeForeignAttestationRows');
4174
4182
  /** appState key recording that the cleanup below has run on this database. */
4175
4183
  const FOREIGN_ATTESTATION_CLEANUP_KEY = 'foreignAttestationRowsRemoved';
4176
4184
  /** Lowercased `attester` of a stored attestation JSON; NULL when the JSON is invalid or has none. */
@@ -4212,7 +4220,7 @@ async function removeForeignAttestationRows() {
4212
4220
  return { versionRows: foreignVersionUids.length, propertyRows };
4213
4221
  }
4214
4222
  /** Runs the cleanup unless this database has had it, and records that it has. */
4215
- async function runOnce() {
4223
+ async function runOnce$1() {
4216
4224
  const appDb = BaseDb.getAppDb();
4217
4225
  const marker = await appDb
4218
4226
  .select()
@@ -4228,22 +4236,22 @@ async function runOnce() {
4228
4236
  .values({ key: FOREIGN_ATTESTATION_CLEANUP_KEY, value })
4229
4237
  .onConflictDoUpdate({ target: appState.key, set: { value } });
4230
4238
  if (result.versionRows > 0 || result.propertyRows > 0) {
4231
- logger$2(`removed ${result.versionRows} version and ${result.propertyRows} property rows from other attesters`);
4239
+ logger$3(`removed ${result.versionRows} version and ${result.propertyRows} property rows from other attesters`);
4232
4240
  }
4233
4241
  }
4234
- let running$1;
4235
- let deferredUntilLeader$1 = false;
4236
- const runInBackground$1 = () => {
4242
+ let running$2;
4243
+ let deferredUntilLeader$2 = false;
4244
+ const runInBackground$2 = () => {
4237
4245
  // Under the sync's lock, so it can't interleave with a sync writing the same rows.
4238
- running$1 ?? (running$1 = withDbTabLock('eas-sync', runOnce, { timeoutMs: Infinity })
4246
+ running$2 ?? (running$2 = withDbTabLock('eas-sync', runOnce$1, { timeoutMs: Infinity })
4239
4247
  .catch((error) => {
4240
4248
  // Never fails init: the rows stay until the next sync of their seeds removes them.
4241
- logger$2('foreign attestation cleanup failed', error);
4249
+ logger$3('foreign attestation cleanup failed', error);
4242
4250
  })
4243
4251
  .finally(() => {
4244
- running$1 = undefined;
4252
+ running$2 = undefined;
4245
4253
  }));
4246
- return running$1;
4254
+ return running$2;
4247
4255
  };
4248
4256
  /**
4249
4257
  * Starts {@link removeForeignAttestationRows} in the background after client init, once per
@@ -4252,6 +4260,123 @@ const runInBackground$1 = () => {
4252
4260
  * tab only (docs/MULTI_TAB.md); a tab that isn't leader runs it if it takes over. Never throws.
4253
4261
  */
4254
4262
  function startForeignAttestationCleanup() {
4263
+ if (isLeaderTab()) {
4264
+ void runInBackground$2();
4265
+ return;
4266
+ }
4267
+ if (deferredUntilLeader$2)
4268
+ return;
4269
+ deferredUntilLeader$2 = true;
4270
+ void whenLeaderTab().then(() => {
4271
+ deferredUntilLeader$2 = false;
4272
+ void runInBackground$2();
4273
+ });
4274
+ }
4275
+
4276
+ const logger$2 = debug('seedSdk:db:alignRowPublishers');
4277
+ /** appState key recording that the fix below has run on this database. */
4278
+ const ROW_PUBLISHERS_ALIGNED_KEY = 'rowPublishersAligned';
4279
+ /**
4280
+ * Gives version and property rows their seed's publisher. Before, edits wrote property rows with no
4281
+ * publisher, and versions and property rows took the session's publisher rather than the seed's,
4282
+ * so connecting another wallet could claim rows of a seed that already had one. Local query reads
4283
+ * report a row's publisher as its attester and leave out rows whose attester isn't their parent's.
4284
+ *
4285
+ * Only rows without a stored attestation are changed: synced rows carry their attester in
4286
+ * `attestation_raw`. When the seed belongs to no wallet yet, its unsealed rows lose any publisher,
4287
+ * so they're claimed with it.
4288
+ */
4289
+ async function alignRowPublishers() {
4290
+ const appDb = BaseDb.getAppDb();
4291
+ const align = async (table) => {
4292
+ const rows = (await appDb
4293
+ .select({
4294
+ localId: table.localId,
4295
+ uid: table.uid,
4296
+ publisher: table.publisher,
4297
+ seedPublisher: seeds.publisher,
4298
+ seedAttestationRaw: seeds.attestationRaw,
4299
+ seedUid: seeds.uid,
4300
+ attestationRaw: table.attestationRaw,
4301
+ })
4302
+ .from(table)
4303
+ .innerJoin(seeds, eq(seeds.localId, table.seedLocalId)));
4304
+ const byTarget = new Map();
4305
+ for (const row of rows) {
4306
+ if (!row.localId || (row.attestationRaw != null && row.attestationRaw !== ''))
4307
+ continue;
4308
+ const seedPublisher = normalizePublisher(resolvePublisherFromSeedRow({
4309
+ publisher: row.seedPublisher,
4310
+ attestationRaw: row.seedAttestationRaw,
4311
+ uid: row.seedUid,
4312
+ }));
4313
+ const current = normalizePublisher(row.publisher);
4314
+ let target;
4315
+ if (seedPublisher) {
4316
+ if (current === seedPublisher)
4317
+ continue;
4318
+ target = seedPublisher;
4319
+ }
4320
+ else {
4321
+ // A seed with no wallet yet: its unsealed rows go with it when it's claimed.
4322
+ if (!current || !isPlaceholderUid(row.uid))
4323
+ continue;
4324
+ target = null;
4325
+ }
4326
+ const ids = byTarget.get(target) ?? [];
4327
+ ids.push(row.localId);
4328
+ byTarget.set(target, ids);
4329
+ }
4330
+ let changed = 0;
4331
+ for (const [target, ids] of byTarget) {
4332
+ await writeInBatches(ids, (chunk) => appDb.update(table).set({ publisher: target }).where(inArray(table.localId, chunk)));
4333
+ changed += ids.length;
4334
+ }
4335
+ return changed;
4336
+ };
4337
+ const versionRows = await align(versions);
4338
+ const propertyRows = await align(metadata$1);
4339
+ return { versionRows, propertyRows };
4340
+ }
4341
+ /** Runs the fix unless this database has had it, and records that it has. */
4342
+ async function runOnce() {
4343
+ const appDb = BaseDb.getAppDb();
4344
+ const marker = await appDb
4345
+ .select()
4346
+ .from(appState)
4347
+ .where(eq(appState.key, ROW_PUBLISHERS_ALIGNED_KEY))
4348
+ .limit(1);
4349
+ if (marker.length > 0)
4350
+ return;
4351
+ const result = await alignRowPublishers();
4352
+ const value = JSON.stringify({ ...result, at: Date.now() });
4353
+ await appDb
4354
+ .insert(appState)
4355
+ .values({ key: ROW_PUBLISHERS_ALIGNED_KEY, value })
4356
+ .onConflictDoUpdate({ target: appState.key, set: { value } });
4357
+ if (result.versionRows > 0 || result.propertyRows > 0) {
4358
+ logger$2(`gave ${result.versionRows} version and ${result.propertyRows} property rows their seed's publisher`);
4359
+ }
4360
+ }
4361
+ let running$1;
4362
+ let deferredUntilLeader$1 = false;
4363
+ const runInBackground$1 = () => {
4364
+ // Under the sync's lock: sync writes these rows too.
4365
+ running$1 ?? (running$1 = withDbTabLock('eas-sync', runOnce, { timeoutMs: Infinity })
4366
+ .catch((error) => {
4367
+ // Never fails init: the rows keep their old publisher.
4368
+ logger$2('row publisher fix failed', error);
4369
+ })
4370
+ .finally(() => {
4371
+ running$1 = undefined;
4372
+ }));
4373
+ return running$1;
4374
+ };
4375
+ /**
4376
+ * Starts {@link alignRowPublishers} in the background after client init, once per database, like
4377
+ * the foreign-attestation cleanup. Leader tab only (docs/MULTI_TAB.md). Never throws.
4378
+ */
4379
+ function startAlignRowPublishers() {
4255
4380
  if (isLeaderTab()) {
4256
4381
  void runInBackground$1();
4257
4382
  return;
@@ -4271,8 +4396,8 @@ const logger$1 = debug('seedSdk:db:canonicalizeModelTypes');
4271
4396
  * EAS name of the model (ADR 0008): `html_page` for HTMLPage. Rows written before that hold other
4272
4397
  * forms: drizzle's snake_case for local seeds (`image_v_2`), or the name an older SDK published,
4273
4398
  * for synced ones (`htmlpage`). This rewrites each stored type that matches exactly one local model
4274
- * name (in the tightest tier, as sync matches) to that model's type. Types matching no model, or
4275
- * several, are left alone. Returns the number of types rewritten.
4399
+ * name (in the tightest tier its nameMatch level allows, as sync matches) to that model's type.
4400
+ * Types matching no model, or several, are left alone. Returns the number of types rewritten.
4276
4401
  */
4277
4402
  async function canonicalizeModelTypes() {
4278
4403
  const appDb = BaseDb.getAppDb();
@@ -4281,6 +4406,8 @@ async function canonicalizeModelTypes() {
4281
4406
  .filter(Boolean);
4282
4407
  if (modelNames.length === 0)
4283
4408
  return 0;
4409
+ // Each model name at its nameMatch level (ADR 0009). Read fresh: this runs after a schema load.
4410
+ const levels = await loadNameMatchLevels(appDb);
4284
4411
  const storedTypes = new Set();
4285
4412
  const collect = (rows) => {
4286
4413
  for (const row of rows)
@@ -4292,7 +4419,7 @@ async function canonicalizeModelTypes() {
4292
4419
  collect(await appDb.selectDistinct({ type: metadata$1.modelType }).from(metadata$1).where(isNotNull(metadata$1.modelType)));
4293
4420
  let rewritten = 0;
4294
4421
  for (const type of storedTypes) {
4295
- const canonical = new Set([...localNamesInBestMatchTier(type, modelNames)].map((name) => easName(name)));
4422
+ const canonical = new Set([...localNamesInBestMatchTier(type, modelNames, { level: (name) => levels.model(name) })].map((name) => easName(name)));
4296
4423
  if (canonical.size !== 1)
4297
4424
  continue;
4298
4425
  const [next] = canonical;
@@ -4570,6 +4697,8 @@ const clientManagerMachine = setup({
4570
4697
  () => startLegacyItemStorageMigration(),
4571
4698
  // Also once, in the background: rows an older sync stored from other accounts' attestations.
4572
4699
  () => startForeignAttestationCleanup(),
4700
+ // Also once: version and property rows get their seed's publisher (rows from older edits had none).
4701
+ () => startAlignRowPublishers(),
4573
4702
  // Stored model types to the ADR 0008 form (html_page), so exact type filters find old rows.
4574
4703
  () => startCanonicalizeModelTypes(),
4575
4704
  ],
@@ -5183,8 +5312,10 @@ const emptyResult = () => ({
5183
5312
  seedLocalIds: [],
5184
5313
  });
5185
5314
  /**
5186
- * Stamp local seeds/versions/metadata that have no publisher and no real uid.
5187
- * Does not touch sealed rows (real EAS uid or attestationRaw).
5315
+ * Gives `publisher` to local drafts that belong to no wallet yet: seeds with no publisher, no real
5316
+ * uid and no attestationRaw, and those seeds' versions and property rows that are unsealed too.
5317
+ * Versions and property rows go only with their seed, so rows of a seed that already has a
5318
+ * publisher are never claimed. Sealed rows (real EAS uid or attestationRaw) are never touched.
5188
5319
  */
5189
5320
  async function claimUnpublishedDrafts(publisher) {
5190
5321
  const normalized = normalizePublisher(publisher);
@@ -5194,33 +5325,38 @@ async function claimUnpublishedDrafts(publisher) {
5194
5325
  if (!appDb)
5195
5326
  return emptyResult();
5196
5327
  const now = Date.now();
5197
- const claimTable = async (table) => {
5198
- const rows = (await appDb
5328
+ const isClaimable = (row) => typeof row.localId === 'string' && row.localId !== '' && isLocalUnsealedDraft(row);
5329
+ const stamp = async (table, ids) => {
5330
+ await writeInBatches(ids, (chunk) => appDb.update(table).set({ publisher: normalized, updatedAt: now }).where(inArray(table.localId, chunk)));
5331
+ };
5332
+ const seedRows = (await appDb
5333
+ .select({
5334
+ localId: seeds.localId,
5335
+ uid: seeds.uid,
5336
+ publisher: seeds.publisher,
5337
+ attestationRaw: seeds.attestationRaw,
5338
+ })
5339
+ .from(seeds));
5340
+ const seedIds = seedRows.filter(isClaimable).map((row) => row.localId);
5341
+ if (seedIds.length === 0)
5342
+ return emptyResult();
5343
+ const claimChildren = async (table) => {
5344
+ const rows = (await selectInBatches(seedIds, (chunk) => appDb
5199
5345
  .select({
5200
5346
  localId: table.localId,
5201
5347
  uid: table.uid,
5202
5348
  publisher: table.publisher,
5203
5349
  attestationRaw: table.attestationRaw,
5204
5350
  })
5205
- .from(table));
5206
- const ids = rows
5207
- .filter((row) => typeof row.localId === 'string' &&
5208
- row.localId !== '' &&
5209
- isLocalUnsealedDraft(row))
5210
- .map((row) => row.localId);
5211
- if (ids.length === 0)
5212
- return [];
5213
- await appDb
5214
- .update(table)
5215
- .set({ publisher: normalized, updatedAt: now })
5216
- .where(inArray(table.localId, ids));
5351
+ .from(table)
5352
+ .where(inArray(table.seedLocalId, chunk))));
5353
+ const ids = rows.filter(isClaimable).map((row) => row.localId);
5354
+ await stamp(table, ids);
5217
5355
  return ids;
5218
5356
  };
5219
- const [seedIds, versionIds, metadataIds] = await Promise.all([
5220
- claimTable(seeds),
5221
- claimTable(versions),
5222
- claimTable(metadata$1),
5223
- ]);
5357
+ await stamp(seeds, seedIds);
5358
+ const versionIds = await claimChildren(versions);
5359
+ const metadataIds = await claimChildren(metadata$1);
5224
5360
  return {
5225
5361
  seeds: seedIds.length,
5226
5362
  versions: versionIds.length,
@@ -5514,5 +5650,5 @@ var ClientManager$1 = /*#__PURE__*/Object.freeze({
5514
5650
  getClient: getClient
5515
5651
  });
5516
5652
 
5517
- export { requestEasSyncFromModelsInit as A, sendEasSyncClientRequest as B, ClientManager as C, setRetriesWhenOnlineEnabled as D, EAS_CHAIN_ID_APP_STATE_KEY as E, startEasSyncActor as F, unregisterSeedQueryLocalSource as G, createModelsFromJson as H, INIT_CONFIG_CONFLICT_MESSAGE as I, getLatestSchemaVersion as J, jsonPropertiesToSchemaProperties as K, schema as L, ClientManager$1 as M, SEEDPROTOCOL_Seed_Protocol_v1 as S, assertLocalDbChain as a, importJsonSchema as b, convertVerbatimItemStorageRow as c, getContentHash as d, claimUnpublishedDrafts as e, createLocalQueryDataSource as f, getRefValueType as g, createSchema as h, isVerbatimItemStorageDraftRow as i, easSyncActor as j, getClient as k, loadSchemaFromFile as l, getPublishedSeedRecord as m, getSchemaNameFromId as n, isSeedQueryLocalSourceRegistered as o, listCompleteSchemaFiles as p, loadAllSchemasFromDb as q, readJsonImportFile as r, syncSchemaFromSource as s, transformImportToSchemaFile as t, mergeEasSyncRequestIntents as u, readSchema as v, waitForEasReadChain as w, registerSeedQueryLocalSource as x, requestEasSyncFromAddressChange as y, requestEasSyncFromEventBus as z };
5518
- //# sourceMappingURL=ClientManager-Dfu4jcgm.js.map
5653
+ export { requestEasSyncFromEventBus as A, requestEasSyncFromModelsInit as B, ClientManager as C, sendEasSyncClientRequest as D, EAS_CHAIN_ID_APP_STATE_KEY as E, setRetriesWhenOnlineEnabled as F, startEasSyncActor as G, unregisterSeedQueryLocalSource as H, INIT_CONFIG_CONFLICT_MESSAGE as I, createModelsFromJson as J, getLatestSchemaVersion as K, jsonPropertiesToSchemaProperties as L, schema as M, ClientManager$1 as N, SEEDPROTOCOL_Seed_Protocol_v1 as S, getContentHash as a, isVerbatimItemStorageDraftRow as b, convertVerbatimItemStorageRow as c, assertLocalDbChain as d, claimUnpublishedDrafts as e, createLocalQueryDataSource as f, getRefValueType as g, hardDeleteLocalSeedsByLocalIds as h, importJsonSchema as i, createSchema as j, easSyncActor as k, loadSchemaFromFile as l, getClient as m, getPublishedSeedRecord as n, getSchemaNameFromId as o, isSeedQueryLocalSourceRegistered as p, listCompleteSchemaFiles as q, readJsonImportFile as r, syncSchemaFromSource as s, transformImportToSchemaFile as t, loadAllSchemasFromDb as u, mergeEasSyncRequestIntents as v, waitForEasReadChain as w, readSchema as x, registerSeedQueryLocalSource as y, requestEasSyncFromAddressChange as z };
5654
+ //# sourceMappingURL=ClientManager-C7VkO5Hg.js.map