@seedprotocol/sdk 0.6.4 → 0.6.6

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 (101) hide show
  1. package/dist/{BasePathResolver-0IHnXxtL.js → BasePathResolver-BGxb4Qod.js} +27 -4
  2. package/dist/BasePathResolver-BGxb4Qod.js.map +1 -0
  3. package/dist/{ModelProperty-BiDQu5rE.js → ModelProperty-Bvg9cJcd.js} +20 -20
  4. package/dist/{ModelProperty-BiDQu5rE.js.map → ModelProperty-Bvg9cJcd.js.map} +1 -1
  5. package/dist/{Schema-qciDB7Nu.js → Schema-BNJBY80k.js} +25 -25
  6. package/dist/{Schema-qciDB7Nu.js.map → Schema-BNJBY80k.js.map} +1 -1
  7. package/dist/{SchemaValidationService-BaOkRjsU.js → SchemaValidationService-aqXkwXTr.js} +5 -5
  8. package/dist/{SchemaValidationService-BaOkRjsU.js.map → SchemaValidationService-aqXkwXTr.js.map} +1 -1
  9. package/dist/{backfillMetadataPropertyIds-oypxoBXv.js → backfillMetadataPropertyIds-DYkvoOMz.js} +3 -3
  10. package/dist/{backfillMetadataPropertyIds-oypxoBXv.js.map → backfillMetadataPropertyIds-DYkvoOMz.js.map} +1 -1
  11. package/dist/cjs/{ModelProperty-DvIIhBnK.js → ModelProperty-alntkSnH.js} +17 -17
  12. package/dist/cjs/{ModelProperty-DvIIhBnK.js.map → ModelProperty-alntkSnH.js.map} +1 -1
  13. package/dist/cjs/{Schema-FdzNqyGo.js → Schema-ByFv6fcb.js} +20 -20
  14. package/dist/cjs/{Schema-FdzNqyGo.js.map → Schema-ByFv6fcb.js.map} +1 -1
  15. package/dist/cjs/{SchemaValidationService-pxRoOs79.js → SchemaValidationService-D55MWsxv.js} +2 -2
  16. package/dist/cjs/{SchemaValidationService-pxRoOs79.js.map → SchemaValidationService-D55MWsxv.js.map} +1 -1
  17. package/dist/cjs/{backfillMetadataPropertyIds-D0o5VwBh.js → backfillMetadataPropertyIds-DrrL5RqD.js} +2 -2
  18. package/dist/cjs/{backfillMetadataPropertyIds-D0o5VwBh.js.map → backfillMetadataPropertyIds-DrrL5RqD.js.map} +1 -1
  19. package/dist/cjs/{eas-DSZkoDUn.js → eas-D2E3_i_c.js} +3 -3
  20. package/dist/cjs/{eas-DSZkoDUn.js.map → eas-D2E3_i_c.js.map} +1 -1
  21. package/dist/cjs/{getItem-CPcdcFuS.js → getItem-B2zLVB_l.js} +2 -2
  22. package/dist/cjs/{getItem-CPcdcFuS.js.map → getItem-B2zLVB_l.js.map} +1 -1
  23. package/dist/cjs/{getPublishPayload-BvmVTKoc.js → getPublishPayload-Bv94k4ak.js} +11 -11
  24. package/dist/cjs/{getPublishPayload-BvmVTKoc.js.map → getPublishPayload-Bv94k4ak.js.map} +1 -1
  25. package/dist/cjs/{getPublishUploads-D2VZHZnu.js → getPublishUploads-CSbHUxYk.js} +4 -4
  26. package/dist/cjs/{getPublishUploads-D2VZHZnu.js.map → getPublishUploads-CSbHUxYk.js.map} +1 -1
  27. package/dist/cjs/{getSegmentedItemProperties-Bm1TEvBS.js → getSegmentedItemProperties-CMhXKQHz.js} +3 -3
  28. package/dist/cjs/{getSegmentedItemProperties-Bm1TEvBS.js.map → getSegmentedItemProperties-CMhXKQHz.js.map} +1 -1
  29. package/dist/cjs/{index-C-POwaLs.js → index-D-9WglxG.js} +190 -85
  30. package/dist/cjs/index-D-9WglxG.js.map +1 -0
  31. package/dist/cjs/{index-D_ph4zut.js → index-pSLjO-ch.js} +3 -3
  32. package/dist/cjs/index-pSLjO-ch.js.map +1 -0
  33. package/dist/cjs/{property-DkUtJxV2.js → property-gUK2PijH.js} +4 -4
  34. package/dist/cjs/{property-DkUtJxV2.js.map → property-gUK2PijH.js.map} +1 -1
  35. package/dist/cjs/{syncDbWithEas-DRoys7eo.js → syncDbWithEas-CYtl7VTD.js} +6 -6
  36. package/dist/cjs/{syncDbWithEas-DRoys7eo.js.map → syncDbWithEas-CYtl7VTD.js.map} +1 -1
  37. package/dist/{configurePlatform-Df4BlXwQ.js → configurePlatform-bGvKBBQy.js} +3 -3
  38. package/dist/{configurePlatform-Df4BlXwQ.js.map → configurePlatform-bGvKBBQy.js.map} +1 -1
  39. package/dist/{constants-CROrIRd-.js → constants-CTs2RUrM.js} +4 -2
  40. package/dist/{constants-CROrIRd-.js.map → constants-CTs2RUrM.js.map} +1 -1
  41. package/dist/{db-DVsy4QZe.js → db-YiH_kIpE.js} +13 -13
  42. package/dist/{db-DVsy4QZe.js.map → db-YiH_kIpE.js.map} +1 -1
  43. package/dist/{eas-z4W41ith.js → eas-1nUCcmeh.js} +4 -4
  44. package/dist/{eas-z4W41ith.js.map → eas-1nUCcmeh.js.map} +1 -1
  45. package/dist/{getItem-BiE_b7Fu.js → getItem-Bb8bTYzY.js} +5 -5
  46. package/dist/{getItem-BiE_b7Fu.js.map → getItem-Bb8bTYzY.js.map} +1 -1
  47. package/dist/{getPublishPayload-CuRGEZa5.js → getPublishPayload-BHw8mPSb.js} +14 -14
  48. package/dist/{getPublishPayload-CuRGEZa5.js.map → getPublishPayload-BHw8mPSb.js.map} +1 -1
  49. package/dist/{getPublishUploads-CMgzBCzZ.js → getPublishUploads-BYhckxFl.js} +7 -7
  50. package/dist/{getPublishUploads-CMgzBCzZ.js.map → getPublishUploads-BYhckxFl.js.map} +1 -1
  51. package/dist/{getSegmentedItemProperties-BCCSwTxr.js → getSegmentedItemProperties-B73nMPBv.js} +5 -5
  52. package/dist/{getSegmentedItemProperties-BCCSwTxr.js.map → getSegmentedItemProperties-B73nMPBv.js.map} +1 -1
  53. package/dist/{index-DjwIC6U3.js → index-CJNKYI37.js} +186 -106
  54. package/dist/index-CJNKYI37.js.map +1 -0
  55. package/dist/{index-xNWgPtlN.js → index-C_5xwOPQ.js} +2 -2
  56. package/dist/index-C_5xwOPQ.js.map +1 -0
  57. package/dist/{index-C41UZTmQ.js → index-DzgMt8ba.js} +7 -7
  58. package/dist/index-DzgMt8ba.js.map +1 -0
  59. package/dist/{index.node-DQZ3cPe-.js → index.node-ZLiBj9Cu.js} +4 -4
  60. package/dist/{index.node-DQZ3cPe-.js.map → index.node-ZLiBj9Cu.js.map} +1 -1
  61. package/dist/main.cjs +1 -1
  62. package/dist/main.js +21 -21
  63. package/dist/node.js +10 -10
  64. package/dist/platform.browser.js +149 -41
  65. package/dist/platform.browser.js.map +1 -1
  66. package/dist/platform.node.js +3 -3
  67. package/dist/{property-Bs3a4Dna.js → property-Dcb50seV.js} +7 -7
  68. package/dist/{property-Bs3a4Dna.js.map → property-Dcb50seV.js.map} +1 -1
  69. package/dist/src/browser/db/Db.d.ts +1 -1
  70. package/dist/src/browser/db/Db.d.ts.map +1 -1
  71. package/dist/src/browser/db/createSqlocalDrizzle.d.ts +21 -0
  72. package/dist/src/browser/db/createSqlocalDrizzle.d.ts.map +1 -0
  73. package/dist/src/browser/helpers/FileManager.d.ts +1 -1
  74. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  75. package/dist/src/client/ClientManager.d.ts +9 -5
  76. package/dist/src/client/ClientManager.d.ts.map +1 -1
  77. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  78. package/dist/src/client/actors/addModelsToStore.d.ts.map +1 -1
  79. package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
  80. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  81. package/dist/src/client/clientManagerMachine.d.ts +1 -0
  82. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  83. package/dist/src/client/coalesceInit.d.ts +7 -0
  84. package/dist/src/client/coalesceInit.d.ts.map +1 -0
  85. package/dist/src/client/constants.d.ts +3 -1
  86. package/dist/src/client/constants.d.ts.map +1 -1
  87. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +7 -0
  88. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  89. package/dist/src/types/machines.d.ts +1 -0
  90. package/dist/src/types/machines.d.ts.map +1 -1
  91. package/dist/{syncDbWithEas-DRpLRxwb.js → syncDbWithEas-B0RUeDuj.js} +10 -10
  92. package/dist/{syncDbWithEas-DRpLRxwb.js.map → syncDbWithEas-B0RUeDuj.js.map} +1 -1
  93. package/dist/{updateSeedRevokedAt-F0ZDvwOO.js → updateSeedRevokedAt-D5ZbBehZ.js} +2 -2
  94. package/dist/{updateSeedRevokedAt-F0ZDvwOO.js.map → updateSeedRevokedAt-D5ZbBehZ.js.map} +1 -1
  95. package/package.json +13 -5
  96. package/dist/BasePathResolver-0IHnXxtL.js.map +0 -1
  97. package/dist/cjs/index-C-POwaLs.js.map +0 -1
  98. package/dist/cjs/index-D_ph4zut.js.map +0 -1
  99. package/dist/index-C41UZTmQ.js.map +0 -1
  100. package/dist/index-DjwIC6U3.js.map +0 -1
  101. package/dist/index-xNWgPtlN.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { waitFor, fromCallback, fromPromise, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
2
- import { a as BaseDb, m as models$1, p as properties, r as seeds, j as modelUids, v as versions, b as metadata$1, s as schemas, i as modelSchemas, B as BaseFileManager, c as appState, f as easSyncProcesses, t as BasePathResolver, h as htmlEmbeddedImageCoPublish, d as arweaveL1FinalizeJobs, q as publishProcesses } from './BasePathResolver-0IHnXxtL.js';
2
+ import { a as BaseDb, m as models$1, p as properties, r as seeds, j as modelUids, v as versions, b as metadata$1, s as schemas, i as modelSchemas, B as BaseFileManager, c as appState, f as easSyncProcesses, t as BasePathResolver, h as htmlEmbeddedImageCoPublish, d as arweaveL1FinalizeJobs, q as publishProcesses } from './BasePathResolver-BGxb4Qod.js';
3
3
  import { eq, and, isNotNull, not, or, max, count, getTableColumns, sql, isNull, desc, inArray, gt } from 'drizzle-orm';
4
- import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, v as getStorageTransactionIdForSeedUid, w as convertTxIdToImage, M as ModelPropertyDataTypes, x as getDataTypeFromString, y as getMimeType, l as getCorrectId, z as ClientManagerEvents, C as ClientManagerState, d as TProperty } from './constants-CROrIRd-.js';
4
+ import { n as normalizeDataType, t as toSnakeCase, o as MachineIds, v as getStorageTransactionIdForSeedUid, w as convertTxIdToImage, M as ModelPropertyDataTypes, x as getDataTypeFromString, y as getMimeType, l as getCorrectId, z as ClientManagerEvents, C as ClientManagerState, d as TProperty } from './constants-CTs2RUrM.js';
5
5
  import debug from 'debug';
6
6
  import { customAlphabet } from 'nanoid';
7
7
  import { alphanumeric } from 'nanoid-dictionary';
8
- import { w as writeModelToDb, m as writePropertyToDb, k as addSchemaToDb, n as normalizePublisher, o as getOwnedAddressesFromDb, j as normalizeAddressList, b as normalizeHexAddress, h as getAddressesForItemsFilter, a as getAllAddressesFromDb, e as escapeSqliteString, g as getPropertyIdForModelAndName, i as normalizeAddressConfig, l as loadModelsFromDbForSchema, p as getWatchedAddressesFromDb, r as renameModelInDb } from './db-DVsy4QZe.js';
8
+ import { w as writeModelToDb, m as writePropertyToDb, k as addSchemaToDb, n as normalizePublisher, o as getOwnedAddressesFromDb, j as normalizeAddressList, b as normalizeHexAddress, h as getAddressesForItemsFilter, a as getAllAddressesFromDb, e as escapeSqliteString, g as getPropertyIdForModelAndName, i as normalizeAddressConfig, l as loadModelsFromDbForSchema, p as getWatchedAddressesFromDb, r as renameModelInDb } from './db-YiH_kIpE.js';
9
9
  import pluralize from 'pluralize';
10
10
  import { BaseQueryClient, BaseEasClient, GET_SCHEMAS, getSchemaUidForModelFromCache, setSchemaUidForModel, GET_PROPERTIES, pickLatestPropertyAttestationsByRefAndSchema, isValidEasAttestationUid, isPlaceholderUid, getEasSchemaUidForSchemaDefinition, GET_FILES_METADATA, GET_SCHEMA_BY_NAME } from '@seedprotocol/eas';
11
11
  import { ZERO_BYTES32, INTERNAL_PROPERTY_NAMES, INTERNAL_DATA_TYPES, ImageSize, PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, isInternalSchema, INTERNAL_SCHEMA_IDS, SEED_PROTOCOL_SCHEMA_NAME, CLIENT_NOT_INITIALIZED } from './constants-Bre6dTJR.js';
@@ -283,7 +283,7 @@ const createPropertyInstances = async (propertyFileIds) => {
283
283
  return;
284
284
  }
285
285
  try {
286
- const mod = await import('./ModelProperty-BiDQu5rE.js');
286
+ const mod = await import('./ModelProperty-Bvg9cJcd.js');
287
287
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
288
288
  if (!ModelProperty) {
289
289
  logger$s('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -467,7 +467,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
467
467
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
468
468
  // This handles the case where model exists in schema file but not yet in database
469
469
  try {
470
- const _mod_0 = await import('./Schema-qciDB7Nu.js');
470
+ const _mod_0 = await import('./Schema-BNJBY80k.js');
471
471
  const _ns_0 = _mod_0.b;
472
472
  const schemaMod = _ns_0;
473
473
  const { Schema } = schemaMod;
@@ -617,11 +617,11 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
617
617
  }
618
618
  // Also check database for models (in case they're persisted but not in Schema context)
619
619
  if (db) {
620
- const _mod_1 = await import('./BasePathResolver-0IHnXxtL.js');
620
+ const _mod_1 = await import('./BasePathResolver-BGxb4Qod.js');
621
621
  const _ns_1 = _mod_1.x;
622
622
  const modelSchemaSchemaMod = _ns_1;
623
623
  const { modelSchemas } = modelSchemaSchemaMod;
624
- const _mod_2 = await import('./BasePathResolver-0IHnXxtL.js');
624
+ const _mod_2 = await import('./BasePathResolver-BGxb4Qod.js');
625
625
  const _ns_2 = _mod_2.S;
626
626
  const schemaSchemaMod = _ns_2;
627
627
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -717,7 +717,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
717
717
  }
718
718
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
719
719
  try {
720
- const _mod_3 = await import('./Schema-qciDB7Nu.js');
720
+ const _mod_3 = await import('./Schema-BNJBY80k.js');
721
721
  const _ns_3 = _mod_3.b;
722
722
  const schemaMod = _ns_3;
723
723
  const { Schema } = schemaMod;
@@ -763,10 +763,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
763
763
  const _validateModel = async () => {
764
764
  try {
765
765
  // Use dynamic imports to break circular dependencies
766
- const validationServiceMod = await import('./SchemaValidationService-BaOkRjsU.js');
766
+ const validationServiceMod = await import('./SchemaValidationService-aqXkwXTr.js');
767
767
  const { SchemaValidationService } = validationServiceMod;
768
768
  const validationService = new SchemaValidationService();
769
- const _mod_4 = await import('./Schema-qciDB7Nu.js');
769
+ const _mod_4 = await import('./Schema-BNJBY80k.js');
770
770
  const _ns_4 = _mod_4.b;
771
771
  const schemaMod = _ns_4;
772
772
  const { Schema } = schemaMod;
@@ -878,7 +878,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
878
878
  return;
879
879
  }
880
880
  logger$q(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
881
- const mod = await import('./ModelProperty-BiDQu5rE.js');
881
+ const mod = await import('./ModelProperty-Bvg9cJcd.js');
882
882
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
883
883
  if (!ModelProperty) {
884
884
  logger$q('ModelProperty not available from dynamic import');
@@ -981,7 +981,7 @@ const validateEntity = fromPromise(async ({ input }) => {
981
981
  const structureMsg = `[validateEntity] Validating model structure`;
982
982
  logger$p(structureMsg);
983
983
  // Use existing Model validation
984
- const validationServiceMod = await import('./SchemaValidationService-BaOkRjsU.js');
984
+ const validationServiceMod = await import('./SchemaValidationService-aqXkwXTr.js');
985
985
  const { SchemaValidationService } = validationServiceMod;
986
986
  const validationService = new SchemaValidationService();
987
987
  // Validate model structure
@@ -999,7 +999,7 @@ const validateEntity = fromPromise(async ({ input }) => {
999
999
  if (entityInput.entityData.schemaName) {
1000
1000
  try {
1001
1001
  logger$p(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
1002
- const _mod_5 = await import('./Schema-qciDB7Nu.js');
1002
+ const _mod_5 = await import('./Schema-BNJBY80k.js');
1003
1003
  const _ns_5 = _mod_5.b;
1004
1004
  const schemaMod = _ns_5;
1005
1005
  const { Schema } = schemaMod;
@@ -1037,7 +1037,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1037
1037
  }
1038
1038
  else if (entityInput.entityType === 'modelProperty') {
1039
1039
  // Use existing ModelProperty validation
1040
- const validationServiceMod = await import('./SchemaValidationService-BaOkRjsU.js');
1040
+ const validationServiceMod = await import('./SchemaValidationService-aqXkwXTr.js');
1041
1041
  const { SchemaValidationService } = validationServiceMod;
1042
1042
  const validationService = new SchemaValidationService();
1043
1043
  // Validate property structure
@@ -1052,7 +1052,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1052
1052
  // If schema name and model name provided, validate against schema
1053
1053
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
1054
1054
  try {
1055
- const _mod_6 = await import('./Schema-qciDB7Nu.js');
1055
+ const _mod_6 = await import('./Schema-BNJBY80k.js');
1056
1056
  const _ns_6 = _mod_6.b;
1057
1057
  const schemaMod = _ns_6;
1058
1058
  const { Schema } = schemaMod;
@@ -1083,7 +1083,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1083
1083
  }
1084
1084
  else if (entityInput.entityType === 'schema') {
1085
1085
  // Schema validation - use existing validation
1086
- const validationServiceMod = await import('./SchemaValidationService-BaOkRjsU.js');
1086
+ const validationServiceMod = await import('./SchemaValidationService-aqXkwXTr.js');
1087
1087
  const { SchemaValidationService } = validationServiceMod;
1088
1088
  const validationService = new SchemaValidationService();
1089
1089
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -1156,7 +1156,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
1156
1156
  // initial write completes is not overwritten by the stale requestWrite payload.
1157
1157
  let dataToWrite = input.entityData;
1158
1158
  try {
1159
- const mod = await import('./ModelProperty-BiDQu5rE.js');
1159
+ const mod = await import('./ModelProperty-Bvg9cJcd.js');
1160
1160
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1161
1161
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
1162
1162
  const instance = ModelProperty.getById(input.entityId);
@@ -1536,7 +1536,7 @@ const modelMachine = setup({
1536
1536
  // Create ModelProperty instances for any new property IDs
1537
1537
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
1538
1538
  // Import and create instances asynchronously (fire-and-forget)
1539
- import('./ModelProperty-BiDQu5rE.js').then(({ ModelProperty }) => {
1539
+ import('./ModelProperty-Bvg9cJcd.js').then(({ ModelProperty }) => {
1540
1540
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
1541
1541
  try {
1542
1542
  const property = await ModelProperty.createById(propertyFileId);
@@ -2539,7 +2539,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2539
2539
  const schemaNameToTry = model$1?.schemaName;
2540
2540
  if (schemaNameToTry) {
2541
2541
  try {
2542
- const _mod_7 = await import('./Schema-qciDB7Nu.js');
2542
+ const _mod_7 = await import('./Schema-BNJBY80k.js');
2543
2543
  const _ns_7 = _mod_7.b;
2544
2544
  const { Schema } = _ns_7;
2545
2545
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
@@ -2573,7 +2573,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2573
2573
  if (Object.keys(propertySchemas).length === 0) {
2574
2574
  try {
2575
2575
  const { listCompleteSchemaFiles } = await Promise.resolve().then(function () { return schema; });
2576
- const _mod_8 = await import('./BasePathResolver-0IHnXxtL.js');
2576
+ const _mod_8 = await import('./BasePathResolver-BGxb4Qod.js');
2577
2577
  const _ns_8 = _mod_8.w;
2578
2578
  const { BaseFileManager } = _ns_8;
2579
2579
  const schemaFiles = await listCompleteSchemaFiles();
@@ -2592,7 +2592,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2592
2592
  }
2593
2593
  }
2594
2594
  if (Object.keys(propertySchemas).length === 0) {
2595
- const schemaMod = await import('./index-C41UZTmQ.js');
2595
+ const schemaMod = await import('./index-DzgMt8ba.js');
2596
2596
  const { ModelPropertyDataTypes } = schemaMod;
2597
2597
  const KNOWN_MODEL_FALLBACKS = {
2598
2598
  Post: {
@@ -2639,7 +2639,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
2639
2639
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
2640
2640
  let propSchema = propertySchemas[propertyName];
2641
2641
  if (!propSchema && isRefTypeFromMeta) {
2642
- const schemaMod = await import('./index-C41UZTmQ.js');
2642
+ const schemaMod = await import('./index-DzgMt8ba.js');
2643
2643
  const { ModelPropertyDataTypes } = schemaMod;
2644
2644
  propSchema = {
2645
2645
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -2896,9 +2896,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
2896
2896
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
2897
2897
  return;
2898
2898
  }
2899
- const getPublishUploadsMod = await import('./getPublishUploads-CMgzBCzZ.js');
2899
+ const getPublishUploadsMod = await import('./getPublishUploads-BYhckxFl.js');
2900
2900
  const { getPublishUploads } = getPublishUploadsMod;
2901
- const getPublishPayloadMod = await import('./getPublishPayload-CuRGEZa5.js');
2901
+ const getPublishPayloadMod = await import('./getPublishPayload-BHw8mPSb.js');
2902
2902
  const { getPublishPayload } = getPublishPayloadMod;
2903
2903
  const uploads = await getPublishUploads(item);
2904
2904
  let uploadedTransactions = [];
@@ -3870,7 +3870,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
3870
3870
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
3871
3871
  const _resolveRelatedValue = async () => {
3872
3872
  // Use dynamic import to break circular dependency
3873
- const schemaMod = await import('./index-C41UZTmQ.js');
3873
+ const schemaMod = await import('./index-DzgMt8ba.js');
3874
3874
  const { ModelPropertyDataTypes } = schemaMod;
3875
3875
  if (!propertyValue || !isRelation || populatedFromDb) {
3876
3876
  return;
@@ -4874,7 +4874,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
4874
4874
  // to use dynamically imported ModelPropertyDataTypes
4875
4875
  const _hydrateFromDb = async () => {
4876
4876
  // Use dynamic import to break circular dependency
4877
- const schemaMod = await import('./index-C41UZTmQ.js');
4877
+ const schemaMod = await import('./index-DzgMt8ba.js');
4878
4878
  const { ModelPropertyDataTypes } = schemaMod;
4879
4879
  const appDb = BaseDb.getAppDb();
4880
4880
  const whereClauses = [];
@@ -5237,14 +5237,14 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
5237
5237
  };
5238
5238
  // Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
5239
5239
  try {
5240
- const { getPropertySchema } = await import('./property-Bs3a4Dna.js');
5240
+ const { getPropertySchema } = await import('./property-Dcb50seV.js');
5241
5241
  let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
5242
5242
  if (!schemaFromFile?.validation) {
5243
5243
  // Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
5244
- const _mod_9 = await import('./BasePathResolver-0IHnXxtL.js');
5244
+ const _mod_9 = await import('./BasePathResolver-BGxb4Qod.js');
5245
5245
  const _ns_9 = _mod_9.S;
5246
5246
  const { schemas: schemasTable } = _ns_9;
5247
- const _mod_10 = await import('./BasePathResolver-0IHnXxtL.js');
5247
+ const _mod_10 = await import('./BasePathResolver-BGxb4Qod.js');
5248
5248
  const _ns_10 = _mod_10.x;
5249
5249
  const { modelSchemas } = _ns_10;
5250
5250
  const modelSchemaRows = await db
@@ -5706,9 +5706,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
5706
5706
  }
5707
5707
  const _analyzeInput = async () => {
5708
5708
  // Use dynamic import to break circular dependency
5709
- const schemaMod = await import('./index-C41UZTmQ.js');
5709
+ const schemaMod = await import('./index-DzgMt8ba.js');
5710
5710
  const { ModelPropertyDataTypes } = schemaMod;
5711
- const { SchemaValidationService } = await import('./SchemaValidationService-BaOkRjsU.js');
5711
+ const { SchemaValidationService } = await import('./SchemaValidationService-aqXkwXTr.js');
5712
5712
  let propertyName = propertyNameRaw;
5713
5713
  if (!propertyName) {
5714
5714
  throw new Error('propertyName is required');
@@ -5906,7 +5906,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
5906
5906
  propertyRecordSchema?.validation &&
5907
5907
  metadataValues.propertyValue != null &&
5908
5908
  metadataValues.propertyValue !== '') {
5909
- const { SchemaValidationService } = await import('./SchemaValidationService-BaOkRjsU.js');
5909
+ const { SchemaValidationService } = await import('./SchemaValidationService-aqXkwXTr.js');
5910
5910
  const validationService = new SchemaValidationService();
5911
5911
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
5912
5912
  ? normalizeDataType(String(propertyRecordSchema.refValueType))
@@ -6499,7 +6499,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
6499
6499
  }
6500
6500
  const _saveRelation = async () => {
6501
6501
  // Use dynamic import to break circular dependency
6502
- const schemaMod = await import('./index-C41UZTmQ.js');
6502
+ const schemaMod = await import('./index-DzgMt8ba.js');
6503
6503
  const { ModelPropertyDataTypes } = schemaMod;
6504
6504
  if (!propertyNameRaw) {
6505
6505
  throw new Error('propertyName is required');
@@ -7454,7 +7454,7 @@ class ItemProperty {
7454
7454
  return;
7455
7455
  }
7456
7456
  // Use dynamic import to break circular dependency
7457
- const schemaMod = await import('./index-C41UZTmQ.js');
7457
+ const schemaMod = await import('./index-DzgMt8ba.js');
7458
7458
  const { ModelPropertyDataTypes } = schemaMod;
7459
7459
  const { context } = snapshot;
7460
7460
  const { propertyRecordSchema } = context;
@@ -7625,7 +7625,7 @@ class ItemProperty {
7625
7625
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
7626
7626
  const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
7627
7627
  const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
7628
- const _mod_11 = await import('./index-xNWgPtlN.js');
7628
+ const _mod_11 = await import('./index-C_5xwOPQ.js');
7629
7629
  const _ns_11 = _mod_11.s;
7630
7630
  const seedSchemaMod = _ns_11;
7631
7631
  const { metadata } = seedSchemaMod;
@@ -8458,7 +8458,7 @@ class ItemProperty {
8458
8458
  if (!propertyName || (!seedLocalId && !seedUid))
8459
8459
  return;
8460
8460
  if (db) {
8461
- const _mod_12 = await import('./index-xNWgPtlN.js');
8461
+ const _mod_12 = await import('./index-C_5xwOPQ.js');
8462
8462
  const _ns_12 = _mod_12.s;
8463
8463
  const seedSchemaMod = _ns_12;
8464
8464
  const { metadata } = seedSchemaMod;
@@ -8767,12 +8767,12 @@ class Item {
8767
8767
  };
8768
8768
  this.getPublishUploads = async (options) => {
8769
8769
  // Use dynamic import to break circular dependency
8770
- const getPublishUploadsMod = await import('./getPublishUploads-CMgzBCzZ.js');
8770
+ const getPublishUploadsMod = await import('./getPublishUploads-BYhckxFl.js');
8771
8771
  const { getPublishUploads } = getPublishUploadsMod;
8772
8772
  return await getPublishUploads(this, [], undefined, options);
8773
8773
  };
8774
8774
  this.getPublishPayload = async (uploadedTransactions, options) => {
8775
- const getPublishPayloadMod = await import('./getPublishPayload-CuRGEZa5.js');
8775
+ const getPublishPayloadMod = await import('./getPublishPayload-BHw8mPSb.js');
8776
8776
  const { getPublishPayload } = getPublishPayloadMod;
8777
8777
  return await getPublishPayload(this, uploadedTransactions, options);
8778
8778
  };
@@ -9240,11 +9240,11 @@ class Item {
9240
9240
  let modelRecords;
9241
9241
  // If we have a schema name, join with modelSchemas to filter by schema
9242
9242
  if (schemaName) {
9243
- const _mod_13 = await import('./BasePathResolver-0IHnXxtL.js');
9243
+ const _mod_13 = await import('./BasePathResolver-BGxb4Qod.js');
9244
9244
  const _ns_13 = _mod_13.x;
9245
9245
  const modelSchemaSchemaMod = _ns_13;
9246
9246
  const { modelSchemas } = modelSchemaSchemaMod;
9247
- const _mod_14 = await import('./BasePathResolver-0IHnXxtL.js');
9247
+ const _mod_14 = await import('./BasePathResolver-BGxb4Qod.js');
9248
9248
  const _ns_14 = _mod_14.S;
9249
9249
  const schemaSchemaMod = _ns_14;
9250
9250
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -9541,7 +9541,7 @@ class Item {
9541
9541
  if (!appDb || Item.instanceCache.size === 0) {
9542
9542
  return;
9543
9543
  }
9544
- const _mod_15 = await import('./index-xNWgPtlN.js');
9544
+ const _mod_15 = await import('./index-C_5xwOPQ.js');
9545
9545
  const _ns_15 = _mod_15.s;
9546
9546
  const { metadata } = _ns_15;
9547
9547
  const { eq, and } = await import('drizzle-orm');
@@ -9993,7 +9993,7 @@ class Item {
9993
9993
  itemActor.send(event);
9994
9994
  };
9995
9995
  try {
9996
- const _mod_16 = await import('./index-xNWgPtlN.js');
9996
+ const _mod_16 = await import('./index-C_5xwOPQ.js');
9997
9997
  const _ns_16 = _mod_16.s;
9998
9998
  const seedSchemaMod = _ns_16;
9999
9999
  const { seeds, versions, metadata } = seedSchemaMod;
@@ -10437,7 +10437,7 @@ const runEasSync = fromPromise(async ({ input, }) => {
10437
10437
  requestPayload: input.requestPayload,
10438
10438
  persistedSnapshot: input.runningSnapshot,
10439
10439
  });
10440
- const { runSyncFromEas } = await import('./syncDbWithEas-DRpLRxwb.js');
10440
+ const { runSyncFromEas } = await import('./syncDbWithEas-B0RUeDuj.js');
10441
10441
  try {
10442
10442
  await runSyncFromEas(toRunSyncArg(input.options));
10443
10443
  await finalizeEasSyncProcessRow(rowId, {
@@ -10716,7 +10716,7 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
10716
10716
  }
10717
10717
  // Prefer the condition-resolved factory when available; fall back to explicit
10718
10718
  // platform imports so source/vitest resolution stays reliable.
10719
- const { configurePlatform } = await import('./configurePlatform-Df4BlXwQ.js');
10719
+ const { configurePlatform } = await import('./configurePlatform-bGvKBBQy.js');
10720
10720
  if (isBrowser()) {
10721
10721
  const { createPlatformServices } = await import('./platform.browser.js');
10722
10722
  configurePlatform(createPlatformServices());
@@ -10900,7 +10900,12 @@ const saveAppState = fromCallback(({ sendBack, input: { key, value } }) => {
10900
10900
  });
10901
10901
  }
10902
10902
  else {
10903
- throw error;
10903
+ sendBack({
10904
+ type: 'saveAppStateError',
10905
+ error: error instanceof Error ? error : new Error(String(error)),
10906
+ key,
10907
+ value,
10908
+ });
10904
10909
  }
10905
10910
  });
10906
10911
  });
@@ -10980,7 +10985,7 @@ const dbInit = fromCallback(({ sendBack, input: { context } }) => {
10980
10985
  .catch((error) => {
10981
10986
  logger$8('Error in dbInit:', error);
10982
10987
  sendBack({
10983
- type: 'ERROR',
10988
+ type: 'error',
10984
10989
  error: error instanceof Error ? error : new Error(String(error))
10985
10990
  });
10986
10991
  });
@@ -11003,8 +11008,16 @@ const addModelsToStore = fromCallback(({ sendBack, input: { context } }) => {
11003
11008
  logger$7('model available:', key);
11004
11009
  }
11005
11010
  };
11006
- _addModelsToStore().then(() => {
11011
+ _addModelsToStore()
11012
+ .then(() => {
11007
11013
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_STORE_SUCCESS });
11014
+ })
11015
+ .catch((error) => {
11016
+ logger$7('[client/actors] [addModelsToStore] Error:', error);
11017
+ sendBack({
11018
+ type: 'error',
11019
+ error: error instanceof Error ? error : new Error(String(error)),
11020
+ });
11008
11021
  });
11009
11022
  });
11010
11023
 
@@ -11134,7 +11147,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
11134
11147
  sendBack({ type: ClientManagerEvents.ADD_MODELS_TO_DB_SUCCESS });
11135
11148
  }
11136
11149
  else {
11137
- throw error;
11150
+ sendBack({
11151
+ type: 'error',
11152
+ error: error instanceof Error ? error : new Error(String(error)),
11153
+ });
11138
11154
  }
11139
11155
  });
11140
11156
  return () => { };
@@ -11246,7 +11262,10 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
11246
11262
  sendBack({ type: ClientManagerEvents.SAVE_CONFIG_SUCCESS });
11247
11263
  }
11248
11264
  else {
11249
- throw error;
11265
+ sendBack({
11266
+ type: 'error',
11267
+ error: error instanceof Error ? error : new Error(String(error)),
11268
+ });
11250
11269
  }
11251
11270
  });
11252
11271
  return () => { };
@@ -11941,7 +11960,7 @@ function getRefValueType(prop) {
11941
11960
  * @returns Promise that resolves when properties are found, or rejects if not found after max retries
11942
11961
  */
11943
11962
  const verifyPropertiesPersisted = async (db, modelId, modelName, maxRetries = 10, retryDelay = 100) => {
11944
- const _mod_17 = await import('./BasePathResolver-0IHnXxtL.js');
11963
+ const _mod_17 = await import('./BasePathResolver-BGxb4Qod.js');
11945
11964
  const _ns_17 = _mod_17.M;
11946
11965
  const modelSchemaMod = _ns_17;
11947
11966
  const { properties: propertiesTable } = modelSchemaMod;
@@ -12289,7 +12308,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
12289
12308
  // Check DB for existing schema by name+version (same as minimal path)
12290
12309
  const db = BaseDb.getAppDb();
12291
12310
  if (db) {
12292
- const _mod_18 = await import('./BasePathResolver-0IHnXxtL.js');
12311
+ const _mod_18 = await import('./BasePathResolver-BGxb4Qod.js');
12293
12312
  const _ns_18 = _mod_18.S;
12294
12313
  const schemaSchemaMod = _ns_18;
12295
12314
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -12373,7 +12392,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
12373
12392
  // For minimal imports: check DB for existing schema before creating new file
12374
12393
  const db = BaseDb.getAppDb();
12375
12394
  if (db) {
12376
- const _mod_19 = await import('./BasePathResolver-0IHnXxtL.js');
12395
+ const _mod_19 = await import('./BasePathResolver-BGxb4Qod.js');
12377
12396
  const _ns_19 = _mod_19.S;
12378
12397
  const schemaSchemaMod = _ns_19;
12379
12398
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -12554,7 +12573,7 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
12554
12573
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
12555
12574
  };
12556
12575
  // Use dynamic import to break circular dependency
12557
- const _mod_20 = await import('./db-DVsy4QZe.js');
12576
+ const _mod_20 = await import('./db-YiH_kIpE.js');
12558
12577
  const _ns_20 = _mod_20.q;
12559
12578
  const dbMod = _ns_20;
12560
12579
  const { addSchemaToDb, addModelsToDb } = dbMod;
@@ -12576,11 +12595,11 @@ async function importJsonSchema(importFilePathOrContents, version = 1) {
12576
12595
  });
12577
12596
  // Verify expected models are linked (single attempt - addModelsToDb already confirmed)
12578
12597
  const expectedModelNames = Object.keys(schemaFile.models || {});
12579
- const _mod_21 = await import('./BasePathResolver-0IHnXxtL.js');
12598
+ const _mod_21 = await import('./BasePathResolver-BGxb4Qod.js');
12580
12599
  const _ns_21 = _mod_21.x;
12581
12600
  const modelSchemaSchemaMod = _ns_21;
12582
12601
  const { modelSchemas } = modelSchemaSchemaMod;
12583
- const _mod_22 = await import('./BasePathResolver-0IHnXxtL.js');
12602
+ const _mod_22 = await import('./BasePathResolver-BGxb4Qod.js');
12584
12603
  const _ns_22 = _mod_22.M;
12585
12604
  const modelSchemaMod = _ns_22;
12586
12605
  const { models: modelsTable } = modelSchemaMod;
@@ -12783,7 +12802,7 @@ async function applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, prope
12783
12802
  createdAt: new Date(schemaFile.metadata.createdAt).getTime(),
12784
12803
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
12785
12804
  };
12786
- const _mod_23 = await import('./db-DVsy4QZe.js');
12805
+ const _mod_23 = await import('./db-YiH_kIpE.js');
12787
12806
  const _ns_23 = _mod_23.q;
12788
12807
  const dbMod = _ns_23;
12789
12808
  const { addSchemaToDb, addModelsToDb } = dbMod;
@@ -12943,11 +12962,11 @@ const loadSchemaFromFile = async (schemaFilePath) => {
12943
12962
  if (db) {
12944
12963
  const { schemaRecord } = await applySchemaToDb(schemaFile, modelDefinitions, modelFileIds, propertyFileIds);
12945
12964
  // Query the database to get model IDs that were just created
12946
- const _mod_24 = await import('./BasePathResolver-0IHnXxtL.js');
12965
+ const _mod_24 = await import('./BasePathResolver-BGxb4Qod.js');
12947
12966
  const _ns_24 = _mod_24.x;
12948
12967
  const modelSchemaSchemaMod = _ns_24;
12949
12968
  const { modelSchemas } = modelSchemaSchemaMod;
12950
- const _mod_25 = await import('./BasePathResolver-0IHnXxtL.js');
12969
+ const _mod_25 = await import('./BasePathResolver-BGxb4Qod.js');
12951
12970
  const _ns_25 = _mod_25.M;
12952
12971
  const modelSchemaMod = _ns_25;
12953
12972
  const { models: modelsTable } = modelSchemaMod;
@@ -13013,7 +13032,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
13013
13032
  // After properties are created (file path), ensure schemaFile has the correct IDs from database
13014
13033
  // Query the database to get the actual schemaFileId values that were used
13015
13034
  // This ensures schemaData matches what's actually in the database
13016
- const _mod_26 = await import('./BasePathResolver-0IHnXxtL.js');
13035
+ const _mod_26 = await import('./BasePathResolver-BGxb4Qod.js');
13017
13036
  const _ns_26 = _mod_26.M;
13018
13037
  const modelSchemaMod2 = _ns_26;
13019
13038
  const { properties: propertiesTable } = modelSchemaMod2;
@@ -13049,7 +13068,7 @@ const loadSchemaFromFile = async (schemaFilePath) => {
13049
13068
  // This is important even if nothing changed, to ensure consistency
13050
13069
  const updatedSchemaData = JSON.stringify(schemaFile, null, 2);
13051
13070
  // Update the schema record in the database with current schemaData
13052
- const _mod_27 = await import('./BasePathResolver-0IHnXxtL.js');
13071
+ const _mod_27 = await import('./BasePathResolver-BGxb4Qod.js');
13053
13072
  const _ns_27 = _mod_27.S;
13054
13073
  const schemaSchemaMod = _ns_27;
13055
13074
  const { schemas: schemasTable } = schemaSchemaMod;
@@ -13746,8 +13765,8 @@ function parseAddressesPersistedPayload(value) {
13746
13765
  return { owned, watched };
13747
13766
  }
13748
13767
 
13749
- const { UNINITIALIZED, PLATFORM_CLASSES_INIT, FILE_SYSTEM_INIT, DB_INIT, SAVE_CONFIG, PROCESS_SCHEMA_FILES, ADD_MODELS_TO_STORE, ADD_MODELS_TO_DB, IDLE, } = ClientManagerState;
13750
- const { UPDATE_CONTEXT, PLATFORM_CLASSES_READY, FILE_SYSTEM_READY, DB_READY, SAVE_CONFIG_SUCCESS, SAVE_APP_STATE_SUCCESS, SET_ADDRESSES, ADD_MODELS_TO_STORE_SUCCESS, ADD_MODELS_TO_DB_SUCCESS, PROCESS_SCHEMA_FILES_SUCCESS, } = ClientManagerEvents;
13768
+ const { UNINITIALIZED, PLATFORM_CLASSES_INIT, FILE_SYSTEM_INIT, DB_INIT, SAVE_CONFIG, PROCESS_SCHEMA_FILES, ADD_MODELS_TO_STORE, ADD_MODELS_TO_DB, IDLE, INIT_FAILED, } = ClientManagerState;
13769
+ const { UPDATE_CONTEXT, PLATFORM_CLASSES_READY, FILE_SYSTEM_READY, DB_READY, SAVE_CONFIG_SUCCESS, SAVE_APP_STATE_SUCCESS, SAVE_APP_STATE_ERROR, SET_ADDRESSES, ADD_MODELS_TO_STORE_SUCCESS, ADD_MODELS_TO_DB_SUCCESS, PROCESS_SCHEMA_FILES_SUCCESS, } = ClientManagerEvents;
13751
13770
  const logSyncAfterAddressSave = debug("seedSdk:client:clientManagerMachine:syncAfterAddressSave");
13752
13771
  function addressesFromPersistedAddressValue(value) {
13753
13772
  if (!value || typeof value !== "object")
@@ -13791,7 +13810,14 @@ function emitAddressesPersistedIfAddressesKey(event) {
13791
13810
  const payload = parseAddressesPersistedPayload(event.value);
13792
13811
  eventEmitter.emit(ADDRESSES_PERSISTED_EVENT, payload);
13793
13812
  }
13794
- const clientManagerMachine = setup({
13813
+ function errorFromEvent(event, fallbackMessage) {
13814
+ const error = event?.error;
13815
+ if (error instanceof Error) {
13816
+ return error;
13817
+ }
13818
+ return new Error(String(error ?? fallbackMessage));
13819
+ }
13820
+ const clientManagerSetup = setup({
13795
13821
  types: {
13796
13822
  context: {},
13797
13823
  input: {},
@@ -13806,7 +13832,18 @@ const clientManagerMachine = setup({
13806
13832
  addModelsToDb,
13807
13833
  processSchemaFiles,
13808
13834
  },
13809
- }).createMachine({
13835
+ });
13836
+ function assignInitError(fallbackMessage) {
13837
+ return clientManagerSetup.assign(({ event }) => ({
13838
+ initError: errorFromEvent(event, fallbackMessage),
13839
+ isInitialized: false,
13840
+ }));
13841
+ }
13842
+ const failInit = (fallbackMessage) => ({
13843
+ target: INIT_FAILED,
13844
+ actions: assignInitError(fallbackMessage),
13845
+ });
13846
+ const clientManagerMachine = clientManagerSetup.createMachine({
13810
13847
  id: MachineIds.CLIENT_MANAGER,
13811
13848
  initial: UNINITIALIZED,
13812
13849
  context: ({ input }) => input,
@@ -13824,6 +13861,7 @@ const clientManagerMachine = setup({
13824
13861
  actions: assign({
13825
13862
  isInitialized: false,
13826
13863
  initError: undefined,
13864
+ saveError: undefined,
13827
13865
  }),
13828
13866
  },
13829
13867
  },
@@ -13840,16 +13878,7 @@ const clientManagerMachine = setup({
13840
13878
  [PLATFORM_CLASSES_READY]: {
13841
13879
  target: FILE_SYSTEM_INIT,
13842
13880
  },
13843
- error: {
13844
- actions: assign(({ event }) => {
13845
- const error = event.error instanceof Error
13846
- ? event.error
13847
- : new Error(String(event.error || 'Platform classes initialization failed'));
13848
- return {
13849
- initError: error,
13850
- };
13851
- }),
13852
- },
13881
+ error: failInit('Platform classes initialization failed'),
13853
13882
  },
13854
13883
  invoke: {
13855
13884
  src: 'platformClassesInit',
@@ -13857,6 +13886,7 @@ const clientManagerMachine = setup({
13857
13886
  event: event,
13858
13887
  context
13859
13888
  }),
13889
+ onError: failInit('Platform classes initialization failed'),
13860
13890
  },
13861
13891
  },
13862
13892
  [FILE_SYSTEM_INIT]: {
@@ -13864,19 +13894,12 @@ const clientManagerMachine = setup({
13864
13894
  [FILE_SYSTEM_READY]: {
13865
13895
  target: DB_INIT,
13866
13896
  },
13867
- error: {
13868
- target: IDLE,
13869
- actions: assign(({ event }) => {
13870
- const error = event.error instanceof Error
13871
- ? event.error
13872
- : new Error(String(event.error ?? 'File system initialization failed'));
13873
- return { initError: error };
13874
- }),
13875
- },
13897
+ error: failInit('File system initialization failed'),
13876
13898
  },
13877
13899
  invoke: {
13878
13900
  src: 'fileSystemInit',
13879
13901
  input: ({ context }) => ({ context }),
13902
+ onError: failInit('File system initialization failed'),
13880
13903
  },
13881
13904
  },
13882
13905
  [DB_INIT]: {
@@ -13884,10 +13907,12 @@ const clientManagerMachine = setup({
13884
13907
  [DB_READY]: {
13885
13908
  target: SAVE_CONFIG,
13886
13909
  },
13910
+ error: failInit('Database initialization failed'),
13887
13911
  },
13888
13912
  invoke: {
13889
13913
  src: 'dbInit',
13890
13914
  input: ({ context }) => ({ context }),
13915
+ onError: failInit('Database initialization failed'),
13891
13916
  },
13892
13917
  },
13893
13918
  [SAVE_CONFIG]: {
@@ -13895,10 +13920,12 @@ const clientManagerMachine = setup({
13895
13920
  [SAVE_CONFIG_SUCCESS]: {
13896
13921
  target: PROCESS_SCHEMA_FILES,
13897
13922
  },
13923
+ error: failInit('Saving config failed'),
13898
13924
  },
13899
13925
  invoke: {
13900
13926
  src: 'saveConfig',
13901
13927
  input: ({ context }) => ({ context }),
13928
+ onError: failInit('Saving config failed'),
13902
13929
  },
13903
13930
  },
13904
13931
  [PROCESS_SCHEMA_FILES]: {
@@ -13906,19 +13933,12 @@ const clientManagerMachine = setup({
13906
13933
  [PROCESS_SCHEMA_FILES_SUCCESS]: {
13907
13934
  target: ADD_MODELS_TO_STORE,
13908
13935
  },
13909
- error: {
13910
- target: IDLE,
13911
- actions: assign(({ event }) => {
13912
- const error = event.error instanceof Error
13913
- ? event.error
13914
- : new Error(String(event.error || 'Schema processing failed'));
13915
- return { initError: error };
13916
- }),
13917
- },
13936
+ error: failInit('Schema processing failed'),
13918
13937
  },
13919
13938
  invoke: {
13920
13939
  src: 'processSchemaFiles',
13921
13940
  input: ({ context }) => ({ context }),
13941
+ onError: failInit('Schema processing failed'),
13922
13942
  },
13923
13943
  },
13924
13944
  [ADD_MODELS_TO_STORE]: {
@@ -13926,10 +13946,12 @@ const clientManagerMachine = setup({
13926
13946
  [ADD_MODELS_TO_STORE_SUCCESS]: {
13927
13947
  target: ADD_MODELS_TO_DB,
13928
13948
  },
13949
+ error: failInit('Adding models to store failed'),
13929
13950
  },
13930
13951
  invoke: {
13931
13952
  src: 'addModelsToStore',
13932
13953
  input: ({ context }) => ({ context }),
13954
+ onError: failInit('Adding models to store failed'),
13933
13955
  },
13934
13956
  },
13935
13957
  [ADD_MODELS_TO_DB]: {
@@ -13937,10 +13959,27 @@ const clientManagerMachine = setup({
13937
13959
  [ADD_MODELS_TO_DB_SUCCESS]: {
13938
13960
  target: IDLE,
13939
13961
  },
13962
+ error: failInit('Adding models to database failed'),
13940
13963
  },
13941
13964
  invoke: {
13942
13965
  src: 'addModelsToDb',
13943
13966
  input: ({ context }) => ({ context }),
13967
+ onError: failInit('Adding models to database failed'),
13968
+ },
13969
+ },
13970
+ [INIT_FAILED]: {
13971
+ entry: assign({
13972
+ isInitialized: false,
13973
+ }),
13974
+ on: {
13975
+ init: {
13976
+ target: PLATFORM_CLASSES_INIT,
13977
+ actions: assign({
13978
+ isInitialized: false,
13979
+ initError: undefined,
13980
+ saveError: undefined,
13981
+ }),
13982
+ },
13944
13983
  },
13945
13984
  },
13946
13985
  [IDLE]: {
@@ -13950,9 +13989,10 @@ const clientManagerMachine = setup({
13950
13989
  on: {
13951
13990
  [SAVE_APP_STATE_SUCCESS]: {
13952
13991
  actions: [
13953
- assign(({ event }) => {
13992
+ assign(() => {
13954
13993
  return {
13955
13994
  isSaving: false,
13995
+ saveError: undefined,
13956
13996
  };
13957
13997
  }),
13958
13998
  ({ context, event }) => maybeRunSyncFromEasAfterAddressSave({
@@ -13962,6 +14002,12 @@ const clientManagerMachine = setup({
13962
14002
  ({ event }) => emitAddressesPersistedIfAddressesKey(event),
13963
14003
  ],
13964
14004
  },
14005
+ [SAVE_APP_STATE_ERROR]: {
14006
+ actions: assign(({ event }) => ({
14007
+ isSaving: false,
14008
+ saveError: errorFromEvent(event, 'Failed to save app state'),
14009
+ })),
14010
+ },
13965
14011
  [SET_ADDRESSES]: {
13966
14012
  actions: [
13967
14013
  assign(({ event, spawn }) => {
@@ -13978,6 +14024,7 @@ const clientManagerMachine = setup({
13978
14024
  ownedAddresses: normalized.owned,
13979
14025
  watchedAddresses: normalized.watched,
13980
14026
  isSaving: true,
14027
+ saveError: undefined,
13981
14028
  };
13982
14029
  })
13983
14030
  ],
@@ -13986,6 +14033,8 @@ const clientManagerMachine = setup({
13986
14033
  target: PLATFORM_CLASSES_INIT,
13987
14034
  actions: assign({
13988
14035
  isInitialized: false,
14036
+ initError: undefined,
14037
+ saveError: undefined,
13989
14038
  }),
13990
14039
  },
13991
14040
  },
@@ -13993,6 +14042,30 @@ const clientManagerMachine = setup({
13993
14042
  },
13994
14043
  });
13995
14044
 
14045
+ /**
14046
+ * Coalesce overlapping async init calls onto one in-flight promise.
14047
+ * Skip when already successfully ready. Always clear in-flight on settle
14048
+ * so a failed init can be retried.
14049
+ */
14050
+ function createCoalescedAsync(run, shouldSkip) {
14051
+ let inFlight = null;
14052
+ return (arg) => {
14053
+ if (inFlight) {
14054
+ return inFlight;
14055
+ }
14056
+ if (shouldSkip(arg)) {
14057
+ return Promise.resolve();
14058
+ }
14059
+ const pending = run(arg).finally(() => {
14060
+ if (inFlight === pending) {
14061
+ inFlight = null;
14062
+ }
14063
+ });
14064
+ inFlight = pending;
14065
+ return pending;
14066
+ };
14067
+ }
14068
+
13996
14069
  function msToUnixSeconds(ms) {
13997
14070
  if (ms == null || !Number.isFinite(ms))
13998
14071
  return 0;
@@ -14561,7 +14634,7 @@ const clientInstance = {
14561
14634
  // ensureInitialized();
14562
14635
  return clientManager;
14563
14636
  },
14564
- init: async (options) => {
14637
+ init: createCoalescedAsync(async (options) => {
14565
14638
  // If the actor is stopped (e.g., from a previous failed test), restart it
14566
14639
  const snapshot = clientManager.getSnapshot();
14567
14640
  const currentState = snapshot.value;
@@ -14597,6 +14670,7 @@ const clientInstance = {
14597
14670
  filesDir: undefined,
14598
14671
  dbConfig: undefined,
14599
14672
  initError: undefined,
14673
+ saveError: undefined,
14600
14674
  }
14601
14675
  });
14602
14676
  // Wait a moment for the context update to be processed
@@ -14619,15 +14693,12 @@ const clientInstance = {
14619
14693
  }
14620
14694
  try {
14621
14695
  await waitFor(clientManager, (snapshot) => {
14622
- // Check for errors in context (for cases where error is set but state hasn't transitioned yet)
14623
- if (snapshot.context.initError) {
14624
- const error = snapshot.context.initError instanceof Error
14625
- ? snapshot.context.initError
14626
- : new Error(String(snapshot.context.initError));
14627
- throw error;
14628
- }
14629
- return snapshot.context.isInitialized;
14696
+ return snapshot.context.isInitialized || snapshot.context.initError != null;
14630
14697
  }, { timeout: 120000 });
14698
+ const initError = clientManager.getSnapshot().context.initError;
14699
+ if (initError) {
14700
+ throw initError instanceof Error ? initError : new Error(String(initError));
14701
+ }
14631
14702
  }
14632
14703
  catch (error) {
14633
14704
  // Ensure we never throw undefined
@@ -14638,12 +14709,21 @@ const clientInstance = {
14638
14709
  }
14639
14710
  // Wire `@seedprotocol/query` local source once DB is ready
14640
14711
  registerSeedQueryLocalSource({ force: true });
14641
- },
14712
+ }, () => {
14713
+ const snapshot = clientManager.getSnapshot();
14714
+ return (snapshot.value === ClientManagerState.IDLE &&
14715
+ snapshot.context.isInitialized === true &&
14716
+ !snapshot.context.initError);
14717
+ }),
14642
14718
  setAddresses: async (addresses) => {
14643
14719
  ensureInitialized();
14644
14720
  logger$1('setAddresses', addresses);
14645
14721
  clientManager.send({ type: 'setAddresses', addresses });
14646
14722
  await waitFor(clientManager, (snapshot) => !snapshot.context.isSaving, { timeout: 10000 });
14723
+ const saveError = clientManager.getSnapshot().context.saveError;
14724
+ if (saveError) {
14725
+ throw saveError instanceof Error ? saveError : new Error(String(saveError));
14726
+ }
14647
14727
  logger$1('setAddresses success', addresses);
14648
14728
  },
14649
14729
  getAddresses: async () => {
@@ -14919,7 +14999,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
14919
14999
  // Lazy import cache for ModelProperty to avoid circular dependency
14920
15000
  // Eagerly start loading to minimize delay on first access
14921
15001
  let ModelPropertyClass = null;
14922
- const modelPropertyImportPromise = import('./ModelProperty-BiDQu5rE.js')
15002
+ const modelPropertyImportPromise = import('./ModelProperty-Bvg9cJcd.js')
14923
15003
  .then(module => {
14924
15004
  ModelPropertyClass = module.ModelProperty;
14925
15005
  return ModelPropertyClass;
@@ -14936,7 +15016,7 @@ function getModelProperty() {
14936
15016
  }
14937
15017
  // Lazy import cache for Schema to avoid circular dependency
14938
15018
  let SchemaClass = null;
14939
- const schemaImportPromise = (async () => { const _mod_28 = await import('./Schema-qciDB7Nu.js'); return _mod_28.b; })()
15019
+ const schemaImportPromise = (async () => { const _mod_28 = await import('./Schema-BNJBY80k.js'); return _mod_28.b; })()
14940
15020
  .then(module => {
14941
15021
  SchemaClass = module.Schema;
14942
15022
  return SchemaClass;
@@ -16665,4 +16745,4 @@ const TModelValues = Type.Record(Type.String(), Type.Any());
16665
16745
  const TModelSchema = Type.Record(Type.String(), TProperty);
16666
16746
 
16667
16747
  export { ownedPublisherSql as $, compareMetadataRowsLatestFirst as A, ADDRESSES_PERSISTED_EVENT as B, ClientManager as C, claimUnpublishedDrafts as D, createLocalQueryDataSource as E, createNewItem as F, createSchema as G, easSyncActor as H, Item as I, getClient as J, getGetPublisherForNewSeeds as K, LOCAL_COPIES_REMOVED_EVENT as L, Model as M, getMetadataLatest as N, getPublishedSeedRecord as O, getRevokeExecutor as P, getSchemaNameFromId as Q, getUploadExecutor as R, getVersionData$1 as S, TModelSchema as T, isItemOwned as U, isLocalUnsealedDraft as V, isSeedQueryLocalSourceRegistered as W, isSeedRowOwned as X, listCompleteSchemaFiles as Y, loadAllSchemasFromDb as Z, mergeEasSyncRequestIntents as _, TModelValues as a, parseAddressesPersistedPayload as a0, propertyMachine as a1, publisherInAddressListSql as a2, publisherIsInOwnedSet as a3, readSchema as a4, registerSeedQueryLocalSource as a5, requestEasSyncFromAddressChange as a6, requestEasSyncFromEventBus as a7, requestEasSyncFromModelsInit as a8, sendEasSyncClientRequest as a9, setAdditionalSyncAddresses as aa, setGetPublisherForNewSeeds as ab, setRevokeExecutor as ac, setUploadExecutor as ad, startEasSyncActor as ae, unregisterSeedQueryLocalSource as af, createModelsFromJson as ag, getLatestSchemaVersion as ah, createModelFromJson as ai, ConflictError as aj, unloadEntity as ak, clearDestroySubscriptions as al, setupEntityLiveQuery as am, generateId$1 as an, model as ao, getPropertyData$1 as ap, Item$1 as aq, schema as ar, SEEDPROTOCOL_Seed_Protocol_v1 as as, Model$1 as at, getItemData as b, getEasSchemaUidForModel as c, getLatestPublishedVersionRow as d, getEasSchemaForItemProperty as e, eventEmitter as f, getContentHash as g, generateId as h, getGetAdditionalSyncAddresses as i, ItemProperty as j, getRefValueType as k, importJsonSchema as l, modelPropertiesToObject as m, loadSchemaFromFile as n, readJsonImportFile as o, parseListPropertyValueFromStorage as p, syncSchemaFromSource as q, resolveStorageNameToSchemaName as r, scheduleBulkFilesDownloadFromEasSync as s, transformImportToSchemaFile as t, waitForEntityIdle as u, createReactiveProxy as v, writeProcessMachine as w, findEntity as x, forceRemoveFromCaches as y, runDestroyLifecycle as z };
16668
- //# sourceMappingURL=index-DjwIC6U3.js.map
16748
+ //# sourceMappingURL=index-CJNKYI37.js.map