@seedprotocol/sdk 0.7.10 → 0.7.11-next.1396.g883ef47

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 (174) hide show
  1. package/README.md +1 -1
  2. package/dist/{BaseFileManager-DLou1TZS.js → BaseFileManager-D-pLXQAp.js} +2 -14
  3. package/dist/BaseFileManager-D-pLXQAp.js.map +1 -0
  4. package/dist/{Item-oPnmIehk.js → Item-BU9wIT7l.js} +2053 -412
  5. package/dist/Item-BU9wIT7l.js.map +1 -0
  6. package/dist/{ModelProperty-D2vJozmW.js → ModelProperty-Bv7KzP97.js} +40 -38
  7. package/dist/ModelProperty-Bv7KzP97.js.map +1 -0
  8. package/dist/{Schema-BMXRF4j9.js → Schema-C_4wv0RP.js} +22 -22
  9. package/dist/{Schema-BMXRF4j9.js.map → Schema-C_4wv0RP.js.map} +1 -1
  10. package/dist/{SchemaValidationService-CieGrj5c.js → SchemaValidationService-Dc-lpFQX.js} +9 -7
  11. package/dist/{SchemaValidationService-CieGrj5c.js.map → SchemaValidationService-Dc-lpFQX.js.map} +1 -1
  12. package/dist/arweaveContentTags-iW_HcWJA.js +1456 -0
  13. package/dist/arweaveContentTags-iW_HcWJA.js.map +1 -0
  14. package/dist/{configurePlatform-WkmvqeTO.js → configurePlatform-BH1YOZpg.js} +2 -2
  15. package/dist/{configurePlatform-WkmvqeTO.js.map → configurePlatform-BH1YOZpg.js.map} +1 -1
  16. package/dist/db/drizzle/0030_drop_property_uids.sql +1 -0
  17. package/dist/db/drizzle/meta/0030_snapshot.json +1638 -0
  18. package/dist/db/drizzle/meta/_journal.json +8 -1
  19. package/dist/{detachRowsBeforeDelete-BZr_0iZU.js → detachRowsBeforeDelete-Cie55SoG.js} +4 -6
  20. package/dist/detachRowsBeforeDelete-Cie55SoG.js.map +1 -0
  21. package/dist/dist/{BaseFileManager-DLou1TZS.d.ts → BaseFileManager-D-pLXQAp.d.ts} +432 -495
  22. package/dist/dist/BaseFileManager-D-pLXQAp.d.ts.map +1 -0
  23. package/dist/dist/{configurePlatform-WkmvqeTO.d.ts → configurePlatform-BH1YOZpg.d.ts} +1 -1
  24. package/dist/dist/configurePlatform-BH1YOZpg.d.ts.map +1 -0
  25. package/dist/dist/{index-BjWk0x4-.d.ts → index-2PaIhvOU.d.ts} +1 -64
  26. package/dist/dist/{index-BjWk0x4-.d.ts.map → index-2PaIhvOU.d.ts.map} +1 -1
  27. package/dist/dist/{index.node-BfiBriEq.d.ts → index.node-C3rI1upv.d.ts} +25 -281
  28. package/dist/dist/{index.node-BfiBriEq.d.ts.map → index.node-C3rI1upv.d.ts.map} +1 -1
  29. package/dist/dist/minimumUpgradeVersion-Dg2MguFf.d.ts +20 -0
  30. package/dist/dist/minimumUpgradeVersion-Dg2MguFf.d.ts.map +1 -0
  31. package/dist/dist/platform.node.d.ts +2 -2
  32. package/dist/download-DHWUPLlK.js +393 -0
  33. package/dist/download-DHWUPLlK.js.map +1 -0
  34. package/dist/{eas-FZPPqxqe.js → eas-MXEdKKVc.js} +12 -10
  35. package/dist/{eas-FZPPqxqe.js.map → eas-MXEdKKVc.js.map} +1 -1
  36. package/dist/ensureImageLocal-B6suz6FC.js +175 -0
  37. package/dist/ensureImageLocal-B6suz6FC.js.map +1 -0
  38. package/dist/{getPublishPayload-DKuEaq96.js → getPublishPayload-Dd3HCYeI.js} +8 -49
  39. package/dist/getPublishPayload-Dd3HCYeI.js.map +1 -0
  40. package/dist/{getPublishPendingDiff-CH5xLMjU.js → getPublishPendingDiff-kcTP52Kj.js} +13 -12
  41. package/dist/{getPublishPendingDiff-CH5xLMjU.js.map → getPublishPendingDiff-kcTP52Kj.js.map} +1 -1
  42. package/dist/{index-BjWk0x4-.js → index-2PaIhvOU.js} +2 -4
  43. package/dist/index-2PaIhvOU.js.map +1 -0
  44. package/dist/index-BXTyvnKb.js +28 -0
  45. package/dist/index-BXTyvnKb.js.map +1 -0
  46. package/dist/{index-DXRhFg1N.js → index-CmNqUKQN.js} +10 -8
  47. package/dist/index-CmNqUKQN.js.map +1 -0
  48. package/dist/{index-Gh42_47r.js → index-Xs_EDi-_.js} +18 -401
  49. package/dist/index-Xs_EDi-_.js.map +1 -0
  50. package/dist/{index.browser-DQstVvRV.js → index.browser-BkcOQGhw.js} +59 -102
  51. package/dist/index.browser-BkcOQGhw.js.map +1 -0
  52. package/dist/{index.node-BfiBriEq.js → index.node-C3rI1upv.js} +14 -36
  53. package/dist/index.node-C3rI1upv.js.map +1 -0
  54. package/dist/main.js +19 -19
  55. package/dist/{minimumUpgradeVersion-BDhHvHtr.js → minimumUpgradeVersion-Dg2MguFf.js} +38 -9
  56. package/dist/minimumUpgradeVersion-Dg2MguFf.js.map +1 -0
  57. package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js → modelPropertyRecordSchemas-CEac3FB8.js} +10 -10
  58. package/dist/{modelPropertyRecordSchemas-DEe-lYhn.js.map → modelPropertyRecordSchemas-CEac3FB8.js.map} +1 -1
  59. package/dist/node.js +14 -12
  60. package/dist/node.js.map +1 -1
  61. package/dist/platform.browser.js +10 -12
  62. package/dist/platform.browser.js.map +1 -1
  63. package/dist/platform.node.js +5 -5
  64. package/dist/{property-iNW1N3vm.js → property-4jSqHieb.js} +9 -9
  65. package/dist/{property-iNW1N3vm.js.map → property-4jSqHieb.js.map} +1 -1
  66. package/dist/{errors-CnT0fSMK.js → publishErrors-DZXDX3B6.js} +1830 -245
  67. package/dist/publishErrors-DZXDX3B6.js.map +1 -0
  68. package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js → readHtmlBodyForStorageSeed-Cva1DPzE.js} +10 -12
  69. package/dist/{readHtmlBodyForStorageSeed-B7HgPmq6.js.map → readHtmlBodyForStorageSeed-Cva1DPzE.js.map} +1 -1
  70. package/dist/seedSchema/index.ts +0 -1
  71. package/dist/src/Item/Item.d.ts.map +1 -1
  72. package/dist/src/ItemProperty/ItemProperty.d.ts +1 -0
  73. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  74. package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
  75. package/dist/src/Model/index.d.ts +0 -2
  76. package/dist/src/Model/index.d.ts.map +1 -1
  77. package/dist/src/browser/db/Db.d.ts.map +1 -1
  78. package/dist/src/browser/db/drizzleFiles.d.ts +3 -2
  79. package/dist/src/browser/db/drizzleFiles.d.ts.map +1 -1
  80. package/dist/src/browser/helpers/FileManager.d.ts +1 -3
  81. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  82. package/dist/src/browser/workers/FileDownloader.d.ts +1 -0
  83. package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
  84. package/dist/src/browser/workers/ImageResizer.d.ts +1 -0
  85. package/dist/src/browser/workers/ImageResizer.d.ts.map +1 -1
  86. package/dist/src/client/actors/addModelsToDb.d.ts.map +1 -1
  87. package/dist/src/client/actors/saveAppState.d.ts.map +1 -1
  88. package/dist/src/client/actors/saveConfig.d.ts.map +1 -1
  89. package/dist/src/db/minimumUpgradeVersion.d.ts +20 -5
  90. package/dist/src/db/minimumUpgradeVersion.d.ts.map +1 -1
  91. package/dist/src/db/read/metadataProperty.d.ts +1 -1
  92. package/dist/src/db/read/metadataProperty.d.ts.map +1 -1
  93. package/dist/src/db/read/resolveModelRecord.d.ts +0 -20
  94. package/dist/src/db/read/resolveModelRecord.d.ts.map +1 -1
  95. package/dist/src/db/write/createMetadata.d.ts +1 -8
  96. package/dist/src/db/write/createMetadata.d.ts.map +1 -1
  97. package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts +0 -5
  98. package/dist/src/db/write/removeLocalCopiesForAddresses.d.ts.map +1 -1
  99. package/dist/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  100. package/dist/src/events/files/download.d.ts.map +1 -1
  101. package/dist/src/events/item/syncDbWithEas.d.ts.map +1 -1
  102. package/dist/src/helpers/easPropertyCanonical.d.ts +1 -1
  103. package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -1
  104. package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts +2 -3
  105. package/dist/src/helpers/entity/detachRowsBeforeDelete.d.ts.map +1 -1
  106. package/dist/src/helpers/entity/entityLifecycle.d.ts +0 -2
  107. package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -1
  108. package/dist/src/helpers/environment.d.ts +0 -13
  109. package/dist/src/helpers/environment.d.ts.map +1 -1
  110. package/dist/src/helpers/index.d.ts +0 -4
  111. package/dist/src/helpers/index.d.ts.map +1 -1
  112. package/dist/src/helpers/itemStorageFile.d.ts +0 -11
  113. package/dist/src/helpers/itemStorageFile.d.ts.map +1 -1
  114. package/dist/src/helpers/propertySchemaUid.d.ts +7 -5
  115. package/dist/src/helpers/propertySchemaUid.d.ts.map +1 -1
  116. package/dist/src/helpers/storageDir.d.ts +0 -2
  117. package/dist/src/helpers/storageDir.d.ts.map +1 -1
  118. package/dist/src/index.d.ts +4 -1
  119. package/dist/src/index.d.ts.map +1 -1
  120. package/dist/src/node/db/Db.d.ts +0 -2
  121. package/dist/src/node/db/Db.d.ts.map +1 -1
  122. package/dist/src/node/helpers/FileManager.d.ts +0 -2
  123. package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
  124. package/dist/src/node/index.d.ts +11 -3
  125. package/dist/src/node/index.d.ts.map +1 -1
  126. package/dist/src/outbox/index.d.ts +5 -5
  127. package/dist/src/outbox/index.d.ts.map +1 -1
  128. package/dist/src/seedSchema/index.d.ts +0 -1
  129. package/dist/src/seedSchema/index.d.ts.map +1 -1
  130. package/dist/{syncDbWithEas-FuyqoEKk.js → syncDbWithEas-V_9gIyHp.js} +25 -23
  131. package/dist/syncDbWithEas-V_9gIyHp.js.map +1 -0
  132. package/dist/{tolerantWebAccess-zEseJ2zT.js → tolerantWebAccess-D6hFxREe.js} +11 -13
  133. package/dist/{tolerantWebAccess-zEseJ2zT.js.map → tolerantWebAccess-D6hFxREe.js.map} +1 -1
  134. package/dist/{updateSeedRevokedAt-B9JRwr5T.js → updateSeedRevokedAt-CsAoUEEt.js} +4 -3
  135. package/dist/{updateSeedRevokedAt-B9JRwr5T.js.map → updateSeedRevokedAt-CsAoUEEt.js.map} +1 -1
  136. package/package.json +7 -12
  137. package/dist/BaseFileManager-DLou1TZS.js.map +0 -1
  138. package/dist/Item-oPnmIehk.js.map +0 -1
  139. package/dist/ModelProperty-D2vJozmW.js.map +0 -1
  140. package/dist/detachRowsBeforeDelete-BZr_0iZU.js.map +0 -1
  141. package/dist/dist/BaseFileManager-DLou1TZS.d.ts.map +0 -1
  142. package/dist/dist/configurePlatform-WkmvqeTO.d.ts.map +0 -1
  143. package/dist/dist/minimumUpgradeVersion-BDhHvHtr.d.ts +0 -9
  144. package/dist/dist/minimumUpgradeVersion-BDhHvHtr.d.ts.map +0 -1
  145. package/dist/errors-CnT0fSMK.js.map +0 -1
  146. package/dist/getPublishPayload-DKuEaq96.js.map +0 -1
  147. package/dist/getPublishUploads-DivYpgNw.js +0 -783
  148. package/dist/getPublishUploads-DivYpgNw.js.map +0 -1
  149. package/dist/index-BjWk0x4-.js.map +0 -1
  150. package/dist/index-CZMWKXLM.js +0 -27
  151. package/dist/index-CZMWKXLM.js.map +0 -1
  152. package/dist/index-DXRhFg1N.js.map +0 -1
  153. package/dist/index-Gh42_47r.js.map +0 -1
  154. package/dist/index.browser-DQstVvRV.js.map +0 -1
  155. package/dist/index.node-BfiBriEq.js.map +0 -1
  156. package/dist/minimumUpgradeVersion-BDhHvHtr.js.map +0 -1
  157. package/dist/publishGraph-CRn_N3NT.js +0 -311
  158. package/dist/publishGraph-CRn_N3NT.js.map +0 -1
  159. package/dist/seedSchema/PropertyUidSchema.ts +0 -16
  160. package/dist/src/db/read/getItemProperty.d.ts +0 -6
  161. package/dist/src/db/read/getItemProperty.d.ts.map +0 -1
  162. package/dist/src/db/read/isSeedRevoked.d.ts +0 -7
  163. package/dist/src/db/read/isSeedRevoked.d.ts.map +0 -1
  164. package/dist/src/db/write/saveMetadata.d.ts +0 -3
  165. package/dist/src/db/write/saveMetadata.d.ts.map +0 -1
  166. package/dist/src/db/write/updateMetadata.d.ts +0 -13
  167. package/dist/src/db/write/updateMetadata.d.ts.map +0 -1
  168. package/dist/src/seedSchema/PropertyUidSchema.d.ts +0 -64
  169. package/dist/src/seedSchema/PropertyUidSchema.d.ts.map +0 -1
  170. package/dist/src/types/fileManager.d.ts +0 -13
  171. package/dist/src/types/fileManager.d.ts.map +0 -1
  172. package/dist/syncDbWithEas-FuyqoEKk.js.map +0 -1
  173. package/dist/tabEvents-DT5ez6io.js +0 -3830
  174. package/dist/tabEvents-DT5ez6io.js.map +0 -1
@@ -0,0 +1,175 @@
1
+ import debug from 'debug';
2
+ import { downloadTransactionIdWithDedupe } from './download-DHWUPLlK.js';
3
+ import { s as supportsOpfsFileDownloads, I as ImageSize } from './arweaveContentTags-iW_HcWJA.js';
4
+ import { r as BaseFileManager } from './BaseFileManager-D-pLXQAp.js';
5
+ import { y as findFileInDir } from './Item-BU9wIT7l.js';
6
+ import 'drizzle-orm';
7
+ import '@seedprotocol/arweave';
8
+ import 'pluralize';
9
+ import '@seedprotocol/eas';
10
+ import 'lodash-es';
11
+ import '@sinclair/typebox';
12
+ import 'nanoid';
13
+ import 'nanoid-dictionary';
14
+ import '@noble/hashes/sha256';
15
+ import '@noble/hashes/sha3';
16
+ import '@noble/hashes/utils';
17
+ import 'drizzle-orm/sqlite-core';
18
+ import 'xstate';
19
+ import 'rxjs';
20
+
21
+ const logger = debug('seedSdk:helpers:ensureImageLocal');
22
+ /** Arweave transaction ids are 43 chars in the URL-safe base64 alphabet. */
23
+ const ARWEAVE_TX_ID_RE = /^[a-z0-9_-]{43}$/i;
24
+ const IMAGE_SIZES = [
25
+ ImageSize.EXTRA_SMALL,
26
+ ImageSize.SMALL,
27
+ ImageSize.MEDIUM,
28
+ ImageSize.LARGE,
29
+ ImageSize.EXTRA_LARGE,
30
+ ];
31
+ const inFlightByKey = new Map();
32
+ const normalizeArweaveTxIdForEnsure = (raw) => {
33
+ if (raw == null || raw === '')
34
+ return undefined;
35
+ const t = String(raw).trim();
36
+ if (ARWEAVE_TX_ID_RE.test(t))
37
+ return t;
38
+ const m = t.match(/^([a-z0-9_-]{43})(?:\.[^/]+)?$/i);
39
+ if (m)
40
+ return m[1];
41
+ const embedded = t.match(/[a-z0-9_-]{43}/gi);
42
+ if (embedded) {
43
+ for (const candidate of embedded) {
44
+ if (ARWEAVE_TX_ID_RE.test(candidate))
45
+ return candidate;
46
+ }
47
+ }
48
+ return undefined;
49
+ };
50
+ const closestImageSize = (width) => {
51
+ let best = ImageSize.EXTRA_SMALL;
52
+ let bestDist = Math.abs(best - width);
53
+ for (const size of IMAGE_SIZES) {
54
+ const dist = Math.abs(size - width);
55
+ if (dist < bestDist) {
56
+ best = size;
57
+ bestDist = dist;
58
+ }
59
+ }
60
+ return best;
61
+ };
62
+ const mapRequestedWidthsToImageSizes = (widths) => {
63
+ const requested = widths && widths.length > 0 ? widths : [ImageSize.EXTRA_SMALL];
64
+ const unique = new Set();
65
+ for (const w of requested) {
66
+ if (typeof w !== 'number' || !Number.isFinite(w) || w <= 0)
67
+ continue;
68
+ unique.add(closestImageSize(w));
69
+ }
70
+ if (unique.size === 0) {
71
+ unique.add(ImageSize.EXTRA_SMALL);
72
+ }
73
+ return Array.from(unique).sort((a, b) => a - b);
74
+ };
75
+ const getBasename = (filePath) => {
76
+ const path = BaseFileManager.getPathModule();
77
+ return path.basename(filePath);
78
+ };
79
+ const getBasenameWithoutExtension = (fileName) => {
80
+ const match = fileName.match(/^(.*[\/\\])?([^\/\\]+?)(\.[^.\/\\]*)?$/);
81
+ return match?.[2] ?? fileName;
82
+ };
83
+ const sizedVariantPath = (originalFilePath, size) => {
84
+ const path = BaseFileManager.getPathModule();
85
+ const dir = path.dirname(originalFilePath);
86
+ const base = getBasenameWithoutExtension(getBasename(originalFilePath));
87
+ return path.join(dir, String(size), `${base}.webp`);
88
+ };
89
+ const ensureKey = (txId, fileName, sizes) => {
90
+ const idPart = txId ?? fileName ?? '';
91
+ return `${idPart}|${sizes.join(',')}`;
92
+ };
93
+ const runEnsureImageLocal = async (params) => {
94
+ if (!supportsOpfsFileDownloads()) {
95
+ return { status: 'unsupported' };
96
+ }
97
+ const fileName = params.fileName?.trim() || undefined;
98
+ const txId = normalizeArweaveTxIdForEnsure(params.transactionId) ??
99
+ normalizeArweaveTxIdForEnsure(fileName);
100
+ if (!txId && !fileName) {
101
+ return { status: 'missing-id' };
102
+ }
103
+ const targetSizes = mapRequestedWidthsToImageSizes(params.widths);
104
+ const needles = [fileName, txId].filter((n) => typeof n === 'string' && n.length > 0);
105
+ try {
106
+ let filePath = await findFileInDir('images', needles);
107
+ if (!filePath && txId) {
108
+ await downloadTransactionIdWithDedupe(txId);
109
+ filePath = await findFileInDir('images', needles);
110
+ }
111
+ if (!filePath) {
112
+ return { status: 'failed' };
113
+ }
114
+ const createdWidths = [];
115
+ for (const size of targetSizes) {
116
+ const variantPath = sizedVariantPath(filePath, size);
117
+ const exists = await BaseFileManager.pathExists(variantPath);
118
+ if (exists)
119
+ continue;
120
+ await BaseFileManager.resizeImage({
121
+ filePath,
122
+ width: size,
123
+ height: size,
124
+ });
125
+ createdWidths.push(size);
126
+ }
127
+ return {
128
+ status: 'ready',
129
+ filePath,
130
+ createdWidths,
131
+ };
132
+ }
133
+ catch (error) {
134
+ logger('ensureImageLocal failed', error);
135
+ return { status: 'failed' };
136
+ }
137
+ };
138
+ /**
139
+ * Ensure an image original exists in OPFS (downloading from Arweave if needed)
140
+ * and create only the requested ImageSize variant(s) for that one file.
141
+ */
142
+ const ensureImageLocal = async (params) => {
143
+ if (!supportsOpfsFileDownloads()) {
144
+ return { status: 'unsupported' };
145
+ }
146
+ const fileName = params.fileName?.trim() || undefined;
147
+ const txId = normalizeArweaveTxIdForEnsure(params.transactionId) ??
148
+ normalizeArweaveTxIdForEnsure(fileName);
149
+ if (!txId && !fileName) {
150
+ return { status: 'missing-id' };
151
+ }
152
+ const targetSizes = mapRequestedWidthsToImageSizes(params.widths);
153
+ const key = ensureKey(txId, fileName, targetSizes);
154
+ const existing = inFlightByKey.get(key);
155
+ if (existing) {
156
+ return existing;
157
+ }
158
+ const inFlight = (async () => {
159
+ try {
160
+ return await runEnsureImageLocal({
161
+ transactionId: txId,
162
+ fileName,
163
+ widths: targetSizes,
164
+ });
165
+ }
166
+ finally {
167
+ inFlightByKey.delete(key);
168
+ }
169
+ })();
170
+ inFlightByKey.set(key, inFlight);
171
+ return inFlight;
172
+ };
173
+
174
+ export { closestImageSize, ensureImageLocal, normalizeArweaveTxIdForEnsure };
175
+ //# sourceMappingURL=ensureImageLocal-B6suz6FC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureImageLocal-B6suz6FC.js","sources":["../../src/helpers/ensureImageLocal.ts"],"sourcesContent":["import debug from 'debug'\nimport { downloadTransactionIdWithDedupe } from '@/events/files/download'\nimport { ImageSize } from '@/helpers/constants'\nimport { supportsOpfsFileDownloads } from '@/helpers/environment'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport { findFileInDir } from '@/storageValue/findFile'\n\nconst logger = debug('seedSdk:helpers:ensureImageLocal')\n\n/** Arweave transaction ids are 43 chars in the URL-safe base64 alphabet. */\nconst ARWEAVE_TX_ID_RE = /^[a-z0-9_-]{43}$/i\n\nconst IMAGE_SIZES = [\n ImageSize.EXTRA_SMALL,\n ImageSize.SMALL,\n ImageSize.MEDIUM,\n ImageSize.LARGE,\n ImageSize.EXTRA_LARGE,\n] as const\n\nexport type EnsureImageLocalParams = {\n /** 43-char tx id, or a URL/path containing one */\n transactionId?: string\n /** Local basename / refResolvedValue under images/ */\n fileName?: string\n /** Display widths; each mapped to closest ImageSize. Default: [EXTRA_SMALL] */\n widths?: number[]\n}\n\nexport type EnsureImageLocalResult = {\n status: 'ready' | 'unsupported' | 'failed' | 'missing-id'\n filePath?: string\n createdWidths?: number[]\n}\n\nconst inFlightByKey = new Map<string, Promise<EnsureImageLocalResult>>()\n\nexport const normalizeArweaveTxIdForEnsure = (\n raw: string | null | undefined,\n): string | undefined => {\n if (raw == null || raw === '') return undefined\n const t = String(raw).trim()\n if (ARWEAVE_TX_ID_RE.test(t)) return t\n const m = t.match(/^([a-z0-9_-]{43})(?:\\.[^/]+)?$/i)\n if (m) return m[1]\n const embedded = t.match(/[a-z0-9_-]{43}/gi)\n if (embedded) {\n for (const candidate of embedded) {\n if (ARWEAVE_TX_ID_RE.test(candidate)) return candidate\n }\n }\n return undefined\n}\n\nexport const closestImageSize = (width: number): ImageSize => {\n let best: ImageSize = ImageSize.EXTRA_SMALL\n let bestDist = Math.abs(best - width)\n for (const size of IMAGE_SIZES) {\n const dist = Math.abs(size - width)\n if (dist < bestDist) {\n best = size\n bestDist = dist\n }\n }\n return best\n}\n\nconst mapRequestedWidthsToImageSizes = (widths?: number[]): ImageSize[] => {\n const requested =\n widths && widths.length > 0 ? widths : [ImageSize.EXTRA_SMALL]\n const unique = new Set<ImageSize>()\n for (const w of requested) {\n if (typeof w !== 'number' || !Number.isFinite(w) || w <= 0) continue\n unique.add(closestImageSize(w))\n }\n if (unique.size === 0) {\n unique.add(ImageSize.EXTRA_SMALL)\n }\n return Array.from(unique).sort((a, b) => a - b)\n}\n\nconst getBasename = (filePath: string): string => {\n const path = BaseFileManager.getPathModule()\n return path.basename(filePath)\n}\n\nconst getBasenameWithoutExtension = (fileName: string): string => {\n const match = fileName.match(/^(.*[\\/\\\\])?([^\\/\\\\]+?)(\\.[^.\\/\\\\]*)?$/)\n return match?.[2] ?? fileName\n}\n\nconst sizedVariantPath = (originalFilePath: string, size: ImageSize): string => {\n const path = BaseFileManager.getPathModule()\n const dir = path.dirname(originalFilePath)\n const base = getBasenameWithoutExtension(getBasename(originalFilePath))\n return path.join(dir, String(size), `${base}.webp`)\n}\n\nconst ensureKey = (\n txId: string | undefined,\n fileName: string | undefined,\n sizes: ImageSize[],\n): string => {\n const idPart = txId ?? fileName ?? ''\n return `${idPart}|${sizes.join(',')}`\n}\n\nconst runEnsureImageLocal = async (\n params: EnsureImageLocalParams,\n): Promise<EnsureImageLocalResult> => {\n if (!supportsOpfsFileDownloads()) {\n return { status: 'unsupported' }\n }\n\n const fileName = params.fileName?.trim() || undefined\n const txId =\n normalizeArweaveTxIdForEnsure(params.transactionId) ??\n normalizeArweaveTxIdForEnsure(fileName)\n\n if (!txId && !fileName) {\n return { status: 'missing-id' }\n }\n\n const targetSizes = mapRequestedWidthsToImageSizes(params.widths)\n const needles = [fileName, txId].filter(\n (n): n is string => typeof n === 'string' && n.length > 0,\n )\n\n try {\n let filePath = await findFileInDir('images', needles)\n if (!filePath && txId) {\n await downloadTransactionIdWithDedupe(txId)\n filePath = await findFileInDir('images', needles)\n }\n\n if (!filePath) {\n return { status: 'failed' }\n }\n\n const createdWidths: number[] = []\n for (const size of targetSizes) {\n const variantPath = sizedVariantPath(filePath, size)\n const exists = await BaseFileManager.pathExists(variantPath)\n if (exists) continue\n await BaseFileManager.resizeImage({\n filePath,\n width: size,\n height: size,\n })\n createdWidths.push(size)\n }\n\n return {\n status: 'ready',\n filePath,\n createdWidths,\n }\n } catch (error) {\n logger('ensureImageLocal failed', error)\n return { status: 'failed' }\n }\n}\n\n/**\n * Ensure an image original exists in OPFS (downloading from Arweave if needed)\n * and create only the requested ImageSize variant(s) for that one file.\n */\nexport const ensureImageLocal = async (\n params: EnsureImageLocalParams,\n): Promise<EnsureImageLocalResult> => {\n if (!supportsOpfsFileDownloads()) {\n return { status: 'unsupported' }\n }\n\n const fileName = params.fileName?.trim() || undefined\n const txId =\n normalizeArweaveTxIdForEnsure(params.transactionId) ??\n normalizeArweaveTxIdForEnsure(fileName)\n\n if (!txId && !fileName) {\n return { status: 'missing-id' }\n }\n\n const targetSizes = mapRequestedWidthsToImageSizes(params.widths)\n const key = ensureKey(txId, fileName, targetSizes)\n\n const existing = inFlightByKey.get(key)\n if (existing) {\n return existing\n }\n\n const inFlight = (async () => {\n try {\n return await runEnsureImageLocal({\n transactionId: txId,\n fileName,\n widths: targetSizes,\n })\n } finally {\n inFlightByKey.delete(key)\n }\n })()\n\n inFlightByKey.set(key, inFlight)\n return inFlight\n}\n\n/** Test-only: clear in-flight dedupe map. */\nexport const resetEnsureImageLocalInFlightForTests = (): void => {\n inFlightByKey.clear()\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA,MAAM,MAAM,GAAG,KAAK,CAAC,kCAAkC,CAAC;AAExD;AACA,MAAM,gBAAgB,GAAG,mBAAmB;AAE5C,MAAM,WAAW,GAAG;AAClB,IAAA,SAAS,CAAC,WAAW;AACrB,IAAA,SAAS,CAAC,KAAK;AACf,IAAA,SAAS,CAAC,MAAM;AAChB,IAAA,SAAS,CAAC,KAAK;AACf,IAAA,SAAS,CAAC,WAAW;CACb;AAiBV,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2C;AAEjE,MAAM,6BAA6B,GAAG,CAC3C,GAA8B,KACR;AACtB,IAAA,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE;AAAE,QAAA,OAAO,SAAS;IAC/C,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AAC5B,IAAA,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,iCAAiC,CAAC;AACpD,IAAA,IAAI,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;IAC5C,IAAI,QAAQ,EAAE;AACZ,QAAA,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE;AAChC,YAAA,IAAI,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC;AAAE,gBAAA,OAAO,SAAS;QACxD;IACF;AACA,IAAA,OAAO,SAAS;AAClB;AAEO,MAAM,gBAAgB,GAAG,CAAC,KAAa,KAAe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,GAAG,OAC9B,MAA8B,KACK;AACnC,IAAA,IAAI,CAAC,yBAAyB,EAAE,EAAE;AAChC,QAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE;IAClC;IAEA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,SAAS;AACrD,IAAA,MAAM,IAAI,GACR,6BAA6B,CAAC,MAAM,CAAC,aAAa,CAAC;QACnD,6BAA6B,CAAC,QAAQ,CAAC;AAEzC,IAAA,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;AACtB,QAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;IACjC;IAEA,MAAM,WAAW,GAAG,8BAA8B,CAAC,MAAM,CAAC,MAAM,CAAC;IACjE,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC;IAElD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,QAAQ;IACjB;AAEA,IAAA,MAAM,QAAQ,GAAG,CAAC,YAAW;AAC3B,QAAA,IAAI;YACF,OAAO,MAAM,mBAAmB,CAAC;AAC/B,gBAAA,aAAa,EAAE,IAAI;gBACnB,QAAQ;AACR,gBAAA,MAAM,EAAE,WAAW;AACpB,aAAA,CAAC;QACJ;gBAAU;AACR,YAAA,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC;QAC3B;IACF,CAAC,GAAG;AAEJ,IAAA,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC;AAChC,IAAA,OAAO,QAAQ;AACjB;;"}
@@ -1,11 +1,10 @@
1
1
  import { isValidEasAttestationUid, VERSION_SCHEMA_UID, decodeEasNumber, getSchemaUidForSchemaDefinitionFromCache, easName, getEasSchemaUidForSchemaDefinition } from '@seedprotocol/eas';
2
- import { $ as isNode, Z as ZERO_BYTES32, a0 as INTERNAL_PROPERTY_NAMES, M as ModelPropertyDataTypes, n as normalizeDataType, a1 as defaultAttestationData, v as INTERNAL_DATA_TYPES } from './tabEvents-DT5ez6io.js';
3
- import { af as matchMetadataProperty, ag as metadataRowsOfProperty, ah as METADATA_LATEST_FIRST_ORDER_SQL, K as isPublishedMetadataRow, ai as getEasSchemaUidForModel, aj as isStorageSeedRef, a9 as listRelationEasPropertyName, aa as easPropertyNameForPublish, ab as metadataStorageName } from './Item-oPnmIehk.js';
2
+ import { q as isNode, Z as ZERO_BYTES32, r as INTERNAL_PROPERTY_NAMES, M as ModelPropertyDataTypes, n as normalizeDataType, t as defaultAttestationData, m as INTERNAL_DATA_TYPES } from './arweaveContentTags-iW_HcWJA.js';
3
+ import { an as matchMetadataProperty, ao as metadataRowsOfProperty, ap as METADATA_LATEST_FIRST_ORDER_SQL, G as isPublishedMetadataRow, aq as getEasSchemaUidForModel, ar as isStorageSeedRef, ah as listRelationEasPropertyName, ai as easPropertyNameForPublish, aj as metadataStorageName } from './Item-BU9wIT7l.js';
4
4
  import { or, eq, and, sql } from 'drizzle-orm';
5
- import { B as BaseDb, m as metadata } from './BaseFileManager-DLou1TZS.js';
6
- import './errors-CnT0fSMK.js';
5
+ import { B as BaseDb, m as metadata } from './BaseFileManager-D-pLXQAp.js';
6
+ import { F as getPublishGraph, c as RelatedItemUnpublishedError, P as PublishValidationFailedError, G as htmlPropertyForHtmlSeed } from './publishErrors-DZXDX3B6.js';
7
7
  import 'pluralize';
8
- import { g as getPublishGraph, h as htmlPropertyForHtmlSeed } from './publishGraph-CRn_N3NT.js';
9
8
 
10
9
  const isEmptyValue = (value) => value == null || value === '';
11
10
  /**
@@ -63,7 +62,7 @@ async function getPendingRetractions(params) {
63
62
  const { seedLocalId, seedUid } = params;
64
63
  if (!seedLocalId && !seedUid)
65
64
  return [];
66
- const { getPublishPendingDiff } = await import('./getPublishPendingDiff-CH5xLMjU.js');
65
+ const { getPublishPendingDiff } = await import('./getPublishPendingDiff-kcTP52Kj.js');
67
66
  const { pendingProperties } = await getPublishPendingDiff({
68
67
  seedLocalId: seedLocalId ?? undefined,
69
68
  seedUid: seedUid ?? undefined,
@@ -130,46 +129,6 @@ function encodeBytes32String(value) {
130
129
  return `0x${hex.padEnd(64, '0')}`;
131
130
  }
132
131
 
133
- /** Error thrown when publish validation fails. Includes all validation errors for user to fix. */
134
- class PublishValidationFailedError extends Error {
135
- constructor(message, validationErrors) {
136
- super(message);
137
- this.validationErrors = validationErrors;
138
- this.name = 'PublishValidationFailedError';
139
- }
140
- }
141
- /** Validation error code for a relation, list member or image/file ref to an unpublished seed. */
142
- const RELATED_ITEM_UNPUBLISHED_CODE = 'related_item_unpublished';
143
- const describeUnpublishedRelatedItem = (r) => `${r.propertyName} -> ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid})`;
144
- /**
145
- * Thrown before anything is uploaded or attested when the item references items whose seed was
146
- * unpublished: the parent would attest a revoked seed uid. Republish those items (which gives
147
- * them a new seed uid) or remove the references, then publish again.
148
- * See docs/ATTESTATION_REVOCATION.md ("Republishing").
149
- *
150
- * A PublishValidationFailedError, so validateItemForPublish and the publish package's checking
151
- * step report it as validation errors (code `related_item_unpublished`, one per reference).
152
- */
153
- class RelatedItemUnpublishedError extends PublishValidationFailedError {
154
- constructor(unpublishedRelatedItems, otherValidationErrors = []) {
155
- const lines = unpublishedRelatedItems.map(describeUnpublishedRelatedItem);
156
- const message = `Cannot publish: it references ${lines.length} unpublished item${lines.length === 1 ? '' : 's'} ` +
157
- `(their seed attestations were revoked). Republish them or remove the references, then publish again:\n` +
158
- lines.join('\n');
159
- super(message, [
160
- ...unpublishedRelatedItems.map((r) => ({
161
- field: r.propertyName,
162
- message: `${r.propertyName} references unpublished ${r.modelName} ${r.seedLocalId} (seed ${r.seedUid}). ` +
163
- `Republish it or remove the reference.`,
164
- code: RELATED_ITEM_UNPUBLISHED_CODE,
165
- })),
166
- ...otherValidationErrors,
167
- ]);
168
- this.name = 'RelatedItemUnpublishedError';
169
- this.unpublishedRelatedItems = unpublishedRelatedItems;
170
- }
171
- }
172
-
173
132
  const matchesDataType = (actual, expected) => normalizeDataType(actual) === expected;
174
133
  /**
175
134
  * An EAS uid (0x + 64 hex), as opposed to a local id. A "0x" prefix alone doesn't tell them apart:
@@ -344,7 +303,7 @@ async function attestProperty(node, property, versionUid, ctx) {
344
303
  value = booleanFromRow(value.trim());
345
304
  // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
346
305
  if (definition.validation) {
347
- const { SchemaValidationService } = await import('./SchemaValidationService-CieGrj5c.js');
306
+ const { SchemaValidationService } = await import('./SchemaValidationService-Dc-lpFQX.js');
348
307
  const result = new SchemaValidationService().validatePropertyValue(value, normalizeDataType(definition.dataType), definition.validation, definition.refValueType ? normalizeDataType(definition.refValueType) : undefined);
349
308
  if (!result.isValid && result.errors.length > 0) {
350
309
  const firstError = result.errors[0];
@@ -756,5 +715,5 @@ var getPublishPayload$1 = /*#__PURE__*/Object.freeze({
756
715
  validateItemForPublish: validateItemForPublish
757
716
  });
758
717
 
759
- export { PublishValidationFailedError as P, RELATED_ITEM_UNPUBLISHED_CODE as R, RelatedItemUnpublishedError as a, getPendingRetractions as b, getPublishPayload$1 as c, getPropertyClear as g, resolvePublishPayloadValues as r, validateItemForPublish as v };
760
- //# sourceMappingURL=getPublishPayload-DKuEaq96.js.map
718
+ export { getPendingRetractions as a, getPublishPayload$1 as b, getPropertyClear as g, resolvePublishPayloadValues as r, validateItemForPublish as v };
719
+ //# sourceMappingURL=getPublishPayload-Dd3HCYeI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPublishPayload-Dd3HCYeI.js","sources":["../../src/db/read/getPropertyClear.ts","../../src/helpers/easSdk.ts","../../src/helpers/ethereumUtils.ts","../../src/db/read/getPublishPayload.ts"],"sourcesContent":["import { and, eq, or, sql } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata, type MetadataType } from '@/seedSchema'\nimport { matchMetadataProperty, metadataRowsOfProperty } from '@/db/read/metadataProperty'\nimport { METADATA_LATEST_FIRST_ORDER_SQL } from '@/helpers/compareMetadataRowsLatestFirst'\nimport { isPublishedMetadataRow } from '@/helpers/isPublishedMetadataRow'\nimport { isValidEasAttestationUid } from '@seedprotocol/eas'\n\n/** An empty current value that publishing changes: it has live attestations to remove or retract. */\nexport type PropertyClear = {\n /** The newest row is an unpublished retraction: publish revokes `retractScope` instead of attesting. */\n retract: boolean\n /** The property's attestations on the seed that are still live, newest first. */\n live: MetadataType[]\n /**\n * What a retraction revokes: the live attestations on the Version of the newest one, and those on\n * other Versions whose value is one of theirs. That Version is the seed's current one unless the\n * property was attested only before it, or a `new_version` publish has just made a newer one.\n */\n retractScope: MetadataType[]\n}\n\nconst isEmptyValue = (value: string | null | undefined): boolean => value == null || value === ''\n\n/**\n * What publishing a property with an empty value does (ADR 0021). Undefined when there is nothing\n * to publish: the newest row holds a value, or the property has no live attestation (never\n * published, or already retracted). The property's rows are those linked by property_id, and rows\n * with none stored under one of its names.\n */\nexport async function getPropertyClear(params: {\n seedLocalId?: string | null\n seedUid?: string | null\n propertyName: string\n /** metadata.property_id when the caller has it; otherwise resolved from the name. */\n propertyId?: number | null\n modelName?: string | null\n dataType?: string\n refValueType?: string\n}): Promise<PropertyClear | undefined> {\n const { seedLocalId, seedUid, propertyName, propertyId, modelName, dataType, refValueType } = params\n if (!seedLocalId && !seedUid) return undefined\n const appDb = BaseDb.getAppDb()\n if (!appDb) return undefined\n\n // The property's rows by property_id (decision D4), rows with none by name\n const property = await matchMetadataProperty(\n { propertyId, propertyName, modelName, seedLocalId, seedUid, dataType, refValueType },\n appDb,\n )\n const seedWhere =\n seedLocalId && seedUid\n ? or(eq(metadata.seedLocalId, seedLocalId), eq(metadata.seedUid, seedUid))\n : seedLocalId\n ? eq(metadata.seedLocalId, seedLocalId)\n : eq(metadata.seedUid, seedUid!)\n const rows = (await appDb\n .select()\n .from(metadata)\n .where(and(metadataRowsOfProperty(property), seedWhere))\n .orderBy(sql.raw(METADATA_LATEST_FIRST_ORDER_SQL))) as MetadataType[]\n\n const newest = rows[0]\n if (!newest || !isEmptyValue(newest.propertyValue)) return undefined\n const live = rows.filter((row) => isValidEasAttestationUid(row.uid) && row.revokedAt == null)\n if (live.length === 0) return undefined\n\n // `live` is newest first\n const onVersion = live.filter((row) => row.versionUid === live[0]!.versionUid)\n const values = new Set(onVersion.map((row) => row.propertyValue))\n const retractScope = live.filter((row) => onVersion.includes(row) || values.has(row.propertyValue))\n\n return { retract: !!newest.retract && !isPublishedMetadataRow(newest), live, retractScope }\n}\n\n/** The empty value of an EAS type, or undefined for `bool` and `uint256`, which have none (ADR 0021). */\nexport function emptyEasValue(easDataType: string | undefined): string | string[] | undefined {\n if (easDataType === 'string') return ''\n if (easDataType === 'bytes32') return `0x${'0'.repeat(64)}`\n if (easDataType === 'bytes32[]') return []\n return undefined\n}\n\n/** A retracted property and the attestations publish revokes for it. */\nexport type PendingRetraction = {\n propertyName: string\n attestations: { uid: string; schemaUid: string }[]\n}\n\n/**\n * The seed's retracted properties that still have attestations to revoke (ADR 0021), with the\n * attestations publish revokes for each.\n */\nexport async function getPendingRetractions(params: {\n seedLocalId?: string | null\n seedUid?: string | null\n}): Promise<PendingRetraction[]> {\n const { seedLocalId, seedUid } = params\n if (!seedLocalId && !seedUid) return []\n const { getPublishPendingDiff } = await import('@/db/read/getPublishPendingDiff')\n const { pendingProperties } = await getPublishPendingDiff({\n seedLocalId: seedLocalId ?? undefined,\n seedUid: seedUid ?? undefined,\n })\n const retractions: PendingRetraction[] = []\n for (const { propertyName, change } of pendingProperties) {\n if (change !== 'retracted') continue\n const clear = await getPropertyClear({ seedLocalId, seedUid, propertyName })\n if (!clear?.retract) continue\n const attestations = clear.retractScope\n .filter((row) => row.uid && row.schemaUid)\n .map((row) => ({ uid: row.uid!, schemaUid: row.schemaUid! }))\n if (attestations.length > 0) retractions.push({ propertyName, attestations })\n }\n return retractions\n}\n","import { isNode } from '@/helpers/environment'\n\ntype EasSdk = typeof import('@ethereum-attestation-service/eas-sdk')\n\nlet easSdkPromise: Promise<EasSdk> | undefined\n\n/**\n * Load eas-sdk on first use instead of at SDK import time.\n *\n * On Node this loads eas-sdk's CommonJS build. Its ESM build (2.9.1+) does\n * `import { isEqual } from 'lodash'`, which Node rejects because lodash is\n * CommonJS, so a static import made `import '@seedprotocol/sdk'` fail unless the\n * app ran with `--import @seedprotocol/sdk/node-eas-lodash`.\n *\n * `process.getBuiltinModule` (Node 20.16+, 22.3+) keeps `node:module` out of the\n * import graph, so browser bundlers never see it. Bundlers resolve the\n * `import()` branch, and handle lodash there themselves.\n */\nexport function loadEasSdk(): Promise<EasSdk> {\n if (!easSdkPromise) {\n easSdkPromise = (async () => {\n if (isNode() && typeof document === 'undefined' && typeof process.getBuiltinModule === 'function') {\n try {\n const { createRequire } = process.getBuiltinModule('node:module')\n return createRequire(import.meta.url)('@ethereum-attestation-service/eas-sdk') as EasSdk\n } catch {\n // e.g. import.meta.url is not a file: URL (bundled renderer). Fall through.\n }\n }\n return import('@ethereum-attestation-service/eas-sdk')\n })()\n easSdkPromise.catch(() => {\n easSdkPromise = undefined\n })\n }\n return easSdkPromise\n}\n","/** UTF-8 string to 0x-prefixed bytes32 hex (right-padded with zeros). */\nexport function encodeBytes32String(value: string): string {\n const bytes = new TextEncoder().encode(value)\n if (bytes.length > 32) {\n throw new Error(`encodeBytes32String: value exceeds 32 bytes (${bytes.length})`)\n }\n const hex = Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n return `0x${hex.padEnd(64, '0')}`\n}\n","import {\n decodeEasNumber,\n easName,\n getEasSchemaUidForSchemaDefinition,\n getSchemaUidForSchemaDefinitionFromCache,\n} from '@seedprotocol/eas'\nimport {\n defaultAttestationData,\n INTERNAL_DATA_TYPES,\n INTERNAL_PROPERTY_NAMES,\n VERSION_SCHEMA_UID,\n ZERO_BYTES32,\n} from '@/helpers/constants'\nimport type {\n AttestationRequest,\n AttestationRequestData,\n} from '@ethereum-attestation-service/eas-sdk'\nimport { loadEasSdk } from '@/helpers/easSdk'\nimport { getEasSchemaUidForModel } from './getSchemaUidForModel'\nimport { emptyEasValue, getPropertyClear } from '@/db/read/getPropertyClear'\nimport { isStorageSeedRef } from '@/helpers/relationSeedRef'\nimport {\n easPropertyNameForPublish,\n listRelationEasPropertyName,\n metadataStorageName,\n} from '@/helpers/metadataPropertyNames'\nimport { encodeBytes32String } from '@/helpers/ethereumUtils'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport {\n PublishValidationFailedError,\n RelatedItemUnpublishedError,\n type PublishValidationError,\n} from '@/db/read/publishErrors'\nimport {\n getPublishGraph,\n htmlPropertyForHtmlSeed,\n type PublishGraph,\n type PublishGraphNode,\n type PublishGraphProperty,\n type PublishMode,\n} from '@/db/read/publishGraph'\n\nexport { PublishValidationFailedError, type PublishValidationError }\nexport type { PublishMode }\n\nexport type GetPublishPayloadOptions = {\n /** `patch` (default): new property attestations on the current Version. `new_version`: new Version attestation + attest all properties. */\n publishMode?: PublishMode\n}\n\ntype Attestation = Omit<AttestationRequest, 'data'> & {\n data: AttestationRequestData[]\n /** The property's schema key. */\n _propertyName?: string\n /** Metadata row the attested value was read from: recording gives the uid to exactly that row. */\n _metadataLocalId?: string\n /** A value that is not in that row yet (the storage transaction id of this publish's upload), for recording to store. */\n _attestedValue?: string\n /** Same as encode step (getPropertyData); resolvePublishPayloadValues must use this, not easName(propertyName). */\n _propertyNameForSchema?: string\n _schemaDef?: string\n _unresolvedValue?: string\n _easDataType?: string\n /** Per-slot raw ids (local or 0x) before encodeBytes32String; re-encoded after sequential publish. */\n _rawListIdsForResolve?: string[]\n}\n\ntype PublishPayload = {\n localId: string\n /** The version row this request's Version attestation is recorded on (none when it attests under an existing version). */\n versionLocalId?: string\n seedIsRevocable: boolean\n seedSchemaUid: string\n seedUid: string\n versionSchemaUid: string\n versionUid: string\n listOfAttestations: Attestation[]\n propertiesToUpdate: { publishLocalId: string; propertySchemaUid: string }[]\n}\n\ntype MultiPublishPayload = PublishPayload[]\n\n/** Map of seed localId -> attestation uid for resolving relation/image property values after dependent seeds are published */\nexport type ResolvedSeedUids = Record<string, string>\n\ntype UploadedTransaction = {\n txId: string\n itemPropertyLocalId?: string\n seedLocalId?: string\n versionLocalId?: string\n itemPropertyName?: string\n}\n\ntype BuildContext = {\n graph: PublishGraph\n errors: PublishValidationError[]\n uploadedTransactions: UploadedTransaction[]\n}\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\n\n/**\n * An EAS uid (0x + 64 hex), as opposed to a local id. A \"0x\" prefix alone doesn't tell them apart:\n * local ids are random alphanumerics, and about 1 in 3,844 starts with \"0x\".\n */\nfunction isUidRef(ref: string): boolean {\n return ref.length === 66 && ref.startsWith('0x')\n}\n\nfunction addValidationError(ctx: BuildContext, message: string, field?: string, code = 'publish_validation'): void {\n if (ctx.errors.some((e) => e.message === message && e.field === (field ?? ''))) return\n ctx.errors.push({ field: field ?? '', message, code })\n}\n\n/** Current uid for a ref to a live published seed, else the ref itself. */\nconst currentRelatedRef = (ctx: BuildContext, ref: string): string => ctx.graph.relatedRefUids.get(ref.trim()) ?? ref\n\nconst uploadedTxFor = (ctx: BuildContext, seedLocalId: string): UploadedTransaction | undefined =>\n ctx.uploadedTransactions.find((u) => u.seedLocalId?.trim() === seedLocalId)\n\ntype PropertyDataResult = {\n schemaUid: string\n easDataType: string\n schemaDef: string\n propertyNameForSchema: string\n}\n\n/** The EAS schema a property attests under. Reports an error and returns null when there is none. */\nconst getPropertyData = async (\n property: PublishGraphProperty,\n ctx: BuildContext,\n): Promise<PropertyDataResult | null> => {\n const { key, definition } = property\n const rawDataType = definition.dataType\n const dataType = rawDataType ? normalizeDataType(String(rawDataType)) : undefined\n const easDataType = dataType ? INTERNAL_DATA_TYPES[dataType as keyof typeof INTERNAL_DATA_TYPES]?.eas : undefined\n if (!easDataType) {\n addValidationError(\n ctx,\n `Unknown or unsupported property data type \"${rawDataType ?? 'undefined'}\" for property: ${key}. Supported types: ${Object.keys(INTERNAL_DATA_TYPES).join(', ')}.`,\n key,\n )\n return null\n }\n\n // ADR 0008: list relations publish under their storage name (authors → author_identity_ids),\n // single relations under their schema key (author), never the local authorId.\n const listRelationName = listRelationEasPropertyName(key, definition)\n const propertyNameForSchema = easPropertyNameForPublish(key, definition)\n const schemaDef = `${easDataType} ${propertyNameForSchema}`\n\n // The UID ensureEasSchemasForItem resolved for this exact definition comes first. A row's\n // schemaUid was looked up under the property's own name, which matches any type: Optimism\n // Sepolia has `bytes32 storage_transaction_id` beside `string storage_transaction_id`, and\n // attesting a string under the bytes32 one reads back as 0x…20. Trust the row's only when\n // that name is the one published (not for a list relation, or a single relation stored as authorId).\n const storageName = metadataStorageName(key, definition)\n let schemaUid: string | undefined =\n getSchemaUidForSchemaDefinitionFromCache(schemaDef) ??\n (!listRelationName && easName(storageName) === propertyNameForSchema ? property.row?.schemaUid ?? undefined : undefined)\n if (!schemaUid) {\n schemaUid = await getEasSchemaUidForSchemaDefinition({ schemaText: schemaDef })\n }\n if (!schemaUid) {\n addValidationError(\n ctx,\n `EAS schema not found for \"${schemaDef}\" (property: ${key}). Register it before publishing (ensureEasSchemasForItem).`,\n key,\n 'publish_schema_not_found',\n )\n return null\n }\n return { schemaUid, easDataType, schemaDef, propertyNameForSchema }\n}\n\n/** The label a required-value error uses for a relation or storage-seed property. */\nfunction refTypeLabel(definition: PublishGraphProperty['definition']): string {\n for (const [type, label] of [\n [ModelPropertyDataTypes.File, 'file'],\n [ModelPropertyDataTypes.Image, 'image'],\n [ModelPropertyDataTypes.Html, 'html'],\n [ModelPropertyDataTypes.Json, 'json'],\n ] as const) {\n if (matchesDataType(definition.dataType, type) || matchesDataType(definition.refValueType, type)) return label\n }\n return 'relation'\n}\n\n/** Required relation and storage-seed properties need a value pointing at an item. */\nfunction checkRequiredRef(node: PublishGraphNode, property: PublishGraphProperty, ctx: BuildContext): void {\n const { key, definition } = property\n if (definition.required !== true) return\n const value = property.row?.propertyValue\n const refLabel = definition.ref ?? definition.refModelName ?? 'related'\n if (value == null || value.trim() === '') {\n addValidationError(\n ctx,\n `Required ${refTypeLabel(definition)} ${key} has no value. A value pointing to a valid ${refLabel} item is required to publish.`,\n key,\n )\n return\n }\n for (const broken of ctx.graph.brokenRefs) {\n if (broken.seedLocalId !== node.seedLocalId || broken.propertyKey !== key || broken.list) continue\n addValidationError(\n ctx,\n broken.reason === 'invalid'\n ? `Required relation ${key} has invalid value: ${JSON.stringify(value)}. ` +\n `Value must be a valid seed reference (localId or uid) pointing to a ${refLabel} item.`\n : `No related item found for required relation: ${key}. Value: ${JSON.stringify(value)} (seedLocalId/seedUid). ` +\n `The related item may be missing, in a different database, or the reference may be broken.`,\n key,\n )\n }\n}\n\n/** A Boolean row value as stored (\"true\"/\"false\", \"1\"/\"0\"). */\nconst booleanFromRow = (value: string): boolean | string =>\n value === 'true' || value === '1' ? true : value === 'false' || value === '0' ? false : value\n\n/**\n * The attestation of one property of `node`, or undefined when the publish leaves it out (no\n * value, already attested in patch mode, deferred, invalid: the last reports an error).\n */\nasync function attestProperty(\n node: PublishGraphNode,\n property: PublishGraphProperty,\n versionUid: string,\n ctx: BuildContext,\n): Promise<Attestation | undefined> {\n const { key, definition, row } = property\n const forceFullSnapshot = ctx.graph.forceFullSnapshot\n if (INTERNAL_PROPERTY_NAMES.includes(key) || property.deferred) return undefined\n\n const isFileImageHtml =\n matchesDataType(definition.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(definition.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(definition.dataType, ModelPropertyDataTypes.Html)\n const isRef = property.kind === 'relation' || property.kind === 'storageSeed'\n const isStorageTransaction = property.kind === 'storageTransaction'\n\n // The storage transaction slot attests this publish's upload of the node's file(s).\n const uploaded = isStorageTransaction ? uploadedTxFor(ctx, node.seedLocalId) : undefined\n if (isStorageTransaction && !uploaded) return undefined\n let value: unknown = uploaded ? uploaded.txId : row?.propertyValue\n\n // 0 and false are values (ADR 0010). An empty value publishes only as a removal of a value\n // attested before (ADR 0021); a retraction attests nothing (publish revokes instead).\n let isRemoval = false\n if (value == null || value === '') {\n if (property.uid && !forceFullSnapshot) return undefined\n const clear = await getPropertyClear({\n seedLocalId: node.seedLocalId,\n seedUid: node.seedUid,\n propertyId: definition._dbId,\n modelName: node.modelName,\n propertyName: key,\n dataType: definition.dataType,\n refValueType: definition.refValueType,\n })\n if (!clear || clear.retract) return undefined\n isRemoval = true\n }\n // Patch mode skips properties that already have an EAS uid, except a storage transaction this\n // publish uploaded.\n if (!isRemoval && property.uid && !forceFullSnapshot && !uploaded) return undefined\n\n // File/Image/Html values must be a storage seed id by now. Raw content means the property's\n // save pipeline never ran or failed (e.g. createNewItem with raw html), so it was never uploaded.\n if (!isRemoval && isFileImageHtml && typeof value === 'string' && !isStorageSeedRef(value.trim())) {\n addValidationError(\n ctx,\n `Invalid value for property: ${key}. Expected a storage seed id ` +\n `(${normalizeDataType(definition.dataType)} content must be saved through the property before publishing), ` +\n `got ${value.length > 40 ? `${value.slice(0, 40)}…` : value}.`,\n key,\n 'publish_storage_value_not_saved',\n )\n return undefined\n }\n\n const propertyData = await getPropertyData(property, ctx)\n if (!propertyData) return undefined\n const { schemaUid, easDataType, schemaDef, propertyNameForSchema } = propertyData\n const isList = schemaDef.startsWith('bytes32[]')\n\n let rawListIdsForResolve: string[] | undefined\n if (isRemoval) {\n const empty = emptyEasValue(easDataType)\n if (empty === undefined) {\n addValidationError(\n ctx,\n `${key} can't be published empty: ${definition.dataType ?? easDataType} properties have no empty value. Clear it with clear({ retract: true }).`,\n key,\n 'publish_clear_unsupported',\n )\n return undefined\n }\n value = empty\n } else {\n if (typeof value === 'string' && isRef) value = currentRelatedRef(ctx, value.trim())\n if (isList && typeof value === 'string') {\n const text = value.trim()\n if (text.startsWith('[')) {\n try {\n value = JSON.parse(text)\n } catch {\n // reported below\n }\n } else if (text.includes(',')) {\n // Legacy comma-separated ids (pre-JSON List storage)\n value = text.split(',').map((s) => s.trim()).filter(Boolean)\n }\n }\n if (isList && !Array.isArray(value)) {\n addValidationError(ctx, `Invalid value for property: ${key}. Expected an array of bytes32, got ${value}.`, key)\n return undefined\n }\n if (easDataType === 'bool' && typeof value === 'string') value = booleanFromRow(value.trim())\n\n // Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding\n if (definition.validation) {\n const { SchemaValidationService } = await import('@/Schema/service/validation/SchemaValidationService')\n const result = new SchemaValidationService().validatePropertyValue(\n value,\n normalizeDataType(definition.dataType) as ModelPropertyDataTypes,\n definition.validation,\n definition.refValueType ? (normalizeDataType(definition.refValueType) as string) : undefined,\n )\n if (!result.isValid && result.errors.length > 0) {\n const firstError = result.errors[0]!\n addValidationError(ctx, firstError.message, key, firstError.code ?? 'publish_validation')\n return undefined\n }\n }\n\n if (isList) {\n const encoded: string[] = []\n const rawIds: string[] = []\n for (const member of value as unknown[]) {\n const id = typeof member === 'string' ? member.trim() : ''\n if (!id) continue\n const ref = currentRelatedRef(ctx, id)\n rawIds.push(ref)\n encoded.push(isUidRef(ref) ? ref : encodeBytes32String(ref))\n }\n value = encoded\n if (rawIds.some((id) => !isUidRef(id))) rawListIdsForResolve = rawIds\n }\n\n // uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds\n if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {\n const ms = value instanceof Date ? value.getTime() : /^\\d+$/.test(value) ? Number(value) : new Date(value).getTime()\n value = BigInt(Math.floor(ms / 1000))\n }\n\n // ADR 0010: Number attests as its decimal string, in the form readers decode it to.\n if (matchesDataType(definition.dataType, ModelPropertyDataTypes.Number)) {\n const decimal = decodeEasNumber(value)\n if (decimal === undefined) {\n addValidationError(\n ctx,\n `Invalid value for property: ${key}. Expected a finite number, got ${JSON.stringify(value)}.`,\n key,\n 'publish_invalid_number',\n )\n return undefined\n }\n value = decimal\n }\n }\n\n let encodedData: string\n try {\n const { SchemaEncoder } = await loadEasSdk()\n encodedData = new SchemaEncoder(schemaDef).encodeData([\n { name: propertyNameForSchema, type: easDataType, value: value as any },\n ]) as string\n } catch (encodeErr) {\n addValidationError(\n ctx,\n `Failed to encode property ${key}: ${encodeErr instanceof Error ? encodeErr.message : String(encodeErr)}`,\n key,\n )\n return undefined\n }\n\n const attestation: Attestation = {\n schema: schemaUid,\n data: [\n {\n ...defaultAttestationData,\n // The storage transaction references the Version attestation (contract may use when supported)\n refUID: isStorageTransaction ? versionUid : defaultAttestationData.refUID,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _propertyName: key,\n ...(row?.localId ? { _metadataLocalId: row.localId } : {}),\n ...(uploaded && uploaded.txId !== row?.propertyValue ? { _attestedValue: uploaded.txId } : {}),\n }\n\n // Refs to seeds of this publish by local id: resolution hints for resolvePublishPayloadValues\n if (\n typeof value === 'string' &&\n !isUidRef(value) &&\n /^[a-zA-Z0-9_-]{10,21}$/.test(value.trim()) &&\n (easDataType === 'bytes32' || easDataType === 'string')\n ) {\n attestation._propertyNameForSchema = propertyNameForSchema\n attestation._schemaDef = schemaDef\n attestation._unresolvedValue = value.trim()\n attestation._easDataType = easDataType\n }\n if (rawListIdsForResolve?.length) {\n attestation._propertyNameForSchema = propertyNameForSchema\n attestation._schemaDef = schemaDef\n attestation._easDataType = 'bytes32[]'\n attestation._rawListIdsForResolve = rawListIdsForResolve\n }\n return attestation\n}\n\n/** The order a node's properties attest in: basic values, its upload, refs, lists. */\nconst ATTEST_ORDER: PublishGraphProperty['kind'][] = ['basic', 'storageTransaction', 'relation', 'storageSeed', 'list']\n\n/** One node's request: its seed, version and property attestations, and the parent properties its seed uid fills. */\nasync function buildRequest(node: PublishGraphNode, ctx: BuildContext): Promise<PublishPayload> {\n const { graph } = ctx\n const isRoot = node.kind === 'root'\n // A storage seed or an embedded image attests its own basic properties only.\n const full = isRoot || node.kind === 'draft'\n const reportField = node.links[0]?.propertyKey\n\n let seedSchemaUid = isRoot ? node.seedSchemaUid : undefined\n seedSchemaUid ??= (await getEasSchemaUidForModel(node.modelName)) ?? undefined\n if (!seedSchemaUid) addValidationError(ctx, `Schema UID not found for model: ${node.modelName}`, isRoot ? undefined : reportField)\n\n let versionUid = node.version.uid ?? (node.newSeed ? undefined : node.version.publishedUid) ?? ZERO_BYTES32\n if (isRoot && graph.forceFullSnapshot && node.seedUid) versionUid = ZERO_BYTES32\n const versionLocalId = versionUid === ZERO_BYTES32 && !node.version.uid ? node.version.localId : undefined\n\n const request: PublishPayload = {\n localId: node.seedLocalId,\n ...(versionLocalId ? { versionLocalId } : {}),\n seedIsRevocable: true,\n seedSchemaUid: seedSchemaUid ?? ZERO_BYTES32,\n seedUid: node.newSeed || !node.seedUid ? ZERO_BYTES32 : node.seedUid,\n versionSchemaUid: VERSION_SCHEMA_UID,\n versionUid,\n listOfAttestations: [],\n propertiesToUpdate: [],\n }\n\n for (const kind of ATTEST_ORDER) {\n for (const property of node.properties) {\n if (property.kind !== kind) continue\n if (!full && kind !== 'basic' && kind !== 'storageTransaction') continue\n if (full && (kind === 'relation' || kind === 'storageSeed')) checkRequiredRef(node, property, ctx)\n const attestation = await attestProperty(node, property, versionUid, ctx)\n if (attestation) request.listOfAttestations.push(attestation)\n }\n }\n\n // Each property this seed's uid fills: the contract writes the uid into that attestation.\n for (const { seedLocalId, propertyKey } of node.links) {\n const owner = graph.nodes.find((n) => n.seedLocalId === seedLocalId)\n const property = owner?.properties.find((p) => p.key === propertyKey)\n if (!property) continue\n const propertySchemaUid = (await getPropertyData(property, ctx))?.schemaUid\n if (!propertySchemaUid) continue\n if (!request.propertiesToUpdate.some((u) => u.publishLocalId === seedLocalId && u.propertySchemaUid.toLowerCase() === propertySchemaUid.toLowerCase())) {\n request.propertiesToUpdate.push({ publishLocalId: seedLocalId, propertySchemaUid })\n }\n }\n return request\n}\n\n/**\n * Embedded image rows must still name an Html value of their owner, with a schema to attest under.\n * No propertiesToUpdate: the Html refers to the image by its Arweave URL (the data URI is\n * rewritten to it before the Html is uploaded), not by seed uid.\n */\nasync function checkEmbeddedImages(ctx: BuildContext): Promise<void> {\n const { graph } = ctx\n for (const owner of graph.nodes) {\n for (const row of owner.embeddedImages) {\n const imageNode = graph.nodes.find((n) => n.seedLocalId === row.imageSeedLocalId && n.kind === 'embeddedImage')\n const missing = graph.missingEmbeddedImages.some((m) => m.imageSeedLocalId === row.imageSeedLocalId)\n if (!imageNode && !missing) continue\n const html = htmlPropertyForHtmlSeed(owner, row.htmlSeedLocalId)\n if (!html) {\n addValidationError(ctx, `Could not find Html property for embedded image rewrite (html seed ${row.htmlSeedLocalId.trim()}).`, 'html', 'html_embed_schema')\n continue\n }\n if (!(await getPropertyData(html, ctx))) continue\n if (missing) {\n addValidationError(ctx, `Embedded Image item not found for seed ${row.imageSeedLocalId}.`, 'html', 'html_embed_image_missing')\n }\n }\n }\n}\n\nexport const getPublishPayload = async (\n item: { seedLocalId: string; modelName?: string },\n uploadedTransactions: UploadedTransaction[],\n options?: GetPublishPayloadOptions,\n): Promise<MultiPublishPayload> => {\n const publishMode: PublishMode = options?.publishMode ?? 'patch'\n const graph = await getPublishGraph(item, { publishMode })\n const ctx: BuildContext = { graph, errors: [], uploadedTransactions }\n\n if (publishMode === 'new_version' && !graph.root.seedUid) {\n addValidationError(\n ctx,\n 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).',\n 'seedUid',\n 'publish_new_version_requires_seed',\n )\n }\n\n let multiPublishPayload: MultiPublishPayload = []\n for (const node of graph.nodes) multiPublishPayload.push(await buildRequest(node, ctx))\n await checkEmbeddedImages(ctx)\n\n // A request whose seed fills another request's property (propertiesToUpdate) publishes first, and a\n // request encoding another's local id publishes after it.\n multiPublishPayload = orderPayloadByDependencies(multiPublishPayload)\n\n if (publishMode === 'new_version') {\n const rootPayload = multiPublishPayload.find((p) => p.localId === graph.root.seedLocalId)\n if (!rootPayload?.listOfAttestations.length) {\n addValidationError(\n ctx,\n 'Publishing as a new version requires at least one property attestation for the item. ' +\n 'Ensure required fields have values and that publishable properties are present.',\n 'listOfAttestations',\n 'publish_new_version_empty_snapshot',\n )\n }\n }\n\n // Stop before anything is uploaded or attested: the payload would attest revoked seed uids.\n if (graph.unpublishedRelatedItems.length) {\n throw new RelatedItemUnpublishedError(graph.unpublishedRelatedItems, ctx.errors)\n }\n\n if (ctx.errors.length > 0) {\n const combinedMessage = ctx.errors.map((e) => e.message).join('\\n')\n throw new PublishValidationFailedError(\n `Validation failed (${ctx.errors.length} error${ctx.errors.length === 1 ? '' : 's'}):\\n${combinedMessage}`,\n ctx.errors,\n )\n }\n\n return multiPublishPayload\n}\n\nexport type ValidateItemForPublishResult = {\n isValid: boolean\n errors: PublishValidationError[]\n}\n\n/**\n * Validates an item for publishing without performing Arweave or EAS work.\n * Use in the checking step to fail fast before creating transactions.\n * Pass empty array for uploadedTransactions when validating before Arweave upload.\n */\nexport const validateItemForPublish = async (\n item: { seedLocalId: string; modelName?: string },\n uploadedTransactions: UploadedTransaction[] = [],\n options?: GetPublishPayloadOptions,\n): Promise<ValidateItemForPublishResult> => {\n try {\n await getPublishPayload(item, uploadedTransactions, options)\n return { isValid: true, errors: [] }\n } catch (err) {\n if (err instanceof PublishValidationFailedError) {\n return { isValid: false, errors: err.validationErrors }\n }\n throw err\n }\n}\n\n/**\n * LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.\n */\nfunction collectAttestationLocalRefIds(req: PublishPayload, allLocalIds: Set<string>): string[] {\n const refs: string[] = []\n for (const att of req.listOfAttestations) {\n if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) refs.push(att._unresolvedValue)\n for (const id of att._rawListIdsForResolve ?? []) {\n const t = id != null ? String(id).trim() : ''\n if (t && allLocalIds.has(t)) refs.push(t)\n }\n }\n return refs\n}\n\n/**\n * Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.\n * - propertiesToUpdate: updater before updatee (contract injection).\n * - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.\n * Ties keep the input order (the graph's finish order).\n */\nfunction orderPayloadByDependencies(payload: MultiPublishPayload): MultiPublishPayload {\n if (payload.length <= 1) return payload\n\n const byLocalId = new Map<string, PublishPayload>()\n const indexOrder = new Map<string, number>()\n payload.forEach((p, i) => {\n byLocalId.set(p.localId, p)\n indexOrder.set(p.localId, i)\n })\n const allIds = new Set(byLocalId.keys())\n const indegree = new Map<string, number>([...allIds].map((id) => [id, 0]))\n const adj = new Map<string, Set<string>>()\n\n const addEdge = (from: string, to: string) => {\n if (from === to || !allIds.has(from) || !allIds.has(to)) return\n if (!adj.has(from)) adj.set(from, new Set())\n const set = adj.get(from)!\n if (set.has(to)) return\n set.add(to)\n indegree.set(to, (indegree.get(to) ?? 0) + 1)\n }\n\n for (const p of payload) {\n for (const u of p.propertiesToUpdate) addEdge(p.localId, u.publishLocalId)\n for (const refId of collectAttestationLocalRefIds(p, allIds)) addEdge(refId, p.localId)\n }\n\n const byInputOrder = (a: string, b: string) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0)\n const queue = [...allIds].filter((id) => (indegree.get(id) ?? 0) === 0).sort(byInputOrder)\n const result: PublishPayload[] = []\n while (queue.length > 0) {\n const id = queue.shift()!\n result.push(byLocalId.get(id)!)\n for (const to of adj.get(id) ?? []) {\n const next = (indegree.get(to) ?? 0) - 1\n indegree.set(to, next)\n if (next === 0) {\n queue.push(to)\n queue.sort(byInputOrder)\n }\n }\n }\n\n if (result.length !== payload.length) {\n const seen = new Set(result.map((r) => r.localId))\n for (const p of payload) if (!seen.has(p.localId)) result.push(p)\n }\n return result\n}\n\n/** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */\nfunction padUidForBytes32Schema(uid: string): string {\n const t = uid.trim()\n if (!t.startsWith('0x')) return uid\n const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '')\n if (hex.length === 0) return uid\n return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase()\n}\n\n/**\n * Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.\n * Call after each payload is published, passing the returned attestation uid for that seed's localId.\n * Returns an updated multiPayload with re-encoded attestations where resolution was applied.\n */\nexport const resolvePublishPayloadValues = async (\n multiPayload: MultiPublishPayload,\n resolvedUids: ResolvedSeedUids,\n): Promise<MultiPublishPayload> => {\n if (Object.keys(resolvedUids).length === 0) {\n return multiPayload\n }\n\n const { SchemaEncoder } = await loadEasSdk()\n const result: MultiPublishPayload = []\n\n for (const payload of multiPayload) {\n const updatedAttestations: PublishPayload['listOfAttestations'] = []\n\n for (const attestation of payload.listOfAttestations) {\n const entry = attestation as Attestation & { data?: AttestationRequestData[] | AttestationRequestData }\n\n const rawList = entry._rawListIdsForResolve\n if (\n rawList &&\n rawList.length > 0 &&\n entry._schemaDef &&\n (entry._propertyNameForSchema || entry._propertyName)\n ) {\n const fieldName =\n entry._propertyNameForSchema ?? easName(entry._propertyName as string)\n const resolvedValues: string[] = []\n let allSlotsResolved = true\n for (const id of rawList) {\n const trimmed = id.trim()\n if (isUidRef(trimmed)) {\n resolvedValues.push(padUidForBytes32Schema(trimmed))\n continue\n }\n const r = resolvedUids[trimmed]\n if (r) {\n resolvedValues.push(padUidForBytes32Schema(r))\n continue\n }\n allSlotsResolved = false\n break\n }\n // Do not encode or clear hints until every slot has a real uid — otherwise sequential\n // publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.\n if (!allSlotsResolved) {\n updatedAttestations.push({\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n })\n continue\n }\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: 'bytes32[]',\n value: resolvedValues,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _rawListIdsForResolve: undefined,\n _easDataType: undefined,\n })\n continue\n }\n\n const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue]\n const easType = (entry._easDataType as 'bytes32' | 'string') || 'bytes32'\n if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {\n const fieldName =\n entry._propertyNameForSchema ?? easName(entry._propertyName as string)\n const valueForEncode =\n easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid\n const dataEncoder = new SchemaEncoder(entry._schemaDef)\n const encodedData = dataEncoder.encodeData([\n {\n name: fieldName,\n type: easType,\n value: valueForEncode,\n },\n ])\n const baseData = Array.isArray(entry.data) ? entry.data[0] : (entry.data as AttestationRequestData)\n updatedAttestations.push({\n ...entry,\n data: [\n {\n ...baseData,\n data: encodedData,\n } as AttestationRequestData,\n ],\n _unresolvedValue: undefined,\n })\n } else {\n const normalizedEntry: PublishPayload['listOfAttestations'][0] = {\n ...entry,\n data: Array.isArray(entry.data) ? entry.data : [entry.data as AttestationRequestData],\n }\n updatedAttestations.push(normalizedEntry)\n }\n }\n\n result.push({\n ...payload,\n listOfAttestations: updatedAttestations,\n })\n }\n\n return result\n}\n"],"names":[],"mappings":";;;;;;;;AAsBA,MAAM,YAAY,GAAG,CAAC,KAAgC,KAAc,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;AAEjG;;;;;AAKG;AACI,eAAe,gBAAgB,CAAC,MAStC,EAAA;AACC,IAAA,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM;AACpG,IAAA,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,SAAS;AAC9C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC/B,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,SAAS;;IAG5B,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAC1C,EAAE,UAAU,EAAE,YAAY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AG,QAAQ;AACX,4BAAA,IAAI,EAAE,WAAW;AACQ,yBAAA;AAC5B,qBAAA;AACD,oBAAA,gBAAgB,EAAE,SAAS;AAC5B,iBAAA,CAAC;YACJ;iBAAO;AACL,gBAAA,MAAM,eAAe,GAA4C;AAC/D,oBAAA,GAAG,KAAK;oBACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAA8B,CAAC;iBACtF;AACD,gBAAA,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC;YAC3C;QACF;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,GAAG,OAAO;AACV,YAAA,kBAAkB,EAAE,mBAAmB;AACxC,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,MAAM;AACf;;;;;;;;;;"}
@@ -1,25 +1,26 @@
1
- import { B as BaseDb, m as metadata } from './BaseFileManager-DLou1TZS.js';
1
+ import { B as BaseDb, m as metadata } from './BaseFileManager-D-pLXQAp.js';
2
2
  import { or, eq } from 'drizzle-orm';
3
- import { F as currentPropertyRows, G as metadataPropertyGroupKeys, H as compareMetadataRowsLatestFirst, J as readMetadataPropertiesById, K as isPublishedMetadataRow, L as getLatestPublishedVersionRow } from './Item-oPnmIehk.js';
4
- import { g as getPropertyClear } from './getPublishPayload-DKuEaq96.js';
3
+ import { z as currentPropertyRows, B as metadataPropertyGroupKeys, D as compareMetadataRowsLatestFirst, F as readMetadataPropertiesById, G as isPublishedMetadataRow, H as getLatestPublishedVersionRow } from './Item-BU9wIT7l.js';
4
+ import { g as getPropertyClear } from './getPublishPayload-Dd3HCYeI.js';
5
5
  import 'debug';
6
6
  import 'drizzle-orm/sqlite-core';
7
- import './tabEvents-DT5ez6io.js';
8
- import 'xstate';
9
- import '@seedprotocol/eas';
10
- import 'pluralize';
7
+ import './arweaveContentTags-iW_HcWJA.js';
11
8
  import '@sinclair/typebox';
12
- import '@seedprotocol/arweave';
13
9
  import 'nanoid';
14
10
  import 'nanoid-dictionary';
11
+ import '@seedprotocol/eas';
12
+ import '@seedprotocol/arweave';
15
13
  import '@noble/hashes/sha256';
16
14
  import '@noble/hashes/sha3';
17
15
  import '@noble/hashes/utils';
18
- import 'lodash-es';
16
+ import 'xstate';
17
+ import 'pluralize';
19
18
  import 'rxjs';
20
- import './errors-CnT0fSMK.js';
19
+ import 'lodash-es';
20
+ import './publishErrors-DZXDX3B6.js';
21
21
  import '@seedprotocol/query';
22
- import './publishGraph-CRn_N3NT.js';
22
+ import '@seedprotocol/archive';
23
+ import 'parse5';
23
24
 
24
25
  function resolveSeedIds(arg) {
25
26
  if (arg && typeof arg === 'object' && 'seedLocalId' in arg) {
@@ -122,4 +123,4 @@ async function getPublishPendingDiff(arg) {
122
123
  }
123
124
 
124
125
  export { getPublishPendingDiff };
125
- //# sourceMappingURL=getPublishPendingDiff-CH5xLMjU.js.map
126
+ //# sourceMappingURL=getPublishPendingDiff-kcTP52Kj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPublishPendingDiff-CH5xLMjU.js","sources":["../../src/db/read/getPublishPendingDiff.ts"],"sourcesContent":["import { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema'\nimport type { MetadataType } from '@/seedSchema/MetadataSchema'\nimport { eq, or } from 'drizzle-orm'\nimport type { IItem } from '@/interfaces'\nimport { isPublishedMetadataRow as isPublished } from '@/helpers/isPublishedMetadataRow'\nimport { compareMetadataRowsLatestFirst, metadataPropertyGroupKeys } from '@/helpers/compareMetadataRowsLatestFirst'\nimport { readMetadataPropertiesById } from '@/db/read/metadataProperty'\nimport { getLatestPublishedVersionRow } from '@/db/read/getLatestPublishedVersionRow'\nimport { getPropertyClear } from '@/db/read/getPropertyClear'\nimport { currentPropertyRows } from '@/db/read/currentPropertyRow'\n\nexport type PublishPendingPropertyDiff = {\n propertyName: string\n currentValue: string | null\n /** Value from the most recent row that had an on-chain attestation uid, if any */\n previousPublishedValue: string | null\n /** True when the latest row for this property has no `uid` (not yet attested) */\n pending: boolean\n /**\n * `set` for a new value. `removed` for an empty value that publish attests as removed, and\n * `retracted` for one whose attestations publish revokes (ADR 0021).\n */\n change: 'set' | 'removed' | 'retracted'\n}\n\nexport type GetPublishPendingDiffResult = {\n /** Properties whose latest metadata row is unpublished (no `uid`) */\n pendingProperties: PublishPendingPropertyDiff[]\n lastPublishedVersionUid: string | null\n lastVersionPublishedAt: number | null\n}\n\nfunction resolveSeedIds(\n arg: { seedLocalId?: string; seedUid?: string } | IItem<any>,\n): { seedLocalId?: string; seedUid?: string } {\n if (arg && typeof arg === 'object' && 'seedLocalId' in arg) {\n const item = arg as IItem<any>\n return {\n seedLocalId: item.seedLocalId,\n seedUid: item.seedUid,\n }\n }\n return arg as { seedLocalId?: string; seedUid?: string }\n}\n\n/**\n * Per property: its current row (currentPropertyRows, with a pending outbox value over the stored\n * row) lacks a valid EAS attestation `uid` — local edit or missing post-publish UID backfill. Rows sync derived for\n * ItemStorage properties (`derivedFromUid` set) count as published. **Not** equivalent to\n * draft vs onchain for the whole seed; use `getSeedPublishState` for that.\n */\nexport async function getPublishPendingDiff(\n arg: { seedLocalId?: string; seedUid?: string } | IItem<any>,\n): Promise<GetPublishPendingDiffResult> {\n const { seedLocalId, seedUid } = resolveSeedIds(arg)\n const appDb = BaseDb.getAppDb()\n const empty: GetPublishPendingDiffResult = {\n pendingProperties: [],\n lastPublishedVersionUid: null,\n lastVersionPublishedAt: null,\n }\n if (!appDb || (!seedLocalId && !seedUid)) {\n return empty\n }\n\n const whereClause =\n seedLocalId && seedUid\n ? or(eq(metadata.seedLocalId, seedLocalId), eq(metadata.seedUid, seedUid))\n : seedLocalId\n ? eq(metadata.seedLocalId, seedLocalId)\n : eq(metadata.seedUid, seedUid!)\n\n // Every row, for each property's last published value; the current one is currentPropertyRows',\n // with a pending outbox value counting as an unpublished edit (ADR 0019)\n const rows = (await appDb.select().from(metadata).where(whereClause)) as MetadataType[]\n const current = await currentPropertyRows({ seedLocalId, seedUid })\n\n // One group per property: by property_id (decision D4), rows without one by stored name. A\n // property is reported under its storage name, the name its new rows are written under.\n const groupKey = metadataPropertyGroupKeys(rows)\n const byProp = new Map<string, MetadataType[]>()\n for (const row of rows) {\n if (!row.propertyName) continue\n const key = groupKey(row)\n const list = byProp.get(key) ?? []\n list.push(row)\n byProp.set(key, list)\n }\n for (const list of byProp.values()) {\n list.sort(compareMetadataRowsLatestFirst)\n }\n\n const propertiesById = await readMetadataPropertiesById(\n appDb,\n [...rows, ...current].map((row) => row.propertyId),\n )\n const pendingProperties: PublishPendingPropertyDiff[] = []\n for (const latest of current) {\n if (!latest.propertyName || isPublished(latest)) continue\n const list = byProp.get(groupKey(latest as MetadataType)) ?? []\n const prevWithUid = list.find(isPublished)\n const groupId = latest.propertyId ?? list.find((row) => row.propertyId != null)?.propertyId\n const property = groupId != null ? propertiesById.get(groupId) : undefined\n const isEmpty = latest.propertyValue == null || latest.propertyValue === ''\n // An empty value changes nothing on chain unless it has an attestation to remove or retract\n // (ADR 0021): one never published, or already retracted, isn't pending.\n if (isEmpty) {\n const clear = await getPropertyClear({\n seedLocalId,\n seedUid,\n propertyId: groupId,\n propertyName: latest.propertyName,\n })\n if (!clear || (clear.retract && clear.retractScope.length === 0)) continue\n }\n pendingProperties.push({\n propertyName: property?.storageName ?? latest.propertyName,\n currentValue: latest.propertyValue ?? null,\n previousPublishedValue: prevWithUid?.propertyValue ?? null,\n pending: true,\n change: !isEmpty ? 'set' : latest.retract ? 'retracted' : 'removed',\n })\n }\n\n pendingProperties.sort((a, b) => a.propertyName.localeCompare(b.propertyName))\n\n let lastPublishedVersionUid: string | null = null\n let lastVersionPublishedAt: number | null = null\n\n if (seedLocalId) {\n const published = await getLatestPublishedVersionRow(seedLocalId)\n if (published) {\n lastPublishedVersionUid = published.uid\n if (published.attestationCreatedAt != null) {\n lastVersionPublishedAt = published.attestationCreatedAt\n }\n }\n }\n\n return {\n pendingProperties,\n lastP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S,CAAC,oBAAoB,IAAI,IAAI,EAAE;AAC1C,gBAAA,sBAAsB,GAAG,SAAS,CAAC,oBAAoB;YACzD;QACF;IACF;IAEA,OAAO;QACL,iBAAiB;QACjB,uBAAuB;QACvB,sBAAsB;KACvB;AACH;;"}
1
+ {"version":3,"file":"getPublishPendingDiff-kcTP52Kj.js","sources":["../../src/db/read/getPublishPendingDiff.ts"],"sourcesContent":["import { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema'\nimport type { MetadataType } from '@/seedSchema/MetadataSchema'\nimport { eq, or } from 'drizzle-orm'\nimport type { IItem } from '@/interfaces'\nimport { isPublishedMetadataRow as isPublished } from '@/helpers/isPublishedMetadataRow'\nimport { compareMetadataRowsLatestFirst, metadataPropertyGroupKeys } from '@/helpers/compareMetadataRowsLatestFirst'\nimport { readMetadataPropertiesById } from '@/db/read/metadataProperty'\nimport { getLatestPublishedVersionRow } from '@/db/read/getLatestPublishedVersionRow'\nimport { getPropertyClear } from '@/db/read/getPropertyClear'\nimport { currentPropertyRows } from '@/db/read/currentPropertyRow'\n\nexport type PublishPendingPropertyDiff = {\n propertyName: string\n currentValue: string | null\n /** Value from the most recent row that had an on-chain attestation uid, if any */\n previousPublishedValue: string | null\n /** True when the latest row for this property has no `uid` (not yet attested) */\n pending: boolean\n /**\n * `set` for a new value. `removed` for an empty value that publish attests as removed, and\n * `retracted` for one whose attestations publish revokes (ADR 0021).\n */\n change: 'set' | 'removed' | 'retracted'\n}\n\nexport type GetPublishPendingDiffResult = {\n /** Properties whose latest metadata row is unpublished (no `uid`) */\n pendingProperties: PublishPendingPropertyDiff[]\n lastPublishedVersionUid: string | null\n lastVersionPublishedAt: number | null\n}\n\nfunction resolveSeedIds(\n arg: { seedLocalId?: string; seedUid?: string } | IItem<any>,\n): { seedLocalId?: string; seedUid?: string } {\n if (arg && typeof arg === 'object' && 'seedLocalId' in arg) {\n const item = arg as IItem<any>\n return {\n seedLocalId: item.seedLocalId,\n seedUid: item.seedUid,\n }\n }\n return arg as { seedLocalId?: string; seedUid?: string }\n}\n\n/**\n * Per property: its current row (currentPropertyRows, with a pending outbox value over the stored\n * row) lacks a valid EAS attestation `uid` — local edit or missing post-publish UID backfill. Rows sync derived for\n * ItemStorage properties (`derivedFromUid` set) count as published. **Not** equivalent to\n * draft vs onchain for the whole seed; use `getSeedPublishState` for that.\n */\nexport async function getPublishPendingDiff(\n arg: { seedLocalId?: string; seedUid?: string } | IItem<any>,\n): Promise<GetPublishPendingDiffResult> {\n const { seedLocalId, seedUid } = resolveSeedIds(arg)\n const appDb = BaseDb.getAppDb()\n const empty: GetPublishPendingDiffResult = {\n pendingProperties: [],\n lastPublishedVersionUid: null,\n lastVersionPublishedAt: null,\n }\n if (!appDb || (!seedLocalId && !seedUid)) {\n return empty\n }\n\n const whereClause =\n seedLocalId && seedUid\n ? or(eq(metadata.seedLocalId, seedLocalId), eq(metadata.seedUid, seedUid))\n : seedLocalId\n ? eq(metadata.seedLocalId, seedLocalId)\n : eq(metadata.seedUid, seedUid!)\n\n // Every row, for each property's last published value; the current one is currentPropertyRows',\n // with a pending outbox value counting as an unpublished edit (ADR 0019)\n const rows = (await appDb.select().from(metadata).where(whereClause)) as MetadataType[]\n const current = await currentPropertyRows({ seedLocalId, seedUid })\n\n // One group per property: by property_id (decision D4), rows without one by stored name. A\n // property is reported under its storage name, the name its new rows are written under.\n const groupKey = metadataPropertyGroupKeys(rows)\n const byProp = new Map<string, MetadataType[]>()\n for (const row of rows) {\n if (!row.propertyName) continue\n const key = groupKey(row)\n const list = byProp.get(key) ?? []\n list.push(row)\n byProp.set(key, list)\n }\n for (const list of byProp.values()) {\n list.sort(compareMetadataRowsLatestFirst)\n }\n\n const propertiesById = await readMetadataPropertiesById(\n appDb,\n [...rows, ...current].map((row) => row.propertyId),\n )\n const pendingProperties: PublishPendingPropertyDiff[] = []\n for (const latest of current) {\n if (!latest.propertyName || isPublished(latest)) continue\n const list = byProp.get(groupKey(latest as MetadataType)) ?? []\n const prevWithUid = list.find(isPublished)\n const groupId = latest.propertyId ?? list.find((row) => row.propertyId != null)?.propertyId\n const property = groupId != null ? propertiesById.get(groupId) : undefined\n const isEmpty = latest.propertyValue == null || latest.propertyValue === ''\n // An empty value changes nothing on chain unless it has an attestation to remove or retract\n // (ADR 0021): one never published, or already retracted, isn't pending.\n if (isEmpty) {\n const clear = await getPropertyClear({\n seedLocalId,\n seedUid,\n propertyId: groupId,\n propertyName: latest.propertyName,\n })\n if (!clear || (clear.retract && clear.retractScope.length === 0)) continue\n }\n pendingProperties.push({\n propertyName: property?.storageName ?? latest.propertyName,\n currentValue: latest.propertyValue ?? null,\n previousPublishedValue: prevWithUid?.propertyValue ?? null,\n pending: true,\n change: !isEmpty ? 'set' : latest.retract ? 'retracted' : 'removed',\n })\n }\n\n pendingProperties.sort((a, b) => a.propertyName.localeCompare(b.propertyName))\n\n let lastPublishedVersionUid: string | null = null\n let lastVersionPublishedAt: number | null = null\n\n if (seedLocalId) {\n const published = await getLatestPublishedVersionRow(seedLocalId)\n if (published) {\n lastPublishedVersionUid = published.uid\n if (published.attestationCreatedAt != null) {\n lastVersionPublishedAt = published.attestationCreatedAt\n }\n }\n }\n\n return {\n pendingProperties,\n lastPublishedVersionUid,\n lastVersionPublishedAt,\n }\n}\n"],"names":["isPublished"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiCA,SAAS,cAAc,CACrB,GAA4D,EAAA;IAE5D,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,aAAa,IAAI,GAAG,EAAE;QAC1D,MAAM,IAAI,GAAG,GAAiB;QAC9B,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB;IACH;AACA,IAAA,OAAO,GAAiD;AAC1D;AAEA;;;;;AAKG;AACI,eAAe,qBAAqB,CACzC,GAA4D,EAAA;IAE5D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,cA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KAAK,CAAC,CAAC;gBAAE;QACpE;QACA,iBAAiB,CAAC,IAAI,CAAC;AACrB,YAAA,YAAY,EAAE,QAAQ,EAAE,WAAW,IAAI,MAAM,CAAC,YAAY;AAC1D,YAAA,YAAY,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;AAC1C,YAAA,sBAAsB,EAAE,WAAW,EAAE,aAAa,IAAI,IAAI;AAC1D,YAAA,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,CAAC,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG,WAAW,GAAG,SAAS;AACpE,SAAA,CAAC;IACJ;IAEA,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAE9E,IAAI,uBAAuB,GAAkB,IAAI;IACjD,IAAI,sBAAsB,GAAkB,IAAI;IAEhD,IAAI,WAAW,EAAE;AACf,QAAA,MAAM,SAAS,GAAG,MAAM,4BAA4B,CAAC,WAAW,CAAC;QACjE,IAAI,SAAS,EAAE;AACb,YAAA,uBAAuB,GAAG,SAAS,CAAC,GAAG;AACvC,YAAA,IAAI,SAAS,CAAC,oBAAoB,IAAI,IAAI,EAAE;AAC1C,gBAAA,sBAAsB,GAAG,SAAS,CAAC,oBAAoB;YACzD;QACF;IACF;IAEA,OAAO;QACL,iBAAiB;QACjB,uBAAuB;QACvB,sBAAsB;KACvB;AACH;;"}
@@ -1,4 +1,4 @@
1
- import { m as metadata, a as appState, e as arweaveL1FinalizeJobs, c as config, f as easSyncProcesses, g as entityChanges, h as htmlEmbeddedImageCoPublish, i as modelRelations, j as modelSchemas, b as modelUids, d as models, k as modelsRelations, p as pendingWrites, l as properties, n as propertiesRelations, o as propertyUidRelations, q as propertyUids, r as publishProcesses, t as schemas, s as seeds, u as uploadProcesses, v as versions } from './BaseFileManager-DLou1TZS.js';
1
+ import { m as metadata, a as appState, e as arweaveL1FinalizeJobs, c as config, f as easSyncProcesses, g as entityChanges, h as htmlEmbeddedImageCoPublish, i as modelRelations, j as modelSchemas, b as modelUids, d as models, k as modelsRelations, p as pendingWrites, l as properties, n as propertiesRelations, o as publishProcesses, q as schemas, s as seeds, u as uploadProcesses, v as versions } from './BaseFileManager-D-pLXQAp.js';
2
2
 
3
3
  var schema = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
@@ -17,8 +17,6 @@ var schema = /*#__PURE__*/Object.freeze({
17
17
  pendingWrites: pendingWrites,
18
18
  properties: properties,
19
19
  propertiesRelations: propertiesRelations,
20
- propertyUidRelations: propertyUidRelations,
21
- propertyUids: propertyUids,
22
20
  publishProcesses: publishProcesses,
23
21
  schemas: schemas,
24
22
  seeds: seeds,
@@ -27,4 +25,4 @@ var schema = /*#__PURE__*/Object.freeze({
27
25
  });
28
26
 
29
27
  export { schema as s };
30
- //# sourceMappingURL=index-BjWk0x4-.js.map
28
+ //# sourceMappingURL=index-2PaIhvOU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-2PaIhvOU.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,28 @@
1
+ import { a as appendOutboxOpAndWait, m as markPropertyConflictsResolved, g as getOutboxOps, o as outboxOpResult, w as waitForOutboxOp, b as waitForPendingOutboxOps } from './Item-BU9wIT7l.js';
2
+ export { O as OUTBOX_PRUNE_AFTER_MS, c as OUTBOX_PRUNE_FAILED_AFTER_MS, d as OutboxOpDeferredError, e as OutboxOpFailedError, f as OutboxOpRejectedError, h as appendOutboxOp, i as drainOutbox, j as getPendingSetValue, k as outboxOpValue, p as pruneOutbox, r as registerOutboxApplier } from './Item-BU9wIT7l.js';
3
+ import { d as deleteFiles, s as startItemOutbox, t as throwItemWriteError } from './publishErrors-DZXDX3B6.js';
4
+ import './arweaveContentTags-iW_HcWJA.js';
5
+ import '@sinclair/typebox';
6
+ import 'debug';
7
+ import 'nanoid';
8
+ import 'nanoid-dictionary';
9
+ import './BaseFileManager-D-pLXQAp.js';
10
+ import 'drizzle-orm/sqlite-core';
11
+ import 'drizzle-orm';
12
+ import '@seedprotocol/eas';
13
+ import '@seedprotocol/arweave';
14
+ import '@noble/hashes/sha256';
15
+ import '@noble/hashes/sha3';
16
+ import '@noble/hashes/utils';
17
+ import 'xstate';
18
+ import 'pluralize';
19
+ import 'rxjs';
20
+ import 'lodash-es';
21
+ import '@seedprotocol/query';
22
+ import '@seedprotocol/archive';
23
+ import 'parse5';
24
+
25
+
26
+
27
+ export { appendOutboxOpAndWait, deleteFiles, getOutboxOps, markPropertyConflictsResolved, outboxOpResult, startItemOutbox, throwItemWriteError, waitForOutboxOp, waitForPendingOutboxOps };
28
+ //# sourceMappingURL=index-BXTyvnKb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BXTyvnKb.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}