@seedprotocol/sdk 0.4.17 → 0.4.19

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 (257) hide show
  1. package/dist/{ArweaveClient-Zz6VwCkj.js → ArweaveClient-CAdWVQnJ.js} +3 -3
  2. package/dist/{ArweaveClient-Zz6VwCkj.js.map → ArweaveClient-CAdWVQnJ.js.map} +1 -1
  3. package/dist/{ArweaveClient-DPeCeRMF.js → ArweaveClient-V62RJhsZ.js} +3 -3
  4. package/dist/{ArweaveClient-DPeCeRMF.js.map → ArweaveClient-V62RJhsZ.js.map} +1 -1
  5. package/dist/{Db-Cvoi9q3N.js → Db-8N3-le9a.js} +4 -4
  6. package/dist/{Db-Cvoi9q3N.js.map → Db-8N3-le9a.js.map} +1 -1
  7. package/dist/{Db-DsFElL33.js → Db-DS2GBY6h.js} +133 -6
  8. package/dist/Db-DS2GBY6h.js.map +1 -0
  9. package/dist/{EasClient-B2N8bc3C.js → EasClient-D1eibg8b.js} +2 -2
  10. package/dist/{EasClient-B2N8bc3C.js.map → EasClient-D1eibg8b.js.map} +1 -1
  11. package/dist/{EasClient-D5Nn1WBF.js → EasClient-nOmY5meW.js} +2 -2
  12. package/dist/{EasClient-D5Nn1WBF.js.map → EasClient-nOmY5meW.js.map} +1 -1
  13. package/dist/{FileManager-Bk-JeMoA.js → FileManager-Cze8qmS1.js} +2 -2
  14. package/dist/{FileManager-Bk-JeMoA.js.map → FileManager-Cze8qmS1.js.map} +1 -1
  15. package/dist/{FileManager-Cqy_Lq46.js → FileManager-DSTAwkqw.js} +2 -2
  16. package/dist/{FileManager-Cqy_Lq46.js.map → FileManager-DSTAwkqw.js.map} +1 -1
  17. package/dist/{ModelProperty-CkQaEsBu.js → ModelProperty-ChevZoUy.js} +24 -24
  18. package/dist/{ModelProperty-CkQaEsBu.js.map → ModelProperty-ChevZoUy.js.map} +1 -1
  19. package/dist/{PathResolver-DF1QFI1d.js → PathResolver-3TuYA9yv.js} +2 -2
  20. package/dist/{PathResolver-DF1QFI1d.js.map → PathResolver-3TuYA9yv.js.map} +1 -1
  21. package/dist/{PathResolver-C3sdR5LL.js → PathResolver-C5gj9EU2.js} +2 -2
  22. package/dist/{PathResolver-C3sdR5LL.js.map → PathResolver-C5gj9EU2.js.map} +1 -1
  23. package/dist/{QueryClient-Ctgd0tDn.js → QueryClient-BGv6JOls.js} +2 -2
  24. package/dist/{QueryClient-Ctgd0tDn.js.map → QueryClient-BGv6JOls.js.map} +1 -1
  25. package/dist/{QueryClient-CnONLIkA.js → QueryClient-By2vdhIz.js} +2 -2
  26. package/dist/{QueryClient-CnONLIkA.js.map → QueryClient-By2vdhIz.js.map} +1 -1
  27. package/dist/{Schema-Bnim4hAF.js → Schema-BQ5W3aOW.js} +38 -38
  28. package/dist/{Schema-Bnim4hAF.js.map → Schema-BQ5W3aOW.js.map} +1 -1
  29. package/dist/{SchemaValidationService-DXxRk-9Q.js → SchemaValidationService-DQx83Cte.js} +2 -2
  30. package/dist/{SchemaValidationService-DXxRk-9Q.js.map → SchemaValidationService-DQx83Cte.js.map} +1 -1
  31. package/dist/{backfillMetadataPropertyIds-dzwzz4dA.js → backfillMetadataPropertyIds-CMsU83q9.js} +2 -2
  32. package/dist/{backfillMetadataPropertyIds-dzwzz4dA.js.map → backfillMetadataPropertyIds-CMsU83q9.js.map} +1 -1
  33. package/dist/cjs/{ModelProperty-C80601ai.js → ModelProperty-Cuj839nX.js} +17 -17
  34. package/dist/cjs/{ModelProperty-C80601ai.js.map → ModelProperty-Cuj839nX.js.map} +1 -1
  35. package/dist/cjs/{Schema-6BQKp7hO.js → Schema-TFe24NNG.js} +20 -20
  36. package/dist/cjs/{Schema-6BQKp7hO.js.map → Schema-TFe24NNG.js.map} +1 -1
  37. package/dist/cjs/{SchemaValidationService-BySF1P0v.js → SchemaValidationService-DVQrRpse.js} +2 -2
  38. package/dist/cjs/{SchemaValidationService-BySF1P0v.js.map → SchemaValidationService-DVQrRpse.js.map} +1 -1
  39. package/dist/cjs/{backfillMetadataPropertyIds-D9uzW5bW.js → backfillMetadataPropertyIds-BiXK4hT1.js} +2 -2
  40. package/dist/cjs/{backfillMetadataPropertyIds-D9uzW5bW.js.map → backfillMetadataPropertyIds-BiXK4hT1.js.map} +1 -1
  41. package/dist/cjs/{getItem-Dj49AjWB.js → getItem-FgLv9abh.js} +2 -2
  42. package/dist/cjs/{getItem-Dj49AjWB.js.map → getItem-FgLv9abh.js.map} +1 -1
  43. package/dist/cjs/{getPublishPayload-dR9co4rH.js → getPublishPayload-h_Rz8nVX.js} +527 -79
  44. package/dist/cjs/getPublishPayload-h_Rz8nVX.js.map +1 -0
  45. package/dist/cjs/{getPublishUploads-g61mgXaA.js → getPublishUploads-DdSwst2x.js} +14 -8
  46. package/dist/cjs/getPublishUploads-DdSwst2x.js.map +1 -0
  47. package/dist/cjs/{getSegmentedItemProperties-NFvOHlAi.js → getSegmentedItemProperties-Bu4P_MG8.js} +5 -4
  48. package/dist/cjs/getSegmentedItemProperties-Bu4P_MG8.js.map +1 -0
  49. package/dist/cjs/{index-ud9i9fpp.js → index-CKJeh6ic.js} +3 -3
  50. package/dist/cjs/index-CKJeh6ic.js.map +1 -0
  51. package/dist/cjs/{index-9O_Ji1kY.js → index-pyKmk9hA.js} +243 -60
  52. package/dist/cjs/index-pyKmk9hA.js.map +1 -0
  53. package/dist/cjs/{ownership-CyLRNReQ.js → ownership-gfm5thj7.js} +2 -2
  54. package/dist/cjs/{ownership-CyLRNReQ.js.map → ownership-gfm5thj7.js.map} +1 -1
  55. package/dist/cjs/{property-Hj-RhQVX.js → property-Dw0b_Sf8.js} +4 -4
  56. package/dist/cjs/{property-Hj-RhQVX.js.map → property-Dw0b_Sf8.js.map} +1 -1
  57. package/dist/db/drizzle/drizzle/0010_add_arweave_l1_finalize_jobs.sql +16 -0
  58. package/dist/db/drizzle/drizzle/meta/0010_snapshot.json +1182 -0
  59. package/dist/db/drizzle/drizzle/meta/_journal.json +7 -0
  60. package/dist/{getItem-ClK0UZqi.js → getItem-Bd9U9Yih.js} +2 -2
  61. package/dist/{getItem-ClK0UZqi.js.map → getItem-Bd9U9Yih.js.map} +1 -1
  62. package/dist/{getPublishPayload-CdfPTl8l.js → getPublishPayload-eJL7ktes.js} +530 -82
  63. package/dist/getPublishPayload-eJL7ktes.js.map +1 -0
  64. package/dist/{getPublishUploads-CGBky9q9.js → getPublishUploads-CKm5dsL6.js} +14 -8
  65. package/dist/getPublishUploads-CKm5dsL6.js.map +1 -0
  66. package/dist/{getSegmentedItemProperties-CJWdYH9W.js → getSegmentedItemProperties-B74LN_bz.js} +5 -4
  67. package/dist/getSegmentedItemProperties-B74LN_bz.js.map +1 -0
  68. package/dist/{index-C74KrwXN.js → index-BQv2k74p.js} +3 -2
  69. package/dist/index-BQv2k74p.js.map +1 -0
  70. package/dist/{index-uPXtq2cf.js → index-BvZCYMxA.js} +268 -75
  71. package/dist/index-BvZCYMxA.js.map +1 -0
  72. package/dist/{index-CgmWq1sF.js → index-BxfqPvtu.js} +3 -3
  73. package/dist/index-BxfqPvtu.js.map +1 -0
  74. package/dist/main.cjs +1 -1
  75. package/dist/main.js +155 -18
  76. package/dist/main.js.map +1 -1
  77. package/dist/node.js +10 -10
  78. package/dist/{ownership-QK5haR3-.js → ownership-tVhYQomL.js} +2 -2
  79. package/dist/{ownership-QK5haR3-.js.map → ownership-tVhYQomL.js.map} +1 -1
  80. package/dist/{property-Dt0U3UXJ.js → property-BOdk-wW1.js} +6 -6
  81. package/dist/{property-Dt0U3UXJ.js.map → property-BOdk-wW1.js.map} +1 -1
  82. package/dist/{queries-BUB-vUBm.js → queries-DBqVwEdv.js} +2 -2
  83. package/dist/{queries-BUB-vUBm.js.map → queries-DBqVwEdv.js.map} +1 -1
  84. package/dist/seedSchema/ArweaveL1FinalizeSchema.ts +28 -0
  85. package/dist/seedSchema/index.d.ts +3 -0
  86. package/dist/seedSchema/index.ts +1 -0
  87. package/dist/src/Item/Item.d.ts +12 -9
  88. package/dist/src/Item/Item.d.ts.map +1 -1
  89. package/dist/src/Item/queries.d.ts +3 -3
  90. package/dist/src/Item/service/actors/fetchDataFromEas.d.ts +1 -1
  91. package/dist/src/Item/service/actors/fetchDataFromEas.d.ts.map +1 -1
  92. package/dist/src/Item/service/actors/hydrateExistingItem.d.ts +1 -1
  93. package/dist/src/Item/service/actors/hydrateNewItem.d.ts +1 -1
  94. package/dist/src/Item/service/actors/initialize.d.ts +1 -1
  95. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +2 -2
  96. package/dist/src/Item/service/actors/reload.d.ts +2 -2
  97. package/dist/src/Item/service/actors/runPublish.d.ts +2 -2
  98. package/dist/src/Item/service/actors/saveDataToDb.d.ts +1 -1
  99. package/dist/src/Item/service/actors/waitForDb.d.ts +1 -1
  100. package/dist/src/Item/service/itemMachineSingle.d.ts +11 -11
  101. package/dist/src/ItemProperty/ItemProperty.d.ts +5 -5
  102. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +2 -2
  103. package/dist/src/ItemProperty/service/actors/initialize.d.ts +2 -2
  104. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +2 -2
  105. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts +2 -2
  106. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts +2 -2
  107. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +2 -2
  108. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +2 -2
  109. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +2 -2
  110. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +2 -2
  111. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
  112. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +2 -2
  113. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +1 -1
  114. package/dist/src/ItemProperty/service/propertyMachine.d.ts +14 -14
  115. package/dist/src/Model/Model.d.ts +2 -2
  116. package/dist/src/Model/service/actors/createModelProperties.d.ts +1 -1
  117. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +1 -1
  118. package/dist/src/Model/service/actors/validateModel.d.ts +1 -1
  119. package/dist/src/Model/service/modelMachine.d.ts +6 -6
  120. package/dist/src/ModelProperty/ModelProperty.d.ts +3 -3
  121. package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts +1 -1
  122. package/dist/src/ModelProperty/service/actors/saveToSchema.d.ts +1 -1
  123. package/dist/src/ModelProperty/service/actors/validateProperty.d.ts +1 -1
  124. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +7 -7
  125. package/dist/src/Schema/Schema.d.ts +1 -1
  126. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +1 -1
  127. package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts +1 -1
  128. package/dist/src/Schema/service/actors/validateSchema.d.ts +1 -1
  129. package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +1 -1
  130. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +1 -1
  131. package/dist/src/Schema/service/addModelsMachine.d.ts +1 -1
  132. package/dist/src/Schema/service/schemaMachine.d.ts +7 -7
  133. package/dist/src/Schema/service/validation/SchemaValidationService.d.ts +4 -4
  134. package/dist/src/browser/db/Db.d.ts +2 -2
  135. package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
  136. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  137. package/dist/src/browser/helpers/ArweaveClient.d.ts +2 -2
  138. package/dist/src/browser/helpers/EasClient.d.ts +1 -1
  139. package/dist/src/browser/helpers/FileManager.d.ts +1 -1
  140. package/dist/src/browser/helpers/PathResolver.d.ts +1 -1
  141. package/dist/src/browser/helpers/QueryClient.d.ts +2 -2
  142. package/dist/src/browser/seed.d.ts +1 -1
  143. package/dist/src/client/BaseClientManager.d.ts +1 -1
  144. package/dist/src/client/ClientManager.d.ts +41 -41
  145. package/dist/src/client/actors/addModelsToDb.d.ts +1 -1
  146. package/dist/src/client/actors/addModelsToStore.d.ts +1 -1
  147. package/dist/src/client/actors/dbInit.d.ts +1 -1
  148. package/dist/src/client/actors/fileSystemInit.d.ts +1 -1
  149. package/dist/src/client/actors/platformClassesInit.d.ts +1 -1
  150. package/dist/src/client/actors/processSchemaFiles.d.ts +1 -1
  151. package/dist/src/client/actors/saveConfig.d.ts +1 -1
  152. package/dist/src/client/clientManagerMachine.d.ts +11 -11
  153. package/dist/src/client/constants.d.ts +2 -2
  154. package/dist/src/db/Db/BaseDb.d.ts +1 -1
  155. package/dist/src/db/read/getItem.d.ts +1 -1
  156. package/dist/src/db/read/getItemData.d.ts +1 -1
  157. package/dist/src/db/read/getItemProperties.d.ts +1 -1
  158. package/dist/src/db/read/getItemProperty.d.ts +1 -1
  159. package/dist/src/db/read/getItems.d.ts +1 -1
  160. package/dist/src/db/read/getMetadata.d.ts +1 -1
  161. package/dist/src/db/read/getModels.d.ts +1 -1
  162. package/dist/src/db/read/getPropertyData.d.ts +2 -2
  163. package/dist/src/db/read/getPublishPayload.d.ts +12 -4
  164. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  165. package/dist/src/db/read/getPublishPendingDiff.d.ts +25 -0
  166. package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -0
  167. package/dist/src/db/read/getPublishUploads.d.ts +3 -3
  168. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  169. package/dist/src/db/read/getRelatedItemsForPublish.d.ts +1 -1
  170. package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +1 -1
  171. package/dist/src/db/read/getRelationValueData.d.ts +1 -1
  172. package/dist/src/db/read/getSeedData.d.ts +1 -1
  173. package/dist/src/db/read/getVersionData.d.ts +1 -1
  174. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +12 -0
  175. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -0
  176. package/dist/src/db/write/createMetadata.d.ts +2 -2
  177. package/dist/src/db/write/createNewItem.d.ts +1 -1
  178. package/dist/src/db/write/createSeeds.d.ts +1 -1
  179. package/dist/src/db/write/saveMetadata.d.ts +1 -1
  180. package/dist/src/db/write/updateItemPropertyValue.d.ts +1 -1
  181. package/dist/src/db/write/updateMetadata.d.ts +2 -2
  182. package/dist/src/eas.d.ts +12 -1
  183. package/dist/src/eas.d.ts.map +1 -1
  184. package/dist/src/events/files/download.d.ts +1 -1
  185. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  186. package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +1 -1
  187. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +46 -0
  188. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +1 -0
  189. package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +1 -1
  190. package/dist/src/helpers/EasClient/BaseEasClient.d.ts +1 -1
  191. package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +1 -1
  192. package/dist/src/helpers/addresses.d.ts +1 -1
  193. package/dist/src/helpers/constants.d.ts +2 -0
  194. package/dist/src/helpers/constants.d.ts.map +1 -1
  195. package/dist/src/helpers/db.d.ts +4 -4
  196. package/dist/src/helpers/easPropertyCanonical.d.ts +15 -0
  197. package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -0
  198. package/dist/src/helpers/file/fetchAll/index.d.ts +1 -1
  199. package/dist/src/helpers/getSchemaForItemProperty.d.ts +1 -1
  200. package/dist/src/helpers/getSegmentedItemProperties.d.ts +6 -6
  201. package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +1 -1
  202. package/dist/src/helpers/index.d.ts +4 -1
  203. package/dist/src/helpers/index.d.ts.map +1 -1
  204. package/dist/src/helpers/model.d.ts +1 -1
  205. package/dist/src/helpers/ownership.d.ts +1 -1
  206. package/dist/src/helpers/property/index.d.ts +1 -1
  207. package/dist/src/helpers/property.d.ts +1 -1
  208. package/dist/src/helpers/publishConfig.d.ts +1 -1
  209. package/dist/src/helpers/relationSeedRef.d.ts +8 -0
  210. package/dist/src/helpers/relationSeedRef.d.ts.map +1 -0
  211. package/dist/src/helpers/schema.d.ts +2 -2
  212. package/dist/src/helpers/updateSchema.d.ts +2 -2
  213. package/dist/src/imports/json.d.ts +1 -1
  214. package/dist/src/imports/markdown.d.ts +1 -1
  215. package/dist/src/index.d.ts +11 -4
  216. package/dist/src/index.d.ts.map +1 -1
  217. package/dist/src/interfaces/IItem.d.ts +5 -3
  218. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  219. package/dist/src/interfaces/IItemProperty.d.ts +3 -3
  220. package/dist/src/node/codegen/drizzle.d.ts +1 -1
  221. package/dist/src/node/db/Db.d.ts +3 -3
  222. package/dist/src/node/helpers/ArweaveClient.d.ts +2 -2
  223. package/dist/src/node/helpers/EasClient.d.ts +1 -1
  224. package/dist/src/node/helpers/FileManager.d.ts +1 -1
  225. package/dist/src/node/helpers/PathResolver.d.ts +1 -1
  226. package/dist/src/node/helpers/QueryClient.d.ts +2 -2
  227. package/dist/src/seedSchema/ArweaveL1FinalizeSchema.d.ts +233 -0
  228. package/dist/src/seedSchema/ArweaveL1FinalizeSchema.d.ts.map +1 -0
  229. package/dist/src/seedSchema/index.d.ts +1 -0
  230. package/dist/src/seedSchema/index.d.ts.map +1 -1
  231. package/dist/src/services/publish/actors/createPublishAttempt.d.ts +1 -1
  232. package/dist/src/services/publish/actors/preparePublishRequestData.d.ts +1 -1
  233. package/dist/src/services/publish/actors/upload.d.ts +1 -1
  234. package/dist/src/services/publish/actors/validateItemData.d.ts +1 -1
  235. package/dist/src/services/publish/publishMachine.d.ts +7 -7
  236. package/dist/src/services/write/writeProcessMachine.d.ts +1 -1
  237. package/dist/src/types/db.d.ts +1 -1
  238. package/dist/src/types/index.d.ts +1 -1
  239. package/dist/src/types/item.d.ts +6 -6
  240. package/dist/src/types/machines.d.ts +2 -2
  241. package/dist/src/types/model.d.ts +3 -3
  242. package/dist/src/types/property.d.ts +3 -3
  243. package/dist/src/types/publish.d.ts +1 -1
  244. package/dist/src/types/seedProtocol.d.ts +1 -1
  245. package/package.json +2 -2
  246. package/dist/Db-DsFElL33.js.map +0 -1
  247. package/dist/cjs/getPublishPayload-dR9co4rH.js.map +0 -1
  248. package/dist/cjs/getPublishUploads-g61mgXaA.js.map +0 -1
  249. package/dist/cjs/getSegmentedItemProperties-NFvOHlAi.js.map +0 -1
  250. package/dist/cjs/index-9O_Ji1kY.js.map +0 -1
  251. package/dist/cjs/index-ud9i9fpp.js.map +0 -1
  252. package/dist/getPublishPayload-CdfPTl8l.js.map +0 -1
  253. package/dist/getPublishUploads-CGBky9q9.js.map +0 -1
  254. package/dist/getSegmentedItemProperties-CJWdYH9W.js.map +0 -1
  255. package/dist/index-C74KrwXN.js.map +0 -1
  256. package/dist/index-CgmWq1sF.js.map +0 -1
  257. package/dist/index-uPXtq2cf.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { w as getEasSchemaUidForModel, Z as ZERO_BYTES32, o as BaseDb, x as models, y as properties, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, z as versions, A as modelPropertiesToObject, b as ModelPropertyDataTypes, q as getCorrectId, C as parseListPropertyValueFromStorage, E as INTERNAL_PROPERTY_NAMES, G as defaultAttestationData, H as INTERNAL_DATA_TYPES, K as toSnakeCase$1, O as getEasSchemaUidForSchemaDefinition, Q as getEasSchemaForItemProperty } from './index-uPXtq2cf.js';
1
+ import { Z as ZERO_BYTES32, x as getEasSchemaUidForModel, o as BaseDb, y as models, z as properties, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, A as versions, C as modelPropertiesToObject, b as ModelPropertyDataTypes, r as resolveSeedIdsFromRefString, q as normalizeRelationPropertyValue, E as parseListPropertyValueFromStorage, G as getCorrectId, H as INTERNAL_PROPERTY_NAMES, K as defaultAttestationData, O as INTERNAL_DATA_TYPES, Q as toSnakeCase$1, S as getEasSchemaUidForSchemaDefinition, U as getEasSchemaForItemProperty } from './index-BvZCYMxA.js';
2
2
  import { toSnakeCase } from 'drizzle-orm/casing';
3
3
  import pluralize from 'pluralize';
4
- import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-CJWdYH9W.js';
5
- import { getPropertySchema } from './property-Dt0U3UXJ.js';
4
+ import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-B74LN_bz.js';
5
+ import { getPropertySchema } from './property-BOdk-wW1.js';
6
6
  import { upperFirst, camelCase } from 'lodash-es';
7
7
  import { eq, and, desc } from 'drizzle-orm';
8
8
  import debug from 'debug';
@@ -24,6 +24,52 @@ debug('seedSdk:db:getPublishPayload');
24
24
  function addValidationError(ctx, message, field, code = 'publish_validation') {
25
25
  ctx.errors.push({ field: field ?? '', message, code });
26
26
  }
27
+ function isStorageTransactionPropertyName(name) {
28
+ return name === 'storageTransactionId' || name === 'storage_transaction_id';
29
+ }
30
+ /**
31
+ * Segmentation or naming variants can leave two rows for the same logical field; keep one
32
+ * resolved slot so processBasicProperties emits a single storage tx attestation.
33
+ */
34
+ function replaceStorageTransactionInBasicProperties(itemBasicProperties, resolved) {
35
+ const filtered = itemBasicProperties.filter((p) => !isStorageTransactionPropertyName(p.propertyName));
36
+ itemBasicProperties.length = 0;
37
+ itemBasicProperties.push(...filtered, resolved);
38
+ }
39
+ /** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */
40
+ function dedupeOneStorageTransactionPropertyInList(itemBasicProperties) {
41
+ const nonStorage = [];
42
+ const storage = [];
43
+ for (const p of itemBasicProperties) {
44
+ if (isStorageTransactionPropertyName(p.propertyName)) {
45
+ storage.push(p);
46
+ }
47
+ else {
48
+ nonStorage.push(p);
49
+ }
50
+ }
51
+ if (storage.length <= 1)
52
+ return;
53
+ itemBasicProperties.length = 0;
54
+ itemBasicProperties.push(...nonStorage, storage[storage.length - 1]);
55
+ }
56
+ /**
57
+ * Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.
58
+ * Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.
59
+ */
60
+ function mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedSeedLocalId, publishLocalId, propertySchemaUid) {
61
+ const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId);
62
+ if (!existing)
63
+ return false;
64
+ const pts = existing.propertiesToUpdate ?? [];
65
+ const already = pts.some((e) => e.publishLocalId === publishLocalId &&
66
+ String(e.propertySchemaUid ?? '').toLowerCase() ===
67
+ String(propertySchemaUid ?? '').toLowerCase());
68
+ if (!already) {
69
+ pts.push({ publishLocalId, propertySchemaUid });
70
+ }
71
+ return true;
72
+ }
27
73
  const getVersionUid = (item) => {
28
74
  const latestVersion = item.latestVersionUid;
29
75
  if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {
@@ -55,8 +101,8 @@ async function resolveVersionUid(seedLocalId, seedUid) {
55
101
  return uid;
56
102
  }
57
103
  try {
58
- const _mod_0 = await import('./index-uPXtq2cf.js');
59
- const _ns_0 = _mod_0.br;
104
+ const _mod_0 = await import('./index-BvZCYMxA.js');
105
+ const _ns_0 = _mod_0.bB;
60
106
  const { getItemVersionsFromEas } = _ns_0;
61
107
  const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] });
62
108
  const latest = attestations?.[0];
@@ -80,9 +126,20 @@ const getPropertyData = async (itemProperty, ctx) => {
80
126
  }
81
127
  let schemaUid = itemProperty.schemaUid;
82
128
  const ip = itemProperty;
83
- const nameForEas = ip.storagePropertyName && ip.storagePropertyName.length > 0
129
+ const propertyDefForName = itemProperty.propertyDef;
130
+ let nameForEas = ip.storagePropertyName && ip.storagePropertyName.length > 0
84
131
  ? ip.storagePropertyName
85
132
  : itemProperty.propertyName;
133
+ // Align List-of-relation EAS field name with processListProperty (authorIdentityIds for authors → Identity)
134
+ if (propertyDefForName?.dataType === ModelPropertyDataTypes.List &&
135
+ (propertyDefForName.ref || propertyDefForName.refModelName) &&
136
+ !(ip.storagePropertyName && ip.storagePropertyName.length > 0)) {
137
+ const ref = propertyDefForName.ref ?? propertyDefForName.refModelName;
138
+ if (ref) {
139
+ const singular = pluralize.singular(itemProperty.propertyName);
140
+ nameForEas = `${singular}${ref}Ids`;
141
+ }
142
+ }
86
143
  const propertyNameForSchema = toSnakeCase$1(nameForEas);
87
144
  const schemaDef = `${easDataType} ${propertyNameForSchema}`;
88
145
  if (!schemaUid) {
@@ -116,8 +173,8 @@ const ensurePropertyDefs = async (targetItem) => {
116
173
  schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName);
117
174
  if (!schema) {
118
175
  try {
119
- const _mod_1 = await import('./index-uPXtq2cf.js');
120
- const _ns_1 = _mod_1.bv;
176
+ const _mod_1 = await import('./index-BvZCYMxA.js');
177
+ const _ns_1 = _mod_1.bF;
121
178
  const { Model } = _ns_1;
122
179
  const normalizedModelName = upperFirst(camelCase(targetItem.modelName));
123
180
  let model = Model.getByName(normalizedModelName);
@@ -199,7 +256,8 @@ const getSchemaEncoder = async () => {
199
256
  }
200
257
  return SchemaEncoderClass;
201
258
  };
202
- const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx) => {
259
+ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx, buildOpts) => {
260
+ const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
203
261
  for (const basicProperty of itemBasicProperties) {
204
262
  // Skip SDK-internal properties (e.g. publisher) - never attest to EAS
205
263
  if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {
@@ -211,9 +269,15 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
211
269
  const isFileImageHtml = propertyDef?.dataType === ModelPropertyDataTypes.File ||
212
270
  propertyDef?.dataType === ModelPropertyDataTypes.Image ||
213
271
  propertyDef?.dataType === ModelPropertyDataTypes.Html;
214
- // File/Image/Html must use propertyValue (seed ID), not basicProperty.value which returns
215
- // renderValue (file content) for File—bytes32 can only hold 31 bytes.
216
- let value = isFileImageHtml && context
272
+ const isJsonStorage = propertyDef?.dataType === ModelPropertyDataTypes.Json ||
273
+ propertyDef?.refValueType === ModelPropertyDataTypes.Json;
274
+ const isRelation = propertyDef?.dataType === ModelPropertyDataTypes.Relation;
275
+ // storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).
276
+ const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName);
277
+ // File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).
278
+ // basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.
279
+ const preferPropertyValueForPublish = isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp;
280
+ let value = preferPropertyValueForPublish && context
217
281
  ? context.propertyValue
218
282
  : (basicProperty.value ??
219
283
  (context ? context.propertyValue : undefined));
@@ -221,9 +285,31 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
221
285
  if (!context) {
222
286
  continue;
223
287
  }
224
- if (!value || basicProperty.uid) {
288
+ // Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints
289
+ if (propertyDef?.dataType === ModelPropertyDataTypes.Relation ||
290
+ isFileImageHtml ||
291
+ isJsonStorage) {
292
+ const pv = context.propertyValue;
293
+ if (typeof value === 'object' || value == null) {
294
+ if (typeof pv === 'string' && pv.trim())
295
+ value = pv.trim();
296
+ else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string')
297
+ value = pv.seedLocalId;
298
+ }
299
+ }
300
+ if (!value) {
225
301
  continue;
226
302
  }
303
+ // Patch mode skips properties that already have an EAS uid. storageTransactionId must still
304
+ // attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.
305
+ if (basicProperty.uid && !forceFullSnapshot) {
306
+ const allowStorageTxAttestation = isStorageTransactionIdProp &&
307
+ typeof value === 'string' &&
308
+ value.trim() !== '';
309
+ if (!allowStorageTxAttestation) {
310
+ continue;
311
+ }
312
+ }
227
313
  const propertyData = await getPropertyData(basicProperty, ctx);
228
314
  if (!propertyData)
229
315
  continue;
@@ -255,7 +341,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
255
341
  }
256
342
  // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
257
343
  if (propertyDef?.validation) {
258
- const { SchemaValidationService } = await import('./SchemaValidationService-DXxRk-9Q.js');
344
+ const { SchemaValidationService } = await import('./SchemaValidationService-DQx83Cte.js');
259
345
  const validationService = new SchemaValidationService();
260
346
  const validationResult = validationService.validatePropertyValue(value, propertyDef.dataType, propertyDef.validation, propertyDef.refValueType);
261
347
  if (!validationResult.isValid && validationResult.errors.length > 0) {
@@ -264,19 +350,42 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
264
350
  continue;
265
351
  }
266
352
  }
353
+ /** Raw id per list slot (nanoid local id or 0x… uid) for resolvePublishPayloadValues after sequential publish */
354
+ let rawListIdsForResolve;
267
355
  if (schemaDef.startsWith('bytes32[]')) {
268
356
  const newValues = [];
357
+ const rawIds = [];
269
358
  const iterableValue = Array.isArray(value) ? value
270
359
  : value != null && typeof value[Symbol.iterator] === 'function' ? value
271
360
  : [];
272
361
  for (const seedId of iterableValue) {
273
- if (seedId.length !== 66 && !seedId.startsWith('0x')) {
274
- newValues.push(ethers.encodeBytes32String(seedId));
362
+ const idStr = typeof seedId === 'string'
363
+ ? seedId
364
+ : seedId &&
365
+ typeof seedId === 'object' &&
366
+ (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)
367
+ ? String(seedId.seedLocalId ??
368
+ seedId.seedUid ??
369
+ '')
370
+ : '';
371
+ if (!idStr)
372
+ continue;
373
+ const trimmed = idStr.trim();
374
+ if (!trimmed)
275
375
  continue;
376
+ rawIds.push(trimmed);
377
+ if (trimmed.length !== 66 && !trimmed.startsWith('0x')) {
378
+ newValues.push(ethers.encodeBytes32String(trimmed));
379
+ }
380
+ else {
381
+ newValues.push(trimmed);
276
382
  }
277
- newValues.push(seedId);
278
383
  }
279
384
  value = newValues;
385
+ const needsUidResolve = rawIds.some((id) => id.length !== 66 || !id.startsWith('0x'));
386
+ if (needsUidResolve && rawIds.length > 0) {
387
+ rawListIdsForResolve = rawIds;
388
+ }
280
389
  }
281
390
  // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds
282
391
  if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {
@@ -301,7 +410,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
301
410
  continue;
302
411
  }
303
412
  // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)
304
- const refUid = basicProperty.propertyName === 'storageTransactionId'
413
+ const refUid = isStorageTransactionIdProp
305
414
  ? itemPublishData.versionUid
306
415
  : defaultAttestationData.refUID;
307
416
  const attestationEntry = {
@@ -315,19 +424,31 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
315
424
  ],
316
425
  };
317
426
  // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues
318
- if (typeof value === 'string' &&
319
- value.length === 10 &&
427
+ const looksLikeLocalSeedRef = typeof value === 'string' &&
428
+ !value.startsWith('0x') &&
429
+ value.length !== 66 &&
430
+ /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim());
431
+ if (looksLikeLocalSeedRef &&
320
432
  (easDataType === 'bytes32' || easDataType === 'string')) {
321
433
  attestationEntry._propertyName = basicProperty.propertyName;
434
+ attestationEntry._propertyNameForSchema = propertyNameForSchema;
322
435
  attestationEntry._schemaDef = schemaDef;
323
- attestationEntry._unresolvedValue = value;
436
+ attestationEntry._unresolvedValue = value.trim();
324
437
  attestationEntry._easDataType = easDataType;
325
438
  }
439
+ if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {
440
+ attestationEntry._propertyName = basicProperty.propertyName;
441
+ attestationEntry._propertyNameForSchema = propertyNameForSchema;
442
+ attestationEntry._schemaDef = schemaDef;
443
+ attestationEntry._easDataType = 'bytes32[]';
444
+ attestationEntry._rawListIdsForResolve = rawListIdsForResolve;
445
+ }
326
446
  itemPublishData.listOfAttestations.push(attestationEntry);
327
447
  }
328
448
  return itemPublishData;
329
449
  };
330
- const processRelationOrImageProperty = async (relationOrImageProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx) => {
450
+ const processRelationOrImageProperty = async (relationOrImageProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx, buildOpts) => {
451
+ const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
331
452
  let relationOrImageSchemaUid = relationOrImageProperty.schemaUid;
332
453
  if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {
333
454
  const propertyData = await getPropertyData(relationOrImageProperty, ctx);
@@ -356,9 +477,9 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
356
477
  relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Image ||
357
478
  relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Html ||
358
479
  relationOrImageProperty.propertyDef?.refValueType === ModelPropertyDataTypes.Json));
359
- if (!value && isStorageSeed && (context.seedLocalId || context.seedUid)) {
360
- const _mod_2 = await import('./index-uPXtq2cf.js');
361
- const _ns_2 = _mod_2.bs;
480
+ if (isStorageSeed && (context.seedLocalId || context.seedUid)) {
481
+ const _mod_2 = await import('./index-BvZCYMxA.js');
482
+ const _ns_2 = _mod_2.bC;
362
483
  const { getPropertyData: getPropertyDataFromDb } = _ns_2;
363
484
  const metaRow = await getPropertyDataFromDb({
364
485
  propertyName: relationOrImageProperty.propertyName,
@@ -366,8 +487,15 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
366
487
  seedUid: context.seedUid,
367
488
  });
368
489
  const fromMeta = metaRow?.propertyValue;
369
- if (fromMeta && typeof fromMeta === 'string' && fromMeta.trim() !== '') {
370
- value = fromMeta;
490
+ if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {
491
+ const idsCtx = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '');
492
+ const idsDb = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(fromMeta) ?? '');
493
+ if (!value) {
494
+ value = fromMeta;
495
+ }
496
+ else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {
497
+ value = fromMeta;
498
+ }
371
499
  }
372
500
  }
373
501
  const propertyDef = relationOrImageProperty.propertyDef;
@@ -421,11 +549,15 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
421
549
  `A value pointing to a valid ${refLabel} item is required to publish.`, relationOrImageProperty.propertyName);
422
550
  return multiPublishPayload;
423
551
  }
424
- if (!value || relationOrImageProperty.uid) {
552
+ if (!value) {
553
+ return multiPublishPayload;
554
+ }
555
+ if (relationOrImageProperty.uid && !forceFullSnapshot) {
425
556
  return multiPublishPayload;
426
557
  }
427
- const { localId: seedLocalId, uid: seedUid } = getCorrectId(value);
428
- // Value is not a valid seed reference (10-char localId or 66-char uid)
558
+ const normalizedRef = normalizeRelationPropertyValue(value);
559
+ const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizedRef ?? '');
560
+ // Value is not a valid seed reference (local id or 0x uid)
429
561
  if (!seedLocalId && !seedUid) {
430
562
  if (isRequired) {
431
563
  addValidationError(ctx, `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +
@@ -434,7 +566,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
434
566
  return multiPublishPayload;
435
567
  }
436
568
  // Use dynamic import to break circular dependency
437
- const getItemMod = await import('./getItem-ClK0UZqi.js');
569
+ const getItemMod = await import('./getItem-Bd9U9Yih.js');
438
570
  const { getItem } = getItemMod;
439
571
  const relatedItem = await getItem({
440
572
  seedLocalId,
@@ -450,7 +582,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
450
582
  return multiPublishPayload;
451
583
  }
452
584
  // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent
453
- if (relatedItem.seedUid) {
585
+ if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
454
586
  return multiPublishPayload;
455
587
  }
456
588
  const versionUid = getVersionUid(relatedItem);
@@ -477,6 +609,9 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
477
609
  addValidationError(ctx, `Schema UID not found for model: ${modelName}`, relationOrImageProperty.propertyName);
478
610
  return multiPublishPayload;
479
611
  }
612
+ if (mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, originalSeedLocalId, relationOrImageSchemaUid)) {
613
+ return multiPublishPayload;
614
+ }
480
615
  let publishPayload = {
481
616
  localId: relatedItem.seedLocalId,
482
617
  seedIsRevocable: true,
@@ -494,21 +629,40 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
494
629
  };
495
630
  await ensurePropertyDefs(relatedItem);
496
631
  const { itemBasicProperties, itemUploadProperties } = await getSegmentedItemProperties(relatedItem);
497
- if (itemUploadProperties.length === 1) {
498
- const uploadProperty = itemUploadProperties[0];
499
- const itemProperty = uploadProperty.itemProperty;
500
- const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === relatedItem.seedLocalId);
632
+ const relatedStorageUpload = resolveStorageTransactionUploadSlot(relatedItem, itemUploadProperties);
633
+ if (relatedStorageUpload) {
634
+ const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, relatedItem.seedLocalId);
501
635
  if (transactionData) {
502
- itemProperty.value = transactionData.txId;
503
- await itemProperty.save();
504
- itemBasicProperties.push(itemProperty);
636
+ const itemProperty = relatedStorageUpload.itemProperty;
637
+ // Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it
638
+ // uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.
639
+ itemProperty.getService().send({
640
+ type: 'updateContext',
641
+ propertyValue: transactionData.txId,
642
+ renderValue: transactionData.txId,
643
+ });
644
+ replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
505
645
  }
506
646
  }
507
- publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx);
647
+ for (const p of itemBasicProperties) {
648
+ if (isStorageTransactionPropertyName(p.propertyName) &&
649
+ !p.propertyDef &&
650
+ relatedItem.modelName) {
651
+ const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId');
652
+ if (schema) {
653
+ p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
654
+ }
655
+ }
656
+ }
657
+ dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
658
+ publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
659
+ forceFullSnapshot,
660
+ });
508
661
  multiPublishPayload.push(publishPayload);
509
662
  return multiPublishPayload;
510
663
  };
511
- const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId, ctx) => {
664
+ const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId, ctx, buildOpts) => {
665
+ const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
512
666
  // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties
513
667
  if (!listProperty.propertyDef?.ref) {
514
668
  addValidationError(ctx, `processListProperty requires ref (list of relations). List property "${listProperty.propertyName}" has no ref. List-of-primitives should be in itemBasicProperties.`, listProperty.propertyName);
@@ -531,7 +685,10 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
531
685
  return multiPublishPayload;
532
686
  }
533
687
  let value = context.propertyValue;
534
- if (!value || listProperty.uid) {
688
+ if (!value) {
689
+ return multiPublishPayload;
690
+ }
691
+ if (listProperty.uid && !forceFullSnapshot) {
535
692
  return multiPublishPayload;
536
693
  }
537
694
  const singularPropertyName = pluralize.singular(listProperty.propertyName);
@@ -556,7 +713,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
556
713
  if (!seedLocalId && !seedUid)
557
714
  continue;
558
715
  // Use dynamic import to break circular dependency
559
- const getItemMod = await import('./getItem-ClK0UZqi.js');
716
+ const getItemMod = await import('./getItem-Bd9U9Yih.js');
560
717
  const { getItem } = getItemMod;
561
718
  const relatedItem = await getItem({
562
719
  seedLocalId,
@@ -566,7 +723,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
566
723
  console.error(`No related item found for list property: ${listProperty.propertyName}`);
567
724
  continue;
568
725
  }
569
- if (relatedItem.seedUid) {
726
+ if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
570
727
  continue;
571
728
  }
572
729
  const versionUid = getVersionUid(relatedItem);
@@ -593,6 +750,9 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
593
750
  addValidationError(ctx, `Schema UID not found for model: ${modelName}`, listProperty.propertyName);
594
751
  continue;
595
752
  }
753
+ if (mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, originalSeedLocalId, listPropertySchemaUid)) {
754
+ continue;
755
+ }
596
756
  let publishPayload = {
597
757
  localId: relatedItem.seedLocalId,
598
758
  seedIsRevocable: true,
@@ -610,11 +770,141 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
610
770
  };
611
771
  await ensurePropertyDefs(relatedItem);
612
772
  const { itemBasicProperties } = await getSegmentedItemProperties(relatedItem);
613
- publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx);
773
+ dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
774
+ publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
775
+ forceFullSnapshot,
776
+ });
614
777
  multiPublishPayload.push(publishPayload);
615
778
  }
616
779
  return multiPublishPayload;
617
780
  };
781
+ /**
782
+ * Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so
783
+ * duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.
784
+ */
785
+ function attestationPayloadDedupeKey(att) {
786
+ const schema = String(att.schema ?? '').toLowerCase();
787
+ const dataArr = att.data;
788
+ const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined;
789
+ const dataHex = d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0
790
+ ? String(d0.data ?? '').toLowerCase()
791
+ : '';
792
+ return `${schema}:${dataHex}`;
793
+ }
794
+ /**
795
+ * Collapse duplicate rows in listOfAttestations (same schema + encoded payload).
796
+ */
797
+ function dedupeListOfAttestationsInEachPayload(payload) {
798
+ for (const p of payload) {
799
+ const list = p.listOfAttestations ?? [];
800
+ if (list.length <= 1)
801
+ continue;
802
+ const seen = new Set();
803
+ const out = [];
804
+ for (const a of list) {
805
+ const k = attestationPayloadDedupeKey(a);
806
+ if (seen.has(k))
807
+ continue;
808
+ seen.add(k);
809
+ out.push(a);
810
+ }
811
+ p.listOfAttestations = out;
812
+ }
813
+ return payload;
814
+ }
815
+ /**
816
+ * Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).
817
+ * Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.
818
+ */
819
+ function dedupeMultiPublishPayloadByLocalId(payload) {
820
+ const map = new Map();
821
+ const order = [];
822
+ for (const p of payload) {
823
+ const id = p.localId;
824
+ const existing = map.get(id);
825
+ if (!existing) {
826
+ map.set(id, p);
827
+ order.push(id);
828
+ continue;
829
+ }
830
+ const ptu = [...(existing.propertiesToUpdate ?? [])];
831
+ for (const u of p.propertiesToUpdate ?? []) {
832
+ if (!ptu.some((e) => e.publishLocalId === u.publishLocalId &&
833
+ String(e.propertySchemaUid ?? '').toLowerCase() ===
834
+ String(u.propertySchemaUid ?? '').toLowerCase())) {
835
+ ptu.push(u);
836
+ }
837
+ }
838
+ existing.propertiesToUpdate = ptu;
839
+ const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)));
840
+ const merged = [...(existing.listOfAttestations ?? [])];
841
+ for (const a of p.listOfAttestations ?? []) {
842
+ const k = attestationPayloadDedupeKey(a);
843
+ if (seenKeys.has(k))
844
+ continue;
845
+ seenKeys.add(k);
846
+ merged.push(a);
847
+ }
848
+ existing.listOfAttestations = merged;
849
+ }
850
+ return order.map((id) => map.get(id)).filter(Boolean);
851
+ }
852
+ /**
853
+ * Child File/Image items may keep storageTransactionId only on the item machine's
854
+ * propertyInstances map; allProperties / item.properties can omit it during publish.
855
+ */
856
+ function getStorageTransactionPropertyFromItemInstances(item) {
857
+ try {
858
+ const svc = item.getService?.();
859
+ if (!svc)
860
+ return undefined;
861
+ const snap = svc.getSnapshot();
862
+ const instances = snap.context?.propertyInstances;
863
+ if (!instances || !(instances instanceof Map))
864
+ return undefined;
865
+ const direct = instances.get('storageTransactionId') ?? instances.get('storage_transaction_id');
866
+ if (direct)
867
+ return direct;
868
+ for (const [, p] of instances) {
869
+ if (p && isStorageTransactionPropertyName(p.propertyName))
870
+ return p;
871
+ }
872
+ }
873
+ catch {
874
+ return undefined;
875
+ }
876
+ return undefined;
877
+ }
878
+ /**
879
+ * Resolve storageTransactionId (+ ItemStorage children) for publish.
880
+ * getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never
881
+ * hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while
882
+ * getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.
883
+ */
884
+ function resolveStorageTransactionUploadSlot(item, itemUploadProperties) {
885
+ const named = itemUploadProperties.find((u) => isStorageTransactionPropertyName(u.itemProperty.propertyName));
886
+ if (named)
887
+ return named;
888
+ if (itemUploadProperties.length === 1)
889
+ return itemUploadProperties[0];
890
+ const all = item.allProperties;
891
+ const fromInstances = getStorageTransactionPropertyFromItemInstances(item);
892
+ const storagePropEarly = all?.['storageTransactionId'] ??
893
+ all?.['storage_transaction_id'] ??
894
+ Object.values(all ?? {}).find((p) => !!p && isStorageTransactionPropertyName(p.propertyName)) ??
895
+ item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName));
896
+ const storageProp = storagePropEarly ?? fromInstances;
897
+ if (!storageProp)
898
+ return undefined;
899
+ const childProps = item.properties?.filter((p) => p.propertyDef &&
900
+ p.propertyDef.storageType === 'ItemStorage') ?? [];
901
+ return { itemProperty: storageProp, childProperties: childProps };
902
+ }
903
+ function findUploadedTxForSeedLocalId(uploadedTransactions, seedLocalId) {
904
+ const t = seedLocalId.trim();
905
+ return (uploadedTransactions.find((u) => u.seedLocalId === t) ??
906
+ uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t));
907
+ }
618
908
  /** Error thrown when publish validation fails. Includes all validation errors for user to fix. */
619
909
  class PublishValidationFailedError extends Error {
620
910
  constructor(message, validationErrors) {
@@ -623,8 +913,13 @@ class PublishValidationFailedError extends Error {
623
913
  this.name = 'PublishValidationFailedError';
624
914
  }
625
915
  }
626
- const getPublishPayload = async (item, uploadedTransactions) => {
916
+ const getPublishPayload = async (item, uploadedTransactions, options) => {
627
917
  const validationCtx = { errors: [] };
918
+ const publishMode = options?.publishMode ?? 'patch';
919
+ const forceFullSnapshot = publishMode === 'new_version';
920
+ if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === ZERO_BYTES32)) {
921
+ addValidationError(validationCtx, 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).', 'seedUid', 'publish_new_version_requires_seed');
922
+ }
628
923
  let multiPublishPayload = [];
629
924
  // Each PublishPayload is generated from a Seed that needs publishing
630
925
  // First we need to determine all Seeds to publish
@@ -645,6 +940,9 @@ const getPublishPayload = async (item, uploadedTransactions) => {
645
940
  if (versionUid === ZERO_BYTES32 && item.seedUid && item.seedUid !== ZERO_BYTES32) {
646
941
  versionUid = await resolveVersionUid(item.seedLocalId, item.seedUid);
647
942
  }
943
+ if (forceFullSnapshot && item.seedUid && item.seedUid !== ZERO_BYTES32) {
944
+ versionUid = ZERO_BYTES32;
945
+ }
648
946
  let itemPublishData = {
649
947
  localId: item.seedLocalId,
650
948
  seedUid: item.seedUid || ZERO_BYTES32,
@@ -691,33 +989,55 @@ const getPublishPayload = async (item, uploadedTransactions) => {
691
989
  `A value pointing to a valid ${refModel} item is required to publish.`, relProp.propertyName);
692
990
  }
693
991
  }
694
- if (itemUploadProperties.length === 1) {
695
- const uploadProperty = itemUploadProperties[0];
696
- const itemProperty = uploadProperty.itemProperty;
697
- const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === item.seedLocalId);
992
+ const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties);
993
+ if (rootStorageUpload) {
994
+ const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId);
698
995
  if (transactionData) {
699
- itemProperty.value = transactionData.txId;
700
- await itemProperty.save();
701
- itemBasicProperties.push(itemProperty);
996
+ const itemProperty = rootStorageUpload.itemProperty;
997
+ itemProperty.getService().send({
998
+ type: 'updateContext',
999
+ propertyValue: transactionData.txId,
1000
+ renderValue: transactionData.txId,
1001
+ });
1002
+ replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
702
1003
  }
703
1004
  }
704
1005
  for (const relationProperty of relationAndImageProperties) {
705
- multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx);
1006
+ multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
706
1007
  itemBasicProperties.push(relationProperty);
707
1008
  }
708
1009
  for (const listProperty of itemListProperties) {
709
- multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId, validationCtx);
1010
+ multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId, validationCtx, { forceFullSnapshot });
710
1011
  itemBasicProperties.push(listProperty);
711
1012
  }
712
- itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData, validationCtx);
1013
+ for (const p of itemBasicProperties) {
1014
+ if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {
1015
+ const schema = await getPropertySchema(item.modelName, 'storageTransactionId');
1016
+ if (schema) {
1017
+ p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
1018
+ }
1019
+ }
1020
+ }
1021
+ dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
1022
+ itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData, validationCtx, { forceFullSnapshot });
713
1023
  multiPublishPayload.push(itemPublishData);
714
1024
  // Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),
715
1025
  // A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's
716
1026
  // attestation before B is sent to EAS.
1027
+ multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload);
717
1028
  multiPublishPayload = orderPayloadByDependencies(multiPublishPayload);
718
1029
  // Ensure attestations referenced in propertiesToUpdate have at least one data element.
719
1030
  // The contract writes the seed UID into data[0].data; empty data causes Panic 50.
720
1031
  multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload);
1032
+ multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload);
1033
+ if (publishMode === 'new_version') {
1034
+ const rootPayload = multiPublishPayload.find((p) => p.localId === item.seedLocalId);
1035
+ const listLen = rootPayload?.listOfAttestations?.length ?? 0;
1036
+ if (!rootPayload || listLen === 0) {
1037
+ addValidationError(validationCtx, 'Publishing as a new version requires at least one property attestation for the item. ' +
1038
+ 'Ensure required fields have values and that publishable properties are present.', 'listOfAttestations', 'publish_new_version_empty_snapshot');
1039
+ }
1040
+ }
721
1041
  if (validationCtx.errors.length > 0) {
722
1042
  const combinedMessage = validationCtx.errors.map((e) => e.message).join('\n');
723
1043
  throw new PublishValidationFailedError(`Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\n${combinedMessage}`, validationCtx.errors);
@@ -729,9 +1049,9 @@ const getPublishPayload = async (item, uploadedTransactions) => {
729
1049
  * Use in the checking step to fail fast before creating transactions.
730
1050
  * Pass empty array for uploadedTransactions when validating before Arweave upload.
731
1051
  */
732
- const validateItemForPublish = async (item, uploadedTransactions = []) => {
1052
+ const validateItemForPublish = async (item, uploadedTransactions = [], options) => {
733
1053
  try {
734
- await getPublishPayload(item, uploadedTransactions);
1054
+ await getPublishPayload(item, uploadedTransactions, options);
735
1055
  return { isValid: true, errors: [] };
736
1056
  }
737
1057
  catch (err) {
@@ -786,37 +1106,110 @@ function ensurePropertiesToUpdateAttestationsHaveData(payload) {
786
1106
  return payload;
787
1107
  }
788
1108
  /**
789
- * Topological sort: when request A has propertiesToUpdate with publishLocalId B,
790
- * A (the updater) must appear before B (the updatee). The contract injects A's seedUid
791
- * into B's attestation before B is sent to EAS; if B is processed first, B's attestation
792
- * goes out with wrong data (string instead of bytes32).
1109
+ * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.
1110
+ */
1111
+ function collectAttestationLocalRefIds(req, allLocalIds) {
1112
+ const refs = [];
1113
+ for (const a of req.listOfAttestations ?? []) {
1114
+ const att = a;
1115
+ if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {
1116
+ refs.push(att._unresolvedValue);
1117
+ }
1118
+ if (Array.isArray(att._rawListIdsForResolve)) {
1119
+ for (const id of att._rawListIdsForResolve) {
1120
+ const t = id != null ? String(id).trim() : '';
1121
+ if (t && allLocalIds.has(t))
1122
+ refs.push(t);
1123
+ }
1124
+ }
1125
+ }
1126
+ return refs;
1127
+ }
1128
+ /**
1129
+ * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.
1130
+ * - propertiesToUpdate: updater before updatee (contract injection).
1131
+ * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.
1132
+ * The previous DFS visit could order [Post, Image] when Post appeared first in the input array,
1133
+ * so resolvedUids was empty when Post was published and attestations kept local ids.
793
1134
  */
794
1135
  function orderPayloadByDependencies(payload) {
1136
+ if (payload.length <= 1)
1137
+ return payload;
795
1138
  const byLocalId = new Map();
796
- for (const p of payload) {
1139
+ const allIds = new Set();
1140
+ const indexOrder = new Map();
1141
+ for (let i = 0; i < payload.length; i++) {
1142
+ const p = payload[i];
797
1143
  byLocalId.set(p.localId, p);
1144
+ allIds.add(p.localId);
1145
+ indexOrder.set(p.localId, i);
798
1146
  }
799
- const visited = new Set();
800
- const result = [];
801
- const visit = (localId) => {
802
- if (visited.has(localId))
1147
+ const indegree = new Map();
1148
+ for (const id of allIds)
1149
+ indegree.set(id, 0);
1150
+ const adj = new Map();
1151
+ const addEdge = (from, to) => {
1152
+ if (from === to || !allIds.has(from) || !allIds.has(to))
803
1153
  return;
804
- visited.add(localId);
805
- const p = byLocalId.get(localId);
806
- if (!p)
1154
+ if (!adj.has(from))
1155
+ adj.set(from, new Set());
1156
+ const set = adj.get(from);
1157
+ if (set.has(to))
807
1158
  return;
808
- result.push(p);
1159
+ set.add(to);
1160
+ indegree.set(to, (indegree.get(to) ?? 0) + 1);
1161
+ };
1162
+ for (const p of payload) {
809
1163
  for (const u of p.propertiesToUpdate ?? []) {
810
1164
  const targetId = u.publishLocalId;
811
- if (targetId && targetId !== localId)
812
- visit(targetId);
1165
+ if (targetId && targetId !== p.localId)
1166
+ addEdge(p.localId, targetId);
1167
+ }
1168
+ for (const refId of collectAttestationLocalRefIds(p, allIds)) {
1169
+ addEdge(refId, p.localId);
1170
+ }
1171
+ }
1172
+ const zero = [];
1173
+ for (const id of allIds) {
1174
+ if ((indegree.get(id) ?? 0) === 0)
1175
+ zero.push(id);
1176
+ }
1177
+ zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
1178
+ const result = [];
1179
+ const queue = zero;
1180
+ while (queue.length > 0) {
1181
+ const id = queue.shift();
1182
+ const p = byLocalId.get(id);
1183
+ if (p)
1184
+ result.push(p);
1185
+ for (const to of adj.get(id) ?? []) {
1186
+ const next = (indegree.get(to) ?? 0) - 1;
1187
+ indegree.set(to, next);
1188
+ if (next === 0) {
1189
+ queue.push(to);
1190
+ queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
1191
+ }
1192
+ }
1193
+ }
1194
+ if (result.length !== payload.length) {
1195
+ const seen = new Set(result.map((r) => r.localId));
1196
+ for (const p of payload) {
1197
+ if (!seen.has(p.localId))
1198
+ result.push(p);
813
1199
  }
814
- };
815
- for (const p of payload) {
816
- visit(p.localId);
817
1200
  }
818
1201
  return result;
819
1202
  }
1203
+ /** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */
1204
+ function padUidForBytes32Schema(uid) {
1205
+ const t = uid.trim();
1206
+ if (!t.startsWith('0x'))
1207
+ return uid;
1208
+ const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '');
1209
+ if (hex.length === 0)
1210
+ return uid;
1211
+ return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase();
1212
+ }
820
1213
  /**
821
1214
  * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.
822
1215
  * Call after each payload is published, passing the returned attestation uid for that seed's localId.
@@ -832,15 +1225,70 @@ const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
832
1225
  const updatedAttestations = [];
833
1226
  for (const attestation of payload.listOfAttestations) {
834
1227
  const entry = attestation;
1228
+ const rawList = entry._rawListIdsForResolve;
1229
+ if (rawList &&
1230
+ rawList.length > 0 &&
1231
+ entry._schemaDef &&
1232
+ (entry._propertyNameForSchema || entry._propertyName)) {
1233
+ const fieldName = entry._propertyNameForSchema ?? toSnakeCase$1(entry._propertyName);
1234
+ const resolvedValues = [];
1235
+ let allSlotsResolved = true;
1236
+ for (const id of rawList) {
1237
+ const trimmed = id.trim();
1238
+ if (trimmed.length === 66 && trimmed.startsWith('0x')) {
1239
+ resolvedValues.push(padUidForBytes32Schema(trimmed));
1240
+ continue;
1241
+ }
1242
+ const r = resolvedUids[trimmed];
1243
+ if (r) {
1244
+ resolvedValues.push(padUidForBytes32Schema(r));
1245
+ continue;
1246
+ }
1247
+ allSlotsResolved = false;
1248
+ break;
1249
+ }
1250
+ // Do not encode or clear hints until every slot has a real uid — otherwise sequential
1251
+ // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.
1252
+ if (!allSlotsResolved) {
1253
+ updatedAttestations.push({
1254
+ ...entry,
1255
+ data: Array.isArray(entry.data) ? entry.data : [entry.data],
1256
+ });
1257
+ continue;
1258
+ }
1259
+ const dataEncoder = new SchemaEncoder(entry._schemaDef);
1260
+ const encodedData = dataEncoder.encodeData([
1261
+ {
1262
+ name: fieldName,
1263
+ type: 'bytes32[]',
1264
+ value: resolvedValues,
1265
+ },
1266
+ ]);
1267
+ const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
1268
+ updatedAttestations.push({
1269
+ ...entry,
1270
+ data: [
1271
+ {
1272
+ ...baseData,
1273
+ data: encodedData,
1274
+ },
1275
+ ],
1276
+ _rawListIdsForResolve: undefined,
1277
+ _easDataType: undefined,
1278
+ });
1279
+ continue;
1280
+ }
835
1281
  const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue];
836
- if (resolvedUid && entry._schemaDef && entry._propertyName) {
837
- const propertyNameForSchema = toSnakeCase$1(entry._propertyName);
1282
+ const easType = entry._easDataType || 'bytes32';
1283
+ if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {
1284
+ const fieldName = entry._propertyNameForSchema ?? toSnakeCase$1(entry._propertyName);
1285
+ const valueForEncode = easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid;
838
1286
  const dataEncoder = new SchemaEncoder(entry._schemaDef);
839
1287
  const encodedData = dataEncoder.encodeData([
840
1288
  {
841
- name: propertyNameForSchema,
842
- type: entry._easDataType || 'bytes32',
843
- value: resolvedUid,
1289
+ name: fieldName,
1290
+ type: easType,
1291
+ value: valueForEncode,
844
1292
  },
845
1293
  ]);
846
1294
  const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
@@ -872,4 +1320,4 @@ const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
872
1320
  };
873
1321
 
874
1322
  export { PublishValidationFailedError, getPublishPayload, resolvePublishPayloadValues, validateItemForPublish };
875
- //# sourceMappingURL=getPublishPayload-CdfPTl8l.js.map
1323
+ //# sourceMappingURL=getPublishPayload-eJL7ktes.js.map