@seedprotocol/sdk 0.7.0 → 0.7.2-next.593.gd5bd4ea
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-BdxCSIzn.js} +2 -2
- package/dist/{BasePathResolver-ndE8XTpw.js.map → BasePathResolver-BdxCSIzn.js.map} +1 -1
- package/dist/{ClientManager-DLleL_2e.js → ClientManager-ClCwwhwo.js} +28 -23
- package/dist/ClientManager-ClCwwhwo.js.map +1 -0
- package/dist/{Item-zBFWQDU9.js → Item-B9Y4VuK1.js} +140 -74
- package/dist/Item-B9Y4VuK1.js.map +1 -0
- package/dist/{ModelProperty-lth9L37R.js → ModelProperty-BMePcicQ.js} +64 -36
- package/dist/ModelProperty-BMePcicQ.js.map +1 -0
- package/dist/{Schema-DOhlrQ-N.js → Schema-COsEXXaR.js} +106 -58
- package/dist/Schema-COsEXXaR.js.map +1 -0
- package/dist/{SchemaValidationService-DDKr5piy.js → SchemaValidationService-DabGMzSE.js} +7 -8
- package/dist/{SchemaValidationService-DDKr5piy.js.map → SchemaValidationService-DabGMzSE.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js → backfillMetadataPropertyIds-Ck6fumnm.js} +4 -4
- package/dist/{backfillMetadataPropertyIds-fG3ujaSh.js.map → backfillMetadataPropertyIds-Ck6fumnm.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BEsIHAjk.js → ModelProperty-BT6Un_MB.js} +59 -30
- package/dist/cjs/ModelProperty-BT6Un_MB.js.map +1 -0
- package/dist/cjs/{Schema-qEp5mH1N.js → Schema-BXhXdUsA.js} +93 -44
- package/dist/cjs/Schema-BXhXdUsA.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js → SchemaValidationService-CC18QDfc.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CWEnZmOH.js.map → SchemaValidationService-CC18QDfc.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js → backfillMetadataPropertyIds-DEHC9ejq.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-tw8JGMT0.js.map → backfillMetadataPropertyIds-DEHC9ejq.js.map} +1 -1
- package/dist/cjs/{eas-CLiV2Hmn.js → eas-C3CL0l7l.js} +3 -3
- package/dist/cjs/{eas-CLiV2Hmn.js.map → eas-C3CL0l7l.js.map} +1 -1
- package/dist/cjs/{getItem-DSRtx_68.js → getItem-CrwWYCkj.js} +2 -2
- package/dist/cjs/{getItem-DSRtx_68.js.map → getItem-CrwWYCkj.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-D5-dYtNq.js → getPublishPayload-DRJh7WR0.js} +171 -209
- package/dist/cjs/getPublishPayload-DRJh7WR0.js.map +1 -0
- package/dist/cjs/{getPublishUploads-B5Lq6q-_.js → getPublishUploads-Bh22D3zJ.js} +49 -10
- package/dist/cjs/getPublishUploads-Bh22D3zJ.js.map +1 -0
- package/dist/cjs/{index-B3UDbm1C.js → index-BA1RIYFG.js} +3 -3
- package/dist/cjs/index-BA1RIYFG.js.map +1 -0
- package/dist/cjs/{index-C66AfYDG.js → index-Dls7aMjr.js} +281 -90
- package/dist/cjs/index-Dls7aMjr.js.map +1 -0
- package/dist/cjs/{property-BVJIP7SX.js → property-ZerTWizX.js} +5 -5
- package/dist/cjs/{property-BVJIP7SX.js.map → property-ZerTWizX.js.map} +1 -1
- package/dist/cjs/publishDraftGraph-CPOAcQFf.js +403 -0
- package/dist/cjs/publishDraftGraph-CPOAcQFf.js.map +1 -0
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js → resetAmbiguousLegacyItemData-adDl4LcT.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-BaZqUui9.js.map → resetAmbiguousLegacyItemData-adDl4LcT.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js → resolveModelForSyncedSeed-DoNThPdL.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-CC6dQctx.js.map → resolveModelForSyncedSeed-DoNThPdL.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js → syncDbWithEas-CYfPkus9.js} +20 -7
- package/dist/cjs/{syncDbWithEas-Dk96sAG-.js.map → syncDbWithEas-CYfPkus9.js.map} +1 -1
- package/dist/{configurePlatform-BMoPG9vY.js → configurePlatform-xU3Hsno3.js} +4 -4
- package/dist/{configurePlatform-BMoPG9vY.js.map → configurePlatform-xU3Hsno3.js.map} +1 -1
- package/dist/{db-BJZN0a0a.js → db-W1g29qsM.js} +31 -27
- package/dist/{db-BJZN0a0a.js.map → db-W1g29qsM.js.map} +1 -1
- package/dist/{eas-B0hsMLqt.js → eas-CSwV6MvB.js} +6 -6
- package/dist/{eas-B0hsMLqt.js.map → eas-CSwV6MvB.js.map} +1 -1
- package/dist/{getItem-DEh4WfHG.js → getItem-BYQeM3DY.js} +5 -6
- package/dist/{getItem-DEh4WfHG.js.map → getItem-BYQeM3DY.js.map} +1 -1
- package/dist/{getPublishPayload-H032DHC7.js → getPublishPayload-D5CQZd-y.js} +167 -206
- package/dist/getPublishPayload-D5CQZd-y.js.map +1 -0
- package/dist/{getPublishUploads-CR66RlGJ.js → getPublishUploads-BGpDsrBp.js} +52 -14
- package/dist/getPublishUploads-BGpDsrBp.js.map +1 -0
- package/dist/{index-6bJuv5Tt.js → index-Bev-hZF-.js} +9 -10
- package/dist/index-Bev-hZF-.js.map +1 -0
- package/dist/{index-B0LgJblD.js → index-CSOQFAOn.js} +2 -2
- package/dist/index-CSOQFAOn.js.map +1 -0
- package/dist/{index-DtfjeuxC.js → index-DRXC5Mra.js} +167 -75
- package/dist/index-DRXC5Mra.js.map +1 -0
- package/dist/{index.browser-CNrqhvEA.js → index.browser-DO20vYuP.js} +9 -9
- package/dist/{index.browser-CNrqhvEA.js.map → index.browser-DO20vYuP.js.map} +1 -1
- package/dist/{index.node-DrHiTuOr.js → index.node-C4iyOhdo.js} +5 -5
- package/dist/{index.node-DrHiTuOr.js.map → index.node-C4iyOhdo.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +258 -183
- package/dist/main.js.map +1 -1
- package/dist/node.js +14 -15
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +3 -3
- package/dist/{property-D2Nnsmm1.js → property-BT1zDSkd.js} +10 -11
- package/dist/property-BT1zDSkd.js.map +1 -0
- package/dist/publishDraftGraph-Bcfrdj7-.js +405 -0
- package/dist/publishDraftGraph-Bcfrdj7-.js.map +1 -0
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js → resetAmbiguousLegacyItemData-Ci6PM_vC.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-BqbHNUYk.js.map → resetAmbiguousLegacyItemData-Ci6PM_vC.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js → resolveModelForSyncedSeed-CLlumTBq.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-DQK6JfXS.js.map → resolveModelForSyncedSeed-CLlumTBq.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/generateId.d.ts +4 -0
- package/dist/src/helpers/generateId.d.ts.map +1 -1
- 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/query/createLocalQueryDataSource.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-BQsXjGhe.js} +15 -16
- package/dist/syncDbWithEas-BQsXjGhe.js.map +1 -0
- package/dist/{tabEvents-DYI2GU7i.js → tabEvents-C9qUKx_z.js} +28 -11
- package/dist/tabEvents-C9qUKx_z.js.map +1 -0
- package/dist/{tolerantWebAccess-CzOBz5M6.js → tolerantWebAccess-B-9bwxbw.js} +6 -6
- package/dist/{tolerantWebAccess-CzOBz5M6.js.map → tolerantWebAccess-B-9bwxbw.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-B58ORbY3.js → updateSeedRevokedAt-D6q0h7pj.js} +3 -3
- package/dist/{updateSeedRevokedAt-B58ORbY3.js.map → updateSeedRevokedAt-D6q0h7pj.js.map} +1 -1
- package/package.json +13 -10
- package/dist/ClientManager-DLleL_2e.js.map +0 -1
- package/dist/Item-zBFWQDU9.js.map +0 -1
- 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/getLatestVersionRow-DVizNNoI.js +0 -59
- package/dist/cjs/getLatestVersionRow-DVizNNoI.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/generateId-BopUwD8F.js +0 -9
- package/dist/generateId-BopUwD8F.js.map +0 -1
- package/dist/getLatestVersionRow-Brrl1AnW.js +0 -46
- package/dist/getLatestVersionRow-Brrl1AnW.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-6bJuv5Tt.js.map +0 -1
- package/dist/index-B0LgJblD.js.map +0 -1
- package/dist/index-DtfjeuxC.js.map +0 -1
- package/dist/property-D2Nnsmm1.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/syncDbWithEas-LRKr_NZF.js.map +0 -1
- package/dist/tabEvents-DYI2GU7i.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
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,
|
|
7
|
-
export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError,
|
|
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 {
|
|
13
|
-
export { E as EAS_SEED_DATA_SYNCED_TO_DB_EVENT,
|
|
2
|
+
export { M as Model } from './index-DRXC5Mra.js';
|
|
3
|
+
import { s as normalizePublisher, k as isDataType, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-W1g29qsM.js';
|
|
4
|
+
export { A as AmbiguousModelError, m as eventEmitter, z as getAddressesForItemsFilter, C as normalizeAddressConfig, E as normalizeAddressList, u as normalizeHexAddress } from './db-W1g29qsM.js';
|
|
5
|
+
export { getPropertySchema } from './property-BT1zDSkd.js';
|
|
6
|
+
import { b as generateId, n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, c as getArweaveUrlForTransaction } from './tabEvents-C9qUKx_z.js';
|
|
7
|
+
export { A as ADDRESSES_PERSISTED_EVENT, F as FILES_CHANGED_EVENT, L as LOCAL_COPIES_REMOVED_EVENT, T as TabLockTimeoutError, d as classifyMediaRef, f as closestImageSize, h as ensureImageLocal, g as getCorrectId, j as getFeedItemStringField, k as isLeaderTab, i as isPublishedSeedRef, l as normalizeArweaveTxIdForEnsure, m as normalizeFeedItemFields, p as parseAddressesPersistedPayload, o as resolveMediaRef, w as whenLeaderTab } from './tabEvents-C9qUKx_z.js';
|
|
8
|
+
import { g as getContentHash } from './ClientManager-ClCwwhwo.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-ClCwwhwo.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-B9Y4VuK1.js';
|
|
11
|
+
export { C as ClientManagerState, f as ItemProperty, h as ItemPropertySaveValidationError, M as METADATA_LATEST_FIRST_ORDER_SQL, u as MachineIds, v as createNewItem, x as getEasSchemaForItemProperty, e as getGetAdditionalSyncAddresses, y as getGetPublisherForNewSeeds, z as getMetadataLatest, A as getRevokeExecutor, B as getUploadExecutor, D as getVersionData, E as isItemOwned, F as isLocalUnsealedDraft, G as isSeedRowOwned, l as listRelationEasPropertyName, H as ownedPublisherSql, J as pickLatestMetadataRowPerProperty, K as propertyMachine, L as publisherInAddressListSql, N as publisherIsInOwnedSet, O as setAdditionalSyncAddresses, P as setGetPublisherForNewSeeds, Q as setRevokeExecutor, R as setUploadExecutor } from './Item-B9Y4VuK1.js';
|
|
12
|
+
import { a as BaseDb, v as versions, r as seeds, m as metadata, h as htmlEmbeddedImageCoPublish, B as BaseFileManager, C as INTERNAL_STORAGE_MODEL_FILE_IDS, I as INTERNAL_PROPERTY_NAMES, Z as ZERO_BYTES32 } from './BasePathResolver-BdxCSIzn.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-BdxCSIzn.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
|
-
|
|
18
|
-
export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-DOhlrQ-N.js';
|
|
17
|
+
export { S as Schema, d as deleteModelFromSchema, a as deletePropertyFromModel, r as renameModelProperty, s as schemaMachine, u as updateModelProperties } from './Schema-COsEXXaR.js';
|
|
19
18
|
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-
|
|
19
|
+
export { M as MODEL_AMBIGUOUS_EVENT } from './resolveModelForSyncedSeed-CLlumTBq.js';
|
|
20
|
+
export { ModelProperty } from './ModelProperty-BMePcicQ.js';
|
|
21
|
+
export { getModelSchemasFromEas } from './eas-CSwV6MvB.js';
|
|
23
22
|
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';
|
|
23
|
+
export { u as updateSeedRevokedAt } from './updateSeedRevokedAt-D6q0h7pj.js';
|
|
24
|
+
import { a as getSegmentedItemProperties, g as getPublishDraftGraph, i as isSeedRevoked, f as findRelatedSeedRow, b as isUnpublishedSeed, h as htmlPropertyNameForHtmlSeed, r as relatedModelNameFromDef } from './publishDraftGraph-Bcfrdj7-.js';
|
|
25
|
+
export { P as PublishValidationFailedError, R as RELATED_ITEM_UNPUBLISHED_CODE, a as RelatedItemUnpublishedError, r as resolvePublishPayloadValues, v as validateItemForPublish } from './getPublishPayload-D5CQZd-y.js';
|
|
28
26
|
import 'pluralize';
|
|
29
|
-
export { itemHasPublishUploadCandidates } from './getPublishUploads-
|
|
30
|
-
import { parseFragment
|
|
27
|
+
export { itemHasPublishUploadCandidates } from './getPublishUploads-BGpDsrBp.js';
|
|
28
|
+
import { parseFragment } from 'parse5';
|
|
31
29
|
import 'js-yaml';
|
|
32
30
|
import 'fs';
|
|
33
31
|
import 'xstate';
|
|
@@ -43,7 +41,7 @@ import '@seedprotocol/query';
|
|
|
43
41
|
import 'drizzle-orm/sqlite-core';
|
|
44
42
|
import '@noble/hashes/sha3';
|
|
45
43
|
import '@noble/hashes/utils';
|
|
46
|
-
import './SchemaValidationService-
|
|
44
|
+
import './SchemaValidationService-DabGMzSE.js';
|
|
47
45
|
import '@sinclair/typebox/value';
|
|
48
46
|
import '@ethereum-attestation-service/eas-sdk';
|
|
49
47
|
|
|
@@ -531,7 +529,7 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
531
529
|
visited.add(seedLocalId);
|
|
532
530
|
const result = [];
|
|
533
531
|
const { itemRelationProperties, itemImageProperties, itemListProperties } = await getSegmentedItemProperties(item);
|
|
534
|
-
const getItemMod = await import('./getItem-
|
|
532
|
+
const getItemMod = await import('./getItem-BYQeM3DY.js');
|
|
535
533
|
const { getItem } = getItemMod;
|
|
536
534
|
const processRelationOrImage = async (prop) => {
|
|
537
535
|
const snapshot = prop.getService().getSnapshot();
|
|
@@ -550,8 +548,8 @@ async function getRelatedItemsForPublish(item, visited = new Set()) {
|
|
|
550
548
|
if (!value && prop.propertyName && isStorageSeed) {
|
|
551
549
|
const ctx = context;
|
|
552
550
|
if (ctx.seedLocalId || ctx.seedUid) {
|
|
553
|
-
const _mod_0 = await import('./Item-
|
|
554
|
-
const _ns_0 = _mod_0.
|
|
551
|
+
const _mod_0 = await import('./Item-B9Y4VuK1.js');
|
|
552
|
+
const _ns_0 = _mod_0.X;
|
|
555
553
|
const { getPropertyData } = _ns_0;
|
|
556
554
|
const meta = await getPropertyData({
|
|
557
555
|
propertyName: prop.propertyName,
|
|
@@ -645,15 +643,6 @@ function getAttr(node, name) {
|
|
|
645
643
|
const a = node.attrs?.find((x) => x.name === name);
|
|
646
644
|
return a?.value;
|
|
647
645
|
}
|
|
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
646
|
/**
|
|
658
647
|
* Walk fragment tree; collect unique data:image base64 URIs with limits.
|
|
659
648
|
*/
|
|
@@ -712,21 +701,39 @@ async function extractDataUriImagesFromHtml(html) {
|
|
|
712
701
|
await walk(c);
|
|
713
702
|
return found;
|
|
714
703
|
}
|
|
704
|
+
function escapeAttributeValue(value) {
|
|
705
|
+
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
706
|
+
}
|
|
715
707
|
/**
|
|
716
|
-
*
|
|
708
|
+
* Rewrite attribute values of `html` by splicing each new value into the original string: every
|
|
709
|
+
* byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would
|
|
710
|
+
* not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,
|
|
711
|
+
* a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),
|
|
712
|
+
* and sealed Html must not change with the serializer.
|
|
713
|
+
*
|
|
714
|
+
* `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to
|
|
715
|
+
* leave it. A rewritten attribute is written as `name="value"`.
|
|
717
716
|
*/
|
|
718
|
-
function
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const fragment = parseFragment(html);
|
|
717
|
+
function rewriteHtmlAttributes(html, rewrite) {
|
|
718
|
+
const fragment = parseFragment(html, { sourceCodeLocationInfo: true });
|
|
719
|
+
const edits = [];
|
|
722
720
|
const walk = (node) => {
|
|
723
721
|
if (node.nodeName === '#text' || node.nodeName === '#comment')
|
|
724
722
|
return;
|
|
725
723
|
const el = node;
|
|
726
|
-
if (el.
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
724
|
+
if (el.attrs?.length) {
|
|
725
|
+
for (const attr of el.attrs) {
|
|
726
|
+
if (attr.prefix)
|
|
727
|
+
continue;
|
|
728
|
+
const next = rewrite(el, attr.name, attr.value);
|
|
729
|
+
const location = el.sourceCodeLocation?.attrs?.[attr.name];
|
|
730
|
+
if (next === undefined || !location)
|
|
731
|
+
continue;
|
|
732
|
+
edits.push({
|
|
733
|
+
start: location.startOffset,
|
|
734
|
+
end: location.endOffset,
|
|
735
|
+
text: `${attr.name}="${escapeAttributeValue(next)}"`,
|
|
736
|
+
});
|
|
730
737
|
}
|
|
731
738
|
}
|
|
732
739
|
const parent = el;
|
|
@@ -737,7 +744,114 @@ function replaceDataUrisInParsedHtml(html, replacements) {
|
|
|
737
744
|
};
|
|
738
745
|
for (const c of fragment.childNodes)
|
|
739
746
|
walk(c);
|
|
740
|
-
|
|
747
|
+
let out = html;
|
|
748
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
749
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
750
|
+
}
|
|
751
|
+
return out;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those
|
|
755
|
+
* `src` attributes change; the rest of the Html is kept byte for byte.
|
|
756
|
+
*/
|
|
757
|
+
function replaceDataUrisInParsedHtml(html, replacements) {
|
|
758
|
+
if (replacements.size === 0)
|
|
759
|
+
return html;
|
|
760
|
+
return rewriteHtmlAttributes(html, (el, attrName, value) => {
|
|
761
|
+
if (el.tagName !== 'img' || attrName !== 'src')
|
|
762
|
+
return undefined;
|
|
763
|
+
return replacements.get(value.trim());
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's
|
|
768
|
+
* `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,
|
|
769
|
+
* then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a
|
|
770
|
+
* file published alongside it without embedding it (e.g. `<img class="u-featured"
|
|
771
|
+
* src="seed:property/featureImage">`).
|
|
772
|
+
*/
|
|
773
|
+
const SEED_PROPERTY_REF_PREFIX = 'seed:property/';
|
|
774
|
+
const SEED_PROPERTY_REF = /^seed:property\/([A-Za-z_$][A-Za-z0-9_$]*)$/;
|
|
775
|
+
/** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */
|
|
776
|
+
const SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster']);
|
|
777
|
+
const seedPropertyRefName = (attrName, value) => SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined;
|
|
778
|
+
/** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */
|
|
779
|
+
class HtmlSeedPropertyRefError extends Error {
|
|
780
|
+
constructor(message) {
|
|
781
|
+
super(message);
|
|
782
|
+
this.name = 'HtmlSeedPropertyRefError';
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
/** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */
|
|
786
|
+
function findSeedPropertyRefsInHtml(html) {
|
|
787
|
+
if (!html.includes(SEED_PROPERTY_REF_PREFIX))
|
|
788
|
+
return [];
|
|
789
|
+
const names = new Set();
|
|
790
|
+
rewriteHtmlAttributes(html, (_el, attrName, value) => {
|
|
791
|
+
const name = seedPropertyRefName(attrName, value);
|
|
792
|
+
if (name)
|
|
793
|
+
names.add(name);
|
|
794
|
+
return undefined;
|
|
795
|
+
});
|
|
796
|
+
return [...names];
|
|
797
|
+
}
|
|
798
|
+
/** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */
|
|
799
|
+
function replaceSeedPropertyRefsInHtml(html, urlByPropertyName) {
|
|
800
|
+
if (urlByPropertyName.size === 0)
|
|
801
|
+
return html;
|
|
802
|
+
return rewriteHtmlAttributes(html, (_el, attrName, value) => {
|
|
803
|
+
const name = seedPropertyRefName(attrName, value);
|
|
804
|
+
return name ? urlByPropertyName.get(name) : undefined;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
const SEED_PROPERTY_REF_DATA_TYPES = [
|
|
808
|
+
ModelPropertyDataTypes.Image,
|
|
809
|
+
ModelPropertyDataTypes.File,
|
|
810
|
+
ModelPropertyDataTypes.Json,
|
|
811
|
+
];
|
|
812
|
+
/**
|
|
813
|
+
* The storage property of `item` a `seed:property/<name>` placeholder names, and the seed it holds.
|
|
814
|
+
* Html properties are refused: an Html seed may itself be deferred to after the rewrite.
|
|
815
|
+
*/
|
|
816
|
+
function resolveSeedPropertyRefTarget(item, propertyName) {
|
|
817
|
+
const property = item.properties.find((p) => p.propertyName === propertyName || p.propertyName === `${propertyName}Id`);
|
|
818
|
+
const def = property?.propertyDef;
|
|
819
|
+
if (!property || !def) {
|
|
820
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${item.modelName} has no property ${propertyName}`);
|
|
821
|
+
}
|
|
822
|
+
const dataType = normalizeDataTypeLocal(def.dataType);
|
|
823
|
+
const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataTypeLocal(def.refValueType) : dataType;
|
|
824
|
+
if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {
|
|
825
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +
|
|
826
|
+
`only Image, File and Json properties can be referenced`);
|
|
827
|
+
}
|
|
828
|
+
const snap = property.getService().getSnapshot();
|
|
829
|
+
const ctx = 'context' in snap ? snap.context : null;
|
|
830
|
+
const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(ctx?.propertyValue) ?? '');
|
|
831
|
+
if (!ids.seedLocalId && !ids.seedUid) {
|
|
832
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`);
|
|
833
|
+
}
|
|
834
|
+
return ids;
|
|
835
|
+
}
|
|
836
|
+
const ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i;
|
|
837
|
+
/**
|
|
838
|
+
* The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,
|
|
839
|
+
* when not uploaded now, the transaction it was published with (its storageTransactionId).
|
|
840
|
+
*/
|
|
841
|
+
async function resolveSeedPropertyRefTxId(item, propertyName, txBySeedLocalId) {
|
|
842
|
+
const { seedLocalId, seedUid } = resolveSeedPropertyRefTarget(item, propertyName);
|
|
843
|
+
const uploaded = seedLocalId ? txBySeedLocalId.get(seedLocalId) : undefined;
|
|
844
|
+
if (uploaded)
|
|
845
|
+
return uploaded;
|
|
846
|
+
const storageItem = await Item.find({ seedLocalId, seedUid });
|
|
847
|
+
const st = storageItem?.internalProperties['storageTransactionId'] ??
|
|
848
|
+
storageItem?.allProperties['storageTransactionId'];
|
|
849
|
+
const stSnap = st?.getService().getSnapshot();
|
|
850
|
+
const stValue = stSnap && 'context' in stSnap ? stSnap.context.propertyValue : undefined;
|
|
851
|
+
if (typeof stValue === 'string' && ARWEAVE_TX_ID.test(stValue.trim()))
|
|
852
|
+
return stValue.trim();
|
|
853
|
+
throw new HtmlSeedPropertyRefError(`Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +
|
|
854
|
+
`in this publish and has no published transaction`);
|
|
741
855
|
}
|
|
742
856
|
async function deleteCoPublishRowsForParent(appDb, parentSeedLocalId) {
|
|
743
857
|
if (!appDb)
|
|
@@ -781,31 +895,16 @@ async function prepareHtmlEmbeddedImagesForPublish(item, publishPolicy) {
|
|
|
781
895
|
return { deferredHtmlSeedLocalIds: [...deferred] };
|
|
782
896
|
}
|
|
783
897
|
/**
|
|
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.
|
|
898
|
+
* Draft items (no seed uid yet) that a publish of `item` publishes with it: every draft reachable
|
|
899
|
+
* through relation and list properties, as getPublishPayload and getPublishUploads walk them
|
|
900
|
+
* (publishDraftGraph.ts). Html-embedded images of these items are co-published with `item` like its own.
|
|
787
901
|
*/
|
|
788
902
|
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;
|
|
903
|
+
const _mod_1 = await import('./publishDraftGraph-Bcfrdj7-.js');
|
|
904
|
+
const _ns_1 = _mod_1.p;
|
|
905
|
+
const { getPublishDraftGraph } = _ns_1;
|
|
906
|
+
const { drafts } = await getPublishDraftGraph(item);
|
|
907
|
+
return drafts.map((d) => d.item);
|
|
809
908
|
}
|
|
810
909
|
async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, deferred) {
|
|
811
910
|
await deleteCoPublishRowsForParent(appDb, item.seedLocalId);
|
|
@@ -813,9 +912,6 @@ async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, defer
|
|
|
813
912
|
const def = p.propertyDef;
|
|
814
913
|
if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
|
|
815
914
|
continue;
|
|
816
|
-
const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(def, publishPolicy);
|
|
817
|
-
if (policy !== 'materialize')
|
|
818
|
-
continue;
|
|
819
915
|
const snap = p.getService().getSnapshot();
|
|
820
916
|
const ctx = 'context' in snap ? snap.context : null;
|
|
821
917
|
const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue : '';
|
|
@@ -846,15 +942,17 @@ async function prepareHtmlEmbeddedImagesOfItem(appDb, item, publishPolicy, defer
|
|
|
846
942
|
html = new TextDecoder('utf-8', { fatal: false }).decode(new Uint8Array(v.buffer, v.byteOffset, v.byteLength));
|
|
847
943
|
}
|
|
848
944
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
945
|
+
// seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A
|
|
946
|
+
// placeholder naming no usable property fails here, before anything is uploaded.
|
|
947
|
+
const refs = findSeedPropertyRefsInHtml(html);
|
|
948
|
+
for (const name of refs)
|
|
949
|
+
resolveSeedPropertyRefTarget(item, name);
|
|
950
|
+
if (refs.length > 0)
|
|
951
|
+
deferred.add(htmlSeedLocalId.trim());
|
|
952
|
+
const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(def, publishPolicy);
|
|
953
|
+
if (policy !== 'materialize')
|
|
954
|
+
continue;
|
|
955
|
+
const extracted = await extractDataUriImagesFromHtml(html);
|
|
858
956
|
if (extracted.length === 0)
|
|
859
957
|
continue;
|
|
860
958
|
deferred.add(htmlSeedLocalId.trim());
|
|
@@ -877,70 +975,73 @@ function normalizeDataTypeLocal(dt) {
|
|
|
877
975
|
return dt.charAt(0).toUpperCase() + dt.slice(1).toLowerCase();
|
|
878
976
|
}
|
|
879
977
|
/**
|
|
880
|
-
* After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL
|
|
978
|
+
* After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and
|
|
979
|
+
* `seed:property/<name>` → the gateway URL of that property's upload.
|
|
980
|
+
*
|
|
981
|
+
* `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to
|
|
982
|
+
* the Html held back from phase 1; without it, every Html of the item and its co-published drafts is
|
|
983
|
+
* considered.
|
|
881
984
|
*/
|
|
882
|
-
async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions) {
|
|
985
|
+
async function rewriteHtmlEmbeddedImagesOnDisk(parentSeedLocalId, uploadedTransactions, deferredHtmlSeedLocalIds) {
|
|
883
986
|
const appDb = BaseDb.getAppDb();
|
|
884
987
|
if (!appDb)
|
|
885
988
|
return;
|
|
886
989
|
const parentItem = await Item.find({ seedLocalId: parentSeedLocalId });
|
|
887
990
|
if (!parentItem)
|
|
888
991
|
return;
|
|
889
|
-
const
|
|
992
|
+
const txBySeedLocalId = new Map();
|
|
890
993
|
for (const u of uploadedTransactions) {
|
|
891
994
|
if (u.seedLocalId && u.txId) {
|
|
892
|
-
|
|
995
|
+
txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim());
|
|
893
996
|
}
|
|
894
997
|
}
|
|
998
|
+
const deferred = deferredHtmlSeedLocalIds
|
|
999
|
+
? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))
|
|
1000
|
+
: undefined;
|
|
895
1001
|
// The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).
|
|
896
1002
|
for (const item of [parentItem, ...(await getRelatedDraftsCoPublishedWith(parentItem))]) {
|
|
897
|
-
await rewriteHtmlEmbeddedImagesOfItem(appDb, item,
|
|
1003
|
+
await rewriteHtmlEmbeddedImagesOfItem(appDb, item, txBySeedLocalId, deferred);
|
|
898
1004
|
}
|
|
899
1005
|
}
|
|
900
|
-
async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem,
|
|
1006
|
+
async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem, txBySeedLocalId, deferred) {
|
|
901
1007
|
const rows = await appDb
|
|
902
1008
|
.select()
|
|
903
1009
|
.from(htmlEmbeddedImageCoPublish)
|
|
904
1010
|
.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)
|
|
1011
|
+
for (const p of parentItem.properties) {
|
|
1012
|
+
const def = p.propertyDef;
|
|
1013
|
+
if (!def || normalizeDataTypeLocal(def.dataType) !== ModelPropertyDataTypes.Html)
|
|
925
1014
|
continue;
|
|
1015
|
+
const snap = p.getService().getSnapshot();
|
|
1016
|
+
const ctx = 'context' in snap ? snap.context : null;
|
|
1017
|
+
const htmlSeedLocalId = typeof ctx?.propertyValue === 'string' ? ctx.propertyValue.trim() : '';
|
|
1018
|
+
const refResolved = ctx?.refResolvedValue;
|
|
1019
|
+
if (!htmlSeedLocalId || !refResolved)
|
|
1020
|
+
continue;
|
|
1021
|
+
if (deferred && !deferred.has(htmlSeedLocalId))
|
|
1022
|
+
continue;
|
|
1023
|
+
const htmlRows = rows.filter((r) => String(r.htmlSeedLocalId).trim() === htmlSeedLocalId);
|
|
926
1024
|
const filePath = `${BaseFileManager.getFilesPath('html')}/${refResolved}`;
|
|
927
1025
|
if (!(await BaseFileManager.pathExists(filePath)))
|
|
928
1026
|
continue;
|
|
929
1027
|
const html = await BaseFileManager.readFileAsString(filePath);
|
|
930
1028
|
const replacements = new Map();
|
|
931
|
-
for (const r of
|
|
932
|
-
|
|
933
|
-
continue;
|
|
934
|
-
const txId = txByImageSeed.get(r.imageSeedLocalId.trim());
|
|
1029
|
+
for (const r of htmlRows) {
|
|
1030
|
+
const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim());
|
|
935
1031
|
if (!txId)
|
|
936
1032
|
continue;
|
|
937
1033
|
const dataUri = await findDataUriForStableKey(html, r.stableKey);
|
|
938
1034
|
if (dataUri)
|
|
939
1035
|
replacements.set(dataUri, getArweaveUrlForTransaction(txId));
|
|
940
1036
|
}
|
|
941
|
-
|
|
1037
|
+
const urlByPropertyName = new Map();
|
|
1038
|
+
for (const name of findSeedPropertyRefsInHtml(html)) {
|
|
1039
|
+
const txId = await resolveSeedPropertyRefTxId(parentItem, name, txBySeedLocalId);
|
|
1040
|
+
urlByPropertyName.set(name, getArweaveUrlForTransaction(txId));
|
|
1041
|
+
}
|
|
1042
|
+
const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName);
|
|
1043
|
+
if (newHtml === html)
|
|
942
1044
|
continue;
|
|
943
|
-
const newHtml = replaceDataUrisInParsedHtml(html, replacements);
|
|
944
1045
|
try {
|
|
945
1046
|
await BaseFileManager.saveFile(filePath, newHtml);
|
|
946
1047
|
}
|
|
@@ -948,19 +1049,10 @@ async function rewriteHtmlEmbeddedImagesOfItem(appDb, parentItem, txByImageSeed)
|
|
|
948
1049
|
const fs = await BaseFileManager.getFs();
|
|
949
1050
|
fs.writeFileSync(filePath, newHtml);
|
|
950
1051
|
}
|
|
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
|
-
}
|
|
1052
|
+
p.getService().send({
|
|
1053
|
+
type: 'updateContext',
|
|
1054
|
+
renderValue: newHtml,
|
|
1055
|
+
});
|
|
964
1056
|
}
|
|
965
1057
|
}
|
|
966
1058
|
async function findDataUriForStableKey(html, stableKey) {
|
|
@@ -1127,7 +1219,7 @@ async function loadRelatedItem(value) {
|
|
|
1127
1219
|
const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalized);
|
|
1128
1220
|
if (!seedLocalId && !seedUid)
|
|
1129
1221
|
return undefined;
|
|
1130
|
-
const { getItem } = await import('./getItem-
|
|
1222
|
+
const { getItem } = await import('./getItem-BYQeM3DY.js');
|
|
1131
1223
|
try {
|
|
1132
1224
|
return await getItem({ seedLocalId, seedUid });
|
|
1133
1225
|
}
|
|
@@ -1144,25 +1236,6 @@ async function relatedIfUnpublished(prop) {
|
|
|
1144
1236
|
return undefined;
|
|
1145
1237
|
return related;
|
|
1146
1238
|
}
|
|
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
1239
|
/** Seed refs held by a relation/image property (one) or a list property (each member). */
|
|
1167
1240
|
function seedRefsOf(prop, isList) {
|
|
1168
1241
|
const context = propertyContext(prop);
|
|
@@ -1180,7 +1253,7 @@ function seedRefsOf(prop, isList) {
|
|
|
1180
1253
|
return ref ? [ref] : [];
|
|
1181
1254
|
}
|
|
1182
1255
|
/** Like getPublishPayload: attested refs to revoked seeds block the publish. */
|
|
1183
|
-
async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot, out) {
|
|
1256
|
+
async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot, out, backReferences) {
|
|
1184
1257
|
for (const prop of props) {
|
|
1185
1258
|
if (!shouldAttestProperty(prop, forceFullSnapshot))
|
|
1186
1259
|
continue;
|
|
@@ -1189,6 +1262,10 @@ async function collectUnpublishedRelatedItems(props, isList, forceFullSnapshot,
|
|
|
1189
1262
|
if (!seedLocalId && !seedUid)
|
|
1190
1263
|
continue;
|
|
1191
1264
|
const row = await findRelatedSeedRow({ seedLocalId, seedUid });
|
|
1265
|
+
// A back reference to a seed this publish creates (e.g. a revoked root published again) is
|
|
1266
|
+
// left for a later publish, not attested (publishDraftGraph.ts)
|
|
1267
|
+
if (row && backReferences?.get(prop)?.has(row.seedLocalId))
|
|
1268
|
+
continue;
|
|
1192
1269
|
if (!isUnpublishedSeed(row))
|
|
1193
1270
|
continue;
|
|
1194
1271
|
if (out.some((r) => r.propertyName === prop.propertyName && r.seedLocalId === row.seedLocalId)) {
|
|
@@ -1229,7 +1306,7 @@ async function collectUnpublishedEmbeddedImages(item, out) {
|
|
|
1229
1306
|
}
|
|
1230
1307
|
}
|
|
1231
1308
|
}
|
|
1232
|
-
async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot, publishMode) {
|
|
1309
|
+
async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot, publishMode, graph) {
|
|
1233
1310
|
const appDb = BaseDb.getAppDb();
|
|
1234
1311
|
if (!appDb)
|
|
1235
1312
|
return;
|
|
@@ -1238,9 +1315,9 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
|
|
|
1238
1315
|
.from(htmlEmbeddedImageCoPublish)
|
|
1239
1316
|
.where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId));
|
|
1240
1317
|
for (const row of rows) {
|
|
1241
|
-
const
|
|
1242
|
-
const
|
|
1243
|
-
const { Item } =
|
|
1318
|
+
const _mod_2 = await import('./Item-B9Y4VuK1.js');
|
|
1319
|
+
const _ns_2 = _mod_2.Y;
|
|
1320
|
+
const { Item } = _ns_2;
|
|
1244
1321
|
const imageItem = await Item.find({
|
|
1245
1322
|
seedLocalId: row.imageSeedLocalId,
|
|
1246
1323
|
modelName: 'Image',
|
|
@@ -1257,10 +1334,10 @@ async function appendCoPublishImages(item, acc, seen, visited, forceFullSnapshot
|
|
|
1257
1334
|
if (dataUriBytes != null && dataUriBytes > 0) {
|
|
1258
1335
|
await addUpload(acc, seen, `seed:${imageItem.seedLocalId}`, dataUriBytes);
|
|
1259
1336
|
}
|
|
1260
|
-
await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited);
|
|
1337
|
+
await summarizeItem(imageItem, publishMode, forceFullSnapshot, acc, seen, visited, graph);
|
|
1261
1338
|
}
|
|
1262
1339
|
}
|
|
1263
|
-
async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUploads, visited) {
|
|
1340
|
+
async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph) {
|
|
1264
1341
|
const seedLocalId = item.seedLocalId;
|
|
1265
1342
|
if (!seedLocalId || visited.has(seedLocalId))
|
|
1266
1343
|
return;
|
|
@@ -1272,20 +1349,20 @@ async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUplo
|
|
|
1272
1349
|
acc.newVersionCount += 1;
|
|
1273
1350
|
const { itemBasicProperties, itemRelationProperties, itemListProperties, itemUploadProperties, itemImageProperties, } = await getSegmentedItemProperties(item);
|
|
1274
1351
|
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);
|
|
1352
|
+
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, acc.unpublishedRelatedItems, graph.backReferences);
|
|
1353
|
+
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, acc.unpublishedRelatedItems, graph.backReferences);
|
|
1354
|
+
// Draft Image/File/Html/Json items its storage relations point at. Draft model items its relations
|
|
1355
|
+
// and lists reach are summarized by summarizePublishWork from the publish's draft graph.
|
|
1356
|
+
const storageProperties = new Set(itemImageProperties);
|
|
1277
1357
|
for (const rel of itemRelationProperties) {
|
|
1358
|
+
if (!storageProperties.has(rel))
|
|
1359
|
+
continue;
|
|
1278
1360
|
const related = await relatedIfUnpublished(rel);
|
|
1279
1361
|
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);
|
|
1362
|
+
await summarizeItem(related, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph);
|
|
1286
1363
|
}
|
|
1287
1364
|
}
|
|
1288
|
-
await appendCoPublishImages(item, acc, seenUploads, visited, forceFullSnapshot, publishMode);
|
|
1365
|
+
await appendCoPublishImages(item, acc, seenUploads, visited, forceFullSnapshot, publishMode, graph);
|
|
1289
1366
|
const attestable = [
|
|
1290
1367
|
...itemBasicProperties,
|
|
1291
1368
|
...itemRelationProperties,
|
|
@@ -1299,6 +1376,9 @@ async function summarizeItem(item, publishMode, forceFullSnapshot, acc, seenUplo
|
|
|
1299
1376
|
if (seenProps.has(key))
|
|
1300
1377
|
continue;
|
|
1301
1378
|
seenProps.add(key);
|
|
1379
|
+
// A ref back to an item this publish creates is left for a later publish (publishDraftGraph.ts).
|
|
1380
|
+
if (graph.deferredProperties.has(prop))
|
|
1381
|
+
continue;
|
|
1302
1382
|
if (shouldAttestProperty(prop, forceFullSnapshot))
|
|
1303
1383
|
acc.attestationCount += 1;
|
|
1304
1384
|
}
|
|
@@ -1313,25 +1393,10 @@ const publishForcesFullSnapshot = async (item, publishMode) => {
|
|
|
1313
1393
|
const republishRevokedSeed = !isZeroUid(item.seedUid) && (await isSeedRevoked(item.seedLocalId));
|
|
1314
1394
|
return { republishRevokedSeed, forceFullSnapshot: publishMode === 'new_version' || republishRevokedSeed };
|
|
1315
1395
|
};
|
|
1316
|
-
async function
|
|
1317
|
-
const seedLocalId = item.seedLocalId;
|
|
1318
|
-
if (!seedLocalId || visited.has(seedLocalId))
|
|
1319
|
-
return;
|
|
1320
|
-
visited.add(seedLocalId);
|
|
1396
|
+
async function collectUnpublishedRelatedItemsOf(item, forceFullSnapshot, out, backReferences) {
|
|
1321
1397
|
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
|
-
}
|
|
1398
|
+
await collectUnpublishedRelatedItems([...itemRelationProperties, ...itemImageProperties], false, forceFullSnapshot, out, backReferences);
|
|
1399
|
+
await collectUnpublishedRelatedItems(itemListProperties, true, forceFullSnapshot, out, backReferences);
|
|
1335
1400
|
}
|
|
1336
1401
|
/**
|
|
1337
1402
|
* References a publish of `item` would attest to items whose seed was unpublished (revoked), the
|
|
@@ -1341,7 +1406,11 @@ async function collectUnpublishedRelatedItemsDeep(item, forceFullSnapshot, out,
|
|
|
1341
1406
|
const getUnpublishedRelatedItems = async (item, options) => {
|
|
1342
1407
|
const { forceFullSnapshot } = await publishForcesFullSnapshot(item, options?.publishMode ?? 'patch');
|
|
1343
1408
|
const out = [];
|
|
1344
|
-
|
|
1409
|
+
// The item and every draft its publish carries along (publishDraftGraph.ts).
|
|
1410
|
+
const { drafts, backReferences } = await getPublishDraftGraph(item, { forceFullSnapshot });
|
|
1411
|
+
for (const owner of [item, ...drafts.map((d) => d.item)]) {
|
|
1412
|
+
await collectUnpublishedRelatedItemsOf(owner, forceFullSnapshot, out, backReferences);
|
|
1413
|
+
}
|
|
1345
1414
|
await collectUnpublishedEmbeddedImages(item, out);
|
|
1346
1415
|
return out;
|
|
1347
1416
|
};
|
|
@@ -1358,7 +1427,13 @@ const summarizePublishWork = async (item, options) => {
|
|
|
1358
1427
|
uploadBytes: 0,
|
|
1359
1428
|
unpublishedRelatedItems: [],
|
|
1360
1429
|
};
|
|
1361
|
-
await
|
|
1430
|
+
const graph = await getPublishDraftGraph(item, { forceFullSnapshot });
|
|
1431
|
+
const { drafts } = graph;
|
|
1432
|
+
const seenUploads = new Set();
|
|
1433
|
+
const visited = new Set();
|
|
1434
|
+
for (const owner of [item, ...drafts.map((d) => d.item)]) {
|
|
1435
|
+
await summarizeItem(owner, publishMode, forceFullSnapshot, acc, seenUploads, visited, graph);
|
|
1436
|
+
}
|
|
1362
1437
|
await collectUnpublishedEmbeddedImages(item, acc.unpublishedRelatedItems);
|
|
1363
1438
|
// summarizeItem counts the root as an existing seed (it has a seedUid).
|
|
1364
1439
|
if (republishRevokedSeed)
|
|
@@ -1366,5 +1441,5 @@ const summarizePublishWork = async (item, options) => {
|
|
|
1366
1441
|
return acc;
|
|
1367
1442
|
};
|
|
1368
1443
|
|
|
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 };
|
|
1444
|
+
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
1445
|
//# sourceMappingURL=main.js.map
|