@seedprotocol/sdk 0.7.2 → 0.7.3-next.654.g52217f6

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 (166) hide show
  1. package/dist/{BasePathResolver-BdxCSIzn.js → BasePathResolver-CfSfMW5_.js} +7 -10
  2. package/dist/BasePathResolver-CfSfMW5_.js.map +1 -0
  3. package/dist/{ClientManager-ClCwwhwo.js → ClientManager-C-QXqUK9.js} +438 -153
  4. package/dist/ClientManager-C-QXqUK9.js.map +1 -0
  5. package/dist/{Item-B9Y4VuK1.js → Item-C7sUUu2B.js} +291 -105
  6. package/dist/Item-C7sUUu2B.js.map +1 -0
  7. package/dist/{ModelProperty-BMePcicQ.js → ModelProperty-DJxeOOrc.js} +28 -27
  8. package/dist/ModelProperty-DJxeOOrc.js.map +1 -0
  9. package/dist/{Schema-COsEXXaR.js → Schema-fXtvd-yL.js} +30 -30
  10. package/dist/{Schema-COsEXXaR.js.map → Schema-fXtvd-yL.js.map} +1 -1
  11. package/dist/{SchemaValidationService-DabGMzSE.js → SchemaValidationService-CvRS2HSO.js} +10 -9
  12. package/dist/{SchemaValidationService-DabGMzSE.js.map → SchemaValidationService-CvRS2HSO.js.map} +1 -1
  13. package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js → backfillMetadataPropertyIds-SXW-8C64.js} +4 -4
  14. package/dist/{backfillMetadataPropertyIds-Ck6fumnm.js.map → backfillMetadataPropertyIds-SXW-8C64.js.map} +1 -1
  15. package/dist/cjs/{ModelProperty-BT6Un_MB.js → ModelProperty-DXZ39Wyv.js} +24 -23
  16. package/dist/cjs/{ModelProperty-BT6Un_MB.js.map → ModelProperty-DXZ39Wyv.js.map} +1 -1
  17. package/dist/cjs/{Schema-BXhXdUsA.js → Schema-DdP109QD.js} +26 -25
  18. package/dist/cjs/{Schema-BXhXdUsA.js.map → Schema-DdP109QD.js.map} +1 -1
  19. package/dist/cjs/{SchemaValidationService-CC18QDfc.js → SchemaValidationService-CSXxx7sQ.js} +5 -4
  20. package/dist/cjs/{SchemaValidationService-CC18QDfc.js.map → SchemaValidationService-CSXxx7sQ.js.map} +1 -1
  21. package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js → backfillMetadataPropertyIds-CPYoaMl4.js} +6 -5
  22. package/dist/cjs/{backfillMetadataPropertyIds-DEHC9ejq.js.map → backfillMetadataPropertyIds-CPYoaMl4.js.map} +1 -1
  23. package/dist/cjs/{eas-C3CL0l7l.js → eas-B2YDQssV.js} +6 -5
  24. package/dist/cjs/{eas-C3CL0l7l.js.map → eas-B2YDQssV.js.map} +1 -1
  25. package/dist/cjs/{getItem-CrwWYCkj.js → getItem-DgnaQzbE.js} +5 -4
  26. package/dist/cjs/{getItem-CrwWYCkj.js.map → getItem-DgnaQzbE.js.map} +1 -1
  27. package/dist/cjs/{getPublishPayload-DRJh7WR0.js → getPublishPayload-CqlqRdot.js} +12 -11
  28. package/dist/cjs/{getPublishPayload-DRJh7WR0.js.map → getPublishPayload-CqlqRdot.js.map} +1 -1
  29. package/dist/cjs/getPublishUploads-DsXY9S4U.js +872 -0
  30. package/dist/cjs/getPublishUploads-DsXY9S4U.js.map +1 -0
  31. package/dist/cjs/{index-BA1RIYFG.js → index-BHaWOwNF.js} +6 -5
  32. package/dist/cjs/index-BHaWOwNF.js.map +1 -0
  33. package/dist/cjs/{index-Dls7aMjr.js → index-C4XlgCJ4.js} +1200 -528
  34. package/dist/cjs/index-C4XlgCJ4.js.map +1 -0
  35. package/dist/cjs/{property-ZerTWizX.js → property-fa0iju0J.js} +8 -7
  36. package/dist/cjs/{property-ZerTWizX.js.map → property-fa0iju0J.js.map} +1 -1
  37. package/dist/cjs/{publishDraftGraph-CPOAcQFf.js → publishDraftGraph-3ASwAlD7.js} +4 -4
  38. package/dist/cjs/{publishDraftGraph-CPOAcQFf.js.map → publishDraftGraph-3ASwAlD7.js.map} +1 -1
  39. package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js → resetAmbiguousLegacyItemData-Bu_MBBYt.js} +5 -4
  40. package/dist/cjs/{resetAmbiguousLegacyItemData-adDl4LcT.js.map → resetAmbiguousLegacyItemData-Bu_MBBYt.js.map} +1 -1
  41. package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js → resolveModelForSyncedSeed-BANIiuFU.js} +2 -2
  42. package/dist/cjs/{resolveModelForSyncedSeed-DoNThPdL.js.map → resolveModelForSyncedSeed-BANIiuFU.js.map} +1 -1
  43. package/dist/cjs/{syncDbWithEas-CYfPkus9.js → syncDbWithEas-CrmxxmUW.js} +10 -9
  44. package/dist/cjs/{syncDbWithEas-CYfPkus9.js.map → syncDbWithEas-CrmxxmUW.js.map} +1 -1
  45. package/dist/{configurePlatform-xU3Hsno3.js → configurePlatform-BRw2j0ZN.js} +7 -4
  46. package/dist/{configurePlatform-xU3Hsno3.js.map → configurePlatform-BRw2j0ZN.js.map} +1 -1
  47. package/dist/{db-W1g29qsM.js → db-D9K_f5cF.js} +14 -14
  48. package/dist/{db-W1g29qsM.js.map → db-D9K_f5cF.js.map} +1 -1
  49. package/dist/{eas-CSwV6MvB.js → eas-DHxfswCt.js} +8 -5
  50. package/dist/eas-DHxfswCt.js.map +1 -0
  51. package/dist/{getItem-BYQeM3DY.js → getItem-d6N_aM6S.js} +8 -5
  52. package/dist/{getItem-BYQeM3DY.js.map → getItem-d6N_aM6S.js.map} +1 -1
  53. package/dist/{getPublishPayload-D5CQZd-y.js → getPublishPayload-BHrxVtzY.js} +16 -16
  54. package/dist/{getPublishPayload-D5CQZd-y.js.map → getPublishPayload-BHrxVtzY.js.map} +1 -1
  55. package/dist/getPublishUploads-BEqRiKIS.js +657 -0
  56. package/dist/getPublishUploads-BEqRiKIS.js.map +1 -0
  57. package/dist/{index-Bev-hZF-.js → index-CiMEoGu3.js} +12 -11
  58. package/dist/index-CiMEoGu3.js.map +1 -0
  59. package/dist/{index-CSOQFAOn.js → index-DglvthOk.js} +2 -2
  60. package/dist/index-DglvthOk.js.map +1 -0
  61. package/dist/{index-DRXC5Mra.js → index-s15q14rm.js} +29 -29
  62. package/dist/{index-DRXC5Mra.js.map → index-s15q14rm.js.map} +1 -1
  63. package/dist/{index.browser-DO20vYuP.js → index.browser-Cm06tP4X.js} +553 -165
  64. package/dist/index.browser-Cm06tP4X.js.map +1 -0
  65. package/dist/{index.node-C4iyOhdo.js → index.node-C30dmFgn.js} +5 -5
  66. package/dist/{index.node-C4iyOhdo.js.map → index.node-C30dmFgn.js.map} +1 -1
  67. package/dist/main.cjs +4 -3
  68. package/dist/main.cjs.map +1 -1
  69. package/dist/main.js +32 -44
  70. package/dist/main.js.map +1 -1
  71. package/dist/mimeTypes-DHAHC4eZ.js +204 -0
  72. package/dist/mimeTypes-DHAHC4eZ.js.map +1 -0
  73. package/dist/node.js +13 -12
  74. package/dist/node.js.map +1 -1
  75. package/dist/platform.browser.js +9 -7
  76. package/dist/platform.browser.js.map +1 -1
  77. package/dist/platform.node.js +3 -3
  78. package/dist/{property-BT1zDSkd.js → property-DhmmYAvQ.js} +12 -9
  79. package/dist/property-DhmmYAvQ.js.map +1 -0
  80. package/dist/{publishDraftGraph-Bcfrdj7-.js → publishDraftGraph-yYP74WRt.js} +8 -8
  81. package/dist/{publishDraftGraph-Bcfrdj7-.js.map → publishDraftGraph-yYP74WRt.js.map} +1 -1
  82. package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js → resetAmbiguousLegacyItemData-Bk0QyDW8.js} +2 -2
  83. package/dist/{resetAmbiguousLegacyItemData-Ci6PM_vC.js.map → resetAmbiguousLegacyItemData-Bk0QyDW8.js.map} +1 -1
  84. package/dist/{resolveModelForSyncedSeed-CLlumTBq.js → resolveModelForSyncedSeed-8cAzvUFd.js} +2 -2
  85. package/dist/{resolveModelForSyncedSeed-CLlumTBq.js.map → resolveModelForSyncedSeed-8cAzvUFd.js.map} +1 -1
  86. package/dist/src/Item/Item.d.ts +1 -1
  87. package/dist/src/Item/Item.d.ts.map +1 -1
  88. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  89. package/dist/src/browser/helpers/FileManager.d.ts +4 -1
  90. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  91. package/dist/src/browser/helpers/tolerantWebAccess.d.ts +79 -4
  92. package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -1
  93. package/dist/src/browser/workers/FileDownloader.d.ts +19 -4
  94. package/dist/src/browser/workers/FileDownloader.d.ts.map +1 -1
  95. package/dist/src/browser/workers/filesDownload.d.ts.map +1 -1
  96. package/dist/src/client/clientManagerMachine.d.ts.map +1 -1
  97. package/dist/src/db/migrateLegacyItemStorageRows.d.ts +57 -0
  98. package/dist/src/db/migrateLegacyItemStorageRows.d.ts.map +1 -0
  99. package/dist/src/db/read/getCompositeChildPaths.d.ts +13 -0
  100. package/dist/src/db/read/getCompositeChildPaths.d.ts.map +1 -0
  101. package/dist/src/db/read/getItems.d.ts.map +1 -1
  102. package/dist/src/db/read/getPublishUploads.d.ts +32 -3
  103. package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
  104. package/dist/src/db/read/summarizePublishWork.d.ts.map +1 -1
  105. package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts +44 -0
  106. package/dist/src/db/write/convertVerbatimItemStorageRow.d.ts.map +1 -0
  107. package/dist/src/db/write/createNewItem.d.ts.map +1 -1
  108. package/dist/src/events/files/download.d.ts.map +1 -1
  109. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +3 -3
  110. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  111. package/dist/src/helpers/FileManager/IFileManager.d.ts +25 -1
  112. package/dist/src/helpers/FileManager/IFileManager.d.ts.map +1 -1
  113. package/dist/src/helpers/arweaveContentTags.d.ts +33 -0
  114. package/dist/src/helpers/arweaveContentTags.d.ts.map +1 -0
  115. package/dist/src/helpers/compositeUpload.d.ts +28 -0
  116. package/dist/src/helpers/compositeUpload.d.ts.map +1 -0
  117. package/dist/src/helpers/itemStorageFile.d.ts +57 -0
  118. package/dist/src/helpers/itemStorageFile.d.ts.map +1 -0
  119. package/dist/src/helpers/mapWithConcurrency.d.ts +7 -0
  120. package/dist/src/helpers/mapWithConcurrency.d.ts.map +1 -0
  121. package/dist/src/helpers/mimeTypes.d.ts +43 -0
  122. package/dist/src/helpers/mimeTypes.d.ts.map +1 -0
  123. package/dist/src/helpers/ownership.d.ts +19 -3
  124. package/dist/src/helpers/ownership.d.ts.map +1 -1
  125. package/dist/src/helpers/storageDir.d.ts +16 -0
  126. package/dist/src/helpers/storageDir.d.ts.map +1 -0
  127. package/dist/src/helpers/tabCoordinator.d.ts +5 -1
  128. package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
  129. package/dist/src/helpers/tabEvents.d.ts +23 -2
  130. package/dist/src/helpers/tabEvents.d.ts.map +1 -1
  131. package/dist/src/helpers/tabLocks.d.ts +11 -1
  132. package/dist/src/helpers/tabLocks.d.ts.map +1 -1
  133. package/dist/src/index.d.ts +6 -4
  134. package/dist/src/index.d.ts.map +1 -1
  135. package/dist/src/types/fileManager.d.ts +3 -14
  136. package/dist/src/types/fileManager.d.ts.map +1 -1
  137. package/dist/src/types/publish.d.ts +14 -0
  138. package/dist/src/types/publish.d.ts.map +1 -1
  139. package/dist/{syncDbWithEas-BQsXjGhe.js → syncDbWithEas--HUA9WNb.js} +15 -14
  140. package/dist/syncDbWithEas--HUA9WNb.js.map +1 -0
  141. package/dist/{tabEvents-C9qUKx_z.js → tabEvents-DguZpCCv.js} +338 -60
  142. package/dist/tabEvents-DguZpCCv.js.map +1 -0
  143. package/dist/tolerantWebAccess-BZYWt09Y.js +551 -0
  144. package/dist/tolerantWebAccess-BZYWt09Y.js.map +1 -0
  145. package/dist/{updateSeedRevokedAt-D6q0h7pj.js → updateSeedRevokedAt-D_EG-q3b.js} +3 -3
  146. package/dist/{updateSeedRevokedAt-D6q0h7pj.js.map → updateSeedRevokedAt-D_EG-q3b.js.map} +1 -1
  147. package/package.json +5 -5
  148. package/dist/BasePathResolver-BdxCSIzn.js.map +0 -1
  149. package/dist/ClientManager-ClCwwhwo.js.map +0 -1
  150. package/dist/Item-B9Y4VuK1.js.map +0 -1
  151. package/dist/ModelProperty-BMePcicQ.js.map +0 -1
  152. package/dist/cjs/getPublishUploads-Bh22D3zJ.js +0 -495
  153. package/dist/cjs/getPublishUploads-Bh22D3zJ.js.map +0 -1
  154. package/dist/cjs/index-BA1RIYFG.js.map +0 -1
  155. package/dist/cjs/index-Dls7aMjr.js.map +0 -1
  156. package/dist/eas-CSwV6MvB.js.map +0 -1
  157. package/dist/getPublishUploads-BGpDsrBp.js +0 -484
  158. package/dist/getPublishUploads-BGpDsrBp.js.map +0 -1
  159. package/dist/index-Bev-hZF-.js.map +0 -1
  160. package/dist/index-CSOQFAOn.js.map +0 -1
  161. package/dist/index.browser-DO20vYuP.js.map +0 -1
  162. package/dist/property-BT1zDSkd.js.map +0 -1
  163. package/dist/syncDbWithEas-BQsXjGhe.js.map +0 -1
  164. package/dist/tabEvents-C9qUKx_z.js.map +0 -1
  165. package/dist/tolerantWebAccess-B-9bwxbw.js +0 -160
  166. package/dist/tolerantWebAccess-B-9bwxbw.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { a as BaseDb, p as properties, j as models, r as seeds, Z as ZERO_BYTES32, v as versions } from './BasePathResolver-BdxCSIzn.js';
2
- import { i as isVersionRevoked, p as parseListPropertyValueFromStorage } from './Item-B9Y4VuK1.js';
1
+ import { B as BaseDb, p as properties, i as models, q as seeds, Z as ZERO_BYTES32, v as versions } from './BasePathResolver-CfSfMW5_.js';
2
+ import { j as isVersionRevoked, p as parseListPropertyValueFromStorage } from './Item-C7sUUu2B.js';
3
3
  import 'reflect-metadata';
4
- import './index-DRXC5Mra.js';
5
- import { q as getItemModelScope, M as ModelPropertyDataTypes, p as resolveModelRecord, n as normalizeDataType } from './db-W1g29qsM.js';
6
- import { getPropertySchema } from './property-BT1zDSkd.js';
4
+ import './index-s15q14rm.js';
5
+ import { q as getItemModelScope, M as ModelPropertyDataTypes, p as resolveModelRecord, n as normalizeDataType } from './db-D9K_f5cF.js';
6
+ import { getPropertySchema } from './property-DhmmYAvQ.js';
7
7
  import { and, eq, isNotNull } from 'drizzle-orm';
8
8
  import { upperFirst, camelCase } from 'lodash-es';
9
- import { n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, i as isPublishedSeedRef } from './tabEvents-C9qUKx_z.js';
9
+ import { n as normalizeRelationPropertyValue, r as resolveSeedIdsFromRefString, i as isPublishedSeedRef } from './tabEvents-DguZpCCv.js';
10
10
  import 'pluralize';
11
11
 
12
12
  const matchesDataType = (actual, expected) => normalizeDataType(actual) === expected;
@@ -306,7 +306,7 @@ function walksProperty(prop, forceFullSnapshot) {
306
306
  return value != null && value !== '' && !(Array.isArray(value) && value.length === 0);
307
307
  }
308
308
  async function loadItem(seedLocalId) {
309
- const { getItem } = await import('./getItem-BYQeM3DY.js');
309
+ const { getItem } = await import('./getItem-d6N_aM6S.js');
310
310
  try {
311
311
  return (await getItem({ seedLocalId })) ?? undefined;
312
312
  }
@@ -402,4 +402,4 @@ var publishDraftGraph = /*#__PURE__*/Object.freeze({
402
402
  });
403
403
 
404
404
  export { getSegmentedItemProperties as a, isUnpublishedSeed as b, isLivePublishedSeed as c, draftWalkProperties as d, findRelatedSeedRow as f, getPublishDraftGraph as g, htmlPropertyNameForHtmlSeed as h, isSeedRevoked as i, publishDraftGraph as p, relatedModelNameFromDef as r };
405
- //# sourceMappingURL=publishDraftGraph-Bcfrdj7-.js.map
405
+ //# sourceMappingURL=publishDraftGraph-yYP74WRt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"publishDraftGraph-Bcfrdj7-.js","sources":["../../src/helpers/getSegmentedItemProperties.ts","../../src/db/read/isSeedRevoked.ts","../../src/db/read/resolveRelatedSeedRef.ts","../../src/db/read/publishDraftGraph.ts"],"sourcesContent":["import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport { getItemModelScope, resolveModelRecord, type ModelScope } from '@/db/read/resolveModelRecord'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n scope: ModelScope,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n let schema = await getPropertySchema(modelName, propertyName, scope)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecord = await resolveModelRecord(normalizedModelName, scope, db)\n const modelRecords = modelRecord ? [modelRecord] : []\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n let itemScope: ModelScope | undefined\n\n for (const itemProperty of item.properties) {\n let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n itemScope ??= await getItemModelScope(item as any)\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName, itemScope)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Json)))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.List)) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { isVersionRevoked } from './subqueries/liveVersion'\n\n/**\n * True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS\n * sync). Such a seed can't take new versions: publishing again creates a new seed attestation\n * (see \"Republishing\" in docs/ATTESTATION_REVOCATION.md).\n */\nexport const isSeedRevoked = async (seedLocalId: string | undefined): Promise<boolean> => {\n if (!seedLocalId) return false\n const appDb = BaseDb.getAppDb()\n if (!appDb) return false\n const [row] = await appDb\n .select({ revokedAt: seeds.revokedAt })\n .from(seeds)\n .where(eq(seeds.localId, seedLocalId))\n .limit(1)\n return isVersionRevoked(row?.revokedAt)\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds, versions } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { ZERO_BYTES32 } from '@/helpers/constants'\nimport { isVersionRevoked } from './subqueries/liveVersion'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\nimport type { IItem } from '@/interfaces'\n\nexport type RelatedSeedRow = {\n seedLocalId: string\n /** The seed's current uid (null while it was never published). */\n seedUid: string | null\n revokedAt: number | null\n type: string | null\n}\n\nconst selectSeed = {\n seedLocalId: seeds.localId,\n seedUid: seeds.uid,\n revokedAt: seeds.revokedAt,\n type: seeds.type,\n}\n\n/**\n * The local seed row a relation/list/image ref points at, by local id or uid. A uid that is no\n * seed's current uid can be the old uid of a seed that was unpublished and published again (a new\n * seed attestation, same local seed): its old version rows still record it, so it resolves to that\n * seed. Null when nothing local matches (e.g. a published uid with no local copy).\n */\nexport const findRelatedSeedRow = async ({\n seedLocalId,\n seedUid,\n}: {\n seedLocalId?: string\n seedUid?: string\n}): Promise<RelatedSeedRow | null> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n if (seedLocalId) {\n const [row] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.localId, seedLocalId)).limit(1)\n if (row?.seedLocalId) return row as RelatedSeedRow\n }\n if (!seedUid || seedUid === ZERO_BYTES32) return null\n const [byUid] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.uid, seedUid)).limit(1)\n if (byUid?.seedLocalId) return byUid as RelatedSeedRow\n const [version] = await appDb\n .select({ seedLocalId: versions.seedLocalId })\n .from(versions)\n .where(and(eq(versions.seedUid, seedUid), isNotNull(versions.seedLocalId)))\n .limit(1)\n if (!version?.seedLocalId) return null\n const [republished] = await appDb\n .select(selectSeed)\n .from(seeds)\n .where(eq(seeds.localId, version.seedLocalId))\n .limit(1)\n return republished?.seedLocalId ? (republished as RelatedSeedRow) : null\n}\n\n/** The seed is attested and its attestation is live. */\nexport const isLivePublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt)\n\n/** The seed was attested and that attestation was revoked (unpublished). */\nexport const isUnpublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt)\n\n/** Model a relation/list/image property points at, from its definition. */\nexport function relatedModelNameFromDef(propertyDef: unknown): string | undefined {\n const def = propertyDef as { dataType?: string; ref?: string; refModelName?: string } | undefined\n if (!def) return undefined\n const dataType = normalizeDataType(def.dataType)\n if (dataType === ModelPropertyDataTypes.Image) return 'Image'\n if (dataType === ModelPropertyDataTypes.File) return 'File'\n if (dataType === ModelPropertyDataTypes.Html) return 'Html'\n return def.ref ?? def.refModelName\n}\n\n/**\n * Name of the item's Html property whose value is the Html seed `htmlSeedLocalId`: the property\n * that refers to the images embedded in that Html (htmlEmbeddedImageCoPublish rows).\n */\nexport function htmlPropertyNameForHtmlSeed(item: IItem<any>, htmlSeedLocalId: string): string {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties ?? []) {\n if (normalizeDataType(p.propertyDef?.dataType) !== ModelPropertyDataTypes.Html) continue\n const snap = p.getService().getSnapshot()\n const value = 'context' in snap ? (snap.context as { propertyValue?: unknown }).propertyValue : undefined\n if (typeof value === 'string' && value.trim() === want) return p.propertyName\n }\n return 'html'\n}\n","import { ZERO_BYTES32 } from '@/helpers/constants'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport type { IItem, IItemProperty } from '@/interfaces'\nimport { findRelatedSeedRow } from '@/db/read/resolveRelatedSeedRef'\nimport { isSeedRevoked } from '@/db/read/isSeedRevoked'\n\n/**\n * The draft items a publish of an item carries along, and how it walks to them.\n *\n * A publish attests the item and every draft item (no seed uid yet) reachable from it through\n * relation and list-of-relation properties, each with its full property set. Already-published\n * targets are referenced by their current uid and not walked into; revoked ones stop the publish\n * (RelatedItemUnpublishedError). getPublishPayload, getPublishUploads, getPublishUploadData (publish\n * package), summarizePublishWork and the Html-embedded image co-publish all walk this graph in the\n * same order: depth first, properties in item order (relations, then lists), list members in order.\n *\n * Cycles: an item can only attest the uid of a seed published before it in the same publish, so a\n * ref back to an item still being walked (an ancestor that gets a new seed in this publish) can't be\n * attested. Such a property is deferred: left out of this publish (it keeps no uid, so the next\n * publish of its item attests it, with the target's uid). For A ↔ B reached from A, A attests B's\n * uid and B's relation to A is deferred.\n */\n\n/** Relation properties that point at model items (not Image/File/Html/Json storage seeds). */\nexport function draftWalkProperties(segmented: {\n itemRelationProperties: IItemProperty<any>[]\n itemImageProperties: IItemProperty<any>[]\n itemListProperties: IItemProperty<any>[]\n}): { relationProperties: IItemProperty<any>[]; listProperties: IItemProperty<any>[] } {\n const storage = new Set(segmented.itemImageProperties)\n return {\n relationProperties: segmented.itemRelationProperties.filter((p) => !storage.has(p)),\n listProperties: segmented.itemListProperties,\n }\n}\n\nconst propertyContext = (prop: IItemProperty<any>): Record<string, unknown> | null => {\n const snapshot = prop.getService().getSnapshot()\n return snapshot && 'context' in snapshot\n ? ((snapshot as { context?: Record<string, unknown> }).context ?? null)\n : null\n}\n\n/** Seed refs held by a relation property (one) or a list property (each member). */\nexport function propertySeedRefs(prop: IItemProperty<any>, isList: boolean): string[] {\n const context = propertyContext(prop)\n if (!context) return []\n let value = context.propertyValue\n if (isList) {\n if (typeof value === 'string') value = parseListPropertyValueFromStorage(value)\n const arr = Array.isArray(value) ? value : value != null ? [value] : []\n return arr\n .map((v) =>\n v && typeof v === 'object'\n ? normalizeRelationPropertyValue(\n (v as { seedLocalId?: string; localId?: string }).seedLocalId ??\n (v as { localId?: string }).localId ??\n (v as { seedUid?: string }).seedUid ??\n (v as { uid?: string }).uid,\n )\n : normalizeRelationPropertyValue(v),\n )\n .filter((v): v is string => !!v)\n }\n const ref = normalizeRelationPropertyValue(value)\n return ref ? [ref] : []\n}\n\nconst isZeroUid = (uid: string | undefined | null): boolean => !uid || uid === ZERO_BYTES32\n\n/** The item gets a new seed attestation in this publish: a draft, or a revoked seed published again. */\nexport async function getsNewSeed(item: IItem<any>): Promise<boolean> {\n return isZeroUid(item.seedUid) || (await isSeedRevoked(item.seedLocalId))\n}\n\n/** Local seed id a ref points at (also for a republished seed's old uid), or undefined. */\nexport async function resolveRefSeedLocalId(ref: string): Promise<string | undefined> {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) return undefined\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n return row?.seedLocalId ?? seedLocalId\n}\n\nexport type PublishDraftGraphNode = {\n item: IItem<any>\n /** The relation or list property the walk first reached the item through. */\n via: IItemProperty<any>\n viaList: boolean\n}\n\nexport type PublishDraftGraph = {\n /** Draft items reachable from the root (root excluded), in the order the walk finishes them. */\n drafts: PublishDraftGraphNode[]\n /** Properties pointing back at an item still being walked; left out of this publish. */\n deferredProperties: Set<IItemProperty<any>>\n /** For each deferred property, the seeds (local ids) of its back references. */\n backReferences: Map<IItemProperty<any>, Set<string>>\n}\n\nexport type GetPublishDraftGraphOptions = {\n /** `new_version` / republish: properties that already have a uid are attested (and walked) again. */\n forceFullSnapshot?: boolean\n /**\n * Throw like getPublishUploads always did when a relation holds an invalid value or a local id\n * with no local item. Otherwise such refs are skipped (getPublishPayload reports them).\n */\n strict?: boolean\n}\n\n/** Would the publish attest this property (so walk its refs)? Same rule as getPublishPayload. */\nfunction walksProperty(prop: IItemProperty<any>, forceFullSnapshot: boolean): boolean {\n if (prop.uid && !forceFullSnapshot) return false\n const ctx = propertyContext(prop)\n const value = ctx?.propertyValue\n return value != null && value !== '' && !(Array.isArray(value) && value.length === 0)\n}\n\nasync function loadItem(seedLocalId: string): Promise<IItem<any> | undefined> {\n const { getItem } = await import('./getItem')\n try {\n return (await getItem({ seedLocalId })) ?? undefined\n } catch {\n return undefined\n }\n}\n\nexport async function getPublishDraftGraph(\n root: IItem<any>,\n options?: GetPublishDraftGraphOptions,\n): Promise<PublishDraftGraph> {\n const forceFullSnapshot = options?.forceFullSnapshot === true\n const strict = options?.strict === true\n const drafts: PublishDraftGraphNode[] = []\n const deferredProperties = new Set<IItemProperty<any>>()\n const backReferences = new Map<IItemProperty<any>, Set<string>>()\n const visited = new Set<string>([root.seedLocalId])\n const inProgress = new Set<string>()\n if (await getsNewSeed(root)) inProgress.add(root.seedLocalId)\n\n /** Draft target of a ref, or undefined (published, revoked, unknown). */\n const draftTarget = async (\n prop: IItemProperty<any>,\n ref: string,\n isList: boolean,\n ): Promise<{ seedLocalId: string; item?: IItem<any> } | undefined> => {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) {\n if (strict && !isList) {\n throw new Error(`Invalid relation value for ${prop.propertyName}: expected local seed id or 0x uid`)\n }\n return undefined\n }\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n const targetLocalId = row?.seedLocalId ?? seedLocalId\n if (!targetLocalId) return undefined\n // An item getting a new seed in this publish, still being walked (also the root when it is a\n // revoked seed published again): a back edge, whatever its current uid.\n if (inProgress.has(targetLocalId)) return { seedLocalId: targetLocalId }\n // Published (live or revoked): referenced by uid / reported, never walked into.\n if (row && !isZeroUid(row.seedUid)) return undefined\n if (visited.has(targetLocalId)) return { seedLocalId: targetLocalId }\n const item = await loadItem(targetLocalId)\n if (!item) {\n if (strict && !isList && !isPublishedSeedRef(ref)) {\n throw new Error(`No relatedItem found for ${prop.propertyName}`)\n }\n return undefined\n }\n if (!isZeroUid(item.seedUid)) return undefined\n return { seedLocalId: targetLocalId, item }\n }\n\n const visit = async (item: IItem<any>): Promise<void> => {\n const segmented = await getSegmentedItemProperties(item)\n const { relationProperties, listProperties } = draftWalkProperties(segmented)\n const walk = async (prop: IItemProperty<any>, isList: boolean) => {\n if (!walksProperty(prop, forceFullSnapshot)) return\n const targets: { seedLocalId: string; item?: IItem<any> }[] = []\n for (const ref of propertySeedRefs(prop, isList)) {\n const t = await draftTarget(prop, ref, isList)\n if (t) targets.push(t)\n }\n const back = targets.filter((t) => inProgress.has(t.seedLocalId)).map((t) => t.seedLocalId)\n if (back.length > 0) {\n deferredProperties.add(prop)\n backReferences.set(prop, new Set(back))\n }\n for (const t of targets) {\n if (!t.item || visited.has(t.seedLocalId)) continue\n visited.add(t.seedLocalId)\n inProgress.add(t.seedLocalId)\n await visit(t.item)\n inProgress.delete(t.seedLocalId)\n drafts.push({ item: t.item, via: prop, viaList: isList })\n }\n }\n for (const prop of relationProperties) await walk(prop, false)\n for (const prop of listProperties) await walk(prop, true)\n }\n\n await visit(root)\n return { drafts, deferredProperties, backReferences }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,MAAM,eAAe,GAAG,CACtB,MAA0B,EAC1B,QAAyC,KAC7B,iBAAiB,CAAC,MAAM,CAAC,KAAK,QAAQ;AACpD,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EACpB,KAAiB,EAAA;IAEjB,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC;AACpE,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,MAAM;AACzB,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,SAAS;AACzB,IAAA,IAAI;QACF,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC;AAC5E,QAAA,MAAM,YAAY,GAAG,WAAW,GAAG,CAAC,WAAW,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AAM,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACnB,gBAAA,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;AAChC,gBAAA,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC3D;AACF,QAAA,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,kBAAkB;AAAE,YAAA,MAAM,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;QAC9D,KAAK,MAAM,IAAI,IAAI,cAAc;AAAE,YAAA,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AAC3D,IAAA,CAAC;AAED,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC;AACjB,IAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE;AACvD;;;;;;;;;;"}
1
+ {"version":3,"file":"publishDraftGraph-yYP74WRt.js","sources":["../../src/helpers/getSegmentedItemProperties.ts","../../src/db/read/isSeedRevoked.ts","../../src/db/read/resolveRelatedSeedRef.ts","../../src/db/read/publishDraftGraph.ts"],"sourcesContent":["import { UploadProperty } from '@/db/read/getPublishUploads'\nimport { IItem } from '@/interfaces'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/Schema'\nimport { getPropertySchema, TProperty } from '@/helpers/property'\nimport { getItemModelScope, resolveModelRecord, type ModelScope } from '@/db/read/resolveModelRecord'\nimport type { Static } from '@sinclair/typebox'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models, properties } from '@/seedSchema'\nimport { eq, and } from 'drizzle-orm'\nimport { camelCase, upperFirst } from 'lodash-es'\n\nconst matchesDataType = (\n actual: string | undefined,\n expected: ModelPropertyDataTypes | string,\n): boolean => normalizeDataType(actual) === expected\nasync function resolvePropertyDef(\n modelName: string,\n propertyName: string,\n scope: ModelScope,\n): Promise<{ dataType?: string; ref?: string; refValueType?: string; storageType?: string; localStorageDir?: string; filenameSuffix?: string; required?: boolean } | undefined> {\n let schema = await getPropertySchema(modelName, propertyName, scope)\n if (schema) return schema\n const db = BaseDb.getAppDb()\n if (!db) return undefined\n try {\n const normalizedModelName = upperFirst(camelCase(modelName))\n const modelRecord = await resolveModelRecord(normalizedModelName, scope, db)\n const modelRecords = modelRecord ? [modelRecord] : []\n if (modelRecords.length === 0 || !modelRecords[0].id) return undefined\n const propertyRecords = await db\n .select()\n .from(properties)\n .where(\n and(\n eq(properties.modelId, modelRecords[0].id),\n eq(properties.name, propertyName),\n ),\n )\n .limit(1)\n if (propertyRecords.length === 0) return undefined\n const propRecord = propertyRecords[0]\n let refModelName: string | undefined\n if (propRecord.refModelId != null) {\n const refModelRows = await db\n .select({ name: models.name })\n .from(models)\n .where(eq(models.id, propRecord.refModelId))\n .limit(1)\n refModelName = refModelRows[0]?.name ?? undefined\n }\n return {\n dataType: propRecord.dataType,\n ref: refModelName ?? undefined,\n refValueType: propRecord.refValueType || undefined,\n storageType: propRecord.storageType || undefined,\n localStorageDir: propRecord.localStorageDir || undefined,\n filenameSuffix: propRecord.filenameSuffix || undefined,\n required: propRecord.required ?? undefined,\n }\n } catch {\n return undefined\n }\n}\n\nexport const getSegmentedItemProperties = async (item: IItem<any>) => {\n const itemBasicProperties = []\n const itemRelationProperties = []\n const itemListProperties = []\n const itemUploadProperties: UploadProperty[] = []\n const itemImageProperties = []\n const itemStorageProperties = []\n let itemStorageTransactionProperty: UploadProperty | undefined\n let itemScope: ModelScope | undefined\n\n for (const itemProperty of item.properties) {\n let propertyDef = itemProperty.propertyDef\n // When propertyDef is missing (e.g. external app, Model not registered), resolve inline\n // so properties are not skipped and metadata attestations can be created\n if (!propertyDef && item.modelName) {\n itemScope ??= await getItemModelScope(item as any)\n const resolved = await resolvePropertyDef(item.modelName, itemProperty.propertyName, itemScope)\n if (resolved) {\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: resolved })\n propertyDef = resolved as Static<typeof TProperty>\n } else {\n // Last resort: Model and DB don't have schema. Use Text so property routes to\n // itemBasicProperties and can be attested (covers title, description, etc.)\n const fallbackDef = { dataType: 'Text' as const }\n itemProperty.getService().send({ type: 'updateContext', propertyRecordSchema: fallbackDef })\n propertyDef = fallbackDef as Static<typeof TProperty>\n }\n }\n if (!propertyDef) {\n continue\n }\n\n const isItemStorage =\n propertyDef.storageType &&\n propertyDef.storageType === 'ItemStorage'\n\n\n const isStorageTransaction =\n itemProperty.propertyName === 'storageTransactionId' ||\n itemProperty.propertyName === 'storage_transaction_id'\n\n const isStorageSeedType =\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Json) ||\n (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation) &&\n (matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Image) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.File) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Html) ||\n matchesDataType(propertyDef.refValueType, ModelPropertyDataTypes.Json)))\n\n if (isStorageSeedType) {\n itemImageProperties.push(itemProperty)\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n }\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.Relation)) {\n itemRelationProperties.push(itemProperty)\n continue\n }\n\n if (matchesDataType(propertyDef.dataType, ModelPropertyDataTypes.List)) {\n // List-of-relations: ref present, goes to processListProperty\n // List-of-primitives: ref absent, treat as basic property\n const listRef =\n propertyDef.ref || (propertyDef as { refModelName?: string }).refModelName\n if (listRef) {\n itemListProperties.push(itemProperty)\n } else {\n itemBasicProperties.push(itemProperty)\n }\n continue\n }\n\n if (isItemStorage) {\n itemStorageProperties.push(itemProperty)\n continue\n }\n\n if (isStorageTransaction) {\n itemStorageTransactionProperty = { itemProperty, childProperties: [] }\n continue\n }\n\n itemBasicProperties.push(itemProperty)\n }\n\n if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {\n itemStorageTransactionProperty.childProperties = itemStorageProperties\n }\n\n if (itemStorageTransactionProperty) {\n itemUploadProperties.push(itemStorageTransactionProperty)\n }\n\n return {\n itemBasicProperties,\n itemRelationProperties,\n itemListProperties,\n itemUploadProperties,\n itemImageProperties,\n }\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { eq } from 'drizzle-orm'\nimport { isVersionRevoked } from './subqueries/liveVersion'\n\n/**\n * True when the item's seed attestation was revoked (`seeds.revoked_at` set, by unpublish or EAS\n * sync). Such a seed can't take new versions: publishing again creates a new seed attestation\n * (see \"Republishing\" in docs/ATTESTATION_REVOCATION.md).\n */\nexport const isSeedRevoked = async (seedLocalId: string | undefined): Promise<boolean> => {\n if (!seedLocalId) return false\n const appDb = BaseDb.getAppDb()\n if (!appDb) return false\n const [row] = await appDb\n .select({ revokedAt: seeds.revokedAt })\n .from(seeds)\n .where(eq(seeds.localId, seedLocalId))\n .limit(1)\n return isVersionRevoked(row?.revokedAt)\n}\n","import { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds, versions } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { ZERO_BYTES32 } from '@/helpers/constants'\nimport { isVersionRevoked } from './subqueries/liveVersion'\nimport { ModelPropertyDataTypes, normalizeDataType } from '@/helpers/property'\nimport type { IItem } from '@/interfaces'\n\nexport type RelatedSeedRow = {\n seedLocalId: string\n /** The seed's current uid (null while it was never published). */\n seedUid: string | null\n revokedAt: number | null\n type: string | null\n}\n\nconst selectSeed = {\n seedLocalId: seeds.localId,\n seedUid: seeds.uid,\n revokedAt: seeds.revokedAt,\n type: seeds.type,\n}\n\n/**\n * The local seed row a relation/list/image ref points at, by local id or uid. A uid that is no\n * seed's current uid can be the old uid of a seed that was unpublished and published again (a new\n * seed attestation, same local seed): its old version rows still record it, so it resolves to that\n * seed. Null when nothing local matches (e.g. a published uid with no local copy).\n */\nexport const findRelatedSeedRow = async ({\n seedLocalId,\n seedUid,\n}: {\n seedLocalId?: string\n seedUid?: string\n}): Promise<RelatedSeedRow | null> => {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return null\n if (seedLocalId) {\n const [row] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.localId, seedLocalId)).limit(1)\n if (row?.seedLocalId) return row as RelatedSeedRow\n }\n if (!seedUid || seedUid === ZERO_BYTES32) return null\n const [byUid] = await appDb.select(selectSeed).from(seeds).where(eq(seeds.uid, seedUid)).limit(1)\n if (byUid?.seedLocalId) return byUid as RelatedSeedRow\n const [version] = await appDb\n .select({ seedLocalId: versions.seedLocalId })\n .from(versions)\n .where(and(eq(versions.seedUid, seedUid), isNotNull(versions.seedLocalId)))\n .limit(1)\n if (!version?.seedLocalId) return null\n const [republished] = await appDb\n .select(selectSeed)\n .from(seeds)\n .where(eq(seeds.localId, version.seedLocalId))\n .limit(1)\n return republished?.seedLocalId ? (republished as RelatedSeedRow) : null\n}\n\n/** The seed is attested and its attestation is live. */\nexport const isLivePublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && !isVersionRevoked(row.revokedAt)\n\n/** The seed was attested and that attestation was revoked (unpublished). */\nexport const isUnpublishedSeed = (row: RelatedSeedRow | null): row is RelatedSeedRow & { seedUid: string } =>\n !!row?.seedUid && row.seedUid !== ZERO_BYTES32 && isVersionRevoked(row.revokedAt)\n\n/** Model a relation/list/image property points at, from its definition. */\nexport function relatedModelNameFromDef(propertyDef: unknown): string | undefined {\n const def = propertyDef as { dataType?: string; ref?: string; refModelName?: string } | undefined\n if (!def) return undefined\n const dataType = normalizeDataType(def.dataType)\n if (dataType === ModelPropertyDataTypes.Image) return 'Image'\n if (dataType === ModelPropertyDataTypes.File) return 'File'\n if (dataType === ModelPropertyDataTypes.Html) return 'Html'\n return def.ref ?? def.refModelName\n}\n\n/**\n * Name of the item's Html property whose value is the Html seed `htmlSeedLocalId`: the property\n * that refers to the images embedded in that Html (htmlEmbeddedImageCoPublish rows).\n */\nexport function htmlPropertyNameForHtmlSeed(item: IItem<any>, htmlSeedLocalId: string): string {\n const want = htmlSeedLocalId.trim()\n for (const p of item.properties ?? []) {\n if (normalizeDataType(p.propertyDef?.dataType) !== ModelPropertyDataTypes.Html) continue\n const snap = p.getService().getSnapshot()\n const value = 'context' in snap ? (snap.context as { propertyValue?: unknown }).propertyValue : undefined\n if (typeof value === 'string' && value.trim() === want) return p.propertyName\n }\n return 'html'\n}\n","import { ZERO_BYTES32 } from '@/helpers/constants'\nimport { parseListPropertyValueFromStorage } from '@/helpers/listPropertyValueFromStorage'\nimport { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'\nimport {\n isPublishedSeedRef,\n normalizeRelationPropertyValue,\n resolveSeedIdsFromRefString,\n} from '@/helpers/relationSeedRef'\nimport type { IItem, IItemProperty } from '@/interfaces'\nimport { findRelatedSeedRow } from '@/db/read/resolveRelatedSeedRef'\nimport { isSeedRevoked } from '@/db/read/isSeedRevoked'\n\n/**\n * The draft items a publish of an item carries along, and how it walks to them.\n *\n * A publish attests the item and every draft item (no seed uid yet) reachable from it through\n * relation and list-of-relation properties, each with its full property set. Already-published\n * targets are referenced by their current uid and not walked into; revoked ones stop the publish\n * (RelatedItemUnpublishedError). getPublishPayload, getPublishUploads, getPublishUploadData (publish\n * package), summarizePublishWork and the Html-embedded image co-publish all walk this graph in the\n * same order: depth first, properties in item order (relations, then lists), list members in order.\n *\n * Cycles: an item can only attest the uid of a seed published before it in the same publish, so a\n * ref back to an item still being walked (an ancestor that gets a new seed in this publish) can't be\n * attested. Such a property is deferred: left out of this publish (it keeps no uid, so the next\n * publish of its item attests it, with the target's uid). For A ↔ B reached from A, A attests B's\n * uid and B's relation to A is deferred.\n */\n\n/** Relation properties that point at model items (not Image/File/Html/Json storage seeds). */\nexport function draftWalkProperties(segmented: {\n itemRelationProperties: IItemProperty<any>[]\n itemImageProperties: IItemProperty<any>[]\n itemListProperties: IItemProperty<any>[]\n}): { relationProperties: IItemProperty<any>[]; listProperties: IItemProperty<any>[] } {\n const storage = new Set(segmented.itemImageProperties)\n return {\n relationProperties: segmented.itemRelationProperties.filter((p) => !storage.has(p)),\n listProperties: segmented.itemListProperties,\n }\n}\n\nconst propertyContext = (prop: IItemProperty<any>): Record<string, unknown> | null => {\n const snapshot = prop.getService().getSnapshot()\n return snapshot && 'context' in snapshot\n ? ((snapshot as { context?: Record<string, unknown> }).context ?? null)\n : null\n}\n\n/** Seed refs held by a relation property (one) or a list property (each member). */\nexport function propertySeedRefs(prop: IItemProperty<any>, isList: boolean): string[] {\n const context = propertyContext(prop)\n if (!context) return []\n let value = context.propertyValue\n if (isList) {\n if (typeof value === 'string') value = parseListPropertyValueFromStorage(value)\n const arr = Array.isArray(value) ? value : value != null ? [value] : []\n return arr\n .map((v) =>\n v && typeof v === 'object'\n ? normalizeRelationPropertyValue(\n (v as { seedLocalId?: string; localId?: string }).seedLocalId ??\n (v as { localId?: string }).localId ??\n (v as { seedUid?: string }).seedUid ??\n (v as { uid?: string }).uid,\n )\n : normalizeRelationPropertyValue(v),\n )\n .filter((v): v is string => !!v)\n }\n const ref = normalizeRelationPropertyValue(value)\n return ref ? [ref] : []\n}\n\nconst isZeroUid = (uid: string | undefined | null): boolean => !uid || uid === ZERO_BYTES32\n\n/** The item gets a new seed attestation in this publish: a draft, or a revoked seed published again. */\nexport async function getsNewSeed(item: IItem<any>): Promise<boolean> {\n return isZeroUid(item.seedUid) || (await isSeedRevoked(item.seedLocalId))\n}\n\n/** Local seed id a ref points at (also for a republished seed's old uid), or undefined. */\nexport async function resolveRefSeedLocalId(ref: string): Promise<string | undefined> {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) return undefined\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n return row?.seedLocalId ?? seedLocalId\n}\n\nexport type PublishDraftGraphNode = {\n item: IItem<any>\n /** The relation or list property the walk first reached the item through. */\n via: IItemProperty<any>\n viaList: boolean\n}\n\nexport type PublishDraftGraph = {\n /** Draft items reachable from the root (root excluded), in the order the walk finishes them. */\n drafts: PublishDraftGraphNode[]\n /** Properties pointing back at an item still being walked; left out of this publish. */\n deferredProperties: Set<IItemProperty<any>>\n /** For each deferred property, the seeds (local ids) of its back references. */\n backReferences: Map<IItemProperty<any>, Set<string>>\n}\n\nexport type GetPublishDraftGraphOptions = {\n /** `new_version` / republish: properties that already have a uid are attested (and walked) again. */\n forceFullSnapshot?: boolean\n /**\n * Throw like getPublishUploads always did when a relation holds an invalid value or a local id\n * with no local item. Otherwise such refs are skipped (getPublishPayload reports them).\n */\n strict?: boolean\n}\n\n/** Would the publish attest this property (so walk its refs)? Same rule as getPublishPayload. */\nfunction walksProperty(prop: IItemProperty<any>, forceFullSnapshot: boolean): boolean {\n if (prop.uid && !forceFullSnapshot) return false\n const ctx = propertyContext(prop)\n const value = ctx?.propertyValue\n return value != null && value !== '' && !(Array.isArray(value) && value.length === 0)\n}\n\nasync function loadItem(seedLocalId: string): Promise<IItem<any> | undefined> {\n const { getItem } = await import('./getItem')\n try {\n return (await getItem({ seedLocalId })) ?? undefined\n } catch {\n return undefined\n }\n}\n\nexport async function getPublishDraftGraph(\n root: IItem<any>,\n options?: GetPublishDraftGraphOptions,\n): Promise<PublishDraftGraph> {\n const forceFullSnapshot = options?.forceFullSnapshot === true\n const strict = options?.strict === true\n const drafts: PublishDraftGraphNode[] = []\n const deferredProperties = new Set<IItemProperty<any>>()\n const backReferences = new Map<IItemProperty<any>, Set<string>>()\n const visited = new Set<string>([root.seedLocalId])\n const inProgress = new Set<string>()\n if (await getsNewSeed(root)) inProgress.add(root.seedLocalId)\n\n /** Draft target of a ref, or undefined (published, revoked, unknown). */\n const draftTarget = async (\n prop: IItemProperty<any>,\n ref: string,\n isList: boolean,\n ): Promise<{ seedLocalId: string; item?: IItem<any> } | undefined> => {\n const { seedLocalId, seedUid } = resolveSeedIdsFromRefString(ref)\n if (!seedLocalId && !seedUid) {\n if (strict && !isList) {\n throw new Error(`Invalid relation value for ${prop.propertyName}: expected local seed id or 0x uid`)\n }\n return undefined\n }\n const row = await findRelatedSeedRow({ seedLocalId, seedUid })\n const targetLocalId = row?.seedLocalId ?? seedLocalId\n if (!targetLocalId) return undefined\n // An item getting a new seed in this publish, still being walked (also the root when it is a\n // revoked seed published again): a back edge, whatever its current uid.\n if (inProgress.has(targetLocalId)) return { seedLocalId: targetLocalId }\n // Published (live or revoked): referenced by uid / reported, never walked into.\n if (row && !isZeroUid(row.seedUid)) return undefined\n if (visited.has(targetLocalId)) return { seedLocalId: targetLocalId }\n const item = await loadItem(targetLocalId)\n if (!item) {\n if (strict && !isList && !isPublishedSeedRef(ref)) {\n throw new Error(`No relatedItem found for ${prop.propertyName}`)\n }\n return undefined\n }\n if (!isZeroUid(item.seedUid)) return undefined\n return { seedLocalId: targetLocalId, item }\n }\n\n const visit = async (item: IItem<any>): Promise<void> => {\n const segmented = await getSegmentedItemProperties(item)\n const { relationProperties, listProperties } = draftWalkProperties(segmented)\n const walk = async (prop: IItemProperty<any>, isList: boolean) => {\n if (!walksProperty(prop, forceFullSnapshot)) return\n const targets: { seedLocalId: string; item?: IItem<any> }[] = []\n for (const ref of propertySeedRefs(prop, isList)) {\n const t = await draftTarget(prop, ref, isList)\n if (t) targets.push(t)\n }\n const back = targets.filter((t) => inProgress.has(t.seedLocalId)).map((t) => t.seedLocalId)\n if (back.length > 0) {\n deferredProperties.add(prop)\n backReferences.set(prop, new Set(back))\n }\n for (const t of targets) {\n if (!t.item || visited.has(t.seedLocalId)) continue\n visited.add(t.seedLocalId)\n inProgress.add(t.seedLocalId)\n await visit(t.item)\n inProgress.delete(t.seedLocalId)\n drafts.push({ item: t.item, via: prop, viaList: isList })\n }\n }\n for (const prop of relationProperties) await walk(prop, false)\n for (const prop of listProperties) await walk(prop, true)\n }\n\n await visit(root)\n return { drafts, deferredProperties, backReferences }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAWA,MAAM,eAAe,GAAG,CACtB,MAA0B,EAC1B,QAAyC,KAC7B,iBAAiB,CAAC,MAAM,CAAC,KAAK,QAAQ;AACpD,eAAe,kBAAkB,CAC/B,SAAiB,EACjB,YAAoB,EACpB,KAAiB,EAAA;IAEjB,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC;AACpE,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,MAAM;AACzB,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,SAAS;AACzB,IAAA,IAAI;QACF,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC;AAC5E,QAAA,MAAM,YAAY,GAAG,WAAW,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE;AACrD,QAAA,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;AAAE,YAAA,OAAO,SAAS;QACtE,MAAM,eAAe,GAAG,MAAM;AAC3B,aAAA,MAAM;aACN,IAAI,CAAC,UAAU;aACf,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1C,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAClC;aAEF,KAAK,CAAC,CAAC,CAAC;AACX,QAAA,IAAI,eAAe,CAAC,MAAM,KAAK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D,IAAA,CAAC;AAED,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC;AACjB,IAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE;AACvD;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { eq, and, isNull, isNotNull } from 'drizzle-orm';
2
2
  import { toSnakeCase } from 'drizzle-orm/casing';
3
3
  import debug from 'debug';
4
- import { a as BaseDb, b as appState, r as seeds, s as schemas, j as models, g as modelSchemas, h as htmlEmbeddedImageCoPublish, c as arweaveL1FinalizeJobs, u as uploadProcesses, q as publishProcesses, e as easSyncProcesses, m as metadata, v as versions } from './BasePathResolver-BdxCSIzn.js';
4
+ import { B as BaseDb, a as appState, q as seeds, s as schemas, i as models, f as modelSchemas, h as htmlEmbeddedImageCoPublish, b as arweaveL1FinalizeJobs, u as uploadProcesses, o as publishProcesses, e as easSyncProcesses, m as metadata, v as versions } from './BasePathResolver-CfSfMW5_.js';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import '@seedprotocol/arweave';
7
7
 
@@ -85,4 +85,4 @@ const resetAmbiguousLegacyItemData = async () => {
85
85
  };
86
86
 
87
87
  export { LEGACY_ITEM_MODEL_CHECK_KEY, resetAmbiguousLegacyItemData };
88
- //# sourceMappingURL=resetAmbiguousLegacyItemData-Ci6PM_vC.js.map
88
+ //# sourceMappingURL=resetAmbiguousLegacyItemData-Bk0QyDW8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resetAmbiguousLegacyItemData-Ci6PM_vC.js","sources":["../../src/db/resetAmbiguousLegacyItemData.ts"],"sourcesContent":["import { eq, isNotNull, isNull, and } from 'drizzle-orm'\nimport { toSnakeCase } from 'drizzle-orm/casing'\nimport debug from 'debug'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport {\n appState,\n arweaveL1FinalizeJobs,\n easSyncProcesses,\n htmlEmbeddedImageCoPublish,\n metadata,\n models,\n publishProcesses,\n schemas,\n seeds,\n uploadProcesses,\n modelSchemas,\n versions,\n} from '@/seedSchema'\n\nconst logger = debug('seedSdk:db:resetAmbiguousLegacyItemData')\n\n/** appState key recording that the one-time check after migration 0015 has run. */\nexport const LEGACY_ITEM_MODEL_CHECK_KEY = 'legacyItemModelCheck:v1'\n\n/**\n * One-time check after seeds.model_file_id was introduced (migration 0015). Seeds from before then\n * that couldn't be backfilled have no model; if their model name now exists in more than one schema\n * there is no way to tell which model they belong to. In that case the local item data (seeds,\n * versions, metadata and the jobs that reference them) is cleared, keeping schemas and models;\n * published items come back on the next EAS sync.\n *\n * Runs once (not on every start): EAS-synced seeds also lack model_file_id until\n * resolveModelForSyncedSeed exists, and re-checking would clear the DB after every sync.\n * TODO: replace the reset with a migration path once there is real user data at stake.\n *\n * @returns true if item data was cleared\n */\nexport const resetAmbiguousLegacyItemData = async (): Promise<boolean> => {\n const db = BaseDb.getAppDb()\n if (!db) return false\n\n const done = await db.select({ key: appState.key }).from(appState).where(eq(appState.key, LEGACY_ITEM_MODEL_CHECK_KEY)).limit(1)\n if (done.length > 0) return false\n\n const markDone = () =>\n db\n .insert(appState)\n .values({ key: LEGACY_ITEM_MODEL_CHECK_KEY, value: String(Date.now()), createdAt: Date.now(), updatedAt: Date.now() })\n .onConflictDoNothing()\n\n const legacyTypes = (await db\n .selectDistinct({ type: seeds.type })\n .from(seeds)\n .where(and(isNull(seeds.modelFileId), isNotNull(seeds.type)))) as { type: string }[]\n if (legacyTypes.length === 0) {\n await markDone()\n return false\n }\n\n // Which seed types (snake_case model names) map to models in more than one schema\n const linkedModels = (await db\n .select({ modelId: models.id, modelName: models.name, schemaName: schemas.name })\n .from(models)\n .innerJoin(modelSchemas, eq(models.id, modelSchemas.modelId))\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))) as {\n modelId: number\n modelName: string\n schemaName: string\n }[]\n const byType = new Map<string, { modelIds: Set<number>; schemaNames: Set<string> }>()\n for (const row of linkedModels) {\n const type = toSnakeCase(row.modelName)\n const entry = byType.get(type) ?? { modelIds: new Set(), schemaNames: new Set() }\n entry.modelIds.add(row.modelId)\n entry.schemaNames.add(row.schemaName)\n byType.set(type, entry)\n }\n const ambiguous = legacyTypes\n .map(({ type }) => ({ type, entry: byType.get(type) }))\n .filter(({ entry }) => entry && entry.modelIds.size > 1)\n\n if (ambiguous.length === 0) {\n await markDone()\n return false\n }\n\n const details = ambiguous\n .map(({ type, entry }) => `\"${type}\" (schemas: ${[...entry!.schemaNames].sort().join(', ')})`)\n .join('; ')\n console.warn(\n `[seed-protocol] Clearing local item data: items created before this SDK version don't record ` +\n `which model they belong to, and these model names now exist in more than one schema: ${details}. ` +\n `Schemas and models are kept; published items will be restored by the next EAS sync.`,\n )\n logger(`Clearing item data for ambiguous legacy seed types: ${details}`)\n\n for (const table of [\n htmlEmbeddedImageCoPublish,\n arweaveL1FinalizeJobs,\n uploadProcesses,\n publishProcesses,\n easSyncProcesses,\n metadata,\n versions,\n seeds,\n ]) {\n await db.delete(table)\n }\n await markDone()\n return true\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,MAAM,GAAG,KAAK,CAAC,yCAAyC,CAAC;AAE/D;AACO,MAAM,2BAA2B,GAAG;AAE3C;;;;;;;;;;;;AAYG;AACI,MAAM,4BAA4B,GAAG,YAA6B;AACvE,IAAA,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC5B,IAAA,IAAI,CAAC,EAAE;AAAE,QAAA,OAAO,KAAK;AAErB,IAAA,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAChI,IAAA,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;AAAE,QAAA,OAAO,KAAK;AAEjC,IAAA,MAAM,QAA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AAgB;QAChB,gBAAgB;QAChB,QAAQ;QACR,QAAQ;QACR,KAAK;AACN,KAAA,EAAE;AACD,QAAA,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IACxB;IACA,MAAM,QAAQ,EAAE;AAChB,IAAA,OAAO,IAAI;AACb;;"}
1
+ {"version":3,"file":"resetAmbiguousLegacyItemData-Bk0QyDW8.js","sources":["../../src/db/resetAmbiguousLegacyItemData.ts"],"sourcesContent":["import { eq, isNotNull, isNull, and } from 'drizzle-orm'\nimport { toSnakeCase } from 'drizzle-orm/casing'\nimport debug from 'debug'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport {\n appState,\n arweaveL1FinalizeJobs,\n easSyncProcesses,\n htmlEmbeddedImageCoPublish,\n metadata,\n models,\n publishProcesses,\n schemas,\n seeds,\n uploadProcesses,\n modelSchemas,\n versions,\n} from '@/seedSchema'\n\nconst logger = debug('seedSdk:db:resetAmbiguousLegacyItemData')\n\n/** appState key recording that the one-time check after migration 0015 has run. */\nexport const LEGACY_ITEM_MODEL_CHECK_KEY = 'legacyItemModelCheck:v1'\n\n/**\n * One-time check after seeds.model_file_id was introduced (migration 0015). Seeds from before then\n * that couldn't be backfilled have no model; if their model name now exists in more than one schema\n * there is no way to tell which model they belong to. In that case the local item data (seeds,\n * versions, metadata and the jobs that reference them) is cleared, keeping schemas and models;\n * published items come back on the next EAS sync.\n *\n * Runs once (not on every start): EAS-synced seeds also lack model_file_id until\n * resolveModelForSyncedSeed exists, and re-checking would clear the DB after every sync.\n * TODO: replace the reset with a migration path once there is real user data at stake.\n *\n * @returns true if item data was cleared\n */\nexport const resetAmbiguousLegacyItemData = async (): Promise<boolean> => {\n const db = BaseDb.getAppDb()\n if (!db) return false\n\n const done = await db.select({ key: appState.key }).from(appState).where(eq(appState.key, LEGACY_ITEM_MODEL_CHECK_KEY)).limit(1)\n if (done.length > 0) return false\n\n const markDone = () =>\n db\n .insert(appState)\n .values({ key: LEGACY_ITEM_MODEL_CHECK_KEY, value: String(Date.now()), createdAt: Date.now(), updatedAt: Date.now() })\n .onConflictDoNothing()\n\n const legacyTypes = (await db\n .selectDistinct({ type: seeds.type })\n .from(seeds)\n .where(and(isNull(seeds.modelFileId), isNotNull(seeds.type)))) as { type: string }[]\n if (legacyTypes.length === 0) {\n await markDone()\n return false\n }\n\n // Which seed types (snake_case model names) map to models in more than one schema\n const linkedModels = (await db\n .select({ modelId: models.id, modelName: models.name, schemaName: schemas.name })\n .from(models)\n .innerJoin(modelSchemas, eq(models.id, modelSchemas.modelId))\n .innerJoin(schemas, eq(modelSchemas.schemaId, schemas.id))) as {\n modelId: number\n modelName: string\n schemaName: string\n }[]\n const byType = new Map<string, { modelIds: Set<number>; schemaNames: Set<string> }>()\n for (const row of linkedModels) {\n const type = toSnakeCase(row.modelName)\n const entry = byType.get(type) ?? { modelIds: new Set(), schemaNames: new Set() }\n entry.modelIds.add(row.modelId)\n entry.schemaNames.add(row.schemaName)\n byType.set(type, entry)\n }\n const ambiguous = legacyTypes\n .map(({ type }) => ({ type, entry: byType.get(type) }))\n .filter(({ entry }) => entry && entry.modelIds.size > 1)\n\n if (ambiguous.length === 0) {\n await markDone()\n return false\n }\n\n const details = ambiguous\n .map(({ type, entry }) => `\"${type}\" (schemas: ${[...entry!.schemaNames].sort().join(', ')})`)\n .join('; ')\n console.warn(\n `[seed-protocol] Clearing local item data: items created before this SDK version don't record ` +\n `which model they belong to, and these model names now exist in more than one schema: ${details}. ` +\n `Schemas and models are kept; published items will be restored by the next EAS sync.`,\n )\n logger(`Clearing item data for ambiguous legacy seed types: ${details}`)\n\n for (const table of [\n htmlEmbeddedImageCoPublish,\n arweaveL1FinalizeJobs,\n uploadProcesses,\n publishProcesses,\n easSyncProcesses,\n metadata,\n versions,\n seeds,\n ]) {\n await db.delete(table)\n }\n await markDone()\n return true\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,MAAM,GAAG,KAAK,CAAC,yCAAyC,CAAC;AAE/D;AACO,MAAM,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AAA,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAA,CAAA,EAAI,IAAI,CAAA,YAAA,EAAe,CAAC,GAAG,KAAM,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;SAC5F,IAAI,CAAC,IAAI,CAAC;IACb,OAAO,CAAC,IAAI,CACV,CAAA,6FAAA,CAA+F;AAC7F,QAAA,CAAA,qFAAA,EAAwF,OAAO,CAAA,EAAA,CAAI;AACnG,QAAA,CAAA,mFAAA,CAAqF,CACxF;AACD,IAAA,MAAM,CAAC,CAAA,oDAAA,EAAuD,OAAO,CAAA,CAAE,CAAC;IAExE,KAAK,MAAM,KAAK,IAAI;QAClB,0BAA0B;QAC1B,qBAAqB;QACrB,eAAe;QACf,gBAAgB;QAChB,gBAAgB;QAChB,QAAQ;QACR,QAAQ;QACR,KAAK;AACN,KAAA,EAAE;AACD,QAAA,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IACxB;IACA,MAAM,QAAQ,EAAE;AAChB,IAAA,OAAO,IAAI;AACb;;"}
@@ -1,5 +1,5 @@
1
1
  import debug from 'debug';
2
- import { A as AmbiguousModelError, m as eventEmitter } from './db-W1g29qsM.js';
2
+ import { A as AmbiguousModelError, m as eventEmitter } from './db-D9K_f5cF.js';
3
3
 
4
4
  const logger = debug('seedSdk:db:read:resolveModelForSyncedSeed');
5
5
  /** Emitted when background work skips a seed whose model name exists in several schemas. */
@@ -43,4 +43,4 @@ const skipSeedOnAmbiguousModel = async (seed, context, work) => {
43
43
  };
44
44
 
45
45
  export { MODEL_AMBIGUOUS_EVENT as M, resolveModelForSyncedSeed as r, skipSeedOnAmbiguousModel as s };
46
- //# sourceMappingURL=resolveModelForSyncedSeed-CLlumTBq.js.map
46
+ //# sourceMappingURL=resolveModelForSyncedSeed-8cAzvUFd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveModelForSyncedSeed-CLlumTBq.js","sources":["../../src/db/read/resolveModelForSyncedSeed.ts"],"sourcesContent":["import debug from 'debug'\nimport { eventEmitter } from '@/eventBus'\nimport { AmbiguousModelError } from '@/Model/errors'\n\nconst logger = debug('seedSdk:db:read:resolveModelForSyncedSeed')\n\n/** Emitted when background work skips a seed whose model name exists in several schemas. */\nexport const MODEL_AMBIGUOUS_EVENT = 'model:ambiguous' as const\n\nexport type ModelAmbiguousEventPayload = {\n modelName: string\n schemaNames: string[]\n seedLocalId?: string\n seedUid?: string\n /** What was being done when the seed was skipped (e.g. 'easSync.metadata'). */\n context: string\n}\n\nexport type SyncedSeedInfo = {\n seedUid?: string | null\n seedLocalId?: string | null\n /** seeds.type as synced from EAS (the EAS schema name, i.e. snake_case model name). */\n modelType?: string | null\n /** EAS schema UID of the seed attestation. */\n schemaUid?: string | null\n}\n\n/**\n * Seam for matching an EAS-synced seed to a local model (its schemaFileId).\n *\n * EAS identifies a seed's model only by name (`bytes32 <model_name>`), so when several local schemas\n * define a model with that name the seed alone can't say which one it is. The plan is to match by\n * the seed's properties and metadata (see docs/EAS_SYNCED_SEED_MODEL_RESOLUTION.md).\n *\n * TODO(eas-synced-seed-model-resolution): not implemented yet. Returns undefined, so callers fall\n * back to the name, which throws AmbiguousModelError when the name is ambiguous.\n */\nexport const resolveModelForSyncedSeed = async (_seed: SyncedSeedInfo): Promise<string | undefined> => {\n return undefined\n}\n\n/**\n * Run background work for one seed; if it hits an ambiguous model name, log, emit\n * MODEL_AMBIGUOUS_EVENT and return undefined (skip) instead of failing the whole job. Loading the\n * item directly still throws, so the problem surfaces where the app touches it.\n */\nexport const skipSeedOnAmbiguousModel = async <T>(\n seed: { seedLocalId?: string | null; seedUid?: string | null },\n context: string,\n work: () => Promise<T>,\n): Promise<T | undefined> => {\n try {\n return await work()\n } catch (error) {\n if (!(error instanceof AmbiguousModelError)) throw error\n logger(`Skipping seed ${seed.seedLocalId ?? seed.seedUid} in ${context}: ${error.message}`)\n const payload: ModelAmbiguousEventPayload = {\n modelName: error.modelName,\n schemaNames: error.schemaNames,\n seedLocalId: seed.seedLocalId ?? undefined,\n seedUid: seed.seedUid ?? undefined,\n context,\n }\n eventEmitter.emit(MODEL_AMBIGUOUS_EVENT, payload)\n return undefined\n }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,MAAM,GAAG,KAAK,CAAC,2CAA2C,CAAC;AAEjE;AACO,MAAM,qBAAqB,GAAG;AAoBrC;;;;;;;;;AASG;MACU,yBAAyB,GAAG,OAAO,KAAqB,KAAiC;AACpG,IAAA,OAAO,SAAS;AAClB;AAEA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,OACtC,IAA8D,EAC9D,OAAe,EACf,IAAsB,KACI;AAC1B,IAAA,IAAI;QACF,OAAO,MAAM,IAAI,EAAE;IACrB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,EAAE,KAAK,YAAY,mBAAmB,CAAC;AAAE,YAAA,MAAM,KAAK;AACxD,QAAA,MAAM,CAAC,CAAA,cAAA,EAAiB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAA,IAAA,EAAO,OAAO,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AAC3F,QAAA,MAAM,OAAO,GAA+B;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;AAC9B,YAAA,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;AAC1C,YAAA,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;YAClC,OAAO;SACR;AACD,QAAA,YAAY,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;AACjD,QAAA,OAAO,SAAS;IAClB;AACF;;"}
1
+ {"version":3,"file":"resolveModelForSyncedSeed-8cAzvUFd.js","sources":["../../src/db/read/resolveModelForSyncedSeed.ts"],"sourcesContent":["import debug from 'debug'\nimport { eventEmitter } from '@/eventBus'\nimport { AmbiguousModelError } from '@/Model/errors'\n\nconst logger = debug('seedSdk:db:read:resolveModelForSyncedSeed')\n\n/** Emitted when background work skips a seed whose model name exists in several schemas. */\nexport const MODEL_AMBIGUOUS_EVENT = 'model:ambiguous' as const\n\nexport type ModelAmbiguousEventPayload = {\n modelName: string\n schemaNames: string[]\n seedLocalId?: string\n seedUid?: string\n /** What was being done when the seed was skipped (e.g. 'easSync.metadata'). */\n context: string\n}\n\nexport type SyncedSeedInfo = {\n seedUid?: string | null\n seedLocalId?: string | null\n /** seeds.type as synced from EAS (the EAS schema name, i.e. snake_case model name). */\n modelType?: string | null\n /** EAS schema UID of the seed attestation. */\n schemaUid?: string | null\n}\n\n/**\n * Seam for matching an EAS-synced seed to a local model (its schemaFileId).\n *\n * EAS identifies a seed's model only by name (`bytes32 <model_name>`), so when several local schemas\n * define a model with that name the seed alone can't say which one it is. The plan is to match by\n * the seed's properties and metadata (see docs/EAS_SYNCED_SEED_MODEL_RESOLUTION.md).\n *\n * TODO(eas-synced-seed-model-resolution): not implemented yet. Returns undefined, so callers fall\n * back to the name, which throws AmbiguousModelError when the name is ambiguous.\n */\nexport const resolveModelForSyncedSeed = async (_seed: SyncedSeedInfo): Promise<string | undefined> => {\n return undefined\n}\n\n/**\n * Run background work for one seed; if it hits an ambiguous model name, log, emit\n * MODEL_AMBIGUOUS_EVENT and return undefined (skip) instead of failing the whole job. Loading the\n * item directly still throws, so the problem surfaces where the app touches it.\n */\nexport const skipSeedOnAmbiguousModel = async <T>(\n seed: { seedLocalId?: string | null; seedUid?: string | null },\n context: string,\n work: () => Promise<T>,\n): Promise<T | undefined> => {\n try {\n return await work()\n } catch (error) {\n if (!(error instanceof AmbiguousModelError)) throw error\n logger(`Skipping seed ${seed.seedLocalId ?? seed.seedUid} in ${context}: ${error.message}`)\n const payload: ModelAmbiguousEventPayload = {\n modelName: error.modelName,\n schemaNames: error.schemaNames,\n seedLocalId: seed.seedLocalId ?? undefined,\n seedUid: seed.seedUid ?? undefined,\n context,\n }\n eventEmitter.emit(MODEL_AMBIGUOUS_EVENT, payload)\n return undefined\n }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,MAAM,GAAG,KAAK,CAAC,2CAA2C,CAAC;AAEjE;AACO,MAAM,qBAAqB,GAAG;AAoBrC;;;;;;;;;AASG;MACU,yBAAyB,GAAG,OAAO,KAAqB,KAAiC;AACpG,IAAA,OAAO,SAAS;AAClB;AAEA;;;;AAIG;AACI,MAAM,wBAAwB,GAAG,OACtC,IAA8D,EAC9D,OAAe,EACf,IAAsB,KACI;AAC1B,IAAA,IAAI;QACF,OAAO,MAAM,IAAI,EAAE;IACrB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,EAAE,KAAK,YAAY,mBAAmB,CAAC;AAAE,YAAA,MAAM,KAAK;AACxD,QAAA,MAAM,CAAC,CAAA,cAAA,EAAiB,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAA,IAAA,EAAO,OAAO,CAAA,EAAA,EAAK,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AAC3F,QAAA,MAAM,OAAO,GAA+B;YAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;AAC9B,YAAA,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;AAC1C,YAAA,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,SAAS;YAClC,OAAO;SACR;AACD,QAAA,YAAY,CAAC,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;AACjD,QAAA,OAAO,SAAS;IAClB;AACF;;"}
@@ -48,7 +48,7 @@ export declare class Item<T extends ModelValues<ModelSchema>> implements IItem<T
48
48
  modelInstance?: import('../Model/Model').Model;
49
49
  }, options?: CreateWaitOptions): Promise<Item<any>>;
50
50
  /**
51
- * Run each File/Image/Html initial value through its ItemProperty save pipeline (sequentially, to
51
+ * Run each File/Image/Html/ItemStorage initial value through its ItemProperty save pipeline (sequentially, to
52
52
  * avoid SQLite write contention). Rejects on the first failure; the item itself has been created.
53
53
  */
54
54
  private static savePipelineValues;
@@ -1 +1 @@
1
- {"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../src/Item/Item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAWpE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3C,OAAO,EACL,2BAA2B,EAC3B,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,QAAQ,CAAA;AAiHf,qBAAa,IAAI,CAAC,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC,CAAE,YAAW,KAAK,CAAC,CAAC,CAAC;IAEvE,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAa;IACnG,SAAS,CAAC,aAAa,EAAE,YAAY,GAAG,SAAS,CAAC;IAClD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7D,SAAS,CAAC,kBAAkB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAA2B;IACvG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAAC;gBAExD,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;IA4L1C,oG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H;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO;IA6B3E;;;OAGG;IACH,IAAI,UAAU,IAAI,aAAa,EAAE,CA6BhC;IAED;;;OAGG;IACH,IAAI,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAOtD;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAEjD;IAED,IAAI,oBAAoB,IAAI,MAAM,CAEjC;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,sBAAsB,IAAI,MAAM,CAEnC;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAWlC;IAED;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAsWnC,MAAM,IAAI,IAAI;IA6Bd;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA2B/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"saveItemStorage.d.ts","sourceRoot":"","sources":["../../../../../../src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,eAAe,8HAuJ1B,CAAA"}
1
+ {"version":3,"file":"saveItemStorage.d.ts","sourceRoot":"","sources":["../../../../../../src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAqBzB,eAAO,MAAM,eAAe,8HAkM1B,CAAA"}
@@ -5,12 +5,15 @@ export declare class BrowserFileManager implements IFileManager {
5
5
  getFsSync(): any;
6
6
  getContentUrlFromPath(path: string): Promise<string | undefined>;
7
7
  initializeFileSystem(_workingDir?: string): Promise<void>;
8
- downloadAllFiles({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions, }: DownloadAllFilesParams): Promise<void>;
8
+ downloadAllFiles(params: DownloadAllFilesParams): Promise<DownloadAllFilesResult>;
9
9
  resizeImage({ filePath, width, height }: ResizeImageParams): Promise<void>;
10
10
  resizeAllImages({ width, height }: ResizeAllImagesParams): Promise<void>;
11
11
  listImageFiles(): Promise<string[]>;
12
12
  listFiles(dir: string): Promise<string[]>;
13
+ /** Invalidations run one at a time: two refreshing the same path at once could interleave. */
14
+ private invalidations;
13
15
  invalidateCachedPaths(filePaths: string[]): Promise<void>;
16
+ private invalidateNow;
14
17
  pathExists(filePath: string): Promise<boolean>;
15
18
  getFileSize(filePath: string): Promise<number | null>;
16
19
  createDirIfNotExists(filePath: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../../../src/browser/helpers/FileManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,oCAAoC,CAAA;AAgI3C,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,UAAU,CAAY;IAExB,KAAK;IAOX,SAAS;IAOH,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IASlE,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCzD,gBAAgB,CAAE,EACS,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,GACrB,EAAE,sBAAsB,GAAI,OAAO,CAAC,I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,2BAAqB,CAAA"}
@@ -1,3 +1,5 @@
1
+ import { Inode } from '@zenfs/core';
2
+ import type { InodeLike } from '@zenfs/core';
1
3
  import { WebAccessFS } from '@zenfs/dom';
2
4
  import type { WebAccessOptions } from '@zenfs/dom';
3
5
  /**
@@ -5,20 +7,93 @@ import type { WebAccessOptions } from '@zenfs/dom';
5
7
  * entry fails the whole mount. This variant skips such entries instead. A skipped file is still
6
8
  * listed by readdir, and WebAccessFS.stat() indexes it lazily on first use, once it is readable.
7
9
  *
10
+ * It also makes overwrites with shorter content shrink the file (see `write` and `touch`), without
11
+ * cutting off bytes another context (a tab, a worker writing through a SyncAccessHandle) added to a
12
+ * file this mount had indexed at a smaller size: OPFS only shrinks for a truncate made through this
13
+ * mount, and stat() re-reads a file's size when OPFS changed since this mount last looked.
14
+ *
8
15
  * Overrides @zenfs/dom 1.2.9 / @zenfs/core 2.5.6 internals (`_loadHandles`, `_loadMetadata`,
9
- * `crossCopy`, `_handles`, `_sync`, `index`); both packages are pinned to exact versions, and
10
- * tolerantWebAccess.test.ts covers the coupling.
16
+ * `crossCopy`, `stat`, `write`, `touch`, `remove`, `get`, `_handles`, `_sync`, `_isInitialized`,
17
+ * `index`, and `vfs.Handle#truncate`/`truncateSync`, see `trackTruncates`); both packages are pinned
18
+ * to exact versions, and tolerantWebAccess.test.ts / opfsOverwrite.test.ts cover the coupling.
11
19
  */
12
20
  export declare class TolerantWebAccessFS extends WebAccessFS {
21
+ /**
22
+ * Truncates made through this mount that OPFS doesn't have yet, by path. ZenFS truncates by
23
+ * lowering the inode's size and syncing it later, so only these may shrink the OPFS file: an
24
+ * inode that is merely smaller than the file is a stale view of a file someone else grew.
25
+ */
26
+ private readonly _truncates;
27
+ /** Each OPFS file as this mount last saw it, to notice writes made elsewhere. */
28
+ private readonly _seen;
29
+ /**
30
+ * Called with each file path whose OPFS contents this mount changed (a write, a truncate, a
31
+ * removal; a rename is both), once the change is in OPFS. BrowserFileManager uses it to tell other
32
+ * tabs. Not called for what invalidate(), stat() or crossCopy() put in the in-memory copy: those
33
+ * only read OPFS.
34
+ */
35
+ onOpfsChange?: (path: string) => void;
36
+ constructor(root: FileSystemDirectoryHandle, disableHandleCache?: boolean);
37
+ /**
38
+ * Called by vfs.Handle#truncate(Sync) for files on this mount (see `trackTruncates`). Returns an
39
+ * undo for a truncate the handle then rejects.
40
+ */
41
+ _noteTruncate(path: string, length: number): () => void;
42
+ /**
43
+ * The sync API's in-memory copy (a StoreFS) truncates by setting the size alone and keeps the old
44
+ * bytes, which a later write past that size then exposes in place of zeros. Cut them off there
45
+ * too. Called by vfs.Handle#truncate(Sync) once the truncate went through.
46
+ */
47
+ _truncateCache(path: string, length: number): void;
48
+ private _takeTruncate;
49
+ private _changed;
50
+ private _remember;
51
+ /** Another context changed the file: the next stat() refreshes the sync API's in-memory copy. */
52
+ private _markChangedElsewhere;
53
+ /**
54
+ * The index holds each file's size from when this mount last looked, and another context may
55
+ * have written the file since. Re-read it from OPFS, so opening a file (an append goes to its
56
+ * size) and reading it see the true file, and refresh the in-memory copy behind the sync API when
57
+ * the file changed. Costs one getFile() per stat of a regular file; contents are only read when
58
+ * the file changed.
59
+ */
60
+ stat(path: string): Promise<Inode>;
61
+ /** Replaces the sync API's in-memory copy of `path` with `file`, if it holds one. */
62
+ private _recache;
63
+ /**
64
+ * WebAccessFS.write opens the file with `keepExistingData` and never truncates, so a whole-file
65
+ * overwrite with shorter content (open 'w', then a write at 0) kept the old tail on disk. Here a
66
+ * truncate this mount made since the file was last written (open 'w', ftruncate) is applied in
67
+ * the same writable as the data: the file is cut to that length first (a write past it leaves
68
+ * zeros in the gap, as POSIX does). Without one, the data goes over the file OPFS has, whatever
69
+ * size this mount last saw: appends and writes at an offset never cut off bytes another context
70
+ * wrote.
71
+ */
72
+ write(path: string, buffer: Uint8Array, offset: number): Promise<void>;
73
+ /**
74
+ * ZenFS truncates by setting the inode's size and syncing it with touch() (FileHandle.truncate
75
+ * with no write after it). Make OPFS follow when this mount truncated the file. Any other touch
76
+ * (chmod, utimes, the size after writes) leaves the OPFS file alone: a smaller size there is a
77
+ * stale view, and the index takes the file's real size back.
78
+ */
79
+ touch(path: string, metadata: InodeLike): Promise<void>;
80
+ remove(path: string): Promise<void>;
13
81
  _loadHandles(path: string, handle: FileSystemDirectoryHandle): Promise<void>;
14
82
  _loadMetadata(metadataPath?: string): Promise<void>;
15
83
  /**
16
84
  * Forgets what the mount cached for `path` (size, handle, contents) and reads it again from OPFS.
17
85
  * For files written outside this ZenFS instance: by another tab, or by a worker writing to OPFS
18
- * directly. A file that's gone stays forgotten. The in-memory copy is only refreshed when its
19
- * directory is already cached; async reads re-index the file either way (WebAccessFS.stat).
86
+ * directly. Only reads OPFS (never writes it, so never calls onOpfsChange).
87
+ *
88
+ * An entry that's gone (removed elsewhere) is forgotten along with anything cached under it, and
89
+ * costs one failed lookup. A file in directories this mount hasn't cached yet (created elsewhere
90
+ * after it mounted) gets them added to the in-memory copy, so the sync API finds it.
20
91
  */
21
92
  invalidate(path: string): Promise<void>;
93
+ /** Drops `path` and everything under it from the index, handles and in-memory copy. */
94
+ private _forgetCached;
95
+ /** Adds the directories above `path` that the in-memory copy lacks, so crossCopy can fill it. */
96
+ private _cacheParents;
22
97
  /**
23
98
  * The Async mixin's ready() then copies every file's contents into an in-memory cache, a second
24
99
  * walk that reads the same busy entries. Skip those too; the root still fails the mount.
@@ -1 +1 @@
1
- {"version":3,"file":"tolerantWebAccess.d.ts","sourceRoot":"","sources":["../../../../src/browser/helpers/tolerantWebAccess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,WAAW,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAMlD;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAC5C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5E,aAAa,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CAAC,SAAS;IAIjB,iGAAiG;IACjG,OAAO,CAAC,qBAAqB;IAI7B;;;;;;OAMG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IA0BxC,qFAAqF;YACvE,QAAQ;IA0BtB;;;;;;;;OAQG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+C5E;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAyCvD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5E,aAAa,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBzD;;;;;;;;OAQG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7C,uFAAuF;IACvF,OAAO,CAAC,aAAa;IA4BrB,iGAAiG;YACnF,aAAa;IAsB3B;;;OAGG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB7C;AAmED,yEAAyE;AACzE,eAAO,MAAM,iBAAiB;;oBAGN,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;CAK9D,CAAA"}
@@ -1,8 +1,23 @@
1
+ /**
2
+ * Longest the worker may go without posting anything before the download is failed. The worker
3
+ * posts after every transaction and each gateway request times out after 60s, so this only fires
4
+ * when the worker died without an error event (e.g. killed for memory) or is wedged.
5
+ */
6
+ export declare const FILE_DOWNLOAD_INACTIVITY_TIMEOUT_MS: number;
7
+ export declare class FileDownloadWorkerError extends Error {
8
+ constructor(message: string, options?: {
9
+ cause?: unknown;
10
+ });
11
+ }
1
12
  export declare class FileDownloader {
13
+ private readonly options;
2
14
  private cores;
3
- private workersArchive;
4
- private workerBlobUrl;
5
- constructor();
6
- downloadAll: ({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions }: DownloadAllFilesParams) => Promise<void>;
15
+ private worker;
16
+ /** Settles the in-flight download, if any; used when a newer `downloadAll` supersedes it. */
17
+ private abortCurrent;
18
+ constructor(options?: {
19
+ inactivityTimeoutMs?: number;
20
+ });
21
+ downloadAll: ({ transactionIds, arweaveHost, arweaveBaseUrls, excludedTransactions, expectedContentHashes, compositeChildPaths, }: DownloadAllFilesParams) => Promise<DownloadAllFilesResult>;
7
22
  }
8
23
  //# sourceMappingURL=FileDownloader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileDownloader.d.ts","sourceRoot":"","sources":["../../../../src/browser/workers/FileDownloader.ts"],"names":[],"mappings":"AAQA,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,aAAa,CAAQ;;IAUtB,WAAW,GAAU,wEAAsE,sBAAsB,KAAG,OAAO,CAAC,IAAI,CAAC,CAqDvI;CACF"}
1
+ {"version":3,"file":"FileDownloader.d.ts","sourceRoot":"","sources":["../../../../src/browser/workers/FileDownloader.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,QAAa,CAAA;AAE7D,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAK3D;AAaD,qBAAa,cAAc;IAMb,OAAO,CAAC,QAAQ,CAAC,OAAO;IALpC,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAoB;IAClC,6FAA6F;IAC7F,OAAO,CAAC,YAAY,CAAsC;gBAE7B,OAAO,GAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;KAAO;IAIpE,WAAW,GAAU,qHAOzB,sBAAsB,KAAG,OAAO,CAAC,sBAAsB,CAAC,CAyK1D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"filesDownload.d.ts","sourceRoot":"","sources":["../../../../src/browser/workers/filesDownload.ts"],"names":[],"mappings":";AAAA,wBAmYI"}
1
+ {"version":3,"file":"filesDownload.d.ts","sourceRoot":"","sources":["../../../../src/browser/workers/filesDownload.ts"],"names":[],"mappings":";AASA,wBAsoBI"}
@@ -1 +1 @@
1
- {"version":3,"file":"clientManagerMachine.d.ts","sourceRoot":"","sources":["../../../src/client/clientManagerMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAStE,OAAO,EAAuB,kBAAkB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AA+GxF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgBkC,MAAM;;;;;;;;;;;;;;;;+BA8MvE,CAAA"}
1
+ {"version":3,"file":"clientManagerMachine.d.ts","sourceRoot":"","sources":["../../../src/client/clientManagerMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAStE,OAAO,EAAuB,kBAAkB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAgHxF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgBkC,MAAM;;;;;;;;;;;;;;;;+BAoNvE,CAAA"}
@@ -0,0 +1,57 @@
1
+ /** appState key recording that legacy ItemStorage rows have been written to their files. */
2
+ export declare const LEGACY_ITEM_STORAGE_MIGRATION_KEY = "legacyItemStorageFiles:v1";
3
+ /** Runs in a row that left rows unconverted because a file write failed, before giving up. */
4
+ export declare const LEGACY_ITEM_STORAGE_MIGRATION_MAX_ATTEMPTS = 3;
5
+ export type LegacyItemStorageMigrationMarker = {
6
+ status: 'done' | 'retry';
7
+ attempts: number;
8
+ converted: number;
9
+ failed: number;
10
+ at: number;
11
+ };
12
+ export type LegacyItemStorageMigrationResult = {
13
+ /** True when the marker said the migration had already run (nothing was checked). */
14
+ alreadyDone: boolean;
15
+ /** Legacy rows found (local drafts of ItemStorage properties holding their content verbatim). */
16
+ candidates: number;
17
+ converted: number;
18
+ /** Rows left as they were because writing the file or updating the row failed. */
19
+ failed: number;
20
+ /** Rows not converted on purpose: an older row of their property, or one that changed meanwhile. */
21
+ skipped: number;
22
+ };
23
+ /**
24
+ * One-time data migration: writes the content of legacy ItemStorage draft rows to their files.
25
+ *
26
+ * Before Item.create / createNewItem saved ItemStorage values through the save pipeline, a value
27
+ * given at creation was stored verbatim in metadata.property_value with no file. Publish converts
28
+ * such a row lazily (resolveItemStorageChildFile); this converts them all up front, with the same
29
+ * code ({@link convertVerbatimItemStorageRow}), so every ItemStorage draft has the shape a save
30
+ * gives it: the content in `<seedUid or seedLocalId><extension>`, the row holding
31
+ * refResolvedValue / localStorageDir / refValueType 'file' and no property_value.
32
+ *
33
+ * Only local drafts (no uid, not derived from an attestation) of properties whose properties row
34
+ * says `storage_type = 'ItemStorage'` are touched, and of those only the newest row of each
35
+ * seed's property: that is the row reads show and saves write to, and older rows sharing the one
36
+ * file name would overwrite it with older content. Published and synced rows are never changed.
37
+ *
38
+ * A row that fails is logged and left as it was (publish still converts it). The run is recorded
39
+ * in appState under {@link LEGACY_ITEM_STORAGE_MIGRATION_KEY}; a run with failed rows is retried
40
+ * on the next start, up to {@link LEGACY_ITEM_STORAGE_MIGRATION_MAX_ATTEMPTS} runs. Safe to run
41
+ * again regardless: a converted row no longer matches.
42
+ *
43
+ * @param options.force run even when the marker says it is done
44
+ */
45
+ export declare function migrateLegacyItemStorageRows(options?: {
46
+ force?: boolean;
47
+ }): Promise<LegacyItemStorageMigrationResult>;
48
+ /**
49
+ * Starts {@link migrateLegacyItemStorageRows} in the background once client init has finished
50
+ * (the properties table then holds the current storage settings). It runs in the leader tab only
51
+ * (docs/MULTI_TAB.md), under a `seed:item-storage-migration:<db>` lock in case several tabs lead
52
+ * (`multiTab: 'off'`); a tab that isn't leader runs it if it takes over. Never throws.
53
+ */
54
+ export declare function startLegacyItemStorageMigration(): void;
55
+ /** Resolves when a background run started by {@link startLegacyItemStorageMigration} has finished (at once if none is running). */
56
+ export declare function whenLegacyItemStorageMigrationSettled(): Promise<void>;
57
+ //# sourceMappingURL=migrateLegacyItemStorageRows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateLegacyItemStorageRows.d.ts","sourceRoot":"","sources":["../../../src/db/migrateLegacyItemStorageRows.ts"],"names":[],"mappings":"AAcA,4FAA4F;AAC5F,eAAO,MAAM,iCAAiC,8BAA8B,CAAA;AAE5E,8FAA8F;AAC9F,eAAO,MAAM,0CAA0C,IAAI,CAAA;AAE3D,MAAM,MAAM,gCAAgC,GAAG;IAC7C,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,qFAAqF;IACrF,WAAW,EAAE,OAAO,CAAA;IACpB,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAA;IACd,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAuFD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,OAAO,CAAC,gCAAgC,CAAC,CAoF3C;AAkBD;;;;;GAKG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAWtD;AAED,mIAAmI;AACnI,wBAAgB,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC,CAErE"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Where the download worker saves each child of a composite upload, by transaction id then child
3
+ * (property) name: a path relative to the files root.
4
+ *
5
+ * The paths come from the ItemStorage rows sync derives from a `storage_transaction_id`
6
+ * attestation (see `createMetadataRecordsForStorageTransactionId`): property value = the
7
+ * transaction id, `refResolvedValue` = `<txId><extension>`, `localStorageDir` = the model's storage
8
+ * directory. Those rows are what hydration reads, so a child saved here is found as that property's
9
+ * file. Transactions with no such rows are left out; the worker then falls back to the legacy
10
+ * html / json layout.
11
+ */
12
+ export declare const getCompositeChildPaths: (transactionIds: string[]) => Promise<Record<string, Record<string, string>>>;
13
+ //# sourceMappingURL=getCompositeChildPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCompositeChildPaths.d.ts","sourceRoot":"","sources":["../../../../src/db/read/getCompositeChildPaths.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,gBAAgB,MAAM,EAAE,KACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkChD,CAAA"}