@seedprotocol/sdk 0.7.6 → 0.7.7

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 (249) hide show
  1. package/dist/{ClientManager-D6YA20jP.js → ClientManager-2GtDWHq6.js} +297 -218
  2. package/dist/ClientManager-2GtDWHq6.js.map +1 -0
  3. package/dist/{Item-B1MH0tXx.js → Item-D6j0IvBP.js} +233 -330
  4. package/dist/Item-D6j0IvBP.js.map +1 -0
  5. package/dist/{ModelProperty-Dw6dHdu_.js → ModelProperty-B52C3CQ2.js} +33 -33
  6. package/dist/ModelProperty-B52C3CQ2.js.map +1 -0
  7. package/dist/{Schema-DppObO6h.js → Schema-O1QLoXv6.js} +49 -58
  8. package/dist/Schema-O1QLoXv6.js.map +1 -0
  9. package/dist/{SchemaValidationService-DXQ-D531.js → SchemaValidationService-BxCbfDaI.js} +9 -9
  10. package/dist/SchemaValidationService-BxCbfDaI.js.map +1 -0
  11. package/dist/{backfillMetadataPropertyIds-Uhzlwg9X.js → backfillMetadataPropertyIds-CzSbuucw.js} +3 -3
  12. package/dist/{backfillMetadataPropertyIds-Uhzlwg9X.js.map → backfillMetadataPropertyIds-CzSbuucw.js.map} +1 -1
  13. package/dist/{configurePlatform-CVoh3JeR.js → configurePlatform-Bbpw_R4y.js} +2 -2
  14. package/dist/{configurePlatform-CVoh3JeR.js.map → configurePlatform-Bbpw_R4y.js.map} +1 -1
  15. package/dist/{detachRowsBeforeDelete-CtmIFpgV.js → detachRowsBeforeDelete-D1TyEMco.js} +2 -2
  16. package/dist/{detachRowsBeforeDelete-CtmIFpgV.js.map → detachRowsBeforeDelete-D1TyEMco.js.map} +1 -1
  17. package/dist/{discardNewDraft-oGYdB5vS.js → discardNewDraft-hiVaUVjV.js} +5 -5
  18. package/dist/{discardNewDraft-oGYdB5vS.js.map → discardNewDraft-hiVaUVjV.js.map} +1 -1
  19. package/dist/dist/{ClientManager-D6YA20jP.d.ts → ClientManager-2GtDWHq6.d.ts} +2 -1
  20. package/dist/dist/ClientManager-2GtDWHq6.d.ts.map +1 -0
  21. package/dist/dist/{Item-B1MH0tXx.d.ts → Item-D6j0IvBP.d.ts} +16 -23
  22. package/dist/dist/Item-D6j0IvBP.d.ts.map +1 -0
  23. package/dist/dist/{ModelProperty-Dw6dHdu_.d.ts → ModelProperty-B52C3CQ2.d.ts} +1 -1
  24. package/dist/dist/{ModelProperty-Dw6dHdu_.d.ts.map → ModelProperty-B52C3CQ2.d.ts.map} +1 -1
  25. package/dist/dist/{Schema-DppObO6h.d.ts → Schema-O1QLoXv6.d.ts} +2 -2
  26. package/dist/dist/{Schema-DppObO6h.d.ts.map → Schema-O1QLoXv6.d.ts.map} +1 -1
  27. package/dist/dist/{SchemaValidationService-DXQ-D531.d.ts → SchemaValidationService-BxCbfDaI.d.ts} +4 -4
  28. package/dist/dist/{SchemaValidationService-DXQ-D531.d.ts.map → SchemaValidationService-BxCbfDaI.d.ts.map} +1 -1
  29. package/dist/dist/{backfillMetadataPropertyIds-Uhzlwg9X.d.ts → backfillMetadataPropertyIds-CzSbuucw.d.ts} +1 -1
  30. package/dist/dist/backfillMetadataPropertyIds-CzSbuucw.d.ts.map +1 -0
  31. package/dist/dist/{configurePlatform-CVoh3JeR.d.ts → configurePlatform-Bbpw_R4y.d.ts} +1 -1
  32. package/dist/dist/configurePlatform-Bbpw_R4y.d.ts.map +1 -0
  33. package/dist/dist/{detachRowsBeforeDelete-CtmIFpgV.d.ts → detachRowsBeforeDelete-D1TyEMco.d.ts} +1 -1
  34. package/dist/dist/detachRowsBeforeDelete-D1TyEMco.d.ts.map +1 -0
  35. package/dist/dist/{discardNewDraft-oGYdB5vS.d.ts → discardNewDraft-hiVaUVjV.d.ts} +1 -1
  36. package/dist/dist/discardNewDraft-hiVaUVjV.d.ts.map +1 -0
  37. package/dist/dist/{eas-CSm5wmry.d.ts → eas-DOdj-EMK.d.ts} +1 -1
  38. package/dist/dist/eas-DOdj-EMK.d.ts.map +1 -0
  39. package/dist/dist/{errors-3tc6XkCB.d.ts → errors-KM-yq2MD.d.ts} +21 -8
  40. package/dist/dist/errors-KM-yq2MD.d.ts.map +1 -0
  41. package/dist/dist/{getItem-DM3a-7XE.d.ts → getItem-Bh0zv-o1.d.ts} +1 -1
  42. package/dist/dist/getItem-Bh0zv-o1.d.ts.map +1 -0
  43. package/dist/dist/{getPublishPayload-CJF0k5d8.d.ts → getPublishPayload-oH8wJhnH.d.ts} +1 -1
  44. package/dist/dist/getPublishPayload-oH8wJhnH.d.ts.map +1 -0
  45. package/dist/dist/{getPublishUploads-C7-fYIgX.d.ts → getPublishUploads-Cex-NBe6.d.ts} +1 -1
  46. package/dist/dist/{getPublishUploads-C7-fYIgX.d.ts.map → getPublishUploads-Cex-NBe6.d.ts.map} +1 -1
  47. package/dist/dist/{index--mmQ3LQu.d.ts → index-BAao3_Po.d.ts} +5 -5
  48. package/dist/dist/index-BAao3_Po.d.ts.map +1 -0
  49. package/dist/dist/{index-B7yAoYli.d.ts → index-BbFwftAv.d.ts} +1 -1
  50. package/dist/dist/{index-B7yAoYli.d.ts.map → index-BbFwftAv.d.ts.map} +1 -1
  51. package/dist/dist/{index-CrvIcVFJ.d.ts → index-DpgQMIRq.d.ts} +8 -4
  52. package/dist/dist/index-DpgQMIRq.d.ts.map +1 -0
  53. package/dist/dist/{index.browser-BmVS-c2C.d.ts → index.browser-nndbVM7z.d.ts} +4 -4
  54. package/dist/dist/{index.browser-BmVS-c2C.d.ts.map → index.browser-nndbVM7z.d.ts.map} +1 -1
  55. package/dist/dist/{index.node-BKpbCAWt.d.ts → index.node-BUfx-JaP.d.ts} +1 -1
  56. package/dist/dist/{index.node-BKpbCAWt.d.ts.map → index.node-BUfx-JaP.d.ts.map} +1 -1
  57. package/dist/dist/platform.browser.d.ts +2 -2
  58. package/dist/dist/platform.node.d.ts +2 -2
  59. package/dist/dist/{property-DQ-Owzki.d.ts → property-BDBvImLs.d.ts} +3 -3
  60. package/dist/dist/property-BDBvImLs.d.ts.map +1 -0
  61. package/dist/dist/{propertyValidationRules-BDhFjlwP.d.ts → propertyValidationRules-BlfLn4rP.d.ts} +1 -1
  62. package/dist/dist/propertyValidationRules-BlfLn4rP.d.ts.map +1 -0
  63. package/dist/dist/{publishDraftGraph-CzPd9oe9.d.ts → publishDraftGraph-CLO85LLz.d.ts} +1 -1
  64. package/dist/dist/{publishDraftGraph-CzPd9oe9.d.ts.map → publishDraftGraph-CLO85LLz.d.ts.map} +1 -1
  65. package/dist/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.d.ts → resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts} +1 -1
  66. package/dist/dist/resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts.map +1 -0
  67. package/dist/dist/{resolveModelForSyncedSeed-BgxtVCHI.d.ts → resolveModelForSyncedSeed-DFr4COc4.d.ts} +3 -3
  68. package/dist/dist/resolveModelForSyncedSeed-DFr4COc4.d.ts.map +1 -0
  69. package/dist/dist/{syncDbWithEas-Y5GysSCm.d.ts → syncDbWithEas-CAOlw3i-.d.ts} +1 -1
  70. package/dist/dist/syncDbWithEas-CAOlw3i-.d.ts.map +1 -0
  71. package/dist/dist/{tabEvents-D9x26vf2.d.ts → tabEvents-DksXwk3X.d.ts} +1 -1
  72. package/dist/dist/{tabEvents-D9x26vf2.d.ts.map → tabEvents-DksXwk3X.d.ts.map} +1 -1
  73. package/dist/dist/{tolerantWebAccess-BFU2t-SC.d.ts → tolerantWebAccess-CEIjFGf0.d.ts} +1 -1
  74. package/dist/dist/{tolerantWebAccess-BFU2t-SC.d.ts.map → tolerantWebAccess-CEIjFGf0.d.ts.map} +1 -1
  75. package/dist/dist/{updateSeedRevokedAt-CCF8WWYS.d.ts → updateSeedRevokedAt-Cjr35YjE.d.ts} +1 -1
  76. package/dist/dist/updateSeedRevokedAt-Cjr35YjE.d.ts.map +1 -0
  77. package/dist/{eas-CSm5wmry.js → eas-DOdj-EMK.js} +4 -4
  78. package/dist/eas-DOdj-EMK.js.map +1 -0
  79. package/dist/{errors-3tc6XkCB.js → errors-KM-yq2MD.js} +55 -41
  80. package/dist/errors-KM-yq2MD.js.map +1 -0
  81. package/dist/{getItem-DM3a-7XE.js → getItem-Bh0zv-o1.js} +4 -4
  82. package/dist/{getItem-DM3a-7XE.js.map → getItem-Bh0zv-o1.js.map} +1 -1
  83. package/dist/{getPublishPayload-CJF0k5d8.js → getPublishPayload-oH8wJhnH.js} +16 -25
  84. package/dist/getPublishPayload-oH8wJhnH.js.map +1 -0
  85. package/dist/{getPublishUploads-C7-fYIgX.js → getPublishUploads-Cex-NBe6.js} +10 -10
  86. package/dist/getPublishUploads-Cex-NBe6.js.map +1 -0
  87. package/dist/{index--mmQ3LQu.js → index-BAao3_Po.js} +9 -9
  88. package/dist/index-BAao3_Po.js.map +1 -0
  89. package/dist/{index-B7yAoYli.js → index-BbFwftAv.js} +2 -2
  90. package/dist/index-BbFwftAv.js.map +1 -0
  91. package/dist/{index-CrvIcVFJ.js → index-DpgQMIRq.js} +32 -15
  92. package/dist/index-DpgQMIRq.js.map +1 -0
  93. package/dist/{index.browser-BmVS-c2C.js → index.browser-nndbVM7z.js} +26 -28
  94. package/dist/index.browser-nndbVM7z.js.map +1 -0
  95. package/dist/{index.node-BKpbCAWt.js → index.node-BUfx-JaP.js} +7 -7
  96. package/dist/index.node-BUfx-JaP.js.map +1 -0
  97. package/dist/main.js +155 -26
  98. package/dist/main.js.map +1 -1
  99. package/dist/node.js +13 -13
  100. package/dist/node.js.map +1 -1
  101. package/dist/platform.browser.js +5 -5
  102. package/dist/platform.node.js +4 -4
  103. package/dist/{property-DQ-Owzki.js → property-BDBvImLs.js} +11 -11
  104. package/dist/property-BDBvImLs.js.map +1 -0
  105. package/dist/{propertyValidationRules-BDhFjlwP.js → propertyValidationRules-BlfLn4rP.js} +6 -6
  106. package/dist/{propertyValidationRules-BDhFjlwP.js.map → propertyValidationRules-BlfLn4rP.js.map} +1 -1
  107. package/dist/{publishDraftGraph-CzPd9oe9.js → publishDraftGraph-CLO85LLz.js} +7 -7
  108. package/dist/publishDraftGraph-CLO85LLz.js.map +1 -0
  109. package/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.js → resetAmbiguousLegacyItemData-Cy8ik7xk.js} +2 -2
  110. package/dist/{resetAmbiguousLegacyItemData-cXZm4NuG.js.map → resetAmbiguousLegacyItemData-Cy8ik7xk.js.map} +1 -1
  111. package/dist/{resolveModelForSyncedSeed-BgxtVCHI.js → resolveModelForSyncedSeed-DFr4COc4.js} +4 -4
  112. package/dist/resolveModelForSyncedSeed-DFr4COc4.js.map +1 -0
  113. package/dist/src/Item/Item.d.ts +2 -2
  114. package/dist/src/Item/Item.d.ts.map +1 -1
  115. package/dist/src/Item/errors.d.ts +25 -0
  116. package/dist/src/Item/errors.d.ts.map +1 -1
  117. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
  118. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  119. package/dist/src/ItemProperty/ItemProperty.d.ts +14 -3
  120. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  121. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  122. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
  123. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
  124. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  125. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -1
  126. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +1 -1
  127. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +1 -1
  128. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +1 -1
  129. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
  130. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  131. package/dist/src/ItemProperty/service/propertyMachine.d.ts +1 -6
  132. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  133. package/dist/src/Model/Model.d.ts.map +1 -1
  134. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  135. package/dist/src/Schema/Schema.d.ts.map +1 -1
  136. package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
  137. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +1 -1
  138. package/dist/src/Schema/service/validation/SchemaValidationService.d.ts +1 -1
  139. package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
  140. package/dist/src/Schema/validation.d.ts.map +1 -1
  141. package/dist/src/browser/db/Db.d.ts +1 -1
  142. package/dist/src/browser/db/Db.d.ts.map +1 -1
  143. package/dist/src/browser/helpers/PathResolver.d.ts +2 -2
  144. package/dist/src/browser/helpers/PathResolver.d.ts.map +1 -1
  145. package/dist/src/browser/seed.d.ts +1 -1
  146. package/dist/src/browser/seed.d.ts.map +1 -1
  147. package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
  148. package/dist/src/client/BaseClientManager.d.ts +1 -1
  149. package/dist/src/client/BaseClientManager.d.ts.map +1 -1
  150. package/dist/src/client/ClientManager.d.ts +1 -0
  151. package/dist/src/client/ClientManager.d.ts.map +1 -1
  152. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  153. package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
  154. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  155. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  156. package/dist/src/client/constants.d.ts.map +1 -1
  157. package/dist/src/db/clearStoredDisplayUrls.d.ts +18 -0
  158. package/dist/src/db/clearStoredDisplayUrls.d.ts.map +1 -0
  159. package/dist/src/db/read/getItems.d.ts.map +1 -1
  160. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  161. package/dist/src/db/read/nameMatchLevels.d.ts +7 -3
  162. package/dist/src/db/read/nameMatchLevels.d.ts.map +1 -1
  163. package/dist/src/db/read/resolveModelForSyncedSeed.d.ts +2 -2
  164. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +10 -0
  165. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
  166. package/dist/src/db/write/deleteItem.d.ts +4 -0
  167. package/dist/src/db/write/deleteItem.d.ts.map +1 -1
  168. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  169. package/dist/src/eas.d.ts.map +1 -1
  170. package/dist/src/events/item/index.d.ts.map +1 -1
  171. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  172. package/dist/src/events/services/allItems.d.ts +1 -1
  173. package/dist/src/events/services/allItems.d.ts.map +1 -1
  174. package/dist/src/helpers/db.d.ts.map +1 -1
  175. package/dist/src/helpers/file/fetchAll/actors.d.ts.map +1 -1
  176. package/dist/src/helpers/file/fetchAll/index.d.ts.map +1 -1
  177. package/dist/src/helpers/schema.d.ts.map +1 -1
  178. package/dist/src/helpers/updateSchema.d.ts +1 -1
  179. package/dist/src/helpers/updateSchema.d.ts.map +1 -1
  180. package/dist/src/imports/json.d.ts.map +1 -1
  181. package/dist/src/imports/markdown.d.ts +1 -1
  182. package/dist/src/imports/markdown.d.ts.map +1 -1
  183. package/dist/src/index.d.ts +1 -1
  184. package/dist/src/index.d.ts.map +1 -1
  185. package/dist/src/interfaces/IItem.d.ts +1 -1
  186. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  187. package/dist/src/interfaces/IItemProperty.d.ts +5 -1
  188. package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
  189. package/dist/src/node/helpers/scripts.d.ts +1 -1
  190. package/dist/src/services/write/actors/validateEntity.d.ts.map +1 -1
  191. package/dist/src/services/write/writeProcessMachine.d.ts +3 -4
  192. package/dist/src/services/write/writeProcessMachine.d.ts.map +1 -1
  193. package/dist/src/types/fileManager.d.ts.map +1 -1
  194. package/dist/src/types/item.d.ts +5 -4
  195. package/dist/src/types/item.d.ts.map +1 -1
  196. package/dist/src/types/model.d.ts.map +1 -1
  197. package/dist/src/types/property.d.ts +5 -5
  198. package/dist/src/types/property.d.ts.map +1 -1
  199. package/dist/{syncDbWithEas-Y5GysSCm.js → syncDbWithEas-CAOlw3i-.js} +17 -18
  200. package/dist/syncDbWithEas-CAOlw3i-.js.map +1 -0
  201. package/dist/{tabEvents-D9x26vf2.js → tabEvents-DksXwk3X.js} +4 -4
  202. package/dist/{tabEvents-D9x26vf2.js.map → tabEvents-DksXwk3X.js.map} +1 -1
  203. package/dist/{tolerantWebAccess-BFU2t-SC.js → tolerantWebAccess-CEIjFGf0.js} +6 -6
  204. package/dist/{tolerantWebAccess-BFU2t-SC.js.map → tolerantWebAccess-CEIjFGf0.js.map} +1 -1
  205. package/dist/{updateSeedRevokedAt-CCF8WWYS.js → updateSeedRevokedAt-Cjr35YjE.js} +3 -3
  206. package/dist/{updateSeedRevokedAt-CCF8WWYS.js.map → updateSeedRevokedAt-Cjr35YjE.js.map} +1 -1
  207. package/package.json +6 -6
  208. package/dist/ClientManager-D6YA20jP.js.map +0 -1
  209. package/dist/Item-B1MH0tXx.js.map +0 -1
  210. package/dist/ModelProperty-Dw6dHdu_.js.map +0 -1
  211. package/dist/Schema-DppObO6h.js.map +0 -1
  212. package/dist/SchemaValidationService-DXQ-D531.js.map +0 -1
  213. package/dist/dist/ClientManager-D6YA20jP.d.ts.map +0 -1
  214. package/dist/dist/Item-B1MH0tXx.d.ts.map +0 -1
  215. package/dist/dist/backfillMetadataPropertyIds-Uhzlwg9X.d.ts.map +0 -1
  216. package/dist/dist/configurePlatform-CVoh3JeR.d.ts.map +0 -1
  217. package/dist/dist/detachRowsBeforeDelete-CtmIFpgV.d.ts.map +0 -1
  218. package/dist/dist/discardNewDraft-oGYdB5vS.d.ts.map +0 -1
  219. package/dist/dist/eas-CSm5wmry.d.ts.map +0 -1
  220. package/dist/dist/errors-3tc6XkCB.d.ts.map +0 -1
  221. package/dist/dist/getItem-DM3a-7XE.d.ts.map +0 -1
  222. package/dist/dist/getPublishPayload-CJF0k5d8.d.ts.map +0 -1
  223. package/dist/dist/index--mmQ3LQu.d.ts.map +0 -1
  224. package/dist/dist/index-CrvIcVFJ.d.ts.map +0 -1
  225. package/dist/dist/property-DQ-Owzki.d.ts.map +0 -1
  226. package/dist/dist/propertyValidationRules-BDhFjlwP.d.ts.map +0 -1
  227. package/dist/dist/resetAmbiguousLegacyItemData-cXZm4NuG.d.ts.map +0 -1
  228. package/dist/dist/resolveModelForSyncedSeed-BgxtVCHI.d.ts.map +0 -1
  229. package/dist/dist/syncDbWithEas-Y5GysSCm.d.ts.map +0 -1
  230. package/dist/dist/updateSeedRevokedAt-CCF8WWYS.d.ts.map +0 -1
  231. package/dist/eas-CSm5wmry.js.map +0 -1
  232. package/dist/errors-3tc6XkCB.js.map +0 -1
  233. package/dist/getPublishPayload-CJF0k5d8.js.map +0 -1
  234. package/dist/getPublishUploads-C7-fYIgX.js.map +0 -1
  235. package/dist/index--mmQ3LQu.js.map +0 -1
  236. package/dist/index-B7yAoYli.js.map +0 -1
  237. package/dist/index-CrvIcVFJ.js.map +0 -1
  238. package/dist/index.browser-BmVS-c2C.js.map +0 -1
  239. package/dist/index.node-BKpbCAWt.js.map +0 -1
  240. package/dist/property-DQ-Owzki.js.map +0 -1
  241. package/dist/publishDraftGraph-CzPd9oe9.js.map +0 -1
  242. package/dist/resolveModelForSyncedSeed-BgxtVCHI.js.map +0 -1
  243. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +0 -5
  244. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +0 -1
  245. package/dist/src/db/write/recoverDeletedItem.d.ts +0 -5
  246. package/dist/src/db/write/recoverDeletedItem.d.ts.map +0 -1
  247. package/dist/src/interfaces/IEasClient.d.ts +0 -3
  248. package/dist/src/interfaces/IEasClient.d.ts.map +0 -1
  249. package/dist/syncDbWithEas-Y5GysSCm.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { waitFor, fromCallback, setup, assign, stateIn, createActor, isMachineSnapshot } from 'xstate';
2
- import { B as BaseDb, F as versions, m as metadata, C as seeds, G as resolveStorageNameToSchemaName, a$ as toSchemaPropertyName, A as schemas, t as models, r as modelSchemas, aZ as getOwnedAddressesFromDb, a2 as ZERO_BYTES32, aF as normalizeAddressList, aj as normalizeHexAddress, aC as getAddressesForItemsFilter, a6 as INTERNAL_PROPERTY_NAMES, b0 as easSchemaDefinitionForProperty, h as BaseFileManager, b1 as getStorageTransactionIdForSeedUid, b2 as convertTxIdToImage, i as isDataType, ae as normalizePublisher, n as normalizeDataType, b3 as getMetadataPropertyNamesForQuery, aB as ensureImageLocal, at as ImageSize, b4 as downloadTransactionIdWithDedupe, b5 as resolveMetadataRecord, v as properties, M as ModelPropertyDataTypes, ai as generateId, a9 as INTERNAL_DATA_TYPES, s as modelUids, aa as listRelationEasPropertyName, ab as easPropertyNameForPublish, L as resolveItemModelFileId, b6 as getPropertyIdForSchemaFileId, K as getPropertyIdForModelAndName, ak as toMetadataPropertyName, b7 as getDataTypeFromString, b8 as getMimeType, X as INTERNAL_STORAGE_MODEL_FILE_IDS, $ as getItemStorageSubdir, a0 as getItemStorageLocalFileName, g as normalizePropertyRecordSchema, b9 as listRelationStoragePropertyName, ba as PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, Q as getCorrectId, I as eventEmitter, bb as getAlternatePropertyNameForInstanceLookup, a7 as isStorageSeedRef } from './index-CrvIcVFJ.js';
3
- import { or, isNull, eq, max, count, and, getTableColumns, sql, desc, inArray, isNotNull, gt } from 'drizzle-orm';
2
+ import { B as BaseDb, F as versions, m as metadata, C as seeds, G as resolveStorageNameToSchemaName, a$ as toSchemaPropertyName, i as isDataType, A as schemas, t as models, r as modelSchemas, aZ as getOwnedAddressesFromDb, a2 as ZERO_BYTES32, aF as normalizeAddressList, aj as normalizeHexAddress, aC as getAddressesForItemsFilter, a6 as INTERNAL_PROPERTY_NAMES, b0 as easSchemaDefinitionForProperty, h as BaseFileManager, b1 as getStorageTransactionIdForSeedUid, b2 as convertTxIdToImage, ae as normalizePublisher, n as normalizeDataType, b3 as getMetadataPropertyNamesForQuery, aB as ensureImageLocal, at as ImageSize, b4 as downloadTransactionIdWithDedupe, b5 as resolveMetadataRecord, v as properties, M as ModelPropertyDataTypes, ai as generateId, a9 as INTERNAL_DATA_TYPES, s as modelUids, aa as listRelationEasPropertyName, ab as easPropertyNameForPublish, L as resolveItemModelFileId, b6 as getPropertyIdForSchemaFileId, K as getPropertyIdForModelAndName, ak as toMetadataPropertyName, b7 as getDataTypeFromString, b8 as getMimeType, X as INTERNAL_STORAGE_MODEL_FILE_IDS, $ as getItemStorageSubdir, a0 as getItemStorageLocalFileName, g as normalizePropertyRecordSchema, b9 as listRelationStoragePropertyName, ba as PROPERTY_NAMES_EXEMPT_FROM_ID_SUFFIX_STRIP, Q as getCorrectId, I as eventEmitter, bb as getAlternatePropertyNameForInstanceLookup, a7 as isStorageSeedRef } from './index-DpgQMIRq.js';
3
+ import { or, isNull, eq, max, count, and, getTableColumns, sql, desc, inArray, gt, isNotNull } from 'drizzle-orm';
4
+ import pluralize from 'pluralize';
4
5
  import debug from 'debug';
5
6
  import { BehaviorSubject } from 'rxjs';
6
- import pluralize from 'pluralize';
7
7
  import { startCase, upperFirst, camelCase, orderBy } from 'lodash-es';
8
8
  import { isValidEasAttestationUid, easName, isPlaceholderUid, BaseQueryClient, BaseEasClient, GET_SCHEMAS, getEasSchemaUidForSchemaDefinition, getSchemaUidForModelFromCache, setSchemaUidForModel, cachedSchemaLookup, getEasSchemaUidForExactDefinition } from '@seedprotocol/eas';
9
9
  import { fetchArweaveRawTextAcrossGateways } from '@seedprotocol/arweave';
10
- import { d as notifyFileSaved, f as withTabLock } from './tabEvents-D9x26vf2.js';
10
+ import { d as notifyFileSaved, f as withTabLock } from './tabEvents-DksXwk3X.js';
11
11
  import { modelPropertiesToObject } from './model-oHA3YhOd.js';
12
12
 
13
13
  /**
@@ -266,7 +266,7 @@ var MachineIds;
266
266
  MachineIds["MODEL"] = "@seedSdk/model";
267
267
  MachineIds["FILE_SYSTEM"] = "@seedSdk/fileSystem";
268
268
  })(MachineIds || (MachineIds = {}));
269
- const { INTERNAL, GLOBAL, EAS, MODEL } = MachineIds;
269
+ const { INTERNAL, GLOBAL } = MachineIds;
270
270
  var ClientManagerState;
271
271
  (function (ClientManagerState) {
272
272
  ClientManagerState["UNINITIALIZED"] = "uninitialized";
@@ -302,7 +302,7 @@ var GlobalState;
302
302
  GlobalState["PUBLISHING_ITEM"] = "publishingItem";
303
303
  GlobalState["ADDING_MODELS_TO_DB"] = "addingModelsToDb";
304
304
  })(GlobalState || (GlobalState = {}));
305
- const { UNINITIALIZED: GLOBAL_UNINITIALIZED, INITIALIZING, INITIALIZED, PUBLISHING_ITEM, ADDING_MODELS_TO_DB, } = GlobalState;
305
+ const { INITIALIZING, PUBLISHING_ITEM, ADDING_MODELS_TO_DB, } = GlobalState;
306
306
  var InternalState;
307
307
  (function (InternalState) {
308
308
  InternalState["IDLE"] = "idle";
@@ -580,8 +580,8 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
580
580
  const itemPropertyMod = await Promise.resolve().then(function () { return ItemProperty$1; });
581
581
  const { ItemProperty } = itemPropertyMod;
582
582
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
583
- const _mod_0 = await import('./errors-3tc6XkCB.js');
584
- const _ns_0 = _mod_0.h;
583
+ const _mod_0 = await import('./errors-KM-yq2MD.js');
584
+ const _ns_0 = _mod_0.j;
585
585
  const { Model } = _ns_0;
586
586
  // Resolve Model and build property schemas (use getByNameAsync for models not yet in cache)
587
587
  let propertySchemas = {};
@@ -598,7 +598,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
598
598
  const schemaNameToTry = schemaName ?? model?.schemaName;
599
599
  if (schemaNameToTry) {
600
600
  try {
601
- const _mod_1 = await import('./Schema-DppObO6h.js');
601
+ const _mod_1 = await import('./Schema-O1QLoXv6.js');
602
602
  const _ns_1 = _mod_1.b;
603
603
  const { Schema } = _ns_1;
604
604
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
@@ -614,7 +614,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
614
614
  }
615
615
  if (Object.keys(propertySchemas).length === 0) {
616
616
  try {
617
- const _mod_2 = await import('./ClientManager-D6YA20jP.js');
617
+ const _mod_2 = await import('./ClientManager-2GtDWHq6.js');
618
618
  const _ns_2 = _mod_2.N;
619
619
  const { loadAllSchemasFromDb } = _ns_2;
620
620
  const allSchemas = await loadAllSchemasFromDb();
@@ -635,10 +635,10 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
635
635
  }
636
636
  if (Object.keys(propertySchemas).length === 0) {
637
637
  try {
638
- const _mod_3 = await import('./ClientManager-D6YA20jP.js');
638
+ const _mod_3 = await import('./ClientManager-2GtDWHq6.js');
639
639
  const _ns_3 = _mod_3.N;
640
640
  const { listCompleteSchemaFiles } = _ns_3;
641
- const _mod_4 = await import('./index-CrvIcVFJ.js');
641
+ const _mod_4 = await import('./index-DpgQMIRq.js');
642
642
  const _ns_4 = _mod_4.be;
643
643
  const { BaseFileManager } = _ns_4;
644
644
  const schemaFiles = await listCompleteSchemaFiles();
@@ -659,7 +659,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
659
659
  }
660
660
  }
661
661
  if (Object.keys(propertySchemas).length === 0) {
662
- const schemaMod = await import('./index--mmQ3LQu.js');
662
+ const schemaMod = await import('./index-BAao3_Po.js');
663
663
  const { ModelPropertyDataTypes } = schemaMod;
664
664
  const KNOWN_MODEL_FALLBACKS = {
665
665
  Post: {
@@ -676,7 +676,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
676
676
  }
677
677
  }
678
678
  // Fallbacks above may return schema-file shape ({ type, model, items }); normalize to dataType/ref/refValueType.
679
- const { normalizePropertyRecordSchema } = await import('./property-DQ-Owzki.js');
679
+ const { normalizePropertyRecordSchema } = await import('./property-BDBvImLs.js');
680
680
  propertySchemas = Object.fromEntries(Object.entries(propertySchemas).map(([name, def]) => [name, normalizePropertyRecordSchema(def)]));
681
681
  // Collapse rows that map to the same instance key (e.g. authorIdentityIds + authors -> authors).
682
682
  // ItemProperty.create cache does not sync propertyValue on hit; processing order would otherwise
@@ -709,7 +709,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
709
709
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
710
710
  let propSchema = propertySchemas[propertyName];
711
711
  if (!propSchema && isRefTypeFromMeta) {
712
- const schemaMod = await import('./index--mmQ3LQu.js');
712
+ const schemaMod = await import('./index-BAao3_Po.js');
713
713
  const { ModelPropertyDataTypes } = schemaMod;
714
714
  propSchema = {
715
715
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -733,7 +733,10 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
733
733
  propertyRecordSchema: propSchema,
734
734
  refSeedType: metaRow.refSeedType ?? undefined,
735
735
  refResolvedValue: metaRow.refResolvedValue ?? undefined,
736
- refResolvedDisplayValue: metaRow.refResolvedDisplayValue ?? undefined,
736
+ // File/Image display values are session URLs the property mints from the file; a stored one is stale.
737
+ refResolvedDisplayValue: refSeedType === 'file' || refSeedType === 'image' || isDataType(propSchema?.dataType, 'File') || isDataType(propSchema?.dataType, 'Image')
738
+ ? undefined
739
+ : metaRow.refResolvedDisplayValue ?? undefined,
737
740
  localStorageDir: metaRow.localStorageDir ?? undefined,
738
741
  };
739
742
  const property = ItemProperty.create(createProps, { waitForReady: false });
@@ -996,7 +999,6 @@ const runPublish = fromCallback(({ sendBack, input: { context, item: itemFromEve
996
999
  _runPublish();
997
1000
  });
998
1001
 
999
- // @ts-ignore - Complex type inference from setup().createMachine()
1000
1002
  const itemMachineSingle = setup({
1001
1003
  types: {
1002
1004
  context: {},
@@ -1110,8 +1112,10 @@ const itemMachineSingle = setup({
1110
1112
  target: 'idle',
1111
1113
  actions: assign({
1112
1114
  _publishError: ({ event }) => {
1113
- const err = 'error' in event ? event.error : null;
1114
- return err ? { message: err.message } : null;
1115
+ if (!('error' in event))
1116
+ return null;
1117
+ const err = event.error;
1118
+ return err instanceof Error ? err : new Error(String(err));
1115
1119
  },
1116
1120
  }),
1117
1121
  },
@@ -1403,7 +1407,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
1403
1407
  console.error('[getItemData] Error querying versions', error);
1404
1408
  // Continue with default versionRow values
1405
1409
  }
1406
- let itemData = {
1410
+ const itemData = {
1407
1411
  ...seedRow,
1408
1412
  ...versionRow,
1409
1413
  schemaName,
@@ -1417,7 +1421,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
1417
1421
  }
1418
1422
  for (const propertyData of propertiesData) {
1419
1423
  const propertyName = propertyData.propertyName;
1420
- let propertyValue = propertyData.propertyValue;
1424
+ const propertyValue = propertyData.propertyValue;
1421
1425
  const schemaBaseName = toSchemaPropertyName(propertyName);
1422
1426
  if (schemaBaseName && propertyData.refSeedType) {
1423
1427
  itemData[schemaBaseName] = propertyValue;
@@ -1711,7 +1715,7 @@ const getItemsData = async ({ modelName, modelFileId, schemaName, deleted, inclu
1711
1715
  conditions.push(eq(seeds.type, easName(modelName)));
1712
1716
  }
1713
1717
  if (!modelFileId && schemaName && modelName) {
1714
- const _mod_5 = await import('./index-CrvIcVFJ.js');
1718
+ const _mod_5 = await import('./index-DpgQMIRq.js');
1715
1719
  const _ns_5 = _mod_5.bh;
1716
1720
  const { resolveModelRecord } = _ns_5;
1717
1721
  modelFileId = (await resolveModelRecord(modelName, { schemaName }))?.schemaFileId ?? undefined;
@@ -1730,7 +1734,7 @@ const getItemsData = async ({ modelName, modelFileId, schemaName, deleted, inclu
1730
1734
  conditions.push(publisherInAddressListSql(seeds.publisher, watchedAddresses));
1731
1735
  }
1732
1736
  if (deleted) {
1733
- conditions.push(or(isNotNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 1)));
1737
+ conditions.push(eq(seeds._markedForDeletion, 1));
1734
1738
  }
1735
1739
  if (!deleted) {
1736
1740
  conditions.push(or(isNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 0)));
@@ -1742,7 +1746,7 @@ const getItemsData = async ({ modelName, modelFileId, schemaName, deleted, inclu
1742
1746
  const selectModelNameOrType = modelName
1743
1747
  ? { modelName: sql `${modelName}` }
1744
1748
  : { type: seeds.type };
1745
- let query = appDb
1749
+ const query = appDb
1746
1750
  .with(versionData)
1747
1751
  .select({
1748
1752
  seedLocalId: seeds.localId,
@@ -1994,10 +1998,10 @@ const storageTransactionIdToContentUrl = new Map();
1994
1998
  const refResolvedValueToContentUrl = new Map();
1995
1999
  const seedUidToContentUrl = new Map();
1996
2000
  const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
1997
- const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
2001
+ const { isRelation, propertyValue, propertyName, propertyRecordSchema, populatedFromDb, } = context;
1998
2002
  const _resolveRelatedValue = async () => {
1999
2003
  // Use dynamic import to break circular dependency
2000
- const schemaMod = await import('./index--mmQ3LQu.js');
2004
+ const schemaMod = await import('./index-BAao3_Po.js');
2001
2005
  const { ModelPropertyDataTypes } = schemaMod;
2002
2006
  if (!propertyValue || !isRelation || populatedFromDb) {
2003
2007
  return;
@@ -2015,7 +2019,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
2015
2019
  try {
2016
2020
  parsedValue = JSON.parse(relationKey);
2017
2021
  }
2018
- catch (error) {
2022
+ catch {
2019
2023
  logger$5(`${propertyName} value is not a JSON string.`);
2020
2024
  }
2021
2025
  if (!parsedValue && seedUidToContentUrl.has(relationKey)) {
@@ -2137,7 +2141,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
2137
2141
  }
2138
2142
  }
2139
2143
  };
2140
- _resolveRelatedValue().then((success) => {
2144
+ _resolveRelatedValue().then(() => {
2141
2145
  // if (success) {
2142
2146
  // sendBack({
2143
2147
  // type: 'resolvingRelatedValueDone',
@@ -2432,7 +2436,7 @@ async function readHtmlBodyFromChildStorageArweave(seedLocalId) {
2432
2436
  /* offline / bad tx id */
2433
2437
  }
2434
2438
  try {
2435
- const _mod_6 = await import('./index-CrvIcVFJ.js');
2439
+ const _mod_6 = await import('./index-DpgQMIRq.js');
2436
2440
  const _ns_6 = _mod_6.bj;
2437
2441
  const { downloadTransactionIdWithDedupe } = _ns_6;
2438
2442
  await downloadTransactionIdWithDedupe(txId);
@@ -2488,12 +2492,12 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
2488
2492
  if (!propertyNameRaw) {
2489
2493
  throw new Error('propertyName is required');
2490
2494
  }
2491
- let propertyName = propertyNameRaw;
2495
+ const propertyName = propertyNameRaw;
2492
2496
  // Note: isRelation, isImage, isFile checks moved inside async function
2493
2497
  // to use dynamically imported ModelPropertyDataTypes
2494
2498
  const _hydrateFromDb = async () => {
2495
2499
  // Use dynamic import to break circular dependency
2496
- const schemaMod = await import('./index--mmQ3LQu.js');
2500
+ const schemaMod = await import('./index-BAao3_Po.js');
2497
2501
  const { ModelPropertyDataTypes } = schemaMod;
2498
2502
  const appDb = BaseDb.getAppDb();
2499
2503
  const whereClauses = [];
@@ -2501,9 +2505,6 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
2501
2505
  // Use normalizeDataType for case-insensitive comparison (schema may use "image" vs "Image")
2502
2506
  const normalizedDataType = normalizeDataType(propertyRecordSchema?.dataType);
2503
2507
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
2504
- propertyRecordSchema &&
2505
- propertyRecordSchema.ref &&
2506
- normalizedDataType === ModelPropertyDataTypes.Relation;
2507
2508
  const isImageDynamic = propertyRecordSchema &&
2508
2509
  (normalizedDataType === ModelPropertyDataTypes.Image ||
2509
2510
  normalizedRefValueType === ModelPropertyDataTypes.Image);
@@ -2536,8 +2537,12 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
2536
2537
  return;
2537
2538
  }
2538
2539
  const firstRow = rows[0];
2539
- const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, versionLocalId: versionLocalIdFromDb, versionUid: versionUidFromDb, refValueType, } = firstRow;
2540
+ const { localId, uid, propertyValue: propertyValueFromDb, seedLocalId: seedLocalIdFromDb, seedUid: seedUidFromDb, schemaUid: schemaUidFromDb, versionLocalId: versionLocalIdFromDb, versionUid: versionUidFromDb, refValueType, } = firstRow;
2540
2541
  let { refResolvedDisplayValue, refResolvedValue, localStorageDir } = firstRow;
2542
+ // File/Image display values are minted below from the file; a stored one is a stale session URL.
2543
+ if (isImageDynamic || isFileDynamic) {
2544
+ refResolvedDisplayValue = null;
2545
+ }
2541
2546
  let propertyValueProcessed = propertyValueFromDb;
2542
2547
  let renderValue = refResolvedDisplayValue ?? undefined;
2543
2548
  // Image: always resolve display value from file (blob URLs in DB are invalid after reload)
@@ -2774,11 +2779,11 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2774
2779
  const modelNameForNew = context.modelName;
2775
2780
  if (modelNameForNew) {
2776
2781
  try {
2777
- const _mod_7 = await import('./errors-3tc6XkCB.js');
2778
- const _ns_7 = _mod_7.h;
2782
+ const _mod_7 = await import('./errors-KM-yq2MD.js');
2783
+ const _ns_7 = _mod_7.j;
2779
2784
  const { Model } = _ns_7;
2780
2785
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
2781
- const _mod_8 = await import('./index-CrvIcVFJ.js');
2786
+ const _mod_8 = await import('./index-DpgQMIRq.js');
2782
2787
  const _ns_8 = _mod_8.bh;
2783
2788
  const { resolveItemModelFileId } = _ns_8;
2784
2789
  const normalizedModelName = upperFirst(camelCase(modelNameForNew));
@@ -2832,7 +2837,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2832
2837
  // It ends up in the context below, and later lookups by name (Model.getByName) can't match it.
2833
2838
  const modelName = context.modelName || (metadataRecord.modelType ? upperFirst(camelCase(metadataRecord.modelType)) : undefined);
2834
2839
  // Model names are only unique per schema: pin lookups to the item's own model row.
2835
- const _mod_9 = await import('./index-CrvIcVFJ.js');
2840
+ const _mod_9 = await import('./index-DpgQMIRq.js');
2836
2841
  const _ns_9 = _mod_9.bh;
2837
2842
  const { resolveItemModelFileId, resolveModelRecord } = _ns_9;
2838
2843
  const modelFileId = await resolveItemModelFileId({
@@ -2877,7 +2882,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2877
2882
  required: propRecord.required ?? undefined,
2878
2883
  };
2879
2884
  // Validation rules (enum, pattern, ...) aren't in the properties table
2880
- const { resolvePropertyValidationRules } = await import('./propertyValidationRules-BDhFjlwP.js');
2885
+ const { resolvePropertyValidationRules } = await import('./propertyValidationRules-BlfLn4rP.js');
2881
2886
  const validation = await resolvePropertyValidationRules(normalizedModelName, propertyName, {
2882
2887
  modelFileId: modelRecord?.schemaFileId ?? modelFileId,
2883
2888
  });
@@ -2892,10 +2897,11 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2892
2897
  // Continue without propertyRecordSchema
2893
2898
  }
2894
2899
  }
2900
+ // Fix 1: Fallback to in-memory Model when DB doesn't have model/properties yet (e.g. runtime-created model)
2895
2901
  if (!propertyRecordSchema && modelName) {
2896
2902
  try {
2897
- const _mod_10 = await import('./errors-3tc6XkCB.js');
2898
- const _ns_10 = _mod_10.h;
2903
+ const _mod_10 = await import('./errors-KM-yq2MD.js');
2904
+ const _ns_10 = _mod_10.j;
2899
2905
  const { Model } = _ns_10;
2900
2906
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
2901
2907
  const normalizedModelName = upperFirst(camelCase(modelName));
@@ -2968,13 +2974,18 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
2968
2974
  }
2969
2975
  }
2970
2976
  }
2971
- // Image: always resolve display value from file (blob URLs in DB are invalid after reload)
2972
- let refResolvedDisplayValue = (metadataRecord.refResolvedDisplayValue ?? context.refResolvedDisplayValue) ?? undefined;
2973
2977
  const normalizedDataType = normalizeDataType(propertyRecordSchema?.dataType);
2974
2978
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
2975
2979
  const isImage = refSeedType === 'image' ||
2976
2980
  normalizedDataType === 'Image' ||
2977
2981
  normalizedRefValueType === 'Image';
2982
+ const isFile = refSeedType === 'file' ||
2983
+ normalizedDataType === 'File';
2984
+ // Image and File: the display value is a session URL minted from the file below. A stored one is a
2985
+ // dead blob: URL after reload (or a file:// URL that breaks when filesDir moves), so never read it.
2986
+ let refResolvedDisplayValue = isImage || isFile
2987
+ ? context.refResolvedDisplayValue ?? undefined
2988
+ : (metadataRecord.refResolvedDisplayValue ?? context.refResolvedDisplayValue) ?? undefined;
2978
2989
  const resolveMatchingFilePath = async (dir, needle) => {
2979
2990
  const dirPath = BaseFileManager.getFilesPath(dir);
2980
2991
  const dirExists = await BaseFileManager.pathExists(dirPath);
@@ -3037,8 +3048,6 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
3037
3048
  logger$3(`Failed to resolve Image file for ${propertyName}: ${e}`);
3038
3049
  }
3039
3050
  }
3040
- const isFile = refSeedType === 'file' ||
3041
- normalizedDataType === 'File';
3042
3051
  if (isFile && metadataRecord.refResolvedValue) {
3043
3052
  try {
3044
3053
  const dir = (metadataRecord.localStorageDir ?? '/files').replace(/^\//, '');
@@ -3050,6 +3059,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
3050
3059
  if (filePath) {
3051
3060
  // The content URL saveFile and hydrateFromDb set, so the value reads the same everywhere.
3052
3061
  renderValue = await BaseFileManager.getContentUrlFromPath(filePath);
3062
+ refResolvedDisplayValue = renderValue;
3053
3063
  }
3054
3064
  }
3055
3065
  catch (e) {
@@ -3201,7 +3211,7 @@ const updateItemPropertyValue = async ({ localId: localIdParam, propertyName, ne
3201
3211
  rows = newestRows;
3202
3212
  }
3203
3213
  if (rows && rows.length > 0) {
3204
- const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, modelType, seedUid, seedLocalId: seedLocalIdFromDb, versionLocalId, versionUid, schemaUid, easDataType, localStorageDir: localStorageDirFromDb, refSeedType: refSeedTypeFromDb, refResolvedValue: refResolvedValueFromDb, refResolvedDisplayValue: refResolvedDisplayValueFromDb, } = rows[0];
3214
+ const { localId, uid, propertyName: propertyNameFromDb, propertyValue: propertyValueFromDb, modelType, seedLocalId: seedLocalIdFromDb, versionLocalId, schemaUid, easDataType, refSeedType: refSeedTypeFromDb, refResolvedValue: refResolvedValueFromDb, } = rows[0];
3205
3215
  // Stored model types are the model's EAS name (ADR 0008): `blog_post` for BlogPost.
3206
3216
  const modelTypeForName = modelName ? easName(modelName) : undefined;
3207
3217
  if (propertyValueFromDb === newValue &&
@@ -3355,7 +3365,7 @@ const hasPendingPropertyWrite = (key) => !!key && (queues.get(key)?.pending ?? 0
3355
3365
  const rowContext = (result) => (result ? { localId: result.localId, uid: result.uid ?? undefined } : {});
3356
3366
 
3357
3367
  const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
3358
- const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, modelName, } = context;
3368
+ const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyRecordSchema, modelName, } = context;
3359
3369
  let { schemaUid } = context;
3360
3370
  let newValue;
3361
3371
  if (event) {
@@ -3379,10 +3389,10 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
3379
3389
  return false;
3380
3390
  }
3381
3391
  // Use dynamic import to break circular dependency
3382
- const schemaMod = await import('./index--mmQ3LQu.js');
3392
+ const schemaMod = await import('./index-BAao3_Po.js');
3383
3393
  const { ModelPropertyDataTypes } = schemaMod;
3384
- const { SchemaValidationService } = await import('./SchemaValidationService-DXQ-D531.js');
3385
- let propertyName = propertyNameRaw;
3394
+ const { SchemaValidationService } = await import('./SchemaValidationService-BxCbfDaI.js');
3395
+ const propertyName = propertyNameRaw;
3386
3396
  if (!propertyName) {
3387
3397
  throw new Error('propertyName is required');
3388
3398
  }
@@ -3400,15 +3410,8 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
3400
3410
  }
3401
3411
  const normalizedDataType = normalizeDataType(propertyRecordSchema.dataType);
3402
3412
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema.refValueType);
3403
- if (propertyRecordSchema.refValueType &&
3404
- normalizedRefValueType !== ModelPropertyDataTypes.Image &&
3405
- normalizedDataType === ModelPropertyDataTypes.Relation) {
3406
- sendBack({
3407
- type: 'saveRelation',
3408
- newValue,
3409
- });
3410
- return false;
3411
- }
3413
+ // A Relation with a non-Image refValueType stores the related seed id like any other value,
3414
+ // through the write below.
3412
3415
  if (normalizedRefValueType === ModelPropertyDataTypes.Image ||
3413
3416
  normalizedDataType === ModelPropertyDataTypes.Image) {
3414
3417
  sendBack({
@@ -3515,7 +3518,7 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
3515
3518
  return true;
3516
3519
  const result = written.result;
3517
3520
  const stringValueForContext = typeof newValue === 'string' ? newValue : (newValue !== null && newValue !== undefined ? String(newValue) : undefined);
3518
- let updatedContext = {
3521
+ const updatedContext = {
3519
3522
  propertyValue: stringValueForContext,
3520
3523
  renderValue: stringValueForContext,
3521
3524
  };
@@ -3701,7 +3704,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
3701
3704
  propertyRecordSchema?.validation &&
3702
3705
  metadataValues.propertyValue != null &&
3703
3706
  metadataValues.propertyValue !== '') {
3704
- const { SchemaValidationService } = await import('./SchemaValidationService-DXQ-D531.js');
3707
+ const { SchemaValidationService } = await import('./SchemaValidationService-BxCbfDaI.js');
3705
3708
  const validationService = new SchemaValidationService();
3706
3709
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, normalizeDataType(propertyRecordSchema.dataType), propertyRecordSchema.validation, propertyRecordSchema.refValueType
3707
3710
  ? normalizeDataType(String(propertyRecordSchema.refValueType))
@@ -3808,8 +3811,8 @@ const fetchImageAsBuffer = async (url) => {
3808
3811
  };
3809
3812
  let imageSchemaUid;
3810
3813
  const saveImage = fromCallback(({ sendBack, input: { context, event } }) => {
3811
- const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
3812
- let { schemaUid } = context;
3814
+ const { localId, propertyName: propertyNameRaw, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
3815
+ const { schemaUid } = context;
3813
3816
  let newValue;
3814
3817
  if (event) {
3815
3818
  newValue = event.newValue;
@@ -3896,7 +3899,7 @@ const saveImage = fromCallback(({ sendBack, input: { context, event } }) => {
3896
3899
  await BaseFileManager.saveFile(filePath, fileData);
3897
3900
  notifyFileSaved(filePath);
3898
3901
  }
3899
- catch (e) {
3902
+ catch {
3900
3903
  const fs = await BaseFileManager.getFs();
3901
3904
  fs.writeFileSync(filePath, new Uint8Array(fileData));
3902
3905
  notifyFileSaved(filePath);
@@ -3907,7 +3910,7 @@ const saveImage = fromCallback(({ sendBack, input: { context, event } }) => {
3907
3910
  await BaseFileManager.saveFile(filePath, fileData);
3908
3911
  notifyFileSaved(filePath);
3909
3912
  }
3910
- catch (e) {
3913
+ catch {
3911
3914
  const fs = await BaseFileManager.getFs();
3912
3915
  fs.writeFileSync(filePath, fileData);
3913
3916
  notifyFileSaved(filePath);
@@ -3931,7 +3934,7 @@ const saveImage = fromCallback(({ sendBack, input: { context, event } }) => {
3931
3934
  new Promise((resolve) => setTimeout(resolve, RESIZE_TIMEOUT_MS)),
3932
3935
  ]);
3933
3936
  }
3934
- catch (e) {
3937
+ catch {
3935
3938
  // Resize not implemented in this environment (e.g. Node); file is already saved
3936
3939
  }
3937
3940
  }
@@ -4030,8 +4033,8 @@ async function classifyFileString(value) {
4030
4033
  return { kind: 'text' };
4031
4034
  }
4032
4035
  const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4033
- const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
4034
- let { schemaUid } = context;
4036
+ const { localId, propertyName: propertyNameRaw, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
4037
+ const { schemaUid } = context;
4035
4038
  let newValue;
4036
4039
  if (event) {
4037
4040
  newValue = event.newValue;
@@ -4118,7 +4121,7 @@ const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4118
4121
  await BaseFileManager.saveFile(filePath, fileData);
4119
4122
  notifyFileSaved(filePath);
4120
4123
  }
4121
- catch (e) {
4124
+ catch {
4122
4125
  const fs = await BaseFileManager.getFs();
4123
4126
  fs.writeFileSync(filePath, new Uint8Array(fileData));
4124
4127
  notifyFileSaved(filePath);
@@ -4129,13 +4132,15 @@ const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4129
4132
  await BaseFileManager.saveFile(filePath, fileData);
4130
4133
  notifyFileSaved(filePath);
4131
4134
  }
4132
- catch (e) {
4135
+ catch {
4133
4136
  const fs = await BaseFileManager.getFs();
4134
4137
  fs.writeFileSync(filePath, fileData);
4135
4138
  notifyFileSaved(filePath);
4136
4139
  }
4137
4140
  }
4138
4141
  }
4142
+ // A session URL (blob: in browsers, file:// in Node): it goes in the context only. Stored, it is a
4143
+ // dead blob: URL after reload, so readers mint their own from the path, as for Image.
4139
4144
  const refResolvedDisplayValue = await BaseFileManager.getContentUrlFromPath(filePath);
4140
4145
  let newLocalId;
4141
4146
  if (!localId) {
@@ -4150,7 +4155,6 @@ const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4150
4155
  schemaUid: fileSchemaUid,
4151
4156
  refSeedType: 'file',
4152
4157
  refModelUid: fileSchemaUid,
4153
- refResolvedDisplayValue,
4154
4158
  refResolvedValue: fileName,
4155
4159
  localStorageDir: '/files',
4156
4160
  easDataType: 'bytes32',
@@ -4170,7 +4174,6 @@ const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4170
4174
  modelName,
4171
4175
  schemaUid,
4172
4176
  refSeedType: 'file',
4173
- refResolvedDisplayValue,
4174
4177
  refResolvedValue: fileName,
4175
4178
  localStorageDir: '/files',
4176
4179
  dataType: 'File',
@@ -4198,8 +4201,8 @@ const saveFile = fromCallback(({ sendBack, input: { context, event } }) => {
4198
4201
 
4199
4202
  let htmlSchemaUid;
4200
4203
  const saveHtml = fromCallback(({ sendBack, input: { context, event } }) => {
4201
- const { localId, propertyName: propertyNameRaw, propertyValue: existingValue, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
4202
- let { schemaUid } = context;
4204
+ const { localId, propertyName: propertyNameRaw, propertyRecordSchema, modelName, seedLocalId, seedUid, versionLocalId, versionUid, } = context;
4205
+ const { schemaUid } = context;
4203
4206
  let newValue;
4204
4207
  if (event) {
4205
4208
  newValue = event.newValue;
@@ -4235,7 +4238,7 @@ const saveHtml = fromCallback(({ sendBack, input: { context, event } }) => {
4235
4238
  await BaseFileManager.saveFile(filePath, htmlContent);
4236
4239
  notifyFileSaved(filePath);
4237
4240
  }
4238
- catch (e) {
4241
+ catch {
4239
4242
  const fs = await BaseFileManager.getFs();
4240
4243
  fs.writeFileSync(filePath, htmlContent);
4241
4244
  notifyFileSaved(filePath);
@@ -4307,91 +4310,6 @@ const saveHtml = fromCallback(({ sendBack, input: { context, event } }) => {
4307
4310
  });
4308
4311
  });
4309
4312
 
4310
- // Dynamic import to break circular dependency: schema/index -> ... -> saveRelation -> schema/index
4311
- // import { ModelPropertyDataTypes } from '@/schema'
4312
- const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
4313
- const { localId, propertyName: propertyNameRaw, versionLocalId, seedUid, seedLocalId, propertyValue: existingValue, propertyRecordSchema, } = context;
4314
- if (!propertyRecordSchema) {
4315
- throw new Error('Missing propertyRecordSchema');
4316
- }
4317
- let newValue;
4318
- if (event) {
4319
- newValue = event.newValue;
4320
- }
4321
- const _saveRelation = async () => {
4322
- // Use dynamic import to break circular dependency
4323
- const schemaMod = await import('./index--mmQ3LQu.js');
4324
- const { ModelPropertyDataTypes } = schemaMod;
4325
- if (!propertyNameRaw) {
4326
- throw new Error('propertyName is required');
4327
- }
4328
- toMetadataPropertyName(propertyNameRaw, 'Relation');
4329
- let newValueType;
4330
- if (typeof newValue === 'string') {
4331
- newValueType = getDataTypeFromString(newValue);
4332
- }
4333
- if (newValue instanceof File) {
4334
- newValueType = 'file';
4335
- }
4336
- if (isDataType(propertyRecordSchema.dataType, ModelPropertyDataTypes.Image)) {
4337
- sendBack({
4338
- type: 'saveImage',
4339
- newValue,
4340
- newValueType,
4341
- });
4342
- return false;
4343
- }
4344
- return true;
4345
- // let fileType
4346
- //
4347
- // const dirs = await fs.promises.readdir('/files')
4348
- //
4349
- // for (const dir of dirs) {
4350
- // const files = await fs.promises.readdir(`/files/${dir}`)
4351
- // if (newValue && files.includes(newValue as string)) {
4352
- // fileType = dir
4353
- // break
4354
- // }
4355
- // }
4356
- //
4357
- // if (newValue && fileType === 'images') {
4358
- // const filePath = `/files/images/${newValue}`
4359
- // refResolvedDisplayValue = await getContentUrlFromPath(filePath)
4360
- // refSeedType = 'image'
4361
- // newValue = await createSeed({
4362
- // type: refSeedType,
4363
- // })
4364
- // await createVersion({
4365
- // seedLocalId,
4366
- // seedUid,
4367
- // seedType: refSeedType,
4368
- // })
4369
- // }
4370
- //
4371
- // await updateItemPropertyValue({
4372
- // propertyLocalId: localId,
4373
- // propertyName,
4374
- // newValue,
4375
- // seedLocalId,
4376
- // refSeedType,
4377
- // refResolvedValue,
4378
- // refResolvedDisplayValue,
4379
- // versionLocalId,
4380
- // modelName: itemModelName,
4381
- // schemaUid,
4382
- // })
4383
- };
4384
- _saveRelation()
4385
- .then((isDone) => {
4386
- if (isDone) {
4387
- sendBack({ type: 'saveRelationSuccess' });
4388
- }
4389
- })
4390
- .catch((error) => {
4391
- sendBack({ type: 'saveRelationError', error });
4392
- });
4393
- });
4394
-
4395
4313
  const getItemPropertyData = async (props) => {
4396
4314
  const appDb = BaseDb.getAppDb();
4397
4315
  const whereClauses = [];
@@ -4494,7 +4412,7 @@ async function withLockedItemStorageRow(localId, fileOf, fn) {
4494
4412
  /** A local edit: no attestation uid of its own and not derived from one. */
4495
4413
  const isLocalDraft = (row) => !row.uid && row.derivedFromUid == null;
4496
4414
  const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) => {
4497
- const { localId, seedLocalId, seedUid, propertyName, propertyRecordSchema, modelName, propertyValue: existingValue, } = context;
4415
+ const { localId, seedLocalId, seedUid, propertyName, propertyRecordSchema, modelName, } = context;
4498
4416
  if (!propertyRecordSchema) {
4499
4417
  throw new Error('Missing propertyRecordSchema');
4500
4418
  }
@@ -4594,7 +4512,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
4594
4512
  try {
4595
4513
  await writeItemStorageFile({ seedId: row.seedUid || row.seedLocalId || '', localStorageDir, fileName }, newValue);
4596
4514
  }
4597
- catch (error) {
4515
+ catch {
4598
4516
  const fs = await BaseFileManager.getFs();
4599
4517
  fs.writeFileSync(filePath, newValue);
4600
4518
  }
@@ -4687,6 +4605,8 @@ const withListValueParsed = (context) => {
4687
4605
  return context;
4688
4606
  return { ...context, propertyValue, renderValue };
4689
4607
  };
4608
+ /** Keeps the thrown Error itself, so `save()` rethrows it with its class, `code` and `cause`. */
4609
+ const toError = (error) => (error instanceof Error ? error : new Error(String(error)));
4690
4610
  const propertyMachine = setup({
4691
4611
  types: {
4692
4612
  context: {},
@@ -4709,7 +4629,6 @@ const propertyMachine = setup({
4709
4629
  saveImage,
4710
4630
  saveFile,
4711
4631
  saveHtml,
4712
- saveRelation,
4713
4632
  saveItemStorage,
4714
4633
  },
4715
4634
  }).createMachine({
@@ -4738,7 +4657,7 @@ const propertyMachine = setup({
4738
4657
  const error = event.error;
4739
4658
  return {
4740
4659
  isSaving: false,
4741
- _saveError: error instanceof Error ? { message: error.message, name: error.name } : { message: String(error) },
4660
+ _saveError: toError(error),
4742
4661
  ...(context._valueBeforeSave ?? {}),
4743
4662
  _valueBeforeSave: undefined,
4744
4663
  };
@@ -4770,12 +4689,15 @@ const propertyMachine = setup({
4770
4689
  : { message: String(event.error) },
4771
4690
  })),
4772
4691
  },
4692
+ /** The value broke its property's rules: nothing was written, so restore the shown value. */
4773
4693
  saveValueValidationError: {
4774
4694
  target: '.idle',
4775
- actions: assign({
4695
+ actions: assign(({ context, event }) => ({
4776
4696
  isSaving: false,
4777
- _saveValidationErrors: ({ event }) => event.errors,
4778
- }),
4697
+ _saveValidationErrors: event.errors,
4698
+ ...(context._valueBeforeSave ?? {}),
4699
+ _valueBeforeSave: undefined,
4700
+ })),
4779
4701
  },
4780
4702
  clearSaveError: {
4781
4703
  actions: assign({ _saveError: null }),
@@ -4887,7 +4809,6 @@ const propertyMachine = setup({
4887
4809
  saveImage: 'savingImage',
4888
4810
  saveFile: 'savingFile',
4889
4811
  saveHtml: 'savingHtml',
4890
- saveRelation: 'savingRelation',
4891
4812
  saveItemStorage: 'savingItemStorage',
4892
4813
  },
4893
4814
  invoke: {
@@ -4904,12 +4825,7 @@ const propertyMachine = setup({
4904
4825
  saveImageError: {
4905
4826
  target: 'doneSaving',
4906
4827
  actions: assign({
4907
- _saveError: ({ event }) => event.error instanceof Error
4908
- ? {
4909
- message: event.error.message,
4910
- name: event.error.name,
4911
- }
4912
- : { message: String(event.error) },
4828
+ _saveError: ({ event }) => toError(event.error),
4913
4829
  }),
4914
4830
  },
4915
4831
  },
@@ -4927,12 +4843,7 @@ const propertyMachine = setup({
4927
4843
  saveFileError: {
4928
4844
  target: 'doneSaving',
4929
4845
  actions: assign({
4930
- _saveError: ({ event }) => event.error instanceof Error
4931
- ? {
4932
- message: event.error.message,
4933
- name: event.error.name,
4934
- }
4935
- : { message: String(event.error) },
4846
+ _saveError: ({ event }) => toError(event.error),
4936
4847
  }),
4937
4848
  },
4938
4849
  },
@@ -4949,12 +4860,7 @@ const propertyMachine = setup({
4949
4860
  saveHtmlError: {
4950
4861
  target: 'doneSaving',
4951
4862
  actions: assign({
4952
- _saveError: ({ event }) => event.error instanceof Error
4953
- ? {
4954
- message: event.error.message,
4955
- name: event.error.name,
4956
- }
4957
- : { message: String(event.error) },
4863
+ _saveError: ({ event }) => toError(event.error),
4958
4864
  }),
4959
4865
  },
4960
4866
  },
@@ -4965,41 +4871,13 @@ const propertyMachine = setup({
4965
4871
  },
4966
4872
  },
4967
4873
  },
4968
- savingRelation: {
4969
- on: {
4970
- saveRelationSuccess: 'doneSaving',
4971
- saveRelationError: {
4972
- target: 'doneSaving',
4973
- actions: assign({
4974
- _saveError: ({ event }) => event.error instanceof Error
4975
- ? {
4976
- message: event.error.message,
4977
- name: event.error.name,
4978
- }
4979
- : { message: String(event.error) },
4980
- }),
4981
- },
4982
- },
4983
- invoke: {
4984
- src: 'saveRelation',
4985
- input: ({ context, event }) => {
4986
- // Type assertion needed because event is AnyEventObject but actor expects SaveValueToDbEvent
4987
- return { context, event: event };
4988
- },
4989
- },
4990
- },
4991
4874
  savingItemStorage: {
4992
4875
  on: {
4993
4876
  saveItemStorageSuccess: 'doneSaving',
4994
4877
  saveItemStorageError: {
4995
4878
  target: 'doneSaving',
4996
4879
  actions: assign({
4997
- _saveError: ({ event }) => event.error instanceof Error
4998
- ? {
4999
- message: event.error.message,
5000
- name: event.error.name,
5001
- }
5002
- : { message: String(event.error) },
4880
+ _saveError: ({ event }) => toError(event.error),
5003
4881
  }),
5004
4882
  },
5005
4883
  },
@@ -5041,10 +4919,10 @@ const getPropertyData = async ({ propertyName, seedLocalId, seedUid, modelName,
5041
4919
  let names = [...getMetadataPropertyNamesForQuery(propertyName)];
5042
4920
  if (modelName) {
5043
4921
  try {
5044
- const _mod_11 = await import('./errors-3tc6XkCB.js');
5045
- const _ns_11 = _mod_11.h;
4922
+ const _mod_11 = await import('./errors-KM-yq2MD.js');
4923
+ const _ns_11 = _mod_11.j;
5046
4924
  const { Model } = _ns_11;
5047
- const _mod_12 = await import('./index-CrvIcVFJ.js');
4925
+ const _mod_12 = await import('./index-DpgQMIRq.js');
5048
4926
  const _ns_12 = _mod_12.bh;
5049
4927
  const { resolveItemModelFileId } = _ns_12;
5050
4928
  // Model names are only unique per schema: use the seed's own model when it is recorded.
@@ -5138,7 +5016,7 @@ function unloadEntity(instance, config) {
5138
5016
  sub.unsubscribe();
5139
5017
  instanceState[key] = null;
5140
5018
  }
5141
- catch (error) {
5019
+ catch {
5142
5020
  // Ignore errors during cleanup
5143
5021
  }
5144
5022
  }
@@ -5149,7 +5027,7 @@ function unloadEntity(instance, config) {
5149
5027
  try {
5150
5028
  config.onUnload(instance);
5151
5029
  }
5152
- catch (error) {
5030
+ catch {
5153
5031
  // Ignore errors during cleanup
5154
5032
  }
5155
5033
  }
@@ -5158,7 +5036,7 @@ function unloadEntity(instance, config) {
5158
5036
  const service = config.getService(instance);
5159
5037
  service.stop();
5160
5038
  }
5161
- catch (error) {
5039
+ catch {
5162
5040
  // Ignore errors if service is already stopped
5163
5041
  }
5164
5042
  }
@@ -5245,7 +5123,7 @@ const HTML_PROP_SEED_UID_RE = /^0x[a-fA-F0-9]{64}$/;
5245
5123
  */
5246
5124
  const resolvePropertyRecordSchemaFromSchemaData = async (modelName, propertyName, modelType, schemaName) => {
5247
5125
  try {
5248
- const _mod_13 = await import('./ClientManager-D6YA20jP.js');
5126
+ const _mod_13 = await import('./ClientManager-2GtDWHq6.js');
5249
5127
  const _ns_13 = _mod_13.N;
5250
5128
  const { loadAllSchemasFromDb } = _ns_13;
5251
5129
  const allSchemas = await loadAllSchemasFromDb();
@@ -5299,11 +5177,11 @@ hints = {}) => {
5299
5177
  return undefined;
5300
5178
  }
5301
5179
  try {
5302
- const _mod_14 = await import('./errors-3tc6XkCB.js');
5303
- const _ns_14 = _mod_14.h;
5180
+ const _mod_14 = await import('./errors-KM-yq2MD.js');
5181
+ const _ns_14 = _mod_14.j;
5304
5182
  const { Model } = _ns_14;
5305
5183
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
5306
- const _mod_15 = await import('./index-CrvIcVFJ.js');
5184
+ const _mod_15 = await import('./index-DpgQMIRq.js');
5307
5185
  const _ns_15 = _mod_15.bh;
5308
5186
  const { resolveItemModelFileId } = _ns_15;
5309
5187
  const modelFileId = await resolveItemModelFileId(hints);
@@ -5342,7 +5220,7 @@ hints = {}) => {
5342
5220
  const schema = schemas[schemaKey];
5343
5221
  return schema;
5344
5222
  }
5345
- catch (e) {
5223
+ catch {
5346
5224
  return undefined;
5347
5225
  }
5348
5226
  };
@@ -5463,7 +5341,7 @@ class ItemProperty {
5463
5341
  return;
5464
5342
  }
5465
5343
  // Use dynamic import to break circular dependency
5466
- const schemaMod = await import('./index--mmQ3LQu.js');
5344
+ const schemaMod = await import('./index-BAao3_Po.js');
5467
5345
  const { ModelPropertyDataTypes } = schemaMod;
5468
5346
  const { context } = snapshot;
5469
5347
  const { propertyRecordSchema } = context;
@@ -5637,11 +5515,23 @@ class ItemProperty {
5637
5515
  const normalizedDataType = normalizeDataType(propertyRecordSchema?.dataType);
5638
5516
  const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
5639
5517
  const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
5640
- const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
5641
- const _mod_16 = await import('./index-B7yAoYli.js');
5642
- const _ns_16 = _mod_16.s;
5643
- const seedSchemaMod = _ns_16;
5644
- const { metadata } = seedSchemaMod;
5518
+ // File and Image display values are session URLs minted from the file on disk; the column holds
5519
+ // nothing useful for them (older versions stored blob: URLs that die on reload). Keep the minted
5520
+ // one unless the row now points at a different file, then clear it so the next render mints anew.
5521
+ const displayValueFromRow = (row) => {
5522
+ const { context } = this._service.getSnapshot();
5523
+ const isSessionUrlType = normalizedDataType === 'Image' ||
5524
+ normalizedDataType === 'File' ||
5525
+ normalizedRefValueType === 'Image' ||
5526
+ context.refSeedType === 'image' ||
5527
+ context.refSeedType === 'file';
5528
+ if (!isSessionUrlType) {
5529
+ return { refResolvedDisplayValue: row.refResolvedDisplayValue || undefined };
5530
+ }
5531
+ if ((row.refResolvedValue || undefined) === context.refResolvedValue)
5532
+ return {};
5533
+ return { refResolvedDisplayValue: undefined };
5534
+ };
5645
5535
  const drizzleMod = await import('drizzle-orm');
5646
5536
  const { eq, and, or } = drizzleMod;
5647
5537
  const metadataLatestMod = await Promise.resolve().then(function () { return metadataLatest; });
@@ -5679,7 +5569,7 @@ class ItemProperty {
5679
5569
  versionUid: metaRow.versionUid || undefined,
5680
5570
  schemaUid: metaRow.schemaUid || undefined,
5681
5571
  refResolvedValue: metaRow.refResolvedValue || undefined,
5682
- refResolvedDisplayValue: metaRow.refResolvedDisplayValue || undefined,
5572
+ ...displayValueFromRow(metaRow),
5683
5573
  localStorageDir: metaRow.localStorageDir || undefined,
5684
5574
  });
5685
5575
  }
@@ -5791,7 +5681,7 @@ class ItemProperty {
5791
5681
  versionUid: metaRow.versionUid || undefined,
5792
5682
  schemaUid: metaRow.schemaUid || undefined,
5793
5683
  refResolvedValue: metaRow.refResolvedValue || undefined,
5794
- refResolvedDisplayValue: metaRow.refResolvedDisplayValue || undefined,
5684
+ ...displayValueFromRow(metaRow),
5795
5685
  localStorageDir: metaRow.localStorageDir || undefined,
5796
5686
  });
5797
5687
  },
@@ -5862,9 +5752,9 @@ class ItemProperty {
5862
5752
  const ctx = this._service.getSnapshot().context;
5863
5753
  let modelFileId;
5864
5754
  try {
5865
- const _mod_17 = await import('./index-CrvIcVFJ.js');
5866
- const _ns_17 = _mod_17.bh;
5867
- const { resolveItemModelFileId } = _ns_17;
5755
+ const _mod_16 = await import('./index-DpgQMIRq.js');
5756
+ const _ns_16 = _mod_16.bh;
5757
+ const { resolveItemModelFileId } = _ns_16;
5868
5758
  modelFileId = await resolveItemModelFileId({
5869
5759
  modelFileId: ctx.modelFileId,
5870
5760
  seedLocalId: ctx.seedLocalId,
@@ -5978,7 +5868,7 @@ class ItemProperty {
5978
5868
  static create(props, options) {
5979
5869
  const waitForReady = options?.waitForReady !== false;
5980
5870
  const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
5981
- const { propertyName, seedLocalId, seedUid, versionLocalId, versionUid } = props;
5871
+ const { propertyName, seedLocalId, seedUid } = props;
5982
5872
  if (!propertyName || (!seedLocalId && !seedUid)) {
5983
5873
  if (!waitForReady)
5984
5874
  return undefined;
@@ -6225,9 +6115,9 @@ class ItemProperty {
6225
6115
  const propertiesData = await getItemProperties({ seedLocalId, seedUid });
6226
6116
  const instances = [];
6227
6117
  const seenNormalized = new Set();
6228
- const _mod_18 = await import('./index-CrvIcVFJ.js');
6229
- const _ns_18 = _mod_18.bh;
6230
- const { resolveItemModelFileId } = _ns_18;
6118
+ const _mod_17 = await import('./index-DpgQMIRq.js');
6119
+ const _ns_17 = _mod_17.bh;
6120
+ const { resolveItemModelFileId } = _ns_17;
6231
6121
  const itemModelFileId = await resolveItemModelFileId({ seedLocalId, seedUid });
6232
6122
  for (const data of propertiesData) {
6233
6123
  const d = data;
@@ -6243,9 +6133,9 @@ class ItemProperty {
6243
6133
  }
6244
6134
  else if (baseName) {
6245
6135
  try {
6246
- const _mod_19 = await import('./errors-3tc6XkCB.js');
6247
- const _ns_19 = _mod_19.h;
6248
- const { Model } = _ns_19;
6136
+ const _mod_18 = await import('./errors-KM-yq2MD.js');
6137
+ const _ns_18 = _mod_18.j;
6138
+ const { Model } = _ns_18;
6249
6139
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
6250
6140
  const model = await Model.resolveAsync(modelName, { modelFileId });
6251
6141
  if (model?.properties) {
@@ -6260,9 +6150,9 @@ class ItemProperty {
6260
6150
  }
6261
6151
  if (modelName && propertyName) {
6262
6152
  try {
6263
- const _mod_20 = await import('./errors-3tc6XkCB.js');
6264
- const _ns_20 = _mod_20.h;
6265
- const { Model } = _ns_20;
6153
+ const _mod_19 = await import('./errors-KM-yq2MD.js');
6154
+ const _ns_19 = _mod_19.j;
6155
+ const { Model } = _ns_19;
6266
6156
  const { modelPropertiesToObject } = await import('./model-oHA3YhOd.js');
6267
6157
  const model = await Model.resolveAsync(modelName, { modelFileId });
6268
6158
  if (model?.properties?.length) {
@@ -6418,8 +6308,20 @@ class ItemProperty {
6418
6308
  if (currentValue === value) {
6419
6309
  return;
6420
6310
  }
6421
- // Restored if the save is refused (item not owned) or fails.
6422
- const before = { propertyValue: context.propertyValue, renderValue: context.renderValue };
6311
+ this.setValue(value);
6312
+ }
6313
+ /**
6314
+ * Shows `value` at once and saves it; `await property.save()` to wait for the result. Unlike
6315
+ * assigning `property.value`, it saves even when `value` is already in context.
6316
+ *
6317
+ * @param options.before - The values to restore if the save is refused or fails. Defaults to the
6318
+ * current context; pass it when you already put `value` into context (a debounced input, say),
6319
+ * so a refusal still rolls back to what was there before.
6320
+ */
6321
+ setValue(value, options = {}) {
6322
+ const context = this._getSnapshotContext();
6323
+ // Restored if the save is refused (item not owned), breaks a validation rule, or fails.
6324
+ const before = options.before ?? { propertyValue: context.propertyValue, renderValue: context.renderValue };
6423
6325
  // Update context immediately so UI shows the value before save completes
6424
6326
  this._service.send({
6425
6327
  type: 'updateContext',
@@ -6483,12 +6385,8 @@ class ItemProperty {
6483
6385
  timeout: 10000,
6484
6386
  });
6485
6387
  const { _saveError: saveError, _saveValidationErrors: validationErrors, propertyName } = settled.context;
6486
- if (saveError) {
6487
- const error = new Error(`Failed to save property ${propertyName}: ${saveError.message}`);
6488
- if (saveError.name)
6489
- error.name = saveError.name;
6490
- throw error;
6491
- }
6388
+ if (saveError)
6389
+ throw saveError;
6492
6390
  if (validationErrors?.length) {
6493
6391
  throw new ItemPropertySaveValidationError(`Invalid value for property ${propertyName}: ${validationErrors.map((e) => e.message).join('; ')}`, validationErrors);
6494
6392
  }
@@ -6540,7 +6438,7 @@ class ItemProperty {
6540
6438
  },
6541
6439
  });
6542
6440
  }
6543
- catch (error) {
6441
+ catch {
6544
6442
  // Still try to clean up what we can
6545
6443
  const instanceState = itemPropertyInstanceState.get(this);
6546
6444
  if (instanceState?.liveQuerySubscription) {
@@ -6592,9 +6490,9 @@ class ItemProperty {
6592
6490
  if (!propertyName || (!seedLocalId && !seedUid))
6593
6491
  return;
6594
6492
  if (db) {
6595
- const _mod_21 = await import('./index-B7yAoYli.js');
6596
- const _ns_21 = _mod_21.s;
6597
- const seedSchemaMod = _ns_21;
6493
+ const _mod_20 = await import('./index-BbFwftAv.js');
6494
+ const _ns_20 = _mod_20.s;
6495
+ const seedSchemaMod = _ns_20;
6598
6496
  const { metadata } = seedSchemaMod;
6599
6497
  const drizzleMod = await import('drizzle-orm');
6600
6498
  const { and, eq } = drizzleMod;
@@ -6637,9 +6535,9 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
6637
6535
  }
6638
6536
  const seedType = easName(modelName);
6639
6537
  // Dynamic import to break circular dependency
6640
- const _mod_22 = await import('./errors-3tc6XkCB.js');
6641
- const _ns_22 = _mod_22.h;
6642
- const modelMod = _ns_22;
6538
+ const _mod_21 = await import('./errors-KM-yq2MD.js');
6539
+ const _ns_21 = _mod_21.j;
6540
+ const modelMod = _ns_21;
6643
6541
  const { Model } = modelMod;
6644
6542
  const model = await Model.resolveAsync(modelName, { modelFileId });
6645
6543
  const propertySchemas = model?.properties ? modelPropertiesToObject(model.properties) : undefined;
@@ -6651,7 +6549,7 @@ const createNewItem = async ({ modelName, modelFileId, ...propertyData }) => {
6651
6549
  catch (error) {
6652
6550
  // The rows are separate inserts (no transaction): remove what was written so a failure leaves
6653
6551
  // no half-made draft.
6654
- const { discardNewDraft } = await import('./discardNewDraft-oGYdB5vS.js');
6552
+ const { discardNewDraft } = await import('./discardNewDraft-hiVaUVjV.js');
6655
6553
  await discardNewDraft(newSeedId).catch(() => undefined);
6656
6554
  throw error;
6657
6555
  }
@@ -6754,24 +6652,25 @@ async function findEntity(config, params, options = {}) {
6754
6652
  return instance;
6755
6653
  }
6756
6654
 
6655
+ /**
6656
+ * Soft-delete one seed row. Matches `seedLocalId` when given; `seeds.uid` isn't unique (a synced
6657
+ * seed and a local copy can share it), so `seedUid` is only used when there's no local id.
6658
+ */
6757
6659
  const deleteItem = async ({ seedLocalId, seedUid }) => {
6758
- const appDb = BaseDb.getAppDb();
6759
- const conditions = [];
6760
- if (seedLocalId) {
6761
- conditions.push(eq(seeds.localId, seedLocalId));
6762
- }
6763
- if (seedUid) {
6764
- conditions.push(eq(seeds.uid, seedUid));
6765
- }
6766
- if (conditions.length === 0) {
6660
+ const condition = seedLocalId
6661
+ ? eq(seeds.localId, seedLocalId)
6662
+ : seedUid
6663
+ ? eq(seeds.uid, seedUid)
6664
+ : undefined;
6665
+ if (!condition) {
6767
6666
  return;
6768
6667
  }
6769
- await appDb
6668
+ await BaseDb.getAppDb()
6770
6669
  .update(seeds)
6771
6670
  .set({
6772
6671
  _markedForDeletion: 1,
6773
6672
  })
6774
- .where(or(...conditions));
6673
+ .where(condition);
6775
6674
  };
6776
6675
 
6777
6676
  /**
@@ -6832,9 +6731,9 @@ const getModel = () => {
6832
6731
  // the fragile `import(...).then(n => n.X)` chunk-namespace pattern.
6833
6732
  if (!modelImportPromise) {
6834
6733
  modelImportPromise = (async () => {
6835
- const _mod_23 = await import('./errors-3tc6XkCB.js');
6836
- const _ns_23 = _mod_23.h;
6837
- const mod = _ns_23;
6734
+ const _mod_22 = await import('./errors-KM-yq2MD.js');
6735
+ const _ns_22 = _mod_22.j;
6736
+ const mod = _ns_22;
6838
6737
  ModelClass = mod.Model;
6839
6738
  return mod;
6840
6739
  })();
@@ -6848,7 +6747,6 @@ const getModel = () => {
6848
6747
  if (!ModelClass) {
6849
6748
  // Fallback: try to access Model directly (works if already in module cache)
6850
6749
  try {
6851
- // @ts-ignore - accessing module cache directly
6852
6750
  const modelModule = globalThis.__seedModelModule ||
6853
6751
  (typeof window !== 'undefined' && window.__seedModelModule);
6854
6752
  if (modelModule) {
@@ -6992,9 +6890,9 @@ class Item {
6992
6890
  }
6993
6891
  if (value === 'idle' && wasPublishing) {
6994
6892
  unsub.unsubscribe();
6995
- const ctx = snapshot.context;
6996
- if (ctx._publishError) {
6997
- reject(new Error(ctx._publishError.message));
6893
+ const { _publishError: publishError } = snapshot.context;
6894
+ if (publishError) {
6895
+ reject(publishError);
6998
6896
  }
6999
6897
  else {
7000
6898
  resolve();
@@ -7008,16 +6906,16 @@ class Item {
7008
6906
  };
7009
6907
  this.getPublishUploads = async (options) => {
7010
6908
  // Use dynamic import to break circular dependency
7011
- const _mod_24 = await import('./getPublishUploads-C7-fYIgX.js');
7012
- const _ns_24 = _mod_24.o;
7013
- const getPublishUploadsMod = _ns_24;
6909
+ const _mod_23 = await import('./getPublishUploads-Cex-NBe6.js');
6910
+ const _ns_23 = _mod_23.o;
6911
+ const getPublishUploadsMod = _ns_23;
7014
6912
  const { getPublishUploads } = getPublishUploadsMod;
7015
6913
  return await getPublishUploads(this, [], undefined, options);
7016
6914
  };
7017
6915
  this.getPublishPayload = async (uploadedTransactions, options) => {
7018
- const _mod_25 = await import('./getPublishPayload-CJF0k5d8.js');
7019
- const _ns_25 = _mod_25.g;
7020
- const getPublishPayloadMod = _ns_25;
6916
+ const _mod_24 = await import('./getPublishPayload-oH8wJhnH.js');
6917
+ const _ns_24 = _mod_24.g;
6918
+ const getPublishPayloadMod = _ns_24;
7021
6919
  const { getPublishPayload } = getPublishPayloadMod;
7022
6920
  return await getPublishPayload(this, uploadedTransactions, options);
7023
6921
  };
@@ -7555,18 +7453,18 @@ class Item {
7555
7453
  const db = BaseDb.getAppDb();
7556
7454
  if (db && props.modelName) {
7557
7455
  // Model names are only unique per schema: resolve the exact models row from the most specific scope.
7558
- const _mod_26 = await import('./index-CrvIcVFJ.js');
7559
- const _ns_26 = _mod_26.bh;
7560
- const { resolveModelRecord } = _ns_26;
7456
+ const _mod_25 = await import('./index-DpgQMIRq.js');
7457
+ const _ns_25 = _mod_25.bh;
7458
+ const { resolveModelRecord } = _ns_25;
7561
7459
  const modelRecord = await resolveModelRecord(props.modelName, {
7562
7460
  modelFileId: props.modelFileId ?? modelInstance?.id,
7563
7461
  schemaName: schemaName ?? modelInstance?.schemaName,
7564
7462
  });
7565
7463
  const modelRecords = modelRecord ? [modelRecord] : [];
7566
7464
  if (!modelRecord) {
7567
- const _mod_27 = await import('./errors-3tc6XkCB.js');
7568
- const _ns_27 = _mod_27.j;
7569
- const { UnknownModelError } = _ns_27;
7465
+ const _mod_26 = await import('./errors-KM-yq2MD.js');
7466
+ const _ns_26 = _mod_26.k;
7467
+ const { UnknownModelError } = _ns_26;
7570
7468
  throw new UnknownModelError(props.modelName, schemaName ?? modelInstance?.schemaName);
7571
7469
  }
7572
7470
  if (modelRecord?.schemaFileId) {
@@ -7575,12 +7473,12 @@ class Item {
7575
7473
  // Scope the constructor's Model lookup to this model's schema (as getItemData does on reload),
7576
7474
  // so a same-named model cached from another schema can't supply the property set.
7577
7475
  if (modelRecord && !props.schemaName) {
7578
- const _mod_28 = await import('./index-CrvIcVFJ.js');
7579
- const _ns_28 = _mod_28.bg;
7580
- const { modelSchemas } = _ns_28;
7581
- const _mod_29 = await import('./index-CrvIcVFJ.js');
7582
- const _ns_29 = _mod_29.bf;
7583
- const { schemas: schemasTable } = _ns_29;
7476
+ const _mod_27 = await import('./index-DpgQMIRq.js');
7477
+ const _ns_27 = _mod_27.bg;
7478
+ const { modelSchemas } = _ns_27;
7479
+ const _mod_28 = await import('./index-DpgQMIRq.js');
7480
+ const _ns_28 = _mod_28.bf;
7481
+ const { schemas: schemasTable } = _ns_28;
7584
7482
  const schemaRows = await db
7585
7483
  .select({ schemaName: schemasTable.name })
7586
7484
  .from(modelSchemas)
@@ -7667,7 +7565,6 @@ class Item {
7667
7565
  const snapshot = target._service.getSnapshot();
7668
7566
  const context = snapshot.context;
7669
7567
  const propertyInstances = context.propertyInstances;
7670
- context.modelName;
7671
7568
  if (!propertyInstances || propertyInstances.size === 0) {
7672
7569
  return [];
7673
7570
  }
@@ -7682,7 +7579,6 @@ class Item {
7682
7579
  }
7683
7580
  // Include if it's a model property
7684
7581
  const isModelProp = target._isModelProperty(key, modelSchemaKeys);
7685
- propertyInstance.value;
7686
7582
  if (isModelProp) {
7687
7583
  properties.push(propertyInstance);
7688
7584
  }
@@ -7768,7 +7664,7 @@ class Item {
7768
7664
  /* best-effort cache cleanup */
7769
7665
  }
7770
7666
  try {
7771
- const { discardNewDraft } = await import('./discardNewDraft-oGYdB5vS.js');
7667
+ const { discardNewDraft } = await import('./discardNewDraft-hiVaUVjV.js');
7772
7668
  await discardNewDraft(seedLocalId);
7773
7669
  }
7774
7670
  catch (error) {
@@ -7778,29 +7674,36 @@ class Item {
7778
7674
  /**
7779
7675
  * Run each File/Image/Html/ItemStorage initial value through its ItemProperty save pipeline (sequentially, to
7780
7676
  * avoid SQLite write contention). Rejects on the first failure, with ItemCreateValidationError when the
7781
- * value breaks its property's rules; Item.create then removes the item.
7677
+ * value breaks its property's rules and ItemCreateError otherwise; Item.create then removes the item.
7782
7678
  */
7783
7679
  static async savePipelineValues(item, pipelineValues, timeout) {
7784
7680
  for (const [propertyName, value] of pipelineValues) {
7785
7681
  const property = await this.waitForPropertyInstance(item, propertyName, timeout);
7786
7682
  if (!property) {
7787
- throw new Error(`Item.create: property ${item.modelName}.${propertyName} did not load for item ${item.seedLocalId}; value was not saved`);
7683
+ const _mod_29 = await import('./errors-KM-yq2MD.js');
7684
+ const _ns_29 = _mod_29.k;
7685
+ const { ItemCreateError } = _ns_29;
7686
+ throw new ItemCreateError(`Item.create: property ${item.modelName}.${propertyName} did not load for item ${item.seedLocalId}; value was not saved`, { code: 'property_not_loaded', modelName: item.modelName, property: propertyName, seedLocalId: item.seedLocalId });
7788
7687
  }
7789
- property.value = value;
7688
+ // setValue, not the setter: the setter skips the save when the value is already in context.
7689
+ property.setValue(value);
7790
7690
  try {
7791
7691
  await property.save();
7792
7692
  }
7793
7693
  catch (error) {
7794
7694
  if (error instanceof ItemPropertySaveValidationError) {
7795
- const _mod_30 = await import('./errors-3tc6XkCB.js');
7796
- const _ns_30 = _mod_30.j;
7695
+ const _mod_30 = await import('./errors-KM-yq2MD.js');
7696
+ const _ns_30 = _mod_30.k;
7797
7697
  const { ItemCreateValidationError } = _ns_30;
7798
7698
  const created = new ItemCreateValidationError(item.modelName, error.validationErrors.map((e) => ({ property: propertyName, code: e.code, message: e.message })));
7799
7699
  created.cause = error;
7800
7700
  throw created;
7801
7701
  }
7802
- throw new Error(`Item.create: failed to save ${item.modelName}.${propertyName} for item ${item.seedLocalId}: ` +
7803
- (error instanceof Error ? error.message : String(error)), { cause: error });
7702
+ const _mod_31 = await import('./errors-KM-yq2MD.js');
7703
+ const _ns_31 = _mod_31.k;
7704
+ const { ItemCreateError } = _ns_31;
7705
+ throw new ItemCreateError(`Item.create: failed to save ${item.modelName}.${propertyName} for item ${item.seedLocalId}: ` +
7706
+ (error instanceof Error ? error.message : String(error)), { code: 'save_failed', modelName: item.modelName, property: propertyName, seedLocalId: item.seedLocalId, cause: error });
7804
7707
  }
7805
7708
  }
7806
7709
  }
@@ -7930,7 +7833,7 @@ class Item {
7930
7833
  readyTimeout,
7931
7834
  });
7932
7835
  }
7933
- catch (error) {
7836
+ catch {
7934
7837
  return undefined;
7935
7838
  }
7936
7839
  }
@@ -7959,9 +7862,9 @@ class Item {
7959
7862
  if (!appDb || Item.instanceCache.size === 0) {
7960
7863
  return;
7961
7864
  }
7962
- const _mod_31 = await import('./index-B7yAoYli.js');
7963
- const _ns_31 = _mod_31.s;
7964
- const { metadata } = _ns_31;
7865
+ const _mod_32 = await import('./index-BbFwftAv.js');
7866
+ const _ns_32 = _mod_32.s;
7867
+ const { metadata } = _ns_32;
7965
7868
  const { eq, and } = await import('drizzle-orm');
7966
7869
  const dedupedInstances = new Map();
7967
7870
  for (const entry of Item.instanceCache.values()) {
@@ -8122,11 +8025,11 @@ class Item {
8122
8025
  }
8123
8026
  /** Throws ItemCreateValidationError for unknown keys and values that break their property's rules. */
8124
8027
  static async assertValidCreateValues(props, propertyNames, dataTypeByPropertyName, skipKeys) {
8125
- const _mod_32 = await import('./errors-3tc6XkCB.js');
8126
- const _ns_32 = _mod_32.j;
8127
- const { ItemCreateValidationError } = _ns_32;
8128
- const { getPropertySchema } = await import('./property-DQ-Owzki.js');
8129
- const { SchemaValidationService } = await import('./SchemaValidationService-DXQ-D531.js');
8028
+ const _mod_33 = await import('./errors-KM-yq2MD.js');
8029
+ const _ns_33 = _mod_33.k;
8030
+ const { ItemCreateValidationError } = _ns_33;
8031
+ const { getPropertySchema } = await import('./property-BDBvImLs.js');
8032
+ const { SchemaValidationService } = await import('./SchemaValidationService-BxCbfDaI.js');
8130
8033
  const validationService = new SchemaValidationService();
8131
8034
  const modelName = props.modelName;
8132
8035
  const known = new Set(propertyNames);
@@ -8163,7 +8066,7 @@ class Item {
8163
8066
  // Not JSON: validated as given, and rejected as a non-array
8164
8067
  }
8165
8068
  }
8166
- const { resolvePropertyValidationRules } = await import('./propertyValidationRules-BDhFjlwP.js');
8069
+ const { resolvePropertyValidationRules } = await import('./propertyValidationRules-BlfLn4rP.js');
8167
8070
  const rules = propertySchema?.validation ??
8168
8071
  (await resolvePropertyValidationRules(modelName, key, {
8169
8072
  modelFileId: props.modelFileId,
@@ -8187,7 +8090,8 @@ class Item {
8187
8090
  if (!normalized)
8188
8091
  return;
8189
8092
  for (const seedLocalId of seedLocalIds) {
8190
- const item = Item.getById(seedLocalId);
8093
+ // Not getById: that adds a cache hold the caller would never release.
8094
+ const item = Item.findItemInstanceCacheEntryById(seedLocalId)?.instance;
8191
8095
  if (!item)
8192
8096
  continue;
8193
8097
  const status = item.getService().getSnapshot().status;
@@ -8332,7 +8236,7 @@ class Item {
8332
8236
  }
8333
8237
  return schemaKeys;
8334
8238
  }
8335
- catch (error) {
8239
+ catch {
8336
8240
  // If Model access fails, return empty array (property instances should be used instead)
8337
8241
  return [];
8338
8242
  }
@@ -8349,7 +8253,7 @@ class Item {
8349
8253
  }
8350
8254
  // Prefer propertyInstance.propertyName if available (most reliable)
8351
8255
  // Otherwise use the Map key
8352
- let propertyName = propertyInstance.propertyName || key;
8256
+ const propertyName = propertyInstance.propertyName || key;
8353
8257
  // Apply transformations if needed
8354
8258
  let transformedKey = propertyName;
8355
8259
  if (propertyInstance.alias) {
@@ -8412,7 +8316,6 @@ class Item {
8412
8316
  get properties() {
8413
8317
  const serviceContext = this.serviceContext;
8414
8318
  const propertyInstances = serviceContext.propertyInstances;
8415
- this.modelName;
8416
8319
  if (!propertyInstances || propertyInstances.size === 0) {
8417
8320
  return [];
8418
8321
  }
@@ -8494,10 +8397,10 @@ class Item {
8494
8397
  itemActor.send(event);
8495
8398
  };
8496
8399
  try {
8497
- const _mod_33 = await import('./index-B7yAoYli.js');
8498
- const _ns_33 = _mod_33.s;
8499
- const seedSchemaMod = _ns_33;
8500
- const { seeds, versions, metadata } = seedSchemaMod;
8400
+ const _mod_34 = await import('./index-BbFwftAv.js');
8401
+ const _ns_34 = _mod_34.s;
8402
+ const seedSchemaMod = _ns_34;
8403
+ const { seeds, metadata } = seedSchemaMod;
8501
8404
  const drizzleMod = await import('drizzle-orm');
8502
8405
  const { eq, and } = drizzleMod;
8503
8406
  const versionDataMod = await Promise.resolve().then(function () { return versionData; });
@@ -8805,7 +8708,7 @@ class Item {
8805
8708
  },
8806
8709
  });
8807
8710
  }
8808
- catch (error) {
8711
+ catch {
8809
8712
  // Still try to clean up what we can
8810
8713
  const instanceState = itemInstanceState.get(this);
8811
8714
  if (instanceState?.liveQuerySubscription) {
@@ -8865,4 +8768,4 @@ var Item$1 = /*#__PURE__*/Object.freeze({
8865
8768
  });
8866
8769
 
8867
8770
  export { unloadEntity as $, getPublishExecutor as A, getRevokeExecutor as B, ClientManagerState as C, DEFAULT_READY_TIMEOUT_MS as D, getUploadExecutor as E, getVersionData$1 as F, isLocalUnsealedDraft as G, isSeedRowOwned as H, Item as I, localUnsealedDraftSql as J, ownedPublisherSql as K, ownedSeedsSql as L, METADATA_LATEST_FIRST_ORDER_SQL as M, pickLatestMetadataRowPerProperty as N, OwnershipError as O, PUBLISH_NOT_CONFIGURED_MESSAGE as P, placeholderUidSql as Q, propertyMachine as R, publisherInAddressListSql as S, publisherIsInOwnedSet as T, setAdditionalSyncAddresses as U, setGetPublisherForNewSeeds as V, setPublishExecutor as W, setRevokeExecutor as X, setUploadExecutor as Y, getInvariantSafePropertyDescriptor as Z, clearDestroySubscriptions as _, ItemProperty as a, ClientManagerEvents as a0, withLockedItemStorageRow as a1, getItemStorageFilePath as a2, writeItemStorageFile as a3, resolvePublisherFromSeedRow as a4, getPropertyData$1 as a5, Item$1 as a6, ItemPropertySaveValidationError as b, assertItemOwned as c, waitForEntityIdle as d, compareMetadataRowsLatestFirst as e, getEasSchemaUidForModel as f, getItemData as g, getLatestPublishedVersionRow as h, isItemOwned as i, chunkValues as j, getGetAdditionalSyncAddresses as k, isVersionRevoked as l, createReactiveProxy as m, findEntity as n, forceRemoveFromCaches as o, parseListPropertyValueFromStorage as p, runDestroyLifecycle as q, rowsPerInsert as r, selectInBatches as s, isPublishedMetadataRow as t, MachineIds as u, createNewItem as v, writeInBatches as w, getEasSchemaForItemProperty as x, getGetPublisherForNewSeeds as y, getMetadataLatest as z };
8868
- //# sourceMappingURL=Item-B1MH0tXx.js.map
8771
+ //# sourceMappingURL=Item-D6j0IvBP.js.map