@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
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { p as resolveModelRecord, q as getItemModelScope, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-W1g29qsM.js';
|
|
2
|
+
import { Z as ZERO_BYTES32, a as BaseDb, p as properties, V as VERSION_SCHEMA_UID, j as models, h as htmlEmbeddedImageCoPublish, I as INTERNAL_PROPERTY_NAMES, w as defaultAttestationData, x as INTERNAL_DATA_TYPES } from './BasePathResolver-BdxCSIzn.js';
|
|
3
3
|
import { SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
4
|
-
import { r as resolveSeedIdsFromRefString, n as normalizeRelationPropertyValue, i as isPublishedSeedRef, g as getCorrectId, a as isStorageSeedRef, t as toSnakeCase$1 } from './tabEvents-
|
|
4
|
+
import { r as resolveSeedIdsFromRefString, n as normalizeRelationPropertyValue, i as isPublishedSeedRef, g as getCorrectId, a as isStorageSeedRef, t as toSnakeCase$1 } from './tabEvents-C9qUKx_z.js';
|
|
5
5
|
import { toSnakeCase } from 'drizzle-orm/casing';
|
|
6
|
-
import {
|
|
6
|
+
import { a as getEasSchemaUidForModel, b as getLatestPublishedVersionRow, p as parseListPropertyValueFromStorage, l as listRelationEasPropertyName } from './Item-B9Y4VuK1.js';
|
|
7
7
|
import { isValidEasAttestationUid, getEasSchemaUidForSchemaDefinition } from '@seedprotocol/eas';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { getPropertySchema } from './property-D2Nnsmm1.js';
|
|
8
|
+
import { i as isSeedRevoked, a as getSegmentedItemProperties, f as findRelatedSeedRow, r as relatedModelNameFromDef, h as htmlPropertyNameForHtmlSeed, b as isUnpublishedSeed, c as isLivePublishedSeed, d as draftWalkProperties } from './publishDraftGraph-Bcfrdj7-.js';
|
|
9
|
+
import { getPropertySchema } from './property-BT1zDSkd.js';
|
|
11
10
|
import { modelPropertiesToObject } from './model-DGMe-TTm.js';
|
|
12
11
|
import { upperFirst, camelCase } from 'lodash-es';
|
|
12
|
+
import { and, eq, sql } from 'drizzle-orm';
|
|
13
13
|
import debug from 'debug';
|
|
14
14
|
import '@noble/hashes/sha3';
|
|
15
15
|
import '@noble/hashes/utils';
|
|
16
16
|
import 'reflect-metadata';
|
|
17
|
-
import './index-
|
|
18
|
-
import 'pluralize';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS
|
|
22
|
-
* sync). Such a seed can't take new versions: publishing again creates a new seed attestation
|
|
23
|
-
* (see "Republishing" in docs/ATTESTATION_REVOCATION.md).
|
|
24
|
-
*/
|
|
25
|
-
const isSeedRevoked = async (seedLocalId) => {
|
|
26
|
-
if (!seedLocalId)
|
|
27
|
-
return false;
|
|
28
|
-
const appDb = BaseDb.getAppDb();
|
|
29
|
-
if (!appDb)
|
|
30
|
-
return false;
|
|
31
|
-
const [row] = await appDb
|
|
32
|
-
.select({ revokedAt: seeds.revokedAt })
|
|
33
|
-
.from(seeds)
|
|
34
|
-
.where(eq(seeds.localId, seedLocalId))
|
|
35
|
-
.limit(1);
|
|
36
|
-
return isVersionRevoked(row?.revokedAt);
|
|
37
|
-
};
|
|
17
|
+
import './index-DRXC5Mra.js';
|
|
38
18
|
|
|
39
19
|
/** UTF-8 string to 0x-prefixed bytes32 hex (right-padded with zeros). */
|
|
40
20
|
function encodeBytes32String(value) {
|
|
@@ -88,84 +68,17 @@ class RelatedItemUnpublishedError extends PublishValidationFailedError {
|
|
|
88
68
|
}
|
|
89
69
|
}
|
|
90
70
|
|
|
91
|
-
const selectSeed = {
|
|
92
|
-
seedLocalId: seeds.localId,
|
|
93
|
-
seedUid: seeds.uid,
|
|
94
|
-
revokedAt: seeds.revokedAt,
|
|
95
|
-
type: seeds.type,
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* The local seed row a relation/list/image ref points at, by local id or uid. A uid that is no
|
|
99
|
-
* seed's current uid can be the old uid of a seed that was unpublished and published again (a new
|
|
100
|
-
* seed attestation, same local seed): its old version rows still record it, so it resolves to that
|
|
101
|
-
* seed. Null when nothing local matches (e.g. a published uid with no local copy).
|
|
102
|
-
*/
|
|
103
|
-
const findRelatedSeedRow = async ({ seedLocalId, seedUid, }) => {
|
|
104
|
-
const appDb = BaseDb.getAppDb();
|
|
105
|
-
if (!appDb)
|
|
106
|
-
return null;
|
|
107
|
-
if (seedLocalId) {
|
|
108
|
-
const [row] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.localId, seedLocalId)).limit(1);
|
|
109
|
-
if (row?.seedLocalId)
|
|
110
|
-
return row;
|
|
111
|
-
}
|
|
112
|
-
if (!seedUid || seedUid === ZERO_BYTES32)
|
|
113
|
-
return null;
|
|
114
|
-
const [byUid] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.uid, seedUid)).limit(1);
|
|
115
|
-
if (byUid?.seedLocalId)
|
|
116
|
-
return byUid;
|
|
117
|
-
const [version] = await appDb
|
|
118
|
-
.select({ seedLocalId: versions.seedLocalId })
|
|
119
|
-
.from(versions)
|
|
120
|
-
.where(and(eq(versions.seedUid, seedUid), isNotNull(versions.seedLocalId)))
|
|
121
|
-
.limit(1);
|
|
122
|
-
if (!version?.seedLocalId)
|
|
123
|
-
return null;
|
|
124
|
-
const [republished] = await appDb
|
|
125
|
-
.select(selectSeed)
|
|
126
|
-
.from(seeds)
|
|
127
|
-
.where(eq(seeds.localId, version.seedLocalId))
|
|
128
|
-
.limit(1);
|
|
129
|
-
return republished?.seedLocalId ? republished : null;
|
|
130
|
-
};
|
|
131
|
-
/** The seed is attested and its attestation is live. */
|
|
132
|
-
const isLivePublishedSeed = (row) => !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt);
|
|
133
|
-
/** The seed was attested and that attestation was revoked (unpublished). */
|
|
134
|
-
const isUnpublishedSeed = (row) => !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt);
|
|
135
|
-
/** Model a relation/list/image property points at, from its definition. */
|
|
136
|
-
function relatedModelNameFromDef(propertyDef) {
|
|
137
|
-
const def = propertyDef;
|
|
138
|
-
if (!def)
|
|
139
|
-
return undefined;
|
|
140
|
-
const dataType = normalizeDataType(def.dataType);
|
|
141
|
-
if (dataType === ModelPropertyDataTypes.Image)
|
|
142
|
-
return 'Image';
|
|
143
|
-
if (dataType === ModelPropertyDataTypes.File)
|
|
144
|
-
return 'File';
|
|
145
|
-
if (dataType === ModelPropertyDataTypes.Html)
|
|
146
|
-
return 'Html';
|
|
147
|
-
return def.ref ?? def.refModelName;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Name of the item's Html property whose value is the Html seed `htmlSeedLocalId`: the property
|
|
151
|
-
* that refers to the images embedded in that Html (htmlEmbeddedImageCoPublish rows).
|
|
152
|
-
*/
|
|
153
|
-
function htmlPropertyNameForHtmlSeed(item, htmlSeedLocalId) {
|
|
154
|
-
const want = htmlSeedLocalId.trim();
|
|
155
|
-
for (const p of item.properties ?? []) {
|
|
156
|
-
if (normalizeDataType(p.propertyDef?.dataType) !== ModelPropertyDataTypes.Html)
|
|
157
|
-
continue;
|
|
158
|
-
const snap = p.getService().getSnapshot();
|
|
159
|
-
const value = 'context' in snap ? snap.context.propertyValue : undefined;
|
|
160
|
-
if (typeof value === 'string' && value.trim() === want)
|
|
161
|
-
return p.propertyName;
|
|
162
|
-
}
|
|
163
|
-
return 'html';
|
|
164
|
-
}
|
|
165
|
-
|
|
166
71
|
debug('seedSdk:db:getPublishPayload');
|
|
167
72
|
/** Case-insensitive dataType match (schema JSON may use "text" vs "Text"). */
|
|
168
73
|
const matchesDataType = (actual, expected) => normalizeDataType(actual) === expected;
|
|
74
|
+
/** True (and the property is deferred) when `targetSeedLocalId` is an item still in progress. */
|
|
75
|
+
function deferIfBackEdge(ctx, property, targetSeedLocalIds) {
|
|
76
|
+
if (!targetSeedLocalIds.some((id) => !!id && ctx.newSeedsInProgress?.has(id)))
|
|
77
|
+
return false;
|
|
78
|
+
ctx.deferredProperties ?? (ctx.deferredProperties = new Set());
|
|
79
|
+
ctx.deferredProperties.add(property);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
169
82
|
/**
|
|
170
83
|
* Checks the seed a relation/list/image ref points at. A revoked (unpublished) seed is recorded in
|
|
171
84
|
* `ctx.unpublishedRelatedItems`; a live published one maps the ref to its current uid. Returns
|
|
@@ -197,6 +110,13 @@ function noteRelatedSeed(ctx, ref, row, propertyName, modelName) {
|
|
|
197
110
|
function currentRelatedRef(ctx, ref) {
|
|
198
111
|
return ctx.relatedRefUids?.get(ref.trim()) ?? ref;
|
|
199
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* An EAS uid (0x + 64 hex), as opposed to a local id. A "0x" prefix alone doesn't tell them apart:
|
|
115
|
+
* local ids are random alphanumerics, and about 1 in 3,844 starts with "0x".
|
|
116
|
+
*/
|
|
117
|
+
function isUidRef(ref) {
|
|
118
|
+
return ref.length === 66 && ref.startsWith('0x');
|
|
119
|
+
}
|
|
200
120
|
function addValidationError(ctx, message, field, code = 'publish_validation') {
|
|
201
121
|
// A property can be validated on more than one path (List of Relation: list + basic); report once.
|
|
202
122
|
if (ctx.errors.some((e) => e.message === message && e.field === (field ?? '')))
|
|
@@ -278,7 +198,7 @@ async function resolveVersionUid(seedLocalId, seedUid) {
|
|
|
278
198
|
if (published?.uid)
|
|
279
199
|
return published.uid;
|
|
280
200
|
try {
|
|
281
|
-
const { getItemVersionsFromEas } = await import('./eas-
|
|
201
|
+
const { getItemVersionsFromEas } = await import('./eas-CSwV6MvB.js');
|
|
282
202
|
const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] });
|
|
283
203
|
const latest = attestations?.[0];
|
|
284
204
|
if (latest?.id)
|
|
@@ -345,8 +265,8 @@ const ensurePropertyDefs = async (targetItem) => {
|
|
|
345
265
|
schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName, targetScope);
|
|
346
266
|
if (!schema) {
|
|
347
267
|
try {
|
|
348
|
-
const _mod_0 = await import('./index-
|
|
349
|
-
const _ns_0 = _mod_0.
|
|
268
|
+
const _mod_0 = await import('./index-DRXC5Mra.js');
|
|
269
|
+
const _ns_0 = _mod_0.f;
|
|
350
270
|
const { Model } = _ns_0;
|
|
351
271
|
const normalizedModelName = upperFirst(camelCase(targetItem.modelName));
|
|
352
272
|
let model = Model.resolve(normalizedModelName, targetScope);
|
|
@@ -423,6 +343,9 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
423
343
|
if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {
|
|
424
344
|
continue;
|
|
425
345
|
}
|
|
346
|
+
if (ctx.deferredProperties?.has(basicProperty)) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
426
349
|
const snapshot = basicProperty.getService().getSnapshot();
|
|
427
350
|
const context = 'context' in snapshot ? snapshot.context : null;
|
|
428
351
|
const propertyDef = basicProperty.propertyDef ?? (context ? context.propertyRecordSchema : undefined);
|
|
@@ -513,7 +436,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
513
436
|
}
|
|
514
437
|
// Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
|
|
515
438
|
if (propertyDef?.validation) {
|
|
516
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
439
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-DabGMzSE.js');
|
|
517
440
|
const validationService = new SchemaValidationService();
|
|
518
441
|
const validationResult = validationService.validatePropertyValue(value, normalizeDataType(propertyDef.dataType), propertyDef.validation, propertyDef.refValueType
|
|
519
442
|
? normalizeDataType(propertyDef.refValueType)
|
|
@@ -548,7 +471,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
548
471
|
if (!trimmed)
|
|
549
472
|
continue;
|
|
550
473
|
rawIds.push(trimmed);
|
|
551
|
-
if (
|
|
474
|
+
if (!isUidRef(trimmed)) {
|
|
552
475
|
newValues.push(encodeBytes32String(trimmed));
|
|
553
476
|
}
|
|
554
477
|
else {
|
|
@@ -556,7 +479,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
556
479
|
}
|
|
557
480
|
}
|
|
558
481
|
value = newValues;
|
|
559
|
-
const needsUidResolve = rawIds.some((id) =>
|
|
482
|
+
const needsUidResolve = rawIds.some((id) => !isUidRef(id));
|
|
560
483
|
if (needsUidResolve && rawIds.length > 0) {
|
|
561
484
|
rawListIdsForResolve = rawIds;
|
|
562
485
|
}
|
|
@@ -600,8 +523,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
600
523
|
};
|
|
601
524
|
// For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues
|
|
602
525
|
const looksLikeLocalSeedRef = typeof value === 'string' &&
|
|
603
|
-
!value
|
|
604
|
-
value.length !== 66 &&
|
|
526
|
+
!isUidRef(value) &&
|
|
605
527
|
/^[a-zA-Z0-9_-]{10,21}$/.test(value.trim());
|
|
606
528
|
if (looksLikeLocalSeedRef &&
|
|
607
529
|
(easDataType === 'bytes32' || easDataType === 'string')) {
|
|
@@ -653,8 +575,8 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
653
575
|
matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Html) ||
|
|
654
576
|
matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Json)));
|
|
655
577
|
if (isStorageSeed && (context.seedLocalId || context.seedUid)) {
|
|
656
|
-
const _mod_1 = await import('./Item-
|
|
657
|
-
const _ns_1 = _mod_1.
|
|
578
|
+
const _mod_1 = await import('./Item-B9Y4VuK1.js');
|
|
579
|
+
const _ns_1 = _mod_1.X;
|
|
658
580
|
const { getPropertyData: getPropertyDataFromDb } = _ns_1;
|
|
659
581
|
const metaRow = await getPropertyDataFromDb({
|
|
660
582
|
propertyName: relationOrImageProperty.propertyName,
|
|
@@ -740,8 +662,11 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
740
662
|
}
|
|
741
663
|
// The local seed, also when the ref is the old uid of a seed published again since.
|
|
742
664
|
const relatedSeed = await findRelatedSeedRow({ seedLocalId, seedUid });
|
|
665
|
+
if (!isStorageSeed && deferIfBackEdge(ctx, relationOrImageProperty, [relatedSeed?.seedLocalId ?? seedLocalId])) {
|
|
666
|
+
return multiPublishPayload;
|
|
667
|
+
}
|
|
743
668
|
// Use dynamic import to break circular dependency
|
|
744
|
-
const getItemMod = await import('./getItem-
|
|
669
|
+
const getItemMod = await import('./getItem-BYQeM3DY.js');
|
|
745
670
|
const { getItem } = getItemMod;
|
|
746
671
|
const relatedItem = await getItem(relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid });
|
|
747
672
|
if (noteRelatedSeed(ctx, normalizedRef, relatedSeed, relationOrImageProperty.propertyName, relatedItem?.modelName ?? relatedModelNameFromDef(relationOrImageProperty.propertyDef))) {
|
|
@@ -761,7 +686,6 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
761
686
|
if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
|
|
762
687
|
return multiPublishPayload;
|
|
763
688
|
}
|
|
764
|
-
const versionUid = getVersionUid(relatedItem);
|
|
765
689
|
let modelName;
|
|
766
690
|
if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {
|
|
767
691
|
modelName = 'Image';
|
|
@@ -780,68 +704,106 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
780
704
|
addValidationError(ctx, `Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`, relationOrImageProperty.propertyName);
|
|
781
705
|
return multiPublishPayload;
|
|
782
706
|
}
|
|
707
|
+
return processRelatedDraftItem({
|
|
708
|
+
relatedItem,
|
|
709
|
+
modelName,
|
|
710
|
+
// A storage seed (Image/File/Html/Json item) attests its own basic properties; a related model
|
|
711
|
+
// item is published with its full property set and the draft items it reaches in turn.
|
|
712
|
+
fullDraft: !isStorageSeed,
|
|
713
|
+
link: { publishLocalId: originalSeedLocalId, propertySchemaUid: relationOrImageSchemaUid },
|
|
714
|
+
reportPropertyName: relationOrImageProperty.propertyName,
|
|
715
|
+
multiPublishPayload,
|
|
716
|
+
uploadedTransactions,
|
|
717
|
+
ctx,
|
|
718
|
+
buildOpts,
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
/**
|
|
722
|
+
* The payload of a draft item (no seed uid) a published item refers to, published with it. Its
|
|
723
|
+
* request fills the referring property (`link`) through propertiesToUpdate. With `fullDraft`, the
|
|
724
|
+
* item's whole property set is attested: its storage seeds and Html-embedded images, and its own
|
|
725
|
+
* relation and list properties, whose draft targets are published with it in turn (depth first,
|
|
726
|
+
* see publishDraftGraph.ts). A draft already in the batch only gains the link.
|
|
727
|
+
*/
|
|
728
|
+
async function processRelatedDraftItem({ relatedItem, modelName, fullDraft, link, reportPropertyName, multiPublishPayload, uploadedTransactions, ctx, buildOpts, }) {
|
|
729
|
+
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
783
730
|
const seedSchemaUid = await getEasSchemaUidForModel(modelName);
|
|
784
731
|
if (!seedSchemaUid) {
|
|
785
|
-
addValidationError(ctx, `Schema UID not found for model: ${modelName}`,
|
|
732
|
+
addValidationError(ctx, `Schema UID not found for model: ${modelName}`, reportPropertyName);
|
|
786
733
|
return multiPublishPayload;
|
|
787
734
|
}
|
|
788
|
-
if (
|
|
735
|
+
if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {
|
|
736
|
+
if (link) {
|
|
737
|
+
mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, link.publishLocalId, link.propertySchemaUid);
|
|
738
|
+
}
|
|
789
739
|
return multiPublishPayload;
|
|
790
740
|
}
|
|
791
741
|
let publishPayload = {
|
|
792
742
|
localId: relatedItem.seedLocalId,
|
|
793
743
|
seedIsRevocable: true,
|
|
794
744
|
versionSchemaUid: VERSION_SCHEMA_UID,
|
|
795
|
-
seedUid:
|
|
745
|
+
seedUid: ZERO_BYTES32,
|
|
796
746
|
seedSchemaUid,
|
|
797
|
-
versionUid,
|
|
747
|
+
versionUid: getVersionUid(relatedItem),
|
|
798
748
|
listOfAttestations: [],
|
|
799
|
-
propertiesToUpdate: [
|
|
800
|
-
{
|
|
801
|
-
publishLocalId: originalSeedLocalId,
|
|
802
|
-
propertySchemaUid: relationOrImageSchemaUid,
|
|
803
|
-
},
|
|
804
|
-
],
|
|
749
|
+
propertiesToUpdate: link ? [{ ...link }] : [],
|
|
805
750
|
};
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
|
|
751
|
+
ctx.newSeedsInProgress ?? (ctx.newSeedsInProgress = new Set());
|
|
752
|
+
ctx.newSeedsInProgress.add(relatedItem.seedLocalId);
|
|
753
|
+
try {
|
|
754
|
+
await ensurePropertyDefs(relatedItem);
|
|
755
|
+
const segmented = await getSegmentedItemProperties(relatedItem);
|
|
756
|
+
const { itemBasicProperties, itemUploadProperties, itemImageProperties: relatedStorageSeedProperties } = segmented;
|
|
757
|
+
if (fullDraft) {
|
|
758
|
+
// Its own Image/File/Html/Json properties and the images embedded in its Html (as for the item itself).
|
|
759
|
+
multiPublishPayload = await processRelatedDraftStorageSeeds(relatedItem, relatedStorageSeedProperties, itemBasicProperties, multiPublishPayload, uploadedTransactions, ctx, buildOpts);
|
|
760
|
+
// Its relations and lists: their draft targets are published too (same walk as publishDraftGraph).
|
|
761
|
+
const { relationProperties, listProperties } = draftWalkProperties(segmented);
|
|
762
|
+
for (const relationProperty of relationProperties) {
|
|
763
|
+
multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
|
|
764
|
+
itemBasicProperties.push(relationProperty);
|
|
765
|
+
}
|
|
766
|
+
for (const listProperty of listProperties) {
|
|
767
|
+
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
|
|
768
|
+
itemBasicProperties.push(listProperty);
|
|
769
|
+
}
|
|
826
770
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
771
|
+
const relatedStorageUpload = resolveStorageTransactionUploadSlot(relatedItem, itemUploadProperties);
|
|
772
|
+
if (relatedStorageUpload) {
|
|
773
|
+
const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, relatedItem.seedLocalId);
|
|
774
|
+
if (transactionData) {
|
|
775
|
+
const itemProperty = relatedStorageUpload.itemProperty;
|
|
776
|
+
// Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it
|
|
777
|
+
// uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.
|
|
778
|
+
itemProperty.getService().send({
|
|
779
|
+
type: 'updateContext',
|
|
780
|
+
propertyValue: transactionData.txId,
|
|
781
|
+
renderValue: transactionData.txId,
|
|
782
|
+
});
|
|
783
|
+
replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
for (const p of itemBasicProperties) {
|
|
787
|
+
if (isStorageTransactionPropertyName(p.propertyName) &&
|
|
788
|
+
!p.propertyDef &&
|
|
789
|
+
relatedItem.modelName) {
|
|
790
|
+
const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId', await getItemModelScope(relatedItem));
|
|
791
|
+
if (schema) {
|
|
792
|
+
p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
|
|
793
|
+
}
|
|
835
794
|
}
|
|
836
795
|
}
|
|
796
|
+
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
797
|
+
publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
|
|
798
|
+
forceFullSnapshot,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
finally {
|
|
802
|
+
ctx.newSeedsInProgress.delete(relatedItem.seedLocalId);
|
|
837
803
|
}
|
|
838
|
-
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
839
|
-
publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
|
|
840
|
-
forceFullSnapshot,
|
|
841
|
-
});
|
|
842
804
|
multiPublishPayload.push(publishPayload);
|
|
843
805
|
return multiPublishPayload;
|
|
844
|
-
}
|
|
806
|
+
}
|
|
845
807
|
/**
|
|
846
808
|
* Storage-seed properties (Image/File/Html/Json) of a draft item related to the published one, and
|
|
847
809
|
* the images embedded in its Html (htmlEmbeddedImageCoPublish rows it owns): payloads for their seeds,
|
|
@@ -853,7 +815,7 @@ async function processRelatedDraftStorageSeeds(relatedItem, storageSeedPropertie
|
|
|
853
815
|
multiPublishPayload = await processRelationOrImageProperty(storageSeedProperty, multiPublishPayload, uploadedTransactions, relatedItem.seedLocalId, ctx, buildOpts);
|
|
854
816
|
itemBasicProperties.push(storageSeedProperty);
|
|
855
817
|
}
|
|
856
|
-
return processHtmlEmbeddedCoPublishImagePayloads(relatedItem, multiPublishPayload, uploadedTransactions,
|
|
818
|
+
return processHtmlEmbeddedCoPublishImagePayloads(relatedItem, multiPublishPayload, uploadedTransactions, ctx, buildOpts);
|
|
857
819
|
}
|
|
858
820
|
async function resolveHtmlPropertySchemaUidByHtmlSeed(item, htmlSeedLocalId, ctx) {
|
|
859
821
|
const want = htmlSeedLocalId.trim();
|
|
@@ -875,7 +837,7 @@ async function resolveHtmlPropertySchemaUidByHtmlSeed(item, htmlSeedLocalId, ctx
|
|
|
875
837
|
addValidationError(ctx, `Could not find Html property for embedded image rewrite (html seed ${want}).`, 'html', 'html_embed_schema');
|
|
876
838
|
return undefined;
|
|
877
839
|
}
|
|
878
|
-
async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions,
|
|
840
|
+
async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions, ctx, buildOpts) {
|
|
879
841
|
const appDb = BaseDb.getAppDb();
|
|
880
842
|
if (!appDb)
|
|
881
843
|
return multiPublishPayload;
|
|
@@ -886,7 +848,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
886
848
|
if (rows.length === 0)
|
|
887
849
|
return multiPublishPayload;
|
|
888
850
|
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
889
|
-
const getItemMod = await import('./getItem-
|
|
851
|
+
const getItemMod = await import('./getItem-BYQeM3DY.js');
|
|
890
852
|
const { getItem } = getItemMod;
|
|
891
853
|
const doneImages = new Set();
|
|
892
854
|
for (const row of rows) {
|
|
@@ -899,6 +861,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
899
861
|
if (noteRelatedSeed(ctx, row.imageSeedLocalId, imageSeed, htmlPropertyNameForHtmlSeed(item, row.htmlSeedLocalId), 'Image')) {
|
|
900
862
|
continue;
|
|
901
863
|
}
|
|
864
|
+
// The row's Html seed must still be the value of one of the item's Html properties.
|
|
902
865
|
const htmlSchemaUid = await resolveHtmlPropertySchemaUidByHtmlSeed(item, row.htmlSeedLocalId, ctx);
|
|
903
866
|
if (!htmlSchemaUid)
|
|
904
867
|
continue;
|
|
@@ -915,10 +878,16 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
915
878
|
addValidationError(ctx, `Schema UID not found for model: Image`, 'html');
|
|
916
879
|
continue;
|
|
917
880
|
}
|
|
918
|
-
|
|
881
|
+
// Already in the batch (e.g. also the value of an Image property): its payload is there.
|
|
882
|
+
if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {
|
|
919
883
|
continue;
|
|
920
884
|
}
|
|
921
885
|
const versionUid = getVersionUid(relatedItem);
|
|
886
|
+
// No propertiesToUpdate: the Html refers to the image by its Arweave URL (the data URI is
|
|
887
|
+
// rewritten to it before the Html is uploaded), not by seed uid. The Html property holds the Html
|
|
888
|
+
// storage seed's uid, which the Html seed's own request writes into it; the contract writes each
|
|
889
|
+
// updater's seed uid into the same data[0] (SeedPublishLib.setSeedReference), so an image
|
|
890
|
+
// targeting the Html property too would overwrite that reference with the image's seed uid.
|
|
922
891
|
let publishPayload = {
|
|
923
892
|
localId: relatedItem.seedLocalId,
|
|
924
893
|
seedIsRevocable: true,
|
|
@@ -927,12 +896,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
927
896
|
seedSchemaUid,
|
|
928
897
|
versionUid,
|
|
929
898
|
listOfAttestations: [],
|
|
930
|
-
propertiesToUpdate: [
|
|
931
|
-
{
|
|
932
|
-
publishLocalId: originalSeedLocalId,
|
|
933
|
-
propertySchemaUid: htmlSchemaUid,
|
|
934
|
-
},
|
|
935
|
-
],
|
|
899
|
+
propertiesToUpdate: [],
|
|
936
900
|
};
|
|
937
901
|
await ensurePropertyDefs(relatedItem);
|
|
938
902
|
const { itemBasicProperties, itemUploadProperties } = await getSegmentedItemProperties(relatedItem);
|
|
@@ -967,7 +931,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
967
931
|
}
|
|
968
932
|
return multiPublishPayload;
|
|
969
933
|
}
|
|
970
|
-
const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId, ctx, buildOpts) => {
|
|
934
|
+
const processListProperty = async (listProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx, buildOpts) => {
|
|
971
935
|
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
972
936
|
// processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties
|
|
973
937
|
if (!listProperty.propertyDef?.ref) {
|
|
@@ -1000,6 +964,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
1000
964
|
: value != null
|
|
1001
965
|
? [value]
|
|
1002
966
|
: [];
|
|
967
|
+
const members = [];
|
|
1003
968
|
for (const seedId of iterableValue) {
|
|
1004
969
|
const idStr = typeof seedId === 'string'
|
|
1005
970
|
? seedId
|
|
@@ -1011,9 +976,20 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
1011
976
|
const { localId: seedLocalId, uid: seedUid } = getCorrectId(idStr);
|
|
1012
977
|
if (!seedLocalId && !seedUid)
|
|
1013
978
|
continue;
|
|
1014
|
-
|
|
979
|
+
members.push({ idStr, seedLocalId, seedUid });
|
|
980
|
+
}
|
|
981
|
+
// A member that is an item still in progress (a cycle back to it) can't be attested in this
|
|
982
|
+
// publish, so the list is deferred; its other draft members are still published, unlinked.
|
|
983
|
+
const memberSeeds = await Promise.all(members.map((m) => findRelatedSeedRow({ seedLocalId: m.seedLocalId, seedUid: m.seedUid })));
|
|
984
|
+
const deferred = deferIfBackEdge(ctx, listProperty, members.map((m, i) => memberSeeds[i]?.seedLocalId ?? m.seedLocalId));
|
|
985
|
+
for (let i = 0; i < members.length; i++) {
|
|
986
|
+
const { idStr, seedLocalId, seedUid } = members[i];
|
|
987
|
+
const relatedSeed = memberSeeds[i] ?? null;
|
|
988
|
+
const memberLocalId = relatedSeed?.seedLocalId ?? seedLocalId;
|
|
989
|
+
if (memberLocalId && ctx.newSeedsInProgress?.has(memberLocalId))
|
|
990
|
+
continue;
|
|
1015
991
|
// Use dynamic import to break circular dependency
|
|
1016
|
-
const getItemMod = await import('./getItem-
|
|
992
|
+
const getItemMod = await import('./getItem-BYQeM3DY.js');
|
|
1017
993
|
const { getItem } = getItemMod;
|
|
1018
994
|
const relatedItem = await getItem(relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid });
|
|
1019
995
|
if (noteRelatedSeed(ctx, idStr.trim(), relatedSeed, listProperty.propertyName, relatedItem?.modelName ?? relatedModelNameFromDef(listProperty.propertyDef))) {
|
|
@@ -1029,7 +1005,6 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
1029
1005
|
if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {
|
|
1030
1006
|
continue;
|
|
1031
1007
|
}
|
|
1032
|
-
const versionUid = getVersionUid(relatedItem);
|
|
1033
1008
|
let modelName;
|
|
1034
1009
|
if (listProperty.propertyDef?.ref || listProperty.propertyDef.refModelName) {
|
|
1035
1010
|
const def = listProperty.propertyDef;
|
|
@@ -1048,36 +1023,17 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
1048
1023
|
addValidationError(ctx, `Model name not found for list property: ${listProperty.propertyName}`, listProperty.propertyName);
|
|
1049
1024
|
continue;
|
|
1050
1025
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
seedIsRevocable: true,
|
|
1062
|
-
versionSchemaUid: VERSION_SCHEMA_UID,
|
|
1063
|
-
seedUid: seedUid || ZERO_BYTES32,
|
|
1064
|
-
seedSchemaUid,
|
|
1065
|
-
versionUid,
|
|
1066
|
-
listOfAttestations: [],
|
|
1067
|
-
propertiesToUpdate: [
|
|
1068
|
-
{
|
|
1069
|
-
publishLocalId: originalSeedLocalId,
|
|
1070
|
-
propertySchemaUid: listPropertySchemaUid,
|
|
1071
|
-
},
|
|
1072
|
-
],
|
|
1073
|
-
};
|
|
1074
|
-
await ensurePropertyDefs(relatedItem);
|
|
1075
|
-
const { itemBasicProperties } = await getSegmentedItemProperties(relatedItem);
|
|
1076
|
-
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
1077
|
-
publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
|
|
1078
|
-
forceFullSnapshot,
|
|
1026
|
+
multiPublishPayload = await processRelatedDraftItem({
|
|
1027
|
+
relatedItem,
|
|
1028
|
+
modelName,
|
|
1029
|
+
fullDraft: true,
|
|
1030
|
+
link: deferred ? null : { publishLocalId: originalSeedLocalId, propertySchemaUid: listPropertySchemaUid },
|
|
1031
|
+
reportPropertyName: listProperty.propertyName,
|
|
1032
|
+
multiPublishPayload,
|
|
1033
|
+
uploadedTransactions,
|
|
1034
|
+
ctx,
|
|
1035
|
+
buildOpts,
|
|
1079
1036
|
});
|
|
1080
|
-
multiPublishPayload.push(publishPayload);
|
|
1081
1037
|
}
|
|
1082
1038
|
return multiPublishPayload;
|
|
1083
1039
|
};
|
|
@@ -1221,6 +1177,11 @@ const getPublishPayload = async (item, uploadedTransactions, options) => {
|
|
|
1221
1177
|
addValidationError(validationCtx, 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).', 'seedUid', 'publish_new_version_requires_seed');
|
|
1222
1178
|
}
|
|
1223
1179
|
let multiPublishPayload = [];
|
|
1180
|
+
// The root gets a new seed (draft, or revoked seed published again): related drafts referring
|
|
1181
|
+
// back to it can't attest its uid in this publish (see publishDraftGraph.ts).
|
|
1182
|
+
if (rootSeedUid === ZERO_BYTES32) {
|
|
1183
|
+
validationCtx.newSeedsInProgress = new Set([item.seedLocalId]);
|
|
1184
|
+
}
|
|
1224
1185
|
// Each PublishPayload is generated from a Seed that needs publishing
|
|
1225
1186
|
// First we need to determine all Seeds to publish
|
|
1226
1187
|
// That means the Seed of the Item, plus any Seeds pointed to by Relations
|
|
@@ -1303,9 +1264,9 @@ const getPublishPayload = async (item, uploadedTransactions, options) => {
|
|
|
1303
1264
|
multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
|
|
1304
1265
|
itemBasicProperties.push(relationProperty);
|
|
1305
1266
|
}
|
|
1306
|
-
multiPublishPayload = await processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions,
|
|
1267
|
+
multiPublishPayload = await processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPayload, uploadedTransactions, validationCtx, { forceFullSnapshot });
|
|
1307
1268
|
for (const listProperty of itemListProperties) {
|
|
1308
|
-
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId, validationCtx, { forceFullSnapshot });
|
|
1269
|
+
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
|
|
1309
1270
|
itemBasicProperties.push(listProperty);
|
|
1310
1271
|
}
|
|
1311
1272
|
for (const p of itemBasicProperties) {
|
|
@@ -1536,7 +1497,7 @@ const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
|
|
|
1536
1497
|
let allSlotsResolved = true;
|
|
1537
1498
|
for (const id of rawList) {
|
|
1538
1499
|
const trimmed = id.trim();
|
|
1539
|
-
if (trimmed
|
|
1500
|
+
if (isUidRef(trimmed)) {
|
|
1540
1501
|
resolvedValues.push(padUidForBytes32Schema(trimmed));
|
|
1541
1502
|
continue;
|
|
1542
1503
|
}
|
|
@@ -1628,5 +1589,5 @@ var getPublishPayload$1 = /*#__PURE__*/Object.freeze({
|
|
|
1628
1589
|
validateItemForPublish: validateItemForPublish
|
|
1629
1590
|
});
|
|
1630
1591
|
|
|
1631
|
-
export { PublishValidationFailedError as P, RELATED_ITEM_UNPUBLISHED_CODE as R,
|
|
1632
|
-
//# sourceMappingURL=getPublishPayload-
|
|
1592
|
+
export { PublishValidationFailedError as P, RELATED_ITEM_UNPUBLISHED_CODE as R, RelatedItemUnpublishedError as a, getPublishPayload$1 as g, resolvePublishPayloadValues as r, validateItemForPublish as v };
|
|
1593
|
+
//# sourceMappingURL=getPublishPayload-D5CQZd-y.js.map
|