@seedprotocol/sdk 0.4.10 → 0.4.12

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 (92) hide show
  1. package/dist/{ArweaveClient-sN5h2FvY.js → ArweaveClient-Bot35vMf.js} +3 -3
  2. package/dist/{ArweaveClient-sN5h2FvY.js.map → ArweaveClient-Bot35vMf.js.map} +1 -1
  3. package/dist/{ArweaveClient-DFqnm5Kj.js → ArweaveClient-C6mBPWwy.js} +3 -3
  4. package/dist/{ArweaveClient-DFqnm5Kj.js.map → ArweaveClient-C6mBPWwy.js.map} +1 -1
  5. package/dist/{Db-DIythELU.js → Db-DP7ELP9S.js} +3 -3
  6. package/dist/{Db-DIythELU.js.map → Db-DP7ELP9S.js.map} +1 -1
  7. package/dist/{Db-Dz17KxVs.js → Db-rlxROH4S.js} +3 -3
  8. package/dist/{Db-Dz17KxVs.js.map → Db-rlxROH4S.js.map} +1 -1
  9. package/dist/{EasClient-BadfcFDk.js → EasClient-CHI9lBP8.js} +2 -2
  10. package/dist/{EasClient-DosbWaZN.js.map → EasClient-CHI9lBP8.js.map} +1 -1
  11. package/dist/{EasClient-DosbWaZN.js → EasClient-CszJzwqw.js} +2 -2
  12. package/dist/{EasClient-BadfcFDk.js.map → EasClient-CszJzwqw.js.map} +1 -1
  13. package/dist/{FileManager-Wthr5yHO.js → FileManager-C7yOhPvS.js} +2 -2
  14. package/dist/{FileManager-Wthr5yHO.js.map → FileManager-C7yOhPvS.js.map} +1 -1
  15. package/dist/{FileManager-BHuVNWT3.js → FileManager-Dy3BbIxq.js} +2 -2
  16. package/dist/{FileManager-BHuVNWT3.js.map → FileManager-Dy3BbIxq.js.map} +1 -1
  17. package/dist/{ModelProperty-B9Z2DRxI.js → ModelProperty--OQb3Dy0.js} +57 -18
  18. package/dist/ModelProperty--OQb3Dy0.js.map +1 -0
  19. package/dist/{PathResolver-NEpTSgQK.js → PathResolver-BtnV9pXS.js} +2 -2
  20. package/dist/{PathResolver-NEpTSgQK.js.map → PathResolver-BtnV9pXS.js.map} +1 -1
  21. package/dist/{PathResolver-Cd1PZDLG.js → PathResolver-D--w4fFE.js} +2 -2
  22. package/dist/{PathResolver-Cd1PZDLG.js.map → PathResolver-D--w4fFE.js.map} +1 -1
  23. package/dist/{QueryClient-C9U8oZUe.js → QueryClient-BdNnK6Es.js} +2 -2
  24. package/dist/{QueryClient-C9U8oZUe.js.map → QueryClient-BdNnK6Es.js.map} +1 -1
  25. package/dist/{QueryClient-ndmA8MYL.js → QueryClient-Bia5wKCO.js} +2 -2
  26. package/dist/{QueryClient-ndmA8MYL.js.map → QueryClient-Bia5wKCO.js.map} +1 -1
  27. package/dist/{Schema-D1-HjT8z.js → Schema-DF4mLt86.js} +21 -21
  28. package/dist/{Schema-D1-HjT8z.js.map → Schema-DF4mLt86.js.map} +1 -1
  29. package/dist/{SchemaValidationService-CIXKzSpb.js → SchemaValidationService-D4LwnnIB.js} +2 -2
  30. package/dist/{SchemaValidationService-CIXKzSpb.js.map → SchemaValidationService-D4LwnnIB.js.map} +1 -1
  31. package/dist/cjs/{ModelProperty-09hNvSBl.js → ModelProperty-C5BRfISV.js} +57 -18
  32. package/dist/cjs/ModelProperty-C5BRfISV.js.map +1 -0
  33. package/dist/cjs/{Schema-BcwvUABB.js → Schema-DVJG8ISB.js} +20 -20
  34. package/dist/cjs/{Schema-BcwvUABB.js.map → Schema-DVJG8ISB.js.map} +1 -1
  35. package/dist/cjs/{SchemaValidationService-zty4nfCu.js → SchemaValidationService-_wef0VX6.js} +2 -2
  36. package/dist/cjs/{SchemaValidationService-zty4nfCu.js.map → SchemaValidationService-_wef0VX6.js.map} +1 -1
  37. package/dist/cjs/{getItem-Dlb5YSQn.js → getItem-CUGoglni.js} +2 -2
  38. package/dist/cjs/{getItem-Dlb5YSQn.js.map → getItem-CUGoglni.js.map} +1 -1
  39. package/dist/cjs/{getPublishPayload-BqL06sEI.js → getPublishPayload-CGl97AXX.js} +5 -5
  40. package/dist/cjs/{getPublishPayload-BqL06sEI.js.map → getPublishPayload-CGl97AXX.js.map} +1 -1
  41. package/dist/cjs/{getPublishUploads-oukGI2N6.js → getPublishUploads-BA5PdoJ3.js} +3 -3
  42. package/dist/cjs/{getPublishUploads-oukGI2N6.js.map → getPublishUploads-BA5PdoJ3.js.map} +1 -1
  43. package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js → getSegmentedItemProperties-D3iBFPeo.js} +2 -2
  44. package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js.map → getSegmentedItemProperties-D3iBFPeo.js.map} +1 -1
  45. package/dist/cjs/{index-BLETlVgA.js → index-B3K0jG2t.js} +109 -55
  46. package/dist/cjs/index-B3K0jG2t.js.map +1 -0
  47. package/dist/cjs/{index-jubgGeM2.js → index-CpBFvNId.js} +2 -2
  48. package/dist/cjs/index-CpBFvNId.js.map +1 -0
  49. package/dist/cjs/{ownership-vfvyz3KJ.js → ownership-CkgGUliG.js} +2 -2
  50. package/dist/cjs/{ownership-vfvyz3KJ.js.map → ownership-CkgGUliG.js.map} +1 -1
  51. package/dist/{getItem-f9rNUz7I.js → getItem-CbGS6wbp.js} +2 -2
  52. package/dist/{getItem-f9rNUz7I.js.map → getItem-CbGS6wbp.js.map} +1 -1
  53. package/dist/{getPublishPayload-BBI_j9I2.js → getPublishPayload-jUcwhhs1.js} +5 -5
  54. package/dist/{getPublishPayload-BBI_j9I2.js.map → getPublishPayload-jUcwhhs1.js.map} +1 -1
  55. package/dist/{getPublishUploads-BFM94w5S.js → getPublishUploads-BAsUuLSM.js} +3 -3
  56. package/dist/{getPublishUploads-BFM94w5S.js.map → getPublishUploads-BAsUuLSM.js.map} +1 -1
  57. package/dist/{getSegmentedItemProperties-Di9vevKz.js → getSegmentedItemProperties-1QklOMkN.js} +2 -2
  58. package/dist/{getSegmentedItemProperties-Di9vevKz.js.map → getSegmentedItemProperties-1QklOMkN.js.map} +1 -1
  59. package/dist/{index-j8WN8W6V.js → index-BUFvepcD.js} +124 -70
  60. package/dist/index-BUFvepcD.js.map +1 -0
  61. package/dist/{index-CSAVWKeA.js → index-BnBV-CWp.js} +3 -3
  62. package/dist/index-BnBV-CWp.js.map +1 -0
  63. package/dist/{index-ajj6SHkh.js → index-CjAALVQh.js} +2 -2
  64. package/dist/index-CjAALVQh.js.map +1 -0
  65. package/dist/main.cjs +1 -1
  66. package/dist/main.js +11 -11
  67. package/dist/node.js +10 -10
  68. package/dist/{ownership-DLNI17NE.js → ownership-CeuRaVwP.js} +2 -2
  69. package/dist/{ownership-DLNI17NE.js.map → ownership-CeuRaVwP.js.map} +1 -1
  70. package/dist/{property-C6qoOzLG.js → property-BiZvboSH.js} +4 -4
  71. package/dist/{property-C6qoOzLG.js.map → property-BiZvboSH.js.map} +1 -1
  72. package/dist/{queries-jMaUn86w.js → queries-B2xdenwS.js} +2 -2
  73. package/dist/{queries-jMaUn86w.js.map → queries-B2xdenwS.js.map} +1 -1
  74. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  75. package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
  76. package/dist/src/ModelProperty/ModelProperty.d.ts +5 -0
  77. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  78. package/dist/src/helpers/db.d.ts.map +1 -1
  79. package/dist/src/services/write/actors/writeToDatabase.d.ts.map +1 -1
  80. package/dist/src/vite/index.d.ts.map +1 -1
  81. package/dist/vite.cjs +10 -1
  82. package/dist/vite.cjs.map +1 -1
  83. package/dist/vite.js +10 -1
  84. package/dist/vite.js.map +1 -1
  85. package/package.json +4 -1
  86. package/dist/ModelProperty-B9Z2DRxI.js.map +0 -1
  87. package/dist/cjs/ModelProperty-09hNvSBl.js.map +0 -1
  88. package/dist/cjs/index-BLETlVgA.js.map +0 -1
  89. package/dist/cjs/index-jubgGeM2.js.map +0 -1
  90. package/dist/index-CSAVWKeA.js.map +0 -1
  91. package/dist/index-ajj6SHkh.js.map +0 -1
  92. package/dist/index-j8WN8W6V.js.map +0 -1
@@ -770,7 +770,7 @@ const createPropertyInstances = async (propertyFileIds) => {
770
770
  return;
771
771
  }
772
772
  try {
773
- const mod = await import('./ModelProperty-B9Z2DRxI.js');
773
+ const mod = await import('./ModelProperty--OQb3Dy0.js');
774
774
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
775
775
  if (!ModelProperty) {
776
776
  logger$s('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -954,7 +954,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
954
954
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
955
955
  // This handles the case where model exists in schema file but not yet in database
956
956
  try {
957
- const _mod_0 = await import('./Schema-D1-HjT8z.js');
957
+ const _mod_0 = await import('./Schema-DF4mLt86.js');
958
958
  const _ns_0 = _mod_0.b;
959
959
  const schemaMod = _ns_0;
960
960
  const { Schema } = schemaMod;
@@ -1200,7 +1200,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
1200
1200
  }
1201
1201
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
1202
1202
  try {
1203
- const _mod_1 = await import('./Schema-D1-HjT8z.js');
1203
+ const _mod_1 = await import('./Schema-DF4mLt86.js');
1204
1204
  const _ns_1 = _mod_1.b;
1205
1205
  const schemaMod = _ns_1;
1206
1206
  const { Schema } = schemaMod;
@@ -1246,10 +1246,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
1246
1246
  const _validateModel = async () => {
1247
1247
  try {
1248
1248
  // Use dynamic imports to break circular dependencies
1249
- const validationServiceMod = await import('./SchemaValidationService-CIXKzSpb.js');
1249
+ const validationServiceMod = await import('./SchemaValidationService-D4LwnnIB.js');
1250
1250
  const { SchemaValidationService } = validationServiceMod;
1251
1251
  const validationService = new SchemaValidationService();
1252
- const _mod_2 = await import('./Schema-D1-HjT8z.js');
1252
+ const _mod_2 = await import('./Schema-DF4mLt86.js');
1253
1253
  const _ns_2 = _mod_2.b;
1254
1254
  const schemaMod = _ns_2;
1255
1255
  const { Schema } = schemaMod;
@@ -1361,7 +1361,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
1361
1361
  return;
1362
1362
  }
1363
1363
  logger$q(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
1364
- const mod = await import('./ModelProperty-B9Z2DRxI.js');
1364
+ const mod = await import('./ModelProperty--OQb3Dy0.js');
1365
1365
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1366
1366
  if (!ModelProperty) {
1367
1367
  logger$q('ModelProperty not available from dynamic import');
@@ -1464,7 +1464,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1464
1464
  const structureMsg = `[validateEntity] Validating model structure`;
1465
1465
  logger$p(structureMsg);
1466
1466
  // Use existing Model validation
1467
- const validationServiceMod = await import('./SchemaValidationService-CIXKzSpb.js');
1467
+ const validationServiceMod = await import('./SchemaValidationService-D4LwnnIB.js');
1468
1468
  const { SchemaValidationService } = validationServiceMod;
1469
1469
  const validationService = new SchemaValidationService();
1470
1470
  // Validate model structure
@@ -1482,7 +1482,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1482
1482
  if (entityInput.entityData.schemaName) {
1483
1483
  try {
1484
1484
  logger$p(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
1485
- const _mod_3 = await import('./Schema-D1-HjT8z.js');
1485
+ const _mod_3 = await import('./Schema-DF4mLt86.js');
1486
1486
  const _ns_3 = _mod_3.b;
1487
1487
  const schemaMod = _ns_3;
1488
1488
  const { Schema } = schemaMod;
@@ -1520,7 +1520,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1520
1520
  }
1521
1521
  else if (entityInput.entityType === 'modelProperty') {
1522
1522
  // Use existing ModelProperty validation
1523
- const validationServiceMod = await import('./SchemaValidationService-CIXKzSpb.js');
1523
+ const validationServiceMod = await import('./SchemaValidationService-D4LwnnIB.js');
1524
1524
  const { SchemaValidationService } = validationServiceMod;
1525
1525
  const validationService = new SchemaValidationService();
1526
1526
  // Validate property structure
@@ -1535,7 +1535,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1535
1535
  // If schema name and model name provided, validate against schema
1536
1536
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
1537
1537
  try {
1538
- const _mod_4 = await import('./Schema-D1-HjT8z.js');
1538
+ const _mod_4 = await import('./Schema-DF4mLt86.js');
1539
1539
  const _ns_4 = _mod_4.b;
1540
1540
  const schemaMod = _ns_4;
1541
1541
  const { Schema } = schemaMod;
@@ -1566,7 +1566,7 @@ const validateEntity = fromPromise(async ({ input }) => {
1566
1566
  }
1567
1567
  else if (entityInput.entityType === 'schema') {
1568
1568
  // Schema validation - use existing validation
1569
- const validationServiceMod = await import('./SchemaValidationService-CIXKzSpb.js');
1569
+ const validationServiceMod = await import('./SchemaValidationService-D4LwnnIB.js');
1570
1570
  const { SchemaValidationService } = validationServiceMod;
1571
1571
  const validationService = new SchemaValidationService();
1572
1572
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -2184,7 +2184,7 @@ async function checkIfPropertyIsEdited(modelName, propertyName, schemaFileValue)
2184
2184
  const cacheKey = `${modelName}:${propertyName}`;
2185
2185
  // First, check the in-memory cache (for current session edits)
2186
2186
  // Robust dynamic import for consumer re-bundling (named or default export)
2187
- const mod = await import('./ModelProperty-B9Z2DRxI.js');
2187
+ const mod = await import('./ModelProperty--OQb3Dy0.js');
2188
2188
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
2189
2189
  if (!ModelProperty) {
2190
2190
  logger$o('ModelProperty not available from dynamic import');
@@ -2551,7 +2551,18 @@ const addModelsToDb$1 = async (models, schema, modelRenames, schemaFileData) =>
2551
2551
  isEdited: false,
2552
2552
  };
2553
2553
  logger$o(`Creating new property ${modelName}:${propertyName} with schemaFileId: ${propertyData.schemaFileId}`);
2554
- const result = await db.insert(properties).values(propertyDataWithIsEdited);
2554
+ try {
2555
+ await db.insert(properties).values(propertyDataWithIsEdited);
2556
+ }
2557
+ catch (insertError) {
2558
+ // Treat UNIQUE constraint as success - property already exists (e.g. from concurrent addModelsToDb call)
2559
+ if (insertError?.code === 'SQLITE_CONSTRAINT_UNIQUE' || insertError?.message?.includes('UNIQUE constraint')) {
2560
+ logger$o(`Property ${modelName}:${propertyName} already exists (UNIQUE constraint), treating as success`);
2561
+ }
2562
+ else {
2563
+ throw insertError;
2564
+ }
2565
+ }
2555
2566
  }
2556
2567
  }
2557
2568
  }
@@ -2747,23 +2758,58 @@ const savePropertyToDb = async (property) => {
2747
2758
  if (!db) {
2748
2759
  throw new Error('Database not found');
2749
2760
  }
2750
- if (!property.modelName || !property.name) {
2751
- throw new Error('Model name and property name are required');
2761
+ if (!property.name) {
2762
+ throw new Error('Property name is required');
2752
2763
  }
2753
- // Find the model
2754
- const modelRecords = await db
2755
- .select()
2756
- .from(models$1)
2757
- .where(eq(models$1.name, property.modelName))
2758
- .limit(1);
2759
- if (modelRecords.length === 0) {
2760
- throw new Error(`Model ${property.modelName} not found in database`);
2764
+ // Find the model: prefer modelId (reliable), then modelName as name, then modelName as schemaFileId
2765
+ // (context.modelName can be a model schemaFileId when schema uses that as identifier)
2766
+ let modelRecord;
2767
+ if (property.modelId != null && typeof property.modelId === 'number') {
2768
+ const byId = await db
2769
+ .select()
2770
+ .from(models$1)
2771
+ .where(eq(models$1.id, property.modelId))
2772
+ .limit(1);
2773
+ modelRecord = byId[0];
2774
+ }
2775
+ if (!modelRecord && property.modelName) {
2776
+ const byName = await db
2777
+ .select()
2778
+ .from(models$1)
2779
+ .where(eq(models$1.name, property.modelName))
2780
+ .limit(1);
2781
+ modelRecord = byName[0];
2782
+ }
2783
+ if (!modelRecord && property.modelName) {
2784
+ const bySchemaFileId = await db
2785
+ .select()
2786
+ .from(models$1)
2787
+ .where(eq(models$1.schemaFileId, property.modelName))
2788
+ .limit(1);
2789
+ modelRecord = bySchemaFileId[0];
2790
+ }
2791
+ // Fallback: resolve model from existing property row (by schemaFileId) when modelName is wrong
2792
+ const schemaFileId = property._propertyFileId || (typeof property.id === 'string' ? property.id : undefined);
2793
+ if (!modelRecord && schemaFileId) {
2794
+ const propRows = await db
2795
+ .select({ modelId: properties.modelId })
2796
+ .from(properties)
2797
+ .where(eq(properties.schemaFileId, schemaFileId))
2798
+ .limit(1);
2799
+ if (propRows.length > 0 && propRows[0].modelId) {
2800
+ const byPropModelId = await db
2801
+ .select()
2802
+ .from(models$1)
2803
+ .where(eq(models$1.id, propRows[0].modelId))
2804
+ .limit(1);
2805
+ modelRecord = byPropModelId[0];
2806
+ }
2807
+ }
2808
+ if (!modelRecord) {
2809
+ throw new Error(`Model not found in database (modelId=${property.modelId}, modelName=${property.modelName})`);
2761
2810
  }
2762
- const modelRecord = modelRecords[0];
2763
2811
  // Find existing property - try multiple strategies to handle name changes
2764
2812
  // 1. First try by schemaFileId (most reliable - doesn't change when name changes)
2765
- // Use _propertyFileId first (from getPropertySchema), then id if it's a string (schemaFileId)
2766
- const schemaFileId = property._propertyFileId || (typeof property.id === 'string' ? property.id : undefined);
2767
2813
  let existingProperties = [];
2768
2814
  logger$o(`[savePropertyToDb] Looking for property ${property.modelName}:${property.name} (schemaFileId: ${schemaFileId}, originalName: ${property._originalValues?.name})`);
2769
2815
  if (schemaFileId) {
@@ -3164,11 +3210,14 @@ async function writePropertyToDb(propertyFileId, data, isEdited = false) {
3164
3210
  // Note: Additional property fields like storageType, localStorageDir, filenameSuffix
3165
3211
  // are not stored in the properties table but may be in the schema JSON
3166
3212
  if (existingProperties.length > 0) {
3167
- // Property exists, update it with new values
3213
+ // Property exists, update it with new values.
3214
+ // Use existing row id for WHERE (not name+modelId) so renames work: the row
3215
+ // may have the old name but we're updating to the new one.
3216
+ const existing = existingProperties[0];
3168
3217
  await db
3169
3218
  .update(properties)
3170
3219
  .set(propertyData)
3171
- .where(and(eq(properties.name, data.name), eq(properties.modelId, data.modelId)));
3220
+ .where(eq(properties.id, existing.id));
3172
3221
  logger$o(`Updated property ${data.name} (${propertyFileId}) in database`);
3173
3222
  }
3174
3223
  else {
@@ -3443,15 +3492,16 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
3443
3492
  // initial write completes is not overwritten by the stale requestWrite payload.
3444
3493
  let dataToWrite = input.entityData;
3445
3494
  try {
3446
- const mod = await import('./ModelProperty-B9Z2DRxI.js');
3495
+ const mod = await import('./ModelProperty--OQb3Dy0.js');
3447
3496
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
3448
3497
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
3449
3498
  const instance = ModelProperty.getById(input.entityId);
3450
3499
  if (instance && typeof instance._getSnapshotContext === 'function') {
3451
3500
  const ctx = instance._getSnapshotContext();
3501
+ const ctxName = ctx.name ?? input.entityData.name;
3452
3502
  dataToWrite = {
3453
3503
  ...input.entityData,
3454
- name: ctx.name ?? input.entityData.name,
3504
+ name: ctxName,
3455
3505
  dataType: ctx.dataType ?? input.entityData.dataType,
3456
3506
  refModelId: ctx.refModelId ?? input.entityData.refModelId,
3457
3507
  refValueType: ctx.refValueType ?? input.entityData.refValueType,
@@ -3822,7 +3872,7 @@ const modelMachine = setup({
3822
3872
  // Create ModelProperty instances for any new property IDs
3823
3873
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
3824
3874
  // Import and create instances asynchronously (fire-and-forget)
3825
- import('./ModelProperty-B9Z2DRxI.js').then(({ ModelProperty }) => {
3875
+ import('./ModelProperty--OQb3Dy0.js').then(({ ModelProperty }) => {
3826
3876
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
3827
3877
  try {
3828
3878
  const property = await ModelProperty.createById(propertyFileId);
@@ -4023,11 +4073,12 @@ const modelMachine = setup({
4023
4073
  target: 'creatingProperties',
4024
4074
  actions: assign(({ context, event }) => {
4025
4075
  logger$l(`[writeSuccess] Transitioning to creatingProperties for model "${context.modelName}"`);
4026
- // Update _dbId from write output if available
4076
+ // Update _dbId from write output if available (writeToDatabase returns _dbId, not id)
4027
4077
  const newContext = { ...context };
4028
- if (event.output?.id) {
4029
- newContext._dbId = event.output.id;
4030
- logger$l(`[writeSuccess] Updated _dbId to ${event.output.id}`);
4078
+ const dbId = event.output?._dbId ?? event.output?.id;
4079
+ if (dbId != null) {
4080
+ newContext._dbId = dbId;
4081
+ logger$l(`[writeSuccess] Updated _dbId to ${dbId}`);
4031
4082
  }
4032
4083
  return newContext;
4033
4084
  }),
@@ -4035,10 +4086,11 @@ const modelMachine = setup({
4035
4086
  {
4036
4087
  target: 'idle',
4037
4088
  actions: assign(({ context, event }) => {
4038
- // Update _dbId from write output if available
4089
+ // Update _dbId from write output if available (writeToDatabase returns _dbId, not id)
4039
4090
  const newContext = { ...context };
4040
- if (event.output?.id) {
4041
- newContext._dbId = event.output.id;
4091
+ const dbId = event.output?._dbId ?? event.output?.id;
4092
+ if (dbId != null) {
4093
+ newContext._dbId = dbId;
4042
4094
  }
4043
4095
  return newContext;
4044
4096
  }),
@@ -5305,9 +5357,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
5305
5357
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
5306
5358
  return;
5307
5359
  }
5308
- const getPublishUploadsMod = await import('./getPublishUploads-BFM94w5S.js');
5360
+ const getPublishUploadsMod = await import('./getPublishUploads-BAsUuLSM.js');
5309
5361
  const { getPublishUploads } = getPublishUploadsMod;
5310
- const getPublishPayloadMod = await import('./getPublishPayload-BBI_j9I2.js');
5362
+ const getPublishPayloadMod = await import('./getPublishPayload-jUcwhhs1.js');
5311
5363
  const { getPublishPayload } = getPublishPayloadMod;
5312
5364
  const uploads = await getPublishUploads(item);
5313
5365
  let uploadedTransactions = [];
@@ -6066,7 +6118,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
6066
6118
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
6067
6119
  const _resolveRelatedValue = async () => {
6068
6120
  // Use dynamic import to break circular dependency
6069
- const schemaMod = await import('./index-CSAVWKeA.js');
6121
+ const schemaMod = await import('./index-BnBV-CWp.js');
6070
6122
  const { ModelPropertyDataTypes } = schemaMod;
6071
6123
  if (!propertyValue || !isRelation || populatedFromDb) {
6072
6124
  return;
@@ -6406,7 +6458,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
6406
6458
  // to use dynamically imported ModelPropertyDataTypes
6407
6459
  const _hydrateFromDb = async () => {
6408
6460
  // Use dynamic import to break circular dependency
6409
- const schemaMod = await import('./index-CSAVWKeA.js');
6461
+ const schemaMod = await import('./index-BnBV-CWp.js');
6410
6462
  const { ModelPropertyDataTypes } = schemaMod;
6411
6463
  const appDb = BaseDb.getAppDb();
6412
6464
  const whereClauses = [];
@@ -6916,7 +6968,7 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
6916
6968
  }
6917
6969
  const _analyzeInput = async () => {
6918
6970
  // Use dynamic import to break circular dependency
6919
- const schemaMod = await import('./index-CSAVWKeA.js');
6971
+ const schemaMod = await import('./index-BnBV-CWp.js');
6920
6972
  const { ModelPropertyDataTypes } = schemaMod;
6921
6973
  let propertyName = propertyNameRaw;
6922
6974
  if (!propertyName) {
@@ -6998,8 +7050,10 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
6998
7050
  modelName,
6999
7051
  schemaUid,
7000
7052
  }); // Type assertion needed because newValue is not in MetadataType but is accepted by the function
7053
+ const stringValueForContext = typeof newValue === 'string' ? newValue : (newValue !== null && newValue !== undefined ? String(newValue) : undefined);
7001
7054
  let updatedContext = {
7002
- propertyValue: typeof newValue === 'string' ? newValue : (newValue !== null && newValue !== undefined ? String(newValue) : undefined),
7055
+ propertyValue: stringValueForContext,
7056
+ renderValue: stringValueForContext,
7003
7057
  };
7004
7058
  if (localId) {
7005
7059
  updatedContext.localId = localId;
@@ -7558,7 +7612,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
7558
7612
  }
7559
7613
  const _saveRelation = async () => {
7560
7614
  // Use dynamic import to break circular dependency
7561
- const schemaMod = await import('./index-CSAVWKeA.js');
7615
+ const schemaMod = await import('./index-BnBV-CWp.js');
7562
7616
  const { ModelPropertyDataTypes } = schemaMod;
7563
7617
  if (!propertyNameRaw) {
7564
7618
  throw new Error('propertyName is required');
@@ -8422,7 +8476,7 @@ class ItemProperty {
8422
8476
  return;
8423
8477
  }
8424
8478
  // Use dynamic import to break circular dependency
8425
- const schemaMod = await import('./index-CSAVWKeA.js');
8479
+ const schemaMod = await import('./index-BnBV-CWp.js');
8426
8480
  const { ModelPropertyDataTypes } = schemaMod;
8427
8481
  const { context } = snapshot;
8428
8482
  const { propertyRecordSchema } = context;
@@ -8538,7 +8592,7 @@ class ItemProperty {
8538
8592
  setupState.subscriptionSetUp = true;
8539
8593
  logger(`[ItemProperty._setupLiveQuerySubscription] Setting up liveQuery for propertyName: ${propertyName}, seedLocalId: ${seedLocalId}`);
8540
8594
  try {
8541
- const _mod_5 = await import('./index-ajj6SHkh.js');
8595
+ const _mod_5 = await import('./index-CjAALVQh.js');
8542
8596
  const _ns_5 = _mod_5.s;
8543
8597
  const seedSchemaMod = _ns_5;
8544
8598
  const { metadata } = seedSchemaMod;
@@ -9110,7 +9164,7 @@ class ItemProperty {
9110
9164
  }
9111
9165
  async save() {
9112
9166
  const ctx = this._getSnapshotContext();
9113
- const { assertItemOwned } = await import('./ownership-DLNI17NE.js');
9167
+ const { assertItemOwned } = await import('./ownership-CeuRaVwP.js');
9114
9168
  await assertItemOwned({
9115
9169
  seedLocalId: ctx?.seedLocalId ?? undefined,
9116
9170
  seedUid: ctx?.seedUid ?? undefined,
@@ -9203,7 +9257,7 @@ class ItemProperty {
9203
9257
  if (!propertyName || (!seedLocalId && !seedUid))
9204
9258
  return;
9205
9259
  if (db) {
9206
- const _mod_6 = await import('./index-ajj6SHkh.js');
9260
+ const _mod_6 = await import('./index-CjAALVQh.js');
9207
9261
  const _ns_6 = _mod_6.s;
9208
9262
  const seedSchemaMod = _ns_6;
9209
9263
  const { metadata } = seedSchemaMod;
@@ -9432,7 +9486,7 @@ class Item {
9432
9486
  });
9433
9487
  };
9434
9488
  this.publish = async () => {
9435
- const { assertItemOwned } = await import('./ownership-DLNI17NE.js');
9489
+ const { assertItemOwned } = await import('./ownership-CeuRaVwP.js');
9436
9490
  await assertItemOwned(this);
9437
9491
  this._service.send({ type: 'startPublish' });
9438
9492
  return new Promise((resolve, reject) => {
@@ -9468,13 +9522,13 @@ class Item {
9468
9522
  };
9469
9523
  this.getPublishUploads = async () => {
9470
9524
  // Use dynamic import to break circular dependency
9471
- const getPublishUploadsMod = await import('./getPublishUploads-BFM94w5S.js');
9525
+ const getPublishUploadsMod = await import('./getPublishUploads-BAsUuLSM.js');
9472
9526
  const { getPublishUploads } = getPublishUploadsMod;
9473
9527
  return await getPublishUploads(this);
9474
9528
  };
9475
9529
  this.getPublishPayload = async (uploadedTransactions) => {
9476
9530
  // Use dynamic import to break circular dependency
9477
- const getPublishPayloadMod = await import('./getPublishPayload-BBI_j9I2.js');
9531
+ const getPublishPayloadMod = await import('./getPublishPayload-jUcwhhs1.js');
9478
9532
  const { getPublishPayload } = getPublishPayloadMod;
9479
9533
  return await getPublishPayload(this, uploadedTransactions);
9480
9534
  };
@@ -10317,7 +10371,7 @@ class Item {
10317
10371
  setupState.subscriptionSetUp = true;
10318
10372
  logger(`[Item._setupLiveQuerySubscription] Setting up liveQuery for seedLocalId: ${seedLocalId}`);
10319
10373
  try {
10320
- const _mod_7 = await import('./index-ajj6SHkh.js');
10374
+ const _mod_7 = await import('./index-CjAALVQh.js');
10321
10375
  const _ns_7 = _mod_7.s;
10322
10376
  const seedSchemaMod = _ns_7;
10323
10377
  const { seeds, versions, metadata } = seedSchemaMod;
@@ -10598,7 +10652,7 @@ class Item {
10598
10652
  * Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
10599
10653
  */
10600
10654
  async destroy() {
10601
- const { assertItemOwned } = await import('./ownership-DLNI17NE.js');
10655
+ const { assertItemOwned } = await import('./ownership-CeuRaVwP.js');
10602
10656
  await assertItemOwned(this);
10603
10657
  const context = this._getSnapshotContext();
10604
10658
  const cacheKey = context.seedUid || context.seedLocalId;
@@ -11260,20 +11314,20 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
11260
11314
  let PathResolver;
11261
11315
  let EasClient;
11262
11316
  if (isBrowser()) {
11263
- FileManager = (await import('./FileManager-Wthr5yHO.js')).FileManager;
11264
- Db = (await import('./Db-Dz17KxVs.js')).Db;
11265
- QueryClient = (await import('./QueryClient-ndmA8MYL.js')).QueryClient;
11266
- ArweaveClient = (await import('./ArweaveClient-DFqnm5Kj.js')).ArweaveClient;
11267
- PathResolver = (await import('./PathResolver-NEpTSgQK.js')).PathResolver;
11268
- EasClient = (await import('./EasClient-BadfcFDk.js')).EasClient;
11317
+ FileManager = (await import('./FileManager-C7yOhPvS.js')).FileManager;
11318
+ Db = (await import('./Db-rlxROH4S.js')).Db;
11319
+ QueryClient = (await import('./QueryClient-Bia5wKCO.js')).QueryClient;
11320
+ ArweaveClient = (await import('./ArweaveClient-C6mBPWwy.js')).ArweaveClient;
11321
+ PathResolver = (await import('./PathResolver-BtnV9pXS.js')).PathResolver;
11322
+ EasClient = (await import('./EasClient-CszJzwqw.js')).EasClient;
11269
11323
  }
11270
11324
  else if (isNode()) {
11271
- FileManager = (await import('./FileManager-BHuVNWT3.js')).FileManager;
11272
- Db = (await import('./Db-DIythELU.js')).Db;
11273
- QueryClient = (await import('./QueryClient-C9U8oZUe.js')).QueryClient;
11274
- ArweaveClient = (await import('./ArweaveClient-sN5h2FvY.js')).ArweaveClient;
11275
- PathResolver = (await import('./PathResolver-Cd1PZDLG.js')).PathResolver;
11276
- EasClient = (await import('./EasClient-DosbWaZN.js')).EasClient;
11325
+ FileManager = (await import('./FileManager-Dy3BbIxq.js')).FileManager;
11326
+ Db = (await import('./Db-DP7ELP9S.js')).Db;
11327
+ QueryClient = (await import('./QueryClient-BdNnK6Es.js')).QueryClient;
11328
+ ArweaveClient = (await import('./ArweaveClient-Bot35vMf.js')).ArweaveClient;
11329
+ PathResolver = (await import('./PathResolver-D--w4fFE.js')).PathResolver;
11330
+ EasClient = (await import('./EasClient-CHI9lBP8.js')).EasClient;
11277
11331
  }
11278
11332
  else {
11279
11333
  throw new Error(`Unable to determine environment. isBrowser()=${isBrowser()}, isNode()=${isNode()}. Platform-specific implementations could not be loaded.`);
@@ -14535,7 +14589,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
14535
14589
  // Lazy import cache for ModelProperty to avoid circular dependency
14536
14590
  // Eagerly start loading to minimize delay on first access
14537
14591
  let ModelPropertyClass = null;
14538
- const modelPropertyImportPromise = import('./ModelProperty-B9Z2DRxI.js')
14592
+ const modelPropertyImportPromise = import('./ModelProperty--OQb3Dy0.js')
14539
14593
  .then(module => {
14540
14594
  ModelPropertyClass = module.ModelProperty;
14541
14595
  return ModelPropertyClass;
@@ -14552,7 +14606,7 @@ function getModelProperty() {
14552
14606
  }
14553
14607
  // Lazy import cache for Schema to avoid circular dependency
14554
14608
  let SchemaClass = null;
14555
- const schemaImportPromise = (async () => { const _mod_8 = await import('./Schema-D1-HjT8z.js'); return _mod_8.b; })()
14609
+ const schemaImportPromise = (async () => { const _mod_8 = await import('./Schema-DF4mLt86.js'); return _mod_8.b; })()
14556
14610
  .then(module => {
14557
14611
  SchemaClass = module.Schema;
14558
14612
  return SchemaClass;
@@ -16292,5 +16346,5 @@ var Model$1 = /*#__PURE__*/Object.freeze({
16292
16346
  Type.Record(Type.String(), Type.Any());
16293
16347
  Type.Record(Type.String(), TProperty);
16294
16348
 
16295
- export { propertyUids as $, BasePathResolver as A, Boolean$1 as B, BaseFileManager as C, Date$1 as D, appState as E, SEED_CONFIG_FALLBACKS as F, BaseEasClient as G, EAS_ENDPOINT as H, Image as I, Json as J, config as K, List as L, Model as M, Number$1 as N, metadata$1 as O, Property as P, modelRelations as Q, Relation as R, SEED_CONFIG_FILE as S, TPropertyDataType as T, modelSchemas as U, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as V, modelUids as W, modelsRelations as X, propertiesRelations as Y, ZERO_BYTES32 as Z, propertyUidRelations as _, ModelPropertyDataTypes as a, Model$1 as a$, schemas as a0, versions as a1, graphql as a2, saveAppState as a3, addModelsToDb$1 as a4, SCHEMA_NJK as a5, ItemProperty as a6, eventEmitter as a7, ClientManager as a8, INIT_SCRIPT_SUCCESS_MESSAGE as a9, getSeedsFromSchemaUids as aA, getSeedsBySchemaName as aB, SeedModels as aC, DEFAULT_ARWEAVE_HOST as aD, DEFAULT_ARWEAVE_GATEWAYS as aE, getArweaveUrlForTransaction as aF, setUploadExecutor as aG, getUploadExecutor as aH, createSchema as aI, readSchema as aJ, listCompleteSchemaFiles as aK, SEED_PROTOCOL_SCHEMA_NAME as aL, addSchemaToDb as aM, createModelsFromJson as aN, loadModelsFromDbForSchema as aO, getLatestSchemaVersion as aP, isInternalSchema as aQ, createModelFromJson as aR, ConflictError as aS, unloadEntity as aT, clearDestroySubscriptions as aU, setupEntityLiveQuery as aV, ModelSchema as aW, BaseFileManager$1 as aX, db as aY, schema as aZ, SEEDPROTOCOL_Seed_Protocol_v1 as a_, SCHEMA_TS as aa, importJsonSchema as ab, loadSchemaFromFile as ac, readJsonImportFile as ad, transformImportToSchemaFile as ae, writeProcessMachine as af, generateId as ag, waitForEntityIdle as ah, createReactiveProxy as ai, findEntity as aj, forceRemoveFromCaches as ak, runDestroyLifecycle as al, getModelIdByFileId as am, getModelId as an, getClient as ao, ClientManagerState as ap, getVersionData$1 as aq, createNewItem as ar, loadAllSchemasFromDb as as, getSchemaNameFromId as at, setSchemaUidForSchemaDefinition as au, setSchemaUidForModel as av, getModelSchemasFromEas as aw, getItemVersionsFromEas as ax, getItemPropertiesFromEas as ay, getEasSchemaUidBySchemaName as az, TStorageType as b, TProperty as c, TPropertyConstructor as d, PropertyMetadataKey as e, PropertyConstructor as f, Text as g, TValidationRules as h, getOwnedAddressesFromDb as i, BaseDb as j, getEasSchemaUidForModel as k, getCorrectId as l, defaultAttestationData as m, normalizeDataType as n, INTERNAL_DATA_TYPES as o, getEasSchemaUidForSchemaDefinition as p, getEasSchemaForItemProperty as q, modelPropertiesToObject as r, seeds as s, toSnakeCase as t, models$1 as u, properties as v, getItemData as w, Item as x, BaseQueryClient as y, BaseArweaveClient as z };
16296
- //# sourceMappingURL=index-j8WN8W6V.js.map
16349
+ export { propertyUids as $, BasePathResolver as A, Boolean$1 as B, BaseFileManager as C, Date$1 as D, appState as E, SEED_CONFIG_FALLBACKS as F, BaseEasClient as G, EAS_ENDPOINT as H, Image as I, Json as J, config as K, List as L, Model as M, Number$1 as N, metadata$1 as O, Property as P, modelRelations as Q, Relation as R, SEED_CONFIG_FILE as S, TPropertyDataType as T, modelSchemas as U, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as V, modelUids as W, modelsRelations as X, propertiesRelations as Y, ZERO_BYTES32 as Z, propertyUidRelations as _, ModelPropertyDataTypes as a, Model$1 as a$, schemas as a0, versions as a1, graphql as a2, saveAppState as a3, addModelsToDb$1 as a4, SCHEMA_NJK as a5, ItemProperty as a6, eventEmitter as a7, ClientManager as a8, INIT_SCRIPT_SUCCESS_MESSAGE as a9, getSeedsFromSchemaUids as aA, getSeedsBySchemaName as aB, SeedModels as aC, DEFAULT_ARWEAVE_HOST as aD, DEFAULT_ARWEAVE_GATEWAYS as aE, getArweaveUrlForTransaction as aF, setUploadExecutor as aG, getUploadExecutor as aH, createSchema as aI, readSchema as aJ, listCompleteSchemaFiles as aK, SEED_PROTOCOL_SCHEMA_NAME as aL, addSchemaToDb as aM, createModelsFromJson as aN, loadModelsFromDbForSchema as aO, getLatestSchemaVersion as aP, isInternalSchema as aQ, createModelFromJson as aR, ConflictError as aS, unloadEntity as aT, clearDestroySubscriptions as aU, setupEntityLiveQuery as aV, ModelSchema as aW, BaseFileManager$1 as aX, db as aY, schema as aZ, SEEDPROTOCOL_Seed_Protocol_v1 as a_, SCHEMA_TS as aa, importJsonSchema as ab, loadSchemaFromFile as ac, readJsonImportFile as ad, transformImportToSchemaFile as ae, writeProcessMachine as af, getModelIdByFileId as ag, generateId as ah, waitForEntityIdle as ai, createReactiveProxy as aj, findEntity as ak, forceRemoveFromCaches as al, runDestroyLifecycle as am, getModelId as an, getClient as ao, ClientManagerState as ap, getVersionData$1 as aq, createNewItem as ar, loadAllSchemasFromDb as as, getSchemaNameFromId as at, setSchemaUidForSchemaDefinition as au, setSchemaUidForModel as av, getModelSchemasFromEas as aw, getItemVersionsFromEas as ax, getItemPropertiesFromEas as ay, getEasSchemaUidBySchemaName as az, TStorageType as b, TProperty as c, TPropertyConstructor as d, PropertyMetadataKey as e, PropertyConstructor as f, Text as g, TValidationRules as h, getOwnedAddressesFromDb as i, BaseDb as j, getEasSchemaUidForModel as k, getCorrectId as l, defaultAttestationData as m, normalizeDataType as n, INTERNAL_DATA_TYPES as o, getEasSchemaUidForSchemaDefinition as p, getEasSchemaForItemProperty as q, modelPropertiesToObject as r, seeds as s, toSnakeCase as t, models$1 as u, properties as v, getItemData as w, Item as x, BaseQueryClient as y, BaseArweaveClient as z };
16350
+ //# sourceMappingURL=index-BUFvepcD.js.map