@seedprotocol/sdk 0.7.4-next.784.g879c6a3 → 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 (120) hide show
  1. package/dist/{BasePathResolver-DxdS0wJ0.js → BasePathResolver-DrzGVH9L.js} +232 -40
  2. package/dist/BasePathResolver-DrzGVH9L.js.map +1 -0
  3. package/dist/{ClientManager-De-vKHGe.js → ClientManager-Dfu4jcgm.js} +583 -219
  4. package/dist/ClientManager-Dfu4jcgm.js.map +1 -0
  5. package/dist/{Item-cq9VcsAY.js → Item-BUUFuywT.js} +175 -306
  6. package/dist/Item-BUUFuywT.js.map +1 -0
  7. package/dist/{ModelProperty-DuuoFXaC.js → ModelProperty-B6cnRvIz.js} +38 -39
  8. package/dist/ModelProperty-B6cnRvIz.js.map +1 -0
  9. package/dist/{Schema-Dc5EA8Yb.js → Schema-Bf-jOLq0.js} +37 -36
  10. package/dist/{Schema-Dc5EA8Yb.js.map → Schema-Bf-jOLq0.js.map} +1 -1
  11. package/dist/{SchemaValidationService-DViJ056F.js → SchemaValidationService-BNYMacsx.js} +7 -8
  12. package/dist/{SchemaValidationService-DViJ056F.js.map → SchemaValidationService-BNYMacsx.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-DacVthS5.js → backfillMetadataPropertyIds-C2-s_jUa.js} +4 -5
  14. package/dist/{backfillMetadataPropertyIds-DacVthS5.js.map → backfillMetadataPropertyIds-C2-s_jUa.js.map} +1 -1
  15. package/dist/{configurePlatform-DlZ23w7e.js → configurePlatform-BzfirKuM.js} +3 -4
  16. package/dist/{configurePlatform-DlZ23w7e.js.map → configurePlatform-BzfirKuM.js.map} +1 -1
  17. package/dist/{detachRowsBeforeDelete-YRSZY6dO.js → detachRowsBeforeDelete-B0Daoz9Z.js} +3 -4
  18. package/dist/{detachRowsBeforeDelete-YRSZY6dO.js.map → detachRowsBeforeDelete-B0Daoz9Z.js.map} +1 -1
  19. package/dist/{eas-D_6ptL_F.js → eas-Dq5Kx_Nd.js} +14 -32
  20. package/dist/eas-Dq5Kx_Nd.js.map +1 -0
  21. package/dist/{errors-Cl8rbtKR.js → errors-DdWbxb_n.js} +42 -39
  22. package/dist/errors-DdWbxb_n.js.map +1 -0
  23. package/dist/{getItem-BcmJcUZB.js → getItem-9bYSErSj.js} +4 -5
  24. package/dist/{getItem-BcmJcUZB.js.map → getItem-9bYSErSj.js.map} +1 -1
  25. package/dist/{getPublishPayload-C278kK9P.js → getPublishPayload-DPy-uMrR.js} +28 -29
  26. package/dist/getPublishPayload-DPy-uMrR.js.map +1 -0
  27. package/dist/{getPublishUploads-DJ1UPh7i.js → getPublishUploads-J-143iSV.js} +10 -11
  28. package/dist/{getPublishUploads-DJ1UPh7i.js.map → getPublishUploads-J-143iSV.js.map} +1 -1
  29. package/dist/{index-DAl9U4rn.js → index-7y2f_iQz.js} +2 -2
  30. package/dist/index-7y2f_iQz.js.map +1 -0
  31. package/dist/{index-CqnU-5i0.js → index-C61Rxy0F.js} +9 -10
  32. package/dist/index-C61Rxy0F.js.map +1 -0
  33. package/dist/{index.browser-J6QZ9smP.js → index.browser-C1pisOEa.js} +10 -10
  34. package/dist/{index.browser-J6QZ9smP.js.map → index.browser-C1pisOEa.js.map} +1 -1
  35. package/dist/{index.node-C9VB9NlX.js → index.node-BAlST8pD.js} +6 -6
  36. package/dist/{index.node-C9VB9NlX.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-Brgr5RdT.js → property-zFPMtR3T.js} +10 -14
  46. package/dist/property-zFPMtR3T.js.map +1 -0
  47. package/dist/{propertyValidationRules-CDRitiiK.js → propertyValidationRules-CeFVhdQg.js} +10 -10
  48. package/dist/{propertyValidationRules-CDRitiiK.js.map → propertyValidationRules-CeFVhdQg.js.map} +1 -1
  49. package/dist/{publishDraftGraph-C37ibxb5.js → publishDraftGraph-CuVq6iAR.js} +7 -6
  50. package/dist/{publishDraftGraph-C37ibxb5.js.map → publishDraftGraph-CuVq6iAR.js.map} +1 -1
  51. package/dist/{resetAmbiguousLegacyItemData-CcLFRREE.js → resetAmbiguousLegacyItemData-DsFTnMBz.js} +5 -6
  52. package/dist/resetAmbiguousLegacyItemData-DsFTnMBz.js.map +1 -0
  53. package/dist/{resolveModelForSyncedSeed-BTAeCOJE.js → resolveModelForSyncedSeed-RUsgAZXG.js} +2 -2
  54. package/dist/{resolveModelForSyncedSeed-BTAeCOJE.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/ClientManager.d.ts.map +1 -1
  64. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  65. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  66. package/dist/src/client/clientManagerMachine.d.ts +2 -2
  67. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  68. package/dist/src/db/canonicalizeModelTypes.d.ts +18 -0
  69. package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -0
  70. package/dist/src/db/read/getModelSchemas.d.ts +6 -0
  71. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  72. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  73. package/dist/src/db/read/getSchemaUidForModel.d.ts +6 -0
  74. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  75. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  76. package/dist/src/db/removeForeignAttestationRows.d.ts +27 -0
  77. package/dist/src/db/removeForeignAttestationRows.d.ts.map +1 -0
  78. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  79. package/dist/src/db/write/easSyncProcess.d.ts +9 -1
  80. package/dist/src/db/write/easSyncProcess.d.ts.map +1 -1
  81. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  82. package/dist/src/eas.d.ts.map +1 -1
  83. package/dist/src/events/item/easSyncManager.d.ts.map +1 -1
  84. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  85. package/dist/src/helpers/db.d.ts +20 -0
  86. package/dist/src/helpers/db.d.ts.map +1 -1
  87. package/dist/src/helpers/index.d.ts +3 -1
  88. package/dist/src/helpers/index.d.ts.map +1 -1
  89. package/dist/src/helpers/metadataPropertyNames.d.ts +12 -0
  90. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  91. package/dist/src/helpers/retryWhenOnline.d.ts +20 -0
  92. package/dist/src/helpers/retryWhenOnline.d.ts.map +1 -0
  93. package/dist/src/imports/json.d.ts +10 -0
  94. package/dist/src/imports/json.d.ts.map +1 -1
  95. package/dist/src/index.d.ts +4 -2
  96. package/dist/src/index.d.ts.map +1 -1
  97. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
  98. package/dist/src/types/import.d.ts +4 -0
  99. package/dist/src/types/import.d.ts.map +1 -1
  100. package/dist/{syncDbWithEas-B-Ho0IOB.js → syncDbWithEas-CRpnkq00.js} +157 -61
  101. package/dist/syncDbWithEas-CRpnkq00.js.map +1 -0
  102. package/dist/{tabEvents-BTzckWrN.js → tabEvents-nBUq_1u1.js} +6 -6
  103. package/dist/{tabEvents-BTzckWrN.js.map → tabEvents-nBUq_1u1.js.map} +1 -1
  104. package/dist/{tolerantWebAccess-DOm2Xv-f.js → tolerantWebAccess-DIt3R8_u.js} +7 -8
  105. package/dist/{tolerantWebAccess-DOm2Xv-f.js.map → tolerantWebAccess-DIt3R8_u.js.map} +1 -1
  106. package/dist/{updateSeedRevokedAt-IHXnJI-i.js → updateSeedRevokedAt-DtTPSzpM.js} +3 -3
  107. package/dist/{updateSeedRevokedAt-IHXnJI-i.js.map → updateSeedRevokedAt-DtTPSzpM.js.map} +1 -1
  108. package/package.json +5 -5
  109. package/dist/BasePathResolver-DxdS0wJ0.js.map +0 -1
  110. package/dist/ClientManager-De-vKHGe.js.map +0 -1
  111. package/dist/Item-cq9VcsAY.js.map +0 -1
  112. package/dist/ModelProperty-DuuoFXaC.js.map +0 -1
  113. package/dist/eas-D_6ptL_F.js.map +0 -1
  114. package/dist/errors-Cl8rbtKR.js.map +0 -1
  115. package/dist/getPublishPayload-C278kK9P.js.map +0 -1
  116. package/dist/index-CqnU-5i0.js.map +0 -1
  117. package/dist/index-DAl9U4rn.js.map +0 -1
  118. package/dist/property-Brgr5RdT.js.map +0 -1
  119. package/dist/resetAmbiguousLegacyItemData-CcLFRREE.js.map +0 -1
  120. package/dist/syncDbWithEas-B-Ho0IOB.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { fromCallback, fromPromise, setup, assign, createActor } from 'xstate';
2
- import { E as BaseDb, s as models, u as properties, $ as generateId, aF as isInternalSchema, aG as writeModelToDb, aH as writePropertyToDb, aI as addSchemaToDb, q as modelSchemas, z as schemas, F as AmbiguousModelError, aJ as renameModelInDb, a as TProperty } from './BasePathResolver-DxdS0wJ0.js';
2
+ import { E as BaseDb, s as models, u as properties, $ as generateId, aI as isInternalSchema, aJ as writeModelToDb, aK as writePropertyToDb, aL as addSchemaToDb, q as modelSchemas, z as schemas, G as AmbiguousModelError, aM as renameModelInDb, a as TProperty } from './BasePathResolver-DrzGVH9L.js';
3
3
  import { eq, and, isNull, or } from 'drizzle-orm';
4
4
  import debug from 'debug';
5
- import { n as waitForEntityIdle, D as DEFAULT_READY_TIMEOUT_MS, $ as getInvariantSafePropertyDescriptor, q as findEntity, C as ClientManagerState, I as Item, a0 as clearDestroySubscriptions, t as forceRemoveFromCaches, a1 as unloadEntity, u as runDestroyLifecycle } from './Item-cq9VcsAY.js';
6
- import { k as getClient } from './ClientManager-De-vKHGe.js';
5
+ import { l as waitForEntityIdle, D as DEFAULT_READY_TIMEOUT_MS, Z as getInvariantSafePropertyDescriptor, n as findEntity, C as ClientManagerState, I as Item, _ as clearDestroySubscriptions, o as forceRemoveFromCaches, $ as unloadEntity, q as runDestroyLifecycle } from './Item-BUUFuywT.js';
6
+ import { k as getClient } from './ClientManager-Dfu4jcgm.js';
7
7
  import { modelPropertiesToObject } from './model-oHA3YhOd.js';
8
- import { toSnakeCase } from 'drizzle-orm/casing';
8
+ import { localNamesInBestMatchTier } from '@seedprotocol/eas';
9
9
  import { Type } from '@sinclair/typebox';
10
10
 
11
11
  /**
@@ -35,7 +35,7 @@ const createPropertyInstances = async (propertyFileIds) => {
35
35
  return;
36
36
  }
37
37
  try {
38
- const mod = await import('./ModelProperty-DuuoFXaC.js');
38
+ const mod = await import('./ModelProperty-B6cnRvIz.js');
39
39
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
40
40
  if (!ModelProperty) {
41
41
  logger$7('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -101,11 +101,11 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
101
101
  if (!modelRecord) {
102
102
  // Model names are only unique per schema: prefer this schema's row, and otherwise only
103
103
  // consider same-name rows that no schema claims yet (never another schema's model).
104
- const _mod_0 = await import('./BasePathResolver-DxdS0wJ0.js');
105
- const _ns_0 = _mod_0.b1;
104
+ const _mod_0 = await import('./BasePathResolver-DrzGVH9L.js');
105
+ const _ns_0 = _mod_0.b9;
106
106
  const { modelSchemas } = _ns_0;
107
- const _mod_1 = await import('./BasePathResolver-DxdS0wJ0.js');
108
- const _ns_1 = _mod_1.b0;
107
+ const _mod_1 = await import('./BasePathResolver-DrzGVH9L.js');
108
+ const _ns_1 = _mod_1.b8;
109
109
  const { schemas: schemasTable } = _ns_1;
110
110
  let dbModels = await db
111
111
  .select({
@@ -252,7 +252,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
252
252
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
253
253
  // This handles the case where model exists in schema file but not yet in database
254
254
  try {
255
- const _mod_2 = await import('./Schema-Dc5EA8Yb.js');
255
+ const _mod_2 = await import('./Schema-Bf-jOLq0.js');
256
256
  const _ns_2 = _mod_2.b;
257
257
  const schemaMod = _ns_2;
258
258
  const { Schema } = schemaMod;
@@ -403,12 +403,12 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
403
403
  }
404
404
  // Also check database for models (in case they're persisted but not in Schema context)
405
405
  if (db) {
406
- const _mod_3 = await import('./BasePathResolver-DxdS0wJ0.js');
407
- const _ns_3 = _mod_3.b1;
406
+ const _mod_3 = await import('./BasePathResolver-DrzGVH9L.js');
407
+ const _ns_3 = _mod_3.b9;
408
408
  const modelSchemaSchemaMod = _ns_3;
409
409
  const { modelSchemas } = modelSchemaSchemaMod;
410
- const _mod_4 = await import('./BasePathResolver-DxdS0wJ0.js');
411
- const _ns_4 = _mod_4.b0;
410
+ const _mod_4 = await import('./BasePathResolver-DrzGVH9L.js');
411
+ const _ns_4 = _mod_4.b8;
412
412
  const schemaSchemaMod = _ns_4;
413
413
  const { schemas: schemasTable } = schemaSchemaMod;
414
414
  // Query all models for this schema to check for duplicates (case-insensitive)
@@ -503,7 +503,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
503
503
  }
504
504
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
505
505
  try {
506
- const _mod_5 = await import('./Schema-Dc5EA8Yb.js');
506
+ const _mod_5 = await import('./Schema-Bf-jOLq0.js');
507
507
  const _ns_5 = _mod_5.b;
508
508
  const schemaMod = _ns_5;
509
509
  const { Schema } = schemaMod;
@@ -551,10 +551,10 @@ const validateModel = fromCallback(({ sendBack, input: { context }, self }) => {
551
551
  const _validateModel = async () => {
552
552
  try {
553
553
  // Use dynamic imports to break circular dependencies
554
- const validationServiceMod = await import('./SchemaValidationService-DViJ056F.js');
554
+ const validationServiceMod = await import('./SchemaValidationService-BNYMacsx.js');
555
555
  const { SchemaValidationService } = validationServiceMod;
556
556
  const validationService = new SchemaValidationService();
557
- const _mod_6 = await import('./Schema-Dc5EA8Yb.js');
557
+ const _mod_6 = await import('./Schema-Bf-jOLq0.js');
558
558
  const _ns_6 = _mod_6.b;
559
559
  const schemaMod = _ns_6;
560
560
  const { Schema } = schemaMod;
@@ -673,7 +673,7 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
673
673
  return;
674
674
  }
675
675
  logger$5(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
676
- const mod = await import('./ModelProperty-DuuoFXaC.js');
676
+ const mod = await import('./ModelProperty-B6cnRvIz.js');
677
677
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
678
678
  if (!ModelProperty) {
679
679
  logger$5('ModelProperty not available from dynamic import');
@@ -698,8 +698,8 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
698
698
  : undefined;
699
699
  // Otherwise use provided ID or generate a random one
700
700
  // IDs should be generated in the import process before creating properties
701
- const _mod_7 = await import('./BasePathResolver-DxdS0wJ0.js');
702
- const _ns_7 = _mod_7.b5;
701
+ const _mod_7 = await import('./BasePathResolver-DrzGVH9L.js');
702
+ const _ns_7 = _mod_7.bd;
703
703
  const { generateId } = _ns_7;
704
704
  const propertyFileId = propData.id || propertyRecord?.schemaFileId || generateId();
705
705
  logger$5(`Creating property "${propName}" with fileId "${propertyFileId}"`);
@@ -716,8 +716,8 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
716
716
  }
717
717
  else if (refModelName) {
718
718
  // Fallback: resolve the ref by name within this model's schema
719
- const _mod_8 = await import('./BasePathResolver-DxdS0wJ0.js');
720
- const _ns_8 = _mod_8.b2;
719
+ const _mod_8 = await import('./BasePathResolver-DrzGVH9L.js');
720
+ const _ns_8 = _mod_8.ba;
721
721
  const { resolveModelRecord } = _ns_8;
722
722
  const refModelRecord = await resolveModelRecord(refModelName, { schemaName }, db);
723
723
  if (refModelRecord?.id) {
@@ -885,7 +885,7 @@ const validateEntity = fromPromise(async ({ input }) => {
885
885
  const evictionEpoch = currentEvictionEpoch();
886
886
  /** The schema to validate against; throws (validation then skips the schema check) once it was evicted. */
887
887
  const schemaForValidation = async (schemaName) => {
888
- const _mod_9 = await import('./Schema-Dc5EA8Yb.js');
888
+ const _mod_9 = await import('./Schema-Bf-jOLq0.js');
889
889
  const _ns_9 = _mod_9.b;
890
890
  const { Schema } = _ns_9;
891
891
  if (schemaEvictedSince(schemaName, evictionEpoch)) {
@@ -903,7 +903,7 @@ const validateEntity = fromPromise(async ({ input }) => {
903
903
  const structureMsg = `[validateEntity] Validating model structure`;
904
904
  logger$4(structureMsg);
905
905
  // Use existing Model validation
906
- const validationServiceMod = await import('./SchemaValidationService-DViJ056F.js');
906
+ const validationServiceMod = await import('./SchemaValidationService-BNYMacsx.js');
907
907
  const { SchemaValidationService } = validationServiceMod;
908
908
  const validationService = new SchemaValidationService();
909
909
  // Validate model structure
@@ -953,7 +953,7 @@ const validateEntity = fromPromise(async ({ input }) => {
953
953
  }
954
954
  else if (entityInput.entityType === 'modelProperty') {
955
955
  // Use existing ModelProperty validation
956
- const validationServiceMod = await import('./SchemaValidationService-DViJ056F.js');
956
+ const validationServiceMod = await import('./SchemaValidationService-BNYMacsx.js');
957
957
  const { SchemaValidationService } = validationServiceMod;
958
958
  const validationService = new SchemaValidationService();
959
959
  // Validate property structure
@@ -993,7 +993,7 @@ const validateEntity = fromPromise(async ({ input }) => {
993
993
  }
994
994
  else if (entityInput.entityType === 'schema') {
995
995
  // Schema validation - use existing validation
996
- const validationServiceMod = await import('./SchemaValidationService-DViJ056F.js');
996
+ const validationServiceMod = await import('./SchemaValidationService-BNYMacsx.js');
997
997
  const { SchemaValidationService } = validationServiceMod;
998
998
  const validationService = new SchemaValidationService();
999
999
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -1082,7 +1082,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
1082
1082
  // initial write completes is not overwritten by the stale requestWrite payload.
1083
1083
  let dataToWrite = input.entityData;
1084
1084
  try {
1085
- const mod = await import('./ModelProperty-DuuoFXaC.js');
1085
+ const mod = await import('./ModelProperty-B6cnRvIz.js');
1086
1086
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1087
1087
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
1088
1088
  const instance = ModelProperty.getById(input.entityId);
@@ -1476,7 +1476,7 @@ const modelMachine = setup({
1476
1476
  // Create ModelProperty instances for any new property IDs
1477
1477
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
1478
1478
  // Import and create instances asynchronously (fire-and-forget)
1479
- import('./ModelProperty-DuuoFXaC.js').then(({ ModelProperty }) => {
1479
+ import('./ModelProperty-B6cnRvIz.js').then(({ ModelProperty }) => {
1480
1480
  if (self.getSnapshot().status === 'stopped')
1481
1481
  return;
1482
1482
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
@@ -2002,7 +2002,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
2002
2002
  // Lazy import cache for ModelProperty to avoid circular dependency
2003
2003
  // Eagerly start loading to minimize delay on first access
2004
2004
  let ModelPropertyClass = null;
2005
- const modelPropertyImportPromise = import('./ModelProperty-DuuoFXaC.js')
2005
+ const modelPropertyImportPromise = import('./ModelProperty-B6cnRvIz.js')
2006
2006
  .then(module => {
2007
2007
  ModelPropertyClass = module.ModelProperty;
2008
2008
  return ModelPropertyClass;
@@ -2882,13 +2882,16 @@ class Model {
2882
2882
  return this.getByName(modelName);
2883
2883
  }
2884
2884
  /**
2885
- * Find Model by modelType (snake_case from DB/metadata).
2886
- * Handles model names with spaces: "new_model" -> finds "New model" (toSnakeCase("New model") === "new_model").
2885
+ * Find Model by modelType (an EAS model name, as seeds.type stores it). Matched as ADR 0008
2886
+ * matches EAS names: `new_model` finds "New model", and `htmlpage` (an older SDK's name) finds
2887
+ * "HTMLPage". Only the tightest matching tier counts; matches in several schemas are ambiguous.
2887
2888
  */
2888
2889
  static findByModelType(modelType) {
2889
2890
  if (!modelType)
2890
2891
  return undefined;
2891
- return this._getUniqueCachedModel(modelType, (cachedModelName) => toSnakeCase(cachedModelName) === modelType);
2892
+ const cachedNames = [...this.instanceCacheByName.keys()].map((key) => key.slice(key.lastIndexOf(':') + 1));
2893
+ const best = localNamesInBestMatchTier(modelType, cachedNames);
2894
+ return this._getUniqueCachedModel(modelType, (cachedModelName) => best.has(cachedModelName));
2892
2895
  }
2893
2896
  /**
2894
2897
  * Get all Model instances for a schema from cache only (synchronous).
@@ -2993,8 +2996,8 @@ class Model {
2993
2996
  const evictionEpoch = options?.evictionEpoch ?? currentEvictionEpoch();
2994
2997
  try {
2995
2998
  // Query model by name (throws AmbiguousModelError when several schemas define it)
2996
- const _mod_10 = await import('./BasePathResolver-DxdS0wJ0.js');
2997
- const _ns_10 = _mod_10.b2;
2999
+ const _mod_10 = await import('./BasePathResolver-DrzGVH9L.js');
3000
+ const _ns_10 = _mod_10.ba;
2998
3001
  const { resolveModelRecord } = _ns_10;
2999
3002
  const resolved = await resolveModelRecord(modelName, {}, db);
3000
3003
  if (!resolved?.schemaFileId) {
@@ -3745,7 +3748,7 @@ class Model {
3745
3748
  .limit(1);
3746
3749
  if (modelRecords.length > 0) {
3747
3750
  const modelId = modelRecords[0].id;
3748
- const { detachModelRows } = await import('./detachRowsBeforeDelete-YRSZY6dO.js');
3751
+ const { detachModelRows } = await import('./detachRowsBeforeDelete-B0Daoz9Z.js');
3749
3752
  await detachModelRows(db, [typeof modelId === 'string' ? parseInt(modelId, 10) : modelId]);
3750
3753
  await db.delete(modelSchemas).where(eq(modelSchemas.modelId, modelId));
3751
3754
  await db
@@ -3756,7 +3759,7 @@ class Model {
3756
3759
  }
3757
3760
  if (schemaName && modelName) {
3758
3761
  // Imported here, not at module load: Model and Schema import each other.
3759
- const _mod_11 = await import('./Schema-Dc5EA8Yb.js');
3762
+ const _mod_11 = await import('./Schema-Bf-jOLq0.js');
3760
3763
  const _ns_11 = _mod_11.b;
3761
3764
  const { Schema } = _ns_11;
3762
3765
  const schema = Schema.create(schemaName, { waitForReady: false });
@@ -3800,8 +3803,8 @@ class Model {
3800
3803
  return undefined;
3801
3804
  }
3802
3805
  // Model names are only unique per schema: find this model's row by its id (schemaFileId).
3803
- const _mod_12 = await import('./BasePathResolver-DxdS0wJ0.js');
3804
- const _ns_12 = _mod_12.b2;
3806
+ const _mod_12 = await import('./BasePathResolver-DrzGVH9L.js');
3807
+ const _ns_12 = _mod_12.ba;
3805
3808
  const { resolveModelRecord } = _ns_12;
3806
3809
  const modelRecord = await resolveModelRecord(modelName, { modelFileId: context.id, schemaName: context.schemaName }, db);
3807
3810
  if (!modelRecord?.id) {
@@ -4036,4 +4039,4 @@ var errors = /*#__PURE__*/Object.freeze({
4036
4039
  });
4037
4040
 
4038
4041
  export { ConflictError as C, ItemCreateValidationError as I, Model as M, TModelSchema as T, UnknownModelError as U, TModelValues as a, anyEvictionSince as b, currentEvictionEpoch as c, setupEntityLiveQuery as d, writeToDatabase$1 as e, finishSchemaDestroy as f, getDraftSaveError as g, Model$1 as h, isActorStopped as i, errors as j, recordSchemaDestroy as r, schemaEvictedSince as s, trackDraftSave as t, writeProcessMachine as w };
4039
- //# sourceMappingURL=errors-Cl8rbtKR.js.map
4042
+ //# sourceMappingURL=errors-DdWbxb_n.js.map