@seedprotocol/sdk 0.4.9 → 0.4.11
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/{ArweaveClient-sN5h2FvY.js → ArweaveClient-CwXE3NCK.js} +3 -3
- package/dist/{ArweaveClient-sN5h2FvY.js.map → ArweaveClient-CwXE3NCK.js.map} +1 -1
- package/dist/{ArweaveClient-DFqnm5Kj.js → ArweaveClient-DyhvHiIT.js} +3 -3
- package/dist/{ArweaveClient-DFqnm5Kj.js.map → ArweaveClient-DyhvHiIT.js.map} +1 -1
- package/dist/{Db-DIythELU.js → Db-Dr6gWq8d.js} +3 -3
- package/dist/{Db-DIythELU.js.map → Db-Dr6gWq8d.js.map} +1 -1
- package/dist/{Db-Dz17KxVs.js → Db-mH9nSDfI.js} +3 -3
- package/dist/{Db-Dz17KxVs.js.map → Db-mH9nSDfI.js.map} +1 -1
- package/dist/{EasClient-BadfcFDk.js → EasClient-Yh-t7zEA.js} +2 -2
- package/dist/{EasClient-DosbWaZN.js.map → EasClient-Yh-t7zEA.js.map} +1 -1
- package/dist/{EasClient-DosbWaZN.js → EasClient-aggdMFrc.js} +2 -2
- package/dist/{EasClient-BadfcFDk.js.map → EasClient-aggdMFrc.js.map} +1 -1
- package/dist/{FileManager-Wthr5yHO.js → FileManager-ClU_rIR0.js} +2 -2
- package/dist/{FileManager-Wthr5yHO.js.map → FileManager-ClU_rIR0.js.map} +1 -1
- package/dist/{FileManager-BHuVNWT3.js → FileManager-Dl2DD4Uc.js} +2 -2
- package/dist/{FileManager-BHuVNWT3.js.map → FileManager-Dl2DD4Uc.js.map} +1 -1
- package/dist/{ModelProperty-B9Z2DRxI.js → ModelProperty-gBmew8gY.js} +94 -18
- package/dist/ModelProperty-gBmew8gY.js.map +1 -0
- package/dist/{PathResolver-NEpTSgQK.js → PathResolver-CILJPhz1.js} +2 -2
- package/dist/{PathResolver-NEpTSgQK.js.map → PathResolver-CILJPhz1.js.map} +1 -1
- package/dist/{PathResolver-Cd1PZDLG.js → PathResolver-CfA_D3wa.js} +2 -2
- package/dist/{PathResolver-Cd1PZDLG.js.map → PathResolver-CfA_D3wa.js.map} +1 -1
- package/dist/{QueryClient-C9U8oZUe.js → QueryClient-BdpWYoxo.js} +2 -2
- package/dist/{QueryClient-C9U8oZUe.js.map → QueryClient-BdpWYoxo.js.map} +1 -1
- package/dist/{QueryClient-ndmA8MYL.js → QueryClient-Dl_P8u5s.js} +2 -2
- package/dist/{QueryClient-ndmA8MYL.js.map → QueryClient-Dl_P8u5s.js.map} +1 -1
- package/dist/{Schema-D1-HjT8z.js → Schema-B-vCLIuU.js} +21 -21
- package/dist/{Schema-D1-HjT8z.js.map → Schema-B-vCLIuU.js.map} +1 -1
- package/dist/{SchemaValidationService-CIXKzSpb.js → SchemaValidationService-C_iTQIjR.js} +2 -2
- package/dist/{SchemaValidationService-CIXKzSpb.js.map → SchemaValidationService-C_iTQIjR.js.map} +1 -1
- package/dist/cjs/{ModelProperty-09hNvSBl.js → ModelProperty-DcAM5M8T.js} +94 -18
- package/dist/cjs/ModelProperty-DcAM5M8T.js.map +1 -0
- package/dist/cjs/{Schema-BcwvUABB.js → Schema-B6ifYEhD.js} +20 -20
- package/dist/cjs/{Schema-BcwvUABB.js.map → Schema-B6ifYEhD.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-zty4nfCu.js → SchemaValidationService-OFyzZIUX.js} +2 -2
- package/dist/cjs/{SchemaValidationService-zty4nfCu.js.map → SchemaValidationService-OFyzZIUX.js.map} +1 -1
- package/dist/cjs/{getItem-Dlb5YSQn.js → getItem-CAYQYTpg.js} +2 -2
- package/dist/cjs/{getItem-Dlb5YSQn.js.map → getItem-CAYQYTpg.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-BqL06sEI.js → getPublishPayload-CBuGIazw.js} +5 -5
- package/dist/cjs/{getPublishPayload-BqL06sEI.js.map → getPublishPayload-CBuGIazw.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-oukGI2N6.js → getPublishUploads-B7bB1OGg.js} +3 -3
- package/dist/cjs/{getPublishUploads-oukGI2N6.js.map → getPublishUploads-B7bB1OGg.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js → getSegmentedItemProperties-MVZ-0mQG.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-JT984OOp.js.map → getSegmentedItemProperties-MVZ-0mQG.js.map} +1 -1
- package/dist/cjs/{index-jubgGeM2.js → index-6P4MEsbO.js} +2 -2
- package/dist/cjs/index-6P4MEsbO.js.map +1 -0
- package/dist/cjs/{index-BLETlVgA.js → index-CA4i5TA7.js} +105 -46
- package/dist/cjs/index-CA4i5TA7.js.map +1 -0
- package/dist/cjs/{ownership-vfvyz3KJ.js → ownership-5TQ-v2CF.js} +2 -2
- package/dist/cjs/{ownership-vfvyz3KJ.js.map → ownership-5TQ-v2CF.js.map} +1 -1
- package/dist/{getItem-f9rNUz7I.js → getItem-xpxRXqHI.js} +2 -2
- package/dist/{getItem-f9rNUz7I.js.map → getItem-xpxRXqHI.js.map} +1 -1
- package/dist/{getPublishPayload-BBI_j9I2.js → getPublishPayload-CBeCMSeQ.js} +5 -5
- package/dist/{getPublishPayload-BBI_j9I2.js.map → getPublishPayload-CBeCMSeQ.js.map} +1 -1
- package/dist/{getPublishUploads-BFM94w5S.js → getPublishUploads-NITxWWDD.js} +3 -3
- package/dist/{getPublishUploads-BFM94w5S.js.map → getPublishUploads-NITxWWDD.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-Di9vevKz.js → getSegmentedItemProperties-CYzNtJxH.js} +2 -2
- package/dist/{getSegmentedItemProperties-Di9vevKz.js.map → getSegmentedItemProperties-CYzNtJxH.js.map} +1 -1
- package/dist/{index-CSAVWKeA.js → index-BC0xKxkf.js} +3 -3
- package/dist/index-BC0xKxkf.js.map +1 -0
- package/dist/{index-j8WN8W6V.js → index-B_apqB1Q.js} +120 -61
- package/dist/index-B_apqB1Q.js.map +1 -0
- package/dist/{index-ajj6SHkh.js → index-CcXvJ2H7.js} +2 -2
- package/dist/index-CcXvJ2H7.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +11 -11
- package/dist/node.js +10 -10
- package/dist/{ownership-DLNI17NE.js → ownership-C7Afj3yr.js} +2 -2
- package/dist/{ownership-DLNI17NE.js.map → ownership-C7Afj3yr.js.map} +1 -1
- package/dist/{property-C6qoOzLG.js → property-C2gviIFJ.js} +4 -4
- package/dist/{property-C6qoOzLG.js.map → property-C2gviIFJ.js.map} +1 -1
- package/dist/{queries-jMaUn86w.js → queries-BFzkFn4Y.js} +2 -2
- package/dist/{queries-jMaUn86w.js.map → queries-BFzkFn4Y.js.map} +1 -1
- package/dist/src/ModelProperty/ModelProperty.d.ts +5 -0
- package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts.map +1 -1
- package/dist/src/helpers/db.d.ts.map +1 -1
- package/dist/src/services/write/actors/writeToDatabase.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/ModelProperty-B9Z2DRxI.js.map +0 -1
- package/dist/cjs/ModelProperty-09hNvSBl.js.map +0 -1
- package/dist/cjs/index-BLETlVgA.js.map +0 -1
- package/dist/cjs/index-jubgGeM2.js.map +0 -1
- package/dist/index-CSAVWKeA.js.map +0 -1
- package/dist/index-ajj6SHkh.js.map +0 -1
- package/dist/index-j8WN8W6V.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var main_cjs = require('./index-
|
|
3
|
+
var main_cjs = require('./index-CA4i5TA7.js');
|
|
4
4
|
var drizzleOrm = require('drizzle-orm');
|
|
5
5
|
require('immer');
|
|
6
6
|
require('reflect-metadata');
|
|
@@ -100,4 +100,4 @@ async function assertItemOwned(item) {
|
|
|
100
100
|
|
|
101
101
|
exports.assertItemOwned = assertItemOwned;
|
|
102
102
|
exports.isItemOwned = isItemOwned;
|
|
103
|
-
//# sourceMappingURL=ownership-
|
|
103
|
+
//# sourceMappingURL=ownership-5TQ-v2CF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership-
|
|
1
|
+
{"version":3,"file":"ownership-5TQ-v2CF.js","sources":["../../../src/helpers/ownership.ts"],"sourcesContent":["import type { IItem } from '@/interfaces/IItem'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq, or } from 'drizzle-orm'\nimport { getOwnedAddressesFromDb } from '@/helpers/db'\n\nconst READ_ONLY_ERROR = 'Item is read-only: you do not own this item'\n\ntype ItemLike = { seedLocalId?: string; seedUid?: string }\n\ntype SeedRow = { publisher: string | null; attestationRaw: string | null; uid: string | null }\n\nasync function getSeedRowForItem(item: ItemLike): Promise<SeedRow | null> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n\n const conditions = []\n if (item.seedLocalId) conditions.push(eq(seeds.localId, item.seedLocalId))\n if (item.seedUid) conditions.push(eq(seeds.uid, item.seedUid))\n if (conditions.length === 0) return null\n\n const seedRows = await appDb\n .select({\n publisher: seeds.publisher,\n attestationRaw: seeds.attestationRaw,\n uid: seeds.uid,\n })\n .from(seeds)\n .where(conditions.length === 1 ? conditions[0] : (or(...conditions) as any))\n .limit(1)\n\n if (!seedRows || seedRows.length === 0) return null\n return seedRows[0]\n}\n\nfunction getPublisherFromRow(row: SeedRow): string | null {\n if (row.publisher) return row.publisher\n if (row.attestationRaw) {\n try {\n const parsed = JSON.parse(row.attestationRaw) as { attester?: string }\n return parsed.attester ?? null\n } catch {\n return null\n }\n }\n return null\n}\n\n/**\n * Checks if the current user owns the item (publisher is in owned addresses).\n * Locally created items (no publisher, no attestationRaw) are considered owned.\n */\nexport async function isItemOwned(item: ItemLike | IItem<any>): Promise<boolean> {\n const row = await getSeedRowForItem(item)\n if (!row) return false\n\n const publisher = getPublisherFromRow(row)\n if (!publisher) {\n if (!row.uid && !row.attestationRaw) {\n return true\n }\n return false\n }\n\n const ownedAddresses = await getOwnedAddressesFromDb()\n return ownedAddresses.includes(publisher)\n}\n\n/**\n * Throws if the item is not owned. Use before write operations (publish, save, destroy).\n */\nexport async function assertItemOwned(item: ItemLike | IItem<any>): Promise<void> {\n const owned = await isItemOwned(item)\n if (!owned) {\n throw new Error(READ_ONLY_ERROR)\n }\n}\n"],"names":["BaseDb","eq","seeds","or","getOwnedAddressesFromDb"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,eAAe,GAAG,6CAA6C;AAMrE,eAAe,iBAAiB,CAAC,IAAc,EAAA;AAC7C,IAAA,MAAM,KAAK,GAAGA,eAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;IAEvB,MAAM,UAAU,GAAG,EAAE;IACrB,IAAI,IAAI,CAAC,WAAW;AAAE,QAAA,UAAU,CAAC,IAAI,CAACC,aAAE,CAACC,cAAK,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1E,IAAI,IAAI,CAAC,OAAO;AAAE,QAAA,UAAU,CAAC,IAAI,CAACD,aAAE,CAACC,cAAK,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9D,IAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;IAExC,MAAM,QAAQ,GAAG,MAAM;AACpB,SAAA,MAAM,CAAC;QACN,SAAS,EAAEA,cAAK,CAAC,SAAS;QAC1B,cAAc,EAAEA,cAAK,CAAC,cAAc;QACpC,GAAG,EAAEA,cAAK,CAAC,GAAG;KACf;SACA,IAAI,CAACA,cAAK;SACV,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,GAAG,UAAU,CAAC,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QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;IAClC;AACF;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as getItemData, x as Item } from './index-
|
|
1
|
+
import { w as getItemData, x as Item } from './index-B_apqB1Q.js';
|
|
2
2
|
import { startCase } from 'lodash-es';
|
|
3
3
|
import 'xstate';
|
|
4
4
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -35,4 +35,4 @@ const getItem = async ({ modelName, seedLocalId, seedUid }) => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
export { getItem };
|
|
38
|
-
//# sourceMappingURL=getItem-
|
|
38
|
+
//# sourceMappingURL=getItem-xpxRXqHI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getItem-
|
|
1
|
+
{"version":3,"file":"getItem-xpxRXqHI.js","sources":["../../src/db/read/getItem.ts"],"sourcesContent":["import { getItemData } from './getItemData'\nimport { GetItem } from '@/types'\nimport { Item } from '@/Item/Item'\nimport { startCase } from 'lodash-es'\n\nexport const getItem: GetItem = async ({ modelName, seedLocalId, seedUid }) => {\n const itemInitObj = await getItemData({\n modelName,\n seedLocalId,\n seedUid,\n })\n\n if (!itemInitObj) {\n console.error(\n `[db/queries] [getItem] no itemInitObj modelName: ${modelName} seedLocalId: ${seedLocalId} seedUid: ${seedUid}`,\n )\n return\n }\n\n if (!itemInitObj.seedLocalId) {\n console.error(\n `[db/queries] [getItem] no itemInitObj.seedLocalId modelName: ${modelName} seedLocalId: ${seedLocalId} seedUid: ${seedUid}`,\n )\n return\n }\n\n if (!itemInitObj.modelName && itemInitObj.type) {\n itemInitObj.modelName = startCase(itemInitObj.type)\n }\n\n return Item.create(itemInitObj)\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKO,MAAM,OAAO,GAAY,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,KAAI;AAC5E,IAAA,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC;QACpC,SAAS;QACT,WAAW;QACX,OAAO;AACR,KAAA,CAAC;IAEF,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,CAAC,KAAK,CACX,CAAA,iDAAA,EAAoD,SAAS,CAAA,cAAA,EAAiB,WAAW,CAAA,UAAA,EAAa,OAAO,CAAA,CAAE,CAChH;QACD;IACF;AAEA,IAAA,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;QAC5B,OAAO,CAAC,KAAK,CACX,CAAA,6DAAA,EAAgE,SAAS,CAAA,cAAA,EAAiB,WAAW,CAAA,UAAA,EAAa,OAAO,CAAA,CAAE,CAC5H;QACD;IACF;IAEA,IAAI,CAAC,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,EAAE;QAC9C,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;IACrD;AAEA,IAAA,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AACjC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { k as getEasSchemaUidForModel, Z as ZERO_BYTES32, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, l as getCorrectId, a as ModelPropertyDataTypes, t as toSnakeCase, m as defaultAttestationData, o as INTERNAL_DATA_TYPES, p as getEasSchemaUidForSchemaDefinition, q as getEasSchemaForItemProperty } from './index-
|
|
1
|
+
import { k as getEasSchemaUidForModel, Z as ZERO_BYTES32, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, l as getCorrectId, a as ModelPropertyDataTypes, t as toSnakeCase, m as defaultAttestationData, o as INTERNAL_DATA_TYPES, p as getEasSchemaUidForSchemaDefinition, q as getEasSchemaForItemProperty } from './index-B_apqB1Q.js';
|
|
2
2
|
import pluralize from 'pluralize';
|
|
3
|
-
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-
|
|
3
|
+
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-CYzNtJxH.js';
|
|
4
4
|
import debug from 'debug';
|
|
5
5
|
import { ethers } from 'ethers';
|
|
6
6
|
import 'reflect-metadata';
|
|
@@ -155,7 +155,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
155
155
|
return multiPublishPayload;
|
|
156
156
|
}
|
|
157
157
|
// Use dynamic import to break circular dependency
|
|
158
|
-
const getItemMod = await import('./getItem-
|
|
158
|
+
const getItemMod = await import('./getItem-xpxRXqHI.js');
|
|
159
159
|
const { getItem } = getItemMod;
|
|
160
160
|
const relatedItem = await getItem({
|
|
161
161
|
seedLocalId,
|
|
@@ -258,7 +258,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
258
258
|
for (const seedId of value) {
|
|
259
259
|
const { localId: seedLocalId, uid: seedUid } = getCorrectId(seedId);
|
|
260
260
|
// Use dynamic import to break circular dependency
|
|
261
|
-
const getItemMod = await import('./getItem-
|
|
261
|
+
const getItemMod = await import('./getItem-xpxRXqHI.js');
|
|
262
262
|
const { getItem } = getItemMod;
|
|
263
263
|
const relatedItem = await getItem({
|
|
264
264
|
seedLocalId,
|
|
@@ -500,4 +500,4 @@ const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
|
|
|
500
500
|
};
|
|
501
501
|
|
|
502
502
|
export { getPublishPayload, resolvePublishPayloadValues };
|
|
503
|
-
//# sourceMappingURL=getPublishPayload-
|
|
503
|
+
//# sourceMappingURL=getPublishPayload-CBeCMSeQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload-BBI_j9I2.js","sources":["../../src/db/read/getPublishPayload.ts"],"sourcesContent":["// Dynamic import to break circular dependency with getItem -> BaseItem\n// import { getItem } from '@/db/read/getItem'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport {\n AttestationRequest,\n AttestationRequestData,\n} from '@ethereum-attestation-service/eas-sdk'\n\nimport { getEasSchemaForItemProperty } from '@/helpers/getSchemaForItemProperty'\nimport { toSnakeCase } from '@/helpers'\nimport pluralize from 'pluralize'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { getEasSchemaUidForSchemaDefinition } from '@/stores/eas'\nimport { getCorrectId } from '@/helpers'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { IItemProperty } from '@/interfaces'\nimport { IItem } from '@/interfaces'\nimport { Item } from '@/Item/Item'\nimport debug from 'debug'\nimport {ethers} from 'ethers'\nimport { ModelPropertyDataTypes } from '@/Schema'\nconst logger = debug('seedSdk:db:getPublishPayload')\n\nconst getVersionUid = (item: IItem<any>): string => {\n const latestVersion = item.latestVersionUid\n if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {\n return latestVersion.uid\n }\n if (latestVersion && typeof latestVersion === 'string') {\n return latestVersion\n }\n return ZERO_BYTES32\n}\n\nconst getPropertyData = async (itemProperty: IItemProperty<any>) => {\n const easDataType =\n INTERNAL_DATA_TYPES[itemProperty.propertyDef!.dataType].eas\n\n let schemaUid: string | undefined = itemProperty.schemaUid\n\n const propertyNameForSchema = toSnakeCase(itemProperty.propertyName)\n\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n if (!schemaUid) {\n const schema = await getEasSchemaForItemProperty({\n propertyName: 'version',\n easDataType: 'bytes32',\n })\n if (schema) {\n schemaUid = schema.id\n }\n }\n }\n\n return {\n schemaUid,\n easDataType,\n schemaDef,\n propertyNameForSchema,\n }\n}\n\n// Lazy import SchemaEncoder to avoid module resolution issues with ts-import\nlet SchemaEncoderClass: typeof import('@ethereum-attestation-service/eas-sdk').SchemaEncoder | null = null\nconst getSchemaEncoder = async () => {\n if (!SchemaEncoderClass) {\n const easSdk = await import('@ethereum-attestation-service/eas-sdk')\n SchemaEncoderClass = easSdk.SchemaEncoder\n }\n return SchemaEncoderClass\n}\n\nconst processBasicProperties = async (\n itemBasicProperties: IItemProperty<any>[],\n itemPublishData: PublishPayload,\n): Promise<PublishPayload> => {\n for (const basicProperty of itemBasicProperties) {\n const snapshot = basicProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n let value = (context as any).propertyValue\n\n if (!value || basicProperty.uid) {\n continue\n }\n\n const { schemaUid, easDataType, schemaDef } =\n await getPropertyData(basicProperty)\n\n const propertyNameForSchema = toSnakeCase(basicProperty.propertyName)\n\n if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {\n throw new Error(`Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`)\n }\n\n if (schemaDef.startsWith('bytes32[]')) {\n const newValues = []\n for (const seedId of value) {\n if (seedId.length !== 66 && !seedId.startsWith('0x')) {\n newValues.push(ethers.encodeBytes32String(seedId))\n continue\n }\n newValues.push(seedId)\n }\n value = newValues\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 const SchemaEncoder = await getSchemaEncoder()\n const dataEncoder = new SchemaEncoder(schemaDef)\n\n const encodedData = dataEncoder.encodeData(data)\n\n // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)\n const refUid =\n basicProperty.propertyName === 'storageTransactionId'\n ? itemPublishData.versionUid\n : defaultAttestationData.refUID\n\n const attestationEntry: Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n } = {\n schema: schemaUid!,\n data: [\n {\n ...defaultAttestationData,\n refUID: refUid,\n data: encodedData,\n } as AttestationRequestData,\n ],\n }\n\n // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues\n if (\n typeof value === 'string' &&\n value.length === 10 &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._schemaDef = schemaDef\n attestationEntry._unresolvedValue = value\n attestationEntry._easDataType = easDataType\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): Promise<MultiPublishPayload> => {\n let relationOrImageSchemaUid = relationOrImageProperty.schemaUid\n if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {\n const propertyData = await getPropertyData(relationOrImageProperty)\n relationOrImageSchemaUid = propertyData.schemaUid\n }\n if (!relationOrImageSchemaUid) {\n throw new Error(\n `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n )\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 const value = (context as any).propertyValue\n if (!value || relationOrImageProperty.uid) {\n return multiPublishPayload\n }\n\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(value)\n\n // Value is not a valid seed reference (10-char localId or 66-char uid); skip (e.g. Html with inline content)\n if (!seedLocalId && !seedUid) {\n return multiPublishPayload\n }\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No related item found for relation or image property: ${relationOrImageProperty.propertyName}`,\n )\n }\n\n // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent\n if (relatedItem.seedUid) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (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 throw new Error(`Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`)\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n throw new Error(`Schema UID not found for model: ${modelName}`)\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: relationOrImageSchemaUid,\n },\n ],\n }\n\n const { itemBasicProperties, itemUploadProperties } =\n getSegmentedItemProperties(relatedItem)\n\n if (itemUploadProperties.length === 1) {\n const uploadProperty = itemUploadProperties[0]\n const itemProperty = uploadProperty.itemProperty\n const transactionData = uploadedTransactions.find(\n (transaction) => transaction.seedLocalId === relatedItem.seedLocalId,\n )\n if (transactionData) {\n itemProperty.value = transactionData.txId\n await itemProperty.save()\n itemBasicProperties.push(itemProperty)\n }\n }\n\n publishPayload = await processBasicProperties(\n itemBasicProperties,\n publishPayload,\n )\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\nconst processListProperty = async (\n listProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n originalSeedLocalId: string,\n): Promise<MultiPublishPayload> => {\n // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties\n if (!listProperty.propertyDef?.ref) {\n throw new Error(\n `processListProperty requires ref (list of relations). List property \"${listProperty.propertyName}\" has no ref. List-of-primitives should be in itemBasicProperties.`,\n )\n }\n let listPropertySchemaUid = listProperty.schemaUid\n if (!listPropertySchemaUid && listProperty.propertyDef) {\n const propertyData = await getPropertyData(listProperty)\n listPropertySchemaUid = propertyData.schemaUid\n }\n if (!listPropertySchemaUid) {\n throw new Error(\n `Schema uid not found for list property: ${listProperty.propertyName}`,\n )\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 || listProperty.uid) {\n return multiPublishPayload\n }\n\n const singularPropertyName = pluralize.singular(listProperty.propertyName)\n const propertyNameForSchema = `${singularPropertyName}${listProperty.propertyDef!.ref}Ids`\n if (typeof value === 'string' && value.length === 66) {\n value = [value]\n }\n if (typeof value === 'string' && value.length > 66) {\n try {\n value = JSON.parse(value)\n } catch (error) {\n value = value.split(',')\n }\n }\n\n for (const seedId of value) {\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(seedId)\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n console.error(\n `No related item found for list property: ${listProperty.propertyName}`,\n )\n continue\n }\n\n if (relatedItem.seedUid) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (listProperty.propertyDef?.ref || (listProperty.propertyDef as { refModelName?: string }).refModelName) {\n const def = listProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (!modelName) {\n throw new Error(`Model name not found for list property: ${listProperty.propertyName}`)\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n throw new Error(`Schema UID not found for model: ${modelName}`)\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: listPropertySchemaUid,\n },\n ],\n }\n\n const { itemBasicProperties } = getSegmentedItemProperties(relatedItem)\n\n publishPayload = await processBasicProperties(\n itemBasicProperties,\n publishPayload,\n )\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\ntype PublishPayload = {\n localId: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: (Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _schemaDef?: string\n _unresolvedValue?: string\n })[]\n propertiesToUpdate: any[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\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\nexport const getPublishPayload = async (\n item: Item<any>,\n uploadedTransactions: UploadedTransaction[],\n): Promise<MultiPublishPayload> => {\n\n let multiPublishPayload: MultiPublishPayload = []\n\n // Each PublishPayload is generated from a Seed that needs publishing\n\n // First we need to determine all Seeds to publish\n\n // That means the Seed of the Item, plus any Seeds pointed to by Relations\n\n // Check if the item has a schema UID\n let itemSchemaUid = item.schemaUid\n if (!itemSchemaUid) {\n const schemaUid = await getEasSchemaUidForModel(item.modelName)\n if (!schemaUid) {\n throw new Error(`Schema UID not found for model: ${item.modelName}`)\n }\n itemSchemaUid = schemaUid\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: item.seedUid || ZERO_BYTES32,\n seedIsRevocable: true,\n seedSchemaUid: itemSchemaUid,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n versionUid: getVersionUid(item),\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n const {\n itemBasicProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n itemRelationProperties,\n } = getSegmentedItemProperties(item)\n\n const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties]\n\n if (itemUploadProperties.length === 1) {\n const uploadProperty = itemUploadProperties[0]\n const itemProperty = uploadProperty.itemProperty\n const transactionData = uploadedTransactions.find(\n (transaction) => transaction.seedLocalId === item.seedLocalId,\n )\n if (transactionData) {\n itemProperty.value = transactionData.txId\n await itemProperty.save()\n itemBasicProperties.push(itemProperty)\n }\n }\n\n for (const relationProperty of relationAndImageProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n )\n itemBasicProperties.push(relationProperty)\n }\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n item.seedLocalId,\n )\n itemBasicProperties.push(listProperty)\n }\n \n itemPublishData = await processBasicProperties(\n itemBasicProperties,\n itemPublishData,\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 = 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\n return multiPublishPayload\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 * Topological sort: when request A has propertiesToUpdate with publishLocalId B,\n * A (the updater) must appear before B (the updatee). The contract injects A's seedUid\n * into B's attestation before B is sent to EAS; if B is processed first, B's attestation\n * goes out with wrong data (string instead of bytes32).\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n const byLocalId = new Map<string, PublishPayload>()\n for (const p of payload) {\n byLocalId.set(p.localId, p)\n }\n const visited = new Set<string>()\n const result: PublishPayload[] = []\n\n const visit = (localId: string) => {\n if (visited.has(localId)) return\n visited.add(localId)\n const p = byLocalId.get(localId)\n if (!p) return\n result.push(p)\n for (const u of p.propertiesToUpdate ?? []) {\n const targetId = (u as { publishLocalId?: string }).publishLocalId\n if (targetId && targetId !== localId) visit(targetId)\n }\n }\n\n for (const p of payload) {\n visit(p.localId)\n }\n return result\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 SchemaEncoder = await getSchemaEncoder()\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 data?: AttestationRequestData[] | AttestationRequestData\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n if (resolvedUid && entry._schemaDef && entry._propertyName) {\n const propertyNameForSchema = toSnakeCase(entry._propertyName)\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: propertyNameForSchema,\n type: (entry._easDataType as 'bytes32' | 'string') || 'bytes32',\n value: resolvedUid,\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":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAyBe,KAAK,CAAC,8BAA8B;AAEnD,MAAM,aAAa,GAAG,CAAC,IAAgB,KAAY;AACjD,IAAA,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB;IAC3C,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,EAAE;QAC3E,OAAO,aAAa,CAAC,GAAG;IAC1B;AACA,IAAA,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;AACtD,QAAA,OAAO,aAAa;IACtB;AACA,IAAA,OAAO,YAAY;AACrB,CAAC;AAED,MAAM,eAAe,GAAG,OAAO,YAAgC,KAAI;AACjE,IAAA,MAAM,WAAW,GACf,mBAAmB,CAAC,YAAY,CAAC,WAAY,CAAC,QAAQ,CAAC,CAAC,GAAG;AAE7D,IAAA,IAAI,SAAS,GAAuB,YAAY,CAAC,SAAS;IAE1D,MAAM,qBAAqB,GAAG,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC;AAEpE,IAAA,MAAM,SAAS,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,qBAAqB,EAAE;IAE3D,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,MAAM,kCAAkC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QAC/E,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,MAAM,MAAM,GAAG,MAAM,2BAA2B,CAAC;AAC/C,gBAAA,YAAY,EAAE,SAAS;AACvB,gBAAA,WAAW,EAAE,SAAS;AACvB,aAAA,CAAC;YACF,IAAI,MAAM,EAAE;AACV,gBAAA,SAAS,GAAG,MAAM,CAAC,EAAE;Y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AC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAA8B,CAAC;iBACtF;AACD,gBAAA,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC3C;QACF;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,GAAG,OAAO;AACV,YAAA,kBAAkB,EAAE,mBAAmB;AACxC,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"getPublishPayload-CBeCMSeQ.js","sources":["../../src/db/read/getPublishPayload.ts"],"sourcesContent":["// Dynamic import to break circular dependency with getItem -> BaseItem\n// import { getItem } from '@/db/read/getItem'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport {\n AttestationRequest,\n AttestationRequestData,\n} from '@ethereum-attestation-service/eas-sdk'\n\nimport { getEasSchemaForItemProperty } from '@/helpers/getSchemaForItemProperty'\nimport { toSnakeCase } from '@/helpers'\nimport pluralize from 'pluralize'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { getEasSchemaUidForSchemaDefinition } from '@/stores/eas'\nimport { getCorrectId } from '@/helpers'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport { IItemProperty } from '@/interfaces'\nimport { IItem } from '@/interfaces'\nimport { Item } from '@/Item/Item'\nimport debug from 'debug'\nimport {ethers} from 'ethers'\nimport { ModelPropertyDataTypes } from '@/Schema'\nconst logger = debug('seedSdk:db:getPublishPayload')\n\nconst getVersionUid = (item: IItem<any>): string => {\n const latestVersion = item.latestVersionUid\n if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {\n return latestVersion.uid\n }\n if (latestVersion && typeof latestVersion === 'string') {\n return latestVersion\n }\n return ZERO_BYTES32\n}\n\nconst getPropertyData = async (itemProperty: IItemProperty<any>) => {\n const easDataType =\n INTERNAL_DATA_TYPES[itemProperty.propertyDef!.dataType].eas\n\n let schemaUid: string | undefined = itemProperty.schemaUid\n\n const propertyNameForSchema = toSnakeCase(itemProperty.propertyName)\n\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n if (!schemaUid) {\n const schema = await getEasSchemaForItemProperty({\n propertyName: 'version',\n easDataType: 'bytes32',\n })\n if (schema) {\n schemaUid = schema.id\n }\n }\n }\n\n return {\n schemaUid,\n easDataType,\n schemaDef,\n propertyNameForSchema,\n }\n}\n\n// Lazy import SchemaEncoder to avoid module resolution issues with ts-import\nlet SchemaEncoderClass: typeof import('@ethereum-attestation-service/eas-sdk').SchemaEncoder | null = null\nconst getSchemaEncoder = async () => {\n if (!SchemaEncoderClass) {\n const easSdk = await import('@ethereum-attestation-service/eas-sdk')\n SchemaEncoderClass = easSdk.SchemaEncoder\n }\n return SchemaEncoderClass\n}\n\nconst processBasicProperties = async (\n itemBasicProperties: IItemProperty<any>[],\n itemPublishData: PublishPayload,\n): Promise<PublishPayload> => {\n for (const basicProperty of itemBasicProperties) {\n const snapshot = basicProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n let value = (context as any).propertyValue\n\n if (!value || basicProperty.uid) {\n continue\n }\n\n const { schemaUid, easDataType, schemaDef } =\n await getPropertyData(basicProperty)\n\n const propertyNameForSchema = toSnakeCase(basicProperty.propertyName)\n\n if (schemaDef.startsWith('bytes32[]') && !Array.isArray(value)) {\n throw new Error(`Invalid value for property: ${basicProperty.propertyName}. Expected an array of bytes32, got ${value}.`)\n }\n\n if (schemaDef.startsWith('bytes32[]')) {\n const newValues = []\n for (const seedId of value) {\n if (seedId.length !== 66 && !seedId.startsWith('0x')) {\n newValues.push(ethers.encodeBytes32String(seedId))\n continue\n }\n newValues.push(seedId)\n }\n value = newValues\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 const SchemaEncoder = await getSchemaEncoder()\n const dataEncoder = new SchemaEncoder(schemaDef)\n\n const encodedData = dataEncoder.encodeData(data)\n\n // For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)\n const refUid =\n basicProperty.propertyName === 'storageTransactionId'\n ? itemPublishData.versionUid\n : defaultAttestationData.refUID\n\n const attestationEntry: Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n } = {\n schema: schemaUid!,\n data: [\n {\n ...defaultAttestationData,\n refUID: refUid,\n data: encodedData,\n } as AttestationRequestData,\n ],\n }\n\n // For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues\n if (\n typeof value === 'string' &&\n value.length === 10 &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestationEntry._propertyName = basicProperty.propertyName\n attestationEntry._schemaDef = schemaDef\n attestationEntry._unresolvedValue = value\n attestationEntry._easDataType = easDataType\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): Promise<MultiPublishPayload> => {\n let relationOrImageSchemaUid = relationOrImageProperty.schemaUid\n if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {\n const propertyData = await getPropertyData(relationOrImageProperty)\n relationOrImageSchemaUid = propertyData.schemaUid\n }\n if (!relationOrImageSchemaUid) {\n throw new Error(\n `Schema uid not found for relation or image property: ${relationOrImageProperty.propertyName}`,\n )\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 const value = (context as any).propertyValue\n if (!value || relationOrImageProperty.uid) {\n return multiPublishPayload\n }\n\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(value)\n\n // Value is not a valid seed reference (10-char localId or 66-char uid); skip (e.g. Html with inline content)\n if (!seedLocalId && !seedUid) {\n return multiPublishPayload\n }\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No related item found for relation or image property: ${relationOrImageProperty.propertyName}`,\n )\n }\n\n // When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent\n if (relatedItem.seedUid) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (relationOrImageProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (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 throw new Error(`Model name not found for relation or image property: ${relationOrImageProperty.propertyName}`)\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n throw new Error(`Schema UID not found for model: ${modelName}`)\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: relationOrImageSchemaUid,\n },\n ],\n }\n\n const { itemBasicProperties, itemUploadProperties } =\n getSegmentedItemProperties(relatedItem)\n\n if (itemUploadProperties.length === 1) {\n const uploadProperty = itemUploadProperties[0]\n const itemProperty = uploadProperty.itemProperty\n const transactionData = uploadedTransactions.find(\n (transaction) => transaction.seedLocalId === relatedItem.seedLocalId,\n )\n if (transactionData) {\n itemProperty.value = transactionData.txId\n await itemProperty.save()\n itemBasicProperties.push(itemProperty)\n }\n }\n\n publishPayload = await processBasicProperties(\n itemBasicProperties,\n publishPayload,\n )\n\n multiPublishPayload.push(publishPayload)\n\n return multiPublishPayload\n}\n\nconst processListProperty = async (\n listProperty: IItemProperty<any>,\n multiPublishPayload: MultiPublishPayload,\n originalSeedLocalId: string,\n): Promise<MultiPublishPayload> => {\n // processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties\n if (!listProperty.propertyDef?.ref) {\n throw new Error(\n `processListProperty requires ref (list of relations). List property \"${listProperty.propertyName}\" has no ref. List-of-primitives should be in itemBasicProperties.`,\n )\n }\n let listPropertySchemaUid = listProperty.schemaUid\n if (!listPropertySchemaUid && listProperty.propertyDef) {\n const propertyData = await getPropertyData(listProperty)\n listPropertySchemaUid = propertyData.schemaUid\n }\n if (!listPropertySchemaUid) {\n throw new Error(\n `Schema uid not found for list property: ${listProperty.propertyName}`,\n )\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 || listProperty.uid) {\n return multiPublishPayload\n }\n\n const singularPropertyName = pluralize.singular(listProperty.propertyName)\n const propertyNameForSchema = `${singularPropertyName}${listProperty.propertyDef!.ref}Ids`\n if (typeof value === 'string' && value.length === 66) {\n value = [value]\n }\n if (typeof value === 'string' && value.length > 66) {\n try {\n value = JSON.parse(value)\n } catch (error) {\n value = value.split(',')\n }\n }\n\n for (const seedId of value) {\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(seedId)\n\n // Use dynamic import to break circular dependency\n const getItemMod = await import('../../db/read/getItem')\n const { getItem } = getItemMod\n const relatedItem = await getItem({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n console.error(\n `No related item found for list property: ${listProperty.propertyName}`,\n )\n continue\n }\n\n if (relatedItem.seedUid) {\n return multiPublishPayload\n }\n\n const versionUid = getVersionUid(relatedItem)\n\n let modelName: string | undefined\n\n if (listProperty.propertyDef?.ref || (listProperty.propertyDef as { refModelName?: string }).refModelName) {\n const def = listProperty.propertyDef as { ref?: string; refModelName?: string }\n modelName = def.ref ?? def.refModelName\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Image) {\n modelName = 'Image'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.File) {\n modelName = 'File'\n }\n\n if (listProperty.propertyDef?.dataType === ModelPropertyDataTypes.Html) {\n modelName = 'Html'\n }\n\n if (!modelName) {\n throw new Error(`Model name not found for list property: ${listProperty.propertyName}`)\n }\n\n const seedSchemaUid = await getEasSchemaUidForModel(modelName)\n \n if (!seedSchemaUid) {\n throw new Error(`Schema UID not found for model: ${modelName}`)\n }\n\n let publishPayload: PublishPayload = {\n localId: relatedItem.seedLocalId,\n seedIsRevocable: true,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n seedUid: seedUid || ZERO_BYTES32,\n seedSchemaUid,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [\n {\n publishLocalId: originalSeedLocalId,\n propertySchemaUid: listPropertySchemaUid,\n },\n ],\n }\n\n const { itemBasicProperties } = getSegmentedItemProperties(relatedItem)\n\n publishPayload = await processBasicProperties(\n itemBasicProperties,\n publishPayload,\n )\n\n multiPublishPayload.push(publishPayload)\n }\n\n return multiPublishPayload\n}\n\ntype PublishPayload = {\n localId: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: (Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n _propertyName?: string\n _schemaDef?: string\n _unresolvedValue?: string\n })[]\n propertiesToUpdate: any[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\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\nexport const getPublishPayload = async (\n item: Item<any>,\n uploadedTransactions: UploadedTransaction[],\n): Promise<MultiPublishPayload> => {\n\n let multiPublishPayload: MultiPublishPayload = []\n\n // Each PublishPayload is generated from a Seed that needs publishing\n\n // First we need to determine all Seeds to publish\n\n // That means the Seed of the Item, plus any Seeds pointed to by Relations\n\n // Check if the item has a schema UID\n let itemSchemaUid = item.schemaUid\n if (!itemSchemaUid) {\n const schemaUid = await getEasSchemaUidForModel(item.modelName)\n if (!schemaUid) {\n throw new Error(`Schema UID not found for model: ${item.modelName}`)\n }\n itemSchemaUid = schemaUid\n }\n\n let itemPublishData: PublishPayload = {\n localId: item.seedLocalId,\n seedUid: item.seedUid || ZERO_BYTES32,\n seedIsRevocable: true,\n seedSchemaUid: itemSchemaUid,\n versionSchemaUid: VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA,\n versionUid: getVersionUid(item),\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n const {\n itemBasicProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n itemRelationProperties,\n } = getSegmentedItemProperties(item)\n\n const relationAndImageProperties = [...itemRelationProperties, ...itemImageProperties]\n\n if (itemUploadProperties.length === 1) {\n const uploadProperty = itemUploadProperties[0]\n const itemProperty = uploadProperty.itemProperty\n const transactionData = uploadedTransactions.find(\n (transaction) => transaction.seedLocalId === item.seedLocalId,\n )\n if (transactionData) {\n itemProperty.value = transactionData.txId\n await itemProperty.save()\n itemBasicProperties.push(itemProperty)\n }\n }\n\n for (const relationProperty of relationAndImageProperties) {\n multiPublishPayload = await processRelationOrImageProperty(\n relationProperty,\n multiPublishPayload,\n uploadedTransactions,\n item.seedLocalId,\n )\n itemBasicProperties.push(relationProperty)\n }\n\n for (const listProperty of itemListProperties) {\n multiPublishPayload = await processListProperty(\n listProperty,\n multiPublishPayload,\n item.seedLocalId,\n )\n itemBasicProperties.push(listProperty)\n }\n \n itemPublishData = await processBasicProperties(\n itemBasicProperties,\n itemPublishData,\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 = 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\n return multiPublishPayload\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 * Topological sort: when request A has propertiesToUpdate with publishLocalId B,\n * A (the updater) must appear before B (the updatee). The contract injects A's seedUid\n * into B's attestation before B is sent to EAS; if B is processed first, B's attestation\n * goes out with wrong data (string instead of bytes32).\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n const byLocalId = new Map<string, PublishPayload>()\n for (const p of payload) {\n byLocalId.set(p.localId, p)\n }\n const visited = new Set<string>()\n const result: PublishPayload[] = []\n\n const visit = (localId: string) => {\n if (visited.has(localId)) return\n visited.add(localId)\n const p = byLocalId.get(localId)\n if (!p) return\n result.push(p)\n for (const u of p.propertiesToUpdate ?? []) {\n const targetId = (u as { publishLocalId?: string }).publishLocalId\n if (targetId && targetId !== localId) visit(targetId)\n }\n }\n\n for (const p of payload) {\n visit(p.localId)\n }\n return result\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 SchemaEncoder = await getSchemaEncoder()\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 data?: AttestationRequestData[] | AttestationRequestData\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n if (resolvedUid && entry._schemaDef && entry._propertyName) {\n const propertyNameForSchema = toSnakeCase(entry._propertyName)\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: propertyNameForSchema,\n type: (entry._easDataType as 'bytes32' | 'string') || 'bytes32',\n value: resolvedUid,\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":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AAyBe,KAAK,CAAC,8BAA8B;AAEnD,MAAM,aAAa,GAAG,CAAC,IAAgB,KAAY;AACjD,IAAA,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB;IAC3C,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,EAAE;QAC3E,OAAO,aAAa,CAAC,GAAG;IAC1B;AACA,IAAA,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;AACtD,QAAA,OAAO,aAAa;IACtB;AACA,IAAA,OAAO,YAAY;AACrB,CAAC;AAED,MAAM,eAAe,GAAG,OAAO,YAAgC,KAAI;AACjE,IAAA,MAAM,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A,IAAI,EAAG,KAAK,CAAC,YAAqC,IAAI,SAAS;AAC/D,wBAAA,KAAK,EAAE,WAAW;AACnB,qBAAA;AACF,iBAAA,CAAC;gBACF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,KAAK,CAAC,IAA+B;gBACnG,mBAAmB,CAAC,IAAI,CAAC;AACvB,oBAAA,GAAG,KAAK;AACR,oBAAA,IAAI,EAAE;AACJ,wBAAA;AACE,4BAAA,GAAG,QAAQ;AACX,4BAAA,IAAI,EAAE,WAAW;AACQ,yBAAA;AAC5B,qBAAA;AACD,oBAAA,gBAAgB,EAAE,SAAS;AAC5B,iBAAA,CAAC;YACJ;iBAAO;AACL,gBAAA,MAAM,eAAe,GAA4C;AAC/D,oBAAA,GAAG,KAAK;oBACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAA8B,CAAC;iBACtF;AACD,gBAAA,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC3C;QACF;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,GAAG,OAAO;AACV,YAAA,kBAAkB,EAAE,mBAAmB;AACxC,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as getCorrectId, x as Item, C as BaseFileManager, z as BaseArweaveClient } from './index-
|
|
2
|
-
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-
|
|
1
|
+
import { l as getCorrectId, x as Item, C as BaseFileManager, z as BaseArweaveClient } from './index-B_apqB1Q.js';
|
|
2
|
+
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-CYzNtJxH.js';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import * as sha3 from 'js-sha3';
|
|
5
5
|
import 'xstate';
|
|
@@ -243,4 +243,4 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
|
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
export { getPublishUploads, prepareArweaveTransaction };
|
|
246
|
-
//# sourceMappingURL=getPublishUploads-
|
|
246
|
+
//# sourceMappingURL=getPublishUploads-NITxWWDD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishUploads-BFM94w5S.js","sources":["../../src/helpers/crypto.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import * as sha3 from 'js-sha3'\n\nconst { sha3_256, } = sha3\n\n\nexport const getContentHash = async (\n data: sha3.Message\n): Promise<string> => {\n return sha3_256(data)\n}","import { BaseFileManager, getCorrectId } from '@/helpers'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { getContentHash } from '@/helpers/crypto'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n): Promise<ArweaveTransaction> => {\n const tags: { name: string; value: string }[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n) => {\n const uploads: PublishUpload[] = []\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { localId: seedLocalId } = getCorrectId(propertyValue)\n if (!seedLocalId) {\n continue\n }\n\n const dataType = itemProperty.propertyDef?.dataType ?? 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n): Promise<PublishUpload[]> => {\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let transaction: ArweaveTransaction\n\n if (!childUploads || childUploads.length === 0) {\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return uploads\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n return uploads\n }\n\n try {\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n fileContents = await toUint8Array(fileBuffer)\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n const separator = '===FILE_SEPARATOR==='\n // let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`\n let compositeFileContents = ''\n\n for (const childUpload of childUploads) {\n let childUploadContents\n\n const fs = await BaseFileManager.getFs()\n\n try {\n childUploadContents = await fs.promises.readFile(\n childUpload.localStoragePath,\n )\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n\n compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`\n }\n\n if (typeof document !== 'undefined') {\n fileContents = new TextEncoder().encode(compositeFileContents)\n } else {\n fileContents = Buffer.from(compositeFileContents)\n }\n }\n\n if (!fileContents) {\n throw new Error(`No file contents found for ${itemProperty.propertyName}`)\n }\n\n const uint8Array = new Uint8Array(fileContents)\n\n const contentHash = await getContentHash(uint8Array)\n\n let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = getMimeTypeFromPath(relatedItemProperty.localStoragePath)\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\n }\n\n transaction = await prepareArweaveTransaction(\n uint8Array,\n contentHash,\n contentType,\n )\n\n let itemPropertyLocalId = relatedItemProperty\n ? relatedItemProperty.localId\n : itemProperty.localId\n let itemPropertyName = relatedItemProperty\n ? relatedItemProperty.propertyName\n : itemProperty.propertyName\n\n uploads.push({\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n\n return uploads\n}\n\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n) => {\n // if (item.modelName === 'Post') {\n // if (!item.authors) {\n // item.authors = [\n // 'Sr0bIx9Fwj',\n // '0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',\n // ]\n // }\n // }\n\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties)\n uploads.push(...storageSeedUploads)\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(propertyValue)\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getPublishUploads(relatedItem, uploads, relationProperty)\n }\n\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,MAAM,EAAE,QAAQ,GAAG,GAAG,IAAI;AAGnB,MAAM,cAAc,GAAG,OAC5B,IAAkB,KACC;AACnB,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;;ACCD,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAEtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,GAAG,EAAE,YAAY;CAClB;AAED,MAAM,mBAAmB,GAAG,CAAC,cAAsB,KAAwB;AACzE,IAAA,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE;AAC1D,IAAA,OAAO,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,OAAO,IAAmB,KAAyB;IACtE,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,EAAE;QACvD,OAAO,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IACjD;AACA,IAA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IAAA,OAAO,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC;AAEnC,IAAA,KAAK,MAAM,gBAAgB,IAAI,sBAAsB,EAAE;QACrD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE;AAC5D,QAAA,MAAM,OAAO,GAAG,SAAS,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,GAAG,IAAI;QAC/D,IAAI,CAAC,OAAO,EAAE;YACZ;QACF;AACA,QAAA,MAAM,aAAa,GAAI,OAAe,CAAC,aAAa;AAEpD,QAAA,IAAI,CAAC,aAAa,IAAI,gBAAgB,CAAC,GAAG,EAAE;YAC1C;QACF;AAEA,QAAA,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,aAAa,CAAC;AAE1E,QAAA,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;YAClC,WAAW;YACX,OAAO;AACR,SAAA,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CACb,CAAA,yBAAA,EAA4B,gBAAgB,CAAC,YAAY,CAAA,CAAE,CAC5D;QACH;QAEA,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,gBAAgB,CAAC;IAC3E;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"getPublishUploads-NITxWWDD.js","sources":["../../src/helpers/crypto.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import * as sha3 from 'js-sha3'\n\nconst { sha3_256, } = sha3\n\n\nexport const getContentHash = async (\n data: sha3.Message\n): Promise<string> => {\n return sha3_256(data)\n}","import { BaseFileManager, getCorrectId } from '@/helpers'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { getContentHash } from '@/helpers/crypto'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n): Promise<ArweaveTransaction> => {\n const tags: { name: string; value: string }[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n) => {\n const uploads: PublishUpload[] = []\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { localId: seedLocalId } = getCorrectId(propertyValue)\n if (!seedLocalId) {\n continue\n }\n\n const dataType = itemProperty.propertyDef?.dataType ?? 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n): Promise<PublishUpload[]> => {\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let transaction: ArweaveTransaction\n\n if (!childUploads || childUploads.length === 0) {\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return uploads\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n return uploads\n }\n\n try {\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n fileContents = await toUint8Array(fileBuffer)\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n const separator = '===FILE_SEPARATOR==='\n // let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`\n let compositeFileContents = ''\n\n for (const childUpload of childUploads) {\n let childUploadContents\n\n const fs = await BaseFileManager.getFs()\n\n try {\n childUploadContents = await fs.promises.readFile(\n childUpload.localStoragePath,\n )\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n\n compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`\n }\n\n if (typeof document !== 'undefined') {\n fileContents = new TextEncoder().encode(compositeFileContents)\n } else {\n fileContents = Buffer.from(compositeFileContents)\n }\n }\n\n if (!fileContents) {\n throw new Error(`No file contents found for ${itemProperty.propertyName}`)\n }\n\n const uint8Array = new Uint8Array(fileContents)\n\n const contentHash = await getContentHash(uint8Array)\n\n let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = getMimeTypeFromPath(relatedItemProperty.localStoragePath)\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\n }\n\n transaction = await prepareArweaveTransaction(\n uint8Array,\n contentHash,\n contentType,\n )\n\n let itemPropertyLocalId = relatedItemProperty\n ? relatedItemProperty.localId\n : itemProperty.localId\n let itemPropertyName = relatedItemProperty\n ? relatedItemProperty.propertyName\n : itemProperty.propertyName\n\n uploads.push({\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n\n return uploads\n}\n\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n) => {\n // if (item.modelName === 'Post') {\n // if (!item.authors) {\n // item.authors = [\n // 'Sr0bIx9Fwj',\n // '0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',\n // ]\n // }\n // }\n\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties)\n uploads.push(...storageSeedUploads)\n\n for (const relationProperty of itemRelationProperties) {\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { localId: seedLocalId, uid: seedUid } = getCorrectId(propertyValue)\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getPublishUploads(relatedItem, uploads, relationProperty)\n }\n\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,MAAM,EAAE,QAAQ,GAAG,GAAG,IAAI;AAGnB,MAAM,cAAc,GAAG,OAC5B,IAAkB,KACC;AACnB,IAAA,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;;ACCD,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAEtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE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R,SAAA,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CACb,CAAA,yBAAA,EAA4B,gBAAgB,CAAC,YAAY,CAAA,CAAE,CAC5D;QACH;QAEA,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,gBAAgB,CAAC;IAC3E;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
package/dist/{getSegmentedItemProperties-Di9vevKz.js → getSegmentedItemProperties-CYzNtJxH.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { a as ModelPropertyDataTypes } from './index-
|
|
2
|
+
import { a as ModelPropertyDataTypes } from './index-B_apqB1Q.js';
|
|
3
3
|
import 'pluralize';
|
|
4
4
|
import 'drizzle-orm';
|
|
5
5
|
|
|
@@ -66,4 +66,4 @@ const getSegmentedItemProperties = (item) => {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export { getSegmentedItemProperties as g };
|
|
69
|
-
//# sourceMappingURL=getSegmentedItemProperties-
|
|
69
|
+
//# sourceMappingURL=getSegmentedItemProperties-CYzNtJxH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSegmentedItemProperties-
|
|
1
|
+
{"version":3,"file":"getSegmentedItemProperties-CYzNtJxH.js","sources":["../../src/helpers/getSegmentedItemProperties.ts"],"sourcesContent":["import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes } from '@/Schema'\n\nexport const getSegmentedItemProperties = (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n\n for (const itemProperty of item.properties) {\n if (!itemProperty.propertyDef) {\n continue\n }\n\n const isItemStorage =\n itemProperty.propertyDef.storageType &&\n itemProperty.propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId'\n\n const isStorageSeedType =\n itemProperty.propertyDef.dataType === ModelPropertyDataTypes.Image ||\n itemProperty.propertyDef.dataType === ModelPropertyDataTypes.File ||\n itemProperty.propertyDef.dataType === ModelPropertyDataTypes.Html\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n continue\n }\n\n if (itemProperty.propertyDef.dataType === ModelPropertyDataTypes.Relation) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (itemProperty.propertyDef.dataType === ModelPropertyDataTypes.List) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n if (itemProperty.propertyDef.ref) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,0BAA0B,GAAG,CAAC,IAAgB,KAAI;IAC7D,MAAM,mBAAmB,GAAG,EAAE;IAC9B,MAAM,sBAAsB,GAAG,EAAE;IACjC,MAAM,kBAAkB,GAAG,EAAE;IAC7B,MAAM,oBAAoB,GAAqB,EAAE;IACjD,MAAM,mBAAmB,GAAG,EAAE;IAC9B,MAAM,qBAAqB,GAAG,EAAE;AAChC,IAAA,IAAI,8BAA0D;AAE9D,IAAA,KAAK,MAAM,YAAY,IAAI,IAAI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B,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE;AACtE,QAAA,8BAA8B,CAAC,eAAe,GAAG,qBAAqB;IACxE;IAEA,IAAI,8BAA8B,EAAE;AAClC,QAAA,oBAAoB,CAAC,IAAI,CAAC,8BAA8B,CAAC;IAC3D;IAEA,OAAO;QACL,mBAAmB;QACnB,sBAAsB;QACtB,kBAAkB;QAClB,oBAAoB;QACpB,mBAAmB;KACpB;AACH;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
export { B as Boolean, D as Date, I as Image, J as Json, L as List, M as Model, a as ModelPropertyDataTypes, N as Number, P as Property, f as PropertyConstructor, e as PropertyMetadataKey, R as Relation, c as TProperty, d as TPropertyConstructor, T as TPropertyDataType, b as TStorageType, h as TValidationRules, g as Text, n as normalizeDataType } from './index-
|
|
3
|
-
export { g as getPropertySchema } from './property-
|
|
2
|
+
export { B as Boolean, D as Date, I as Image, J as Json, L as List, M as Model, a as ModelPropertyDataTypes, N as Number, P as Property, f as PropertyConstructor, e as PropertyMetadataKey, R as Relation, c as TProperty, d as TPropertyConstructor, T as TPropertyDataType, b as TStorageType, h as TValidationRules, g as Text, n as normalizeDataType } from './index-B_apqB1Q.js';
|
|
3
|
+
export { g as getPropertySchema } from './property-C2gviIFJ.js';
|
|
4
4
|
import 'xstate';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import 'drizzle-orm';
|
|
@@ -15,4 +15,4 @@ import 'drizzle-orm/casing';
|
|
|
15
15
|
import 'eventemitter3';
|
|
16
16
|
import 'arweave';
|
|
17
17
|
import '@sinclair/typebox';
|
|
18
|
-
//# sourceMappingURL=index-
|
|
18
|
+
//# sourceMappingURL=index-BC0xKxkf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BC0xKxkf.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|