@seedprotocol/sdk 0.6.6 → 0.6.8
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-BGxb4Qod.js → BasePathResolver-B6CKqoKw.js} +137 -4
- package/dist/BasePathResolver-B6CKqoKw.js.map +1 -0
- package/dist/{index-CJNKYI37.js → ClientManager-ChcmUL47.js} +1928 -5543
- package/dist/ClientManager-ChcmUL47.js.map +1 -0
- package/dist/{ModelProperty-Bvg9cJcd.js → ModelProperty-D79uV42p.js} +42 -36
- package/dist/ModelProperty-D79uV42p.js.map +1 -0
- package/dist/{Schema-BNJBY80k.js → Schema-a8uO-hIZ.js} +48 -47
- package/dist/Schema-a8uO-hIZ.js.map +1 -0
- package/dist/{SchemaValidationService-aqXkwXTr.js → SchemaValidationService-Y49vqast.js} +16 -12
- package/dist/SchemaValidationService-Y49vqast.js.map +1 -0
- package/dist/{backfillMetadataPropertyIds-DYkvoOMz.js → backfillMetadataPropertyIds-CBsf7LnU.js} +6 -3
- package/dist/{backfillMetadataPropertyIds-DYkvoOMz.js.map → backfillMetadataPropertyIds-CBsf7LnU.js.map} +1 -1
- package/dist/cjs/{ModelProperty-alntkSnH.js → ModelProperty-D9FGaGuE.js} +25 -20
- package/dist/cjs/ModelProperty-D9FGaGuE.js.map +1 -0
- package/dist/cjs/{Schema-ByFv6fcb.js → Schema-BiJIPLEL.js} +29 -27
- package/dist/cjs/Schema-BiJIPLEL.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-D55MWsxv.js → SchemaValidationService-DtYs_CNY.js} +9 -6
- package/dist/cjs/SchemaValidationService-DtYs_CNY.js.map +1 -0
- package/dist/cjs/{backfillMetadataPropertyIds-DrrL5RqD.js → backfillMetadataPropertyIds-2XaN3b9S.js} +7 -5
- package/dist/cjs/{backfillMetadataPropertyIds-DrrL5RqD.js.map → backfillMetadataPropertyIds-2XaN3b9S.js.map} +1 -1
- package/dist/cjs/{eas-D2E3_i_c.js → eas-CMNppmGE.js} +32 -6
- package/dist/cjs/eas-CMNppmGE.js.map +1 -0
- package/dist/cjs/{getItem-B2zLVB_l.js → getItem-B6jEINjW.js} +6 -4
- package/dist/cjs/{getItem-B2zLVB_l.js.map → getItem-B6jEINjW.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-Bv94k4ak.js → getPublishPayload-D5DhLGvN.js} +66 -60
- package/dist/cjs/getPublishPayload-D5DhLGvN.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CSbHUxYk.js → getPublishUploads-DMhCCKYF.js} +21 -13
- package/dist/cjs/getPublishUploads-DMhCCKYF.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-CMhXKQHz.js → getSegmentedItemProperties-CU8rtBAo.js} +3 -51
- package/dist/cjs/getSegmentedItemProperties-CU8rtBAo.js.map +1 -0
- package/dist/cjs/{index-D-9WglxG.js → index-CSNtEnbF.js} +5986 -5389
- package/dist/cjs/index-CSNtEnbF.js.map +1 -0
- package/dist/cjs/{index-pSLjO-ch.js → index-DPp9rdRL.js} +10 -6
- package/dist/cjs/index-DPp9rdRL.js.map +1 -0
- package/dist/cjs/{property-gUK2PijH.js → property-DlKiAWt4.js} +11 -7
- package/dist/cjs/{property-gUK2PijH.js.map → property-DlKiAWt4.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-CYtl7VTD.js → syncDbWithEas-C6n34o_Q.js} +14 -8
- package/dist/cjs/syncDbWithEas-C6n34o_Q.js.map +1 -0
- package/dist/{configurePlatform-bGvKBBQy.js → configurePlatform-CE0Vew17.js} +6 -3
- package/dist/{configurePlatform-bGvKBBQy.js.map → configurePlatform-CE0Vew17.js.map} +1 -1
- package/dist/db/drizzle/0014_add_error_code_to_publish_processes.sql +1 -0
- package/dist/db/drizzle/meta/0014_snapshot.json +1269 -0
- package/dist/db/drizzle/meta/_journal.json +7 -0
- package/dist/{db-YiH_kIpE.js → db-WbrzEf7c.js} +266 -53
- package/dist/db-WbrzEf7c.js.map +1 -0
- package/dist/{eas-1nUCcmeh.js → eas-CfYCu4IX.js} +9 -6
- package/dist/eas-CfYCu4IX.js.map +1 -0
- package/dist/generateId-BopUwD8F.js +9 -0
- package/dist/generateId-BopUwD8F.js.map +1 -0
- package/dist/{getItem-Bb8bTYzY.js → getItem-Br-bGNFO.js} +12 -10
- package/dist/{getItem-Bb8bTYzY.js.map → getItem-Br-bGNFO.js.map} +1 -1
- package/dist/{getPublishPayload-BHw8mPSb.js → getPublishPayload-BIrTVUxb.js} +72 -65
- package/dist/getPublishPayload-BIrTVUxb.js.map +1 -0
- package/dist/{getPublishUploads-BYhckxFl.js → getPublishUploads-C6cDeZdz.js} +22 -13
- package/dist/getPublishUploads-C6cDeZdz.js.map +1 -0
- package/dist/{getSegmentedItemProperties-B73nMPBv.js → getSegmentedItemProperties-BmKE71vU.js} +5 -5
- package/dist/{getSegmentedItemProperties-B73nMPBv.js.map → getSegmentedItemProperties-BmKE71vU.js.map} +1 -1
- package/dist/index-280bL-n4.js +1122 -0
- package/dist/index-280bL-n4.js.map +1 -0
- package/dist/{index-DzgMt8ba.js → index-ClSv5pTA.js} +17 -14
- package/dist/index-ClSv5pTA.js.map +1 -0
- package/dist/{index-C_5xwOPQ.js → index-Djd3667v.js} +2 -2
- package/dist/index-Djd3667v.js.map +1 -0
- package/dist/index-HRHkbVQd.js +3492 -0
- package/dist/index-HRHkbVQd.js.map +1 -0
- package/dist/{index.node-ZLiBj9Cu.js → index.node-DBtQkEfz.js} +8 -7
- package/dist/index.node-DBtQkEfz.js.map +1 -0
- package/dist/main.cjs +10 -4
- package/dist/main.cjs.map +1 -1
- package/dist/main.js +43 -43
- package/dist/main.js.map +1 -1
- package/dist/model-DGMe-TTm.js +25 -0
- package/dist/model-DGMe-TTm.js.map +1 -0
- package/dist/node.js +21 -17
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +162 -63
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.node.js +5 -5
- package/dist/{property-Dcb50seV.js → property-CQjuZ4JW.js} +20 -17
- package/dist/property-CQjuZ4JW.js.map +1 -0
- package/dist/seedSchema/PublishProcessSchema.ts +1 -0
- package/dist/src/Item/Item.d.ts +6 -0
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts +10 -1
- package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts.map +1 -1
- package/dist/src/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts.map +1 -1
- package/dist/src/browser/db/Db.d.ts.map +1 -1
- package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
- package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
- package/dist/src/browser/db/embeddedMigrations.d.ts +17 -0
- package/dist/src/browser/db/embeddedMigrations.d.ts.map +1 -0
- package/dist/src/browser/helpers/ArweaveClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/EasClient.d.ts +2 -1
- package/dist/src/browser/helpers/EasClient.d.ts.map +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts +1 -1
- package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
- package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
- package/dist/src/client/ClientManager.d.ts +18 -3
- 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/actors/saveConfig.d.ts.map +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +6 -1
- package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
- package/dist/src/client/constants.d.ts +4 -0
- package/dist/src/client/constants.d.ts.map +1 -1
- package/dist/src/client/nodeEndpointDefaults.d.ts +8 -0
- package/dist/src/client/nodeEndpointDefaults.d.ts.map +1 -0
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +1 -1
- package/dist/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/src/eas.d.ts +2 -2
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts.map +1 -1
- package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/index.d.ts.map +1 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts +1 -1
- package/dist/src/helpers/ArweaveClient/selectReadGateway.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -2
- package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/src/helpers/FileManager/IFileManager.d.ts +4 -0
- package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
- package/dist/src/helpers/constants.d.ts +9 -2
- package/dist/src/helpers/constants.d.ts.map +1 -1
- package/dist/src/helpers/crypto.d.ts +3 -2
- package/dist/src/helpers/crypto.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts +6 -0
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/helpers/ensureImageLocal.d.ts +24 -0
- package/dist/src/helpers/ensureImageLocal.d.ts.map +1 -0
- package/dist/src/helpers/ethereumUtils.d.ts.map +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts +1 -1
- package/dist/src/helpers/gateway/gatewayState.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +10 -2
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/localDbChain.d.ts +22 -0
- package/dist/src/helpers/localDbChain.d.ts.map +1 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts +9 -0
- package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
- package/dist/src/helpers/property/index.d.ts +12 -0
- package/dist/src/helpers/property/index.d.ts.map +1 -1
- package/dist/src/helpers/readHtmlBodyForStorageSeed.d.ts.map +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +8 -0
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -1
- package/dist/src/imports/json.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node/easLodashHook.d.ts +2 -0
- package/dist/src/node/easLodashHook.d.ts.map +1 -0
- package/dist/src/node/easLodashRegister.d.ts +2 -0
- package/dist/src/node/easLodashRegister.d.ts.map +1 -0
- package/dist/src/node/helpers/FileManager.d.ts +2 -1
- package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/src/node/index.d.ts +2 -1
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/seedSchema/PublishProcessSchema.d.ts +19 -0
- package/dist/src/seedSchema/PublishProcessSchema.d.ts.map +1 -1
- package/dist/src/types/fileManager.d.ts +4 -0
- package/dist/src/types/fileManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +15 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/{syncDbWithEas-B0RUeDuj.js → syncDbWithEas-CuARXfyN.js} +24 -18
- package/dist/syncDbWithEas-CuARXfyN.js.map +1 -0
- package/dist/{updateSeedRevokedAt-D5ZbBehZ.js → updateSeedRevokedAt-CBcLfHWs.js} +2 -2
- package/dist/{updateSeedRevokedAt-D5ZbBehZ.js.map → updateSeedRevokedAt-CBcLfHWs.js.map} +1 -1
- package/package.json +12 -8
- package/src/node/easLodashHook.js +22 -0
- package/src/node/easLodashRegister.js +13 -0
- package/dist/BasePathResolver-BGxb4Qod.js.map +0 -1
- package/dist/ModelProperty-Bvg9cJcd.js.map +0 -1
- package/dist/Schema-BNJBY80k.js.map +0 -1
- package/dist/SchemaValidationService-aqXkwXTr.js.map +0 -1
- package/dist/cjs/ModelProperty-alntkSnH.js.map +0 -1
- package/dist/cjs/Schema-ByFv6fcb.js.map +0 -1
- package/dist/cjs/SchemaValidationService-D55MWsxv.js.map +0 -1
- package/dist/cjs/eas-D2E3_i_c.js.map +0 -1
- package/dist/cjs/getPublishPayload-Bv94k4ak.js.map +0 -1
- package/dist/cjs/getPublishUploads-CSbHUxYk.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-CMhXKQHz.js.map +0 -1
- package/dist/cjs/index-D-9WglxG.js.map +0 -1
- package/dist/cjs/index-pSLjO-ch.js.map +0 -1
- package/dist/cjs/syncDbWithEas-CYtl7VTD.js.map +0 -1
- package/dist/constants-Bre6dTJR.js +0 -122
- package/dist/constants-Bre6dTJR.js.map +0 -1
- package/dist/constants-CTs2RUrM.js +0 -657
- package/dist/constants-CTs2RUrM.js.map +0 -1
- package/dist/db-YiH_kIpE.js.map +0 -1
- package/dist/eas-1nUCcmeh.js.map +0 -1
- package/dist/getPublishPayload-BHw8mPSb.js.map +0 -1
- package/dist/getPublishUploads-BYhckxFl.js.map +0 -1
- package/dist/index-CJNKYI37.js.map +0 -1
- package/dist/index-C_5xwOPQ.js.map +0 -1
- package/dist/index-DzgMt8ba.js.map +0 -1
- package/dist/index.node-ZLiBj9Cu.js.map +0 -1
- package/dist/property-Dcb50seV.js.map +0 -1
- package/dist/seedSchema/AppStateSchema.d.ts +0 -82
- package/dist/seedSchema/AppStateSchema.d.ts.map +0 -1
- package/dist/seedSchema/ConfigSchema.d.ts +0 -101
- package/dist/seedSchema/ConfigSchema.d.ts.map +0 -1
- package/dist/seedSchema/MetadataSchema.d.ts +0 -422
- package/dist/seedSchema/MetadataSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchema.d.ts +0 -243
- package/dist/seedSchema/ModelSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelSchemaSchema.d.ts +0 -61
- package/dist/seedSchema/ModelSchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/ModelUidSchema.d.ts +0 -64
- package/dist/seedSchema/ModelUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/PropertyUidSchema.d.ts +0 -64
- package/dist/seedSchema/PropertyUidSchema.d.ts.map +0 -1
- package/dist/seedSchema/SchemaSchema.d.ts +0 -169
- package/dist/seedSchema/SchemaSchema.d.ts.map +0 -1
- package/dist/seedSchema/SeedSchema.d.ts +0 -192
- package/dist/seedSchema/SeedSchema.d.ts.map +0 -1
- package/dist/seedSchema/VersionSchema.d.ts +0 -194
- package/dist/seedSchema/VersionSchema.d.ts.map +0 -1
- package/dist/seedSchema/index.d.ts +0 -14
- package/dist/seedSchema/index.d.ts.map +0 -1
- package/dist/syncDbWithEas-B0RUeDuj.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var main_cjs = require('./index-
|
|
3
|
+
var main_cjs = require('./index-CSNtEnbF.js');
|
|
4
4
|
var easSdk = require('@ethereum-attestation-service/eas-sdk');
|
|
5
5
|
var casing = require('drizzle-orm/casing');
|
|
6
|
-
var pluralize = require('pluralize');
|
|
7
6
|
var eas = require('@seedprotocol/eas');
|
|
8
|
-
var getSegmentedItemProperties = require('./getSegmentedItemProperties-
|
|
9
|
-
var property = require('./property-
|
|
7
|
+
var getSegmentedItemProperties = require('./getSegmentedItemProperties-CU8rtBAo.js');
|
|
8
|
+
var property = require('./property-DlKiAWt4.js');
|
|
10
9
|
var lodashEs = require('lodash-es');
|
|
11
10
|
var drizzleOrm = require('drizzle-orm');
|
|
12
11
|
var debug = require('debug');
|
|
13
|
-
require('
|
|
12
|
+
require('@noble/hashes/sha3');
|
|
13
|
+
require('@noble/hashes/utils');
|
|
14
14
|
require('reflect-metadata');
|
|
15
15
|
require('immer');
|
|
16
16
|
require('xstate');
|
|
17
17
|
require('drizzle-orm/sqlite-core');
|
|
18
18
|
require('@seedprotocol/arweave');
|
|
19
|
+
require('pluralize');
|
|
19
20
|
require('@sinclair/typebox');
|
|
20
21
|
require('nanoid');
|
|
21
22
|
require('nanoid-dictionary');
|
|
@@ -24,6 +25,7 @@ require('rxjs');
|
|
|
24
25
|
require('fs/promises');
|
|
25
26
|
require('fs');
|
|
26
27
|
require('path');
|
|
28
|
+
require('url');
|
|
27
29
|
require('node:url');
|
|
28
30
|
require('@libsql/client');
|
|
29
31
|
require('drizzle-orm/libsql');
|
|
@@ -51,8 +53,17 @@ debug('seedSdk:db:getPublishPayload');
|
|
|
51
53
|
/** Case-insensitive dataType match (schema JSON may use "text" vs "Text"). */
|
|
52
54
|
const matchesDataType = (actual, expected) => main_cjs.normalizeDataType(actual) === expected;
|
|
53
55
|
function addValidationError(ctx, message, field, code = 'publish_validation') {
|
|
56
|
+
// A property can be validated on more than one path (List of Relation: list + basic); report once.
|
|
57
|
+
if (ctx.errors.some((e) => e.message === message && e.field === (field ?? '')))
|
|
58
|
+
return;
|
|
54
59
|
ctx.errors.push({ field: field ?? '', message, code });
|
|
55
60
|
}
|
|
61
|
+
/** File/Image/Html value is raw content instead of a storage seed id, so it was never saved/uploaded. */
|
|
62
|
+
function addStorageValueNotSavedError(ctx, propertyName, dataType, value) {
|
|
63
|
+
addValidationError(ctx, `Invalid value for property: ${propertyName}. Expected a storage seed id ` +
|
|
64
|
+
`(${main_cjs.normalizeDataType(dataType)} content must be saved through the property before publishing), ` +
|
|
65
|
+
`got ${value.length > 40 ? `${value.slice(0, 40)}…` : value}.`, propertyName, 'publish_storage_value_not_saved');
|
|
66
|
+
}
|
|
56
67
|
function isStorageTransactionPropertyName(name) {
|
|
57
68
|
return name === 'storageTransactionId' || name === 'storage_transaction_id';
|
|
58
69
|
}
|
|
@@ -122,7 +133,7 @@ async function resolveVersionUid(seedLocalId, seedUid) {
|
|
|
122
133
|
if (published?.uid)
|
|
123
134
|
return published.uid;
|
|
124
135
|
try {
|
|
125
|
-
const { getItemVersionsFromEas } = await Promise.resolve().then(function () { return require('./eas-
|
|
136
|
+
const { getItemVersionsFromEas } = await Promise.resolve().then(function () { return require('./eas-CMNppmGE.js'); });
|
|
126
137
|
const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] });
|
|
127
138
|
const latest = attestations?.[0];
|
|
128
139
|
if (latest?.id)
|
|
@@ -146,35 +157,25 @@ const getPropertyData = async (itemProperty, ctx) => {
|
|
|
146
157
|
}
|
|
147
158
|
return null;
|
|
148
159
|
}
|
|
149
|
-
let schemaUid = itemProperty.schemaUid;
|
|
150
160
|
const ip = itemProperty;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
!(ip.storagePropertyName && ip.storagePropertyName.length > 0)) {
|
|
159
|
-
const ref = propertyDefForName?.ref ?? propertyDefForName?.refModelName;
|
|
160
|
-
if (ref) {
|
|
161
|
-
const singular = pluralize.singular(itemProperty.propertyName);
|
|
162
|
-
nameForEas = `${singular}${ref}Ids`;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
161
|
+
// List of Relation: the EAS name always comes from the property definition (authors → authorIdentityIds),
|
|
162
|
+
// never from whatever name the ItemProperty was constructed with or a cached schemaUid.
|
|
163
|
+
const listRelationName = main_cjs.listRelationEasPropertyName(itemProperty.propertyName, itemProperty.propertyDef);
|
|
164
|
+
const nameForEas = listRelationName ??
|
|
165
|
+
(ip.storagePropertyName && ip.storagePropertyName.length > 0
|
|
166
|
+
? ip.storagePropertyName
|
|
167
|
+
: itemProperty.propertyName);
|
|
165
168
|
const propertyNameForSchema = main_cjs.toSnakeCase(nameForEas);
|
|
166
169
|
const schemaDef = `${easDataType} ${propertyNameForSchema}`;
|
|
170
|
+
let schemaUid = listRelationName ? undefined : itemProperty.schemaUid;
|
|
167
171
|
if (!schemaUid) {
|
|
168
172
|
schemaUid = await eas.getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef });
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
if (schema) {
|
|
175
|
-
schemaUid = schema.id;
|
|
176
|
-
}
|
|
173
|
+
}
|
|
174
|
+
if (!schemaUid) {
|
|
175
|
+
if (ctx) {
|
|
176
|
+
addValidationError(ctx, `EAS schema not found for "${schemaDef}" (property: ${itemProperty.propertyName}). Register it before publishing (ensureEasSchemasForItem).`, itemProperty.propertyName, 'publish_schema_not_found');
|
|
177
177
|
}
|
|
178
|
+
return null;
|
|
178
179
|
}
|
|
179
180
|
return {
|
|
180
181
|
schemaUid,
|
|
@@ -197,7 +198,7 @@ const ensurePropertyDefs = async (targetItem) => {
|
|
|
197
198
|
schema = await property.getPropertySchema(targetItem.modelName, itemProperty.propertyName);
|
|
198
199
|
if (!schema) {
|
|
199
200
|
try {
|
|
200
|
-
const { Model } = await Promise.resolve().then(function () { return require('./index-
|
|
201
|
+
const { Model } = await Promise.resolve().then(function () { return require('./index-CSNtEnbF.js'); }).then(function (n) { return n.Model$1; });
|
|
201
202
|
const normalizedModelName = lodashEs.upperFirst(lodashEs.camelCase(targetItem.modelName));
|
|
202
203
|
let model = Model.getByName(normalizedModelName);
|
|
203
204
|
if (!model?.properties?.length) {
|
|
@@ -323,6 +324,14 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
323
324
|
continue;
|
|
324
325
|
}
|
|
325
326
|
}
|
|
327
|
+
// File/Image/Html values must be a storage seed id by now. Raw content means the property's
|
|
328
|
+
// save pipeline never ran or failed (e.g. createNewItem with raw html), so it was never uploaded.
|
|
329
|
+
// Relation/image properties are appended to the basic list after processRelationOrImageProperty,
|
|
330
|
+
// so this one check covers both paths.
|
|
331
|
+
if (isFileImageHtml && typeof value === 'string' && !main_cjs.isStorageSeedRef(value)) {
|
|
332
|
+
addStorageValueNotSavedError(ctx, basicProperty.propertyName, propertyDef?.dataType, value);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
326
335
|
const propertyData = await getPropertyData(basicProperty, ctx);
|
|
327
336
|
if (!propertyData)
|
|
328
337
|
continue;
|
|
@@ -354,7 +363,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx,
|
|
|
354
363
|
}
|
|
355
364
|
// Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
|
|
356
365
|
if (propertyDef?.validation) {
|
|
357
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
366
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-DtYs_CNY.js'); });
|
|
358
367
|
const validationService = new SchemaValidationService();
|
|
359
368
|
const validationResult = validationService.validatePropertyValue(value, main_cjs.normalizeDataType(propertyDef.dataType), propertyDef.validation, propertyDef.refValueType
|
|
360
369
|
? main_cjs.normalizeDataType(propertyDef.refValueType)
|
|
@@ -494,7 +503,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
494
503
|
matchesDataType(relationOrImageProperty.propertyDef?.refValueType, main_cjs.ModelPropertyDataTypes.Html) ||
|
|
495
504
|
matchesDataType(relationOrImageProperty.propertyDef?.refValueType, main_cjs.ModelPropertyDataTypes.Json)));
|
|
496
505
|
if (isStorageSeed && (context.seedLocalId || context.seedUid)) {
|
|
497
|
-
const { getPropertyData: getPropertyDataFromDb } = await Promise.resolve().then(function () { return require('./index-
|
|
506
|
+
const { getPropertyData: getPropertyDataFromDb } = await Promise.resolve().then(function () { return require('./index-CSNtEnbF.js'); }).then(function (n) { return n.getPropertyData; });
|
|
498
507
|
const metaRow = await getPropertyDataFromDb({
|
|
499
508
|
propertyName: relationOrImageProperty.propertyName,
|
|
500
509
|
seedLocalId: context.seedLocalId,
|
|
@@ -502,8 +511,8 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
502
511
|
});
|
|
503
512
|
const fromMeta = metaRow?.propertyValue;
|
|
504
513
|
if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {
|
|
505
|
-
const idsCtx =
|
|
506
|
-
const idsDb =
|
|
514
|
+
const idsCtx = main_cjs.resolveSeedIdsFromRefString(main_cjs.normalizeRelationPropertyValue(value) ?? '');
|
|
515
|
+
const idsDb = main_cjs.resolveSeedIdsFromRefString(main_cjs.normalizeRelationPropertyValue(fromMeta) ?? '');
|
|
507
516
|
if (!value) {
|
|
508
517
|
value = fromMeta;
|
|
509
518
|
}
|
|
@@ -569,8 +578,8 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
569
578
|
if (relationOrImageProperty.uid && !forceFullSnapshot) {
|
|
570
579
|
return multiPublishPayload;
|
|
571
580
|
}
|
|
572
|
-
const normalizedRef =
|
|
573
|
-
const { seedLocalId, seedUid } =
|
|
581
|
+
const normalizedRef = main_cjs.normalizeRelationPropertyValue(value);
|
|
582
|
+
const { seedLocalId, seedUid } = main_cjs.resolveSeedIdsFromRefString(normalizedRef ?? '');
|
|
574
583
|
// Value is not a valid seed reference (local id or 0x uid)
|
|
575
584
|
if (!seedLocalId && !seedUid) {
|
|
576
585
|
if (isRequired) {
|
|
@@ -580,7 +589,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
580
589
|
return multiPublishPayload;
|
|
581
590
|
}
|
|
582
591
|
// Use dynamic import to break circular dependency
|
|
583
|
-
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-
|
|
592
|
+
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-B6jEINjW.js'); });
|
|
584
593
|
const { getItem } = getItemMod;
|
|
585
594
|
const relatedItem = await getItem({
|
|
586
595
|
seedLocalId,
|
|
@@ -588,7 +597,8 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
588
597
|
});
|
|
589
598
|
// When related item not found (e.g. different DB, not yet created)
|
|
590
599
|
if (!relatedItem) {
|
|
591
|
-
|
|
600
|
+
// An attested uid with no local copy is already published; the parent attests the uid as-is.
|
|
601
|
+
if (isRequired && !main_cjs.isPublishedSeedRef(normalizedRef)) {
|
|
592
602
|
addValidationError(ctx, `No related item found for required relation: ${relationOrImageProperty.propertyName}. ` +
|
|
593
603
|
`Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +
|
|
594
604
|
`The related item may be missing, in a different database, or the reference may be broken.`, relationOrImageProperty.propertyName);
|
|
@@ -629,7 +639,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
629
639
|
let publishPayload = {
|
|
630
640
|
localId: relatedItem.seedLocalId,
|
|
631
641
|
seedIsRevocable: true,
|
|
632
|
-
versionSchemaUid: main_cjs.
|
|
642
|
+
versionSchemaUid: main_cjs.VERSION_SCHEMA_UID,
|
|
633
643
|
seedUid: seedUid || main_cjs.ZERO_BYTES32,
|
|
634
644
|
seedSchemaUid,
|
|
635
645
|
versionUid,
|
|
@@ -706,7 +716,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
706
716
|
if (rows.length === 0)
|
|
707
717
|
return multiPublishPayload;
|
|
708
718
|
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
709
|
-
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-
|
|
719
|
+
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-B6jEINjW.js'); });
|
|
710
720
|
const { getItem } = getItemMod;
|
|
711
721
|
const doneImages = new Set();
|
|
712
722
|
for (const row of rows) {
|
|
@@ -736,7 +746,7 @@ async function processHtmlEmbeddedCoPublishImagePayloads(item, multiPublishPaylo
|
|
|
736
746
|
let publishPayload = {
|
|
737
747
|
localId: relatedItem.seedLocalId,
|
|
738
748
|
seedIsRevocable: true,
|
|
739
|
-
versionSchemaUid: main_cjs.
|
|
749
|
+
versionSchemaUid: main_cjs.VERSION_SCHEMA_UID,
|
|
740
750
|
seedUid: relatedItem.seedUid || main_cjs.ZERO_BYTES32,
|
|
741
751
|
seedSchemaUid,
|
|
742
752
|
versionUid,
|
|
@@ -788,17 +798,6 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
788
798
|
addValidationError(ctx, `processListProperty requires ref (list of relations). List property "${listProperty.propertyName}" has no ref. List-of-primitives should be in itemBasicProperties.`, listProperty.propertyName);
|
|
789
799
|
return multiPublishPayload;
|
|
790
800
|
}
|
|
791
|
-
let listPropertySchemaUid = listProperty.schemaUid;
|
|
792
|
-
if (!listPropertySchemaUid && listProperty.propertyDef) {
|
|
793
|
-
const propertyData = await getPropertyData(listProperty, ctx);
|
|
794
|
-
if (!propertyData)
|
|
795
|
-
return multiPublishPayload;
|
|
796
|
-
listPropertySchemaUid = propertyData.schemaUid;
|
|
797
|
-
}
|
|
798
|
-
if (!listPropertySchemaUid) {
|
|
799
|
-
addValidationError(ctx, `Schema uid not found for list property: ${listProperty.propertyName}`, listProperty.propertyName);
|
|
800
|
-
return multiPublishPayload;
|
|
801
|
-
}
|
|
802
801
|
const snapshot = listProperty.getService().getSnapshot();
|
|
803
802
|
const context = 'context' in snapshot ? snapshot.context : null;
|
|
804
803
|
if (!context) {
|
|
@@ -811,8 +810,12 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
811
810
|
if (listProperty.uid && !forceFullSnapshot) {
|
|
812
811
|
return multiPublishPayload;
|
|
813
812
|
}
|
|
814
|
-
|
|
815
|
-
|
|
813
|
+
// Always resolve from the property definition; a cached schemaUid may point at a schema
|
|
814
|
+
// registered under the schema key (bytes32[] authors) instead of authorIdentityIds.
|
|
815
|
+
const propertyData = await getPropertyData(listProperty, ctx);
|
|
816
|
+
if (!propertyData)
|
|
817
|
+
return multiPublishPayload;
|
|
818
|
+
const listPropertySchemaUid = propertyData.schemaUid;
|
|
816
819
|
if (typeof value === 'string') {
|
|
817
820
|
value = main_cjs.parseListPropertyValueFromStorage(value);
|
|
818
821
|
}
|
|
@@ -833,14 +836,17 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
833
836
|
if (!seedLocalId && !seedUid)
|
|
834
837
|
continue;
|
|
835
838
|
// Use dynamic import to break circular dependency
|
|
836
|
-
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-
|
|
839
|
+
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-B6jEINjW.js'); });
|
|
837
840
|
const { getItem } = getItemMod;
|
|
838
841
|
const relatedItem = await getItem({
|
|
839
842
|
seedLocalId,
|
|
840
843
|
seedUid,
|
|
841
844
|
});
|
|
842
845
|
if (!relatedItem) {
|
|
843
|
-
|
|
846
|
+
// An attested uid with no local copy is already published; the list attests the uid as-is.
|
|
847
|
+
if (!main_cjs.isPublishedSeedRef(idStr)) {
|
|
848
|
+
console.error(`No related item found for list property: ${listProperty.propertyName}`);
|
|
849
|
+
}
|
|
844
850
|
continue;
|
|
845
851
|
}
|
|
846
852
|
if (relatedItem.seedUid && relatedItem.seedUid !== main_cjs.ZERO_BYTES32) {
|
|
@@ -876,7 +882,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
876
882
|
let publishPayload = {
|
|
877
883
|
localId: relatedItem.seedLocalId,
|
|
878
884
|
seedIsRevocable: true,
|
|
879
|
-
versionSchemaUid: main_cjs.
|
|
885
|
+
versionSchemaUid: main_cjs.VERSION_SCHEMA_UID,
|
|
880
886
|
seedUid: seedUid || main_cjs.ZERO_BYTES32,
|
|
881
887
|
seedSchemaUid,
|
|
882
888
|
versionUid,
|
|
@@ -1068,7 +1074,7 @@ const getPublishPayload = async (item, uploadedTransactions, options) => {
|
|
|
1068
1074
|
seedUid: item.seedUid || main_cjs.ZERO_BYTES32,
|
|
1069
1075
|
seedIsRevocable: true,
|
|
1070
1076
|
seedSchemaUid: itemSchemaUid,
|
|
1071
|
-
versionSchemaUid: main_cjs.
|
|
1077
|
+
versionSchemaUid: main_cjs.VERSION_SCHEMA_UID,
|
|
1072
1078
|
versionUid,
|
|
1073
1079
|
listOfAttestations: [],
|
|
1074
1080
|
propertiesToUpdate: [],
|
|
@@ -1096,7 +1102,7 @@ const getPublishPayload = async (item, uploadedTransactions, options) => {
|
|
|
1096
1102
|
const propRows = await main_cjs.BaseDb.getAppDb()
|
|
1097
1103
|
.select({ required: main_cjs.properties.required, refModelId: main_cjs.properties.refModelId })
|
|
1098
1104
|
.from(main_cjs.properties)
|
|
1099
|
-
.where(drizzleOrm.and(drizzleOrm.eq(main_cjs.properties.modelId, modelRows[0].id), drizzleOrm.eq(main_cjs.properties.name, relProp.propertyName), drizzleOrm.
|
|
1105
|
+
.where(drizzleOrm.and(drizzleOrm.eq(main_cjs.properties.modelId, modelRows[0].id), drizzleOrm.eq(main_cjs.properties.name, relProp.propertyName), drizzleOrm.sql `lower(${main_cjs.properties.dataType}) = 'relation'`))
|
|
1100
1106
|
.limit(1);
|
|
1101
1107
|
if (propRows.length > 0 && (propRows[0].required === true || propRows[0].required === 1)) {
|
|
1102
1108
|
isRequired = true;
|
|
@@ -1443,4 +1449,4 @@ exports.PublishValidationFailedError = PublishValidationFailedError;
|
|
|
1443
1449
|
exports.getPublishPayload = getPublishPayload;
|
|
1444
1450
|
exports.resolvePublishPayloadValues = resolvePublishPayloadValues;
|
|
1445
1451
|
exports.validateItemForPublish = validateItemForPublish;
|
|
1446
|
-
//# sourceMappingURL=getPublishPayload-
|
|
1452
|
+
//# sourceMappingURL=getPublishPayload-D5DhLGvN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublishPayload-D5DhLGvN.js","sources":["../../../src/helpers/ethereumUtils.ts","../../../src/db/read/getPublishPayload.ts"],"sourcesContent":["import { keccak_256 } from '@noble/hashes/sha3'\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils'\n\n/** EIP-55 checksum for a 20-byte hex address (with or without 0x prefix). */\nexport function checksumAddress(address: string): string {\n const addr = address.toLowerCase().replace(/^0x/, '')\n if (addr.length !== 40 || !/^[0-9a-f]+$/.test(addr)) {\n return address\n }\n const hash = bytesToHex(keccak_256(utf8ToBytes(addr)))\n let result = '0x'\n for (let i = 0; i < 40; i++) {\n result += parseInt(hash[i]!, 16) >= 8 ? addr[i]!.toUpperCase() : addr[i]!\n }\n return result\n}\n\n/** UTF-8 string to 0x-prefixed bytes32 hex (right-padded with zeros). */\nexport function encodeBytes32String(value: string): string {\n const bytes = new TextEncoder().encode(value)\n if (bytes.length > 32) {\n throw new Error(`encodeBytes32String: value exceeds 32 bytes (${bytes.length})`)\n }\n const hex = Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n return `0x${hex.padEnd(64, '0')}`\n}\n","// Dynamic import to break circular dependency with getItem -> BaseItem\n// import { getItem } from '@/db/read/getItem'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n INTERNAL_PROPERTY_NAMES,\n VERSION_SCHEMA_UID,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport {\n AttestationRequest,\n AttestationRequestData,\n SchemaEncoder,\n} from '@ethereum-attestation-service/eas-sdk'\n\nimport { toSnakeCase } from '@/helpers'\nimport { toSnakeCase as toSnakeCaseDb } from 'drizzle-orm/casing'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { getEasSchemaUidForSchemaDefinition } from '@/stores/eas'\nimport { getCorrectId } from '@/helpers'\nimport { isValidEasAttestationUid } from '@/helpers/easUid'\nimport { getLatestPublishedVersionRow } from '@/db/read/getLatestPublishedVersionRow'\nimport {\n isStorageSeedRef,\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { getPropertySchema } from '@/helpers/property'\nimport { listRelationEasPropertyName, type PropertySchemaEntry } from '@/helpers/metadataPropertyNames'\nimport { modelPropertiesToObject } from '@/helpers/model'\nimport { IItemProperty } from '@/interfaces'\nimport { camelCase, upperFirst } from 'lodash-es'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq, and, sql } from 'drizzle-orm'\nimport { IItem } from '@/interfaces'\nimport debug from 'debug'\nimport { encodeBytes32String } from '@/helpers/ethereumUtils'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport type { ValidationError } from '@/Schema/validation'\nconst logger = debug('seedSdk:db:getPublishPayload')\n\n/** Case-insensitive dataType match (schema JSON may use \"text\" vs \"Text\"). */\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\n\n/** Validation error collected during publish payload building. */\nexport type PublishValidationError = Pick<ValidationError, 'field' | 'message'> & { code?: string }\n\n/** Context for collecting validation errors instead of throwing on first error. */\nexport type PublishValidationContext = { errors: PublishValidationError[] }\n\n/** `patch` (default): new property attestations on the current Version. `new_version`: new Version attestation + attest all properties. */\nexport type PublishMode = 'patch' | 'new_version'\n\nexport type GetPublishPayloadOptions = {\n publishMode?: PublishMode\n}\n\nfunction addValidationError(\n ctx: PublishValidationContext,\n message: string,\n field?: string,\n code = 'publish_validation',\n): void {\n // A property can be validated on more than one path (List of Relation: list + basic); report once.\n if (ctx.errors.some((e) => e.message === message && e.field === (field ?? ''))) return\n ctx.errors.push({ field: field ?? '', message, code })\n}\n\n/** File/Image/Html value is raw content instead of a storage seed id, so it was never saved/uploaded. */\nfunction addStorageValueNotSavedError(\n ctx: PublishValidationContext,\n propertyName: string,\n dataType: string | undefined,\n value: string,\n): void {\n addValidationError(\n ctx,\n `Invalid value for property: ${propertyName}. Expected a storage seed id ` +\n `(${normalizeDataType(dataType)} content must be saved through the property before publishing), ` +\n `got ${value.length > 40 ? `${value.slice(0, 40)}…` : value}.`,\n propertyName,\n 'publish_storage_value_not_saved',\n )\n}\n\nfunction isStorageTransactionPropertyName(name: string | undefined): boolean {\n return name === 'storageTransactionId' || name === 'storage_transaction_id'\n}\n\n/**\n * Segmentation or naming variants can leave two rows for the same logical field; keep one\n * resolved slot so processBasicProperties emits a single storage tx attestation.\n */\nfunction replaceStorageTransactionInBasicProperties(\n itemBasicProperties: IItemProperty<any>[],\n resolved: IItemProperty<any>,\n): void {\n const filtered = itemBasicProperties.filter(\n (p) => !isStorageTransactionPropertyName(p.propertyName),\n )\n itemBasicProperties.length = 0\n itemBasicProperties.push(...filtered, resolved)\n}\n\n/** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */\nfunction dedupeOneStorageTransactionPropertyInList(itemBasicProperties: IItemProperty<any>[]): void {\n const nonStorage: IItemProperty<any>[] = []\n const storage: IItemProperty<any>[] = []\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName)) {\n storage.push(p)\n } else {\n nonStorage.push(p)\n }\n }\n if (storage.length <= 1) return\n itemBasicProperties.length = 0\n itemBasicProperties.push(...nonStorage, storage[storage.length - 1]!)\n}\n\n/**\n * Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.\n * Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.\n */\nfunction mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload: MultiPublishPayload,\n relatedSeedLocalId: string,\n publishLocalId: string,\n propertySchemaUid: string | undefined,\n): boolean {\n const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId)\n if (!existing) return false\n const pts = existing.propertiesToUpdate ?? []\n const already = pts.some(\n (e) =>\n e.publishLocalId === publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(propertySchemaUid ?? '').toLowerCase(),\n )\n if (!already) {\n pts.push({ publishLocalId, propertySchemaUid })\n }\n return true\n}\n\nconst getVersionUid = (item: IItem<any>): string => {\n const latestVersion = item.latestVersionUid\n if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {\n const u = latestVersion.uid\n return isValidEasAttestationUid(u) ? u : ZERO_BYTES32\n }\n if (latestVersion && typeof latestVersion === 'string') {\n return isValidEasAttestationUid(latestVersion) ? latestVersion : ZERO_BYTES32\n }\n return ZERO_BYTES32\n}\n\n/**\n * Resolve versionUid when item.latestVersionUid is empty but item has been published (has seedUid).\n * Tries DB first, then EAS. If the local versions row still has a placeholder uid after publish,\n * EAS fallback queries attestations where refUID=seedUid (Version attestations).\n */\nasync function resolveVersionUid(\n seedLocalId: string,\n seedUid: string | undefined,\n): Promise<string> {\n if (!seedLocalId || !seedUid || seedUid === ZERO_BYTES32) return ZERO_BYTES32\n\n const published = await getLatestPublishedVersionRow(seedLocalId)\n if (published?.uid) return published.uid\n\n try {\n const { getItemVersionsFromEas } = await import('@/eas')\n const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] })\n const latest = attestations?.[0]\n if (latest?.id) return latest.id\n } catch {\n // EAS client may not be initialized or network error\n }\n return ZERO_BYTES32\n}\n\ntype PropertyDataResult = {\n schemaUid: string\n easDataType: string\n schemaDef: string\n propertyNameForSchema: string\n}\n\nconst getPropertyData = async (\n itemProperty: IItemProperty<any>,\n ctx?: PublishValidationContext,\n): Promise<PropertyDataResult | null> => {\n const rawDataType = itemProperty.propertyDef?.dataType\n const dataType = rawDataType ? normalizeDataType(String(rawDataType)) : undefined\n const entry = dataType\n ? INTERNAL_DATA_TYPES[dataType as keyof typeof INTERNAL_DATA_TYPES]\n : undefined\n const easDataType = entry?.eas\n if (!easDataType) {\n if (ctx) {\n addValidationError(\n ctx,\n `Unknown or unsupported property data type \"${rawDataType ?? 'undefined'}\" for property: ${itemProperty.propertyName}. Supported types: ${Object.keys(INTERNAL_DATA_TYPES).join(', ')}.`,\n itemProperty.propertyName,\n )\n }\n return null\n }\n\n const ip = itemProperty as IItemProperty<any> & { storagePropertyName?: string }\n // List of Relation: the EAS name always comes from the property definition (authors → authorIdentityIds),\n // never from whatever name the ItemProperty was constructed with or a cached schemaUid.\n const listRelationName = listRelationEasPropertyName(\n itemProperty.propertyName,\n itemProperty.propertyDef as PropertySchemaEntry | undefined,\n )\n const nameForEas =\n listRelationName ??\n (ip.storagePropertyName && ip.storagePropertyName.length > 0\n ? ip.storagePropertyName\n : itemProperty.propertyName)\n const propertyNameForSchema = toSnakeCase(nameForEas)\n\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n let schemaUid: string | undefined = listRelationName ? undefined : itemProperty.schemaUid\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n }\n if (!schemaUid) {\n if (ctx) {\n addValidationError(\n ctx,\n `EAS schema not found for \"${schemaDef}\" (property: ${itemProperty.propertyName}). Register it before publishing (ensureEasSchemasForItem).`,\n itemProperty.propertyName,\n 'publish_schema_not_found',\n )\n }\n return null\n }\n\n return {\n schemaUid,\n easDataType,\n schemaDef,\n propertyNameForSchema,\n }\n}\n\n/** Resolve propertyDef from Model for properties that lack it (e.g. cached instances\n * created before loadOrCreateProperty was fixed). Ensures both new and existing items get property attestations.\n * Also ensures Relation/Image properties have required from schema when missing (for publish validation). */\nconst ensurePropertyDefs = async (targetItem: IItem<any>) => {\n const toFix = targetItem.properties.filter(\n (p) =>\n targetItem.modelName &&\n (!p.propertyDef ||\n (matchesDataType(p.propertyDef?.dataType, ModelPropertyDataTypes.Relation) &&\n p.propertyDef?.required === undefined)),\n )\n let schema: any\n for (const itemProperty of targetItem.properties) {\n if (!itemProperty.propertyDef && targetItem.modelName) {\n schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName)\n if (!schema) {\n try {\n const { Model } = await import('@/Model/Model')\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n let model = Model.getByName(normalizedModelName)\n if (!model?.properties?.length) {\n model = Model.findByModelType(toSnakeCaseDb(targetItem.modelName))\n }\n const modelFound = !!model\n const propsCount = model?.properties?.length ?? 0\n const schemaKeys: string[] = []\n if (model?.properties?.length) {\n const schemas = modelPropertiesToObject(model.properties)\n schemaKeys.push(...Object.keys(schemas))\n schema = schemas[itemProperty.propertyName]\n }\n } catch (err) {\n schema = undefined\n }\n }\n if (!schema) {\n const db = BaseDb.getAppDb()\n if (db) {\n try {\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, itemProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n schema = {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n }\n }\n } catch {\n schema = undefined\n }\n }\n }\n if (schema) {\n itemProperty.getService().send({\n type: 'updateContext',\n propertyRecordSchema: schema,\n })\n }\n }\n }\n}\n\ntype PublishBuildOpts = { forceFullSnapshot?: boolean }\n\nconst processBasicProperties = async (\n itemBasicProperties: IItemProperty<any>[],\n itemPublishData: PublishPayload,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<PublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n for (const basicProperty of itemBasicProperties) {\n // Skip SDK-internal properties (e.g. publisher) - never attest to EAS\n if (INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {\n continue\n }\n const snapshot = basicProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n const propertyDef =\n basicProperty.propertyDef ?? (context ? (context as any).propertyRecordSchema : undefined)\n const isFileImageHtml =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html)\n const isJsonStorage =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json)\n const isRelation = matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation)\n // storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).\n const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName)\n // File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).\n // basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.\n const preferPropertyValueForPublish =\n isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp\n let value =\n preferPropertyValueForPublish && context\n ? (context as any).propertyValue\n : ((basicProperty as IItemProperty<any>).value ??\n (context ? (context as any).propertyValue : undefined))\n const hasContext = !!context\n const hasValue = value != null && value !== ''\n const hasUid = !!basicProperty.uid\n const skipReason = !hasContext ? 'no_context' : (!hasValue || hasUid) ? (hasUid ? 'has_uid' : 'no_value') : null\n if (!context) {\n continue\n }\n // Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints\n if (\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Relation) ||\n isFileImageHtml ||\n isJsonStorage\n ) {\n const pv = (context as any).propertyValue\n if (typeof value === 'object' || value == null) {\n if (typeof pv === 'string' && pv.trim()) value = pv.trim()\n else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string') value = pv.seedLocalId\n }\n }\n if (!value) {\n continue\n }\n // Patch mode skips properties that already have an EAS uid. storageTransactionId must still\n // attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.\n if (basicProperty.uid && !forceFullSnapshot) {\n const allowStorageTxAttestation =\n isStorageTransactionIdProp &&\n typeof value === 'string' &&\n value.trim() !== ''\n if (!allowStorageTxAttestation) {\n continue\n }\n }\n\n // File/Image/Html values must be a storage seed id by now. Raw content means the property's\n // save pipeline never ran or failed (e.g. createNewItem with raw html), so it was never uploaded.\n // Relation/image properties are appended to the basic list after processRelationOrImageProperty,\n // so this one check covers both paths.\n if (isFileImageHtml && typeof value === 'string' && !isStorageSeedRef(value)) {\n addStorageValueNotSavedError(ctx, basicProperty.propertyName, propertyDef?.dataType, value)\n continue\n }\n\n const propertyData = await getPropertyData(basicProperty, ctx)\n if (!propertyData) continue\n const { schemaUid, easDataType, schemaDef, propertyNameForSchema } = propertyData\n if (!schemaDef) continue\n\n // Normalize value: string that parses to array (e.g. from browser storage) -> array\n if (schemaDef.startsWith('bytes32[]') && typeof value === 'string' && value.trim().startsWith('[')) {\n try {\n value = JSON.parse(value)\n } catch {\n // fall through to array check\n }\n }\n\n // Legacy comma-separated ids (pre-JSON List storage)\n if (\n schemaDef.startsWith('bytes32[]') &&\n typeof value === 'string' &&\n !value.trim().startsWith('[') &&\n value.includes(',')\n ) {\n value = value\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean)\n }\n\n if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {\n addValidationError(\n ctx,\n `Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding\n if (propertyDef?.validation) {\n const { SchemaValidationService } = await import(\n '@/Schema/service/validation/SchemaValidationService'\n )\n const validationService = new SchemaValidationService()\n const validationResult = validationService.validatePropertyValue(\n value,\n normalizeDataType(propertyDef.dataType) as ModelPropertyDataTypes,\n propertyDef.validation,\n propertyDef.refValueType\n ? (normalizeDataType(propertyDef.refValueType) as string)\n : undefined,\n )\n if (!validationResult.isValid && validationResult.errors.length > 0) {\n const firstError = validationResult.errors[0]\n addValidationError(\n ctx,\n firstError.message,\n basicProperty.propertyName,\n firstError.code ?? 'publish_validation',\n )\n continue\n }\n }\n\n /** Raw id per list slot (nanoid local id or 0x… uid) for resolvePublishPayloadValues after sequential publish */\n let rawListIdsForResolve: string[] | undefined\n if (schemaDef.startsWith('bytes32[]')) {\n const newValues: string[] = []\n const rawIds: string[] = []\n const iterableValue =\n Array.isArray(value) ? value\n : value != null && typeof value[Symbol.iterator] === 'function' ? value\n : []\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n ? String(\n (seedId as { seedLocalId?: string; seedUid?: string }).seedLocalId ??\n (seedId as { seedUid?: string }).seedUid ??\n '',\n )\n : ''\n if (!idStr) continue\n const trimmed = idStr.trim()\n if (!trimmed) continue\n rawIds.push(trimmed)\n if (trimmed.length !== 66 && !trimmed.startsWith('0x')) {\n newValues.push(encodeBytes32String(trimmed))\n } else {\n newValues.push(trimmed)\n }\n }\n value = newValues\n const needsUidResolve = rawIds.some(\n (id) => id.length !== 66 || !id.startsWith('0x'),\n )\n if (needsUidResolve && rawIds.length > 0) {\n rawListIdsForResolve = rawIds\n }\n }\n\n // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds\n if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {\n const ms = value instanceof Date ? value.getTime() : new Date(value).getTime()\n value = BigInt(Math.floor(ms / 1000))\n }\n\n let data = [\n {\n name: propertyNameForSchema,\n type: easDataType,\n value,\n },\n ]\n\n let encodedData: string\n try {\n const dataEncoder = new SchemaEncoder(schemaDef)\n encodedData = dataEncoder.encodeData(data) as string\n } catch (encodeErr) {\n addValidationError(\n ctx,\n `Failed to encode property ${basicProperty.propertyName}: ${encodeErr instanceof Error ? encodeErr.message : String(encodeErr)}`,\n basicProperty.propertyName,\n )\n continue\n }\n\n // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)\n const refUid = isStorageTransactionIdProp\n ? itemPublishData.versionUid\n : defaultAttestationData.refUID\n\n const attestationEntry: Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n /** Same as encode step (getPropertyData); resolvePublishPayloadValues must use this, not toSnakeCase(propertyName). */\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n /** Per-slot raw ids (local or 0x) before encodeBytes32String; re-encoded after sequential publish. */\n _rawListIdsForResolve?: string[]\n } = {\n schema: schemaUid!,\n data: [\n {\n ...defaultAttestationData,\n refUID: refUid,\n data: encodedData,\n } as AttestationRequestData,\n ],\n // Always set so persist can match metadata rows that lack schemaUid\n _propertyName: basicProperty.propertyName,\n }\n\n // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues\n const looksLikeLocalSeedRef =\n typeof value === 'string' &&\n !value.startsWith('0x') &&\n value.length !== 66 &&\n /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim())\n if (\n looksLikeLocalSeedRef &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._unresolvedValue = value.trim()\n attestationEntry._easDataType = easDataType\n }\n if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._propertyNameForSchema = propertyNameForSchema\n attestationEntry._schemaDef = schemaDef\n attestationEntry._easDataType = 'bytes32[]'\n attestationEntry._rawListIdsForResolve = rawListIdsForResolve\n }\n\n itemPublishData.listOfAttestations.push(attestationEntry)\n }\n\n return itemPublishData\n}\n\n\nconst processRelationOrImageProperty = async (\n relationOrImageProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n let relationOrImageSchemaUid = relationOrImageProperty.schemaUid\n if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {\n const propertyData = await getPropertyData(relationOrImageProperty, ctx)\n if (!propertyData) return multiPublishPayload\n relationOrImageSchemaUid = propertyData.schemaUid\n }\n if (!relationOrImageSchemaUid) {\n addValidationError(\n ctx,\n `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = relationOrImageProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n // File/Image/Html/Json metadata is stored with Id suffix (e.g. \"textId\"); context may not have propertyValue\n // if the property was created from schema before metadata loaded. Fallback to metadata lookup.\n const isStorageSeed =\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(relationOrImageProperty.propertyDef?.refValueType, ModelPropertyDataTypes.Json)))\n if (isStorageSeed && ((context as any).seedLocalId || (context as any).seedUid)) {\n const { getPropertyData: getPropertyDataFromDb } = await import('@/db/read/getPropertyData')\n const metaRow = await getPropertyDataFromDb({\n propertyName: relationOrImageProperty.propertyName,\n seedLocalId: (context as any).seedLocalId,\n seedUid: (context as any).seedUid,\n })\n const fromMeta = metaRow?.propertyValue\n if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {\n const idsCtx = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(value) ?? '')\n const idsDb = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(fromMeta) ?? '')\n if (!value) {\n value = fromMeta\n } else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {\n value = fromMeta\n }\n }\n }\n const propertyDef = relationOrImageProperty.propertyDef\n let isRequired = propertyDef?.required === true\n // Resolve required from schema/DB when propertyDef lacks it\n if (!isRequired && relationOrImageProperty.modelName) {\n let schema = await getPropertySchema(\n relationOrImageProperty.modelName,\n relationOrImageProperty.propertyName,\n )\n if (!schema && BaseDb.getAppDb()) {\n const normalizedModelName = upperFirst(camelCase(relationOrImageProperty.modelName))\n const modelRecords = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length > 0 && modelRecords[0].id) {\n const propertyRecords = await BaseDb.getAppDb()!\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, relationOrImageProperty.propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length > 0) {\n schema = {\n dataType: propertyRecords[0].dataType,\n ref: undefined,\n required: propertyRecords[0].required ?? undefined,\n } as any\n }\n }\n }\n if (schema?.required === true || (schema as any)?.required === 1) {\n isRequired = true\n }\n }\n\n // Required relation/image/file/html/json with no value: cannot publish\n if (isRequired && !value) {\n const typeLabel =\n matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.File)\n ? 'file'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Image)\n ? 'image'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Html)\n ? 'html'\n : matchesDataType(propertyDef?.dataType, ModelPropertyDataTypes.Json) ||\n matchesDataType(propertyDef?.refValueType, ModelPropertyDataTypes.Json)\n ? 'json'\n : 'relation'\n const refLabel = propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'\n addValidationError(\n ctx,\n `Required ${typeLabel} ${relationOrImageProperty.propertyName} has no value. ` +\n `A value pointing to a valid ${refLabel} item is required to publish.`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (!value) {\n return multiPublishPayload\n }\n if (relationOrImageProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n const normalizedRef = normalizeRelationPropertyValue(value)\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(normalizedRef ?? '')\n\n // Value is not a valid seed reference (local id or 0x uid)\n if (!seedLocalId && !seedUid) {\n if (isRequired) {\n addValidationError(\n ctx,\n `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +\n `Value must be a valid seed reference (localId or uid) pointing to a ${propertyDef?.ref ?? propertyDef?.refModelName ?? 'related'} item.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n // When related item not found (e.g. different DB, not yet created)\n if (!relatedItem) {\n // An attested uid with no local copy is already published; the parent attests the uid as-is.\n if (isRequired && !isPublishedSeedRef(normalizedRef)) {\n addValidationError(\n ctx,\n `No related item found for required relation: ${relationOrImageProperty.propertyName}. ` +\n `Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +\n `The related item may be missing, in a different database, or the reference may be broken.`,\n relationOrImageProperty.propertyName,\n )\n }\n return multiPublishPayload\n }\n\n // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {\n modelName = 'Image'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {\n modelName = 'File'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {\n modelName = 'Html'\n }\n\n if (matchesDataType(relationOrImageProperty.propertyDef?.dataType, ModelPropertyDataTypes.Relation)) {\n const def = relationOrImageProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n relationOrImageProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n relationOrImageSchemaUid,\n )\n ) {\n return multiPublishPayload\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: relationOrImageSchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties, itemUploadProperties } =\n await getSegmentedItemProperties(relatedItem)\n\n const relatedStorageUpload = resolveStorageTransactionUploadSlot(\n relatedItem,\n itemUploadProperties,\n )\n if (relatedStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(\n uploadedTransactions,\n relatedItem.seedLocalId,\n )\n if (transactionData) {\n const itemProperty = relatedStorageUpload.itemProperty\n // Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it\n // uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const p of itemBasicProperties) {\n if (\n isStorageTransactionPropertyName(p.propertyName) &&\n !p.propertyDef &&\n relatedItem.modelName\n ) {\n const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\nasync function resolveHtmlPropertySchemaUidByHtmlSeed(\n item: IItem<any>,\n htmlSeedLocalId: string,\n ctx: PublishValidationContext,\n): Promise<string | undefined> {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties) {\n if (!matchesDataType(p.propertyDef?.dataType, ModelPropertyDataTypes.Html)) continue\n const snap = p.getService().getSnapshot()\n const c = 'context' in snap ? snap.context : null\n const pv = typeof (c as any)?.propertyValue === 'string' ? (c as any).propertyValue.trim() : ''\n if (pv !== want) continue\n let uid = p.schemaUid\n if (!uid) {\n const pd = await getPropertyData(p, ctx)\n uid = pd?.schemaUid\n }\n return uid\n }\n addValidationError(\n ctx,\n `Could not find Html property for embedded image rewrite (html seed ${want}).`,\n 'html',\n 'html_embed_schema',\n )\n return undefined\n}\n\nasync function processHtmlEmbeddedCoPublishImagePayloads(\n item: IItem<any>,\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return multiPublishPayload\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n if (rows.length === 0) return multiPublishPayload\n\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const doneImages = new Set<string>()\n\n for (const row of rows) {\n if (doneImages.has(row.imageSeedLocalId)) continue\n doneImages.add(row.imageSeedLocalId)\n\n const htmlSchemaUid = await resolveHtmlPropertySchemaUidByHtmlSeed(item, row.htmlSeedLocalId, ctx)\n if (!htmlSchemaUid) continue\n\n const relatedItem = await getItem({ seedLocalId: row.imageSeedLocalId })\n if (!relatedItem) {\n addValidationError(\n ctx,\n `Embedded Image item not found for seed ${row.imageSeedLocalId}.`,\n 'html',\n 'html_embed_image_missing',\n )\n continue\n }\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n continue\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel('Image')\n if (!seedSchemaUid) {\n addValidationError(ctx, `Schema UID not found for model: Image`, 'html')\n continue\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n htmlSchemaUid,\n )\n ) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID,\n seedUid: relatedItem.seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: htmlSchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties, itemUploadProperties } =\n await getSegmentedItemProperties(relatedItem)\n\n const relatedStorageUpload = resolveStorageTransactionUploadSlot(\n relatedItem,\n itemUploadProperties,\n )\n if (relatedStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(\n uploadedTransactions,\n relatedItem.seedLocalId,\n )\n if (transactionData) {\n const itemProperty = relatedStorageUpload.itemProperty\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const p of itemBasicProperties) {\n if (\n isStorageTransactionPropertyName(p.propertyName) &&\n !p.propertyDef &&\n relatedItem.modelName\n ) {\n const schema = await getPropertySchema(relatedItem.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\nconst processListProperty = async (\n listProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n originalSeedLocalId: string,\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> => {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties\n if (!listProperty.propertyDef?.ref) {\n addValidationError(\n ctx,\n `processListProperty requires ref (list of relations). List property \"${listProperty.propertyName}\" has no ref. List-of-primitives should be in itemBasicProperties.`,\n listProperty.propertyName,\n )\n return multiPublishPayload\n }\n\n const snapshot = listProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n return multiPublishPayload\n }\n let value = (context as any).propertyValue\n if (!value) {\n return multiPublishPayload\n }\n if (listProperty.uid && !forceFullSnapshot) {\n return multiPublishPayload\n }\n\n // Always resolve from the property definition; a cached schemaUid may point at a schema\n // registered under the schema key (bytes32[] authors) instead of authorIdentityIds.\n const propertyData = await getPropertyData(listProperty, ctx)\n if (!propertyData) return multiPublishPayload\n const listPropertySchemaUid = propertyData.schemaUid\n\n if (typeof value === 'string') {\n value = parseListPropertyValueFromStorage(value)\n }\n\n const iterableValue = Array.isArray(value)\n ? value\n : value != null\n ? [value]\n : []\n\n for (const seedId of iterableValue) {\n const idStr =\n typeof seedId === 'string'\n ? seedId\n : seedId &&\n typeof seedId === 'object' &&\n (seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)\n if (!idStr) continue\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(idStr)\n if (!seedLocalId && !seedUid) continue\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // An attested uid with no local copy is already published; the list attests the uid as-is.\n if (!isPublishedSeedRef(idStr)) {\n console.error(\n `No related item found for list property: ${listProperty.propertyName}`,\n )\n }\n continue\n }\n\n if (relatedItem.seedUid && relatedItem.seedUid !== ZERO_BYTES32) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (listProperty.propertyDef?.ref || (listProperty.propertyDef as { refModelName?: string }).refModelName) {\n const def = listProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Image)) {\n modelName = 'Image'\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.File)) {\n modelName = 'File'\n }\n\n if (matchesDataType(listProperty.propertyDef?.dataType, ModelPropertyDataTypes.Html)) {\n modelName = 'Html'\n }\n\n if (!modelName) {\n addValidationError(\n ctx,\n `Model name not found for list property: ${listProperty.propertyName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n addValidationError(\n ctx,\n `Schema UID not found for model: ${modelName}`,\n listProperty.propertyName,\n )\n continue\n }\n\n if (\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n originalSeedLocalId,\n listPropertySchemaUid,\n )\n ) {\n continue\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: listPropertySchemaUid,\n },\n ],\n }\n\n await ensurePropertyDefs(relatedItem)\n const { itemBasicProperties } = await getSegmentedItemProperties(relatedItem)\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {\n forceFullSnapshot,\n })\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\ntype PublishPayload = {\n localId: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: (Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n _rawListIdsForResolve?: string[]\n })[]\n propertiesToUpdate: any[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\n\n/**\n * Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so\n * duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.\n */\nfunction attestationPayloadDedupeKey(att: PublishPayload['listOfAttestations'][number]): string {\n const schema = String((att as { schema?: string }).schema ?? '').toLowerCase()\n const dataArr = (att as { data?: unknown[] }).data\n const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined\n const dataHex =\n d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0\n ? String((d0 as { data?: string }).data ?? '').toLowerCase()\n : ''\n return `${schema}:${dataHex}`\n}\n\n/**\n * Collapse duplicate rows in listOfAttestations (same schema + encoded payload).\n */\nfunction dedupeListOfAttestationsInEachPayload(payload: MultiPublishPayload): MultiPublishPayload {\n for (const p of payload) {\n const list = p.listOfAttestations ?? []\n if (list.length <= 1) continue\n const seen = new Set<string>()\n const out: PublishPayload['listOfAttestations'] = []\n for (const a of list) {\n const k = attestationPayloadDedupeKey(a)\n if (seen.has(k)) continue\n seen.add(k)\n out.push(a)\n }\n p.listOfAttestations = out\n }\n return payload\n}\n\n/**\n * Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).\n * Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.\n */\nfunction dedupeMultiPublishPayloadByLocalId(payload: MultiPublishPayload): MultiPublishPayload {\n const map = new Map<string, PublishPayload>()\n const order: string[] = []\n\n for (const p of payload) {\n const id = p.localId\n const existing = map.get(id)\n if (!existing) {\n map.set(id, p)\n order.push(id)\n continue\n }\n const ptu = [...(existing.propertiesToUpdate ?? [])]\n for (const u of p.propertiesToUpdate ?? []) {\n if (\n !ptu.some(\n (e) =>\n e.publishLocalId === u.publishLocalId &&\n String(e.propertySchemaUid ?? '').toLowerCase() ===\n String(u.propertySchemaUid ?? '').toLowerCase(),\n )\n ) {\n ptu.push(u)\n }\n }\n existing.propertiesToUpdate = ptu\n const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)))\n const merged = [...(existing.listOfAttestations ?? [])]\n for (const a of p.listOfAttestations ?? []) {\n const k = attestationPayloadDedupeKey(a)\n if (seenKeys.has(k)) continue\n seenKeys.add(k)\n merged.push(a)\n }\n existing.listOfAttestations = merged\n }\n\n return order.map((id) => map.get(id)!).filter(Boolean) as MultiPublishPayload\n}\n\n/** Map of seed localId -> attestation uid for resolving relation/image property values after dependent seeds are published */\nexport type ResolvedSeedUids = Record<string, string>\n\ntype UploadedTransaction = {\n txId: string\n itemPropertyLocalId?: string\n seedLocalId?: string\n versionLocalId?: string\n itemPropertyName?: string\n}\n\n/** Same shape as UploadProperty in getPublishUploads */\ntype StorageUploadSlot = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\n\n/**\n * Child File/Image items may keep storageTransactionId only on the item machine's\n * propertyInstances map; allProperties / item.properties can omit it during publish.\n */\nfunction getStorageTransactionPropertyFromItemInstances(\n item: IItem<any>,\n): IItemProperty<any> | undefined {\n try {\n const svc = (item as { getService?: () => { getSnapshot: () => unknown } }).getService?.()\n if (!svc) return undefined\n const snap = svc.getSnapshot() as {\n context?: { propertyInstances?: Map<string, IItemProperty<any>> }\n }\n const instances = snap.context?.propertyInstances\n if (!instances || !(instances instanceof Map)) return undefined\n const direct =\n instances.get('storageTransactionId') ?? instances.get('storage_transaction_id')\n if (direct) return direct\n for (const [, p] of instances) {\n if (p && isStorageTransactionPropertyName(p.propertyName)) return p\n }\n } catch {\n return undefined\n }\n return undefined\n}\n\n/**\n * Resolve storageTransactionId (+ ItemStorage children) for publish.\n * getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never\n * hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while\n * getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.\n */\nfunction resolveStorageTransactionUploadSlot(\n item: IItem<any>,\n itemUploadProperties: StorageUploadSlot[],\n): StorageUploadSlot | undefined {\n const named = itemUploadProperties.find((u) =>\n isStorageTransactionPropertyName(u.itemProperty.propertyName),\n )\n if (named) return named\n if (itemUploadProperties.length === 1) return itemUploadProperties[0]\n\n const all = (item as { allProperties?: Record<string, IItemProperty<any>> }).allProperties\n const fromInstances = getStorageTransactionPropertyFromItemInstances(item)\n const storagePropEarly =\n all?.['storageTransactionId'] ??\n all?.['storage_transaction_id'] ??\n Object.values(all ?? {}).find(\n (p): p is IItemProperty<any> =>\n !!p && isStorageTransactionPropertyName((p as IItemProperty<any>).propertyName),\n ) ??\n item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName))\n const storageProp = storagePropEarly ?? fromInstances\n if (!storageProp) return undefined\n\n const childProps =\n item.properties?.filter(\n (p) =>\n p.propertyDef &&\n (p.propertyDef as { storageType?: string }).storageType === 'ItemStorage',\n ) ?? []\n return { itemProperty: storageProp, childProperties: childProps }\n}\n\nfunction findUploadedTxForSeedLocalId(\n uploadedTransactions: UploadedTransaction[],\n seedLocalId: string,\n): UploadedTransaction | undefined {\n const t = seedLocalId.trim()\n return (\n uploadedTransactions.find((u) => u.seedLocalId === t) ??\n uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t)\n )\n}\n\n/** Error thrown when publish validation fails. Includes all validation errors for user to fix. */\nexport class PublishValidationFailedError extends Error {\n constructor(\n message: string,\n public readonly validationErrors: PublishValidationError[],\n ) {\n super(message)\n this.name = 'PublishValidationFailedError'\n }\n}\n\nexport const getPublishPayload = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[],\n options?: GetPublishPayloadOptions,\n): Promise<MultiPublishPayload> => {\n const validationCtx: PublishValidationContext = { errors: [] }\n const publishMode: PublishMode = options?.publishMode ?? 'patch'\n const forceFullSnapshot = publishMode === 'new_version'\n\n if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === ZERO_BYTES32)) {\n addValidationError(\n validationCtx,\n 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).',\n 'seedUid',\n 'publish_new_version_requires_seed',\n )\n }\n\n let multiPublishPayload: MultiPublishPayload = []\n\n // Each PublishPayload is generated from a Seed that needs publishing\n\n // First we need to determine all Seeds to publish\n\n // That means the Seed of the Item, plus any Seeds pointed to by Relations\n\n // Check if the item has a schema UID\n let itemSchemaUid = item.schemaUid\n if (!itemSchemaUid) {\n const schemaUid = await getEasSchemaUidForModel(item.modelName)\n if (!schemaUid) {\n addValidationError(validationCtx, `Schema UID not found for model: ${item.modelName}`)\n itemSchemaUid = ZERO_BYTES32 // placeholder so we can continue collecting errors\n } else {\n itemSchemaUid = schemaUid\n }\n }\n\n let versionUid = getVersionUid(item)\n if (versionUid === ZERO_BYTES32 && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = await resolveVersionUid(item.seedLocalId, item.seedUid)\n }\n if (forceFullSnapshot && item.seedUid && item.seedUid !== ZERO_BYTES32) {\n versionUid = ZERO_BYTES32\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: item.seedUid || ZERO_BYTES32,\n seedIsRevocable: true,\n seedSchemaUid: itemSchemaUid,\n versionSchemaUid: VERSION_SCHEMA_UID,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n await ensurePropertyDefs(item)\n\n const {\n itemBasicProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n itemRelationProperties,\n } = await getSegmentedItemProperties(item)\n\n const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties]\n\n // Validate required relations have values before processing\n for (const relProp of itemRelationProperties) {\n const snapshot = relProp.getService().getSnapshot()\n const ctx = 'context' in snapshot ? snapshot.context : null\n const val = ctx ? (ctx as any).renderValue ?? (ctx as any).propertyValue : undefined\n if (val != null && typeof val === 'string' && val.trim() !== '') continue\n // No value - check if required from propertyDef or DB\n let isRequired = relProp.propertyDef?.required === true\n if (!isRequired && BaseDb.getAppDb() && item.modelName) {\n const normalizedModelName = upperFirst(camelCase(item.modelName))\n const modelRows = await BaseDb.getAppDb()!\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRows.length > 0) {\n const propRows = await BaseDb.getAppDb()!\n .select({ required: properties.required, refModelId: properties.refModelId })\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRows[0].id),\n eq(properties.name, relProp.propertyName),\n sql`lower(${properties.dataType}) = 'relation'`,\n ),\n )\n .limit(1)\n if (propRows.length > 0 && (propRows[0].required === true || propRows[0].required === 1)) {\n isRequired = true\n }\n }\n }\n if (isRequired) {\n const refModel = relProp.propertyDef?.ref ?? relProp.propertyDef?.refModelName ?? 'related'\n addValidationError(\n validationCtx,\n `Required relation ${relProp.propertyName} has no value. ` +\n `A value pointing to a valid ${refModel} item is required to publish.`,\n relProp.propertyName,\n )\n }\n }\n\n const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties)\n if (rootStorageUpload) {\n const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId)\n if (transactionData) {\n const itemProperty = rootStorageUpload.itemProperty\n itemProperty.getService().send({\n type: 'updateContext',\n propertyValue: transactionData.txId,\n renderValue: transactionData.txId,\n })\n replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty)\n }\n }\n\n for (const relationProperty of relationAndImageProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(relationProperty)\n }\n\n multiPublishPayload = await processHtmlEmbeddedCoPublishImagePayloads(\n item,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n item.seedLocalId,\n validationCtx,\n { forceFullSnapshot },\n )\n itemBasicProperties.push(listProperty)\n }\n\n for (const p of itemBasicProperties) {\n if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {\n const schema = await getPropertySchema(item.modelName, 'storageTransactionId')\n if (schema) {\n p.getService().send({ type: 'updateContext', propertyRecordSchema: schema })\n }\n }\n }\n\n dedupeOneStorageTransactionPropertyInList(itemBasicProperties)\n itemPublishData = await processBasicProperties(\n itemBasicProperties,\n itemPublishData,\n validationCtx,\n { forceFullSnapshot },\n )\n\n multiPublishPayload.push(itemPublishData)\n\n // Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),\n // A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's\n // attestation before B is sent to EAS.\n multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload)\n multiPublishPayload = orderPayloadByDependencies(multiPublishPayload)\n\n // Ensure attestations referenced in propertiesToUpdate have at least one data element.\n // The contract writes the seed UID into data[0].data; empty data causes Panic 50.\n multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload)\n multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload)\n\n if (publishMode === 'new_version') {\n const rootPayload = multiPublishPayload.find((p) => p.localId === item.seedLocalId)\n const listLen = rootPayload?.listOfAttestations?.length ?? 0\n if (!rootPayload || listLen === 0) {\n addValidationError(\n validationCtx,\n 'Publishing as a new version requires at least one property attestation for the item. ' +\n 'Ensure required fields have values and that publishable properties are present.',\n 'listOfAttestations',\n 'publish_new_version_empty_snapshot',\n )\n }\n }\n\n if (validationCtx.errors.length > 0) {\n const combinedMessage = validationCtx.errors.map((e) => e.message).join('\\n')\n throw new PublishValidationFailedError(\n `Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\\n${combinedMessage}`,\n validationCtx.errors,\n )\n }\n\n return multiPublishPayload\n}\n\nexport type ValidateItemForPublishResult = {\n isValid: boolean\n errors: PublishValidationError[]\n}\n\n/**\n * Validates an item for publishing without performing Arweave or EAS work.\n * Use in the checking step to fail fast before creating transactions.\n * Pass empty array for uploadedTransactions when validating before Arweave upload.\n */\nexport const validateItemForPublish = async (\n item: IItem<any>,\n uploadedTransactions: UploadedTransaction[] = [],\n options?: GetPublishPayloadOptions,\n): Promise<ValidateItemForPublishResult> => {\n try {\n await getPublishPayload(item, uploadedTransactions, options)\n return { isValid: true, errors: [] }\n } catch (err) {\n if (err instanceof PublishValidationFailedError) {\n return { isValid: false, errors: err.validationErrors }\n }\n throw err\n }\n}\n\n/**\n * Normalize a schema UID to 0x-prefixed 64-char hex for comparison.\n */\nfunction normalizeSchemaUid(v: string | undefined): string {\n if (v == null || v === '') return ''\n const raw = v.startsWith('0x') ? v.slice(2) : v\n const hex = raw.replace(/[^0-9a-fA-F]/g, '0').padStart(64, '0').slice(-64)\n return ('0x' + hex).toLowerCase()\n}\n\n/**\n * Ensure that when request A has propertiesToUpdate with (publishLocalId: B, propertySchemaUid: X),\n * request B has an attestation for schema X with at least one data element. The contract writes\n * the seed UID into data[0].data; empty data causes Panic 50.\n */\nfunction ensurePropertiesToUpdateAttestationsHaveData(\n payload: MultiPublishPayload,\n): MultiPublishPayload {\n const byLocalId = new Map<string, PublishPayload>()\n for (const p of payload) {\n byLocalId.set(p.localId, p)\n }\n\n const placeholderData: AttestationRequestData = {\n ...defaultAttestationData,\n data: ZERO_BYTES32,\n }\n\n for (const req of payload) {\n for (const pu of req.propertiesToUpdate ?? []) {\n const targetId = (pu as { publishLocalId?: string }).publishLocalId\n const schemaUid = (pu as { propertySchemaUid?: string }).propertySchemaUid\n if (!targetId || !schemaUid) continue\n\n const targetReq = byLocalId.get(targetId)\n if (!targetReq?.listOfAttestations) continue\n\n const wantSchema = normalizeSchemaUid(schemaUid)\n const att = targetReq.listOfAttestations.find(\n (a) => normalizeSchemaUid(a?.schema) === wantSchema,\n )\n if (!att) continue\n\n if (!Array.isArray(att.data) || att.data.length === 0) {\n att.data = [placeholderData]\n }\n }\n }\n\n return payload\n}\n\n/**\n * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.\n */\nfunction collectAttestationLocalRefIds(\n req: PublishPayload,\n allLocalIds: Set<string>,\n): string[] {\n const refs: string[] = []\n for (const a of req.listOfAttestations ?? []) {\n const att = a as {\n _unresolvedValue?: string\n _rawListIdsForResolve?: string[]\n }\n if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {\n refs.push(att._unresolvedValue)\n }\n if (Array.isArray(att._rawListIdsForResolve)) {\n for (const id of att._rawListIdsForResolve) {\n const t = id != null ? String(id).trim() : ''\n if (t && allLocalIds.has(t)) refs.push(t)\n }\n }\n }\n return refs\n}\n\n/**\n * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.\n * - propertiesToUpdate: updater before updatee (contract injection).\n * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.\n * The previous DFS visit could order [Post, Image] when Post appeared first in the input array,\n * so resolvedUids was empty when Post was published and attestations kept local ids.\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n if (payload.length <= 1) return payload\n\n const byLocalId = new Map<string, PublishPayload>()\n const allIds = new Set<string>()\n const indexOrder = new Map<string, number>()\n for (let i = 0; i < payload.length; i++) {\n const p = payload[i]\n byLocalId.set(p.localId, p)\n allIds.add(p.localId)\n indexOrder.set(p.localId, i)\n }\n\n const indegree = new Map<string, number>()\n for (const id of allIds) indegree.set(id, 0)\n\n const adj = new Map<string, Set<string>>()\n\n const addEdge = (from: string, to: string) => {\n if (from === to || !allIds.has(from) || !allIds.has(to)) return\n if (!adj.has(from)) adj.set(from, new Set())\n const set = adj.get(from)!\n if (set.has(to)) return\n set.add(to)\n indegree.set(to, (indegree.get(to) ?? 0) + 1)\n }\n\n for (const p of payload) {\n for (const u of p.propertiesToUpdate ?? []) {\n const targetId = (u as { publishLocalId?: string }).publishLocalId\n if (targetId && targetId !== p.localId) addEdge(p.localId, targetId)\n }\n for (const refId of collectAttestationLocalRefIds(p, allIds)) {\n addEdge(refId, p.localId)\n }\n }\n\n const zero: string[] = []\n for (const id of allIds) {\n if ((indegree.get(id) ?? 0) === 0) zero.push(id)\n }\n zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n\n const result: PublishPayload[] = []\n const queue = zero\n\n while (queue.length > 0) {\n const id = queue.shift()!\n const p = byLocalId.get(id)\n if (p) result.push(p)\n for (const to of adj.get(id) ?? []) {\n const next = (indegree.get(to) ?? 0) - 1\n indegree.set(to, next)\n if (next === 0) {\n queue.push(to)\n queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0))\n }\n }\n }\n\n if (result.length !== payload.length) {\n const seen = new Set(result.map((r) => r.localId))\n for (const p of payload) {\n if (!seen.has(p.localId)) result.push(p)\n }\n }\n\n return result\n}\n\n/** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */\nfunction padUidForBytes32Schema(uid: string): string {\n const t = uid.trim()\n if (!t.startsWith('0x')) return uid\n const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '')\n if (hex.length === 0) return uid\n return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase()\n}\n\n/**\n * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.\n * Call after each payload is published, passing the returned attestation uid for that seed's localId.\n * Returns an updated multiPayload with re-encoded attestations where resolution was applied.\n */\nexport const resolvePublishPayloadValues = async (\n multiPayload: MultiPublishPayload,\n resolvedUids: ResolvedSeedUids,\n): Promise<MultiPublishPayload> => {\n if (Object.keys(resolvedUids).length === 0) {\n return multiPayload\n }\n\n const result: MultiPublishPayload = []\n\n for (const payload of multiPayload) {\n const updatedAttestations: PublishPayload['listOfAttestations'] = []\n\n for (const attestation of payload.listOfAttestations) {\n const entry = attestation as PublishPayload['listOfAttestations'][0] & {\n _easDataType?: string\n _propertyNameForSchema?: string\n _rawListIdsForResolve?: string[]\n data?: AttestationRequestData[] | AttestationRequestData\n }\n\n const rawList = entry._rawListIdsForResolve\n if (\n rawList &&\n rawList.length > 0 &&\n entry._schemaDef &&\n (entry._propertyNameForSchema || entry._propertyName)\n ) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const resolvedValues: string[] = []\n let allSlotsResolved = true\n for (const id of rawList) {\n const trimmed = id.trim()\n if (trimmed.length === 66 && trimmed.startsWith('0x')) {\n resolvedValues.push(padUidForBytes32Schema(trimmed))\n continue\n }\n const r = resolvedUids[trimmed]\n if (r) {\n resolvedValues.push(padUidForBytes32Schema(r))\n continue\n }\n allSlotsResolved = false\n break\n }\n // Do not encode or clear hints until every slot has a real uid — otherwise sequential\n // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.\n if (!allSlotsResolved) {\n updatedAttestations.push({\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n })\n continue\n }\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: 'bytes32[]',\n value: resolvedValues,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _rawListIdsForResolve: undefined,\n _easDataType: undefined,\n })\n continue\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n const easType = (entry._easDataType as 'bytes32' | 'string') || 'bytes32'\n if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {\n const fieldName =\n entry._propertyNameForSchema ?? toSnakeCase(entry._propertyName as string)\n const valueForEncode =\n easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: easType,\n value: valueForEncode,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _unresolvedValue: undefined,\n })\n } else {\n const normalizedEntry: PublishPayload['listOfAttestations'][0] = {\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n }\n updatedAttestations.push(normalizedEntry)\n }\n }\n\n result.push({\n ...payload,\n listOfAttestations: updatedAttestations,\n })\n }\n\n return result\n}\n"],"names":["normalizeDataType","isValidEasAttestationUid","ZERO_BYTES32","getLatestPublishedVersionRow","INTERNAL_DATA_TYPES","listRelationEasPropertyName","toSnakeCase","getEasSchemaUidForSchemaDefinition","ModelPropertyDataTypes","getPropertySchema","upperFirst","camelCase","toSnakeCaseDb","modelPropertiesToObject","BaseDb","models","eq","properties","and","INTERNAL_PROPERTY_NAMES","isStorageSeedRef","SchemaEncoder","defaultAttestationData","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","isPublishedSeedRef","getEasSchemaUidForModel","VERSION_SCHEMA_UID","getSegmentedItemProperties","htmlEmbeddedImageCoPublish","parseListPropertyValueFromStorage","getCorrectId","sql"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;AACM,SAAU,mBAAmB,CAAC,KAAa,EAAA;IAC/C,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;AAC7C,IAAA,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,CAAA,6CAAA,EAAgD,KAAK,CAAC,MAAM,CAAA,CAAA,CAAG,CAAC;IAClF;AACA,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;AACzB,SAAA,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;SAC1C,IAAI,CAAC,EAAE,CAAC;IACX,OAAO,CAAA,EAAA,EAAK,GAAG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