@seedprotocol/sdk 0.6.4 → 0.6.5

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 (97) 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-BKvUJGud.js} +20 -20
  4. package/dist/{ModelProperty-BiDQu5rE.js.map → ModelProperty-BKvUJGud.js.map} +1 -1
  5. package/dist/{Schema-qciDB7Nu.js → Schema-BBh7ZhRk.js} +25 -25
  6. package/dist/{Schema-qciDB7Nu.js.map → Schema-BBh7ZhRk.js.map} +1 -1
  7. package/dist/{SchemaValidationService-BaOkRjsU.js → SchemaValidationService-BnJ43zov.js} +5 -5
  8. package/dist/{SchemaValidationService-BaOkRjsU.js.map → SchemaValidationService-BnJ43zov.js.map} +1 -1
  9. package/dist/{backfillMetadataPropertyIds-oypxoBXv.js → backfillMetadataPropertyIds-BEryy6Mu.js} +3 -3
  10. package/dist/{backfillMetadataPropertyIds-oypxoBXv.js.map → backfillMetadataPropertyIds-BEryy6Mu.js.map} +1 -1
  11. package/dist/cjs/{ModelProperty-DvIIhBnK.js → ModelProperty-CGjXNHFW.js} +17 -17
  12. package/dist/cjs/{ModelProperty-DvIIhBnK.js.map → ModelProperty-CGjXNHFW.js.map} +1 -1
  13. package/dist/cjs/{Schema-FdzNqyGo.js → Schema-CLMqGTHn.js} +20 -20
  14. package/dist/cjs/{Schema-FdzNqyGo.js.map → Schema-CLMqGTHn.js.map} +1 -1
  15. package/dist/cjs/{SchemaValidationService-pxRoOs79.js → SchemaValidationService-BnS8o5FK.js} +2 -2
  16. package/dist/cjs/{SchemaValidationService-pxRoOs79.js.map → SchemaValidationService-BnS8o5FK.js.map} +1 -1
  17. package/dist/cjs/{backfillMetadataPropertyIds-D0o5VwBh.js → backfillMetadataPropertyIds-B3xNIFjQ.js} +2 -2
  18. package/dist/cjs/{backfillMetadataPropertyIds-D0o5VwBh.js.map → backfillMetadataPropertyIds-B3xNIFjQ.js.map} +1 -1
  19. package/dist/cjs/{eas-DSZkoDUn.js → eas-wqfFyiti.js} +3 -3
  20. package/dist/cjs/{eas-DSZkoDUn.js.map → eas-wqfFyiti.js.map} +1 -1
  21. package/dist/cjs/{getItem-CPcdcFuS.js → getItem-BbEWSf4-.js} +2 -2
  22. package/dist/cjs/{getItem-CPcdcFuS.js.map → getItem-BbEWSf4-.js.map} +1 -1
  23. package/dist/cjs/{getPublishPayload-BvmVTKoc.js → getPublishPayload-i3UrBhza.js} +11 -11
  24. package/dist/cjs/{getPublishPayload-BvmVTKoc.js.map → getPublishPayload-i3UrBhza.js.map} +1 -1
  25. package/dist/cjs/{getPublishUploads-D2VZHZnu.js → getPublishUploads-CHhrLQmE.js} +4 -4
  26. package/dist/cjs/{getPublishUploads-D2VZHZnu.js.map → getPublishUploads-CHhrLQmE.js.map} +1 -1
  27. package/dist/cjs/{getSegmentedItemProperties-Bm1TEvBS.js → getSegmentedItemProperties-ZlOTqI0r.js} +3 -3
  28. package/dist/cjs/{getSegmentedItemProperties-Bm1TEvBS.js.map → getSegmentedItemProperties-ZlOTqI0r.js.map} +1 -1
  29. package/dist/cjs/{index-C-POwaLs.js → index-Bx8ReSFI.js} +192 -83
  30. package/dist/cjs/index-Bx8ReSFI.js.map +1 -0
  31. package/dist/cjs/{index-D_ph4zut.js → index-DBGNShZR.js} +3 -3
  32. package/dist/cjs/index-DBGNShZR.js.map +1 -0
  33. package/dist/cjs/{property-DkUtJxV2.js → property-CWZoijFu.js} +4 -4
  34. package/dist/cjs/{property-DkUtJxV2.js.map → property-CWZoijFu.js.map} +1 -1
  35. package/dist/cjs/{syncDbWithEas-DRoys7eo.js → syncDbWithEas-DRbf_wzk.js} +6 -6
  36. package/dist/cjs/{syncDbWithEas-DRoys7eo.js.map → syncDbWithEas-DRbf_wzk.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-CbeA8ykN.js} +13 -13
  42. package/dist/{db-DVsy4QZe.js.map → db-CbeA8ykN.js.map} +1 -1
  43. package/dist/{eas-z4W41ith.js → eas-CDANhqoz.js} +4 -4
  44. package/dist/{eas-z4W41ith.js.map → eas-CDANhqoz.js.map} +1 -1
  45. package/dist/{getItem-BiE_b7Fu.js → getItem-CUOCDTe8.js} +5 -5
  46. package/dist/{getItem-BiE_b7Fu.js.map → getItem-CUOCDTe8.js.map} +1 -1
  47. package/dist/{getPublishPayload-CuRGEZa5.js → getPublishPayload-0ntIkzv8.js} +14 -14
  48. package/dist/{getPublishPayload-CuRGEZa5.js.map → getPublishPayload-0ntIkzv8.js.map} +1 -1
  49. package/dist/{getPublishUploads-CMgzBCzZ.js → getPublishUploads-DLeAkS2m.js} +7 -7
  50. package/dist/{getPublishUploads-CMgzBCzZ.js.map → getPublishUploads-DLeAkS2m.js.map} +1 -1
  51. package/dist/{getSegmentedItemProperties-BCCSwTxr.js → getSegmentedItemProperties-C0rMewcl.js} +5 -5
  52. package/dist/{getSegmentedItemProperties-BCCSwTxr.js.map → getSegmentedItemProperties-C0rMewcl.js.map} +1 -1
  53. package/dist/{index-DjwIC6U3.js → index-BMeU7u_g.js} +188 -104
  54. package/dist/index-BMeU7u_g.js.map +1 -0
  55. package/dist/{index-C41UZTmQ.js → index-CQIlolE1.js} +7 -7
  56. package/dist/index-CQIlolE1.js.map +1 -0
  57. package/dist/{index-xNWgPtlN.js → index-C_5xwOPQ.js} +2 -2
  58. package/dist/index-C_5xwOPQ.js.map +1 -0
  59. package/dist/{index.node-DQZ3cPe-.js → index.node-DkpiPLbZ.js} +4 -4
  60. package/dist/{index.node-DQZ3cPe-.js.map → index.node-DkpiPLbZ.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 +32 -21
  65. package/dist/platform.browser.js.map +1 -1
  66. package/dist/platform.node.js +3 -3
  67. package/dist/{property-Bs3a4Dna.js → property-B-9szEcZ.js} +7 -7
  68. package/dist/{property-Bs3a4Dna.js.map → property-B-9szEcZ.js.map} +1 -1
  69. package/dist/src/browser/helpers/FileManager.d.ts +1 -1
  70. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  71. package/dist/src/client/ClientManager.d.ts +24 -5
  72. package/dist/src/client/ClientManager.d.ts.map +1 -1
  73. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  74. package/dist/src/client/actors/addModelsToStore.d.ts.map +1 -1
  75. package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
  76. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  77. package/dist/src/client/clientManagerMachine.d.ts +7 -1
  78. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  79. package/dist/src/client/coalesceInit.d.ts +7 -0
  80. package/dist/src/client/coalesceInit.d.ts.map +1 -0
  81. package/dist/src/client/constants.d.ts +3 -1
  82. package/dist/src/client/constants.d.ts.map +1 -1
  83. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +7 -0
  84. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  85. package/dist/src/types/machines.d.ts +1 -0
  86. package/dist/src/types/machines.d.ts.map +1 -1
  87. package/dist/{syncDbWithEas-DRpLRxwb.js → syncDbWithEas-CNBuYKo_.js} +10 -10
  88. package/dist/{syncDbWithEas-DRpLRxwb.js.map → syncDbWithEas-CNBuYKo_.js.map} +1 -1
  89. package/dist/{updateSeedRevokedAt-F0ZDvwOO.js → updateSeedRevokedAt-D5ZbBehZ.js} +2 -2
  90. package/dist/{updateSeedRevokedAt-F0ZDvwOO.js.map → updateSeedRevokedAt-D5ZbBehZ.js.map} +1 -1
  91. package/package.json +13 -5
  92. package/dist/BasePathResolver-0IHnXxtL.js.map +0 -1
  93. package/dist/cjs/index-C-POwaLs.js.map +0 -1
  94. package/dist/cjs/index-D_ph4zut.js.map +0 -1
  95. package/dist/index-C41UZTmQ.js.map +0 -1
  96. package/dist/index-DjwIC6U3.js.map +0 -1
  97. 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-CbeA8ykN.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-BKvUJGud.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-BBh7ZhRk.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-BBh7ZhRk.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-BnJ43zov.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-BBh7ZhRk.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-BKvUJGud.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-BnJ43zov.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-BBh7ZhRk.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-BnJ43zov.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-BBh7ZhRk.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-BnJ43zov.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-BKvUJGud.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-BKvUJGud.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-BBh7ZhRk.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-CQIlolE1.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-CQIlolE1.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-DLeAkS2m.js');
2900
2900
  const { getPublishUploads } = getPublishUploadsMod;
2901
- const getPublishPayloadMod = await import('./getPublishPayload-CuRGEZa5.js');
2901
+ const getPublishPayloadMod = await import('./getPublishPayload-0ntIkzv8.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-CQIlolE1.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-CQIlolE1.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-B-9szEcZ.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-CQIlolE1.js');
5710
5710
  const { ModelPropertyDataTypes } = schemaMod;
5711
- const { SchemaValidationService } = await import('./SchemaValidationService-BaOkRjsU.js');
5711
+ const { SchemaValidationService } = await import('./SchemaValidationService-BnJ43zov.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-BnJ43zov.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-CQIlolE1.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-CQIlolE1.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-DLeAkS2m.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-0ntIkzv8.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-CNBuYKo_.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-CbeA8ykN.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-CbeA8ykN.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,6 +13810,22 @@ function emitAddressesPersistedIfAddressesKey(event) {
13791
13810
  const payload = parseAddressesPersistedPayload(event.value);
13792
13811
  eventEmitter.emit(ADDRESSES_PERSISTED_EVENT, payload);
13793
13812
  }
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
+ function failInit(fallbackMessage) {
13821
+ return {
13822
+ target: INIT_FAILED,
13823
+ actions: {
13824
+ type: 'assignInitError',
13825
+ params: { fallbackMessage },
13826
+ },
13827
+ };
13828
+ }
13794
13829
  const clientManagerMachine = setup({
13795
13830
  types: {
13796
13831
  context: {},
@@ -13806,6 +13841,12 @@ const clientManagerMachine = setup({
13806
13841
  addModelsToDb,
13807
13842
  processSchemaFiles,
13808
13843
  },
13844
+ actions: {
13845
+ assignInitError: assign(({ event }, params) => ({
13846
+ initError: errorFromEvent(event, params.fallbackMessage),
13847
+ isInitialized: false,
13848
+ })),
13849
+ },
13809
13850
  }).createMachine({
13810
13851
  id: MachineIds.CLIENT_MANAGER,
13811
13852
  initial: UNINITIALIZED,
@@ -13824,6 +13865,7 @@ const clientManagerMachine = setup({
13824
13865
  actions: assign({
13825
13866
  isInitialized: false,
13826
13867
  initError: undefined,
13868
+ saveError: undefined,
13827
13869
  }),
13828
13870
  },
13829
13871
  },
@@ -13840,16 +13882,7 @@ const clientManagerMachine = setup({
13840
13882
  [PLATFORM_CLASSES_READY]: {
13841
13883
  target: FILE_SYSTEM_INIT,
13842
13884
  },
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
- },
13885
+ error: failInit('Platform classes initialization failed'),
13853
13886
  },
13854
13887
  invoke: {
13855
13888
  src: 'platformClassesInit',
@@ -13857,6 +13890,7 @@ const clientManagerMachine = setup({
13857
13890
  event: event,
13858
13891
  context
13859
13892
  }),
13893
+ onError: failInit('Platform classes initialization failed'),
13860
13894
  },
13861
13895
  },
13862
13896
  [FILE_SYSTEM_INIT]: {
@@ -13864,19 +13898,12 @@ const clientManagerMachine = setup({
13864
13898
  [FILE_SYSTEM_READY]: {
13865
13899
  target: DB_INIT,
13866
13900
  },
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
- },
13901
+ error: failInit('File system initialization failed'),
13876
13902
  },
13877
13903
  invoke: {
13878
13904
  src: 'fileSystemInit',
13879
13905
  input: ({ context }) => ({ context }),
13906
+ onError: failInit('File system initialization failed'),
13880
13907
  },
13881
13908
  },
13882
13909
  [DB_INIT]: {
@@ -13884,10 +13911,12 @@ const clientManagerMachine = setup({
13884
13911
  [DB_READY]: {
13885
13912
  target: SAVE_CONFIG,
13886
13913
  },
13914
+ error: failInit('Database initialization failed'),
13887
13915
  },
13888
13916
  invoke: {
13889
13917
  src: 'dbInit',
13890
13918
  input: ({ context }) => ({ context }),
13919
+ onError: failInit('Database initialization failed'),
13891
13920
  },
13892
13921
  },
13893
13922
  [SAVE_CONFIG]: {
@@ -13895,10 +13924,12 @@ const clientManagerMachine = setup({
13895
13924
  [SAVE_CONFIG_SUCCESS]: {
13896
13925
  target: PROCESS_SCHEMA_FILES,
13897
13926
  },
13927
+ error: failInit('Saving config failed'),
13898
13928
  },
13899
13929
  invoke: {
13900
13930
  src: 'saveConfig',
13901
13931
  input: ({ context }) => ({ context }),
13932
+ onError: failInit('Saving config failed'),
13902
13933
  },
13903
13934
  },
13904
13935
  [PROCESS_SCHEMA_FILES]: {
@@ -13906,19 +13937,12 @@ const clientManagerMachine = setup({
13906
13937
  [PROCESS_SCHEMA_FILES_SUCCESS]: {
13907
13938
  target: ADD_MODELS_TO_STORE,
13908
13939
  },
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
- },
13940
+ error: failInit('Schema processing failed'),
13918
13941
  },
13919
13942
  invoke: {
13920
13943
  src: 'processSchemaFiles',
13921
13944
  input: ({ context }) => ({ context }),
13945
+ onError: failInit('Schema processing failed'),
13922
13946
  },
13923
13947
  },
13924
13948
  [ADD_MODELS_TO_STORE]: {
@@ -13926,10 +13950,12 @@ const clientManagerMachine = setup({
13926
13950
  [ADD_MODELS_TO_STORE_SUCCESS]: {
13927
13951
  target: ADD_MODELS_TO_DB,
13928
13952
  },
13953
+ error: failInit('Adding models to store failed'),
13929
13954
  },
13930
13955
  invoke: {
13931
13956
  src: 'addModelsToStore',
13932
13957
  input: ({ context }) => ({ context }),
13958
+ onError: failInit('Adding models to store failed'),
13933
13959
  },
13934
13960
  },
13935
13961
  [ADD_MODELS_TO_DB]: {
@@ -13937,10 +13963,27 @@ const clientManagerMachine = setup({
13937
13963
  [ADD_MODELS_TO_DB_SUCCESS]: {
13938
13964
  target: IDLE,
13939
13965
  },
13966
+ error: failInit('Adding models to database failed'),
13940
13967
  },
13941
13968
  invoke: {
13942
13969
  src: 'addModelsToDb',
13943
13970
  input: ({ context }) => ({ context }),
13971
+ onError: failInit('Adding models to database failed'),
13972
+ },
13973
+ },
13974
+ [INIT_FAILED]: {
13975
+ entry: assign({
13976
+ isInitialized: false,
13977
+ }),
13978
+ on: {
13979
+ init: {
13980
+ target: PLATFORM_CLASSES_INIT,
13981
+ actions: assign({
13982
+ isInitialized: false,
13983
+ initError: undefined,
13984
+ saveError: undefined,
13985
+ }),
13986
+ },
13944
13987
  },
13945
13988
  },
13946
13989
  [IDLE]: {
@@ -13950,9 +13993,10 @@ const clientManagerMachine = setup({
13950
13993
  on: {
13951
13994
  [SAVE_APP_STATE_SUCCESS]: {
13952
13995
  actions: [
13953
- assign(({ event }) => {
13996
+ assign(() => {
13954
13997
  return {
13955
13998
  isSaving: false,
13999
+ saveError: undefined,
13956
14000
  };
13957
14001
  }),
13958
14002
  ({ context, event }) => maybeRunSyncFromEasAfterAddressSave({
@@ -13962,6 +14006,12 @@ const clientManagerMachine = setup({
13962
14006
  ({ event }) => emitAddressesPersistedIfAddressesKey(event),
13963
14007
  ],
13964
14008
  },
14009
+ [SAVE_APP_STATE_ERROR]: {
14010
+ actions: assign(({ event }) => ({
14011
+ isSaving: false,
14012
+ saveError: errorFromEvent(event, 'Failed to save app state'),
14013
+ })),
14014
+ },
13965
14015
  [SET_ADDRESSES]: {
13966
14016
  actions: [
13967
14017
  assign(({ event, spawn }) => {
@@ -13978,6 +14028,7 @@ const clientManagerMachine = setup({
13978
14028
  ownedAddresses: normalized.owned,
13979
14029
  watchedAddresses: normalized.watched,
13980
14030
  isSaving: true,
14031
+ saveError: undefined,
13981
14032
  };
13982
14033
  })
13983
14034
  ],
@@ -13986,6 +14037,8 @@ const clientManagerMachine = setup({
13986
14037
  target: PLATFORM_CLASSES_INIT,
13987
14038
  actions: assign({
13988
14039
  isInitialized: false,
14040
+ initError: undefined,
14041
+ saveError: undefined,
13989
14042
  }),
13990
14043
  },
13991
14044
  },
@@ -13993,6 +14046,30 @@ const clientManagerMachine = setup({
13993
14046
  },
13994
14047
  });
13995
14048
 
14049
+ /**
14050
+ * Coalesce overlapping async init calls onto one in-flight promise.
14051
+ * Skip when already successfully ready. Always clear in-flight on settle
14052
+ * so a failed init can be retried.
14053
+ */
14054
+ function createCoalescedAsync(run, shouldSkip) {
14055
+ let inFlight = null;
14056
+ return (arg) => {
14057
+ if (inFlight) {
14058
+ return inFlight;
14059
+ }
14060
+ if (shouldSkip(arg)) {
14061
+ return Promise.resolve();
14062
+ }
14063
+ const pending = run(arg).finally(() => {
14064
+ if (inFlight === pending) {
14065
+ inFlight = null;
14066
+ }
14067
+ });
14068
+ inFlight = pending;
14069
+ return pending;
14070
+ };
14071
+ }
14072
+
13996
14073
  function msToUnixSeconds(ms) {
13997
14074
  if (ms == null || !Number.isFinite(ms))
13998
14075
  return 0;
@@ -14561,7 +14638,7 @@ const clientInstance = {
14561
14638
  // ensureInitialized();
14562
14639
  return clientManager;
14563
14640
  },
14564
- init: async (options) => {
14641
+ init: createCoalescedAsync(async (options) => {
14565
14642
  // If the actor is stopped (e.g., from a previous failed test), restart it
14566
14643
  const snapshot = clientManager.getSnapshot();
14567
14644
  const currentState = snapshot.value;
@@ -14597,6 +14674,7 @@ const clientInstance = {
14597
14674
  filesDir: undefined,
14598
14675
  dbConfig: undefined,
14599
14676
  initError: undefined,
14677
+ saveError: undefined,
14600
14678
  }
14601
14679
  });
14602
14680
  // Wait a moment for the context update to be processed
@@ -14619,15 +14697,12 @@ const clientInstance = {
14619
14697
  }
14620
14698
  try {
14621
14699
  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;
14700
+ return snapshot.context.isInitialized || snapshot.context.initError != null;
14630
14701
  }, { timeout: 120000 });
14702
+ const initError = clientManager.getSnapshot().context.initError;
14703
+ if (initError) {
14704
+ throw initError instanceof Error ? initError : new Error(String(initError));
14705
+ }
14631
14706
  }
14632
14707
  catch (error) {
14633
14708
  // Ensure we never throw undefined
@@ -14638,12 +14713,21 @@ const clientInstance = {
14638
14713
  }
14639
14714
  // Wire `@seedprotocol/query` local source once DB is ready
14640
14715
  registerSeedQueryLocalSource({ force: true });
14641
- },
14716
+ }, () => {
14717
+ const snapshot = clientManager.getSnapshot();
14718
+ return (snapshot.value === ClientManagerState.IDLE &&
14719
+ snapshot.context.isInitialized === true &&
14720
+ !snapshot.context.initError);
14721
+ }),
14642
14722
  setAddresses: async (addresses) => {
14643
14723
  ensureInitialized();
14644
14724
  logger$1('setAddresses', addresses);
14645
14725
  clientManager.send({ type: 'setAddresses', addresses });
14646
14726
  await waitFor(clientManager, (snapshot) => !snapshot.context.isSaving, { timeout: 10000 });
14727
+ const saveError = clientManager.getSnapshot().context.saveError;
14728
+ if (saveError) {
14729
+ throw saveError instanceof Error ? saveError : new Error(String(saveError));
14730
+ }
14647
14731
  logger$1('setAddresses success', addresses);
14648
14732
  },
14649
14733
  getAddresses: async () => {
@@ -14919,7 +15003,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
14919
15003
  // Lazy import cache for ModelProperty to avoid circular dependency
14920
15004
  // Eagerly start loading to minimize delay on first access
14921
15005
  let ModelPropertyClass = null;
14922
- const modelPropertyImportPromise = import('./ModelProperty-BiDQu5rE.js')
15006
+ const modelPropertyImportPromise = import('./ModelProperty-BKvUJGud.js')
14923
15007
  .then(module => {
14924
15008
  ModelPropertyClass = module.ModelProperty;
14925
15009
  return ModelPropertyClass;
@@ -14936,7 +15020,7 @@ function getModelProperty() {
14936
15020
  }
14937
15021
  // Lazy import cache for Schema to avoid circular dependency
14938
15022
  let SchemaClass = null;
14939
- const schemaImportPromise = (async () => { const _mod_28 = await import('./Schema-qciDB7Nu.js'); return _mod_28.b; })()
15023
+ const schemaImportPromise = (async () => { const _mod_28 = await import('./Schema-BBh7ZhRk.js'); return _mod_28.b; })()
14940
15024
  .then(module => {
14941
15025
  SchemaClass = module.Schema;
14942
15026
  return SchemaClass;
@@ -16665,4 +16749,4 @@ const TModelValues = Type.Record(Type.String(), Type.Any());
16665
16749
  const TModelSchema = Type.Record(Type.String(), TProperty);
16666
16750
 
16667
16751
  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
16752
+ //# sourceMappingURL=index-BMeU7u_g.js.map