@seedprotocol/sdk 0.7.4 → 0.7.5-next.871.g8788c94

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 (135) hide show
  1. package/README.md +99 -0
  2. package/dist/{BasePathResolver-DrzGVH9L.js → BasePathResolver-B-fK7_N_.js} +142 -8
  3. package/dist/BasePathResolver-B-fK7_N_.js.map +1 -0
  4. package/dist/{ClientManager-Dfu4jcgm.js → ClientManager-C7VkO5Hg.js} +342 -206
  5. package/dist/ClientManager-C7VkO5Hg.js.map +1 -0
  6. package/dist/{Item-BUUFuywT.js → Item-BDmsdNTQ.js} +234 -163
  7. package/dist/Item-BDmsdNTQ.js.map +1 -0
  8. package/dist/{ModelProperty-B6cnRvIz.js → ModelProperty-Cqw6yn7y.js} +37 -37
  9. package/dist/{ModelProperty-B6cnRvIz.js.map → ModelProperty-Cqw6yn7y.js.map} +1 -1
  10. package/dist/{Schema-Bf-jOLq0.js → Schema-BJLYOUgp.js} +57 -37
  11. package/dist/Schema-BJLYOUgp.js.map +1 -0
  12. package/dist/{SchemaValidationService-BNYMacsx.js → SchemaValidationService-CzybXLiS.js} +6 -6
  13. package/dist/{SchemaValidationService-BNYMacsx.js.map → SchemaValidationService-CzybXLiS.js.map} +1 -1
  14. package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js → backfillMetadataPropertyIds-DAsETfD_.js} +3 -3
  15. package/dist/{backfillMetadataPropertyIds-C2-s_jUa.js.map → backfillMetadataPropertyIds-DAsETfD_.js.map} +1 -1
  16. package/dist/{configurePlatform-BzfirKuM.js → configurePlatform-CFQF_i1T.js} +2 -2
  17. package/dist/{configurePlatform-BzfirKuM.js.map → configurePlatform-CFQF_i1T.js.map} +1 -1
  18. package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js → detachRowsBeforeDelete-D4gxxk46.js} +2 -2
  19. package/dist/{detachRowsBeforeDelete-B0Daoz9Z.js.map → detachRowsBeforeDelete-D4gxxk46.js.map} +1 -1
  20. package/dist/discardNewDraft-g8w3uHFM.js +78 -0
  21. package/dist/discardNewDraft-g8w3uHFM.js.map +1 -0
  22. package/dist/{eas-Dq5Kx_Nd.js → eas-BcXZ2hIn.js} +25 -12
  23. package/dist/eas-BcXZ2hIn.js.map +1 -0
  24. package/dist/{errors-DdWbxb_n.js → errors-CCMxedOB.js} +43 -38
  25. package/dist/errors-CCMxedOB.js.map +1 -0
  26. package/dist/{getItem-9bYSErSj.js → getItem-BUs1Xa48.js} +4 -4
  27. package/dist/{getItem-9bYSErSj.js.map → getItem-BUs1Xa48.js.map} +1 -1
  28. package/dist/{getPublishPayload-DPy-uMrR.js → getPublishPayload-CwNOhnir.js} +25 -15
  29. package/dist/getPublishPayload-CwNOhnir.js.map +1 -0
  30. package/dist/{getPublishUploads-J-143iSV.js → getPublishUploads-pEOrXJbF.js} +506 -45
  31. package/dist/getPublishUploads-pEOrXJbF.js.map +1 -0
  32. package/dist/{index-7y2f_iQz.js → index-BQSK-r_A.js} +2 -2
  33. package/dist/index-BQSK-r_A.js.map +1 -0
  34. package/dist/{index-C61Rxy0F.js → index-zAs84LDi.js} +8 -8
  35. package/dist/index-zAs84LDi.js.map +1 -0
  36. package/dist/{index.browser-C1pisOEa.js → index.browser-irwaBIj0.js} +11 -11
  37. package/dist/{index.browser-C1pisOEa.js.map → index.browser-irwaBIj0.js.map} +1 -1
  38. package/dist/{index.node-BAlST8pD.js → index.node-BYkndQN7.js} +6 -6
  39. package/dist/{index.node-BAlST8pD.js.map → index.node-BYkndQN7.js.map} +1 -1
  40. package/dist/main.js +91 -504
  41. package/dist/main.js.map +1 -1
  42. package/dist/{mimeTypes-DHAHC4eZ.js → mimeTypes-C9r76DCH.js} +7 -2
  43. package/dist/{mimeTypes-DHAHC4eZ.js.map → mimeTypes-C9r76DCH.js.map} +1 -1
  44. package/dist/node.js +10 -10
  45. package/dist/platform.browser.js +6 -6
  46. package/dist/platform.node.js +4 -4
  47. package/dist/{property-zFPMtR3T.js → property-5AD2naVS.js} +7 -7
  48. package/dist/{property-zFPMtR3T.js.map → property-5AD2naVS.js.map} +1 -1
  49. package/dist/{propertyValidationRules-CeFVhdQg.js → propertyValidationRules-Bdgz0Nrr.js} +10 -10
  50. package/dist/{propertyValidationRules-CeFVhdQg.js.map → propertyValidationRules-Bdgz0Nrr.js.map} +1 -1
  51. package/dist/{publishDraftGraph-CuVq6iAR.js → publishDraftGraph-DGhC9ifI.js} +6 -6
  52. package/dist/{publishDraftGraph-CuVq6iAR.js.map → publishDraftGraph-DGhC9ifI.js.map} +1 -1
  53. package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js → resetAmbiguousLegacyItemData-HSB77N9c.js} +2 -2
  54. package/dist/{resetAmbiguousLegacyItemData-DsFTnMBz.js.map → resetAmbiguousLegacyItemData-HSB77N9c.js.map} +1 -1
  55. package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js → resolveModelForSyncedSeed-CAKAJgr6.js} +2 -2
  56. package/dist/{resolveModelForSyncedSeed-RUsgAZXG.js.map → resolveModelForSyncedSeed-CAKAJgr6.js.map} +1 -1
  57. package/dist/src/Item/Item.d.ts +4 -1
  58. package/dist/src/Item/Item.d.ts.map +1 -1
  59. package/dist/src/Item/errors.d.ts +3 -1
  60. package/dist/src/Item/errors.d.ts.map +1 -1
  61. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  62. package/dist/src/Model/Model.d.ts +2 -1
  63. package/dist/src/Model/Model.d.ts.map +1 -1
  64. package/dist/src/Schema/Schema.d.ts.map +1 -1
  65. package/dist/src/Schema/service/schemaMachine.d.ts +3 -0
  66. package/dist/src/Schema/service/schemaMachine.d.ts.map +1 -1
  67. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  68. package/dist/src/db/alignRowPublishers.d.ts +25 -0
  69. package/dist/src/db/alignRowPublishers.d.ts.map +1 -0
  70. package/dist/src/db/canonicalizeModelTypes.d.ts +2 -2
  71. package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -1
  72. package/dist/src/db/read/getModelSchemas.d.ts +3 -2
  73. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  74. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  75. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  76. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  77. package/dist/src/db/read/getSeedPublisher.d.ts +7 -0
  78. package/dist/src/db/read/getSeedPublisher.d.ts.map +1 -0
  79. package/dist/src/db/read/nameMatchLevels.d.ts +64 -0
  80. package/dist/src/db/read/nameMatchLevels.d.ts.map +1 -0
  81. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  82. package/dist/src/db/read/summarizePublishWork.d.ts +2 -0
  83. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  84. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts +5 -3
  85. package/dist/src/db/write/applyArweaveL1TransactionIdLocal.d.ts.map +1 -1
  86. package/dist/src/db/write/claimUnpublishedDrafts.d.ts +4 -2
  87. package/dist/src/db/write/claimUnpublishedDrafts.d.ts.map +1 -1
  88. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  89. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  90. package/dist/src/db/write/createSeed.d.ts.map +1 -1
  91. package/dist/src/db/write/createVersion.d.ts.map +1 -1
  92. package/dist/src/db/write/discardNewDraft.d.ts +8 -0
  93. package/dist/src/db/write/discardNewDraft.d.ts.map +1 -0
  94. package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts +18 -0
  95. package/dist/src/db/write/restoreDataItemIdsOverwrittenByL1.d.ts.map +1 -0
  96. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  97. package/dist/src/eas.d.ts.map +1 -1
  98. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  99. package/dist/src/helpers/constants.d.ts.map +1 -1
  100. package/dist/src/helpers/db.d.ts.map +1 -1
  101. package/dist/src/helpers/easValueTypes.d.ts +16 -0
  102. package/dist/src/helpers/easValueTypes.d.ts.map +1 -0
  103. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +13 -2
  104. package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
  105. package/dist/src/helpers/ownership.d.ts +9 -12
  106. package/dist/src/helpers/ownership.d.ts.map +1 -1
  107. package/dist/src/helpers/publishConfig.d.ts +9 -4
  108. package/dist/src/helpers/publishConfig.d.ts.map +1 -1
  109. package/dist/src/imports/index.d.ts +1 -1
  110. package/dist/src/imports/index.d.ts.map +1 -1
  111. package/dist/src/imports/json.d.ts.map +1 -1
  112. package/dist/src/index.d.ts +2 -1
  113. package/dist/src/index.d.ts.map +1 -1
  114. package/dist/src/types/import.d.ts +20 -0
  115. package/dist/src/types/import.d.ts.map +1 -1
  116. package/dist/{syncDbWithEas-CRpnkq00.js → syncDbWithEas-BmJXqfgN.js} +92 -22
  117. package/dist/syncDbWithEas-BmJXqfgN.js.map +1 -0
  118. package/dist/{tabEvents-nBUq_1u1.js → tabEvents-DXun7vdK.js} +4 -4
  119. package/dist/{tabEvents-nBUq_1u1.js.map → tabEvents-DXun7vdK.js.map} +1 -1
  120. package/dist/{tolerantWebAccess-DIt3R8_u.js → tolerantWebAccess-DXxgX2x7.js} +7 -7
  121. package/dist/{tolerantWebAccess-DIt3R8_u.js.map → tolerantWebAccess-DXxgX2x7.js.map} +1 -1
  122. package/dist/{updateSeedRevokedAt-DtTPSzpM.js → updateSeedRevokedAt-DkLSDwUX.js} +3 -3
  123. package/dist/{updateSeedRevokedAt-DtTPSzpM.js.map → updateSeedRevokedAt-DkLSDwUX.js.map} +1 -1
  124. package/package.json +9 -5
  125. package/dist/BasePathResolver-DrzGVH9L.js.map +0 -1
  126. package/dist/ClientManager-Dfu4jcgm.js.map +0 -1
  127. package/dist/Item-BUUFuywT.js.map +0 -1
  128. package/dist/Schema-Bf-jOLq0.js.map +0 -1
  129. package/dist/eas-Dq5Kx_Nd.js.map +0 -1
  130. package/dist/errors-DdWbxb_n.js.map +0 -1
  131. package/dist/getPublishPayload-DPy-uMrR.js.map +0 -1
  132. package/dist/getPublishUploads-J-143iSV.js.map +0 -1
  133. package/dist/index-7y2f_iQz.js.map +0 -1
  134. package/dist/index-C61Rxy0F.js.map +0 -1
  135. package/dist/syncDbWithEas-CRpnkq00.js.map +0 -1
package/dist/main.js CHANGED
@@ -1,27 +1,26 @@
1
- export { C as ConflictError, I as ItemCreateValidationError, M as Model, U as UnknownModelError } from './errors-DdWbxb_n.js';
2
- import { E as BaseDb, C as versions, X as normalizePublisher, A as seeds, $ as generateId, m as metadata, O as normalizeRelationPropertyValue, N as resolveSeedIdsFromRefString, i as isDataType, M as ModelPropertyDataTypes, o as htmlEmbeddedImageCoPublish, J as BaseFileManager, ao as getArweaveUrlForTransaction, ap as INTERNAL_STORAGE_MODEL_FILE_IDS, ag as INTERNAL_PROPERTY_NAMES, ac as ZERO_BYTES32, n as normalizeDataType, R as getStorageDirForDataType } from './BasePathResolver-DrzGVH9L.js';
3
- export { G as AmbiguousModelError, aq as CONTENT_SHA256_TAG, ar as CONTENT_TYPE_TAG, _ as EAS_SEED_DATA_SYNCED_TO_DB_EVENT, aj as INTERNAL_DATA_TYPES, as as ImageSize, at as SEED_PROTOCOL_SCHEMA_NAME, au as SeedModels, av as VERSION_SCHEMA_DEF, af as VERSION_SCHEMA_UID, aw as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, h as appState, j as arweaveL1FinalizeJobs, U as buildArweaveContentTags, ax as classifyMediaRef, ay as closestImageSize, az as contentSha256TagMatches, a2 as easPropertyNameForPublish, l as easSyncProcesses, aA as ensureImageLocal, H as eventEmitter, aB as getAddressesForItemsFilter, S as getContentSha256, a8 as getCorrectId, aC as getFeedItemStringField, Q as isPublishedSeedRef, a1 as listRelationEasPropertyName, q as modelSchemas, r as modelUids, s as models, aD as normalizeAddressConfig, aE as normalizeAddressList, aF as normalizeArweaveTxIdForEnsure, aG as normalizeFeedItemFields, a0 as normalizeHexAddress, u as properties, x as propertyUids, y as publishProcesses, aH as resolveMediaRef, z as schemas, B as uploadProcesses } from './BasePathResolver-DrzGVH9L.js';
4
- export { getPropertySchema } from './property-zFPMtR3T.js';
5
- export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError, i as isLeaderTab, p as parseAddressesPersistedPayload, w as whenLeaderTab } from './tabEvents-nBUq_1u1.js';
6
- import { d as getContentHash } from './ClientManager-Dfu4jcgm.js';
7
- export { E as EAS_CHAIN_ID_APP_STATE_KEY, I as INIT_CONFIG_CONFLICT_MESSAGE, a as assertLocalDbChain, e as claimUnpublishedDrafts, C as client, f as createLocalQueryDataSource, h as createSchema, j as easSyncActor, k as getClient, m as getPublishedSeedRecord, n as getSchemaNameFromId, b as importJsonSchema, o as isSeedQueryLocalSourceRegistered, p as listSchemas, q as loadAllSchemasFromDb, u as mergeEasSyncRequestIntents, r as readJsonImportFile, v as readSchema, x as registerSeedQueryLocalSource, y as requestEasSyncFromAddressChange, z as requestEasSyncFromEventBus, A as requestEasSyncFromModelsInit, B as sendEasSyncClientRequest, D as setRetriesWhenOnlineEnabled, F as startEasSyncActor, s as syncSchemaFromSource, t as transformImportToSchemaFile, G as unregisterSeedQueryLocalSource } from './ClientManager-Dfu4jcgm.js';
8
- import { k as isVersionRevoked, c as compareMetadataRowsLatestFirst, t as isPublishedMetadataRow, j as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage, I as Item, l as waitForEntityIdle } from './Item-BUUFuywT.js';
9
- export { C as ClientManagerState, d as ItemProperty, e as ItemPropertySaveValidationError, M as METADATA_LATEST_FIRST_ORDER_SQL, u as MachineIds, O as OwnershipError, P as PUBLISH_NOT_CONFIGURED_MESSAGE, f as assertItemOwned, v as createNewItem, x as getEasSchemaForItemProperty, b as getGetAdditionalSyncAddresses, y as getGetPublisherForNewSeeds, z as getMetadataLatest, A as getPublishExecutor, B as getRevokeExecutor, E as getUploadExecutor, F as getVersionData, i as isItemOwned, G as isLocalUnsealedDraft, H as isSeedRowOwned, J as localUnsealedDraftSql, K as ownedPublisherSql, L as ownedSeedsSql, N as pickLatestMetadataRowPerProperty, Q as placeholderUidSql, R as propertyMachine, S as publisherInAddressListSql, T as publisherIsInOwnedSet, U as setAdditionalSyncAddresses, V as setGetPublisherForNewSeeds, W as setPublishExecutor, X as setRevokeExecutor, Y as setUploadExecutor } from './Item-BUUFuywT.js';
10
- import { eq, desc, and, or, isNotNull, ne } from 'drizzle-orm';
1
+ export { C as ConflictError, I as ItemCreateValidationError, M as Model, U as UnknownModelError } from './errors-CCMxedOB.js';
2
+ import { B as BaseDb, F as versions, ah as normalizePublisher, C as seeds, al as generateId, m as metadata, k as arweaveL1FinalizeJobs, V as normalizeRelationPropertyValue, W as resolveSeedIdsFromRefString, i as isDataType, M as ModelPropertyDataTypes, a9 as INTERNAL_PROPERTY_NAMES, p as htmlEmbeddedImageCoPublish, a5 as ZERO_BYTES32, n as normalizeDataType, h as BaseFileManager, $ as getStorageDirForDataType } from './BasePathResolver-B-fK7_N_.js';
3
+ export { H as AmbiguousModelError, as as CONTENT_SHA256_TAG, at as CONTENT_TYPE_TAG, ag as EAS_SEED_DATA_SYNCED_TO_DB_EVENT, ac as INTERNAL_DATA_TYPES, au as ImageSize, av as SEED_PROTOCOL_SCHEMA_NAME, aw as SeedModels, ax as VERSION_SCHEMA_DEF, a8 as VERSION_SCHEMA_UID, ay as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, j as appState, a1 as buildArweaveContentTags, az as classifyMediaRef, aA as closestImageSize, aB as contentSha256TagMatches, ae as easPropertyNameForPublish, o as easSyncProcesses, aC as ensureImageLocal, I as eventEmitter, aD as getAddressesForItemsFilter, Z as getArweaveUrlForTransaction, a0 as getContentSha256, R as getCorrectId, aE as getFeedItemStringField, U as isPublishedSeedRef, ad as listRelationEasPropertyName, r as modelSchemas, s as modelUids, t as models, aF as normalizeAddressConfig, aG as normalizeAddressList, aH as normalizeArweaveTxIdForEnsure, aI as normalizeFeedItemFields, am as normalizeHexAddress, v as properties, y as propertyUids, z as publishProcesses, aJ as resolveMediaRef, A as schemas, E as uploadProcesses } from './BasePathResolver-B-fK7_N_.js';
4
+ export { getPropertySchema } from './property-5AD2naVS.js';
5
+ export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError, i as isLeaderTab, p as parseAddressesPersistedPayload, w as whenLeaderTab } from './tabEvents-DXun7vdK.js';
6
+ export { E as EAS_CHAIN_ID_APP_STATE_KEY, I as INIT_CONFIG_CONFLICT_MESSAGE, d as assertLocalDbChain, e as claimUnpublishedDrafts, C as client, f as createLocalQueryDataSource, j as createSchema, k as easSyncActor, m as getClient, n as getPublishedSeedRecord, o as getSchemaNameFromId, i as importJsonSchema, p as isSeedQueryLocalSourceRegistered, q as listSchemas, u as loadAllSchemasFromDb, v as mergeEasSyncRequestIntents, r as readJsonImportFile, x as readSchema, y as registerSeedQueryLocalSource, z as requestEasSyncFromAddressChange, A as requestEasSyncFromEventBus, B as requestEasSyncFromModelsInit, D as sendEasSyncClientRequest, F as setRetriesWhenOnlineEnabled, G as startEasSyncActor, s as syncSchemaFromSource, t as transformImportToSchemaFile, H as unregisterSeedQueryLocalSource } from './ClientManager-C7VkO5Hg.js';
7
+ import { j as isVersionRevoked, e as compareMetadataRowsLatestFirst, t as isPublishedMetadataRow, h as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage } from './Item-BDmsdNTQ.js';
8
+ export { C as ClientManagerState, I as Item, a as ItemProperty, b as ItemPropertySaveValidationError, M as METADATA_LATEST_FIRST_ORDER_SQL, u as MachineIds, O as OwnershipError, P as PUBLISH_NOT_CONFIGURED_MESSAGE, c as assertItemOwned, v as createNewItem, x as getEasSchemaForItemProperty, l as getGetAdditionalSyncAddresses, y as getGetPublisherForNewSeeds, z as getMetadataLatest, A as getPublishExecutor, B as getRevokeExecutor, E as getUploadExecutor, F as getVersionData, i as isItemOwned, G as isLocalUnsealedDraft, H as isSeedRowOwned, J as localUnsealedDraftSql, K as ownedPublisherSql, L as ownedSeedsSql, N as pickLatestMetadataRowPerProperty, Q as placeholderUidSql, R as propertyMachine, S as publisherInAddressListSql, T as publisherIsInOwnedSet, U as setAdditionalSyncAddresses, V as setGetPublisherForNewSeeds, W as setPublishExecutor, X as setRevokeExecutor, Y as setUploadExecutor, d as waitForEntityIdle } from './Item-BDmsdNTQ.js';
9
+ import { eq, desc, and, or, isNotNull, ne, isNull } from 'drizzle-orm';
11
10
  import { isPlaceholderUid, isValidEasAttestationUid, normalizeBytes32Hex } from '@seedprotocol/eas';
12
11
  export { EAS_CHAIN_DEPLOYMENTS, BaseEasClient as EasClient, easName, getCanonicalItemPropertiesFromEas, getEasChainDeployment, getEasEndpoint, getEasReadChainId, getEasSchemaUidBySchemaName, getItemPropertiesFromEas, getItemVersionsFromEas, getSeedsBySchemaName, getSeedsFromSchemaUids, isPlaceholderUid, isValidEasAttestationUid, matchEasName, normalizeBytes32Hex, pickLatestPropertyAttestationsByRefAndSchema, setSchemaUidForModel, setSchemaUidForSchemaDefinition, withExcludeRevokedFilter } from '@seedprotocol/eas';
13
- export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-Bf-jOLq0.js';
12
+ export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-BJLYOUgp.js';
14
13
  export { F as FileSystemLockedError } from './errors-CrBxGWah.js';
15
- export { M as MODEL_AMBIGUOUS_EVENT } from './resolveModelForSyncedSeed-RUsgAZXG.js';
16
- export { ModelProperty } from './ModelProperty-B6cnRvIz.js';
17
- export { getModelSchemasFromEas } from './eas-Dq5Kx_Nd.js';
14
+ export { M as MODEL_AMBIGUOUS_EVENT } from './resolveModelForSyncedSeed-CAKAJgr6.js';
15
+ export { ModelProperty } from './ModelProperty-Cqw6yn7y.js';
16
+ export { getModelSchemasFromEas } from './eas-BcXZ2hIn.js';
18
17
  export { BaseArweaveClient, DEFAULT_ARWEAVE_GATEWAYS, DEFAULT_ARWEAVE_GRAPHQL_URL, DEFAULT_ARWEAVE_HOST, DEFAULT_GATEWAY_SIDECAR_HOST, DEFAULT_GATEWAY_SIDECAR_PORT, DEFAULT_SEED_FEED_HYPER_KEY, DEFAULT_SEED_GATEWAY_HYPER_KEY, SEED_RSS_IMAGE_RELATION_FIELD_KEYS, ensureReadGatewaySelected, fetchArweaveRawFromBaseUrl, fetchArweaveRawTextAcrossGateways, getArweaveReadBaseUrls, getArweaveUploadStatus, getDefaultArweaveReadGatewayHostsOrdered, getLastHealthyReadGatewayHost, getPreferredArweaveReadBaseUrls, getReadGatewayHostsForConfig, getResolvedArweaveReadBaseUrls, getResolvedSeedGatewayEndpoints, getUploadApiArweaveDataUrl, getUploadApiArweaveStatusUrl, getUploadPipelineTransactionStatus, hasArweaveContentReadTransform, invalidateReadGatewayCache, invalidateSidecarProbeCache, isArweaveL1AnchoringComplete, isEasAttestationExplorerUrl, isGatewayHostCircuitOpen, isKnownArweaveGatewayHostname, isReadGatewayKnownHealthy, mergePrimaryHostWithDefaults, normalizeGatewayHostKey, normalizeUploadApiBaseUrl, queryArweaveGatewayTransaction, queryArweaveGatewayTransactionWithFallback, readArweaveContentResponse, recordGatewayHostFailure, recordGatewayHostSuccess, resetArweaveReadGatewayForTests, resolveSeedGatewayEndpoints, resolveSeedRssImageRelationFromItem, resolveSeedRssImageRelationRef, seedGatewayConfigFromClientContext, seedGatewayConfigFromSeedConfig, setArweaveContentReadTransform, setPreferredArweaveReadBaseUrls, setResolvedSeedGatewayEndpoints, transformArweaveContent } from '@seedprotocol/arweave';
19
- export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-DtTPSzpM.js';
20
- import { a as getSegmentedItemProperties, g as getPublishDraftGraph, i as isSeedRevoked, f as findRelatedSeedRow, b as isUnpublishedSeed, h as htmlPropertyNameForHtmlSeed, r as relatedModelNameFromDef } from './publishDraftGraph-CuVq6iAR.js';
21
- export { P as PublishValidationFailedError, R as RELATED_ITEM_UNPUBLISHED_CODE, a as RelatedItemUnpublishedError, r as resolvePublishPayloadValues, v as validateItemForPublish } from './getPublishPayload-DPy-uMrR.js';
18
+ export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-DkLSDwUX.js';
19
+ import { a as getSegmentedItemProperties, g as getPublishDraftGraph, i as isSeedRevoked, f as findRelatedSeedRow, b as isUnpublishedSeed, h as htmlPropertyNameForHtmlSeed, r as relatedModelNameFromDef } from './publishDraftGraph-DGhC9ifI.js';
20
+ export { P as PublishValidationFailedError, R as RELATED_ITEM_UNPUBLISHED_CODE, a as RelatedItemUnpublishedError, r as resolvePublishPayloadValues, v as validateItemForPublish } from './getPublishPayload-CwNOhnir.js';
22
21
  import 'pluralize';
23
- export { getPublishUploadData, itemHasPublishUploadCandidates } from './getPublishUploads-J-143iSV.js';
24
- import { parseFragment } from 'parse5';
22
+ import { g as getRelatedDraftsCoPublishedWith, f as findEmbeddedImageFilePath } from './getPublishUploads-pEOrXJbF.js';
23
+ export { H as HTML_EMBEDDED_MAX_IMAGES_PER_DOC, a as HTML_EMBEDDED_MAX_IMAGE_BYTES, b as HTML_EMBEDDED_MAX_TOTAL_BYTES, c as HtmlEmbeddedDataUriLimitError, d as HtmlSeedPropertyRefError, S as SEED_PROPERTY_REF_PREFIX, e as clearHtmlEmbeddedImageCoPublishRows, h as extractDataUriImagesFromHtml, i as findSeedPropertyRefsInHtml, j as getPublishUploadData, k as itemHasPublishUploadCandidates, p as prepareHtmlEmbeddedImagesForPublish, r as replaceDataUrisInParsedHtml, l as replaceSeedPropertyRefsInHtml, m as resolveEffectiveHtmlEmbeddedDataUriPolicy, n as rewriteHtmlEmbeddedImagesOnDisk } from './getPublishUploads-pEOrXJbF.js';
25
24
  import 'js-yaml';
26
25
  import 'fs';
27
26
  import 'xstate';
@@ -37,9 +36,10 @@ import '@noble/hashes/sha3';
37
36
  import '@noble/hashes/utils';
38
37
  import 'lodash-es';
39
38
  import 'rxjs';
40
- import './SchemaValidationService-BNYMacsx.js';
39
+ import './SchemaValidationService-CzybXLiS.js';
41
40
  import '@sinclair/typebox/value';
42
- import './mimeTypes-DHAHC4eZ.js';
41
+ import 'parse5';
42
+ import './mimeTypes-C9r76DCH.js';
43
43
 
44
44
  /**
45
45
  * Updates the version record with the attestation UID after a Version attestation is created.
@@ -472,9 +472,11 @@ async function getAttesterForSeed(params) {
472
472
  }
473
473
 
474
474
  /**
475
- * After L1 confirmation, updates local `metadata` rows that still reference the ANS-104
476
- * DataItem id with the L1 bundle transaction id (for gateway URLs / validation). Does not
477
- * change on-chain attestations.
475
+ * @deprecated Don't use: it makes the local value differ from the attested one. It replaces
476
+ * local `metadata` rows' ANS-104 data item id with the L1 bundle transaction id, but the
477
+ * attestation holds the data item id, gateways serve a bundled data item by its own id, and
478
+ * `/raw/<bundle>` returns the whole bundle. Publish no longer calls it;
479
+ * restoreDataItemIdsOverwrittenByL1 undoes it.
478
480
  */
479
481
  async function applyArweaveL1TransactionIdLocal(params) {
480
482
  const { seedLocalId, versionLocalId, dataItemId, l1TransactionId } = params;
@@ -512,6 +514,59 @@ async function applyArweaveL1TransactionIdLocal(params) {
512
514
  }
513
515
  }
514
516
 
517
+ /**
518
+ * Undo what the bundler L1-finalize worker used to do: once a bundle was confirmed, it replaced
519
+ * the `storage_transaction_id` rows' data item id with the bundle's L1 transaction id. The
520
+ * attestation holds the data item id, and `/raw/<bundle>` returns the whole bundle, so the local
521
+ * value was wrong. The worker no longer does this; this sets rows it changed back, from the
522
+ * confirmed jobs in `arweave_l1_finalize_jobs`.
523
+ *
524
+ * Only when a seed's version has one job in that bundle: with several, the rows all hold the same
525
+ * bundle id and can't be matched to their data items, so they are counted as ambiguous and left.
526
+ */
527
+ async function restoreDataItemIdsOverwrittenByL1() {
528
+ const appDb = BaseDb.getAppDb();
529
+ const jobs = await appDb
530
+ .select()
531
+ .from(arweaveL1FinalizeJobs)
532
+ .where(and(eq(arweaveL1FinalizeJobs.phase, 'confirmed'), isNotNull(arweaveL1FinalizeJobs.l1TransactionId)));
533
+ const groups = new Map();
534
+ for (const job of jobs) {
535
+ if (!job.l1TransactionId || job.l1TransactionId === job.dataItemId)
536
+ continue;
537
+ const key = `${job.seedLocalId}|${job.versionLocalId ?? ''}|${job.l1TransactionId}`;
538
+ groups.set(key, [...(groups.get(key) ?? []), job]);
539
+ }
540
+ let restored = 0;
541
+ let ambiguous = 0;
542
+ for (const group of groups.values()) {
543
+ const job = group[0];
544
+ const l1 = job.l1TransactionId;
545
+ const where = and(eq(metadata.seedLocalId, job.seedLocalId), job.versionLocalId ? eq(metadata.versionLocalId, job.versionLocalId) : isNull(metadata.versionLocalId), eq(metadata.propertyValue, l1), or(eq(metadata.propertyName, 'storage_transaction_id'), eq(metadata.propertyName, 'storageTransactionId')));
546
+ const rows = await appDb.select().from(metadata).where(where);
547
+ if (rows.length === 0)
548
+ continue;
549
+ if (group.length > 1) {
550
+ ambiguous += 1;
551
+ continue;
552
+ }
553
+ for (const row of rows) {
554
+ const swap = (value) => (value ? value.split(l1).join(job.dataItemId) : value);
555
+ await appDb
556
+ .update(metadata)
557
+ .set({
558
+ propertyValue: job.dataItemId,
559
+ refResolvedValue: swap(row.refResolvedValue),
560
+ refResolvedDisplayValue: swap(row.refResolvedDisplayValue),
561
+ updatedAt: Date.now(),
562
+ })
563
+ .where(eq(metadata.localId, row.localId));
564
+ restored += 1;
565
+ }
566
+ }
567
+ return { restored, ambiguous };
568
+ }
569
+
515
570
  /**
516
571
  * Collects all items that will be in the publish payload (main item + related items from
517
572
  * relations and lists). Used by ensureEasSchemas to register schemas for nested items.
@@ -525,7 +580,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
525
580
  visited.add(seedLocalId);
526
581
  const result = [];
527
582
  const { itemRelationProperties, itemImageProperties, itemListProperties } = await getSegmentedItemProperties(item);
528
- const getItemMod = await import('./getItem-9bYSErSj.js');
583
+ const getItemMod = await import('./getItem-BUs1Xa48.js');
529
584
  const { getItem } = getItemMod;
530
585
  const processRelationOrImage = async (prop) => {
531
586
  const snapshot = prop.getService().getSnapshot();
@@ -544,7 +599,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
544
599
  if (!value && prop.propertyName && isStorageSeed) {
545
600
  const ctx = context;
546
601
  if (ctx.seedLocalId || ctx.seedUid) {
547
- const _mod_0 = await import('./Item-BUUFuywT.js');
602
+ const _mod_0 = await import('./Item-BDmsdNTQ.js');
548
603
  const _ns_0 = _mod_0.a5;
549
604
  const { getPropertyData } = _ns_0;
550
605
  const meta = await getPropertyData({
@@ -603,471 +658,6 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
603
658
  return result;
604
659
  }
605
660
 
606
- const HTML_EMBEDDED_MAX_IMAGES_PER_DOC = 50;
607
- const HTML_EMBEDDED_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
608
- const HTML_EMBEDDED_MAX_TOTAL_BYTES = 25 * 1024 * 1024;
609
- const DATA_URI_IMAGE = /^data:(image\/[a-zA-Z0-9.+-]+);base64,([\s\S]*)$/i;
610
- const MIME_NORMALIZE = {
611
- 'image/jpg': 'image/jpeg',
612
- };
613
- function normalizeMime(m) {
614
- const lower = m.toLowerCase().trim();
615
- return MIME_NORMALIZE[lower] ?? lower;
616
- }
617
- const ALLOWED_MIMES = new Set([
618
- 'image/png',
619
- 'image/jpeg',
620
- 'image/webp',
621
- 'image/gif',
622
- 'image/svg+xml',
623
- ]);
624
- class HtmlEmbeddedDataUriLimitError extends Error {
625
- constructor(message) {
626
- super(message);
627
- this.name = 'HtmlEmbeddedDataUriLimitError';
628
- }
629
- }
630
- function resolveEffectiveHtmlEmbeddedDataUriPolicy(propertyDef, publishLevel) {
631
- const fromProp = propertyDef?.htmlEmbeddedDataUriPolicy;
632
- if (fromProp === 'materialize' || fromProp === 'preserve')
633
- return fromProp;
634
- if (publishLevel === 'materialize' || publishLevel === 'preserve')
635
- return publishLevel;
636
- return 'materialize';
637
- }
638
- function getAttr(node, name) {
639
- const a = node.attrs?.find((x) => x.name === name);
640
- return a?.value;
641
- }
642
- /**
643
- * Walk fragment tree; collect unique data:image base64 URIs with limits.
644
- */
645
- async function extractDataUriImagesFromHtml(html) {
646
- const fragment = parseFragment(html);
647
- const found = [];
648
- const seenUris = new Set();
649
- let totalBytes = 0;
650
- const walk = async (node) => {
651
- if (node.nodeName === '#text' || node.nodeName === '#comment')
652
- return;
653
- const el = node;
654
- if (el.tagName === 'img') {
655
- const src = getAttr(el, 'src')?.trim();
656
- if (src && src.startsWith('data:image/')) {
657
- const m = DATA_URI_IMAGE.exec(src);
658
- if (m) {
659
- const mimeRaw = normalizeMime(m[1]);
660
- if (!ALLOWED_MIMES.has(mimeRaw)) {
661
- throw new HtmlEmbeddedDataUriLimitError(`Unsupported embedded image type: ${mimeRaw}. Allowed: ${[...ALLOWED_MIMES].join(', ')}`);
662
- }
663
- let binary;
664
- try {
665
- const b64 = m[2].replace(/\s/g, '');
666
- binary = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
667
- }
668
- catch {
669
- throw new HtmlEmbeddedDataUriLimitError('Invalid base64 in embedded image data URI');
670
- }
671
- const byteLength = binary.byteLength;
672
- if (byteLength > HTML_EMBEDDED_MAX_IMAGE_BYTES) {
673
- throw new HtmlEmbeddedDataUriLimitError(`Embedded image exceeds max size (${HTML_EMBEDDED_MAX_IMAGE_BYTES} bytes)`);
674
- }
675
- totalBytes += byteLength;
676
- if (totalBytes > HTML_EMBEDDED_MAX_TOTAL_BYTES) {
677
- throw new HtmlEmbeddedDataUriLimitError(`Total embedded image size exceeds max (${HTML_EMBEDDED_MAX_TOTAL_BYTES} bytes)`);
678
- }
679
- if (!seenUris.has(src)) {
680
- if (seenUris.size >= HTML_EMBEDDED_MAX_IMAGES_PER_DOC) {
681
- throw new HtmlEmbeddedDataUriLimitError(`Too many distinct embedded images (max ${HTML_EMBEDDED_MAX_IMAGES_PER_DOC})`);
682
- }
683
- seenUris.add(src);
684
- const stableKey = await getContentHash(binary);
685
- found.push({ dataUri: src, stableKey, byteLength, mimeType: mimeRaw });
686
- }
687
- }
688
- }
689
- }
690
- const parent = el;
691
- if (parent.childNodes) {
692
- for (const c of parent.childNodes)
693
- await walk(c);
694
- }
695
- };
696
- for (const c of fragment.childNodes)
697
- await walk(c);
698
- return found;
699
- }
700
- function escapeAttributeValue(value) {
701
- return value.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
702
- }
703
- /**
704
- * Rewrite attribute values of `html` by splicing each new value into the original string: every
705
- * byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would
706
- * not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,
707
- * a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),
708
- * and sealed Html must not change with the serializer.
709
- *
710
- * `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to
711
- * leave it. A rewritten attribute is written as `name="value"`.
712
- */
713
- function rewriteHtmlAttributes(html, rewrite) {
714
- const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
715
- const edits = [];
716
- const walk = (node) => {
717
- if (node.nodeName === '#text' || node.nodeName === '#comment')
718
- return;
719
- const el = node;
720
- if (el.attrs?.length) {
721
- for (const attr of el.attrs) {
722
- if (attr.prefix)
723
- continue;
724
- const next = rewrite(el, attr.name, attr.value);
725
- const location = el.sourceCodeLocation?.attrs?.[attr.name];
726
- if (next === undefined || !location)
727
- continue;
728
- edits.push({
729
- start: location.startOffset,
730
- end: location.endOffset,
731
- text: `${attr.name}="${escapeAttributeValue(next)}"`,
732
- });
733
- }
734
- }
735
- const parent = el;
736
- if (parent.childNodes) {
737
- for (const c of parent.childNodes)
738
- walk(c);
739
- }
740
- };
741
- for (const c of fragment.childNodes)
742
- walk(c);
743
- let out = html;
744
- for (const edit of edits.sort((a, b) => b.start - a.start)) {
745
- out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
746
- }
747
- return out;
748
- }
749
- /**
750
- * Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those
751
- * `src` attributes change; the rest of the Html is kept byte for byte.
752
- */
753
- function replaceDataUrisInParsedHtml(html, replacements) {
754
- if (replacements.size === 0)
755
- return html;
756
- return rewriteHtmlAttributes(html, (el, attrName, value) => {
757
- if (el.tagName !== 'img' || attrName !== 'src')
758
- return undefined;
759
- return replacements.get(value.trim());
760
- });
761
- }
762
- /**
763
- * `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's
764
- * `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,
765
- * then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a
766
- * file published alongside it without embedding it (e.g. `<img class="u-featured"
767
- * src="seed:property/featureImage">`).
768
- */
769
- const SEED_PROPERTY_REF_PREFIX = 'seed:property/';
770
- const SEED_PROPERTY_REF = /^seed:property\/([A-Za-z_$][A-Za-z0-9_$]*)$/;
771
- /** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */
772
- const SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster']);
773
- const seedPropertyRefName = (attrName, value) => SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined;
774
- /** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */
775
- class HtmlSeedPropertyRefError extends Error {
776
- constructor(message) {
777
- super(message);
778
- this.name = 'HtmlSeedPropertyRefError';
779
- }
780
- }
781
- /** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */
782
- function findSeedPropertyRefsInHtml(html) {
783
- if (!html.includes(SEED_PROPERTY_REF_PREFIX))
784
- return [];
785
- const names = new Set();
786
- rewriteHtmlAttributes(html, (_el, attrName, value) => {
787
- const name = seedPropertyRefName(attrName, value);
788
- if (name)
789
- names.add(name);
790
- return undefined;
791
- });
792
- return [...names];
793
- }
794
- /** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */
795
- function replaceSeedPropertyRefsInHtml(html, urlByPropertyName) {
796
- if (urlByPropertyName.size === 0)
797
- return html;
798
- return rewriteHtmlAttributes(html, (_el, attrName, value) => {
799
- const name = seedPropertyRefName(attrName, value);
800
- return name ? urlByPropertyName.get(name) : undefined;
801
- });
802
- }
803
- const SEED_PROPERTY_REF_DATA_TYPES = [
804
- ModelPropertyDataTypes.Image,
805
- ModelPropertyDataTypes.File,
806
- ModelPropertyDataTypes.Json,
807
- ];
808
- /**
809
- * The storage property of `item` a `seed:property/<name>` placeholder names, and the seed it holds.
810
- * Html properties are refused: an Html seed may itself be deferred to after the rewrite.
811
- */
812
- function resolveSeedPropertyRefTarget(item, propertyName) {
813
- const property = item.properties.find((p) => p.propertyName === propertyName || p.propertyName === `${propertyName}Id`);
814
- const def = property?.propertyDef;
815
- if (!property || !def) {
816
- throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${item.modelName} has no property ${propertyName}`);
817
- }
818
- const dataType = normalizeDataTypeLocal(def.dataType);
819
- const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataTypeLocal(def.refValueType) : dataType;
820
- if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {
821
- throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +
822
- `only Image, File and Json properties can be referenced`);
823
- }
824
- const snap = property.getService().getSnapshot();
825
- const ctx = 'context' in snap ? snap.context : null;
826
- const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(ctx?.propertyValue) ?? '');
827
- if (!ids.seedLocalId && !ids.seedUid) {
828
- throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`);
829
- }
830
- return ids;
831
- }
832
- const ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i;
833
- /**
834
- * The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,
835
- * when not uploaded now, the transaction it was published with (its storageTransactionId).
836
- */
837
- async function resolveSeedPropertyRefTxId(item, propertyName, txBySeedLocalId) {
838
- const { seedLocalId, seedUid } = resolveSeedPropertyRefTarget(item, propertyName);
839
- const uploaded = seedLocalId ? txBySeedLocalId.get(seedLocalId) : undefined;
840
- if (uploaded)
841
- return uploaded;
842
- const storageItem = await Item.find({ seedLocalId, seedUid });
843
- const st = storageItem?.internalProperties['storageTransactionId'] ??
844
- storageItem?.allProperties['storageTransactionId'];
845
- const stSnap = st?.getService().getSnapshot();
846
- const stValue = stSnap && 'context' in stSnap ? stSnap.context.propertyValue : undefined;
847
- if (typeof stValue === 'string' && ARWEAVE_TX_ID.test(stValue.trim()))
848
- return stValue.trim();
849
- throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +
850
- `in this publish and has no published transaction`);
851
- }
852
- async function deleteCoPublishRowsForParent(appDb, parentSeedLocalId) {
853
- if (!appDb)
854
- return;
855
- await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId));
856
- }
857
- /**
858
- * Create an Image item and persist a data URI into its storageTransactionId (same path as user paste).
859
- */
860
- async function createImageItemFromDataUri(dataUri) {
861
- const imageItem = await Item.create({
862
- modelName: 'Image',
863
- modelFileId: INTERNAL_STORAGE_MODEL_FILE_IDS.image,
864
- });
865
- await waitForEntityIdle(imageItem, { timeout: 60000 });
866
- const st = imageItem.internalProperties['storageTransactionId'] ??
867
- imageItem.allProperties['storageTransactionId'];
868
- if (!st) {
869
- throw new Error('Image item missing storageTransactionId property');
870
- }
871
- st.value = dataUri;
872
- await st.save();
873
- await waitForEntityIdle(imageItem, { timeout: 60000 });
874
- return { seedLocalId: imageItem.seedLocalId };
875
- }
876
- /**
877
- * Scan Html storage properties, materialize embedded images as Image items, insert co-publish rows.
878
- * Call before phase-1 Arweave tx build. Does not rewrite Html files yet.
879
- */
880
- async function prepareHtmlEmbeddedImagesForPublish(item, publishPolicy) {
881
- const appDb = BaseDb.getAppDb();
882
- if (!appDb) {
883
- return { deferredHtmlSeedLocalIds: [] };
884
- }
885
- const deferred = new Set();
886
- // The item's own Html, and the Html of the draft items published with it: each gets its embedded
887
- // images materialized and co-published (rows keyed by the item owning the Html property).
888
- for (const parent of [item, ...(await getRelatedDraftsCoPublishedWith(item))]) {
889
- await prepareHtmlEmbeddedImagesOfItem(appDb, parent, publishPolicy, deferred);
890
- }
891
- return { deferredHtmlSeedLocalIds: [...deferred] };
892
- }
893
- /**
894
- * Draft items (no seed uid yet) that a publish of `item` publishes with it: every draft reachable
895
- * through relation and list properties, as getPublishPayload and getPublishUploads walk them
896
- * (publishDraftGraph.ts). Html-embedded images of these items are co-published with `item` like its own.
897
- */
898
- async function getRelatedDraftsCoPublishedWith(item) {
899
- const _mod_1 = await import('./publishDraftGraph-CuVq6iAR.js');
900
- const _ns_1 = _mod_1.p;
901
- const { getPublishDraftGraph } = _ns_1;
902
- const { drafts } = await getPublishDraftGraph(item);
903
- return drafts.map((d) => d.item);
904
- }
905
- async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, deferred) {
906
- await deleteCoPublishRowsForParent(appDb, item.seedLocalId);
907
- for (const p of item.properties) {
908
- const def = p.propertyDef;
909
- if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
910
- continue;
911
- const snap = p.getService().getSnapshot();
912
- const ctx = 'context' in snap ? snap.context : null;
913
- const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue : '';
914
- const refResolved = ctx?.refResolvedValue;
915
- if (!htmlSeedLocalId?.trim() || !refResolved)
916
- continue;
917
- const filePath = `${BaseFileManager.getFilesPath('html')}/${refResolved}`;
918
- const exists = await BaseFileManager.pathExists(filePath);
919
- if (!exists)
920
- continue;
921
- let html;
922
- try {
923
- html = await BaseFileManager.readFileAsString(filePath);
924
- }
925
- catch {
926
- const buf = await BaseFileManager.readFileAsBuffer(filePath);
927
- if (typeof Buffer !== 'undefined' && Buffer.isBuffer(buf)) {
928
- html = buf.toString('utf-8');
929
- }
930
- else if (typeof Blob !== 'undefined' && buf instanceof Blob) {
931
- html = await buf.text();
932
- }
933
- else if (buf instanceof ArrayBuffer) {
934
- html = new TextDecoder('utf-8', { fatal: false }).decode(buf);
935
- }
936
- else {
937
- const v = buf;
938
- html = new TextDecoder('utf-8', { fatal: false }).decode(new Uint8Array(v.buffer, v.byteOffset, v.byteLength));
939
- }
940
- }
941
- // seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A
942
- // placeholder naming no usable property fails here, before anything is uploaded.
943
- const refs = findSeedPropertyRefsInHtml(html);
944
- for (const name of refs)
945
- resolveSeedPropertyRefTarget(item, name);
946
- if (refs.length > 0)
947
- deferred.add(htmlSeedLocalId.trim());
948
- const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(def, publishPolicy);
949
- if (policy !== 'materialize')
950
- continue;
951
- const extracted = await extractDataUriImagesFromHtml(html);
952
- if (extracted.length === 0)
953
- continue;
954
- deferred.add(htmlSeedLocalId.trim());
955
- for (const ent of extracted) {
956
- const { seedLocalId: imageSeedLocalId } = await createImageItemFromDataUri(ent.dataUri);
957
- const now = Date.now();
958
- await appDb.insert(htmlEmbeddedImageCoPublish).values({
959
- parentSeedLocalId: item.seedLocalId,
960
- htmlSeedLocalId: htmlSeedLocalId.trim(),
961
- imageSeedLocalId,
962
- stableKey: ent.stableKey,
963
- createdAt: now,
964
- }).onConflictDoNothing();
965
- }
966
- }
967
- }
968
- function normalizeDataTypeLocal(dt) {
969
- if (!dt)
970
- return '';
971
- return dt.charAt(0).toUpperCase() + dt.slice(1).toLowerCase();
972
- }
973
- /**
974
- * After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and
975
- * `seed:property/<name>` → the gateway URL of that property's upload.
976
- *
977
- * `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to
978
- * the Html held back from phase 1; without it, every Html of the item and its co-published drafts is
979
- * considered.
980
- */
981
- async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions, deferredHtmlSeedLocalIds) {
982
- const appDb = BaseDb.getAppDb();
983
- if (!appDb)
984
- return;
985
- const parentItem = await Item.find({ seedLocalId: parentSeedLocalId });
986
- if (!parentItem)
987
- return;
988
- const txBySeedLocalId = new Map();
989
- for (const u of uploadedTransactions) {
990
- if (u.seedLocalId && u.txId) {
991
- txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim());
992
- }
993
- }
994
- const deferred = deferredHtmlSeedLocalIds
995
- ? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))
996
- : undefined;
997
- // The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).
998
- for (const item of [parentItem, ...(await getRelatedDraftsCoPublishedWith(parentItem))]) {
999
- await rewriteHtmlEmbeddedImagesOfItem(appDb, item, txBySeedLocalId, deferred);
1000
- }
1001
- }
1002
- async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem, txBySeedLocalId, deferred) {
1003
- const rows = await appDb
1004
- .select()
1005
- .from(htmlEmbeddedImageCoPublish)
1006
- .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentItem.seedLocalId));
1007
- for (const p of parentItem.properties) {
1008
- const def = p.propertyDef;
1009
- if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
1010
- continue;
1011
- const snap = p.getService().getSnapshot();
1012
- const ctx = 'context' in snap ? snap.context : null;
1013
- const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue.trim() : '';
1014
- const refResolved = ctx?.refResolvedValue;
1015
- if (!htmlSeedLocalId || !refResolved)
1016
- continue;
1017
- if (deferred && !deferred.has(htmlSeedLocalId))
1018
- continue;
1019
- const htmlRows = rows.filter((r) => String(r.htmlSeedLocalId).trim() === htmlSeedLocalId);
1020
- const filePath = `${BaseFileManager.getFilesPath('html')}/${refResolved}`;
1021
- if (!(await BaseFileManager.pathExists(filePath)))
1022
- continue;
1023
- const html = await BaseFileManager.readFileAsString(filePath);
1024
- const replacements = new Map();
1025
- for (const r of htmlRows) {
1026
- const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim());
1027
- if (!txId)
1028
- continue;
1029
- const dataUri = await findDataUriForStableKey(html, r.stableKey);
1030
- if (dataUri)
1031
- replacements.set(dataUri, getArweaveUrlForTransaction(txId));
1032
- }
1033
- const urlByPropertyName = new Map();
1034
- for (const name of findSeedPropertyRefsInHtml(html)) {
1035
- const txId = await resolveSeedPropertyRefTxId(parentItem, name, txBySeedLocalId);
1036
- urlByPropertyName.set(name, getArweaveUrlForTransaction(txId));
1037
- }
1038
- const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName);
1039
- if (newHtml === html)
1040
- continue;
1041
- try {
1042
- await BaseFileManager.saveFile(filePath, newHtml);
1043
- }
1044
- catch {
1045
- const fs = await BaseFileManager.getFs();
1046
- fs.writeFileSync(filePath, newHtml);
1047
- }
1048
- p.getService().send({
1049
- type: 'updateContext',
1050
- renderValue: newHtml,
1051
- });
1052
- }
1053
- }
1054
- async function findDataUriForStableKey(html, stableKey) {
1055
- const entries = await extractDataUriImagesFromHtml(html);
1056
- const hit = entries.find((e) => e.stableKey === stableKey);
1057
- return hit?.dataUri;
1058
- }
1059
- /**
1060
- * Remove co-publish rows after a successful publish for this parent seed.
1061
- */
1062
- async function clearHtmlEmbeddedImageCoPublishRows(parentSeedLocalId) {
1063
- const appDb = BaseDb.getAppDb();
1064
- if (!appDb || !parentSeedLocalId)
1065
- return;
1066
- await appDb
1067
- .delete(htmlEmbeddedImageCoPublish)
1068
- .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId.trim()));
1069
- }
1070
-
1071
661
  /**
1072
662
  * Counts seeds, property attestations, and Arweave upload bytes for a publish
1073
663
  * without building transactions or requiring a valid payload.
@@ -1146,6 +736,7 @@ async function addUpload(acc, seen, key, bytes) {
1146
736
  seen.add(key);
1147
737
  acc.uploadCount += 1;
1148
738
  acc.uploadBytes += bytes;
739
+ acc.uploadSizes.push(bytes);
1149
740
  }
1150
741
  async function addUploadFromPath(acc, seen, filePath, key) {
1151
742
  if (!filePath || filePath.endsWith('undefined'))
@@ -1201,7 +792,7 @@ async function loadRelatedItem(value) {
1201
792
  const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalized);
1202
793
  if (!seedLocalId && !seedUid)
1203
794
  return undefined;
1204
- const { getItem } = await import('./getItem-9bYSErSj.js');
795
+ const { getItem } = await import('./getItem-BUs1Xa48.js');
1205
796
  try {
1206
797
  return await getItem({ seedLocalId, seedUid });
1207
798
  }
@@ -1297,9 +888,9 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
1297
888
  .from(htmlEmbeddedImageCoPublish)
1298
889
  .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId));
1299
890
  for (const row of rows) {
1300
- const _mod_2 = await import('./Item-BUUFuywT.js');
1301
- const _ns_2 = _mod_2.a6;
1302
- const { Item } = _ns_2;
891
+ const _mod_1 = await import('./Item-BDmsdNTQ.js');
892
+ const _ns_1 = _mod_1.a6;
893
+ const { Item } = _ns_1;
1303
894
  const imageItem = await Item.find({
1304
895
  seedLocalId: row.imageSeedLocalId,
1305
896
  modelName: 'Image',
@@ -1308,14 +899,9 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
1308
899
  // and reported by collectUnpublishedEmbeddedImages) is not co-published.
1309
900
  if (!imageItem || !isZeroUid(imageItem.seedUid))
1310
901
  continue;
1311
- const st = imageItem.internalProperties['storageTransactionId'] ??
1312
- imageItem.allProperties['storageTransactionId'];
1313
- const stCtx = st ? propertyContext(st) : null;
1314
- const stValue = typeof stCtx?.propertyValue === 'string' ? stCtx.propertyValue : '';
1315
- const dataUriBytes = estimateDataUriByteLength(stValue);
1316
- if (dataUriBytes != null && dataUriBytes > 0) {
1317
- await addUpload(acc, seen, `seed:${imageItem.seedLocalId}`, dataUriBytes);
1318
- }
902
+ const filePath = await findEmbeddedImageFilePath(imageItem.seedLocalId);
903
+ if (filePath)
904
+ await addUploadFromPath(acc, seen, filePath, `seed:${imageItem.seedLocalId}`);
1319
905
  await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited, graph);
1320
906
  }
1321
907
  }
@@ -1407,6 +993,7 @@ const summarizePublishWork = async (item, options) => {
1407
993
  attestationCount: 0,
1408
994
  uploadCount: 0,
1409
995
  uploadBytes: 0,
996
+ uploadSizes: [],
1410
997
  unpublishedRelatedItems: [],
1411
998
  };
1412
999
  const graph = await getPublishDraftGraph(item, { forceFullSnapshot });
@@ -1423,5 +1010,5 @@ const summarizePublishWork = async (item, options) => {
1423
1010
  return acc;
1424
1011
  };
1425
1012
 
1426
- export { BaseDb, BaseFileManager, BaseFileManager as FileManager, HTML_EMBEDDED_MAX_IMAGES_PER_DOC, HTML_EMBEDDED_MAX_IMAGE_BYTES, HTML_EMBEDDED_MAX_TOTAL_BYTES, HtmlEmbeddedDataUriLimitError, HtmlSeedPropertyRefError, Item, ModelPropertyDataTypes, SEED_PROPERTY_REF_PREFIX, applyArweaveL1TransactionIdLocal, applyPropertyAttestationUidsFromPublish, clearHtmlEmbeddedImageCoPublishRows, compareMetadataRowsLatestFirst, estimateDataUriByteLength, extractDataUriImagesFromHtml, findSeedPropertyRefsInHtml, generateId, getArweaveUrlForTransaction, getAttesterForSeed, getMetadataAttestationUidsForSeedUid, getPublishDraftGraph, getPublishPendingDiff, getRelatedItemsForPublish, getSeedPublishState, getSegmentedItemProperties, getUnpublishedRelatedItems, getVersionsForSeedUid, htmlEmbeddedImageCoPublish, isDataType, metadata, normalizeDataType, normalizePublisher, normalizeRelationPropertyValue, prepareHtmlEmbeddedImagesForPublish, replaceDataUrisInParsedHtml, replaceSeedPropertyRefsInHtml, resolveEffectiveHtmlEmbeddedDataUriPolicy, resolveSeedIdsFromRefString, rewriteHtmlEmbeddedImagesOnDisk, seeds, shouldAttestProperty, summarizePublishWork, updateVersionUid, versions, waitForEntityIdle };
1013
+ export { BaseDb, BaseFileManager, BaseFileManager as FileManager, ModelPropertyDataTypes, applyArweaveL1TransactionIdLocal, applyPropertyAttestationUidsFromPublish, arweaveL1FinalizeJobs, compareMetadataRowsLatestFirst, estimateDataUriByteLength, generateId, getAttesterForSeed, getMetadataAttestationUidsForSeedUid, getPublishDraftGraph, getPublishPendingDiff, getRelatedItemsForPublish, getSeedPublishState, getSegmentedItemProperties, getUnpublishedRelatedItems, getVersionsForSeedUid, htmlEmbeddedImageCoPublish, isDataType, metadata, normalizeDataType, normalizePublisher, normalizeRelationPropertyValue, resolveSeedIdsFromRefString, restoreDataItemIdsOverwrittenByL1, seeds, shouldAttestProperty, summarizePublishWork, updateVersionUid, versions };
1427
1014
  //# sourceMappingURL=main.js.map