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