@seedprotocol/sdk 0.7.1 → 0.7.2
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-DRT09oVv.js → BasePathResolver-BdxCSIzn.js} +2 -2
- package/dist/{BasePathResolver-DRT09oVv.js.map → BasePathResolver-BdxCSIzn.js.map} +1 -1
- package/dist/{ClientManager-DngaZdw6.js → ClientManager-ClCwwhwo.js} +27 -22
- package/dist/ClientManager-ClCwwhwo.js.map +1 -0
- package/dist/{Item-ZUAmf943.js → Item-B9Y4VuK1.js} +75 -55
- package/dist/Item-B9Y4VuK1.js.map +1 -0
- package/dist/{ModelProperty-6llK4MTH.js → ModelProperty-BMePcicQ.js} +26 -27
- package/dist/ModelProperty-BMePcicQ.js.map +1 -0
- package/dist/{Schema-D-Ud-XYw.js → Schema-COsEXXaR.js} +30 -31
- package/dist/{Schema-D-Ud-XYw.js.map → Schema-COsEXXaR.js.map} +1 -1
- package/dist/{SchemaValidationService-IoS7JquP.js → SchemaValidationService-DabGMzSE.js} +7 -8
- package/dist/{SchemaValidationService-IoS7JquP.js.map → SchemaValidationService-DabGMzSE.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-BlVeE7w7.js → backfillMetadataPropertyIds-Ck6fumnm.js} +4 -4
- package/dist/{backfillMetadataPropertyIds-BlVeE7w7.js.map → backfillMetadataPropertyIds-Ck6fumnm.js.map} +1 -1
- package/dist/cjs/{ModelProperty-Dv7AQfmQ.js → ModelProperty-BT6Un_MB.js} +21 -21
- package/dist/cjs/{ModelProperty-Dv7AQfmQ.js.map → ModelProperty-BT6Un_MB.js.map} +1 -1
- package/dist/cjs/{Schema-BHVp1g-M.js → Schema-BXhXdUsA.js} +23 -23
- package/dist/cjs/{Schema-BHVp1g-M.js.map → Schema-BXhXdUsA.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-BSU9knjf.js → SchemaValidationService-CC18QDfc.js} +2 -2
- package/dist/cjs/{SchemaValidationService-BSU9knjf.js.map → SchemaValidationService-CC18QDfc.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-WIovQ_d8.js → backfillMetadataPropertyIds-DEHC9ejq.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-WIovQ_d8.js.map → backfillMetadataPropertyIds-DEHC9ejq.js.map} +1 -1
- package/dist/cjs/{eas-CUYXdr2t.js → eas-C3CL0l7l.js} +3 -3
- package/dist/cjs/{eas-CUYXdr2t.js.map → eas-C3CL0l7l.js.map} +1 -1
- package/dist/cjs/{getItem-z1tHu0hu.js → getItem-CrwWYCkj.js} +2 -2
- package/dist/cjs/{getItem-z1tHu0hu.js.map → getItem-CrwWYCkj.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-CEP_e-Kv.js → getPublishPayload-DRJh7WR0.js} +22 -16
- package/dist/cjs/getPublishPayload-DRJh7WR0.js.map +1 -0
- package/dist/cjs/{getPublishUploads-Ctn5k1k6.js → getPublishUploads-Bh22D3zJ.js} +4 -4
- package/dist/cjs/{getPublishUploads-Ctn5k1k6.js.map → getPublishUploads-Bh22D3zJ.js.map} +1 -1
- package/dist/cjs/{index-DfGhF1dc.js → index-BA1RIYFG.js} +3 -3
- package/dist/cjs/index-BA1RIYFG.js.map +1 -0
- package/dist/cjs/{index-Cvvt0-5B.js → index-Dls7aMjr.js} +74 -40
- package/dist/cjs/index-Dls7aMjr.js.map +1 -0
- package/dist/cjs/{property-DbEPQ1m9.js → property-ZerTWizX.js} +5 -5
- package/dist/cjs/{property-DbEPQ1m9.js.map → property-ZerTWizX.js.map} +1 -1
- package/dist/cjs/{publishDraftGraph-C38gf302.js → publishDraftGraph-CPOAcQFf.js} +4 -4
- package/dist/cjs/{publishDraftGraph-C38gf302.js.map → publishDraftGraph-CPOAcQFf.js.map} +1 -1
- package/dist/cjs/{resetAmbiguousLegacyItemData-CfMhRHwK.js → resetAmbiguousLegacyItemData-adDl4LcT.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-CfMhRHwK.js.map → resetAmbiguousLegacyItemData-adDl4LcT.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-CNYaLOir.js → resolveModelForSyncedSeed-DoNThPdL.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-CNYaLOir.js.map → resolveModelForSyncedSeed-DoNThPdL.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-d1iOdTTI.js → syncDbWithEas-CYfPkus9.js} +7 -7
- package/dist/cjs/{syncDbWithEas-d1iOdTTI.js.map → syncDbWithEas-CYfPkus9.js.map} +1 -1
- package/dist/{configurePlatform-CZpjyuCo.js → configurePlatform-xU3Hsno3.js} +4 -4
- package/dist/{configurePlatform-CZpjyuCo.js.map → configurePlatform-xU3Hsno3.js.map} +1 -1
- package/dist/{db-Lw0KVZmc.js → db-W1g29qsM.js} +30 -26
- package/dist/{db-Lw0KVZmc.js.map → db-W1g29qsM.js.map} +1 -1
- package/dist/{eas-CQ-Smzk2.js → eas-CSwV6MvB.js} +5 -5
- package/dist/{eas-CQ-Smzk2.js.map → eas-CSwV6MvB.js.map} +1 -1
- package/dist/{getItem-CSfSok9f.js → getItem-BYQeM3DY.js} +5 -6
- package/dist/{getItem-CSfSok9f.js.map → getItem-BYQeM3DY.js.map} +1 -1
- package/dist/{getPublishPayload-76_KfB5Y.js → getPublishPayload-D5CQZd-y.js} +27 -21
- package/dist/getPublishPayload-D5CQZd-y.js.map +1 -0
- package/dist/{getPublishUploads-CqgMBD8f.js → getPublishUploads-BGpDsrBp.js} +9 -10
- package/dist/{getPublishUploads-CqgMBD8f.js.map → getPublishUploads-BGpDsrBp.js.map} +1 -1
- package/dist/{index-BpgD305l.js → index-Bev-hZF-.js} +9 -10
- package/dist/index-Bev-hZF-.js.map +1 -0
- package/dist/{index-5b3JsS55.js → index-CSOQFAOn.js} +2 -2
- package/dist/index-CSOQFAOn.js.map +1 -0
- package/dist/{index-Y-yYyRBf.js → index-DRXC5Mra.js} +38 -37
- package/dist/{index-Y-yYyRBf.js.map → index-DRXC5Mra.js.map} +1 -1
- package/dist/{index.browser-DaTzn79x.js → index.browser-DO20vYuP.js} +8 -8
- package/dist/{index.browser-DaTzn79x.js.map → index.browser-DO20vYuP.js.map} +1 -1
- package/dist/{index.node-NYKqFOoe.js → index.node-C4iyOhdo.js} +5 -5
- package/dist/{index.node-NYKqFOoe.js.map → index.node-C4iyOhdo.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +28 -29
- package/dist/main.js.map +1 -1
- package/dist/node.js +14 -15
- package/dist/node.js.map +1 -1
- package/dist/platform.browser.js +5 -5
- package/dist/platform.node.js +3 -3
- package/dist/{property-ByaiSyUK.js → property-BT1zDSkd.js} +9 -10
- package/dist/property-BT1zDSkd.js.map +1 -0
- package/dist/{publishDraftGraph-BRm6Pq3Q.js → publishDraftGraph-Bcfrdj7-.js} +8 -8
- package/dist/{publishDraftGraph-BRm6Pq3Q.js.map → publishDraftGraph-Bcfrdj7-.js.map} +1 -1
- package/dist/{resetAmbiguousLegacyItemData-B4dX6ZA1.js → resetAmbiguousLegacyItemData-Ci6PM_vC.js} +2 -2
- package/dist/{resetAmbiguousLegacyItemData-B4dX6ZA1.js.map → resetAmbiguousLegacyItemData-Ci6PM_vC.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-B0tco3zG.js → resolveModelForSyncedSeed-CLlumTBq.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-B0tco3zG.js.map → resolveModelForSyncedSeed-CLlumTBq.js.map} +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/helpers/generateId.d.ts +4 -0
- package/dist/src/helpers/generateId.d.ts.map +1 -1
- package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
- package/dist/{syncDbWithEas-BPap9Sru.js → syncDbWithEas-BQsXjGhe.js} +13 -14
- package/dist/syncDbWithEas-BQsXjGhe.js.map +1 -0
- package/dist/{tabEvents-C6NXS6Jl.js → tabEvents-C9qUKx_z.js} +28 -11
- package/dist/tabEvents-C9qUKx_z.js.map +1 -0
- package/dist/{tolerantWebAccess-NBQ1NB4i.js → tolerantWebAccess-B-9bwxbw.js} +6 -6
- package/dist/{tolerantWebAccess-NBQ1NB4i.js.map → tolerantWebAccess-B-9bwxbw.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-CYwgVNlM.js → updateSeedRevokedAt-D6q0h7pj.js} +3 -3
- package/dist/{updateSeedRevokedAt-CYwgVNlM.js.map → updateSeedRevokedAt-D6q0h7pj.js.map} +1 -1
- package/package.json +10 -5
- package/dist/ClientManager-DngaZdw6.js.map +0 -1
- package/dist/Item-ZUAmf943.js.map +0 -1
- package/dist/ModelProperty-6llK4MTH.js.map +0 -1
- package/dist/cjs/getLatestVersionRow-CcaabxIW.js +0 -59
- package/dist/cjs/getLatestVersionRow-CcaabxIW.js.map +0 -1
- package/dist/cjs/getPublishPayload-CEP_e-Kv.js.map +0 -1
- package/dist/cjs/index-Cvvt0-5B.js.map +0 -1
- package/dist/cjs/index-DfGhF1dc.js.map +0 -1
- package/dist/generateId-BopUwD8F.js +0 -9
- package/dist/generateId-BopUwD8F.js.map +0 -1
- package/dist/getLatestVersionRow-72Atl9vB.js +0 -46
- package/dist/getLatestVersionRow-72Atl9vB.js.map +0 -1
- package/dist/getPublishPayload-76_KfB5Y.js.map +0 -1
- package/dist/index-5b3JsS55.js.map +0 -1
- package/dist/index-BpgD305l.js.map +0 -1
- package/dist/property-ByaiSyUK.js.map +0 -1
- package/dist/syncDbWithEas-BPap9Sru.js.map +0 -1
- package/dist/tabEvents-C6NXS6Jl.js.map +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var main_cjs = require('./index-Cvvt0-5B.js');
|
|
4
|
-
var drizzleOrm = require('drizzle-orm');
|
|
5
|
-
require('immer');
|
|
6
|
-
require('reflect-metadata');
|
|
7
|
-
require('xstate');
|
|
8
|
-
require('drizzle-orm/sqlite-core');
|
|
9
|
-
require('debug');
|
|
10
|
-
require('@seedprotocol/arweave');
|
|
11
|
-
require('@seedprotocol/eas');
|
|
12
|
-
require('pluralize');
|
|
13
|
-
require('@sinclair/typebox');
|
|
14
|
-
require('drizzle-orm/casing');
|
|
15
|
-
require('lodash-es');
|
|
16
|
-
require('nanoid');
|
|
17
|
-
require('nanoid-dictionary');
|
|
18
|
-
require('@seedprotocol/query');
|
|
19
|
-
require('rxjs');
|
|
20
|
-
require('@noble/hashes/sha3');
|
|
21
|
-
require('@noble/hashes/utils');
|
|
22
|
-
require('fs/promises');
|
|
23
|
-
require('fs');
|
|
24
|
-
require('path');
|
|
25
|
-
require('url');
|
|
26
|
-
require('node:url');
|
|
27
|
-
require('@libsql/client');
|
|
28
|
-
require('drizzle-orm/libsql');
|
|
29
|
-
require('drizzle-orm/libsql/migrator');
|
|
30
|
-
require('js-yaml');
|
|
31
|
-
require('child_process');
|
|
32
|
-
require('@seedprotocol/arweave/node');
|
|
33
|
-
require('@seedprotocol/eas/node');
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The seed's head version row: newest by (created_at DESC, local_id DESC), attested or not, skipping
|
|
37
|
-
* revoked versions. Null when the seed has no version or every version is revoked (a fully
|
|
38
|
-
* unpublished item). Same choice as `latestVersionLocalId` in the `getVersionData` subquery.
|
|
39
|
-
*/
|
|
40
|
-
async function getLatestVersionRow(seedLocalId) {
|
|
41
|
-
const appDb = main_cjs.BaseDb.getAppDb();
|
|
42
|
-
if (!appDb || !seedLocalId)
|
|
43
|
-
return null;
|
|
44
|
-
const rows = await appDb
|
|
45
|
-
.select({
|
|
46
|
-
localId: main_cjs.versions.localId,
|
|
47
|
-
uid: main_cjs.versions.uid,
|
|
48
|
-
createdAt: main_cjs.versions.createdAt,
|
|
49
|
-
attestationCreatedAt: main_cjs.versions.attestationCreatedAt,
|
|
50
|
-
})
|
|
51
|
-
.from(main_cjs.versions)
|
|
52
|
-
.where(drizzleOrm.and(drizzleOrm.eq(main_cjs.versions.seedLocalId, seedLocalId), main_cjs.versionNotRevoked()))
|
|
53
|
-
.orderBy(drizzleOrm.desc(main_cjs.versions.createdAt), drizzleOrm.desc(main_cjs.versions.localId))
|
|
54
|
-
.limit(1);
|
|
55
|
-
return rows[0] ?? null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exports.getLatestVersionRow = getLatestVersionRow;
|
|
59
|
-
//# sourceMappingURL=getLatestVersionRow-CcaabxIW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLatestVersionRow-CcaabxIW.js","sources":["../../../src/db/read/getLatestVersionRow.ts"],"sourcesContent":["import { BaseDb } from '@/db/Db/BaseDb'\nimport { versions } from '@/seedSchema'\nimport { and, desc, eq } from 'drizzle-orm'\nimport { versionNotRevoked } from '@/db/read/subqueries/liveVersion'\n\nexport type LatestVersionRow = {\n localId: string | null\n uid: string | null\n createdAt: number | null\n attestationCreatedAt: number | null\n}\n\n/**\n * The seed's head version row: newest by (created_at DESC, local_id DESC), attested or not, skipping\n * revoked versions. Null when the seed has no version or every version is revoked (a fully\n * unpublished item). Same choice as `latestVersionLocalId` in the `getVersionData` subquery.\n */\nexport async function getLatestVersionRow(seedLocalId: string): Promise<LatestVersionRow | null> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || !seedLocalId) return null\n\n const rows = await appDb\n .select({\n localId: versions.localId,\n uid: versions.uid,\n createdAt: versions.createdAt,\n attestationCreatedAt: versions.attestationCreatedAt,\n })\n .from(versions)\n .where(and(eq(versions.seedLocalId, seedLocalId), versionNotRevoked()))\n .orderBy(desc(versions.createdAt), desc(versions.localId))\n .limit(1)\n\n return rows[0] ?? null\n}\n"],"names":["BaseDb","versions","and","eq","versionNotRevoked","desc"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;;;;AAIG;AACI,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,KAAK,GAAGA,eAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;IAEvC,MAAM,IAAI,GAAG,MAAM;AAChB,SAAA,MAAM,CAAC;QACN,OAAO,EAAEC,iBAAQ,CAAC,OAAO;QACzB,GAAG,EAAEA,iBAAQ,CAAC,GAAG;QACjB,SAAS,EAAEA,iBAAQ,CAAC,SAAS;QAC7B,oBAAoB,EAAEA,iBAAQ,CAAC,oBAAoB;KACpD;SACA,IAAI,CAACA,iBAAQ;AACb,SAAA,KAAK,CAACC,cAAG,CAACC,aAAE,CAACF,iBAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,EAAEG,0BAAiB,EAAE,CAAC;AACrE,SAAA,OAAO,CAACC,eAAI,CAACJ,iBAAQ,CAAC,SAAS,CAAC,EAAEI,eAAI,CAACJ,iBAAQ,CAAC,OAAO,CAAC;SACxD,KAAK,CAAC,CAAC,CAAC;AAEX,IAAA,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;AACxB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload-CEP_e-Kv.js","sources":["../../../src/helpers/ethereumUtils.ts","../../../src/db/read/publishErrors.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","import type { ValidationError } from '@/Schema/validation'\n\n/** Validation error collected during publish payload building. */\nexport type PublishValidationError = Pick<ValidationError, 'field' | 'message'> & { code?: string }\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\n/** Validation error code for a relation, list member or image/file ref to an unpublished seed. */\nexport const RELATED_ITEM_UNPUBLISHED_CODE = 'related_item_unpublished'\n\n/** A seed a publish would reference although its seed attestation was revoked (unpublished). */\nexport type UnpublishedRelatedItem = {\n /** The referring property on the item being published (or on an item published with it). */\n propertyName: string\n /** Model of the referenced item (e.g. `Author`, `Image`). */\n modelName: string\n seedLocalId: string\n /** The revoked seed uid the reference would attest. */\n seedUid: string\n}\n\nexport const describeUnpublishedRelatedItem = (r: UnpublishedRelatedItem): string =>\n `${r.propertyName} -> ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid})`\n\n/**\n * Thrown before anything is uploaded or attested when the item references items whose seed was\n * unpublished: the parent would attest a revoked seed uid. Republish those items (which gives\n * them a new seed uid) or remove the references, then publish again.\n * See docs/ATTESTATION_REVOCATION.md (\"Republishing\").\n *\n * A PublishValidationFailedError, so validateItemForPublish and the publish package's checking\n * step report it as validation errors (code `related_item_unpublished`, one per reference).\n */\nexport class RelatedItemUnpublishedError extends PublishValidationFailedError {\n readonly unpublishedRelatedItems: UnpublishedRelatedItem[]\n\n constructor(\n unpublishedRelatedItems: UnpublishedRelatedItem[],\n otherValidationErrors: PublishValidationError[] = [],\n ) {\n const lines = unpublishedRelatedItems.map(describeUnpublishedRelatedItem)\n const message =\n `Cannot publish: it references ${lines.length} unpublished item${lines.length === 1 ? '' : 's'} ` +\n `(their seed attestations were revoked). Republish them or remove the references, then publish again:\\n` +\n lines.join('\\n')\n super(message, [\n ...unpublishedRelatedItems.map((r) => ({\n field: r.propertyName,\n message:\n `${r.propertyName} references unpublished ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid}). ` +\n `Republish it or remove the reference.`,\n code: RELATED_ITEM_UNPUBLISHED_CODE,\n })),\n ...otherValidationErrors,\n ])\n this.name = 'RelatedItemUnpublishedError'\n this.unpublishedRelatedItems = unpublishedRelatedItems\n }\n}\n","import { getItemModelScope, resolveModelRecord } from '@/db/read/resolveModelRecord'\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 { isSeedRevoked } from '@/db/read/isSeedRevoked'\nimport {\n isStorageSeedRef,\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { draftWalkProperties } from '@/db/read/publishDraftGraph'\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'\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\nimport {\n PublishValidationFailedError,\n RelatedItemUnpublishedError,\n type PublishValidationError,\n type UnpublishedRelatedItem,\n} from '@/db/read/publishErrors'\nimport {\n findRelatedSeedRow,\n htmlPropertyNameForHtmlSeed,\n isLivePublishedSeed,\n isUnpublishedSeed,\n relatedModelNameFromDef,\n type RelatedSeedRow,\n} from '@/db/read/resolveRelatedSeedRef'\n\nexport { PublishValidationFailedError, type PublishValidationError }\n\n/** Context for collecting validation errors instead of throwing on first error. */\nexport type PublishValidationContext = {\n errors: PublishValidationError[]\n /** Refs to seeds whose attestation was revoked; publish stops with RelatedItemUnpublishedError. */\n unpublishedRelatedItems?: UnpublishedRelatedItem[]\n /**\n * Relation/list/image refs (local id, or a republished seed's old uid) to seeds that are\n * published and live, mapped to their current uid: the parent attests that uid.\n */\n relatedRefUids?: Map<string, string>\n /**\n * Items getting a new seed in this publish whose payload is still being built (the root when it\n * gets a new seed, and the related drafts being walked). A ref to one of them is a cycle back\n * edge: see publishDraftGraph.ts.\n */\n newSeedsInProgress?: Set<string>\n /** Properties left out of this publish because they point back at an item in progress. */\n deferredProperties?: Set<IItemProperty<any>>\n}\n\n/** True (and the property is deferred) when `targetSeedLocalId` is an item still in progress. */\nfunction deferIfBackEdge(\n ctx: PublishValidationContext,\n property: IItemProperty<any>,\n targetSeedLocalIds: (string | undefined)[],\n): boolean {\n if (!targetSeedLocalIds.some((id) => !!id && ctx.newSeedsInProgress?.has(id))) return false\n ctx.deferredProperties ??= new Set()\n ctx.deferredProperties.add(property)\n return true\n}\n\n/**\n * Checks the seed a relation/list/image ref points at. A revoked (unpublished) seed is recorded in\n * `ctx.unpublishedRelatedItems`; a live published one maps the ref to its current uid. Returns\n * true when the caller must not walk into the related item (it is published, live or revoked).\n */\nfunction noteRelatedSeed(\n ctx: PublishValidationContext,\n ref: string,\n row: RelatedSeedRow | null,\n propertyName: string,\n modelName: string | undefined,\n): boolean {\n if (isUnpublishedSeed(row)) {\n ctx.unpublishedRelatedItems ??= []\n if (\n !ctx.unpublishedRelatedItems.some(\n (r) => r.propertyName === propertyName && r.seedLocalId === row.seedLocalId,\n )\n ) {\n ctx.unpublishedRelatedItems.push({\n propertyName,\n modelName: modelName ?? row.type ?? 'unknown',\n seedLocalId: row.seedLocalId,\n seedUid: row.seedUid,\n })\n }\n return true\n }\n if (isLivePublishedSeed(row)) {\n if (ref !== row.seedUid) {\n ctx.relatedRefUids ??= new Map()\n ctx.relatedRefUids.set(ref, row.seedUid)\n }\n return true\n }\n return false\n}\n\n/** Current uid for a ref noted by noteRelatedSeed, else the ref itself. */\nfunction currentRelatedRef(ctx: PublishValidationContext, ref: string): string {\n return ctx.relatedRefUids?.get(ref.trim()) ?? ref\n}\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 // Model names are only unique per schema: resolve definitions from this item's own model.\n const targetScope = await getItemModelScope(targetItem as any)\n for (const itemProperty of targetItem.properties) {\n if (!itemProperty.propertyDef && targetItem.modelName) {\n schema = await getPropertySchema(targetItem.modelName, itemProperty.propertyName, targetScope)\n if (!schema) {\n try {\n const { Model } = await import('@/Model/Model')\n const normalizedModelName = upperFirst(camelCase(targetItem.modelName))\n let model = Model.resolve(normalizedModelName, targetScope)\n if (!model?.properties?.length && !targetScope.modelFileId) {\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 modelRecord = await resolveModelRecord(normalizedModelName, targetScope, db)\n const modelRecords = modelRecord ? [modelRecord] : []\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 if (ctx.deferredProperties?.has(basicProperty)) {\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 // A ref to a published related item attests that item's current uid.\n if (typeof value === 'string' && (isRelation || isFileImageHtml || isJsonStorage)) {\n value = currentRelatedRef(ctx, value)\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 = currentRelatedRef(ctx, 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 const propertyScope = await getItemModelScope(relationOrImageProperty as any)\n let schema = await getPropertySchema(\n relationOrImageProperty.modelName,\n relationOrImageProperty.propertyName,\n propertyScope,\n )\n if (!schema && BaseDb.getAppDb()) {\n const normalizedModelName = upperFirst(camelCase(relationOrImageProperty.modelName))\n const modelRecord = await resolveModelRecord(normalizedModelName, propertyScope)\n const modelRecords = modelRecord ? [modelRecord] : []\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 // The local seed, also when the ref is the old uid of a seed published again since.\n const relatedSeed = await findRelatedSeedRow({ seedLocalId, seedUid })\n\n if (!isStorageSeed && deferIfBackEdge(ctx, relationOrImageProperty, [relatedSeed?.seedLocalId ?? seedLocalId])) {\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 relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid },\n )\n\n if (\n noteRelatedSeed(\n ctx,\n normalizedRef!,\n relatedSeed,\n relationOrImageProperty.propertyName,\n relatedItem?.modelName ?? relatedModelNameFromDef(relationOrImageProperty.propertyDef),\n )\n ) {\n return multiPublishPayload\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 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 return processRelatedDraftItem({\n relatedItem,\n modelName,\n // A storage seed (Image/File/Html/Json item) attests its own basic properties; a related model\n // item is published with its full property set and the draft items it reaches in turn.\n fullDraft: !isStorageSeed,\n link: { publishLocalId: originalSeedLocalId, propertySchemaUid: relationOrImageSchemaUid },\n reportPropertyName: relationOrImageProperty.propertyName,\n multiPublishPayload,\n uploadedTransactions,\n ctx,\n buildOpts,\n })\n}\n\n/**\n * The payload of a draft item (no seed uid) a published item refers to, published with it. Its\n * request fills the referring property (`link`) through propertiesToUpdate. With `fullDraft`, the\n * item's whole property set is attested: its storage seeds and Html-embedded images, and its own\n * relation and list properties, whose draft targets are published with it in turn (depth first,\n * see publishDraftGraph.ts). A draft already in the batch only gains the link.\n */\nasync function processRelatedDraftItem({\n relatedItem,\n modelName,\n fullDraft,\n link,\n reportPropertyName,\n multiPublishPayload,\n uploadedTransactions,\n ctx,\n buildOpts,\n}: {\n relatedItem: IItem<any>\n modelName: string\n fullDraft: boolean\n /** The referring property, filled with this item's new seed uid; null when nothing refers to it in this publish. */\n link: { publishLocalId: string; propertySchemaUid: string } | null\n reportPropertyName: string\n multiPublishPayload: MultiPublishPayload\n uploadedTransactions: UploadedTransaction[]\n ctx: PublishValidationContext\n buildOpts?: PublishBuildOpts\n}): Promise<MultiPublishPayload> {\n const forceFullSnapshot = buildOpts?.forceFullSnapshot === true\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n\n if (!seedSchemaUid) {\n addValidationError(ctx, `Schema UID not found for model: ${modelName}`, reportPropertyName)\n return multiPublishPayload\n }\n\n if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {\n if (link) {\n mergeChildPublishPayloadIfDuplicateInBatch(\n multiPublishPayload,\n relatedItem.seedLocalId,\n link.publishLocalId,\n link.propertySchemaUid,\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: ZERO_BYTES32,\n seedSchemaUid,\n versionUid: getVersionUid(relatedItem),\n listOfAttestations: [],\n propertiesToUpdate: link ? [{ ...link }] : [],\n }\n\n ctx.newSeedsInProgress ??= new Set()\n ctx.newSeedsInProgress.add(relatedItem.seedLocalId)\n try {\n await ensurePropertyDefs(relatedItem)\n const segmented = await getSegmentedItemProperties(relatedItem)\n const { itemBasicProperties, itemUploadProperties, itemImageProperties: relatedStorageSeedProperties } =\n segmented\n\n if (fullDraft) {\n // Its own Image/File/Html/Json properties and the images embedded in its Html (as for the item itself).\n multiPublishPayload = await processRelatedDraftStorageSeeds(\n relatedItem,\n relatedStorageSeedProperties,\n itemBasicProperties,\n multiPublishPayload,\n uploadedTransactions,\n ctx,\n buildOpts,\n )\n // Its relations and lists: their draft targets are published too (same walk as publishDraftGraph).\n const { relationProperties, listProperties } = draftWalkProperties(segmented)\n for (const relationProperty of relationProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n relatedItem.seedLocalId,\n ctx,\n buildOpts,\n )\n itemBasicProperties.push(relationProperty)\n }\n for (const listProperty of listProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n uploadedTransactions,\n relatedItem.seedLocalId,\n ctx,\n buildOpts,\n )\n itemBasicProperties.push(listProperty)\n }\n }\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', await getItemModelScope(relatedItem as any))\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 } finally {\n ctx.newSeedsInProgress.delete(relatedItem.seedLocalId)\n }\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\n/**\n * Storage-seed properties (Image/File/Html/Json) of a draft item related to the published one, and\n * the images embedded in its Html (htmlEmbeddedImageCoPublish rows it owns): payloads for their seeds,\n * and the properties added to `itemBasicProperties` so the related item attests them. Same handling\n * as the published item's own (see getPublishPayload).\n */\nasync function processRelatedDraftStorageSeeds(\n relatedItem: IItem<any>,\n storageSeedProperties: IItemProperty<any>[],\n itemBasicProperties: IItemProperty<any>[],\n multiPublishPayload: MultiPublishPayload,\n uploadedTransactions: UploadedTransaction[],\n ctx: PublishValidationContext,\n buildOpts?: PublishBuildOpts,\n): Promise<MultiPublishPayload> {\n for (const storageSeedProperty of storageSeedProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n storageSeedProperty,\n multiPublishPayload,\n uploadedTransactions,\n relatedItem.seedLocalId,\n ctx,\n buildOpts,\n )\n itemBasicProperties.push(storageSeedProperty)\n }\n return processHtmlEmbeddedCoPublishImagePayloads(\n relatedItem,\n multiPublishPayload,\n uploadedTransactions,\n ctx,\n buildOpts,\n )\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 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 // An embedded image that is already published is not co-published; one whose seed was revoked\n // (unpublished) blocks the publish like an image property pointing at it would.\n const imageSeed = await findRelatedSeedRow({ seedLocalId: row.imageSeedLocalId })\n if (\n noteRelatedSeed(\n ctx,\n row.imageSeedLocalId,\n imageSeed,\n htmlPropertyNameForHtmlSeed(item, row.htmlSeedLocalId),\n 'Image',\n )\n ) {\n continue\n }\n\n // The row's Html seed must still be the value of one of the item's Html properties.\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 // Already in the batch (e.g. also the value of an Image property): its payload is there.\n if (multiPublishPayload.some((p) => p.localId === relatedItem.seedLocalId)) {\n continue\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n // No propertiesToUpdate: the Html refers to the image by its Arweave URL (the data URI is\n // rewritten to it before the Html is uploaded), not by seed uid. The Html property holds the Html\n // storage seed's uid, which the Html seed's own request writes into it; the contract writes each\n // updater's seed uid into the same data[0] (SeedPublishLib.setSeedReference), so an image\n // targeting the Html property too would overwrite that reference with the image's seed uid.\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\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', await getItemModelScope(relatedItem as any))\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 uploadedTransactions: UploadedTransaction[],\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 const members: { idStr: string; seedLocalId?: string; seedUid?: string }[] = []\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 members.push({ idStr, seedLocalId, seedUid })\n }\n\n // A member that is an item still in progress (a cycle back to it) can't be attested in this\n // publish, so the list is deferred; its other draft members are still published, unlinked.\n const memberSeeds = await Promise.all(\n members.map((m) => findRelatedSeedRow({ seedLocalId: m.seedLocalId, seedUid: m.seedUid })),\n )\n const deferred = deferIfBackEdge(\n ctx,\n listProperty,\n members.map((m, i) => memberSeeds[i]?.seedLocalId ?? m.seedLocalId),\n )\n\n for (let i = 0; i < members.length; i++) {\n const { idStr, seedLocalId, seedUid } = members[i]!\n const relatedSeed = memberSeeds[i] ?? null\n const memberLocalId = relatedSeed?.seedLocalId ?? seedLocalId\n if (memberLocalId && ctx.newSeedsInProgress?.has(memberLocalId)) 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 relatedSeed ? { seedLocalId: relatedSeed.seedLocalId } : { seedLocalId, seedUid },\n )\n\n if (\n noteRelatedSeed(\n ctx,\n idStr.trim(),\n relatedSeed,\n listProperty.propertyName,\n relatedItem?.modelName ?? relatedModelNameFromDef(listProperty.propertyDef),\n )\n ) {\n continue\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 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 multiPublishPayload = await processRelatedDraftItem({\n relatedItem,\n modelName,\n fullDraft: true,\n link: deferred ? null : { publishLocalId: originalSeedLocalId, propertySchemaUid: listPropertySchemaUid },\n reportPropertyName: listProperty.propertyName,\n multiPublishPayload,\n uploadedTransactions,\n ctx,\n buildOpts,\n })\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\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 // A revoked seed can't be published under again: republishing creates a new seed attestation\n // (new seedUid) and a new version carrying every property (see docs/ATTESTATION_REVOCATION.md).\n const hasSeedUid = !!item.seedUid && item.seedUid !== ZERO_BYTES32\n const republishRevokedSeed = hasSeedUid && (await isSeedRevoked(item.seedLocalId))\n const rootSeedUid = republishRevokedSeed ? ZERO_BYTES32 : item.seedUid || ZERO_BYTES32\n const forceFullSnapshot = publishMode === 'new_version' || republishRevokedSeed\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 // The root gets a new seed (draft, or revoked seed published again): related drafts referring\n // back to it can't attest its uid in this publish (see publishDraftGraph.ts).\n if (rootSeedUid === ZERO_BYTES32) {\n validationCtx.newSeedsInProgress = new Set([item.seedLocalId])\n }\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 && rootSeedUid !== ZERO_BYTES32) {\n versionUid = await resolveVersionUid(item.seedLocalId, rootSeedUid)\n }\n if (forceFullSnapshot && hasSeedUid) {\n versionUid = ZERO_BYTES32\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: rootSeedUid,\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 modelRecord = await resolveModelRecord(normalizedModelName, await getItemModelScope(item as any))\n const modelRows = modelRecord ? [modelRecord] : []\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 validationCtx,\n { forceFullSnapshot },\n )\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n uploadedTransactions,\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', await getItemModelScope(item as any))\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 // Stop before anything is uploaded or attested: the payload would attest revoked seed uids.\n if (validationCtx.unpublishedRelatedItems?.length) {\n throw new RelatedItemUnpublishedError(validationCtx.unpublishedRelatedItems, validationCtx.errors)\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","isUnpublishedSeed","isLivePublishedSeed","isValidEasAttestationUid","ZERO_BYTES32","getLatestPublishedVersionRow","INTERNAL_DATA_TYPES","listRelationEasPropertyName","toSnakeCase","getEasSchemaUidForSchemaDefinition","ModelPropertyDataTypes","getItemModelScope","getPropertySchema","upperFirst","camelCase","toSnakeCaseDb","modelPropertiesToObject","BaseDb","resolveModelRecord","properties","and","eq","models","INTERNAL_PROPERTY_NAMES","isStorageSeedRef","SchemaEncoder","defaultAttestationData","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","findRelatedSeedRow","relatedModelNameFromDef","isPublishedSeedRef","getEasSchemaUidForModel","VERSION_SCHEMA_UID","getSegmentedItemProperties","draftWalkProperties","htmlEmbeddedImageCoPublish","htmlPropertyNameForHtmlSeed","parseListPropertyValueFromStorage","getCorrectId","isSeedRevoked","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,MAA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