@seedprotocol/sdk 0.4.19 → 0.4.20
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-V62RJhsZ.js → ArweaveClient-C1bakApw.js} +3 -3
- package/dist/{ArweaveClient-V62RJhsZ.js.map → ArweaveClient-C1bakApw.js.map} +1 -1
- package/dist/{ArweaveClient-CAdWVQnJ.js → ArweaveClient-Ck4wflb3.js} +3 -3
- package/dist/{ArweaveClient-CAdWVQnJ.js.map → ArweaveClient-Ck4wflb3.js.map} +1 -1
- package/dist/{Db-DS2GBY6h.js → Db-CCMLWMi-.js} +4 -4
- package/dist/{Db-DS2GBY6h.js.map → Db-CCMLWMi-.js.map} +1 -1
- package/dist/{Db-8N3-le9a.js → Db-YFg99EDt.js} +4 -4
- package/dist/{Db-8N3-le9a.js.map → Db-YFg99EDt.js.map} +1 -1
- package/dist/{EasClient-D1eibg8b.js → EasClient-BmYeAnq7.js} +2 -2
- package/dist/{EasClient-nOmY5meW.js.map → EasClient-BmYeAnq7.js.map} +1 -1
- package/dist/{EasClient-nOmY5meW.js → EasClient-Bqzb-xF2.js} +2 -2
- package/dist/{EasClient-D1eibg8b.js.map → EasClient-Bqzb-xF2.js.map} +1 -1
- package/dist/{FileManager-Cze8qmS1.js → FileManager-Ba1qAT8_.js} +2 -2
- package/dist/{FileManager-Cze8qmS1.js.map → FileManager-Ba1qAT8_.js.map} +1 -1
- package/dist/{FileManager-DSTAwkqw.js → FileManager-rVAH7uNp.js} +2 -2
- package/dist/{FileManager-DSTAwkqw.js.map → FileManager-rVAH7uNp.js.map} +1 -1
- package/dist/{ModelProperty-ChevZoUy.js → ModelProperty-Csj84uQv.js} +17 -17
- package/dist/{ModelProperty-ChevZoUy.js.map → ModelProperty-Csj84uQv.js.map} +1 -1
- package/dist/{PathResolver-C5gj9EU2.js → PathResolver-B5XBxiLt.js} +2 -2
- package/dist/{PathResolver-C5gj9EU2.js.map → PathResolver-B5XBxiLt.js.map} +1 -1
- package/dist/{PathResolver-3TuYA9yv.js → PathResolver-CzhXp_OH.js} +2 -2
- package/dist/{PathResolver-3TuYA9yv.js.map → PathResolver-CzhXp_OH.js.map} +1 -1
- package/dist/{QueryClient-BGv6JOls.js → QueryClient-5NAcOOvw.js} +2 -2
- package/dist/{QueryClient-BGv6JOls.js.map → QueryClient-5NAcOOvw.js.map} +1 -1
- package/dist/{QueryClient-By2vdhIz.js → QueryClient-BqpbpJEP.js} +2 -2
- package/dist/{QueryClient-By2vdhIz.js.map → QueryClient-BqpbpJEP.js.map} +1 -1
- package/dist/{Schema-BQ5W3aOW.js → Schema-QjwZN91G.js} +22 -22
- package/dist/{Schema-BQ5W3aOW.js.map → Schema-QjwZN91G.js.map} +1 -1
- package/dist/{SchemaValidationService-DQx83Cte.js → SchemaValidationService-Cwkeb4fG.js} +2 -2
- package/dist/{SchemaValidationService-DQx83Cte.js.map → SchemaValidationService-Cwkeb4fG.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-CMsU83q9.js → backfillMetadataPropertyIds-DCYUHZDQ.js} +2 -2
- package/dist/{backfillMetadataPropertyIds-CMsU83q9.js.map → backfillMetadataPropertyIds-DCYUHZDQ.js.map} +1 -1
- package/dist/cjs/{ModelProperty-Cuj839nX.js → ModelProperty-m4dACdoX.js} +17 -17
- package/dist/cjs/{ModelProperty-Cuj839nX.js.map → ModelProperty-m4dACdoX.js.map} +1 -1
- package/dist/cjs/{Schema-TFe24NNG.js → Schema-DlSTkGtE.js} +20 -20
- package/dist/cjs/{Schema-TFe24NNG.js.map → Schema-DlSTkGtE.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-DVQrRpse.js → SchemaValidationService-C06zlv2z.js} +2 -2
- package/dist/cjs/{SchemaValidationService-DVQrRpse.js.map → SchemaValidationService-C06zlv2z.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-BiXK4hT1.js → backfillMetadataPropertyIds-gyFrK_ny.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds-BiXK4hT1.js.map → backfillMetadataPropertyIds-gyFrK_ny.js.map} +1 -1
- package/dist/cjs/{getItem-FgLv9abh.js → getItem-gFz18nL2.js} +2 -2
- package/dist/cjs/{getItem-FgLv9abh.js.map → getItem-gFz18nL2.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-h_Rz8nVX.js → getPublishPayload-DHNfV-GE.js} +10 -10
- package/dist/cjs/{getPublishPayload-h_Rz8nVX.js.map → getPublishPayload-DHNfV-GE.js.map} +1 -1
- package/dist/cjs/{getPublishUploads-DdSwst2x.js → getPublishUploads-Dt-3g6eW.js} +18 -13
- package/dist/cjs/getPublishUploads-Dt-3g6eW.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-Bu4P_MG8.js → getSegmentedItemProperties-D3XpxCt8.js} +3 -3
- package/dist/cjs/{getSegmentedItemProperties-Bu4P_MG8.js.map → getSegmentedItemProperties-D3XpxCt8.js.map} +1 -1
- package/dist/cjs/{index-CKJeh6ic.js → index-4M2KX6s4.js} +3 -3
- package/dist/cjs/index-4M2KX6s4.js.map +1 -0
- package/dist/cjs/{index-pyKmk9hA.js → index-CHrEZZ71.js} +39 -39
- package/dist/cjs/{index-pyKmk9hA.js.map → index-CHrEZZ71.js.map} +1 -1
- package/dist/cjs/{ownership-gfm5thj7.js → ownership-CC_YF-XC.js} +2 -2
- package/dist/cjs/{ownership-gfm5thj7.js.map → ownership-CC_YF-XC.js.map} +1 -1
- package/dist/cjs/{property-Dw0b_Sf8.js → property-DtCxuPrc.js} +4 -4
- package/dist/cjs/{property-Dw0b_Sf8.js.map → property-DtCxuPrc.js.map} +1 -1
- package/dist/{getItem-Bd9U9Yih.js → getItem-CpjN3MFQ.js} +2 -2
- package/dist/{getItem-Bd9U9Yih.js.map → getItem-CpjN3MFQ.js.map} +1 -1
- package/dist/{getPublishPayload-eJL7ktes.js → getPublishPayload-CMhy9jfz.js} +10 -10
- package/dist/{getPublishPayload-eJL7ktes.js.map → getPublishPayload-CMhy9jfz.js.map} +1 -1
- package/dist/{getPublishUploads-CKm5dsL6.js → getPublishUploads-DTE4SEWk.js} +18 -13
- package/dist/getPublishUploads-DTE4SEWk.js.map +1 -0
- package/dist/{getSegmentedItemProperties-B74LN_bz.js → getSegmentedItemProperties-DzPjQtcg.js} +3 -3
- package/dist/{getSegmentedItemProperties-B74LN_bz.js.map → getSegmentedItemProperties-DzPjQtcg.js.map} +1 -1
- package/dist/{index-BvZCYMxA.js → index-C1HlP_fU.js} +52 -52
- package/dist/{index-BvZCYMxA.js.map → index-C1HlP_fU.js.map} +1 -1
- package/dist/{index-BxfqPvtu.js → index-DvUyNZc9.js} +3 -3
- package/dist/index-DvUyNZc9.js.map +1 -0
- package/dist/{index-BQv2k74p.js → index-dDmXPEJC.js} +2 -2
- package/dist/index-dDmXPEJC.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +12 -12
- package/dist/node.js +10 -10
- package/dist/{ownership-tVhYQomL.js → ownership-C7GyMbsf.js} +2 -2
- package/dist/{ownership-tVhYQomL.js.map → ownership-C7GyMbsf.js.map} +1 -1
- package/dist/{property-BOdk-wW1.js → property-BNt7Dkmw.js} +5 -5
- package/dist/{property-BOdk-wW1.js.map → property-BNt7Dkmw.js.map} +1 -1
- package/dist/{queries-DBqVwEdv.js → queries-D09IIJg_.js} +2 -2
- package/dist/{queries-DBqVwEdv.js.map → queries-D09IIJg_.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +1 -1
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/db/read/getPublishUploads.d.ts +7 -3
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +1 -1
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/getPublishUploads-DdSwst2x.js.map +0 -1
- package/dist/cjs/index-CKJeh6ic.js.map +0 -1
- package/dist/getPublishUploads-CKm5dsL6.js.map +0 -1
- package/dist/index-BQv2k74p.js.map +0 -1
- package/dist/index-BxfqPvtu.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as resolveSeedIdsFromRefString, q as normalizeRelationPropertyValue, t as Item, u as BaseFileManager, v as getContentHash, w as BaseArweaveClient } from './index-
|
|
2
|
-
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-
|
|
1
|
+
import { r as resolveSeedIdsFromRefString, q as normalizeRelationPropertyValue, t as Item, u as BaseFileManager, v as getContentHash, w as BaseArweaveClient } from './index-C1HlP_fU.js';
|
|
2
|
+
import { g as getSegmentedItemProperties } from './getSegmentedItemProperties-DzPjQtcg.js';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import 'xstate';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -16,7 +16,7 @@ import 'eventemitter3';
|
|
|
16
16
|
import 'arweave';
|
|
17
17
|
import 'js-sha3';
|
|
18
18
|
import 'reflect-metadata';
|
|
19
|
-
import './property-
|
|
19
|
+
import './property-BNt7Dkmw.js';
|
|
20
20
|
|
|
21
21
|
const logger = debug('seedSdk:item:getPublishUploads');
|
|
22
22
|
const EXTENSION_TO_MIME = {
|
|
@@ -41,7 +41,7 @@ const toUint8Array = async (data) => {
|
|
|
41
41
|
}
|
|
42
42
|
return new Uint8Array(data);
|
|
43
43
|
};
|
|
44
|
-
const prepareArweaveTransaction = async (data, contentHash, contentType) => {
|
|
44
|
+
const prepareArweaveTransaction = async (data, contentHash, contentType, additionalTags) => {
|
|
45
45
|
const tags = [];
|
|
46
46
|
if (contentHash) {
|
|
47
47
|
tags.push({ name: 'Content-SHA-256', value: contentHash });
|
|
@@ -51,6 +51,9 @@ const prepareArweaveTransaction = async (data, contentHash, contentType) => {
|
|
|
51
51
|
if (contentType) {
|
|
52
52
|
tags.push({ name: 'Content-Type', value: contentType });
|
|
53
53
|
}
|
|
54
|
+
if (additionalTags?.length) {
|
|
55
|
+
tags.push(...additionalTags);
|
|
56
|
+
}
|
|
54
57
|
const tx = await BaseArweaveClient.createTransaction(data, {
|
|
55
58
|
tags: tags.length ? tags : undefined,
|
|
56
59
|
});
|
|
@@ -70,8 +73,9 @@ const getStorageDirForDataType = (dataType) => {
|
|
|
70
73
|
return BaseFileManager.getFilesPath('images');
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
|
-
const getStorageSeedUploads = async (itemStorageSeedProperties) => {
|
|
76
|
+
const getStorageSeedUploads = async (itemStorageSeedProperties, options) => {
|
|
74
77
|
const uploads = [];
|
|
78
|
+
const extra = options?.arweaveUploadTags;
|
|
75
79
|
for (const itemProperty of itemStorageSeedProperties) {
|
|
76
80
|
const snapshot = itemProperty.getService().getSnapshot();
|
|
77
81
|
const context = 'context' in snapshot ? snapshot.context : null;
|
|
@@ -101,7 +105,7 @@ const getStorageSeedUploads = async (itemStorageSeedProperties) => {
|
|
|
101
105
|
const fileContents = await toUint8Array(fileBuffer);
|
|
102
106
|
const contentHash = await getContentHash(fileContents);
|
|
103
107
|
const contentType = getMimeTypeFromPath(refResolvedValue);
|
|
104
|
-
const transaction = await prepareArweaveTransaction(fileContents, contentHash, contentType);
|
|
108
|
+
const transaction = await prepareArweaveTransaction(fileContents, contentHash, contentType, extra);
|
|
105
109
|
uploads.push({
|
|
106
110
|
itemPropertyName: itemProperty.propertyName,
|
|
107
111
|
itemPropertyLocalId: itemProperty.localId,
|
|
@@ -209,7 +213,8 @@ async function itemHasPublishUploadCandidates(item, relatedItemProperty) {
|
|
|
209
213
|
}
|
|
210
214
|
return false;
|
|
211
215
|
}
|
|
212
|
-
const processUploadProperty = async (uploadProperty, uploads, relatedItemProperty) => {
|
|
216
|
+
const processUploadProperty = async (uploadProperty, uploads, relatedItemProperty, options) => {
|
|
217
|
+
const extra = options?.arweaveUploadTags;
|
|
213
218
|
const itemProperty = uploadProperty.itemProperty;
|
|
214
219
|
const childUploads = [];
|
|
215
220
|
for (const childProperty of uploadProperty.childProperties) {
|
|
@@ -285,7 +290,7 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
|
|
|
285
290
|
else if (childUploads.length > 0) {
|
|
286
291
|
contentType = 'application/octet-stream';
|
|
287
292
|
}
|
|
288
|
-
transaction = await prepareArweaveTransaction(uint8Array, contentHash, contentType);
|
|
293
|
+
transaction = await prepareArweaveTransaction(uint8Array, contentHash, contentType, extra);
|
|
289
294
|
let itemPropertyLocalId = relatedItemProperty
|
|
290
295
|
? relatedItemProperty.localId
|
|
291
296
|
: itemProperty.localId;
|
|
@@ -301,7 +306,7 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
|
|
|
301
306
|
});
|
|
302
307
|
return uploads;
|
|
303
308
|
};
|
|
304
|
-
const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
|
|
309
|
+
const getPublishUploads = async (item, uploads = [], relatedItemProperty, options) => {
|
|
305
310
|
// if (item.modelName === 'Post') {
|
|
306
311
|
// if (!item.authors) {
|
|
307
312
|
// item.authors = [
|
|
@@ -312,9 +317,9 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
|
|
|
312
317
|
// }
|
|
313
318
|
const { itemUploadProperties, itemRelationProperties, itemImageProperties } = await getSegmentedItemProperties(item);
|
|
314
319
|
for (const uploadProperty of itemUploadProperties) {
|
|
315
|
-
uploads = await processUploadProperty(uploadProperty, uploads, relatedItemProperty);
|
|
320
|
+
uploads = await processUploadProperty(uploadProperty, uploads, relatedItemProperty, options);
|
|
316
321
|
}
|
|
317
|
-
const storageSeedUploads = await getStorageSeedUploads(itemImageProperties);
|
|
322
|
+
const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options);
|
|
318
323
|
uploads.push(...storageSeedUploads);
|
|
319
324
|
for (const relationProperty of itemRelationProperties) {
|
|
320
325
|
const snapshot = relationProperty.getService().getSnapshot();
|
|
@@ -337,10 +342,10 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
|
|
|
337
342
|
if (!relatedItem) {
|
|
338
343
|
throw new Error(`No relatedItem found for ${relationProperty.propertyName}`);
|
|
339
344
|
}
|
|
340
|
-
uploads = await getPublishUploads(relatedItem, uploads, relationProperty);
|
|
345
|
+
uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options);
|
|
341
346
|
}
|
|
342
347
|
return uploads;
|
|
343
348
|
};
|
|
344
349
|
|
|
345
350
|
export { getPublishUploads, itemHasPublishUploadCandidates, prepareArweaveTransaction };
|
|
346
|
-
//# sourceMappingURL=getPublishUploads-
|
|
351
|
+
//# sourceMappingURL=getPublishUploads-DTE4SEWk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublishUploads-DTE4SEWk.js","sources":["../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { BaseFileManager } from '@/helpers'\nimport {\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'\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\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 (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 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 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\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\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\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 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 { 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 throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemHasPublishUploadCandidates(relatedItem, relationProperty)) {\n return true\n }\n }\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\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\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 await getSegmentedItemProperties(item)\n\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 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 { 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 throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options)\n }\n\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAOtD,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,IAA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C,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,WAAW,EAAE,OAAO,EAAE,GAAG,2BAA2B,CAC1D,8BAA8B,CAAC,aAAa,CAAC,IAAI,EAAE,CACpD;AACD,QAAA,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE;YAC5B,MAAM,IAAI,KAAK,CACb,CAAA,2BAAA,EAA8B,gBAAgB,CAAC,YAAY,CAAA,kCAAA,CAAoC,CAChG;QACH;AAEA,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;AAEA,QAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC;IACpF;AAEA,IAAA,OAAO,OAAO;AAChB;;;;"}
|
package/dist/{getSegmentedItemProperties-B74LN_bz.js → getSegmentedItemProperties-DzPjQtcg.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { b as ModelPropertyDataTypes, o as BaseDb, y as models, z as properties } from './index-
|
|
3
|
-
import { getPropertySchema } from './property-
|
|
2
|
+
import { b as ModelPropertyDataTypes, o as BaseDb, y as models, z as properties } from './index-C1HlP_fU.js';
|
|
3
|
+
import { getPropertySchema } from './property-BNt7Dkmw.js';
|
|
4
4
|
import { eq, and } from 'drizzle-orm';
|
|
5
5
|
import { upperFirst, camelCase } from 'lodash-es';
|
|
6
6
|
|
|
@@ -142,4 +142,4 @@ const getSegmentedItemProperties = async (item) => {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
export { getSegmentedItemProperties as g };
|
|
145
|
-
//# sourceMappingURL=getSegmentedItemProperties-
|
|
145
|
+
//# sourceMappingURL=getSegmentedItemProperties-DzPjQtcg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSegmentedItemProperties-B74LN_bz.js","sources":["../../src/helpers/getSegmentedItemProperties.ts"],"sourcesContent":["import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n let schema = await getPropertySchema(modelName, propertyName)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (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 let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n propertyDef.dataType === ModelPropertyDataTypes.Image ||\n propertyDef.dataType === ModelPropertyDataTypes.File ||\n propertyDef.dataType === ModelPropertyDataTypes.Html ||\n propertyDef.dataType === ModelPropertyDataTypes.Json ||\n (propertyDef.dataType === ModelPropertyDataTypes.Relation &&\n (propertyDef.refValueType === ModelPropertyDataTypes.Image ||\n propertyDef.refValueType === ModelPropertyDataTypes.File ||\n propertyDef.refValueType === ModelPropertyDataTypes.Html ||\n propertyDef.refValueType === ModelPropertyDataTypes.Json))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (propertyDef.dataType === ModelPropertyDataTypes.Relation) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (propertyDef.dataType === ModelPropertyDataTypes.Relation) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (propertyDef.dataType === ModelPropertyDataTypes.List) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\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":";;;;;;AASA,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EAAA;IAEpB,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,YAAY,CAAC;AAC7D,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,MAAM;AACzB,IAAA,MAAM,EAAE,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AAQ,EAAE;AAC5D,YAAA,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC;YACzC;QACF;QAEA,IAAI,WAAW,CAAC,QAAQ,KAAK,sBAAsB,CAAC,IAAI,EAAE;;;YAGxD,MAAM,OAAO,GACX,WAAW,CAAC,GAAG,IAAK,WAAyC,CAAC,YAAY;YAC5E,IAAI,OAAO,EAAE;AACX,gBAAA,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC;YACvC;iBAAO;AACL,gBAAA,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC;YACxC;YACA;QACF;QAEA,IAAI,aAAa,EAAE;AACjB,YAAA,qBAAqB,CAAC,IAAI,CAAC,YAAY,CAAC;YACxC;QACF;QAEA,IAAI,oBAAoB,EAAE;YACxB,8BAA8B,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE,EAAE;YACtE;QACF;AAEA,QAAA,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC;IACxC;IAEA,IAAI,8BAA8B,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
|
+
{"version":3,"file":"getSegmentedItemProperties-DzPjQtcg.js","sources":["../../src/helpers/getSegmentedItemProperties.ts"],"sourcesContent":["import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n let schema = await getPropertySchema(modelName, propertyName)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecords = await db\n .select({ id: models.id })\n .from(models)\n .where(eq(models.name, normalizedModelName))\n .limit(1)\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (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 let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n propertyDef.dataType === ModelPropertyDataTypes.Image ||\n propertyDef.dataType === ModelPropertyDataTypes.File ||\n propertyDef.dataType === ModelPropertyDataTypes.Html ||\n propertyDef.dataType === ModelPropertyDataTypes.Json ||\n (propertyDef.dataType === ModelPropertyDataTypes.Relation &&\n (propertyDef.refValueType === ModelPropertyDataTypes.Image ||\n propertyDef.refValueType === ModelPropertyDataTypes.File ||\n propertyDef.refValueType === ModelPropertyDataTypes.Html ||\n propertyDef.refValueType === ModelPropertyDataTypes.Json))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (propertyDef.dataType === ModelPropertyDataTypes.Relation) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (propertyDef.dataType === ModelPropertyDataTypes.Relation) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (propertyDef.dataType === ModelPropertyDataTypes.List) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\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":";;;;;;AASA,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EAAA;IAEpB,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,YAAY,CAAC;AAC7D,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,MAAM;AACzB,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,SAAS;AACzB,IAAA,IAAI;QACF,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAG,MAAM;aACxB,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE;aACxB,IAAI,CAAC,MAAM;aACX,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC;aAC1C,KAAK,CAAC,CAAC,CAAC;AACX,QAAA,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;AAAE,YAAA,OAAO,SAAS;QACtE,MAAM,eAAe,GAAG,MAAM;AAC3B,aAAA,MAAM;aACN,IAAI,CAAC,UAAU;aACf,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1C,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAClC;aAEF,KAAK,CAAC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oBAAoB,CAAC,IAAI,CAAC,8BAA8B,CAAC;IAC3D;IAEA,OAAO;QACL,mBAAmB;QACnB,sBAAsB;QACtB,kBAAkB;QAClB,oBAAoB;QACpB,mBAAmB;KACpB;AACH;;;;"}
|
|
@@ -1396,7 +1396,7 @@ const createPropertyInstances = async (propertyFileIds) => {
|
|
|
1396
1396
|
return;
|
|
1397
1397
|
}
|
|
1398
1398
|
try {
|
|
1399
|
-
const mod = await import('./ModelProperty-
|
|
1399
|
+
const mod = await import('./ModelProperty-Csj84uQv.js');
|
|
1400
1400
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1401
1401
|
if (!ModelProperty) {
|
|
1402
1402
|
logger$t('createPropertyInstances: ModelProperty not available from dynamic import');
|
|
@@ -1580,7 +1580,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1580
1580
|
// Step 2: Fallback to Schema context (only if database doesn't have the model)
|
|
1581
1581
|
// This handles the case where model exists in schema file but not yet in database
|
|
1582
1582
|
try {
|
|
1583
|
-
const _mod_0 = await import('./Schema-
|
|
1583
|
+
const _mod_0 = await import('./Schema-QjwZN91G.js');
|
|
1584
1584
|
const _ns_0 = _mod_0.b;
|
|
1585
1585
|
const schemaMod = _ns_0;
|
|
1586
1586
|
const { Schema } = schemaMod;
|
|
@@ -1826,7 +1826,7 @@ const loadOrCreateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1826
1826
|
}
|
|
1827
1827
|
// Mark schema as draft when a new model is created so saveNewVersion() can persist it
|
|
1828
1828
|
try {
|
|
1829
|
-
const _mod_1 = await import('./Schema-
|
|
1829
|
+
const _mod_1 = await import('./Schema-QjwZN91G.js');
|
|
1830
1830
|
const _ns_1 = _mod_1.b;
|
|
1831
1831
|
const schemaMod = _ns_1;
|
|
1832
1832
|
const { Schema } = schemaMod;
|
|
@@ -1872,10 +1872,10 @@ const validateModel = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1872
1872
|
const _validateModel = async () => {
|
|
1873
1873
|
try {
|
|
1874
1874
|
// Use dynamic imports to break circular dependencies
|
|
1875
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
1875
|
+
const validationServiceMod = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
1876
1876
|
const { SchemaValidationService } = validationServiceMod;
|
|
1877
1877
|
const validationService = new SchemaValidationService();
|
|
1878
|
-
const _mod_2 = await import('./Schema-
|
|
1878
|
+
const _mod_2 = await import('./Schema-QjwZN91G.js');
|
|
1879
1879
|
const _ns_2 = _mod_2.b;
|
|
1880
1880
|
const schemaMod = _ns_2;
|
|
1881
1881
|
const { Schema } = schemaMod;
|
|
@@ -1987,7 +1987,7 @@ const createModelProperties = fromCallback(({ sendBack, input }) => {
|
|
|
1987
1987
|
return;
|
|
1988
1988
|
}
|
|
1989
1989
|
logger$r(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
|
|
1990
|
-
const mod = await import('./ModelProperty-
|
|
1990
|
+
const mod = await import('./ModelProperty-Csj84uQv.js');
|
|
1991
1991
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
1992
1992
|
if (!ModelProperty) {
|
|
1993
1993
|
logger$r('ModelProperty not available from dynamic import');
|
|
@@ -2091,7 +2091,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
2091
2091
|
const structureMsg = `[validateEntity] Validating model structure`;
|
|
2092
2092
|
logger$q(structureMsg);
|
|
2093
2093
|
// Use existing Model validation
|
|
2094
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
2094
|
+
const validationServiceMod = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
2095
2095
|
const { SchemaValidationService } = validationServiceMod;
|
|
2096
2096
|
const validationService = new SchemaValidationService();
|
|
2097
2097
|
// Validate model structure
|
|
@@ -2109,7 +2109,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
2109
2109
|
if (entityInput.entityData.schemaName) {
|
|
2110
2110
|
try {
|
|
2111
2111
|
logger$q(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
|
|
2112
|
-
const _mod_3 = await import('./Schema-
|
|
2112
|
+
const _mod_3 = await import('./Schema-QjwZN91G.js');
|
|
2113
2113
|
const _ns_3 = _mod_3.b;
|
|
2114
2114
|
const schemaMod = _ns_3;
|
|
2115
2115
|
const { Schema } = schemaMod;
|
|
@@ -2147,7 +2147,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
else if (entityInput.entityType === 'modelProperty') {
|
|
2149
2149
|
// Use existing ModelProperty validation
|
|
2150
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
2150
|
+
const validationServiceMod = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
2151
2151
|
const { SchemaValidationService } = validationServiceMod;
|
|
2152
2152
|
const validationService = new SchemaValidationService();
|
|
2153
2153
|
// Validate property structure
|
|
@@ -2162,7 +2162,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
2162
2162
|
// If schema name and model name provided, validate against schema
|
|
2163
2163
|
if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
|
|
2164
2164
|
try {
|
|
2165
|
-
const _mod_4 = await import('./Schema-
|
|
2165
|
+
const _mod_4 = await import('./Schema-QjwZN91G.js');
|
|
2166
2166
|
const _ns_4 = _mod_4.b;
|
|
2167
2167
|
const schemaMod = _ns_4;
|
|
2168
2168
|
const { Schema } = schemaMod;
|
|
@@ -2193,7 +2193,7 @@ const validateEntity = fromPromise(async ({ input }) => {
|
|
|
2193
2193
|
}
|
|
2194
2194
|
else if (entityInput.entityType === 'schema') {
|
|
2195
2195
|
// Schema validation - use existing validation
|
|
2196
|
-
const validationServiceMod = await import('./SchemaValidationService-
|
|
2196
|
+
const validationServiceMod = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
2197
2197
|
const { SchemaValidationService } = validationServiceMod;
|
|
2198
2198
|
const validationService = new SchemaValidationService();
|
|
2199
2199
|
const schemaResult = validationService.validateSchema(entityInput.entityData);
|
|
@@ -4319,7 +4319,7 @@ const writeToDatabase = fromCallback(({ sendBack, input }) => {
|
|
|
4319
4319
|
// initial write completes is not overwritten by the stale requestWrite payload.
|
|
4320
4320
|
let dataToWrite = input.entityData;
|
|
4321
4321
|
try {
|
|
4322
|
-
const mod = await import('./ModelProperty-
|
|
4322
|
+
const mod = await import('./ModelProperty-Csj84uQv.js');
|
|
4323
4323
|
const ModelProperty = mod?.ModelProperty ?? mod?.default;
|
|
4324
4324
|
if (ModelProperty && typeof ModelProperty.getById === 'function') {
|
|
4325
4325
|
const instance = ModelProperty.getById(input.entityId);
|
|
@@ -4699,7 +4699,7 @@ const modelMachine = setup({
|
|
|
4699
4699
|
// Create ModelProperty instances for any new property IDs
|
|
4700
4700
|
if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
|
|
4701
4701
|
// Import and create instances asynchronously (fire-and-forget)
|
|
4702
|
-
import('./ModelProperty-
|
|
4702
|
+
import('./ModelProperty-Csj84uQv.js').then(({ ModelProperty }) => {
|
|
4703
4703
|
const createPromises = newPropertyIds.map(async (propertyFileId) => {
|
|
4704
4704
|
try {
|
|
4705
4705
|
const property = await ModelProperty.createById(propertyFileId);
|
|
@@ -5982,7 +5982,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
5982
5982
|
const schemaNameToTry = model$1?.schemaName;
|
|
5983
5983
|
if (schemaNameToTry) {
|
|
5984
5984
|
try {
|
|
5985
|
-
const _mod_5 = await import('./Schema-
|
|
5985
|
+
const _mod_5 = await import('./Schema-QjwZN91G.js');
|
|
5986
5986
|
const _ns_5 = _mod_5.b;
|
|
5987
5987
|
const { Schema } = _ns_5;
|
|
5988
5988
|
const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
|
|
@@ -6033,7 +6033,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
6033
6033
|
}
|
|
6034
6034
|
}
|
|
6035
6035
|
if (Object.keys(propertySchemas).length === 0) {
|
|
6036
|
-
const schemaMod = await import('./index-
|
|
6036
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
6037
6037
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6038
6038
|
const KNOWN_MODEL_FALLBACKS = {
|
|
6039
6039
|
Post: {
|
|
@@ -6082,7 +6082,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
|
|
|
6082
6082
|
// Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
|
|
6083
6083
|
let propSchema = propertySchemas[propertyName];
|
|
6084
6084
|
if (!propSchema && isRefTypeFromMeta) {
|
|
6085
|
-
const schemaMod = await import('./index-
|
|
6085
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
6086
6086
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
6087
6087
|
propSchema = {
|
|
6088
6088
|
dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
|
|
@@ -6330,9 +6330,9 @@ const runPublish = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
6330
6330
|
sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
|
|
6331
6331
|
return;
|
|
6332
6332
|
}
|
|
6333
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
6333
|
+
const getPublishUploadsMod = await import('./getPublishUploads-DTE4SEWk.js');
|
|
6334
6334
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
6335
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
6335
|
+
const getPublishPayloadMod = await import('./getPublishPayload-CMhy9jfz.js');
|
|
6336
6336
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
6337
6337
|
const uploads = await getPublishUploads(item);
|
|
6338
6338
|
let uploadedTransactions = [];
|
|
@@ -7097,7 +7097,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
7097
7097
|
const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
|
|
7098
7098
|
const _resolveRelatedValue = async () => {
|
|
7099
7099
|
// Use dynamic import to break circular dependency
|
|
7100
|
-
const schemaMod = await import('./index-
|
|
7100
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
7101
7101
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7102
7102
|
if (!propertyValue || !isRelation || populatedFromDb) {
|
|
7103
7103
|
return;
|
|
@@ -7473,7 +7473,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
7473
7473
|
// to use dynamically imported ModelPropertyDataTypes
|
|
7474
7474
|
const _hydrateFromDb = async () => {
|
|
7475
7475
|
// Use dynamic import to break circular dependency
|
|
7476
|
-
const schemaMod = await import('./index-
|
|
7476
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
7477
7477
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
7478
7478
|
const appDb = BaseDb.getAppDb();
|
|
7479
7479
|
const whereClauses = [];
|
|
@@ -7778,7 +7778,7 @@ const loadOrCreateProperty = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
7778
7778
|
};
|
|
7779
7779
|
// Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
|
|
7780
7780
|
try {
|
|
7781
|
-
const { getPropertySchema } = await import('./property-
|
|
7781
|
+
const { getPropertySchema } = await import('./property-BNt7Dkmw.js');
|
|
7782
7782
|
let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
|
|
7783
7783
|
if (!schemaFromFile?.validation) {
|
|
7784
7784
|
// Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
|
|
@@ -8162,9 +8162,9 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
8162
8162
|
}
|
|
8163
8163
|
const _analyzeInput = async () => {
|
|
8164
8164
|
// Use dynamic import to break circular dependency
|
|
8165
|
-
const schemaMod = await import('./index-
|
|
8165
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
8166
8166
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
8167
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
8167
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
8168
8168
|
let propertyName = propertyNameRaw;
|
|
8169
8169
|
if (!propertyName) {
|
|
8170
8170
|
throw new Error('propertyName is required');
|
|
@@ -8362,7 +8362,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
|
|
|
8362
8362
|
propertyRecordSchema?.validation &&
|
|
8363
8363
|
metadataValues.propertyValue != null &&
|
|
8364
8364
|
metadataValues.propertyValue !== '') {
|
|
8365
|
-
const { SchemaValidationService } = await import('./SchemaValidationService-
|
|
8365
|
+
const { SchemaValidationService } = await import('./SchemaValidationService-Cwkeb4fG.js');
|
|
8366
8366
|
const validationService = new SchemaValidationService();
|
|
8367
8367
|
const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, propertyRecordSchema.dataType, propertyRecordSchema.validation, propertyRecordSchema.refValueType);
|
|
8368
8368
|
if (!validationResult.isValid && validationResult.errors.length > 0) {
|
|
@@ -8949,7 +8949,7 @@ const saveRelation = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
8949
8949
|
}
|
|
8950
8950
|
const _saveRelation = async () => {
|
|
8951
8951
|
// Use dynamic import to break circular dependency
|
|
8952
|
-
const schemaMod = await import('./index-
|
|
8952
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
8953
8953
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
8954
8954
|
if (!propertyNameRaw) {
|
|
8955
8955
|
throw new Error('propertyName is required');
|
|
@@ -9981,7 +9981,7 @@ class ItemProperty {
|
|
|
9981
9981
|
return;
|
|
9982
9982
|
}
|
|
9983
9983
|
// Use dynamic import to break circular dependency
|
|
9984
|
-
const schemaMod = await import('./index-
|
|
9984
|
+
const schemaMod = await import('./index-DvUyNZc9.js');
|
|
9985
9985
|
const { ModelPropertyDataTypes } = schemaMod;
|
|
9986
9986
|
const { context } = snapshot;
|
|
9987
9987
|
const { propertyRecordSchema } = context;
|
|
@@ -10139,7 +10139,7 @@ class ItemProperty {
|
|
|
10139
10139
|
const normalizedRefValueType = normalizeDataType(propertyRecordSchema?.refValueType);
|
|
10140
10140
|
const propertyNames = getMetadataPropertyNamesForQuery(propertyName, normalizedDataType, normalizedRefValueType);
|
|
10141
10141
|
const propertyNameVariant = propertyNames.length > 1 ? propertyNames[1] : undefined;
|
|
10142
|
-
const _mod_6 = await import('./index-
|
|
10142
|
+
const _mod_6 = await import('./index-dDmXPEJC.js');
|
|
10143
10143
|
const _ns_6 = _mod_6.s;
|
|
10144
10144
|
const seedSchemaMod = _ns_6;
|
|
10145
10145
|
const { metadata } = seedSchemaMod;
|
|
@@ -10840,7 +10840,7 @@ class ItemProperty {
|
|
|
10840
10840
|
}
|
|
10841
10841
|
async save() {
|
|
10842
10842
|
const ctx = this._getSnapshotContext();
|
|
10843
|
-
const { assertItemOwned } = await import('./ownership-
|
|
10843
|
+
const { assertItemOwned } = await import('./ownership-C7GyMbsf.js');
|
|
10844
10844
|
await assertItemOwned({
|
|
10845
10845
|
seedLocalId: ctx?.seedLocalId ?? undefined,
|
|
10846
10846
|
seedUid: ctx?.seedUid ?? undefined,
|
|
@@ -10933,7 +10933,7 @@ class ItemProperty {
|
|
|
10933
10933
|
if (!propertyName || (!seedLocalId && !seedUid))
|
|
10934
10934
|
return;
|
|
10935
10935
|
if (db) {
|
|
10936
|
-
const _mod_7 = await import('./index-
|
|
10936
|
+
const _mod_7 = await import('./index-dDmXPEJC.js');
|
|
10937
10937
|
const _ns_7 = _mod_7.s;
|
|
10938
10938
|
const seedSchemaMod = _ns_7;
|
|
10939
10939
|
const { metadata } = seedSchemaMod;
|
|
@@ -11180,7 +11180,7 @@ class Item {
|
|
|
11180
11180
|
});
|
|
11181
11181
|
};
|
|
11182
11182
|
this.unpublish = async () => {
|
|
11183
|
-
const { assertItemOwned } = await import('./ownership-
|
|
11183
|
+
const { assertItemOwned } = await import('./ownership-C7GyMbsf.js');
|
|
11184
11184
|
const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
|
|
11185
11185
|
await assertItemOwned(this);
|
|
11186
11186
|
const seedUid = this.seedUid;
|
|
@@ -11204,7 +11204,7 @@ class Item {
|
|
|
11204
11204
|
this._service.send({ type: 'updateContext', revokedAt });
|
|
11205
11205
|
};
|
|
11206
11206
|
this.publish = async () => {
|
|
11207
|
-
const { assertItemOwned } = await import('./ownership-
|
|
11207
|
+
const { assertItemOwned } = await import('./ownership-C7GyMbsf.js');
|
|
11208
11208
|
await assertItemOwned(this);
|
|
11209
11209
|
this._service.send({ type: 'startPublish' });
|
|
11210
11210
|
return new Promise((resolve, reject) => {
|
|
@@ -11238,14 +11238,14 @@ class Item {
|
|
|
11238
11238
|
});
|
|
11239
11239
|
});
|
|
11240
11240
|
};
|
|
11241
|
-
this.getPublishUploads = async () => {
|
|
11241
|
+
this.getPublishUploads = async (options) => {
|
|
11242
11242
|
// Use dynamic import to break circular dependency
|
|
11243
|
-
const getPublishUploadsMod = await import('./getPublishUploads-
|
|
11243
|
+
const getPublishUploadsMod = await import('./getPublishUploads-DTE4SEWk.js');
|
|
11244
11244
|
const { getPublishUploads } = getPublishUploadsMod;
|
|
11245
|
-
return await getPublishUploads(this);
|
|
11245
|
+
return await getPublishUploads(this, [], undefined, options);
|
|
11246
11246
|
};
|
|
11247
11247
|
this.getPublishPayload = async (uploadedTransactions, options) => {
|
|
11248
|
-
const getPublishPayloadMod = await import('./getPublishPayload-
|
|
11248
|
+
const getPublishPayloadMod = await import('./getPublishPayload-CMhy9jfz.js');
|
|
11249
11249
|
const { getPublishPayload } = getPublishPayloadMod;
|
|
11250
11250
|
return await getPublishPayload(this, uploadedTransactions, options);
|
|
11251
11251
|
};
|
|
@@ -12136,7 +12136,7 @@ class Item {
|
|
|
12136
12136
|
setupState.subscriptionSetUp = true;
|
|
12137
12137
|
logger(`[Item._setupLiveQuerySubscription] Setting up liveQuery for seedLocalId: ${seedLocalId}`);
|
|
12138
12138
|
try {
|
|
12139
|
-
const _mod_8 = await import('./index-
|
|
12139
|
+
const _mod_8 = await import('./index-dDmXPEJC.js');
|
|
12140
12140
|
const _ns_8 = _mod_8.s;
|
|
12141
12141
|
const seedSchemaMod = _ns_8;
|
|
12142
12142
|
const { seeds, versions, metadata } = seedSchemaMod;
|
|
@@ -12447,7 +12447,7 @@ class Item {
|
|
|
12447
12447
|
* Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
|
|
12448
12448
|
*/
|
|
12449
12449
|
async destroy() {
|
|
12450
|
-
const { assertItemOwned } = await import('./ownership-
|
|
12450
|
+
const { assertItemOwned } = await import('./ownership-C7GyMbsf.js');
|
|
12451
12451
|
await assertItemOwned(this);
|
|
12452
12452
|
const context = this._getSnapshotContext();
|
|
12453
12453
|
const cacheKey = context.seedUid || context.seedLocalId;
|
|
@@ -13182,20 +13182,20 @@ const platformClassesInit = fromCallback(({ sendBack, input: { context, event }
|
|
|
13182
13182
|
let PathResolver;
|
|
13183
13183
|
let EasClient;
|
|
13184
13184
|
if (isBrowser()) {
|
|
13185
|
-
FileManager = (await import('./FileManager-
|
|
13186
|
-
Db = (await import('./Db-
|
|
13187
|
-
QueryClient = (await import('./QueryClient-
|
|
13188
|
-
ArweaveClient = (await import('./ArweaveClient-
|
|
13189
|
-
PathResolver = (await import('./PathResolver-
|
|
13190
|
-
EasClient = (await import('./EasClient-
|
|
13185
|
+
FileManager = (await import('./FileManager-Ba1qAT8_.js')).FileManager;
|
|
13186
|
+
Db = (await import('./Db-CCMLWMi-.js')).Db;
|
|
13187
|
+
QueryClient = (await import('./QueryClient-BqpbpJEP.js')).QueryClient;
|
|
13188
|
+
ArweaveClient = (await import('./ArweaveClient-Ck4wflb3.js')).ArweaveClient;
|
|
13189
|
+
PathResolver = (await import('./PathResolver-B5XBxiLt.js')).PathResolver;
|
|
13190
|
+
EasClient = (await import('./EasClient-Bqzb-xF2.js')).EasClient;
|
|
13191
13191
|
}
|
|
13192
13192
|
else if (isNode()) {
|
|
13193
|
-
FileManager = (await import('./FileManager-
|
|
13194
|
-
Db = (await import('./Db-
|
|
13195
|
-
QueryClient = (await import('./QueryClient-
|
|
13196
|
-
ArweaveClient = (await import('./ArweaveClient-
|
|
13197
|
-
PathResolver = (await import('./PathResolver-
|
|
13198
|
-
EasClient = (await import('./EasClient-
|
|
13193
|
+
FileManager = (await import('./FileManager-rVAH7uNp.js')).FileManager;
|
|
13194
|
+
Db = (await import('./Db-YFg99EDt.js')).Db;
|
|
13195
|
+
QueryClient = (await import('./QueryClient-5NAcOOvw.js')).QueryClient;
|
|
13196
|
+
ArweaveClient = (await import('./ArweaveClient-C1bakApw.js')).ArweaveClient;
|
|
13197
|
+
PathResolver = (await import('./PathResolver-CzhXp_OH.js')).PathResolver;
|
|
13198
|
+
EasClient = (await import('./EasClient-BmYeAnq7.js')).EasClient;
|
|
13199
13199
|
}
|
|
13200
13200
|
else {
|
|
13201
13201
|
throw new Error(`Unable to determine environment. isBrowser()=${isBrowser()}, isNode()=${isNode()}. Platform-specific implementations could not be loaded.`);
|
|
@@ -16730,7 +16730,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
|
|
|
16730
16730
|
// Lazy import cache for ModelProperty to avoid circular dependency
|
|
16731
16731
|
// Eagerly start loading to minimize delay on first access
|
|
16732
16732
|
let ModelPropertyClass = null;
|
|
16733
|
-
const modelPropertyImportPromise = import('./ModelProperty-
|
|
16733
|
+
const modelPropertyImportPromise = import('./ModelProperty-Csj84uQv.js')
|
|
16734
16734
|
.then(module => {
|
|
16735
16735
|
ModelPropertyClass = module.ModelProperty;
|
|
16736
16736
|
return ModelPropertyClass;
|
|
@@ -16747,7 +16747,7 @@ function getModelProperty() {
|
|
|
16747
16747
|
}
|
|
16748
16748
|
// Lazy import cache for Schema to avoid circular dependency
|
|
16749
16749
|
let SchemaClass = null;
|
|
16750
|
-
const schemaImportPromise = (async () => { const _mod_9 = await import('./Schema-
|
|
16750
|
+
const schemaImportPromise = (async () => { const _mod_9 = await import('./Schema-QjwZN91G.js'); return _mod_9.b; })()
|
|
16751
16751
|
.then(module => {
|
|
16752
16752
|
SchemaClass = module.Schema;
|
|
16753
16753
|
return SchemaClass;
|
|
@@ -18488,4 +18488,4 @@ const TModelValues = Type.Record(Type.String(), Type.Any());
|
|
|
18488
18488
|
const TModelSchema = Type.Record(Type.String(), TProperty);
|
|
18489
18489
|
|
|
18490
18490
|
export { SEED_CONFIG_FILE as $, versions as A, Boolean$1 as B, modelPropertiesToObject as C, Date$1 as D, parseListPropertyValueFromStorage as E, File$1 as F, getCorrectId as G, INTERNAL_PROPERTY_NAMES as H, Image as I, Json as J, defaultAttestationData as K, List as L, Model as M, Number$1 as N, INTERNAL_DATA_TYPES as O, Property as P, toSnakeCase as Q, Relation as R, getEasSchemaUidForSchemaDefinition as S, TModelValues as T, getEasSchemaForItemProperty as U, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as V, getItemData as W, resolveStorageNameToSchemaName as X, appState as Y, ZERO_BYTES32 as Z, BasePathResolver as _, TModelSchema as a, SeedModels as a$, SEED_CONFIG_FALLBACKS as a0, BaseEasClient as a1, EAS_ENDPOINT as a2, BaseQueryClient as a3, arweaveL1FinalizeJobs as a4, config as a5, metadata$1 as a6, modelRelations as a7, modelSchemas as a8, modelUids as a9, waitForEntityIdle as aA, createReactiveProxy as aB, findEntity as aC, forceRemoveFromCaches as aD, runDestroyLifecycle as aE, getModelId as aF, getClient as aG, ClientManagerState as aH, MachineIds as aI, createNewItem as aJ, getVersionData$1 as aK, getMetadataLatest as aL, loadAllSchemasFromDb as aM, propertyMachine as aN, SEED_PROTOCOL_SCHEMA_NAME as aO, ImageSize as aP, setSchemaUidForSchemaDefinition as aQ, setSchemaUidForModel as aR, getModelSchemasFromEas as aS, getItemVersionsFromEas as aT, getItemPropertiesFromEas as aU, getCanonicalItemPropertiesFromEas as aV, getEasSchemaUidBySchemaName as aW, getSeedsFromSchemaUids as aX, getSeedsBySchemaName as aY, withExcludeRevokedFilter as aZ, pickLatestPropertyAttestationsByRefAndSchema as a_, modelsRelations as aa, propertiesRelations as ab, propertyUidRelations as ac, propertyUids as ad, publishProcesses as ae, schemas as af, uploadProcesses as ag, graphql as ah, getPropertyIdForModelAndName as ai, saveAppState as aj, addModelsToDb$1 as ak, SCHEMA_NJK as al, ItemProperty as am, eventEmitter as an, ClientManager as ao, INIT_SCRIPT_SUCCESS_MESSAGE as ap, SCHEMA_TS as aq, getRefValueType as ar, importJsonSchema as as, loadSchemaFromFile as at, readJsonImportFile as au, syncSchemaFromSource as av, transformImportToSchemaFile as aw, writeProcessMachine as ax, getModelIdByFileId as ay, generateId as az, ModelPropertyDataTypes as b, DEFAULT_ARWEAVE_HOST as b0, DEFAULT_ARWEAVE_GATEWAYS as b1, DEFAULT_ARWEAVE_GRAPHQL_URL as b2, updateSeedRevokedAt as b3, getAddressesForItemsFilter as b4, getArweaveUrlForTransaction as b5, normalizeUploadApiBaseUrl as b6, getUploadApiArweaveDataUrl as b7, getUploadPipelineTransactionStatus as b8, getUploadApiArweaveStatusUrl as b9, db as bA, eas as bB, getPropertyData$1 as bC, schema as bD, SEEDPROTOCOL_Seed_Protocol_v1 as bE, Model$1 as bF, getArweaveUploadStatus as ba, isArweaveL1AnchoringComplete as bb, queryArweaveGatewayTransaction as bc, setUploadExecutor as bd, getUploadExecutor as be, setGetPublisherForNewSeeds as bf, getGetPublisherForNewSeeds as bg, setRevokeExecutor as bh, getRevokeExecutor as bi, setAdditionalSyncAddresses as bj, createSchema as bk, readSchema as bl, listCompleteSchemaFiles as bm, getSchemaNameFromId as bn, addSchemaToDb as bo, createModelsFromJson as bp, loadModelsFromDbForSchema as bq, getLatestSchemaVersion as br, isInternalSchema as bs, createModelFromJson as bt, ConflictError as bu, unloadEntity as bv, clearDestroySubscriptions as bw, setupEntityLiveQuery as bx, ModelSchema as by, BaseFileManager$1 as bz, TPropertyDataType as c, TStorageType as d, TProperty as e, TPropertyConstructor as f, TPropertyDefs as g, PropertyMetadataKey as h, PropertyConstructor as i, Text as j, DEFAULT_TEXT_MAX_LENGTH as k, TValidationRules as l, getOwnedAddressesFromDb as m, normalizeDataType as n, BaseDb as o, getGetAdditionalSyncAddresses as p, normalizeRelationPropertyValue as q, resolveSeedIdsFromRefString as r, seeds as s, Item as t, BaseFileManager as u, getContentHash as v, BaseArweaveClient as w, getEasSchemaUidForModel as x, models$1 as y, properties as z };
|
|
18491
|
-
//# sourceMappingURL=index-
|
|
18491
|
+
//# sourceMappingURL=index-C1HlP_fU.js.map
|