@seedprotocol/sdk 0.7.9-next.1177.ga3e08ed → 0.7.9-next.1306.g4ff6582

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 (586) hide show
  1. package/dist/BaseFileManager-BAlySv8w.js +650 -0
  2. package/dist/BaseFileManager-BAlySv8w.js.map +1 -0
  3. package/dist/{Item-0oDoTPhi.js → Item-Bf4kWKpH.js} +5647 -6573
  4. package/dist/Item-Bf4kWKpH.js.map +1 -0
  5. package/dist/{ModelProperty-i5flwzQG.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-DnGKel4V.js → SchemaValidationService-CnmKyzR-.js} +6 -9
  10. package/dist/{SchemaValidationService-DnGKel4V.js.map → SchemaValidationService-CnmKyzR-.js.map} +1 -1
  11. package/dist/{configurePlatform-CrMafpMW.js → configurePlatform-CiOJ1R3q.js} +3 -12
  12. package/dist/configurePlatform-CiOJ1R3q.js.map +1 -0
  13. package/dist/db/drizzle/0025_add_metadata_retract.sql +1 -0
  14. package/dist/db/drizzle/0026_add_content_hash_to_schemas.sql +1 -0
  15. package/dist/db/drizzle/0027_link_metadata_property_ids.sql +74 -0
  16. package/dist/db/drizzle/0028_add_definition_to_properties.sql +17 -0
  17. package/dist/db/drizzle/0029_dedupe_chain_uids_add_unique_indexes.sql +120 -0
  18. package/dist/db/drizzle/meta/0025_snapshot.json +1652 -0
  19. package/dist/db/drizzle/meta/0026_snapshot.json +1659 -0
  20. package/dist/db/drizzle/meta/0027_snapshot.json +1659 -0
  21. package/dist/db/drizzle/meta/0028_snapshot.json +1666 -0
  22. package/dist/db/drizzle/meta/0029_snapshot.json +1691 -0
  23. package/dist/db/drizzle/meta/_journal.json +36 -1
  24. package/dist/{detachRowsBeforeDelete-DXFYSHRR.js → detachRowsBeforeDelete-sEaUwlOU.js} +2 -13
  25. package/dist/{detachRowsBeforeDelete-DXFYSHRR.js.map → detachRowsBeforeDelete-sEaUwlOU.js.map} +1 -1
  26. package/dist/dist/{index-Dx_GTdyQ.d.ts → BaseFileManager-BAlySv8w.d.ts} +1424 -2696
  27. package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +1 -0
  28. package/dist/dist/{configurePlatform-CrMafpMW.d.ts → configurePlatform-CiOJ1R3q.d.ts} +1 -1
  29. package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +1 -0
  30. package/dist/dist/{index-PbnKw2es.d.ts → index-D0V-mjCV.d.ts} +56 -1
  31. package/dist/dist/{index-PbnKw2es.d.ts.map → index-D0V-mjCV.d.ts.map} +1 -1
  32. package/dist/dist/{index.node-CzMwMr_d.d.ts → index.node-CYPemH-t.d.ts} +225 -5
  33. package/dist/dist/{index.node-CzMwMr_d.d.ts.map → index.node-CYPemH-t.d.ts.map} +1 -1
  34. package/dist/dist/platform.node.d.ts +2 -2
  35. package/dist/eas-wB_fQ8Tc.js +32 -0
  36. package/dist/eas-wB_fQ8Tc.js.map +1 -0
  37. package/dist/errors-DLSoqSHG.js +6550 -0
  38. package/dist/errors-DLSoqSHG.js.map +1 -0
  39. package/dist/getPublishPayload-BnIwpwz1.js +760 -0
  40. package/dist/getPublishPayload-BnIwpwz1.js.map +1 -0
  41. package/dist/getPublishPendingDiff-D6_-A5ns.js +125 -0
  42. package/dist/getPublishPendingDiff-D6_-A5ns.js.map +1 -0
  43. package/dist/getPublishUploads-sS6JfPgz.js +783 -0
  44. package/dist/getPublishUploads-sS6JfPgz.js.map +1 -0
  45. package/dist/{index-DJmWkVIK.js → index-BVBmz_cc.js} +11 -14
  46. package/dist/index-BVBmz_cc.js.map +1 -0
  47. package/dist/index-CYGWPoOx.js +27 -0
  48. package/dist/index-CYGWPoOx.js.map +1 -0
  49. package/dist/{index-PbnKw2es.js → index-D0V-mjCV.js} +2 -2
  50. package/dist/index-D0V-mjCV.js.map +1 -0
  51. package/dist/index-DmTtj1nk.js +817 -0
  52. package/dist/index-DmTtj1nk.js.map +1 -0
  53. package/dist/{index.browser-i9uPJice.js → index.browser-CUmBVYen.js} +436 -379
  54. package/dist/index.browser-CUmBVYen.js.map +1 -0
  55. package/dist/{index.node-CzMwMr_d.js → index.node-CYPemH-t.js} +10 -10
  56. package/dist/index.node-CYPemH-t.js.map +1 -0
  57. package/dist/main.js +23 -1105
  58. package/dist/main.js.map +1 -1
  59. package/dist/modelPropertyRecordSchemas-C7UgA5TH.js +48 -0
  60. package/dist/modelPropertyRecordSchemas-C7UgA5TH.js.map +1 -0
  61. package/dist/node.js +14 -18
  62. package/dist/node.js.map +1 -1
  63. package/dist/platform.browser.js +8 -13
  64. package/dist/platform.browser.js.map +1 -1
  65. package/dist/platform.node.js +6 -16
  66. package/dist/platform.node.js.map +1 -1
  67. package/dist/property-BxUYznH0.js +87 -0
  68. package/dist/property-BxUYznH0.js.map +1 -0
  69. package/dist/publishGraph-EcB40Uii.js +311 -0
  70. package/dist/publishGraph-EcB40Uii.js.map +1 -0
  71. package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js +110 -0
  72. package/dist/readHtmlBodyForStorageSeed-D6KPtWoR.js.map +1 -0
  73. package/dist/seedSchema/MetadataSchema.ts +3 -0
  74. package/dist/seedSchema/ModelSchema.ts +4 -0
  75. package/dist/seedSchema/ModelSchemaSchema.ts +5 -2
  76. package/dist/seedSchema/PendingWriteSchema.ts +4 -1
  77. package/dist/seedSchema/SchemaSchema.ts +3 -0
  78. package/dist/seedSchema/SeedSchema.ts +8 -2
  79. package/dist/seedSchema/VersionSchema.ts +7 -2
  80. package/dist/seedSchema/attestedUid.ts +10 -0
  81. package/dist/src/Item/Item.d.ts +32 -30
  82. package/dist/src/Item/Item.d.ts.map +1 -1
  83. package/dist/src/Item/loadItem.d.ts +12 -0
  84. package/dist/src/Item/loadItem.d.ts.map +1 -0
  85. package/dist/src/Item/service/itemMachineSingle.d.ts +2 -13
  86. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  87. package/dist/src/ItemProperty/ItemProperty.d.ts +98 -41
  88. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  89. package/dist/src/ItemProperty/loadProperty.d.ts +11 -0
  90. package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -0
  91. package/dist/src/ItemProperty/propertyWrite.d.ts +54 -0
  92. package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -0
  93. package/dist/src/ItemProperty/{service/actors/saveValueToDb/rowContext.d.ts → rowContext.d.ts} +1 -1
  94. package/dist/src/ItemProperty/rowContext.d.ts.map +1 -0
  95. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +6 -0
  96. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  97. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts +5 -15
  98. package/dist/src/ItemProperty/service/actors/modelPropertyRecordSchemas.d.ts.map +1 -1
  99. package/dist/src/ItemProperty/service/propertyMachine.d.ts +3 -46
  100. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  101. package/dist/src/Model/Model.d.ts +26 -56
  102. package/dist/src/Model/Model.d.ts.map +1 -1
  103. package/dist/src/Model/createModelProperties.d.ts +10 -0
  104. package/dist/src/Model/createModelProperties.d.ts.map +1 -0
  105. package/dist/src/Model/loadModel.d.ts +13 -0
  106. package/dist/src/Model/loadModel.d.ts.map +1 -0
  107. package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
  108. package/dist/src/Model/service/modelMachine.d.ts +5 -114
  109. package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
  110. package/dist/src/ModelProperty/ModelProperty.d.ts +44 -37
  111. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  112. package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
  113. package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
  114. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +6 -77
  115. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
  116. package/dist/src/Schema/Schema.d.ts +36 -37
  117. package/dist/src/Schema/Schema.d.ts.map +1 -1
  118. package/dist/src/Schema/loadOrCreateSchema.d.ts +21 -0
  119. package/dist/src/Schema/loadOrCreateSchema.d.ts.map +1 -0
  120. package/dist/src/Schema/service/schemaMachine.d.ts +7 -125
  121. package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
  122. package/dist/src/browser/db/Db.d.ts.map +1 -1
  123. package/dist/src/browser/db/changeFeed.d.ts +2 -18
  124. package/dist/src/browser/db/changeFeed.d.ts.map +1 -1
  125. package/dist/src/browser/db/drizzleFiles.d.ts +7 -2
  126. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  127. package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
  128. package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
  129. package/dist/src/client/ClientManager.d.ts +90 -57
  130. package/dist/src/client/ClientManager.d.ts.map +1 -1
  131. package/dist/src/client/actors/addModelsToDb.d.ts +9 -7
  132. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  133. package/dist/src/client/actors/dbInit.d.ts +3 -3
  134. package/dist/src/client/actors/dbInit.d.ts.map +1 -1
  135. package/dist/src/client/actors/fileSystemInit.d.ts +3 -3
  136. package/dist/src/client/actors/fileSystemInit.d.ts.map +1 -1
  137. package/dist/src/client/actors/platformClassesInit.d.ts +10 -5
  138. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  139. package/dist/src/client/actors/processSchemaFiles.d.ts +18 -3
  140. package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
  141. package/dist/src/client/actors/saveConfig.d.ts +6 -3
  142. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  143. package/dist/src/client/clientManagerMachine.d.ts +22 -20
  144. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  145. package/dist/src/client/constants.d.ts +1 -9
  146. package/dist/src/client/constants.d.ts.map +1 -1
  147. package/dist/src/client/readiness.d.ts +26 -0
  148. package/dist/src/client/readiness.d.ts.map +1 -0
  149. package/dist/src/db/read/currentPropertyRow.d.ts +61 -0
  150. package/dist/src/db/read/currentPropertyRow.d.ts.map +1 -0
  151. package/dist/src/db/read/findSeedRow.d.ts +20 -0
  152. package/dist/src/db/read/findSeedRow.d.ts.map +1 -0
  153. package/dist/src/db/read/findSeedRowsByUid.d.ts +4 -1
  154. package/dist/src/db/read/findSeedRowsByUid.d.ts.map +1 -1
  155. package/dist/src/db/read/getAttesterForSeed.d.ts +1 -1
  156. package/dist/src/db/read/getAttesterForSeed.d.ts.map +1 -1
  157. package/dist/src/db/read/getItemData.d.ts.map +1 -1
  158. package/dist/src/db/read/getItemProperties.d.ts +5 -0
  159. package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
  160. package/dist/src/db/read/getMetadataAttestationUidsForSeedUid.d.ts.map +1 -1
  161. package/dist/src/db/read/getModelSchemas.d.ts +0 -7
  162. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  163. package/dist/src/db/read/getModelsData.d.ts.map +1 -1
  164. package/dist/src/db/read/getPropertyClear.d.ts +49 -0
  165. package/dist/src/db/read/getPropertyClear.d.ts.map +1 -0
  166. package/dist/src/db/read/getPublishPayload.d.ts +35 -40
  167. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  168. package/dist/src/db/read/getPublishPendingDiff.d.ts +7 -2
  169. package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -1
  170. package/dist/src/db/read/getPublishUploads.d.ts +59 -28
  171. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  172. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  173. package/dist/src/db/read/getSeedPublishState.d.ts.map +1 -1
  174. package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -1
  175. package/dist/src/db/read/getVersionsForSeedUid.d.ts.map +1 -1
  176. package/dist/src/db/read/isSeedRevoked.d.ts.map +1 -1
  177. package/dist/src/db/read/localModelSchemaLookups.d.ts +8 -0
  178. package/dist/src/db/read/localModelSchemaLookups.d.ts.map +1 -0
  179. package/dist/src/db/read/metadataProperty.d.ts +104 -0
  180. package/dist/src/db/read/metadataProperty.d.ts.map +1 -0
  181. package/dist/src/db/read/publishGraph.d.ts +148 -0
  182. package/dist/src/db/read/publishGraph.d.ts.map +1 -0
  183. package/dist/src/db/read/resolveModelRecord.d.ts +26 -2
  184. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  185. package/dist/src/db/read/resolveRelatedSeedRef.d.ts +1 -7
  186. package/dist/src/db/read/resolveRelatedSeedRef.d.ts.map +1 -1
  187. package/dist/src/db/read/subqueries/metadataLatest.d.ts +3 -1
  188. package/dist/src/db/read/subqueries/metadataLatest.d.ts.map +1 -1
  189. package/dist/src/db/read/summarizePublishWork.d.ts +18 -5
  190. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  191. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +20 -21
  192. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
  193. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  194. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  195. package/dist/src/db/write/createSeeds.d.ts +5 -1
  196. package/dist/src/db/write/createSeeds.d.ts.map +1 -1
  197. package/dist/src/db/write/definitions.d.ts +127 -0
  198. package/dist/src/db/write/definitions.d.ts.map +1 -0
  199. package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts +11 -0
  200. package/dist/src/db/write/markPropertyAttestationsRetracted.d.ts.map +1 -0
  201. package/dist/src/db/write/mergeChainRows.d.ts +22 -0
  202. package/dist/src/db/write/mergeChainRows.d.ts.map +1 -0
  203. package/dist/src/db/write/saveDefinition.d.ts +29 -0
  204. package/dist/src/db/write/saveDefinition.d.ts.map +1 -0
  205. package/dist/src/db/write/updateItemPropertyValue.d.ts +2 -0
  206. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  207. package/dist/src/db/write/updateSeedUid.d.ts +4 -2
  208. package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
  209. package/dist/src/db/write/updateVersionUid.d.ts +12 -4
  210. package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
  211. package/dist/src/db/write/writeModelUids.d.ts +10 -0
  212. package/dist/src/db/write/writeModelUids.d.ts.map +1 -0
  213. package/dist/src/eas.d.ts +8 -6
  214. package/dist/src/eas.d.ts.map +1 -1
  215. package/dist/src/events/files/download.d.ts.map +1 -1
  216. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  217. package/dist/src/helpers/arweaveContentTags.d.ts +1 -1
  218. package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -1
  219. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts +27 -12
  220. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts.map +1 -1
  221. package/dist/src/helpers/constants.d.ts +5 -2
  222. package/dist/src/helpers/constants.d.ts.map +1 -1
  223. package/dist/src/helpers/dataUrl.d.ts +10 -0
  224. package/dist/src/helpers/dataUrl.d.ts.map +1 -0
  225. package/dist/src/helpers/db.d.ts +54 -105
  226. package/dist/src/helpers/db.d.ts.map +1 -1
  227. package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -1
  228. package/dist/src/helpers/entity/contextUpdate.d.ts +20 -0
  229. package/dist/src/helpers/entity/contextUpdate.d.ts.map +1 -0
  230. package/dist/src/helpers/entity/draftSaveErrors.d.ts +5 -0
  231. package/dist/src/helpers/entity/draftSaveErrors.d.ts.map +1 -1
  232. package/dist/src/helpers/entity/entityCache.d.ts +65 -3
  233. package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
  234. package/dist/src/helpers/entity/entityCommon.d.ts +0 -22
  235. package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
  236. package/dist/src/helpers/entity/entityLifecycle.d.ts +75 -0
  237. package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -0
  238. package/dist/src/helpers/entity/entityLiveQuery.d.ts +1 -23
  239. package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
  240. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +4 -9
  241. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
  242. package/dist/src/helpers/index.d.ts +2 -24
  243. package/dist/src/helpers/index.d.ts.map +1 -1
  244. package/dist/src/helpers/localImageBlobUrl.d.ts +7 -0
  245. package/dist/src/helpers/localImageBlobUrl.d.ts.map +1 -0
  246. package/dist/src/helpers/mediaRef.d.ts +3 -70
  247. package/dist/src/helpers/mediaRef.d.ts.map +1 -1
  248. package/dist/src/helpers/metadataPropertyNames.d.ts +34 -21
  249. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  250. package/dist/src/helpers/mimeTypes.d.ts +2 -1
  251. package/dist/src/helpers/mimeTypes.d.ts.map +1 -1
  252. package/dist/src/helpers/model.d.ts.map +1 -1
  253. package/dist/src/helpers/ownership.d.ts.map +1 -1
  254. package/dist/src/helpers/property.d.ts +21 -26
  255. package/dist/src/helpers/property.d.ts.map +1 -1
  256. package/dist/src/helpers/propertyDefinition.d.ts +59 -0
  257. package/dist/src/helpers/propertyDefinition.d.ts.map +1 -0
  258. package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
  259. package/dist/src/helpers/relationSeedRef.d.ts +0 -7
  260. package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
  261. package/dist/src/helpers/schema.d.ts +24 -38
  262. package/dist/src/helpers/schema.d.ts.map +1 -1
  263. package/dist/src/helpers/schemaApply.d.ts +135 -0
  264. package/dist/src/helpers/schemaApply.d.ts.map +1 -0
  265. package/dist/src/helpers/tabEvents.d.ts.map +1 -1
  266. package/dist/src/helpers/updateSchema.d.ts +2 -18
  267. package/dist/src/helpers/updateSchema.d.ts.map +1 -1
  268. package/dist/src/imports/index.d.ts +1 -1
  269. package/dist/src/imports/index.d.ts.map +1 -1
  270. package/dist/src/imports/json.d.ts +8 -78
  271. package/dist/src/imports/json.d.ts.map +1 -1
  272. package/dist/src/index.d.ts +16 -14
  273. package/dist/src/index.d.ts.map +1 -1
  274. package/dist/src/interfaces/IItem.d.ts +5 -0
  275. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  276. package/dist/src/interfaces/IItemProperty.d.ts +13 -7
  277. package/dist/src/interfaces/IItemProperty.d.ts.map +1 -1
  278. package/dist/src/node/db/Db.d.ts.map +1 -1
  279. package/dist/src/node/index.d.ts +3 -2
  280. package/dist/src/node/index.d.ts.map +1 -1
  281. package/dist/src/outbox/conflicts.d.ts +2 -0
  282. package/dist/src/outbox/conflicts.d.ts.map +1 -1
  283. package/dist/src/outbox/itemAppliers.d.ts +70 -14
  284. package/dist/src/outbox/itemAppliers.d.ts.map +1 -1
  285. package/dist/src/outbox/outbox.d.ts +14 -3
  286. package/dist/src/outbox/outbox.d.ts.map +1 -1
  287. package/dist/src/outbox/pendingValues.d.ts +3 -1
  288. package/dist/src/outbox/pendingValues.d.ts.map +1 -1
  289. package/dist/src/outbox/storageValueRow.d.ts +7 -0
  290. package/dist/src/outbox/storageValueRow.d.ts.map +1 -0
  291. package/dist/src/platform/configurePlatform.d.ts.map +1 -1
  292. package/dist/src/platform/index.browser.d.ts.map +1 -1
  293. package/dist/src/platform/index.node.d.ts.map +1 -1
  294. package/dist/src/seedSchema/MetadataSchema.d.ts +17 -0
  295. package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
  296. package/dist/src/seedSchema/ModelSchema.d.ts +19 -0
  297. package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
  298. package/dist/src/seedSchema/ModelSchemaSchema.d.ts.map +1 -1
  299. package/dist/src/seedSchema/PendingWriteSchema.d.ts.map +1 -1
  300. package/dist/src/seedSchema/SchemaSchema.d.ts +19 -0
  301. package/dist/src/seedSchema/SchemaSchema.d.ts.map +1 -1
  302. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  303. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  304. package/dist/src/seedSchema/attestedUid.d.ts +9 -0
  305. package/dist/src/seedSchema/attestedUid.d.ts.map +1 -0
  306. package/dist/src/storageValue/content.d.ts +45 -0
  307. package/dist/src/storageValue/content.d.ts.map +1 -0
  308. package/dist/src/storageValue/findFile.d.ts +7 -0
  309. package/dist/src/storageValue/findFile.d.ts.map +1 -0
  310. package/dist/src/storageValue/resolve.d.ts +71 -0
  311. package/dist/src/storageValue/resolve.d.ts.map +1 -0
  312. package/dist/src/storageValue/save.d.ts +24 -0
  313. package/dist/src/storageValue/save.d.ts.map +1 -0
  314. package/dist/src/storageValue/stage.d.ts +22 -0
  315. package/dist/src/storageValue/stage.d.ts.map +1 -0
  316. package/dist/src/types/db.d.ts +0 -14
  317. package/dist/src/types/db.d.ts.map +1 -1
  318. package/dist/src/types/index.d.ts +3 -3
  319. package/dist/src/types/index.d.ts.map +1 -1
  320. package/dist/src/types/machines.d.ts +1 -1
  321. package/dist/src/types/machines.d.ts.map +1 -1
  322. package/dist/src/types/property.d.ts +9 -16
  323. package/dist/src/types/property.d.ts.map +1 -1
  324. package/dist/src/types/publish.d.ts +1 -1
  325. package/dist/src/types/publish.d.ts.map +1 -1
  326. package/dist/{syncDbWithEas-DUu_wjUG.js → syncDbWithEas-CA7PvBgu.js} +142 -168
  327. package/dist/syncDbWithEas-CA7PvBgu.js.map +1 -0
  328. package/dist/tabEvents-CaVmngqr.js +3804 -0
  329. package/dist/tabEvents-CaVmngqr.js.map +1 -0
  330. package/dist/{tolerantWebAccess-DecKDGen.js → tolerantWebAccess-BJqViq08.js} +10 -15
  331. package/dist/{tolerantWebAccess-DecKDGen.js.map → tolerantWebAccess-BJqViq08.js.map} +1 -1
  332. package/dist/{resolveModelForSyncedSeed-4gO9Hfn2.js → updateSeedRevokedAt-BL9Bg-G7.js} +30 -4
  333. package/dist/updateSeedRevokedAt-BL9Bg-G7.js.map +1 -0
  334. package/package.json +6 -6
  335. package/dist/ClientManager-GZfXErDX.js +0 -5279
  336. package/dist/ClientManager-GZfXErDX.js.map +0 -1
  337. package/dist/Item-0oDoTPhi.js.map +0 -1
  338. package/dist/ModelProperty-i5flwzQG.js.map +0 -1
  339. package/dist/Schema-PFZwG9Nl.js +0 -4370
  340. package/dist/Schema-PFZwG9Nl.js.map +0 -1
  341. package/dist/backfillMetadataPropertyIds-BbxgavEQ.js +0 -72
  342. package/dist/backfillMetadataPropertyIds-BbxgavEQ.js.map +0 -1
  343. package/dist/changeFeed-DKdVlUmt.js +0 -726
  344. package/dist/changeFeed-DKdVlUmt.js.map +0 -1
  345. package/dist/configurePlatform-CrMafpMW.js.map +0 -1
  346. package/dist/dist/ClientManager-GZfXErDX.d.ts +0 -952
  347. package/dist/dist/ClientManager-GZfXErDX.d.ts.map +0 -1
  348. package/dist/dist/Item-0oDoTPhi.d.ts +0 -1076
  349. package/dist/dist/Item-0oDoTPhi.d.ts.map +0 -1
  350. package/dist/dist/ModelProperty-i5flwzQG.d.ts +0 -315
  351. package/dist/dist/ModelProperty-i5flwzQG.d.ts.map +0 -1
  352. package/dist/dist/Schema-PFZwG9Nl.d.ts +0 -432
  353. package/dist/dist/Schema-PFZwG9Nl.d.ts.map +0 -1
  354. package/dist/dist/SchemaValidationService-DnGKel4V.d.ts +0 -118
  355. package/dist/dist/SchemaValidationService-DnGKel4V.d.ts.map +0 -1
  356. package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts +0 -7
  357. package/dist/dist/backfillMetadataPropertyIds-BbxgavEQ.d.ts.map +0 -1
  358. package/dist/dist/changeFeed-DKdVlUmt.d.ts +0 -160
  359. package/dist/dist/changeFeed-DKdVlUmt.d.ts.map +0 -1
  360. package/dist/dist/configurePlatform-CrMafpMW.d.ts.map +0 -1
  361. package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts +0 -13
  362. package/dist/dist/detachRowsBeforeDelete-DXFYSHRR.d.ts.map +0 -1
  363. package/dist/dist/eas-dyepi5jz.d.ts +0 -12
  364. package/dist/dist/eas-dyepi5jz.d.ts.map +0 -1
  365. package/dist/dist/errors-C1qUEZ7A.d.ts +0 -25
  366. package/dist/dist/errors-C1qUEZ7A.d.ts.map +0 -1
  367. package/dist/dist/errors-D1zHAqjr.d.ts +0 -515
  368. package/dist/dist/errors-D1zHAqjr.d.ts.map +0 -1
  369. package/dist/dist/eventBus-7vxTCc3a.d.ts +0 -18
  370. package/dist/dist/eventBus-7vxTCc3a.d.ts.map +0 -1
  371. package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts +0 -13
  372. package/dist/dist/findSeedRowsByUid-CT3sOXXw.d.ts.map +0 -1
  373. package/dist/dist/getItem-Bhjecbia.d.ts +0 -6
  374. package/dist/dist/getItem-Bhjecbia.d.ts.map +0 -1
  375. package/dist/dist/getPublishPayload-DH4rMqXG.d.ts +0 -47
  376. package/dist/dist/getPublishPayload-DH4rMqXG.d.ts.map +0 -1
  377. package/dist/dist/getPublishUploads-BzUIDA2G.d.ts +0 -89
  378. package/dist/dist/getPublishUploads-BzUIDA2G.d.ts.map +0 -1
  379. package/dist/dist/index-CkYb3wcU.d.ts +0 -14
  380. package/dist/dist/index-CkYb3wcU.d.ts.map +0 -1
  381. package/dist/dist/index-DJmWkVIK.d.ts +0 -6
  382. package/dist/dist/index-DJmWkVIK.d.ts.map +0 -1
  383. package/dist/dist/index-Dx_GTdyQ.d.ts.map +0 -1
  384. package/dist/dist/index.browser-i9uPJice.d.ts +0 -9908
  385. package/dist/dist/index.browser-i9uPJice.d.ts.map +0 -1
  386. package/dist/dist/mimeTypes-C9r76DCH.d.ts +0 -30
  387. package/dist/dist/mimeTypes-C9r76DCH.d.ts.map +0 -1
  388. package/dist/dist/model-oHA3YhOd.d.ts +0 -6
  389. package/dist/dist/model-oHA3YhOd.d.ts.map +0 -1
  390. package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts +0 -7
  391. package/dist/dist/modelPropertyRecordSchemas-C5lW9aA-.d.ts.map +0 -1
  392. package/dist/dist/platform.browser.d.ts +0 -3
  393. package/dist/dist/platform.browser.d.ts.map +0 -1
  394. package/dist/dist/property-BwYtg5Q_.d.ts +0 -37
  395. package/dist/dist/property-BwYtg5Q_.d.ts.map +0 -1
  396. package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts +0 -13
  397. package/dist/dist/propertyValidationRules-CyHdpcPP.d.ts.map +0 -1
  398. package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts +0 -93
  399. package/dist/dist/publishDraftGraph-C5F6b7GK.d.ts.map +0 -1
  400. package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts +0 -21
  401. package/dist/dist/resolveModelForSyncedSeed-4gO9Hfn2.d.ts.map +0 -1
  402. package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts +0 -13
  403. package/dist/dist/syncDbWithEas-DUu_wjUG.d.ts.map +0 -1
  404. package/dist/dist/tolerantWebAccess-DecKDGen.d.ts +0 -113
  405. package/dist/dist/tolerantWebAccess-DecKDGen.d.ts.map +0 -1
  406. package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts +0 -11
  407. package/dist/dist/updateSeedRevokedAt-CP606vKs.d.ts.map +0 -1
  408. package/dist/eas-dyepi5jz.js +0 -67
  409. package/dist/eas-dyepi5jz.js.map +0 -1
  410. package/dist/errors-D1zHAqjr.js +0 -4006
  411. package/dist/errors-D1zHAqjr.js.map +0 -1
  412. package/dist/eventBus-7vxTCc3a.js +0 -64
  413. package/dist/eventBus-7vxTCc3a.js.map +0 -1
  414. package/dist/findSeedRowsByUid-CT3sOXXw.js +0 -47
  415. package/dist/findSeedRowsByUid-CT3sOXXw.js.map +0 -1
  416. package/dist/getItem-Bhjecbia.js +0 -45
  417. package/dist/getItem-Bhjecbia.js.map +0 -1
  418. package/dist/getPublishPayload-DH4rMqXG.js +0 -1634
  419. package/dist/getPublishPayload-DH4rMqXG.js.map +0 -1
  420. package/dist/getPublishUploads-BzUIDA2G.js +0 -1080
  421. package/dist/getPublishUploads-BzUIDA2G.js.map +0 -1
  422. package/dist/index-CkYb3wcU.js +0 -29
  423. package/dist/index-CkYb3wcU.js.map +0 -1
  424. package/dist/index-DJmWkVIK.js.map +0 -1
  425. package/dist/index-Dx_GTdyQ.js +0 -4745
  426. package/dist/index-Dx_GTdyQ.js.map +0 -1
  427. package/dist/index-PbnKw2es.js.map +0 -1
  428. package/dist/index.browser-i9uPJice.js.map +0 -1
  429. package/dist/index.node-CzMwMr_d.js.map +0 -1
  430. package/dist/mimeTypes-C9r76DCH.js +0 -209
  431. package/dist/mimeTypes-C9r76DCH.js.map +0 -1
  432. package/dist/model-oHA3YhOd.js +0 -29
  433. package/dist/model-oHA3YhOd.js.map +0 -1
  434. package/dist/modelPropertyRecordSchemas-C5lW9aA-.js +0 -94
  435. package/dist/modelPropertyRecordSchemas-C5lW9aA-.js.map +0 -1
  436. package/dist/property-BwYtg5Q_.js +0 -289
  437. package/dist/property-BwYtg5Q_.js.map +0 -1
  438. package/dist/propertyValidationRules-CyHdpcPP.js +0 -73
  439. package/dist/propertyValidationRules-CyHdpcPP.js.map +0 -1
  440. package/dist/publishDraftGraph-C5F6b7GK.js +0 -505
  441. package/dist/publishDraftGraph-C5F6b7GK.js.map +0 -1
  442. package/dist/resolveModelForSyncedSeed-4gO9Hfn2.js.map +0 -1
  443. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +0 -5
  444. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +0 -1
  445. package/dist/src/Item/service/actors/waitForDb.d.ts +0 -4
  446. package/dist/src/Item/service/actors/waitForDb.d.ts.map +0 -1
  447. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +0 -5
  448. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +0 -1
  449. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +0 -5
  450. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +0 -1
  451. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts +0 -6
  452. package/dist/src/ItemProperty/service/actors/saveValueToDb/index.d.ts.map +0 -1
  453. package/dist/src/ItemProperty/service/actors/saveValueToDb/rowContext.d.ts.map +0 -1
  454. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +0 -24
  455. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +0 -1
  456. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +0 -5
  457. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +0 -1
  458. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +0 -5
  459. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +0 -1
  460. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +0 -10
  461. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +0 -1
  462. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts +0 -22
  463. package/dist/src/ItemProperty/service/actors/saveValueToDb/storageValue.d.ts.map +0 -1
  464. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +0 -4
  465. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +0 -1
  466. package/dist/src/Model/service/actors/createModelProperties.d.ts +0 -9
  467. package/dist/src/Model/service/actors/createModelProperties.d.ts.map +0 -1
  468. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +0 -5
  469. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +0 -1
  470. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +0 -5
  471. package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +0 -1
  472. package/dist/src/Schema/service/actors/createModelInstances.d.ts +0 -11
  473. package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +0 -1
  474. package/dist/src/Schema/service/actors/createPropertyInstances.d.ts +0 -12
  475. package/dist/src/Schema/service/actors/createPropertyInstances.d.ts.map +0 -1
  476. package/dist/src/Schema/service/actors/validateSchema.d.ts +0 -5
  477. package/dist/src/Schema/service/actors/validateSchema.d.ts.map +0 -1
  478. package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts +0 -6
  479. package/dist/src/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +0 -1
  480. package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts +0 -7
  481. package/dist/src/Schema/service/actors/verifyModelsInDb.d.ts.map +0 -1
  482. package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts +0 -8
  483. package/dist/src/Schema/service/actors/verifyPropertiesInDb.d.ts.map +0 -1
  484. package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts +0 -6
  485. package/dist/src/Schema/service/actors/verifyPropertyInstancesInCache.d.ts.map +0 -1
  486. package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts +0 -7
  487. package/dist/src/Schema/service/actors/verifySchemaInDb.d.ts.map +0 -1
  488. package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +0 -9
  489. package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +0 -1
  490. package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts +0 -10
  491. package/dist/src/Schema/service/actors/writePropertiesToDb.d.ts.map +0 -1
  492. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +0 -11
  493. package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts.map +0 -1
  494. package/dist/src/browser/helpers/ArweaveClient.d.ts +0 -14
  495. package/dist/src/browser/helpers/ArweaveClient.d.ts.map +0 -1
  496. package/dist/src/browser/helpers/EasClient.d.ts +0 -10
  497. package/dist/src/browser/helpers/EasClient.d.ts.map +0 -1
  498. package/dist/src/browser/helpers/QueryClient.d.ts +0 -9
  499. package/dist/src/browser/helpers/QueryClient.d.ts.map +0 -1
  500. package/dist/src/client/actors/addModelsToStore.d.ts +0 -4
  501. package/dist/src/client/actors/addModelsToStore.d.ts.map +0 -1
  502. package/dist/src/db/backfillMetadataPropertyIds.d.ts +0 -7
  503. package/dist/src/db/backfillMetadataPropertyIds.d.ts.map +0 -1
  504. package/dist/src/db/read/getItem.d.ts +0 -3
  505. package/dist/src/db/read/getItem.d.ts.map +0 -1
  506. package/dist/src/db/read/getPropertyData.d.ts +0 -4
  507. package/dist/src/db/read/getPropertyData.d.ts.map +0 -1
  508. package/dist/src/db/read/getRelatedItemsForPublish.d.ts +0 -10
  509. package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +0 -1
  510. package/dist/src/db/read/getSeedData.d.ts +0 -12
  511. package/dist/src/db/read/getSeedData.d.ts.map +0 -1
  512. package/dist/src/db/read/itemLoads.d.ts +0 -20
  513. package/dist/src/db/read/itemLoads.d.ts.map +0 -1
  514. package/dist/src/db/read/publishDraftGraph.d.ts +0 -64
  515. package/dist/src/db/read/publishDraftGraph.d.ts.map +0 -1
  516. package/dist/src/db/write/linkModelToSchema.d.ts +0 -12
  517. package/dist/src/db/write/linkModelToSchema.d.ts.map +0 -1
  518. package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +0 -2
  519. package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts.map +0 -1
  520. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts +0 -2
  521. package/dist/src/helpers/ArweaveClient/arweaveL1UploadApi.d.ts.map +0 -1
  522. package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +0 -2
  523. package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +0 -1
  524. package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +0 -2
  525. package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts.map +0 -1
  526. package/dist/src/helpers/EasClient/BaseEasClient.d.ts +0 -2
  527. package/dist/src/helpers/EasClient/BaseEasClient.d.ts.map +0 -1
  528. package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +0 -2
  529. package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts.map +0 -1
  530. package/dist/src/helpers/easUid.d.ts +0 -2
  531. package/dist/src/helpers/easUid.d.ts.map +0 -1
  532. package/dist/src/helpers/entity/entityDestroy.d.ts +0 -49
  533. package/dist/src/helpers/entity/entityDestroy.d.ts.map +0 -1
  534. package/dist/src/helpers/entity/entityFind.d.ts +0 -52
  535. package/dist/src/helpers/entity/entityFind.d.ts.map +0 -1
  536. package/dist/src/helpers/entity/entityState.d.ts +0 -28
  537. package/dist/src/helpers/entity/entityState.d.ts.map +0 -1
  538. package/dist/src/helpers/entity/entityUnload.d.ts +0 -56
  539. package/dist/src/helpers/entity/entityUnload.d.ts.map +0 -1
  540. package/dist/src/helpers/entity/evictionEpoch.d.ts +0 -43
  541. package/dist/src/helpers/entity/evictionEpoch.d.ts.map +0 -1
  542. package/dist/src/helpers/entity/index.d.ts +0 -12
  543. package/dist/src/helpers/entity/index.d.ts.map +0 -1
  544. package/dist/src/helpers/gateway/gatewayState.d.ts +0 -2
  545. package/dist/src/helpers/gateway/gatewayState.d.ts.map +0 -1
  546. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts +0 -2
  547. package/dist/src/helpers/gateway/resolveSeedGatewayEndpoints.d.ts.map +0 -1
  548. package/dist/src/helpers/gateway/seedGatewayConfig.d.ts +0 -2
  549. package/dist/src/helpers/gateway/seedGatewayConfig.d.ts.map +0 -1
  550. package/dist/src/helpers/getSchemaForItemProperty.d.ts +0 -15
  551. package/dist/src/helpers/getSchemaForItemProperty.d.ts.map +0 -1
  552. package/dist/src/helpers/getSegmentedItemProperties.d.ts +0 -10
  553. package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +0 -1
  554. package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts +0 -7
  555. package/dist/src/helpers/isSqliteUniqueConstraintError.d.ts.map +0 -1
  556. package/dist/src/helpers/propertyValidationRules.d.ts +0 -20
  557. package/dist/src/helpers/propertyValidationRules.d.ts.map +0 -1
  558. package/dist/src/helpers/propertyWriteTickets.d.ts +0 -11
  559. package/dist/src/helpers/propertyWriteTickets.d.ts.map +0 -1
  560. package/dist/src/helpers/reconcilePropertyDraftRows.d.ts +0 -10
  561. package/dist/src/helpers/reconcilePropertyDraftRows.d.ts.map +0 -1
  562. package/dist/src/helpers/waitForEntityIdle.d.ts +0 -21
  563. package/dist/src/helpers/waitForEntityIdle.d.ts.map +0 -1
  564. package/dist/src/interfaces/IQueryClient.d.ts +0 -15
  565. package/dist/src/interfaces/IQueryClient.d.ts.map +0 -1
  566. package/dist/src/node/helpers/ArweaveClient.d.ts +0 -5
  567. package/dist/src/node/helpers/ArweaveClient.d.ts.map +0 -1
  568. package/dist/src/node/helpers/EasClient.d.ts +0 -5
  569. package/dist/src/node/helpers/EasClient.d.ts.map +0 -1
  570. package/dist/src/node/helpers/QueryClient.d.ts +0 -5
  571. package/dist/src/node/helpers/QueryClient.d.ts.map +0 -1
  572. package/dist/src/services/write/actors/validateEntity.d.ts +0 -6
  573. package/dist/src/services/write/actors/validateEntity.d.ts.map +0 -1
  574. package/dist/src/services/write/actors/writeToDatabase.d.ts +0 -14
  575. package/dist/src/services/write/actors/writeToDatabase.d.ts.map +0 -1
  576. package/dist/src/services/write/writeProcessMachine.d.ts +0 -56
  577. package/dist/src/services/write/writeProcessMachine.d.ts.map +0 -1
  578. package/dist/src/stores/eas.d.ts +0 -2
  579. package/dist/src/stores/eas.d.ts.map +0 -1
  580. package/dist/src/types/arweave.d.ts +0 -57
  581. package/dist/src/types/arweave.d.ts.map +0 -1
  582. package/dist/src/types/gateway.d.ts +0 -2
  583. package/dist/src/types/gateway.d.ts.map +0 -1
  584. package/dist/syncDbWithEas-DUu_wjUG.js.map +0 -1
  585. package/dist/updateSeedRevokedAt-CP606vKs.js +0 -31
  586. package/dist/updateSeedRevokedAt-CP606vKs.js.map +0 -1
@@ -0,0 +1,783 @@
1
+ import { getPublicArweaveRawUrl, resolveSeedIdsFromRefString, normalizeRelationPropertyValue, BaseArweaveClient } from '@seedprotocol/arweave';
2
+ import { w as BaseFileManager, B as BaseDb, h as htmlEmbeddedImageCoPublish } from './BaseFileManager-BAlySv8w.js';
3
+ import 'pluralize';
4
+ import { isValidEasAttestationUid } from '@seedprotocol/eas';
5
+ import { R as getExtensionForMimeType, M as ModelPropertyDataTypes, n as normalizeDataType, j as findSeedRow, U as INTERNAL_STORAGE_MODEL_FILE_IDS, i as isDataType, V as resolveUploadMimeType, W as getContentSha256, X as buildArweaveContentTags, Y as getItemStorageSubdir, _ as getItemStorageLocalFileName } from './tabEvents-CaVmngqr.js';
6
+ import { eq } from 'drizzle-orm';
7
+ import { I as Item, _ as waitForEntityReady, ac as storageSeedTransactionId, ad as storageUploadPath } from './Item-Bf4kWKpH.js';
8
+ import debug from 'debug';
9
+ import { parseFragment } from 'parse5';
10
+ import { E as getContentHash } from './errors-DLSoqSHG.js';
11
+ import { g as getPublishGraph, p as publishGraphItemNodes } from './publishGraph-EcB40Uii.js';
12
+
13
+ const HTML_EMBEDDED_MAX_IMAGES_PER_DOC = 50;
14
+ const HTML_EMBEDDED_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
15
+ const HTML_EMBEDDED_MAX_TOTAL_BYTES = 25 * 1024 * 1024;
16
+ const DATA_URI_IMAGE = /^data:(image\/[a-zA-Z0-9.+-]+);base64,([\s\S]*)$/i;
17
+ const MIME_NORMALIZE = {
18
+ 'image/jpg': 'image/jpeg',
19
+ };
20
+ function normalizeMime(m) {
21
+ const lower = m.toLowerCase().trim();
22
+ return MIME_NORMALIZE[lower] ?? lower;
23
+ }
24
+ const ALLOWED_MIMES = new Set([
25
+ 'image/png',
26
+ 'image/jpeg',
27
+ 'image/webp',
28
+ 'image/gif',
29
+ 'image/svg+xml',
30
+ ]);
31
+ class HtmlEmbeddedDataUriLimitError extends Error {
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = 'HtmlEmbeddedDataUriLimitError';
35
+ }
36
+ }
37
+ function resolveEffectiveHtmlEmbeddedDataUriPolicy(propertyDef, publishLevel) {
38
+ const fromProp = propertyDef?.htmlEmbeddedDataUriPolicy;
39
+ if (fromProp === 'materialize' || fromProp === 'preserve')
40
+ return fromProp;
41
+ if (publishLevel === 'materialize' || publishLevel === 'preserve')
42
+ return publishLevel;
43
+ return 'materialize';
44
+ }
45
+ function getAttr(node, name) {
46
+ const a = node.attrs?.find((x) => x.name === name);
47
+ return a?.value;
48
+ }
49
+ /**
50
+ * Walk fragment tree; collect unique data:image base64 URIs with limits.
51
+ */
52
+ async function extractDataUriImagesFromHtml(html) {
53
+ const fragment = parseFragment(html);
54
+ const found = [];
55
+ const seenUris = new Set();
56
+ let totalBytes = 0;
57
+ const walk = async (node) => {
58
+ if (node.nodeName === '#text' || node.nodeName === '#comment')
59
+ return;
60
+ const el = node;
61
+ if (el.tagName === 'img') {
62
+ const src = getAttr(el, 'src')?.trim();
63
+ if (src && src.startsWith('data:image/')) {
64
+ const m = DATA_URI_IMAGE.exec(src);
65
+ if (m) {
66
+ const mimeRaw = normalizeMime(m[1]);
67
+ if (!ALLOWED_MIMES.has(mimeRaw)) {
68
+ throw new HtmlEmbeddedDataUriLimitError(`Unsupported embedded image type: ${mimeRaw}. Allowed: ${[...ALLOWED_MIMES].join(', ')}`);
69
+ }
70
+ let binary;
71
+ try {
72
+ const b64 = m[2].replace(/\s/g, '');
73
+ binary = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
74
+ }
75
+ catch {
76
+ throw new HtmlEmbeddedDataUriLimitError('Invalid base64 in embedded image data URI');
77
+ }
78
+ const byteLength = binary.byteLength;
79
+ if (byteLength > HTML_EMBEDDED_MAX_IMAGE_BYTES) {
80
+ throw new HtmlEmbeddedDataUriLimitError(`Embedded image exceeds max size (${HTML_EMBEDDED_MAX_IMAGE_BYTES} bytes)`);
81
+ }
82
+ totalBytes += byteLength;
83
+ if (totalBytes > HTML_EMBEDDED_MAX_TOTAL_BYTES) {
84
+ throw new HtmlEmbeddedDataUriLimitError(`Total embedded image size exceeds max (${HTML_EMBEDDED_MAX_TOTAL_BYTES} bytes)`);
85
+ }
86
+ if (!seenUris.has(src)) {
87
+ if (seenUris.size >= HTML_EMBEDDED_MAX_IMAGES_PER_DOC) {
88
+ throw new HtmlEmbeddedDataUriLimitError(`Too many distinct embedded images (max ${HTML_EMBEDDED_MAX_IMAGES_PER_DOC})`);
89
+ }
90
+ seenUris.add(src);
91
+ const stableKey = await getContentHash(binary);
92
+ found.push({ dataUri: src, stableKey, byteLength, mimeType: mimeRaw, bytes: binary });
93
+ }
94
+ }
95
+ }
96
+ }
97
+ const parent = el;
98
+ if (parent.childNodes) {
99
+ for (const c of parent.childNodes)
100
+ await walk(c);
101
+ }
102
+ };
103
+ for (const c of fragment.childNodes)
104
+ await walk(c);
105
+ return found;
106
+ }
107
+ function escapeAttributeValue(value) {
108
+ return value.replace(/&/g, '&').replace(/"/g, '"');
109
+ }
110
+ /**
111
+ * Rewrite attribute values of `html` by splicing each new value into the original string: every
112
+ * byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would
113
+ * not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,
114
+ * a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),
115
+ * and sealed Html must not change with the serializer.
116
+ *
117
+ * `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to
118
+ * leave it. A rewritten attribute is written as `name="value"`.
119
+ */
120
+ function rewriteHtmlAttributes(html, rewrite) {
121
+ const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
122
+ const edits = [];
123
+ const walk = (node) => {
124
+ if (node.nodeName === '#text' || node.nodeName === '#comment')
125
+ return;
126
+ const el = node;
127
+ if (el.attrs?.length) {
128
+ for (const attr of el.attrs) {
129
+ if (attr.prefix)
130
+ continue;
131
+ const next = rewrite(el, attr.name, attr.value);
132
+ const location = el.sourceCodeLocation?.attrs?.[attr.name];
133
+ if (next === undefined || !location)
134
+ continue;
135
+ edits.push({
136
+ start: location.startOffset,
137
+ end: location.endOffset,
138
+ text: `${attr.name}="${escapeAttributeValue(next)}"`,
139
+ });
140
+ }
141
+ }
142
+ const parent = el;
143
+ if (parent.childNodes) {
144
+ for (const c of parent.childNodes)
145
+ walk(c);
146
+ }
147
+ };
148
+ for (const c of fragment.childNodes)
149
+ walk(c);
150
+ let out = html;
151
+ for (const edit of edits.sort((a, b) => b.start - a.start)) {
152
+ out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
153
+ }
154
+ return out;
155
+ }
156
+ /**
157
+ * Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those
158
+ * `src` attributes change; the rest of the Html is kept byte for byte.
159
+ */
160
+ function replaceDataUrisInParsedHtml(html, replacements) {
161
+ if (replacements.size === 0)
162
+ return html;
163
+ return rewriteHtmlAttributes(html, (el, attrName, value) => {
164
+ if (el.tagName !== 'img' || attrName !== 'src')
165
+ return undefined;
166
+ return replacements.get(value.trim());
167
+ });
168
+ }
169
+ /**
170
+ * `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's
171
+ * `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,
172
+ * then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a
173
+ * file published alongside it without embedding it (e.g. `<img class="u-featured"
174
+ * src="seed:property/featureImage">`).
175
+ */
176
+ const SEED_PROPERTY_REF_PREFIX = 'seed:property/';
177
+ const SEED_PROPERTY_REF = /^seed:property\/([A-Za-z_$][A-Za-z0-9_$]*)$/;
178
+ /** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */
179
+ const SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster']);
180
+ const seedPropertyRefName = (attrName, value) => SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined;
181
+ /** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */
182
+ class HtmlSeedPropertyRefError extends Error {
183
+ constructor(message) {
184
+ super(message);
185
+ this.name = 'HtmlSeedPropertyRefError';
186
+ }
187
+ }
188
+ /** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */
189
+ function findSeedPropertyRefsInHtml(html) {
190
+ if (!html.includes(SEED_PROPERTY_REF_PREFIX))
191
+ return [];
192
+ const names = new Set();
193
+ rewriteHtmlAttributes(html, (_el, attrName, value) => {
194
+ const name = seedPropertyRefName(attrName, value);
195
+ if (name)
196
+ names.add(name);
197
+ return undefined;
198
+ });
199
+ return [...names];
200
+ }
201
+ /** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */
202
+ function replaceSeedPropertyRefsInHtml(html, urlByPropertyName) {
203
+ if (urlByPropertyName.size === 0)
204
+ return html;
205
+ return rewriteHtmlAttributes(html, (_el, attrName, value) => {
206
+ const name = seedPropertyRefName(attrName, value);
207
+ return name ? urlByPropertyName.get(name) : undefined;
208
+ });
209
+ }
210
+ const SEED_PROPERTY_REF_DATA_TYPES = [
211
+ ModelPropertyDataTypes.Image,
212
+ ModelPropertyDataTypes.File,
213
+ ModelPropertyDataTypes.Json,
214
+ ];
215
+ /**
216
+ * The storage property of `node` a `seed:property/<name>` placeholder names, and the seed it holds.
217
+ * Html properties are refused: an Html seed may itself be deferred to after the rewrite.
218
+ */
219
+ function resolveSeedPropertyRefTarget(node, propertyName) {
220
+ const property = node.properties.find((p) => p.key === propertyName);
221
+ if (!property) {
222
+ throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${node.modelName} has no property ${propertyName}`);
223
+ }
224
+ const def = property.definition;
225
+ const dataType = normalizeDataType(def.dataType);
226
+ const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataType(def.refValueType) : dataType;
227
+ if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {
228
+ throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +
229
+ `only Image, File and Json properties can be referenced`);
230
+ }
231
+ const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(property.row?.propertyValue) ?? '');
232
+ if (!ids.seedLocalId && !ids.seedUid) {
233
+ throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`);
234
+ }
235
+ return ids;
236
+ }
237
+ const ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i;
238
+ /**
239
+ * The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,
240
+ * when not uploaded now, the transaction it was published with (its storageTransactionId row).
241
+ */
242
+ async function resolveSeedPropertyRefTxId(node, propertyName, txBySeedLocalId) {
243
+ const target = resolveSeedPropertyRefTarget(node, propertyName);
244
+ const uploaded = target.seedLocalId ? txBySeedLocalId.get(target.seedLocalId) : undefined;
245
+ if (uploaded)
246
+ return uploaded;
247
+ const recorded = await storageSeedTransactionId(target);
248
+ if (recorded && ARWEAVE_TX_ID.test(recorded))
249
+ return recorded;
250
+ throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +
251
+ `in this publish and has no published transaction`);
252
+ }
253
+ /**
254
+ * Name of the file holding an embedded image's bytes in the images folder: `<imageSeedLocalId>.<ext>`,
255
+ * the extension following the image's MIME type (one of {@link ALLOWED_MIMES}).
256
+ */
257
+ function embeddedImageFileName(imageSeedLocalId, mimeType) {
258
+ return `${imageSeedLocalId}.${getExtensionForMimeType(mimeType) ?? 'bin'}`;
259
+ }
260
+ /** Path of the file {@link createImageItemFromBytes} wrote for an Image seed, or undefined if there is none. */
261
+ async function findEmbeddedImageFilePath(imageSeedLocalId) {
262
+ for (const mimeType of ALLOWED_MIMES) {
263
+ const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageSeedLocalId, mimeType));
264
+ if (await BaseFileManager.pathExists(filePath))
265
+ return filePath;
266
+ }
267
+ return undefined;
268
+ }
269
+ /**
270
+ * Create an Image item for an embedded image and write its bytes to the images folder, where publish
271
+ * reads them for upload ({@link findEmbeddedImageFilePath}). Its storageTransactionId stays empty
272
+ * until the upload writes the transaction id, as for any other storage seed.
273
+ */
274
+ async function createImageItemFromBytes(bytes, mimeType) {
275
+ const imageItem = await Item.create({
276
+ modelName: 'Image',
277
+ modelFileId: INTERNAL_STORAGE_MODEL_FILE_IDS.image,
278
+ });
279
+ await waitForEntityReady(imageItem, { timeout: 60000 });
280
+ const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageItem.seedLocalId, mimeType));
281
+ await BaseFileManager.createDirIfNotExists(BaseFileManager.getFilesPath('images'));
282
+ const data = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
283
+ try {
284
+ await BaseFileManager.saveFile(filePath, data);
285
+ }
286
+ catch {
287
+ const fs = await BaseFileManager.getFs();
288
+ fs.writeFileSync(filePath, bytes);
289
+ }
290
+ const { seedLocalId } = imageItem;
291
+ // Publish reads the image from its rows when it uploads and attests it
292
+ imageItem.unload();
293
+ return { seedLocalId };
294
+ }
295
+ /** The Html properties of a node with a stored Html seed and file name. */
296
+ const htmlValuesOf = (node) => node.properties.flatMap((property) => {
297
+ if (normalizeDataType(property.definition.dataType) !== ModelPropertyDataTypes.Html)
298
+ return [];
299
+ const htmlSeedLocalId = property.row?.propertyValue?.trim();
300
+ const fileName = property.row?.refResolvedValue;
301
+ return htmlSeedLocalId && fileName ? [{ property, htmlSeedLocalId, filePath: `${BaseFileManager.getFilesPath('html')}/${fileName}` }] : [];
302
+ });
303
+ /**
304
+ * Scan Html storage properties, materialize embedded images as Image items, insert co-publish rows.
305
+ * Call before phase-1 Arweave tx build. Does not rewrite Html files yet.
306
+ */
307
+ async function prepareHtmlEmbeddedImagesForPublish(item, publishPolicy) {
308
+ const appDb = BaseDb.getAppDb();
309
+ if (!appDb) {
310
+ return { deferredHtmlSeedLocalIds: [] };
311
+ }
312
+ const deferred = new Set();
313
+ // The item's own Html, and the Html of the draft items published with it: each gets its embedded
314
+ // images materialized and co-published (rows keyed by the item owning the Html property).
315
+ const graph = await getPublishGraph(item);
316
+ for (const node of publishGraphItemNodes(graph)) {
317
+ await prepareHtmlEmbeddedImagesOfNode(appDb, node, publishPolicy, deferred);
318
+ }
319
+ return { deferredHtmlSeedLocalIds: [...deferred] };
320
+ }
321
+ /**
322
+ * An embedded image an earlier attempt materialized for this data URI that can be used again: its
323
+ * Image seed is still a local draft and its file is there.
324
+ */
325
+ async function reusableImage(row) {
326
+ if (!row)
327
+ return undefined;
328
+ const seed = await findSeedRow({ localId: row.imageSeedLocalId });
329
+ if (!seed || isValidEasAttestationUid(seed.uid))
330
+ return undefined;
331
+ return (await findEmbeddedImageFilePath(row.imageSeedLocalId)) ? row.imageSeedLocalId : undefined;
332
+ }
333
+ async function prepareHtmlEmbeddedImagesOfNode(appDb, node, publishPolicy, deferred) {
334
+ // An earlier attempt's rows: their images are reused for the same Html and data URI
335
+ const earlier = node.embeddedImages;
336
+ const kept = [];
337
+ for (const { property, htmlSeedLocalId, filePath } of htmlValuesOf(node)) {
338
+ if (!(await BaseFileManager.pathExists(filePath)))
339
+ continue;
340
+ const html = await BaseFileManager.readFileAsString(filePath);
341
+ // seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A
342
+ // placeholder naming no usable property fails here, before anything is uploaded.
343
+ const refs = findSeedPropertyRefsInHtml(html);
344
+ for (const name of refs)
345
+ resolveSeedPropertyRefTarget(node, name);
346
+ if (refs.length > 0)
347
+ deferred.add(htmlSeedLocalId);
348
+ // The policy is the row's definition (a schema file's htmlEmbeddedDataUriPolicy or a code-defined one)
349
+ const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(property.definition, publishPolicy);
350
+ if (policy !== 'materialize')
351
+ continue;
352
+ const extracted = await extractDataUriImagesFromHtml(html);
353
+ if (extracted.length === 0)
354
+ continue;
355
+ deferred.add(htmlSeedLocalId);
356
+ for (const ent of extracted) {
357
+ const previous = earlier.find((r) => r.htmlSeedLocalId.trim() === htmlSeedLocalId && r.stableKey === ent.stableKey);
358
+ const reused = await reusableImage(previous);
359
+ if (reused) {
360
+ kept.push(previous);
361
+ continue;
362
+ }
363
+ const { seedLocalId: imageSeedLocalId } = await createImageItemFromBytes(ent.bytes, ent.mimeType);
364
+ if (previous)
365
+ await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, previous.id));
366
+ await appDb.insert(htmlEmbeddedImageCoPublish).values({
367
+ parentSeedLocalId: node.seedLocalId,
368
+ htmlSeedLocalId,
369
+ imageSeedLocalId,
370
+ stableKey: ent.stableKey,
371
+ createdAt: Date.now(),
372
+ }).onConflictDoNothing();
373
+ }
374
+ }
375
+ // Rows for Html or data URIs no longer there
376
+ for (const row of earlier) {
377
+ if (kept.includes(row))
378
+ continue;
379
+ await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, row.id));
380
+ }
381
+ }
382
+ /**
383
+ * After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and
384
+ * `seed:property/<name>` → the gateway URL of that property's upload.
385
+ *
386
+ * `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to
387
+ * the Html held back from phase 1; without it, every Html of the item and its co-published drafts is
388
+ * considered.
389
+ */
390
+ async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions, deferredHtmlSeedLocalIds) {
391
+ const appDb = BaseDb.getAppDb();
392
+ if (!appDb)
393
+ return;
394
+ const txBySeedLocalId = new Map();
395
+ for (const u of uploadedTransactions) {
396
+ if (u.seedLocalId && u.txId) {
397
+ txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim());
398
+ }
399
+ }
400
+ const deferred = deferredHtmlSeedLocalIds
401
+ ? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))
402
+ : undefined;
403
+ // The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).
404
+ const graph = await getPublishGraph({ seedLocalId: parentSeedLocalId });
405
+ for (const node of publishGraphItemNodes(graph)) {
406
+ await rewriteHtmlEmbeddedImagesOfNode(node, txBySeedLocalId, deferred);
407
+ }
408
+ }
409
+ async function rewriteHtmlEmbeddedImagesOfNode(node, txBySeedLocalId, deferred) {
410
+ for (const { htmlSeedLocalId, filePath } of htmlValuesOf(node)) {
411
+ if (deferred && !deferred.has(htmlSeedLocalId))
412
+ continue;
413
+ if (!(await BaseFileManager.pathExists(filePath)))
414
+ continue;
415
+ const html = await BaseFileManager.readFileAsString(filePath);
416
+ const replacements = new Map();
417
+ const entries = await extractDataUriImagesFromHtml(html);
418
+ for (const r of node.embeddedImages) {
419
+ if (r.htmlSeedLocalId.trim() !== htmlSeedLocalId)
420
+ continue;
421
+ const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim());
422
+ const dataUri = entries.find((e) => e.stableKey === r.stableKey)?.dataUri;
423
+ if (txId && dataUri)
424
+ replacements.set(dataUri, getPublicArweaveRawUrl(txId));
425
+ }
426
+ const urlByPropertyName = new Map();
427
+ for (const name of findSeedPropertyRefsInHtml(html)) {
428
+ const txId = await resolveSeedPropertyRefTxId(node, name, txBySeedLocalId);
429
+ urlByPropertyName.set(name, getPublicArweaveRawUrl(txId));
430
+ }
431
+ const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName);
432
+ if (newHtml === html)
433
+ continue;
434
+ try {
435
+ await BaseFileManager.saveFile(filePath, newHtml);
436
+ }
437
+ catch {
438
+ const fs = await BaseFileManager.getFs();
439
+ fs.writeFileSync(filePath, newHtml);
440
+ }
441
+ }
442
+ }
443
+ /**
444
+ * Remove co-publish rows after a successful publish for this parent seed.
445
+ */
446
+ async function clearHtmlEmbeddedImageCoPublishRows(parentSeedLocalId) {
447
+ const appDb = BaseDb.getAppDb();
448
+ if (!appDb || !parentSeedLocalId)
449
+ return;
450
+ await appDb
451
+ .delete(htmlEmbeddedImageCoPublish)
452
+ .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId.trim()));
453
+ }
454
+
455
+ /**
456
+ * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.
457
+ * Rejects with the first error (by time); after that no new calls start, though calls already in
458
+ * flight run to completion.
459
+ */
460
+ async function mapWithConcurrency(items, limit, fn) {
461
+ const results = new Array(items.length);
462
+ const workerCount = Math.max(1, Math.min(Math.floor(limit) || 1, items.length));
463
+ let next = 0;
464
+ let failed = false;
465
+ const worker = async () => {
466
+ while (!failed && next < items.length) {
467
+ const index = next++;
468
+ try {
469
+ results[index] = await fn(items[index], index);
470
+ }
471
+ catch (error) {
472
+ failed = true;
473
+ throw error;
474
+ }
475
+ }
476
+ };
477
+ await Promise.all(Array.from({ length: workerCount }, worker));
478
+ return results;
479
+ }
480
+
481
+ /**
482
+ * Composite uploads: several ItemStorage files of one item in a single Arweave transaction.
483
+ *
484
+ * Producer: `getPublishUploads.ts` (`processUploadPropertyData`), for an item with a
485
+ * `storageTransactionId` property and ItemStorage properties (e.g. a Post's `html` and `json`).
486
+ * Consumer: the download worker (`browser/workers/filesDownload.ts`), which keeps its own copy of
487
+ * {@link decodeCompositeUpload} because it runs from a string; a test keeps the two in step.
488
+ *
489
+ * Format (unchanged for text children, so composites already on Arweave still read):
490
+ *
491
+ * ===FILE_SEPARATOR===<name>===FILE_SEPARATOR===<utf-8 text> (repeated per child)
492
+ *
493
+ * A child that is not valid UTF-8 text (or whose text contains the separator) is written as
494
+ * base64 under the name `<name>;base64`. Composites written before this suffix existed converted
495
+ * every child to text, which corrupted binary children; those bytes cannot be recovered.
496
+ */
497
+ const COMPOSITE_SEPARATOR = '===FILE_SEPARATOR===';
498
+ const COMPOSITE_BASE64_SUFFIX = ';base64';
499
+ const bytesToBase64 = (bytes) => {
500
+ let binary = '';
501
+ const chunk = 0x8000;
502
+ for (let i = 0; i < bytes.length; i += chunk) {
503
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
504
+ }
505
+ return btoa(binary);
506
+ };
507
+ /** The child's text when it can travel as text: valid UTF-8, no NUL bytes, no separator. */
508
+ const childAsText = (bytes) => {
509
+ if (bytes.includes(0))
510
+ return undefined;
511
+ let text;
512
+ try {
513
+ text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
514
+ }
515
+ catch {
516
+ return undefined;
517
+ }
518
+ return text.includes(COMPOSITE_SEPARATOR) ? undefined : text;
519
+ };
520
+ const encodeCompositeUpload = (children) => {
521
+ let composite = '';
522
+ for (const { name, bytes } of children) {
523
+ const text = childAsText(bytes);
524
+ composite +=
525
+ text !== undefined
526
+ ? `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_SEPARATOR}${text}`
527
+ : `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_BASE64_SUFFIX}${COMPOSITE_SEPARATOR}${bytesToBase64(bytes)}`;
528
+ }
529
+ return new TextEncoder().encode(composite);
530
+ };
531
+ new TextEncoder().encode(COMPOSITE_SEPARATOR);
532
+
533
+ const logger = debug('seedSdk:item:getPublishUploads');
534
+ /** L1 transactions {@link getPublishUploads} creates at once (each asks the gateway for price and anchor). */
535
+ const CREATE_TRANSACTION_CONCURRENCY = 4;
536
+ const toUint8Array = async (data) => {
537
+ if (typeof Blob !== 'undefined' && data instanceof Blob) {
538
+ return new Uint8Array(await data.arrayBuffer());
539
+ }
540
+ return new Uint8Array(data);
541
+ };
542
+ /** A local file's bytes plus its MIME type: the Blob's own type, else the name's extension, else a sniff of the bytes. */
543
+ const readUploadFile = async (filePath, fileName = filePath) => {
544
+ const data = await BaseFileManager.readFileAsBuffer(filePath);
545
+ const bytes = await toUint8Array(data);
546
+ const sourceType = typeof Blob !== 'undefined' && data instanceof Blob ? data.type : undefined;
547
+ return { bytes, contentType: resolveUploadMimeType({ sourceType, fileName, bytes }) };
548
+ };
549
+ /**
550
+ * The one place an upload's bytes become a {@link PublishUploadData}: everything after this
551
+ * (Content-SHA-256, tags, the L1 transaction or the bundler DataItem, signing) works from what it
552
+ * returns. A future private-publish option that encrypts content belongs here, before the hash and
553
+ * tags are computed, so both publish paths pick it up.
554
+ */
555
+ const buildPublishUploadData = (data, contentType, target, options) => {
556
+ const contentHash = getContentSha256(data);
557
+ return {
558
+ data,
559
+ contentHash,
560
+ contentType,
561
+ tags: buildArweaveContentTags(contentHash, contentType, options?.arweaveUploadTags),
562
+ ...target,
563
+ };
564
+ };
565
+ const isUsablePath = (filePath) => !!filePath && !filePath.endsWith('undefined') && !filePath.endsWith('null');
566
+ /**
567
+ * Local file of one ItemStorage property of a node. Tries, in order: its current row's
568
+ * refResolvedValue + localStorageDir, then (for a local draft, or no row) the name saveItemStorage
569
+ * gives a new file (`<seedUid or seedLocalId><extension>` in the model's storage directory). A
570
+ * published or derived row is never swapped for a local file of another name: that file would be
571
+ * older content.
572
+ *
573
+ * `missingLocalEdit` lists the paths tried when nothing exists although the row is a saved local
574
+ * edit (no attestation uid, not derived from one, refResolvedValue set by saveItemStorage): that
575
+ * edit's file should be there. A published or derived row without a file (e.g. content not
576
+ * downloaded, or a property the composite never had) is skipped.
577
+ */
578
+ const resolveItemStorageChildFile = async (node, property) => {
579
+ const tried = [];
580
+ const tryPath = async (filePath) => {
581
+ if (!isUsablePath(filePath) || tried.includes(filePath))
582
+ return undefined;
583
+ tried.push(filePath);
584
+ return (await BaseFileManager.pathExists(filePath)) ? filePath : undefined;
585
+ };
586
+ const { row, definition } = property;
587
+ const dir = getItemStorageSubdir(definition.localStorageDir || row?.localStorageDir);
588
+ if (row?.refResolvedValue) {
589
+ const fromRow = await tryPath(BaseFileManager.getFilesPath(dir, row.refResolvedValue));
590
+ if (fromRow)
591
+ return { filePath: fromRow };
592
+ }
593
+ const isLocalDraft = !!row && !row.uid && row.derivedFromUid == null;
594
+ const seedIds = !row || isLocalDraft ? [row?.seedUid, node.seedUid, row?.seedLocalId, node.seedLocalId] : [];
595
+ for (const seedId of seedIds) {
596
+ if (!seedId)
597
+ continue;
598
+ const derived = await tryPath(BaseFileManager.getFilesPath(dir, getItemStorageLocalFileName(seedId, definition.filenameSuffix)));
599
+ if (derived)
600
+ return { filePath: derived };
601
+ }
602
+ // saveItemStorage sets refResolvedValue on the draft row once the file is written. A draft row
603
+ // without one is the empty row createNewItem makes for every model property: nothing to upload.
604
+ return isLocalDraft && !!row?.refResolvedValue ? { missingLocalEdit: tried } : {};
605
+ };
606
+ const slotOf = (node) => node.properties.find((p) => p.kind === 'storageTransaction');
607
+ /** Where an upload attesting through `node`'s storageTransactionId is recorded. */
608
+ const slotTarget = (node) => {
609
+ const slot = slotOf(node);
610
+ return {
611
+ seedLocalId: node.seedLocalId,
612
+ itemPropertyName: slot?.key ?? 'storageTransactionId',
613
+ itemPropertyLocalId: slot?.row?.localId ?? '',
614
+ versionLocalId: slot?.row?.versionLocalId ?? node.version.localId ?? '',
615
+ };
616
+ };
617
+ /** A node's own files: the ItemStorage properties beside its storageTransactionId, as one composite. */
618
+ async function compositeSource(node) {
619
+ if (!slotOf(node))
620
+ return undefined;
621
+ const children = [];
622
+ const missingLocalEdits = [];
623
+ for (const property of node.properties) {
624
+ if (property.kind !== 'itemStorage')
625
+ continue;
626
+ const { filePath, missingLocalEdit } = await resolveItemStorageChildFile(node, property);
627
+ if (filePath)
628
+ children.push({ name: property.key, filePath });
629
+ else if (missingLocalEdit)
630
+ missingLocalEdits.push({ name: property.key, tried: missingLocalEdit });
631
+ }
632
+ if (children.length === 0 && missingLocalEdits.length === 0)
633
+ return undefined;
634
+ return { ...slotTarget(node), children, ...(missingLocalEdits.length ? { missingLocalEdits } : {}) };
635
+ }
636
+ /** The file of a storage seed this publish attests, named by the referring property's row. */
637
+ async function storageSeedSource(owner, property) {
638
+ const target = property.refs[0]?.node;
639
+ const refResolvedValue = property.row?.refResolvedValue;
640
+ if (!target || !refResolvedValue)
641
+ return undefined;
642
+ const filePath = storageUploadPath({
643
+ dataType: property.definition.refValueType ?? property.definition.dataType,
644
+ refResolvedValue,
645
+ localStorageDir: property.row?.localStorageDir,
646
+ });
647
+ if (!(await BaseFileManager.pathExists(filePath)))
648
+ return undefined;
649
+ return {
650
+ seedLocalId: target.seedLocalId,
651
+ itemPropertyName: property.key,
652
+ itemPropertyLocalId: property.row?.localId ?? '',
653
+ versionLocalId: property.row?.versionLocalId ?? owner.version.localId ?? '',
654
+ filePath,
655
+ };
656
+ }
657
+ const isHtmlStorageProperty = (property) => isDataType(property.definition.refValueType ?? property.definition.dataType, ModelPropertyDataTypes.Html);
658
+ /**
659
+ * Every upload a publish makes, in graph order (the root's first), one per attesting seed. The
660
+ * options select the phases of a publish with Html-embedded images: phase 1 defers the listed Html
661
+ * storage seeds, phase 2 uploads only those.
662
+ */
663
+ async function getPublishUploadSources(graph, options) {
664
+ const onlyHtml = options?.onlyHtmlStorageSeedLocalIds?.length ? new Set(options.onlyHtmlStorageSeedLocalIds) : undefined;
665
+ const deferHtml = new Set(options?.deferHtmlStorageSeedLocalIds ?? []);
666
+ const sources = [];
667
+ const add = (source) => {
668
+ if (source && !sources.some((s) => s.seedLocalId === source.seedLocalId))
669
+ sources.push(source);
670
+ };
671
+ for (const node of [graph.root, ...graph.nodes.filter((n) => n !== graph.root)]) {
672
+ if (!onlyHtml)
673
+ add(await compositeSource(node));
674
+ if (node.kind !== 'root' && node.kind !== 'draft')
675
+ continue;
676
+ for (const property of node.properties) {
677
+ if (property.kind !== 'storageSeed' || property.deferred)
678
+ continue;
679
+ const seedLocalId = property.refs[0]?.node?.seedLocalId;
680
+ if (!seedLocalId)
681
+ continue;
682
+ if (isHtmlStorageProperty(property) ? deferHtml.has(seedLocalId) || (onlyHtml && !onlyHtml.has(seedLocalId)) : onlyHtml)
683
+ continue;
684
+ add(await storageSeedSource(node, property));
685
+ }
686
+ if (onlyHtml)
687
+ continue;
688
+ for (const row of node.embeddedImages) {
689
+ const image = graph.nodes.find((n) => n.seedLocalId === row.imageSeedLocalId && n.kind === 'embeddedImage');
690
+ const filePath = image ? await findEmbeddedImageFilePath(image.seedLocalId) : undefined;
691
+ if (image && filePath)
692
+ add({ ...slotTarget(image), filePath });
693
+ }
694
+ }
695
+ return sources;
696
+ }
697
+ /** The bytes of one source; a missing local ItemStorage edit fails the publish. */
698
+ async function readSource(source, options) {
699
+ const { filePath, children, missingLocalEdits, ...target } = source;
700
+ const missing = missingLocalEdits?.[0];
701
+ if (missing) {
702
+ // Uploading without it would publish a composite that silently lacks this edit.
703
+ throw new Error(`Cannot publish ${source.seedLocalId}: the local file for ${missing.name} ` +
704
+ `was not found (looked in ${missing.tried.join(', ')})`);
705
+ }
706
+ if (children) {
707
+ // Composite of the node's ItemStorage files; see helpers/compositeUpload.ts for the format.
708
+ // Children are read as bytes: a binary child is base64-framed instead of decoded as text.
709
+ const parts = [];
710
+ for (const child of children)
711
+ parts.push({ name: child.name, bytes: (await readUploadFile(child.filePath)).bytes });
712
+ return buildPublishUploadData(encodeCompositeUpload(parts), 'application/octet-stream', target, options);
713
+ }
714
+ const { bytes, contentType } = await readUploadFile(filePath);
715
+ return buildPublishUploadData(bytes, contentType, target, options);
716
+ }
717
+ /** Fails like a publish would when an item's relation names a seed that isn't there. */
718
+ function assertRefsResolve(graph) {
719
+ for (const broken of graph.brokenRefs) {
720
+ if (broken.list)
721
+ continue;
722
+ throw new Error(broken.reason === 'invalid'
723
+ ? `Invalid relation value for ${broken.propertyKey}: expected local seed id or 0x uid`
724
+ : `No relatedItem found for ${broken.propertyKey}`);
725
+ }
726
+ }
727
+ /**
728
+ * True if publish would include at least one Arweave upload (local file / storage seed present,
729
+ * or a saved local edit whose file is missing, which the upload then reports). Reads rows and
730
+ * file metadata only, for routing (e.g. skip the Arweave steps).
731
+ */
732
+ async function itemHasPublishUploadCandidates(item) {
733
+ const graph = await getPublishGraph(item);
734
+ assertRefsResolve(graph);
735
+ return (await getPublishUploadSources(graph)).length > 0;
736
+ }
737
+ /**
738
+ * Upload data for a publish of `item`: its own, and that of every seed the publish attests with it
739
+ * (see publishGraph.ts). Raw bytes plus Content-SHA-256 / Content-Type / configured tags; no
740
+ * Arweave transaction is created, so this does not touch the network. The bundler path in
741
+ * `@seedprotocol/publish` signs these as DataItems; {@link getPublishUploads} turns them into L1
742
+ * transactions.
743
+ */
744
+ const getPublishUploadData = async (item, options) => {
745
+ const graph = await getPublishGraph(item);
746
+ assertRefsResolve(graph);
747
+ const sources = await getPublishUploadSources(graph, options);
748
+ logger('%d uploads for %s', sources.length, item.seedLocalId);
749
+ const uploads = [];
750
+ for (const source of sources)
751
+ uploads.push(await readSource(source, options));
752
+ return uploads;
753
+ };
754
+ /**
755
+ * Arweave L1 transactions for a publish of `item`: {@link getPublishUploadData}, each made into an
756
+ * unsigned transaction carrying the same tags.
757
+ */
758
+ const getPublishUploads = async (item, options) => {
759
+ const uploadData = await getPublishUploadData(item, options);
760
+ // Each createTransaction fetches the price / anchor from the gateway: run a few at once.
761
+ return mapWithConcurrency(uploadData, CREATE_TRANSACTION_CONCURRENCY, async (upload) => ({
762
+ itemPropertyName: upload.itemPropertyName,
763
+ itemPropertyLocalId: upload.itemPropertyLocalId,
764
+ seedLocalId: upload.seedLocalId,
765
+ versionLocalId: upload.versionLocalId,
766
+ transactionToSign: await BaseArweaveClient.createTransaction(upload.data, {
767
+ tags: upload.tags.length ? upload.tags : undefined,
768
+ }),
769
+ }));
770
+ };
771
+
772
+ var getPublishUploads$1 = /*#__PURE__*/Object.freeze({
773
+ __proto__: null,
774
+ CREATE_TRANSACTION_CONCURRENCY: CREATE_TRANSACTION_CONCURRENCY,
775
+ getPublishUploadData: getPublishUploadData,
776
+ getPublishUploadSources: getPublishUploadSources,
777
+ getPublishUploads: getPublishUploads,
778
+ itemHasPublishUploadCandidates: itemHasPublishUploadCandidates,
779
+ resolveItemStorageChildFile: resolveItemStorageChildFile
780
+ });
781
+
782
+ export { HTML_EMBEDDED_MAX_IMAGES_PER_DOC as H, SEED_PROPERTY_REF_PREFIX as S, HTML_EMBEDDED_MAX_IMAGE_BYTES as a, HTML_EMBEDDED_MAX_TOTAL_BYTES as b, HtmlEmbeddedDataUriLimitError as c, HtmlSeedPropertyRefError as d, clearHtmlEmbeddedImageCoPublishRows as e, extractDataUriImagesFromHtml as f, getPublishUploadSources as g, findSeedPropertyRefsInHtml as h, getPublishUploadData as i, itemHasPublishUploadCandidates as j, replaceSeedPropertyRefsInHtml as k, resolveEffectiveHtmlEmbeddedDataUriPolicy as l, rewriteHtmlEmbeddedImagesOnDisk as m, getPublishUploads$1 as n, prepareHtmlEmbeddedImagesForPublish as p, replaceDataUrisInParsedHtml as r };
783
+ //# sourceMappingURL=getPublishUploads-sS6JfPgz.js.map