@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.
Files changed (93) hide show
  1. package/dist/{ArweaveClient-V62RJhsZ.js → ArweaveClient-C1bakApw.js} +3 -3
  2. package/dist/{ArweaveClient-V62RJhsZ.js.map → ArweaveClient-C1bakApw.js.map} +1 -1
  3. package/dist/{ArweaveClient-CAdWVQnJ.js → ArweaveClient-Ck4wflb3.js} +3 -3
  4. package/dist/{ArweaveClient-CAdWVQnJ.js.map → ArweaveClient-Ck4wflb3.js.map} +1 -1
  5. package/dist/{Db-DS2GBY6h.js → Db-CCMLWMi-.js} +4 -4
  6. package/dist/{Db-DS2GBY6h.js.map → Db-CCMLWMi-.js.map} +1 -1
  7. package/dist/{Db-8N3-le9a.js → Db-YFg99EDt.js} +4 -4
  8. package/dist/{Db-8N3-le9a.js.map → Db-YFg99EDt.js.map} +1 -1
  9. package/dist/{EasClient-D1eibg8b.js → EasClient-BmYeAnq7.js} +2 -2
  10. package/dist/{EasClient-nOmY5meW.js.map → EasClient-BmYeAnq7.js.map} +1 -1
  11. package/dist/{EasClient-nOmY5meW.js → EasClient-Bqzb-xF2.js} +2 -2
  12. package/dist/{EasClient-D1eibg8b.js.map → EasClient-Bqzb-xF2.js.map} +1 -1
  13. package/dist/{FileManager-Cze8qmS1.js → FileManager-Ba1qAT8_.js} +2 -2
  14. package/dist/{FileManager-Cze8qmS1.js.map → FileManager-Ba1qAT8_.js.map} +1 -1
  15. package/dist/{FileManager-DSTAwkqw.js → FileManager-rVAH7uNp.js} +2 -2
  16. package/dist/{FileManager-DSTAwkqw.js.map → FileManager-rVAH7uNp.js.map} +1 -1
  17. package/dist/{ModelProperty-ChevZoUy.js → ModelProperty-Csj84uQv.js} +17 -17
  18. package/dist/{ModelProperty-ChevZoUy.js.map → ModelProperty-Csj84uQv.js.map} +1 -1
  19. package/dist/{PathResolver-C5gj9EU2.js → PathResolver-B5XBxiLt.js} +2 -2
  20. package/dist/{PathResolver-C5gj9EU2.js.map → PathResolver-B5XBxiLt.js.map} +1 -1
  21. package/dist/{PathResolver-3TuYA9yv.js → PathResolver-CzhXp_OH.js} +2 -2
  22. package/dist/{PathResolver-3TuYA9yv.js.map → PathResolver-CzhXp_OH.js.map} +1 -1
  23. package/dist/{QueryClient-BGv6JOls.js → QueryClient-5NAcOOvw.js} +2 -2
  24. package/dist/{QueryClient-BGv6JOls.js.map → QueryClient-5NAcOOvw.js.map} +1 -1
  25. package/dist/{QueryClient-By2vdhIz.js → QueryClient-BqpbpJEP.js} +2 -2
  26. package/dist/{QueryClient-By2vdhIz.js.map → QueryClient-BqpbpJEP.js.map} +1 -1
  27. package/dist/{Schema-BQ5W3aOW.js → Schema-QjwZN91G.js} +22 -22
  28. package/dist/{Schema-BQ5W3aOW.js.map → Schema-QjwZN91G.js.map} +1 -1
  29. package/dist/{SchemaValidationService-DQx83Cte.js → SchemaValidationService-Cwkeb4fG.js} +2 -2
  30. package/dist/{SchemaValidationService-DQx83Cte.js.map → SchemaValidationService-Cwkeb4fG.js.map} +1 -1
  31. package/dist/{backfillMetadataPropertyIds-CMsU83q9.js → backfillMetadataPropertyIds-DCYUHZDQ.js} +2 -2
  32. package/dist/{backfillMetadataPropertyIds-CMsU83q9.js.map → backfillMetadataPropertyIds-DCYUHZDQ.js.map} +1 -1
  33. package/dist/cjs/{ModelProperty-Cuj839nX.js → ModelProperty-m4dACdoX.js} +17 -17
  34. package/dist/cjs/{ModelProperty-Cuj839nX.js.map → ModelProperty-m4dACdoX.js.map} +1 -1
  35. package/dist/cjs/{Schema-TFe24NNG.js → Schema-DlSTkGtE.js} +20 -20
  36. package/dist/cjs/{Schema-TFe24NNG.js.map → Schema-DlSTkGtE.js.map} +1 -1
  37. package/dist/cjs/{SchemaValidationService-DVQrRpse.js → SchemaValidationService-C06zlv2z.js} +2 -2
  38. package/dist/cjs/{SchemaValidationService-DVQrRpse.js.map → SchemaValidationService-C06zlv2z.js.map} +1 -1
  39. package/dist/cjs/{backfillMetadataPropertyIds-BiXK4hT1.js → backfillMetadataPropertyIds-gyFrK_ny.js} +2 -2
  40. package/dist/cjs/{backfillMetadataPropertyIds-BiXK4hT1.js.map → backfillMetadataPropertyIds-gyFrK_ny.js.map} +1 -1
  41. package/dist/cjs/{getItem-FgLv9abh.js → getItem-gFz18nL2.js} +2 -2
  42. package/dist/cjs/{getItem-FgLv9abh.js.map → getItem-gFz18nL2.js.map} +1 -1
  43. package/dist/cjs/{getPublishPayload-h_Rz8nVX.js → getPublishPayload-DHNfV-GE.js} +10 -10
  44. package/dist/cjs/{getPublishPayload-h_Rz8nVX.js.map → getPublishPayload-DHNfV-GE.js.map} +1 -1
  45. package/dist/cjs/{getPublishUploads-DdSwst2x.js → getPublishUploads-Dt-3g6eW.js} +18 -13
  46. package/dist/cjs/getPublishUploads-Dt-3g6eW.js.map +1 -0
  47. package/dist/cjs/{getSegmentedItemProperties-Bu4P_MG8.js → getSegmentedItemProperties-D3XpxCt8.js} +3 -3
  48. package/dist/cjs/{getSegmentedItemProperties-Bu4P_MG8.js.map → getSegmentedItemProperties-D3XpxCt8.js.map} +1 -1
  49. package/dist/cjs/{index-CKJeh6ic.js → index-4M2KX6s4.js} +3 -3
  50. package/dist/cjs/index-4M2KX6s4.js.map +1 -0
  51. package/dist/cjs/{index-pyKmk9hA.js → index-CHrEZZ71.js} +39 -39
  52. package/dist/cjs/{index-pyKmk9hA.js.map → index-CHrEZZ71.js.map} +1 -1
  53. package/dist/cjs/{ownership-gfm5thj7.js → ownership-CC_YF-XC.js} +2 -2
  54. package/dist/cjs/{ownership-gfm5thj7.js.map → ownership-CC_YF-XC.js.map} +1 -1
  55. package/dist/cjs/{property-Dw0b_Sf8.js → property-DtCxuPrc.js} +4 -4
  56. package/dist/cjs/{property-Dw0b_Sf8.js.map → property-DtCxuPrc.js.map} +1 -1
  57. package/dist/{getItem-Bd9U9Yih.js → getItem-CpjN3MFQ.js} +2 -2
  58. package/dist/{getItem-Bd9U9Yih.js.map → getItem-CpjN3MFQ.js.map} +1 -1
  59. package/dist/{getPublishPayload-eJL7ktes.js → getPublishPayload-CMhy9jfz.js} +10 -10
  60. package/dist/{getPublishPayload-eJL7ktes.js.map → getPublishPayload-CMhy9jfz.js.map} +1 -1
  61. package/dist/{getPublishUploads-CKm5dsL6.js → getPublishUploads-DTE4SEWk.js} +18 -13
  62. package/dist/getPublishUploads-DTE4SEWk.js.map +1 -0
  63. package/dist/{getSegmentedItemProperties-B74LN_bz.js → getSegmentedItemProperties-DzPjQtcg.js} +3 -3
  64. package/dist/{getSegmentedItemProperties-B74LN_bz.js.map → getSegmentedItemProperties-DzPjQtcg.js.map} +1 -1
  65. package/dist/{index-BvZCYMxA.js → index-C1HlP_fU.js} +52 -52
  66. package/dist/{index-BvZCYMxA.js.map → index-C1HlP_fU.js.map} +1 -1
  67. package/dist/{index-BxfqPvtu.js → index-DvUyNZc9.js} +3 -3
  68. package/dist/index-DvUyNZc9.js.map +1 -0
  69. package/dist/{index-BQv2k74p.js → index-dDmXPEJC.js} +2 -2
  70. package/dist/index-dDmXPEJC.js.map +1 -0
  71. package/dist/main.cjs +1 -1
  72. package/dist/main.js +12 -12
  73. package/dist/node.js +10 -10
  74. package/dist/{ownership-tVhYQomL.js → ownership-C7GyMbsf.js} +2 -2
  75. package/dist/{ownership-tVhYQomL.js.map → ownership-C7GyMbsf.js.map} +1 -1
  76. package/dist/{property-BOdk-wW1.js → property-BNt7Dkmw.js} +5 -5
  77. package/dist/{property-BOdk-wW1.js.map → property-BNt7Dkmw.js.map} +1 -1
  78. package/dist/{queries-DBqVwEdv.js → queries-D09IIJg_.js} +2 -2
  79. package/dist/{queries-DBqVwEdv.js.map → queries-D09IIJg_.js.map} +1 -1
  80. package/dist/src/Item/Item.d.ts +1 -1
  81. package/dist/src/Item/Item.d.ts.map +1 -1
  82. package/dist/src/db/read/getPublishUploads.d.ts +7 -3
  83. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  84. package/dist/src/index.d.ts +1 -1
  85. package/dist/src/index.d.ts.map +1 -1
  86. package/dist/src/interfaces/IItem.d.ts +1 -1
  87. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/cjs/getPublishUploads-DdSwst2x.js.map +0 -1
  90. package/dist/cjs/index-CKJeh6ic.js.map +0 -1
  91. package/dist/getPublishUploads-CKm5dsL6.js.map +0 -1
  92. package/dist/index-BQv2k74p.js.map +0 -1
  93. package/dist/index-BxfqPvtu.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var main_cjs = require('./index-pyKmk9hA.js');
4
- var getSegmentedItemProperties = require('./getSegmentedItemProperties-Bu4P_MG8.js');
3
+ var main_cjs = require('./index-CHrEZZ71.js');
4
+ var getSegmentedItemProperties = require('./getSegmentedItemProperties-D3XpxCt8.js');
5
5
  var debug = require('debug');
6
6
  require('immer');
7
7
  require('reflect-metadata');
@@ -32,7 +32,7 @@ require('rimraf');
32
32
  require('child_process');
33
33
  require('url');
34
34
  require('graphql-request');
35
- require('./property-Dw0b_Sf8.js');
35
+ require('./property-DtCxuPrc.js');
36
36
 
37
37
  const logger = debug('seedSdk:item:getPublishUploads');
38
38
  const EXTENSION_TO_MIME = {
@@ -57,7 +57,7 @@ const toUint8Array = async (data) => {
57
57
  }
58
58
  return new Uint8Array(data);
59
59
  };
60
- const prepareArweaveTransaction = async (data, contentHash, contentType) => {
60
+ const prepareArweaveTransaction = async (data, contentHash, contentType, additionalTags) => {
61
61
  const tags = [];
62
62
  if (contentHash) {
63
63
  tags.push({ name: 'Content-SHA-256', value: contentHash });
@@ -67,6 +67,9 @@ const prepareArweaveTransaction = async (data, contentHash, contentType) => {
67
67
  if (contentType) {
68
68
  tags.push({ name: 'Content-Type', value: contentType });
69
69
  }
70
+ if (additionalTags?.length) {
71
+ tags.push(...additionalTags);
72
+ }
70
73
  const tx = await main_cjs.BaseArweaveClient.createTransaction(data, {
71
74
  tags: tags.length ? tags : undefined,
72
75
  });
@@ -86,8 +89,9 @@ const getStorageDirForDataType = (dataType) => {
86
89
  return main_cjs.BaseFileManager.getFilesPath('images');
87
90
  }
88
91
  };
89
- const getStorageSeedUploads = async (itemStorageSeedProperties) => {
92
+ const getStorageSeedUploads = async (itemStorageSeedProperties, options) => {
90
93
  const uploads = [];
94
+ const extra = options?.arweaveUploadTags;
91
95
  for (const itemProperty of itemStorageSeedProperties) {
92
96
  const snapshot = itemProperty.getService().getSnapshot();
93
97
  const context = 'context' in snapshot ? snapshot.context : null;
@@ -117,7 +121,7 @@ const getStorageSeedUploads = async (itemStorageSeedProperties) => {
117
121
  const fileContents = await toUint8Array(fileBuffer);
118
122
  const contentHash = await main_cjs.getContentHash(fileContents);
119
123
  const contentType = getMimeTypeFromPath(refResolvedValue);
120
- const transaction = await prepareArweaveTransaction(fileContents, contentHash, contentType);
124
+ const transaction = await prepareArweaveTransaction(fileContents, contentHash, contentType, extra);
121
125
  uploads.push({
122
126
  itemPropertyName: itemProperty.propertyName,
123
127
  itemPropertyLocalId: itemProperty.localId,
@@ -225,7 +229,8 @@ async function itemHasPublishUploadCandidates(item, relatedItemProperty) {
225
229
  }
226
230
  return false;
227
231
  }
228
- const processUploadProperty = async (uploadProperty, uploads, relatedItemProperty) => {
232
+ const processUploadProperty = async (uploadProperty, uploads, relatedItemProperty, options) => {
233
+ const extra = options?.arweaveUploadTags;
229
234
  const itemProperty = uploadProperty.itemProperty;
230
235
  const childUploads = [];
231
236
  for (const childProperty of uploadProperty.childProperties) {
@@ -301,7 +306,7 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
301
306
  else if (childUploads.length > 0) {
302
307
  contentType = 'application/octet-stream';
303
308
  }
304
- transaction = await prepareArweaveTransaction(uint8Array, contentHash, contentType);
309
+ transaction = await prepareArweaveTransaction(uint8Array, contentHash, contentType, extra);
305
310
  let itemPropertyLocalId = relatedItemProperty
306
311
  ? relatedItemProperty.localId
307
312
  : itemProperty.localId;
@@ -317,7 +322,7 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
317
322
  });
318
323
  return uploads;
319
324
  };
320
- const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
325
+ const getPublishUploads = async (item, uploads = [], relatedItemProperty, options) => {
321
326
  // if (item.modelName === 'Post') {
322
327
  // if (!item.authors) {
323
328
  // item.authors = [
@@ -328,9 +333,9 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
328
333
  // }
329
334
  const { itemUploadProperties, itemRelationProperties, itemImageProperties } = await getSegmentedItemProperties.getSegmentedItemProperties(item);
330
335
  for (const uploadProperty of itemUploadProperties) {
331
- uploads = await processUploadProperty(uploadProperty, uploads, relatedItemProperty);
336
+ uploads = await processUploadProperty(uploadProperty, uploads, relatedItemProperty, options);
332
337
  }
333
- const storageSeedUploads = await getStorageSeedUploads(itemImageProperties);
338
+ const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options);
334
339
  uploads.push(...storageSeedUploads);
335
340
  for (const relationProperty of itemRelationProperties) {
336
341
  const snapshot = relationProperty.getService().getSnapshot();
@@ -353,7 +358,7 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
353
358
  if (!relatedItem) {
354
359
  throw new Error(`No relatedItem found for ${relationProperty.propertyName}`);
355
360
  }
356
- uploads = await getPublishUploads(relatedItem, uploads, relationProperty);
361
+ uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options);
357
362
  }
358
363
  return uploads;
359
364
  };
@@ -361,4 +366,4 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty) => {
361
366
  exports.getPublishUploads = getPublishUploads;
362
367
  exports.itemHasPublishUploadCandidates = itemHasPublishUploadCandidates;
363
368
  exports.prepareArweaveTransaction = prepareArweaveTransaction;
364
- //# sourceMappingURL=getPublishUploads-DdSwst2x.js.map
369
+ //# sourceMappingURL=getPublishUploads-Dt-3g6eW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPublishUploads-Dt-3g6eW.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":["BaseArweaveClient","BaseFileManager","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","getContentHash","getSegmentedItemProperties","Item"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAc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AAM,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,GAAGH,oCAA2B,CAC1DC,uCAA8B,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,MAAMG,aAAI,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;;;;;;"}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  require('reflect-metadata');
4
- var main_cjs = require('./index-pyKmk9hA.js');
5
- var property = require('./property-Dw0b_Sf8.js');
4
+ var main_cjs = require('./index-CHrEZZ71.js');
5
+ var property = require('./property-DtCxuPrc.js');
6
6
  var drizzleOrm = require('drizzle-orm');
7
7
  var lodashEs = require('lodash-es');
8
8
 
@@ -144,4 +144,4 @@ const getSegmentedItemProperties = async (item) => {
144
144
  };
145
145
 
146
146
  exports.getSegmentedItemProperties = getSegmentedItemProperties;
147
- //# sourceMappingURL=getSegmentedItemProperties-Bu4P_MG8.js.map
147
+ //# sourceMappingURL=getSegmentedItemProperties-D3XpxCt8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSegmentedItemProperties-Bu4P_MG8.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":["getPropertySchema","BaseDb","upperFirst","camelCase","models","eq","properties","and","ModelPropertyDataTypes"],"mappings":";;;;;;;;AASA,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EAAA;IAEpB,IAAI,MAAM,GAAG,MAAMA,0BAAiB,CAAC,SAAS,EAAE,YAAY,CAAC;AAC7D,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,MAAM;AACzB,IAAA,MAAM,EAAE,GAAGC,eAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,SAAS;AACzB,IAAA,IAAI;QACF,MAAM,mBAAmB,GAAGC,mBAAU,CAACC,kBAAS,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,YAAY,GAAG,MAAM;aACxB,MAAM,CAAC,EAAE,EAAE,EAAEC,eAAM,CAAC,EAAE,EAAE;aACxB,IAAI,CAACA,eAAM;aACX,KAAK,CAACC,aAAE,CAACD,eAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC;aAC1C,KAAK,CAAC,CAAC,CAAC;AACX,QAAA,IAAI,YAA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E;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-D3XpxCt8.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":["getPropertySchema","BaseDb","upperFirst","camelCase","models","eq","properties","and","ModelPropertyDataTypes"],"mappings":";;;;;;;;AASA,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EAAA;IAE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,QAAQ,KAAKA,+BAAsB,CAAC,QAAQ,EAAE;AAC5D,gBAAA,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC;YAC3C;YACA;QACF;QAEA,IAAI,WAAW,CAAC,QAAQ,KAAKA,+BAAsB,CAAC,QAAQ,EAAE;AAC5D,YAAA,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC;YACzC;QACF;QAEA,IAAI,WAAW,CAAC,QAAQ,KAAKA,+BAAsB,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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  require('reflect-metadata');
4
- var main_cjs = require('./index-pyKmk9hA.js');
5
- var property = require('./property-Dw0b_Sf8.js');
4
+ var main_cjs = require('./index-CHrEZZ71.js');
5
+ var property = require('./property-DtCxuPrc.js');
6
6
  require('immer');
7
7
  require('xstate');
8
8
  require('drizzle-orm/sqlite-core');
@@ -63,4 +63,4 @@ exports.TValidationRules = main_cjs.TValidationRules;
63
63
  exports.Text = main_cjs.Text;
64
64
  exports.normalizeDataType = main_cjs.normalizeDataType;
65
65
  exports.getPropertySchema = property.getPropertySchema;
66
- //# sourceMappingURL=index-CKJeh6ic.js.map
66
+ //# sourceMappingURL=index-4M2KX6s4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-4M2KX6s4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1431,7 +1431,7 @@ const createPropertyInstances = async (propertyFileIds) => {
1431
1431
  return;
1432
1432
  }
1433
1433
  try {
1434
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Cuj839nX.js'); });
1434
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-m4dACdoX.js'); });
1435
1435
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
1436
1436
  if (!ModelProperty) {
1437
1437
  logger$y('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -1615,7 +1615,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
1615
1615
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
1616
1616
  // This handles the case where model exists in schema file but not yet in database
1617
1617
  try {
1618
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
1618
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
1619
1619
  const { Schema } = schemaMod;
1620
1620
  const schema = Schema.create(schemaName, { waitForReady: false });
1621
1621
  const schemaSnapshot = schema.getService().getSnapshot();
@@ -1859,7 +1859,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
1859
1859
  }
1860
1860
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
1861
1861
  try {
1862
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
1862
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
1863
1863
  const { Schema } = schemaMod;
1864
1864
  const schema = Schema.create(schemaName, { waitForReady: false });
1865
1865
  schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
@@ -1903,10 +1903,10 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
1903
1903
  const _validateModel = async () => {
1904
1904
  try {
1905
1905
  // Use dynamic imports to break circular dependencies
1906
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
1906
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
1907
1907
  const { SchemaValidationService } = validationServiceMod;
1908
1908
  const validationService = new SchemaValidationService();
1909
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
1909
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
1910
1910
  const { Schema } = schemaMod;
1911
1911
  // Validate model structure
1912
1912
  const structureResult = validationService.validateModelStructure(context);
@@ -2016,7 +2016,7 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
2016
2016
  return;
2017
2017
  }
2018
2018
  logger$w(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
2019
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Cuj839nX.js'); });
2019
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-m4dACdoX.js'); });
2020
2020
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
2021
2021
  if (!ModelProperty) {
2022
2022
  logger$w('ModelProperty not available from dynamic import');
@@ -2120,7 +2120,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2120
2120
  const structureMsg = `[validateEntity] Validating model structure`;
2121
2121
  logger$v(structureMsg);
2122
2122
  // Use existing Model validation
2123
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
2123
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
2124
2124
  const { SchemaValidationService } = validationServiceMod;
2125
2125
  const validationService = new SchemaValidationService();
2126
2126
  // Validate model structure
@@ -2138,7 +2138,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2138
2138
  if (entityInput.entityData.schemaName) {
2139
2139
  try {
2140
2140
  logger$v(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
2141
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
2141
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
2142
2142
  const { Schema } = schemaMod;
2143
2143
  const schema = Schema.create(entityInput.entityData.schemaName, {
2144
2144
  waitForReady: false,
@@ -2174,7 +2174,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2174
2174
  }
2175
2175
  else if (entityInput.entityType === 'modelProperty') {
2176
2176
  // Use existing ModelProperty validation
2177
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
2177
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
2178
2178
  const { SchemaValidationService } = validationServiceMod;
2179
2179
  const validationService = new SchemaValidationService();
2180
2180
  // Validate property structure
@@ -2189,7 +2189,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2189
2189
  // If schema name and model name provided, validate against schema
2190
2190
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
2191
2191
  try {
2192
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
2192
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
2193
2193
  const { Schema } = schemaMod;
2194
2194
  const schema = Schema.create(entityInput.entityData._schemaName, {
2195
2195
  waitForReady: false,
@@ -2218,7 +2218,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2218
2218
  }
2219
2219
  else if (entityInput.entityType === 'schema') {
2220
2220
  // Schema validation - use existing validation
2221
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
2221
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
2222
2222
  const { SchemaValidationService } = validationServiceMod;
2223
2223
  const validationService = new SchemaValidationService();
2224
2224
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -4366,7 +4366,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
4366
4366
  // initial write completes is not overwritten by the stale requestWrite payload.
4367
4367
  let dataToWrite = input.entityData;
4368
4368
  try {
4369
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Cuj839nX.js'); });
4369
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-m4dACdoX.js'); });
4370
4370
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
4371
4371
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
4372
4372
  const instance = ModelProperty.getById(input.entityId);
@@ -4746,7 +4746,7 @@ const modelMachine = xstate.setup({
4746
4746
  // Create ModelProperty instances for any new property IDs
4747
4747
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
4748
4748
  // Import and create instances asynchronously (fire-and-forget)
4749
- Promise.resolve().then(function () { return require('./ModelProperty-Cuj839nX.js'); }).then(({ ModelProperty }) => {
4749
+ Promise.resolve().then(function () { return require('./ModelProperty-m4dACdoX.js'); }).then(({ ModelProperty }) => {
4750
4750
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
4751
4751
  try {
4752
4752
  const property = await ModelProperty.createById(propertyFileId);
@@ -5991,7 +5991,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
5991
5991
  const schemaNameToTry = model$1?.schemaName;
5992
5992
  if (schemaNameToTry) {
5993
5993
  try {
5994
- const { Schema } = await Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); });
5994
+ const { Schema } = await Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); });
5995
5995
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
5996
5996
  const schemaContext = schemaInstance.getService().getSnapshot().context;
5997
5997
  if (schemaContext.models?.[modelName]?.properties) {
@@ -6040,7 +6040,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
6040
6040
  }
6041
6041
  }
6042
6042
  if (Object.keys(propertySchemas).length === 0) {
6043
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
6043
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
6044
6044
  const { ModelPropertyDataTypes } = schemaMod;
6045
6045
  const KNOWN_MODEL_FALLBACKS = {
6046
6046
  Post: {
@@ -6089,7 +6089,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
6089
6089
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
6090
6090
  let propSchema = propertySchemas[propertyName];
6091
6091
  if (!propSchema && isRefTypeFromMeta) {
6092
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
6092
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
6093
6093
  const { ModelPropertyDataTypes } = schemaMod;
6094
6094
  propSchema = {
6095
6095
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -6337,9 +6337,9 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
6337
6337
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
6338
6338
  return;
6339
6339
  }
6340
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-DdSwst2x.js'); });
6340
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-Dt-3g6eW.js'); });
6341
6341
  const { getPublishUploads } = getPublishUploadsMod;
6342
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-h_Rz8nVX.js'); });
6342
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DHNfV-GE.js'); });
6343
6343
  const { getPublishPayload } = getPublishPayloadMod;
6344
6344
  const uploads = await getPublishUploads(item);
6345
6345
  let uploadedTransactions = [];
@@ -7104,7 +7104,7 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
7104
7104
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
7105
7105
  const _resolveRelatedValue = async () => {
7106
7106
  // Use dynamic import to break circular dependency
7107
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
7107
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
7108
7108
  const { ModelPropertyDataTypes } = schemaMod;
7109
7109
  if (!propertyValue || !isRelation || populatedFromDb) {
7110
7110
  return;
@@ -7480,7 +7480,7 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
7480
7480
  // to use dynamically imported ModelPropertyDataTypes
7481
7481
  const _hydrateFromDb = async () => {
7482
7482
  // Use dynamic import to break circular dependency
7483
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
7483
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
7484
7484
  const { ModelPropertyDataTypes } = schemaMod;
7485
7485
  const appDb = BaseDb.getAppDb();
7486
7486
  const whereClauses = [];
@@ -7785,7 +7785,7 @@ const loadOrCreateProperty = xstate.fromCallback(({ sendBack, input: { context }
7785
7785
  };
7786
7786
  // Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
7787
7787
  try {
7788
- const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-Dw0b_Sf8.js'); });
7788
+ const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-DtCxuPrc.js'); });
7789
7789
  let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
7790
7790
  if (!schemaFromFile?.validation) {
7791
7791
  // Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
@@ -8169,9 +8169,9 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
8169
8169
  }
8170
8170
  const _analyzeInput = async () => {
8171
8171
  // Use dynamic import to break circular dependency
8172
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
8172
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
8173
8173
  const { ModelPropertyDataTypes } = schemaMod;
8174
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
8174
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
8175
8175
  let propertyName = propertyNameRaw;
8176
8176
  if (!propertyName) {
8177
8177
  throw new Error('propertyName is required');
@@ -8369,7 +8369,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
8369
8369
  propertyRecordSchema?.validation &&
8370
8370
  metadataValues.propertyValue != null &&
8371
8371
  metadataValues.propertyValue !== '') {
8372
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-DVQrRpse.js'); });
8372
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-C06zlv2z.js'); });
8373
8373
  const validationService = new SchemaValidationService();
8374
8374
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, propertyRecordSchema.dataType, propertyRecordSchema.validation, propertyRecordSchema.refValueType);
8375
8375
  if (!validationResult.isValid && validationResult.errors.length > 0) {
@@ -8956,7 +8956,7 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
8956
8956
  }
8957
8957
  const _saveRelation = async () => {
8958
8958
  // Use dynamic import to break circular dependency
8959
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
8959
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
8960
8960
  const { ModelPropertyDataTypes } = schemaMod;
8961
8961
  if (!propertyNameRaw) {
8962
8962
  throw new Error('propertyName is required');
@@ -9988,7 +9988,7 @@ class ItemProperty {
9988
9988
  return;
9989
9989
  }
9990
9990
  // Use dynamic import to break circular dependency
9991
- const schemaMod = await Promise.resolve().then(function () { return require('./index-CKJeh6ic.js'); });
9991
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-4M2KX6s4.js'); });
9992
9992
  const { ModelPropertyDataTypes } = schemaMod;
9993
9993
  const { context } = snapshot;
9994
9994
  const { propertyRecordSchema } = context;
@@ -10845,7 +10845,7 @@ class ItemProperty {
10845
10845
  }
10846
10846
  async save() {
10847
10847
  const ctx = this._getSnapshotContext();
10848
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-gfm5thj7.js'); });
10848
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-CC_YF-XC.js'); });
10849
10849
  await assertItemOwned({
10850
10850
  seedLocalId: ctx?.seedLocalId ?? undefined,
10851
10851
  seedUid: ctx?.seedUid ?? undefined,
@@ -11183,7 +11183,7 @@ class Item {
11183
11183
  });
11184
11184
  };
11185
11185
  this.unpublish = async () => {
11186
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-gfm5thj7.js'); });
11186
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-CC_YF-XC.js'); });
11187
11187
  const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
11188
11188
  await assertItemOwned(this);
11189
11189
  const seedUid = this.seedUid;
@@ -11207,7 +11207,7 @@ class Item {
11207
11207
  this._service.send({ type: 'updateContext', revokedAt });
11208
11208
  };
11209
11209
  this.publish = async () => {
11210
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-gfm5thj7.js'); });
11210
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-CC_YF-XC.js'); });
11211
11211
  await assertItemOwned(this);
11212
11212
  this._service.send({ type: 'startPublish' });
11213
11213
  return new Promise((resolve, reject) => {
@@ -11241,14 +11241,14 @@ class Item {
11241
11241
  });
11242
11242
  });
11243
11243
  };
11244
- this.getPublishUploads = async () => {
11244
+ this.getPublishUploads = async (options) => {
11245
11245
  // Use dynamic import to break circular dependency
11246
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-DdSwst2x.js'); });
11246
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-Dt-3g6eW.js'); });
11247
11247
  const { getPublishUploads } = getPublishUploadsMod;
11248
- return await getPublishUploads(this);
11248
+ return await getPublishUploads(this, [], undefined, options);
11249
11249
  };
11250
11250
  this.getPublishPayload = async (uploadedTransactions, options) => {
11251
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-h_Rz8nVX.js'); });
11251
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DHNfV-GE.js'); });
11252
11252
  const { getPublishPayload } = getPublishPayloadMod;
11253
11253
  return await getPublishPayload(this, uploadedTransactions, options);
11254
11254
  };
@@ -12448,7 +12448,7 @@ class Item {
12448
12448
  * Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
12449
12449
  */
12450
12450
  async destroy() {
12451
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-gfm5thj7.js'); });
12451
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-CC_YF-XC.js'); });
12452
12452
  await assertItemOwned(this);
12453
12453
  const context = this._getSnapshotContext();
12454
12454
  const cacheKey = context.seedUid || context.seedLocalId;
@@ -16623,7 +16623,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
16623
16623
  // Lazy import cache for ModelProperty to avoid circular dependency
16624
16624
  // Eagerly start loading to minimize delay on first access
16625
16625
  let ModelPropertyClass = null;
16626
- const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-Cuj839nX.js'); })
16626
+ const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-m4dACdoX.js'); })
16627
16627
  .then(module => {
16628
16628
  ModelPropertyClass = module.ModelProperty;
16629
16629
  return ModelPropertyClass;
@@ -16640,7 +16640,7 @@ function getModelProperty() {
16640
16640
  }
16641
16641
  // Lazy import cache for Schema to avoid circular dependency
16642
16642
  let SchemaClass = null;
16643
- const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-TFe24NNG.js'); })
16643
+ const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-DlSTkGtE.js'); })
16644
16644
  .then(module => {
16645
16645
  SchemaClass = module.Schema;
16646
16646
  return SchemaClass;
@@ -18594,7 +18594,7 @@ class Db extends BaseDb {
18594
18594
  // You can inspect what will happen before applying
18595
18595
  await apply();
18596
18596
  this.db = db;
18597
- const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-BiXK4hT1.js'); });
18597
+ const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-gyFrK_ny.js'); });
18598
18598
  await backfillMetadataPropertyIds();
18599
18599
  return this.db;
18600
18600
  }
@@ -19241,7 +19241,7 @@ const getTsImport = async (filePath) => {
19241
19241
 
19242
19242
  // Get the directory of this file to resolve relative paths
19243
19243
  // @ts-ignore - rollup plugin-typescript doesn't recognize import.meta with module: "preserve"
19244
- const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-pyKmk9hA.js', document.baseURI).href)));
19244
+ const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs/index-CHrEZZ71.js', document.baseURI).href)));
19245
19245
  path.dirname(__filename$1);
19246
19246
  const commandExists = (command) => {
19247
19247
  try {
@@ -19816,4 +19816,4 @@ exports.versions = versions;
19816
19816
  exports.waitForEntityIdle = waitForEntityIdle;
19817
19817
  exports.withSeed = withSeed;
19818
19818
  exports.writeProcessMachine = writeProcessMachine;
19819
- //# sourceMappingURL=index-pyKmk9hA.js.map
19819
+ //# sourceMappingURL=index-CHrEZZ71.js.map