@seedprotocol/sdk 0.7.4-next.793.g6dd83dd → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/{BasePathResolver-DT63t0XU.js → BasePathResolver-DrzGVH9L.js} +231 -39
  2. package/dist/BasePathResolver-DrzGVH9L.js.map +1 -0
  3. package/dist/{ClientManager-Cos8NaRU.js → ClientManager-Dfu4jcgm.js} +300 -188
  4. package/dist/ClientManager-Dfu4jcgm.js.map +1 -0
  5. package/dist/{Item-CoP48bl3.js → Item-BUUFuywT.js} +75 -219
  6. package/dist/Item-BUUFuywT.js.map +1 -0
  7. package/dist/{ModelProperty-jSo2QWIc.js → ModelProperty-B6cnRvIz.js} +37 -38
  8. package/dist/ModelProperty-B6cnRvIz.js.map +1 -0
  9. package/dist/{Schema-DN1KwJ57.js → Schema-Bf-jOLq0.js} +36 -35
  10. package/dist/{Schema-DN1KwJ57.js.map → Schema-Bf-jOLq0.js.map} +1 -1
  11. package/dist/{SchemaValidationService-CCG9Bu__.js → SchemaValidationService-BNYMacsx.js} +7 -8
  12. package/dist/{SchemaValidationService-CCG9Bu__.js.map → SchemaValidationService-BNYMacsx.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-D8t61oNl.js → backfillMetadataPropertyIds-C2-s_jUa.js} +4 -5
  14. package/dist/{backfillMetadataPropertyIds-D8t61oNl.js.map → backfillMetadataPropertyIds-C2-s_jUa.js.map} +1 -1
  15. package/dist/{configurePlatform-Su9vV5qO.js → configurePlatform-BzfirKuM.js} +3 -4
  16. package/dist/{configurePlatform-Su9vV5qO.js.map → configurePlatform-BzfirKuM.js.map} +1 -1
  17. package/dist/{detachRowsBeforeDelete-DcWDZ8KP.js → detachRowsBeforeDelete-B0Daoz9Z.js} +3 -4
  18. package/dist/{detachRowsBeforeDelete-DcWDZ8KP.js.map → detachRowsBeforeDelete-B0Daoz9Z.js.map} +1 -1
  19. package/dist/{eas-Ce0KDpvb.js → eas-Dq5Kx_Nd.js} +14 -32
  20. package/dist/eas-Dq5Kx_Nd.js.map +1 -0
  21. package/dist/{errors-D1brJy1k.js → errors-DdWbxb_n.js} +42 -39
  22. package/dist/errors-DdWbxb_n.js.map +1 -0
  23. package/dist/{getItem-Cs5IIZCQ.js → getItem-9bYSErSj.js} +4 -5
  24. package/dist/{getItem-Cs5IIZCQ.js.map → getItem-9bYSErSj.js.map} +1 -1
  25. package/dist/{getPublishPayload-CquFaK1c.js → getPublishPayload-DPy-uMrR.js} +28 -29
  26. package/dist/getPublishPayload-DPy-uMrR.js.map +1 -0
  27. package/dist/{getPublishUploads-Bv9aOq2x.js → getPublishUploads-J-143iSV.js} +10 -11
  28. package/dist/{getPublishUploads-Bv9aOq2x.js.map → getPublishUploads-J-143iSV.js.map} +1 -1
  29. package/dist/{index-BPrJV9Wt.js → index-7y2f_iQz.js} +2 -2
  30. package/dist/index-7y2f_iQz.js.map +1 -0
  31. package/dist/{index-DhP5gMMF.js → index-C61Rxy0F.js} +9 -10
  32. package/dist/index-C61Rxy0F.js.map +1 -0
  33. package/dist/{index.browser-cpZehMwT.js → index.browser-C1pisOEa.js} +10 -10
  34. package/dist/{index.browser-cpZehMwT.js.map → index.browser-C1pisOEa.js.map} +1 -1
  35. package/dist/{index.node-D_-a9z-S.js → index.node-BAlST8pD.js} +6 -6
  36. package/dist/{index.node-D_-a9z-S.js.map → index.node-BAlST8pD.js.map} +1 -1
  37. package/dist/main.js +27 -28
  38. package/dist/main.js.map +1 -1
  39. package/dist/node.js +12 -13
  40. package/dist/node.js.map +1 -1
  41. package/dist/platform.browser.js +6 -7
  42. package/dist/platform.browser.js.map +1 -1
  43. package/dist/platform.node.js +5 -6
  44. package/dist/platform.node.js.map +1 -1
  45. package/dist/{property-DNfhGsdq.js → property-zFPMtR3T.js} +10 -14
  46. package/dist/property-zFPMtR3T.js.map +1 -0
  47. package/dist/{propertyValidationRules-BiEBQvPZ.js → propertyValidationRules-CeFVhdQg.js} +10 -10
  48. package/dist/{propertyValidationRules-BiEBQvPZ.js.map → propertyValidationRules-CeFVhdQg.js.map} +1 -1
  49. package/dist/{publishDraftGraph-BZ6gku_X.js → publishDraftGraph-CuVq6iAR.js} +7 -6
  50. package/dist/{publishDraftGraph-BZ6gku_X.js.map → publishDraftGraph-CuVq6iAR.js.map} +1 -1
  51. package/dist/{resetAmbiguousLegacyItemData-CkSoBEOU.js → resetAmbiguousLegacyItemData-DsFTnMBz.js} +5 -6
  52. package/dist/resetAmbiguousLegacyItemData-DsFTnMBz.js.map +1 -0
  53. package/dist/{resolveModelForSyncedSeed-CsnKV72V.js → resolveModelForSyncedSeed-RUsgAZXG.js} +2 -2
  54. package/dist/{resolveModelForSyncedSeed-CsnKV72V.js.map → resolveModelForSyncedSeed-RUsgAZXG.js.map} +1 -1
  55. package/dist/src/Item/Item.d.ts.map +1 -1
  56. package/dist/src/ItemProperty/service/propertyMachine.d.ts +4 -4
  57. package/dist/src/Model/Model.d.ts +3 -2
  58. package/dist/src/Model/Model.d.ts.map +1 -1
  59. package/dist/src/ModelProperty/ModelProperty.d.ts +1 -1
  60. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +1 -1
  61. package/dist/src/Schema/service/schemaMachine.d.ts +2 -2
  62. package/dist/src/client/ClientManager.d.ts +6 -6
  63. package/dist/src/client/clientManagerMachine.d.ts +2 -2
  64. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  65. package/dist/src/db/canonicalizeModelTypes.d.ts +18 -0
  66. package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -0
  67. package/dist/src/db/read/getModelSchemas.d.ts +6 -0
  68. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  69. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  70. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  71. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  72. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  73. package/dist/src/eas.d.ts.map +1 -1
  74. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  75. package/dist/src/helpers/db.d.ts +20 -0
  76. package/dist/src/helpers/db.d.ts.map +1 -1
  77. package/dist/src/helpers/index.d.ts +3 -1
  78. package/dist/src/helpers/index.d.ts.map +1 -1
  79. package/dist/src/helpers/metadataPropertyNames.d.ts +12 -0
  80. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  81. package/dist/src/imports/json.d.ts +10 -0
  82. package/dist/src/imports/json.d.ts.map +1 -1
  83. package/dist/src/index.d.ts +2 -2
  84. package/dist/src/index.d.ts.map +1 -1
  85. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
  86. package/dist/src/types/import.d.ts +4 -0
  87. package/dist/src/types/import.d.ts.map +1 -1
  88. package/dist/{syncDbWithEas-CfRijZhj.js → syncDbWithEas-CRpnkq00.js} +157 -61
  89. package/dist/syncDbWithEas-CRpnkq00.js.map +1 -0
  90. package/dist/{tabEvents-D5X2Hwcp.js → tabEvents-nBUq_1u1.js} +6 -6
  91. package/dist/{tabEvents-D5X2Hwcp.js.map → tabEvents-nBUq_1u1.js.map} +1 -1
  92. package/dist/{tolerantWebAccess-BNYRvW9a.js → tolerantWebAccess-DIt3R8_u.js} +7 -8
  93. package/dist/{tolerantWebAccess-BNYRvW9a.js.map → tolerantWebAccess-DIt3R8_u.js.map} +1 -1
  94. package/dist/{updateSeedRevokedAt-B-xAQxaj.js → updateSeedRevokedAt-DtTPSzpM.js} +3 -3
  95. package/dist/{updateSeedRevokedAt-B-xAQxaj.js.map → updateSeedRevokedAt-DtTPSzpM.js.map} +1 -1
  96. package/package.json +5 -5
  97. package/dist/BasePathResolver-DT63t0XU.js.map +0 -1
  98. package/dist/ClientManager-Cos8NaRU.js.map +0 -1
  99. package/dist/Item-CoP48bl3.js.map +0 -1
  100. package/dist/ModelProperty-jSo2QWIc.js.map +0 -1
  101. package/dist/eas-Ce0KDpvb.js.map +0 -1
  102. package/dist/errors-D1brJy1k.js.map +0 -1
  103. package/dist/getPublishPayload-CquFaK1c.js.map +0 -1
  104. package/dist/index-BPrJV9Wt.js.map +0 -1
  105. package/dist/index-DhP5gMMF.js.map +0 -1
  106. package/dist/property-DNfhGsdq.js.map +0 -1
  107. package/dist/resetAmbiguousLegacyItemData-CkSoBEOU.js.map +0 -1
  108. package/dist/syncDbWithEas-CfRijZhj.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  import { startCase, isEqual } from 'lodash-es';
2
- import { E as BaseDb, l as easSyncProcesses, G as eventEmitter, a8 as isNode, ah as isBrowser, I as BasePathResolver, aA as normalizeAddressConfig, h as appState, aL as downloadAllFilesRequestHandler, aM as downloadAllFilesBinaryRequestHandler, J as BaseFileManager, H as toSnakeCase, s as models$1, r as modelUids, A as seeds, aB as normalizeAddressList, z as schemas, aK as loadModelsFromDbForSchema, aI as addSchemaToDb, aF as isInternalSchema, aN as INTERNAL_SCHEMA_IDS, $ as generateId, aO as linkModelToSchema, n as normalizeDataType, aq 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, aP as getWatchedAddressesFromDb, aQ as getOwnedAddressesFromDb, aR as CLIENT_NOT_INITIALIZED } from './BasePathResolver-DT63t0XU.js';
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';
3
3
  import debug from 'debug';
4
4
  import { createActor, setup, assign, fromPromise, fromCallback, waitFor } from 'xstate';
5
- import { x as MachineIds, a2 as ClientManagerEvents, a3 as withLockedItemStorageRow, a4 as getItemStorageFilePath, a5 as writeItemStorageFile, c as compareMetadataRowsLatestFirst, w as writeInBatches, C as ClientManagerState, a6 as resolvePublisherFromSeedRow, J as isLocalUnsealedDraft, I as Item } from './Item-CoP48bl3.js';
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';
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-D5X2Hwcp.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-nBUq_1u1.js';
8
8
  import { seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, resolveSeedGatewayEndpoints, setResolvedSeedGatewayEndpoints, BaseArweaveClient, ensureReadGatewaySelected, DEFAULT_ARWEAVE_HOST } from '@seedprotocol/arweave';
9
- import { configureEasReadChain, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, isValidEasAttestationUid } from '@seedprotocol/eas';
9
+ import { configureEasReadChain, easName, BaseQueryClient, BaseEasClient, GET_SCHEMAS, whenEasReadChainSettled, getEasReadChainId, DEFAULT_EAS_CHAIN_ID, isEasReadChainConfigured, 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-CfRijZhj.js');
215
+ const { runSyncFromEas } = await import('./syncDbWithEas-CRpnkq00.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$2 = new Set();
425
+ const deferredUntilLeader$3 = 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$2.has(source))
436
+ if (deferredUntilLeader$3.has(source))
437
437
  return;
438
- deferredUntilLeader$2.add(source);
438
+ deferredUntilLeader$3.add(source);
439
439
  void whenLeaderTab().then(() => {
440
- deferredUntilLeader$2.delete(source);
440
+ deferredUntilLeader$3.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$d = debug('seedSdk:services:events');
514
+ const logger$e = debug('seedSdk:services:events');
515
515
  const handleServiceSaveState = (event) => {
516
516
  const { state, serviceId } = event;
517
- logger$d(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
517
+ logger$e(`[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$c = debug('seedSdk:ClientManager:initialize');
568
+ const logger$d = 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$c('initialize from ClientManager');
579
+ logger$d('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-Su9vV5qO.js');
612
+ const { configurePlatform } = await import('./configurePlatform-BzfirKuM.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$b = debug('seedSdk:client:writeToDb');
752
+ const logger$c = 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$b('[client/actors] [saveAppState] App DB not found, but continuing in test environment');
760
+ logger$c('[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$b('result', result);
776
+ logger$c('result', result);
777
777
  }
778
778
  catch (error) {
779
- logger$b('[client/actors] [saveAppState] Error saving app state:', error);
779
+ logger$c('[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$b('[client/actors] [saveAppState] Continuing despite error in test environment');
782
+ logger$c('[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$b('[client/actors] [saveAppState] Error in promise chain:', error);
797
+ logger$c('[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$b('[client/actors] [saveAppState] Sending success despite error in test environment');
800
+ logger$c('[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$a = debug('seedSdk:client:actors:dbInit');
870
+ const logger$b = 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$a('[client/actors] [dbInit] Database prepared and ready');
884
+ logger$b('[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$a('Error in dbInit:', error);
891
+ logger$b('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$9 = debug('seedSdk:client:actors:addModelsToStore');
899
+ const logger$a = 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$9('model available:', key);
913
+ logger$a('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$9('[client/actors] [addModelsToStore] Error:', error);
921
+ logger$a('[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$8 = debug('seedSdk:client:actors:addModelsToDb');
929
+ const logger$9 = 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$8('[client/actors] [addModelsToDb] inserted model:', name);
952
+ logger$9('[client/actors] [addModelsToDb] inserted model:', name);
953
953
  }
954
954
  }
955
955
  return rows;
@@ -989,19 +989,19 @@ 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$8('[client/actors] [addModelsToDb] Warning: Could not find or create model:', modelName);
992
+ logger$9('[client/actors] [addModelsToDb] Warning: Could not find or create model:', modelName);
993
993
  hasModelsInDb = false;
994
994
  continue;
995
995
  }
996
996
  // The EAS schema string depends only on the model name, so every same-name row shares its uid.
997
997
  schemaDefsByModelName.set(modelName, {
998
998
  dbIds: existingModels.filter((m) => m.name === modelName).map((m) => m.id),
999
- schemaDef: `bytes32 ${toSnakeCase(modelName)}`,
999
+ schemaDef: `bytes32 ${easName(modelName)}`,
1000
1000
  });
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$8('[client/actors] [addModelsToDb] No models to process, but continuing');
1004
+ logger$9('[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$8('[client/actors] [addModelsToDb] No schemas found from EAS, but continuing');
1052
+ logger$9('[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$8('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
1057
+ logger$9('[client/actors] [addModelsToDb] Warning: Could not fetch schemas from EAS (background):', error.message);
1058
1058
  }
1059
1059
  else {
1060
- logger$8('[client/actors] [addModelsToDb] Error fetching schemas (background):', error.message);
1060
+ logger$9('[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$8('[client/actors] [addModelsToDb] Error:', error);
1076
+ logger$9('[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$8('[client/actors] [addModelsToDb] Continuing despite error in test environment');
1079
+ logger$9('[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$7 = debug('seedSdk:helpers:localDbChain');
1092
+ const logger$8 = 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$7('local DB holds chain %d', localChainId);
1162
+ logger$8('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$6 = debug('seedSdk:client:actors:saveConfig');
1188
+ const logger$7 = 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$6('saveConfig starting');
1229
+ logger$7('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$6('[internal/actors] [saveConfig] Invalid endpoints:', { endpoints });
1235
+ logger$7('[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$6('[internal/actors] [saveConfig] App DB not found, but continuing in test environment');
1244
+ logger$7('[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$6('[internal/actors] [saveConfig] Error saving config:', error);
1299
+ logger$7('[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$6('[internal/actors] [saveConfig] Continuing despite error in test environment');
1302
+ logger$7('[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$6('[internal/actors] [saveConfig] saveConfig success');
1311
+ logger$7('[internal/actors] [saveConfig] saveConfig success');
1312
1312
  return sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
1313
1313
  })
1314
1314
  .catch((error) => {
1315
- logger$6('[internal/actors] [saveConfig] Error in saveConfig promise chain:', error);
1315
+ logger$7('[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$6('[internal/actors] [saveConfig] Sending success despite error in test environment');
1318
+ logger$7('[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$5 = debug('seedSdk:helpers:schema');
1331
+ const logger$6 = 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$5(`Working directory does not exist yet: ${workingDir}, returning empty schema list`);
1527
+ logger$6(`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$5(`Error listing complete schema files (continuing with DB data): ${error instanceof Error ? error.message : String(error)}`);
1664
+ logger$6(`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$5(`Error parsing schemaData for ${schemaName}:`, error);
1717
+ logger$6(`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$5(`Error loading schema file for ${schemaName}:`, error);
1759
+ logger$6(`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$5(`Error parsing schemaData for ${schemaName}:`, error);
1803
+ logger$6(`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$5(`STEP 3: skipping internal schema file: ${schemaFileInfo.filePath}`);
1814
+ logger$6(`STEP 3: skipping internal schema file: ${schemaFileInfo.filePath}`);
1815
1815
  continue;
1816
1816
  }
1817
1817
  try {
1818
- logger$5(`STEP 3: processing schema file: ${schemaFileInfo.name} from ${schemaFileInfo.filePath}`);
1818
+ logger$6(`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$5(`Error loading schema file ${schemaFileInfo.filePath}:`, error);
1838
+ logger$6(`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$5('Starting migration of file-based schemas to database');
1855
+ logger$6('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$5(`Skipping invalid schema file: ${schemaFileInfo.filePath}`);
1865
+ logger$6(`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$5(`Migrated schema: ${schemaName} v${schemaFile.version}`);
1887
+ logger$6(`Migrated schema: ${schemaName} v${schemaFile.version}`);
1888
1888
  }
1889
1889
  else {
1890
- logger$5(`Schema ${schemaName} already exists in database, skipping`);
1890
+ logger$6(`Schema ${schemaName} already exists in database, skipping`);
1891
1891
  }
1892
1892
  }
1893
1893
  catch (error) {
1894
- logger$5(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
1894
+ logger$6(`Error migrating schema file ${schemaFileInfo.filePath}:`, error);
1895
1895
  }
1896
1896
  }
1897
- logger$5(`Migration complete: ${migratedCount} schemas migrated`);
1897
+ logger$6(`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$4 = debug('seedSdk:imports:json');
1950
+ const logger$5 = 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-DT63t0XU.js');
2029
- const _ns_0 = _mod_0.a_;
2028
+ const _mod_0 = await import('./BasePathResolver-DrzGVH9L.js');
2029
+ const _ns_0 = _mod_0.b6;
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$4(`Verified properties exist for model "${modelName}" (modelId: ${modelId}) after ${attempt + 1} attempt(s)`);
2041
+ logger$5(`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$4(`Properties not yet visible for model "${modelName}" (modelId: ${modelId}), retrying in ${retryDelay}ms (attempt ${attempt + 1}/${maxRetries})`);
2045
+ logger$5(`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
  }
@@ -2331,6 +2331,46 @@ const getSchemaFilePath = (workingDir, name, version, schemaFileId) => {
2331
2331
  const filename = `${schemaFileId}_${sanitizedName}_v${version}.json`;
2332
2332
  return path.join(workingDir, filename);
2333
2333
  };
2334
+ /**
2335
+ * Import a JSON schema file and save it in the full schema file format
2336
+ * Also converts the JSON models to Model classes and adds them to the database
2337
+ * @param importFilePath - Path to the JSON import file
2338
+ * @param version - The version number for the schema (defaults to 1)
2339
+ * @returns The file path where the schema was saved
2340
+ * @throws Error if import file cannot be read, parsed, or if schema already exists
2341
+ */
2342
+ /**
2343
+ * Warns when two models, or two properties of one model, have the same EAS name (ADR 0008): they
2344
+ * would publish to the same EAS schema (`HTMLPage` and `HtmlPage` are both `html_page`). A warning,
2345
+ * not an error, so schema files that already load keep loading.
2346
+ */
2347
+ function warnOnEasNameCollisions(schemaFile) {
2348
+ const warnings = [];
2349
+ const collisions = (names) => {
2350
+ const byEasName = new Map();
2351
+ for (const [name, eas] of names)
2352
+ byEasName.set(eas, [...(byEasName.get(eas) ?? []), name]);
2353
+ return [...byEasName.entries()].filter(([, group]) => group.length > 1);
2354
+ };
2355
+ const models = Object.entries(schemaFile.models ?? {});
2356
+ for (const [eas, group] of collisions(models.map(([name]) => [name, easName(name)]))) {
2357
+ warnings.push(`models ${group.join(', ')} all publish as "bytes32 ${eas}"`);
2358
+ }
2359
+ for (const [modelName, model] of models) {
2360
+ const properties = Object.entries(model?.properties ?? {});
2361
+ const named = properties.map(([key, def]) => [
2362
+ key,
2363
+ easPropertyNameForPublish(key, { ...def, dataType: def?.dataType ?? def?.type, name: key }),
2364
+ ]);
2365
+ for (const [eas, group] of collisions(named)) {
2366
+ warnings.push(`${modelName} properties ${group.join(', ')} all publish as "${eas}"`);
2367
+ }
2368
+ }
2369
+ for (const warning of warnings) {
2370
+ console.warn(`[seed] schema ${schemaFile.metadata?.name ?? ''}: ${warning}; EAS can't tell them apart.`);
2371
+ }
2372
+ return warnings;
2373
+ }
2334
2374
  async function importJsonSchema(importFilePathOrContents, version = 1) {
2335
2375
  // Determine if we have a file path or file contents
2336
2376
  let importData;
@@ -2348,7 +2388,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2348
2388
  if (parsed.$schema && parsed.metadata) {
2349
2389
  // It's already a complete schema format - preserve it (id may be missing, will be generated)
2350
2390
  originalSchemaFile = parsed;
2351
- logger$4(`Input is complete schema format (${originalSchemaFile.id ? `preserving ID: ${originalSchemaFile.id}` : 'id will be generated'})`);
2391
+ logger$5(`Input is complete schema format (${originalSchemaFile.id ? `preserving ID: ${originalSchemaFile.id}` : 'id will be generated'})`);
2352
2392
  }
2353
2393
  }
2354
2394
  catch {
@@ -2373,8 +2413,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2373
2413
  // Check DB for existing schema by name+version (same as minimal path)
2374
2414
  const db = BaseDb.getAppDb();
2375
2415
  if (db) {
2376
- const _mod_1 = await import('./BasePathResolver-DT63t0XU.js');
2377
- const _ns_1 = _mod_1.b0;
2416
+ const _mod_1 = await import('./BasePathResolver-DrzGVH9L.js');
2417
+ const _ns_1 = _mod_1.b8;
2378
2418
  const schemaSchemaMod = _ns_1;
2379
2419
  const { schemas: schemasTable } = schemaSchemaMod;
2380
2420
  const drizzleMod = await import('drizzle-orm');
@@ -2387,16 +2427,16 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2387
2427
  .limit(1);
2388
2428
  if (existingByName.length > 0 && existingByName[0].schemaData) {
2389
2429
  const existing = existingByName[0];
2390
- logger$4(`Idempotency: found existing schema by name+version: ${schemaFile.metadata.name} v${schemaFile.version ?? version}`);
2430
+ logger$5(`Idempotency: found existing schema by name+version: ${schemaFile.metadata.name} v${schemaFile.version ?? version}`);
2391
2431
  const existingSchema = JSON.parse(existing.schemaData);
2392
2432
  const contentMatches = compareSchemaContent(schemaFile, existingSchema);
2393
- logger$4(`Idempotency: compareSchemaContent=${contentMatches} for ${schemaFile.metadata.name}`);
2433
+ logger$5(`Idempotency: compareSchemaContent=${contentMatches} for ${schemaFile.metadata.name}`);
2394
2434
  if (contentMatches) {
2395
2435
  if (existing.schemaFileId) {
2396
2436
  const workingDir = BaseFileManager.getWorkingDir();
2397
2437
  const existingFilePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, schemaFile.version ?? version, existing.schemaFileId);
2398
2438
  if (await BaseFileManager.pathExists(existingFilePath)) {
2399
- logger$4(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content, loading existing file`);
2439
+ logger$5(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content, loading existing file`);
2400
2440
  return await loadSchemaFromFile(existingFilePath);
2401
2441
  }
2402
2442
  await BaseFileManager.createDirIfNotExists(workingDir);
@@ -2404,7 +2444,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2404
2444
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2405
2445
  return await loadSchemaFromFile(existingFilePath);
2406
2446
  }
2407
- logger$4(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content (no schemaFileId), using DB`);
2447
+ logger$5(`Schema ${schemaFile.metadata.name} v${schemaFile.version} already exists with same content (no schemaFileId), using DB`);
2408
2448
  return '';
2409
2449
  }
2410
2450
  }
@@ -2420,7 +2460,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2420
2460
  // processSchemaFiles runs multiple times (React StrictMode, app restarts).
2421
2461
  if (!schemaFile.id) {
2422
2462
  schemaFile.id = await getDeterministicSchemaFileId(schemaFile);
2423
- logger$4(`Generated deterministic schema ID for ${schemaFile.metadata.name}:`, schemaFile.id);
2463
+ logger$5(`Generated deterministic schema ID for ${schemaFile.metadata.name}:`, schemaFile.id);
2424
2464
  }
2425
2465
  // Before generating IDs, check if a file already exists with this schemaFileId
2426
2466
  // This handles the case where the schema was already loaded via loadSchemaFromFile
@@ -2430,7 +2470,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2430
2470
  const existingFileExists = await BaseFileManager.pathExists(existingFilePath);
2431
2471
  if (existingFileExists) {
2432
2472
  // File already exists with this schemaFileId - just load it instead of creating a new one
2433
- logger$4(`Schema file already exists with schemaFileId ${schemaFile.id}, loading it instead of creating new file`);
2473
+ logger$5(`Schema file already exists with schemaFileId ${schemaFile.id}, loading it instead of creating new file`);
2434
2474
  return await loadSchemaFromFile(existingFilePath);
2435
2475
  }
2436
2476
  // Generate missing model and property IDs.
@@ -2441,12 +2481,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2441
2481
  for (const [modelName, model] of Object.entries(schemaFile.models || {})) {
2442
2482
  if (!model.id) {
2443
2483
  model.id = getDeterministicId(modelName);
2444
- logger$4(`Generated deterministic model ID for ${modelName}:`, model.id);
2484
+ logger$5(`Generated deterministic model ID for ${modelName}:`, model.id);
2445
2485
  }
2446
2486
  for (const [propName, prop] of Object.entries(model.properties || {})) {
2447
2487
  if (!prop.id) {
2448
2488
  prop.id = getDeterministicId(modelName + propName);
2449
- logger$4(`Generated deterministic property ID for ${modelName}.${propName}:`, prop.id);
2489
+ logger$5(`Generated deterministic property ID for ${modelName}.${propName}:`, prop.id);
2450
2490
  }
2451
2491
  }
2452
2492
  }
@@ -2458,8 +2498,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2458
2498
  // For minimal imports: check DB for existing schema before creating new file
2459
2499
  const db = BaseDb.getAppDb();
2460
2500
  if (db) {
2461
- const _mod_2 = await import('./BasePathResolver-DT63t0XU.js');
2462
- const _ns_2 = _mod_2.b0;
2501
+ const _mod_2 = await import('./BasePathResolver-DrzGVH9L.js');
2502
+ const _ns_2 = _mod_2.b8;
2463
2503
  const schemaSchemaMod = _ns_2;
2464
2504
  const { schemas: schemasTable } = schemaSchemaMod;
2465
2505
  const drizzleMod = await import('drizzle-orm');
@@ -2482,14 +2522,14 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2482
2522
  const workingDir = BaseFileManager.getWorkingDir();
2483
2523
  const existingFilePath = getSchemaFilePath(workingDir, importData.name, version, existing.schemaFileId);
2484
2524
  if (await BaseFileManager.pathExists(existingFilePath)) {
2485
- logger$4(`Schema ${importData.name} v${version} already exists with same content, loading existing file`);
2525
+ logger$5(`Schema ${importData.name} v${version} already exists with same content, loading existing file`);
2486
2526
  return await loadSchemaFromFile(existingFilePath);
2487
2527
  }
2488
2528
  // File missing but schemaData exists - restore file from schemaData
2489
2529
  await BaseFileManager.createDirIfNotExists(workingDir);
2490
2530
  await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
2491
2531
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2492
- logger$4(`Restored schema file from schemaData for ${importData.name} v${version}`);
2532
+ logger$5(`Restored schema file from schemaData for ${importData.name} v${version}`);
2493
2533
  return await loadSchemaFromFile(existingFilePath);
2494
2534
  }
2495
2535
  // No schemaFileId - restore file from schemaData using id from parsed schema
@@ -2500,10 +2540,10 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2500
2540
  await BaseFileManager.createDirIfNotExists(workingDir);
2501
2541
  await BaseFileManager.saveFile(existingFilePath, existing.schemaData);
2502
2542
  await BaseFileManager.waitForFileWithContent(existingFilePath, 100, 5000);
2503
- logger$4(`Restored schema file from schemaData for ${importData.name} v${version}`);
2543
+ logger$5(`Restored schema file from schemaData for ${importData.name} v${version}`);
2504
2544
  return await loadSchemaFromFile(existingFilePath);
2505
2545
  }
2506
- logger$4(`Schema ${importData.name} v${version} already exists with same content (no id), using DB`);
2546
+ logger$5(`Schema ${importData.name} v${version} already exists with same content (no id), using DB`);
2507
2547
  return '';
2508
2548
  }
2509
2549
  // Content differs - create new version
@@ -2514,7 +2554,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2514
2554
  .orderBy(desc(schemasTable.version))
2515
2555
  .limit(1);
2516
2556
  const newVersion = latestVersionRows.length > 0 ? latestVersionRows[0].version + 1 : version;
2517
- logger$4(`Schema ${importData.name} content changed, creating new version v${newVersion}`);
2557
+ logger$5(`Schema ${importData.name} content changed, creating new version v${newVersion}`);
2518
2558
  schemaFile = transformImportToSchemaFile(importData, newVersion);
2519
2559
  version = newVersion;
2520
2560
  }
@@ -2535,10 +2575,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2535
2575
  schemaFile = transformImportToSchemaFile(importData, version);
2536
2576
  }
2537
2577
  }
2578
+ warnOnEasNameCollisions(schemaFile);
2538
2579
  // Check if this is an internal SDK schema (should not create files in app directory)
2539
2580
  const isInternal = isInternalSchema(schemaFile.metadata.name, schemaFile.id);
2540
2581
  if (isInternal) {
2541
- logger$4(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
2582
+ logger$5(`Skipping file creation for internal schema: ${schemaFile.metadata.name}`);
2542
2583
  // For internal schemas, just load to database and store, don't create file
2543
2584
  // Extract schema name and version
2544
2585
  const schemaName = schemaFile.metadata?.name;
@@ -2595,7 +2636,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2595
2636
  // Use fixed internal schema ID if missing (never generate for internal)
2596
2637
  if (!schemaFile.id) {
2597
2638
  schemaFile.id = INTERNAL_SCHEMA_IDS[0];
2598
- logger$4('Using fixed internal schema ID:', schemaFile.id);
2639
+ logger$5('Using fixed internal schema ID:', schemaFile.id);
2599
2640
  }
2600
2641
  // Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
2601
2642
  // This ensures Model instances are created with correct IDs
@@ -2605,7 +2646,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2605
2646
  // Generate model ID if missing
2606
2647
  if (!model.id) {
2607
2648
  model.id = generateId();
2608
- logger$4(`Generated model ID for ${modelName}:`, model.id);
2649
+ logger$5(`Generated model ID for ${modelName}:`, model.id);
2609
2650
  // Update the schemaFile object so it's included in schemaData
2610
2651
  schemaFile.models[modelName].id = model.id;
2611
2652
  }
@@ -2615,7 +2656,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2615
2656
  // Generate property ID if missing
2616
2657
  if (!prop.id) {
2617
2658
  prop.id = generateId();
2618
- logger$4(`Generated property ID for ${modelName}.${propName}:`, prop.id);
2659
+ logger$5(`Generated property ID for ${modelName}.${propName}:`, prop.id);
2619
2660
  // Update the schemaFile object so it's included in schemaData
2620
2661
  schemaFile.models[modelName].properties[propName].id = prop.id;
2621
2662
  }
@@ -2627,7 +2668,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2627
2668
  }
2628
2669
  // Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
2629
2670
  const modelDefinitions = await createModelsFromJson(importDataForInternal, modelFileIds, propertyFileIds);
2630
- logger$4('loadSchemaFromFile (internal) - modelDefinitions length:', Object.keys(modelDefinitions).length);
2671
+ logger$5('loadSchemaFromFile (internal) - modelDefinitions length:', Object.keys(modelDefinitions).length);
2631
2672
  // Convert schema file metadata to schema input for database
2632
2673
  const schemaInput = {
2633
2674
  name: schemaName,
@@ -2637,8 +2678,8 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2637
2678
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2638
2679
  };
2639
2680
  // Use dynamic import to break circular dependency
2640
- const _mod_3 = await import('./BasePathResolver-DT63t0XU.js');
2641
- const _ns_3 = _mod_3.b3;
2681
+ const _mod_3 = await import('./BasePathResolver-DrzGVH9L.js');
2682
+ const _ns_3 = _mod_3.bb;
2642
2683
  const dbMod = _ns_3;
2643
2684
  const { addSchemaToDb, addModelsToDb } = dbMod;
2644
2685
  // Try to add schema and models to database if database is available
@@ -2659,12 +2700,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2659
2700
  });
2660
2701
  // Verify expected models are linked (single attempt - addModelsToDb already confirmed)
2661
2702
  const expectedModelNames = Object.keys(schemaFile.models || {});
2662
- const _mod_4 = await import('./BasePathResolver-DT63t0XU.js');
2663
- const _ns_4 = _mod_4.b1;
2703
+ const _mod_4 = await import('./BasePathResolver-DrzGVH9L.js');
2704
+ const _ns_4 = _mod_4.b9;
2664
2705
  const modelSchemaSchemaMod = _ns_4;
2665
2706
  const { modelSchemas } = modelSchemaSchemaMod;
2666
- const _mod_5 = await import('./BasePathResolver-DT63t0XU.js');
2667
- const _ns_5 = _mod_5.a_;
2707
+ const _mod_5 = await import('./BasePathResolver-DrzGVH9L.js');
2708
+ const _ns_5 = _mod_5.b6;
2668
2709
  const modelSchemaMod = _ns_5;
2669
2710
  const { models: modelsTable } = modelSchemaMod;
2670
2711
  const drizzleMod = await import('drizzle-orm');
@@ -2753,12 +2794,12 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2753
2794
  }
2754
2795
  catch (dbError) {
2755
2796
  // Database not available - log warning but continue
2756
- logger$4('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
2797
+ logger$5('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
2757
2798
  }
2758
2799
  // Models are now Model instances, no registration needed
2759
2800
  // They should be created via Model.create() and are accessible via Model static methods
2760
2801
  for (const [modelName] of Object.entries(modelDefinitions)) {
2761
- logger$4('loadSchemaFromFile (internal) - model available:', modelName);
2802
+ logger$5('loadSchemaFromFile (internal) - model available:', modelName);
2762
2803
  }
2763
2804
  // Schema is now saved to database
2764
2805
  // useSchemas hook will pick it up via database queries
@@ -2769,7 +2810,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2769
2810
  // Ensure schema ID is defined (should always be set by this point, but check for safety)
2770
2811
  if (!schemaFile.id) {
2771
2812
  schemaFile.id = generateId();
2772
- logger$4('Generated schema ID before file path creation:', schemaFile.id);
2813
+ logger$5('Generated schema ID before file path creation:', schemaFile.id);
2773
2814
  }
2774
2815
  // Get the target file path using ID-based naming (preferred)
2775
2816
  const filePath = getSchemaFilePath(workingDir, schemaFile.metadata.name, version, schemaFile.id);
@@ -2788,7 +2829,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2788
2829
  const data = JSON.parse(content);
2789
2830
  if (data.$schema) {
2790
2831
  // File is already a complete schema, just load it
2791
- logger$4(`Schema file ${filePath} already exists and is complete, loading it`);
2832
+ logger$5(`Schema file ${filePath} already exists and is complete, loading it`);
2792
2833
  return await loadSchemaFromFile(filePath);
2793
2834
  }
2794
2835
  }
@@ -2806,7 +2847,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
2806
2847
  // Compare schemas structurally
2807
2848
  if (compareSchemasStructurally(schemaFile, existingSchema)) {
2808
2849
  // Schemas match - just load the existing file
2809
- logger$4(`Schema ${schemaFile.metadata.name} v${version} already exists with matching content, loading it`);
2850
+ logger$5(`Schema ${schemaFile.metadata.name} v${version} already exists with matching content, loading it`);
2810
2851
  return await loadSchemaFromFile(filePath);
2811
2852
  }
2812
2853
  else {
@@ -2862,8 +2903,8 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
2862
2903
  createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
2863
2904
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
2864
2905
  };
2865
- const _mod_6 = await import('./BasePathResolver-DT63t0XU.js');
2866
- const _ns_6 = _mod_6.b3;
2906
+ const _mod_6 = await import('./BasePathResolver-DrzGVH9L.js');
2907
+ const _ns_6 = _mod_6.bb;
2867
2908
  const dbMod = _ns_6;
2868
2909
  const { addSchemaToDb, addModelsToDb } = dbMod;
2869
2910
  const db = BaseDb.getAppDb();
@@ -2984,7 +3025,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
2984
3025
  // Generate schema ID if missing (before creating schemaInput)
2985
3026
  if (!schemaFile.id) {
2986
3027
  schemaFile.id = generateId();
2987
- logger$4('Generated schema ID for schema file:', schemaFile.id);
3028
+ logger$5('Generated schema ID for schema file:', schemaFile.id);
2988
3029
  }
2989
3030
  // Extract schemaFileIds from JSON file and generate missing ones BEFORE creating models
2990
3031
  // This ensures Model instances are created with correct IDs
@@ -2994,7 +3035,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
2994
3035
  // Generate model ID if missing
2995
3036
  if (!model.id) {
2996
3037
  model.id = generateId();
2997
- logger$4(`Generated model ID for ${modelName}:`, model.id);
3038
+ logger$5(`Generated model ID for ${modelName}:`, model.id);
2998
3039
  // Update the schemaFile object so it's included in schemaData
2999
3040
  schemaFile.models[modelName].id = model.id;
3000
3041
  }
@@ -3004,7 +3045,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3004
3045
  // Generate property ID if missing
3005
3046
  if (!prop.id) {
3006
3047
  prop.id = generateId();
3007
- logger$4(`Generated property ID for ${modelName}.${propName}:`, prop.id);
3048
+ logger$5(`Generated property ID for ${modelName}.${propName}:`, prop.id);
3008
3049
  // Update the schemaFile object so it's included in schemaData
3009
3050
  schemaFile.models[modelName].properties[propName].id = prop.id;
3010
3051
  }
@@ -3016,7 +3057,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3016
3057
  }
3017
3058
  // Convert JSON models to Model classes, passing modelFileIds and propertyFileIds so Model instances use correct IDs
3018
3059
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3019
- logger$4('loadSchemaFromFile - modelDefinitions length:', Object.keys(modelDefinitions).length);
3060
+ logger$5('loadSchemaFromFile - modelDefinitions length:', Object.keys(modelDefinitions).length);
3020
3061
  // Try to add schema and models to database if database is available
3021
3062
  try {
3022
3063
  const db = BaseDb.getAppDb();
@@ -3030,12 +3071,12 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3030
3071
  ]));
3031
3072
  const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds, propertyDefinitions);
3032
3073
  // Query the database to get model IDs that were just created
3033
- const _mod_7 = await import('./BasePathResolver-DT63t0XU.js');
3034
- const _ns_7 = _mod_7.b1;
3074
+ const _mod_7 = await import('./BasePathResolver-DrzGVH9L.js');
3075
+ const _ns_7 = _mod_7.b9;
3035
3076
  const modelSchemaSchemaMod = _ns_7;
3036
3077
  const { modelSchemas } = modelSchemaSchemaMod;
3037
- const _mod_8 = await import('./BasePathResolver-DT63t0XU.js');
3038
- const _ns_8 = _mod_8.a_;
3078
+ const _mod_8 = await import('./BasePathResolver-DrzGVH9L.js');
3079
+ const _ns_8 = _mod_8.b6;
3039
3080
  const modelSchemaMod = _ns_8;
3040
3081
  const { models: modelsTable } = modelSchemaMod;
3041
3082
  const drizzleMod = await import('drizzle-orm');
@@ -3082,17 +3123,17 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3082
3123
  await new Promise(resolve => setTimeout(resolve, 100));
3083
3124
  }
3084
3125
  }
3085
- logger$4(`Verifying properties: found ${modelLinks.length} model links for schema ${schemaName} (id: ${schemaRecord.id})`);
3126
+ logger$5(`Verifying properties: found ${modelLinks.length} model links for schema ${schemaName} (id: ${schemaRecord.id})`);
3086
3127
  // If we didn't verify via direct lookup, verify via join table
3087
3128
  if (!seedModelId || (seedModel.length === 0 || !seedModel[0].id)) {
3088
3129
  const seedModelLink = modelLinks.find((link) => link.modelName === 'Seed');
3089
3130
  if (seedModelLink && seedModelLink.modelId) {
3090
- logger$4(`Verifying properties for Seed model via join table (modelId: ${seedModelLink.modelId})`);
3131
+ logger$5(`Verifying properties for Seed model via join table (modelId: ${seedModelLink.modelId})`);
3091
3132
  await verifyPropertiesPersisted(db, seedModelLink.modelId, 'Seed', 10, 100);
3092
3133
  }
3093
3134
  else if (modelLinks.length > 0 && modelLinks[0].modelId) {
3094
3135
  // Fallback to first model if Seed not found
3095
- logger$4(`Verifying properties for ${modelLinks[0].modelName} model via join table (modelId: ${modelLinks[0].modelId})`);
3136
+ logger$5(`Verifying properties for ${modelLinks[0].modelName} model via join table (modelId: ${modelLinks[0].modelId})`);
3096
3137
  await verifyPropertiesPersisted(db, modelLinks[0].modelId, modelLinks[0].modelName || 'unknown', 10, 100);
3097
3138
  }
3098
3139
  }
@@ -3100,8 +3141,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3100
3141
  // After properties are created (file path), ensure schemaFile has the correct IDs from database
3101
3142
  // Query the database to get the actual schemaFileId values that were used
3102
3143
  // This ensures schemaData matches what's actually in the database
3103
- const _mod_9 = await import('./BasePathResolver-DT63t0XU.js');
3104
- const _ns_9 = _mod_9.a_;
3144
+ const _mod_9 = await import('./BasePathResolver-DrzGVH9L.js');
3145
+ const _ns_9 = _mod_9.b6;
3105
3146
  const modelSchemaMod2 = _ns_9;
3106
3147
  const { properties: propertiesTable } = modelSchemaMod2;
3107
3148
  let schemaFileUpdated = false;
@@ -3125,7 +3166,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3125
3166
  const currentId = schemaFile.models[modelName].properties[propRecord.name].id;
3126
3167
  if (currentId !== propRecord.schemaFileId) {
3127
3168
  schemaFile.models[modelName].properties[propRecord.name].id = propRecord.schemaFileId;
3128
- logger$4(`Updated schemaFile property ID for ${modelName}.${propRecord.name} from ${currentId} to ${propRecord.schemaFileId}`);
3169
+ logger$5(`Updated schemaFile property ID for ${modelName}.${propRecord.name} from ${currentId} to ${propRecord.schemaFileId}`);
3129
3170
  schemaFileUpdated = true;
3130
3171
  }
3131
3172
  }
@@ -3136,8 +3177,8 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3136
3177
  // This is important even if nothing changed, to ensure consistency
3137
3178
  const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
3138
3179
  // Update the schema record in the database with current schemaData
3139
- const _mod_10 = await import('./BasePathResolver-DT63t0XU.js');
3140
- const _ns_10 = _mod_10.b0;
3180
+ const _mod_10 = await import('./BasePathResolver-DrzGVH9L.js');
3181
+ const _ns_10 = _mod_10.b8;
3141
3182
  const schemaSchemaMod = _ns_10;
3142
3183
  const { schemas: schemasTable } = schemaSchemaMod;
3143
3184
  await db
@@ -3145,21 +3186,21 @@ const loadSchemaFromFile = async (schemaFilePath) => {
3145
3186
  .set({ schemaData: updatedSchemaData })
3146
3187
  .where(eq(schemasTable.id, schemaRecord.id));
3147
3188
  if (schemaFileUpdated) {
3148
- logger$4(`Updated schemaData in database with actual property IDs for schema "${schemaName}"`);
3189
+ logger$5(`Updated schemaData in database with actual property IDs for schema "${schemaName}"`);
3149
3190
  }
3150
3191
  else {
3151
- logger$4(`Verified schemaData in database matches schemaFile for schema "${schemaName}"`);
3192
+ logger$5(`Verified schemaData in database matches schemaFile for schema "${schemaName}"`);
3152
3193
  }
3153
3194
  }
3154
3195
  }
3155
3196
  catch (dbError) {
3156
3197
  // Database not available - log warning but continue
3157
- logger$4('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
3198
+ logger$5('Database not available, skipping database operations:', dbError instanceof Error ? dbError.message : String(dbError));
3158
3199
  }
3159
3200
  // Models are now Model instances, no registration needed
3160
3201
  // They should be created via Model.create() and are accessible via Model static methods
3161
3202
  for (const [modelName] of Object.entries(modelDefinitions)) {
3162
- logger$4('loadSchemaFromFile - model available:', modelName);
3203
+ logger$5('loadSchemaFromFile - model available:', modelName);
3163
3204
  }
3164
3205
  return schemaFilePath;
3165
3206
  }
@@ -3246,7 +3287,7 @@ const jsonPropertiesToSchemaProperties = (modelName, modelDef, propertyFileIds)
3246
3287
  */
3247
3288
  const createModelFromJson = async (modelName, modelDef, schemaName, modelFileId, // Optional modelFileId from JSON file
3248
3289
  propertyFileIds) => {
3249
- const _mod_11 = await import('./errors-D1brJy1k.js');
3290
+ const _mod_11 = await import('./errors-DdWbxb_n.js');
3250
3291
  const _ns_11 = _mod_11.h;
3251
3292
  const modelMod = _ns_11;
3252
3293
  const { Model } = modelMod;
@@ -3255,10 +3296,10 @@ propertyFileIds) => {
3255
3296
  // Pass id (schemaFileId) if provided to ensure Model instance uses correct ID
3256
3297
  // Note: indexes and description are ignored - they remain in JSON for schema file format compliance but are not used by Model instances
3257
3298
  if (modelFileId) {
3258
- logger$4(`Creating schema model "${modelName}" with modelFileId: ${modelFileId}`);
3299
+ logger$5(`Creating schema model "${modelName}" with modelFileId: ${modelFileId}`);
3259
3300
  }
3260
3301
  else {
3261
- logger$4(`Warning: Creating schema model "${modelName}" without modelFileId - it will be renamed if duplicates exist`);
3302
+ logger$5(`Warning: Creating schema model "${modelName}" without modelFileId - it will be renamed if duplicates exist`);
3262
3303
  }
3263
3304
  const modelInstance = Model.create(modelName, schemaName, {
3264
3305
  modelFileId: modelFileId, // Pass modelFileId (preferred) as id (schemaFileId) from JSON file
@@ -3284,7 +3325,7 @@ const createModelsFromJson = async (importData, modelFileIds, propertyFileIds) =
3284
3325
  // Use modelFileId from map (no fallback to modelDef.id as JsonImportSchema doesn't have id property)
3285
3326
  const finalModelFileId = modelFileId;
3286
3327
  if (!finalModelFileId) {
3287
- logger$4(`Warning: No modelFileId found for model "${modelName}" - model will be created without ID`);
3328
+ logger$5(`Warning: No modelFileId found for model "${modelName}" - model will be created without ID`);
3288
3329
  }
3289
3330
  // Get propertyFileIds for this model if available
3290
3331
  const modelPropertyFileIds = propertyFileIds?.get(modelName);
@@ -3474,7 +3515,7 @@ var SEEDPROTOCOL_Seed_Protocol_v1 = /*#__PURE__*/Object.freeze({
3474
3515
  version: version
3475
3516
  });
3476
3517
 
3477
- const logger$3 = debug('seedSdk:client:actors:processSchemaFiles');
3518
+ const logger$4 = debug('seedSdk:client:actors:processSchemaFiles');
3478
3519
  let processSchemaFilesChain = Promise.resolve();
3479
3520
  function resolveSchemaFilePath(schemaFile) {
3480
3521
  const path = BaseFileManager.getPathModule();
@@ -3502,7 +3543,7 @@ async function resolveSchemaNameFromSource(source) {
3502
3543
  }
3503
3544
  }
3504
3545
  catch (error) {
3505
- logger$3('Could not resolve schema name from path:', source, error);
3546
+ logger$4('Could not resolve schema name from path:', source, error);
3506
3547
  }
3507
3548
  }
3508
3549
  return null;
@@ -3517,7 +3558,7 @@ function userSchemaLoadError(option, source, error) {
3517
3558
  // Schema processing can be slow with syncSchemaFromSource, loadAllSchemasFromDb, and OPFS file I/O
3518
3559
  const PROCESS_SCHEMA_FILES_TIMEOUT_MS = 120000;
3519
3560
  const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3520
- logger$3('processSchemaFiles started');
3561
+ logger$4('processSchemaFiles started');
3521
3562
  let hasResponded = false;
3522
3563
  let timeoutId = null;
3523
3564
  const reportError = (error) => {
@@ -3527,7 +3568,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3527
3568
  clearTimeout(timeoutId);
3528
3569
  timeoutId = null;
3529
3570
  }
3530
- logger$3('processSchemaFiles error:', error);
3571
+ logger$4('processSchemaFiles error:', error);
3531
3572
  sendBack({
3532
3573
  type: 'error',
3533
3574
  error: error instanceof Error ? error : new Error(String(error))
@@ -3541,7 +3582,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3541
3582
  clearTimeout(timeoutId);
3542
3583
  timeoutId = null;
3543
3584
  }
3544
- logger$3('processSchemaFiles completed');
3585
+ logger$4('processSchemaFiles completed');
3545
3586
  sendBack({ type: ClientManagerEvents.PROCESS_SCHEMA_FILES_SUCCESS });
3546
3587
  }
3547
3588
  };
@@ -3553,7 +3594,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3553
3594
  // Schemas written (or confirmed present) this run — skip redundant loadSchemaFromFile later
3554
3595
  const schemasWrittenThisRun = new Set();
3555
3596
  // First, load the internal seed-protocol schema
3556
- logger$3('Loading internal seed-protocol schema');
3597
+ logger$4('Loading internal seed-protocol schema');
3557
3598
  const internalSchemaData = internalSchema;
3558
3599
  const db = BaseDb.getAppDb();
3559
3600
  const internalSchemaExists = db
@@ -3562,21 +3603,21 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3562
3603
  // Always mark internal schema as written so the DB/file loop does not re-apply it
3563
3604
  schemasWrittenThisRun.add(SEED_PROTOCOL_SCHEMA_NAME);
3564
3605
  if (internalSchemaExists) {
3565
- logger$3('Internal seed-protocol schema already in DB, skipping import');
3606
+ logger$4('Internal seed-protocol schema already in DB, skipping import');
3566
3607
  }
3567
3608
  else {
3568
3609
  try {
3569
3610
  // Import the internal schema to database (will create models and add to store)
3570
3611
  await importJsonSchema({ contents: JSON.stringify(internalSchemaData) }, internalSchemaData.version);
3571
- logger$3(`Loaded internal seed-protocol schema v${internalSchemaData.version}`);
3612
+ logger$4(`Loaded internal seed-protocol schema v${internalSchemaData.version}`);
3572
3613
  }
3573
3614
  catch (error) {
3574
3615
  // If schema already exists, that's fine - it means it was already loaded
3575
3616
  if (error?.message?.includes('already exists')) {
3576
- logger$3('Internal seed-protocol schema already loaded');
3617
+ logger$4('Internal seed-protocol schema already loaded');
3577
3618
  }
3578
3619
  else {
3579
- logger$3('Error loading internal seed-protocol schema:', error);
3620
+ logger$4('Error loading internal seed-protocol schema:', error);
3580
3621
  // Don't fail if internal schema can't be loaded - it might already be in DB
3581
3622
  }
3582
3623
  }
@@ -3589,7 +3630,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3589
3630
  : '';
3590
3631
  const schemaId = typeof context.schema === 'object' && context.schema?.id ? String(context.schema.id) : undefined;
3591
3632
  if (isInternalSchema(schemaName, schemaId)) {
3592
- logger$3('Schema is internal (Seed Protocol), already loaded - skipping syncSchemaFromSource');
3633
+ logger$4('Schema is internal (Seed Protocol), already loaded - skipping syncSchemaFromSource');
3593
3634
  }
3594
3635
  else {
3595
3636
  try {
@@ -3598,7 +3639,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3598
3639
  if (syncedName) {
3599
3640
  schemasWrittenThisRun.add(syncedName);
3600
3641
  }
3601
- logger$3(`Synced canonical schema from ${typeof context.schema === 'string' ? context.schema : 'object'}`);
3642
+ logger$4(`Synced canonical schema from ${typeof context.schema === 'string' ? context.schema : 'object'}`);
3602
3643
  }
3603
3644
  catch (error) {
3604
3645
  // A schema the app passed in failed (missing file, bad JSON, DB write). Re-running an
@@ -3617,7 +3658,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3617
3658
  if (parsed?.metadata?.name) {
3618
3659
  schemasWrittenThisRun.add(String(parsed.metadata.name));
3619
3660
  }
3620
- logger$3(`Loaded schema from ${resolvedPath}`);
3661
+ logger$4(`Loaded schema from ${resolvedPath}`);
3621
3662
  }
3622
3663
  catch (error) {
3623
3664
  throw userSchemaLoadError('schemaFile', context.schemaFile, error);
@@ -3625,14 +3666,14 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3625
3666
  }
3626
3667
  // Process minimal import files (files without $schema) - skip when canonical schema is set
3627
3668
  if (!context.schema) {
3628
- logger$3('Listing schema files');
3669
+ logger$4('Listing schema files');
3629
3670
  let schemaFiles = [];
3630
3671
  try {
3631
3672
  schemaFiles = await listSchemaFiles();
3632
- logger$3(`Found ${schemaFiles.length} schema files to process`);
3673
+ logger$4(`Found ${schemaFiles.length} schema files to process`);
3633
3674
  }
3634
3675
  catch (error) {
3635
- logger$3('Error listing schema files (continuing anyway):', error);
3676
+ logger$4('Error listing schema files (continuing anyway):', error);
3636
3677
  schemaFiles = [];
3637
3678
  }
3638
3679
  for (const schemaFile of schemaFiles) {
@@ -3643,19 +3684,19 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3643
3684
  }
3644
3685
  }
3645
3686
  catch (error) {
3646
- logger$3(`Error importing schema file ${schemaFile.filePath}:`, error);
3687
+ logger$4(`Error importing schema file ${schemaFile.filePath}:`, error);
3647
3688
  }
3648
3689
  }
3649
3690
  }
3650
3691
  // Then, load all schemas using the unified database-first approach
3651
- logger$3('Loading schemas from database and files');
3692
+ logger$4('Loading schemas from database and files');
3652
3693
  let allSchemasData = [];
3653
3694
  try {
3654
3695
  allSchemasData = await loadAllSchemasFromDb();
3655
- logger$3(`Loaded ${allSchemasData.length} schemas (${allSchemasData.filter(s => s.isDraft).length} drafts, ${allSchemasData.filter(s => !s.isDraft).length} published)`);
3696
+ logger$4(`Loaded ${allSchemasData.length} schemas (${allSchemasData.filter(s => s.isDraft).length} drafts, ${allSchemasData.filter(s => !s.isDraft).length} published)`);
3656
3697
  }
3657
3698
  catch (error) {
3658
- logger$3('Error loading schemas from database (continuing anyway):', error);
3699
+ logger$4('Error loading schemas from database (continuing anyway):', error);
3659
3700
  // Continue with empty array - this is not critical for initialization
3660
3701
  // Schemas can be loaded on-demand later
3661
3702
  allSchemasData = [];
@@ -3676,13 +3717,13 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3676
3717
  }
3677
3718
  }
3678
3719
  catch (error) {
3679
- logger$3('Error counting linked models (re-applying all schema files):', error);
3720
+ logger$4('Error counting linked models (re-applying all schema files):', error);
3680
3721
  }
3681
3722
  }
3682
3723
  for (const schemaData of allSchemasData) {
3683
3724
  const schema = schemaData.schema;
3684
3725
  const schemaName = schema.metadata?.name || 'unknown';
3685
- logger$3(`Processing schema: ${schemaName} v${schema.version} (${schemaData.isDraft ? 'draft' : 'published'}, source: ${schemaData.source})`);
3726
+ logger$4(`Processing schema: ${schemaName} v${schema.version} (${schemaData.isDraft ? 'draft' : 'published'}, source: ${schemaData.source})`);
3686
3727
  // For published schemas (not drafts), load models from file if available
3687
3728
  if (!schemaData.isDraft && schema.id) {
3688
3729
  // loadAllSchemasFromDb already picked the latest file for this schema (and read it)
@@ -3712,7 +3753,7 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3712
3753
  }
3713
3754
  }
3714
3755
  catch (error) {
3715
- logger$3(`Error loading schema file for ${schemaName}:`, error);
3756
+ logger$4(`Error loading schema file for ${schemaName}:`, error);
3716
3757
  }
3717
3758
  }
3718
3759
  else {
@@ -3761,11 +3802,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3761
3802
  };
3762
3803
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3763
3804
  Object.assign(allModels, modelDefinitions);
3764
- logger$3(`Loaded ${Object.keys(modelDefinitions).length} models from schema data for ${schemaName}`);
3805
+ logger$4(`Loaded ${Object.keys(modelDefinitions).length} models from schema data for ${schemaName}`);
3765
3806
  }
3766
3807
  }
3767
3808
  catch (error) {
3768
- logger$3(`Error creating models from schema data for ${schemaName}:`, error);
3809
+ logger$4(`Error creating models from schema data for ${schemaName}:`, error);
3769
3810
  }
3770
3811
  }
3771
3812
  }
@@ -3815,11 +3856,11 @@ const processSchemaFiles = fromCallback(({ sendBack, input: { context } }) => {
3815
3856
  };
3816
3857
  const modelDefinitions = await createModelsFromJson(importData, modelFileIds, propertyFileIds);
3817
3858
  Object.assign(allModels, modelDefinitions);
3818
- logger$3(`Loaded ${Object.keys(modelDefinitions).length} models from draft schema ${schemaName}`);
3859
+ logger$4(`Loaded ${Object.keys(modelDefinitions).length} models from draft schema ${schemaName}`);
3819
3860
  }
3820
3861
  }
3821
3862
  catch (error) {
3822
- logger$3(`Error creating models from draft schema ${schemaName}:`, error);
3863
+ logger$4(`Error creating models from draft schema ${schemaName}:`, error);
3823
3864
  }
3824
3865
  }
3825
3866
  // Schemas are now loaded on-demand via database queries (useSchemas hook uses loadAllSchemasFromDb)
@@ -3916,7 +3957,7 @@ const convertVerbatimItemStorageRow = async (localId, storage = {}) => {
3916
3957
  });
3917
3958
  };
3918
3959
 
3919
- const logger$2 = debug('seedSdk:db:migrateLegacyItemStorageRows');
3960
+ const logger$3 = debug('seedSdk:db:migrateLegacyItemStorageRows');
3920
3961
  /** appState key recording that legacy ItemStorage rows have been written to their files. */
3921
3962
  const LEGACY_ITEM_STORAGE_MIGRATION_KEY = 'legacyItemStorageFiles:v1';
3922
3963
  /** Runs in a row that left rows unconverted because a file write failed, before giving up. */
@@ -4070,7 +4111,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
4070
4111
  });
4071
4112
  if (converted) {
4072
4113
  result.converted++;
4073
- logger$2(`wrote ${row.propertyName} of ${row.seedLocalId} to ${converted.filePath}`);
4114
+ logger$3(`wrote ${row.propertyName} of ${row.seedLocalId} to ${converted.filePath}`);
4074
4115
  }
4075
4116
  else {
4076
4117
  result.skipped++;
@@ -4078,7 +4119,7 @@ async function migrateLegacyItemStorageRows(options = {}) {
4078
4119
  }
4079
4120
  catch (error) {
4080
4121
  result.failed++;
4081
- logger$2(`converting ${row.propertyName} of ${row.seedLocalId} (${row.localId}) failed; left as is`, error);
4122
+ logger$3(`converting ${row.propertyName} of ${row.seedLocalId} (${row.localId}) failed; left as is`, error);
4082
4123
  }
4083
4124
  }
4084
4125
  const attempts = previousAttempts + 1;
@@ -4090,24 +4131,24 @@ async function migrateLegacyItemStorageRows(options = {}) {
4090
4131
  at: Date.now(),
4091
4132
  });
4092
4133
  if (result.candidates > 0) {
4093
- logger$2(`legacy ItemStorage rows: ${result.converted} converted, ${result.failed} failed, ` +
4134
+ logger$3(`legacy ItemStorage rows: ${result.converted} converted, ${result.failed} failed, ` +
4094
4135
  `${result.skipped} skipped of ${result.candidates}`);
4095
4136
  }
4096
4137
  return result;
4097
4138
  }
4098
- let running$1;
4099
- let deferredUntilLeader$1 = false;
4100
- const runInBackground$1 = () => {
4101
- running$1 ?? (running$1 = withDbTabLock('item-storage-migration', () => migrateLegacyItemStorageRows())
4139
+ let running$2;
4140
+ let deferredUntilLeader$2 = false;
4141
+ const runInBackground$2 = () => {
4142
+ running$2 ?? (running$2 = withDbTabLock('item-storage-migration', () => migrateLegacyItemStorageRows())
4102
4143
  .then(() => undefined)
4103
4144
  .catch((error) => {
4104
4145
  // Never fails init: rows stay as they were and publish converts them lazily.
4105
- logger$2('legacy ItemStorage migration failed', error);
4146
+ logger$3('legacy ItemStorage migration failed', error);
4106
4147
  })
4107
4148
  .finally(() => {
4108
- running$1 = undefined;
4149
+ running$2 = undefined;
4109
4150
  }));
4110
- return running$1;
4151
+ return running$2;
4111
4152
  };
4112
4153
  /**
4113
4154
  * Starts {@link migrateLegacyItemStorageRows} in the background once client init has finished
@@ -4117,19 +4158,19 @@ const runInBackground$1 = () => {
4117
4158
  */
4118
4159
  function startLegacyItemStorageMigration() {
4119
4160
  if (isLeaderTab()) {
4120
- void runInBackground$1();
4161
+ void runInBackground$2();
4121
4162
  return;
4122
4163
  }
4123
- if (deferredUntilLeader$1)
4164
+ if (deferredUntilLeader$2)
4124
4165
  return;
4125
- deferredUntilLeader$1 = true;
4166
+ deferredUntilLeader$2 = true;
4126
4167
  void whenLeaderTab().then(() => {
4127
- deferredUntilLeader$1 = false;
4128
- void runInBackground$1();
4168
+ deferredUntilLeader$2 = false;
4169
+ void runInBackground$2();
4129
4170
  });
4130
4171
  }
4131
4172
 
4132
- const logger$1 = debug('seedSdk:db:removeForeignAttestationRows');
4173
+ const logger$2 = debug('seedSdk:db:removeForeignAttestationRows');
4133
4174
  /** appState key recording that the cleanup below has run on this database. */
4134
4175
  const FOREIGN_ATTESTATION_CLEANUP_KEY = 'foreignAttestationRowsRemoved';
4135
4176
  /** Lowercased `attester` of a stored attestation JSON; NULL when the JSON is invalid or has none. */
@@ -4187,22 +4228,22 @@ async function runOnce() {
4187
4228
  .values({ key: FOREIGN_ATTESTATION_CLEANUP_KEY, value })
4188
4229
  .onConflictDoUpdate({ target: appState.key, set: { value } });
4189
4230
  if (result.versionRows > 0 || result.propertyRows > 0) {
4190
- logger$1(`removed ${result.versionRows} version and ${result.propertyRows} property rows from other attesters`);
4231
+ logger$2(`removed ${result.versionRows} version and ${result.propertyRows} property rows from other attesters`);
4191
4232
  }
4192
4233
  }
4193
- let running;
4194
- let deferredUntilLeader = false;
4195
- const runInBackground = () => {
4234
+ let running$1;
4235
+ let deferredUntilLeader$1 = false;
4236
+ const runInBackground$1 = () => {
4196
4237
  // Under the sync's lock, so it can't interleave with a sync writing the same rows.
4197
- running ?? (running = withDbTabLock('eas-sync', runOnce, { timeoutMs: Infinity })
4238
+ running$1 ?? (running$1 = withDbTabLock('eas-sync', runOnce, { timeoutMs: Infinity })
4198
4239
  .catch((error) => {
4199
4240
  // Never fails init: the rows stay until the next sync of their seeds removes them.
4200
- logger$1('foreign attestation cleanup failed', error);
4241
+ logger$2('foreign attestation cleanup failed', error);
4201
4242
  })
4202
4243
  .finally(() => {
4203
- running = undefined;
4244
+ running$1 = undefined;
4204
4245
  }));
4205
- return running;
4246
+ return running$1;
4206
4247
  };
4207
4248
  /**
4208
4249
  * Starts {@link removeForeignAttestationRows} in the background after client init, once per
@@ -4211,6 +4252,81 @@ const runInBackground = () => {
4211
4252
  * tab only (docs/MULTI_TAB.md); a tab that isn't leader runs it if it takes over. Never throws.
4212
4253
  */
4213
4254
  function startForeignAttestationCleanup() {
4255
+ if (isLeaderTab()) {
4256
+ void runInBackground$1();
4257
+ return;
4258
+ }
4259
+ if (deferredUntilLeader$1)
4260
+ return;
4261
+ deferredUntilLeader$1 = true;
4262
+ void whenLeaderTab().then(() => {
4263
+ deferredUntilLeader$1 = false;
4264
+ void runInBackground$1();
4265
+ });
4266
+ }
4267
+
4268
+ const logger$1 = debug('seedSdk:db:canonicalizeModelTypes');
4269
+ /**
4270
+ * Model types in the local DB (`seeds.type`, `versions.seed_type`, `metadata.model_type`) are the
4271
+ * EAS name of the model (ADR 0008): `html_page` for HTMLPage. Rows written before that hold other
4272
+ * forms: drizzle's snake_case for local seeds (`image_v_2`), or the name an older SDK published,
4273
+ * 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.
4276
+ */
4277
+ async function canonicalizeModelTypes() {
4278
+ const appDb = BaseDb.getAppDb();
4279
+ const modelNames = (await appDb.selectDistinct({ name: models$1.name }).from(models$1))
4280
+ .map((row) => row.name)
4281
+ .filter(Boolean);
4282
+ if (modelNames.length === 0)
4283
+ return 0;
4284
+ const storedTypes = new Set();
4285
+ const collect = (rows) => {
4286
+ for (const row of rows)
4287
+ if (row.type)
4288
+ storedTypes.add(row.type);
4289
+ };
4290
+ collect(await appDb.selectDistinct({ type: seeds.type }).from(seeds).where(isNotNull(seeds.type)));
4291
+ collect(await appDb.selectDistinct({ type: versions.seedType }).from(versions).where(isNotNull(versions.seedType)));
4292
+ collect(await appDb.selectDistinct({ type: metadata$1.modelType }).from(metadata$1).where(isNotNull(metadata$1.modelType)));
4293
+ let rewritten = 0;
4294
+ for (const type of storedTypes) {
4295
+ const canonical = new Set([...localNamesInBestMatchTier(type, modelNames)].map((name) => easName(name)));
4296
+ if (canonical.size !== 1)
4297
+ continue;
4298
+ const [next] = canonical;
4299
+ if (!next || next === type)
4300
+ continue;
4301
+ await appDb.update(seeds).set({ type: next }).where(eq(seeds.type, type));
4302
+ await appDb.update(versions).set({ seedType: next }).where(eq(versions.seedType, type));
4303
+ await appDb.update(metadata$1).set({ modelType: next }).where(eq(metadata$1.modelType, type));
4304
+ logger$1(`model type ${type} → ${next}`);
4305
+ rewritten++;
4306
+ }
4307
+ return rewritten;
4308
+ }
4309
+ let running;
4310
+ let deferredUntilLeader = false;
4311
+ const runInBackground = () => {
4312
+ // Under the sync's lock: sync writes these columns too.
4313
+ running ?? (running = withDbTabLock('eas-sync', () => canonicalizeModelTypes(), { timeoutMs: Infinity })
4314
+ .then(() => undefined)
4315
+ .catch((error) => {
4316
+ // Never fails init: readers still match old types by name, only exact type filters miss them.
4317
+ logger$1('canonicalizing model types failed', error);
4318
+ })
4319
+ .finally(() => {
4320
+ running = undefined;
4321
+ }));
4322
+ return running;
4323
+ };
4324
+ /**
4325
+ * Starts {@link canonicalizeModelTypes} in the background after client init, in the leader tab
4326
+ * (docs/MULTI_TAB.md). It runs on every init: it reads only the distinct stored types, and a
4327
+ * model added since the last run may match types that matched nothing before. Never throws.
4328
+ */
4329
+ function startCanonicalizeModelTypes() {
4214
4330
  if (isLeaderTab()) {
4215
4331
  void runInBackground();
4216
4332
  return;
@@ -4454,6 +4570,8 @@ const clientManagerMachine = setup({
4454
4570
  () => startLegacyItemStorageMigration(),
4455
4571
  // Also once, in the background: rows an older sync stored from other accounts' attestations.
4456
4572
  () => startForeignAttestationCleanup(),
4573
+ // Stored model types to the ADR 0008 form (html_page), so exact type filters find old rows.
4574
+ () => startCanonicalizeModelTypes(),
4457
4575
  ],
4458
4576
  on: {
4459
4577
  [SAVE_APP_STATE_SUCCESS]: {
@@ -4545,12 +4663,6 @@ function msToUnixSeconds(ms) {
4545
4663
  return Math.floor(ms / 1000);
4546
4664
  return Math.floor(ms);
4547
4665
  }
4548
- function toSnakeCaseName(name) {
4549
- return name
4550
- .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
4551
- .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
4552
- .toLowerCase();
4553
- }
4554
4666
  function parsePropertyValue(raw) {
4555
4667
  if (raw == null)
4556
4668
  return '';
@@ -4667,7 +4779,7 @@ function metadataRowToAttestation(row) {
4667
4779
  }, row.revokedAt);
4668
4780
  }
4669
4781
  const name = row.propertyName
4670
- ? toSnakeCaseName(row.propertyName)
4782
+ ? easName(row.propertyName)
4671
4783
  : 'unknown';
4672
4784
  const value = parsePropertyValue(row.propertyValue);
4673
4785
  const type = row.easDataType || 'string';
@@ -5403,4 +5515,4 @@ var ClientManager$1 = /*#__PURE__*/Object.freeze({
5403
5515
  });
5404
5516
 
5405
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 };
5406
- //# sourceMappingURL=ClientManager-Cos8NaRU.js.map
5518
+ //# sourceMappingURL=ClientManager-Dfu4jcgm.js.map