@seedprotocol/sdk 0.4.26 → 0.4.27

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 (100) hide show
  1. package/dist/{ArweaveClient-KF_T3NSr.js → ArweaveClient-BeW65rGS.js} +3 -3
  2. package/dist/{ArweaveClient-KF_T3NSr.js.map → ArweaveClient-BeW65rGS.js.map} +1 -1
  3. package/dist/{ArweaveClient-DoBABTLW.js → ArweaveClient-lm4d-WFB.js} +3 -3
  4. package/dist/{ArweaveClient-DoBABTLW.js.map → ArweaveClient-lm4d-WFB.js.map} +1 -1
  5. package/dist/{Db-Cg7Q5gIc.js → Db-CbS7T1_D.js} +4 -4
  6. package/dist/{Db-Cg7Q5gIc.js.map → Db-CbS7T1_D.js.map} +1 -1
  7. package/dist/{Db-DA_e7Jcc.js → Db-VYLhDCFW.js} +4 -4
  8. package/dist/{Db-DA_e7Jcc.js.map → Db-VYLhDCFW.js.map} +1 -1
  9. package/dist/{EasClient-B4VivHxM.js → EasClient-BsdrEbha.js} +2 -2
  10. package/dist/{EasClient-B4VivHxM.js.map → EasClient-BsdrEbha.js.map} +1 -1
  11. package/dist/{EasClient-CVPHYGNP.js → EasClient-McZ-yLnh.js} +2 -2
  12. package/dist/{EasClient-CVPHYGNP.js.map → EasClient-McZ-yLnh.js.map} +1 -1
  13. package/dist/{FileManager-BOxbzROS.js → FileManager-8X0RFG8j.js} +39 -6
  14. package/dist/FileManager-8X0RFG8j.js.map +1 -0
  15. package/dist/{FileManager-Ba5BCbCL.js → FileManager-wXAlwkmU.js} +2 -2
  16. package/dist/{FileManager-Ba5BCbCL.js.map → FileManager-wXAlwkmU.js.map} +1 -1
  17. package/dist/{ModelProperty-D6JLRqQW.js → ModelProperty-e1IIoSSC.js} +17 -17
  18. package/dist/{ModelProperty-D6JLRqQW.js.map → ModelProperty-e1IIoSSC.js.map} +1 -1
  19. package/dist/{PathResolver-D7WqjJCo.js → PathResolver-CCuiAvIu.js} +2 -2
  20. package/dist/{PathResolver-D7WqjJCo.js.map → PathResolver-CCuiAvIu.js.map} +1 -1
  21. package/dist/{PathResolver-DHTAlCzo.js → PathResolver-C_AdI9lp.js} +2 -2
  22. package/dist/{PathResolver-DHTAlCzo.js.map → PathResolver-C_AdI9lp.js.map} +1 -1
  23. package/dist/{QueryClient-B12y2daD.js → QueryClient-BCuLIB8_.js} +2 -2
  24. package/dist/{QueryClient-B12y2daD.js.map → QueryClient-BCuLIB8_.js.map} +1 -1
  25. package/dist/{QueryClient-BCxuWg7f.js → QueryClient-F2a7YH_K.js} +2 -2
  26. package/dist/{QueryClient-BCxuWg7f.js.map → QueryClient-F2a7YH_K.js.map} +1 -1
  27. package/dist/{Schema-B5_B8nM5.js → Schema-3_R_m7fn.js} +22 -22
  28. package/dist/{Schema-B5_B8nM5.js.map → Schema-3_R_m7fn.js.map} +1 -1
  29. package/dist/{SchemaValidationService-DXYRdSYa.js → SchemaValidationService-BAPhc_z8.js} +2 -2
  30. package/dist/{SchemaValidationService-DXYRdSYa.js.map → SchemaValidationService-BAPhc_z8.js.map} +1 -1
  31. package/dist/{backfillMetadataPropertyIds-BWEhAJPS.js → backfillMetadataPropertyIds-pnhgDwmf.js} +2 -2
  32. package/dist/{backfillMetadataPropertyIds-BWEhAJPS.js.map → backfillMetadataPropertyIds-pnhgDwmf.js.map} +1 -1
  33. package/dist/cjs/{ModelProperty-Ov1_YL9l.js → ModelProperty-B_wtA6Tp.js} +17 -17
  34. package/dist/cjs/{ModelProperty-Ov1_YL9l.js.map → ModelProperty-B_wtA6Tp.js.map} +1 -1
  35. package/dist/cjs/{Schema-CeG5iRX_.js → Schema-DycmdXix.js} +20 -20
  36. package/dist/cjs/{Schema-CeG5iRX_.js.map → Schema-DycmdXix.js.map} +1 -1
  37. package/dist/cjs/{SchemaValidationService-C8mdrNnp.js → SchemaValidationService-CutWcs3L.js} +2 -2
  38. package/dist/cjs/{SchemaValidationService-C8mdrNnp.js.map → SchemaValidationService-CutWcs3L.js.map} +1 -1
  39. package/dist/cjs/{backfillMetadataPropertyIds-LDYghZxU.js → backfillMetadataPropertyIds-BtL7WeI5.js} +2 -2
  40. package/dist/cjs/{backfillMetadataPropertyIds-LDYghZxU.js.map → backfillMetadataPropertyIds-BtL7WeI5.js.map} +1 -1
  41. package/dist/cjs/{getItem-CW3BFytl.js → getItem-B1qXuyLl.js} +2 -2
  42. package/dist/cjs/{getItem-CW3BFytl.js.map → getItem-B1qXuyLl.js.map} +1 -1
  43. package/dist/cjs/{getPublishPayload-C0hWIYCX.js → getPublishPayload-DGtDyXfX.js} +11 -11
  44. package/dist/cjs/{getPublishPayload-C0hWIYCX.js.map → getPublishPayload-DGtDyXfX.js.map} +1 -1
  45. package/dist/cjs/{getPublishUploads-CMpPR2JJ.js → getPublishUploads-BMVJ2gfR.js} +4 -4
  46. package/dist/cjs/{getPublishUploads-CMpPR2JJ.js.map → getPublishUploads-BMVJ2gfR.js.map} +1 -1
  47. package/dist/cjs/{getSegmentedItemProperties-B4ao_B1Q.js → getSegmentedItemProperties-V0HYWzgM.js} +3 -3
  48. package/dist/cjs/{getSegmentedItemProperties-B4ao_B1Q.js.map → getSegmentedItemProperties-V0HYWzgM.js.map} +1 -1
  49. package/dist/cjs/{index-Far6-WGM.js → index-C0v35eOT.js} +42 -43
  50. package/dist/cjs/index-C0v35eOT.js.map +1 -0
  51. package/dist/cjs/{index-Dty7eE10.js → index-Dbu8yrzO.js} +3 -3
  52. package/dist/cjs/index-Dbu8yrzO.js.map +1 -0
  53. package/dist/cjs/{ownership-TCXiKRY_.js → ownership-BPK6LY7d.js} +2 -2
  54. package/dist/cjs/{ownership-TCXiKRY_.js.map → ownership-BPK6LY7d.js.map} +1 -1
  55. package/dist/cjs/{property-BT7i8Tl-.js → property-Ctv4ZGoa.js} +4 -4
  56. package/dist/cjs/{property-BT7i8Tl-.js.map → property-Ctv4ZGoa.js.map} +1 -1
  57. package/dist/cjs/{syncDbWithEas-DUi78csI.js → syncDbWithEas-DgZ7Acmb.js} +5 -5
  58. package/dist/cjs/{syncDbWithEas-DUi78csI.js.map → syncDbWithEas-DgZ7Acmb.js.map} +1 -1
  59. package/dist/{getItem-D5_bPYyC.js → getItem-2pjRoJa0.js} +2 -2
  60. package/dist/{getItem-D5_bPYyC.js.map → getItem-2pjRoJa0.js.map} +1 -1
  61. package/dist/{getPublishPayload-DEdHgrgC.js → getPublishPayload-BAPoXumQ.js} +11 -11
  62. package/dist/{getPublishPayload-DEdHgrgC.js.map → getPublishPayload-BAPoXumQ.js.map} +1 -1
  63. package/dist/{getPublishUploads-CH72lAID.js → getPublishUploads-D75w3Et5.js} +4 -4
  64. package/dist/{getPublishUploads-CH72lAID.js.map → getPublishUploads-D75w3Et5.js.map} +1 -1
  65. package/dist/{getSegmentedItemProperties-Cp92QUHQ.js → getSegmentedItemProperties-BLU_UBYI.js} +3 -3
  66. package/dist/{getSegmentedItemProperties-Cp92QUHQ.js.map → getSegmentedItemProperties-BLU_UBYI.js.map} +1 -1
  67. package/dist/{index-Bp0ChnQr.js → index-CKY29lZp.js} +2 -2
  68. package/dist/index-CKY29lZp.js.map +1 -0
  69. package/dist/{index-DB3nZ0lK.js → index-CjrqUOwu.js} +3 -3
  70. package/dist/index-CjrqUOwu.js.map +1 -0
  71. package/dist/{index-18lln0cM.js → index-DKXcFcFk.js} +56 -57
  72. package/dist/index-DKXcFcFk.js.map +1 -0
  73. package/dist/main.cjs +1 -1
  74. package/dist/main.js +13 -13
  75. package/dist/node.js +10 -10
  76. package/dist/{ownership-D-KsIkxM.js → ownership-BbSCKuz4.js} +2 -2
  77. package/dist/{ownership-D-KsIkxM.js.map → ownership-BbSCKuz4.js.map} +1 -1
  78. package/dist/{property-DViA9nga.js → property-D0iZYPNc.js} +5 -5
  79. package/dist/{property-DViA9nga.js.map → property-D0iZYPNc.js.map} +1 -1
  80. package/dist/{queries-ANFHy2e0.js → queries-D4DDYMy9.js} +2 -2
  81. package/dist/{queries-ANFHy2e0.js.map → queries-D4DDYMy9.js.map} +1 -1
  82. package/dist/src/browser/db/Db.d.ts.map +1 -1
  83. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  84. package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
  85. package/dist/src/vite/index.d.ts.map +1 -1
  86. package/dist/{syncDbWithEas-m-_3Ds7d.js → syncDbWithEas-D3gGL9OM.js} +6 -6
  87. package/dist/{syncDbWithEas-m-_3Ds7d.js.map → syncDbWithEas-D3gGL9OM.js.map} +1 -1
  88. package/dist/{updateSeedRevokedAt-BvAK-Rfh.js → updateSeedRevokedAt-DrtFzF85.js} +2 -2
  89. package/dist/{updateSeedRevokedAt-BvAK-Rfh.js.map → updateSeedRevokedAt-DrtFzF85.js.map} +1 -1
  90. package/dist/vite.cjs +15 -1
  91. package/dist/vite.cjs.map +1 -1
  92. package/dist/vite.js +15 -1
  93. package/dist/vite.js.map +1 -1
  94. package/package.json +3 -4
  95. package/dist/FileManager-BOxbzROS.js.map +0 -1
  96. package/dist/cjs/index-Dty7eE10.js.map +0 -1
  97. package/dist/cjs/index-Far6-WGM.js.map +0 -1
  98. package/dist/index-18lln0cM.js.map +0 -1
  99. package/dist/index-Bp0ChnQr.js.map +0 -1
  100. package/dist/index-DB3nZ0lK.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"getPublishUploads-CMpPR2JJ.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'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq } from 'drizzle-orm'\nimport { ModelPropertyDataTypes } from '@/helpers/property'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n /** When true, do not recurse into relation properties (phase 2 must not re-upload related items). */\n skipRelationRecursion?: boolean\n}\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n additionalTags?: TransactionTag[],\n): Promise<ArweaveTransaction> => {\n const tags: TransactionTag[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n if (additionalTags?.length) {\n tags.push(...additionalTags)\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nfunction decodeDataUriImage(dataUri: string): { mimeType: string; bytes: Uint8Array } | null {\n const m = DATA_URI_IMAGE.exec((dataUri ?? '').trim())\n if (!m) return null\n try {\n const mimeType = m[1]!.toLowerCase().trim()\n const base64 = m[2]!.replace(/\\s/g, '')\n const binary = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))\n return { mimeType, bytes: binary }\n } catch {\n return null\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n) => {\n const uploads: PublishUpload[] = []\n const extra = options?.arweaveUploadTags\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (dataType === ModelPropertyDataTypes.Html) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n extra,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\nasync function appendCoPublishedImageUploads(\n item: IItem<any>,\n uploads: PublishUpload[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || options?.onlyHtmlStorageSeedLocalIds?.length) return uploads\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n const seen = new Set(uploads.map((u) => u.seedLocalId))\n\n for (const row of rows) {\n if (seen.has(row.imageSeedLocalId)) continue\n const imageItem = await Item.find({ seedLocalId: row.imageSeedLocalId, modelName: 'Image' })\n if (!imageItem) continue\n const st =\n imageItem.internalProperties['storageTransactionId'] ??\n imageItem.allProperties['storageTransactionId']\n const stSnap = st?.getService().getSnapshot()\n const stCtx = stSnap && 'context' in stSnap ? stSnap.context : undefined\n const stValue = typeof (stCtx as { propertyValue?: unknown } | undefined)?.propertyValue === 'string'\n ? ((stCtx as { propertyValue?: string }).propertyValue ?? '')\n : ''\n const decoded = decodeDataUriImage(stValue)\n\n const more: PublishUpload[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n const contentHash = await getContentHash(decoded.bytes)\n const transaction = await prepareArweaveTransaction(\n decoded.bytes,\n contentHash,\n decoded.mimeType,\n options?.arweaveUploadTags,\n )\n more.push({\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n transactionToSign: transaction,\n })\n }\n for (const u of more) {\n if (!seen.has(u.seedLocalId)) {\n uploads.push(u)\n seen.add(u.seedLocalId)\n }\n }\n }\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\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 const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n if (!relatedItemProperty && options?.onlyHtmlStorageSeedLocalIds?.length) {\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n return uploads\n }\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 if (!relatedItemProperty && !options?.onlyHtmlStorageSeedLocalIds?.length) {\n uploads = await appendCoPublishedImageUploads(item, uploads, options)\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\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 uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options)\n }\n\n return uploads\n}\n"],"names":["BaseArweaveClient","BaseFileManager","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","ModelPropertyDataTypes","getContentHash","BaseDb","htmlEmbeddedImageCoPublish","eq","Item","getSegmentedItemProperties"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAiBtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,GAAG,EAAE,YAAY;CAClB;AAED,MAAM,mBAAmB,GAAG,CAAC,cAAsB,KAAwB;AACzE,IAAA,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE;AAC1D,IAAA,OAAO,GAAG,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS;AACjD,CAAC;AAED,MAAM,YAAY,GAAG,OAAO,IAAmB,KAAyB;IACtE,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,EAAE;QACvD,OAAO,IAAI,UAAU,CAAC,MAAM,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,EAAE,OAAO,EAAE,OAAO,CAAC;IACvE;AAEA,IAAA,IAAI,OAAO,EAAE,qBAAqB,EAAE;AAClC,QAAA,OAAO,OAAO;IAChB;AAEA,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,GAAGR,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,MAAMM,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
+ {"version":3,"file":"getPublishUploads-BMVJ2gfR.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'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { eq } from 'drizzle-orm'\nimport { ModelPropertyDataTypes } from '@/helpers/property'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n /** When true, do not recurse into relation properties (phase 2 must not re-upload related items). */\n skipRelationRecursion?: boolean\n}\n\nconst EXTENSION_TO_MIME: Record<string, string> = {\n png: 'image/png',\n jpg: 'image/jpeg',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n webp: 'image/webp',\n svg: 'image/svg+xml',\n html: 'text/html',\n htm: 'text/html',\n json: 'application/json',\n txt: 'text/plain',\n}\n\nconst getMimeTypeFromPath = (filePathOrName: string): string | undefined => {\n const ext = filePathOrName.split('.').pop()?.toLowerCase()\n return ext ? EXTENSION_TO_MIME[ext] : undefined\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\nexport const prepareArweaveTransaction = async (\n data: string | Uint8Array,\n contentHash: string | undefined,\n contentType?: string,\n additionalTags?: TransactionTag[],\n): Promise<ArweaveTransaction> => {\n const tags: TransactionTag[] = []\n if (contentHash) {\n tags.push({ name: 'Content-SHA-256', value: contentHash })\n logger('contentHash', contentHash)\n logger('adding content hash tag')\n }\n if (contentType) {\n tags.push({ name: 'Content-Type', value: contentType })\n }\n if (additionalTags?.length) {\n tags.push(...additionalTags)\n }\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\n\nconst getStorageDirForDataType = (dataType: string): string => {\n switch (dataType) {\n case 'Image':\n return BaseFileManager.getFilesPath('images')\n case 'File':\n return BaseFileManager.getFilesPath('files')\n case 'Html':\n return BaseFileManager.getFilesPath('html')\n case 'Json':\n return BaseFileManager.getFilesPath('json')\n default:\n return BaseFileManager.getFilesPath('images')\n }\n}\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nfunction decodeDataUriImage(dataUri: string): { mimeType: string; bytes: Uint8Array } | null {\n const m = DATA_URI_IMAGE.exec((dataUri ?? '').trim())\n if (!m) return null\n try {\n const mimeType = m[1]!.toLowerCase().trim()\n const base64 = m[2]!.replace(/\\s/g, '')\n const binary = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))\n return { mimeType, bytes: binary }\n } catch {\n return null\n }\n}\n\nconst getStorageSeedUploads = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n) => {\n const uploads: PublishUpload[] = []\n const extra = options?.arweaveUploadTags\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (dataType === ModelPropertyDataTypes.Html) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const fileBuffer = await BaseFileManager.readFileAsBuffer(filePath)\n const fileContents = await toUint8Array(fileBuffer)\n\n const contentHash = await getContentHash(fileContents)\n const contentType = getMimeTypeFromPath(refResolvedValue)\n\n const transaction = await prepareArweaveTransaction(\n fileContents,\n contentHash,\n contentType,\n extra,\n )\n\n uploads.push({\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n transactionToSign: transaction,\n })\n }\n\n return uploads\n}\n\nasync function appendCoPublishedImageUploads(\n item: IItem<any>,\n uploads: PublishUpload[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || options?.onlyHtmlStorageSeedLocalIds?.length) return uploads\n\n const rows = await appDb\n .select()\n .from(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, item.seedLocalId))\n\n const seen = new Set(uploads.map((u) => u.seedLocalId))\n\n for (const row of rows) {\n if (seen.has(row.imageSeedLocalId)) continue\n const imageItem = await Item.find({ seedLocalId: row.imageSeedLocalId, modelName: 'Image' })\n if (!imageItem) continue\n const st =\n imageItem.internalProperties['storageTransactionId'] ??\n imageItem.allProperties['storageTransactionId']\n const stSnap = st?.getService().getSnapshot()\n const stCtx = stSnap && 'context' in stSnap ? stSnap.context : undefined\n const stValue = typeof (stCtx as { propertyValue?: unknown } | undefined)?.propertyValue === 'string'\n ? ((stCtx as { propertyValue?: string }).propertyValue ?? '')\n : ''\n const decoded = decodeDataUriImage(stValue)\n\n const more: PublishUpload[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n const contentHash = await getContentHash(decoded.bytes)\n const transaction = await prepareArweaveTransaction(\n decoded.bytes,\n contentHash,\n decoded.mimeType,\n options?.arweaveUploadTags,\n )\n more.push({\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n transactionToSign: transaction,\n })\n }\n for (const u of more) {\n if (!seen.has(u.seedLocalId)) {\n uploads.push(u)\n seen.add(u.seedLocalId)\n }\n }\n }\n return uploads\n}\n\nexport type UploadProperty = {\n itemProperty: IItemProperty<any>\n childProperties: IItemProperty<any>[]\n}\ntype ChildUploadData = {\n propertyName: string\n localStoragePath: string\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present).\n * Does not create Arweave transactions or hit the network — use for routing (e.g. skip EAS-only)\n * when {@link getPublishUploads} would fail early (e.g. gateway unreachable during tx creation).\n */\nasync function storageSeedHasUploadCandidates(\n itemStorageSeedProperties: IItemProperty<any>[],\n): Promise<boolean> {\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n if (await BaseFileManager.pathExists(filePath)) {\n return true\n }\n }\n\n return false\n}\n\nasync function uploadPropertyWouldUpload(\n uploadProperty: UploadProperty,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const filePath = childProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n continue\n }\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n if (childUploads.length > 0) {\n return true\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\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 const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n if (!relatedItemProperty && options?.onlyHtmlStorageSeedLocalIds?.length) {\n const storageSeedUploads = await getStorageSeedUploads(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n return uploads\n }\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 if (!relatedItemProperty && !options?.onlyHtmlStorageSeedLocalIds?.length) {\n uploads = await appendCoPublishedImageUploads(item, uploads, options)\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\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 uploads = await getPublishUploads(relatedItem, uploads, relationProperty, options)\n }\n\n return uploads\n}\n"],"names":["BaseArweaveClient","BaseFileManager","resolveSeedIdsFromRefString","normalizeRelationPropertyValue","ModelPropertyDataTypes","getContentHash","BaseDb","htmlEmbeddedImageCoPublish","eq","Item","getSegmentedItemProperties"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,MAAM,GAAG,KAAK,CAAC,gCAAgC,CAAC;AAiBtD,MAAM,iBAAiB,GAA2B;AAChD,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,GAAG,EAAE,YAAY;CAClB;AAED,MAAM,mBAAmB,GAAG,CAAC,cAAsB,KAAwB;AACzE,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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-Far6-WGM.js');
5
- var property = require('./property-BT7i8Tl-.js');
4
+ var main_cjs = require('./index-C0v35eOT.js');
5
+ var property = require('./property-Ctv4ZGoa.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-B4ao_B1Q.js.map
147
+ //# sourceMappingURL=getSegmentedItemProperties-V0HYWzgM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSegmentedItemProperties-B4ao_B1Q.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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version":3,"file":"getSegmentedItemProperties-V0HYWzgM.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;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AEA,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;;;;"}
@@ -61,10 +61,9 @@ class BaseDb {
61
61
  this.PlatformClass = platformClass;
62
62
  }
63
63
  static getAppDb() {
64
- if (!this.PlatformClass) {
65
- return undefined;
66
- }
67
- return this.PlatformClass.getAppDb();
64
+ const _pc = this.PlatformClass;
65
+ const _db = _pc ? _pc.getAppDb() : undefined;
66
+ return _db;
68
67
  }
69
68
  static prepareDb(filesDir) {
70
69
  return this.PlatformClass.prepareDb(filesDir);
@@ -2249,7 +2248,7 @@ const createPropertyInstances = async (propertyFileIds) => {
2249
2248
  return;
2250
2249
  }
2251
2250
  try {
2252
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Ov1_YL9l.js'); });
2251
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B_wtA6Tp.js'); });
2253
2252
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
2254
2253
  if (!ModelProperty) {
2255
2254
  logger$y('createPropertyInstances: ModelProperty not available from dynamic import');
@@ -2433,7 +2432,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
2433
2432
  // Step 2: Fallback to Schema context (only if database doesn't have the model)
2434
2433
  // This handles the case where model exists in schema file but not yet in database
2435
2434
  try {
2436
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
2435
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
2437
2436
  const { Schema } = schemaMod;
2438
2437
  const schema = Schema.create(schemaName, { waitForReady: false });
2439
2438
  const schemaSnapshot = schema.getService().getSnapshot();
@@ -2677,7 +2676,7 @@ const loadOrCreateModel = xstate.fromCallback(({ sendBack, input: { context } })
2677
2676
  }
2678
2677
  // Mark schema as draft when a new model is created so saveNewVersion() can persist it
2679
2678
  try {
2680
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
2679
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
2681
2680
  const { Schema } = schemaMod;
2682
2681
  const schema = Schema.create(schemaName, { waitForReady: false });
2683
2682
  schema.getService().send({ type: 'markAsDraft', propertyKey: 'schema:models' });
@@ -2721,10 +2720,10 @@ const validateModel = xstate.fromCallback(({ sendBack, input: { context } }) =>
2721
2720
  const _validateModel = async () => {
2722
2721
  try {
2723
2722
  // Use dynamic imports to break circular dependencies
2724
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
2723
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
2725
2724
  const { SchemaValidationService } = validationServiceMod;
2726
2725
  const validationService = new SchemaValidationService();
2727
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
2726
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
2728
2727
  const { Schema } = schemaMod;
2729
2728
  // Validate model structure
2730
2729
  const structureResult = validationService.validateModelStructure(context);
@@ -2834,7 +2833,7 @@ const createModelProperties = xstate.fromCallback(({ sendBack, input }) => {
2834
2833
  return;
2835
2834
  }
2836
2835
  logger$w(`Creating ${Object.keys(propertyDefinitions).length} properties for model "${modelName}" (id: ${_dbId})`);
2837
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Ov1_YL9l.js'); });
2836
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B_wtA6Tp.js'); });
2838
2837
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
2839
2838
  if (!ModelProperty) {
2840
2839
  logger$w('ModelProperty not available from dynamic import');
@@ -2938,7 +2937,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2938
2937
  const structureMsg = `[validateEntity] Validating model structure`;
2939
2938
  logger$v(structureMsg);
2940
2939
  // Use existing Model validation
2941
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
2940
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
2942
2941
  const { SchemaValidationService } = validationServiceMod;
2943
2942
  const validationService = new SchemaValidationService();
2944
2943
  // Validate model structure
@@ -2956,7 +2955,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2956
2955
  if (entityInput.entityData.schemaName) {
2957
2956
  try {
2958
2957
  logger$v(`[validateEntity] Validating model against schema "${entityInput.entityData.schemaName}"`);
2959
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
2958
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
2960
2959
  const { Schema } = schemaMod;
2961
2960
  const schema = Schema.create(entityInput.entityData.schemaName, {
2962
2961
  waitForReady: false,
@@ -2992,7 +2991,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
2992
2991
  }
2993
2992
  else if (entityInput.entityType === 'modelProperty') {
2994
2993
  // Use existing ModelProperty validation
2995
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
2994
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
2996
2995
  const { SchemaValidationService } = validationServiceMod;
2997
2996
  const validationService = new SchemaValidationService();
2998
2997
  // Validate property structure
@@ -3007,7 +3006,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
3007
3006
  // If schema name and model name provided, validate against schema
3008
3007
  if (entityInput.entityData._schemaName && entityInput.entityData.modelName) {
3009
3008
  try {
3010
- const schemaMod = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
3009
+ const schemaMod = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
3011
3010
  const { Schema } = schemaMod;
3012
3011
  const schema = Schema.create(entityInput.entityData._schemaName, {
3013
3012
  waitForReady: false,
@@ -3036,7 +3035,7 @@ const validateEntity = xstate.fromPromise(async ({ input }) => {
3036
3035
  }
3037
3036
  else if (entityInput.entityType === 'schema') {
3038
3037
  // Schema validation - use existing validation
3039
- const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
3038
+ const validationServiceMod = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
3040
3039
  const { SchemaValidationService } = validationServiceMod;
3041
3040
  const validationService = new SchemaValidationService();
3042
3041
  const schemaResult = validationService.validateSchema(entityInput.entityData);
@@ -4988,7 +4987,7 @@ const writeToDatabase = xstate.fromCallback(({ sendBack, input }) => {
4988
4987
  // initial write completes is not overwritten by the stale requestWrite payload.
4989
4988
  let dataToWrite = input.entityData;
4990
4989
  try {
4991
- const mod = await Promise.resolve().then(function () { return require('./ModelProperty-Ov1_YL9l.js'); });
4990
+ const mod = await Promise.resolve().then(function () { return require('./ModelProperty-B_wtA6Tp.js'); });
4992
4991
  const ModelProperty = mod?.ModelProperty ?? mod?.default;
4993
4992
  if (ModelProperty && typeof ModelProperty.getById === 'function') {
4994
4993
  const instance = ModelProperty.getById(input.entityId);
@@ -5368,7 +5367,7 @@ const modelMachine = xstate.setup({
5368
5367
  // Create ModelProperty instances for any new property IDs
5369
5368
  if (Array.isArray(newPropertyIds) && newPropertyIds.length > 0) {
5370
5369
  // Import and create instances asynchronously (fire-and-forget)
5371
- Promise.resolve().then(function () { return require('./ModelProperty-Ov1_YL9l.js'); }).then(({ ModelProperty }) => {
5370
+ Promise.resolve().then(function () { return require('./ModelProperty-B_wtA6Tp.js'); }).then(({ ModelProperty }) => {
5372
5371
  const createPromises = newPropertyIds.map(async (propertyFileId) => {
5373
5372
  try {
5374
5373
  const property = await ModelProperty.createById(propertyFileId);
@@ -6749,7 +6748,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
6749
6748
  const schemaNameToTry = model$1?.schemaName;
6750
6749
  if (schemaNameToTry) {
6751
6750
  try {
6752
- const { Schema } = await Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); });
6751
+ const { Schema } = await Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); });
6753
6752
  const schemaInstance = Schema.create(schemaNameToTry, { waitForReady: false });
6754
6753
  const schemaContext = schemaInstance.getService().getSnapshot().context;
6755
6754
  if (schemaContext.models?.[modelName]?.properties) {
@@ -6798,7 +6797,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
6798
6797
  }
6799
6798
  }
6800
6799
  if (Object.keys(propertySchemas).length === 0) {
6801
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
6800
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
6802
6801
  const { ModelPropertyDataTypes } = schemaMod;
6803
6802
  const KNOWN_MODEL_FALLBACKS = {
6804
6803
  Post: {
@@ -6845,7 +6844,7 @@ const createItemPropertyInstances = async (metadataRows, seedLocalId, seedUid, m
6845
6844
  // Infer propertyRecordSchema from metadata when schema is missing (enables persistence)
6846
6845
  let propSchema = propertySchemas[propertyName];
6847
6846
  if (!propSchema && isRefTypeFromMeta) {
6848
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
6847
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
6849
6848
  const { ModelPropertyDataTypes } = schemaMod;
6850
6849
  propSchema = {
6851
6850
  dataType: refSeedType === 'html' ? ModelPropertyDataTypes.Html
@@ -7054,7 +7053,7 @@ const loadOrCreateItem = xstate.fromCallback(({ sendBack, input: { context } })
7054
7053
  // Without this, post.html returns seed ID on first render because loadOrCreateProperty hasn't finished.
7055
7054
  // Publish/attestation can keep properties in `saving` for many seconds; 5s caused timeouts during EAS work.
7056
7055
  const propertyIdleTimeoutMs = 120000;
7057
- await Promise.all(Array.from(propertyInstances.values()).map((prop) => waitForEntityIdle(prop, { timeout: propertyIdleTimeoutMs, throwOnError: false })));
7056
+ Promise.all(Array.from(propertyInstances.values()).map((prop) => waitForEntityIdle(prop, { timeout: propertyIdleTimeoutMs, throwOnError: false }))).catch(() => { });
7058
7057
  // Step 5: Return loaded item data with property instances
7059
7058
  sendBack({
7060
7059
  type: 'loadOrCreateItemSuccess',
@@ -7102,9 +7101,9 @@ const runPublish = xstate.fromCallback(({ sendBack, input: { context } }) => {
7102
7101
  sendBack({ type: 'publishError', error: new Error(`Item not found for seedLocalId: ${seedLocalId}`) });
7103
7102
  return;
7104
7103
  }
7105
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-CMpPR2JJ.js'); });
7104
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-BMVJ2gfR.js'); });
7106
7105
  const { getPublishUploads } = getPublishUploadsMod;
7107
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-C0hWIYCX.js'); });
7106
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DGtDyXfX.js'); });
7108
7107
  const { getPublishPayload } = getPublishPayloadMod;
7109
7108
  const uploads = await getPublishUploads(item);
7110
7109
  let uploadedTransactions = [];
@@ -7944,7 +7943,7 @@ const resolveRelatedValue = xstate.fromCallback(({ sendBack, input: { context }
7944
7943
  const { isRelation, propertyValue, propertyName, seedUid, propertyRecordSchema, populatedFromDb, schemaUid, } = context;
7945
7944
  const _resolveRelatedValue = async () => {
7946
7945
  // Use dynamic import to break circular dependency
7947
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
7946
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
7948
7947
  const { ModelPropertyDataTypes } = schemaMod;
7949
7948
  if (!propertyValue || !isRelation || populatedFromDb) {
7950
7949
  return;
@@ -8952,7 +8951,7 @@ const hydrateFromDb = xstate.fromCallback(({ sendBack, input: { context } }) =>
8952
8951
  // to use dynamically imported ModelPropertyDataTypes
8953
8952
  const _hydrateFromDb = async () => {
8954
8953
  // Use dynamic import to break circular dependency
8955
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
8954
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
8956
8955
  const { ModelPropertyDataTypes } = schemaMod;
8957
8956
  const appDb = BaseDb.getAppDb();
8958
8957
  const whereClauses = [];
@@ -9315,7 +9314,7 @@ const loadOrCreateProperty = xstate.fromCallback(({ sendBack, input: { context }
9315
9314
  };
9316
9315
  // Merge with schema from file/DB to get validation rules (enum, pattern, etc.) - properties table doesn't store these
9317
9316
  try {
9318
- const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-BT7i8Tl-.js'); });
9317
+ const { getPropertySchema } = await Promise.resolve().then(function () { return require('./property-Ctv4ZGoa.js'); });
9319
9318
  let schemaFromFile = await getPropertySchema(normalizedModelName, propertyName);
9320
9319
  if (!schemaFromFile?.validation) {
9321
9320
  // Fallback: get validation from schemaData in database (Schema context may not be loaded yet)
@@ -9780,9 +9779,9 @@ const analyzeInput = xstate.fromCallback(({ sendBack, input: { context, event }
9780
9779
  }
9781
9780
  const _analyzeInput = async () => {
9782
9781
  // Use dynamic import to break circular dependency
9783
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
9782
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
9784
9783
  const { ModelPropertyDataTypes } = schemaMod;
9785
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
9784
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
9786
9785
  let propertyName = propertyNameRaw;
9787
9786
  if (!propertyName) {
9788
9787
  throw new Error('propertyName is required');
@@ -9980,7 +9979,7 @@ const createMetadata = async (metadataValues, propertyRecordSchema, options) =>
9980
9979
  propertyRecordSchema?.validation &&
9981
9980
  metadataValues.propertyValue != null &&
9982
9981
  metadataValues.propertyValue !== '') {
9983
- const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-C8mdrNnp.js'); });
9982
+ const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-CutWcs3L.js'); });
9984
9983
  const validationService = new SchemaValidationService();
9985
9984
  const validationResult = validationService.validatePropertyValue(metadataValues.propertyValue, propertyRecordSchema.dataType, propertyRecordSchema.validation, propertyRecordSchema.refValueType);
9986
9985
  if (!validationResult.isValid && validationResult.errors.length > 0) {
@@ -10571,7 +10570,7 @@ const saveRelation = xstate.fromCallback(({ sendBack, input: { context, event }
10571
10570
  }
10572
10571
  const _saveRelation = async () => {
10573
10572
  // Use dynamic import to break circular dependency
10574
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
10573
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
10575
10574
  const { ModelPropertyDataTypes } = schemaMod;
10576
10575
  if (!propertyNameRaw) {
10577
10576
  throw new Error('propertyName is required');
@@ -11615,7 +11614,7 @@ class ItemProperty {
11615
11614
  return;
11616
11615
  }
11617
11616
  // Use dynamic import to break circular dependency
11618
- const schemaMod = await Promise.resolve().then(function () { return require('./index-Dty7eE10.js'); });
11617
+ const schemaMod = await Promise.resolve().then(function () { return require('./index-Dbu8yrzO.js'); });
11619
11618
  const { ModelPropertyDataTypes } = schemaMod;
11620
11619
  const { context } = snapshot;
11621
11620
  const { propertyRecordSchema } = context;
@@ -12514,7 +12513,7 @@ class ItemProperty {
12514
12513
  }
12515
12514
  async save() {
12516
12515
  const ctx = this._getSnapshotContext();
12517
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-TCXiKRY_.js'); });
12516
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-BPK6LY7d.js'); });
12518
12517
  await assertItemOwned({
12519
12518
  seedLocalId: ctx?.seedLocalId ?? undefined,
12520
12519
  seedUid: ctx?.seedUid ?? undefined,
@@ -12853,7 +12852,7 @@ class Item {
12853
12852
  });
12854
12853
  };
12855
12854
  this.unpublish = async () => {
12856
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-TCXiKRY_.js'); });
12855
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-BPK6LY7d.js'); });
12857
12856
  const { getRevokeExecutor } = await Promise.resolve().then(function () { return publishConfig; });
12858
12857
  await assertItemOwned(this);
12859
12858
  const seedUid = this.seedUid;
@@ -12877,7 +12876,7 @@ class Item {
12877
12876
  this._service.send({ type: 'updateContext', revokedAt });
12878
12877
  };
12879
12878
  this.publish = async () => {
12880
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-TCXiKRY_.js'); });
12879
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-BPK6LY7d.js'); });
12881
12880
  await assertItemOwned(this);
12882
12881
  this._service.send({ type: 'startPublish' });
12883
12882
  return new Promise((resolve, reject) => {
@@ -12913,12 +12912,12 @@ class Item {
12913
12912
  };
12914
12913
  this.getPublishUploads = async (options) => {
12915
12914
  // Use dynamic import to break circular dependency
12916
- const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-CMpPR2JJ.js'); });
12915
+ const getPublishUploadsMod = await Promise.resolve().then(function () { return require('./getPublishUploads-BMVJ2gfR.js'); });
12917
12916
  const { getPublishUploads } = getPublishUploadsMod;
12918
12917
  return await getPublishUploads(this, [], undefined, options);
12919
12918
  };
12920
12919
  this.getPublishPayload = async (uploadedTransactions, options) => {
12921
- const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-C0hWIYCX.js'); });
12920
+ const getPublishPayloadMod = await Promise.resolve().then(function () { return require('./getPublishPayload-DGtDyXfX.js'); });
12922
12921
  const { getPublishPayload } = getPublishPayloadMod;
12923
12922
  return await getPublishPayload(this, uploadedTransactions, options);
12924
12923
  };
@@ -14412,7 +14411,7 @@ class Item {
14412
14411
  * Destroy the item: soft delete in DB, remove from caches, clean up subscriptions, stop service.
14413
14412
  */
14414
14413
  async destroy() {
14415
- const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-TCXiKRY_.js'); });
14414
+ const { assertItemOwned } = await Promise.resolve().then(function () { return require('./ownership-BPK6LY7d.js'); });
14416
14415
  await assertItemOwned(this);
14417
14416
  const context = this._getSnapshotContext();
14418
14417
  const cacheKeys = Item.collectInstanceCacheKeysForInstance(this);
@@ -14568,7 +14567,7 @@ const runEasSync = xstate.fromPromise(async ({ input, }) => {
14568
14567
  requestPayload: input.requestPayload,
14569
14568
  persistedSnapshot: input.runningSnapshot,
14570
14569
  });
14571
- const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-DUi78csI.js'); });
14570
+ const { runSyncFromEas } = await Promise.resolve().then(function () { return require('./syncDbWithEas-DgZ7Acmb.js'); });
14572
14571
  try {
14573
14572
  await runSyncFromEas(toRunSyncArg(input.options));
14574
14573
  await finalizeEasSyncProcessRow(rowId, {
@@ -18183,7 +18182,7 @@ const saveDraftLogger = debug('seedSdk:model:saveDraftToDb');
18183
18182
  // Lazy import cache for ModelProperty to avoid circular dependency
18184
18183
  // Eagerly start loading to minimize delay on first access
18185
18184
  let ModelPropertyClass = null;
18186
- const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-Ov1_YL9l.js'); })
18185
+ const modelPropertyImportPromise = Promise.resolve().then(function () { return require('./ModelProperty-B_wtA6Tp.js'); })
18187
18186
  .then(module => {
18188
18187
  ModelPropertyClass = module.ModelProperty;
18189
18188
  return ModelPropertyClass;
@@ -18200,7 +18199,7 @@ function getModelProperty() {
18200
18199
  }
18201
18200
  // Lazy import cache for Schema to avoid circular dependency
18202
18201
  let SchemaClass = null;
18203
- const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-CeG5iRX_.js'); })
18202
+ const schemaImportPromise = Promise.resolve().then(function () { return require('./Schema-DycmdXix.js'); })
18204
18203
  .then(module => {
18205
18204
  SchemaClass = module.Schema;
18206
18205
  return SchemaClass;
@@ -20154,7 +20153,7 @@ class Db extends BaseDb {
20154
20153
  // You can inspect what will happen before applying
20155
20154
  await apply();
20156
20155
  this.db = db;
20157
- const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-LDYghZxU.js'); });
20156
+ const { backfillMetadataPropertyIds } = await Promise.resolve().then(function () { return require('./backfillMetadataPropertyIds-BtL7WeI5.js'); });
20158
20157
  await backfillMetadataPropertyIds();
20159
20158
  return this.db;
20160
20159
  }
@@ -20801,7 +20800,7 @@ const getTsImport = async (filePath) => {
20801
20800
 
20802
20801
  // Get the directory of this file to resolve relative paths
20803
20802
  // @ts-ignore - rollup plugin-typescript doesn't recognize import.meta with module: "preserve"
20804
- 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-Far6-WGM.js', document.baseURI).href)));
20803
+ 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-C0v35eOT.js', document.baseURI).href)));
20805
20804
  path.dirname(__filename$1);
20806
20805
  const commandExists = (command) => {
20807
20806
  try {
@@ -21399,4 +21398,4 @@ exports.versions = versions;
21399
21398
  exports.waitForEntityIdle = waitForEntityIdle;
21400
21399
  exports.withSeed = withSeed;
21401
21400
  exports.writeProcessMachine = writeProcessMachine;
21402
- //# sourceMappingURL=index-Far6-WGM.js.map
21401
+ //# sourceMappingURL=index-C0v35eOT.js.map