@seedprotocol/sdk 0.7.0 → 0.7.1
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.
- package/dist/{BasePathResolver-ndE8XTpw.js → BasePathResolver-DRT09oVv.js} +2 -2
- package/dist/{BasePathResolver-ndE8XTpw.js.map → BasePathResolver-DRT09oVv.js.map} +1 -1
- package/dist/{ClientManager-DLleL_2e.js → ClientManager-DngaZdw6.js} +20 -20
- package/dist/{ClientManager-DLleL_2e.js.map → ClientManager-DngaZdw6.js.map} +1 -1
- package/dist/{Item-zBFWQDU9.js → Item-ZUAmf943.js} +118 -72
- package/dist/{Item-zBFWQDU9.js.map → Item-ZUAmf943.js.map} +1 -1
- package/dist/{ModelProperty-lth9L37R.js → ModelProperty-6llK4MTH.js} +64 -35
- package/dist/ModelProperty-6llK4MTH.js.map +1 -0
- package/dist/{Schema-DOhlrQ-N.js → Schema-D-Ud-XYw.js} +106 -57
- package/dist/Schema-D-Ud-XYw.js.map +1 -0
- package/dist/{SchemaValidationService-DDKr5piy.js → SchemaValidationService-IoS7JquP.js} +7 -7
- package/dist/{SchemaValidationService-DDKr5piy.js.map → SchemaValidationService-IoS7JquP.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js → backfillMetadataPropertyIds-BlVeE7w7.js} +4 -4
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js.map → backfillMetadataPropertyIds-BlVeE7w7.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BEsIHAjk.js → ModelProperty-Dv7AQfmQ.js} +59 -30
- package/dist/cjs/ModelProperty-Dv7AQfmQ.js.map +1 -0
- package/dist/cjs/{Schema-qEp5mH1N.js → Schema-BHVp1g-M.js} +93 -44
- package/dist/cjs/Schema-BHVp1g-M.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js → SchemaValidationService-BSU9knjf.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js.map → SchemaValidationService-BSU9knjf.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js → backfillMetadataPropertyIds-WIovQ_d8.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js.map → backfillMetadataPropertyIds-WIovQ_d8.js.map} +1 -1
- package/dist/cjs/{eas-CLiV2Hmn.js → eas-CUYXdr2t.js} +3 -3
- package/dist/cjs/{eas-CLiV2Hmn.js.map → eas-CUYXdr2t.js.map} +1 -1
- package/dist/cjs/{getItem-DSRtx_68.js → getItem-z1tHu0hu.js} +2 -2
- package/dist/cjs/{getItem-DSRtx_68.js.map → getItem-z1tHu0hu.js.map} +1 -1
- package/dist/cjs/{getLatestVersionRow-DVizNNoI.js → getLatestVersionRow-CcaabxIW.js} +2 -2
- package/dist/cjs/{getLatestVersionRow-DVizNNoI.js.map → getLatestVersionRow-CcaabxIW.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-D5-dYtNq.js → getPublishPayload-CEP_e-Kv.js} +160 -204
- package/dist/cjs/getPublishPayload-CEP_e-Kv.js.map +1 -0
- package/dist/cjs/{getPublishUploads-B5Lq6q-_.js → getPublishUploads-Ctn5k1k6.js} +49 -10
- package/dist/cjs/getPublishUploads-Ctn5k1k6.js.map +1 -0
- package/dist/cjs/{index-C66AfYDG.js → index-Cvvt0-5B.js} +244 -87
- package/dist/cjs/index-Cvvt0-5B.js.map +1 -0
- package/dist/cjs/{index-B3UDbm1C.js → index-DfGhF1dc.js} +3 -3
- package/dist/cjs/index-DfGhF1dc.js.map +1 -0
- package/dist/cjs/{property-BVJIP7SX.js → property-DbEPQ1m9.js} +5 -5
- package/dist/cjs/{property-BVJIP7SX.js.map → property-DbEPQ1m9.js.map} +1 -1
- package/dist/cjs/publishDraftGraph-C38gf302.js +403 -0
- package/dist/cjs/publishDraftGraph-C38gf302.js.map +1 -0
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js → resetAmbiguousLegacyItemData-CfMhRHwK.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js.map → resetAmbiguousLegacyItemData-CfMhRHwK.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js → resolveModelForSyncedSeed-CNYaLOir.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js.map → resolveModelForSyncedSeed-CNYaLOir.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js → syncDbWithEas-d1iOdTTI.js} +20 -7
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js.map → syncDbWithEas-d1iOdTTI.js.map} +1 -1
- package/dist/{configurePlatform-BMoPG9vY.js → configurePlatform-CZpjyuCo.js} +4 -4
- package/dist/{configurePlatform-BMoPG9vY.js.map → configurePlatform-CZpjyuCo.js.map} +1 -1
- package/dist/{db-BJZN0a0a.js → db-Lw0KVZmc.js} +11 -11
- package/dist/{db-BJZN0a0a.js.map → db-Lw0KVZmc.js.map} +1 -1
- package/dist/{eas-B0hsMLqt.js → eas-CQ-Smzk2.js} +6 -6
- package/dist/{eas-B0hsMLqt.js.map → eas-CQ-Smzk2.js.map} +1 -1
- package/dist/{getItem-DEh4WfHG.js → getItem-CSfSok9f.js} +5 -5
- package/dist/{getItem-DEh4WfHG.js.map → getItem-CSfSok9f.js.map} +1 -1
- package/dist/{getLatestVersionRow-Brrl1AnW.js → getLatestVersionRow-72Atl9vB.js} +5 -5
- package/dist/{getLatestVersionRow-Brrl1AnW.js.map → getLatestVersionRow-72Atl9vB.js.map} +1 -1
- package/dist/{getPublishPayload-H032DHC7.js → getPublishPayload-76_KfB5Y.js} +155 -200
- package/dist/getPublishPayload-76_KfB5Y.js.map +1 -0
- package/dist/{getPublishUploads-CR66RlGJ.js → getPublishUploads-CqgMBD8f.js} +52 -13
- package/dist/getPublishUploads-CqgMBD8f.js.map +1 -0
- package/dist/{index-B0LgJblD.js → index-5b3JsS55.js} +2 -2
- package/dist/index-5b3JsS55.js.map +1 -0
- package/dist/{index-6bJuv5Tt.js → index-BpgD305l.js} +9 -9
- package/dist/{index-6bJuv5Tt.js.map → index-BpgD305l.js.map} +1 -1
- package/dist/{index-DtfjeuxC.js → index-Y-yYyRBf.js} +166 -75
- package/dist/index-Y-yYyRBf.js.map +1 -0
- package/dist/{index.browser-CNrqhvEA.js → index.browser-DaTzn79x.js} +9 -9
- package/dist/{index.browser-CNrqhvEA.js.map → index.browser-DaTzn79x.js.map} +1 -1
- package/dist/{index.node-DrHiTuOr.js → index.node-NYKqFOoe.js} +5 -5
- package/dist/{index.node-DrHiTuOr.js.map → index.node-NYKqFOoe.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +257 -181
- package/dist/main.js.map +1 -1
- package/dist/node.js +12 -12
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +3 -3
- package/dist/{property-D2Nnsmm1.js → property-ByaiSyUK.js} +10 -10
- package/dist/{property-D2Nnsmm1.js.map → property-ByaiSyUK.js.map} +1 -1
- package/dist/publishDraftGraph-BRm6Pq3Q.js +405 -0
- package/dist/publishDraftGraph-BRm6Pq3Q.js.map +1 -0
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js → resetAmbiguousLegacyItemData-B4dX6ZA1.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js.map → resetAmbiguousLegacyItemData-B4dX6ZA1.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js → resolveModelForSyncedSeed-B0tco3zG.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js.map → resolveModelForSyncedSeed-B0tco3zG.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +11 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +10 -0
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/Model/Model.d.ts +15 -2
- package/dist/src/Model/Model.d.ts.map +1 -1
- package/dist/src/Model/service/actors/createModelProperties.d.ts.map +1 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/src/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/src/Model/service/modelMachine.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +9 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/Schema/Schema.d.ts +7 -0
- package/dist/src/Schema/Schema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/createModelInstances.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts +9 -0
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +5 -0
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/publishDraftGraph.d.ts +57 -0
- package/dist/src/db/read/publishDraftGraph.d.ts.map +1 -0
- package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
- package/dist/src/helpers/entity/entityLiveQuery.d.ts.map +1 -1
- package/dist/src/helpers/entity/evictionEpoch.d.ts +18 -0
- package/dist/src/helpers/entity/evictionEpoch.d.ts.map +1 -0
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts +28 -6
- package/dist/src/helpers/htmlEmbeddedDataUriPublish.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/write/actors/validateEntity.d.ts.map +1 -1
- package/dist/src/types/item.d.ts +7 -8
- package/dist/src/types/item.d.ts.map +1 -1
- package/dist/{syncDbWithEas-LRKr_NZF.js → syncDbWithEas-BPap9Sru.js} +14 -14
- package/dist/{syncDbWithEas-LRKr_NZF.js.map → syncDbWithEas-BPap9Sru.js.map} +1 -1
- package/dist/{tabEvents-DYI2GU7i.js → tabEvents-C6NXS6Jl.js} +6 -6
- package/dist/{tabEvents-DYI2GU7i.js.map → tabEvents-C6NXS6Jl.js.map} +1 -1
- package/dist/{tolerantWebAccess-CzOBz5M6.js → tolerantWebAccess-NBQ1NB4i.js} +6 -6
- package/dist/{tolerantWebAccess-CzOBz5M6.js.map → tolerantWebAccess-NBQ1NB4i.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-B58ORbY3.js → updateSeedRevokedAt-CYwgVNlM.js} +3 -3
- package/dist/{updateSeedRevokedAt-B58ORbY3.js.map → updateSeedRevokedAt-CYwgVNlM.js.map} +1 -1
- package/package.json +8 -10
- package/dist/ModelProperty-lth9L37R.js.map +0 -1
- package/dist/Schema-DOhlrQ-N.js.map +0 -1
- package/dist/cjs/ModelProperty-BEsIHAjk.js.map +0 -1
- package/dist/cjs/Schema-qEp5mH1N.js.map +0 -1
- package/dist/cjs/getPublishPayload-D5-dYtNq.js.map +0 -1
- package/dist/cjs/getPublishUploads-B5Lq6q-_.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-giHO7R3d.js +0 -147
- package/dist/cjs/getSegmentedItemProperties-giHO7R3d.js.map +0 -1
- package/dist/cjs/index-B3UDbm1C.js.map +0 -1
- package/dist/cjs/index-C66AfYDG.js.map +0 -1
- package/dist/getPublishPayload-H032DHC7.js.map +0 -1
- package/dist/getPublishUploads-CR66RlGJ.js.map +0 -1
- package/dist/getSegmentedItemProperties-C2EJ2G0N.js +0 -147
- package/dist/getSegmentedItemProperties-C2EJ2G0N.js.map +0 -1
- package/dist/index-B0LgJblD.js.map +0 -1
- package/dist/index-DtfjeuxC.js.map +0 -1
- package/dist/src/browser/helpers/index.d.ts +0 -4
- package/dist/src/browser/helpers/index.d.ts.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
export { M as Model } from './index-
|
|
3
|
-
import { s as normalizePublisher, k as isDataType, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-
|
|
4
|
-
export { A as AmbiguousModelError,
|
|
5
|
-
export { getPropertySchema } from './property-
|
|
6
|
-
import { n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, b as getArweaveUrlForTransaction } from './tabEvents-
|
|
7
|
-
export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError, c as classifyMediaRef, d as closestImageSize, f as ensureImageLocal, g as getCorrectId, h as getFeedItemStringField, j as isLeaderTab, i as isPublishedSeedRef, k as normalizeArweaveTxIdForEnsure, l as normalizeFeedItemFields, p as parseAddressesPersistedPayload, m as resolveMediaRef, w as whenLeaderTab } from './tabEvents-
|
|
8
|
-
import { g as getContentHash } from './ClientManager-
|
|
9
|
-
export { E as EAS_CHAIN_ID_APP_STATE_KEY, a as assertLocalDbChain, c as claimUnpublishedDrafts, C as client, d as createLocalQueryDataSource, e as createSchema, f as easSyncActor, h as getClient, j as getPublishedSeedRecord, k as getSchemaNameFromId, i as importJsonSchema, m as isSeedQueryLocalSourceRegistered, n as listSchemas, o as loadAllSchemasFromDb, p as mergeEasSyncRequestIntents, r as readJsonImportFile, q as readSchema, u as registerSeedQueryLocalSource, v as requestEasSyncFromAddressChange, x as requestEasSyncFromEventBus, y as requestEasSyncFromModelsInit, z as sendEasSyncClientRequest, A as startEasSyncActor, s as syncSchemaFromSource, t as transformImportToSchemaFile, B as unregisterSeedQueryLocalSource } from './ClientManager-
|
|
10
|
-
import { i as isVersionRevoked, q as compareMetadataRowsLatestFirst, t as isPublishedMetadataRow,
|
|
11
|
-
export { C as ClientManagerState,
|
|
12
|
-
import { B as BaseDb, v as versions, r as seeds,
|
|
13
|
-
export { E as EAS_SEED_DATA_SYNCED_TO_DB_EVENT,
|
|
2
|
+
export { M as Model } from './index-Y-yYyRBf.js';
|
|
3
|
+
import { s as normalizePublisher, k as isDataType, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-Lw0KVZmc.js';
|
|
4
|
+
export { A as AmbiguousModelError, m as eventEmitter, z as getAddressesForItemsFilter, C as normalizeAddressConfig, E as normalizeAddressList, u as normalizeHexAddress } from './db-Lw0KVZmc.js';
|
|
5
|
+
export { getPropertySchema } from './property-ByaiSyUK.js';
|
|
6
|
+
import { n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, b as getArweaveUrlForTransaction } from './tabEvents-C6NXS6Jl.js';
|
|
7
|
+
export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError, c as classifyMediaRef, d as closestImageSize, f as ensureImageLocal, g as getCorrectId, h as getFeedItemStringField, j as isLeaderTab, i as isPublishedSeedRef, k as normalizeArweaveTxIdForEnsure, l as normalizeFeedItemFields, p as parseAddressesPersistedPayload, m as resolveMediaRef, w as whenLeaderTab } from './tabEvents-C6NXS6Jl.js';
|
|
8
|
+
import { g as getContentHash } from './ClientManager-DngaZdw6.js';
|
|
9
|
+
export { E as EAS_CHAIN_ID_APP_STATE_KEY, a as assertLocalDbChain, c as claimUnpublishedDrafts, C as client, d as createLocalQueryDataSource, e as createSchema, f as easSyncActor, h as getClient, j as getPublishedSeedRecord, k as getSchemaNameFromId, i as importJsonSchema, m as isSeedQueryLocalSourceRegistered, n as listSchemas, o as loadAllSchemasFromDb, p as mergeEasSyncRequestIntents, r as readJsonImportFile, q as readSchema, u as registerSeedQueryLocalSource, v as requestEasSyncFromAddressChange, x as requestEasSyncFromEventBus, y as requestEasSyncFromModelsInit, z as sendEasSyncClientRequest, A as startEasSyncActor, s as syncSchemaFromSource, t as transformImportToSchemaFile, B as unregisterSeedQueryLocalSource } from './ClientManager-DngaZdw6.js';
|
|
10
|
+
import { i as isVersionRevoked, q as compareMetadataRowsLatestFirst, t as isPublishedMetadataRow, b as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage, I as Item, j as waitForEntityIdle } from './Item-ZUAmf943.js';
|
|
11
|
+
export { C as ClientManagerState, f as ItemProperty, h as ItemPropertySaveValidationError, M as METADATA_LATEST_FIRST_ORDER_SQL, u as MachineIds, x as createNewItem, y as getEasSchemaForItemProperty, e as getGetAdditionalSyncAddresses, z as getGetPublisherForNewSeeds, A as getMetadataLatest, B as getRevokeExecutor, D as getUploadExecutor, E as getVersionData, F as isItemOwned, G as isLocalUnsealedDraft, H as isSeedRowOwned, l as listRelationEasPropertyName, J as ownedPublisherSql, K as pickLatestMetadataRowPerProperty, L as propertyMachine, N as publisherInAddressListSql, O as publisherIsInOwnedSet, P as setAdditionalSyncAddresses, Q as setGetPublisherForNewSeeds, R as setRevokeExecutor, S as setUploadExecutor } from './Item-ZUAmf943.js';
|
|
12
|
+
import { B as BaseDb, v as versions, r as seeds, m as metadata, h as htmlEmbeddedImageCoPublish, a as BaseFileManager, C as INTERNAL_STORAGE_MODEL_FILE_IDS, I as INTERNAL_PROPERTY_NAMES, Z as ZERO_BYTES32 } from './BasePathResolver-DRT09oVv.js';
|
|
13
|
+
export { E as EAS_SEED_DATA_SYNCED_TO_DB_EVENT, x as INTERNAL_DATA_TYPES, D as ImageSize, F as SEED_PROTOCOL_SCHEMA_NAME, G as SeedModels, H as VERSION_SCHEMA_DEF, V as VERSION_SCHEMA_UID, J as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, b as appState, c as arweaveL1FinalizeJobs, e as easSyncProcesses, g as modelSchemas, i as modelUids, j as models, p as properties, o as propertyUids, q as publishProcesses, s as schemas, u as uploadProcesses } from './BasePathResolver-DRT09oVv.js';
|
|
14
14
|
import { eq, desc, and, or, isNotNull, ne } from 'drizzle-orm';
|
|
15
15
|
import { isPlaceholderUid, isValidEasAttestationUid, normalizeBytes32Hex } from '@seedprotocol/eas';
|
|
16
16
|
export { EAS_CHAIN_DEPLOYMENTS, BaseEasClient as EasClient, getCanonicalItemPropertiesFromEas, getEasChainDeployment, getEasEndpoint, getEasReadChainId, getEasSchemaUidBySchemaName, getItemPropertiesFromEas, getItemVersionsFromEas, getSeedsBySchemaName, getSeedsFromSchemaUids, isPlaceholderUid, isValidEasAttestationUid, normalizeBytes32Hex, pickLatestPropertyAttestationsByRefAndSchema, setSchemaUidForModel, setSchemaUidForSchemaDefinition, withExcludeRevokedFilter } from '@seedprotocol/eas';
|
|
17
17
|
import { generateId } from './generateId-BopUwD8F.js';
|
|
18
|
-
export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-
|
|
18
|
+
export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-D-Ud-XYw.js';
|
|
19
19
|
export { F as FileSystemLockedError } from './errors-CrBxGWah.js';
|
|
20
|
-
export { M as MODEL_AMBIGUOUS_EVENT } from './resolveModelForSyncedSeed-
|
|
21
|
-
export { ModelProperty } from './ModelProperty-
|
|
22
|
-
export { getModelSchemasFromEas } from './eas-
|
|
20
|
+
export { M as MODEL_AMBIGUOUS_EVENT } from './resolveModelForSyncedSeed-B0tco3zG.js';
|
|
21
|
+
export { ModelProperty } from './ModelProperty-6llK4MTH.js';
|
|
22
|
+
export { getModelSchemasFromEas } from './eas-CQ-Smzk2.js';
|
|
23
23
|
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, invalidateReadGatewayCache, invalidateSidecarProbeCache, isArweaveL1AnchoringComplete, isEasAttestationExplorerUrl, isGatewayHostCircuitOpen, isKnownArweaveGatewayHostname, isReadGatewayKnownHealthy, mergePrimaryHostWithDefaults, normalizeGatewayHostKey, normalizeUploadApiBaseUrl, queryArweaveGatewayTransaction, queryArweaveGatewayTransactionWithFallback, recordGatewayHostFailure, recordGatewayHostSuccess, resetArweaveReadGatewayForTests, resolveSeedGatewayEndpoints, resolveSeedRssImageRelationFromItem, resolveSeedRssImageRelationRef, seedGatewayConfigFromClientContext, seedGatewayConfigFromSeedConfig, setPreferredArweaveReadBaseUrls, setResolvedSeedGatewayEndpoints } from '@seedprotocol/arweave';
|
|
24
|
-
export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
export { P as PublishValidationFailedError, R as RELATED_ITEM_UNPUBLISHED_CODE, b as RelatedItemUnpublishedError, c as resolvePublishPayloadValues, v as validateItemForPublish } from './getPublishPayload-H032DHC7.js';
|
|
24
|
+
export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-CYwgVNlM.js';
|
|
25
|
+
import { a as getSegmentedItemProperties, g as getPublishDraftGraph, i as isSeedRevoked, f as findRelatedSeedRow, b as isUnpublishedSeed, h as htmlPropertyNameForHtmlSeed, r as relatedModelNameFromDef } from './publishDraftGraph-BRm6Pq3Q.js';
|
|
26
|
+
export { P as PublishValidationFailedError, R as RELATED_ITEM_UNPUBLISHED_CODE, a as RelatedItemUnpublishedError, r as resolvePublishPayloadValues, v as validateItemForPublish } from './getPublishPayload-76_KfB5Y.js';
|
|
28
27
|
import 'pluralize';
|
|
29
|
-
export { itemHasPublishUploadCandidates } from './getPublishUploads-
|
|
30
|
-
import { parseFragment
|
|
28
|
+
export { itemHasPublishUploadCandidates } from './getPublishUploads-CqgMBD8f.js';
|
|
29
|
+
import { parseFragment } from 'parse5';
|
|
31
30
|
import 'js-yaml';
|
|
32
31
|
import 'fs';
|
|
33
32
|
import 'xstate';
|
|
@@ -43,7 +42,7 @@ import '@seedprotocol/query';
|
|
|
43
42
|
import 'drizzle-orm/sqlite-core';
|
|
44
43
|
import '@noble/hashes/sha3';
|
|
45
44
|
import '@noble/hashes/utils';
|
|
46
|
-
import './SchemaValidationService-
|
|
45
|
+
import './SchemaValidationService-IoS7JquP.js';
|
|
47
46
|
import '@sinclair/typebox/value';
|
|
48
47
|
import '@ethereum-attestation-service/eas-sdk';
|
|
49
48
|
|
|
@@ -531,7 +530,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
531
530
|
visited.add(seedLocalId);
|
|
532
531
|
const result = [];
|
|
533
532
|
const { itemRelationProperties, itemImageProperties, itemListProperties } = await getSegmentedItemProperties(item);
|
|
534
|
-
const getItemMod = await import('./getItem-
|
|
533
|
+
const getItemMod = await import('./getItem-CSfSok9f.js');
|
|
535
534
|
const { getItem } = getItemMod;
|
|
536
535
|
const processRelationOrImage = async (prop) => {
|
|
537
536
|
const snapshot = prop.getService().getSnapshot();
|
|
@@ -550,7 +549,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
550
549
|
if (!value && prop.propertyName && isStorageSeed) {
|
|
551
550
|
const ctx = context;
|
|
552
551
|
if (ctx.seedLocalId || ctx.seedUid) {
|
|
553
|
-
const _mod_0 = await import('./Item-
|
|
552
|
+
const _mod_0 = await import('./Item-ZUAmf943.js');
|
|
554
553
|
const _ns_0 = _mod_0.Y;
|
|
555
554
|
const { getPropertyData } = _ns_0;
|
|
556
555
|
const meta = await getPropertyData({
|
|
@@ -645,15 +644,6 @@ function getAttr(node, name) {
|
|
|
645
644
|
const a = node.attrs?.find((x) => x.name === name);
|
|
646
645
|
return a?.value;
|
|
647
646
|
}
|
|
648
|
-
function setAttr(node, name, value) {
|
|
649
|
-
if (!node.attrs)
|
|
650
|
-
node.attrs = [];
|
|
651
|
-
const i = node.attrs.findIndex((x) => x.name === name);
|
|
652
|
-
if (i >= 0)
|
|
653
|
-
node.attrs[i].value = value;
|
|
654
|
-
else
|
|
655
|
-
node.attrs.push({ name, value });
|
|
656
|
-
}
|
|
657
647
|
/**
|
|
658
648
|
* Walk fragment tree; collect unique data:image base64 URIs with limits.
|
|
659
649
|
*/
|
|
@@ -712,21 +702,39 @@ async function extractDataUriImagesFromHtml(html) {
|
|
|
712
702
|
await walk(c);
|
|
713
703
|
return found;
|
|
714
704
|
}
|
|
705
|
+
function escapeAttributeValue(value) {
|
|
706
|
+
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
707
|
+
}
|
|
715
708
|
/**
|
|
716
|
-
*
|
|
709
|
+
* Rewrite attribute values of `html` by splicing each new value into the original string: every
|
|
710
|
+
* byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would
|
|
711
|
+
* not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,
|
|
712
|
+
* a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),
|
|
713
|
+
* and sealed Html must not change with the serializer.
|
|
714
|
+
*
|
|
715
|
+
* `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to
|
|
716
|
+
* leave it. A rewritten attribute is written as `name="value"`.
|
|
717
717
|
*/
|
|
718
|
-
function
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const fragment = parseFragment(html);
|
|
718
|
+
function rewriteHtmlAttributes(html, rewrite) {
|
|
719
|
+
const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
|
|
720
|
+
const edits = [];
|
|
722
721
|
const walk = (node) => {
|
|
723
722
|
if (node.nodeName === '#text' || node.nodeName === '#comment')
|
|
724
723
|
return;
|
|
725
724
|
const el = node;
|
|
726
|
-
if (el.
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
725
|
+
if (el.attrs?.length) {
|
|
726
|
+
for (const attr of el.attrs) {
|
|
727
|
+
if (attr.prefix)
|
|
728
|
+
continue;
|
|
729
|
+
const next = rewrite(el, attr.name, attr.value);
|
|
730
|
+
const location = el.sourceCodeLocation?.attrs?.[attr.name];
|
|
731
|
+
if (next === undefined || !location)
|
|
732
|
+
continue;
|
|
733
|
+
edits.push({
|
|
734
|
+
start: location.startOffset,
|
|
735
|
+
end: location.endOffset,
|
|
736
|
+
text: `${attr.name}="${escapeAttributeValue(next)}"`,
|
|
737
|
+
});
|
|
730
738
|
}
|
|
731
739
|
}
|
|
732
740
|
const parent = el;
|
|
@@ -737,7 +745,114 @@ function replaceDataUrisInParsedHtml(html, replacements) {
|
|
|
737
745
|
};
|
|
738
746
|
for (const c of fragment.childNodes)
|
|
739
747
|
walk(c);
|
|
740
|
-
|
|
748
|
+
let out = html;
|
|
749
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
750
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
751
|
+
}
|
|
752
|
+
return out;
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those
|
|
756
|
+
* `src` attributes change; the rest of the Html is kept byte for byte.
|
|
757
|
+
*/
|
|
758
|
+
function replaceDataUrisInParsedHtml(html, replacements) {
|
|
759
|
+
if (replacements.size === 0)
|
|
760
|
+
return html;
|
|
761
|
+
return rewriteHtmlAttributes(html, (el, attrName, value) => {
|
|
762
|
+
if (el.tagName !== 'img' || attrName !== 'src')
|
|
763
|
+
return undefined;
|
|
764
|
+
return replacements.get(value.trim());
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's
|
|
769
|
+
* `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,
|
|
770
|
+
* then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a
|
|
771
|
+
* file published alongside it without embedding it (e.g. `<img class="u-featured"
|
|
772
|
+
* src="seed:property/featureImage">`).
|
|
773
|
+
*/
|
|
774
|
+
const SEED_PROPERTY_REF_PREFIX = 'seed:property/';
|
|
775
|
+
const SEED_PROPERTY_REF = /^seed:property\/([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
776
|
+
/** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */
|
|
777
|
+
const SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster']);
|
|
778
|
+
const seedPropertyRefName = (attrName, value) => SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined;
|
|
779
|
+
/** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */
|
|
780
|
+
class HtmlSeedPropertyRefError extends Error {
|
|
781
|
+
constructor(message) {
|
|
782
|
+
super(message);
|
|
783
|
+
this.name = 'HtmlSeedPropertyRefError';
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
/** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */
|
|
787
|
+
function findSeedPropertyRefsInHtml(html) {
|
|
788
|
+
if (!html.includes(SEED_PROPERTY_REF_PREFIX))
|
|
789
|
+
return [];
|
|
790
|
+
const names = new Set();
|
|
791
|
+
rewriteHtmlAttributes(html, (_el, attrName, value) => {
|
|
792
|
+
const name = seedPropertyRefName(attrName, value);
|
|
793
|
+
if (name)
|
|
794
|
+
names.add(name);
|
|
795
|
+
return undefined;
|
|
796
|
+
});
|
|
797
|
+
return [...names];
|
|
798
|
+
}
|
|
799
|
+
/** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */
|
|
800
|
+
function replaceSeedPropertyRefsInHtml(html, urlByPropertyName) {
|
|
801
|
+
if (urlByPropertyName.size === 0)
|
|
802
|
+
return html;
|
|
803
|
+
return rewriteHtmlAttributes(html, (_el, attrName, value) => {
|
|
804
|
+
const name = seedPropertyRefName(attrName, value);
|
|
805
|
+
return name ? urlByPropertyName.get(name) : undefined;
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
const SEED_PROPERTY_REF_DATA_TYPES = [
|
|
809
|
+
ModelPropertyDataTypes.Image,
|
|
810
|
+
ModelPropertyDataTypes.File,
|
|
811
|
+
ModelPropertyDataTypes.Json,
|
|
812
|
+
];
|
|
813
|
+
/**
|
|
814
|
+
* The storage property of `item` a `seed:property/<name>` placeholder names, and the seed it holds.
|
|
815
|
+
* Html properties are refused: an Html seed may itself be deferred to after the rewrite.
|
|
816
|
+
*/
|
|
817
|
+
function resolveSeedPropertyRefTarget(item, propertyName) {
|
|
818
|
+
const property = item.properties.find((p) => p.propertyName === propertyName || p.propertyName === `${propertyName}Id`);
|
|
819
|
+
const def = property?.propertyDef;
|
|
820
|
+
if (!property || !def) {
|
|
821
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${item.modelName} has no property ${propertyName}`);
|
|
822
|
+
}
|
|
823
|
+
const dataType = normalizeDataTypeLocal(def.dataType);
|
|
824
|
+
const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataTypeLocal(def.refValueType) : dataType;
|
|
825
|
+
if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {
|
|
826
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +
|
|
827
|
+
`only Image, File and Json properties can be referenced`);
|
|
828
|
+
}
|
|
829
|
+
const snap = property.getService().getSnapshot();
|
|
830
|
+
const ctx = 'context' in snap ? snap.context : null;
|
|
831
|
+
const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(ctx?.propertyValue) ?? '');
|
|
832
|
+
if (!ids.seedLocalId && !ids.seedUid) {
|
|
833
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`);
|
|
834
|
+
}
|
|
835
|
+
return ids;
|
|
836
|
+
}
|
|
837
|
+
const ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i;
|
|
838
|
+
/**
|
|
839
|
+
* The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,
|
|
840
|
+
* when not uploaded now, the transaction it was published with (its storageTransactionId).
|
|
841
|
+
*/
|
|
842
|
+
async function resolveSeedPropertyRefTxId(item, propertyName, txBySeedLocalId) {
|
|
843
|
+
const { seedLocalId, seedUid } = resolveSeedPropertyRefTarget(item, propertyName);
|
|
844
|
+
const uploaded = seedLocalId ? txBySeedLocalId.get(seedLocalId) : undefined;
|
|
845
|
+
if (uploaded)
|
|
846
|
+
return uploaded;
|
|
847
|
+
const storageItem = await Item.find({ seedLocalId, seedUid });
|
|
848
|
+
const st = storageItem?.internalProperties['storageTransactionId'] ??
|
|
849
|
+
storageItem?.allProperties['storageTransactionId'];
|
|
850
|
+
const stSnap = st?.getService().getSnapshot();
|
|
851
|
+
const stValue = stSnap && 'context' in stSnap ? stSnap.context.propertyValue : undefined;
|
|
852
|
+
if (typeof stValue === 'string' && ARWEAVE_TX_ID.test(stValue.trim()))
|
|
853
|
+
return stValue.trim();
|
|
854
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +
|
|
855
|
+
`in this publish and has no published transaction`);
|
|
741
856
|
}
|
|
742
857
|
async function deleteCoPublishRowsForParent(appDb, parentSeedLocalId) {
|
|
743
858
|
if (!appDb)
|
|
@@ -781,31 +896,16 @@ async function prepareHtmlEmbeddedImagesForPublish(item, publishPolicy) {
|
|
|
781
896
|
return { deferredHtmlSeedLocalIds: [...deferred] };
|
|
782
897
|
}
|
|
783
898
|
/**
|
|
784
|
-
* Draft items (no seed uid yet) that a publish of `item` publishes with it:
|
|
785
|
-
* relation
|
|
786
|
-
* Html-embedded images of these items are co-published with `item` like its own.
|
|
899
|
+
* Draft items (no seed uid yet) that a publish of `item` publishes with it: every draft reachable
|
|
900
|
+
* through relation and list properties, as getPublishPayload and getPublishUploads walk them
|
|
901
|
+
* (publishDraftGraph.ts). Html-embedded images of these items are co-published with `item` like its own.
|
|
787
902
|
*/
|
|
788
903
|
async function getRelatedDraftsCoPublishedWith(item) {
|
|
789
|
-
const
|
|
790
|
-
const
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
continue;
|
|
795
|
-
const snap = relationProperty.getService().getSnapshot();
|
|
796
|
-
const value = 'context' in snap ? snap.context.propertyValue : undefined;
|
|
797
|
-
const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '');
|
|
798
|
-
if (!seedLocalId && !seedUid)
|
|
799
|
-
continue;
|
|
800
|
-
const related = await Item.find({ seedLocalId, seedUid });
|
|
801
|
-
if (!related?.seedLocalId || seen.has(related.seedLocalId))
|
|
802
|
-
continue;
|
|
803
|
-
if (related.seedUid && related.seedUid !== ZERO_BYTES32)
|
|
804
|
-
continue;
|
|
805
|
-
seen.add(related.seedLocalId);
|
|
806
|
-
out.push(related);
|
|
807
|
-
}
|
|
808
|
-
return out;
|
|
904
|
+
const _mod_1 = await import('./publishDraftGraph-BRm6Pq3Q.js');
|
|
905
|
+
const _ns_1 = _mod_1.p;
|
|
906
|
+
const { getPublishDraftGraph } = _ns_1;
|
|
907
|
+
const { drafts } = await getPublishDraftGraph(item);
|
|
908
|
+
return drafts.map((d) => d.item);
|
|
809
909
|
}
|
|
810
910
|
async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, deferred) {
|
|
811
911
|
await deleteCoPublishRowsForParent(appDb, item.seedLocalId);
|
|
@@ -813,9 +913,6 @@ async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, defer
|
|
|
813
913
|
const def = p.propertyDef;
|
|
814
914
|
if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
|
|
815
915
|
continue;
|
|
816
|
-
const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(def, publishPolicy);
|
|
817
|
-
if (policy !== 'materialize')
|
|
818
|
-
continue;
|
|
819
916
|
const snap = p.getService().getSnapshot();
|
|
820
917
|
const ctx = 'context' in snap ? snap.context : null;
|
|
821
918
|
const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue : '';
|
|
@@ -846,15 +943,17 @@ async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, defer
|
|
|
846
943
|
html = new TextDecoder('utf-8', { fatal: false }).decode(new Uint8Array(v.buffer, v.byteOffset, v.byteLength));
|
|
847
944
|
}
|
|
848
945
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
946
|
+
// seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A
|
|
947
|
+
// placeholder naming no usable property fails here, before anything is uploaded.
|
|
948
|
+
const refs = findSeedPropertyRefsInHtml(html);
|
|
949
|
+
for (const name of refs)
|
|
950
|
+
resolveSeedPropertyRefTarget(item, name);
|
|
951
|
+
if (refs.length > 0)
|
|
952
|
+
deferred.add(htmlSeedLocalId.trim());
|
|
953
|
+
const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(def, publishPolicy);
|
|
954
|
+
if (policy !== 'materialize')
|
|
955
|
+
continue;
|
|
956
|
+
const extracted = await extractDataUriImagesFromHtml(html);
|
|
858
957
|
if (extracted.length === 0)
|
|
859
958
|
continue;
|
|
860
959
|
deferred.add(htmlSeedLocalId.trim());
|
|
@@ -877,70 +976,73 @@ function normalizeDataTypeLocal(dt) {
|
|
|
877
976
|
return dt.charAt(0).toUpperCase() + dt.slice(1).toLowerCase();
|
|
878
977
|
}
|
|
879
978
|
/**
|
|
880
|
-
* After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL
|
|
979
|
+
* After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and
|
|
980
|
+
* `seed:property/<name>` → the gateway URL of that property's upload.
|
|
981
|
+
*
|
|
982
|
+
* `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to
|
|
983
|
+
* the Html held back from phase 1; without it, every Html of the item and its co-published drafts is
|
|
984
|
+
* considered.
|
|
881
985
|
*/
|
|
882
|
-
async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions) {
|
|
986
|
+
async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions, deferredHtmlSeedLocalIds) {
|
|
883
987
|
const appDb = BaseDb.getAppDb();
|
|
884
988
|
if (!appDb)
|
|
885
989
|
return;
|
|
886
990
|
const parentItem = await Item.find({ seedLocalId: parentSeedLocalId });
|
|
887
991
|
if (!parentItem)
|
|
888
992
|
return;
|
|
889
|
-
const
|
|
993
|
+
const txBySeedLocalId = new Map();
|
|
890
994
|
for (const u of uploadedTransactions) {
|
|
891
995
|
if (u.seedLocalId && u.txId) {
|
|
892
|
-
|
|
996
|
+
txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim());
|
|
893
997
|
}
|
|
894
998
|
}
|
|
999
|
+
const deferred = deferredHtmlSeedLocalIds
|
|
1000
|
+
? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))
|
|
1001
|
+
: undefined;
|
|
895
1002
|
// The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).
|
|
896
1003
|
for (const item of [parentItem, ...(await getRelatedDraftsCoPublishedWith(parentItem))]) {
|
|
897
|
-
await rewriteHtmlEmbeddedImagesOfItem(appDb, item,
|
|
1004
|
+
await rewriteHtmlEmbeddedImagesOfItem(appDb, item, txBySeedLocalId, deferred);
|
|
898
1005
|
}
|
|
899
1006
|
}
|
|
900
|
-
async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem,
|
|
1007
|
+
async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem, txBySeedLocalId, deferred) {
|
|
901
1008
|
const rows = await appDb
|
|
902
1009
|
.select()
|
|
903
1010
|
.from(htmlEmbeddedImageCoPublish)
|
|
904
1011
|
.where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentItem.seedLocalId));
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const refByHtmlSeed = new Map();
|
|
909
|
-
if (parentItem) {
|
|
910
|
-
for (const p of parentItem.properties) {
|
|
911
|
-
const def = p.propertyDef;
|
|
912
|
-
if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
|
|
913
|
-
continue;
|
|
914
|
-
const snap = p.getService().getSnapshot();
|
|
915
|
-
const ctx = 'context' in snap ? snap.context : null;
|
|
916
|
-
const pv = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue.trim() : '';
|
|
917
|
-
const refResolved = ctx?.refResolvedValue;
|
|
918
|
-
if (pv && refResolved)
|
|
919
|
-
refByHtmlSeed.set(pv, refResolved);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
for (const htmlSeedLocalId of htmlSeedIds) {
|
|
923
|
-
const refResolved = refByHtmlSeed.get(String(htmlSeedLocalId));
|
|
924
|
-
if (!refResolved)
|
|
1012
|
+
for (const p of parentItem.properties) {
|
|
1013
|
+
const def = p.propertyDef;
|
|
1014
|
+
if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
|
|
925
1015
|
continue;
|
|
1016
|
+
const snap = p.getService().getSnapshot();
|
|
1017
|
+
const ctx = 'context' in snap ? snap.context : null;
|
|
1018
|
+
const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue.trim() : '';
|
|
1019
|
+
const refResolved = ctx?.refResolvedValue;
|
|
1020
|
+
if (!htmlSeedLocalId || !refResolved)
|
|
1021
|
+
continue;
|
|
1022
|
+
if (deferred && !deferred.has(htmlSeedLocalId))
|
|
1023
|
+
continue;
|
|
1024
|
+
const htmlRows = rows.filter((r) => String(r.htmlSeedLocalId).trim() === htmlSeedLocalId);
|
|
926
1025
|
const filePath = `${BaseFileManager.getFilesPath('html')}/${refResolved}`;
|
|
927
1026
|
if (!(await BaseFileManager.pathExists(filePath)))
|
|
928
1027
|
continue;
|
|
929
1028
|
const html = await BaseFileManager.readFileAsString(filePath);
|
|
930
1029
|
const replacements = new Map();
|
|
931
|
-
for (const r of
|
|
932
|
-
|
|
933
|
-
continue;
|
|
934
|
-
const txId = txByImageSeed.get(r.imageSeedLocalId.trim());
|
|
1030
|
+
for (const r of htmlRows) {
|
|
1031
|
+
const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim());
|
|
935
1032
|
if (!txId)
|
|
936
1033
|
continue;
|
|
937
1034
|
const dataUri = await findDataUriForStableKey(html, r.stableKey);
|
|
938
1035
|
if (dataUri)
|
|
939
1036
|
replacements.set(dataUri, getArweaveUrlForTransaction(txId));
|
|
940
1037
|
}
|
|
941
|
-
|
|
1038
|
+
const urlByPropertyName = new Map();
|
|
1039
|
+
for (const name of findSeedPropertyRefsInHtml(html)) {
|
|
1040
|
+
const txId = await resolveSeedPropertyRefTxId(parentItem, name, txBySeedLocalId);
|
|
1041
|
+
urlByPropertyName.set(name, getArweaveUrlForTransaction(txId));
|
|
1042
|
+
}
|
|
1043
|
+
const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName);
|
|
1044
|
+
if (newHtml === html)
|
|
942
1045
|
continue;
|
|
943
|
-
const newHtml = replaceDataUrisInParsedHtml(html, replacements);
|
|
944
1046
|
try {
|
|
945
1047
|
await BaseFileManager.saveFile(filePath, newHtml);
|
|
946
1048
|
}
|
|
@@ -948,19 +1050,10 @@ async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem, txByImageSeed)
|
|
|
948
1050
|
const fs = await BaseFileManager.getFs();
|
|
949
1051
|
fs.writeFileSync(filePath, newHtml);
|
|
950
1052
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const pv = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue.trim() : '';
|
|
956
|
-
if (pv === htmlSeedLocalId) {
|
|
957
|
-
p.getService().send({
|
|
958
|
-
type: 'updateContext',
|
|
959
|
-
renderValue: newHtml,
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
}
|
|
1053
|
+
p.getService().send({
|
|
1054
|
+
type: 'updateContext',
|
|
1055
|
+
renderValue: newHtml,
|
|
1056
|
+
});
|
|
964
1057
|
}
|
|
965
1058
|
}
|
|
966
1059
|
async function findDataUriForStableKey(html, stableKey) {
|
|
@@ -1127,7 +1220,7 @@ async function loadRelatedItem(value) {
|
|
|
1127
1220
|
const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalized);
|
|
1128
1221
|
if (!seedLocalId && !seedUid)
|
|
1129
1222
|
return undefined;
|
|
1130
|
-
const { getItem } = await import('./getItem-
|
|
1223
|
+
const { getItem } = await import('./getItem-CSfSok9f.js');
|
|
1131
1224
|
try {
|
|
1132
1225
|
return await getItem({ seedLocalId, seedUid });
|
|
1133
1226
|
}
|
|
@@ -1144,25 +1237,6 @@ async function relatedIfUnpublished(prop) {
|
|
|
1144
1237
|
return undefined;
|
|
1145
1238
|
return related;
|
|
1146
1239
|
}
|
|
1147
|
-
async function unpublishedListItems(listProperty) {
|
|
1148
|
-
const context = propertyContext(listProperty);
|
|
1149
|
-
if (!context)
|
|
1150
|
-
return [];
|
|
1151
|
-
let value = context.propertyValue;
|
|
1152
|
-
if (!value)
|
|
1153
|
-
return [];
|
|
1154
|
-
if (typeof value === 'string') {
|
|
1155
|
-
value = parseListPropertyValueFromStorage(value);
|
|
1156
|
-
}
|
|
1157
|
-
const arr = Array.isArray(value) ? value : [];
|
|
1158
|
-
const out = [];
|
|
1159
|
-
for (const seedId of arr) {
|
|
1160
|
-
const related = await loadRelatedItem(seedId);
|
|
1161
|
-
if (related && isZeroUid(related.seedUid))
|
|
1162
|
-
out.push(related);
|
|
1163
|
-
}
|
|
1164
|
-
return out;
|
|
1165
|
-
}
|
|
1166
1240
|
/** Seed refs held by a relation/image property (one) or a list property (each member). */
|
|
1167
1241
|
function seedRefsOf(prop, isList) {
|
|
1168
1242
|
const context = propertyContext(prop);
|
|
@@ -1180,7 +1254,7 @@ function seedRefsOf(prop, isList) {
|
|
|
1180
1254
|
return ref ? [ref] : [];
|
|
1181
1255
|
}
|
|
1182
1256
|
/** Like getPublishPayload: attested refs to revoked seeds block the publish. */
|
|
1183
|
-
async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot, out) {
|
|
1257
|
+
async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot, out, backReferences) {
|
|
1184
1258
|
for (const prop of props) {
|
|
1185
1259
|
if (!shouldAttestProperty(prop, forceFullSnapshot))
|
|
1186
1260
|
continue;
|
|
@@ -1189,6 +1263,10 @@ async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot,
|
|
|
1189
1263
|
if (!seedLocalId && !seedUid)
|
|
1190
1264
|
continue;
|
|
1191
1265
|
const row = await findRelatedSeedRow({ seedLocalId, seedUid });
|
|
1266
|
+
// A back reference to a seed this publish creates (e.g. a revoked root published again) is
|
|
1267
|
+
// left for a later publish, not attested (publishDraftGraph.ts)
|
|
1268
|
+
if (row && backReferences?.get(prop)?.has(row.seedLocalId))
|
|
1269
|
+
continue;
|
|
1192
1270
|
if (!isUnpublishedSeed(row))
|
|
1193
1271
|
continue;
|
|
1194
1272
|
if (out.some((r) => r.propertyName === prop.propertyName && r.seedLocalId === row.seedLocalId)) {
|
|
@@ -1229,7 +1307,7 @@ async function collectUnpublishedEmbeddedImages(item, out) {
|
|
|
1229
1307
|
}
|
|
1230
1308
|
}
|
|
1231
1309
|
}
|
|
1232
|
-
async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot, publishMode) {
|
|
1310
|
+
async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot, publishMode, graph) {
|
|
1233
1311
|
const appDb = BaseDb.getAppDb();
|
|
1234
1312
|
if (!appDb)
|
|
1235
1313
|
return;
|
|
@@ -1238,9 +1316,9 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
|
|
|
1238
1316
|
.from(htmlEmbeddedImageCoPublish)
|
|
1239
1317
|
.where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId));
|
|
1240
1318
|
for (const row of rows) {
|
|
1241
|
-
const
|
|
1242
|
-
const
|
|
1243
|
-
const { Item } =
|
|
1319
|
+
const _mod_2 = await import('./Item-ZUAmf943.js');
|
|
1320
|
+
const _ns_2 = _mod_2.Z;
|
|
1321
|
+
const { Item } = _ns_2;
|
|
1244
1322
|
const imageItem = await Item.find({
|
|
1245
1323
|
seedLocalId: row.imageSeedLocalId,
|
|
1246
1324
|
modelName: 'Image',
|
|
@@ -1257,10 +1335,10 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
|
|
|
1257
1335
|
if (dataUriBytes != null && dataUriBytes > 0) {
|
|
1258
1336
|
await addUpload(acc, seen, `seed:${imageItem.seedLocalId}`, dataUriBytes);
|
|
1259
1337
|
}
|
|
1260
|
-
await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited);
|
|
1338
|
+
await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited, graph);
|
|
1261
1339
|
}
|
|
1262
1340
|
}
|
|
1263
|
-
async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUploads, visited) {
|
|
1341
|
+
async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph) {
|
|
1264
1342
|
const seedLocalId = item.seedLocalId;
|
|
1265
1343
|
if (!seedLocalId || visited.has(seedLocalId))
|
|
1266
1344
|
return;
|
|
@@ -1272,20 +1350,20 @@ async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUplo
|
|
|
1272
1350
|
acc.newVersionCount += 1;
|
|
1273
1351
|
const { itemBasicProperties, itemRelationProperties, itemListProperties, itemUploadProperties, itemImageProperties, } = await getSegmentedItemProperties(item);
|
|
1274
1352
|
await collectUploadBytes(item, itemUploadProperties, itemImageProperties, undefined, acc, seenUploads);
|
|
1275
|
-
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, acc.unpublishedRelatedItems);
|
|
1276
|
-
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, acc.unpublishedRelatedItems);
|
|
1353
|
+
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, acc.unpublishedRelatedItems, graph.backReferences);
|
|
1354
|
+
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, acc.unpublishedRelatedItems, graph.backReferences);
|
|
1355
|
+
// Draft Image/File/Html/Json items its storage relations point at. Draft model items its relations
|
|
1356
|
+
// and lists reach are summarized by summarizePublishWork from the publish's draft graph.
|
|
1357
|
+
const storageProperties = new Set(itemImageProperties);
|
|
1277
1358
|
for (const rel of itemRelationProperties) {
|
|
1359
|
+
if (!storageProperties.has(rel))
|
|
1360
|
+
continue;
|
|
1278
1361
|
const related = await relatedIfUnpublished(rel);
|
|
1279
1362
|
if (related) {
|
|
1280
|
-
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited);
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
for (const listProperty of itemListProperties) {
|
|
1284
|
-
for (const related of await unpublishedListItems(listProperty)) {
|
|
1285
|
-
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited);
|
|
1363
|
+
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph);
|
|
1286
1364
|
}
|
|
1287
1365
|
}
|
|
1288
|
-
await appendCoPublishImages(item, acc, seenUploads, visited, forceFullSnapshot, publishMode);
|
|
1366
|
+
await appendCoPublishImages(item, acc, seenUploads, visited, forceFullSnapshot, publishMode, graph);
|
|
1289
1367
|
const attestable = [
|
|
1290
1368
|
...itemBasicProperties,
|
|
1291
1369
|
...itemRelationProperties,
|
|
@@ -1299,6 +1377,9 @@ async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUplo
|
|
|
1299
1377
|
if (seenProps.has(key))
|
|
1300
1378
|
continue;
|
|
1301
1379
|
seenProps.add(key);
|
|
1380
|
+
// A ref back to an item this publish creates is left for a later publish (publishDraftGraph.ts).
|
|
1381
|
+
if (graph.deferredProperties.has(prop))
|
|
1382
|
+
continue;
|
|
1302
1383
|
if (shouldAttestProperty(prop, forceFullSnapshot))
|
|
1303
1384
|
acc.attestationCount += 1;
|
|
1304
1385
|
}
|
|
@@ -1313,25 +1394,10 @@ const publishForcesFullSnapshot = async (item, publishMode) => {
|
|
|
1313
1394
|
const republishRevokedSeed = !isZeroUid(item.seedUid) && (await isSeedRevoked(item.seedLocalId));
|
|
1314
1395
|
return { republishRevokedSeed, forceFullSnapshot: publishMode === 'new_version' || republishRevokedSeed };
|
|
1315
1396
|
};
|
|
1316
|
-
async function
|
|
1317
|
-
const seedLocalId = item.seedLocalId;
|
|
1318
|
-
if (!seedLocalId || visited.has(seedLocalId))
|
|
1319
|
-
return;
|
|
1320
|
-
visited.add(seedLocalId);
|
|
1397
|
+
async function collectUnpublishedRelatedItemsOf(item, forceFullSnapshot, out, backReferences) {
|
|
1321
1398
|
const { itemRelationProperties, itemListProperties, itemImageProperties } = await getSegmentedItemProperties(item);
|
|
1322
|
-
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, out);
|
|
1323
|
-
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, out);
|
|
1324
|
-
// Unpublished drafts the publish carries along are checked too.
|
|
1325
|
-
for (const rel of itemRelationProperties) {
|
|
1326
|
-
const related = await relatedIfUnpublished(rel);
|
|
1327
|
-
if (related)
|
|
1328
|
-
await collectUnpublishedRelatedItemsDeep(related, forceFullSnapshot, out, visited);
|
|
1329
|
-
}
|
|
1330
|
-
for (const listProperty of itemListProperties) {
|
|
1331
|
-
for (const related of await unpublishedListItems(listProperty)) {
|
|
1332
|
-
await collectUnpublishedRelatedItemsDeep(related, forceFullSnapshot, out, visited);
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1399
|
+
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, out, backReferences);
|
|
1400
|
+
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, out, backReferences);
|
|
1335
1401
|
}
|
|
1336
1402
|
/**
|
|
1337
1403
|
* References a publish of `item` would attest to items whose seed was unpublished (revoked), the
|
|
@@ -1341,7 +1407,11 @@ async function collectUnpublishedRelatedItemsDeep(item, forceFullSnapshot, out,
|
|
|
1341
1407
|
const getUnpublishedRelatedItems = async (item, options) => {
|
|
1342
1408
|
const { forceFullSnapshot } = await publishForcesFullSnapshot(item, options?.publishMode ?? 'patch');
|
|
1343
1409
|
const out = [];
|
|
1344
|
-
|
|
1410
|
+
// The item and every draft its publish carries along (publishDraftGraph.ts).
|
|
1411
|
+
const { drafts, backReferences } = await getPublishDraftGraph(item, { forceFullSnapshot });
|
|
1412
|
+
for (const owner of [item, ...drafts.map((d) => d.item)]) {
|
|
1413
|
+
await collectUnpublishedRelatedItemsOf(owner, forceFullSnapshot, out, backReferences);
|
|
1414
|
+
}
|
|
1345
1415
|
await collectUnpublishedEmbeddedImages(item, out);
|
|
1346
1416
|
return out;
|
|
1347
1417
|
};
|
|
@@ -1358,7 +1428,13 @@ const summarizePublishWork = async (item, options) => {
|
|
|
1358
1428
|
uploadBytes: 0,
|
|
1359
1429
|
unpublishedRelatedItems: [],
|
|
1360
1430
|
};
|
|
1361
|
-
await
|
|
1431
|
+
const graph = await getPublishDraftGraph(item, { forceFullSnapshot });
|
|
1432
|
+
const { drafts } = graph;
|
|
1433
|
+
const seenUploads = new Set();
|
|
1434
|
+
const visited = new Set();
|
|
1435
|
+
for (const owner of [item, ...drafts.map((d) => d.item)]) {
|
|
1436
|
+
await summarizeItem(owner, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph);
|
|
1437
|
+
}
|
|
1362
1438
|
await collectUnpublishedEmbeddedImages(item, acc.unpublishedRelatedItems);
|
|
1363
1439
|
// summarizeItem counts the root as an existing seed (it has a seedUid).
|
|
1364
1440
|
if (republishRevokedSeed)
|
|
@@ -1366,5 +1442,5 @@ const summarizePublishWork = async (item, options) => {
|
|
|
1366
1442
|
return acc;
|
|
1367
1443
|
};
|
|
1368
1444
|
|
|
1369
|
-
export { BaseDb, BaseFileManager, BaseFileManager as FileManager, HTML_EMBEDDED_MAX_IMAGES_PER_DOC, HTML_EMBEDDED_MAX_IMAGE_BYTES, HTML_EMBEDDED_MAX_TOTAL_BYTES, HtmlEmbeddedDataUriLimitError, Item, ModelPropertyDataTypes, applyArweaveL1TransactionIdLocal, applyPropertyAttestationUidsFromPublish, clearHtmlEmbeddedImageCoPublishRows, compareMetadataRowsLatestFirst, estimateDataUriByteLength, extractDataUriImagesFromHtml, generateId, getArweaveUrlForTransaction, getAttesterForSeed, getMetadataAttestationUidsForSeedUid, getPublishPendingDiff, getRelatedItemsForPublish, getSeedPublishState, getSegmentedItemProperties, getUnpublishedRelatedItems, getVersionsForSeedUid, htmlEmbeddedImageCoPublish, isDataType, metadata, normalizeDataType, normalizePublisher, normalizeRelationPropertyValue, prepareHtmlEmbeddedImagesForPublish, replaceDataUrisInParsedHtml, resolveEffectiveHtmlEmbeddedDataUriPolicy, resolveSeedIdsFromRefString, rewriteHtmlEmbeddedImagesOnDisk, seeds, shouldAttestProperty, summarizePublishWork, updateVersionUid, versions, waitForEntityIdle };
|
|
1445
|
+
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 };
|
|
1370
1446
|
//# sourceMappingURL=main.js.map
|