@seedprotocol/sdk 0.7.2 → 0.7.3-next.613.g79a8dfd
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/{ClientManager-ClCwwhwo.js → ClientManager-DDA9956Y.js} +9 -9
- package/dist/{ClientManager-ClCwwhwo.js.map → ClientManager-DDA9956Y.js.map} +1 -1
- package/dist/{Item-B9Y4VuK1.js → Item-D4FigtYS.js} +40 -40
- package/dist/{Item-B9Y4VuK1.js.map → Item-D4FigtYS.js.map} +1 -1
- package/dist/{ModelProperty-BMePcicQ.js → ModelProperty-BDt6AU2h.js} +23 -23
- package/dist/{ModelProperty-BMePcicQ.js.map → ModelProperty-BDt6AU2h.js.map} +1 -1
- package/dist/{Schema-COsEXXaR.js → Schema-B8xqLWkL.js} +28 -28
- package/dist/{Schema-COsEXXaR.js.map → Schema-B8xqLWkL.js.map} +1 -1
- package/dist/{SchemaValidationService-DabGMzSE.js → SchemaValidationService-BPxkfDLU.js} +6 -6
- package/dist/{SchemaValidationService-DabGMzSE.js.map → SchemaValidationService-BPxkfDLU.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js → backfillMetadataPropertyIds-DuTPcv8t.js} +3 -3
- package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js.map → backfillMetadataPropertyIds-DuTPcv8t.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BT6Un_MB.js → ModelProperty-B-cZm1yU.js} +21 -21
- package/dist/cjs/{ModelProperty-BT6Un_MB.js.map → ModelProperty-B-cZm1yU.js.map} +1 -1
- package/dist/cjs/{Schema-BXhXdUsA.js → Schema-STP972Xw.js} +23 -23
- package/dist/cjs/{Schema-BXhXdUsA.js.map → Schema-STP972Xw.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-CC18QDfc.js → SchemaValidationService-CKNW1bKg.js} +2 -2
- package/dist/cjs/{SchemaValidationService-CC18QDfc.js.map → SchemaValidationService-CKNW1bKg.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js → backfillMetadataPropertyIds-CP3y1skt.js} +3 -3
- package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js.map → backfillMetadataPropertyIds-CP3y1skt.js.map} +1 -1
- package/dist/cjs/{eas-C3CL0l7l.js → eas-CAnUC4wd.js} +3 -3
- package/dist/cjs/{eas-C3CL0l7l.js.map → eas-CAnUC4wd.js.map} +1 -1
- package/dist/cjs/{getItem-CrwWYCkj.js → getItem-CWgb3e9G.js} +2 -2
- package/dist/cjs/{getItem-CrwWYCkj.js.map → getItem-CWgb3e9G.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-DRJh7WR0.js → getPublishPayload-BsZWiJ03.js} +11 -11
- package/dist/cjs/{getPublishPayload-DRJh7WR0.js.map → getPublishPayload-BsZWiJ03.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-Bh22D3zJ.js → getPublishUploads-BQr8aMVP.js} +4 -4
- package/dist/cjs/{getPublishUploads-Bh22D3zJ.js.map → getPublishUploads-BQr8aMVP.js.map} +1 -1
- package/dist/cjs/{index-BA1RIYFG.js → index-nA5PxBSs.js} +3 -3
- package/dist/cjs/index-nA5PxBSs.js.map +1 -0
- package/dist/cjs/{index-Dls7aMjr.js → index-usKaANAq.js} +79 -37
- package/dist/cjs/index-usKaANAq.js.map +1 -0
- package/dist/cjs/{property-ZerTWizX.js → property-xMwPhQ5N.js} +5 -5
- package/dist/cjs/{property-ZerTWizX.js.map → property-xMwPhQ5N.js.map} +1 -1
- package/dist/cjs/{publishDraftGraph-CPOAcQFf.js → publishDraftGraph-BRWlR1KO.js} +4 -4
- package/dist/cjs/{publishDraftGraph-CPOAcQFf.js.map → publishDraftGraph-BRWlR1KO.js.map} +1 -1
- package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js → resetAmbiguousLegacyItemData-8nfkj9rz.js} +2 -2
- package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js.map → resetAmbiguousLegacyItemData-8nfkj9rz.js.map} +1 -1
- package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js → resolveModelForSyncedSeed-kYRuDWYw.js} +2 -2
- package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js.map → resolveModelForSyncedSeed-kYRuDWYw.js.map} +1 -1
- package/dist/cjs/{syncDbWithEas-CYfPkus9.js → syncDbWithEas-DqRhV8o2.js} +7 -7
- package/dist/cjs/{syncDbWithEas-CYfPkus9.js.map → syncDbWithEas-DqRhV8o2.js.map} +1 -1
- package/dist/{configurePlatform-xU3Hsno3.js → configurePlatform-YcOiDQBZ.js} +3 -3
- package/dist/{configurePlatform-xU3Hsno3.js.map → configurePlatform-YcOiDQBZ.js.map} +1 -1
- package/dist/{db-W1g29qsM.js → db-CQt-gcAl.js} +3 -3
- package/dist/{db-W1g29qsM.js.map → db-CQt-gcAl.js.map} +1 -1
- package/dist/{eas-CSwV6MvB.js → eas-CpOD74Ke.js} +4 -4
- package/dist/{eas-CSwV6MvB.js.map → eas-CpOD74Ke.js.map} +1 -1
- package/dist/{getItem-BYQeM3DY.js → getItem-B_OoFkd7.js} +4 -4
- package/dist/{getItem-BYQeM3DY.js.map → getItem-B_OoFkd7.js.map} +1 -1
- package/dist/{getPublishPayload-D5CQZd-y.js → getPublishPayload-Xl3sRkR-.js} +14 -14
- package/dist/{getPublishPayload-D5CQZd-y.js.map → getPublishPayload-Xl3sRkR-.js.map} +1 -1
- package/dist/{getPublishUploads-BGpDsrBp.js → getPublishUploads-DHP01KgU.js} +8 -8
- package/dist/{getPublishUploads-BGpDsrBp.js.map → getPublishUploads-DHP01KgU.js.map} +1 -1
- package/dist/{index-Bev-hZF-.js → index-BGt4_oPO.js} +8 -8
- package/dist/index-BGt4_oPO.js.map +1 -0
- package/dist/{index-DRXC5Mra.js → index-Xl1_4Lmb.js} +23 -23
- package/dist/{index-DRXC5Mra.js.map → index-Xl1_4Lmb.js.map} +1 -1
- package/dist/{index.browser-DO20vYuP.js → index.browser-CjTe0vt1.js} +5 -5
- package/dist/{index.browser-DO20vYuP.js.map → index.browser-CjTe0vt1.js.map} +1 -1
- package/dist/{index.node-C4iyOhdo.js → index.node-Cfa7npS6.js} +2 -2
- package/dist/{index.node-C4iyOhdo.js.map → index.node-Cfa7npS6.js.map} +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +24 -24
- package/dist/node.js +9 -9
- package/dist/platform.browser.js +3 -3
- package/dist/platform.node.js +1 -1
- package/dist/{property-BT1zDSkd.js → property-BrXkY1Rg.js} +8 -8
- package/dist/{property-BT1zDSkd.js.map → property-BrXkY1Rg.js.map} +1 -1
- package/dist/{publishDraftGraph-Bcfrdj7-.js → publishDraftGraph-X0Wr9txE.js} +7 -7
- package/dist/{publishDraftGraph-Bcfrdj7-.js.map → publishDraftGraph-X0Wr9txE.js.map} +1 -1
- package/dist/{resolveModelForSyncedSeed-CLlumTBq.js → resolveModelForSyncedSeed-DFVdnYq8.js} +2 -2
- package/dist/{resolveModelForSyncedSeed-CLlumTBq.js.map → resolveModelForSyncedSeed-DFVdnYq8.js.map} +1 -1
- package/dist/src/helpers/tabLocks.d.ts +11 -1
- package/dist/src/helpers/tabLocks.d.ts.map +1 -1
- package/dist/{syncDbWithEas-BQsXjGhe.js → syncDbWithEas-BU-jZ5bJ.js} +11 -11
- package/dist/{syncDbWithEas-BQsXjGhe.js.map → syncDbWithEas-BU-jZ5bJ.js.map} +1 -1
- package/dist/{tabEvents-C9qUKx_z.js → tabEvents-BZJMY5uK.js} +49 -7
- package/dist/tabEvents-BZJMY5uK.js.map +1 -0
- package/dist/{tolerantWebAccess-B-9bwxbw.js → tolerantWebAccess-BZ2RA_mb.js} +4 -4
- package/dist/{tolerantWebAccess-B-9bwxbw.js.map → tolerantWebAccess-BZ2RA_mb.js.map} +1 -1
- package/dist/{updateSeedRevokedAt-D6q0h7pj.js → updateSeedRevokedAt-iLpzae1i.js} +2 -2
- package/dist/{updateSeedRevokedAt-D6q0h7pj.js.map → updateSeedRevokedAt-iLpzae1i.js.map} +1 -1
- package/package.json +5 -5
- package/dist/cjs/index-BA1RIYFG.js.map +0 -1
- package/dist/cjs/index-Dls7aMjr.js.map +0 -1
- package/dist/index-Bev-hZF-.js.map +0 -1
- package/dist/tabEvents-C9qUKx_z.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { r as resolveSeedIdsFromRefString, n as normalizeRelationPropertyValue, i as isPublishedSeedRef } from './tabEvents-
|
|
1
|
+
import { r as resolveSeedIdsFromRefString, n as normalizeRelationPropertyValue, i as isPublishedSeedRef } from './tabEvents-BZJMY5uK.js';
|
|
2
2
|
import { BaseArweaveClient } from '@seedprotocol/arweave';
|
|
3
|
-
import { g as getPublishDraftGraph, a as getSegmentedItemProperties } from './publishDraftGraph-
|
|
3
|
+
import { g as getPublishDraftGraph, a as getSegmentedItemProperties } from './publishDraftGraph-X0Wr9txE.js';
|
|
4
4
|
import debug from 'debug';
|
|
5
|
-
import { g as getContentHash } from './ClientManager-
|
|
6
|
-
import { I as Item } from './Item-
|
|
5
|
+
import { g as getContentHash } from './ClientManager-DDA9956Y.js';
|
|
6
|
+
import { I as Item } from './Item-D4FigtYS.js';
|
|
7
7
|
import { B as BaseFileManager, a as BaseDb, h as htmlEmbeddedImageCoPublish } from './BasePathResolver-BdxCSIzn.js';
|
|
8
8
|
import { eq } from 'drizzle-orm';
|
|
9
9
|
import 'pluralize';
|
|
10
|
-
import { k as isDataType, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-
|
|
10
|
+
import { k as isDataType, M as ModelPropertyDataTypes, n as normalizeDataType } from './db-CQt-gcAl.js';
|
|
11
11
|
import '@seedprotocol/eas';
|
|
12
12
|
import 'xstate';
|
|
13
13
|
import 'nanoid';
|
|
@@ -15,11 +15,11 @@ import 'nanoid-dictionary';
|
|
|
15
15
|
import '@seedprotocol/query';
|
|
16
16
|
import 'lodash-es';
|
|
17
17
|
import 'reflect-metadata';
|
|
18
|
-
import './index-
|
|
18
|
+
import './index-Xl1_4Lmb.js';
|
|
19
19
|
import './model-DGMe-TTm.js';
|
|
20
20
|
import 'drizzle-orm/casing';
|
|
21
21
|
import '@sinclair/typebox';
|
|
22
|
-
import './property-
|
|
22
|
+
import './property-BrXkY1Rg.js';
|
|
23
23
|
import '@noble/hashes/sha3';
|
|
24
24
|
import '@noble/hashes/utils';
|
|
25
25
|
import 'rxjs';
|
|
@@ -481,4 +481,4 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty, option
|
|
|
481
481
|
};
|
|
482
482
|
|
|
483
483
|
export { getPublishUploads, itemHasPublishUploadCandidates, prepareArweaveTransaction };
|
|
484
|
-
//# sourceMappingURL=getPublishUploads-
|
|
484
|
+
//# sourceMappingURL=getPublishUploads-DHP01KgU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishUploads-BGpDsrBp.js","sources":["../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { BaseFileManager } from '@/helpers'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\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, TransactionTag } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq } from 'drizzle-orm'\nimport { ModelPropertyDataTypes, isDataType, normalizeDataType } from '@/helpers/property'\nimport { getPublishDraftGraph } from '@/db/read/publishDraftGraph'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n /** When true, do not recurse into relation properties (phase 2 must not re-upload related items). */\n skipRelationRecursion?: boolean\n}\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 additionalTags?: TransactionTag[],\n): Promise<ArweaveTransaction> => {\n const tags: TransactionTag[] = []\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 if (additionalTags?.length) {\n tags.push(...additionalTags)\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 (normalizeDataType(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 case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nfunction decodeDataUriImage(dataUri: string): { mimeType: string; bytes: Uint8Array } | null {\n const m = DATA_URI_IMAGE.exec((dataUri ?? '').trim())\n if (!m) return null\n try {\n const mimeType = m[1]!.toLowerCase().trim()\n const base64 = m[2]!.replace(/\\s/g, '')\n const binary = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))\n return { mimeType, bytes: binary }\n } catch {\n return null\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n) => {\n const uploads: PublishUpload[] = []\n const extra = options?.arweaveUploadTags\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 { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (isDataType(dataType, ModelPropertyDataTypes.Html)) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\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 extra,\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\nasync function appendCoPublishedImageUploads(\n item: IItem<any>,\n uploads: PublishUpload[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || options?.onlyHtmlStorageSeedLocalIds?.length) return uploads\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n const seen = new Set(uploads.map((u) => u.seedLocalId))\n\n for (const row of rows) {\n if (seen.has(row.imageSeedLocalId)) continue\n const imageItem = await Item.find({ seedLocalId: row.imageSeedLocalId, modelName: 'Image' })\n if (!imageItem) continue\n const st =\n imageItem.internalProperties['storageTransactionId'] ??\n imageItem.allProperties['storageTransactionId']\n const stSnap = st?.getService().getSnapshot()\n const stCtx = stSnap && 'context' in stSnap ? stSnap.context : undefined\n const stValue = typeof (stCtx as { propertyValue?: unknown } | undefined)?.propertyValue === 'string'\n ? ((stCtx as { propertyValue?: string }).propertyValue ?? '')\n : ''\n const decoded = decodeDataUriImage(stValue)\n\n const more: PublishUpload[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n const contentHash = await getContentHash(decoded.bytes)\n const transaction = await prepareArweaveTransaction(\n decoded.bytes,\n contentHash,\n decoded.mimeType,\n options?.arweaveUploadTags,\n )\n more.push({\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n transactionToSign: transaction,\n })\n }\n for (const u of more) {\n if (!seen.has(u.seedLocalId)) {\n uploads.push(u)\n seen.add(u.seedLocalId)\n }\n }\n }\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\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 const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\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 if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nasync function itemOwnUploadCandidates(\n item: IItem<any>,\n relatedItemProperty: IItemProperty<any> | undefined,\n recurseStorageRelations: boolean,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n if (!recurseStorageRelations) return false\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\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 { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemOwnUploadCandidates(relatedItem, relationProperty, false)) {\n return true\n }\n }\n\n return false\n}\n\n/** Same walk as getPublishUploads: the item and the draft items its publish carries along. */\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n if (await itemOwnUploadCandidates(item, relatedItemProperty, true)) return true\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n if (await itemOwnUploadCandidates(draft, viaList ? undefined : via, true)) return true\n }\n return false\n}\n\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const extra = options?.arweaveUploadTags\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 extra,\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\n/** No seed uid yet: a related item in this state is published together with the item. */\nconst isDraftItem = (item: IItem<any>): boolean =>\n !item.seedUid || item.seedUid === '0x' + '0'.repeat(64)\n\n/** One item's own uploads: its files, storage seeds, Html-embedded images, and the items its storage relations point at. */\nconst getItemOwnPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[],\n relatedItemProperty: IItemProperty<any> | undefined,\n options: GetPublishUploadsOptions | undefined,\n) => {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n // Phase 2 of an embedded-image publish: only the deferred Html storage seeds, of this item and of\n // the related items published with it (whose Html can embed images too).\n const onlyDeferredHtml = !!options?.onlyHtmlStorageSeedLocalIds?.length\n if (onlyDeferredHtml) {\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n } else {\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n options,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n\n // Images embedded in this item's Html: the published item's, and a related draft's published with it.\n if (!relatedItemProperty || isDraftItem(item)) {\n uploads = await appendCoPublishedImageUploads(item, uploads, options)\n }\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n // Relations to Image/File/Html/Json items: their file, read through the relation property.\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\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 { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getItemOwnPublishUploads(relatedItem, uploads, relationProperty, {\n ...options,\n skipRelationRecursion: true,\n })\n }\n\n return uploads\n}\n\n/**\n * Arweave uploads for a publish of `item`: its own, and those of every draft item the publish\n * carries along (reachable through relation and list properties, see publishDraftGraph.ts).\n */\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n) => {\n uploads = await getItemOwnPublishUploads(item, uploads, relatedItemProperty, options)\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n uploads = await getItemOwnPublishUploads(draft, uploads, viaList ? undefined : via, options)\n }\n\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAiBtD,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,IAAA,OAAO,IAAI,UAAU,CAAC,IAAc,CAAC;AACvC,CAAC;AAEM,MAAM,yBAAyB,GAAG,OACvC,IAAyB,EACzB,WAA+B,EAC/B,WAAoB,EACpB,cAAiC,KACF;IAC/B,MAAM,IAAI,GAAqB,EAAE;IACjC,IAAI,WAAW,EAAE;AACf,QAAA,IAAI,CAAC,IAAI,CAAC,E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AAO,EAAE,IAAI,MAAM,EAAE;QAClD,OAAO,GAAG,MAAM,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC;IAC9F;AAEA,IAAA,OAAO,OAAO;AAChB;;"}
|
|
1
|
+
{"version":3,"file":"getPublishUploads-DHP01KgU.js","sources":["../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { BaseFileManager } from '@/helpers'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\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, TransactionTag } from '@/types/arweave'\nimport { PublishUpload } from '@/types/publish'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq } from 'drizzle-orm'\nimport { ModelPropertyDataTypes, isDataType, normalizeDataType } from '@/helpers/property'\nimport { getPublishDraftGraph } from '@/db/read/publishDraftGraph'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n /** When true, do not recurse into relation properties (phase 2 must not re-upload related items). */\n skipRelationRecursion?: boolean\n}\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 additionalTags?: TransactionTag[],\n): Promise<ArweaveTransaction> => {\n const tags: TransactionTag[] = []\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 if (additionalTags?.length) {\n tags.push(...additionalTags)\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 (normalizeDataType(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 case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nfunction decodeDataUriImage(dataUri: string): { mimeType: string; bytes: Uint8Array } | null {\n const m = DATA_URI_IMAGE.exec((dataUri ?? '').trim())\n if (!m) return null\n try {\n const mimeType = m[1]!.toLowerCase().trim()\n const base64 = m[2]!.replace(/\\s/g, '')\n const binary = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))\n return { mimeType, bytes: binary }\n } catch {\n return null\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n) => {\n const uploads: PublishUpload[] = []\n const extra = options?.arweaveUploadTags\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 { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (isDataType(dataType, ModelPropertyDataTypes.Html)) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\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 extra,\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\nasync function appendCoPublishedImageUploads(\n item: IItem<any>,\n uploads: PublishUpload[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || options?.onlyHtmlStorageSeedLocalIds?.length) return uploads\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n const seen = new Set(uploads.map((u) => u.seedLocalId))\n\n for (const row of rows) {\n if (seen.has(row.imageSeedLocalId)) continue\n const imageItem = await Item.find({ seedLocalId: row.imageSeedLocalId, modelName: 'Image' })\n if (!imageItem) continue\n const st =\n imageItem.internalProperties['storageTransactionId'] ??\n imageItem.allProperties['storageTransactionId']\n const stSnap = st?.getService().getSnapshot()\n const stCtx = stSnap && 'context' in stSnap ? stSnap.context : undefined\n const stValue = typeof (stCtx as { propertyValue?: unknown } | undefined)?.propertyValue === 'string'\n ? ((stCtx as { propertyValue?: string }).propertyValue ?? '')\n : ''\n const decoded = decodeDataUriImage(stValue)\n\n const more: PublishUpload[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n const contentHash = await getContentHash(decoded.bytes)\n const transaction = await prepareArweaveTransaction(\n decoded.bytes,\n contentHash,\n decoded.mimeType,\n options?.arweaveUploadTags,\n )\n more.push({\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n transactionToSign: transaction,\n })\n }\n for (const u of more) {\n if (!seen.has(u.seedLocalId)) {\n uploads.push(u)\n seen.add(u.seedLocalId)\n }\n }\n }\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\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 const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\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 if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nasync function itemOwnUploadCandidates(\n item: IItem<any>,\n relatedItemProperty: IItemProperty<any> | undefined,\n recurseStorageRelations: boolean,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n if (!recurseStorageRelations) return false\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\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 { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemOwnUploadCandidates(relatedItem, relationProperty, false)) {\n return true\n }\n }\n\n return false\n}\n\n/** Same walk as getPublishUploads: the item and the draft items its publish carries along. */\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n if (await itemOwnUploadCandidates(item, relatedItemProperty, true)) return true\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n if (await itemOwnUploadCandidates(draft, viaList ? undefined : via, true)) return true\n }\n return false\n}\n\nconst processUploadProperty = async (\n uploadProperty: UploadProperty,\n uploads: PublishUpload[],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const extra = options?.arweaveUploadTags\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 extra,\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\n/** No seed uid yet: a related item in this state is published together with the item. */\nconst isDraftItem = (item: IItem<any>): boolean =>\n !item.seedUid || item.seedUid === '0x' + '0'.repeat(64)\n\n/** One item's own uploads: its files, storage seeds, Html-embedded images, and the items its storage relations point at. */\nconst getItemOwnPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[],\n relatedItemProperty: IItemProperty<any> | undefined,\n options: GetPublishUploadsOptions | undefined,\n) => {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n // Phase 2 of an embedded-image publish: only the deferred Html storage seeds, of this item and of\n // the related items published with it (whose Html can embed images too).\n const onlyDeferredHtml = !!options?.onlyHtmlStorageSeedLocalIds?.length\n if (onlyDeferredHtml) {\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n } else {\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadProperty(\n uploadProperty,\n uploads,\n relatedItemProperty,\n options,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n\n // Images embedded in this item's Html: the published item's, and a related draft's published with it.\n if (!relatedItemProperty || isDraftItem(item)) {\n uploads = await appendCoPublishedImageUploads(item, uploads, options)\n }\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n // Relations to Image/File/Html/Json items: their file, read through the relation property.\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\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 { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getItemOwnPublishUploads(relatedItem, uploads, relationProperty, {\n ...options,\n skipRelationRecursion: true,\n })\n }\n\n return uploads\n}\n\n/**\n * Arweave uploads for a publish of `item`: its own, and those of every draft item the publish\n * carries along (reachable through relation and list properties, see publishDraftGraph.ts).\n */\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n) => {\n uploads = await getItemOwnPublishUploads(item, uploads, relatedItemProperty, options)\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n uploads = await getItemOwnPublishUploads(draft, uploads, viaList ? undefined : via, options)\n }\n\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAiBtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AAC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AAM,IAAI,CAAC,IAAI,CAAC;YAClC,WAAW;YACX,OAAO;AACR,SAAA,CAAC;QAEF,IAAI,CAAC,WAAW,EAAE;;YAEhB,IAAI,kBAAkB,CAAC,aAAa,CAAC;gBAAE;YACvC,MAAM,IAAI,KAAK,CACb,CAAA,yBAAA,EAA4B,gBAAgB,CAAC,YAAY,CAAA,CAAE,CAC5D;QACH;QAEA,OAAO,GAAG,MAAM,wBAAwB,CAAC,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE;AAC/E,YAAA,GAAG,OAAO;AACV,YAAA,qBAAqB,EAAE,IAAI;AAC5B,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,OAAO;AAChB,CAAC;AAED;;;AAGG;AACI,MAAM,iBAAiB,GAAG,OAC/B,IAAgB,EAChB,OAAA,GAA2B,EAAE,EAC7B,mBAAwC,EACxC,OAAkC,KAChC;AACF,IAAA,OAAO,GAAG,MAAM,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC;AAErF,IAAA,IAAI,OAAO,EAAE,qBAAqB,EAAE;AAClC,QAAA,OAAO,OAAO;IAChB;AAEA,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACrE,IAAA,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,MAAM,EAAE;QAClD,OAAO,GAAG,MAAM,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC;IAC9F;AAEA,IAAA,OAAO,OAAO;AAChB;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
export { M as Model, T as TModelSchema, a as TModelValues } from './index-
|
|
3
|
-
import { M as ModelPropertyDataTypes } from './db-
|
|
4
|
-
export { B as Boolean, D as DEFAULT_TEXT_MAX_LENGTH, a as Date, F as File, H as Html, I as Image, J as Json, L as List, N as Number, P as Property, b as PropertyConstructor, c as PropertyMetadataKey, R as Relation, T as THtmlEmbeddedDataUriPolicy, d as TProperty, e as TPropertyConstructor, f as TPropertyDataType, g as TPropertyDefs, h as TStorageType, i as TValidationRules, j as Text, k as isDataType, n as normalizeDataType, l as normalizePropertyRecordSchema } from './db-
|
|
5
|
-
export { getPropertySchema } from './property-
|
|
2
|
+
export { M as Model, T as TModelSchema, a as TModelValues } from './index-Xl1_4Lmb.js';
|
|
3
|
+
import { M as ModelPropertyDataTypes } from './db-CQt-gcAl.js';
|
|
4
|
+
export { B as Boolean, D as DEFAULT_TEXT_MAX_LENGTH, a as Date, F as File, H as Html, I as Image, J as Json, L as List, N as Number, P as Property, b as PropertyConstructor, c as PropertyMetadataKey, R as Relation, T as THtmlEmbeddedDataUriPolicy, d as TProperty, e as TPropertyConstructor, f as TPropertyDataType, g as TPropertyDefs, h as TStorageType, i as TValidationRules, j as Text, k as isDataType, n as normalizeDataType, l as normalizePropertyRecordSchema } from './db-CQt-gcAl.js';
|
|
5
|
+
export { getPropertySchema } from './property-BrXkY1Rg.js';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import './BasePathResolver-BdxCSIzn.js';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
10
|
import '@seedprotocol/arweave';
|
|
11
|
-
import './tabEvents-
|
|
11
|
+
import './tabEvents-BZJMY5uK.js';
|
|
12
12
|
import 'debug';
|
|
13
13
|
import '@seedprotocol/eas';
|
|
14
14
|
import 'pluralize';
|
|
@@ -16,11 +16,11 @@ import 'nanoid';
|
|
|
16
16
|
import 'nanoid-dictionary';
|
|
17
17
|
import '@seedprotocol/query';
|
|
18
18
|
import 'lodash-es';
|
|
19
|
-
import './Item-
|
|
19
|
+
import './Item-D4FigtYS.js';
|
|
20
20
|
import 'rxjs';
|
|
21
21
|
import 'drizzle-orm/casing';
|
|
22
22
|
import './model-DGMe-TTm.js';
|
|
23
|
-
import './ClientManager-
|
|
23
|
+
import './ClientManager-DDA9956Y.js';
|
|
24
24
|
import '@noble/hashes/sha3';
|
|
25
25
|
import '@noble/hashes/utils';
|
|
26
26
|
import '@sinclair/typebox';
|
|
@@ -28,4 +28,4 @@ import '@sinclair/typebox';
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
export { ModelPropertyDataTypes };
|
|
31
|
-
//# sourceMappingURL=index-
|
|
31
|
+
//# sourceMappingURL=index-BGt4_oPO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BGt4_oPO.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { fromCallback, fromPromise, setup, assign, createActor } from 'xstate';
|
|
2
2
|
import { a as BaseDb, j as models, p as properties, K as isInternalSchema, g as modelSchemas, s as schemas } from './BasePathResolver-BdxCSIzn.js';
|
|
3
3
|
import { eq, and, isNull, or } from 'drizzle-orm';
|
|
4
|
-
import { b as generateId } from './tabEvents-
|
|
4
|
+
import { b as generateId } from './tabEvents-BZJMY5uK.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
|
-
import { G as writeModelToDb, K as writePropertyToDb, O as addSchemaToDb, A as AmbiguousModelError, Q as renameModelInDb, d as TProperty } from './db-
|
|
7
|
-
import { j as waitForEntityIdle, S as getInvariantSafePropertyDescriptor, m as findEntity, C as ClientManagerState, I as Item, T as clearDestroySubscriptions, n as forceRemoveFromCaches, U as unloadEntity, o as runDestroyLifecycle } from './Item-
|
|
8
|
-
import { h as getClient } from './ClientManager-
|
|
6
|
+
import { G as writeModelToDb, K as writePropertyToDb, O as addSchemaToDb, A as AmbiguousModelError, Q as renameModelInDb, d as TProperty } from './db-CQt-gcAl.js';
|
|
7
|
+
import { j as waitForEntityIdle, S as getInvariantSafePropertyDescriptor, m as findEntity, C as ClientManagerState, I as Item, T as clearDestroySubscriptions, n as forceRemoveFromCaches, U as unloadEntity, o as runDestroyLifecycle } from './Item-D4FigtYS.js';
|
|
8
|
+
import { h as getClient } from './ClientManager-DDA9956Y.js';
|
|
9
9
|
import { modelPropertiesToObject } from './model-DGMe-TTm.js';
|
|
10
10
|
import { toSnakeCase } from 'drizzle-orm/casing';
|
|
11
11
|
import { Type } from '@sinclair/typebox';
|
|
@@ -37,7 +37,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
40
|
-
const mod = await import('./ModelProperty-
|
|
40
|
+
const mod = await import('./ModelProperty-BDt6AU2h.js');
|
|
41
41
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
42
42
|
if (!ModelProperty) {
|
|
43
43
|
logger$7('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -254,7 +254,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
254
254
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
255
255
|
// This handles the case where model exists in schema file but not yet in database
|
|
256
256
|
try {
|
|
257
|
-
const _mod_2 = await import('./Schema-
|
|
257
|
+
const _mod_2 = await import('./Schema-B8xqLWkL.js');
|
|
258
258
|
const _ns_2 = _mod_2.b;
|
|
259
259
|
const schemaMod = _ns_2;
|
|
260
260
|
const { Schema } = schemaMod;
|
|
@@ -505,7 +505,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context }, self })
|
|
|
505
505
|
}
|
|
506
506
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
507
507
|
try {
|
|
508
|
-
const _mod_5 = await import('./Schema-
|
|
508
|
+
const _mod_5 = await import('./Schema-B8xqLWkL.js');
|
|
509
509
|
const _ns_5 = _mod_5.b;
|
|
510
510
|
const schemaMod = _ns_5;
|
|
511
511
|
const { Schema } = schemaMod;
|
|
@@ -553,10 +553,10 @@ const validateModel = fromCallback(({ sendBack, input: { context }, self }) => {
|
|
|
553
553
|
const _validateModel = async () => {
|
|
554
554
|
try {
|
|
555
555
|
// Use dynamic imports to break circular dependencies
|
|
556
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
556
|
+
const validationServiceMod = await import('./SchemaValidationService-BPxkfDLU.js');
|
|
557
557
|
const { SchemaValidationService } = validationServiceMod;
|
|
558
558
|
const validationService = new SchemaValidationService();
|
|
559
|
-
const _mod_6 = await import('./Schema-
|
|
559
|
+
const _mod_6 = await import('./Schema-B8xqLWkL.js');
|
|
560
560
|
const _ns_6 = _mod_6.b;
|
|
561
561
|
const schemaMod = _ns_6;
|
|
562
562
|
const { Schema } = schemaMod;
|
|
@@ -675,7 +675,7 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
675
675
|
return;
|
|
676
676
|
}
|
|
677
677
|
logger$5(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
678
|
-
const mod = await import('./ModelProperty-
|
|
678
|
+
const mod = await import('./ModelProperty-BDt6AU2h.js');
|
|
679
679
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
680
680
|
if (!ModelProperty) {
|
|
681
681
|
logger$5('ModelProperty not available from dynamic import');
|
|
@@ -700,7 +700,7 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
700
700
|
: undefined;
|
|
701
701
|
// Otherwise use provided ID or generate a random one
|
|
702
702
|
// IDs should be generated in the import process before creating properties
|
|
703
|
-
const _mod_7 = await import('./tabEvents-
|
|
703
|
+
const _mod_7 = await import('./tabEvents-BZJMY5uK.js');
|
|
704
704
|
const _ns_7 = _mod_7.P;
|
|
705
705
|
const { generateId } = _ns_7;
|
|
706
706
|
const propertyFileId = propData.id || propertyRecord?.schemaFileId || generateId();
|
|
@@ -718,7 +718,7 @@ const createModelProperties = fromCallback(({ sendBack, input, self }) => {
|
|
|
718
718
|
}
|
|
719
719
|
else if (refModelName) {
|
|
720
720
|
// Fallback: resolve the ref by name within this model's schema
|
|
721
|
-
const _mod_8 = await import('./db-
|
|
721
|
+
const _mod_8 = await import('./db-CQt-gcAl.js');
|
|
722
722
|
const _ns_8 = _mod_8.Y;
|
|
723
723
|
const { resolveModelRecord } = _ns_8;
|
|
724
724
|
const refModelRecord = await resolveModelRecord(refModelName, { schemaName }, db);
|
|
@@ -819,7 +819,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
819
819
|
const evictionEpoch = currentEvictionEpoch();
|
|
820
820
|
/** The schema to validate against; throws (validation then skips the schema check) once it was evicted. */
|
|
821
821
|
const schemaForValidation = async (schemaName) => {
|
|
822
|
-
const _mod_9 = await import('./Schema-
|
|
822
|
+
const _mod_9 = await import('./Schema-B8xqLWkL.js');
|
|
823
823
|
const _ns_9 = _mod_9.b;
|
|
824
824
|
const { Schema } = _ns_9;
|
|
825
825
|
if (schemaEvictedSince(schemaName, evictionEpoch)) {
|
|
@@ -837,7 +837,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
837
837
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
838
838
|
logger$4(structureMsg);
|
|
839
839
|
// Use existing Model validation
|
|
840
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
840
|
+
const validationServiceMod = await import('./SchemaValidationService-BPxkfDLU.js');
|
|
841
841
|
const { SchemaValidationService } = validationServiceMod;
|
|
842
842
|
const validationService = new SchemaValidationService();
|
|
843
843
|
// Validate model structure
|
|
@@ -887,7 +887,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
887
887
|
}
|
|
888
888
|
else if (entityInput.entityType === 'modelProperty') {
|
|
889
889
|
// Use existing ModelProperty validation
|
|
890
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
890
|
+
const validationServiceMod = await import('./SchemaValidationService-BPxkfDLU.js');
|
|
891
891
|
const { SchemaValidationService } = validationServiceMod;
|
|
892
892
|
const validationService = new SchemaValidationService();
|
|
893
893
|
// Validate property structure
|
|
@@ -927,7 +927,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
927
927
|
}
|
|
928
928
|
else if (entityInput.entityType === 'schema') {
|
|
929
929
|
// Schema validation - use existing validation
|
|
930
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
930
|
+
const validationServiceMod = await import('./SchemaValidationService-BPxkfDLU.js');
|
|
931
931
|
const { SchemaValidationService } = validationServiceMod;
|
|
932
932
|
const validationService = new SchemaValidationService();
|
|
933
933
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -1016,7 +1016,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
|
|
|
1016
1016
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
1017
1017
|
let dataToWrite = input.entityData;
|
|
1018
1018
|
try {
|
|
1019
|
-
const mod = await import('./ModelProperty-
|
|
1019
|
+
const mod = await import('./ModelProperty-BDt6AU2h.js');
|
|
1020
1020
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1021
1021
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
1022
1022
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -1410,7 +1410,7 @@ const modelMachine = setup({
|
|
|
1410
1410
|
// Create ModelProperty instances for any new property IDs
|
|
1411
1411
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
1412
1412
|
// Import and create instances asynchronously (fire-and-forget)
|
|
1413
|
-
import('./ModelProperty-
|
|
1413
|
+
import('./ModelProperty-BDt6AU2h.js').then(({ ModelProperty }) => {
|
|
1414
1414
|
if (self.getSnapshot().status === 'stopped')
|
|
1415
1415
|
return;
|
|
1416
1416
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
@@ -1915,7 +1915,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
1915
1915
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
1916
1916
|
// Eagerly start loading to minimize delay on first access
|
|
1917
1917
|
let ModelPropertyClass = null;
|
|
1918
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
1918
|
+
const modelPropertyImportPromise = import('./ModelProperty-BDt6AU2h.js')
|
|
1919
1919
|
.then(module => {
|
|
1920
1920
|
ModelPropertyClass = module.ModelProperty;
|
|
1921
1921
|
return ModelPropertyClass;
|
|
@@ -1931,7 +1931,7 @@ function getModelProperty() {
|
|
|
1931
1931
|
return ModelPropertyClass;
|
|
1932
1932
|
}
|
|
1933
1933
|
// Lazy import for Schema to avoid circular dependency
|
|
1934
|
-
const schemaImportPromise = (async () => { const _mod_12 = await import('./Schema-
|
|
1934
|
+
const schemaImportPromise = (async () => { const _mod_12 = await import('./Schema-B8xqLWkL.js'); return _mod_12.b; })()
|
|
1935
1935
|
.then(module => module.Schema)
|
|
1936
1936
|
.catch(() => null);
|
|
1937
1937
|
// WeakMap to store mutable state per Model instance
|
|
@@ -2842,7 +2842,7 @@ class Model {
|
|
|
2842
2842
|
const evictionEpoch = options?.evictionEpoch ?? currentEvictionEpoch();
|
|
2843
2843
|
try {
|
|
2844
2844
|
// Query model by name (throws AmbiguousModelError when several schemas define it)
|
|
2845
|
-
const _mod_10 = await import('./db-
|
|
2845
|
+
const _mod_10 = await import('./db-CQt-gcAl.js');
|
|
2846
2846
|
const _ns_10 = _mod_10.Y;
|
|
2847
2847
|
const { resolveModelRecord } = _ns_10;
|
|
2848
2848
|
const resolved = await resolveModelRecord(modelName, {}, db);
|
|
@@ -3618,7 +3618,7 @@ class Model {
|
|
|
3618
3618
|
return undefined;
|
|
3619
3619
|
}
|
|
3620
3620
|
// Model names are only unique per schema: find this model's row by its id (schemaFileId).
|
|
3621
|
-
const _mod_11 = await import('./db-
|
|
3621
|
+
const _mod_11 = await import('./db-CQt-gcAl.js');
|
|
3622
3622
|
const _ns_11 = _mod_11.Y;
|
|
3623
3623
|
const { resolveModelRecord } = _ns_11;
|
|
3624
3624
|
const modelRecord = await resolveModelRecord(modelName, { modelFileId: context.id, schemaName: context.schemaName }, db);
|
|
@@ -3824,4 +3824,4 @@ const TModelValues = Type.Record(Type.String(), Type.Any());
|
|
|
3824
3824
|
const TModelSchema = Type.Record(Type.String(), TProperty);
|
|
3825
3825
|
|
|
3826
3826
|
export { ConflictError as C, Model as M, TModelSchema as T, TModelValues as a, anyEvictionSince as b, currentEvictionEpoch as c, setupEntityLiveQuery as d, writeToDatabase$1 as e, Model$1 as f, isActorStopped as i, schemaEvictedSince as s, writeProcessMachine as w };
|
|
3827
|
-
//# sourceMappingURL=index-
|
|
3827
|
+
//# sourceMappingURL=index-Xl1_4Lmb.js.map
|