@seedprotocol/sdk 0.7.4-next.784.g879c6a3 → 0.7.4

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 (120) hide show
  1. package/dist/{BasePathResolver-DxdS0wJ0.js → BasePathResolver-DrzGVH9L.js} +232 -40
  2. package/dist/BasePathResolver-DrzGVH9L.js.map +1 -0
  3. package/dist/{ClientManager-De-vKHGe.js → ClientManager-Dfu4jcgm.js} +583 -219
  4. package/dist/ClientManager-Dfu4jcgm.js.map +1 -0
  5. package/dist/{Item-cq9VcsAY.js → Item-BUUFuywT.js} +175 -306
  6. package/dist/Item-BUUFuywT.js.map +1 -0
  7. package/dist/{ModelProperty-DuuoFXaC.js → ModelProperty-B6cnRvIz.js} +38 -39
  8. package/dist/ModelProperty-B6cnRvIz.js.map +1 -0
  9. package/dist/{Schema-Dc5EA8Yb.js → Schema-Bf-jOLq0.js} +37 -36
  10. package/dist/{Schema-Dc5EA8Yb.js.map → Schema-Bf-jOLq0.js.map} +1 -1
  11. package/dist/{SchemaValidationService-DViJ056F.js → SchemaValidationService-BNYMacsx.js} +7 -8
  12. package/dist/{SchemaValidationService-DViJ056F.js.map → SchemaValidationService-BNYMacsx.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-DacVthS5.js → backfillMetadataPropertyIds-C2-s_jUa.js} +4 -5
  14. package/dist/{backfillMetadataPropertyIds-DacVthS5.js.map → backfillMetadataPropertyIds-C2-s_jUa.js.map} +1 -1
  15. package/dist/{configurePlatform-DlZ23w7e.js → configurePlatform-BzfirKuM.js} +3 -4
  16. package/dist/{configurePlatform-DlZ23w7e.js.map → configurePlatform-BzfirKuM.js.map} +1 -1
  17. package/dist/{detachRowsBeforeDelete-YRSZY6dO.js → detachRowsBeforeDelete-B0Daoz9Z.js} +3 -4
  18. package/dist/{detachRowsBeforeDelete-YRSZY6dO.js.map → detachRowsBeforeDelete-B0Daoz9Z.js.map} +1 -1
  19. package/dist/{eas-D_6ptL_F.js → eas-Dq5Kx_Nd.js} +14 -32
  20. package/dist/eas-Dq5Kx_Nd.js.map +1 -0
  21. package/dist/{errors-Cl8rbtKR.js → errors-DdWbxb_n.js} +42 -39
  22. package/dist/errors-DdWbxb_n.js.map +1 -0
  23. package/dist/{getItem-BcmJcUZB.js → getItem-9bYSErSj.js} +4 -5
  24. package/dist/{getItem-BcmJcUZB.js.map → getItem-9bYSErSj.js.map} +1 -1
  25. package/dist/{getPublishPayload-C278kK9P.js → getPublishPayload-DPy-uMrR.js} +28 -29
  26. package/dist/getPublishPayload-DPy-uMrR.js.map +1 -0
  27. package/dist/{getPublishUploads-DJ1UPh7i.js → getPublishUploads-J-143iSV.js} +10 -11
  28. package/dist/{getPublishUploads-DJ1UPh7i.js.map → getPublishUploads-J-143iSV.js.map} +1 -1
  29. package/dist/{index-DAl9U4rn.js → index-7y2f_iQz.js} +2 -2
  30. package/dist/index-7y2f_iQz.js.map +1 -0
  31. package/dist/{index-CqnU-5i0.js → index-C61Rxy0F.js} +9 -10
  32. package/dist/index-C61Rxy0F.js.map +1 -0
  33. package/dist/{index.browser-J6QZ9smP.js → index.browser-C1pisOEa.js} +10 -10
  34. package/dist/{index.browser-J6QZ9smP.js.map → index.browser-C1pisOEa.js.map} +1 -1
  35. package/dist/{index.node-C9VB9NlX.js → index.node-BAlST8pD.js} +6 -6
  36. package/dist/{index.node-C9VB9NlX.js.map → index.node-BAlST8pD.js.map} +1 -1
  37. package/dist/main.js +27 -28
  38. package/dist/main.js.map +1 -1
  39. package/dist/node.js +12 -13
  40. package/dist/node.js.map +1 -1
  41. package/dist/platform.browser.js +6 -7
  42. package/dist/platform.browser.js.map +1 -1
  43. package/dist/platform.node.js +5 -6
  44. package/dist/platform.node.js.map +1 -1
  45. package/dist/{property-Brgr5RdT.js → property-zFPMtR3T.js} +10 -14
  46. package/dist/property-zFPMtR3T.js.map +1 -0
  47. package/dist/{propertyValidationRules-CDRitiiK.js → propertyValidationRules-CeFVhdQg.js} +10 -10
  48. package/dist/{propertyValidationRules-CDRitiiK.js.map → propertyValidationRules-CeFVhdQg.js.map} +1 -1
  49. package/dist/{publishDraftGraph-C37ibxb5.js → publishDraftGraph-CuVq6iAR.js} +7 -6
  50. package/dist/{publishDraftGraph-C37ibxb5.js.map → publishDraftGraph-CuVq6iAR.js.map} +1 -1
  51. package/dist/{resetAmbiguousLegacyItemData-CcLFRREE.js → resetAmbiguousLegacyItemData-DsFTnMBz.js} +5 -6
  52. package/dist/resetAmbiguousLegacyItemData-DsFTnMBz.js.map +1 -0
  53. package/dist/{resolveModelForSyncedSeed-BTAeCOJE.js → resolveModelForSyncedSeed-RUsgAZXG.js} +2 -2
  54. package/dist/{resolveModelForSyncedSeed-BTAeCOJE.js.map → resolveModelForSyncedSeed-RUsgAZXG.js.map} +1 -1
  55. package/dist/src/Item/Item.d.ts.map +1 -1
  56. package/dist/src/ItemProperty/service/propertyMachine.d.ts +4 -4
  57. package/dist/src/Model/Model.d.ts +3 -2
  58. package/dist/src/Model/Model.d.ts.map +1 -1
  59. package/dist/src/ModelProperty/ModelProperty.d.ts +1 -1
  60. package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +1 -1
  61. package/dist/src/Schema/service/schemaMachine.d.ts +2 -2
  62. package/dist/src/client/ClientManager.d.ts +6 -6
  63. package/dist/src/client/ClientManager.d.ts.map +1 -1
  64. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  65. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  66. package/dist/src/client/clientManagerMachine.d.ts +2 -2
  67. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  68. package/dist/src/db/canonicalizeModelTypes.d.ts +18 -0
  69. package/dist/src/db/canonicalizeModelTypes.d.ts.map +1 -0
  70. package/dist/src/db/read/getModelSchemas.d.ts +6 -0
  71. package/dist/src/db/read/getModelSchemas.d.ts.map +1 -1
  72. package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
  73. package/dist/src/db/read/getSchemaUidForModel.d.ts +6 -0
  74. package/dist/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
  75. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  76. package/dist/src/db/removeForeignAttestationRows.d.ts +27 -0
  77. package/dist/src/db/removeForeignAttestationRows.d.ts.map +1 -0
  78. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  79. package/dist/src/db/write/easSyncProcess.d.ts +9 -1
  80. package/dist/src/db/write/easSyncProcess.d.ts.map +1 -1
  81. package/dist/src/db/write/updateMetadata.d.ts.map +1 -1
  82. package/dist/src/eas.d.ts.map +1 -1
  83. package/dist/src/events/item/easSyncManager.d.ts.map +1 -1
  84. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  85. package/dist/src/helpers/db.d.ts +20 -0
  86. package/dist/src/helpers/db.d.ts.map +1 -1
  87. package/dist/src/helpers/index.d.ts +3 -1
  88. package/dist/src/helpers/index.d.ts.map +1 -1
  89. package/dist/src/helpers/metadataPropertyNames.d.ts +12 -0
  90. package/dist/src/helpers/metadataPropertyNames.d.ts.map +1 -1
  91. package/dist/src/helpers/retryWhenOnline.d.ts +20 -0
  92. package/dist/src/helpers/retryWhenOnline.d.ts.map +1 -0
  93. package/dist/src/imports/json.d.ts +10 -0
  94. package/dist/src/imports/json.d.ts.map +1 -1
  95. package/dist/src/index.d.ts +4 -2
  96. package/dist/src/index.d.ts.map +1 -1
  97. package/dist/src/query/createLocalQueryDataSource.d.ts.map +1 -1
  98. package/dist/src/types/import.d.ts +4 -0
  99. package/dist/src/types/import.d.ts.map +1 -1
  100. package/dist/{syncDbWithEas-B-Ho0IOB.js → syncDbWithEas-CRpnkq00.js} +157 -61
  101. package/dist/syncDbWithEas-CRpnkq00.js.map +1 -0
  102. package/dist/{tabEvents-BTzckWrN.js → tabEvents-nBUq_1u1.js} +6 -6
  103. package/dist/{tabEvents-BTzckWrN.js.map → tabEvents-nBUq_1u1.js.map} +1 -1
  104. package/dist/{tolerantWebAccess-DOm2Xv-f.js → tolerantWebAccess-DIt3R8_u.js} +7 -8
  105. package/dist/{tolerantWebAccess-DOm2Xv-f.js.map → tolerantWebAccess-DIt3R8_u.js.map} +1 -1
  106. package/dist/{updateSeedRevokedAt-IHXnJI-i.js → updateSeedRevokedAt-DtTPSzpM.js} +3 -3
  107. package/dist/{updateSeedRevokedAt-IHXnJI-i.js.map → updateSeedRevokedAt-DtTPSzpM.js.map} +1 -1
  108. package/package.json +5 -5
  109. package/dist/BasePathResolver-DxdS0wJ0.js.map +0 -1
  110. package/dist/ClientManager-De-vKHGe.js.map +0 -1
  111. package/dist/Item-cq9VcsAY.js.map +0 -1
  112. package/dist/ModelProperty-DuuoFXaC.js.map +0 -1
  113. package/dist/eas-D_6ptL_F.js.map +0 -1
  114. package/dist/errors-Cl8rbtKR.js.map +0 -1
  115. package/dist/getPublishPayload-C278kK9P.js.map +0 -1
  116. package/dist/index-CqnU-5i0.js.map +0 -1
  117. package/dist/index-DAl9U4rn.js.map +0 -1
  118. package/dist/property-Brgr5RdT.js.map +0 -1
  119. package/dist/resetAmbiguousLegacyItemData-CcLFRREE.js.map +0 -1
  120. package/dist/syncDbWithEas-B-Ho0IOB.js.map +0 -1
@@ -1,29 +1,28 @@
1
- import { N as resolveSeedIdsFromRefString, O as normalizeRelationPropertyValue, Q as isPublishedSeedRef, i as isDataType, M as ModelPropertyDataTypes, R as getStorageDirForDataType, J as BaseFileManager, E as BaseDb, o as htmlEmbeddedImageCoPublish, S as getContentSha256, U as buildArweaveContentTags, V as getItemStorageSubdir, W as getItemStorageLocalFileName, m as metadata } from './BasePathResolver-DxdS0wJ0.js';
1
+ import { N as resolveSeedIdsFromRefString, O as normalizeRelationPropertyValue, Q as isPublishedSeedRef, i as isDataType, M as ModelPropertyDataTypes, R as getStorageDirForDataType, J as BaseFileManager, E as BaseDb, o as htmlEmbeddedImageCoPublish, S as getContentSha256, U as buildArweaveContentTags, V as getItemStorageSubdir, W as getItemStorageLocalFileName, m as metadata } from './BasePathResolver-DrzGVH9L.js';
2
2
  import { BaseArweaveClient } from '@seedprotocol/arweave';
3
- import { g as getPublishDraftGraph, a as getSegmentedItemProperties } from './publishDraftGraph-C37ibxb5.js';
3
+ import { g as getPublishDraftGraph, a as getSegmentedItemProperties } from './publishDraftGraph-CuVq6iAR.js';
4
4
  import debug from 'debug';
5
- import { I as Item, c as compareMetadataRowsLatestFirst } from './Item-cq9VcsAY.js';
5
+ import { I as Item, c as compareMetadataRowsLatestFirst } from './Item-BUUFuywT.js';
6
6
  import { eq, and } from 'drizzle-orm';
7
7
  import 'pluralize';
8
- import { r as resolveUploadMimeType } from './mimeTypes-DHAHC4eZ.js';
9
- import { i as isVerbatimItemStorageDraftRow, c as convertVerbatimItemStorageRow } from './ClientManager-De-vKHGe.js';
10
8
  import '@seedprotocol/eas';
9
+ import { r as resolveUploadMimeType } from './mimeTypes-DHAHC4eZ.js';
10
+ import { i as isVerbatimItemStorageDraftRow, c as convertVerbatimItemStorageRow } from './ClientManager-Dfu4jcgm.js';
11
11
  import 'xstate';
12
12
  import '@sinclair/typebox';
13
13
  import 'drizzle-orm/sqlite-core';
14
- import 'drizzle-orm/casing';
15
- import 'lodash-es';
16
14
  import 'nanoid';
17
15
  import 'nanoid-dictionary';
18
16
  import '@seedprotocol/query';
19
17
  import '@noble/hashes/sha256';
20
18
  import '@noble/hashes/sha3';
21
19
  import '@noble/hashes/utils';
22
- import './errors-Cl8rbtKR.js';
20
+ import 'lodash-es';
21
+ import './errors-DdWbxb_n.js';
23
22
  import './model-oHA3YhOd.js';
24
- import './property-Brgr5RdT.js';
23
+ import './property-zFPMtR3T.js';
25
24
  import 'rxjs';
26
- import './tabEvents-BTzckWrN.js';
25
+ import './tabEvents-nBUq_1u1.js';
27
26
 
28
27
  /**
29
28
  * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.
@@ -645,4 +644,4 @@ const getPublishUploads = async (item, uploads = [], relatedItemProperty, option
645
644
  };
646
645
 
647
646
  export { CREATE_TRANSACTION_CONCURRENCY, getPublishUploadData, getPublishUploads, itemHasPublishUploadCandidates, resolveItemStorageChildFile };
648
- //# sourceMappingURL=getPublishUploads-DJ1UPh7i.js.map
647
+ //# sourceMappingURL=getPublishUploads-J-143iSV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPublishUploads-DJ1UPh7i.js","sources":["../../src/helpers/mapWithConcurrency.ts","../../src/helpers/compositeUpload.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["/**\n * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.\n * Rejects with the first error (by time); after that no new calls start, though calls already in\n * flight run to completion.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n const workerCount = Math.max(1, Math.min(Math.floor(limit) || 1, items.length))\n let next = 0\n let failed = false\n\n const worker = async (): Promise<void> => {\n while (!failed && next < items.length) {\n const index = next++\n try {\n results[index] = await fn(items[index]!, index)\n } catch (error) {\n failed = true\n throw error\n }\n }\n }\n\n await Promise.all(Array.from({ length: workerCount }, worker))\n return results\n}\n","/**\n * Composite uploads: several ItemStorage files of one item in a single Arweave transaction.\n *\n * Producer: `getPublishUploads.ts` (`processUploadPropertyData`), for an item with a\n * `storageTransactionId` property and ItemStorage properties (e.g. a Post's `html` and `json`).\n * Consumer: the download worker (`browser/workers/filesDownload.ts`), which keeps its own copy of\n * {@link decodeCompositeUpload} because it runs from a string; a test keeps the two in step.\n *\n * Format (unchanged for text children, so composites already on Arweave still read):\n *\n * ===FILE_SEPARATOR===<name>===FILE_SEPARATOR===<utf-8 text> (repeated per child)\n *\n * A child that is not valid UTF-8 text (or whose text contains the separator) is written as\n * base64 under the name `<name>;base64`. Composites written before this suffix existed converted\n * every child to text, which corrupted binary children; those bytes cannot be recovered.\n */\nexport const COMPOSITE_SEPARATOR = '===FILE_SEPARATOR==='\nexport const COMPOSITE_BASE64_SUFFIX = ';base64'\n\nexport type CompositeChild = { name: string; bytes: Uint8Array }\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n let binary = ''\n const chunk = 0x8000\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk))\n }\n return btoa(binary)\n}\n\nconst base64ToBytes = (base64: string): Uint8Array | undefined => {\n try {\n const binary = atob(base64.replace(/\\s/g, ''))\n const out = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i)\n return out\n } catch {\n return undefined\n }\n}\n\n/** The child's text when it can travel as text: valid UTF-8, no NUL bytes, no separator. */\nconst childAsText = (bytes: Uint8Array): string | undefined => {\n if (bytes.includes(0)) return undefined\n let text: string\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n } catch {\n return undefined\n }\n return text.includes(COMPOSITE_SEPARATOR) ? undefined : text\n}\n\nexport const encodeCompositeUpload = (children: CompositeChild[]): Uint8Array => {\n let composite = ''\n for (const { name, bytes } of children) {\n const text = childAsText(bytes)\n composite +=\n text !== undefined\n ? `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_SEPARATOR}${text}`\n : `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_BASE64_SUFFIX}${COMPOSITE_SEPARATOR}${bytesToBase64(bytes)}`\n }\n return new TextEncoder().encode(composite)\n}\n\nconst SEPARATOR_BYTES = new TextEncoder().encode(COMPOSITE_SEPARATOR)\n\n/** True when `bytes` start with the composite separator (checked on bytes, before any text heuristics). */\nexport const isCompositeUpload = (bytes: Uint8Array): boolean =>\n bytes.length >= SEPARATOR_BYTES.length && SEPARATOR_BYTES.every((b, i) => bytes[i] === b)\n\n/** Children of a composite, or `undefined` when `bytes` are not a well-formed composite. */\nexport const decodeCompositeUpload = (bytes: Uint8Array): CompositeChild[] | undefined => {\n if (!isCompositeUpload(bytes)) return undefined\n const parts = new TextDecoder('utf-8').decode(bytes).split(COMPOSITE_SEPARATOR).slice(1)\n if (parts.length % 2 !== 0) return undefined\n const encoder = new TextEncoder()\n const children: CompositeChild[] = []\n for (let i = 0; i < parts.length; i += 2) {\n const rawName = parts[i]!\n const content = parts[i + 1]!\n if (rawName.endsWith(COMPOSITE_BASE64_SUFFIX)) {\n const decoded = base64ToBytes(content)\n if (!decoded) return undefined\n children.push({ name: rawName.slice(0, -COMPOSITE_BASE64_SUFFIX.length), bytes: decoded })\n } else {\n children.push({ name: rawName, bytes: encoder.encode(content) })\n }\n }\n return children\n}\n","import { BaseFileManager } from '@/helpers'\nimport {\n getStorageDirForDataType,\n getItemStorageLocalFileName,\n getItemStorageSubdir,\n} from '@/helpers/storageDir'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { buildArweaveContentTags, getContentSha256 } from '@/helpers/arweaveContentTags'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction, TransactionTag } from '@/types/arweave'\nimport type { PublishUpload, PublishUploadData } from '@/types/publish'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { and, eq } from 'drizzle-orm'\nimport { metadata, type MetadataType } from '@/seedSchema'\nimport { compareMetadataRowsLatestFirst } from '@/helpers/compareMetadataRowsLatestFirst'\nimport { ModelPropertyDataTypes, isDataType } from '@/helpers/property'\nimport { getPublishDraftGraph } from '@/db/read/publishDraftGraph'\nimport { resolveUploadMimeType } from '@/helpers/mimeTypes'\nimport { mapWithConcurrency } from '@/helpers/mapWithConcurrency'\nimport { encodeCompositeUpload, type CompositeChild } from '@/helpers/compositeUpload'\nimport {\n convertVerbatimItemStorageRow,\n isVerbatimItemStorageDraftRow,\n} from '@/db/write/convertVerbatimItemStorageRow'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** L1 transactions {@link getPublishUploads} creates at once (each asks the gateway for price and anchor). */\nexport const CREATE_TRANSACTION_CONCURRENCY = 4\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 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\n/** A local file's bytes plus its MIME type: the Blob's own type, else the name's extension, else a sniff of the bytes. */\nconst readUploadFile = async (\n filePath: string,\n fileName: string = filePath,\n): Promise<{ bytes: Uint8Array; contentType: string | undefined }> => {\n const data = await BaseFileManager.readFileAsBuffer(filePath)\n const bytes = await toUint8Array(data)\n const sourceType = typeof Blob !== 'undefined' && data instanceof Blob ? data.type : undefined\n return { bytes, contentType: resolveUploadMimeType({ sourceType, fileName, bytes }) }\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 = buildArweaveContentTags(contentHash, contentType, additionalTags)\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\ntype UploadTarget = Pick<\n PublishUploadData,\n 'itemPropertyName' | 'itemPropertyLocalId' | 'seedLocalId' | 'versionLocalId'\n>\n\n/**\n * The one place an upload's bytes become a {@link PublishUploadData}: everything after this\n * (Content-SHA-256, tags, the L1 transaction or the bundler DataItem, signing) works from what it\n * returns. A future private-publish option that encrypts content belongs here, before the hash and\n * tags are computed, so both publish paths pick it up.\n */\nconst buildPublishUploadData = (\n data: Uint8Array,\n contentType: string | undefined,\n target: UploadTarget,\n options: GetPublishUploadsOptions | undefined,\n): PublishUploadData => {\n const contentHash = getContentSha256(data)\n return {\n data,\n contentHash,\n contentType,\n tags: buildArweaveContentTags(contentHash, contentType, options?.arweaveUploadTags),\n ...target,\n }\n}\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 getStorageSeedUploadData = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const uploads: PublishUploadData[] = []\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (isDataType(dataType, ModelPropertyDataTypes.Html)) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const { bytes: fileContents, contentType } = await readUploadFile(filePath, refResolvedValue)\n\n uploads.push(\n buildPublishUploadData(\n fileContents,\n contentType,\n {\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n },\n options,\n ),\n )\n }\n\n return uploads\n}\n\nasync function appendCoPublishedImageUploadData(\n item: IItem<any>,\n uploads: PublishUploadData[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> {\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: PublishUploadData[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n more.push(\n buildPublishUploadData(\n decoded.bytes,\n decoded.mimeType,\n {\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n },\n options,\n ),\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\nconst isUsablePath = (filePath: string | void | null | undefined): filePath is string =>\n !!filePath && !filePath.endsWith('undefined') && !filePath.endsWith('null')\n\n/** The newest metadata row of an ItemStorage property, read from the DB (not the live query). */\nconst getLatestItemStorageRow = async (\n childProperty: IItemProperty<any>,\n): Promise<MetadataType | undefined> => {\n const appDb = BaseDb.getAppDb()\n const seedLocalId = childProperty.seedLocalId\n const propertyName = childProperty.storagePropertyName || childProperty.propertyName\n if (!appDb || !seedLocalId || !propertyName) return undefined\n const where = [eq(metadata.seedLocalId, seedLocalId), eq(metadata.propertyName, propertyName)]\n if (childProperty.versionLocalId) where.push(eq(metadata.versionLocalId, childProperty.versionLocalId))\n const rows: MetadataType[] = await appDb.select().from(metadata).where(and(...where))\n return [...rows].sort(compareMetadataRowsLatestFirst)[0]\n}\n\n/**\n * Write a legacy ItemStorage draft row's verbatim content to `<seedUid or seedLocalId><extension>`\n * and record it on the row (refResolvedValue, localStorageDir) and in the property context. The\n * row's propertyValue is cleared once the file is written, so the row has the same shape as one a\n * save makes and a later edit of the file never leaves stale text behind it.\n */\nconst migrateVerbatimItemStorageRow = async (\n childProperty: IItemProperty<any>,\n row: MetadataType,\n): Promise<string | undefined> => {\n const seedId = row.seedUid || childProperty.seedUid || row.seedLocalId || childProperty.seedLocalId\n if (!seedId || !row.localId) return undefined\n const propertyDef = childProperty.propertyDef\n const converted = await convertVerbatimItemStorageRow(row.localId, {\n seedId,\n localStorageDir: propertyDef?.localStorageDir || row.localStorageDir,\n filenameSuffix: propertyDef?.filenameSuffix,\n })\n if (!converted) return undefined\n const { fileName, filePath, localStorageDir, content } = converted\n // The content is still the value: keep it as renderValue (the property may show it from propertyValue).\n childProperty.getService().send({\n type: 'updateContext',\n refResolvedValue: fileName,\n localStorageDir,\n renderValue: content,\n })\n logger(`resolveItemStorageChildFile: wrote verbatim ${childProperty.propertyName} content to ${filePath}`)\n return filePath\n}\n\n/**\n * Local file of one ItemStorage child of a composite upload. Tries, in order: the property's\n * localStoragePath (context set by save / hydration / the live query), its newest metadata row's\n * refResolvedValue + localStorageDir, then (for a local draft whose propertyValue is the content\n * itself, as rows made before Item.create saved ItemStorage values) that content written to its\n * file, then (for a local draft, or no row) the name\n * saveItemStorage gives a new file (`<seedUid or seedLocalId><extension>` in the model's storage\n * directory). A published or derived row is never swapped for a local file of another name: that\n * file would be older content.\n *\n * `missingLocalEdit` lists the paths tried when nothing exists although the newest row is a saved\n * local edit (no attestation uid, not derived from one, refResolvedValue set by saveItemStorage):\n * that edit's file should be there. A published or derived row without a file (e.g. content not\n * downloaded, or a property the composite never had) is skipped as before.\n */\nexport const resolveItemStorageChildFile = async (\n childProperty: IItemProperty<any>,\n): Promise<{ filePath?: string; missingLocalEdit?: string[] }> => {\n const tried: string[] = []\n const tryPath = async (filePath: string | void | null | undefined): Promise<string | undefined> => {\n if (!isUsablePath(filePath) || tried.includes(filePath)) return undefined\n tried.push(filePath)\n return (await BaseFileManager.pathExists(filePath)) ? filePath : undefined\n }\n\n const fromContext = await tryPath(childProperty.localStoragePath)\n if (fromContext) return { filePath: fromContext }\n\n const row = await getLatestItemStorageRow(childProperty).catch((error) => {\n logger('resolveItemStorageChildFile: metadata lookup failed', error)\n return undefined\n })\n const propertyDef = childProperty.propertyDef\n const dir = getItemStorageSubdir(propertyDef?.localStorageDir || row?.localStorageDir)\n\n if (row?.refResolvedValue) {\n const fromRow = await tryPath(BaseFileManager.getFilesPath(dir, row.refResolvedValue))\n if (fromRow) return { filePath: fromRow }\n }\n\n const isLocalDraft = !!row && !row.uid && row.derivedFromUid == null\n\n // A local draft holding the content itself (no file reference): what Item.create / createNewItem\n // stored for ItemStorage values before they went through the save pipeline. Write it to the file a\n // save would have, point the row and the property at it, and upload that.\n if (row && isVerbatimItemStorageDraftRow(row)) {\n const migrated = await migrateVerbatimItemStorageRow(childProperty, row).catch((error) => {\n logger('resolveItemStorageChildFile: writing verbatim ItemStorage content failed', error)\n return undefined\n })\n if (migrated) return { filePath: migrated }\n }\n\n const suffix = propertyDef?.filenameSuffix\n const seedIds = !row || isLocalDraft\n ? [row?.seedUid, childProperty.seedUid, row?.seedLocalId, childProperty.seedLocalId]\n : []\n for (const seedId of seedIds) {\n if (!seedId) continue\n const derived = await tryPath(\n BaseFileManager.getFilesPath(dir, getItemStorageLocalFileName(seedId, suffix)),\n )\n if (derived) return { filePath: derived }\n }\n\n // saveItemStorage sets refResolvedValue on the draft row once the file is written. A draft row\n // without one is the empty row createNewItem makes for every model property: nothing to upload.\n return isLocalDraft && !!row?.refResolvedValue ? { missingLocalEdit: tried } : {}\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\n for (const childProperty of uploadProperty.childProperties) {\n // Not strict: a local edit whose file is missing still means \"would upload\", so the publish\n // goes ahead and fails loudly in processUploadPropertyData instead of skipping the upload.\n const resolved = await resolveItemStorageChildFile(childProperty)\n if (resolved.filePath || resolved.missingLocalEdit) {\n return true\n }\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nasync function itemOwnUploadCandidates(\n item: IItem<any>,\n relatedItemProperty: IItemProperty<any> | undefined,\n recurseStorageRelations: boolean,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n if (!recurseStorageRelations) return false\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemOwnUploadCandidates(relatedItem, relationProperty, false)) {\n return true\n }\n }\n\n return false\n}\n\n/** Same walk as getPublishUploads: the item and the draft items its publish carries along. */\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n if (await itemOwnUploadCandidates(item, relatedItemProperty, true)) return true\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n if (await itemOwnUploadCandidates(draft, viaList ? undefined : via, true)) return true\n }\n return false\n}\n\nconst processUploadPropertyData = async (\n uploadProperty: UploadProperty,\n uploads: PublishUploadData[],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const { filePath, missingLocalEdit } = await resolveItemStorageChildFile(childProperty)\n\n if (!filePath) {\n if (missingLocalEdit) {\n // Uploading without it would publish a composite that silently lacks this edit.\n throw new Error(\n `Cannot publish ${itemProperty.seedLocalId}: the local file for ${childProperty.propertyName} ` +\n `was not found (looked in ${missingLocalEdit.join(', ')})`,\n )\n }\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let fileContentType: string | undefined\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 read = await readUploadFile(filePath)\n fileContents = read.bytes\n fileContentType = read.contentType\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n fileContentType = resolveUploadMimeType({ fileName: filePath, bytes: fileContents })\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n // Composite of the item's ItemStorage files; see helpers/compositeUpload.ts for the format.\n // Children are read as bytes: a binary child is base64-framed instead of decoded as text.\n const children: CompositeChild[] = []\n const fs = await BaseFileManager.getFs()\n for (const childUpload of childUploads) {\n let childUploadContents: Uint8Array | string\n try {\n childUploadContents = await fs.promises.readFile(childUpload.localStoragePath)\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n children.push({\n name: childUpload.propertyName,\n bytes:\n typeof childUploadContents === 'string'\n ? new TextEncoder().encode(childUploadContents)\n : new Uint8Array(childUploadContents),\n })\n }\n fileContents = encodeCompositeUpload(children)\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 let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = fileContentType\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\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 buildPublishUploadData(\n uint8Array,\n contentType,\n {\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n },\n options,\n ),\n )\n\n return uploads\n}\n\n/** No seed uid yet: a related item in this state is published together with the item. */\nconst isDraftItem = (item: IItem<any>): boolean =>\n !item.seedUid || item.seedUid === '0x' + '0'.repeat(64)\n\n/** One item's own uploads: its files, storage seeds, Html-embedded images, and the items its storage relations point at. */\nconst getItemOwnPublishUploadData = async (\n item: IItem<any>,\n uploads: PublishUploadData[],\n relatedItemProperty: IItemProperty<any> | undefined,\n options: GetPublishUploadsOptions | undefined,\n): Promise<PublishUploadData[]> => {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n // Phase 2 of an embedded-image publish: only the deferred Html storage seeds, of this item and of\n // the related items published with it (whose Html can embed images too).\n const onlyDeferredHtml = !!options?.onlyHtmlStorageSeedLocalIds?.length\n if (onlyDeferredHtml) {\n const storageSeedUploads = await getStorageSeedUploadData(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n } else {\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadPropertyData(\n uploadProperty,\n uploads,\n relatedItemProperty,\n options,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploadData(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n\n // Images embedded in this item's Html: the published item's, and a related draft's published with it.\n if (!relatedItemProperty || isDraftItem(item)) {\n uploads = await appendCoPublishedImageUploadData(item, uploads, options)\n }\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n // Relations to Image/File/Html/Json items: their file, read through the relation property.\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getItemOwnPublishUploadData(relatedItem, uploads, relationProperty, {\n ...options,\n skipRelationRecursion: true,\n })\n }\n\n return uploads\n}\n\n/**\n * Upload data for a publish of `item`: its own, and that of every draft item the publish carries\n * along (reachable through relation and list properties, see publishDraftGraph.ts). Raw bytes plus\n * Content-SHA-256 / Content-Type / configured tags; no Arweave transaction is created, so this\n * does not touch the network. The bundler path in `@seedprotocol/publish` signs these as\n * DataItems; {@link getPublishUploads} turns them into L1 transactions.\n */\nexport const getPublishUploadData = async (\n item: IItem<any>,\n uploads: PublishUploadData[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n uploads = await getItemOwnPublishUploadData(item, uploads, relatedItemProperty, options)\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n uploads = await getItemOwnPublishUploadData(draft, uploads, viaList ? undefined : via, options)\n }\n\n return uploads\n}\n\n/**\n * Arweave L1 transactions for a publish of `item`: {@link getPublishUploadData}, each made into an\n * unsigned transaction carrying the same tags.\n */\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const uploadData = await getPublishUploadData(item, [], relatedItemProperty, options)\n // Each createTransaction fetches the price / anchor from the gateway: run a few at once.\n const created = await mapWithConcurrency(uploadData, CREATE_TRANSACTION_CONCURRENCY, async (upload) => ({\n itemPropertyName: upload.itemPropertyName,\n itemPropertyLocalId: upload.itemPropertyLocalId,\n seedLocalId: upload.seedLocalId,\n versionLocalId: upload.versionLocalId,\n transactionToSign: await BaseArweaveClient.createTransaction(upload.data, {\n tags: upload.tags.length ? upload.tags : und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;AAGG;AACI,MAAM,iBAAiB,GAAG,OAC/B,IAAgB,EAChB,OAAA,GAA2B,EAAE,EAC7B,mBAAwC,EACxC,OAAkC,KACN;AAC5B,IAAA,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,mBAAmB,EAAE,OAAO,CAAC;;AAErF,IAAA,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,UAAU,EAAE,8BAA8B,EAAE,OAAO,MAAM,MAAM;QACtG,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,iBAAiB,EAAE,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE;AACxE,YAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,SAAS;SACnD,CAAC;AACH,KAAA,CAAC,CAAC;AACH,IAAA,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AACxB,IAAA,OAAO,OAAO;AAChB;;"}
1
+ {"version":3,"file":"getPublishUploads-J-143iSV.js","sources":["../../src/helpers/mapWithConcurrency.ts","../../src/helpers/compositeUpload.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["/**\n * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.\n * Rejects with the first error (by time); after that no new calls start, though calls already in\n * flight run to completion.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n const workerCount = Math.max(1, Math.min(Math.floor(limit) || 1, items.length))\n let next = 0\n let failed = false\n\n const worker = async (): Promise<void> => {\n while (!failed && next < items.length) {\n const index = next++\n try {\n results[index] = await fn(items[index]!, index)\n } catch (error) {\n failed = true\n throw error\n }\n }\n }\n\n await Promise.all(Array.from({ length: workerCount }, worker))\n return results\n}\n","/**\n * Composite uploads: several ItemStorage files of one item in a single Arweave transaction.\n *\n * Producer: `getPublishUploads.ts` (`processUploadPropertyData`), for an item with a\n * `storageTransactionId` property and ItemStorage properties (e.g. a Post's `html` and `json`).\n * Consumer: the download worker (`browser/workers/filesDownload.ts`), which keeps its own copy of\n * {@link decodeCompositeUpload} because it runs from a string; a test keeps the two in step.\n *\n * Format (unchanged for text children, so composites already on Arweave still read):\n *\n * ===FILE_SEPARATOR===<name>===FILE_SEPARATOR===<utf-8 text> (repeated per child)\n *\n * A child that is not valid UTF-8 text (or whose text contains the separator) is written as\n * base64 under the name `<name>;base64`. Composites written before this suffix existed converted\n * every child to text, which corrupted binary children; those bytes cannot be recovered.\n */\nexport const COMPOSITE_SEPARATOR = '===FILE_SEPARATOR==='\nexport const COMPOSITE_BASE64_SUFFIX = ';base64'\n\nexport type CompositeChild = { name: string; bytes: Uint8Array }\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n let binary = ''\n const chunk = 0x8000\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk))\n }\n return btoa(binary)\n}\n\nconst base64ToBytes = (base64: string): Uint8Array | undefined => {\n try {\n const binary = atob(base64.replace(/\\s/g, ''))\n const out = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i)\n return out\n } catch {\n return undefined\n }\n}\n\n/** The child's text when it can travel as text: valid UTF-8, no NUL bytes, no separator. */\nconst childAsText = (bytes: Uint8Array): string | undefined => {\n if (bytes.includes(0)) return undefined\n let text: string\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n } catch {\n return undefined\n }\n return text.includes(COMPOSITE_SEPARATOR) ? undefined : text\n}\n\nexport const encodeCompositeUpload = (children: CompositeChild[]): Uint8Array => {\n let composite = ''\n for (const { name, bytes } of children) {\n const text = childAsText(bytes)\n composite +=\n text !== undefined\n ? `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_SEPARATOR}${text}`\n : `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_BASE64_SUFFIX}${COMPOSITE_SEPARATOR}${bytesToBase64(bytes)}`\n }\n return new TextEncoder().encode(composite)\n}\n\nconst SEPARATOR_BYTES = new TextEncoder().encode(COMPOSITE_SEPARATOR)\n\n/** True when `bytes` start with the composite separator (checked on bytes, before any text heuristics). */\nexport const isCompositeUpload = (bytes: Uint8Array): boolean =>\n bytes.length >= SEPARATOR_BYTES.length && SEPARATOR_BYTES.every((b, i) => bytes[i] === b)\n\n/** Children of a composite, or `undefined` when `bytes` are not a well-formed composite. */\nexport const decodeCompositeUpload = (bytes: Uint8Array): CompositeChild[] | undefined => {\n if (!isCompositeUpload(bytes)) return undefined\n const parts = new TextDecoder('utf-8').decode(bytes).split(COMPOSITE_SEPARATOR).slice(1)\n if (parts.length % 2 !== 0) return undefined\n const encoder = new TextEncoder()\n const children: CompositeChild[] = []\n for (let i = 0; i < parts.length; i += 2) {\n const rawName = parts[i]!\n const content = parts[i + 1]!\n if (rawName.endsWith(COMPOSITE_BASE64_SUFFIX)) {\n const decoded = base64ToBytes(content)\n if (!decoded) return undefined\n children.push({ name: rawName.slice(0, -COMPOSITE_BASE64_SUFFIX.length), bytes: decoded })\n } else {\n children.push({ name: rawName, bytes: encoder.encode(content) })\n }\n }\n return children\n}\n","import { BaseFileManager } from '@/helpers'\nimport {\n getStorageDirForDataType,\n getItemStorageLocalFileName,\n getItemStorageSubdir,\n} from '@/helpers/storageDir'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport debug from 'debug'\nimport { IItem, IItemProperty } from '@/interfaces'\nimport { buildArweaveContentTags, getContentSha256 } from '@/helpers/arweaveContentTags'\nimport { Item } from '@/Item/Item'\nimport type { ArweaveTransaction, TransactionTag } from '@/types/arweave'\nimport type { PublishUpload, PublishUploadData } from '@/types/publish'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { and, eq } from 'drizzle-orm'\nimport { metadata, type MetadataType } from '@/seedSchema'\nimport { compareMetadataRowsLatestFirst } from '@/helpers/compareMetadataRowsLatestFirst'\nimport { ModelPropertyDataTypes, isDataType } from '@/helpers/property'\nimport { getPublishDraftGraph } from '@/db/read/publishDraftGraph'\nimport { resolveUploadMimeType } from '@/helpers/mimeTypes'\nimport { mapWithConcurrency } from '@/helpers/mapWithConcurrency'\nimport { encodeCompositeUpload, type CompositeChild } from '@/helpers/compositeUpload'\nimport {\n convertVerbatimItemStorageRow,\n isVerbatimItemStorageDraftRow,\n} from '@/db/write/convertVerbatimItemStorageRow'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** L1 transactions {@link getPublishUploads} creates at once (each asks the gateway for price and anchor). */\nexport const CREATE_TRANSACTION_CONCURRENCY = 4\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 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\n/** A local file's bytes plus its MIME type: the Blob's own type, else the name's extension, else a sniff of the bytes. */\nconst readUploadFile = async (\n filePath: string,\n fileName: string = filePath,\n): Promise<{ bytes: Uint8Array; contentType: string | undefined }> => {\n const data = await BaseFileManager.readFileAsBuffer(filePath)\n const bytes = await toUint8Array(data)\n const sourceType = typeof Blob !== 'undefined' && data instanceof Blob ? data.type : undefined\n return { bytes, contentType: resolveUploadMimeType({ sourceType, fileName, bytes }) }\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 = buildArweaveContentTags(contentHash, contentType, additionalTags)\n\n const tx = await BaseArweaveClient.createTransaction(data, {\n tags: tags.length ? tags : undefined,\n })\n\n return tx\n}\n\ntype UploadTarget = Pick<\n PublishUploadData,\n 'itemPropertyName' | 'itemPropertyLocalId' | 'seedLocalId' | 'versionLocalId'\n>\n\n/**\n * The one place an upload's bytes become a {@link PublishUploadData}: everything after this\n * (Content-SHA-256, tags, the L1 transaction or the bundler DataItem, signing) works from what it\n * returns. A future private-publish option that encrypts content belongs here, before the hash and\n * tags are computed, so both publish paths pick it up.\n */\nconst buildPublishUploadData = (\n data: Uint8Array,\n contentType: string | undefined,\n target: UploadTarget,\n options: GetPublishUploadsOptions | undefined,\n): PublishUploadData => {\n const contentHash = getContentSha256(data)\n return {\n data,\n contentHash,\n contentType,\n tags: buildArweaveContentTags(contentHash, contentType, options?.arweaveUploadTags),\n ...target,\n }\n}\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 getStorageSeedUploadData = async (\n itemStorageSeedProperties: IItemProperty<any>[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const uploads: PublishUploadData[] = []\n\n for (const itemProperty of itemStorageSeedProperties) {\n const snapshot = itemProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n const refResolvedValue = (context as any).refResolvedValue\n if (!refResolvedValue) {\n continue\n }\n\n // propertyValue is the storage seed's seedLocalId; use it for the upload so processRelationOrImageProperty can match\n const { seedLocalId } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId) {\n continue\n }\n\n const dataType =\n itemProperty.propertyDef?.refValueType ??\n itemProperty.propertyDef?.dataType ??\n 'Image'\n\n if (isDataType(dataType, ModelPropertyDataTypes.Html)) {\n if (options?.deferHtmlStorageSeedLocalIds?.includes(seedLocalId)) {\n continue\n }\n if (\n options?.onlyHtmlStorageSeedLocalIds?.length &&\n !options.onlyHtmlStorageSeedLocalIds.includes(seedLocalId)\n ) {\n continue\n }\n } else if (options?.onlyHtmlStorageSeedLocalIds?.length) {\n continue\n }\n\n const baseDir = getStorageDirForDataType(dataType)\n const filePath = `${baseDir}/${refResolvedValue}`\n\n const exists = await BaseFileManager.pathExists(filePath)\n if (!exists) {\n continue\n }\n\n const { bytes: fileContents, contentType } = await readUploadFile(filePath, refResolvedValue)\n\n uploads.push(\n buildPublishUploadData(\n fileContents,\n contentType,\n {\n itemPropertyName: itemProperty.propertyName,\n itemPropertyLocalId: itemProperty.localId,\n seedLocalId,\n versionLocalId: itemProperty.versionLocalId!,\n },\n options,\n ),\n )\n }\n\n return uploads\n}\n\nasync function appendCoPublishedImageUploadData(\n item: IItem<any>,\n uploads: PublishUploadData[],\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> {\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: PublishUploadData[] = []\n if (decoded && st && st.localId && st.versionLocalId) {\n more.push(\n buildPublishUploadData(\n decoded.bytes,\n decoded.mimeType,\n {\n itemPropertyName: st.propertyName,\n itemPropertyLocalId: st.localId,\n seedLocalId: imageItem.seedLocalId,\n versionLocalId: st.versionLocalId,\n },\n options,\n ),\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\nconst isUsablePath = (filePath: string | void | null | undefined): filePath is string =>\n !!filePath && !filePath.endsWith('undefined') && !filePath.endsWith('null')\n\n/** The newest metadata row of an ItemStorage property, read from the DB (not the live query). */\nconst getLatestItemStorageRow = async (\n childProperty: IItemProperty<any>,\n): Promise<MetadataType | undefined> => {\n const appDb = BaseDb.getAppDb()\n const seedLocalId = childProperty.seedLocalId\n const propertyName = childProperty.storagePropertyName || childProperty.propertyName\n if (!appDb || !seedLocalId || !propertyName) return undefined\n const where = [eq(metadata.seedLocalId, seedLocalId), eq(metadata.propertyName, propertyName)]\n if (childProperty.versionLocalId) where.push(eq(metadata.versionLocalId, childProperty.versionLocalId))\n const rows: MetadataType[] = await appDb.select().from(metadata).where(and(...where))\n return [...rows].sort(compareMetadataRowsLatestFirst)[0]\n}\n\n/**\n * Write a legacy ItemStorage draft row's verbatim content to `<seedUid or seedLocalId><extension>`\n * and record it on the row (refResolvedValue, localStorageDir) and in the property context. The\n * row's propertyValue is cleared once the file is written, so the row has the same shape as one a\n * save makes and a later edit of the file never leaves stale text behind it.\n */\nconst migrateVerbatimItemStorageRow = async (\n childProperty: IItemProperty<any>,\n row: MetadataType,\n): Promise<string | undefined> => {\n const seedId = row.seedUid || childProperty.seedUid || row.seedLocalId || childProperty.seedLocalId\n if (!seedId || !row.localId) return undefined\n const propertyDef = childProperty.propertyDef\n const converted = await convertVerbatimItemStorageRow(row.localId, {\n seedId,\n localStorageDir: propertyDef?.localStorageDir || row.localStorageDir,\n filenameSuffix: propertyDef?.filenameSuffix,\n })\n if (!converted) return undefined\n const { fileName, filePath, localStorageDir, content } = converted\n // The content is still the value: keep it as renderValue (the property may show it from propertyValue).\n childProperty.getService().send({\n type: 'updateContext',\n refResolvedValue: fileName,\n localStorageDir,\n renderValue: content,\n })\n logger(`resolveItemStorageChildFile: wrote verbatim ${childProperty.propertyName} content to ${filePath}`)\n return filePath\n}\n\n/**\n * Local file of one ItemStorage child of a composite upload. Tries, in order: the property's\n * localStoragePath (context set by save / hydration / the live query), its newest metadata row's\n * refResolvedValue + localStorageDir, then (for a local draft whose propertyValue is the content\n * itself, as rows made before Item.create saved ItemStorage values) that content written to its\n * file, then (for a local draft, or no row) the name\n * saveItemStorage gives a new file (`<seedUid or seedLocalId><extension>` in the model's storage\n * directory). A published or derived row is never swapped for a local file of another name: that\n * file would be older content.\n *\n * `missingLocalEdit` lists the paths tried when nothing exists although the newest row is a saved\n * local edit (no attestation uid, not derived from one, refResolvedValue set by saveItemStorage):\n * that edit's file should be there. A published or derived row without a file (e.g. content not\n * downloaded, or a property the composite never had) is skipped as before.\n */\nexport const resolveItemStorageChildFile = async (\n childProperty: IItemProperty<any>,\n): Promise<{ filePath?: string; missingLocalEdit?: string[] }> => {\n const tried: string[] = []\n const tryPath = async (filePath: string | void | null | undefined): Promise<string | undefined> => {\n if (!isUsablePath(filePath) || tried.includes(filePath)) return undefined\n tried.push(filePath)\n return (await BaseFileManager.pathExists(filePath)) ? filePath : undefined\n }\n\n const fromContext = await tryPath(childProperty.localStoragePath)\n if (fromContext) return { filePath: fromContext }\n\n const row = await getLatestItemStorageRow(childProperty).catch((error) => {\n logger('resolveItemStorageChildFile: metadata lookup failed', error)\n return undefined\n })\n const propertyDef = childProperty.propertyDef\n const dir = getItemStorageSubdir(propertyDef?.localStorageDir || row?.localStorageDir)\n\n if (row?.refResolvedValue) {\n const fromRow = await tryPath(BaseFileManager.getFilesPath(dir, row.refResolvedValue))\n if (fromRow) return { filePath: fromRow }\n }\n\n const isLocalDraft = !!row && !row.uid && row.derivedFromUid == null\n\n // A local draft holding the content itself (no file reference): what Item.create / createNewItem\n // stored for ItemStorage values before they went through the save pipeline. Write it to the file a\n // save would have, point the row and the property at it, and upload that.\n if (row && isVerbatimItemStorageDraftRow(row)) {\n const migrated = await migrateVerbatimItemStorageRow(childProperty, row).catch((error) => {\n logger('resolveItemStorageChildFile: writing verbatim ItemStorage content failed', error)\n return undefined\n })\n if (migrated) return { filePath: migrated }\n }\n\n const suffix = propertyDef?.filenameSuffix\n const seedIds = !row || isLocalDraft\n ? [row?.seedUid, childProperty.seedUid, row?.seedLocalId, childProperty.seedLocalId]\n : []\n for (const seedId of seedIds) {\n if (!seedId) continue\n const derived = await tryPath(\n BaseFileManager.getFilesPath(dir, getItemStorageLocalFileName(seedId, suffix)),\n )\n if (derived) return { filePath: derived }\n }\n\n // saveItemStorage sets refResolvedValue on the draft row once the file is written. A draft row\n // without one is the empty row createNewItem makes for every model property: nothing to upload.\n return isLocalDraft && !!row?.refResolvedValue ? { missingLocalEdit: tried } : {}\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\n for (const childProperty of uploadProperty.childProperties) {\n // Not strict: a local edit whose file is missing still means \"would upload\", so the publish\n // goes ahead and fails loudly in processUploadPropertyData instead of skipping the upload.\n const resolved = await resolveItemStorageChildFile(childProperty)\n if (resolved.filePath || resolved.missingLocalEdit) {\n return true\n }\n }\n\n if (relatedItemProperty && relatedItemProperty.localStoragePath) {\n const filePath = relatedItemProperty.localStoragePath\n\n if (!filePath || filePath.endsWith('undefined')) {\n return false\n }\n\n return await BaseFileManager.pathExists(filePath)\n }\n\n return false\n}\n\nasync function itemOwnUploadCandidates(\n item: IItem<any>,\n relatedItemProperty: IItemProperty<any> | undefined,\n recurseStorageRelations: boolean,\n): Promise<boolean> {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n for (const uploadProperty of itemUploadProperties) {\n if (await uploadPropertyWouldUpload(uploadProperty, relatedItemProperty)) {\n return true\n }\n }\n\n if (await storageSeedHasUploadCandidates(itemImageProperties)) {\n return true\n }\n\n if (!recurseStorageRelations) return false\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n if (await itemOwnUploadCandidates(relatedItem, relationProperty, false)) {\n return true\n }\n }\n\n return false\n}\n\n/** Same walk as getPublishUploads: the item and the draft items its publish carries along. */\nexport async function itemHasPublishUploadCandidates(\n item: IItem<any>,\n relatedItemProperty?: IItemProperty<any>,\n): Promise<boolean> {\n if (await itemOwnUploadCandidates(item, relatedItemProperty, true)) return true\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n if (await itemOwnUploadCandidates(draft, viaList ? undefined : via, true)) return true\n }\n return false\n}\n\nconst processUploadPropertyData = async (\n uploadProperty: UploadProperty,\n uploads: PublishUploadData[],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const itemProperty = uploadProperty.itemProperty\n\n const childUploads: ChildUploadData[] = []\n\n for (const childProperty of uploadProperty.childProperties) {\n const { filePath, missingLocalEdit } = await resolveItemStorageChildFile(childProperty)\n\n if (!filePath) {\n if (missingLocalEdit) {\n // Uploading without it would publish a composite that silently lacks this edit.\n throw new Error(\n `Cannot publish ${itemProperty.seedLocalId}: the local file for ${childProperty.propertyName} ` +\n `was not found (looked in ${missingLocalEdit.join(', ')})`,\n )\n }\n continue\n }\n\n childUploads.push({\n propertyName: childProperty.propertyName,\n localStoragePath: filePath,\n })\n }\n\n let fileContents\n let fileContentType: string | undefined\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 read = await readUploadFile(filePath)\n fileContents = read.bytes\n fileContentType = read.contentType\n } catch (e) {\n const fs = await BaseFileManager.getFs()\n fileContents = await toUint8Array(fs.readFileSync(filePath))\n fileContentType = resolveUploadMimeType({ fileName: filePath, bytes: fileContents })\n }\n }\n if (!fileContents) {\n return uploads\n }\n }\n\n if (childUploads.length > 0) {\n // Composite of the item's ItemStorage files; see helpers/compositeUpload.ts for the format.\n // Children are read as bytes: a binary child is base64-framed instead of decoded as text.\n const children: CompositeChild[] = []\n const fs = await BaseFileManager.getFs()\n for (const childUpload of childUploads) {\n let childUploadContents: Uint8Array | string\n try {\n childUploadContents = await fs.promises.readFile(childUpload.localStoragePath)\n } catch (e) {\n childUploadContents = fs.readFileSync(childUpload.localStoragePath)\n }\n children.push({\n name: childUpload.propertyName,\n bytes:\n typeof childUploadContents === 'string'\n ? new TextEncoder().encode(childUploadContents)\n : new Uint8Array(childUploadContents),\n })\n }\n fileContents = encodeCompositeUpload(children)\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 let contentType: string | undefined\n if (childUploads.length === 0 && relatedItemProperty?.localStoragePath) {\n contentType = fileContentType\n } else if (childUploads.length > 0) {\n contentType = 'application/octet-stream'\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 buildPublishUploadData(\n uint8Array,\n contentType,\n {\n itemPropertyName,\n itemPropertyLocalId,\n seedLocalId: itemProperty.seedLocalId!,\n versionLocalId: itemProperty.versionLocalId!,\n },\n options,\n ),\n )\n\n return uploads\n}\n\n/** No seed uid yet: a related item in this state is published together with the item. */\nconst isDraftItem = (item: IItem<any>): boolean =>\n !item.seedUid || item.seedUid === '0x' + '0'.repeat(64)\n\n/** One item's own uploads: its files, storage seeds, Html-embedded images, and the items its storage relations point at. */\nconst getItemOwnPublishUploadData = async (\n item: IItem<any>,\n uploads: PublishUploadData[],\n relatedItemProperty: IItemProperty<any> | undefined,\n options: GetPublishUploadsOptions | undefined,\n): Promise<PublishUploadData[]> => {\n const { itemUploadProperties, itemRelationProperties, itemImageProperties } =\n await getSegmentedItemProperties(item)\n\n // Phase 2 of an embedded-image publish: only the deferred Html storage seeds, of this item and of\n // the related items published with it (whose Html can embed images too).\n const onlyDeferredHtml = !!options?.onlyHtmlStorageSeedLocalIds?.length\n if (onlyDeferredHtml) {\n const storageSeedUploads = await getStorageSeedUploadData(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n } else {\n for (const uploadProperty of itemUploadProperties) {\n uploads = await processUploadPropertyData(\n uploadProperty,\n uploads,\n relatedItemProperty,\n options,\n )\n }\n\n const storageSeedUploads = await getStorageSeedUploadData(itemImageProperties, options)\n uploads.push(...storageSeedUploads)\n\n // Images embedded in this item's Html: the published item's, and a related draft's published with it.\n if (!relatedItemProperty || isDraftItem(item)) {\n uploads = await appendCoPublishedImageUploadData(item, uploads, options)\n }\n }\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n // Relations to Image/File/Html/Json items: their file, read through the relation property.\n const storageProperties = new Set(itemImageProperties)\n for (const relationProperty of itemRelationProperties) {\n if (!storageProperties.has(relationProperty)) continue\n const snapshot = relationProperty.getService().getSnapshot()\n const context = 'context' in snapshot ? snapshot.context : null\n if (!context) {\n continue\n }\n const propertyValue = (context as any).propertyValue\n\n if (!propertyValue || relationProperty.uid) {\n continue\n }\n\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(\n normalizeRelationPropertyValue(propertyValue) ?? '',\n )\n if (!seedLocalId && !seedUid) {\n throw new Error(\n `Invalid relation value for ${relationProperty.propertyName}: expected local seed id or 0x uid`,\n )\n }\n\n const relatedItem = await Item.find({\n seedLocalId,\n seedUid,\n })\n\n if (!relatedItem) {\n // Related seed referenced by attested uid with no local copy: already published, nothing to upload.\n if (isPublishedSeedRef(propertyValue)) continue\n throw new Error(\n `No relatedItem found for ${relationProperty.propertyName}`,\n )\n }\n\n uploads = await getItemOwnPublishUploadData(relatedItem, uploads, relationProperty, {\n ...options,\n skipRelationRecursion: true,\n })\n }\n\n return uploads\n}\n\n/**\n * Upload data for a publish of `item`: its own, and that of every draft item the publish carries\n * along (reachable through relation and list properties, see publishDraftGraph.ts). Raw bytes plus\n * Content-SHA-256 / Content-Type / configured tags; no Arweave transaction is created, so this\n * does not touch the network. The bundler path in `@seedprotocol/publish` signs these as\n * DataItems; {@link getPublishUploads} turns them into L1 transactions.\n */\nexport const getPublishUploadData = async (\n item: IItem<any>,\n uploads: PublishUploadData[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n uploads = await getItemOwnPublishUploadData(item, uploads, relatedItemProperty, options)\n\n if (options?.skipRelationRecursion) {\n return uploads\n }\n\n const { drafts } = await getPublishDraftGraph(item, { strict: true })\n for (const { item: draft, via, viaList } of drafts) {\n uploads = await getItemOwnPublishUploadData(draft, uploads, viaList ? undefined : via, options)\n }\n\n return uploads\n}\n\n/**\n * Arweave L1 transactions for a publish of `item`: {@link getPublishUploadData}, each made into an\n * unsigned transaction carrying the same tags.\n */\nexport const getPublishUploads = async (\n item: IItem<any>,\n uploads: PublishUpload[] = [],\n relatedItemProperty?: IItemProperty<any>,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const uploadData = await getPublishUploadData(item, [], relatedItemProperty, options)\n // Each createTransaction fetches the price / anchor from the gateway: run a few at once.\n const created = await mapWithConcurrency(uploadData, CREATE_TRANSACTION_CONCURRENCY, async (upload) => ({\n itemPropertyName: upload.itemPropertyName,\n itemPropertyLocalId: upload.itemPropertyLocalId,\n seedLocalId: upload.seedLocalId,\n versionLocalId: upload.versionLocalId,\n transactionToSign: await BaseArweaveClient.createTransaction(upload.data, {\n tags: upload.tags.length ? upload.tags : undefined,\n }),\n }))\n uploads.push(...created)\n return uploads\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAIG;AACI,eAAe,kBAAkB,CACtC,KAAmB,EACnB,KAAa,EACb,EAA0C,EAAA;IAE1C,MAAM,OAAO,GAAG,IAAI,KAAK,CAAI,KAAK,CAAC,MAAM,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/E,IAAI,IAAI,GAAG,CAAC;IACZ,IAAI,MAAM,GAAG,KAAK;AAElB,IAAA,MAAM,MAAM,GAAG,YAA0B;QACvC,OAAO,CAAC,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE;AACrC,YAAA,MAAM,KAAK,GAAG,IAAI,EAAE;AACpB,YAAA,IAAI;AACF,gBAAA,OAAO,CAAC,KAAK,CA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CAAC;AACH,IAAA,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AACxB,IAAA,OAAO,OAAO;AAChB;;"}
@@ -1,4 +1,4 @@
1
- import { m as metadata, h as appState, j as arweaveL1FinalizeJobs, k as config, l as easSyncProcesses, o as htmlEmbeddedImageCoPublish, p as modelRelations, q as modelSchemas, r as modelUids, s as models, t as modelsRelations, u as properties, v as propertiesRelations, w as propertyUidRelations, x as propertyUids, y as publishProcesses, z as schemas, A as seeds, B as uploadProcesses, C as versions } from './BasePathResolver-DxdS0wJ0.js';
1
+ import { m as metadata, h as appState, j as arweaveL1FinalizeJobs, k as config, l as easSyncProcesses, o as htmlEmbeddedImageCoPublish, p as modelRelations, q as modelSchemas, r as modelUids, s as models, t as modelsRelations, u as properties, v as propertiesRelations, w as propertyUidRelations, x as propertyUids, y as publishProcesses, z as schemas, A as seeds, B as uploadProcesses, C as versions } from './BasePathResolver-DrzGVH9L.js';
2
2
 
3
3
  var schema = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
@@ -25,4 +25,4 @@ var schema = /*#__PURE__*/Object.freeze({
25
25
  });
26
26
 
27
27
  export { schema as s };
28
- //# sourceMappingURL=index-DAl9U4rn.js.map
28
+ //# sourceMappingURL=index-7y2f_iQz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-7y2f_iQz.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,20 +1,19 @@
1
- export { M as Model, T as TModelSchema, a as TModelValues } from './errors-Cl8rbtKR.js';
2
- import { M as ModelPropertyDataTypes } from './BasePathResolver-DxdS0wJ0.js';
3
- export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './BasePathResolver-DxdS0wJ0.js';
4
- export { getPropertySchema } from './property-Brgr5RdT.js';
1
+ export { M as Model, T as TModelSchema, a as TModelValues } from './errors-DdWbxb_n.js';
2
+ import { M as ModelPropertyDataTypes } from './BasePathResolver-DrzGVH9L.js';
3
+ export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './BasePathResolver-DrzGVH9L.js';
4
+ export { getPropertySchema } from './property-zFPMtR3T.js';
5
5
  import 'xstate';
6
6
  import 'drizzle-orm';
7
7
  import 'debug';
8
- import './Item-cq9VcsAY.js';
9
- import 'pluralize';
8
+ import './Item-BUUFuywT.js';
10
9
  import 'rxjs';
10
+ import 'pluralize';
11
11
  import 'lodash-es';
12
- import 'drizzle-orm/casing';
13
12
  import '@seedprotocol/eas';
14
13
  import '@seedprotocol/arweave';
15
- import './tabEvents-BTzckWrN.js';
14
+ import './tabEvents-nBUq_1u1.js';
16
15
  import './model-oHA3YhOd.js';
17
- import './ClientManager-De-vKHGe.js';
16
+ import './ClientManager-Dfu4jcgm.js';
18
17
  import '@noble/hashes/sha3';
19
18
  import '@noble/hashes/utils';
20
19
  import '@seedprotocol/query';
@@ -27,4 +26,4 @@ import '@noble/hashes/sha256';
27
26
 
28
27
 
29
28
  export { ModelPropertyDataTypes };
30
- //# sourceMappingURL=index-CqnU-5i0.js.map
29
+ //# sourceMappingURL=index-C61Rxy0F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-C61Rxy0F.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,13 +1,13 @@
1
- import { I as BasePathResolver, E as BaseDb, h as appState, aw as contentSha256TagMatches, J as BaseFileManager } from './BasePathResolver-DxdS0wJ0.js';
1
+ import { I as BasePathResolver, E as BaseDb, h as appState, az as contentSha256TagMatches, J as BaseFileManager } from './BasePathResolver-DrzGVH9L.js';
2
2
  import { eq, sql } from 'drizzle-orm';
3
- import { a as withDbTabLock, n as notifyFilesWrittenOutsideCache, b as withSeedDbLock } from './tabEvents-BTzckWrN.js';
3
+ import { a as withDbTabLock, n as notifyFilesWrittenOutsideCache, b as withSeedDbLock } from './tabEvents-nBUq_1u1.js';
4
4
  import { M as MIME_TO_EXTENSION } from './mimeTypes-DHAHC4eZ.js';
5
5
  import debug from 'debug';
6
6
  import { F as FileSystemLockedError } from './errors-CrBxGWah.js';
7
7
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
8
8
  import { sha256 } from '@noble/hashes/sha256';
9
9
  import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
10
- import { s as schema } from './index-DAl9U4rn.js';
10
+ import { s as schema } from './index-7y2f_iQz.js';
11
11
  import { SQLocalDrizzle } from 'sqlocal/drizzle';
12
12
  import { Observable, distinctUntilChanged } from 'rxjs';
13
13
  import { BaseArweaveClient, getPreferredArweaveReadBaseUrls, fetchArweaveRawFromBaseUrl, GET_TRANSACTION_TAGS } from '@seedprotocol/arweave';
@@ -15,7 +15,7 @@ import { GraphQLClient } from 'graphql-request';
15
15
  import Arweave from 'arweave';
16
16
  import { getEasEndpoint, BaseEasClient, BaseQueryClient } from '@seedprotocol/eas';
17
17
  import { QueryClient } from '@tanstack/react-query';
18
- import './configurePlatform-DlZ23w7e.js';
18
+ import './configurePlatform-BzfirKuM.js';
19
19
 
20
20
  class BrowserPathResolver {
21
21
  /** @deprecated Prefer BasePathResolver static methods or configure(). */
@@ -1448,8 +1448,8 @@ class BrowserFileManager {
1448
1448
  }
1449
1449
  async initializeFileSystem(_workingDir) {
1450
1450
  const zenfs = await this.getFs();
1451
- const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-DOm2Xv-f.js');
1452
- const _mod_0 = await import('./tabEvents-BTzckWrN.js');
1451
+ const { TolerantWebAccess, TolerantWebAccessFS } = await import('./tolerantWebAccess-DIt3R8_u.js');
1452
+ const _mod_0 = await import('./tabEvents-nBUq_1u1.js');
1453
1453
  const _ns_0 = _mod_0.t;
1454
1454
  const { queueFilesChangedNotice } = _ns_0;
1455
1455
  const { configureSingle } = zenfs;
@@ -1518,7 +1518,7 @@ class BrowserFileManager {
1518
1518
  }
1519
1519
  async invalidateNow(filePaths) {
1520
1520
  const { mounts } = await this.getFs();
1521
- const { TolerantWebAccessFS } = await import('./tolerantWebAccess-DOm2Xv-f.js');
1521
+ const { TolerantWebAccessFS } = await import('./tolerantWebAccess-DIt3R8_u.js');
1522
1522
  const mounted = mounts.get('/');
1523
1523
  if (!(mounted instanceof TolerantWebAccessFS))
1524
1524
  return;
@@ -4057,10 +4057,10 @@ class BrowserDb {
4057
4057
  await raceSqlocalStartup((async () => {
4058
4058
  await this.runMigrations(db);
4059
4059
  this.appDb = db;
4060
- const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-DacVthS5.js');
4060
+ const { backfillMetadataPropertyIds } = await import('./backfillMetadataPropertyIds-C2-s_jUa.js');
4061
4061
  await backfillMetadataPropertyIds();
4062
4062
  // One-time: clear item data whose model can't be determined (seeds.model_file_id, migration 0015)
4063
- const { resetAmbiguousLegacyItemData } = await import('./resetAmbiguousLegacyItemData-CcLFRREE.js');
4063
+ const { resetAmbiguousLegacyItemData } = await import('./resetAmbiguousLegacyItemData-DsFTnMBz.js');
4064
4064
  await resetAmbiguousLegacyItemData();
4065
4065
  })(), workerFailed);
4066
4066
  return this.appDb;
@@ -4525,4 +4525,4 @@ function createPlatformServices() {
4525
4525
  }
4526
4526
 
4527
4527
  export { createPlatformServices as c, isSkippableOpfsEntryError as i };
4528
- //# sourceMappingURL=index.browser-J6QZ9smP.js.map
4528
+ //# sourceMappingURL=index.browser-C1pisOEa.js.map