@seedprotocol/sdk 0.6.9 → 0.7.0

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 (382) hide show
  1. package/dist/{BasePathResolver-B6CKqoKw.js → BasePathResolver-ndE8XTpw.js} +36 -2
  2. package/dist/BasePathResolver-ndE8XTpw.js.map +1 -0
  3. package/dist/ClientManager-DLleL_2e.js +4763 -0
  4. package/dist/ClientManager-DLleL_2e.js.map +1 -0
  5. package/dist/{ClientManager-ChcmUL47.js → Item-zBFWQDU9.js} +1119 -5893
  6. package/dist/Item-zBFWQDU9.js.map +1 -0
  7. package/dist/{ModelProperty-D79uV42p.js → ModelProperty-lth9L37R.js} +289 -101
  8. package/dist/ModelProperty-lth9L37R.js.map +1 -0
  9. package/dist/{Schema-a8uO-hIZ.js → Schema-DOhlrQ-N.js} +94 -864
  10. package/dist/Schema-DOhlrQ-N.js.map +1 -0
  11. package/dist/{SchemaValidationService-Y49vqast.js → SchemaValidationService-DDKr5piy.js} +26 -18
  12. package/dist/SchemaValidationService-DDKr5piy.js.map +1 -0
  13. package/dist/{backfillMetadataPropertyIds-CBsf7LnU.js → backfillMetadataPropertyIds-fG3ujaSh.js} +11 -6
  14. package/dist/backfillMetadataPropertyIds-fG3ujaSh.js.map +1 -0
  15. package/dist/cjs/{ModelProperty-D9FGaGuE.js → ModelProperty-BEsIHAjk.js} +260 -81
  16. package/dist/cjs/ModelProperty-BEsIHAjk.js.map +1 -0
  17. package/dist/cjs/{Schema-BiJIPLEL.js → Schema-qEp5mH1N.js} +66 -847
  18. package/dist/cjs/Schema-qEp5mH1N.js.map +1 -0
  19. package/dist/cjs/{SchemaValidationService-DtYs_CNY.js → SchemaValidationService-CWEnZmOH.js} +18 -11
  20. package/dist/cjs/SchemaValidationService-CWEnZmOH.js.map +1 -0
  21. package/dist/cjs/{backfillMetadataPropertyIds-2XaN3b9S.js → backfillMetadataPropertyIds-tw8JGMT0.js} +8 -3
  22. package/dist/cjs/backfillMetadataPropertyIds-tw8JGMT0.js.map +1 -0
  23. package/dist/cjs/{eas-CMNppmGE.js → eas-CLiV2Hmn.js} +4 -4
  24. package/dist/cjs/{eas-CMNppmGE.js.map → eas-CLiV2Hmn.js.map} +1 -1
  25. package/dist/cjs/{getItem-B6jEINjW.js → getItem-DSRtx_68.js} +2 -2
  26. package/dist/cjs/{getItem-B6jEINjW.js.map → getItem-DSRtx_68.js.map} +1 -1
  27. package/dist/cjs/getLatestVersionRow-DVizNNoI.js +59 -0
  28. package/dist/cjs/getLatestVersionRow-DVizNNoI.js.map +1 -0
  29. package/dist/cjs/{getPublishPayload-D5DhLGvN.js → getPublishPayload-D5-dYtNq.js} +249 -60
  30. package/dist/cjs/getPublishPayload-D5-dYtNq.js.map +1 -0
  31. package/dist/cjs/{getPublishUploads-DMhCCKYF.js → getPublishUploads-B5Lq6q-_.js} +20 -13
  32. package/dist/cjs/getPublishUploads-B5Lq6q-_.js.map +1 -0
  33. package/dist/cjs/{getSegmentedItemProperties-CU8rtBAo.js → getSegmentedItemProperties-giHO7R3d.js} +10 -11
  34. package/dist/cjs/getSegmentedItemProperties-giHO7R3d.js.map +1 -0
  35. package/dist/cjs/{index-DPp9rdRL.js → index-B3UDbm1C.js} +3 -3
  36. package/dist/cjs/index-B3UDbm1C.js.map +1 -0
  37. package/dist/cjs/{index-CSNtEnbF.js → index-C66AfYDG.js} +2510 -1694
  38. package/dist/cjs/index-C66AfYDG.js.map +1 -0
  39. package/dist/cjs/{property-DlKiAWt4.js → property-BVJIP7SX.js} +40 -35
  40. package/dist/cjs/property-BVJIP7SX.js.map +1 -0
  41. package/dist/cjs/resetAmbiguousLegacyItemData-BaZqUui9.js +116 -0
  42. package/dist/cjs/resetAmbiguousLegacyItemData-BaZqUui9.js.map +1 -0
  43. package/dist/cjs/resolveModelForSyncedSeed-CC6dQctx.js +49 -0
  44. package/dist/cjs/resolveModelForSyncedSeed-CC6dQctx.js.map +1 -0
  45. package/dist/cjs/syncDbWithEas-Dk96sAG-.js +873 -0
  46. package/dist/cjs/syncDbWithEas-Dk96sAG-.js.map +1 -0
  47. package/dist/{configurePlatform-CE0Vew17.js → configurePlatform-BMoPG9vY.js} +4 -4
  48. package/dist/{configurePlatform-CE0Vew17.js.map → configurePlatform-BMoPG9vY.js.map} +1 -1
  49. package/dist/db/drizzle/0015_add_model_file_id_to_seeds.sql +11 -0
  50. package/dist/db/drizzle/0016_add_revoked_at_to_metadata.sql +1 -0
  51. package/dist/db/drizzle/0017_add_revoked_at_to_versions.sql +1 -0
  52. package/dist/db/drizzle/0018_add_storage_settings_to_properties.sql +53 -0
  53. package/dist/db/drizzle/0019_add_derived_from_uid_to_metadata.sql +35 -0
  54. package/dist/db/drizzle/meta/0011_snapshot.json +1182 -0
  55. package/dist/db/drizzle/meta/0012_snapshot.json +1244 -0
  56. package/dist/db/drizzle/meta/0013_snapshot.json +63 -1
  57. package/dist/db/drizzle/meta/0014_snapshot.json +62 -0
  58. package/dist/db/drizzle/meta/0015_snapshot.json +1338 -0
  59. package/dist/db/drizzle/meta/0016_snapshot.json +1345 -0
  60. package/dist/db/drizzle/meta/0017_snapshot.json +1352 -0
  61. package/dist/db/drizzle/meta/0018_snapshot.json +1373 -0
  62. package/dist/db/drizzle/meta/0019_snapshot.json +1380 -0
  63. package/dist/db/drizzle/meta/_journal.json +35 -0
  64. package/dist/{db-WbrzEf7c.js → db-BJZN0a0a.js} +546 -106
  65. package/dist/db-BJZN0a0a.js.map +1 -0
  66. package/dist/{eas-CfYCu4IX.js → eas-B0hsMLqt.js} +7 -7
  67. package/dist/eas-B0hsMLqt.js.map +1 -0
  68. package/dist/errors-CrBxGWah.js +17 -0
  69. package/dist/errors-CrBxGWah.js.map +1 -0
  70. package/dist/{getItem-Br-bGNFO.js → getItem-DEh4WfHG.js} +8 -10
  71. package/dist/{getItem-Br-bGNFO.js.map → getItem-DEh4WfHG.js.map} +1 -1
  72. package/dist/getLatestVersionRow-Brrl1AnW.js +46 -0
  73. package/dist/getLatestVersionRow-Brrl1AnW.js.map +1 -0
  74. package/dist/{getPublishPayload-BIrTVUxb.js → getPublishPayload-H032DHC7.js} +263 -75
  75. package/dist/getPublishPayload-H032DHC7.js.map +1 -0
  76. package/dist/{getPublishUploads-C6cDeZdz.js → getPublishUploads-CR66RlGJ.js} +25 -17
  77. package/dist/{getPublishUploads-C6cDeZdz.js.map → getPublishUploads-CR66RlGJ.js.map} +1 -1
  78. package/dist/{getSegmentedItemProperties-BmKE71vU.js → getSegmentedItemProperties-C2EJ2G0N.js} +13 -14
  79. package/dist/getSegmentedItemProperties-C2EJ2G0N.js.map +1 -0
  80. package/dist/{index-ClSv5pTA.js → index-6bJuv5Tt.js} +12 -11
  81. package/dist/index-6bJuv5Tt.js.map +1 -0
  82. package/dist/{index-Djd3667v.js → index-B0LgJblD.js} +2 -2
  83. package/dist/index-B0LgJblD.js.map +1 -0
  84. package/dist/{index-HRHkbVQd.js → index-DtfjeuxC.js} +417 -174
  85. package/dist/index-DtfjeuxC.js.map +1 -0
  86. package/dist/index.browser-CNrqhvEA.js +4139 -0
  87. package/dist/index.browser-CNrqhvEA.js.map +1 -0
  88. package/dist/{index.node-DBtQkEfz.js → index.node-DrHiTuOr.js} +9 -4
  89. package/dist/index.node-DrHiTuOr.js.map +1 -0
  90. package/dist/main.cjs +1 -1
  91. package/dist/main.js +771 -521
  92. package/dist/main.js.map +1 -1
  93. package/dist/node.js +19 -15
  94. package/dist/node.js.map +1 -1
  95. package/dist/platform.browser.js +18 -3719
  96. package/dist/platform.browser.js.map +1 -1
  97. package/dist/platform.node.js +3 -3
  98. package/dist/{property-CQjuZ4JW.js → property-D2Nnsmm1.js} +53 -48
  99. package/dist/property-D2Nnsmm1.js.map +1 -0
  100. package/dist/resetAmbiguousLegacyItemData-BqbHNUYk.js +88 -0
  101. package/dist/resetAmbiguousLegacyItemData-BqbHNUYk.js.map +1 -0
  102. package/dist/resolveModelForSyncedSeed-DQK6JfXS.js +46 -0
  103. package/dist/resolveModelForSyncedSeed-DQK6JfXS.js.map +1 -0
  104. package/dist/seedSchema/MetadataSchema.ts +9 -0
  105. package/dist/seedSchema/ModelSchema.ts +5 -0
  106. package/dist/seedSchema/SeedSchema.ts +3 -0
  107. package/dist/seedSchema/VersionSchema.ts +5 -0
  108. package/dist/src/Item/Item.d.ts +10 -0
  109. package/dist/src/Item/Item.d.ts.map +1 -1
  110. package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
  111. package/dist/src/Item/service/actors/waitForDb.d.ts.map +1 -1
  112. package/dist/src/Item/service/itemMachineSingle.d.ts +3 -29
  113. package/dist/src/Item/service/itemMachineSingle.d.ts.map +1 -1
  114. package/dist/src/ItemProperty/ItemProperty.d.ts +3 -4
  115. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  116. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  117. package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
  118. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts.map +1 -1
  119. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts.map +1 -1
  120. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
  121. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  122. package/dist/src/ItemProperty/service/propertyMachine.d.ts +4 -9
  123. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  124. package/dist/src/Model/Model.d.ts +37 -0
  125. package/dist/src/Model/Model.d.ts.map +1 -1
  126. package/dist/src/Model/errors.d.ts +10 -0
  127. package/dist/src/Model/errors.d.ts.map +1 -0
  128. package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
  129. package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
  130. package/dist/src/Model/service/modelMachine.d.ts +0 -8
  131. package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
  132. package/dist/src/ModelProperty/ModelProperty.d.ts +33 -1
  133. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  134. package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
  135. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +2 -9
  136. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
  137. package/dist/src/Schema/Schema.d.ts +1 -2
  138. package/dist/src/Schema/Schema.d.ts.map +1 -1
  139. package/dist/src/Schema/service/schemaMachine.d.ts +1 -217
  140. package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
  141. package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
  142. package/dist/src/browser/db/Db.d.ts +3 -0
  143. package/dist/src/browser/db/Db.d.ts.map +1 -1
  144. package/dist/src/browser/db/drizzleFiles.d.ts +7 -2
  145. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  146. package/dist/src/browser/db/embeddedMigrations.d.ts +11 -2
  147. package/dist/src/browser/db/embeddedMigrations.d.ts.map +1 -1
  148. package/dist/src/browser/db/sqliteBusyRetry.d.ts +14 -0
  149. package/dist/src/browser/db/sqliteBusyRetry.d.ts.map +1 -0
  150. package/dist/src/browser/helpers/FileManager.d.ts +1 -0
  151. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  152. package/dist/src/browser/helpers/QueryClient.d.ts +1 -0
  153. package/dist/src/browser/helpers/QueryClient.d.ts.map +1 -1
  154. package/dist/src/browser/helpers/opfsErrors.d.ts +2 -0
  155. package/dist/src/browser/helpers/opfsErrors.d.ts.map +1 -0
  156. package/dist/src/browser/helpers/tolerantWebAccess.d.ts +47 -0
  157. package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -0
  158. package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
  159. package/dist/src/browser/workers/ImageResizer.d.ts.map +1 -1
  160. package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
  161. package/dist/src/browser/workers/imageResize.d.ts.map +1 -1
  162. package/dist/src/client/ClientManager.d.ts.map +1 -1
  163. package/dist/src/client/actors/addModelsToDb.d.ts +14 -0
  164. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  165. package/dist/src/client/actors/platformClassesInit.d.ts.map +1 -1
  166. package/dist/src/client/actors/processSchemaFiles.d.ts.map +1 -1
  167. package/dist/src/client/actors/saveConfig.d.ts +11 -0
  168. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  169. package/dist/src/client/constants.d.ts +0 -8
  170. package/dist/src/client/constants.d.ts.map +1 -1
  171. package/dist/src/db/backfillMetadataPropertyIds.d.ts.map +1 -1
  172. package/dist/src/db/configs/{dev.schema.config.d.ts → migrations.config.d.ts} +1 -1
  173. package/dist/src/db/configs/migrations.config.d.ts.map +1 -0
  174. package/dist/src/db/read/batchLatestPublishedVersionBySeedLocalIds.d.ts +1 -1
  175. package/dist/src/db/read/batchLatestPublishedVersionBySeedLocalIds.d.ts.map +1 -1
  176. package/dist/src/db/read/getItemData.d.ts.map +1 -1
  177. package/dist/src/db/read/getItemProperties.d.ts.map +1 -1
  178. package/dist/src/db/read/getItems.d.ts +7 -2
  179. package/dist/src/db/read/getItems.d.ts.map +1 -1
  180. package/dist/src/db/read/getLatestPublishedVersionRow.d.ts +2 -1
  181. package/dist/src/db/read/getLatestPublishedVersionRow.d.ts.map +1 -1
  182. package/dist/src/db/read/getLatestVersionRow.d.ts +13 -0
  183. package/dist/src/db/read/getLatestVersionRow.d.ts.map +1 -0
  184. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  185. package/dist/src/db/read/getPropertyData.d.ts.map +1 -1
  186. package/dist/src/db/read/getPublishPayload.d.ts +9 -11
  187. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  188. package/dist/src/db/read/getPublishPendingDiff.d.ts +2 -1
  189. package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -1
  190. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  191. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  192. package/dist/src/db/read/getSeedPublishState.d.ts +8 -2
  193. package/dist/src/db/read/getSeedPublishState.d.ts.map +1 -1
  194. package/dist/src/db/read/isSeedRevoked.d.ts +7 -0
  195. package/dist/src/db/read/isSeedRevoked.d.ts.map +1 -0
  196. package/dist/src/db/read/publishErrors.d.ts +37 -0
  197. package/dist/src/db/read/publishErrors.d.ts.map +1 -0
  198. package/dist/src/db/read/resolveModelForSyncedSeed.d.ts +39 -0
  199. package/dist/src/db/read/resolveModelForSyncedSeed.d.ts.map +1 -0
  200. package/dist/src/db/read/resolveModelRecord.d.ts +69 -0
  201. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -0
  202. package/dist/src/db/read/resolveRelatedSeedRef.d.ts +34 -0
  203. package/dist/src/db/read/resolveRelatedSeedRef.d.ts.map +1 -0
  204. package/dist/src/db/read/subqueries/liveVersion.d.ts +12 -0
  205. package/dist/src/db/read/subqueries/liveVersion.d.ts.map +1 -0
  206. package/dist/src/db/read/subqueries/metadataLatest.d.ts +4 -0
  207. package/dist/src/db/read/subqueries/metadataLatest.d.ts.map +1 -1
  208. package/dist/src/db/read/subqueries/versionData.d.ts +7 -2
  209. package/dist/src/db/read/subqueries/versionData.d.ts.map +1 -1
  210. package/dist/src/db/read/summarizePublishWork.d.ts +10 -2
  211. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  212. package/dist/src/db/resetAmbiguousLegacyItemData.d.ts +17 -0
  213. package/dist/src/db/resetAmbiguousLegacyItemData.d.ts.map +1 -0
  214. package/dist/src/db/sqlParamBatches.d.ts +27 -0
  215. package/dist/src/db/sqlParamBatches.d.ts.map +1 -0
  216. package/dist/src/db/write/addExcludedTransactions.d.ts +7 -0
  217. package/dist/src/db/write/addExcludedTransactions.d.ts.map +1 -0
  218. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts +6 -0
  219. package/dist/src/db/write/applyPropertyAttestationUidsFromPublish.d.ts.map +1 -1
  220. package/dist/src/db/write/createMetadata.d.ts +2 -0
  221. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  222. package/dist/src/db/write/createNewItem.d.ts +3 -1
  223. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  224. package/dist/src/db/write/createSeed.d.ts +2 -1
  225. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  226. package/dist/src/db/write/createSeeds.d.ts +1 -1
  227. package/dist/src/db/write/createSeeds.d.ts.map +1 -1
  228. package/dist/src/db/write/linkModelToSchema.d.ts +12 -0
  229. package/dist/src/db/write/linkModelToSchema.d.ts.map +1 -0
  230. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  231. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  232. package/dist/src/db/write/updateSeedRevokedAt.d.ts +11 -1
  233. package/dist/src/db/write/updateSeedRevokedAt.d.ts.map +1 -1
  234. package/dist/src/db/write/updateSeedUid.d.ts.map +1 -1
  235. package/dist/src/db/write/updateVersionUid.d.ts +2 -1
  236. package/dist/src/db/write/updateVersionUid.d.ts.map +1 -1
  237. package/dist/src/events/files/download.d.ts.map +1 -1
  238. package/dist/src/events/item/easSyncManager.d.ts +2 -0
  239. package/dist/src/events/item/easSyncManager.d.ts.map +1 -1
  240. package/dist/src/events/item/index.d.ts.map +1 -1
  241. package/dist/src/events/item/syncDbWithEas.d.ts +16 -0
  242. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  243. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +1 -0
  244. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  245. package/dist/src/helpers/FileManager/IFileManager.d.ts +5 -0
  246. package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
  247. package/dist/src/helpers/FileManager/errors.d.ts +10 -0
  248. package/dist/src/helpers/FileManager/errors.d.ts.map +1 -0
  249. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts +21 -3
  250. package/dist/src/helpers/compareMetadataRowsLatestFirst.d.ts.map +1 -1
  251. package/dist/src/helpers/constants.d.ts +9 -0
  252. package/dist/src/helpers/constants.d.ts.map +1 -1
  253. package/dist/src/helpers/crypto.d.ts +5 -0
  254. package/dist/src/helpers/crypto.d.ts.map +1 -1
  255. package/dist/src/helpers/db.d.ts +25 -5
  256. package/dist/src/helpers/db.d.ts.map +1 -1
  257. package/dist/src/helpers/easPropertyCanonical.d.ts +1 -1
  258. package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -1
  259. package/dist/src/helpers/entity/entityCommon.d.ts +10 -0
  260. package/dist/src/helpers/entity/entityCommon.d.ts.map +1 -1
  261. package/dist/src/helpers/entity/entityDestroy.d.ts +1 -1
  262. package/dist/src/helpers/entity/entityDestroy.d.ts.map +1 -1
  263. package/dist/src/helpers/entity/entityLiveQuery.d.ts +5 -0
  264. package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
  265. package/dist/src/helpers/file/fetchAll/actors.d.ts.map +1 -1
  266. package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +1 -1
  267. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +6 -0
  268. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
  269. package/dist/src/helpers/isPublishedMetadataRow.d.ts +10 -0
  270. package/dist/src/helpers/isPublishedMetadataRow.d.ts.map +1 -0
  271. package/dist/src/helpers/ownership.d.ts.map +1 -1
  272. package/dist/src/helpers/property.d.ts +6 -1
  273. package/dist/src/helpers/property.d.ts.map +1 -1
  274. package/dist/src/helpers/schema.d.ts +14 -4
  275. package/dist/src/helpers/schema.d.ts.map +1 -1
  276. package/dist/src/helpers/tabCoordinator.d.ts +45 -0
  277. package/dist/src/helpers/tabCoordinator.d.ts.map +1 -0
  278. package/dist/src/helpers/tabEvents.d.ts +27 -0
  279. package/dist/src/helpers/tabEvents.d.ts.map +1 -0
  280. package/dist/src/helpers/tabLocks.d.ts +28 -0
  281. package/dist/src/helpers/tabLocks.d.ts.map +1 -0
  282. package/dist/src/helpers/updateSchema.d.ts.map +1 -1
  283. package/dist/src/imports/json.d.ts.map +1 -1
  284. package/dist/src/imports/markdown.d.ts.map +1 -1
  285. package/dist/src/index.d.ts +11 -2
  286. package/dist/src/index.d.ts.map +1 -1
  287. package/dist/src/node/db/Db.d.ts.map +1 -1
  288. package/dist/src/node/helpers/FileManager.d.ts +2 -0
  289. package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
  290. package/dist/src/query/createLocalQueryDataSource.d.ts +4 -0
  291. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
  292. package/dist/src/seedSchema/MetadataSchema.d.ts +36 -0
  293. package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
  294. package/dist/src/seedSchema/ModelSchema.d.ts +57 -0
  295. package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
  296. package/dist/src/seedSchema/SeedSchema.d.ts +19 -0
  297. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  298. package/dist/src/seedSchema/VersionSchema.d.ts +17 -0
  299. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  300. package/dist/src/services/write/actors/writeToDatabase.d.ts +5 -0
  301. package/dist/src/services/write/actors/writeToDatabase.d.ts.map +1 -1
  302. package/dist/src/services/write/writeProcessMachine.d.ts.map +1 -1
  303. package/dist/src/stores/eas.d.ts +1 -1
  304. package/dist/src/stores/eas.d.ts.map +1 -1
  305. package/dist/src/types/index.d.ts +7 -0
  306. package/dist/src/types/index.d.ts.map +1 -1
  307. package/dist/src/types/item.d.ts +12 -3
  308. package/dist/src/types/item.d.ts.map +1 -1
  309. package/dist/src/types/property.d.ts +3 -2
  310. package/dist/src/types/property.d.ts.map +1 -1
  311. package/dist/syncDbWithEas-LRKr_NZF.js +855 -0
  312. package/dist/syncDbWithEas-LRKr_NZF.js.map +1 -0
  313. package/dist/{index-280bL-n4.js → tabEvents-DYI2GU7i.js} +231 -68
  314. package/dist/tabEvents-DYI2GU7i.js.map +1 -0
  315. package/dist/tolerantWebAccess-CzOBz5M6.js +160 -0
  316. package/dist/tolerantWebAccess-CzOBz5M6.js.map +1 -0
  317. package/dist/updateSeedRevokedAt-B58ORbY3.js +32 -0
  318. package/dist/updateSeedRevokedAt-B58ORbY3.js.map +1 -0
  319. package/package.json +5 -5
  320. package/dist/BasePathResolver-B6CKqoKw.js.map +0 -1
  321. package/dist/ClientManager-ChcmUL47.js.map +0 -1
  322. package/dist/ModelProperty-D79uV42p.js.map +0 -1
  323. package/dist/Schema-a8uO-hIZ.js.map +0 -1
  324. package/dist/SchemaValidationService-Y49vqast.js.map +0 -1
  325. package/dist/backfillMetadataPropertyIds-CBsf7LnU.js.map +0 -1
  326. package/dist/cjs/ModelProperty-D9FGaGuE.js.map +0 -1
  327. package/dist/cjs/Schema-BiJIPLEL.js.map +0 -1
  328. package/dist/cjs/SchemaValidationService-DtYs_CNY.js.map +0 -1
  329. package/dist/cjs/backfillMetadataPropertyIds-2XaN3b9S.js.map +0 -1
  330. package/dist/cjs/getPublishPayload-D5DhLGvN.js.map +0 -1
  331. package/dist/cjs/getPublishUploads-DMhCCKYF.js.map +0 -1
  332. package/dist/cjs/getSegmentedItemProperties-CU8rtBAo.js.map +0 -1
  333. package/dist/cjs/index-CSNtEnbF.js.map +0 -1
  334. package/dist/cjs/index-DPp9rdRL.js.map +0 -1
  335. package/dist/cjs/property-DlKiAWt4.js.map +0 -1
  336. package/dist/cjs/syncDbWithEas-C6n34o_Q.js +0 -606
  337. package/dist/cjs/syncDbWithEas-C6n34o_Q.js.map +0 -1
  338. package/dist/db-WbrzEf7c.js.map +0 -1
  339. package/dist/eas-CfYCu4IX.js.map +0 -1
  340. package/dist/getPublishPayload-BIrTVUxb.js.map +0 -1
  341. package/dist/getSegmentedItemProperties-BmKE71vU.js.map +0 -1
  342. package/dist/index-280bL-n4.js.map +0 -1
  343. package/dist/index-ClSv5pTA.js.map +0 -1
  344. package/dist/index-Djd3667v.js.map +0 -1
  345. package/dist/index-HRHkbVQd.js.map +0 -1
  346. package/dist/index.node-DBtQkEfz.js.map +0 -1
  347. package/dist/property-CQjuZ4JW.js.map +0 -1
  348. package/dist/src/Item/service/actors/fetchDataFromEas.d.ts +0 -4
  349. package/dist/src/Item/service/actors/fetchDataFromEas.d.ts.map +0 -1
  350. package/dist/src/Item/service/actors/hydrateExistingItem.d.ts +0 -4
  351. package/dist/src/Item/service/actors/hydrateExistingItem.d.ts.map +0 -1
  352. package/dist/src/Item/service/actors/hydrateNewItem.d.ts +0 -4
  353. package/dist/src/Item/service/actors/hydrateNewItem.d.ts.map +0 -1
  354. package/dist/src/Item/service/actors/initialize.d.ts +0 -4
  355. package/dist/src/Item/service/actors/initialize.d.ts.map +0 -1
  356. package/dist/src/Item/service/actors/reload.d.ts +0 -5
  357. package/dist/src/Item/service/actors/reload.d.ts.map +0 -1
  358. package/dist/src/Item/service/actors/saveDataToDb.d.ts +0 -4
  359. package/dist/src/Item/service/actors/saveDataToDb.d.ts.map +0 -1
  360. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts +0 -5
  361. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts.map +0 -1
  362. package/dist/src/Schema/service/addModelsMachine.d.ts +0 -123
  363. package/dist/src/Schema/service/addModelsMachine.d.ts.map +0 -1
  364. package/dist/src/db/configs/dev.schema.config.d.ts.map +0 -1
  365. package/dist/src/helpers/file/download/actors.d.ts +0 -17
  366. package/dist/src/helpers/file/download/actors.d.ts.map +0 -1
  367. package/dist/src/helpers/file/download/index.d.ts +0 -70
  368. package/dist/src/helpers/file/download/index.d.ts.map +0 -1
  369. package/dist/src/services/publish/actors/createPublishAttempt.d.ts +0 -4
  370. package/dist/src/services/publish/actors/createPublishAttempt.d.ts.map +0 -1
  371. package/dist/src/services/publish/actors/preparePublishRequestData.d.ts +0 -4
  372. package/dist/src/services/publish/actors/preparePublishRequestData.d.ts.map +0 -1
  373. package/dist/src/services/publish/actors/upload.d.ts +0 -4
  374. package/dist/src/services/publish/actors/upload.d.ts.map +0 -1
  375. package/dist/src/services/publish/actors/validateItemData.d.ts +0 -4
  376. package/dist/src/services/publish/actors/validateItemData.d.ts.map +0 -1
  377. package/dist/src/services/publish/publishMachine.d.ts +0 -32
  378. package/dist/src/services/publish/publishMachine.d.ts.map +0 -1
  379. package/dist/syncDbWithEas-CuARXfyN.js +0 -598
  380. package/dist/syncDbWithEas-CuARXfyN.js.map +0 -1
  381. package/dist/updateSeedRevokedAt-CBcLfHWs.js +0 -22
  382. package/dist/updateSeedRevokedAt-CBcLfHWs.js.map +0 -1
@@ -1,3729 +1,28 @@
1
- import { a as BaseDb, c as appState, t as BasePathResolver, B as BaseFileManager } from './BasePathResolver-B6CKqoKw.js';
2
- import debug from 'debug';
3
- import { drizzle } from 'drizzle-orm/sqlite-proxy';
4
- import { sha256 } from '@noble/hashes/sha256';
5
- import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
6
- import { sql } from 'drizzle-orm';
7
- import './index-280bL-n4.js';
8
- import { s as schema } from './index-Djd3667v.js';
9
- import { SQLocalDrizzle } from 'sqlocal/drizzle';
10
- import { Observable, distinctUntilChanged } from 'rxjs';
11
- import { BaseArweaveClient, getPreferredArweaveReadBaseUrls, fetchArweaveRawFromBaseUrl, GET_TRANSACTION_TAGS } from '@seedprotocol/arweave';
12
- import { GraphQLClient } from 'graphql-request';
13
- import Arweave from 'arweave';
14
- import { getEasEndpoint, BaseEasClient, BaseQueryClient } from '@seedprotocol/eas';
15
- import { QueryClient } from '@tanstack/react-query';
1
+ export { c as createPlatformServices } from './index.browser-CNrqhvEA.js';
2
+ import './BasePathResolver-ndE8XTpw.js';
16
3
  import 'drizzle-orm/sqlite-core';
4
+ import 'drizzle-orm';
5
+ import '@seedprotocol/arweave';
6
+ import './tabEvents-DYI2GU7i.js';
7
+ import 'debug';
8
+ import '@seedprotocol/eas';
17
9
  import 'xstate';
18
10
  import 'pluralize';
19
- import './db-WbrzEf7c.js';
11
+ import './db-BJZN0a0a.js';
20
12
  import 'drizzle-orm/casing';
21
13
  import 'lodash-es';
22
14
  import '@sinclair/typebox';
23
15
  import 'nanoid';
24
16
  import 'nanoid-dictionary';
25
17
  import '@seedprotocol/query';
26
-
27
- const saveAppState = async (key, value) => {
28
- const appDb = BaseDb.getAppDb();
29
- await appDb
30
- .insert(appState)
31
- .values({
32
- key,
33
- value,
34
- })
35
- .onConflictDoUpdate({
36
- target: appState.key,
37
- set: {
38
- value,
39
- },
40
- });
41
- };
42
-
43
- class BrowserPathResolver {
44
- /** @deprecated Prefer BasePathResolver static methods or configure(). */
45
- static getInstance() {
46
- return BasePathResolver.getInstance();
47
- }
48
- /**
49
- * Gets the root directory containing node_modules
50
- * Note: In browser, this returns a virtual path based on OPFS
51
- */
52
- getRootWithNodeModules() {
53
- // In browser, we use OPFS which doesn't have traditional paths
54
- // Return a virtual root path
55
- return '/';
56
- }
57
- /**
58
- * Gets the SDK root directory
59
- * Note: In browser, this returns a virtual path
60
- */
61
- getSdkRootDir() {
62
- // In browser, SDK is bundled, so we return a virtual path
63
- return '/sdk';
64
- }
65
- getNodeModulesDir() {
66
- // In browser, node_modules don't exist in the traditional sense
67
- return '/node_modules';
68
- }
69
- /**
70
- * Gets the .seed directory path
71
- * Note: In browser, this returns the OPFS path where .seed data is stored
72
- */
73
- getDotSeedDir(schemaFileDir) {
74
- // In browser, .seed directory is stored in OPFS
75
- // The actual path is handled by the FileManager
76
- return '/.seed';
77
- }
78
- /**
79
- * Finds the Seed Protocol config file
80
- * Note: In browser, config files are not accessible via filesystem
81
- */
82
- findConfigFile(searchDir) {
83
- // In browser, config files are typically embedded in the bundle
84
- // or loaded via fetch/import
85
- return null;
86
- }
87
- /**
88
- * Gets paths for app-specific directories
89
- * Note: In browser, these are virtual paths for OPFS
90
- */
91
- getAppPaths(schemaFileDir) {
92
- const dotSeedDir = this.getDotSeedDir(schemaFileDir);
93
- return {
94
- sdkRootDir: this.getSdkRootDir(),
95
- dotSeedDir,
96
- nodeModulesDir: this.getNodeModulesDir(),
97
- appSchemaDir: `${dotSeedDir}/schema`,
98
- appDbDir: `${dotSeedDir}/db`,
99
- appMetaDir: `${dotSeedDir}/db/meta`,
100
- };
101
- }
102
- }
103
- BasePathResolver.configure(new BrowserPathResolver());
104
-
105
- var filesDownload = `(
106
- ${function () {
107
- const identifyString = (str) => {
108
- try {
109
- JSON.parse(str);
110
- return 'json';
111
- }
112
- catch (e) {
113
- // Not JSON
114
- }
115
- if (!str) {
116
- return;
117
- }
118
- if (str.trim().startsWith('<') && str.trim().endsWith('>')) {
119
- return 'html';
120
- }
121
- // Simple markdown checks (very naive)
122
- if (/^#{1,6}\s|^-{3,}|\*{3,}|^-{1,2}\s|\*\s/.test(str)) {
123
- return 'markdown';
124
- }
125
- if (/^data:image\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {
126
- return 'base64';
127
- }
128
- // Default to plain text if unsure
129
- return 'text';
130
- };
131
- const getMimeType = (base64) => {
132
- if (!base64) {
133
- return null;
134
- }
135
- const result = base64.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,/);
136
- if (result && result.length > 1) {
137
- return result[1];
138
- }
139
- else {
140
- return null; // MIME type could not be determined
141
- }
142
- };
143
- const getDataTypeFromString = (data) => {
144
- const nonImageBase64Regex = /^(?!data:image\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/;
145
- if (nonImageBase64Regex.test(data)) {
146
- return 'base64';
147
- }
148
- // Regular expression for base64 (simple version, checking for base64 format)
149
- const imageBase64Regex = /^data:image\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/;
150
- if (imageBase64Regex.test(data)) {
151
- return 'imageBase64';
152
- }
153
- // Regular expression for URL (simple version, checking for common URL format)
154
- const urlRegex = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
155
- if (urlRegex.test(data)) {
156
- return 'url';
157
- }
158
- return null;
159
- };
160
- const isBinary = (arrayBuffer) => {
161
- const view = new Uint8Array(arrayBuffer);
162
- let nonTextCount = 0;
163
- const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)
164
- for (let i = 0; i < view.length; i++) {
165
- const byte = view[i];
166
- // ASCII printable characters (32-126) and common whitespace (9, 10, 13)
167
- if ((byte >= 32 && byte <= 126) || // Printable ASCII
168
- byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR
169
- ) {
170
- continue;
171
- }
172
- nonTextCount++;
173
- if (nonTextCount / view.length > threshold) {
174
- return true; // More than threshold are non-text bytes
175
- }
176
- }
177
- return false; // Fewer than threshold are non-text bytes
178
- };
179
- const saveBufferToOPFS = async (filePath, buffer) => {
180
- // Access the OPFS root directory
181
- const rootHandle = await navigator.storage.getDirectory();
182
- // Split the filePath into directory segments and file name
183
- const segments = filePath.split('/').filter(Boolean);
184
- const fileName = segments.pop(); // Extract the file name
185
- if (!fileName) {
186
- throw new Error('Invalid file path: No file name provided.');
187
- }
188
- // Traverse or create directories as needed
189
- let currentDirHandle = rootHandle;
190
- for (const segment of segments) {
191
- currentDirHandle = await currentDirHandle.getDirectoryHandle(segment, { create: true });
192
- }
193
- // Create or open the file in OPFS
194
- const fileHandleAsync = await currentDirHandle.getFileHandle(fileName, { create: true });
195
- const fileHandle = await fileHandleAsync.createSyncAccessHandle();
196
- // Write the buffer to the file
197
- fileHandle.write(buffer);
198
- fileHandle.flush();
199
- fileHandle.close();
200
- };
201
- const getFilesPath = (filesRoot, ...parts) => {
202
- const root = filesRoot.replace(/\/$/, '');
203
- return [root, ...parts].filter(Boolean).join('/').replace(/\/+/g, '/');
204
- };
205
- const toBaseUrl = (hostOrUrl) => {
206
- const h = (hostOrUrl || '').trim().replace(/\/$/, '');
207
- if (!h)
208
- return '';
209
- if (h.startsWith('http://') || h.startsWith('https://'))
210
- return h;
211
- const protocol = h.startsWith('127.0.0.1') || h.startsWith('localhost') || h.includes(':1984')
212
- ? 'http'
213
- : 'https';
214
- return `${protocol}://${h}`;
215
- };
216
- /**
217
- * GET /raw/{id} from each gateway in order. `networkFailedEverywhere` is true only when no gateway
218
- * answered at all; a non-2xx (e.g. not yet propagated) is not a reason to exclude the transaction.
219
- */
220
- const fetchRaw = async (baseUrls, transactionId) => {
221
- let answered = false;
222
- for (const base of baseUrls) {
223
- try {
224
- const response = await fetch(`${base}/raw/${transactionId}`);
225
- answered = true;
226
- if (!response.ok)
227
- continue;
228
- const arrayBuffer = await response.arrayBuffer();
229
- if (arrayBuffer.byteLength > 0) {
230
- return { arrayBuffer, networkFailedEverywhere: false };
231
- }
232
- }
233
- catch (error) {
234
- /* next gateway */
235
- }
236
- }
237
- return { networkFailedEverywhere: !answered };
238
- };
239
- const downloadFiles = async ({ transactionIds, arweaveHost, arweaveBaseUrls, filesRoot = '/files', }) => {
240
- // Preferred / resolved gateways first, then the configured host; deduped.
241
- const baseUrls = [];
242
- for (const candidate of (arweaveBaseUrls || []).concat([arweaveHost])) {
243
- const base = toBaseUrl(candidate);
244
- if (base && baseUrls.indexOf(base) === -1) {
245
- baseUrls.push(base);
246
- }
247
- }
248
- for (const transactionId of transactionIds) {
249
- const { arrayBuffer, networkFailedEverywhere } = await fetchRaw(baseUrls, transactionId);
250
- if (!arrayBuffer) {
251
- if (networkFailedEverywhere) {
252
- globalThis.postMessage({
253
- message: 'excludeTransaction',
254
- transactionId,
255
- });
256
- }
257
- continue;
258
- }
259
- let dataString;
260
- const isBinaryData = isBinary(arrayBuffer);
261
- if (!isBinaryData) {
262
- const decoder = new TextDecoder('utf-8');
263
- const text = decoder.decode(arrayBuffer);
264
- dataString = text;
265
- }
266
- if (dataString && dataString.startsWith('===FILE_SEPARATOR===')) {
267
- const dataStringParts = dataString
268
- .split('===FILE_SEPARATOR===')
269
- .slice(1);
270
- if (dataStringParts.length % 2 !== 0) {
271
- throw new Error('Input array must have an even number of elements.');
272
- }
273
- for (let i = 0; i < dataStringParts.length; i += 2) {
274
- const contentType = dataStringParts[i];
275
- const content = dataStringParts[i + 1];
276
- const encoder = new TextEncoder();
277
- if (contentType === 'html') {
278
- const fileName = `${transactionId}.html`;
279
- const buffer = encoder.encode(content);
280
- saveBufferToOPFS(getFilesPath(filesRoot, 'html', fileName), buffer);
281
- }
282
- if (contentType === 'json') {
283
- const fileName = `${transactionId}.json`;
284
- const buffer = encoder.encode(content);
285
- saveBufferToOPFS(getFilesPath(filesRoot, 'json', fileName), buffer);
286
- }
287
- }
288
- continue;
289
- }
290
- if (!dataString && arrayBuffer) {
291
- saveBufferToOPFS(getFilesPath(filesRoot, 'images', transactionId), new Uint8Array(arrayBuffer));
292
- continue;
293
- }
294
- if (!dataString) {
295
- continue;
296
- }
297
- let contentType = identifyString(dataString);
298
- if (contentType !== 'json' &&
299
- contentType !== 'base64' &&
300
- contentType !== 'html') {
301
- const possibleImageType = getDataTypeFromString(dataString);
302
- if (!possibleImageType) {
303
- continue;
304
- }
305
- contentType = possibleImageType;
306
- }
307
- if (contentType === 'url') {
308
- const url = dataString;
309
- let buffer;
310
- try {
311
- const response = await fetch(url);
312
- if (!response.ok) {
313
- continue;
314
- }
315
- buffer = await response.arrayBuffer();
316
- }
317
- catch (error) {
318
- globalThis.postMessage({
319
- message: 'excludeTransaction',
320
- transactionId,
321
- });
322
- continue;
323
- }
324
- const bufferUint8Array = new Uint8Array(buffer);
325
- // Extract the file extension from the URL
326
- const extensionMatch = url.match(/\.(jpg|jpeg|png|gif|bmp|webp|svg)$/i);
327
- if (!extensionMatch) {
328
- throw new Error('Unable to determine the file extension from the URL.');
329
- }
330
- extensionMatch[0]; // e.g., ".jpg"
331
- // Set the file name (you can customize this)
332
- // const fileNameFromUrl = `${transactionId}${fileExtension}`
333
- await saveBufferToOPFS(getFilesPath(filesRoot, 'images', transactionId), bufferUint8Array);
334
- continue;
335
- }
336
- const mimeType = getMimeType(dataString);
337
- let fileExtension = mimeType;
338
- if (fileExtension && fileExtension?.startsWith('image')) {
339
- fileExtension = fileExtension.replace('image/', '');
340
- }
341
- let fileName = transactionId;
342
- if (contentType === 'base64') {
343
- if (fileExtension) {
344
- fileName += `.${fileExtension}`;
345
- }
346
- // Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
347
- const base64Data = dataString.split(',').pop() || '';
348
- // Decode the Base64 string to binary
349
- const binaryString = atob(base64Data);
350
- const length = binaryString.length;
351
- const binaryData = new Uint8Array(length);
352
- for (let i = 0; i < length; i++) {
353
- binaryData[i] = binaryString.charCodeAt(i);
354
- }
355
- await saveBufferToOPFS(getFilesPath(filesRoot, 'images', fileName), binaryData);
356
- }
357
- if (contentType === 'html') {
358
- fileName += '.html';
359
- const encoder = new TextEncoder();
360
- const buffer = encoder.encode(dataString);
361
- await saveBufferToOPFS(getFilesPath(filesRoot, 'html', fileName), buffer);
362
- }
363
- if (contentType === 'json') {
364
- fileName += '.json';
365
- const encoder = new TextEncoder();
366
- const buffer = encoder.encode(dataString);
367
- await saveBufferToOPFS(getFilesPath(filesRoot, 'json', fileName), buffer);
368
- }
369
- }
370
- };
371
- onmessage = async (e) => {
372
- const { debug, filesRoot } = e.data;
373
- if (!debug) {
374
- console.log = () => { };
375
- }
376
- await downloadFiles({ ...e.data, filesRoot });
377
- globalThis.postMessage({
378
- message: 'filesDownload onmessage done',
379
- done: true,
380
- });
381
- };
382
- }.toString()}
383
- )()`;
384
-
385
- const logger$5 = debug('seedSdk:browser:workers:FileDownloader');
386
- class FileDownloader {
387
- constructor() {
388
- this.workersArchive = [];
389
- this.downloadAll = async ({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions }) => {
390
- if (this.workersArchive.length > 0) {
391
- for (let i = 0; i < this.workersArchive.length; i++) {
392
- this.workersArchive[i].terminate();
393
- delete this.workersArchive[i];
394
- }
395
- this.workersArchive = [];
396
- }
397
- const worker = new Worker(this.workerBlobUrl);
398
- this.workersArchive.push(worker);
399
- const localExcludedTransactions = new Set(excludedTransactions);
400
- return new Promise((resolve, reject) => {
401
- worker.onmessage = (e) => {
402
- logger$5('filesDownload main thread onmessage', e.data);
403
- if (e.data.message === 'excludeTransaction') {
404
- localExcludedTransactions.add(e.data.transactionId);
405
- }
406
- if (e.data.done) {
407
- saveAppState('excludedTransactions', JSON.stringify(Array.from(localExcludedTransactions)))
408
- .then(() => {
409
- resolve(e.data);
410
- })
411
- .catch((error) => {
412
- reject(error);
413
- });
414
- }
415
- if (e.data.error) {
416
- reject(e.data.error);
417
- }
418
- };
419
- worker.postMessage({
420
- transactionIds,
421
- arweaveHost,
422
- arweaveBaseUrls,
423
- debug: logger$5.enabled,
424
- filesRoot: BaseFileManager.getWorkingDir(),
425
- });
426
- });
427
- };
428
- this.cores = Math.min(navigator.hardwareConcurrency || 4, 4);
429
- this.workerBlobUrl = globalThis.URL.createObjectURL(new Blob([filesDownload], { type: 'application/javascript' }));
430
- }
431
- }
432
-
433
- var imageResize = `(
434
- ${function () {
435
- async function listFilesInDirectory(directoryHandle) {
436
- const entries = [];
437
- for await (const [name, handle] of directoryHandle.entries()) {
438
- entries.push({
439
- name,
440
- kind: handle.kind,
441
- });
442
- }
443
- return entries;
444
- }
445
- const getFileHandle = async (path, rootHandle = null) => {
446
- // Split the path into segments
447
- const segments = path.split('/').filter(Boolean);
448
- // Start from the root directory if not provided
449
- if (!rootHandle) {
450
- rootHandle = await navigator.storage.getDirectory();
451
- }
452
- let currentHandle = rootHandle;
453
- // Traverse the path segments
454
- for (let i = 0; i < segments.length; i++) {
455
- const segment = segments[i];
456
- const isLastSegment = i === segments.length - 1;
457
- try {
458
- for await (const [name, handle] of currentHandle.entries()) {
459
- if (name !== segment) {
460
- continue;
461
- }
462
- if (isLastSegment) {
463
- if (handle.kind === 'file') {
464
- return handle; // Return the file handle if found
465
- }
466
- else {
467
- throw new Error(`Path '${path}' refers to a directory, not a file.`);
468
- }
469
- }
470
- else if (handle.kind === 'directory') {
471
- currentHandle = handle; // Traverse into the directory
472
- }
473
- else {
474
- throw new Error(`Invalid path segment '${segment}'`);
475
- }
476
- }
477
- }
478
- catch (err) {
479
- if (err instanceof Error && err.name === 'NotFoundError') {
480
- throw new Error(`Path '${path}' does not exist.`);
481
- }
482
- else {
483
- throw err;
484
- }
485
- }
486
- }
487
- throw new Error(`Path '${path}' could not be resolved.`);
488
- };
489
- async function getFileFromOPFS(path) {
490
- const fileHandleAsync = await getFileHandle(path);
491
- const file = await fileHandleAsync.getFile();
492
- return file;
493
- }
494
- /** Infer MIME from magic bytes. OPFS File may have empty type, causing createImageBitmap to fail. */
495
- async function getBlobWithInferredMime(file) {
496
- const buf = await file.arrayBuffer();
497
- const bytes = new Uint8Array(buf);
498
- let mime = file.type;
499
- if (!mime || mime === '') {
500
- if (bytes[0] === 0xff && bytes[1] === 0xd8)
501
- mime = 'image/jpeg';
502
- else if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47)
503
- mime = 'image/png';
504
- else if (bytes[0] === 0x52 && bytes[1] === 0x49 && bytes[2] === 0x46 && bytes[3] === 0x52 && bytes[8] === 0x57 && bytes[9] === 0x45 && bytes[10] === 0x42 && bytes[11] === 0x50)
505
- mime = 'image/webp';
506
- else if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46)
507
- mime = 'image/gif';
508
- else if (bytes[0] === 0x42 && bytes[1] === 0x4d)
509
- mime = 'image/bmp';
510
- else if (bytes[4] === 0x66 && bytes[5] === 0x74 && bytes[6] === 0x79 && bytes[7] === 0x70 && bytes[8] === 0x61 && bytes[9] === 0x76 && bytes[10] === 0x69 && bytes[11] === 0x66)
511
- mime = 'image/avif';
512
- else if (bytes[4] === 0x66 && bytes[5] === 0x74 && bytes[6] === 0x79 && bytes[7] === 0x70 && bytes[8] === 0x68 && bytes[9] === 0x65 && bytes[10] === 0x69 && bytes[11] === 0x63)
513
- mime = 'image/heic';
514
- else
515
- mime = 'image/jpeg';
516
- }
517
- return new Blob([buf], { type: mime });
518
- }
519
- const DEFAULT_CONFIG = {
520
- argorithm: 'null',
521
- processByHalf: true,
522
- quality: 0.5,
523
- maxWidth: 800,
524
- maxHeight: 600,
525
- debug: false,
526
- mimeType: 'image/jpeg',
527
- };
528
- function isIos() {
529
- if (typeof navigator === 'undefined')
530
- return false;
531
- if (!navigator.userAgent)
532
- return false;
533
- return /iPad|iPhone|iPod/.test(navigator.userAgent);
534
- }
535
- const getTargetHeight = (srcHeight, scale, config) => {
536
- return Math.min(Math.floor(srcHeight * scale), config.maxHeight);
537
- };
538
- const findMaxWidth = (config, canvas) => {
539
- //Let's find the max available width for scaled image
540
- const ratio = canvas.width / canvas.height;
541
- let mWidth = Math.min(canvas.width, config.maxWidth, ratio * config.maxHeight);
542
- if (config.maxSize &&
543
- config.maxSize > 0 &&
544
- config.maxSize < (canvas.width * canvas.height) / 1000)
545
- mWidth = Math.min(mWidth, Math.floor((config.maxSize * 1000) / canvas.height));
546
- if (!!config.scaleRatio)
547
- mWidth = Math.min(mWidth, Math.floor(config.scaleRatio * canvas.width));
548
- const rHeight = getTargetHeight(canvas.height, mWidth / canvas.width, config);
549
- // console.log(
550
- // 'browser-image-resizer: original image size = ' +
551
- // canvas.width +
552
- // ' px (width) X ' +
553
- // canvas.height +
554
- // ' px (height)'
555
- // );
556
- // console.log(
557
- // 'browser-image-resizer: scaled image size = ' +
558
- // mWidth +
559
- // ' px (width) X ' +
560
- // rHeight +
561
- // ' px (height)'
562
- // );
563
- if (mWidth <= 0) {
564
- mWidth = 1;
565
- console.warn("browser-image-resizer: image size is too small");
566
- }
567
- if (isIos() && mWidth * rHeight > 167777216) {
568
- console.error("browser-image-resizer: image size is too large for iOS WebKit.", mWidth, rHeight);
569
- throw new Error("browser-image-resizer: image size is too large for iOS WebKit.");
570
- }
571
- return mWidth;
572
- };
573
- /**
574
- * Hermite resize, multicore version - fast image resize/resample using Hermite filter.
575
- */
576
- const resample = (srcCanvas, destCanvas, config) => {
577
- return new Promise((resolve, reject) => {
578
- const ratio_h = srcCanvas.height / destCanvas.height;
579
- const cores = Math.min(navigator.hardwareConcurrency || 4, 4);
580
- //prepare source and target data for workers
581
- const ctx = srcCanvas.getContext('2d');
582
- if (!ctx)
583
- return reject('Canvas is empty (resample)');
584
- const data_part = [];
585
- const block_height = Math.ceil(srcCanvas.height / cores / 2) * 2;
586
- let end_y = -1;
587
- for (let c = 0; c < cores; c++) {
588
- //source
589
- const offset_y = end_y + 1;
590
- if (offset_y >= srcCanvas.height) {
591
- //size too small, nothing left for this core
592
- continue;
593
- }
594
- end_y = Math.min(offset_y + block_height - 1, srcCanvas.height - 1);
595
- const current_block_height = Math.min(block_height, srcCanvas.height - offset_y);
596
- data_part.push({
597
- source: ctx.getImageData(0, offset_y, srcCanvas.width, block_height),
598
- startY: Math.ceil(offset_y / ratio_h),
599
- height: current_block_height
600
- });
601
- }
602
- //start
603
- const destCtx = destCanvas.getContext('2d');
604
- if (!destCtx)
605
- return reject('Canvas is empty (resample dest)');
606
- for (let c = 0; c < data_part.length; c++) {
607
- //draw
608
- const height_part = Math.ceil(data_part[c].height / ratio_h);
609
- const target = destCtx.createImageData(destCanvas.width, height_part);
610
- // target.data.set(event.data.target);
611
- destCtx.putImageData(target, 0, data_part[c].startY);
612
- }
613
- });
614
- };
615
- /**
616
- * Hermite resize - fast image resize/resample using Hermite filter. 1 cpu version!
617
- */
618
- const resampleSingle = (srcCanvasData, destCanvasData) => {
619
- const ratio_w = srcCanvasData.width / destCanvasData.width;
620
- const ratio_h = srcCanvasData.height / destCanvasData.height;
621
- const ratio_w_half = Math.ceil(ratio_w / 2);
622
- const ratio_h_half = Math.ceil(ratio_h / 2);
623
- const data = srcCanvasData.data;
624
- const data2 = destCanvasData.data;
625
- for (let j = 0; j < destCanvasData.height; j++) {
626
- for (let i = 0; i < destCanvasData.width; i++) {
627
- const x2 = (i + j * destCanvasData.width) * 4;
628
- let weight = 0;
629
- let weights = 0;
630
- let weights_alpha = 0;
631
- let gx_r = 0;
632
- let gx_g = 0;
633
- let gx_b = 0;
634
- let gx_a = 0;
635
- const center_y = j * ratio_h;
636
- const xx_start = Math.floor(i * ratio_w);
637
- const xx_stop = Math.min(Math.ceil((i + 1) * ratio_w), srcCanvasData.width);
638
- const yy_start = Math.floor(j * ratio_h);
639
- const yy_stop = Math.min(Math.ceil((j + 1) * ratio_h), srcCanvasData.height);
640
- for (let yy = yy_start; yy < yy_stop; yy++) {
641
- let dy = Math.abs(center_y - yy) / ratio_h_half;
642
- let center_x = i * ratio_w;
643
- let w0 = dy * dy; //pre-calc part of w
644
- for (let xx = xx_start; xx < xx_stop; xx++) {
645
- let dx = Math.abs(center_x - xx) / ratio_w_half;
646
- let w = Math.sqrt(w0 + dx * dx);
647
- if (w >= 1) {
648
- //pixel too far
649
- continue;
650
- }
651
- //hermite filter
652
- weight = 2 * w * w * w - 3 * w * w + 1;
653
- let pos_x = 4 * (xx + yy * srcCanvasData.width);
654
- //alpha
655
- gx_a += weight * data[pos_x + 3];
656
- weights_alpha += weight;
657
- //colors
658
- if (data[pos_x + 3] < 255)
659
- weight = weight * data[pos_x + 3] / 250;
660
- gx_r += weight * data[pos_x];
661
- gx_g += weight * data[pos_x + 1];
662
- gx_b += weight * data[pos_x + 2];
663
- weights += weight;
664
- }
665
- }
666
- data2[x2] = gx_r / weights;
667
- data2[x2 + 1] = gx_g / weights;
668
- data2[x2 + 2] = gx_b / weights;
669
- data2[x2 + 3] = gx_a / weights_alpha;
670
- }
671
- }
672
- };
673
- /**
674
- * Hermite resize. Detect cpu count and use best option for user.
675
- */
676
- const resampleAuto = (srcCanvas, destCanvas, config) => {
677
- if (!!globalThis.Worker && navigator.hardwareConcurrency > 1 && config?.argorithm !== 'hermite_single') {
678
- //workers supported and we have at least 2 cpu cores - using multithreading
679
- return resample(srcCanvas, destCanvas);
680
- }
681
- else {
682
- //1 cpu version
683
- const { srcImgData, destImgData } = getImageData(srcCanvas, destCanvas);
684
- resampleSingle(srcImgData, destImgData);
685
- destCanvas.getContext('2d').putImageData(destImgData, 0, 0);
686
- return;
687
- }
688
- };
689
- async function scaleCanvasWithAlgorithm(canvas, config) {
690
- const scale = config.outputWidth / canvas.width;
691
- const scaled = new OffscreenCanvas(Math.floor(config.outputWidth), getTargetHeight(canvas.height, scale, config));
692
- switch (config.algorithm) {
693
- case 'hermite': {
694
- await resampleAuto(canvas, scaled, config);
695
- break;
696
- }
697
- case 'hermite_single': {
698
- const { srcImgData, destImgData } = getImageData(canvas, scaled);
699
- resampleSingle(srcImgData, destImgData);
700
- scaled?.getContext('2d')?.putImageData(destImgData, 0, 0);
701
- break;
702
- }
703
- case 'bilinear': {
704
- // const { srcImgData, destImgData } = getImageData(canvas, scaled);
705
- // bilinear(srcImgData, destImgData, scale);
706
- // scaled?.getContext('2d')?.putImageData(destImgData, 0, 0);
707
- break;
708
- }
709
- default: {
710
- scaled.getContext('2d')?.drawImage(canvas, 0, 0, scaled.width, scaled.height);
711
- break;
712
- }
713
- }
714
- return scaled;
715
- }
716
- const getHalfScaleCanvas = (src) => {
717
- const half = new OffscreenCanvas(src.width / 2, src.height / 2);
718
- half
719
- ?.getContext('2d')
720
- ?.drawImage(src, 0, 0, half.width, half.height);
721
- return half;
722
- };
723
- const getImageData = (canvas, scaled) => {
724
- const srcImgData = canvas
725
- ?.getContext('2d')
726
- ?.getImageData(0, 0, canvas.width, canvas.height);
727
- const destImgData = scaled
728
- ?.getContext('2d')
729
- ?.createImageData(scaled.width, scaled.height);
730
- if (!srcImgData || !destImgData)
731
- throw Error('Canvas is empty (scaleCanvasWithAlgorithm). You should run this script after the document is ready.');
732
- return { srcImgData, destImgData };
733
- };
734
- async function saveBlobToOPFS(filePath, blob) {
735
- // Access the OPFS root directory
736
- const rootHandle = await navigator.storage.getDirectory();
737
- // Split the filePath into directory segments and file name
738
- const segments = filePath.split('/').filter(Boolean);
739
- const fileName = segments.pop(); // Extract the file name
740
- if (!fileName) {
741
- throw new Error('Invalid file path: No file name provided.');
742
- }
743
- // Traverse or create directories as needed
744
- let currentDirHandle = rootHandle;
745
- for (const segment of segments) {
746
- currentDirHandle = await currentDirHandle.getDirectoryHandle(segment, { create: true });
747
- }
748
- // Create or open the file in OPFS
749
- const fileHandle = await currentDirHandle.getFileHandle(fileName, { create: true });
750
- // Write the Blob to the file
751
- const writableStream = await fileHandle.createWritable();
752
- await writableStream.write(blob);
753
- await writableStream.close();
754
- }
755
- const imageResize = async (filePath, width, height) => {
756
- const config = {
757
- ...DEFAULT_CONFIG,
758
- algorithm: 'hermite_single',
759
- mimeType: 'image/webp',
760
- maxWidth: width,
761
- maxHeight: height,
762
- };
763
- const rootHandle = await navigator.storage.getDirectory();
764
- // List files in the root directory
765
- await listFilesInDirectory(rootHandle);
766
- const file = await getFileFromOPFS(filePath);
767
- const blobWithMime = await getBlobWithInferredMime(file);
768
- const imageBitmap = await createImageBitmap(blobWithMime);
769
- let converting;
770
- if (isIos() && imageBitmap.width * imageBitmap.height > 16777216) {
771
- const scale = Math.sqrt(16777216 / (imageBitmap.width * imageBitmap.height));
772
- converting = new OffscreenCanvas(Math.floor(imageBitmap.width * scale), Math.floor(imageBitmap.height * scale));
773
- converting.getContext('2d')?.drawImage(imageBitmap, 0, 0, converting.width, converting.height);
774
- }
775
- else {
776
- converting = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
777
- converting.getContext('2d')?.drawImage(imageBitmap, 0, 0);
778
- }
779
- const maxWidth = findMaxWidth(config, converting);
780
- if (!maxWidth) {
781
- throw Error(`browser-image-resizer: maxWidth is ${maxWidth}!!`);
782
- }
783
- while (config.processByHalf && converting.width >= 2 * maxWidth) {
784
- converting = getHalfScaleCanvas(converting);
785
- }
786
- if (converting.width > maxWidth) {
787
- converting = await scaleCanvasWithAlgorithm(converting, Object.assign(config, { outputWidth: maxWidth }));
788
- }
789
- if (config.mimeType === null) {
790
- return converting;
791
- }
792
- const resizedBlob = await converting.convertToBlob({ type: config.mimeType, quality: config.quality });
793
- const pathSegments = filePath.split('/');
794
- const fileName = pathSegments.pop();
795
- if (!fileName) {
796
- throw Error('Invalid file path: No file name provided.');
797
- }
798
- const newSegments = [
799
- ...pathSegments,
800
- width,
801
- ];
802
- const fileNameParts = fileName.split('.');
803
- const newFileName = `${fileNameParts[0]}.webp`;
804
- const newDirPath = newSegments.join('/');
805
- const newFilePath = `${newDirPath}/${newFileName}`;
806
- await saveBlobToOPFS(newFilePath, resizedBlob);
807
- globalThis.postMessage({
808
- done: true,
809
- filePath: newFilePath,
810
- });
811
- };
812
- onmessage = async (e) => {
813
- const { filePath, width, height, debug } = e.data;
814
- if (!debug) {
815
- console.log = () => { };
816
- }
817
- try {
818
- await imageResize(filePath, width, height);
819
- }
820
- catch (err) {
821
- globalThis.postMessage({ error: err instanceof Error ? err.message : String(err) });
822
- }
823
- };
824
- }.toString()}
825
- )()`;
826
-
827
- const logger$4 = debug('seedSdk:browser:workers:ImageResizer');
828
- class ImageResizer {
829
- constructor() {
830
- this.workersArchive = new Map();
831
- this.cores = Math.min(navigator.hardwareConcurrency || 4, 4);
832
- this.workerBlobUrl = globalThis.URL.createObjectURL(new Blob([imageResize], { type: 'application/javascript' }));
833
- }
834
- async resize({ filePath, width, height }) {
835
- if (this.workersArchive.has(filePath)) {
836
- const savedWorker = this.workersArchive.get(filePath);
837
- savedWorker?.terminate();
838
- logger$4('[ImageResizer.resize] Terminated worker for filePath due to incoming request', filePath);
839
- this.workersArchive.delete(filePath);
840
- }
841
- const worker = new Worker(this.workerBlobUrl);
842
- this.workersArchive.set(filePath, worker);
843
- return new Promise((resolve, reject) => {
844
- worker.onmessage = (e) => {
845
- logger$4('[ImageResizer.resize] main thread onmessage', e.data);
846
- if (e.data.done) {
847
- const savedWorker = this.workersArchive.get(filePath);
848
- savedWorker?.terminate();
849
- logger$4('[ImageResizer.resize] Terminated worker for filePath due to done', filePath);
850
- this.workersArchive.delete(filePath);
851
- resolve(e.data);
852
- }
853
- if (e.data.error) {
854
- reject(e.data.error);
855
- }
856
- };
857
- worker.onerror = (err) => {
858
- reject(err);
859
- };
860
- worker.postMessage({
861
- filePath,
862
- width,
863
- height,
864
- debug: logger$4.enabled,
865
- });
866
- });
867
- }
868
- async resizeAll({ width, height }) {
869
- const fs = await BaseFileManager.getFs();
870
- const imageDir = BaseFileManager.getFilesPath('images');
871
- let imageFilesStats = await fs.promises.readdir(imageDir, {
872
- withFileTypes: true
873
- });
874
- imageFilesStats = imageFilesStats.filter((file) => file.isFile());
875
- const imageFiles = imageFilesStats.map((file) => file.path);
876
- const widthDir = `${imageDir}/${width}`;
877
- await BaseFileManager.createDirIfNotExists(widthDir);
878
- for (const imageFile of imageFiles) {
879
- const resizedImageExists = await BaseFileManager.pathExists(`${widthDir}/${imageFile}`);
880
- if (!resizedImageExists) {
881
- await this.resize({ filePath: `${imageDir}/${imageFile}`, width, height });
882
- }
883
- }
884
- }
885
- }
886
-
887
- const logger$3 = debug('seedSdk:browser:helpers:FileManager');
888
- /**
889
- * Browser-safe path helpers for SDK virtual file paths.
890
- * We intentionally avoid Node/CJS path polyfills here to keep browser bundles ESM-safe.
891
- * Provides the subset of Node path APIs used via BaseFileManager.getPathModule().
892
- */
893
- const pathCompat = {
894
- dirname(filePath) {
895
- if (!filePath)
896
- return '.';
897
- const normalized = filePath.replace(/\\/g, '/');
898
- if (normalized === '/')
899
- return '/';
900
- const trimmed = normalized.endsWith('/') && normalized.length > 1
901
- ? normalized.slice(0, -1)
902
- : normalized;
903
- const lastSlash = trimmed.lastIndexOf('/');
904
- if (lastSlash === -1)
905
- return '.';
906
- if (lastSlash === 0)
907
- return '/';
908
- return trimmed.slice(0, lastSlash);
909
- },
910
- basename(filePath) {
911
- if (!filePath)
912
- return '';
913
- const normalized = filePath.replace(/\\/g, '/');
914
- if (normalized === '/')
915
- return '/';
916
- const trimmed = normalized.endsWith('/') && normalized.length > 1
917
- ? normalized.slice(0, -1)
918
- : normalized;
919
- const lastSlash = trimmed.lastIndexOf('/');
920
- return lastSlash === -1 ? trimmed : trimmed.slice(lastSlash + 1);
921
- },
922
- isAbsolute(filePath) {
923
- if (!filePath)
924
- return false;
925
- const normalized = filePath.replace(/\\/g, '/');
926
- return normalized.startsWith('/');
927
- },
928
- join(...segments) {
929
- if (segments.length === 0)
930
- return '.';
931
- const joined = segments
932
- .filter((s) => s != null && s !== '')
933
- .map((s) => String(s).replace(/\\/g, '/'))
934
- .join('/');
935
- return pathCompat.normalize(joined);
936
- },
937
- resolve(...segments) {
938
- // POSIX-like resolve for virtual paths: walk right-to-left until absolute.
939
- let resolved = '';
940
- let absolute = false;
941
- for (let i = segments.length - 1; i >= 0 && !absolute; i--) {
942
- const segment = segments[i];
943
- if (segment == null || segment === '')
944
- continue;
945
- const normalized = String(segment).replace(/\\/g, '/');
946
- resolved = resolved ? `${normalized}/${resolved}` : normalized;
947
- absolute = pathCompat.isAbsolute(normalized);
948
- }
949
- // Browser has no process.cwd(); treat unresolved relative paths as root-relative.
950
- if (!absolute) {
951
- resolved = `/${resolved}`;
952
- }
953
- return pathCompat.normalize(resolved);
954
- },
955
- normalize(filePath) {
956
- if (!filePath)
957
- return '.';
958
- const normalized = filePath.replace(/\\/g, '/');
959
- const absolute = normalized.startsWith('/');
960
- const parts = normalized.split('/');
961
- const stack = [];
962
- for (const part of parts) {
963
- if (!part || part === '.')
964
- continue;
965
- if (part === '..') {
966
- if (stack.length > 0 && stack[stack.length - 1] !== '..') {
967
- stack.pop();
968
- }
969
- else if (!absolute) {
970
- stack.push('..');
971
- }
972
- continue;
973
- }
974
- stack.push(part);
975
- }
976
- const result = stack.join('/');
977
- if (absolute)
978
- return `/${result}`;
979
- return result || '.';
980
- },
981
- };
982
- /** Chromium OPFS: a directory/file handle is stale (reload, other tab, leftover sync access handle). */
983
- function isStaleOpfsHandleError(error) {
984
- if (error instanceof DOMException && error.name === 'InvalidStateError') {
985
- return true;
986
- }
987
- const message = error instanceof Error ? error.message : String(error);
988
- return message.includes('state cached in an interface object');
989
- }
990
- /** OPFS / ZenFS can throw NotReadableError while a file is still settling after write. */
991
- function isTransientOpfsReadError(error) {
992
- if (error instanceof DOMException && error.name === 'NotReadableError') {
993
- return true;
994
- }
995
- const message = error instanceof Error ? error.message : String(error);
996
- // Chromium wording when getFile/read races a writer or stale handle
997
- if (message.includes('permission problems') && message.includes('reference')) {
998
- return true;
999
- }
1000
- return false;
1001
- }
1002
- function sleep(ms) {
1003
- return new Promise((resolve) => setTimeout(resolve, ms));
1004
- }
1005
- class BrowserFileManager {
1006
- constructor() {
1007
- this.zenfsCache = null;
1008
- }
1009
- async getFs() {
1010
- if (!this.zenfsCache) {
1011
- this.zenfsCache = await import('@zenfs/core');
1012
- }
1013
- return this.zenfsCache;
1014
- }
1015
- getFsSync() {
1016
- if (!this.zenfsCache) {
1017
- throw new Error('File system not initialized. Call getFs() or initializeFileSystem() first.');
1018
- }
1019
- return this.zenfsCache;
1020
- }
1021
- async getContentUrlFromPath(path) {
1022
- const fileExists = await this.pathExists(path);
1023
- if (fileExists) {
1024
- const file = await this.readFile(path);
1025
- return URL.createObjectURL(file);
1026
- }
1027
- }
1028
- async initializeFileSystem(_workingDir) {
1029
- const zenfs = await this.getFs();
1030
- const zenfsDomMod = await import('@zenfs/dom');
1031
- const { WebAccess } = zenfsDomMod;
1032
- const { configureSingle } = zenfs;
1033
- const configureRoot = async () => {
1034
- const handle = await navigator.storage.getDirectory();
1035
- await configureSingle({
1036
- backend: WebAccess,
1037
- handle,
1038
- });
1039
- };
1040
- try {
1041
- await configureRoot();
1042
- }
1043
- catch (error) {
1044
- if (!isStaleOpfsHandleError(error)) {
1045
- throw error;
1046
- }
1047
- // Leftover sync-access handles can make the first walk throw. Retry once
1048
- // without deleting OPFS data; BaseFileManager resets flags if this still fails.
1049
- await sleep(50);
1050
- await configureRoot();
1051
- }
1052
- }
1053
- async downloadAllFiles({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions, }) {
1054
- const fileDownloader = new FileDownloader();
1055
- await fileDownloader.downloadAll({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions });
1056
- }
1057
- async resizeImage({ filePath, width, height }) {
1058
- const imageResizer = new ImageResizer();
1059
- await imageResizer.resize({ filePath, width, height });
1060
- }
1061
- async resizeAllImages({ width, height }) {
1062
- const imageResizer = new ImageResizer();
1063
- await imageResizer.resizeAll({ width, height });
1064
- }
1065
- async listImageFiles() {
1066
- return this.listFiles('images');
1067
- }
1068
- async listFiles(dir) {
1069
- const targetDir = BaseFileManager.getFilesPath(dir);
1070
- const exists = await this.pathExists(targetDir);
1071
- if (!exists) {
1072
- return [];
1073
- }
1074
- const zenfs = await this.getFs();
1075
- const entries = await zenfs.promises.readdir(targetDir, { withFileTypes: true });
1076
- return entries.filter((entry) => entry.isFile()).map((entry) => entry.name);
1077
- }
1078
- async pathExists(filePath) {
1079
- try {
1080
- const zenfs = await this.getFs();
1081
- await zenfs.promises.access(filePath, zenfs.constants.F_OK);
1082
- return true;
1083
- }
1084
- catch (error) {
1085
- // ENOENT means the file doesn't exist, which is expected
1086
- if (error?.code === 'ENOENT' || error?.errno === -2) {
1087
- return false;
1088
- }
1089
- // For other errors, re-throw them
1090
- throw error;
1091
- }
1092
- }
1093
- async getFileSize(filePath) {
1094
- try {
1095
- const zenfs = await this.getFs();
1096
- const stat = await zenfs.promises.stat(filePath);
1097
- return typeof stat?.size === 'number' ? stat.size : null;
1098
- }
1099
- catch {
1100
- return null;
1101
- }
1102
- }
1103
- async createDirIfNotExists(filePath) {
1104
- if (!(await this.pathExists(filePath))) {
1105
- try {
1106
- const zenfs = await this.getFs();
1107
- await zenfs.promises.mkdir(filePath, { recursive: true });
1108
- }
1109
- catch (error) {
1110
- // This is a no-op. We tried to create a directory that already exists.
1111
- logger$3('Attempted to create a directory that already exists');
1112
- }
1113
- }
1114
- }
1115
- /**
1116
- * Waits for a file to exist at the specified path.
1117
- * @param {string} filePath - The path of the file to check.
1118
- * @param {number} interval - The interval in milliseconds between checks (default: 500ms).
1119
- * @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
1120
- * @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
1121
- */
1122
- async waitForFile(filePath, interval = 1000, timeout = 60000) {
1123
- // const fs = await this.getFs()
1124
- // const fsNode = await import('node:fs')
1125
- const pathExists = await this.pathExists(filePath);
1126
- if (pathExists) {
1127
- return true;
1128
- }
1129
- return new Promise((resolve, reject) => {
1130
- const startTime = Date.now();
1131
- let isBusy = false;
1132
- const cancelableInterval = new CancelableInterval(async (stop) => {
1133
- logger$3('waitForFile', filePath);
1134
- if (isBusy) {
1135
- return;
1136
- }
1137
- isBusy = true;
1138
- // // TODO: Needs to read from OPFS
1139
- // const exists = await BaseFileManager.pathExists(filePath)
1140
- // if (exists) {
1141
- // stop()
1142
- // resolve(true)
1143
- // }
1144
- const pathExists = await this.pathExists(filePath);
1145
- if (pathExists) {
1146
- stop();
1147
- resolve(true);
1148
- }
1149
- if (Date.now() - startTime >= timeout) {
1150
- stop();
1151
- reject(new Error('Timeout exceeded while waiting for file'));
1152
- }
1153
- isBusy = false;
1154
- }, interval);
1155
- cancelableInterval.start();
1156
- // const _interval = setInterval(async () => {
1157
- // logger('waitForFile', filePath)
1158
- // if (isBusy) {
1159
- // return
1160
- // }
1161
- // isBusy = true
1162
- // // TODO: Needs to read from OPFS
1163
- // if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
1164
- // clearInterval(_interval)
1165
- // resolve(true)
1166
- // }
1167
- // const pathExists = await this.pathExists(filePath)
1168
- // if (pathExists) {
1169
- // clearInterval(_interval)
1170
- // resolve(true)
1171
- // }
1172
- // if (Date.now() - startTime >= timeout) {
1173
- // clearInterval(_interval)
1174
- // reject(new Error('Timeout exceeded while waiting for file'))
1175
- // }
1176
- // isBusy = false
1177
- // }, interval)
1178
- // retry(
1179
- // {
1180
- // times: Math.ceil(timeout / interval),
1181
- // interval: interval,
1182
- // },
1183
- // (callback: Function) => {
1184
- // if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
1185
- // return callback(null, true) // File exists, finish with success
1186
- // }
1187
- // if (Date.now() - startTime >= timeout) {
1188
- // return callback(new Error('Timeout exceeded while waiting for file'))
1189
- // }
1190
- // callback(new Error('File does not exist yet')) // Retry with this error
1191
- // },
1192
- // (err: Error, result: boolean) => {
1193
- // if (err) {
1194
- // return resolve(false) // Resolve as false if timeout or error occurs
1195
- // }
1196
- // resolve(result) // Resolve as true if file exists
1197
- // },
1198
- // )
1199
- });
1200
- }
1201
- /**
1202
- * Waits for a file to exist and have content (non-zero size).
1203
- * This is important for browser/OPFS where writes may not be immediately readable.
1204
- * @param {string} filePath - The path of the file to check.
1205
- * @param {number} interval - The interval in milliseconds between checks (default: 100ms).
1206
- * @param {number} timeout - The timeout in milliseconds to wait (default: 5s).
1207
- * @returns {Promise<boolean>} - Resolves to true if the file exists with content within the timeout period.
1208
- */
1209
- async waitForFileWithContent(filePath, interval = 100, timeout = 5000) {
1210
- // First wait for file to exist
1211
- await this.waitForFile(filePath, interval, timeout);
1212
- // Now wait for file to have content
1213
- return new Promise((resolve, reject) => {
1214
- const startTime = Date.now();
1215
- let isBusy = false;
1216
- const cancelableInterval = new CancelableInterval(async (stop) => {
1217
- logger$3('waitForFileWithContent', filePath);
1218
- if (isBusy) {
1219
- return;
1220
- }
1221
- isBusy = true;
1222
- try {
1223
- // Try to read the file to check if it has content
1224
- const file = await this.readFile(filePath);
1225
- if (file.size > 0) {
1226
- stop();
1227
- resolve(true);
1228
- return;
1229
- }
1230
- // File exists but is 0 bytes, continue waiting
1231
- }
1232
- catch (error) {
1233
- // If error is about file being 0 bytes, not readable, or I/O error, continue waiting
1234
- const errorMessage = error?.message || String(error);
1235
- if (errorMessage.includes('0 bytes') ||
1236
- errorMessage.includes('ENOENT') ||
1237
- errorMessage.includes('EIO') ||
1238
- errorMessage.includes('Input/output error') ||
1239
- isTransientOpfsReadError(error)) ;
1240
- else {
1241
- // Other errors should be thrown
1242
- stop();
1243
- reject(error);
1244
- return;
1245
- }
1246
- }
1247
- if (Date.now() - startTime >= timeout) {
1248
- stop();
1249
- reject(new Error(`Timeout exceeded while waiting for file ${filePath} to have content`));
1250
- return;
1251
- }
1252
- isBusy = false;
1253
- }, interval);
1254
- cancelableInterval.start();
1255
- });
1256
- }
1257
- async saveFile(filePath, content) {
1258
- const zenfs = await this.getFs();
1259
- // Convert content to a format that zenfs.writeFile accepts
1260
- let writeContent;
1261
- if (typeof content === 'string') {
1262
- writeContent = content;
1263
- }
1264
- else if (content instanceof Blob) {
1265
- const arrayBuffer = await content.arrayBuffer();
1266
- writeContent = new Uint8Array(arrayBuffer);
1267
- }
1268
- else if (content instanceof ArrayBuffer) {
1269
- writeContent = new Uint8Array(content);
1270
- }
1271
- else {
1272
- throw new Error('Unsupported content type');
1273
- }
1274
- await zenfs.writeFile(filePath, writeContent);
1275
- await this.waitForFileWithContent(filePath, 100, 5000);
1276
- // try {
1277
- // // Get a handle to the OPFS root directory
1278
- // const root = await navigator.storage.getDirectory();
1279
- // // Split the file path into directory and file name
1280
- // const pathParts = filePath.split('/');
1281
- // const fileName = pathParts.pop();
1282
- // if (!fileName) throw new Error('Invalid file path');
1283
- // // Traverse directories and create them if they don't exist
1284
- // let currentDir = root;
1285
- // for (const part of pathParts) {
1286
- // if (part !== '') {
1287
- // currentDir = await currentDir.getDirectoryHandle(part, { create: true });
1288
- // }
1289
- // }
1290
- // // Get the file handle and create the file if it doesn't exist
1291
- // const fileHandle = await currentDir.getFileHandle(fileName, { create: true });
1292
- // // Create a writable stream and write the content
1293
- // const writable = await fileHandle.createWritable();
1294
- // if (typeof content === 'string' || content instanceof Uint8Array) {
1295
- // await writable.write(content);
1296
- // } else if (content instanceof Blob) {
1297
- // await writable.write(content);
1298
- // } else if (content instanceof ArrayBuffer) {
1299
- // await writable.write(new Blob([content]));
1300
- // } else {
1301
- // throw new Error('Unsupported content type');
1302
- // }
1303
- // await writable.close();
1304
- // logger(`File written successfully: ${filePath}`);
1305
- // } catch (error) {
1306
- // console.error(`Error writing to OPFS: ${error.message}`);
1307
- // }
1308
- }
1309
- saveFileSync(filePath, content) {
1310
- // Note: This is a synchronous wrapper, but zenfs operations may still be async under the hood
1311
- // For true sync operations in browser, we'd need to use OPFS sync access handles
1312
- // For now, we'll use zenfs.writeFileSync which should be available
1313
- const zenfs = this.getFsSync();
1314
- // Convert content to a format that zenfs.writeFileSync accepts
1315
- let writeContent;
1316
- if (typeof content === 'string') {
1317
- writeContent = content;
1318
- }
1319
- else if (content instanceof Blob) {
1320
- // Blob cannot be converted synchronously - throw error
1321
- throw new Error('Blob content not supported in saveFileSync. Use saveFile() instead or convert to ArrayBuffer first.');
1322
- }
1323
- else if (content instanceof ArrayBuffer) {
1324
- writeContent = new Uint8Array(content);
1325
- }
1326
- else {
1327
- throw new Error('Unsupported content type');
1328
- }
1329
- zenfs.writeFileSync(filePath, writeContent);
1330
- }
1331
- async readFile(filePath) {
1332
- const zenfs = await this.getFs();
1333
- const maxAttempts = 3;
1334
- const baseDelayMs = 50;
1335
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
1336
- try {
1337
- const data = await zenfs.promises.readFile(filePath);
1338
- return new File([new Uint8Array(data)], filePath);
1339
- }
1340
- catch (error) {
1341
- if (!isTransientOpfsReadError(error) || attempt === maxAttempts - 1) {
1342
- throw error;
1343
- }
1344
- await sleep(baseDelayMs * (attempt + 1));
1345
- }
1346
- }
1347
- throw new Error('readFile: exhausted retries');
1348
- // try {
1349
- // // Get a handle to the OPFS root directory
1350
- // const root = await navigator.storage.getDirectory();
1351
- // // Split the file path into directory and file name
1352
- // const pathParts = filePath.split('/');
1353
- // const fileName = pathParts.pop();
1354
- // if (!fileName) throw new Error('Invalid file path');
1355
- // // Traverse directories to reach the target file
1356
- // let currentDir = root;
1357
- // for (const part of pathParts) {
1358
- // if (part !== '') {
1359
- // currentDir = await currentDir.getDirectoryHandle(part, { create: false });
1360
- // }
1361
- // }
1362
- // // Get the file handle
1363
- // const fileHandle = await currentDir.getFileHandle(fileName, { create: false });
1364
- // // Get the file and read it as an ArrayBuffer
1365
- // return await fileHandle.getFile();
1366
- // } catch (error) {
1367
- // console.error(`Error reading from OPFS: ${error.message}`);
1368
- // throw error;
1369
- // }
1370
- }
1371
- readFileSync(filePath) {
1372
- // Note: This is a synchronous wrapper, but zenfs operations may still be async under the hood
1373
- // For true sync operations in browser, we'd need to use OPFS sync access handles
1374
- // For now, we'll use zenfs.readFileSync which should be available
1375
- const zenfs = this.getFsSync();
1376
- const file = zenfs.readFileSync(filePath);
1377
- return new File([new Uint8Array(file)], filePath);
1378
- }
1379
- async readFileAsBuffer(filePath) {
1380
- try {
1381
- // Get the file and read it as an ArrayBuffer
1382
- const file = await this.readFile(filePath);
1383
- const arrayBuffer = await file.arrayBuffer();
1384
- // Convert ArrayBuffer to Blob
1385
- return new Blob([arrayBuffer]);
1386
- }
1387
- catch (error) {
1388
- const errorMessage = error instanceof Error ? error.message : String(error);
1389
- console.error(`Error reading from OPFS: ${errorMessage}`);
1390
- throw error;
1391
- }
1392
- }
1393
- async readFileAsString(filePath) {
1394
- const blob = await this.readFileAsBuffer(filePath);
1395
- return blob.text();
1396
- }
1397
- getParentDirPath(filePath) {
1398
- return pathCompat.dirname(filePath);
1399
- }
1400
- getFilenameFromPath(filePath) {
1401
- return pathCompat.basename(filePath);
1402
- }
1403
- getPathModule() {
1404
- return pathCompat;
1405
- }
1406
- }
1407
- class CancelableInterval {
1408
- constructor(task, interval) {
1409
- this.task = task;
1410
- this.interval = interval;
1411
- this.intervalId = null;
1412
- this.currentTaskAbortController = null;
1413
- }
1414
- start() {
1415
- this.intervalId = window.setInterval(async () => {
1416
- if (this.currentTaskAbortController) {
1417
- // Cancel the previous running task
1418
- this.currentTaskAbortController.abort();
1419
- }
1420
- // Create a new abort controller for the current task
1421
- this.currentTaskAbortController = new AbortController();
1422
- const signal = this.currentTaskAbortController.signal;
1423
- try {
1424
- await this.taskWithCancellation(signal);
1425
- }
1426
- catch (error) {
1427
- if (error instanceof DOMException && error.name === 'AbortError') {
1428
- logger$3('Previous task was canceled.');
1429
- }
1430
- else {
1431
- console.error('Task error:', error);
1432
- }
1433
- this.stop();
1434
- }
1435
- }, this.interval);
1436
- }
1437
- async taskWithCancellation(signal) {
1438
- await this.task(() => this.stop());
1439
- if (signal.aborted) {
1440
- throw new DOMException('Task was aborted', 'AbortError');
1441
- }
1442
- }
1443
- stop() {
1444
- if (this.intervalId !== null) {
1445
- clearInterval(this.intervalId);
1446
- this.intervalId = null;
1447
- }
1448
- if (this.currentTaskAbortController) {
1449
- this.currentTaskAbortController.abort();
1450
- }
1451
- }
1452
- }
1453
- BaseFileManager.configure(new BrowserFileManager());
1454
-
1455
- // This file embeds the drizzle migration files as strings for browser runtime
1456
- // These files are copied from packages/sdk/src/db/drizzle at build time
1457
- // Individual migration SQL files
1458
- const migrationSql_0000_married_malice = `CREATE TABLE \`appState\` (
1459
- \`key\` text,
1460
- \`value\` text,
1461
- \`created_at\` integer,
1462
- \`updated_at\` integer
1463
- );
1464
- --> statement-breakpoint
1465
- CREATE UNIQUE INDEX \`appState_key_unique\` ON \`appState\` (\`key\`);--> statement-breakpoint
1466
- CREATE TABLE \`config\` (
1467
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1468
- \`key\` text NOT NULL,
1469
- \`text\` text,
1470
- \`json\` text,
1471
- \`blob\` blob
1472
- );
1473
- --> statement-breakpoint
1474
- CREATE TABLE \`metadata\` (
1475
- \`local_id\` text,
1476
- \`uid\` text,
1477
- \`property_name\` text,
1478
- \`property_value\` text,
1479
- \`schema_uid\` text,
1480
- \`model_type\` text,
1481
- \`seed_local_id\` text,
1482
- \`seed_uid\` text,
1483
- \`version_local_id\` text,
1484
- \`version_uid\` text,
1485
- \`eas_data_type\` text,
1486
- \`ref_value_type\` text,
1487
- \`ref_schema_uid\` text,
1488
- \`ref_seed_type\` text,
1489
- \`ref_resolved_value\` text,
1490
- \`ref_resolved_display_value\` text,
1491
- \`local_storage_dir\` text,
1492
- \`attestation_raw\` text,
1493
- \`attestation_created_at\` integer,
1494
- \`content_hash\` text,
1495
- \`created_at\` integer,
1496
- \`updated_at\` integer
1497
- );
1498
- --> statement-breakpoint
1499
- CREATE UNIQUE INDEX \`metadata_local_id_unique\` ON \`metadata\` (\`local_id\`);--> statement-breakpoint
1500
- CREATE TABLE \`models\` (
1501
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1502
- \`name\` text NOT NULL,
1503
- \`schema_file_id\` text
1504
- );
1505
- --> statement-breakpoint
1506
- CREATE TABLE \`properties\` (
1507
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1508
- \`name\` text NOT NULL,
1509
- \`data_type\` text NOT NULL,
1510
- \`model_id\` integer NOT NULL,
1511
- \`ref_model_id\` integer,
1512
- \`ref_value_type\` text,
1513
- \`schema_file_id\` text,
1514
- FOREIGN KEY (\`model_id\`) REFERENCES \`models\`(\`id\`) ON UPDATE no action ON DELETE no action,
1515
- FOREIGN KEY (\`ref_model_id\`) REFERENCES \`models\`(\`id\`) ON UPDATE no action ON DELETE no action
1516
- );
1517
- --> statement-breakpoint
1518
- CREATE UNIQUE INDEX \`unique_name_model_id\` ON \`properties\` (\`name\`,\`model_id\`);--> statement-breakpoint
1519
- CREATE TABLE \`model_schemas\` (
1520
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1521
- \`model_id\` integer,
1522
- \`schema_id\` integer,
1523
- FOREIGN KEY (\`model_id\`) REFERENCES \`models\`(\`id\`) ON UPDATE no action ON DELETE no action,
1524
- FOREIGN KEY (\`schema_id\`) REFERENCES \`schemas\`(\`id\`) ON UPDATE no action ON DELETE no action
1525
- );
1526
- --> statement-breakpoint
1527
- CREATE TABLE \`model_uids\` (
1528
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1529
- \`uid\` text NOT NULL,
1530
- \`model_id\` integer NOT NULL,
1531
- FOREIGN KEY (\`model_id\`) REFERENCES \`models\`(\`id\`) ON UPDATE no action ON DELETE no action
1532
- );
1533
- --> statement-breakpoint
1534
- CREATE UNIQUE INDEX \`model_uids_model_id_unique\` ON \`model_uids\` (\`model_id\`);--> statement-breakpoint
1535
- CREATE TABLE \`property_uids\` (
1536
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1537
- \`uid\` text NOT NULL,
1538
- \`property_id\` integer NOT NULL,
1539
- FOREIGN KEY (\`property_id\`) REFERENCES \`models\`(\`id\`) ON UPDATE no action ON DELETE no action
1540
- );
1541
- --> statement-breakpoint
1542
- CREATE UNIQUE INDEX \`property_uids_property_id_unique\` ON \`property_uids\` (\`property_id\`);--> statement-breakpoint
1543
- CREATE TABLE \`schemas\` (
1544
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1545
- \`name\` text NOT NULL,
1546
- \`version\` integer NOT NULL,
1547
- \`schema_file_id\` text,
1548
- \`created_at\` integer,
1549
- \`updated_at\` integer
1550
- );
1551
- --> statement-breakpoint
1552
- CREATE TABLE \`seeds\` (
1553
- \`local_id\` text,
1554
- \`uid\` text,
1555
- \`schema_uid\` text,
1556
- \`type\` text,
1557
- \`attestation_raw\` text,
1558
- \`attestation_created_at\` integer,
1559
- \`created_at\` integer,
1560
- \`updated_at\` integer,
1561
- \`_marked_for_deletion\` integer
1562
- );
1563
- --> statement-breakpoint
1564
- CREATE UNIQUE INDEX \`seeds_local_id_unique\` ON \`seeds\` (\`local_id\`);--> statement-breakpoint
1565
- CREATE TABLE \`versions\` (
1566
- \`local_id\` text,
1567
- \`uid\` text,
1568
- \`seed_local_id\` text,
1569
- \`seed_uid\` text,
1570
- \`seed_type\` text,
1571
- \`note\` text,
1572
- \`created_at\` integer,
1573
- \`updated_at\` integer,
1574
- \`attestation_created_at\` integer,
1575
- \`attestation_raw\` text
1576
- );
1577
- --> statement-breakpoint
1578
- CREATE UNIQUE INDEX \`versions_local_id_unique\` ON \`versions\` (\`local_id\`);`;
1579
- const migrationSql_0001_sweet_bruce_banner = `ALTER TABLE \`schemas\` ADD \`schema_data\` text;--> statement-breakpoint
1580
- ALTER TABLE \`schemas\` ADD \`is_draft\` integer;`;
1581
- const migrationSql_0002_bitter_proudstar = `CREATE UNIQUE INDEX \`unique_schema_file_id\` ON \`models\` (\`schema_file_id\`);--> statement-breakpoint
1582
- CREATE UNIQUE INDEX \`unique_property_schema_file_id\` ON \`properties\` (\`schema_file_id\`);--> statement-breakpoint
1583
- CREATE UNIQUE INDEX \`unique_schema_schema_file_id\` ON \`schemas\` (\`schema_file_id\`);`;
1584
- const migrationSql_0003_cultured_senator_kelly = `ALTER TABLE \`models\` ADD \`is_edited\` integer;--> statement-breakpoint
1585
- ALTER TABLE \`properties\` ADD \`is_edited\` integer;--> statement-breakpoint
1586
- ALTER TABLE \`schemas\` ADD \`is_edited\` integer;`;
1587
- const migrationSql_0004_add_publisher_to_seeds = `ALTER TABLE \`seeds\` ADD \`publisher\` text;`;
1588
- const migrationSql_0005_bright_lily_hollister = `CREATE TABLE \`publish_processes\` (
1589
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1590
- \`seed_local_id\` text NOT NULL,
1591
- \`model_name\` text NOT NULL,
1592
- \`schema_id\` text,
1593
- \`status\` text NOT NULL,
1594
- \`started_at\` integer NOT NULL,
1595
- \`completed_at\` integer,
1596
- \`error_message\` text,
1597
- \`error_step\` text,
1598
- \`error_details\` text,
1599
- \`persisted_snapshot\` text NOT NULL,
1600
- \`seed_id\` text,
1601
- \`existing_seed_uid\` text,
1602
- \`created_at\` integer,
1603
- \`updated_at\` integer
1604
- );
1605
- --> statement-breakpoint
1606
- CREATE TABLE \`upload_processes\` (
1607
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1608
- \`reimbursement_confirmed\` integer NOT NULL,
1609
- \`reimbursement_transaction_id\` text,
1610
- \`transaction_keys\` text,
1611
- \`persisted_snapshot\` text NOT NULL,
1612
- \`created_at\` integer,
1613
- \`updated_at\` integer
1614
- );
1615
- `;
1616
- const migrationSql_0006_add_publisher_to_versions_and_metadata = `ALTER TABLE \`versions\` ADD \`publisher\` text;
1617
- --> statement-breakpoint
1618
- ALTER TABLE \`metadata\` ADD \`publisher\` text;
1619
- `;
1620
- const migrationSql_0007_add_required_to_properties = `ALTER TABLE \`properties\` ADD \`required\` integer DEFAULT 0;
1621
- `;
1622
- const migrationSql_0008_add_revoked_at_to_seeds = `ALTER TABLE \`seeds\` ADD \`revoked_at\` integer;
1623
- `;
1624
- const migrationSql_0009_happy_namor = `PRAGMA foreign_keys=OFF;--> statement-breakpoint
1625
- CREATE TABLE \`__new_property_uids\` (
1626
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1627
- \`uid\` text NOT NULL,
1628
- \`property_id\` integer NOT NULL,
1629
- FOREIGN KEY (\`property_id\`) REFERENCES \`properties\`(\`id\`) ON UPDATE no action ON DELETE no action
1630
- );
1631
- --> statement-breakpoint
1632
- INSERT INTO \`__new_property_uids\`("id", "uid", "property_id") SELECT "id", "uid", "property_id" FROM \`property_uids\`;--> statement-breakpoint
1633
- DROP TABLE \`property_uids\`;--> statement-breakpoint
1634
- ALTER TABLE \`__new_property_uids\` RENAME TO \`property_uids\`;--> statement-breakpoint
1635
- PRAGMA foreign_keys=ON;--> statement-breakpoint
1636
- CREATE UNIQUE INDEX \`property_uids_property_id_unique\` ON \`property_uids\` (\`property_id\`);--> statement-breakpoint
1637
- ALTER TABLE \`metadata\` ADD \`property_id\` integer REFERENCES properties(id);`;
1638
- const migrationSql_0010_add_arweave_l1_finalize_jobs = `CREATE TABLE \`arweave_l1_finalize_jobs\` (
1639
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1640
- \`seed_local_id\` text NOT NULL,
1641
- \`data_item_id\` text NOT NULL,
1642
- \`l1_transaction_id\` text,
1643
- \`bundle_id\` text,
1644
- \`version_local_id\` text,
1645
- \`item_property_name\` text,
1646
- \`phase\` text NOT NULL,
1647
- \`status_json\` text,
1648
- \`error_message\` text,
1649
- \`created_at\` integer NOT NULL,
1650
- \`updated_at\` integer NOT NULL
1651
- );
1652
- --> statement-breakpoint
1653
- CREATE UNIQUE INDEX \`arweave_l1_finalize_jobs_data_item_id_unique\` ON \`arweave_l1_finalize_jobs\` (\`data_item_id\`);
1654
- `;
1655
- const migrationSql_0011_normalize_placeholder_uids = `UPDATE \`versions\` SET \`uid\` = NULL WHERE \`uid\` = 'NULL';
1656
- --> statement-breakpoint
1657
- UPDATE \`versions\` SET \`seed_uid\` = NULL WHERE \`seed_uid\` = 'NULL';
1658
- --> statement-breakpoint
1659
- UPDATE \`metadata\` SET \`uid\` = NULL WHERE \`uid\` = 'NULL';
1660
- --> statement-breakpoint
1661
- UPDATE \`metadata\` SET \`version_uid\` = NULL WHERE \`version_uid\` = 'NULL';
1662
- --> statement-breakpoint
1663
- UPDATE \`seeds\` SET \`uid\` = NULL WHERE \`uid\` = 'NULL';
1664
- `;
1665
- const migrationSql_0012_html_embedded_image_co_publish = `CREATE TABLE \`html_embedded_image_co_publish\` (
1666
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1667
- \`parent_seed_local_id\` text NOT NULL,
1668
- \`html_seed_local_id\` text NOT NULL,
1669
- \`image_seed_local_id\` text NOT NULL,
1670
- \`stable_key\` text NOT NULL,
1671
- \`created_at\` integer NOT NULL
1672
- );
1673
- --> statement-breakpoint
1674
- CREATE UNIQUE INDEX \`html_embed_co_pub_parent_html_stable\` ON \`html_embedded_image_co_publish\` (\`parent_seed_local_id\`,\`html_seed_local_id\`,\`stable_key\`);
1675
- `;
1676
- const migrationSql_0013_eas_sync_processes = `CREATE TABLE \`eas_sync_processes\` (
1677
- \`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
1678
- \`status\` text NOT NULL,
1679
- \`started_at\` integer NOT NULL,
1680
- \`completed_at\` integer,
1681
- \`request_payload\` text NOT NULL,
1682
- \`error_message\` text,
1683
- \`error_details\` text,
1684
- \`persisted_snapshot\` text NOT NULL,
1685
- \`created_at\` integer,
1686
- \`updated_at\` integer
1687
- );
1688
- `;
1689
- const migrationSql_0014_add_error_code_to_publish_processes = `ALTER TABLE \`publish_processes\` ADD \`error_code\` text;
1690
- `;
1691
- // Journal JSON file
1692
- const journalJson = `{
1693
- "version": "7",
1694
- "dialect": "sqlite",
1695
- "entries": [
1696
- {
1697
- "idx": 0,
1698
- "version": "6",
1699
- "when": 1765976502903,
1700
- "tag": "0000_married_malice",
1701
- "breakpoints": true
1702
- },
1703
- {
1704
- "idx": 1,
1705
- "version": "6",
1706
- "when": 1766010851770,
1707
- "tag": "0001_sweet_bruce_banner",
1708
- "breakpoints": true
1709
- },
1710
- {
1711
- "idx": 2,
1712
- "version": "6",
1713
- "when": 1767621120087,
1714
- "tag": "0002_bitter_proudstar",
1715
- "breakpoints": true
1716
- },
1717
- {
1718
- "idx": 3,
1719
- "version": "6",
1720
- "when": 1768415440282,
1721
- "tag": "0003_cultured_senator_kelly",
1722
- "breakpoints": true
1723
- },
1724
- {
1725
- "idx": 4,
1726
- "version": "6",
1727
- "when": 1768500000000,
1728
- "tag": "0004_add_publisher_to_seeds",
1729
- "breakpoints": true
1730
- },
1731
- {
1732
- "idx": 5,
1733
- "version": "6",
1734
- "when": 1772489937031,
1735
- "tag": "0005_bright_lily_hollister",
1736
- "breakpoints": true
1737
- },
1738
- {
1739
- "idx": 6,
1740
- "version": "6",
1741
- "when": 1772600000000,
1742
- "tag": "0006_add_publisher_to_versions_and_metadata",
1743
- "breakpoints": true
1744
- },
1745
- {
1746
- "idx": 7,
1747
- "version": "6",
1748
- "when": 1772700000000,
1749
- "tag": "0007_add_required_to_properties",
1750
- "breakpoints": true
1751
- },
1752
- {
1753
- "idx": 8,
1754
- "version": "6",
1755
- "when": 1772800000000,
1756
- "tag": "0008_add_revoked_at_to_seeds",
1757
- "breakpoints": true
1758
- },
1759
- {
1760
- "idx": 9,
1761
- "version": "6",
1762
- "when": 1773924021107,
1763
- "tag": "0009_happy_namor",
1764
- "breakpoints": true
1765
- },
1766
- {
1767
- "idx": 10,
1768
- "version": "6",
1769
- "when": 1774000000000,
1770
- "tag": "0010_add_arweave_l1_finalize_jobs",
1771
- "breakpoints": true
1772
- },
1773
- {
1774
- "idx": 11,
1775
- "version": "6",
1776
- "when": 1774100000000,
1777
- "tag": "0011_normalize_placeholder_uids",
1778
- "breakpoints": true
1779
- },
1780
- {
1781
- "idx": 12,
1782
- "version": "6",
1783
- "when": 1774200000000,
1784
- "tag": "0012_html_embedded_image_co_publish",
1785
- "breakpoints": true
1786
- },
1787
- {
1788
- "idx": 13,
1789
- "version": "6",
1790
- "when": 1774300000000,
1791
- "tag": "0013_eas_sync_processes",
1792
- "breakpoints": true
1793
- },
1794
- {
1795
- "idx": 14,
1796
- "version": "6",
1797
- "when": 1774400000000,
1798
- "tag": "0014_add_error_code_to_publish_processes",
1799
- "breakpoints": true
1800
- }
1801
- ]
1802
- }`;
1803
- // Snapshot JSON file - this is large, so we'll import it dynamically if needed
1804
- // For now, we'll read it from the actual file if ?raw works, otherwise we'll need to embed it
1805
- const snapshotJson = `{
1806
- "version": "6",
1807
- "dialect": "sqlite",
1808
- "id": "14e73eef-092a-4310-a86f-2f815470bdce",
1809
- "prevId": "a9e8f7d6-c5b4-4321-a0b9-c8d7e6f5a4b3",
1810
- "tables": {
1811
- "appState": {
1812
- "name": "appState",
1813
- "columns": {
1814
- "key": {
1815
- "name": "key",
1816
- "type": "text",
1817
- "primaryKey": false,
1818
- "notNull": false,
1819
- "autoincrement": false
1820
- },
1821
- "value": {
1822
- "name": "value",
1823
- "type": "text",
1824
- "primaryKey": false,
1825
- "notNull": false,
1826
- "autoincrement": false
1827
- },
1828
- "created_at": {
1829
- "name": "created_at",
1830
- "type": "integer",
1831
- "primaryKey": false,
1832
- "notNull": false,
1833
- "autoincrement": false
1834
- },
1835
- "updated_at": {
1836
- "name": "updated_at",
1837
- "type": "integer",
1838
- "primaryKey": false,
1839
- "notNull": false,
1840
- "autoincrement": false
1841
- }
1842
- },
1843
- "indexes": {
1844
- "appState_key_unique": {
1845
- "name": "appState_key_unique",
1846
- "columns": [
1847
- "key"
1848
- ],
1849
- "isUnique": true
1850
- }
1851
- },
1852
- "foreignKeys": {},
1853
- "compositePrimaryKeys": {},
1854
- "uniqueConstraints": {},
1855
- "checkConstraints": {}
1856
- },
1857
- "config": {
1858
- "name": "config",
1859
- "columns": {
1860
- "id": {
1861
- "name": "id",
1862
- "type": "integer",
1863
- "primaryKey": true,
1864
- "notNull": true,
1865
- "autoincrement": true
1866
- },
1867
- "key": {
1868
- "name": "key",
1869
- "type": "text",
1870
- "primaryKey": false,
1871
- "notNull": true,
1872
- "autoincrement": false
1873
- },
1874
- "text": {
1875
- "name": "text",
1876
- "type": "text",
1877
- "primaryKey": false,
1878
- "notNull": false,
1879
- "autoincrement": false
1880
- },
1881
- "json": {
1882
- "name": "json",
1883
- "type": "text",
1884
- "primaryKey": false,
1885
- "notNull": false,
1886
- "autoincrement": false
1887
- },
1888
- "blob": {
1889
- "name": "blob",
1890
- "type": "blob",
1891
- "primaryKey": false,
1892
- "notNull": false,
1893
- "autoincrement": false
1894
- }
1895
- },
1896
- "indexes": {},
1897
- "foreignKeys": {},
1898
- "compositePrimaryKeys": {},
1899
- "uniqueConstraints": {},
1900
- "checkConstraints": {}
1901
- },
1902
- "metadata": {
1903
- "name": "metadata",
1904
- "columns": {
1905
- "local_id": {
1906
- "name": "local_id",
1907
- "type": "text",
1908
- "primaryKey": false,
1909
- "notNull": false,
1910
- "autoincrement": false
1911
- },
1912
- "uid": {
1913
- "name": "uid",
1914
- "type": "text",
1915
- "primaryKey": false,
1916
- "notNull": false,
1917
- "autoincrement": false
1918
- },
1919
- "property_id": {
1920
- "name": "property_id",
1921
- "type": "integer",
1922
- "primaryKey": false,
1923
- "notNull": false,
1924
- "autoincrement": false
1925
- },
1926
- "property_name": {
1927
- "name": "property_name",
1928
- "type": "text",
1929
- "primaryKey": false,
1930
- "notNull": false,
1931
- "autoincrement": false
1932
- },
1933
- "property_value": {
1934
- "name": "property_value",
1935
- "type": "text",
1936
- "primaryKey": false,
1937
- "notNull": false,
1938
- "autoincrement": false
1939
- },
1940
- "schema_uid": {
1941
- "name": "schema_uid",
1942
- "type": "text",
1943
- "primaryKey": false,
1944
- "notNull": false,
1945
- "autoincrement": false
1946
- },
1947
- "model_type": {
1948
- "name": "model_type",
1949
- "type": "text",
1950
- "primaryKey": false,
1951
- "notNull": false,
1952
- "autoincrement": false
1953
- },
1954
- "seed_local_id": {
1955
- "name": "seed_local_id",
1956
- "type": "text",
1957
- "primaryKey": false,
1958
- "notNull": false,
1959
- "autoincrement": false
1960
- },
1961
- "seed_uid": {
1962
- "name": "seed_uid",
1963
- "type": "text",
1964
- "primaryKey": false,
1965
- "notNull": false,
1966
- "autoincrement": false
1967
- },
1968
- "version_local_id": {
1969
- "name": "version_local_id",
1970
- "type": "text",
1971
- "primaryKey": false,
1972
- "notNull": false,
1973
- "autoincrement": false
1974
- },
1975
- "version_uid": {
1976
- "name": "version_uid",
1977
- "type": "text",
1978
- "primaryKey": false,
1979
- "notNull": false,
1980
- "autoincrement": false
1981
- },
1982
- "eas_data_type": {
1983
- "name": "eas_data_type",
1984
- "type": "text",
1985
- "primaryKey": false,
1986
- "notNull": false,
1987
- "autoincrement": false
1988
- },
1989
- "ref_value_type": {
1990
- "name": "ref_value_type",
1991
- "type": "text",
1992
- "primaryKey": false,
1993
- "notNull": false,
1994
- "autoincrement": false
1995
- },
1996
- "ref_schema_uid": {
1997
- "name": "ref_schema_uid",
1998
- "type": "text",
1999
- "primaryKey": false,
2000
- "notNull": false,
2001
- "autoincrement": false
2002
- },
2003
- "ref_seed_type": {
2004
- "name": "ref_seed_type",
2005
- "type": "text",
2006
- "primaryKey": false,
2007
- "notNull": false,
2008
- "autoincrement": false
2009
- },
2010
- "ref_resolved_value": {
2011
- "name": "ref_resolved_value",
2012
- "type": "text",
2013
- "primaryKey": false,
2014
- "notNull": false,
2015
- "autoincrement": false
2016
- },
2017
- "ref_resolved_display_value": {
2018
- "name": "ref_resolved_display_value",
2019
- "type": "text",
2020
- "primaryKey": false,
2021
- "notNull": false,
2022
- "autoincrement": false
2023
- },
2024
- "local_storage_dir": {
2025
- "name": "local_storage_dir",
2026
- "type": "text",
2027
- "primaryKey": false,
2028
- "notNull": false,
2029
- "autoincrement": false
2030
- },
2031
- "attestation_raw": {
2032
- "name": "attestation_raw",
2033
- "type": "text",
2034
- "primaryKey": false,
2035
- "notNull": false,
2036
- "autoincrement": false
2037
- },
2038
- "attestation_created_at": {
2039
- "name": "attestation_created_at",
2040
- "type": "integer",
2041
- "primaryKey": false,
2042
- "notNull": false,
2043
- "autoincrement": false
2044
- },
2045
- "content_hash": {
2046
- "name": "content_hash",
2047
- "type": "text",
2048
- "primaryKey": false,
2049
- "notNull": false,
2050
- "autoincrement": false
2051
- },
2052
- "created_at": {
2053
- "name": "created_at",
2054
- "type": "integer",
2055
- "primaryKey": false,
2056
- "notNull": false,
2057
- "autoincrement": false
2058
- },
2059
- "updated_at": {
2060
- "name": "updated_at",
2061
- "type": "integer",
2062
- "primaryKey": false,
2063
- "notNull": false,
2064
- "autoincrement": false
2065
- },
2066
- "publisher": {
2067
- "name": "publisher",
2068
- "type": "text",
2069
- "primaryKey": false,
2070
- "notNull": false,
2071
- "autoincrement": false
2072
- }
2073
- },
2074
- "indexes": {
2075
- "metadata_local_id_unique": {
2076
- "name": "metadata_local_id_unique",
2077
- "columns": [
2078
- "local_id"
2079
- ],
2080
- "isUnique": true
2081
- }
2082
- },
2083
- "foreignKeys": {
2084
- "metadata_property_id_properties_id_fk": {
2085
- "name": "metadata_property_id_properties_id_fk",
2086
- "tableFrom": "metadata",
2087
- "tableTo": "properties",
2088
- "columnsFrom": [
2089
- "property_id"
2090
- ],
2091
- "columnsTo": [
2092
- "id"
2093
- ],
2094
- "onDelete": "no action",
2095
- "onUpdate": "no action"
2096
- }
2097
- },
2098
- "compositePrimaryKeys": {},
2099
- "uniqueConstraints": {},
2100
- "checkConstraints": {}
2101
- },
2102
- "models": {
2103
- "name": "models",
2104
- "columns": {
2105
- "id": {
2106
- "name": "id",
2107
- "type": "integer",
2108
- "primaryKey": true,
2109
- "notNull": true,
2110
- "autoincrement": true
2111
- },
2112
- "name": {
2113
- "name": "name",
2114
- "type": "text",
2115
- "primaryKey": false,
2116
- "notNull": true,
2117
- "autoincrement": false
2118
- },
2119
- "schema_file_id": {
2120
- "name": "schema_file_id",
2121
- "type": "text",
2122
- "primaryKey": false,
2123
- "notNull": false,
2124
- "autoincrement": false
2125
- },
2126
- "is_edited": {
2127
- "name": "is_edited",
2128
- "type": "integer",
2129
- "primaryKey": false,
2130
- "notNull": false,
2131
- "autoincrement": false
2132
- }
2133
- },
2134
- "indexes": {
2135
- "unique_schema_file_id": {
2136
- "name": "unique_schema_file_id",
2137
- "columns": [
2138
- "schema_file_id"
2139
- ],
2140
- "isUnique": true
2141
- }
2142
- },
2143
- "foreignKeys": {},
2144
- "compositePrimaryKeys": {},
2145
- "uniqueConstraints": {},
2146
- "checkConstraints": {}
2147
- },
2148
- "properties": {
2149
- "name": "properties",
2150
- "columns": {
2151
- "id": {
2152
- "name": "id",
2153
- "type": "integer",
2154
- "primaryKey": true,
2155
- "notNull": true,
2156
- "autoincrement": true
2157
- },
2158
- "name": {
2159
- "name": "name",
2160
- "type": "text",
2161
- "primaryKey": false,
2162
- "notNull": true,
2163
- "autoincrement": false
2164
- },
2165
- "data_type": {
2166
- "name": "data_type",
2167
- "type": "text",
2168
- "primaryKey": false,
2169
- "notNull": true,
2170
- "autoincrement": false
2171
- },
2172
- "model_id": {
2173
- "name": "model_id",
2174
- "type": "integer",
2175
- "primaryKey": false,
2176
- "notNull": true,
2177
- "autoincrement": false
2178
- },
2179
- "ref_model_id": {
2180
- "name": "ref_model_id",
2181
- "type": "integer",
2182
- "primaryKey": false,
2183
- "notNull": false,
2184
- "autoincrement": false
2185
- },
2186
- "ref_value_type": {
2187
- "name": "ref_value_type",
2188
- "type": "text",
2189
- "primaryKey": false,
2190
- "notNull": false,
2191
- "autoincrement": false
2192
- },
2193
- "schema_file_id": {
2194
- "name": "schema_file_id",
2195
- "type": "text",
2196
- "primaryKey": false,
2197
- "notNull": false,
2198
- "autoincrement": false
2199
- },
2200
- "is_edited": {
2201
- "name": "is_edited",
2202
- "type": "integer",
2203
- "primaryKey": false,
2204
- "notNull": false,
2205
- "autoincrement": false
2206
- },
2207
- "required": {
2208
- "name": "required",
2209
- "type": "integer",
2210
- "primaryKey": false,
2211
- "notNull": false,
2212
- "autoincrement": false
2213
- }
2214
- },
2215
- "indexes": {
2216
- "unique_name_model_id": {
2217
- "name": "unique_name_model_id",
2218
- "columns": [
2219
- "name",
2220
- "model_id"
2221
- ],
2222
- "isUnique": true
2223
- },
2224
- "unique_property_schema_file_id": {
2225
- "name": "unique_property_schema_file_id",
2226
- "columns": [
2227
- "schema_file_id"
2228
- ],
2229
- "isUnique": true
2230
- }
2231
- },
2232
- "foreignKeys": {
2233
- "properties_model_id_models_id_fk": {
2234
- "name": "properties_model_id_models_id_fk",
2235
- "tableFrom": "properties",
2236
- "tableTo": "models",
2237
- "columnsFrom": [
2238
- "model_id"
2239
- ],
2240
- "columnsTo": [
2241
- "id"
2242
- ],
2243
- "onDelete": "no action",
2244
- "onUpdate": "no action"
2245
- },
2246
- "properties_ref_model_id_models_id_fk": {
2247
- "name": "properties_ref_model_id_models_id_fk",
2248
- "tableFrom": "properties",
2249
- "tableTo": "models",
2250
- "columnsFrom": [
2251
- "ref_model_id"
2252
- ],
2253
- "columnsTo": [
2254
- "id"
2255
- ],
2256
- "onDelete": "no action",
2257
- "onUpdate": "no action"
2258
- }
2259
- },
2260
- "compositePrimaryKeys": {},
2261
- "uniqueConstraints": {},
2262
- "checkConstraints": {}
2263
- },
2264
- "model_schemas": {
2265
- "name": "model_schemas",
2266
- "columns": {
2267
- "id": {
2268
- "name": "id",
2269
- "type": "integer",
2270
- "primaryKey": true,
2271
- "notNull": true,
2272
- "autoincrement": true
2273
- },
2274
- "model_id": {
2275
- "name": "model_id",
2276
- "type": "integer",
2277
- "primaryKey": false,
2278
- "notNull": false,
2279
- "autoincrement": false
2280
- },
2281
- "schema_id": {
2282
- "name": "schema_id",
2283
- "type": "integer",
2284
- "primaryKey": false,
2285
- "notNull": false,
2286
- "autoincrement": false
2287
- }
2288
- },
2289
- "indexes": {},
2290
- "foreignKeys": {
2291
- "model_schemas_model_id_models_id_fk": {
2292
- "name": "model_schemas_model_id_models_id_fk",
2293
- "tableFrom": "model_schemas",
2294
- "tableTo": "models",
2295
- "columnsFrom": [
2296
- "model_id"
2297
- ],
2298
- "columnsTo": [
2299
- "id"
2300
- ],
2301
- "onDelete": "no action",
2302
- "onUpdate": "no action"
2303
- },
2304
- "model_schemas_schema_id_schemas_id_fk": {
2305
- "name": "model_schemas_schema_id_schemas_id_fk",
2306
- "tableFrom": "model_schemas",
2307
- "tableTo": "schemas",
2308
- "columnsFrom": [
2309
- "schema_id"
2310
- ],
2311
- "columnsTo": [
2312
- "id"
2313
- ],
2314
- "onDelete": "no action",
2315
- "onUpdate": "no action"
2316
- }
2317
- },
2318
- "compositePrimaryKeys": {},
2319
- "uniqueConstraints": {},
2320
- "checkConstraints": {}
2321
- },
2322
- "model_uids": {
2323
- "name": "model_uids",
2324
- "columns": {
2325
- "id": {
2326
- "name": "id",
2327
- "type": "integer",
2328
- "primaryKey": true,
2329
- "notNull": true,
2330
- "autoincrement": true
2331
- },
2332
- "uid": {
2333
- "name": "uid",
2334
- "type": "text",
2335
- "primaryKey": false,
2336
- "notNull": true,
2337
- "autoincrement": false
2338
- },
2339
- "model_id": {
2340
- "name": "model_id",
2341
- "type": "integer",
2342
- "primaryKey": false,
2343
- "notNull": true,
2344
- "autoincrement": false
2345
- }
2346
- },
2347
- "indexes": {
2348
- "model_uids_model_id_unique": {
2349
- "name": "model_uids_model_id_unique",
2350
- "columns": [
2351
- "model_id"
2352
- ],
2353
- "isUnique": true
2354
- }
2355
- },
2356
- "foreignKeys": {
2357
- "model_uids_model_id_models_id_fk": {
2358
- "name": "model_uids_model_id_models_id_fk",
2359
- "tableFrom": "model_uids",
2360
- "tableTo": "models",
2361
- "columnsFrom": [
2362
- "model_id"
2363
- ],
2364
- "columnsTo": [
2365
- "id"
2366
- ],
2367
- "onDelete": "no action",
2368
- "onUpdate": "no action"
2369
- }
2370
- },
2371
- "compositePrimaryKeys": {},
2372
- "uniqueConstraints": {},
2373
- "checkConstraints": {}
2374
- },
2375
- "property_uids": {
2376
- "name": "property_uids",
2377
- "columns": {
2378
- "id": {
2379
- "name": "id",
2380
- "type": "integer",
2381
- "primaryKey": true,
2382
- "notNull": true,
2383
- "autoincrement": true
2384
- },
2385
- "uid": {
2386
- "name": "uid",
2387
- "type": "text",
2388
- "primaryKey": false,
2389
- "notNull": true,
2390
- "autoincrement": false
2391
- },
2392
- "property_id": {
2393
- "name": "property_id",
2394
- "type": "integer",
2395
- "primaryKey": false,
2396
- "notNull": true,
2397
- "autoincrement": false
2398
- }
2399
- },
2400
- "indexes": {
2401
- "property_uids_property_id_unique": {
2402
- "name": "property_uids_property_id_unique",
2403
- "columns": [
2404
- "property_id"
2405
- ],
2406
- "isUnique": true
2407
- }
2408
- },
2409
- "foreignKeys": {
2410
- "property_uids_property_id_properties_id_fk": {
2411
- "name": "property_uids_property_id_properties_id_fk",
2412
- "tableFrom": "property_uids",
2413
- "tableTo": "properties",
2414
- "columnsFrom": [
2415
- "property_id"
2416
- ],
2417
- "columnsTo": [
2418
- "id"
2419
- ],
2420
- "onDelete": "no action",
2421
- "onUpdate": "no action"
2422
- }
2423
- },
2424
- "compositePrimaryKeys": {},
2425
- "uniqueConstraints": {},
2426
- "checkConstraints": {}
2427
- },
2428
- "publish_processes": {
2429
- "name": "publish_processes",
2430
- "columns": {
2431
- "id": {
2432
- "name": "id",
2433
- "type": "integer",
2434
- "primaryKey": true,
2435
- "notNull": true,
2436
- "autoincrement": true
2437
- },
2438
- "seed_local_id": {
2439
- "name": "seed_local_id",
2440
- "type": "text",
2441
- "primaryKey": false,
2442
- "notNull": true,
2443
- "autoincrement": false
2444
- },
2445
- "model_name": {
2446
- "name": "model_name",
2447
- "type": "text",
2448
- "primaryKey": false,
2449
- "notNull": true,
2450
- "autoincrement": false
2451
- },
2452
- "schema_id": {
2453
- "name": "schema_id",
2454
- "type": "text",
2455
- "primaryKey": false,
2456
- "notNull": false,
2457
- "autoincrement": false
2458
- },
2459
- "status": {
2460
- "name": "status",
2461
- "type": "text",
2462
- "primaryKey": false,
2463
- "notNull": true,
2464
- "autoincrement": false
2465
- },
2466
- "started_at": {
2467
- "name": "started_at",
2468
- "type": "integer",
2469
- "primaryKey": false,
2470
- "notNull": true,
2471
- "autoincrement": false
2472
- },
2473
- "completed_at": {
2474
- "name": "completed_at",
2475
- "type": "integer",
2476
- "primaryKey": false,
2477
- "notNull": false,
2478
- "autoincrement": false
2479
- },
2480
- "error_message": {
2481
- "name": "error_message",
2482
- "type": "text",
2483
- "primaryKey": false,
2484
- "notNull": false,
2485
- "autoincrement": false
2486
- },
2487
- "error_step": {
2488
- "name": "error_step",
2489
- "type": "text",
2490
- "primaryKey": false,
2491
- "notNull": false,
2492
- "autoincrement": false
2493
- },
2494
- "error_details": {
2495
- "name": "error_details",
2496
- "type": "text",
2497
- "primaryKey": false,
2498
- "notNull": false,
2499
- "autoincrement": false
2500
- },
2501
- "error_code": {
2502
- "name": "error_code",
2503
- "type": "text",
2504
- "primaryKey": false,
2505
- "notNull": false,
2506
- "autoincrement": false
2507
- },
2508
- "persisted_snapshot": {
2509
- "name": "persisted_snapshot",
2510
- "type": "text",
2511
- "primaryKey": false,
2512
- "notNull": true,
2513
- "autoincrement": false
2514
- },
2515
- "seed_id": {
2516
- "name": "seed_id",
2517
- "type": "text",
2518
- "primaryKey": false,
2519
- "notNull": false,
2520
- "autoincrement": false
2521
- },
2522
- "existing_seed_uid": {
2523
- "name": "existing_seed_uid",
2524
- "type": "text",
2525
- "primaryKey": false,
2526
- "notNull": false,
2527
- "autoincrement": false
2528
- },
2529
- "created_at": {
2530
- "name": "created_at",
2531
- "type": "integer",
2532
- "primaryKey": false,
2533
- "notNull": false,
2534
- "autoincrement": false
2535
- },
2536
- "updated_at": {
2537
- "name": "updated_at",
2538
- "type": "integer",
2539
- "primaryKey": false,
2540
- "notNull": false,
2541
- "autoincrement": false
2542
- }
2543
- },
2544
- "indexes": {},
2545
- "foreignKeys": {},
2546
- "compositePrimaryKeys": {},
2547
- "uniqueConstraints": {},
2548
- "checkConstraints": {}
2549
- },
2550
- "schemas": {
2551
- "name": "schemas",
2552
- "columns": {
2553
- "id": {
2554
- "name": "id",
2555
- "type": "integer",
2556
- "primaryKey": true,
2557
- "notNull": true,
2558
- "autoincrement": true
2559
- },
2560
- "name": {
2561
- "name": "name",
2562
- "type": "text",
2563
- "primaryKey": false,
2564
- "notNull": true,
2565
- "autoincrement": false
2566
- },
2567
- "version": {
2568
- "name": "version",
2569
- "type": "integer",
2570
- "primaryKey": false,
2571
- "notNull": true,
2572
- "autoincrement": false
2573
- },
2574
- "schema_file_id": {
2575
- "name": "schema_file_id",
2576
- "type": "text",
2577
- "primaryKey": false,
2578
- "notNull": false,
2579
- "autoincrement": false
2580
- },
2581
- "schema_data": {
2582
- "name": "schema_data",
2583
- "type": "text",
2584
- "primaryKey": false,
2585
- "notNull": false,
2586
- "autoincrement": false
2587
- },
2588
- "is_draft": {
2589
- "name": "is_draft",
2590
- "type": "integer",
2591
- "primaryKey": false,
2592
- "notNull": false,
2593
- "autoincrement": false
2594
- },
2595
- "is_edited": {
2596
- "name": "is_edited",
2597
- "type": "integer",
2598
- "primaryKey": false,
2599
- "notNull": false,
2600
- "autoincrement": false
2601
- },
2602
- "created_at": {
2603
- "name": "created_at",
2604
- "type": "integer",
2605
- "primaryKey": false,
2606
- "notNull": false,
2607
- "autoincrement": false
2608
- },
2609
- "updated_at": {
2610
- "name": "updated_at",
2611
- "type": "integer",
2612
- "primaryKey": false,
2613
- "notNull": false,
2614
- "autoincrement": false
2615
- }
2616
- },
2617
- "indexes": {
2618
- "unique_schema_schema_file_id": {
2619
- "name": "unique_schema_schema_file_id",
2620
- "columns": [
2621
- "schema_file_id"
2622
- ],
2623
- "isUnique": true
2624
- }
2625
- },
2626
- "foreignKeys": {},
2627
- "compositePrimaryKeys": {},
2628
- "uniqueConstraints": {},
2629
- "checkConstraints": {}
2630
- },
2631
- "seeds": {
2632
- "name": "seeds",
2633
- "columns": {
2634
- "local_id": {
2635
- "name": "local_id",
2636
- "type": "text",
2637
- "primaryKey": false,
2638
- "notNull": false,
2639
- "autoincrement": false
2640
- },
2641
- "uid": {
2642
- "name": "uid",
2643
- "type": "text",
2644
- "primaryKey": false,
2645
- "notNull": false,
2646
- "autoincrement": false
2647
- },
2648
- "schema_uid": {
2649
- "name": "schema_uid",
2650
- "type": "text",
2651
- "primaryKey": false,
2652
- "notNull": false,
2653
- "autoincrement": false
2654
- },
2655
- "type": {
2656
- "name": "type",
2657
- "type": "text",
2658
- "primaryKey": false,
2659
- "notNull": false,
2660
- "autoincrement": false
2661
- },
2662
- "publisher": {
2663
- "name": "publisher",
2664
- "type": "text",
2665
- "primaryKey": false,
2666
- "notNull": false,
2667
- "autoincrement": false
2668
- },
2669
- "attestation_raw": {
2670
- "name": "attestation_raw",
2671
- "type": "text",
2672
- "primaryKey": false,
2673
- "notNull": false,
2674
- "autoincrement": false
2675
- },
2676
- "attestation_created_at": {
2677
- "name": "attestation_created_at",
2678
- "type": "integer",
2679
- "primaryKey": false,
2680
- "notNull": false,
2681
- "autoincrement": false
2682
- },
2683
- "created_at": {
2684
- "name": "created_at",
2685
- "type": "integer",
2686
- "primaryKey": false,
2687
- "notNull": false,
2688
- "autoincrement": false
2689
- },
2690
- "updated_at": {
2691
- "name": "updated_at",
2692
- "type": "integer",
2693
- "primaryKey": false,
2694
- "notNull": false,
2695
- "autoincrement": false
2696
- },
2697
- "_marked_for_deletion": {
2698
- "name": "_marked_for_deletion",
2699
- "type": "integer",
2700
- "primaryKey": false,
2701
- "notNull": false,
2702
- "autoincrement": false
2703
- },
2704
- "revoked_at": {
2705
- "name": "revoked_at",
2706
- "type": "integer",
2707
- "primaryKey": false,
2708
- "notNull": false,
2709
- "autoincrement": false
2710
- }
2711
- },
2712
- "indexes": {
2713
- "seeds_local_id_unique": {
2714
- "name": "seeds_local_id_unique",
2715
- "columns": [
2716
- "local_id"
2717
- ],
2718
- "isUnique": true
2719
- }
2720
- },
2721
- "foreignKeys": {},
2722
- "compositePrimaryKeys": {},
2723
- "uniqueConstraints": {},
2724
- "checkConstraints": {}
2725
- },
2726
- "upload_processes": {
2727
- "name": "upload_processes",
2728
- "columns": {
2729
- "id": {
2730
- "name": "id",
2731
- "type": "integer",
2732
- "primaryKey": true,
2733
- "notNull": true,
2734
- "autoincrement": true
2735
- },
2736
- "reimbursement_confirmed": {
2737
- "name": "reimbursement_confirmed",
2738
- "type": "integer",
2739
- "primaryKey": false,
2740
- "notNull": true,
2741
- "autoincrement": false
2742
- },
2743
- "reimbursement_transaction_id": {
2744
- "name": "reimbursement_transaction_id",
2745
- "type": "text",
2746
- "primaryKey": false,
2747
- "notNull": false,
2748
- "autoincrement": false
2749
- },
2750
- "transaction_keys": {
2751
- "name": "transaction_keys",
2752
- "type": "text",
2753
- "primaryKey": false,
2754
- "notNull": false,
2755
- "autoincrement": false
2756
- },
2757
- "persisted_snapshot": {
2758
- "name": "persisted_snapshot",
2759
- "type": "text",
2760
- "primaryKey": false,
2761
- "notNull": true,
2762
- "autoincrement": false
2763
- },
2764
- "created_at": {
2765
- "name": "created_at",
2766
- "type": "integer",
2767
- "primaryKey": false,
2768
- "notNull": false,
2769
- "autoincrement": false
2770
- },
2771
- "updated_at": {
2772
- "name": "updated_at",
2773
- "type": "integer",
2774
- "primaryKey": false,
2775
- "notNull": false,
2776
- "autoincrement": false
2777
- }
2778
- },
2779
- "indexes": {},
2780
- "foreignKeys": {},
2781
- "compositePrimaryKeys": {},
2782
- "uniqueConstraints": {},
2783
- "checkConstraints": {}
2784
- },
2785
- "versions": {
2786
- "name": "versions",
2787
- "columns": {
2788
- "local_id": {
2789
- "name": "local_id",
2790
- "type": "text",
2791
- "primaryKey": false,
2792
- "notNull": false,
2793
- "autoincrement": false
2794
- },
2795
- "uid": {
2796
- "name": "uid",
2797
- "type": "text",
2798
- "primaryKey": false,
2799
- "notNull": false,
2800
- "autoincrement": false
2801
- },
2802
- "seed_local_id": {
2803
- "name": "seed_local_id",
2804
- "type": "text",
2805
- "primaryKey": false,
2806
- "notNull": false,
2807
- "autoincrement": false
2808
- },
2809
- "seed_uid": {
2810
- "name": "seed_uid",
2811
- "type": "text",
2812
- "primaryKey": false,
2813
- "notNull": false,
2814
- "autoincrement": false
2815
- },
2816
- "seed_type": {
2817
- "name": "seed_type",
2818
- "type": "text",
2819
- "primaryKey": false,
2820
- "notNull": false,
2821
- "autoincrement": false
2822
- },
2823
- "note": {
2824
- "name": "note",
2825
- "type": "text",
2826
- "primaryKey": false,
2827
- "notNull": false,
2828
- "autoincrement": false
2829
- },
2830
- "created_at": {
2831
- "name": "created_at",
2832
- "type": "integer",
2833
- "primaryKey": false,
2834
- "notNull": false,
2835
- "autoincrement": false
2836
- },
2837
- "updated_at": {
2838
- "name": "updated_at",
2839
- "type": "integer",
2840
- "primaryKey": false,
2841
- "notNull": false,
2842
- "autoincrement": false
2843
- },
2844
- "attestation_created_at": {
2845
- "name": "attestation_created_at",
2846
- "type": "integer",
2847
- "primaryKey": false,
2848
- "notNull": false,
2849
- "autoincrement": false
2850
- },
2851
- "attestation_raw": {
2852
- "name": "attestation_raw",
2853
- "type": "text",
2854
- "primaryKey": false,
2855
- "notNull": false,
2856
- "autoincrement": false
2857
- },
2858
- "publisher": {
2859
- "name": "publisher",
2860
- "type": "text",
2861
- "primaryKey": false,
2862
- "notNull": false,
2863
- "autoincrement": false
2864
- }
2865
- },
2866
- "indexes": {
2867
- "versions_local_id_unique": {
2868
- "name": "versions_local_id_unique",
2869
- "columns": [
2870
- "local_id"
2871
- ],
2872
- "isUnique": true
2873
- }
2874
- },
2875
- "foreignKeys": {},
2876
- "compositePrimaryKeys": {},
2877
- "uniqueConstraints": {},
2878
- "checkConstraints": {}
2879
- },
2880
- "arweave_l1_finalize_jobs": {
2881
- "name": "arweave_l1_finalize_jobs",
2882
- "columns": {
2883
- "id": {
2884
- "name": "id",
2885
- "type": "integer",
2886
- "primaryKey": true,
2887
- "notNull": true,
2888
- "autoincrement": true
2889
- },
2890
- "seed_local_id": {
2891
- "name": "seed_local_id",
2892
- "type": "text",
2893
- "primaryKey": false,
2894
- "notNull": true,
2895
- "autoincrement": false
2896
- },
2897
- "data_item_id": {
2898
- "name": "data_item_id",
2899
- "type": "text",
2900
- "primaryKey": false,
2901
- "notNull": true,
2902
- "autoincrement": false
2903
- },
2904
- "l1_transaction_id": {
2905
- "name": "l1_transaction_id",
2906
- "type": "text",
2907
- "primaryKey": false,
2908
- "notNull": false,
2909
- "autoincrement": false
2910
- },
2911
- "bundle_id": {
2912
- "name": "bundle_id",
2913
- "type": "text",
2914
- "primaryKey": false,
2915
- "notNull": false,
2916
- "autoincrement": false
2917
- },
2918
- "version_local_id": {
2919
- "name": "version_local_id",
2920
- "type": "text",
2921
- "primaryKey": false,
2922
- "notNull": false,
2923
- "autoincrement": false
2924
- },
2925
- "item_property_name": {
2926
- "name": "item_property_name",
2927
- "type": "text",
2928
- "primaryKey": false,
2929
- "notNull": false,
2930
- "autoincrement": false
2931
- },
2932
- "phase": {
2933
- "name": "phase",
2934
- "type": "text",
2935
- "primaryKey": false,
2936
- "notNull": true,
2937
- "autoincrement": false
2938
- },
2939
- "status_json": {
2940
- "name": "status_json",
2941
- "type": "text",
2942
- "primaryKey": false,
2943
- "notNull": false,
2944
- "autoincrement": false
2945
- },
2946
- "error_message": {
2947
- "name": "error_message",
2948
- "type": "text",
2949
- "primaryKey": false,
2950
- "notNull": false,
2951
- "autoincrement": false
2952
- },
2953
- "created_at": {
2954
- "name": "created_at",
2955
- "type": "integer",
2956
- "primaryKey": false,
2957
- "notNull": true,
2958
- "autoincrement": false
2959
- },
2960
- "updated_at": {
2961
- "name": "updated_at",
2962
- "type": "integer",
2963
- "primaryKey": false,
2964
- "notNull": true,
2965
- "autoincrement": false
2966
- }
2967
- },
2968
- "indexes": {
2969
- "arweave_l1_finalize_jobs_data_item_id_unique": {
2970
- "name": "arweave_l1_finalize_jobs_data_item_id_unique",
2971
- "columns": [
2972
- "data_item_id"
2973
- ],
2974
- "isUnique": true
2975
- }
2976
- },
2977
- "foreignKeys": {},
2978
- "compositePrimaryKeys": {},
2979
- "uniqueConstraints": {},
2980
- "checkConstraints": {}
2981
- },
2982
- "eas_sync_processes": {
2983
- "name": "eas_sync_processes",
2984
- "columns": {
2985
- "id": {
2986
- "name": "id",
2987
- "type": "integer",
2988
- "primaryKey": true,
2989
- "notNull": true,
2990
- "autoincrement": true
2991
- },
2992
- "status": {
2993
- "name": "status",
2994
- "type": "text",
2995
- "primaryKey": false,
2996
- "notNull": true,
2997
- "autoincrement": false
2998
- },
2999
- "started_at": {
3000
- "name": "started_at",
3001
- "type": "integer",
3002
- "primaryKey": false,
3003
- "notNull": true,
3004
- "autoincrement": false
3005
- },
3006
- "completed_at": {
3007
- "name": "completed_at",
3008
- "type": "integer",
3009
- "primaryKey": false,
3010
- "notNull": false,
3011
- "autoincrement": false
3012
- },
3013
- "request_payload": {
3014
- "name": "request_payload",
3015
- "type": "text",
3016
- "primaryKey": false,
3017
- "notNull": true,
3018
- "autoincrement": false
3019
- },
3020
- "error_message": {
3021
- "name": "error_message",
3022
- "type": "text",
3023
- "primaryKey": false,
3024
- "notNull": false,
3025
- "autoincrement": false
3026
- },
3027
- "error_details": {
3028
- "name": "error_details",
3029
- "type": "text",
3030
- "primaryKey": false,
3031
- "notNull": false,
3032
- "autoincrement": false
3033
- },
3034
- "persisted_snapshot": {
3035
- "name": "persisted_snapshot",
3036
- "type": "text",
3037
- "primaryKey": false,
3038
- "notNull": true,
3039
- "autoincrement": false
3040
- },
3041
- "created_at": {
3042
- "name": "created_at",
3043
- "type": "integer",
3044
- "primaryKey": false,
3045
- "notNull": false,
3046
- "autoincrement": false
3047
- },
3048
- "updated_at": {
3049
- "name": "updated_at",
3050
- "type": "integer",
3051
- "primaryKey": false,
3052
- "notNull": false,
3053
- "autoincrement": false
3054
- }
3055
- },
3056
- "indexes": {},
3057
- "foreignKeys": {},
3058
- "compositePrimaryKeys": {},
3059
- "uniqueConstraints": {},
3060
- "checkConstraints": {}
3061
- }
3062
- },
3063
- "views": {},
3064
- "enums": {},
3065
- "_meta": {
3066
- "schemas": {},
3067
- "tables": {},
3068
- "columns": {}
3069
- },
3070
- "internal": {
3071
- "indexes": {}
3072
- }
3073
- }`;
3074
-
3075
- var drizzleFiles = /*#__PURE__*/Object.freeze({
3076
- __proto__: null,
3077
- journalJson: journalJson,
3078
- migrationSql_0000_married_malice: migrationSql_0000_married_malice,
3079
- migrationSql_0001_sweet_bruce_banner: migrationSql_0001_sweet_bruce_banner,
3080
- migrationSql_0002_bitter_proudstar: migrationSql_0002_bitter_proudstar,
3081
- migrationSql_0003_cultured_senator_kelly: migrationSql_0003_cultured_senator_kelly,
3082
- migrationSql_0004_add_publisher_to_seeds: migrationSql_0004_add_publisher_to_seeds,
3083
- migrationSql_0005_bright_lily_hollister: migrationSql_0005_bright_lily_hollister,
3084
- migrationSql_0006_add_publisher_to_versions_and_metadata: migrationSql_0006_add_publisher_to_versions_and_metadata,
3085
- migrationSql_0007_add_required_to_properties: migrationSql_0007_add_required_to_properties,
3086
- migrationSql_0008_add_revoked_at_to_seeds: migrationSql_0008_add_revoked_at_to_seeds,
3087
- migrationSql_0009_happy_namor: migrationSql_0009_happy_namor,
3088
- migrationSql_0010_add_arweave_l1_finalize_jobs: migrationSql_0010_add_arweave_l1_finalize_jobs,
3089
- migrationSql_0011_normalize_placeholder_uids: migrationSql_0011_normalize_placeholder_uids,
3090
- migrationSql_0012_html_embedded_image_co_publish: migrationSql_0012_html_embedded_image_co_publish,
3091
- migrationSql_0013_eas_sync_processes: migrationSql_0013_eas_sync_processes,
3092
- migrationSql_0014_add_error_code_to_publish_processes: migrationSql_0014_add_error_code_to_publish_processes,
3093
- snapshotJson: snapshotJson
3094
- });
3095
-
3096
- /**
3097
- * Build drizzle migration metadata from embedded SQL strings.
3098
- * Avoids `drizzle-orm/migrator` (Node fs / path / crypto) on the browser graph.
3099
- */
3100
- function getEmbeddedMigrations() {
3101
- const journal = JSON.parse(journalJson);
3102
- const entries = journal.entries ?? [];
3103
- return entries.map((entry) => {
3104
- const varName = `migrationSql_${entry.tag}`;
3105
- const query = drizzleFiles[varName];
3106
- if (typeof query !== 'string') {
3107
- throw new Error(`No embedded migration content for ${entry.tag}`);
3108
- }
3109
- const trimmed = query.trim();
3110
- return {
3111
- sql: trimmed.split('--> statement-breakpoint'),
3112
- bps: Boolean(entry.breakpoints),
3113
- folderMillis: entry.when,
3114
- hash: bytesToHex(sha256(utf8ToBytes(trimmed))),
3115
- };
3116
- });
3117
- }
3118
- /**
3119
- * Same apply loop as drizzle-orm/sqlite-proxy/migrator, with in-memory migrations.
3120
- */
3121
- async function applyEmbeddedMigrations(db, migrations, migrationsTable = '__drizzle_migrations') {
3122
- await db.run(sql `
3123
- CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (
3124
- id SERIAL PRIMARY KEY,
3125
- hash text NOT NULL,
3126
- created_at numeric
3127
- )
3128
- `);
3129
- const dbMigrations = await db.values(sql `SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`);
3130
- const lastDbMigration = dbMigrations[0] ?? undefined;
3131
- const queriesToRun = [];
3132
- for (const migration of migrations) {
3133
- if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
3134
- queriesToRun.push(...migration.sql, `INSERT INTO \`${migrationsTable}\` ("hash", "created_at") VALUES('${migration.hash}', '${migration.folderMillis}')`);
3135
- }
3136
- }
3137
- for (const query of queriesToRun) {
3138
- await db.run(sql.raw(query));
3139
- }
3140
- }
3141
-
3142
- const logger$2 = debug('seedSdk:browser:db:createSqlocalDrizzle');
3143
- /** First sqlocal work can include sqlite-wasm fetch; keep this long to avoid false positives. */
3144
- const SQLOCAL_FIRST_QUERY_TIMEOUT_MS = 90000;
3145
- const HTTP_MODULE_WORKER_URL = /^https?:/i;
3146
- function shouldBlobWrapModuleWorker(scriptURL, options) {
3147
- const type = options?.type ?? 'classic';
3148
- if (type !== 'module')
3149
- return false;
3150
- return HTTP_MODULE_WORKER_URL.test(String(scriptURL));
3151
- }
3152
- function createBlobModuleWorkerSource(scriptURL) {
3153
- return `import ${JSON.stringify(String(scriptURL))};`;
3154
- }
3155
- /**
3156
- * Construct SQLocal while starting its HTTPS module worker from a blob that
3157
- * only imports the bundled worker URL. Some Chrome profiles kill
3158
- * `new Worker(https://…/worker-HASH.js, { type: 'module' })` as an entry
3159
- * script; importing the same URL from a blob worker reaches connect.
3160
- *
3161
- * The `Worker` patch is scoped to `factory()` so Vite still sees sqlocal's
3162
- * own `new Worker(new URL('./worker', import.meta.url))` and emits a real
3163
- * worker chunk.
3164
- */
3165
- function createSqlocalDrizzle(factory) {
3166
- let rejectFailed;
3167
- const workerFailed = new Promise((_, reject) => {
3168
- rejectFailed = reject;
3169
- });
3170
- // Avoid an unhandled rejection if the caller throws before racing this promise.
3171
- workerFailed.catch(() => { });
3172
- const restore = installModuleWorkerBlobWrap((error) => {
3173
- rejectFailed?.(error);
3174
- });
3175
- try {
3176
- return { instance: factory(), workerFailed };
3177
- }
3178
- finally {
3179
- restore();
3180
- }
3181
- }
3182
- async function raceSqlocalStartup(work, workerFailed, timeoutMs = SQLOCAL_FIRST_QUERY_TIMEOUT_MS) {
3183
- let timeoutId;
3184
- const timedOut = new Promise((_, reject) => {
3185
- timeoutId = setTimeout(() => {
3186
- reject(new Error(`sqlocal database failed to become ready within ${timeoutMs}ms`));
3187
- }, timeoutMs);
3188
- });
3189
- try {
3190
- return await Promise.race([work, workerFailed, timedOut]);
3191
- }
3192
- finally {
3193
- if (timeoutId !== undefined) {
3194
- clearTimeout(timeoutId);
3195
- }
3196
- }
3197
- }
3198
- function installModuleWorkerBlobWrap(onWorkerFailed) {
3199
- const OriginalWorker = globalThis.Worker;
3200
- if (typeof OriginalWorker === 'undefined') {
3201
- return () => { };
3202
- }
3203
- function WrappedWorker(scriptURL, options) {
3204
- const worker = shouldBlobWrapModuleWorker(scriptURL, options)
3205
- ? new OriginalWorker(URL.createObjectURL(new Blob([createBlobModuleWorkerSource(scriptURL)], {
3206
- type: 'text/javascript',
3207
- })), { ...options, type: 'module' })
3208
- : new OriginalWorker(scriptURL, options);
3209
- const fail = (event) => {
3210
- const filename = 'filename' in event && typeof event.filename === 'string'
3211
- ? event.filename
3212
- : '';
3213
- const message = 'message' in event && typeof event.message === 'string'
3214
- ? event.message
3215
- : event.type;
3216
- const error = new Error(filename
3217
- ? `sqlocal worker failed to start (${event.type}): ${message} [${filename}]`
3218
- : `sqlocal worker failed to start (${event.type}): ${message}`);
3219
- logger$2('[createSqlocalDrizzle] worker failed', error.message);
3220
- onWorkerFailed(error);
3221
- };
3222
- worker.addEventListener('error', fail);
3223
- worker.addEventListener('messageerror', fail);
3224
- return worker;
3225
- }
3226
- WrappedWorker.prototype = OriginalWorker.prototype;
3227
- Object.setPrototypeOf(WrappedWorker, OriginalWorker);
3228
- globalThis.Worker = WrappedWorker;
3229
- return () => {
3230
- globalThis.Worker = OriginalWorker;
3231
- };
3232
- }
3233
-
3234
- const logger$1 = debug('seedSdk:browser:db:Db');
3235
- class BrowserDb {
3236
- getAppDb() {
3237
- return this.appDb;
3238
- }
3239
- isAppDbReady() {
3240
- return !!this.appDb;
3241
- }
3242
- async prepareDb(filesDir) {
3243
- logger$1('[Db.prepareDb] preparing database');
3244
- this.filesDir = filesDir;
3245
- try {
3246
- // Copy drizzle migration files from src/db/drizzle to filesDir/db
3247
- await this.copyDrizzleFiles(filesDir);
3248
- // Ensure meta directory exists
3249
- const metaDirPath = `${filesDir}/db/meta`;
3250
- await BaseFileManager.createDirIfNotExists(metaDirPath);
3251
- // Ensure _journal.json file exists in meta directory
3252
- const journalFilePath = `${metaDirPath}/_journal.json`;
3253
- const journalExists = await BaseFileManager.pathExists(journalFilePath);
3254
- if (!journalExists) {
3255
- await BaseFileManager.saveFile(journalFilePath, JSON.stringify({
3256
- version: 1,
3257
- dialect: 'sqlite',
3258
- entries: [],
3259
- }, null, 2));
3260
- }
3261
- // Wait for journal file to be fully written before proceeding with migration
3262
- // This is critical in browser/OPFS where writes may not be immediately readable
3263
- logger$1('[Db.prepareDb] waiting for journal file to be fully written...');
3264
- await BaseFileManager.waitForFileWithContent(journalFilePath, 100, 5000);
3265
- logger$1('[Db.prepareDb] journal file is ready');
3266
- // Initialize SQLocalDrizzle with reactive: true to enable reactive queries.
3267
- // Blob-wrap sqlocal's HTTPS module worker so Chrome profiles that kill
3268
- // `new Worker(https://…/worker-HASH.js, { type: 'module' })` as an entry
3269
- // still reach connect via `import` of the same URL.
3270
- const { instance: sqlocalDrizzle, workerFailed } = createSqlocalDrizzle(() => new SQLocalDrizzle({
3271
- databasePath: `${this.filesDir}/db/seed.db`,
3272
- reactive: true,
3273
- }));
3274
- const { driver, batchDriver } = sqlocalDrizzle;
3275
- // Store SQLocalDrizzle instance for reactive queries
3276
- this.sqlocalInstance = sqlocalDrizzle;
3277
- // Create db instance but do NOT set this.appDb yet. restoreFromDb (and other
3278
- // callers of getAppDb()) must not see the db until migrations have completed,
3279
- // otherwise they may query tables (e.g. publish_processes) that don't exist yet.
3280
- const db = drizzle(driver, batchDriver, {
3281
- schema,
3282
- });
3283
- logger$1('[Db.prepareDb] database prepared');
3284
- await raceSqlocalStartup((async () => {
3285
- await this.runMigrations(db);
3286
- this.appDb = db;
3287
- const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-CBsf7LnU.js');
3288
- await backfillMetadataPropertyIds();
3289
- })(), workerFailed);
3290
- return this.appDb;
3291
- }
3292
- catch (error) {
3293
- logger$1('[Db.prepareDb] error', JSON.stringify(error));
3294
- throw error;
3295
- }
3296
- }
3297
- // static async prepareDb(filesDir: string) {
3298
- // console.log('prepareDb', filesDir)
3299
- // if (Db.sqliteWasmClient) {
3300
- // return this.dbId
3301
- // }
3302
- // this.filesDir = filesDir
3303
- // this.pathToDb = `${filesDir}/db/${DB_NAME_APP}.db`
3304
- // if (typeof document === 'undefined') {
3305
- // return
3306
- // }
3307
- // let promiser
3308
- // try {
3309
- // let sqlite3Worker1Promiser
3310
- // const sqliteWasm = await import('@sqlite.org/sqlite-wasm')
3311
- // if (sqliteWasm && sqliteWasm.sqlite3Worker1Promiser) {
3312
- // sqlite3Worker1Promiser = sqliteWasm.sqlite3Worker1Promiser
3313
- // }
3314
- // if (!sqlite3Worker1Promiser && window.sqlite3Worker1Promiser) {
3315
- // sqlite3Worker1Promiser = window.sqlite3Worker1Promiser
3316
- // }
3317
- // if (!sqlite3Worker1Promiser) {
3318
- // throw new Error('Failed to load sqlite3Worker1Promiser')
3319
- // }
3320
- // promiser = await new Promise<(event: string, config: Record<string, unknown>) => Promise<any>>((resolve) => {
3321
- // const _promiser = sqlite3Worker1Promiser({
3322
- // onready: () => {
3323
- // resolve(_promiser);
3324
- // },
3325
- // });
3326
- // }).catch((error) => {
3327
- // console.error('Error from sqlite proxy server: ', JSON.stringify(error))
3328
- // });
3329
- // } catch ( e ) {
3330
- // console.error('Error from sqlite proxy server: ', JSON.stringify(e))
3331
- // }
3332
- // if (!promiser) {
3333
- // throw new Error('Failed to create promiser')
3334
- // }
3335
- // this.sqliteWasmClient = promiser
3336
- // const responseGet = await this.sqliteWasmClient('config-get', {});
3337
- // logger('[Db.prepareDb] Running SQLite3 version', responseGet.result.version.libVersion);
3338
- // const responseOpen = await this.sqliteWasmClient('open', {
3339
- // filename: `file:${filesDir}/db/${DB_NAME_APP}.db?vfs=opfs`,
3340
- // });
3341
- // const { dbId } = responseOpen;
3342
- // logger(
3343
- // '[Db.prepareDb] OPFS is available, created persisted database at',
3344
- // responseOpen.result.filename.replace(/^file:(.*?)\?vfs=opfs/, '$1'),
3345
- // );
3346
- // logger('[Db.prepareDb] dbId', dbId)
3347
- // this.dbId = dbId
3348
- // await this.migrate()
3349
- // }
3350
- async connectToDb(filesDir) {
3351
- return this.dbId;
3352
- }
3353
- async copyDrizzleFiles(filesDir) {
3354
- logger$1('[Db.copyDrizzleFiles] copying drizzle migration files');
3355
- try {
3356
- // Ensure db directory exists
3357
- const dbDirPath = `${filesDir}/db`;
3358
- await BaseFileManager.createDirIfNotExists(dbDirPath);
3359
- // Ensure meta directory exists
3360
- const metaDirPath = `${dbDirPath}/meta`;
3361
- await BaseFileManager.createDirIfNotExists(metaDirPath);
3362
- // Parse journal JSON to get all migration entries
3363
- const journal = JSON.parse(journalJson);
3364
- const entries = journal.entries || [];
3365
- if (entries.length === 0) {
3366
- logger$1('[Db.copyDrizzleFiles] no migration entries found in journal');
3367
- return;
3368
- }
3369
- // Copy each migration SQL file (always overwrite to ensure they're up-to-date)
3370
- // Each migration is exported as a separate variable (e.g., migrationSql_0000_married_malice)
3371
- for (let i = 0; i < entries.length; i++) {
3372
- const entry = entries[i];
3373
- const tag = entry.tag; // e.g., "0000_married_malice"
3374
- const migrationFileName = `${tag}.sql`;
3375
- const migrationPath = `${dbDirPath}/${migrationFileName}`;
3376
- // Get the SQL for this migration from the exported variable
3377
- const migrationVarName = `migrationSql_${tag}`;
3378
- const migrationContent = drizzleFiles[migrationVarName];
3379
- if (!migrationContent) {
3380
- logger$1(`[Db.copyDrizzleFiles] ERROR: No migration content found for ${migrationFileName} (variable: ${migrationVarName})`);
3381
- throw new Error(`No migration content found for ${migrationFileName}. Expected variable: ${migrationVarName}`);
3382
- }
3383
- await BaseFileManager.saveFile(migrationPath, migrationContent.trim());
3384
- logger$1(`[Db.copyDrizzleFiles] copied/updated migration SQL file: ${migrationFileName}`);
3385
- }
3386
- // Copy journal JSON file (always overwrite to ensure it's up-to-date with all migrations)
3387
- const journalPath = `${metaDirPath}/_journal.json`;
3388
- await BaseFileManager.saveFile(journalPath, journalJson);
3389
- logger$1('[Db.copyDrizzleFiles] copied/updated journal JSON file');
3390
- // Copy snapshot JSON file (use the latest snapshot based on the highest idx in journal)
3391
- // Snapshot files are named like: 0000_snapshot.json, 0001_snapshot.json, etc.
3392
- // The tag format is like "0000_married_malice", so we extract the numeric prefix
3393
- const latestEntry = entries[entries.length - 1];
3394
- const tagPrefixMatch = latestEntry.tag.match(/^(\d+_)/);
3395
- const tagPrefix = tagPrefixMatch ? tagPrefixMatch[1] : '0000_';
3396
- const snapshotFileName = `${tagPrefix}snapshot.json`;
3397
- const snapshotPath = `${metaDirPath}/${snapshotFileName}`;
3398
- // Always overwrite snapshot to ensure it's up-to-date
3399
- await BaseFileManager.saveFile(snapshotPath, snapshotJson);
3400
- logger$1(`[Db.copyDrizzleFiles] copied/updated snapshot JSON file: ${snapshotFileName}`);
3401
- logger$1('[Db.copyDrizzleFiles] drizzle files copied successfully');
3402
- }
3403
- catch (error) {
3404
- logger$1('[Db.copyDrizzleFiles] error copying drizzle files', error);
3405
- // Don't throw - the files might already exist or migration might work without them
3406
- // The migration will fail later if the files are truly needed
3407
- }
3408
- }
3409
- /** Internal migration runner. Used by prepareDb before appDb is set. */
3410
- async runMigrations(db, _pathToDbDir) {
3411
- try {
3412
- const migrations = getEmbeddedMigrations();
3413
- logger$1('[Db.runMigrations] embedded migrations', migrations.length);
3414
- await applyEmbeddedMigrations(db, migrations);
3415
- logger$1('[Db.runMigrations] migrations completed');
3416
- }
3417
- catch (error) {
3418
- logger$1('[Db.runMigrations] error', JSON.stringify(error));
3419
- throw error;
3420
- }
3421
- }
3422
- async migrate(pathToDbDir, _dbName, _dbId) {
3423
- const targetDb = this.appDb;
3424
- if (!targetDb) {
3425
- throw new Error('Database not prepared');
3426
- }
3427
- await this.runMigrations(targetDb, pathToDbDir);
3428
- }
3429
- // Legacy commented migrate/exec implementation archived at
3430
- // docs/archive/commented/browser-Db-legacy-migrate.ts.txt
3431
- /**
3432
- * Execute a reactive query that emits new results whenever the underlying data changes.
3433
- *
3434
- * Supports two usage patterns:
3435
- * 1. SQL tag function: liveQuery((sql) => sql`SELECT * FROM models`)
3436
- * 2. Drizzle query builder: liveQuery(db.select().from(models))
3437
- *
3438
- * @param query - SQL query function or Drizzle query builder
3439
- * @returns Observable that emits arrays of query results
3440
- *
3441
- * @example
3442
- * ```typescript
3443
- * // Using SQL tag function
3444
- * const models$ = Db.liveQuery<ModelRow>(
3445
- * (sql) => sql`SELECT * FROM models WHERE schema_file_id = ${schemaId}`
3446
- * )
3447
- *
3448
- * // Using Drizzle query builder
3449
- * const models$ = Db.liveQuery<ModelRow>(
3450
- * appDb.select().from(models).where(eq(models.schemaFileId, schemaId))
3451
- * )
3452
- *
3453
- * models$.subscribe(models => {
3454
- * console.log('Models updated:', models)
3455
- * })
3456
- * ```
3457
- */
3458
- liveQuery(query) {
3459
- if (!this.sqlocalInstance) {
3460
- throw new Error('Database not initialized. Call prepareDb first.');
3461
- }
3462
- if (!this.sqlocalInstance.reactiveQuery) {
3463
- throw new Error('Reactive queries not enabled. Initialize SQLocalDrizzle with reactive: true.');
3464
- }
3465
- const baseObservable = new Observable((subscriber) => {
3466
- const reactiveQueryResult = this.sqlocalInstance.reactiveQuery(query);
3467
- const subscription = reactiveQueryResult.subscribe((data) => {
3468
- subscriber.next(data);
3469
- }, (err) => {
3470
- console.error('[BaseDb.liveQuery] SQLocal reactiveQuery error:', err);
3471
- subscriber.error(err);
3472
- });
3473
- return () => {
3474
- subscription.unsubscribe();
3475
- };
3476
- });
3477
- // Compare stable JSON snapshots via keySelector. SQLocal may reuse one array reference
3478
- // and mutate rows in place; comparing (prev, curr) on the same reference makes
3479
- // JSON.stringify(prev) === JSON.stringify(curr) after mutation and suppresses emissions.
3480
- return baseObservable.pipe(distinctUntilChanged((a, b) => a === b, (x) => JSON.stringify(x)));
3481
- }
3482
- }
3483
- BaseDb.configure(new BrowserDb());
3484
-
3485
- const logger = debug("seedSdk:browser:ArweaveClient");
3486
- // Cached Arweave instance (keyed by gateway so setHost / protocol changes apply)
3487
- let _arweaveInstance = null;
3488
- let _arweaveGatewayKey = null;
3489
- /**
3490
- * Get or create the Arweave instance for browser
3491
- */
3492
- const getArweaveInstance = () => {
3493
- const gatewayKey = `${BaseArweaveClient.getProtocol()}://${BaseArweaveClient.getHost()}`;
3494
- if (_arweaveInstance && _arweaveGatewayKey === gatewayKey) {
3495
- return _arweaveInstance;
3496
- }
3497
- _arweaveGatewayKey = gatewayKey;
3498
- const apiConfig = BaseArweaveClient.getArweaveJsApiConfig();
3499
- // Handle both ES modules and CommonJS exports from arweave package
3500
- if ("default" in Arweave && typeof Arweave.default?.init === "function") {
3501
- _arweaveInstance = Arweave.default.init(apiConfig);
3502
- }
3503
- else {
3504
- _arweaveInstance = Arweave.init(apiConfig);
3505
- }
3506
- return _arweaveInstance;
3507
- };
3508
- class BrowserArweaveClient {
3509
- getArweaveClient() {
3510
- return new GraphQLClient(BaseArweaveClient.getEndpoint());
3511
- }
3512
- async getTransactionStatus(transactionId) {
3513
- const url = BaseArweaveClient.getStatusUrl(transactionId);
3514
- try {
3515
- const response = await fetch(url);
3516
- if (response.status === 404) {
3517
- return {
3518
- status: 404,
3519
- confirmed: null,
3520
- };
3521
- }
3522
- if (!response.ok) {
3523
- return {
3524
- status: response.status,
3525
- confirmed: null,
3526
- };
3527
- }
3528
- if (response.body) {
3529
- await response.body.cancel();
3530
- }
3531
- return {
3532
- status: 200,
3533
- confirmed: null,
3534
- };
3535
- }
3536
- catch (error) {
3537
- logger("Error fetching transaction status:", error);
3538
- return {
3539
- status: 500,
3540
- confirmed: null,
3541
- };
3542
- }
3543
- }
3544
- async getTransactionData(transactionId, options) {
3545
- // Preferred gateways (usually the one the item was uploaded through) serve it before L1 does.
3546
- // `/raw` is already decoded, so skip them when the caller asked for undecoded data.
3547
- const preferred = options?.decode === false ? [] : getPreferredArweaveReadBaseUrls();
3548
- for (const base of preferred) {
3549
- const response = await fetchArweaveRawFromBaseUrl(base, transactionId);
3550
- if (!response)
3551
- continue;
3552
- try {
3553
- if (options?.string) {
3554
- return await response.text();
3555
- }
3556
- return new Uint8Array(await response.arrayBuffer());
3557
- }
3558
- catch (error) {
3559
- logger("Error reading preferred gateway response:", error);
3560
- }
3561
- }
3562
- // Path-prefixed proxies (app-server Hyper proxy) are not supported by arweave.init host;
3563
- // fetch via getRawUrl so /api/seed-gateway/... works.
3564
- if (BaseArweaveClient.getGatewayPath()) {
3565
- const response = await fetch(BaseArweaveClient.getRawUrl(transactionId));
3566
- if (!response.ok) {
3567
- throw new Error(`Failed to fetch transaction data: HTTP ${response.status}`);
3568
- }
3569
- if (options?.string) {
3570
- return response.text();
3571
- }
3572
- return new Uint8Array(await response.arrayBuffer());
3573
- }
3574
- const arweave = getArweaveInstance();
3575
- try {
3576
- const data = await arweave.transactions.getData(transactionId, {
3577
- decode: options?.decode ?? true,
3578
- string: options?.string ?? false,
3579
- });
3580
- if (options?.string && typeof data === "string") {
3581
- return data;
3582
- }
3583
- // Ensure we return Uint8Array
3584
- if (data instanceof Uint8Array) {
3585
- return data;
3586
- }
3587
- // Handle string data when not requesting string
3588
- if (typeof data === "string") {
3589
- return new TextEncoder().encode(data);
3590
- }
3591
- return data;
3592
- }
3593
- catch (error) {
3594
- logger("Error fetching transaction data:", error);
3595
- throw error;
3596
- }
3597
- }
3598
- async getTransactionTags(transactionId) {
3599
- const client = this.getArweaveClient();
3600
- try {
3601
- const result = await client.request(GET_TRANSACTION_TAGS, { transactionId });
3602
- if (!result.tags?.tags) {
3603
- return [];
3604
- }
3605
- return result.tags.tags.map((tag) => ({
3606
- name: tag.name,
3607
- value: tag.value,
3608
- }));
3609
- }
3610
- catch (error) {
3611
- logger("Error fetching transaction tags:", error);
3612
- return [];
3613
- }
3614
- }
3615
- async createTransaction(data, options) {
3616
- const arweave = getArweaveInstance();
3617
- const tx = await arweave.createTransaction({
3618
- data,
3619
- });
3620
- // Add tags if provided
3621
- if (options?.tags) {
3622
- for (const tag of options.tags) {
3623
- tx.addTag(tag.name, tag.value);
3624
- }
3625
- }
3626
- return tx;
3627
- }
3628
- async downloadFiles(params) {
3629
- const { transactionIds, excludedTransactions } = params;
3630
- const results = [];
3631
- const baseUrl = BaseArweaveClient.getBaseUrl();
3632
- for (const transactionId of transactionIds) {
3633
- // Skip excluded transactions
3634
- if (excludedTransactions?.has(transactionId)) {
3635
- continue;
3636
- }
3637
- try {
3638
- const url = `${baseUrl}/raw/${transactionId}`;
3639
- const response = await fetch(url);
3640
- if (!response.ok) {
3641
- results.push({
3642
- transactionId,
3643
- success: false,
3644
- error: `HTTP ${response.status}: ${response.statusText}`,
3645
- });
3646
- continue;
3647
- }
3648
- const arrayBuffer = await response.arrayBuffer();
3649
- const data = new Uint8Array(arrayBuffer);
3650
- // Detect content type
3651
- const contentType = response.headers.get("content-type") || undefined;
3652
- results.push({
3653
- transactionId,
3654
- success: true,
3655
- contentType,
3656
- data,
3657
- });
3658
- }
3659
- catch (error) {
3660
- logger(`Error downloading transaction ${transactionId}:`, error);
3661
- results.push({
3662
- transactionId,
3663
- success: false,
3664
- error: error instanceof Error ? error.message : String(error),
3665
- });
3666
- }
3667
- }
3668
- return results;
3669
- }
3670
- }
3671
- BaseArweaveClient.configure(new BrowserArweaveClient());
3672
-
3673
- class BrowserEasClient {
3674
- /** Reads the endpoint per call so SDK / publish chain config applied after import takes effect. */
3675
- getEasClient() {
3676
- const url = getEasEndpoint();
3677
- if (this.easClient?.url !== url) {
3678
- this.easClient = { url, client: new GraphQLClient(url) };
3679
- }
3680
- return this.easClient.client;
3681
- }
3682
- }
3683
- BaseEasClient.configure(new BrowserEasClient());
3684
-
3685
- class BrowserQueryClient {
3686
- getQueryClient() {
3687
- const reactQueryClient = new QueryClient({
3688
- defaultOptions: {
3689
- queries: {
3690
- networkMode: 'offlineFirst',
3691
- gcTime: 1000 * 60 * 60 * 24, // 24 hours
3692
- },
3693
- },
3694
- });
3695
- const queryClient = {
3696
- fetchQuery: async (options) => {
3697
- const { queryKey, queryFn, networkMode, staleTime } = options;
3698
- return reactQueryClient.fetchQuery({
3699
- queryKey,
3700
- queryFn,
3701
- networkMode: networkMode,
3702
- staleTime,
3703
- });
3704
- },
3705
- getQueryData: (queryKey) => {
3706
- return reactQueryClient.getQueryData(queryKey);
3707
- },
3708
- removeQueries: async (filters) => {
3709
- await reactQueryClient.removeQueries(filters);
3710
- },
3711
- };
3712
- return queryClient;
3713
- }
3714
- }
3715
- BaseQueryClient.configure(new BrowserQueryClient());
3716
-
3717
- function createPlatformServices() {
3718
- return {
3719
- pathResolver: new BrowserPathResolver(),
3720
- fileManager: new BrowserFileManager(),
3721
- db: new BrowserDb(),
3722
- arweaveClient: new BrowserArweaveClient(),
3723
- easClient: new BrowserEasClient(),
3724
- queryClient: new BrowserQueryClient(),
3725
- };
3726
- }
3727
-
3728
- export { createPlatformServices };
18
+ import './errors-CrBxGWah.js';
19
+ import 'drizzle-orm/sqlite-proxy';
20
+ import '@noble/hashes/sha256';
21
+ import '@noble/hashes/utils';
22
+ import './index-B0LgJblD.js';
23
+ import 'sqlocal/drizzle';
24
+ import 'rxjs';
25
+ import 'graphql-request';
26
+ import 'arweave';
27
+ import '@tanstack/react-query';
3729
28
  //# sourceMappingURL=platform.browser.js.map