@seedprotocol/sdk 0.7.9-next.1189.g5e63267 → 0.7.9

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 (581) hide show
  1. package/dist/BaseFileManager-BAlySv8w.js +650 -0
  2. package/dist/BaseFileManager-BAlySv8w.js.map +1 -0
  3. package/dist/{Item-CG5IhPtL.js → Item-Bf4kWKpH.js} +5576 -6649
  4. package/dist/Item-Bf4kWKpH.js.map +1 -0
  5. package/dist/{ModelProperty-DDD47KVm.js → ModelProperty-BlaEgb_U.js} +345 -709
  6. package/dist/ModelProperty-BlaEgb_U.js.map +1 -0
  7. package/dist/Schema-J_1f6p0c.js +1456 -0
  8. package/dist/Schema-J_1f6p0c.js.map +1 -0
  9. package/dist/{SchemaValidationService-CZzKNL04.js → SchemaValidationService-CnmKyzR-.js} +6 -9
  10. package/dist/{SchemaValidationService-CZzKNL04.js.map → SchemaValidationService-CnmKyzR-.js.map} +1 -1
  11. package/dist/{configurePlatform-Dukm2QwO.js → configurePlatform-CiOJ1R3q.js} +3 -12
  12. package/dist/configurePlatform-CiOJ1R3q.js.map +1 -0
  13. package/dist/db/drizzle/0026_add_content_hash_to_schemas.sql +1 -0
  14. package/dist/db/drizzle/0027_link_metadata_property_ids.sql +74 -0
  15. package/dist/db/drizzle/0028_add_definition_to_properties.sql +17 -0
  16. package/dist/db/drizzle/0029_dedupe_chain_uids_add_unique_indexes.sql +120 -0
  17. package/dist/db/drizzle/meta/0026_snapshot.json +1659 -0
  18. package/dist/db/drizzle/meta/0027_snapshot.json +1659 -0
  19. package/dist/db/drizzle/meta/0028_snapshot.json +1666 -0
  20. package/dist/db/drizzle/meta/0029_snapshot.json +1691 -0
  21. package/dist/db/drizzle/meta/_journal.json +29 -1
  22. package/dist/{detachRowsBeforeDelete-Di1enVUF.js → detachRowsBeforeDelete-sEaUwlOU.js} +2 -13
  23. package/dist/{detachRowsBeforeDelete-Di1enVUF.js.map → detachRowsBeforeDelete-sEaUwlOU.js.map} +1 -1
  24. package/dist/dist/{index-rOTW-2QZ.d.ts → BaseFileManager-BAlySv8w.d.ts} +1407 -2700
  25. package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +1 -0
  26. package/dist/dist/{configurePlatform-Dukm2QwO.d.ts → configurePlatform-CiOJ1R3q.d.ts} +1 -1
  27. package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +1 -0
  28. package/dist/dist/{index-DxHpPNfn.d.ts → index-D0V-mjCV.d.ts} +39 -1
  29. package/dist/dist/{index-DxHpPNfn.d.ts.map → index-D0V-mjCV.d.ts.map} +1 -1
  30. package/dist/dist/{index.node-WsEJCOwC.d.ts → index.node-CYPemH-t.d.ts} +157 -5
  31. package/dist/dist/{index.node-WsEJCOwC.d.ts.map → index.node-CYPemH-t.d.ts.map} +1 -1
  32. package/dist/dist/platform.node.d.ts +2 -2
  33. package/dist/eas-wB_fQ8Tc.js +32 -0
  34. package/dist/eas-wB_fQ8Tc.js.map +1 -0
  35. package/dist/errors-DLSoqSHG.js +6550 -0
  36. package/dist/errors-DLSoqSHG.js.map +1 -0
  37. package/dist/getPublishPayload-BnIwpwz1.js +760 -0
  38. package/dist/getPublishPayload-BnIwpwz1.js.map +1 -0
  39. package/dist/getPublishPendingDiff-D6_-A5ns.js +125 -0
  40. package/dist/getPublishPendingDiff-D6_-A5ns.js.map +1 -0
  41. package/dist/getPublishUploads-sS6JfPgz.js +783 -0
  42. package/dist/getPublishUploads-sS6JfPgz.js.map +1 -0
  43. package/dist/{index-DQoyhp2c.js → index-BVBmz_cc.js} +11 -14
  44. package/dist/index-BVBmz_cc.js.map +1 -0
  45. package/dist/index-CYGWPoOx.js +27 -0
  46. package/dist/index-CYGWPoOx.js.map +1 -0
  47. package/dist/{index-DxHpPNfn.js → index-D0V-mjCV.js} +2 -2
  48. package/dist/index-D0V-mjCV.js.map +1 -0
  49. package/dist/index-DmTtj1nk.js +817 -0
  50. package/dist/index-DmTtj1nk.js.map +1 -0
  51. package/dist/{index.browser-QPWBkLJA.js → index.browser-CUmBVYen.js} +397 -356
  52. package/dist/index.browser-CUmBVYen.js.map +1 -0
  53. package/dist/{index.node-WsEJCOwC.js → index.node-CYPemH-t.js} +10 -10
  54. package/dist/index.node-CYPemH-t.js.map +1 -0
  55. package/dist/main.js +23 -1075
  56. package/dist/main.js.map +1 -1
  57. package/dist/modelPropertyRecordSchemas-C7UgA5TH.js +48 -0
  58. package/dist/modelPropertyRecordSchemas-C7UgA5TH.js.map +1 -0
  59. package/dist/node.js +14 -18
  60. package/dist/node.js.map +1 -1
  61. package/dist/platform.browser.js +8 -13
  62. package/dist/platform.browser.js.map +1 -1
  63. package/dist/platform.node.js +6 -16
  64. package/dist/platform.node.js.map +1 -1
  65. package/dist/property-BxUYznH0.js +87 -0
  66. package/dist/property-BxUYznH0.js.map +1 -0
  67. package/dist/publishGraph-EcB40Uii.js +311 -0
  68. package/dist/publishGraph-EcB40Uii.js.map +1 -0
  69. package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js +110 -0
  70. package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js.map +1 -0
  71. package/dist/seedSchema/ModelSchema.ts +4 -0
  72. package/dist/seedSchema/ModelSchemaSchema.ts +5 -2
  73. package/dist/seedSchema/PendingWriteSchema.ts +4 -1
  74. package/dist/seedSchema/SchemaSchema.ts +3 -0
  75. package/dist/seedSchema/SeedSchema.ts +8 -2
  76. package/dist/seedSchema/VersionSchema.ts +7 -2
  77. package/dist/seedSchema/attestedUid.ts +10 -0
  78. package/dist/src/Item/Item.d.ts +32 -30
  79. package/dist/src/Item/Item.d.ts.map +1 -1
  80. package/dist/src/Item/loadItem.d.ts +12 -0
  81. package/dist/src/Item/loadItem.d.ts.map +1 -0
  82. package/dist/src/Item/service/itemMachineSingle.d.ts +2 -13
  83. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  84. package/dist/src/ItemProperty/ItemProperty.d.ts +77 -46
  85. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  86. package/dist/src/ItemProperty/loadProperty.d.ts +11 -0
  87. package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -0
  88. package/dist/src/ItemProperty/propertyWrite.d.ts +54 -0
  89. package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -0
  90. package/dist/src/ItemProperty/{service/actors/saveValueToDb/rowContext.d.ts → rowContext.d.ts} +1 -1
  91. package/dist/src/ItemProperty/rowContext.d.ts.map +1 -0
  92. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +6 -0
  93. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  94. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +5 -15
  95. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -1
  96. package/dist/src/ItemProperty/service/propertyMachine.d.ts +4 -50
  97. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  98. package/dist/src/Model/Model.d.ts +26 -56
  99. package/dist/src/Model/Model.d.ts.map +1 -1
  100. package/dist/src/Model/createModelProperties.d.ts +10 -0
  101. package/dist/src/Model/createModelProperties.d.ts.map +1 -0
  102. package/dist/src/Model/loadModel.d.ts +13 -0
  103. package/dist/src/Model/loadModel.d.ts.map +1 -0
  104. package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
  105. package/dist/src/Model/service/modelMachine.d.ts +5 -114
  106. package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
  107. package/dist/src/ModelProperty/ModelProperty.d.ts +44 -37
  108. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  109. package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
  110. package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
  111. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +6 -77
  112. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
  113. package/dist/src/Schema/Schema.d.ts +36 -37
  114. package/dist/src/Schema/Schema.d.ts.map +1 -1
  115. package/dist/src/Schema/loadOrCreateSchema.d.ts +21 -0
  116. package/dist/src/Schema/loadOrCreateSchema.d.ts.map +1 -0
  117. package/dist/src/Schema/service/schemaMachine.d.ts +7 -125
  118. package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
  119. package/dist/src/browser/db/Db.d.ts.map +1 -1
  120. package/dist/src/browser/db/changeFeed.d.ts +2 -18
  121. package/dist/src/browser/db/changeFeed.d.ts.map +1 -1
  122. package/dist/src/browser/db/drizzleFiles.d.ts +6 -2
  123. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  124. package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
  125. package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
  126. package/dist/src/client/ClientManager.d.ts +90 -57
  127. package/dist/src/client/ClientManager.d.ts.map +1 -1
  128. package/dist/src/client/actors/addModelsToDb.d.ts +9 -7
  129. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  130. package/dist/src/client/actors/dbInit.d.ts +3 -3
  131. package/dist/src/client/actors/dbInit.d.ts.map +1 -1
  132. package/dist/src/client/actors/fileSystemInit.d.ts +3 -3
  133. package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
  134. package/dist/src/client/actors/platformClassesInit.d.ts +10 -5
  135. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  136. package/dist/src/client/actors/processSchemaFiles.d.ts +18 -3
  137. package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
  138. package/dist/src/client/actors/saveConfig.d.ts +6 -3
  139. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  140. package/dist/src/client/clientManagerMachine.d.ts +22 -20
  141. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  142. package/dist/src/client/constants.d.ts +1 -9
  143. package/dist/src/client/constants.d.ts.map +1 -1
  144. package/dist/src/client/readiness.d.ts +26 -0
  145. package/dist/src/client/readiness.d.ts.map +1 -0
  146. package/dist/src/db/read/currentPropertyRow.d.ts +61 -0
  147. package/dist/src/db/read/currentPropertyRow.d.ts.map +1 -0
  148. package/dist/src/db/read/findSeedRow.d.ts +20 -0
  149. package/dist/src/db/read/findSeedRow.d.ts.map +1 -0
  150. package/dist/src/db/read/findSeedRowsByUid.d.ts +4 -1
  151. package/dist/src/db/read/findSeedRowsByUid.d.ts.map +1 -1
  152. package/dist/src/db/read/getAttesterForSeed.d.ts +1 -1
  153. package/dist/src/db/read/getAttesterForSeed.d.ts.map +1 -1
  154. package/dist/src/db/read/getItemData.d.ts.map +1 -1
  155. package/dist/src/db/read/getItemProperties.d.ts +5 -0
  156. package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
  157. package/dist/src/db/read/getMetadataAttestationUidsForSeedUid.d.ts.map +1 -1
  158. package/dist/src/db/read/getModelSchemas.d.ts +0 -7
  159. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  160. package/dist/src/db/read/getModelsData.d.ts.map +1 -1
  161. package/dist/src/db/read/getPropertyClear.d.ts +5 -1
  162. package/dist/src/db/read/getPropertyClear.d.ts.map +1 -1
  163. package/dist/src/db/read/getPublishPayload.d.ts +35 -40
  164. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  165. package/dist/src/db/read/getPublishPendingDiff.d.ts +2 -2
  166. package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -1
  167. package/dist/src/db/read/getPublishUploads.d.ts +59 -28
  168. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  169. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  170. package/dist/src/db/read/getSeedPublishState.d.ts.map +1 -1
  171. package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -1
  172. package/dist/src/db/read/getVersionsForSeedUid.d.ts.map +1 -1
  173. package/dist/src/db/read/isSeedRevoked.d.ts.map +1 -1
  174. package/dist/src/db/read/localModelSchemaLookups.d.ts +8 -0
  175. package/dist/src/db/read/localModelSchemaLookups.d.ts.map +1 -0
  176. package/dist/src/db/read/metadataProperty.d.ts +104 -0
  177. package/dist/src/db/read/metadataProperty.d.ts.map +1 -0
  178. package/dist/src/db/read/publishGraph.d.ts +148 -0
  179. package/dist/src/db/read/publishGraph.d.ts.map +1 -0
  180. package/dist/src/db/read/resolveModelRecord.d.ts +26 -2
  181. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  182. package/dist/src/db/read/resolveRelatedSeedRef.d.ts +1 -7
  183. package/dist/src/db/read/resolveRelatedSeedRef.d.ts.map +1 -1
  184. package/dist/src/db/read/subqueries/metadataLatest.d.ts +3 -1
  185. package/dist/src/db/read/subqueries/metadataLatest.d.ts.map +1 -1
  186. package/dist/src/db/read/summarizePublishWork.d.ts +13 -5
  187. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  188. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +20 -21
  189. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
  190. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  191. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  192. package/dist/src/db/write/createSeeds.d.ts +5 -1
  193. package/dist/src/db/write/createSeeds.d.ts.map +1 -1
  194. package/dist/src/db/write/definitions.d.ts +127 -0
  195. package/dist/src/db/write/definitions.d.ts.map +1 -0
  196. package/dist/src/db/write/mergeChainRows.d.ts +22 -0
  197. package/dist/src/db/write/mergeChainRows.d.ts.map +1 -0
  198. package/dist/src/db/write/saveDefinition.d.ts +29 -0
  199. package/dist/src/db/write/saveDefinition.d.ts.map +1 -0
  200. package/dist/src/db/write/updateSeedUid.d.ts +4 -2
  201. package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
  202. package/dist/src/db/write/updateVersionUid.d.ts +12 -4
  203. package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
  204. package/dist/src/db/write/writeModelUids.d.ts +10 -0
  205. package/dist/src/db/write/writeModelUids.d.ts.map +1 -0
  206. package/dist/src/eas.d.ts +8 -6
  207. package/dist/src/eas.d.ts.map +1 -1
  208. package/dist/src/events/files/download.d.ts.map +1 -1
  209. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  210. package/dist/src/helpers/arweaveContentTags.d.ts +1 -1
  211. package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -1
  212. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts +18 -3
  213. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts.map +1 -1
  214. package/dist/src/helpers/constants.d.ts +5 -2
  215. package/dist/src/helpers/constants.d.ts.map +1 -1
  216. package/dist/src/helpers/dataUrl.d.ts +10 -0
  217. package/dist/src/helpers/dataUrl.d.ts.map +1 -0
  218. package/dist/src/helpers/db.d.ts +54 -105
  219. package/dist/src/helpers/db.d.ts.map +1 -1
  220. package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -1
  221. package/dist/src/helpers/entity/contextUpdate.d.ts +20 -0
  222. package/dist/src/helpers/entity/contextUpdate.d.ts.map +1 -0
  223. package/dist/src/helpers/entity/draftSaveErrors.d.ts +5 -0
  224. package/dist/src/helpers/entity/draftSaveErrors.d.ts.map +1 -1
  225. package/dist/src/helpers/entity/entityCache.d.ts +65 -3
  226. package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
  227. package/dist/src/helpers/entity/entityCommon.d.ts +0 -22
  228. package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
  229. package/dist/src/helpers/entity/entityLifecycle.d.ts +75 -0
  230. package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -0
  231. package/dist/src/helpers/entity/entityLiveQuery.d.ts +1 -23
  232. package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
  233. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +4 -9
  234. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
  235. package/dist/src/helpers/index.d.ts +2 -24
  236. package/dist/src/helpers/index.d.ts.map +1 -1
  237. package/dist/src/helpers/localImageBlobUrl.d.ts +7 -0
  238. package/dist/src/helpers/localImageBlobUrl.d.ts.map +1 -0
  239. package/dist/src/helpers/mediaRef.d.ts +3 -70
  240. package/dist/src/helpers/mediaRef.d.ts.map +1 -1
  241. package/dist/src/helpers/metadataPropertyNames.d.ts +34 -26
  242. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  243. package/dist/src/helpers/mimeTypes.d.ts +2 -1
  244. package/dist/src/helpers/mimeTypes.d.ts.map +1 -1
  245. package/dist/src/helpers/model.d.ts.map +1 -1
  246. package/dist/src/helpers/ownership.d.ts.map +1 -1
  247. package/dist/src/helpers/property.d.ts +21 -26
  248. package/dist/src/helpers/property.d.ts.map +1 -1
  249. package/dist/src/helpers/propertyDefinition.d.ts +59 -0
  250. package/dist/src/helpers/propertyDefinition.d.ts.map +1 -0
  251. package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
  252. package/dist/src/helpers/relationSeedRef.d.ts +0 -7
  253. package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
  254. package/dist/src/helpers/schema.d.ts +24 -38
  255. package/dist/src/helpers/schema.d.ts.map +1 -1
  256. package/dist/src/helpers/schemaApply.d.ts +135 -0
  257. package/dist/src/helpers/schemaApply.d.ts.map +1 -0
  258. package/dist/src/helpers/tabEvents.d.ts.map +1 -1
  259. package/dist/src/helpers/updateSchema.d.ts +2 -18
  260. package/dist/src/helpers/updateSchema.d.ts.map +1 -1
  261. package/dist/src/imports/index.d.ts +1 -1
  262. package/dist/src/imports/index.d.ts.map +1 -1
  263. package/dist/src/imports/json.d.ts +8 -78
  264. package/dist/src/imports/json.d.ts.map +1 -1
  265. package/dist/src/index.d.ts +13 -13
  266. package/dist/src/index.d.ts.map +1 -1
  267. package/dist/src/interfaces/IItem.d.ts +5 -0
  268. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  269. package/dist/src/interfaces/IItemProperty.d.ts +9 -7
  270. package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
  271. package/dist/src/node/db/Db.d.ts.map +1 -1
  272. package/dist/src/node/index.d.ts +2 -1
  273. package/dist/src/node/index.d.ts.map +1 -1
  274. package/dist/src/outbox/conflicts.d.ts +2 -0
  275. package/dist/src/outbox/conflicts.d.ts.map +1 -1
  276. package/dist/src/outbox/itemAppliers.d.ts +63 -14
  277. package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
  278. package/dist/src/outbox/outbox.d.ts +14 -3
  279. package/dist/src/outbox/outbox.d.ts.map +1 -1
  280. package/dist/src/outbox/pendingValues.d.ts +3 -1
  281. package/dist/src/outbox/pendingValues.d.ts.map +1 -1
  282. package/dist/src/outbox/storageValueRow.d.ts +7 -0
  283. package/dist/src/outbox/storageValueRow.d.ts.map +1 -0
  284. package/dist/src/platform/configurePlatform.d.ts.map +1 -1
  285. package/dist/src/platform/index.browser.d.ts.map +1 -1
  286. package/dist/src/platform/index.node.d.ts.map +1 -1
  287. package/dist/src/seedSchema/ModelSchema.d.ts +19 -0
  288. package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
  289. package/dist/src/seedSchema/ModelSchemaSchema.d.ts.map +1 -1
  290. package/dist/src/seedSchema/PendingWriteSchema.d.ts.map +1 -1
  291. package/dist/src/seedSchema/SchemaSchema.d.ts +19 -0
  292. package/dist/src/seedSchema/SchemaSchema.d.ts.map +1 -1
  293. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  294. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  295. package/dist/src/seedSchema/attestedUid.d.ts +9 -0
  296. package/dist/src/seedSchema/attestedUid.d.ts.map +1 -0
  297. package/dist/src/storageValue/content.d.ts +45 -0
  298. package/dist/src/storageValue/content.d.ts.map +1 -0
  299. package/dist/src/storageValue/findFile.d.ts +7 -0
  300. package/dist/src/storageValue/findFile.d.ts.map +1 -0
  301. package/dist/src/storageValue/resolve.d.ts +71 -0
  302. package/dist/src/storageValue/resolve.d.ts.map +1 -0
  303. package/dist/src/storageValue/save.d.ts +24 -0
  304. package/dist/src/storageValue/save.d.ts.map +1 -0
  305. package/dist/src/storageValue/stage.d.ts +22 -0
  306. package/dist/src/storageValue/stage.d.ts.map +1 -0
  307. package/dist/src/types/db.d.ts +0 -14
  308. package/dist/src/types/db.d.ts.map +1 -1
  309. package/dist/src/types/index.d.ts +3 -3
  310. package/dist/src/types/index.d.ts.map +1 -1
  311. package/dist/src/types/machines.d.ts +1 -1
  312. package/dist/src/types/machines.d.ts.map +1 -1
  313. package/dist/src/types/property.d.ts +9 -24
  314. package/dist/src/types/property.d.ts.map +1 -1
  315. package/dist/src/types/publish.d.ts +1 -1
  316. package/dist/src/types/publish.d.ts.map +1 -1
  317. package/dist/{syncDbWithEas-BMHoou6X.js → syncDbWithEas-CA7PvBgu.js} +112 -162
  318. package/dist/syncDbWithEas-CA7PvBgu.js.map +1 -0
  319. package/dist/tabEvents-CaVmngqr.js +3804 -0
  320. package/dist/tabEvents-CaVmngqr.js.map +1 -0
  321. package/dist/{tolerantWebAccess-BHndShch.js → tolerantWebAccess-BJqViq08.js} +10 -15
  322. package/dist/{tolerantWebAccess-BHndShch.js.map → tolerantWebAccess-BJqViq08.js.map} +1 -1
  323. package/dist/{resolveModelForSyncedSeed-fIURvYRV.js → updateSeedRevokedAt-BL9Bg-G7.js} +30 -4
  324. package/dist/updateSeedRevokedAt-BL9Bg-G7.js.map +1 -0
  325. package/package.json +6 -6
  326. package/dist/ClientManager-DqL0q_eu.js +0 -5292
  327. package/dist/ClientManager-DqL0q_eu.js.map +0 -1
  328. package/dist/Item-CG5IhPtL.js.map +0 -1
  329. package/dist/ModelProperty-DDD47KVm.js.map +0 -1
  330. package/dist/Schema-BS8oR7QV.js +0 -4370
  331. package/dist/Schema-BS8oR7QV.js.map +0 -1
  332. package/dist/backfillMetadataPropertyIds-C7P7FL6F.js +0 -72
  333. package/dist/backfillMetadataPropertyIds-C7P7FL6F.js.map +0 -1
  334. package/dist/changeFeed-M8sGbOrW.js +0 -726
  335. package/dist/changeFeed-M8sGbOrW.js.map +0 -1
  336. package/dist/configurePlatform-Dukm2QwO.js.map +0 -1
  337. package/dist/dist/ClientManager-DqL0q_eu.d.ts +0 -952
  338. package/dist/dist/ClientManager-DqL0q_eu.d.ts.map +0 -1
  339. package/dist/dist/Item-CG5IhPtL.d.ts +0 -1115
  340. package/dist/dist/Item-CG5IhPtL.d.ts.map +0 -1
  341. package/dist/dist/ModelProperty-DDD47KVm.d.ts +0 -315
  342. package/dist/dist/ModelProperty-DDD47KVm.d.ts.map +0 -1
  343. package/dist/dist/Schema-BS8oR7QV.d.ts +0 -432
  344. package/dist/dist/Schema-BS8oR7QV.d.ts.map +0 -1
  345. package/dist/dist/SchemaValidationService-CZzKNL04.d.ts +0 -118
  346. package/dist/dist/SchemaValidationService-CZzKNL04.d.ts.map +0 -1
  347. package/dist/dist/backfillMetadataPropertyIds-C7P7FL6F.d.ts +0 -7
  348. package/dist/dist/backfillMetadataPropertyIds-C7P7FL6F.d.ts.map +0 -1
  349. package/dist/dist/changeFeed-M8sGbOrW.d.ts +0 -160
  350. package/dist/dist/changeFeed-M8sGbOrW.d.ts.map +0 -1
  351. package/dist/dist/configurePlatform-Dukm2QwO.d.ts.map +0 -1
  352. package/dist/dist/detachRowsBeforeDelete-Di1enVUF.d.ts +0 -13
  353. package/dist/dist/detachRowsBeforeDelete-Di1enVUF.d.ts.map +0 -1
  354. package/dist/dist/eas-B5VJolSj.d.ts +0 -12
  355. package/dist/dist/eas-B5VJolSj.d.ts.map +0 -1
  356. package/dist/dist/errors-C1qUEZ7A.d.ts +0 -25
  357. package/dist/dist/errors-C1qUEZ7A.d.ts.map +0 -1
  358. package/dist/dist/errors-CS3nDpUU.d.ts +0 -515
  359. package/dist/dist/errors-CS3nDpUU.d.ts.map +0 -1
  360. package/dist/dist/eventBus-7vxTCc3a.d.ts +0 -18
  361. package/dist/dist/eventBus-7vxTCc3a.d.ts.map +0 -1
  362. package/dist/dist/findSeedRowsByUid-CuQmK7An.d.ts +0 -13
  363. package/dist/dist/findSeedRowsByUid-CuQmK7An.d.ts.map +0 -1
  364. package/dist/dist/getItem-Uha3_H0t.d.ts +0 -6
  365. package/dist/dist/getItem-Uha3_H0t.d.ts.map +0 -1
  366. package/dist/dist/getPublishPayload-pbin4lk8.d.ts +0 -65
  367. package/dist/dist/getPublishPayload-pbin4lk8.d.ts.map +0 -1
  368. package/dist/dist/getPublishPendingDiff-ByIaPvCn.d.ts +0 -18
  369. package/dist/dist/getPublishPendingDiff-ByIaPvCn.d.ts.map +0 -1
  370. package/dist/dist/getPublishUploads-BBqiowVc.d.ts +0 -89
  371. package/dist/dist/getPublishUploads-BBqiowVc.d.ts.map +0 -1
  372. package/dist/dist/index-DQoyhp2c.d.ts +0 -6
  373. package/dist/dist/index-DQoyhp2c.d.ts.map +0 -1
  374. package/dist/dist/index-njjjo74v.d.ts +0 -14
  375. package/dist/dist/index-njjjo74v.d.ts.map +0 -1
  376. package/dist/dist/index-rOTW-2QZ.d.ts.map +0 -1
  377. package/dist/dist/index.browser-QPWBkLJA.d.ts +0 -9959
  378. package/dist/dist/index.browser-QPWBkLJA.d.ts.map +0 -1
  379. package/dist/dist/mimeTypes-C9r76DCH.d.ts +0 -30
  380. package/dist/dist/mimeTypes-C9r76DCH.d.ts.map +0 -1
  381. package/dist/dist/model-oHA3YhOd.d.ts +0 -6
  382. package/dist/dist/model-oHA3YhOd.d.ts.map +0 -1
  383. package/dist/dist/modelPropertyRecordSchemas-onFOG2x6.d.ts +0 -7
  384. package/dist/dist/modelPropertyRecordSchemas-onFOG2x6.d.ts.map +0 -1
  385. package/dist/dist/platform.browser.d.ts +0 -3
  386. package/dist/dist/platform.browser.d.ts.map +0 -1
  387. package/dist/dist/property-C85DCD7K.d.ts +0 -37
  388. package/dist/dist/property-C85DCD7K.d.ts.map +0 -1
  389. package/dist/dist/propertyValidationRules-CjUPOFeu.d.ts +0 -13
  390. package/dist/dist/propertyValidationRules-CjUPOFeu.d.ts.map +0 -1
  391. package/dist/dist/publishDraftGraph-DBWAN72w.d.ts +0 -93
  392. package/dist/dist/publishDraftGraph-DBWAN72w.d.ts.map +0 -1
  393. package/dist/dist/resolveModelForSyncedSeed-fIURvYRV.d.ts +0 -21
  394. package/dist/dist/resolveModelForSyncedSeed-fIURvYRV.d.ts.map +0 -1
  395. package/dist/dist/syncDbWithEas-BMHoou6X.d.ts +0 -13
  396. package/dist/dist/syncDbWithEas-BMHoou6X.d.ts.map +0 -1
  397. package/dist/dist/tolerantWebAccess-BHndShch.d.ts +0 -113
  398. package/dist/dist/tolerantWebAccess-BHndShch.d.ts.map +0 -1
  399. package/dist/dist/updateSeedRevokedAt-DpfG6ztE.d.ts +0 -11
  400. package/dist/dist/updateSeedRevokedAt-DpfG6ztE.d.ts.map +0 -1
  401. package/dist/eas-B5VJolSj.js +0 -67
  402. package/dist/eas-B5VJolSj.js.map +0 -1
  403. package/dist/errors-CS3nDpUU.js +0 -4006
  404. package/dist/errors-CS3nDpUU.js.map +0 -1
  405. package/dist/eventBus-7vxTCc3a.js +0 -64
  406. package/dist/eventBus-7vxTCc3a.js.map +0 -1
  407. package/dist/findSeedRowsByUid-CuQmK7An.js +0 -47
  408. package/dist/findSeedRowsByUid-CuQmK7An.js.map +0 -1
  409. package/dist/getItem-Uha3_H0t.js +0 -45
  410. package/dist/getItem-Uha3_H0t.js.map +0 -1
  411. package/dist/getPublishPayload-pbin4lk8.js +0 -1736
  412. package/dist/getPublishPayload-pbin4lk8.js.map +0 -1
  413. package/dist/getPublishPendingDiff-ByIaPvCn.js +0 -118
  414. package/dist/getPublishPendingDiff-ByIaPvCn.js.map +0 -1
  415. package/dist/getPublishUploads-BBqiowVc.js +0 -1080
  416. package/dist/getPublishUploads-BBqiowVc.js.map +0 -1
  417. package/dist/index-DQoyhp2c.js.map +0 -1
  418. package/dist/index-DxHpPNfn.js.map +0 -1
  419. package/dist/index-njjjo74v.js +0 -29
  420. package/dist/index-njjjo74v.js.map +0 -1
  421. package/dist/index-rOTW-2QZ.js +0 -4760
  422. package/dist/index-rOTW-2QZ.js.map +0 -1
  423. package/dist/index.browser-QPWBkLJA.js.map +0 -1
  424. package/dist/index.node-WsEJCOwC.js.map +0 -1
  425. package/dist/mimeTypes-C9r76DCH.js +0 -209
  426. package/dist/mimeTypes-C9r76DCH.js.map +0 -1
  427. package/dist/model-oHA3YhOd.js +0 -29
  428. package/dist/model-oHA3YhOd.js.map +0 -1
  429. package/dist/modelPropertyRecordSchemas-onFOG2x6.js +0 -94
  430. package/dist/modelPropertyRecordSchemas-onFOG2x6.js.map +0 -1
  431. package/dist/property-C85DCD7K.js +0 -289
  432. package/dist/property-C85DCD7K.js.map +0 -1
  433. package/dist/propertyValidationRules-CjUPOFeu.js +0 -73
  434. package/dist/propertyValidationRules-CjUPOFeu.js.map +0 -1
  435. package/dist/publishDraftGraph-DBWAN72w.js +0 -505
  436. package/dist/publishDraftGraph-DBWAN72w.js.map +0 -1
  437. package/dist/resolveModelForSyncedSeed-fIURvYRV.js.map +0 -1
  438. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +0 -5
  439. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +0 -1
  440. package/dist/src/Item/service/actors/waitForDb.d.ts +0 -4
  441. package/dist/src/Item/service/actors/waitForDb.d.ts.map +0 -1
  442. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +0 -5
  443. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +0 -1
  444. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +0 -5
  445. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +0 -1
  446. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -6
  447. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +0 -1
  448. package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts.map +0 -1
  449. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +0 -24
  450. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +0 -1
  451. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +0 -5
  452. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +0 -1
  453. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +0 -5
  454. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +0 -1
  455. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +0 -10
  456. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +0 -1
  457. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts +0 -22
  458. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts.map +0 -1
  459. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +0 -4
  460. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +0 -1
  461. package/dist/src/Model/service/actors/createModelProperties.d.ts +0 -9
  462. package/dist/src/Model/service/actors/createModelProperties.d.ts.map +0 -1
  463. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +0 -5
  464. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +0 -1
  465. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +0 -5
  466. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +0 -1
  467. package/dist/src/Schema/service/actors/createModelInstances.d.ts +0 -11
  468. package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +0 -1
  469. package/dist/src/Schema/service/actors/createPropertyInstances.d.ts +0 -12
  470. package/dist/src/Schema/service/actors/createPropertyInstances.d.ts.map +0 -1
  471. package/dist/src/Schema/service/actors/validateSchema.d.ts +0 -5
  472. package/dist/src/Schema/service/actors/validateSchema.d.ts.map +0 -1
  473. package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts +0 -6
  474. package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +0 -1
  475. package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts +0 -7
  476. package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts.map +0 -1
  477. package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts +0 -8
  478. package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts.map +0 -1
  479. package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts +0 -6
  480. package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts.map +0 -1
  481. package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts +0 -7
  482. package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts.map +0 -1
  483. package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +0 -9
  484. package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +0 -1
  485. package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts +0 -10
  486. package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts.map +0 -1
  487. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +0 -11
  488. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +0 -1
  489. package/dist/src/browser/helpers/ArweaveClient.d.ts +0 -14
  490. package/dist/src/browser/helpers/ArweaveClient.d.ts.map +0 -1
  491. package/dist/src/browser/helpers/EasClient.d.ts +0 -10
  492. package/dist/src/browser/helpers/EasClient.d.ts.map +0 -1
  493. package/dist/src/browser/helpers/QueryClient.d.ts +0 -9
  494. package/dist/src/browser/helpers/QueryClient.d.ts.map +0 -1
  495. package/dist/src/client/actors/addModelsToStore.d.ts +0 -4
  496. package/dist/src/client/actors/addModelsToStore.d.ts.map +0 -1
  497. package/dist/src/db/backfillMetadataPropertyIds.d.ts +0 -7
  498. package/dist/src/db/backfillMetadataPropertyIds.d.ts.map +0 -1
  499. package/dist/src/db/read/getItem.d.ts +0 -3
  500. package/dist/src/db/read/getItem.d.ts.map +0 -1
  501. package/dist/src/db/read/getPropertyData.d.ts +0 -4
  502. package/dist/src/db/read/getPropertyData.d.ts.map +0 -1
  503. package/dist/src/db/read/getRelatedItemsForPublish.d.ts +0 -10
  504. package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +0 -1
  505. package/dist/src/db/read/getSeedData.d.ts +0 -12
  506. package/dist/src/db/read/getSeedData.d.ts.map +0 -1
  507. package/dist/src/db/read/itemLoads.d.ts +0 -20
  508. package/dist/src/db/read/itemLoads.d.ts.map +0 -1
  509. package/dist/src/db/read/publishDraftGraph.d.ts +0 -64
  510. package/dist/src/db/read/publishDraftGraph.d.ts.map +0 -1
  511. package/dist/src/db/write/linkModelToSchema.d.ts +0 -12
  512. package/dist/src/db/write/linkModelToSchema.d.ts.map +0 -1
  513. package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +0 -2
  514. package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts.map +0 -1
  515. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +0 -2
  516. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +0 -1
  517. package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +0 -2
  518. package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +0 -1
  519. package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +0 -2
  520. package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts.map +0 -1
  521. package/dist/src/helpers/EasClient/BaseEasClient.d.ts +0 -2
  522. package/dist/src/helpers/EasClient/BaseEasClient.d.ts.map +0 -1
  523. package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +0 -2
  524. package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts.map +0 -1
  525. package/dist/src/helpers/easUid.d.ts +0 -2
  526. package/dist/src/helpers/easUid.d.ts.map +0 -1
  527. package/dist/src/helpers/entity/entityDestroy.d.ts +0 -49
  528. package/dist/src/helpers/entity/entityDestroy.d.ts.map +0 -1
  529. package/dist/src/helpers/entity/entityFind.d.ts +0 -52
  530. package/dist/src/helpers/entity/entityFind.d.ts.map +0 -1
  531. package/dist/src/helpers/entity/entityState.d.ts +0 -28
  532. package/dist/src/helpers/entity/entityState.d.ts.map +0 -1
  533. package/dist/src/helpers/entity/entityUnload.d.ts +0 -56
  534. package/dist/src/helpers/entity/entityUnload.d.ts.map +0 -1
  535. package/dist/src/helpers/entity/evictionEpoch.d.ts +0 -43
  536. package/dist/src/helpers/entity/evictionEpoch.d.ts.map +0 -1
  537. package/dist/src/helpers/entity/index.d.ts +0 -12
  538. package/dist/src/helpers/entity/index.d.ts.map +0 -1
  539. package/dist/src/helpers/gateway/gatewayState.d.ts +0 -2
  540. package/dist/src/helpers/gateway/gatewayState.d.ts.map +0 -1
  541. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +0 -2
  542. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +0 -1
  543. package/dist/src/helpers/gateway/seedGatewayConfig.d.ts +0 -2
  544. package/dist/src/helpers/gateway/seedGatewayConfig.d.ts.map +0 -1
  545. package/dist/src/helpers/getSchemaForItemProperty.d.ts +0 -15
  546. package/dist/src/helpers/getSchemaForItemProperty.d.ts.map +0 -1
  547. package/dist/src/helpers/getSegmentedItemProperties.d.ts +0 -10
  548. package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +0 -1
  549. package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts +0 -7
  550. package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts.map +0 -1
  551. package/dist/src/helpers/propertyValidationRules.d.ts +0 -20
  552. package/dist/src/helpers/propertyValidationRules.d.ts.map +0 -1
  553. package/dist/src/helpers/propertyWriteTickets.d.ts +0 -11
  554. package/dist/src/helpers/propertyWriteTickets.d.ts.map +0 -1
  555. package/dist/src/helpers/reconcilePropertyDraftRows.d.ts +0 -10
  556. package/dist/src/helpers/reconcilePropertyDraftRows.d.ts.map +0 -1
  557. package/dist/src/helpers/waitForEntityIdle.d.ts +0 -21
  558. package/dist/src/helpers/waitForEntityIdle.d.ts.map +0 -1
  559. package/dist/src/interfaces/IQueryClient.d.ts +0 -15
  560. package/dist/src/interfaces/IQueryClient.d.ts.map +0 -1
  561. package/dist/src/node/helpers/ArweaveClient.d.ts +0 -5
  562. package/dist/src/node/helpers/ArweaveClient.d.ts.map +0 -1
  563. package/dist/src/node/helpers/EasClient.d.ts +0 -5
  564. package/dist/src/node/helpers/EasClient.d.ts.map +0 -1
  565. package/dist/src/node/helpers/QueryClient.d.ts +0 -5
  566. package/dist/src/node/helpers/QueryClient.d.ts.map +0 -1
  567. package/dist/src/services/write/actors/validateEntity.d.ts +0 -6
  568. package/dist/src/services/write/actors/validateEntity.d.ts.map +0 -1
  569. package/dist/src/services/write/actors/writeToDatabase.d.ts +0 -14
  570. package/dist/src/services/write/actors/writeToDatabase.d.ts.map +0 -1
  571. package/dist/src/services/write/writeProcessMachine.d.ts +0 -56
  572. package/dist/src/services/write/writeProcessMachine.d.ts.map +0 -1
  573. package/dist/src/stores/eas.d.ts +0 -2
  574. package/dist/src/stores/eas.d.ts.map +0 -1
  575. package/dist/src/types/arweave.d.ts +0 -57
  576. package/dist/src/types/arweave.d.ts.map +0 -1
  577. package/dist/src/types/gateway.d.ts +0 -2
  578. package/dist/src/types/gateway.d.ts.map +0 -1
  579. package/dist/syncDbWithEas-BMHoou6X.js.map +0 -1
  580. package/dist/updateSeedRevokedAt-DpfG6ztE.js +0 -31
  581. package/dist/updateSeedRevokedAt-DpfG6ztE.js.map +0 -1
@@ -1,1736 +0,0 @@
1
- import { isValidEasAttestationUid, VERSION_SCHEMA_UID, easName, decodeEasNumber, getSchemaUidForSchemaDefinitionFromCache, getEasSchemaUidForSchemaDefinition } from '@seedprotocol/eas';
2
- import { L as BaseDb, ab as getMetadataPropertyNamesForQuery, m as metadata, ac as isNode, ad as ZERO_BYTES32, R as resolveModelRecord, ae as getItemModelScope, E as properties, p as models, M as ModelPropertyDataTypes, r as resolveSeedIdsFromRefString, q as normalizeRelationPropertyValue, l as isPublishedSeedRef, x as htmlEmbeddedImageCoPublish, k as getCorrectId, af as INTERNAL_PROPERTY_NAMES, ag as isStorageSeedRef, n as normalizeDataType, ah as defaultAttestationData, $ as INTERNAL_DATA_TYPES, a7 as listRelationEasPropertyName, a8 as easPropertyNameForPublish } from './index-rOTW-2QZ.js';
3
- import { I as ItemLoads, i as isSeedRevoked, a as getSegmentedItemProperties, f as findRelatedSeedRow, r as relatedModelNameFromDef, h as htmlPropertyNameForHtmlSeed, b as isUnpublishedSeed, c as isLivePublishedSeed, d as draftWalkProperties } from './publishDraftGraph-DBWAN72w.js';
4
- import { M as METADATA_LATEST_FIRST_ORDER_SQL, z as isPublishedMetadataRow, K as getEasSchemaUidForModel, A as getLatestPublishedVersionRow, L as parseListPropertyValueFromStorage } from './Item-CG5IhPtL.js';
5
- import { or, eq, and, sql } from 'drizzle-orm';
6
- import { getPropertySchema } from './property-C85DCD7K.js';
7
- import { modelPropertiesToObject } from './model-oHA3YhOd.js';
8
- import { upperFirst, camelCase } from 'lodash-es';
9
- import './errors-CS3nDpUU.js';
10
-
11
- const isEmptyValue = (value) => value == null || value === '';
12
- /**
13
- * What publishing a property with an empty value does (ADR 0021). Undefined when there is nothing
14
- * to publish: the newest row holds a value, or the property has no live attestation (never
15
- * published, or already retracted). Rows of every name the property is stored under count.
16
- */
17
- async function getPropertyClear(params) {
18
- const { seedLocalId, seedUid, propertyName, dataType, refValueType } = params;
19
- if (!seedLocalId && !seedUid)
20
- return undefined;
21
- const appDb = BaseDb.getAppDb();
22
- if (!appDb)
23
- return undefined;
24
- const names = getMetadataPropertyNamesForQuery(propertyName, dataType, refValueType);
25
- const seedWhere = seedLocalId && seedUid
26
- ? or(eq(metadata.seedLocalId, seedLocalId), eq(metadata.seedUid, seedUid))
27
- : seedLocalId
28
- ? eq(metadata.seedLocalId, seedLocalId)
29
- : eq(metadata.seedUid, seedUid);
30
- const rows = (await appDb
31
- .select()
32
- .from(metadata)
33
- .where(and(or(...names.map((name) => eq(metadata.propertyName, name))), seedWhere))
34
- .orderBy(sql.raw(METADATA_LATEST_FIRST_ORDER_SQL)));
35
- const newest = rows[0];
36
- if (!newest || !isEmptyValue(newest.propertyValue))
37
- return undefined;
38
- const live = rows.filter((row) => isValidEasAttestationUid(row.uid) && row.revokedAt == null);
39
- if (live.length === 0)
40
- return undefined;
41
- // `live` is newest first
42
- const onVersion = live.filter((row) => row.versionUid === live[0].versionUid);
43
- const values = new Set(onVersion.map((row) => row.propertyValue));
44
- const retractScope = live.filter((row) => onVersion.includes(row) || values.has(row.propertyValue));
45
- return { retract: !!newest.retract && !isPublishedMetadataRow(newest), live, retractScope };
46
- }
47
- /** The empty value of an EAS type, or undefined for `bool` and `uint256`, which have none (ADR 0021). */
48
- function emptyEasValue(easDataType) {
49
- if (easDataType === 'string')
50
- return '';
51
- if (easDataType === 'bytes32')
52
- return `0x${'0'.repeat(64)}`;
53
- if (easDataType === 'bytes32[]')
54
- return [];
55
- return undefined;
56
- }
57
- /**
58
- * The seed's retracted properties that still have attestations to revoke (ADR 0021), with the
59
- * attestations publish revokes for each.
60
- */
61
- async function getPendingRetractions(params) {
62
- const { seedLocalId, seedUid } = params;
63
- if (!seedLocalId && !seedUid)
64
- return [];
65
- const { getPublishPendingDiff } = await import('./getPublishPendingDiff-ByIaPvCn.js');
66
- const { pendingProperties } = await getPublishPendingDiff({
67
- seedLocalId: seedLocalId ?? undefined,
68
- seedUid: seedUid ?? undefined,
69
- });
70
- const retractions = [];
71
- for (const { propertyName, change } of pendingProperties) {
72
- if (change !== 'retracted')
73
- continue;
74
- const clear = await getPropertyClear({ seedLocalId, seedUid, propertyName });
75
- if (!clear?.retract)
76
- continue;
77
- const attestations = clear.retractScope
78
- .filter((row) => row.uid && row.schemaUid)
79
- .map((row) => ({ uid: row.uid, schemaUid: row.schemaUid }));
80
- if (attestations.length > 0)
81
- retractions.push({ propertyName, attestations });
82
- }
83
- return retractions;
84
- }
85
-
86
- let easSdkPromise;
87
- /**
88
- * Load eas-sdk on first use instead of at SDK import time.
89
- *
90
- * On Node this loads eas-sdk's CommonJS build. Its ESM build (2.9.1+) does
91
- * `import { isEqual } from 'lodash'`, which Node rejects because lodash is
92
- * CommonJS, so a static import made `import '@seedprotocol/sdk'` fail unless the
93
- * app ran with `--import @seedprotocol/sdk/node-eas-lodash`.
94
- *
95
- * `process.getBuiltinModule` (Node 20.16+, 22.3+) keeps `node:module` out of the
96
- * import graph, so browser bundlers never see it. Bundlers resolve the
97
- * `import()` branch, and handle lodash there themselves.
98
- */
99
- function loadEasSdk() {
100
- if (!easSdkPromise) {
101
- easSdkPromise = (async () => {
102
- if (isNode() && typeof document === 'undefined' && typeof process.getBuiltinModule === 'function') {
103
- try {
104
- const { createRequire } = process.getBuiltinModule('node:module');
105
- return createRequire(import.meta.url)('@ethereum-attestation-service/eas-sdk');
106
- }
107
- catch {
108
- // e.g. import.meta.url is not a file: URL (bundled renderer). Fall through.
109
- }
110
- }
111
- return import('@ethereum-attestation-service/eas-sdk');
112
- })();
113
- easSdkPromise.catch(() => {
114
- easSdkPromise = undefined;
115
- });
116
- }
117
- return easSdkPromise;
118
- }
119
-
120
- /** UTF-8 string to 0x-prefixed bytes32 hex (right-padded with zeros). */
121
- function encodeBytes32String(value) {
122
- const bytes = new TextEncoder().encode(value);
123
- if (bytes.length > 32) {
124
- throw new Error(`encodeBytes32String: value exceeds 32 bytes (${bytes.length})`);
125
- }
126
- const hex = Array.from(bytes)
127
- .map((b) => b.toString(16).padStart(2, '0'))
128
- .join('');
129
- return `0x${hex.padEnd(64, '0')}`;
130
- }
131
-
132
- /** Error thrown when publish validation fails. Includes all validation errors for user to fix. */
133
- class PublishValidationFailedError extends Error {
134
- constructor(message, validationErrors) {
135
- super(message);
136
- this.validationErrors = validationErrors;
137
- this.name = 'PublishValidationFailedError';
138
- }
139
- }
140
- /** Validation error code for a relation, list member or image/file ref to an unpublished seed. */
141
- const RELATED_ITEM_UNPUBLISHED_CODE = 'related_item_unpublished';
142
- const describeUnpublishedRelatedItem = (r) => `${r.propertyName} -> ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid})`;
143
- /**
144
- * Thrown before anything is uploaded or attested when the item references items whose seed was
145
- * unpublished: the parent would attest a revoked seed uid. Republish those items (which gives
146
- * them a new seed uid) or remove the references, then publish again.
147
- * See docs/ATTESTATION_REVOCATION.md ("Republishing").
148
- *
149
- * A PublishValidationFailedError, so validateItemForPublish and the publish package's checking
150
- * step report it as validation errors (code `related_item_unpublished`, one per reference).
151
- */
152
- class RelatedItemUnpublishedError extends PublishValidationFailedError {
153
- constructor(unpublishedRelatedItems, otherValidationErrors = []) {
154
- const lines = unpublishedRelatedItems.map(describeUnpublishedRelatedItem);
155
- const message = `Cannot publish: it references ${lines.length} unpublished item${lines.length === 1 ? '' : 's'} ` +
156
- `(their seed attestations were revoked). Republish them or remove the references, then publish again:\n` +
157
- lines.join('\n');
158
- super(message, [
159
- ...unpublishedRelatedItems.map((r) => ({
160
- field: r.propertyName,
161
- message: `${r.propertyName} references unpublished ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid}). ` +
162
- `Republish it or remove the reference.`,
163
- code: RELATED_ITEM_UNPUBLISHED_CODE,
164
- })),
165
- ...otherValidationErrors,
166
- ]);
167
- this.name = 'RelatedItemUnpublishedError';
168
- this.unpublishedRelatedItems = unpublishedRelatedItems;
169
- }
170
- }
171
-
172
- /** Case-insensitive dataType match (schema JSON may use "text" vs "Text"). */
173
- const matchesDataType = (actual, expected) => normalizeDataType(actual) === expected;
174
- /** True (and the property is deferred) when `targetSeedLocalId` is an item still in progress. */
175
- function deferIfBackEdge(ctx, property, targetSeedLocalIds) {
176
- if (!targetSeedLocalIds.some((id) => !!id && ctx.newSeedsInProgress?.has(id)))
177
- return false;
178
- ctx.deferredProperties ?? (ctx.deferredProperties = new Set());
179
- ctx.deferredProperties.add(property);
180
- return true;
181
- }
182
- /**
183
- * Checks the seed a relation/list/image ref points at. A revoked (unpublished) seed is recorded in
184
- * `ctx.unpublishedRelatedItems`; a live published one maps the ref to its current uid. Returns
185
- * true when the caller must not walk into the related item (it is published, live or revoked).
186
- */
187
- function noteRelatedSeed(ctx, ref, row, propertyName, modelName) {
188
- if (isUnpublishedSeed(row)) {
189
- ctx.unpublishedRelatedItems ?? (ctx.unpublishedRelatedItems = []);
190
- if (!ctx.unpublishedRelatedItems.some((r) => r.propertyName === propertyName && r.seedLocalId === row.seedLocalId)) {
191
- ctx.unpublishedRelatedItems.push({
192
- propertyName,
193
- modelName: modelName ?? row.type ?? 'unknown',
194
- seedLocalId: row.seedLocalId,
195
- seedUid: row.seedUid,
196
- });
197
- }
198
- return true;
199
- }
200
- if (isLivePublishedSeed(row)) {
201
- if (ref !== row.seedUid) {
202
- ctx.relatedRefUids ?? (ctx.relatedRefUids = new Map());
203
- ctx.relatedRefUids.set(ref, row.seedUid);
204
- }
205
- return true;
206
- }
207
- return false;
208
- }
209
- /** Current uid for a ref noted by noteRelatedSeed, else the ref itself. */
210
- function currentRelatedRef(ctx, ref) {
211
- return ctx.relatedRefUids?.get(ref.trim()) ?? ref;
212
- }
213
- /**
214
- * An EAS uid (0x + 64 hex), as opposed to a local id. A "0x" prefix alone doesn't tell them apart:
215
- * local ids are random alphanumerics, and about 1 in 3,844 starts with "0x".
216
- */
217
- function isUidRef(ref) {
218
- return ref.length === 66 && ref.startsWith('0x');
219
- }
220
- function addValidationError(ctx, message, field, code = 'publish_validation') {
221
- // A property can be validated on more than one path (List of Relation: list + basic); report once.
222
- if (ctx.errors.some((e) => e.message === message && e.field === (field ?? '')))
223
- return;
224
- ctx.errors.push({ field: field ?? '', message, code });
225
- }
226
- /** File/Image/Html value is raw content instead of a storage seed id, so it was never saved/uploaded. */
227
- function addStorageValueNotSavedError(ctx, propertyName, dataType, value) {
228
- addValidationError(ctx, `Invalid value for property: ${propertyName}. Expected a storage seed id ` +
229
- `(${normalizeDataType(dataType)} content must be saved through the property before publishing), ` +
230
- `got ${value.length > 40 ? `${value.slice(0, 40)}…` : value}.`, propertyName, 'publish_storage_value_not_saved');
231
- }
232
- function isStorageTransactionPropertyName(name) {
233
- return name === 'storageTransactionId' || name === 'storage_transaction_id';
234
- }
235
- /**
236
- * Segmentation or naming variants can leave two rows for the same logical field; keep one
237
- * resolved slot so processBasicProperties emits a single storage tx attestation.
238
- */
239
- function replaceStorageTransactionInBasicProperties(itemBasicProperties, resolved) {
240
- const filtered = itemBasicProperties.filter((p) => !isStorageTransactionPropertyName(p.propertyName));
241
- itemBasicProperties.length = 0;
242
- itemBasicProperties.push(...filtered, resolved);
243
- }
244
- /** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */
245
- function dedupeOneStorageTransactionPropertyInList(itemBasicProperties) {
246
- const nonStorage = [];
247
- const storage = [];
248
- for (const p of itemBasicProperties) {
249
- if (isStorageTransactionPropertyName(p.propertyName)) {
250
- storage.push(p);
251
- }
252
- else {
253
- nonStorage.push(p);
254
- }
255
- }
256
- if (storage.length <= 1)
257
- return;
258
- itemBasicProperties.length = 0;
259
- itemBasicProperties.push(...nonStorage, storage[storage.length - 1]);
260
- }
261
- /**
262
- * Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.
263
- * Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.
264
- */
265
- function mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedSeedLocalId, publishLocalId, propertySchemaUid) {
266
- const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId);
267
- if (!existing)
268
- return false;
269
- const pts = existing.propertiesToUpdate ?? [];
270
- const already = pts.some((e) => e.publishLocalId === publishLocalId &&
271
- String(e.propertySchemaUid ?? '').toLowerCase() ===
272
- String(propertySchemaUid ?? '').toLowerCase());
273
- if (!already) {
274
- pts.push({ publishLocalId, propertySchemaUid });
275
- }
276
- return true;
277
- }
278
- const getVersionUid = (item) => {
279
- const latestVersion = item.latestVersionUid;
280
- if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {
281
- const u = latestVersion.uid;
282
- return isValidEasAttestationUid(u) ? u : ZERO_BYTES32;
283
- }
284
- if (latestVersion && typeof latestVersion === 'string') {
285
- return isValidEasAttestationUid(latestVersion) ? latestVersion : ZERO_BYTES32;
286
- }
287
- return ZERO_BYTES32;
288
- };
289
- /**
290
- * Resolve versionUid when item.latestVersionUid is empty but item has been published (has seedUid).
291
- * Tries DB first, then EAS. If the local versions row still has a placeholder uid after publish,
292
- * EAS fallback queries attestations where refUID=seedUid (Version attestations).
293
- */
294
- async function resolveVersionUid(seedLocalId, seedUid) {
295
- if (!seedLocalId || !seedUid || seedUid === ZERO_BYTES32)
296
- return ZERO_BYTES32;
297
- const published = await getLatestPublishedVersionRow(seedLocalId);
298
- if (published?.uid)
299
- return published.uid;
300
- try {
301
- const { getItemVersionsFromEas } = await import('./eas-B5VJolSj.js');
302
- const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] });
303
- const latest = attestations?.[0];
304
- if (latest?.id)
305
- return latest.id;
306
- }
307
- catch {
308
- // EAS client may not be initialized or network error
309
- }
310
- return ZERO_BYTES32;
311
- }
312
- const getPropertyData = async (itemProperty, ctx) => {
313
- const rawDataType = itemProperty.propertyDef?.dataType;
314
- const dataType = rawDataType ? normalizeDataType(String(rawDataType)) : undefined;
315
- const entry = dataType
316
- ? INTERNAL_DATA_TYPES[dataType]
317
- : undefined;
318
- const easDataType = entry?.eas;
319
- if (!easDataType) {
320
- if (ctx) {
321
- addValidationError(ctx, `Unknown or unsupported property data type "${rawDataType ?? 'undefined'}" for property: ${itemProperty.propertyName}. Supported types: ${Object.keys(INTERNAL_DATA_TYPES).join(', ')}.`, itemProperty.propertyName);
322
- }
323
- return null;
324
- }
325
- // ADR 0008: list relations publish under their storage name (authors → author_identity_ids),
326
- // single relations under their schema key (author), never the local authorId.
327
- const propertyDef = itemProperty.propertyDef;
328
- const listRelationName = listRelationEasPropertyName(itemProperty.propertyName, propertyDef);
329
- const propertyNameForSchema = easPropertyNameForPublish(itemProperty.propertyName, propertyDef);
330
- const schemaDef = `${easDataType} ${propertyNameForSchema}`;
331
- // The UID ensureEasSchemasForItem resolved for this exact definition comes first. A cached
332
- // schemaUid was looked up under the property's own name, which matches any type: Optimism
333
- // Sepolia has `bytes32 storage_transaction_id` beside `string storage_transaction_id`, and
334
- // attesting a string under the bytes32 one reads back as 0x…20. Trust the cached one only when
335
- // that name is the one published (not for a list relation, or a single relation stored as authorId).
336
- const storageName = itemProperty.storagePropertyName ||
337
- itemProperty.propertyName;
338
- let schemaUid = getSchemaUidForSchemaDefinitionFromCache(schemaDef) ??
339
- (!listRelationName && easName(storageName) === propertyNameForSchema ? itemProperty.schemaUid : undefined);
340
- if (!schemaUid) {
341
- schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef });
342
- }
343
- if (!schemaUid) {
344
- if (ctx) {
345
- addValidationError(ctx, `EAS schema not found for "${schemaDef}" (property: ${itemProperty.propertyName}). Register it before publishing (ensureEasSchemasForItem).`, itemProperty.propertyName, 'publish_schema_not_found');
346
- }
347
- return null;
348
- }
349
- return {
350
- schemaUid,
351
- easDataType,
352
- schemaDef,
353
- propertyNameForSchema,
354
- };
355
- };
356
- /** Resolve propertyDef from Model for properties that lack it (e.g. cached instances
357
- * created before loadOrCreateProperty was fixed). Ensures both new and existing items get property attestations.
358
- * Also ensures Relation/Image properties have required from schema when missing (for publish validation). */
359
- const ensurePropertyDefs = async (targetItem) => {
360
- let schema;
361
- // Model names are only unique per schema: resolve definitions from this item's own model.
362
- const targetScope = await getItemModelScope(targetItem);
363
- for (const itemProperty of targetItem.properties) {
364
- if (!itemProperty.propertyDef && targetItem.modelName) {
365
- schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName, targetScope);
366
- if (!schema) {
367
- try {
368
- const _mod_0 = await import('./errors-CS3nDpUU.js');
369
- const _ns_0 = _mod_0.i;
370
- const { Model } = _ns_0;
371
- const normalizedModelName = upperFirst(camelCase(targetItem.modelName));
372
- let model = Model.resolve(normalizedModelName, targetScope);
373
- if (!model?.properties?.length && !targetScope.modelFileId) {
374
- model = Model.findByModelType(easName(targetItem.modelName));
375
- }
376
- const schemaKeys = [];
377
- if (model?.properties?.length) {
378
- const schemas = modelPropertiesToObject(model.properties);
379
- schemaKeys.push(...Object.keys(schemas));
380
- schema = schemas[itemProperty.propertyName];
381
- }
382
- }
383
- catch {
384
- schema = undefined;
385
- }
386
- }
387
- if (!schema) {
388
- const db = BaseDb.getAppDb();
389
- if (db) {
390
- try {
391
- const normalizedModelName = upperFirst(camelCase(targetItem.modelName));
392
- const modelRecord = await resolveModelRecord(normalizedModelName, targetScope, db);
393
- const modelRecords = modelRecord ? [modelRecord] : [];
394
- if (modelRecords.length > 0 && modelRecords[0].id) {
395
- const propertyRecords = await db
396
- .select()
397
- .from(properties)
398
- .where(and(eq(properties.modelId, modelRecords[0].id), eq(properties.name, itemProperty.propertyName)))
399
- .limit(1);
400
- if (propertyRecords.length > 0) {
401
- const propRecord = propertyRecords[0];
402
- let refModelName;
403
- if (propRecord.refModelId != null) {
404
- const refModelRows = await db
405
- .select({ name: models.name })
406
- .from(models)
407
- .where(eq(models.id, propRecord.refModelId))
408
- .limit(1);
409
- refModelName = refModelRows[0]?.name ?? undefined;
410
- }
411
- schema = {
412
- dataType: propRecord.dataType,
413
- ref: refModelName ?? undefined,
414
- refValueType: propRecord.refValueType || undefined,
415
- storageType: propRecord.storageType || undefined,
416
- localStorageDir: propRecord.localStorageDir || undefined,
417
- filenameSuffix: propRecord.filenameSuffix || undefined,
418
- required: propRecord.required ?? undefined,
419
- };
420
- }
421
- }
422
- }
423
- catch {
424
- schema = undefined;
425
- }
426
- }
427
- }
428
- if (schema) {
429
- itemProperty.getService().send({
430
- type: 'updateContext',
431
- propertyRecordSchema: schema,
432
- });
433
- }
434
- }
435
- }
436
- };
437
- const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx, buildOpts) => {
438
- const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
439
- for (const basicProperty of itemBasicProperties) {
440
- // Skip SDK-internal properties (e.g. publisher) - never attest to EAS
441
- if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {
442
- continue;
443
- }
444
- if (ctx.deferredProperties?.has(basicProperty)) {
445
- continue;
446
- }
447
- const snapshot = basicProperty.getService().getSnapshot();
448
- const context = 'context' in snapshot ? snapshot.context : null;
449
- const propertyDef = basicProperty.propertyDef ?? (context ? context.propertyRecordSchema : undefined);
450
- const isFileImageHtml = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||
451
- matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||
452
- matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html);
453
- const isJsonStorage = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||
454
- matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json);
455
- const isRelation = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation);
456
- // storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).
457
- const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName);
458
- // File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).
459
- // basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.
460
- const preferPropertyValueForPublish = isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp;
461
- let value = preferPropertyValueForPublish && context
462
- ? context.propertyValue
463
- : (basicProperty.value ??
464
- (context ? context.propertyValue : undefined));
465
- if (!context) {
466
- continue;
467
- }
468
- // Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints
469
- if (matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation) ||
470
- isFileImageHtml ||
471
- isJsonStorage) {
472
- const pv = context.propertyValue;
473
- if (typeof value === 'object' || value == null) {
474
- if (typeof pv === 'string' && pv.trim())
475
- value = pv.trim();
476
- else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string')
477
- value = pv.seedLocalId;
478
- }
479
- }
480
- // 0 and false are values (ADR 0010). An empty value publishes only as a removal of a value
481
- // attested before (ADR 0021); a retraction attests nothing (publish revokes instead).
482
- let isRemoval = false;
483
- if (value == null || value === '' || (Array.isArray(value) && value.length === 0)) {
484
- if (basicProperty.uid && !forceFullSnapshot)
485
- continue;
486
- const clear = await getPropertyClear({
487
- seedLocalId: context.seedLocalId,
488
- seedUid: context.seedUid,
489
- propertyName: basicProperty.propertyName,
490
- dataType: propertyDef?.dataType,
491
- refValueType: propertyDef?.refValueType,
492
- });
493
- if (!clear || clear.retract) {
494
- // An empty List is a value: it attests [] as before
495
- if (!(Array.isArray(value) && !clear))
496
- continue;
497
- }
498
- else {
499
- isRemoval = true;
500
- }
501
- }
502
- // Patch mode skips properties that already have an EAS uid. storageTransactionId must still
503
- // attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.
504
- if (!isRemoval && basicProperty.uid && !forceFullSnapshot) {
505
- const allowStorageTxAttestation = isStorageTransactionIdProp &&
506
- typeof value === 'string' &&
507
- value.trim() !== '';
508
- if (!allowStorageTxAttestation) {
509
- continue;
510
- }
511
- }
512
- // File/Image/Html values must be a storage seed id by now. Raw content means the property's
513
- // save pipeline never ran or failed (e.g. createNewItem with raw html), so it was never uploaded.
514
- // Relation/image properties are appended to the basic list after processRelationOrImageProperty,
515
- // so this one check covers both paths.
516
- if (!isRemoval && isFileImageHtml && typeof value === 'string' && !isStorageSeedRef(value)) {
517
- addStorageValueNotSavedError(ctx, basicProperty.propertyName, propertyDef?.dataType, value);
518
- continue;
519
- }
520
- const propertyData = await getPropertyData(basicProperty, ctx);
521
- if (!propertyData)
522
- continue;
523
- const { schemaUid, easDataType, schemaDef, propertyNameForSchema } = propertyData;
524
- if (!schemaDef)
525
- continue;
526
- let rawListIdsForResolve;
527
- if (isRemoval) {
528
- const empty = emptyEasValue(easDataType);
529
- if (empty === undefined) {
530
- addValidationError(ctx, `${basicProperty.propertyName} can't be published empty: ${propertyDef?.dataType ?? easDataType} properties have no empty value. Clear it with clear({ retract: true }).`, basicProperty.propertyName, 'publish_clear_unsupported');
531
- continue;
532
- }
533
- value = empty;
534
- }
535
- else {
536
- // Normalize value: string that parses to array (e.g. from browser storage) -> array
537
- if (schemaDef.startsWith('bytes32[]') && typeof value === 'string' && value.trim().startsWith('[')) {
538
- try {
539
- value = JSON.parse(value);
540
- }
541
- catch {
542
- // fall through to array check
543
- }
544
- }
545
- // Legacy comma-separated ids (pre-JSON List storage)
546
- if (schemaDef.startsWith('bytes32[]') &&
547
- typeof value === 'string' &&
548
- !value.trim().startsWith('[') &&
549
- value.includes(',')) {
550
- value = value
551
- .split(',')
552
- .map((s) => s.trim())
553
- .filter(Boolean);
554
- }
555
- // A ref to a published related item attests that item's current uid.
556
- if (typeof value === 'string' && (isRelation || isFileImageHtml || isJsonStorage)) {
557
- value = currentRelatedRef(ctx, value);
558
- }
559
- if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {
560
- addValidationError(ctx, `Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`, basicProperty.propertyName);
561
- continue;
562
- }
563
- // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
564
- if (propertyDef?.validation) {
565
- const { SchemaValidationService } = await import('./SchemaValidationService-CZzKNL04.js');
566
- const validationService = new SchemaValidationService();
567
- const validationResult = validationService.validatePropertyValue(value, normalizeDataType(propertyDef.dataType), propertyDef.validation, propertyDef.refValueType
568
- ? normalizeDataType(propertyDef.refValueType)
569
- : undefined);
570
- if (!validationResult.isValid && validationResult.errors.length > 0) {
571
- const firstError = validationResult.errors[0];
572
- addValidationError(ctx, firstError.message, basicProperty.propertyName, firstError.code ?? 'publish_validation');
573
- continue;
574
- }
575
- }
576
- if (schemaDef.startsWith('bytes32[]')) {
577
- const newValues = [];
578
- const rawIds = [];
579
- const iterableValue = Array.isArray(value) ? value
580
- : value != null && typeof value[Symbol.iterator] === 'function' ? value
581
- : [];
582
- for (const seedId of iterableValue) {
583
- const idStr = typeof seedId === 'string'
584
- ? seedId
585
- : seedId &&
586
- typeof seedId === 'object' &&
587
- (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)
588
- ? String(seedId.seedLocalId ??
589
- seedId.seedUid ??
590
- '')
591
- : '';
592
- if (!idStr)
593
- continue;
594
- const trimmed = currentRelatedRef(ctx, idStr.trim());
595
- if (!trimmed)
596
- continue;
597
- rawIds.push(trimmed);
598
- if (!isUidRef(trimmed)) {
599
- newValues.push(encodeBytes32String(trimmed));
600
- }
601
- else {
602
- newValues.push(trimmed);
603
- }
604
- }
605
- value = newValues;
606
- const needsUidResolve = rawIds.some((id) => !isUidRef(id));
607
- if (needsUidResolve && rawIds.length > 0) {
608
- rawListIdsForResolve = rawIds;
609
- }
610
- }
611
- // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds
612
- if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {
613
- const ms = value instanceof Date ? value.getTime() : new Date(value).getTime();
614
- value = BigInt(Math.floor(ms / 1000));
615
- }
616
- // ADR 0010: Number attests as its decimal string, in the form readers decode it to.
617
- if (matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Number)) {
618
- const decimal = decodeEasNumber(value);
619
- if (decimal === undefined) {
620
- addValidationError(ctx, `Invalid value for property: ${basicProperty.propertyName}. Expected a finite number, got ${JSON.stringify(value)}.`, basicProperty.propertyName, 'publish_invalid_number');
621
- continue;
622
- }
623
- value = decimal;
624
- }
625
- }
626
- const data = [
627
- {
628
- name: propertyNameForSchema,
629
- type: easDataType,
630
- value,
631
- },
632
- ];
633
- let encodedData;
634
- try {
635
- const { SchemaEncoder } = await loadEasSdk();
636
- const dataEncoder = new SchemaEncoder(schemaDef);
637
- encodedData = dataEncoder.encodeData(data);
638
- }
639
- catch (encodeErr) {
640
- addValidationError(ctx, `Failed to encode property ${basicProperty.propertyName}: ${encodeErr instanceof Error ? encodeErr.message : String(encodeErr)}`, basicProperty.propertyName);
641
- continue;
642
- }
643
- // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)
644
- const refUid = isStorageTransactionIdProp
645
- ? itemPublishData.versionUid
646
- : defaultAttestationData.refUID;
647
- const attestationEntry = {
648
- schema: schemaUid,
649
- data: [
650
- {
651
- ...defaultAttestationData,
652
- refUID: refUid,
653
- data: encodedData,
654
- },
655
- ],
656
- // Always set so persist can match metadata rows that lack schemaUid
657
- _propertyName: basicProperty.propertyName,
658
- // The row whose value this attests; recording gives the uid to exactly that row.
659
- ...(context.localId ? { _metadataLocalId: context.localId } : {}),
660
- };
661
- // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues
662
- const looksLikeLocalSeedRef = typeof value === 'string' &&
663
- !isUidRef(value) &&
664
- /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim());
665
- if (looksLikeLocalSeedRef &&
666
- (easDataType === 'bytes32' || easDataType === 'string')) {
667
- attestationEntry._propertyName = basicProperty.propertyName;
668
- attestationEntry._propertyNameForSchema = propertyNameForSchema;
669
- attestationEntry._schemaDef = schemaDef;
670
- attestationEntry._unresolvedValue = value.trim();
671
- attestationEntry._easDataType = easDataType;
672
- }
673
- if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {
674
- attestationEntry._propertyName = basicProperty.propertyName;
675
- attestationEntry._propertyNameForSchema = propertyNameForSchema;
676
- attestationEntry._schemaDef = schemaDef;
677
- attestationEntry._easDataType = 'bytes32[]';
678
- attestationEntry._rawListIdsForResolve = rawListIdsForResolve;
679
- }
680
- itemPublishData.listOfAttestations.push(attestationEntry);
681
- }
682
- return itemPublishData;
683
- };
684
- const processRelationOrImageProperty = async (relationOrImageProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx, buildOpts) => {
685
- const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
686
- // Resolve from the definition like every other property; the cached schemaUid was found by
687
- // name alone and can belong to a schema of another type.
688
- let relationOrImageSchemaUid;
689
- if (relationOrImageProperty.propertyDef) {
690
- const propertyData = await getPropertyData(relationOrImageProperty, ctx);
691
- if (!propertyData)
692
- return multiPublishPayload;
693
- relationOrImageSchemaUid = propertyData.schemaUid;
694
- }
695
- else {
696
- relationOrImageSchemaUid = relationOrImageProperty.schemaUid;
697
- }
698
- if (!relationOrImageSchemaUid) {
699
- addValidationError(ctx, `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`, relationOrImageProperty.propertyName);
700
- return multiPublishPayload;
701
- }
702
- const snapshot = relationOrImageProperty.getService().getSnapshot();
703
- const context = 'context' in snapshot ? snapshot.context : null;
704
- if (!context) {
705
- return multiPublishPayload;
706
- }
707
- let value = context.propertyValue;
708
- // File/Image/Html/Json metadata is stored with Id suffix (e.g. "textId"); context may not have propertyValue
709
- // if the property was created from schema before metadata loaded. Fallback to metadata lookup.
710
- const isStorageSeed = matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File) ||
711
- matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image) ||
712
- matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html) ||
713
- matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Json) ||
714
- (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation) &&
715
- (matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.File) ||
716
- matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Image) ||
717
- matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Html) ||
718
- matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Json)));
719
- if (isStorageSeed && (context.seedLocalId || context.seedUid)) {
720
- const _mod_1 = await import('./Item-CG5IhPtL.js');
721
- const _ns_1 = _mod_1.au;
722
- const { getPropertyData: getPropertyDataFromDb } = _ns_1;
723
- const metaRow = await getPropertyDataFromDb({
724
- propertyName: relationOrImageProperty.propertyName,
725
- seedLocalId: context.seedLocalId,
726
- seedUid: context.seedUid,
727
- });
728
- const fromMeta = metaRow?.propertyValue;
729
- if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {
730
- const idsCtx = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '');
731
- const idsDb = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(fromMeta) ?? '');
732
- if (!value) {
733
- value = fromMeta;
734
- }
735
- else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {
736
- value = fromMeta;
737
- }
738
- }
739
- }
740
- const propertyDef = relationOrImageProperty.propertyDef;
741
- let isRequired = propertyDef?.required === true;
742
- // Resolve required from schema/DB when propertyDef lacks it
743
- if (!isRequired && relationOrImageProperty.modelName) {
744
- const propertyScope = await getItemModelScope(relationOrImageProperty);
745
- let schema = await getPropertySchema(relationOrImageProperty.modelName, relationOrImageProperty.propertyName, propertyScope);
746
- if (!schema && BaseDb.getAppDb()) {
747
- const normalizedModelName = upperFirst(camelCase(relationOrImageProperty.modelName));
748
- const modelRecord = await resolveModelRecord(normalizedModelName, propertyScope);
749
- const modelRecords = modelRecord ? [modelRecord] : [];
750
- if (modelRecords.length > 0 && modelRecords[0].id) {
751
- const propertyRecords = await BaseDb.getAppDb()
752
- .select()
753
- .from(properties)
754
- .where(and(eq(properties.modelId, modelRecords[0].id), eq(properties.name, relationOrImageProperty.propertyName)))
755
- .limit(1);
756
- if (propertyRecords.length > 0) {
757
- schema = {
758
- dataType: propertyRecords[0].dataType,
759
- ref: undefined,
760
- required: propertyRecords[0].required ?? undefined,
761
- };
762
- }
763
- }
764
- }
765
- if (schema?.required === true || schema?.required === 1) {
766
- isRequired = true;
767
- }
768
- }
769
- // Required relation/image/file/html/json with no value: cannot publish
770
- if (isRequired && !value) {
771
- const typeLabel = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||
772
- matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.File)
773
- ? 'file'
774
- : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||
775
- matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Image)
776
- ? 'image'
777
- : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html) ||
778
- matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Html)
779
- ? 'html'
780
- : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||
781
- matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json)
782
- ? 'json'
783
- : 'relation';
784
- const refLabel = propertyDef?.ref ?? propertyDef?.refModelName ?? 'related';
785
- addValidationError(ctx, `Required ${typeLabel} ${relationOrImageProperty.propertyName} has no value. ` +
786
- `A value pointing to a valid ${refLabel} item is required to publish.`, relationOrImageProperty.propertyName);
787
- return multiPublishPayload;
788
- }
789
- if (!value) {
790
- return multiPublishPayload;
791
- }
792
- if (relationOrImageProperty.uid && !forceFullSnapshot) {
793
- return multiPublishPayload;
794
- }
795
- const normalizedRef = normalizeRelationPropertyValue(value);
796
- const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizedRef ?? '');
797
- // Value is not a valid seed reference (local id or 0x uid)
798
- if (!seedLocalId && !seedUid) {
799
- if (isRequired) {
800
- addValidationError(ctx, `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +
801
- `Value must be a valid seed reference (localId or uid) pointing to a ${propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'} item.`, relationOrImageProperty.propertyName);
802
- }
803
- return multiPublishPayload;
804
- }
805
- // The local seed, also when the ref is the old uid of a seed published again since.
806
- const relatedSeed = await findRelatedSeedRow({ seedLocalId, seedUid });
807
- if (!isStorageSeed && deferIfBackEdge(ctx, relationOrImageProperty, [relatedSeed?.seedLocalId ?? seedLocalId])) {
808
- return multiPublishPayload;
809
- }
810
- const relatedItem = await ctx.loads.getItem(relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid });
811
- if (noteRelatedSeed(ctx, normalizedRef, relatedSeed, relationOrImageProperty.propertyName, relatedItem?.modelName ?? relatedModelNameFromDef(relationOrImageProperty.propertyDef))) {
812
- return multiPublishPayload;
813
- }
814
- // When related item not found (e.g. different DB, not yet created)
815
- if (!relatedItem) {
816
- // An attested uid with no local copy is already published; the parent attests the uid as-is.
817
- if (isRequired && !isPublishedSeedRef(normalizedRef)) {
818
- addValidationError(ctx, `No related item found for required relation: ${relationOrImageProperty.propertyName}. ` +
819
- `Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +
820
- `The related item may be missing, in a different database, or the reference may be broken.`, relationOrImageProperty.propertyName);
821
- }
822
- return multiPublishPayload;
823
- }
824
- // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent
825
- if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
826
- return multiPublishPayload;
827
- }
828
- let modelName;
829
- if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {
830
- modelName = 'Image';
831
- }
832
- if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {
833
- modelName = 'File';
834
- }
835
- if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {
836
- modelName = 'Html';
837
- }
838
- if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation)) {
839
- const def = relationOrImageProperty.propertyDef;
840
- modelName = def.ref ?? def.refModelName;
841
- }
842
- if (!modelName) {
843
- addValidationError(ctx, `Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`, relationOrImageProperty.propertyName);
844
- return multiPublishPayload;
845
- }
846
- return processRelatedDraftItem({
847
- relatedItem,
848
- modelName,
849
- // A storage seed (Image/File/Html/Json item) attests its own basic properties; a related model
850
- // item is published with its full property set and the draft items it reaches in turn.
851
- fullDraft: !isStorageSeed,
852
- link: { publishLocalId: originalSeedLocalId, propertySchemaUid: relationOrImageSchemaUid },
853
- reportPropertyName: relationOrImageProperty.propertyName,
854
- multiPublishPayload,
855
- uploadedTransactions,
856
- ctx,
857
- buildOpts,
858
- });
859
- };
860
- /**
861
- * The payload of a draft item (no seed uid) a published item refers to, published with it. Its
862
- * request fills the referring property (`link`) through propertiesToUpdate. With `fullDraft`, the
863
- * item's whole property set is attested: its storage seeds and Html-embedded images, and its own
864
- * relation and list properties, whose draft targets are published with it in turn (depth first,
865
- * see publishDraftGraph.ts). A draft already in the batch only gains the link.
866
- */
867
- async function processRelatedDraftItem({ relatedItem, modelName, fullDraft, link, reportPropertyName, multiPublishPayload, uploadedTransactions, ctx, buildOpts, }) {
868
- const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
869
- const seedSchemaUid = await getEasSchemaUidForModel(modelName);
870
- if (!seedSchemaUid) {
871
- addValidationError(ctx, `Schema UID not found for model: ${modelName}`, reportPropertyName);
872
- return multiPublishPayload;
873
- }
874
- if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {
875
- if (link) {
876
- mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, link.publishLocalId, link.propertySchemaUid);
877
- }
878
- return multiPublishPayload;
879
- }
880
- let publishPayload = {
881
- localId: relatedItem.seedLocalId,
882
- seedIsRevocable: true,
883
- versionSchemaUid: VERSION_SCHEMA_UID,
884
- seedUid: ZERO_BYTES32,
885
- seedSchemaUid,
886
- versionUid: getVersionUid(relatedItem),
887
- listOfAttestations: [],
888
- propertiesToUpdate: link ? [{ ...link }] : [],
889
- };
890
- ctx.newSeedsInProgress ?? (ctx.newSeedsInProgress = new Set());
891
- ctx.newSeedsInProgress.add(relatedItem.seedLocalId);
892
- try {
893
- await ensurePropertyDefs(relatedItem);
894
- const segmented = await getSegmentedItemProperties(relatedItem);
895
- const { itemBasicProperties, itemUploadProperties, itemImageProperties: relatedStorageSeedProperties } = segmented;
896
- if (fullDraft) {
897
- // Its own Image/File/Html/Json properties and the images embedded in its Html (as for the item itself).
898
- multiPublishPayload = await processRelatedDraftStorageSeeds(relatedItem, relatedStorageSeedProperties, itemBasicProperties, multiPublishPayload, uploadedTransactions, ctx, buildOpts);
899
- // Its relations and lists: their draft targets are published too (same walk as publishDraftGraph).
900
- const { relationProperties, listProperties } = draftWalkProperties(segmented);
901
- for (const relationProperty of relationProperties) {
902
- multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
903
- itemBasicProperties.push(relationProperty);
904
- }
905
- for (const listProperty of listProperties) {
906
- multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
907
- itemBasicProperties.push(listProperty);
908
- }
909
- }
910
- const relatedStorageUpload = resolveStorageTransactionUploadSlot(relatedItem, itemUploadProperties);
911
- if (relatedStorageUpload) {
912
- const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, relatedItem.seedLocalId);
913
- if (transactionData) {
914
- const itemProperty = relatedStorageUpload.itemProperty;
915
- // Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it
916
- // uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.
917
- itemProperty.getService().send({
918
- type: 'updateContext',
919
- propertyValue: transactionData.txId,
920
- renderValue: transactionData.txId,
921
- });
922
- replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
923
- }
924
- }
925
- for (const p of itemBasicProperties) {
926
- if (isStorageTransactionPropertyName(p.propertyName) &&
927
- !p.propertyDef &&
928
- relatedItem.modelName) {
929
- const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId', await getItemModelScope(relatedItem));
930
- if (schema) {
931
- p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
932
- }
933
- }
934
- }
935
- dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
936
- publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
937
- forceFullSnapshot,
938
- });
939
- }
940
- finally {
941
- ctx.newSeedsInProgress.delete(relatedItem.seedLocalId);
942
- }
943
- multiPublishPayload.push(publishPayload);
944
- return multiPublishPayload;
945
- }
946
- /**
947
- * Storage-seed properties (Image/File/Html/Json) of a draft item related to the published one, and
948
- * the images embedded in its Html (htmlEmbeddedImageCoPublish rows it owns): payloads for their seeds,
949
- * and the properties added to `itemBasicProperties` so the related item attests them. Same handling
950
- * as the published item's own (see getPublishPayload).
951
- */
952
- async function processRelatedDraftStorageSeeds(relatedItem, storageSeedProperties, itemBasicProperties, multiPublishPayload, uploadedTransactions, ctx, buildOpts) {
953
- for (const storageSeedProperty of storageSeedProperties) {
954
- multiPublishPayload = await processRelationOrImageProperty(storageSeedProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
955
- itemBasicProperties.push(storageSeedProperty);
956
- }
957
- return processHtmlEmbeddedCoPublishImagePayloads(relatedItem, multiPublishPayload, uploadedTransactions, ctx, buildOpts);
958
- }
959
- async function resolveHtmlPropertySchemaUidByHtmlSeed(item, htmlSeedLocalId, ctx) {
960
- const want = htmlSeedLocalId.trim();
961
- for (const p of item.properties) {
962
- if (!matchesDataType(p.propertyDef?.dataType, ModelPropertyDataTypes.Html))
963
- continue;
964
- const snap = p.getService().getSnapshot();
965
- const c = 'context' in snap ? snap.context : null;
966
- const pv = typeof c?.propertyValue === 'string' ? c.propertyValue.trim() : '';
967
- if (pv !== want)
968
- continue;
969
- // Resolved like the Html property's own attestation, so a schema it lacks fails here too. The
970
- // caller only checks that a uid was found: embedded images don't update the Html property.
971
- return (await getPropertyData(p, ctx))?.schemaUid;
972
- }
973
- addValidationError(ctx, `Could not find Html property for embedded image rewrite (html seed ${want}).`, 'html', 'html_embed_schema');
974
- return undefined;
975
- }
976
- async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions, ctx, buildOpts) {
977
- const appDb = BaseDb.getAppDb();
978
- if (!appDb)
979
- return multiPublishPayload;
980
- const rows = await appDb
981
- .select()
982
- .from(htmlEmbeddedImageCoPublish)
983
- .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId));
984
- if (rows.length === 0)
985
- return multiPublishPayload;
986
- const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
987
- const doneImages = new Set();
988
- for (const row of rows) {
989
- if (doneImages.has(row.imageSeedLocalId))
990
- continue;
991
- doneImages.add(row.imageSeedLocalId);
992
- // An embedded image that is already published is not co-published; one whose seed was revoked
993
- // (unpublished) blocks the publish like an image property pointing at it would.
994
- const imageSeed = await findRelatedSeedRow({ seedLocalId: row.imageSeedLocalId });
995
- if (noteRelatedSeed(ctx, row.imageSeedLocalId, imageSeed, htmlPropertyNameForHtmlSeed(item, row.htmlSeedLocalId), 'Image')) {
996
- continue;
997
- }
998
- // The row's Html seed must still be the value of one of the item's Html properties.
999
- const htmlSchemaUid = await resolveHtmlPropertySchemaUidByHtmlSeed(item, row.htmlSeedLocalId, ctx);
1000
- if (!htmlSchemaUid)
1001
- continue;
1002
- const relatedItem = await ctx.loads.getItem({ seedLocalId: row.imageSeedLocalId });
1003
- if (!relatedItem) {
1004
- addValidationError(ctx, `Embedded Image item not found for seed ${row.imageSeedLocalId}.`, 'html', 'html_embed_image_missing');
1005
- continue;
1006
- }
1007
- if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
1008
- continue;
1009
- }
1010
- const seedSchemaUid = await getEasSchemaUidForModel('Image');
1011
- if (!seedSchemaUid) {
1012
- addValidationError(ctx, `Schema UID not found for model: Image`, 'html');
1013
- continue;
1014
- }
1015
- // Already in the batch (e.g. also the value of an Image property): its payload is there.
1016
- if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {
1017
- continue;
1018
- }
1019
- const versionUid = getVersionUid(relatedItem);
1020
- // No propertiesToUpdate: the Html refers to the image by its Arweave URL (the data URI is
1021
- // rewritten to it before the Html is uploaded), not by seed uid. The Html property holds the Html
1022
- // storage seed's uid, which the Html seed's own request writes into it; the contract writes each
1023
- // updater's seed uid into the same data[0] (SeedPublishLib.setSeedReference), so an image
1024
- // targeting the Html property too would overwrite that reference with the image's seed uid.
1025
- let publishPayload = {
1026
- localId: relatedItem.seedLocalId,
1027
- seedIsRevocable: true,
1028
- versionSchemaUid: VERSION_SCHEMA_UID,
1029
- seedUid: relatedItem.seedUid || ZERO_BYTES32,
1030
- seedSchemaUid,
1031
- versionUid,
1032
- listOfAttestations: [],
1033
- propertiesToUpdate: [],
1034
- };
1035
- await ensurePropertyDefs(relatedItem);
1036
- const { itemBasicProperties, itemUploadProperties } = await getSegmentedItemProperties(relatedItem);
1037
- const relatedStorageUpload = resolveStorageTransactionUploadSlot(relatedItem, itemUploadProperties);
1038
- if (relatedStorageUpload) {
1039
- const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, relatedItem.seedLocalId);
1040
- if (transactionData) {
1041
- const itemProperty = relatedStorageUpload.itemProperty;
1042
- itemProperty.getService().send({
1043
- type: 'updateContext',
1044
- propertyValue: transactionData.txId,
1045
- renderValue: transactionData.txId,
1046
- });
1047
- replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
1048
- }
1049
- }
1050
- for (const p of itemBasicProperties) {
1051
- if (isStorageTransactionPropertyName(p.propertyName) &&
1052
- !p.propertyDef &&
1053
- relatedItem.modelName) {
1054
- const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId', await getItemModelScope(relatedItem));
1055
- if (schema) {
1056
- p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
1057
- }
1058
- }
1059
- }
1060
- dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
1061
- publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
1062
- forceFullSnapshot,
1063
- });
1064
- multiPublishPayload.push(publishPayload);
1065
- }
1066
- return multiPublishPayload;
1067
- }
1068
- const processListProperty = async (listProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx, buildOpts) => {
1069
- const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
1070
- // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties
1071
- if (!listProperty.propertyDef?.ref) {
1072
- addValidationError(ctx, `processListProperty requires ref (list of relations). List property "${listProperty.propertyName}" has no ref. List-of-primitives should be in itemBasicProperties.`, listProperty.propertyName);
1073
- return multiPublishPayload;
1074
- }
1075
- const snapshot = listProperty.getService().getSnapshot();
1076
- const context = 'context' in snapshot ? snapshot.context : null;
1077
- if (!context) {
1078
- return multiPublishPayload;
1079
- }
1080
- let value = context.propertyValue;
1081
- if (!value) {
1082
- return multiPublishPayload;
1083
- }
1084
- if (listProperty.uid && !forceFullSnapshot) {
1085
- return multiPublishPayload;
1086
- }
1087
- // Always resolve from the property definition; a cached schemaUid may point at a schema
1088
- // registered under the schema key (bytes32[] authors) instead of authorIdentityIds.
1089
- const propertyData = await getPropertyData(listProperty, ctx);
1090
- if (!propertyData)
1091
- return multiPublishPayload;
1092
- const listPropertySchemaUid = propertyData.schemaUid;
1093
- if (typeof value === 'string') {
1094
- value = parseListPropertyValueFromStorage(value);
1095
- }
1096
- const iterableValue = Array.isArray(value)
1097
- ? value
1098
- : value != null
1099
- ? [value]
1100
- : [];
1101
- const members = [];
1102
- for (const seedId of iterableValue) {
1103
- const idStr = typeof seedId === 'string'
1104
- ? seedId
1105
- : seedId &&
1106
- typeof seedId === 'object' &&
1107
- (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid);
1108
- if (!idStr)
1109
- continue;
1110
- const { localId: seedLocalId, uid: seedUid } = getCorrectId(idStr);
1111
- if (!seedLocalId && !seedUid)
1112
- continue;
1113
- members.push({ idStr, seedLocalId, seedUid });
1114
- }
1115
- // A member that is an item still in progress (a cycle back to it) can't be attested in this
1116
- // publish, so the list is deferred; its other draft members are still published, unlinked.
1117
- const memberSeeds = await Promise.all(members.map((m) => findRelatedSeedRow({ seedLocalId: m.seedLocalId, seedUid: m.seedUid })));
1118
- const deferred = deferIfBackEdge(ctx, listProperty, members.map((m, i) => memberSeeds[i]?.seedLocalId ?? m.seedLocalId));
1119
- for (let i = 0; i < members.length; i++) {
1120
- const { idStr, seedLocalId, seedUid } = members[i];
1121
- const relatedSeed = memberSeeds[i] ?? null;
1122
- const memberLocalId = relatedSeed?.seedLocalId ?? seedLocalId;
1123
- if (memberLocalId && ctx.newSeedsInProgress?.has(memberLocalId))
1124
- continue;
1125
- const relatedItem = await ctx.loads.getItem(relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid });
1126
- if (noteRelatedSeed(ctx, idStr.trim(), relatedSeed, listProperty.propertyName, relatedItem?.modelName ?? relatedModelNameFromDef(listProperty.propertyDef))) {
1127
- continue;
1128
- }
1129
- if (!relatedItem) {
1130
- // An attested uid with no local copy is already published; the list attests the uid as-is.
1131
- if (!isPublishedSeedRef(idStr)) {
1132
- console.error(`No related item found for list property: ${listProperty.propertyName}`);
1133
- }
1134
- continue;
1135
- }
1136
- if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
1137
- continue;
1138
- }
1139
- let modelName;
1140
- if (listProperty.propertyDef?.ref || listProperty.propertyDef.refModelName) {
1141
- const def = listProperty.propertyDef;
1142
- modelName = def.ref ?? def.refModelName;
1143
- }
1144
- if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {
1145
- modelName = 'Image';
1146
- }
1147
- if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {
1148
- modelName = 'File';
1149
- }
1150
- if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {
1151
- modelName = 'Html';
1152
- }
1153
- if (!modelName) {
1154
- addValidationError(ctx, `Model name not found for list property: ${listProperty.propertyName}`, listProperty.propertyName);
1155
- continue;
1156
- }
1157
- multiPublishPayload = await processRelatedDraftItem({
1158
- relatedItem,
1159
- modelName,
1160
- fullDraft: true,
1161
- link: deferred ? null : { publishLocalId: originalSeedLocalId, propertySchemaUid: listPropertySchemaUid },
1162
- reportPropertyName: listProperty.propertyName,
1163
- multiPublishPayload,
1164
- uploadedTransactions,
1165
- ctx,
1166
- buildOpts,
1167
- });
1168
- }
1169
- return multiPublishPayload;
1170
- };
1171
- /**
1172
- * Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so
1173
- * duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.
1174
- */
1175
- function attestationPayloadDedupeKey(att) {
1176
- const schema = String(att.schema ?? '').toLowerCase();
1177
- const dataArr = att.data;
1178
- const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined;
1179
- const dataHex = d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0
1180
- ? String(d0.data ?? '').toLowerCase()
1181
- : '';
1182
- return `${schema}:${dataHex}`;
1183
- }
1184
- /**
1185
- * Collapse duplicate rows in listOfAttestations (same schema + encoded payload).
1186
- */
1187
- function dedupeListOfAttestationsInEachPayload(payload) {
1188
- for (const p of payload) {
1189
- const list = p.listOfAttestations ?? [];
1190
- if (list.length <= 1)
1191
- continue;
1192
- const seen = new Set();
1193
- const out = [];
1194
- for (const a of list) {
1195
- const k = attestationPayloadDedupeKey(a);
1196
- if (seen.has(k))
1197
- continue;
1198
- seen.add(k);
1199
- out.push(a);
1200
- }
1201
- p.listOfAttestations = out;
1202
- }
1203
- return payload;
1204
- }
1205
- /**
1206
- * Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).
1207
- * Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.
1208
- */
1209
- function dedupeMultiPublishPayloadByLocalId(payload) {
1210
- const map = new Map();
1211
- const order = [];
1212
- for (const p of payload) {
1213
- const id = p.localId;
1214
- const existing = map.get(id);
1215
- if (!existing) {
1216
- map.set(id, p);
1217
- order.push(id);
1218
- continue;
1219
- }
1220
- const ptu = [...(existing.propertiesToUpdate ?? [])];
1221
- for (const u of p.propertiesToUpdate ?? []) {
1222
- if (!ptu.some((e) => e.publishLocalId === u.publishLocalId &&
1223
- String(e.propertySchemaUid ?? '').toLowerCase() ===
1224
- String(u.propertySchemaUid ?? '').toLowerCase())) {
1225
- ptu.push(u);
1226
- }
1227
- }
1228
- existing.propertiesToUpdate = ptu;
1229
- const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)));
1230
- const merged = [...(existing.listOfAttestations ?? [])];
1231
- for (const a of p.listOfAttestations ?? []) {
1232
- const k = attestationPayloadDedupeKey(a);
1233
- if (seenKeys.has(k))
1234
- continue;
1235
- seenKeys.add(k);
1236
- merged.push(a);
1237
- }
1238
- existing.listOfAttestations = merged;
1239
- }
1240
- return order.map((id) => map.get(id)).filter(Boolean);
1241
- }
1242
- /**
1243
- * Child File/Image items may keep storageTransactionId only on the item machine's
1244
- * propertyInstances map; allProperties / item.properties can omit it during publish.
1245
- */
1246
- function getStorageTransactionPropertyFromItemInstances(item) {
1247
- try {
1248
- const svc = item.getService?.();
1249
- if (!svc)
1250
- return undefined;
1251
- const snap = svc.getSnapshot();
1252
- const instances = snap.context?.propertyInstances;
1253
- if (!instances || !(instances instanceof Map))
1254
- return undefined;
1255
- const direct = instances.get('storageTransactionId') ?? instances.get('storage_transaction_id');
1256
- if (direct)
1257
- return direct;
1258
- for (const [, p] of instances) {
1259
- if (p && isStorageTransactionPropertyName(p.propertyName))
1260
- return p;
1261
- }
1262
- }
1263
- catch {
1264
- return undefined;
1265
- }
1266
- return undefined;
1267
- }
1268
- /**
1269
- * Resolve storageTransactionId (+ ItemStorage children) for publish.
1270
- * getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never
1271
- * hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while
1272
- * getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.
1273
- */
1274
- function resolveStorageTransactionUploadSlot(item, itemUploadProperties) {
1275
- const named = itemUploadProperties.find((u) => isStorageTransactionPropertyName(u.itemProperty.propertyName));
1276
- if (named)
1277
- return named;
1278
- if (itemUploadProperties.length === 1)
1279
- return itemUploadProperties[0];
1280
- const all = item.allProperties;
1281
- const fromInstances = getStorageTransactionPropertyFromItemInstances(item);
1282
- const storagePropEarly = all?.['storageTransactionId'] ??
1283
- all?.['storage_transaction_id'] ??
1284
- Object.values(all ?? {}).find((p) => !!p && isStorageTransactionPropertyName(p.propertyName)) ??
1285
- item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName));
1286
- const storageProp = storagePropEarly ?? fromInstances;
1287
- if (!storageProp)
1288
- return undefined;
1289
- const childProps = item.properties?.filter((p) => p.propertyDef &&
1290
- p.propertyDef.storageType === 'ItemStorage') ?? [];
1291
- return { itemProperty: storageProp, childProperties: childProps };
1292
- }
1293
- function findUploadedTxForSeedLocalId(uploadedTransactions, seedLocalId) {
1294
- const t = seedLocalId.trim();
1295
- return (uploadedTransactions.find((u) => u.seedLocalId === t) ??
1296
- uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t));
1297
- }
1298
- const getPublishPayload = async (item, uploadedTransactions, options) => {
1299
- // Every edit made before publishing is in `metadata` first (ADR 0019)
1300
- const { waitForPendingOutboxOps } = await import('./index-njjjo74v.js');
1301
- await waitForPendingOutboxOps();
1302
- const validationCtx = { errors: [], loads: new ItemLoads() };
1303
- try {
1304
- return await buildPublishPayload(item, uploadedTransactions, validationCtx, options);
1305
- }
1306
- finally {
1307
- validationCtx.loads.release();
1308
- }
1309
- };
1310
- const buildPublishPayload = async (item, uploadedTransactions, validationCtx, options) => {
1311
- const publishMode = options?.publishMode ?? 'patch';
1312
- // A revoked seed can't be published under again: republishing creates a new seed attestation
1313
- // (new seedUid) and a new version carrying every property (see docs/ATTESTATION_REVOCATION.md).
1314
- const hasSeedUid = !!item.seedUid && item.seedUid !== ZERO_BYTES32;
1315
- const republishRevokedSeed = hasSeedUid && (await isSeedRevoked(item.seedLocalId));
1316
- const rootSeedUid = republishRevokedSeed ? ZERO_BYTES32 : item.seedUid || ZERO_BYTES32;
1317
- const forceFullSnapshot = publishMode === 'new_version' || republishRevokedSeed;
1318
- if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === ZERO_BYTES32)) {
1319
- 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');
1320
- }
1321
- let multiPublishPayload = [];
1322
- // The root gets a new seed (draft, or revoked seed published again): related drafts referring
1323
- // back to it can't attest its uid in this publish (see publishDraftGraph.ts).
1324
- if (rootSeedUid === ZERO_BYTES32) {
1325
- validationCtx.newSeedsInProgress = new Set([item.seedLocalId]);
1326
- }
1327
- // Each PublishPayload is generated from a Seed that needs publishing
1328
- // First we need to determine all Seeds to publish
1329
- // That means the Seed of the Item, plus any Seeds pointed to by Relations
1330
- // Check if the item has a schema UID
1331
- let itemSchemaUid = item.schemaUid;
1332
- if (!itemSchemaUid) {
1333
- const schemaUid = await getEasSchemaUidForModel(item.modelName);
1334
- if (!schemaUid) {
1335
- addValidationError(validationCtx, `Schema UID not found for model: ${item.modelName}`);
1336
- itemSchemaUid = ZERO_BYTES32; // placeholder so we can continue collecting errors
1337
- }
1338
- else {
1339
- itemSchemaUid = schemaUid;
1340
- }
1341
- }
1342
- let versionUid = getVersionUid(item);
1343
- if (versionUid === ZERO_BYTES32 && rootSeedUid !== ZERO_BYTES32) {
1344
- versionUid = await resolveVersionUid(item.seedLocalId, rootSeedUid);
1345
- }
1346
- if (forceFullSnapshot && hasSeedUid) {
1347
- versionUid = ZERO_BYTES32;
1348
- }
1349
- let itemPublishData = {
1350
- localId: item.seedLocalId,
1351
- seedUid: rootSeedUid,
1352
- seedIsRevocable: true,
1353
- seedSchemaUid: itemSchemaUid,
1354
- versionSchemaUid: VERSION_SCHEMA_UID,
1355
- versionUid,
1356
- listOfAttestations: [],
1357
- propertiesToUpdate: [],
1358
- };
1359
- await ensurePropertyDefs(item);
1360
- const { itemBasicProperties, itemListProperties, itemUploadProperties, itemImageProperties, itemRelationProperties, } = await getSegmentedItemProperties(item);
1361
- const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties];
1362
- // Validate required relations have values before processing
1363
- for (const relProp of itemRelationProperties) {
1364
- const snapshot = relProp.getService().getSnapshot();
1365
- const ctx = 'context' in snapshot ? snapshot.context : null;
1366
- const val = ctx ? ctx.renderValue ?? ctx.propertyValue : undefined;
1367
- if (val != null && typeof val === 'string' && val.trim() !== '')
1368
- continue;
1369
- // No value - check if required from propertyDef or DB
1370
- let isRequired = relProp.propertyDef?.required === true;
1371
- if (!isRequired && BaseDb.getAppDb() && item.modelName) {
1372
- const normalizedModelName = upperFirst(camelCase(item.modelName));
1373
- const modelRecord = await resolveModelRecord(normalizedModelName, await getItemModelScope(item));
1374
- const modelRows = modelRecord ? [modelRecord] : [];
1375
- if (modelRows.length > 0) {
1376
- const propRows = await BaseDb.getAppDb()
1377
- .select({ required: properties.required, refModelId: properties.refModelId })
1378
- .from(properties)
1379
- .where(and(eq(properties.modelId, modelRows[0].id), eq(properties.name, relProp.propertyName), sql `lower(${properties.dataType}) = 'relation'`))
1380
- .limit(1);
1381
- if (propRows.length > 0 && (propRows[0].required === true || propRows[0].required === 1)) {
1382
- isRequired = true;
1383
- }
1384
- }
1385
- }
1386
- if (isRequired) {
1387
- const refModel = relProp.propertyDef?.ref ?? relProp.propertyDef?.refModelName ?? 'related';
1388
- addValidationError(validationCtx, `Required relation ${relProp.propertyName} has no value. ` +
1389
- `A value pointing to a valid ${refModel} item is required to publish.`, relProp.propertyName);
1390
- }
1391
- }
1392
- const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties);
1393
- if (rootStorageUpload) {
1394
- const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId);
1395
- if (transactionData) {
1396
- const itemProperty = rootStorageUpload.itemProperty;
1397
- itemProperty.getService().send({
1398
- type: 'updateContext',
1399
- propertyValue: transactionData.txId,
1400
- renderValue: transactionData.txId,
1401
- });
1402
- replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
1403
- }
1404
- }
1405
- for (const relationProperty of relationAndImageProperties) {
1406
- multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
1407
- itemBasicProperties.push(relationProperty);
1408
- }
1409
- multiPublishPayload = await processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions, validationCtx, { forceFullSnapshot });
1410
- for (const listProperty of itemListProperties) {
1411
- multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
1412
- itemBasicProperties.push(listProperty);
1413
- }
1414
- for (const p of itemBasicProperties) {
1415
- if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {
1416
- const schema = await getPropertySchema(item.modelName, 'storageTransactionId', await getItemModelScope(item));
1417
- if (schema) {
1418
- p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
1419
- }
1420
- }
1421
- }
1422
- dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
1423
- itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData, validationCtx, { forceFullSnapshot });
1424
- multiPublishPayload.push(itemPublishData);
1425
- // Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),
1426
- // A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's
1427
- // attestation before B is sent to EAS.
1428
- multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload);
1429
- multiPublishPayload = orderPayloadByDependencies(multiPublishPayload);
1430
- // Ensure attestations referenced in propertiesToUpdate have at least one data element.
1431
- // The contract writes the seed UID into data[0].data; empty data causes Panic 50.
1432
- multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload);
1433
- multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload);
1434
- if (publishMode === 'new_version') {
1435
- const rootPayload = multiPublishPayload.find((p) => p.localId === item.seedLocalId);
1436
- const listLen = rootPayload?.listOfAttestations?.length ?? 0;
1437
- if (!rootPayload || listLen === 0) {
1438
- addValidationError(validationCtx, 'Publishing as a new version requires at least one property attestation for the item. ' +
1439
- 'Ensure required fields have values and that publishable properties are present.', 'listOfAttestations', 'publish_new_version_empty_snapshot');
1440
- }
1441
- }
1442
- // Stop before anything is uploaded or attested: the payload would attest revoked seed uids.
1443
- if (validationCtx.unpublishedRelatedItems?.length) {
1444
- throw new RelatedItemUnpublishedError(validationCtx.unpublishedRelatedItems, validationCtx.errors);
1445
- }
1446
- if (validationCtx.errors.length > 0) {
1447
- const combinedMessage = validationCtx.errors.map((e) => e.message).join('\n');
1448
- throw new PublishValidationFailedError(`Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\n${combinedMessage}`, validationCtx.errors);
1449
- }
1450
- return multiPublishPayload;
1451
- };
1452
- /**
1453
- * Validates an item for publishing without performing Arweave or EAS work.
1454
- * Use in the checking step to fail fast before creating transactions.
1455
- * Pass empty array for uploadedTransactions when validating before Arweave upload.
1456
- */
1457
- const validateItemForPublish = async (item, uploadedTransactions = [], options) => {
1458
- try {
1459
- await getPublishPayload(item, uploadedTransactions, options);
1460
- return { isValid: true, errors: [] };
1461
- }
1462
- catch (err) {
1463
- if (err instanceof PublishValidationFailedError) {
1464
- return { isValid: false, errors: err.validationErrors };
1465
- }
1466
- throw err;
1467
- }
1468
- };
1469
- /**
1470
- * Normalize a schema UID to 0x-prefixed 64-char hex for comparison.
1471
- */
1472
- function normalizeSchemaUid(v) {
1473
- if (v == null || v === '')
1474
- return '';
1475
- const raw = v.startsWith('0x') ? v.slice(2) : v;
1476
- const hex = raw.replace(/[^0-9a-fA-F]/g, '0').padStart(64, '0').slice(-64);
1477
- return ('0x' + hex).toLowerCase();
1478
- }
1479
- /**
1480
- * Ensure that when request A has propertiesToUpdate with (publishLocalId: B, propertySchemaUid: X),
1481
- * request B has an attestation for schema X with at least one data element. The contract writes
1482
- * the seed UID into data[0].data; empty data causes Panic 50.
1483
- */
1484
- function ensurePropertiesToUpdateAttestationsHaveData(payload) {
1485
- const byLocalId = new Map();
1486
- for (const p of payload) {
1487
- byLocalId.set(p.localId, p);
1488
- }
1489
- const placeholderData = {
1490
- ...defaultAttestationData,
1491
- data: ZERO_BYTES32,
1492
- };
1493
- for (const req of payload) {
1494
- for (const pu of req.propertiesToUpdate ?? []) {
1495
- const targetId = pu.publishLocalId;
1496
- const schemaUid = pu.propertySchemaUid;
1497
- if (!targetId || !schemaUid)
1498
- continue;
1499
- const targetReq = byLocalId.get(targetId);
1500
- if (!targetReq?.listOfAttestations)
1501
- continue;
1502
- const wantSchema = normalizeSchemaUid(schemaUid);
1503
- const att = targetReq.listOfAttestations.find((a) => normalizeSchemaUid(a?.schema) === wantSchema);
1504
- if (!att)
1505
- continue;
1506
- if (!Array.isArray(att.data) || att.data.length === 0) {
1507
- att.data = [placeholderData];
1508
- }
1509
- }
1510
- }
1511
- return payload;
1512
- }
1513
- /**
1514
- * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.
1515
- */
1516
- function collectAttestationLocalRefIds(req, allLocalIds) {
1517
- const refs = [];
1518
- for (const a of req.listOfAttestations ?? []) {
1519
- const att = a;
1520
- if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {
1521
- refs.push(att._unresolvedValue);
1522
- }
1523
- if (Array.isArray(att._rawListIdsForResolve)) {
1524
- for (const id of att._rawListIdsForResolve) {
1525
- const t = id != null ? String(id).trim() : '';
1526
- if (t && allLocalIds.has(t))
1527
- refs.push(t);
1528
- }
1529
- }
1530
- }
1531
- return refs;
1532
- }
1533
- /**
1534
- * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.
1535
- * - propertiesToUpdate: updater before updatee (contract injection).
1536
- * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.
1537
- * The previous DFS visit could order [Post, Image] when Post appeared first in the input array,
1538
- * so resolvedUids was empty when Post was published and attestations kept local ids.
1539
- */
1540
- function orderPayloadByDependencies(payload) {
1541
- if (payload.length <= 1)
1542
- return payload;
1543
- const byLocalId = new Map();
1544
- const allIds = new Set();
1545
- const indexOrder = new Map();
1546
- for (let i = 0; i < payload.length; i++) {
1547
- const p = payload[i];
1548
- byLocalId.set(p.localId, p);
1549
- allIds.add(p.localId);
1550
- indexOrder.set(p.localId, i);
1551
- }
1552
- const indegree = new Map();
1553
- for (const id of allIds)
1554
- indegree.set(id, 0);
1555
- const adj = new Map();
1556
- const addEdge = (from, to) => {
1557
- if (from === to || !allIds.has(from) || !allIds.has(to))
1558
- return;
1559
- if (!adj.has(from))
1560
- adj.set(from, new Set());
1561
- const set = adj.get(from);
1562
- if (set.has(to))
1563
- return;
1564
- set.add(to);
1565
- indegree.set(to, (indegree.get(to) ?? 0) + 1);
1566
- };
1567
- for (const p of payload) {
1568
- for (const u of p.propertiesToUpdate ?? []) {
1569
- const targetId = u.publishLocalId;
1570
- if (targetId && targetId !== p.localId)
1571
- addEdge(p.localId, targetId);
1572
- }
1573
- for (const refId of collectAttestationLocalRefIds(p, allIds)) {
1574
- addEdge(refId, p.localId);
1575
- }
1576
- }
1577
- const zero = [];
1578
- for (const id of allIds) {
1579
- if ((indegree.get(id) ?? 0) === 0)
1580
- zero.push(id);
1581
- }
1582
- zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
1583
- const result = [];
1584
- const queue = zero;
1585
- while (queue.length > 0) {
1586
- const id = queue.shift();
1587
- const p = byLocalId.get(id);
1588
- if (p)
1589
- result.push(p);
1590
- for (const to of adj.get(id) ?? []) {
1591
- const next = (indegree.get(to) ?? 0) - 1;
1592
- indegree.set(to, next);
1593
- if (next === 0) {
1594
- queue.push(to);
1595
- queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
1596
- }
1597
- }
1598
- }
1599
- if (result.length !== payload.length) {
1600
- const seen = new Set(result.map((r) => r.localId));
1601
- for (const p of payload) {
1602
- if (!seen.has(p.localId))
1603
- result.push(p);
1604
- }
1605
- }
1606
- return result;
1607
- }
1608
- /** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */
1609
- function padUidForBytes32Schema(uid) {
1610
- const t = uid.trim();
1611
- if (!t.startsWith('0x'))
1612
- return uid;
1613
- const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '');
1614
- if (hex.length === 0)
1615
- return uid;
1616
- return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase();
1617
- }
1618
- /**
1619
- * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.
1620
- * Call after each payload is published, passing the returned attestation uid for that seed's localId.
1621
- * Returns an updated multiPayload with re-encoded attestations where resolution was applied.
1622
- */
1623
- const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
1624
- if (Object.keys(resolvedUids).length === 0) {
1625
- return multiPayload;
1626
- }
1627
- const { SchemaEncoder } = await loadEasSdk();
1628
- const result = [];
1629
- for (const payload of multiPayload) {
1630
- const updatedAttestations = [];
1631
- for (const attestation of payload.listOfAttestations) {
1632
- const entry = attestation;
1633
- const rawList = entry._rawListIdsForResolve;
1634
- if (rawList &&
1635
- rawList.length > 0 &&
1636
- entry._schemaDef &&
1637
- (entry._propertyNameForSchema || entry._propertyName)) {
1638
- const fieldName = entry._propertyNameForSchema ?? easName(entry._propertyName);
1639
- const resolvedValues = [];
1640
- let allSlotsResolved = true;
1641
- for (const id of rawList) {
1642
- const trimmed = id.trim();
1643
- if (isUidRef(trimmed)) {
1644
- resolvedValues.push(padUidForBytes32Schema(trimmed));
1645
- continue;
1646
- }
1647
- const r = resolvedUids[trimmed];
1648
- if (r) {
1649
- resolvedValues.push(padUidForBytes32Schema(r));
1650
- continue;
1651
- }
1652
- allSlotsResolved = false;
1653
- break;
1654
- }
1655
- // Do not encode or clear hints until every slot has a real uid — otherwise sequential
1656
- // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.
1657
- if (!allSlotsResolved) {
1658
- updatedAttestations.push({
1659
- ...entry,
1660
- data: Array.isArray(entry.data) ? entry.data : [entry.data],
1661
- });
1662
- continue;
1663
- }
1664
- const dataEncoder = new SchemaEncoder(entry._schemaDef);
1665
- const encodedData = dataEncoder.encodeData([
1666
- {
1667
- name: fieldName,
1668
- type: 'bytes32[]',
1669
- value: resolvedValues,
1670
- },
1671
- ]);
1672
- const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
1673
- updatedAttestations.push({
1674
- ...entry,
1675
- data: [
1676
- {
1677
- ...baseData,
1678
- data: encodedData,
1679
- },
1680
- ],
1681
- _rawListIdsForResolve: undefined,
1682
- _easDataType: undefined,
1683
- });
1684
- continue;
1685
- }
1686
- const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue];
1687
- const easType = entry._easDataType || 'bytes32';
1688
- if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {
1689
- const fieldName = entry._propertyNameForSchema ?? easName(entry._propertyName);
1690
- const valueForEncode = easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid;
1691
- const dataEncoder = new SchemaEncoder(entry._schemaDef);
1692
- const encodedData = dataEncoder.encodeData([
1693
- {
1694
- name: fieldName,
1695
- type: easType,
1696
- value: valueForEncode,
1697
- },
1698
- ]);
1699
- const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
1700
- updatedAttestations.push({
1701
- ...entry,
1702
- data: [
1703
- {
1704
- ...baseData,
1705
- data: encodedData,
1706
- },
1707
- ],
1708
- _unresolvedValue: undefined,
1709
- });
1710
- }
1711
- else {
1712
- const normalizedEntry = {
1713
- ...entry,
1714
- data: Array.isArray(entry.data) ? entry.data : [entry.data],
1715
- };
1716
- updatedAttestations.push(normalizedEntry);
1717
- }
1718
- }
1719
- result.push({
1720
- ...payload,
1721
- listOfAttestations: updatedAttestations,
1722
- });
1723
- }
1724
- return result;
1725
- };
1726
-
1727
- var getPublishPayload$1 = /*#__PURE__*/Object.freeze({
1728
- __proto__: null,
1729
- PublishValidationFailedError: PublishValidationFailedError,
1730
- getPublishPayload: getPublishPayload,
1731
- resolvePublishPayloadValues: resolvePublishPayloadValues,
1732
- validateItemForPublish: validateItemForPublish
1733
- });
1734
-
1735
- export { PublishValidationFailedError as P, RELATED_ITEM_UNPUBLISHED_CODE as R, RelatedItemUnpublishedError as a, getPendingRetractions as b, getPublishPayload$1 as c, getPropertyClear as g, resolvePublishPayloadValues as r, validateItemForPublish as v };
1736
- //# sourceMappingURL=getPublishPayload-pbin4lk8.js.map