@seedprotocol/sdk 0.7.7 → 0.7.8-next.1066.gac32194

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 (302) hide show
  1. package/dist/{ClientManager-2GtDWHq6.js → ClientManager-Dcju5x4k.js} +835 -80
  2. package/dist/ClientManager-Dcju5x4k.js.map +1 -0
  3. package/dist/{Item-D6j0IvBP.js → Item-DZfNz7xl.js} +2145 -1354
  4. package/dist/Item-DZfNz7xl.js.map +1 -0
  5. package/dist/{ModelProperty-B52C3CQ2.js → ModelProperty-sMGL-_LK.js} +51 -52
  6. package/dist/ModelProperty-sMGL-_LK.js.map +1 -0
  7. package/dist/{Schema-O1QLoXv6.js → Schema-D-TczaIj.js} +106 -91
  8. package/dist/Schema-D-TczaIj.js.map +1 -0
  9. package/dist/{SchemaValidationService-BxCbfDaI.js → SchemaValidationService-NYTtSCxd.js} +6 -6
  10. package/dist/{SchemaValidationService-BxCbfDaI.js.map → SchemaValidationService-NYTtSCxd.js.map} +1 -1
  11. package/dist/{backfillMetadataPropertyIds-CzSbuucw.js → backfillMetadataPropertyIds-DEvD0OAT.js} +3 -3
  12. package/dist/{backfillMetadataPropertyIds-CzSbuucw.js.map → backfillMetadataPropertyIds-DEvD0OAT.js.map} +1 -1
  13. package/dist/{configurePlatform-Bbpw_R4y.js → configurePlatform-CtA7fydC.js} +2 -2
  14. package/dist/{configurePlatform-Bbpw_R4y.js.map → configurePlatform-CtA7fydC.js.map} +1 -1
  15. package/dist/db/drizzle/0020_add_pending_writes.sql +24 -0
  16. package/dist/db/drizzle/0021_add_pending_write_error_name.sql +1 -0
  17. package/dist/db/drizzle/meta/0020_snapshot.json +1542 -0
  18. package/dist/db/drizzle/meta/0021_snapshot.json +1549 -0
  19. package/dist/db/drizzle/meta/_journal.json +14 -0
  20. package/dist/{detachRowsBeforeDelete-D1TyEMco.js → detachRowsBeforeDelete-CLbBbpX4.js} +2 -2
  21. package/dist/{detachRowsBeforeDelete-D1TyEMco.js.map → detachRowsBeforeDelete-CLbBbpX4.js.map} +1 -1
  22. package/dist/dist/{ClientManager-2GtDWHq6.d.ts → ClientManager-Dcju5x4k.d.ts} +393 -292
  23. package/dist/dist/ClientManager-Dcju5x4k.d.ts.map +1 -0
  24. package/dist/dist/{Item-D6j0IvBP.d.ts → Item-DZfNz7xl.d.ts} +456 -266
  25. package/dist/dist/Item-DZfNz7xl.d.ts.map +1 -0
  26. package/dist/dist/{ModelProperty-B52C3CQ2.d.ts → ModelProperty-sMGL-_LK.d.ts} +1 -1
  27. package/dist/dist/{ModelProperty-B52C3CQ2.d.ts.map → ModelProperty-sMGL-_LK.d.ts.map} +1 -1
  28. package/dist/dist/{Schema-O1QLoXv6.d.ts → Schema-D-TczaIj.d.ts} +11 -4
  29. package/dist/dist/Schema-D-TczaIj.d.ts.map +1 -0
  30. package/dist/dist/{SchemaValidationService-BxCbfDaI.d.ts → SchemaValidationService-NYTtSCxd.d.ts} +1 -1
  31. package/dist/dist/{SchemaValidationService-BxCbfDaI.d.ts.map → SchemaValidationService-NYTtSCxd.d.ts.map} +1 -1
  32. package/dist/dist/{backfillMetadataPropertyIds-CzSbuucw.d.ts → backfillMetadataPropertyIds-DEvD0OAT.d.ts} +1 -1
  33. package/dist/dist/backfillMetadataPropertyIds-DEvD0OAT.d.ts.map +1 -0
  34. package/dist/dist/{configurePlatform-Bbpw_R4y.d.ts → configurePlatform-CtA7fydC.d.ts} +1 -1
  35. package/dist/dist/configurePlatform-CtA7fydC.d.ts.map +1 -0
  36. package/dist/dist/{detachRowsBeforeDelete-D1TyEMco.d.ts → detachRowsBeforeDelete-CLbBbpX4.d.ts} +1 -1
  37. package/dist/dist/detachRowsBeforeDelete-CLbBbpX4.d.ts.map +1 -0
  38. package/dist/dist/{eas-DOdj-EMK.d.ts → eas-CcpQiXum.d.ts} +1 -1
  39. package/dist/dist/eas-CcpQiXum.d.ts.map +1 -0
  40. package/dist/dist/{errors-KM-yq2MD.d.ts → errors-BGk_IJO5.d.ts} +39 -24
  41. package/dist/dist/errors-BGk_IJO5.d.ts.map +1 -0
  42. package/dist/dist/{getItem-Bh0zv-o1.d.ts → getItem-CHSX3aMm.d.ts} +1 -1
  43. package/dist/dist/getItem-CHSX3aMm.d.ts.map +1 -0
  44. package/dist/dist/{getPublishPayload-oH8wJhnH.d.ts → getPublishPayload-DMd4oLir.d.ts} +1 -1
  45. package/dist/dist/getPublishPayload-DMd4oLir.d.ts.map +1 -0
  46. package/dist/dist/{getPublishUploads-Cex-NBe6.d.ts → getPublishUploads-C9FnRG9c.d.ts} +1 -1
  47. package/dist/dist/{getPublishUploads-Cex-NBe6.d.ts.map → getPublishUploads-C9FnRG9c.d.ts.map} +1 -1
  48. package/dist/dist/{index-BbFwftAv.d.ts → index-C--KAWoe.d.ts} +378 -1
  49. package/dist/dist/{index-BbFwftAv.d.ts.map → index-C--KAWoe.d.ts.map} +1 -1
  50. package/dist/dist/{index-DpgQMIRq.d.ts → index-CI0NFf4B.d.ts} +836 -426
  51. package/dist/dist/index-CI0NFf4B.d.ts.map +1 -0
  52. package/dist/dist/{index-BAao3_Po.d.ts → index-Ccmd9_KY.d.ts} +5 -5
  53. package/dist/dist/index-Ccmd9_KY.d.ts.map +1 -0
  54. package/dist/dist/index-l3b6p1Ih.d.ts +14 -0
  55. package/dist/dist/index-l3b6p1Ih.d.ts.map +1 -0
  56. package/dist/dist/{index.browser-nndbVM7z.d.ts → index.browser-kY8M-xUA.d.ts} +2892 -1754
  57. package/dist/dist/{index.browser-nndbVM7z.d.ts.map → index.browser-kY8M-xUA.d.ts.map} +1 -1
  58. package/dist/dist/{index.node-BUfx-JaP.d.ts → index.node-Ba2KbmOq.d.ts} +4125 -2613
  59. package/dist/dist/{index.node-BUfx-JaP.d.ts.map → index.node-Ba2KbmOq.d.ts.map} +1 -1
  60. package/dist/dist/platform.browser.d.ts +2 -2
  61. package/dist/dist/platform.node.d.ts +2 -2
  62. package/dist/dist/{property-BDBvImLs.d.ts → property-CO7pKTWK.d.ts} +3 -3
  63. package/dist/dist/property-CO7pKTWK.d.ts.map +1 -0
  64. package/dist/dist/{propertyValidationRules-BlfLn4rP.d.ts → propertyValidationRules-D5HZy0Bq.d.ts} +1 -1
  65. package/dist/dist/propertyValidationRules-D5HZy0Bq.d.ts.map +1 -0
  66. package/dist/dist/{publishDraftGraph-CLO85LLz.d.ts → publishDraftGraph-B5KPqtbg.d.ts} +1 -1
  67. package/dist/dist/{publishDraftGraph-CLO85LLz.d.ts.map → publishDraftGraph-B5KPqtbg.d.ts.map} +1 -1
  68. package/dist/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts → resetAmbiguousLegacyItemData-77CZ8HT7.d.ts} +1 -1
  69. package/dist/dist/resetAmbiguousLegacyItemData-77CZ8HT7.d.ts.map +1 -0
  70. package/dist/dist/{resolveModelForSyncedSeed-DFr4COc4.d.ts → resolveModelForSyncedSeed-DHOq_FGs.d.ts} +1 -1
  71. package/dist/dist/resolveModelForSyncedSeed-DHOq_FGs.d.ts.map +1 -0
  72. package/dist/dist/{syncDbWithEas-CAOlw3i-.d.ts → syncDbWithEas-BZ6AI-IC.d.ts} +1 -1
  73. package/dist/dist/syncDbWithEas-BZ6AI-IC.d.ts.map +1 -0
  74. package/dist/dist/{tabEvents-DksXwk3X.d.ts → tabEvents-CIlzHSKZ.d.ts} +35 -18
  75. package/dist/dist/tabEvents-CIlzHSKZ.d.ts.map +1 -0
  76. package/dist/dist/{tolerantWebAccess-CEIjFGf0.d.ts → tolerantWebAccess-BwJ8bElF.d.ts} +1 -1
  77. package/dist/dist/{tolerantWebAccess-CEIjFGf0.d.ts.map → tolerantWebAccess-BwJ8bElF.d.ts.map} +1 -1
  78. package/dist/dist/{updateSeedRevokedAt-Cjr35YjE.d.ts → updateSeedRevokedAt-ClxMSXcB.d.ts} +1 -1
  79. package/dist/dist/updateSeedRevokedAt-ClxMSXcB.d.ts.map +1 -0
  80. package/dist/{eas-DOdj-EMK.js → eas-CcpQiXum.js} +4 -4
  81. package/dist/{eas-DOdj-EMK.js.map → eas-CcpQiXum.js.map} +1 -1
  82. package/dist/{errors-KM-yq2MD.js → errors-BGk_IJO5.js} +222 -275
  83. package/dist/errors-BGk_IJO5.js.map +1 -0
  84. package/dist/{getItem-Bh0zv-o1.js → getItem-CHSX3aMm.js} +5 -5
  85. package/dist/{getItem-Bh0zv-o1.js.map → getItem-CHSX3aMm.js.map} +1 -1
  86. package/dist/{getPublishPayload-oH8wJhnH.js → getPublishPayload-DMd4oLir.js} +18 -15
  87. package/dist/getPublishPayload-DMd4oLir.js.map +1 -0
  88. package/dist/{getPublishUploads-Cex-NBe6.js → getPublishUploads-C9FnRG9c.js} +9 -6
  89. package/dist/getPublishUploads-C9FnRG9c.js.map +1 -0
  90. package/dist/{index-BbFwftAv.js → index-C--KAWoe.js} +3 -2
  91. package/dist/index-C--KAWoe.js.map +1 -0
  92. package/dist/{index-DpgQMIRq.js → index-CI0NFf4B.js} +132 -9
  93. package/dist/index-CI0NFf4B.js.map +1 -0
  94. package/dist/{index-BAao3_Po.js → index-Ccmd9_KY.js} +8 -8
  95. package/dist/index-Ccmd9_KY.js.map +1 -0
  96. package/dist/index-l3b6p1Ih.js +28 -0
  97. package/dist/index-l3b6p1Ih.js.map +1 -0
  98. package/dist/{index.browser-nndbVM7z.js → index.browser-kY8M-xUA.js} +284 -73
  99. package/dist/index.browser-kY8M-xUA.js.map +1 -0
  100. package/dist/{index.node-BUfx-JaP.js → index.node-Ba2KbmOq.js} +93 -6
  101. package/dist/index.node-Ba2KbmOq.js.map +1 -0
  102. package/dist/main.js +84 -26
  103. package/dist/main.js.map +1 -1
  104. package/dist/node.js +11 -11
  105. package/dist/platform.browser.js +5 -5
  106. package/dist/platform.node.js +4 -4
  107. package/dist/{property-BDBvImLs.js → property-CO7pKTWK.js} +9 -11
  108. package/dist/property-CO7pKTWK.js.map +1 -0
  109. package/dist/{propertyValidationRules-BlfLn4rP.js → propertyValidationRules-D5HZy0Bq.js} +10 -10
  110. package/dist/{propertyValidationRules-BlfLn4rP.js.map → propertyValidationRules-D5HZy0Bq.js.map} +1 -1
  111. package/dist/{publishDraftGraph-CLO85LLz.js → publishDraftGraph-B5KPqtbg.js} +6 -6
  112. package/dist/{publishDraftGraph-CLO85LLz.js.map → publishDraftGraph-B5KPqtbg.js.map} +1 -1
  113. package/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.js → resetAmbiguousLegacyItemData-77CZ8HT7.js} +2 -2
  114. package/dist/{resetAmbiguousLegacyItemData-Cy8ik7xk.js.map → resetAmbiguousLegacyItemData-77CZ8HT7.js.map} +1 -1
  115. package/dist/{resolveModelForSyncedSeed-DFr4COc4.js → resolveModelForSyncedSeed-DHOq_FGs.js} +2 -2
  116. package/dist/{resolveModelForSyncedSeed-DFr4COc4.js.map → resolveModelForSyncedSeed-DHOq_FGs.js.map} +1 -1
  117. package/dist/seedSchema/PendingWriteSchema.ts +57 -0
  118. package/dist/seedSchema/index.ts +1 -0
  119. package/dist/src/Item/Item.d.ts +38 -7
  120. package/dist/src/Item/Item.d.ts.map +1 -1
  121. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  122. package/dist/src/ItemProperty/ItemProperty.d.ts +66 -9
  123. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  124. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  125. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
  126. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.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 +5 -0
  131. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  132. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts +22 -0
  133. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts.map +1 -0
  134. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  135. package/dist/src/Model/Model.d.ts +50 -9
  136. package/dist/src/Model/Model.d.ts.map +1 -1
  137. package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
  138. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  139. package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
  140. package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
  141. package/dist/src/Schema/Schema.d.ts +22 -3
  142. package/dist/src/Schema/Schema.d.ts.map +1 -1
  143. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +1 -1
  144. package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +1 -1
  145. package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
  146. package/dist/src/browser/db/Db.d.ts +7 -0
  147. package/dist/src/browser/db/Db.d.ts.map +1 -1
  148. package/dist/src/browser/db/drizzleFiles.d.ts +4 -2
  149. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  150. package/dist/src/browser/db/sqliteBusyRetry.d.ts.map +1 -1
  151. package/dist/src/browser/helpers/EasClient.d.ts +1 -1
  152. package/dist/src/browser/helpers/EasClient.d.ts.map +1 -1
  153. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  154. package/dist/src/client/ClientManager.d.ts +13 -0
  155. package/dist/src/client/ClientManager.d.ts.map +1 -1
  156. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  157. package/dist/src/client/addressesPersisted.d.ts +10 -0
  158. package/dist/src/client/addressesPersisted.d.ts.map +1 -0
  159. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  160. package/dist/src/db/Db/BaseDb.d.ts +10 -0
  161. package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
  162. package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
  163. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  164. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  165. package/dist/src/db/read/getSeedData.d.ts +4 -1
  166. package/dist/src/db/read/getSeedData.d.ts.map +1 -1
  167. package/dist/src/db/read/getSeedPublisher.d.ts +4 -1
  168. package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -1
  169. package/dist/src/db/read/getVersionData.d.ts +4 -1
  170. package/dist/src/db/read/getVersionData.d.ts.map +1 -1
  171. package/dist/src/db/write/claimUnpublishedDrafts.d.ts +6 -0
  172. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
  173. package/dist/src/db/write/createMetadata.d.ts +13 -0
  174. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  175. package/dist/src/db/write/createNewItem.d.ts +5 -0
  176. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  177. package/dist/src/db/write/createSeed.d.ts +20 -1
  178. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  179. package/dist/src/db/write/createVersion.d.ts +5 -1
  180. package/dist/src/db/write/createVersion.d.ts.map +1 -1
  181. package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts +9 -2
  182. package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts.map +1 -1
  183. package/dist/src/db/write/updateItemPropertyValue.d.ts +9 -1
  184. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  185. package/dist/src/db/write/updateMetadata.d.ts +8 -1
  186. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  187. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  188. package/dist/src/helpers/db.d.ts +4 -2
  189. package/dist/src/helpers/db.d.ts.map +1 -1
  190. package/dist/src/helpers/entity/entityCache.d.ts +2 -42
  191. package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
  192. package/dist/src/helpers/entity/entityCommon.d.ts +9 -0
  193. package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
  194. package/dist/src/helpers/entity/entityDestroy.d.ts +13 -7
  195. package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
  196. package/dist/src/helpers/entity/entityLiveQuery.d.ts +3 -2
  197. package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
  198. package/dist/src/helpers/entity/entityState.d.ts +28 -0
  199. package/dist/src/helpers/entity/entityState.d.ts.map +1 -0
  200. package/dist/src/helpers/entity/entityUnload.d.ts +3 -2
  201. package/dist/src/helpers/entity/entityUnload.d.ts.map +1 -1
  202. package/dist/src/helpers/entity/index.d.ts +1 -0
  203. package/dist/src/helpers/entity/index.d.ts.map +1 -1
  204. package/dist/src/helpers/itemStorageFile.d.ts +7 -0
  205. package/dist/src/helpers/itemStorageFile.d.ts.map +1 -1
  206. package/dist/src/helpers/metadataPropertyNames.d.ts +6 -0
  207. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  208. package/dist/src/helpers/property.d.ts.map +1 -1
  209. package/dist/src/helpers/propertySchemaUid.d.ts +13 -0
  210. package/dist/src/helpers/propertySchemaUid.d.ts.map +1 -0
  211. package/dist/src/helpers/propertyWriteTickets.d.ts +11 -0
  212. package/dist/src/helpers/propertyWriteTickets.d.ts.map +1 -0
  213. package/dist/src/helpers/reactiveProxy.d.ts +18 -0
  214. package/dist/src/helpers/reactiveProxy.d.ts.map +1 -1
  215. package/dist/src/helpers/sessionObjectUrls.d.ts +4 -0
  216. package/dist/src/helpers/sessionObjectUrls.d.ts.map +1 -0
  217. package/dist/src/helpers/tabCoordinator.d.ts +9 -0
  218. package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
  219. package/dist/src/helpers/tabLocks.d.ts +11 -0
  220. package/dist/src/helpers/tabLocks.d.ts.map +1 -1
  221. package/dist/src/helpers/timing.d.ts +10 -0
  222. package/dist/src/helpers/timing.d.ts.map +1 -0
  223. package/dist/src/imports/json.d.ts.map +1 -1
  224. package/dist/src/index.d.ts +1 -0
  225. package/dist/src/index.d.ts.map +1 -1
  226. package/dist/src/interfaces/IDb.d.ts +2 -0
  227. package/dist/src/interfaces/IDb.d.ts.map +1 -1
  228. package/dist/src/interfaces/IItem.d.ts +1 -0
  229. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  230. package/dist/src/interfaces/IItemProperty.d.ts +5 -0
  231. package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
  232. package/dist/src/node/db/Db.d.ts +3 -0
  233. package/dist/src/node/db/Db.d.ts.map +1 -1
  234. package/dist/src/node/db/singleConnectionTransactions.d.ts +22 -0
  235. package/dist/src/node/db/singleConnectionTransactions.d.ts.map +1 -0
  236. package/dist/src/outbox/conflicts.d.ts +60 -0
  237. package/dist/src/outbox/conflicts.d.ts.map +1 -0
  238. package/dist/src/outbox/index.d.ts +9 -0
  239. package/dist/src/outbox/index.d.ts.map +1 -0
  240. package/dist/src/outbox/itemAppliers.d.ts +153 -0
  241. package/dist/src/outbox/itemAppliers.d.ts.map +1 -0
  242. package/dist/src/outbox/outbox.d.ts +143 -0
  243. package/dist/src/outbox/outbox.d.ts.map +1 -0
  244. package/dist/src/outbox/pendingValues.d.ts +27 -0
  245. package/dist/src/outbox/pendingValues.d.ts.map +1 -0
  246. package/dist/src/seedSchema/PendingWriteSchema.d.ts +385 -0
  247. package/dist/src/seedSchema/PendingWriteSchema.d.ts.map +1 -0
  248. package/dist/src/seedSchema/index.d.ts +1 -0
  249. package/dist/src/seedSchema/index.d.ts.map +1 -1
  250. package/dist/src/types/property.d.ts +5 -0
  251. package/dist/src/types/property.d.ts.map +1 -1
  252. package/dist/{syncDbWithEas-CAOlw3i-.js → syncDbWithEas-BZ6AI-IC.js} +25 -20
  253. package/dist/syncDbWithEas-BZ6AI-IC.js.map +1 -0
  254. package/dist/{tabEvents-DksXwk3X.js → tabEvents-CIlzHSKZ.js} +56 -25
  255. package/dist/tabEvents-CIlzHSKZ.js.map +1 -0
  256. package/dist/{tolerantWebAccess-CEIjFGf0.js → tolerantWebAccess-BwJ8bElF.js} +6 -6
  257. package/dist/{tolerantWebAccess-CEIjFGf0.js.map → tolerantWebAccess-BwJ8bElF.js.map} +1 -1
  258. package/dist/{updateSeedRevokedAt-Cjr35YjE.js → updateSeedRevokedAt-ClxMSXcB.js} +3 -3
  259. package/dist/{updateSeedRevokedAt-Cjr35YjE.js.map → updateSeedRevokedAt-ClxMSXcB.js.map} +1 -1
  260. package/package.json +7 -7
  261. package/dist/ClientManager-2GtDWHq6.js.map +0 -1
  262. package/dist/Item-D6j0IvBP.js.map +0 -1
  263. package/dist/ModelProperty-B52C3CQ2.js.map +0 -1
  264. package/dist/Schema-O1QLoXv6.js.map +0 -1
  265. package/dist/discardNewDraft-hiVaUVjV.js +0 -78
  266. package/dist/discardNewDraft-hiVaUVjV.js.map +0 -1
  267. package/dist/dist/ClientManager-2GtDWHq6.d.ts.map +0 -1
  268. package/dist/dist/Item-D6j0IvBP.d.ts.map +0 -1
  269. package/dist/dist/Schema-O1QLoXv6.d.ts.map +0 -1
  270. package/dist/dist/backfillMetadataPropertyIds-CzSbuucw.d.ts.map +0 -1
  271. package/dist/dist/configurePlatform-Bbpw_R4y.d.ts.map +0 -1
  272. package/dist/dist/detachRowsBeforeDelete-D1TyEMco.d.ts.map +0 -1
  273. package/dist/dist/discardNewDraft-hiVaUVjV.d.ts +0 -8
  274. package/dist/dist/discardNewDraft-hiVaUVjV.d.ts.map +0 -1
  275. package/dist/dist/eas-DOdj-EMK.d.ts.map +0 -1
  276. package/dist/dist/errors-KM-yq2MD.d.ts.map +0 -1
  277. package/dist/dist/getItem-Bh0zv-o1.d.ts.map +0 -1
  278. package/dist/dist/getPublishPayload-oH8wJhnH.d.ts.map +0 -1
  279. package/dist/dist/index-BAao3_Po.d.ts.map +0 -1
  280. package/dist/dist/index-DpgQMIRq.d.ts.map +0 -1
  281. package/dist/dist/property-BDBvImLs.d.ts.map +0 -1
  282. package/dist/dist/propertyValidationRules-BlfLn4rP.d.ts.map +0 -1
  283. package/dist/dist/resetAmbiguousLegacyItemData-Cy8ik7xk.d.ts.map +0 -1
  284. package/dist/dist/resolveModelForSyncedSeed-DFr4COc4.d.ts.map +0 -1
  285. package/dist/dist/syncDbWithEas-CAOlw3i-.d.ts.map +0 -1
  286. package/dist/dist/tabEvents-DksXwk3X.d.ts.map +0 -1
  287. package/dist/dist/updateSeedRevokedAt-Cjr35YjE.d.ts.map +0 -1
  288. package/dist/errors-KM-yq2MD.js.map +0 -1
  289. package/dist/getPublishPayload-oH8wJhnH.js.map +0 -1
  290. package/dist/getPublishUploads-Cex-NBe6.js.map +0 -1
  291. package/dist/index-BAao3_Po.js.map +0 -1
  292. package/dist/index-BbFwftAv.js.map +0 -1
  293. package/dist/index-DpgQMIRq.js.map +0 -1
  294. package/dist/index.browser-nndbVM7z.js.map +0 -1
  295. package/dist/index.node-BUfx-JaP.js.map +0 -1
  296. package/dist/property-BDBvImLs.js.map +0 -1
  297. package/dist/src/db/write/discardNewDraft.d.ts +0 -8
  298. package/dist/src/db/write/discardNewDraft.d.ts.map +0 -1
  299. package/dist/src/helpers/propertyWriteQueue.d.ts +0 -15
  300. package/dist/src/helpers/propertyWriteQueue.d.ts.map +0 -1
  301. package/dist/syncDbWithEas-CAOlw3i-.js.map +0 -1
  302. package/dist/tabEvents-DksXwk3X.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { fromCallback, setup, assign, createActor } from 'xstate';
2
- import { au as SEED_PROTOCOL_SCHEMA_NAME, B as BaseDb, A as schemas, aM as addSchemaToDb, i as isDataType, M as ModelPropertyDataTypes, ai as generateId, N as addModelsToDb, t as models, r as modelSchemas, v as properties, h as BaseFileManager, aP as loadModelsFromDbForSchema, aQ as mergeDbModelsIntoSchemaModels, aJ as isInternalSchema, aR as clearNameMatchLevels } from './index-DpgQMIRq.js';
3
- import { g as getRefValueType, J as createRowsWrittenSignal, K as createModelsFromJson, q as listCompleteSchemaFiles, L as getLatestSchemaVersion, l as loadSchemaFromFile, M as jsonPropertiesToSchemaProperties, u as loadAllSchemasFromDb, m as getClient } from './ClientManager-2GtDWHq6.js';
2
+ import { aw as SEED_PROTOCOL_SCHEMA_NAME, F as BaseDb, A as schemas, aO as addSchemaToDb, i as isDataType, M as ModelPropertyDataTypes, ai as generateId, O as addModelsToDb, s as models, q as modelSchemas, v as properties, N as BaseFileManager, aR as loadModelsFromDbForSchema, aS as mergeDbModelsIntoSchemaModels, aL as isInternalSchema, aT as clearNameMatchLevels } from './index-CI0NFf4B.js';
3
+ import { h as getRefValueType, T as createRowsWrittenSignal, U as createModelsFromJson, F as listCompleteSchemaFiles, V as getLatestSchemaVersion, l as loadSchemaFromFile, W as jsonPropertiesToSchemaProperties, G as loadAllSchemasFromDb, z as getClient } from './ClientManager-Dcju5x4k.js';
4
4
  import { eq, desc, and } from 'drizzle-orm';
5
5
  import debug from 'debug';
6
- import { c as currentEvictionEpoch, w as writeProcessMachine, t as trackDraftSave, M as Model, g as getDraftSaveError, C as ConflictError, r as recordSchemaDestroy, f as finishSchemaDestroy, e as setupEntityLiveQuery } from './errors-KM-yq2MD.js';
6
+ import { c as currentEvictionEpoch, w as writeProcessMachine, M as Model, g as getDraftSaveError, C as ConflictError, r as recordSchemaDestroy, f as finishSchemaDestroy, e as setupEntityLiveQuery, t as trackDraftSave } from './errors-BGk_IJO5.js';
7
7
  import 'pluralize';
8
8
  import '@seedprotocol/eas';
9
- import { SchemaValidationService } from './SchemaValidationService-BxCbfDaI.js';
10
- import { D as DEFAULT_READY_TIMEOUT_MS, d as waitForEntityIdle, m as createReactiveProxy, n as findEntity, C as ClientManagerState, _ as clearDestroySubscriptions, o as forceRemoveFromCaches, $ as unloadEntity, q as runDestroyLifecycle } from './Item-D6j0IvBP.js';
9
+ import { SchemaValidationService } from './SchemaValidationService-NYTtSCxd.js';
10
+ import { ak as ActorKeyedState, Q as DEFAULT_READY_TIMEOUT_MS, C as waitForEntityIdle, R as createReactiveProxy, T as findEntity, X as ClientManagerState, al as clearDestroySubscriptions, U as forceRemoveFromCaches, am as unloadEntity, V as runDestroyLifecycle } from './Item-DZfNz7xl.js';
11
11
 
12
12
  const logger$d = debug('seedSdk:schema:actors:loadOrCreateSchema');
13
13
  /**
@@ -51,8 +51,8 @@ const createModelInstances$2 = async (modelIds, evictionEpoch) => {
51
51
  return;
52
52
  }
53
53
  try {
54
- const _mod_0 = await import('./errors-KM-yq2MD.js');
55
- const _ns_0 = _mod_0.j;
54
+ const _mod_0 = await import('./errors-BGk_IJO5.js');
55
+ const _ns_0 = _mod_0.i;
56
56
  const modelMod = _ns_0;
57
57
  const { Model } = modelMod;
58
58
  // Create instances for all model IDs in parallel
@@ -60,7 +60,10 @@ const createModelInstances$2 = async (modelIds, evictionEpoch) => {
60
60
  const createPromises = modelIds.map(async (modelFileId) => {
61
61
  try {
62
62
  // Not if the schema was evicted (Schema.destroy, test cleanup) since this load started
63
- const model = await Model.createById(modelFileId, { evictionEpoch });
63
+ const schemaHold = Model.takeSchemaHold(modelFileId);
64
+ const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
65
+ if (!model && schemaHold)
66
+ Model.dropSchemaHold(modelFileId);
64
67
  if (model) {
65
68
  logger$d(`Created/cached Model instance for modelFileId "${modelFileId}"`);
66
69
  }
@@ -168,8 +171,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
168
171
  // For Seed Protocol, always load from internal file, never create new
169
172
  logger$d(`Loading internal Seed Protocol schema from SDK`);
170
173
  try {
171
- const _mod_1 = await import('./ClientManager-2GtDWHq6.js');
172
- const _ns_1 = _mod_1.S;
174
+ const _mod_1 = await import('./ClientManager-Dcju5x4k.js');
175
+ const _ns_1 = _mod_1.Y;
173
176
  const internalSchema = _ns_1;
174
177
  const schemaFile = internalSchema.default;
175
178
  // Check if it exists in database, if not, add it
@@ -667,8 +670,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
667
670
  // Ensure models are populated (fallback for seed-protocol if missing)
668
671
  if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
669
672
  try {
670
- const _mod_2 = await import('./ClientManager-2GtDWHq6.js');
671
- const _ns_2 = _mod_2.S;
673
+ const _mod_2 = await import('./ClientManager-Dcju5x4k.js');
674
+ const _ns_2 = _mod_2.Y;
672
675
  const internalSchema = _ns_2;
673
676
  const internalSchemaFile = internalSchema.default;
674
677
  mergedModels = { ...(internalSchemaFile.models || {}) };
@@ -832,8 +835,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
832
835
  // Ensure models are populated (fallback for seed-protocol if missing)
833
836
  if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
834
837
  try {
835
- const _mod_3 = await import('./ClientManager-2GtDWHq6.js');
836
- const _ns_3 = _mod_3.S;
838
+ const _mod_3 = await import('./ClientManager-Dcju5x4k.js');
839
+ const _ns_3 = _mod_3.Y;
837
840
  const internalSchema = _ns_3;
838
841
  const internalSchemaFile = internalSchema.default;
839
842
  mergedModels = { ...(internalSchemaFile.models || {}) };
@@ -887,8 +890,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
887
890
  // Ensure models are populated (fallback for seed-protocol if missing)
888
891
  if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
889
892
  try {
890
- const _mod_4 = await import('./ClientManager-2GtDWHq6.js');
891
- const _ns_4 = _mod_4.S;
893
+ const _mod_4 = await import('./ClientManager-Dcju5x4k.js');
894
+ const _ns_4 = _mod_4.Y;
892
895
  const internalSchema = _ns_4;
893
896
  const internalSchemaFile = internalSchema.default;
894
897
  mergedModels = { ...(internalSchemaFile.models || {}) };
@@ -937,8 +940,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
937
940
  // If schemaData is missing, try to load from internal schema file for seed-protocol
938
941
  if (!dbSchema.schemaData && schemaName === 'Seed Protocol') {
939
942
  try {
940
- const _mod_5 = await import('./ClientManager-2GtDWHq6.js');
941
- const _ns_5 = _mod_5.S;
943
+ const _mod_5 = await import('./ClientManager-Dcju5x4k.js');
944
+ const _ns_5 = _mod_5.Y;
942
945
  const internalSchema = _ns_5;
943
946
  const schemaFile = internalSchema.default;
944
947
  logger$d(`Found seed-protocol schema in internal file (schemaData missing, using internal schema)`);
@@ -1048,8 +1051,8 @@ const loadOrCreateSchema = fromCallback(({ sendBack, input: { context } }) => {
1048
1051
  // Ensure models are populated (fallback for seed-protocol if missing)
1049
1052
  if ((!mergedModels || Object.keys(mergedModels).length === 0) && schemaName === 'Seed Protocol') {
1050
1053
  try {
1051
- const _mod_6 = await import('./ClientManager-2GtDWHq6.js');
1052
- const _ns_6 = _mod_6.S;
1054
+ const _mod_6 = await import('./ClientManager-Dcju5x4k.js');
1055
+ const _ns_6 = _mod_6.Y;
1053
1056
  const internalSchema = _ns_6;
1054
1057
  const internalSchemaFile = internalSchema.default;
1055
1058
  mergedModels = { ...(internalSchemaFile.models || {}) };
@@ -1375,8 +1378,8 @@ const createModelInstances$1 = async (modelIds, evictionEpoch) => {
1375
1378
  return;
1376
1379
  }
1377
1380
  try {
1378
- const _mod_7 = await import('./errors-KM-yq2MD.js');
1379
- const _ns_7 = _mod_7.j;
1381
+ const _mod_7 = await import('./errors-BGk_IJO5.js');
1382
+ const _ns_7 = _mod_7.i;
1380
1383
  const mod = _ns_7;
1381
1384
  const Model = mod?.Model ?? mod?.default;
1382
1385
  if (!Model) {
@@ -1386,7 +1389,10 @@ const createModelInstances$1 = async (modelIds, evictionEpoch) => {
1386
1389
  const createPromises = modelIds.map(async (modelFileId) => {
1387
1390
  try {
1388
1391
  // Not if the schema was evicted (Schema.destroy, test cleanup) since this check started
1389
- const model = await Model.createById(modelFileId, { evictionEpoch });
1392
+ const schemaHold = Model.takeSchemaHold(modelFileId);
1393
+ const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
1394
+ if (!model && schemaHold)
1395
+ Model.dropSchemaHold(modelFileId);
1390
1396
  if (model) {
1391
1397
  logger$c(`Created/cached Model instance for modelFileId "${modelFileId}"`);
1392
1398
  }
@@ -1424,8 +1430,8 @@ const checkExistingSchema = fromCallback(({ sendBack, input: { context } }) => {
1424
1430
  if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
1425
1431
  // For Seed Protocol, check if it exists in database
1426
1432
  try {
1427
- const _mod_8 = await import('./ClientManager-2GtDWHq6.js');
1428
- const _ns_8 = _mod_8.S;
1433
+ const _mod_8 = await import('./ClientManager-Dcju5x4k.js');
1434
+ const _ns_8 = _mod_8.Y;
1429
1435
  const internalSchema = _ns_8;
1430
1436
  const schemaFile = internalSchema.default;
1431
1437
  if (db && schemaFile.id) {
@@ -1760,8 +1766,8 @@ const writeSchemaToDb = fromCallback(({ sendBack, input }) => {
1760
1766
  if (isInternal && schemaName === SEED_PROTOCOL_SCHEMA_NAME) {
1761
1767
  // For Seed Protocol, load from internal file
1762
1768
  logger$b(`Loading internal Seed Protocol schema from SDK`);
1763
- const _mod_9 = await import('./ClientManager-2GtDWHq6.js');
1764
- const _ns_9 = _mod_9.S;
1769
+ const _mod_9 = await import('./ClientManager-Dcju5x4k.js');
1770
+ const _ns_9 = _mod_9.Y;
1765
1771
  const internalSchema = _ns_9;
1766
1772
  finalSchema = internalSchema.default;
1767
1773
  const db = BaseDb.getAppDb();
@@ -2233,8 +2239,8 @@ const createModelInstances = fromCallback(({ sendBack, input }) => {
2233
2239
  return;
2234
2240
  }
2235
2241
  try {
2236
- const _mod_10 = await import('./errors-KM-yq2MD.js');
2237
- const _ns_10 = _mod_10.j;
2242
+ const _mod_10 = await import('./errors-BGk_IJO5.js');
2243
+ const _ns_10 = _mod_10.i;
2238
2244
  const modelMod = _ns_10;
2239
2245
  const { Model } = modelMod;
2240
2246
  // Create instances for all model IDs in parallel
@@ -2242,7 +2248,10 @@ const createModelInstances = fromCallback(({ sendBack, input }) => {
2242
2248
  const createPromises = modelIds.map(async (modelFileId) => {
2243
2249
  try {
2244
2250
  // Not if the schema was evicted (Schema.destroy, test cleanup) since this started
2245
- const model = await Model.createById(modelFileId, { evictionEpoch });
2251
+ const schemaHold = Model.takeSchemaHold(modelFileId);
2252
+ const model = await Model.createById(modelFileId, { evictionEpoch, ...(!schemaHold && { hold: false }) });
2253
+ if (!model && schemaHold)
2254
+ Model.dropSchemaHold(modelFileId);
2246
2255
  if (model) {
2247
2256
  logger$7(`Created/cached Model instance for modelFileId "${modelFileId}"`);
2248
2257
  return true;
@@ -2322,8 +2331,8 @@ const verifyModelInstancesInCache = fromCallback(({ sendBack, input }) => {
2322
2331
  }
2323
2332
  try {
2324
2333
  const result = await verifyWithRetry$2(async () => {
2325
- const _mod_11 = await import('./errors-KM-yq2MD.js');
2326
- const _ns_11 = _mod_11.j;
2334
+ const _mod_11 = await import('./errors-BGk_IJO5.js');
2335
+ const _ns_11 = _mod_11.i;
2327
2336
  const modelMod = _ns_11;
2328
2337
  const { Model } = modelMod;
2329
2338
  // Check each model ID in the cache
@@ -2331,7 +2340,7 @@ const verifyModelInstancesInCache = fromCallback(({ sendBack, input }) => {
2331
2340
  const missingIds = [];
2332
2341
  for (const modelFileId of modelIds) {
2333
2342
  // Try to get instance from cache
2334
- const instance = Model.getById(modelFileId);
2343
+ const instance = Model.peek(modelFileId);
2335
2344
  if (instance) {
2336
2345
  verifiedInstances.push(modelFileId);
2337
2346
  }
@@ -2381,8 +2390,8 @@ const writePropertiesToDb = fromCallback(({ sendBack, input }) => {
2381
2390
  const _write = async () => {
2382
2391
  const { modelIds } = input;
2383
2392
  try {
2384
- const _mod_12 = await import('./index-DpgQMIRq.js');
2385
- const _ns_12 = _mod_12.bd;
2393
+ const _mod_12 = await import('./index-CI0NFf4B.js');
2394
+ const _ns_12 = _mod_12.bh;
2386
2395
  const modelSchemaMod = _ns_12;
2387
2396
  const { models: modelsTable, properties: propertiesTable } = modelSchemaMod;
2388
2397
  const drizzleMod = await import('drizzle-orm');
@@ -2571,10 +2580,10 @@ const createPropertyInstances = fromCallback(({ sendBack, input }) => {
2571
2580
  return;
2572
2581
  }
2573
2582
  try {
2574
- const modProp = await import('./ModelProperty-B52C3CQ2.js');
2583
+ const modProp = await import('./ModelProperty-sMGL-_LK.js');
2575
2584
  const ModelProperty = modProp?.ModelProperty ?? modProp?.default;
2576
- const _mod_13 = await import('./errors-KM-yq2MD.js');
2577
- const _ns_13 = _mod_13.j;
2585
+ const _mod_13 = await import('./errors-BGk_IJO5.js');
2586
+ const _ns_13 = _mod_13.i;
2578
2587
  const modModel = _ns_13;
2579
2588
  const Model = modModel?.Model ?? modModel?.default;
2580
2589
  if (!ModelProperty || !Model) {
@@ -2587,7 +2596,7 @@ const createPropertyInstances = fromCallback(({ sendBack, input }) => {
2587
2596
  let successCount = 0;
2588
2597
  // For each model, check if properties are loaded
2589
2598
  for (const modelFileId of modelIds) {
2590
- const model = Model.getById(modelFileId);
2599
+ const model = Model.peek(modelFileId);
2591
2600
  if (model && model.properties) {
2592
2601
  // Count properties that match our property IDs
2593
2602
  for (const prop of model.properties) {
@@ -2680,7 +2689,7 @@ const verifyPropertyInstancesInCache = fromCallback(({ sendBack, input }) => {
2680
2689
  }
2681
2690
  try {
2682
2691
  const result = await verifyWithRetry(async () => {
2683
- const mod = await import('./ModelProperty-B52C3CQ2.js');
2692
+ const mod = await import('./ModelProperty-sMGL-_LK.js');
2684
2693
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
2685
2694
  if (!ModelProperty) {
2686
2695
  throw new Error('ModelProperty not available from dynamic import');
@@ -3700,8 +3709,8 @@ async function loadSchemaWithRenames(schemaFilePath, modelRenames) {
3700
3709
  updatedAt: new Date(schemaFile.metadata.updatedAt).getTime(),
3701
3710
  };
3702
3711
  // Use dynamic import to break circular dependency
3703
- const _mod_14 = await import('./index-DpgQMIRq.js');
3704
- const _ns_14 = _mod_14.bi;
3712
+ const _mod_14 = await import('./index-CI0NFf4B.js');
3713
+ const _ns_14 = _mod_14.bm;
3705
3714
  const dbMod = _ns_14;
3706
3715
  const { addSchemaToDb, addModelsToDb } = dbMod;
3707
3716
  // Add schema to database with schemaFileId
@@ -3824,8 +3833,8 @@ async function renameModelProperty(schemaName, modelName, oldPropertyName, newPr
3824
3833
  await BaseFileManager.waitForFileWithContent(newFilePath);
3825
3834
  logger$1(`Renamed property ${oldPropertyName} to ${newPropertyName} in schema ${schemaName} v${newVersion}`);
3826
3835
  // Migrate metadata rows so ItemProperty values follow the new name (prevents duplicate ItemProperties)
3827
- const _mod_15 = await import('./index-DpgQMIRq.js');
3828
- const _ns_15 = _mod_15.bi;
3836
+ const _mod_15 = await import('./index-CI0NFf4B.js');
3837
+ const _ns_15 = _mod_15.bm;
3829
3838
  const { migrateMetadataForPropertyRename } = _ns_15;
3830
3839
  const migratedCount = await migrateMetadataForPropertyRename(modelName, oldPropertyName, newPropertyName, oldProperty.id, { schemaName });
3831
3840
  if (migratedCount > 0) {
@@ -4083,9 +4092,8 @@ var updateSchema = /*#__PURE__*/Object.freeze({
4083
4092
 
4084
4093
  const logger = debug('seedSdk:schema:saveNewVersion');
4085
4094
  const saveDraftLogger = debug('seedSdk:schema:saveDraftToDb');
4086
- // WeakMap to store non-serializable resources per Schema instance
4087
- // Only stores resources that cannot be serialized (subscriptions, timers, etc.)
4088
- const schemaInstanceState = new WeakMap();
4095
+ // Non-serializable resources per Schema instance (subscriptions, timers, etc.)
4096
+ const schemaInstanceState = new ActorKeyedState();
4089
4097
  // Cache client initialization state globally to avoid repeated checks
4090
4098
  let cachedClientInitialized = null;
4091
4099
  let clientCheckTime = 0;
@@ -4142,18 +4150,18 @@ class Schema {
4142
4150
  }
4143
4151
  const waitForReady = options?.waitForReady !== false;
4144
4152
  const readyTimeout = options?.readyTimeout ?? DEFAULT_READY_TIMEOUT_MS;
4153
+ const holds = options?.hold === false ? 0 : 1;
4145
4154
  // First, check if we have an instance cached by name
4146
- if (this.instanceCacheByName.has(schemaName)) {
4147
- const { instance, refCount } = this.instanceCacheByName.get(schemaName);
4148
- this.instanceCacheByName.set(schemaName, {
4149
- instance,
4150
- refCount: refCount + 1,
4151
- });
4155
+ const cached = this.instanceCacheByName.get(schemaName);
4156
+ if (cached) {
4157
+ cached.refCount += holds;
4158
+ const { instance } = cached;
4152
4159
  if (!waitForReady)
4153
4160
  return instance;
4154
4161
  return waitForEntityIdle(instance, { timeout: readyTimeout }).then(() => instance);
4155
4162
  }
4156
- // Deduplicate concurrent creates for same schema (prevents many parallel checkExistingSchema loads)
4163
+ // Deduplicate concurrent creates for same schema (prevents many parallel checkExistingSchema loads).
4164
+ // The name cache is set before a pending load is recorded, so a hold was already taken above.
4157
4165
  if (waitForReady) {
4158
4166
  const pending = this.pendingSchemaByName.get(schemaName);
4159
4167
  if (pending) {
@@ -4366,7 +4374,7 @@ class Schema {
4366
4374
  // Cache by name initially (will be moved to id-based cache once schemaFileId is available)
4367
4375
  this.instanceCacheByName.set(schemaName, {
4368
4376
  instance: proxiedInstance,
4369
- refCount: 1,
4377
+ refCount: holds,
4370
4378
  });
4371
4379
  const schema = proxiedInstance;
4372
4380
  if (!waitForReady)
@@ -4392,14 +4400,11 @@ class Schema {
4392
4400
  return;
4393
4401
  }
4394
4402
  // If we have an instance cached by name, also add it to id-based cache
4395
- // Keep it in both caches for efficient lookups
4403
+ // Keep it in both caches for efficient lookups, as one entry: one hold count for both keys
4396
4404
  if (this.instanceCacheByName.has(schemaName)) {
4397
4405
  const cacheEntry = this.instanceCacheByName.get(schemaName);
4398
4406
  // Add to ID cache (don't remove from name cache)
4399
- this.instanceCacheById.set(schemaFileId, {
4400
- instance: cacheEntry.instance,
4401
- refCount: cacheEntry.refCount, // Use same refCount
4402
- });
4407
+ this.instanceCacheById.set(schemaFileId, cacheEntry);
4403
4408
  logger(`Added schema cache entry to id "${schemaFileId}" (kept in name cache: "${schemaName}")`);
4404
4409
  }
4405
4410
  }
@@ -4408,15 +4413,19 @@ class Schema {
4408
4413
  * Returns null if not found in cache
4409
4414
  */
4410
4415
  static getById(schemaFileId) {
4411
- if (this.instanceCacheById.has(schemaFileId)) {
4412
- const { instance, refCount } = this.instanceCacheById.get(schemaFileId);
4413
- this.instanceCacheById.set(schemaFileId, {
4414
- instance,
4415
- refCount: refCount + 1,
4416
- });
4417
- return instance;
4418
- }
4419
- return null;
4416
+ const entry = this.instanceCacheById.get(schemaFileId);
4417
+ if (!entry)
4418
+ return null;
4419
+ entry.refCount += 1;
4420
+ return entry.instance;
4421
+ }
4422
+ /**
4423
+ * The cached schema with this file id or name, without taking a hold. For SDK code that reads
4424
+ * the schema and doesn't hand it to a caller; callers that keep it use `create` or `find`.
4425
+ */
4426
+ static peek(schemaFileIdOrName) {
4427
+ return (this.instanceCacheById.get(schemaFileIdOrName)?.instance ??
4428
+ this.instanceCacheByName.get(schemaFileIdOrName)?.instance);
4420
4429
  }
4421
4430
  /**
4422
4431
  * Clear all cached Schema instances.
@@ -4452,14 +4461,16 @@ class Schema {
4452
4461
  * Create or get schema instance by schemaFileId
4453
4462
  * Queries the database to find the schema name if not cached
4454
4463
  * @param schemaFileId - The schema file ID
4455
- * @returns Schema instance
4464
+ * @returns Schema instance, with a hold taken (unless `hold: false`)
4456
4465
  */
4457
- static async createById(schemaFileId) {
4466
+ static async createById(schemaFileId,
4467
+ /** @internal `hold: false` as for `create` */
4468
+ options) {
4458
4469
  if (!schemaFileId) {
4459
4470
  throw new Error('Schema file ID is required');
4460
4471
  }
4461
4472
  // First, check if we have an instance cached by ID
4462
- const cachedInstance = this.getById(schemaFileId);
4473
+ const cachedInstance = options?.hold === false ? this.peek(schemaFileId) : this.getById(schemaFileId);
4463
4474
  if (cachedInstance) {
4464
4475
  return cachedInstance;
4465
4476
  }
@@ -4483,7 +4494,7 @@ class Schema {
4483
4494
  throw new Error(`Schema with ID "${schemaFileId}" has no name in database`);
4484
4495
  }
4485
4496
  // Create schema using the name (this will load from database/file)
4486
- return this.create(schemaName);
4497
+ return this.create(schemaName, options?.hold === false ? { hold: false } : undefined);
4487
4498
  }
4488
4499
  /**
4489
4500
  * Find schema instance by schemaFileId
@@ -4512,6 +4523,7 @@ class Schema {
4512
4523
  * Get instantiated Schema objects for all schemas (from database and files)
4513
4524
  * By default, returns only the latest version of each schema and excludes the internal Seed Protocol schema.
4514
4525
  * Uses loadAllSchemasFromDb() as the single source of truth, which intelligently merges database and file data.
4526
+ * Takes no holds on the instances it returns: a caller that keeps one uses `Schema.create` or `Schema.find`.
4515
4527
  *
4516
4528
  * @param options - Configuration options
4517
4529
  * @param options.includeAllVersions - If true, returns all versions of each schema. Default: false
@@ -4570,9 +4582,10 @@ class Schema {
4570
4582
  }
4571
4583
  processedSchemaNames.add(schemaName);
4572
4584
  // Try to use schemaFileId to ensure we load the correct version
4573
- // First check if we have a cached instance by schemaFileId
4585
+ // First check if we have a cached instance by schemaFileId. Schema.all takes no holds: it
4586
+ // lists schemas (useSchemas caches the list and never unloads it).
4574
4587
  if (schemaFileId) {
4575
- const cachedById = this.getById(schemaFileId);
4588
+ const cachedById = this.peek(schemaFileId);
4576
4589
  if (cachedById) {
4577
4590
  // Verify the cached instance has the correct version
4578
4591
  const cachedContext = cachedById.getService().getSnapshot().context;
@@ -4597,16 +4610,16 @@ class Schema {
4597
4610
  // But to ensure we get the correct version, we'll use createById if we have the schemaFileId
4598
4611
  if (schemaFileId) {
4599
4612
  try {
4600
- const instance = await this.createById(schemaFileId);
4613
+ const instance = await this.createById(schemaFileId, { hold: false });
4601
4614
  schemaInstances.push(instance);
4602
4615
  }
4603
4616
  catch {
4604
4617
  // Fallback to creating by name if createById fails
4605
- schemaInstances.push(this.create(schemaName, { waitForReady: false }));
4618
+ schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
4606
4619
  }
4607
4620
  }
4608
4621
  else {
4609
- schemaInstances.push(this.create(schemaName, { waitForReady: false }));
4622
+ schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
4610
4623
  }
4611
4624
  }
4612
4625
  if (waitForReady && schemaInstances.length > 0) {
@@ -4651,7 +4664,7 @@ class Schema {
4651
4664
  // Create Schema instances for each unique schema name
4652
4665
  const schemaInstances = [];
4653
4666
  for (const schemaName of uniqueSchemaNames) {
4654
- schemaInstances.push(this.create(schemaName, { waitForReady: false }));
4667
+ schemaInstances.push(this.create(schemaName, { waitForReady: false, hold: false }));
4655
4668
  }
4656
4669
  if (waitForReady && schemaInstances.length > 0) {
4657
4670
  await Promise.all(schemaInstances.map((s) => waitForEntityIdle(s, {
@@ -4712,7 +4725,7 @@ class Schema {
4712
4725
  const seen = new Set();
4713
4726
  const modelInstances = [];
4714
4727
  for (const modelFileId of allModelIds) {
4715
- const model = Model.getById(modelFileId);
4728
+ const model = Model.peek(modelFileId);
4716
4729
  if (model && modelFileId && !seen.has(modelFileId)) {
4717
4730
  modelInstances.push(model);
4718
4731
  seen.add(modelFileId);
@@ -4821,7 +4834,7 @@ class Schema {
4821
4834
  const modelDbId = modelInstance.getService().getSnapshot().context._dbId;
4822
4835
  const db = BaseDb.getAppDb();
4823
4836
  if (propertyContexts.length === 0 && modelDbId && db) {
4824
- const { ModelProperty } = await import('./ModelProperty-B52C3CQ2.js');
4837
+ const { ModelProperty } = await import('./ModelProperty-sMGL-_LK.js');
4825
4838
  const rows = await db.select().from(properties).where(eq(properties.modelId, modelDbId));
4826
4839
  propertyContexts = rows.map((row) => {
4827
4840
  const cached = row.schemaFileId ? ModelProperty.getById(row.schemaFileId) : undefined;
@@ -4987,7 +5000,7 @@ class Schema {
4987
5000
  savedSchema: publishedSchema,
4988
5001
  });
4989
5002
  // Clear edited flags on all ModelProperty instances and in database
4990
- const modelPropertyMod = await import('./ModelProperty-B52C3CQ2.js');
5003
+ const modelPropertyMod = await import('./ModelProperty-sMGL-_LK.js');
4991
5004
  const { ModelProperty } = modelPropertyMod;
4992
5005
  for (const propertyKey of context._editedProperties) {
4993
5006
  const [modelName, propertyName] = propertyKey.split(':');
@@ -5010,8 +5023,8 @@ class Schema {
5010
5023
  try {
5011
5024
  if (db && modelName && propertyName) {
5012
5025
  // Find this schema's model by name
5013
- const _mod_16 = await import('./index-DpgQMIRq.js');
5014
- const _ns_16 = _mod_16.bh;
5026
+ const _mod_16 = await import('./index-CI0NFf4B.js');
5027
+ const _ns_16 = _mod_16.bl;
5015
5028
  const { resolveModelRecord } = _ns_16;
5016
5029
  const modelRecord = await resolveModelRecord(modelName, { schemaName: thisSchemaName }, db);
5017
5030
  const modelRecords = modelRecord ? [modelRecord] : [];
@@ -5577,6 +5590,8 @@ class Schema {
5577
5590
  onUnload: () => {
5578
5591
  // Clean up WeakMap entry
5579
5592
  schemaInstanceState.delete(this);
5593
+ if (context.schemaName)
5594
+ Model.releaseSchemaHolds(context.schemaName);
5580
5595
  },
5581
5596
  });
5582
5597
  }
@@ -5640,10 +5655,10 @@ class Schema {
5640
5655
  // instances too, or a re-import would get them back with dangling _dbIds.
5641
5656
  if (schemaName) {
5642
5657
  const evictedModelNames = Model.evictForSchema(schemaName);
5643
- const { ModelProperty } = await import('./ModelProperty-B52C3CQ2.js');
5658
+ const { ModelProperty } = await import('./ModelProperty-sMGL-_LK.js');
5644
5659
  ModelProperty.evictForModels(evictedModelNames, schemaName);
5645
5660
  // Evicting stops new writes but not ones already running; let those land before deleting their rows
5646
- const _mod_17 = await import('./errors-KM-yq2MD.js');
5661
+ const _mod_17 = await import('./errors-BGk_IJO5.js');
5647
5662
  const _ns_17 = _mod_17.h;
5648
5663
  const { waitForInFlightWrites } = _ns_17;
5649
5664
  await waitForInFlightWrites();
@@ -5676,7 +5691,7 @@ class Schema {
5676
5691
  .map((r) => r.modelId)
5677
5692
  .filter((id) => id != null)),
5678
5693
  ];
5679
- const { detachModelRows } = await import('./detachRowsBeforeDelete-D1TyEMco.js');
5694
+ const { detachModelRows } = await import('./detachRowsBeforeDelete-CLbBbpX4.js');
5680
5695
  await detachModelRows(db, modelIds);
5681
5696
  await db.delete(modelSchemas).where(inArray(modelSchemas.schemaId, schemaIds));
5682
5697
  for (const modelId of modelIds) {
@@ -5691,8 +5706,8 @@ class Schema {
5691
5706
  // the destroyed schema back on the next Schema.all().
5692
5707
  // Match on name as well as id: versions imported from complete schema files can each
5693
5708
  // have their own id, and any version left behind would bring the schema back.
5694
- const _mod_18 = await import('./ClientManager-2GtDWHq6.js');
5695
- const _ns_18 = _mod_18.N;
5709
+ const _mod_18 = await import('./ClientManager-Dcju5x4k.js');
5710
+ const _ns_18 = _mod_18.X;
5696
5711
  const { listCompleteSchemaFiles } = _ns_18;
5697
5712
  const files = await listCompleteSchemaFiles().catch(() => []);
5698
5713
  const fs = await BaseFileManager.getFs();
@@ -5810,7 +5825,7 @@ class Schema {
5810
5825
  // One at a time: an eviction of this schema part way through stops the rest
5811
5826
  const evictionEpoch = currentEvictionEpoch();
5812
5827
  for (const id of ids) {
5813
- await Model.createById(id, { evictionEpoch });
5828
+ await Model.createById(id, { evictionEpoch, hold: false });
5814
5829
  }
5815
5830
  },
5816
5831
  queryInitialData: async (schemaId) => {
@@ -5887,4 +5902,4 @@ var Schema$1 = /*#__PURE__*/Object.freeze({
5887
5902
  });
5888
5903
 
5889
5904
  export { Schema as S, deletePropertyFromModel as a, Schema$1 as b, deleteModelFromSchema as d, renameModelProperty as r, schemaMachine as s, updateModelProperties as u };
5890
- //# sourceMappingURL=Schema-O1QLoXv6.js.map
5905
+ //# sourceMappingURL=Schema-D-TczaIj.js.map