@tearleads/client-sdk 0.1.60 → 0.1.62

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 (299) hide show
  1. package/Tearleads.d.ts +8 -48
  2. package/Tearleads.js +18 -25
  3. package/Tearleads.js.map +1 -1
  4. package/TearleadsOptions.d.ts +49 -0
  5. package/TearleadsOptions.js +2 -0
  6. package/TearleadsOptions.js.map +1 -0
  7. package/client/containerContents/documentDiscovery.js +5 -5
  8. package/client/containerContents/documentDiscovery.js.map +1 -1
  9. package/client/containerContents/index.d.ts +7 -7
  10. package/client/containerContents/index.js +7 -7
  11. package/client/containerContents/index.js.map +1 -1
  12. package/client/containerContents/types.d.ts +6 -6
  13. package/client/containerContents/types.js.map +1 -1
  14. package/client/deviceFirst/index.js +2 -2
  15. package/client/deviceFirst/index.js.map +1 -1
  16. package/client/root/index.d.ts +1 -1
  17. package/client/root/index.js.map +1 -1
  18. package/client/runtime/workflowRuntime.d.ts +1 -1
  19. package/client/runtime/workflowRuntime.js.map +1 -1
  20. package/index.d.ts +2 -1
  21. package/index.js +1 -1
  22. package/index.js.map +1 -1
  23. package/package.json +1 -1
  24. package/stores/container-contents/containerStatePersistence.js +1 -1
  25. package/stores/container-contents/documentRecovery.js +2 -2
  26. package/stores/container-contents/documentRecovery.js.map +1 -1
  27. package/stores/container-contents/documentWork.js.map +1 -1
  28. package/stores/container-contents/localRefresh.js +2 -2
  29. package/stores/container-contents/localRefresh.js.map +1 -1
  30. package/stores/container-contents/operations.js +2 -2
  31. package/stores/container-contents/operations.js.map +1 -1
  32. package/stores/container-contents/remoteContainerIngestion.js +1 -1
  33. package/stores/container-contents/remoteEventSync.js +1 -1
  34. package/stores/container-contents/remoteHydrationRequest.js +1 -1
  35. package/stores/container-contents/setContainerIconOperation.js +2 -2
  36. package/stores/container-contents/setContainerIconOperation.js.map +1 -1
  37. package/stores/container-contents/shareOperations.js +1 -1
  38. package/stores/container-contents/startupHydration.js +1 -1
  39. package/stores/container-contents/syncAgent.d.ts +2 -2
  40. package/stores/container-contents/syncAgentTypes.d.ts +1 -1
  41. package/stores/container-contents/syncLaneIteration.js +2 -2
  42. package/stores/container-contents/syncLaneIteration.js.map +1 -1
  43. package/stores/container-contents/systemContainerIcon.js +1 -1
  44. package/stores/container-contents/systemContainerIcon.js.map +1 -1
  45. package/workflows/container-contents/{documentAttributionRanges.d.ts → attribution/documentAttributionRanges.d.ts} +1 -1
  46. package/workflows/container-contents/{documentCharacterBlame.js → attribution/documentCharacterBlame.js} +3 -3
  47. package/workflows/container-contents/attribution/documentCharacterBlame.js.map +1 -0
  48. package/workflows/container-contents/{documentFieldBlame.js → attribution/documentFieldBlame.js} +4 -4
  49. package/workflows/container-contents/attribution/documentFieldBlame.js.map +1 -0
  50. package/workflows/container-contents/container-state/createIntentSync.js +1 -1
  51. package/workflows/container-contents/container-state/createIntentSync.js.map +1 -1
  52. package/workflows/container-contents/container-state/moveIntentSync.js +1 -1
  53. package/workflows/container-contents/container-state/moveIntentSync.js.map +1 -1
  54. package/workflows/container-contents/container-state/purgeTree.js +2 -2
  55. package/workflows/container-contents/container-state/purgeTree.js.map +1 -1
  56. package/workflows/container-contents/container-state/sharePersistence.js +2 -2
  57. package/workflows/container-contents/container-state/sharePersistence.js.map +1 -1
  58. package/workflows/container-contents/{containerDocumentListing.js → documentDiscovery/containerDocumentListing.js} +1 -1
  59. package/workflows/container-contents/{documentDiscoveryApply.js → documentDiscovery/documentDiscoveryApply.js} +3 -3
  60. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -0
  61. package/workflows/container-contents/{documentDiscoveryCandidates.js.map → documentDiscovery/documentDiscoveryCandidates.js.map} +1 -1
  62. package/workflows/container-contents/{documentDiscoveryEvidence.js → documentDiscovery/documentDiscoveryEvidence.js} +1 -1
  63. package/workflows/container-contents/documentDiscovery/documentDiscoveryEvidence.js.map +1 -0
  64. package/workflows/container-contents/{documentDiscoveryInputs.js → documentDiscovery/documentDiscoveryInputs.js} +2 -2
  65. package/workflows/container-contents/documentDiscovery/documentDiscoveryInputs.js.map +1 -0
  66. package/workflows/container-contents/documentDiscovery/documentDiscoveryLanes.js.map +1 -0
  67. package/workflows/container-contents/{documentDiscoveryTypes.d.ts → documentDiscovery/documentDiscoveryTypes.d.ts} +4 -4
  68. package/workflows/container-contents/documentDiscovery/documentDiscoveryTypes.js.map +1 -0
  69. package/workflows/container-contents/{documentDiscovery.d.ts → documentDiscovery/index.d.ts} +1 -1
  70. package/workflows/container-contents/{documentDiscovery.js → documentDiscovery/index.js} +5 -5
  71. package/workflows/container-contents/documentDiscovery/index.js.map +1 -0
  72. package/workflows/container-contents/{availableDocumentLinkIntent.js → documentLinks/availableDocumentLinkIntent.js} +1 -1
  73. package/workflows/container-contents/documentLinks/availableDocumentLinkIntent.js.map +1 -0
  74. package/workflows/container-contents/{deferredDocumentLinks.js → documentLinks/deferredDocumentLinks.js} +1 -1
  75. package/workflows/container-contents/documentLinks/deferredDocumentLinks.js.map +1 -0
  76. package/workflows/container-contents/{documentLinkIntent.js → documentLinks/documentLinkIntent.js} +4 -4
  77. package/workflows/container-contents/documentLinks/documentLinkIntent.js.map +1 -0
  78. package/workflows/container-contents/documentLinks/documentLocalRelink.js.map +1 -0
  79. package/workflows/container-contents/{documentLinks.d.ts → documentLinks/index.d.ts} +5 -5
  80. package/workflows/container-contents/{documentLinks.js → documentLinks/index.js} +10 -10
  81. package/workflows/container-contents/documentLinks/index.js.map +1 -0
  82. package/workflows/container-contents/documentMove/documentMoveDeniedReplay.js.map +1 -0
  83. package/workflows/container-contents/{documentMoveFailure.js → documentMove/documentMoveFailure.js} +1 -1
  84. package/workflows/container-contents/documentMove/documentMoveFailure.js.map +1 -0
  85. package/workflows/container-contents/{documentMoveIntent.js → documentMove/documentMoveIntent.js} +7 -7
  86. package/workflows/container-contents/documentMove/documentMoveIntent.js.map +1 -0
  87. package/workflows/container-contents/{documentMoveIntentErrors.js → documentMove/documentMoveIntentErrors.js} +1 -1
  88. package/workflows/container-contents/documentMove/documentMoveIntentErrors.js.map +1 -0
  89. package/workflows/container-contents/{documentMoveIntentSettlement.js → documentMove/documentMoveIntentSettlement.js} +4 -4
  90. package/workflows/container-contents/documentMove/documentMoveIntentSettlement.js.map +1 -0
  91. package/workflows/container-contents/{documentMoveIntentSync.js → documentMove/documentMoveIntentSync.js} +7 -7
  92. package/workflows/container-contents/documentMove/documentMoveIntentSync.js.map +1 -0
  93. package/workflows/container-contents/{documentMoveVanishedRefresh.js → documentMove/documentMoveVanishedRefresh.js} +3 -3
  94. package/workflows/container-contents/documentMove/documentMoveVanishedRefresh.js.map +1 -0
  95. package/workflows/container-contents/{documentHydrationProbe.js → documentPriming/documentHydrationProbe.js} +4 -4
  96. package/workflows/container-contents/documentPriming/documentHydrationProbe.js.map +1 -0
  97. package/workflows/container-contents/documentPriming/documentRuntimeTargetSync.js.map +1 -0
  98. package/workflows/container-contents/{documentPriming.js → documentPriming/index.js} +5 -5
  99. package/workflows/container-contents/documentPriming/index.js.map +1 -0
  100. package/workflows/container-contents/{documentStructure.d.ts → documentQueries/documentStructure.d.ts} +1 -1
  101. package/workflows/container-contents/{documentStructure.js → documentQueries/documentStructure.js} +4 -4
  102. package/workflows/container-contents/documentQueries/documentStructure.js.map +1 -0
  103. package/workflows/container-contents/{documentStructureTypes.d.ts → documentQueries/documentStructureTypes.d.ts} +4 -4
  104. package/workflows/container-contents/documentQueries/documentStructureTypes.js.map +1 -0
  105. package/workflows/container-contents/{documentSubtreeQueries.js → documentQueries/documentSubtreeQueries.js} +5 -5
  106. package/workflows/container-contents/documentQueries/documentSubtreeQueries.js.map +1 -0
  107. package/workflows/container-contents/{documentQueries.d.ts → documentQueries/index.d.ts} +8 -8
  108. package/workflows/container-contents/{documentQueries.js → documentQueries/index.js} +13 -13
  109. package/workflows/container-contents/documentQueries/index.js.map +1 -0
  110. package/workflows/container-contents/{orphanedDocumentSql.js → documentQueries/orphanedDocumentSql.js} +1 -1
  111. package/workflows/container-contents/documentQueries/orphanedDocumentSql.js.map +1 -0
  112. package/workflows/container-contents/{pendingDownloads.d.ts → documentQueries/pendingDownloads.d.ts} +1 -1
  113. package/workflows/container-contents/{pendingDownloads.js → documentQueries/pendingDownloads.js} +3 -3
  114. package/workflows/container-contents/documentQueries/pendingDownloads.js.map +1 -0
  115. package/workflows/container-contents/documentQueries/sql.js +1 -1
  116. package/workflows/container-contents/documentQueries/sql.js.map +1 -1
  117. package/workflows/container-contents/index.d.ts +13 -13
  118. package/workflows/container-contents/index.js +11 -11
  119. package/workflows/container-contents/index.js.map +1 -1
  120. package/workflows/container-contents/{blobInfo.d.ts → info/blobInfo.d.ts} +1 -1
  121. package/workflows/container-contents/{blobInfo.js → info/blobInfo.js} +4 -4
  122. package/workflows/container-contents/info/blobInfo.js.map +1 -0
  123. package/workflows/container-contents/{blobInfoTypes.d.ts → info/blobInfoTypes.d.ts} +1 -1
  124. package/workflows/container-contents/info/blobInfoTypes.js.map +1 -0
  125. package/workflows/container-contents/{containerInfo.d.ts → info/containerInfo.d.ts} +4 -4
  126. package/workflows/container-contents/{containerInfo.js → info/containerInfo.js} +5 -5
  127. package/workflows/container-contents/info/containerInfo.js.map +1 -0
  128. package/workflows/container-contents/{documentInfo.d.ts → info/documentInfo.d.ts} +3 -3
  129. package/workflows/container-contents/{documentInfo.js → info/documentInfo.js} +11 -11
  130. package/workflows/container-contents/info/documentInfo.js.map +1 -0
  131. package/workflows/container-contents/{documentInfoTypes.d.ts → info/documentInfoTypes.d.ts} +3 -3
  132. package/workflows/container-contents/info/documentInfoTypes.js.map +1 -0
  133. package/workflows/container-contents/{metadata.d.ts → metadata/index.d.ts} +2 -2
  134. package/workflows/container-contents/{metadata.js → metadata/index.js} +5 -5
  135. package/workflows/container-contents/metadata/index.js.map +1 -0
  136. package/workflows/container-contents/{metadataEvents.d.ts → metadata/metadataEvents.d.ts} +1 -1
  137. package/workflows/container-contents/{metadataEvents.js → metadata/metadataEvents.js} +1 -1
  138. package/workflows/container-contents/metadata/metadataEvents.js.map +1 -0
  139. package/workflows/container-contents/{metadataIncomingUpdateIsolation.js → metadata/metadataIncomingUpdateIsolation.js} +5 -5
  140. package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js.map +1 -0
  141. package/workflows/container-contents/{metadataMutationPreparation.d.ts → metadata/metadataMutationPreparation.d.ts} +7 -7
  142. package/workflows/container-contents/{metadataMutationPreparation.js → metadata/metadataMutationPreparation.js} +5 -5
  143. package/workflows/container-contents/metadata/metadataMutationPreparation.js.map +1 -0
  144. package/workflows/container-contents/{metadataPersistence.d.ts → metadata/metadataPersistence.d.ts} +2 -2
  145. package/workflows/container-contents/{metadataPersistence.js → metadata/metadataPersistence.js} +4 -4
  146. package/workflows/container-contents/metadata/metadataPersistence.js.map +1 -0
  147. package/workflows/container-contents/{metadataPullContinuationInvalidation.js → metadata/metadataPullContinuationInvalidation.js} +4 -4
  148. package/workflows/container-contents/metadata/metadataPullContinuationInvalidation.js.map +1 -0
  149. package/workflows/container-contents/{metadataReadState.d.ts → metadata/metadataReadState.d.ts} +1 -1
  150. package/workflows/container-contents/metadata/metadataReadState.js.map +1 -0
  151. package/workflows/container-contents/{metadataRecord.js → metadata/metadataRecord.js} +2 -2
  152. package/workflows/container-contents/metadata/metadataRecord.js.map +1 -0
  153. package/workflows/container-contents/{metadataRemoteSync.d.ts → metadata/metadataRemoteSync.d.ts} +5 -5
  154. package/workflows/container-contents/{metadataRemoteSync.js → metadata/metadataRemoteSync.js} +3 -3
  155. package/workflows/container-contents/metadata/metadataRemoteSync.js.map +1 -0
  156. package/workflows/container-contents/{metadataStateInstallation.d.ts → metadata/metadataStateInstallation.d.ts} +1 -1
  157. package/workflows/container-contents/metadata/metadataStateInstallation.js.map +1 -0
  158. package/workflows/container-contents/{metadataStateIsolation.js → metadata/metadataStateIsolation.js} +3 -3
  159. package/workflows/container-contents/metadata/metadataStateIsolation.js.map +1 -0
  160. package/workflows/container-contents/{metadataSyncErrors.js → metadata/metadataSyncErrors.js} +3 -3
  161. package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -0
  162. package/workflows/container-contents/{metadataSyncSettlement.d.ts → metadata/metadataSyncSettlement.d.ts} +2 -2
  163. package/workflows/container-contents/{metadataSyncSettlement.js → metadata/metadataSyncSettlement.js} +3 -3
  164. package/workflows/container-contents/metadata/metadataSyncSettlement.js.map +1 -0
  165. package/workflows/container-contents/{metadataTypes.d.ts → metadata/metadataTypes.d.ts} +5 -5
  166. package/workflows/container-contents/metadata/metadataTypes.js.map +1 -0
  167. package/workflows/container-contents/pendingWrites/aggregation.js.map +1 -1
  168. package/workflows/container-contents/pendingWrites/deferredTails.js.map +1 -1
  169. package/workflows/container-contents/{pendingWrites.d.ts → pendingWrites/index.d.ts} +1 -1
  170. package/workflows/container-contents/{pendingWrites.js → pendingWrites/index.js} +12 -12
  171. package/workflows/container-contents/pendingWrites/index.js.map +1 -0
  172. package/workflows/container-contents/projectionGeneration.js.map +1 -1
  173. package/workflows/container-contents/projectionKeys.d.ts +1 -1
  174. package/workflows/container-contents/projectionKeys.js.map +1 -1
  175. package/workflows/container-contents/projectionView.js +1 -1
  176. package/workflows/container-contents/projectionView.js.map +1 -1
  177. package/workflows/container-contents/{folderRecovery.d.ts → recovery/folderRecovery.d.ts} +1 -1
  178. package/workflows/container-contents/{folderRecovery.js → recovery/folderRecovery.js} +4 -4
  179. package/workflows/container-contents/recovery/folderRecovery.js.map +1 -0
  180. package/workflows/container-contents/{staleRootRecovery.js → recovery/staleRootRecovery.js} +1 -1
  181. package/workflows/container-contents/recovery/staleRootRecovery.js.map +1 -0
  182. package/workflows/container-contents/remoteHydration/completeHydration.js +1 -1
  183. package/workflows/container-contents/remoteHydration/completeHydration.js.map +1 -1
  184. package/workflows/container-contents/remoteHydration/heldContainerRebind.js +1 -1
  185. package/workflows/container-contents/remoteHydration/heldContainerRebind.js.map +1 -1
  186. package/workflows/container-contents/{remoteHydration.d.ts → remoteHydration/index.d.ts} +2 -2
  187. package/workflows/container-contents/{remoteHydration.js → remoteHydration/index.js} +6 -6
  188. package/workflows/container-contents/remoteHydration/index.js.map +1 -0
  189. package/workflows/container-contents/{remoteContainerPageHydration.js → remoteHydration/remoteContainerPageHydration.js} +8 -8
  190. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +1 -0
  191. package/workflows/container-contents/{remoteContainerState.js → remoteHydration/remoteContainerState.js} +11 -11
  192. package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +1 -0
  193. package/workflows/container-contents/remoteHydration/types.d.ts +1 -1
  194. package/workflows/container-contents/runtime.d.ts +1 -1
  195. package/workflows/container-contents/runtime.js.map +1 -1
  196. package/workflows/container-contents/{documentPurge.d.ts → tombstones/documentPurge.d.ts} +6 -6
  197. package/workflows/container-contents/{documentPurge.js → tombstones/documentPurge.js} +6 -6
  198. package/workflows/container-contents/tombstones/documentPurge.js.map +1 -0
  199. package/workflows/container-contents/{documentTombstoneEvidence.js → tombstones/documentTombstoneEvidence.js} +9 -9
  200. package/workflows/container-contents/tombstones/documentTombstoneEvidence.js.map +1 -0
  201. package/workflows/container-contents/{documentTombstoneGate.js → tombstones/documentTombstoneGate.js} +1 -1
  202. package/workflows/container-contents/tombstones/documentTombstoneGate.js.map +1 -0
  203. package/workflows/documents/projectionKeys.d.ts +1 -1
  204. package/workflows/documents/projectionKeys.js.map +1 -1
  205. package/workflows/documents/reportDocumentSyncQuarantine.js.map +1 -1
  206. package/workflows/documents/runtime.d.ts +1 -1
  207. package/workflows/documents/runtime.js.map +1 -1
  208. package/workflows/{runtimeInput.d.ts → shared/runtimeInput.d.ts} +6 -6
  209. package/workflows/shared/runtimeInput.js.map +1 -0
  210. package/workflows/container-contents/availableDocumentLinkIntent.js.map +0 -1
  211. package/workflows/container-contents/blobInfo.js.map +0 -1
  212. package/workflows/container-contents/blobInfoTypes.js.map +0 -1
  213. package/workflows/container-contents/containerInfo.js.map +0 -1
  214. package/workflows/container-contents/deferredDocumentLinks.js.map +0 -1
  215. package/workflows/container-contents/documentCharacterBlame.js.map +0 -1
  216. package/workflows/container-contents/documentDiscovery.js.map +0 -1
  217. package/workflows/container-contents/documentDiscoveryApply.js.map +0 -1
  218. package/workflows/container-contents/documentDiscoveryEvidence.js.map +0 -1
  219. package/workflows/container-contents/documentDiscoveryInputs.js.map +0 -1
  220. package/workflows/container-contents/documentDiscoveryLanes.js.map +0 -1
  221. package/workflows/container-contents/documentDiscoveryTypes.js.map +0 -1
  222. package/workflows/container-contents/documentFieldBlame.js.map +0 -1
  223. package/workflows/container-contents/documentHydrationProbe.js.map +0 -1
  224. package/workflows/container-contents/documentInfo.js.map +0 -1
  225. package/workflows/container-contents/documentInfoTypes.js.map +0 -1
  226. package/workflows/container-contents/documentLinkIntent.js.map +0 -1
  227. package/workflows/container-contents/documentLinks.js.map +0 -1
  228. package/workflows/container-contents/documentLocalRelink.js.map +0 -1
  229. package/workflows/container-contents/documentMoveDeniedReplay.js.map +0 -1
  230. package/workflows/container-contents/documentMoveFailure.js.map +0 -1
  231. package/workflows/container-contents/documentMoveIntent.js.map +0 -1
  232. package/workflows/container-contents/documentMoveIntentErrors.js.map +0 -1
  233. package/workflows/container-contents/documentMoveIntentSettlement.js.map +0 -1
  234. package/workflows/container-contents/documentMoveIntentSync.js.map +0 -1
  235. package/workflows/container-contents/documentMoveVanishedRefresh.js.map +0 -1
  236. package/workflows/container-contents/documentPriming.js.map +0 -1
  237. package/workflows/container-contents/documentPurge.js.map +0 -1
  238. package/workflows/container-contents/documentQueries.js.map +0 -1
  239. package/workflows/container-contents/documentRuntimeTargetSync.js.map +0 -1
  240. package/workflows/container-contents/documentStructure.js.map +0 -1
  241. package/workflows/container-contents/documentStructureTypes.js.map +0 -1
  242. package/workflows/container-contents/documentSubtreeQueries.js.map +0 -1
  243. package/workflows/container-contents/documentTombstoneEvidence.js.map +0 -1
  244. package/workflows/container-contents/documentTombstoneGate.js.map +0 -1
  245. package/workflows/container-contents/folderRecovery.js.map +0 -1
  246. package/workflows/container-contents/metadata.js.map +0 -1
  247. package/workflows/container-contents/metadataEvents.js.map +0 -1
  248. package/workflows/container-contents/metadataIncomingUpdateIsolation.js.map +0 -1
  249. package/workflows/container-contents/metadataMutationPreparation.js.map +0 -1
  250. package/workflows/container-contents/metadataPersistence.js.map +0 -1
  251. package/workflows/container-contents/metadataPullContinuationInvalidation.js.map +0 -1
  252. package/workflows/container-contents/metadataReadState.js.map +0 -1
  253. package/workflows/container-contents/metadataRecord.js.map +0 -1
  254. package/workflows/container-contents/metadataRemoteSync.js.map +0 -1
  255. package/workflows/container-contents/metadataStateInstallation.js.map +0 -1
  256. package/workflows/container-contents/metadataStateIsolation.js.map +0 -1
  257. package/workflows/container-contents/metadataSyncErrors.js.map +0 -1
  258. package/workflows/container-contents/metadataSyncSettlement.js.map +0 -1
  259. package/workflows/container-contents/metadataTypes.js.map +0 -1
  260. package/workflows/container-contents/orphanedDocumentSql.js.map +0 -1
  261. package/workflows/container-contents/pendingDownloads.js.map +0 -1
  262. package/workflows/container-contents/pendingWrites.js.map +0 -1
  263. package/workflows/container-contents/remoteContainerPageHydration.js.map +0 -1
  264. package/workflows/container-contents/remoteContainerState.js.map +0 -1
  265. package/workflows/container-contents/remoteHydration.js.map +0 -1
  266. package/workflows/container-contents/staleRootRecovery.js.map +0 -1
  267. package/workflows/runtimeInput.js.map +0 -1
  268. /package/workflows/container-contents/{documentAttributionRanges.js → attribution/documentAttributionRanges.js} +0 -0
  269. /package/workflows/container-contents/{documentAttributionRanges.js.map → attribution/documentAttributionRanges.js.map} +0 -0
  270. /package/workflows/container-contents/{containerDocumentListing.js.map → documentDiscovery/containerDocumentListing.js.map} +0 -0
  271. /package/workflows/container-contents/{documentDiscoveryCandidates.js → documentDiscovery/documentDiscoveryCandidates.js} +0 -0
  272. /package/workflows/container-contents/{documentDiscoveryLanes.js → documentDiscovery/documentDiscoveryLanes.js} +0 -0
  273. /package/workflows/container-contents/{documentDiscoveryTypes.js → documentDiscovery/documentDiscoveryTypes.js} +0 -0
  274. /package/workflows/container-contents/{documentHeadScope.js → documentDiscovery/documentHeadScope.js} +0 -0
  275. /package/workflows/container-contents/{documentHeadScope.js.map → documentDiscovery/documentHeadScope.js.map} +0 -0
  276. /package/workflows/container-contents/{documentLocalRelink.js → documentLinks/documentLocalRelink.js} +0 -0
  277. /package/workflows/container-contents/{documentMoveDeniedReplay.js → documentMove/documentMoveDeniedReplay.js} +0 -0
  278. /package/workflows/container-contents/{documentMoveUnlinkIds.js → documentMove/documentMoveUnlinkIds.js} +0 -0
  279. /package/workflows/container-contents/{documentMoveUnlinkIds.js.map → documentMove/documentMoveUnlinkIds.js.map} +0 -0
  280. /package/workflows/container-contents/{documentRuntimeTargetSync.js → documentPriming/documentRuntimeTargetSync.js} +0 -0
  281. /package/workflows/container-contents/{documentStructureTypes.js → documentQueries/documentStructureTypes.js} +0 -0
  282. /package/workflows/container-contents/{blobInfoRows.js → info/blobInfoRows.js} +0 -0
  283. /package/workflows/container-contents/{blobInfoRows.js.map → info/blobInfoRows.js.map} +0 -0
  284. /package/workflows/container-contents/{blobInfoTypes.js → info/blobInfoTypes.js} +0 -0
  285. /package/workflows/container-contents/{documentInfoTypes.js → info/documentInfoTypes.js} +0 -0
  286. /package/workflows/container-contents/{metadataReadState.js → metadata/metadataReadState.js} +0 -0
  287. /package/workflows/container-contents/{metadataStateInstallation.js → metadata/metadataStateInstallation.js} +0 -0
  288. /package/workflows/container-contents/{metadataSyncFollowup.js → metadata/metadataSyncFollowup.js} +0 -0
  289. /package/workflows/container-contents/{metadataSyncFollowup.js.map → metadata/metadataSyncFollowup.js.map} +0 -0
  290. /package/workflows/container-contents/{metadataSyncRegistrations.d.ts → metadata/metadataSyncRegistrations.d.ts} +0 -0
  291. /package/workflows/container-contents/{metadataSyncRegistrations.js → metadata/metadataSyncRegistrations.js} +0 -0
  292. /package/workflows/container-contents/{metadataSyncRegistrations.js.map → metadata/metadataSyncRegistrations.js.map} +0 -0
  293. /package/workflows/container-contents/{metadataTypes.js → metadata/metadataTypes.js} +0 -0
  294. /package/workflows/container-contents/{pendingWritesTypes.d.ts → pendingWrites/pendingWritesTypes.d.ts} +0 -0
  295. /package/workflows/container-contents/{pendingWritesTypes.js → pendingWrites/pendingWritesTypes.js} +0 -0
  296. /package/workflows/container-contents/{pendingWritesTypes.js.map → pendingWrites/pendingWritesTypes.js.map} +0 -0
  297. /package/workflows/container-contents/{remoteHydrationLog.js → remoteHydration/remoteHydrationLog.js} +0 -0
  298. /package/workflows/container-contents/{remoteHydrationLog.js.map → remoteHydration/remoteHydrationLog.js.map} +0 -0
  299. /package/workflows/{runtimeInput.js → shared/runtimeInput.js} +0 -0
@@ -1,14 +1,14 @@
1
- import { CONTAINER_METADATA_APP_KIND } from "../../data/persistence/container-contents/containerContentsPersistence.js";
2
- import { sqlDocumentMoveIntentPersistence } from "../../data/persistence/container-contents/documentMoveIntentPersistence.js";
3
- import { sqlDocumentsPersistence } from "../../data/persistence/documents/documentsPersistence.js";
4
- import { DOCUMENTS_APP_KIND } from "../../data/persistence/documents/internal/constants.js";
5
- import { clearDocumentSyncFailure, resetDocumentPendingUpdateRekeyBudget, } from "../../data/sqlite/documentPersistence.js";
6
- import { documentPlacementIntentTables, documentTables, LOCAL_INTENT_LANES, } from "../../data/sqlite/schema.js";
7
- import { ensureSqlTables } from "../../data/sqlite/sqlSchema.js";
8
- import { defaultContainerContentsPersistence } from "./containerPersistence.js";
9
- import { groupPendingWriteCandidates } from "./pendingWrites/aggregation.js";
10
- import { hasDeferredTailScopeWork, listDeferredPendingWriteCandidates, } from "./pendingWrites/deferredTails.js";
11
- import { listPersistedPendingWriteCandidates } from "./pendingWrites/sources.js";
1
+ import { CONTAINER_METADATA_APP_KIND } from "../../../data/persistence/container-contents/containerContentsPersistence.js";
2
+ import { sqlDocumentMoveIntentPersistence } from "../../../data/persistence/container-contents/documentMoveIntentPersistence.js";
3
+ import { sqlDocumentsPersistence } from "../../../data/persistence/documents/documentsPersistence.js";
4
+ import { DOCUMENTS_APP_KIND } from "../../../data/persistence/documents/internal/constants.js";
5
+ import { clearDocumentSyncFailure, resetDocumentPendingUpdateRekeyBudget, } from "../../../data/sqlite/documentPersistence.js";
6
+ import { documentPlacementIntentTables, documentTables, LOCAL_INTENT_LANES, } from "../../../data/sqlite/schema.js";
7
+ import { ensureSqlTables } from "../../../data/sqlite/sqlSchema.js";
8
+ import { defaultContainerContentsPersistence } from "../containerPersistence.js";
9
+ import { groupPendingWriteCandidates } from "./aggregation.js";
10
+ import { hasDeferredTailScopeWork, listDeferredPendingWriteCandidates, } from "./deferredTails.js";
11
+ import { listPersistedPendingWriteCandidates } from "./sources.js";
12
12
  /**
13
13
  * List identity-wide local state that still requires a remote write. The
14
14
  * returned diagnostic contains only navigation/display metadata and aggregate
@@ -113,4 +113,4 @@ async function hasQueuedScopeWork(execSql, scope) {
113
113
  // version-vector coverage check.
114
114
  return hasDeferredTailScopeWork(execSql, scope);
115
115
  }
116
- //# sourceMappingURL=pendingWrites.js.map
116
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,2EAA2E,CAAC;AACxH,OAAO,EAAE,gCAAgC,EAAE,MAAM,4EAA4E,CAAC;AAC9H,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EACL,wBAAwB,EACxB,qCAAqC,GACtC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,6BAA6B,EAC7B,cAAc,EACd,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AA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sEAAsE;QACtE,uBAAuB;QACvB,MAAM,gCAAgC,CAAC,sBAAsB,CAAC,OAAO,EAAE;YACrE,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,yEAAyE;IACzE,0EAA0E;IAC1E,sEAAsE;IACtE,wEAAwE;IACxE,yEAAyE;IACzE,IAAI,MAAM,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,kBAAkB,CAC/B,OAAgB,EAChB,KAA2C;IAE3C,MAAM,eAAe,CAAC,OAAO,EAAE;QAC7B,GAAG,cAAc;QACjB,GAAG,6BAA6B;KACjC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,CACxB;;;;;;;;;;;;gCAY4B,kBAAkB,CAAC,iBAAiB;;;;;;;;;aASvD,EACT;QACE,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,OAAO;QACb,KAAK,CAAC,OAAO;KACd,CACF,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,sEAAsE;IACtE,kEAAkE;IAClE,iCAAiC;IACjC,OAAO,wBAAwB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import { CONTAINER_METADATA_APP_KIND } from \"../../../data/persistence/container-contents/containerContentsPersistence\";\nimport { sqlDocumentMoveIntentPersistence } from \"../../../data/persistence/container-contents/documentMoveIntentPersistence\";\nimport { sqlDocumentsPersistence } from \"../../../data/persistence/documents/documentsPersistence\";\nimport { DOCUMENTS_APP_KIND } from \"../../../data/persistence/documents/internal/constants\";\nimport {\n clearDocumentSyncFailure,\n resetDocumentPendingUpdateRekeyBudget,\n} from \"../../../data/sqlite/documentPersistence\";\nimport {\n documentPlacementIntentTables,\n documentTables,\n LOCAL_INTENT_LANES,\n} from \"../../../data/sqlite/schema\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { ensureSqlTables } from \"../../../data/sqlite/sqlSchema\";\nimport { defaultContainerContentsPersistence } from \"../containerPersistence\";\nimport { groupPendingWriteCandidates } from \"./aggregation\";\nimport {\n hasDeferredTailScopeWork,\n listDeferredPendingWriteCandidates,\n} from \"./deferredTails\";\nimport type { PendingWriteQueueItem } from \"./pendingWritesTypes\";\nimport { listPersistedPendingWriteCandidates } from \"./sources\";\n\nexport type {\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n} from \"./pendingWritesTypes\";\n\n/**\n * List identity-wide local state that still requires a remote write. The\n * returned diagnostic contains only navigation/display metadata and aggregate\n * counts; serialized updates, local storage keys, and upload crypto stay below\n * the workflow boundary.\n */\nexport async function listPendingWrites(\n execSql: ExecSql,\n): Promise<ReadonlyArray<PendingWriteQueueItem>> {\n await defaultContainerContentsPersistence.ensureSchema(execSql);\n await sqlDocumentsPersistence.ensureSchema(execSql);\n await sqlDocumentMoveIntentPersistence.ensureSchema(execSql);\n\n const [persisted, deferred] = await Promise.all([\n listPersistedPendingWriteCandidates(execSql),\n listDeferredPendingWriteCandidates(execSql),\n ]);\n return groupPendingWriteCandidates([...persisted, ...deferred]);\n}\n\n/**\n * Explicit manual retry for one write-queue item: reset the durable re-key\n * budget for the item's ACTUAL pending-update scope (container metadata and\n * unknown document namespaces re-key through the same recovery path as\n * ordinary documents) and clear the recorded terminal failure — the next\n * pass re-records both if they still hold. The cap protects against a\n * server driving a network-speed re-key loop; a deliberate user retry is\n * the rate-limited signal that conditions have changed (e.g. an outage that\n * burned the budget has healed). The caller re-arms the sync lanes.\n */\nexport async function resetPendingWriteRetryState(\n execSql: ExecSql,\n input: {\n localId: string;\n /** The item's `namespace` — the unrecognized documents.app_kind, if any. */\n namespace: string | null;\n objectKind: PendingWriteQueueItem[\"objectKind\"];\n },\n): Promise<void> {\n const appKind =\n input.objectKind === \"container\"\n ? CONTAINER_METADATA_APP_KIND\n : (input.namespace ??\n (input.objectKind === \"document\" ? DOCUMENTS_APP_KIND : null));\n if (appKind === null) {\n // An unknown object kind with no namespace: there is no scope to reset,\n // and guessing one could clear an unrelated scope sharing the localId.\n return;\n }\n const scope = { appKind, localId: input.localId };\n await resetDocumentPendingUpdateRekeyBudget(execSql, scope);\n if (appKind === DOCUMENTS_APP_KIND) {\n // A deliberate retry is the rate-limited signal that conditions changed:\n // a parked permission-denied move (row 7) replays once, like row 11's\n // re-key budget reset.\n await sqlDocumentMoveIntentPersistence.resetDeniedMoveIntents(execSql, {\n localId: input.localId,\n });\n }\n // Clearing the failure row is part of the re-key budget reset (edge-case\n // row 11) and only makes sense alongside queued work. A failure-only item\n // (a refused revalidation, row 13) has no queued work: its row is the\n // priming ticket that re-drives the store, so it must survive the retry\n // and clear on the next clean pass instead of vanishing with no request.\n if (await hasQueuedScopeWork(execSql, scope)) {\n await clearDocumentSyncFailure(execSql, scope);\n }\n}\n\n/**\n * Whether ANY durable outbound work exists for the scope — CRDT updates,\n * staged attachment uploads, move intents, a never-created local document, or\n * a deferred write whose only durable content is the history tail ahead of\n * its covered frontier. Mirrors the queue's own document candidate sources,\n * so \"failure-only\" here agrees with the item the panel rendered.\n */\nasync function hasQueuedScopeWork(\n execSql: ExecSql,\n scope: { appKind: string; localId: string },\n): Promise<boolean> {\n await ensureSqlTables(execSql, [\n ...documentTables,\n ...documentPlacementIntentTables,\n ]);\n const rows = await execSql(\n `SELECT 1 AS present\n WHERE EXISTS (\n SELECT 1 FROM document_history_updates pending\n WHERE pending.app_kind = ? AND pending.local_id = ?\n AND pending.update_id IS NOT NULL\n )\n OR EXISTS (\n SELECT 1 FROM document_pending_attachments attachment\n WHERE attachment.local_id = ?\n )\n OR EXISTS (\n SELECT 1 FROM local_intents intent\n WHERE intent.lane = '${LOCAL_INTENT_LANES.documentPlacement}'\n AND intent.local_id = ?\n AND intent.intent_type IN ('document.move', 'document.link')\n )\n OR EXISTS (\n SELECT 1 FROM documents stored\n WHERE stored.app_kind = ? AND stored.local_id = ?\n AND stored.document_id IS NULL\n )\n LIMIT 1`,\n [\n scope.appKind,\n scope.localId,\n scope.localId,\n scope.localId,\n scope.appKind,\n scope.localId,\n ],\n );\n if (rows.length > 0) {\n return true;\n }\n // The queue's deferred-update source has no queued rows to probe: the\n // write lives in the durable history tail, detectable only by the\n // version-vector coverage check.\n return hasDeferredTailScopeWork(execSql, scope);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"projectionGeneration.js","sourceRoot":"","sources":["projectionGeneration.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAiE;IAEjE,OAAO,KAAK,CAAC,0BAA0B,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { ContainerMetadataState } from \"./metadataTypes\";\n\n/**\n * The shared writer-projection generation of a container state (container and\n * metadata-document projections move together). A leaf so hydration, metadata\n * settlement, and the projection cache can all read it without importing one\n * another.\n */\nexport function projectionGeneration(\n state: Pick<ContainerMetadataState, \"writerProjectionGeneration\">,\n): number {\n return state.writerProjectionGeneration ?? 0;\n}\n"]}
1
+ {"version":3,"file":"projectionGeneration.js","sourceRoot":"","sources":["projectionGeneration.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAiE;IAEjE,OAAO,KAAK,CAAC,0BAA0B,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { ContainerMetadataState } from \"./metadata/metadataTypes\";\n\n/**\n * The shared writer-projection generation of a container state (container and\n * metadata-document projections move together). A leaf so hydration, metadata\n * settlement, and the projection cache can all read it without importing one\n * another.\n */\nexport function projectionGeneration(\n state: Pick<ContainerMetadataState, \"writerProjectionGeneration\">,\n): number {\n return state.writerProjectionGeneration ?? 0;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { ProjectionUserKeyResolver } from "../../data/keyingProjectionVerification/index.js";
2
2
  import { createProjectionUserKeyResolver } from "../../data/keyingProjectionVerification/userKeyResolver.js";
3
- import type { WorkflowRuntimeAuthInput, WorkflowRuntimeCryptoInput, WorkflowRuntimeStateInput } from "../runtimeInput.js";
3
+ import type { WorkflowRuntimeAuthInput, WorkflowRuntimeCryptoInput, WorkflowRuntimeStateInput } from "../shared/runtimeInput.js";
4
4
  export type ContainerContentsProjectionUserKeyResolver = ProjectionUserKeyResolver;
5
5
  type ProjectionKeyRuntime = Parameters<typeof createProjectionUserKeyResolver>[0];
6
6
  export interface ContainerContentsProjectionKeyRuntime {
@@ -1 +1 @@
1
- {"version":3,"file":"projectionKeys.js","sourceRoot":"","sources":["projectionKeys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yDAAyD,CAAC;AAoB1G,MAAM,UAAU,gDAAgD,CAC9D,OAA8C;IAE9C,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,wDAAwD,CACtE,OAA8C;IAE9C,OAAO,gDAAgD,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,8CAA8C,CAC5D,eAAsD,EACtD,WAAkD;IAElD,4EAA4E;IAC5E,uEAAuE;IACvE,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,CACL,eAAe,CAAC,0BAA0B;QACxC,WAAW,CAAC,0BAA0B;QACxC,eAAe,CAAC,IAAI,CAAC,eAAe,KAAK,WAAW,CAAC,IAAI,CAAC,eAAe;QACzE,eAAe,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,IAAI,CAAC,MAAM;QACvD,eAAe,CAAC,MAAM,CAAC,oBAAoB;YACzC,WAAW,CAAC,MAAM,CAAC,oBAAoB;QACzC,eAAe,CAAC,MAAM,CAAC,kBAAkB;YACvC,WAAW,CAAC,MAAM,CAAC,kBAAkB;QACvC,eAAe,CAAC,MAAM,CAAC,cAAc;YACnC,WAAW,CAAC,MAAM,CAAC,cAAc;QACnC,eAAe,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,KAAK,CAAC,WAAW,CACpE,CAAC;AACJ,CAAC","sourcesContent":["import type { ProjectionUserKeyResolver } from \"../../data/keyingProjectionVerification\";\nimport { createProjectionUserKeyResolver } from \"../../data/keyingProjectionVerification/userKeyResolver\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeStateInput,\n} from \"../runtimeInput\";\n\nexport type ContainerContentsProjectionUserKeyResolver =\n ProjectionUserKeyResolver;\ntype ProjectionKeyRuntime = Parameters<\n typeof createProjectionUserKeyResolver\n>[0];\n\nexport interface ContainerContentsProjectionKeyRuntime {\n readonly auth: Pick<WorkflowRuntimeAuthInput, \"isAuthenticated\" | \"userId\">;\n readonly crypto: WorkflowRuntimeCryptoInput;\n readonly resolveTrustedUserIdentity: ProjectionKeyRuntime[\"resolveTrustedUserIdentity\"];\n readonly state: Pick<WorkflowRuntimeStateInput, \"domainScope\">;\n}\n\nexport function createContainerContentsProjectionUserKeyResolver(\n runtime: ContainerContentsProjectionKeyRuntime,\n): ContainerContentsProjectionUserKeyResolver {\n return createProjectionUserKeyResolver(runtime);\n}\n\nexport function createContainerContentsDocumentProjectionUserKeyResolver(\n runtime: ContainerContentsProjectionKeyRuntime,\n): ContainerContentsProjectionUserKeyResolver {\n return createContainerContentsProjectionUserKeyResolver(runtime);\n}\n\nexport function didContainerContentsProjectionKeyRuntimeChange(\n previousRuntime: ContainerContentsProjectionKeyRuntime,\n nextRuntime: ContainerContentsProjectionKeyRuntime,\n): boolean {\n // The SDK-owned resolver is stable for the lifetime of Tearleads, but reads\n // mutable session, identity, and database dependencies. The projection\n // resolver adds its own per-user cache, so compare that trust context rather\n // than relying only on the resolver function reference.\n return (\n previousRuntime.resolveTrustedUserIdentity !==\n nextRuntime.resolveTrustedUserIdentity ||\n previousRuntime.auth.isAuthenticated !== nextRuntime.auth.isAuthenticated ||\n previousRuntime.auth.userId !== nextRuntime.auth.userId ||\n previousRuntime.crypto.encapsulationKeyPair !==\n nextRuntime.crypto.encapsulationKeyPair ||\n previousRuntime.crypto.signingFingerprint !==\n nextRuntime.crypto.signingFingerprint ||\n previousRuntime.crypto.signingKeyPair !==\n nextRuntime.crypto.signingKeyPair ||\n previousRuntime.state.domainScope !== nextRuntime.state.domainScope\n );\n}\n"]}
1
+ {"version":3,"file":"projectionKeys.js","sourceRoot":"","sources":["projectionKeys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yDAAyD,CAAC;AAoB1G,MAAM,UAAU,gDAAgD,CAC9D,OAA8C;IAE9C,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,wDAAwD,CACtE,OAA8C;IAE9C,OAAO,gDAAgD,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,8CAA8C,CAC5D,eAAsD,EACtD,WAAkD;IAElD,4EAA4E;IAC5E,uEAAuE;IACvE,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,CACL,eAAe,CAAC,0BAA0B;QACxC,WAAW,CAAC,0BAA0B;QACxC,eAAe,CAAC,IAAI,CAAC,eAAe,KAAK,WAAW,CAAC,IAAI,CAAC,eAAe;QACzE,eAAe,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,IAAI,CAAC,MAAM;QACvD,eAAe,CAAC,MAAM,CAAC,oBAAoB;YACzC,WAAW,CAAC,MAAM,CAAC,oBAAoB;QACzC,eAAe,CAAC,MAAM,CAAC,kBAAkB;YACvC,WAAW,CAAC,MAAM,CAAC,kBAAkB;QACvC,eAAe,CAAC,MAAM,CAAC,cAAc;YACnC,WAAW,CAAC,MAAM,CAAC,cAAc;QACnC,eAAe,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,KAAK,CAAC,WAAW,CACpE,CAAC;AACJ,CAAC","sourcesContent":["import type { ProjectionUserKeyResolver } from \"../../data/keyingProjectionVerification\";\nimport { createProjectionUserKeyResolver } from \"../../data/keyingProjectionVerification/userKeyResolver\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeStateInput,\n} from \"../shared/runtimeInput\";\n\nexport type ContainerContentsProjectionUserKeyResolver =\n ProjectionUserKeyResolver;\ntype ProjectionKeyRuntime = Parameters<\n typeof createProjectionUserKeyResolver\n>[0];\n\nexport interface ContainerContentsProjectionKeyRuntime {\n readonly auth: Pick<WorkflowRuntimeAuthInput, \"isAuthenticated\" | \"userId\">;\n readonly crypto: WorkflowRuntimeCryptoInput;\n readonly resolveTrustedUserIdentity: ProjectionKeyRuntime[\"resolveTrustedUserIdentity\"];\n readonly state: Pick<WorkflowRuntimeStateInput, \"domainScope\">;\n}\n\nexport function createContainerContentsProjectionUserKeyResolver(\n runtime: ContainerContentsProjectionKeyRuntime,\n): ContainerContentsProjectionUserKeyResolver {\n return createProjectionUserKeyResolver(runtime);\n}\n\nexport function createContainerContentsDocumentProjectionUserKeyResolver(\n runtime: ContainerContentsProjectionKeyRuntime,\n): ContainerContentsProjectionUserKeyResolver {\n return createContainerContentsProjectionUserKeyResolver(runtime);\n}\n\nexport function didContainerContentsProjectionKeyRuntimeChange(\n previousRuntime: ContainerContentsProjectionKeyRuntime,\n nextRuntime: ContainerContentsProjectionKeyRuntime,\n): boolean {\n // The SDK-owned resolver is stable for the lifetime of Tearleads, but reads\n // mutable session, identity, and database dependencies. The projection\n // resolver adds its own per-user cache, so compare that trust context rather\n // than relying only on the resolver function reference.\n return (\n previousRuntime.resolveTrustedUserIdentity !==\n nextRuntime.resolveTrustedUserIdentity ||\n previousRuntime.auth.isAuthenticated !== nextRuntime.auth.isAuthenticated ||\n previousRuntime.auth.userId !== nextRuntime.auth.userId ||\n previousRuntime.crypto.encapsulationKeyPair !==\n nextRuntime.crypto.encapsulationKeyPair ||\n previousRuntime.crypto.signingFingerprint !==\n nextRuntime.crypto.signingFingerprint ||\n previousRuntime.crypto.signingKeyPair !==\n nextRuntime.crypto.signingKeyPair ||\n previousRuntime.state.domainScope !== nextRuntime.state.domainScope\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { listContainerContentsDocumentsForContainers } from "./documentSubtreeQueries.js";
1
+ import { listContainerContentsDocumentsForContainers } from "./documentQueries/documentSubtreeQueries.js";
2
2
  /**
3
3
  * Device-first projection reads for the local-projection store (Layer A).
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"projectionView.js","sourceRoot":"","sources":["projectionView.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AAEvF;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gDAAgD,CAAC,KAGtE;IACC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAC7B,IAAI,GAAG,CACL,KAAK,CAAC,YAAY,CAAC,MAAM,CACvB,CAAC,WAAW,EAAyB,EAAE,CACrC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAC5D,CACF,CACF,CAAC;IACF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,iBAAiB,EAAE,EAAE;YACrB,8BAA8B,EAAE,IAAI,GAAG,EAAE;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO,2CAA2C,CAChD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC3B,YAAY,EACZ,EAAE,qBAAqB,EAAE,KAAK,EAAE,CACjC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ContainerContentsSharedDocumentSummaries,\n ContainerDocumentQueriesRuntime,\n} from \"./documentQueries/types\";\nimport { listContainerContentsDocumentsForContainers } from \"./documentSubtreeQueries\";\n\n/**\n * Device-first projection reads for the local-projection store (Layer A).\n *\n * These load document summaries and their container links straight from\n * SQLite — no network — so the explorer can paint a container's contents on\n * first open. They reuse the shared `documentSubtreeQueries` pipeline, kept in\n * this small module so the local projection store does not import raw\n * persistence itself.\n */\n\n/**\n * Load document summaries + container links for a flat set of container ids,\n * directly from SQLite. Returns empty results when no containers are given.\n */\nexport async function loadLocalContainerProjectionDocumentsFromRuntime(input: {\n containerIds: ReadonlyArray<string>;\n runtime: ContainerDocumentQueriesRuntime;\n}): Promise<ContainerContentsSharedDocumentSummaries> {\n const containerIds = Array.from(\n new Set(\n input.containerIds.filter(\n (containerId): containerId is string =>\n typeof containerId === \"string\" && containerId.length > 0,\n ),\n ),\n );\n if (containerIds.length === 0) {\n return {\n documentSummaries: [],\n linkedContainerIdsByDocumentId: new Map(),\n };\n }\n\n return listContainerContentsDocumentsForContainers(\n input.runtime.infra.execSql,\n containerIds,\n { sortDocumentSummaries: false },\n );\n}\n"]}
1
+ {"version":3,"file":"projectionView.js","sourceRoot":"","sources":["projectionView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2CAA2C,EAAE,MAAM,0CAA0C,CAAC;AAMvG;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gDAAgD,CAAC,KAGtE;IACC,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAC7B,IAAI,GAAG,CACL,KAAK,CAAC,YAAY,CAAC,MAAM,CACvB,CAAC,WAAW,EAAyB,EAAE,CACrC,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAC5D,CACF,CACF,CAAC;IACF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,iBAAiB,EAAE,EAAE;YACrB,8BAA8B,EAAE,IAAI,GAAG,EAAE;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO,2CAA2C,CAChD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC3B,YAAY,EACZ,EAAE,qBAAqB,EAAE,KAAK,EAAE,CACjC,CAAC;AACJ,CAAC","sourcesContent":["import { listContainerContentsDocumentsForContainers } from \"./documentQueries/documentSubtreeQueries\";\nimport type {\n ContainerContentsSharedDocumentSummaries,\n ContainerDocumentQueriesRuntime,\n} from \"./documentQueries/types\";\n\n/**\n * Device-first projection reads for the local-projection store (Layer A).\n *\n * These load document summaries and their container links straight from\n * SQLite — no network — so the explorer can paint a container's contents on\n * first open. They reuse the shared `documentSubtreeQueries` pipeline, kept in\n * this small module so the local projection store does not import raw\n * persistence itself.\n */\n\n/**\n * Load document summaries + container links for a flat set of container ids,\n * directly from SQLite. Returns empty results when no containers are given.\n */\nexport async function loadLocalContainerProjectionDocumentsFromRuntime(input: {\n containerIds: ReadonlyArray<string>;\n runtime: ContainerDocumentQueriesRuntime;\n}): Promise<ContainerContentsSharedDocumentSummaries> {\n const containerIds = Array.from(\n new Set(\n input.containerIds.filter(\n (containerId): containerId is string =>\n typeof containerId === \"string\" && containerId.length > 0,\n ),\n ),\n );\n if (containerIds.length === 0) {\n return {\n documentSummaries: [],\n linkedContainerIdsByDocumentId: new Map(),\n };\n }\n\n return listContainerContentsDocumentsForContainers(\n input.runtime.infra.execSql,\n containerIds,\n { sortDocumentSummaries: false },\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ExecSql } from "../../data/sqlite/sqlSchema.js";
1
+ import type { ExecSql } from "../../../data/sqlite/sqlSchema.js";
2
2
  export interface RecoveryFolder {
3
3
  containerId: string;
4
4
  organizationId: string;
@@ -1,7 +1,7 @@
1
- import { base64ToBytes } from "../../internal/encoding/index.js";
2
- import { importUpdates } from "../../internal/loro/index.js";
3
- import { createContainerMetadataDocument, readContainerMetadataValue, } from "../../data/containers/containerMetadataDocument.js";
4
- import { discardRetainedContainerMetadata, listRecoveryFolderMoveIds, listRetainedContainerMetadata, } from "../../data/persistence/container-contents/containerRecoveryPersistence.js";
1
+ import { base64ToBytes } from "../../../internal/encoding/index.js";
2
+ import { importUpdates } from "../../../internal/loro/index.js";
3
+ import { createContainerMetadataDocument, readContainerMetadataValue, } from "../../../data/containers/containerMetadataDocument.js";
4
+ import { discardRetainedContainerMetadata, listRecoveryFolderMoveIds, listRetainedContainerMetadata, } from "../../../data/persistence/container-contents/containerRecoveryPersistence.js";
5
5
  export function createFolderRecoveryQueries(execSql) {
6
6
  return {
7
7
  listRecoveryFolderMoveIds(input) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folderRecovery.js","sourceRoot":"","sources":["folderRecovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,2EAA2E,CAAC;AAanF,MAAM,UAAU,2BAA2B,CAAC,OAAgB;IAC1D,OAAO;QACL,yBAAyB,CAAC,KAEzB;YACC,OAAO,yBAAyB,CAAC,OAAO,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzE,CAAC;QACD,KAAK,CAAC,mBAAmB,CAAC,KAEzB;YACC,MAAM,OAAO,GAAG,MAAM,6BAA6B,CACjD,OAAO,EACP,KAAK,CAAC,qBAAqB,CAC5B,CAAC;YACF,OAAO,OAAO,CAAC,GAAG,CAChB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE;gBACnD,MAAM,GAAG,GAAG,MAAM,+BAA+B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBACtE,IAAI,CAAC;oBACH,IAAI,eAAe;wBACjB,aAAa,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;oBACvD,OAAO;wBACL,GAAG,MAAM;wBACT,GAAG,0BAA0B,CAAC,GAAG,EAAE,iBAAiB,CAAC;qBACtD,CAAC;gBACJ,CAAC;wBAAS,CAAC;oBACT,GAAG,CAAC,IAAI,EAAE,CAAC;gBACb,CAAC;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QACD,qBAAqB,CACnB,KAGC;YAED,OAAO,gCAAgC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { base64ToBytes } from \"@tearleads/encoding\";\nimport { importUpdates } from \"@tearleads/loro\";\nimport {\n createContainerMetadataDocument,\n readContainerMetadataValue,\n} from \"../../../data/containers/containerMetadataDocument\";\nimport {\n discardRetainedContainerMetadata,\n listRecoveryFolderMoveIds,\n listRetainedContainerMetadata,\n} from \"../../../data/persistence/container-contents/containerRecoveryPersistence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\n\nexport interface RecoveryFolder {\n containerId: string;\n organizationId: string;\n name: string;\n icon: string | null;\n pendingUpdateCount: number;\n hasStructuralIntent: boolean;\n revision: string;\n}\n\nexport function createFolderRecoveryQueries(execSql: ExecSql) {\n return {\n listRecoveryFolderMoveIds(input: {\n currentOrganizationId: string | null;\n }): Promise<string[]> {\n return listRecoveryFolderMoveIds(execSql, input.currentOrganizationId);\n },\n async listRecoveryFolders(input: {\n currentOrganizationId: string | null;\n }): Promise<RecoveryFolder[]> {\n const records = await listRetainedContainerMetadata(\n execSql,\n input.currentOrganizationId,\n );\n return Promise.all(\n records.map(async ({ metadataUpdates, ...record }) => {\n const doc = await createContainerMetadataDocument(record.containerId);\n try {\n if (metadataUpdates)\n importUpdates(doc, [base64ToBytes(metadataUpdates)]);\n return {\n ...record,\n ...readContainerMetadataValue(doc, \"Untitled folder\"),\n };\n } finally {\n doc.free();\n }\n }),\n );\n },\n discardRecoveryFolder(\n input: Pick<\n RecoveryFolder,\n \"containerId\" | \"organizationId\" | \"revision\"\n >,\n ): Promise<boolean> {\n return discardRetainedContainerMetadata(execSql, input);\n },\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { hasRemoteContainerMetadataState } from "./remoteHydration/reconciliation.js";
1
+ import { hasRemoteContainerMetadataState } from "../remoteHydration/reconciliation.js";
2
2
  function hasSameRecoveryContext(state, input) {
3
3
  return (state.runtime.auth.isAuthenticated &&
4
4
  state.runtime.auth.defaultOrganizationId === input.defaultOrganizationId &&
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleRootRecovery.js","sourceRoot":"","sources":["staleRootRecovery.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AA6CpF,SAAS,sBAAsB,CAC7B,KAA6B,EAC7B,KAOC;IAED,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;QAClC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,qBAAqB;QACxE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc;QAC1D,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC1C,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,KAAK,KAAK,CAAC,eAAe;QAC5D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,gBAAgB;QAC1D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,WAAW,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B,CACtC,KAA6B,EAC7B,cAAsB;IAEtB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,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import type { ContainerState } from \"../remoteHydration\";\nimport { hasRemoteContainerMetadataState } from \"../remoteHydration/reconciliation\";\nimport type {\n ContainerContentsRootAdopter,\n ContainerContentsWorkflowRuntime,\n} from \"../runtime\";\n\nexport type StaleRootRecoveryStatus =\n | \"already-adopted\"\n | \"ambiguous\"\n | \"context-changed\"\n | \"not-needed\"\n | \"reassigned\"\n | \"unsupported\";\n\ninterface StaleRootRecoveryResult {\n readonly candidateCount: number;\n readonly reassigned: boolean;\n readonly status: StaleRootRecoveryStatus;\n}\n\ninterface StaleRootRecoveryState {\n readonly containersById: ReadonlyMap<string, ContainerState>;\n readonly persistence: Pick<\n ContainerContentsPersistence,\n \"containerExists\" | \"reassignContainerDocuments\"\n >;\n readonly rootLaneHydrated: boolean;\n readonly runtime: {\n readonly adoptRootContainer?: ContainerContentsRootAdopter | undefined;\n readonly auth: Pick<\n ContainerContentsWorkflowRuntime[\"auth\"],\n | \"defaultOrganizationId\"\n | \"isAuthenticated\"\n | \"organizationId\"\n | \"userId\"\n | \"rootContainerId\"\n >;\n readonly infra: Pick<ContainerContentsWorkflowRuntime[\"infra\"], \"execSql\">;\n readonly state: Pick<\n ContainerContentsWorkflowRuntime[\"state\"],\n \"containerId\" | \"domainScope\"\n >;\n };\n}\n\nfunction hasSameRecoveryContext(\n state: StaleRootRecoveryState,\n input: {\n domainScope: ContainerContentsWorkflowRuntime[\"state\"][\"domainScope\"];\n defaultOrganizationId: string;\n organizationId: string;\n staleContainerId: string;\n rootContainerId: string | null | undefined;\n userId: string;\n },\n): boolean {\n return (\n state.runtime.auth.isAuthenticated &&\n state.runtime.auth.defaultOrganizationId === input.defaultOrganizationId &&\n state.runtime.auth.organizationId === input.organizationId &&\n state.runtime.auth.userId === input.userId &&\n state.runtime.auth.rootContainerId === input.rootContainerId &&\n state.runtime.state.containerId === input.staleContainerId &&\n state.runtime.state.domainScope === input.domainScope\n );\n}\n\nfunction listAuthoritativeRootCandidates(\n state: StaleRootRecoveryState,\n organizationId: string,\n): ContainerState[] {\n return Array.from(state.containersById.values()).filter(\n (containerState) =>\n containerState.container.id === state.runtime.auth.rootContainerId &&\n containerState.container.parentId === null &&\n containerState.container.organizationId === organizationId &&\n (containerState.container.systemSlot ?? null) === null &&\n containerState.container.effectiveAccessLevel === \"admin\" &&\n hasRemoteContainerMetadataState(containerState),\n );\n}\n\n/**\n * Repairs the root identity left by a cold-cache login.\n *\n * Root reconciliation can delete the device-first local root without updating\n * the session's default container. Documents created afterward are projected\n * beneath that deleted id, so startup priming detects their writes but cannot\n * route them. Recovery is intentionally narrow: the stale id must be absent\n * from both the loaded topology and durable storage, and the active\n * organization must contain the session-acknowledged root after the root lane\n * has hydrated and verified its signed destination role. This recovery path only repairs document\n * references; structural container descendants remain owned by normal root\n * reconciliation. Durable reassignment deliberately precedes live session\n * adoption so consumers never observe the new root before its documents move.\n * If the live-session guard rejects that adoption, the idempotent reassignment\n * remains applied and the sync lane is re-armed to retry under the next runtime\n * snapshot.\n */\nexport async function recoverStaleSessionRoot(\n state: StaleRootRecoveryState,\n isCurrent: () => boolean = () => true,\n): Promise<StaleRootRecoveryResult> {\n const staleContainerId = state.runtime.state.containerId;\n const domainScope = state.runtime.state.domainScope;\n const defaultOrganizationId = state.runtime.auth.defaultOrganizationId;\n const organizationId = state.runtime.auth.organizationId;\n const userId = state.runtime.auth.userId;\n if (\n !isCurrent() ||\n !state.runtime.auth.isAuthenticated ||\n !staleContainerId ||\n !defaultOrganizationId ||\n !organizationId ||\n !userId ||\n organizationId !== defaultOrganizationId ||\n !state.rootLaneHydrated ||\n state.containersById.has(staleContainerId)\n ) {\n return { candidateCount: 0, reassigned: false, status: \"not-needed\" };\n }\n const recoveryContext = {\n domainScope,\n defaultOrganizationId,\n organizationId,\n staleContainerId,\n userId,\n rootContainerId: state.runtime.auth.rootContainerId,\n };\n\n const storedContainerExists = await state.persistence.containerExists(\n state.runtime.infra.execSql,\n staleContainerId,\n );\n if (storedContainerExists) {\n return { candidateCount: 0, reassigned: false, status: \"not-needed\" };\n }\n if (!isCurrent() || !hasSameRecoveryContext(state, recoveryContext)) {\n return { candidateCount: 0, reassigned: false, status: \"context-changed\" };\n }\n if (state.containersById.has(staleContainerId)) {\n return { candidateCount: 0, reassigned: false, status: \"not-needed\" };\n }\n\n const candidates = listAuthoritativeRootCandidates(\n state,\n defaultOrganizationId,\n );\n const [remoteRootState] = candidates;\n if (!remoteRootState || candidates.length > 1) {\n return {\n candidateCount: candidates.length,\n reassigned: false,\n status: \"ambiguous\",\n };\n }\n if (!state.runtime.adoptRootContainer) {\n return { candidateCount: 1, reassigned: false, status: \"unsupported\" };\n }\n if (!isCurrent() || !hasSameRecoveryContext(state, recoveryContext)) {\n return { candidateCount: 0, reassigned: false, status: \"context-changed\" };\n }\n\n await state.persistence.reassignContainerDocuments(\n state.runtime.infra.execSql,\n {\n fromContainerId: staleContainerId,\n stillCurrent: isCurrent,\n toContainerId: remoteRootState.container.id,\n },\n );\n if (!isCurrent() || !hasSameRecoveryContext(state, recoveryContext)) {\n return { candidateCount: 1, reassigned: false, status: \"context-changed\" };\n }\n const adoptionResult = state.runtime.adoptRootContainer({\n domainScope,\n expectedContainerId: staleContainerId,\n nextContainerId: remoteRootState.container.id,\n organizationId,\n userId,\n });\n\n return {\n candidateCount: 1,\n reassigned: true,\n status:\n adoptionResult === \"already-adopted\"\n ? \"already-adopted\"\n : adoptionResult\n ? \"reassigned\"\n : \"context-changed\",\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { describeRemoteContainerHydration } from "../remoteHydrationLog.js";
1
+ import { describeRemoteContainerHydration } from "./remoteHydrationLog.js";
2
2
  export async function finishRemoteHydration(input) {
3
3
  if (input.isCurrent?.() === false) {
4
4
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"completeHydration.js","sourceRoot":"","sources":["completeHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AAMzE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAS3C;IACC,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;YACjD,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxD,aAAa,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAC1B,gCAAgC,CAAC;YAC/B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,aAAa;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IACD,IACE,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAC7B,KAAK,CAAC,eAAe,EACrB,CAAC;QACD,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { describeRemoteContainerHydration } from \"../remoteHydrationLog\";\nimport type {\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nexport async function finishRemoteHydration(input: {\n changedCount: number;\n complete: boolean;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n seenContainerIds: ReadonlySet<string>;\n containerIdsBeforeHydration: ReadonlySet<string>;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n if (input.isCurrent?.() === false) {\n return;\n }\n if (input.changedCount > 0) {\n input.host.updateSnapshot();\n let insertedCount = 0;\n for (const containerId of input.seenContainerIds) {\n if (!input.containerIdsBeforeHydration.has(containerId)) {\n insertedCount++;\n }\n }\n input.state.runtime.util.log(\n describeRemoteContainerHydration({\n changedCount: input.changedCount,\n insertedCount,\n }),\n );\n }\n if (\n input.complete &&\n input.isCurrent?.() !== false &&\n input.onFullyHydrated\n ) {\n await input.onFullyHydrated();\n }\n}\n"]}
1
+ {"version":3,"file":"completeHydration.js","sourceRoot":"","sources":["completeHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAMxE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAS3C;IACC,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,KAAK,MAAM,WAAW,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;YACjD,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxD,aAAa,EAAE,CAAC;YAClB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAC1B,gCAAgC,CAAC;YAC/B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,aAAa;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IACD,IACE,KAAK,CAAC,QAAQ;QACd,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAC7B,KAAK,CAAC,eAAe,EACrB,CAAC;QACD,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { describeRemoteContainerHydration } from \"./remoteHydrationLog\";\nimport type {\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nexport async function finishRemoteHydration(input: {\n changedCount: number;\n complete: boolean;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n seenContainerIds: ReadonlySet<string>;\n containerIdsBeforeHydration: ReadonlySet<string>;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n if (input.isCurrent?.() === false) {\n return;\n }\n if (input.changedCount > 0) {\n input.host.updateSnapshot();\n let insertedCount = 0;\n for (const containerId of input.seenContainerIds) {\n if (!input.containerIdsBeforeHydration.has(containerId)) {\n insertedCount++;\n }\n }\n input.state.runtime.util.log(\n describeRemoteContainerHydration({\n changedCount: input.changedCount,\n insertedCount,\n }),\n );\n }\n if (\n input.complete &&\n input.isCurrent?.() !== false &&\n input.onFullyHydrated\n ) {\n await input.onFullyHydrated();\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { rebindsHeldContainer, } from "../../../data/containers/containerBinding.js";
2
- import { installContainerMetadataRecord } from "../metadataStateInstallation.js";
2
+ import { installContainerMetadataRecord } from "../metadata/metadataStateInstallation.js";
3
3
  /**
4
4
  * Apply a re-home verified from the session user's create or the pinned
5
5
  * founder's replacement authorization before hydration updates or inserts
@@ -1 +1 @@
1
- {"version":3,"file":"heldContainerRebind.js","sourceRoot":"","sources":["heldContainerRebind.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAO9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAM5C;IACC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC9D,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE;QACnE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACxB,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE;YACJ,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;YAC/C,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC;QACD,YAAY,EAAE,KAAK,CAAC,SAAS;KAC9B,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC5D,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,0BAA0B,CAC/D,OAAO,EACP,QAAQ,CAAC,EAAE,CACZ,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACnE,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IAC3C,aAAa,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,wBAAwB,GAAG,IAAI,CAAC;IAC9C,8BAA8B,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n type HeldContainerBinding,\n rebindsHeldContainer,\n} from \"../../../data/containers/containerBinding\";\nimport { installContainerMetadataRecord } from \"../metadataStateInstallation\";\nimport type {\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationState,\n} from \"./types\";\n\n/**\n * Apply a re-home verified from the session user's create or the pinned\n * founder's replacement authorization before hydration updates or inserts\n * the folder. Returns false when\n * the held binding changed underneath, leaving the listing unapplied.\n */\nexport async function rebindReHomedContainer(input: {\n existingState: ContainerState | undefined;\n heldBinding: HeldContainerBinding | null;\n isCurrent?: (() => boolean) | undefined;\n state: RemoteContainerHydrationState;\n verified: RemoteContainer;\n}): Promise<boolean> {\n const { existingState, heldBinding, state, verified } = input;\n if (!heldBinding || !rebindsHeldContainer(heldBinding, verified)) return true;\n const execSql = state.runtime.infra.execSql;\n const rebound = await state.persistence.rebindHeldContainer(execSql, {\n containerId: verified.id,\n expected: heldBinding,\n next: {\n metadataDocumentId: verified.metadataDocumentId,\n organizationId: verified.organizationId,\n },\n stillCurrent: input.isCurrent,\n });\n if (!rebound || input.isCurrent?.() === false) return false;\n if (!existingState) return true;\n const stored = await state.persistence.loadContainerMetadataState(\n execSql,\n verified.id,\n );\n if (!stored?.record || input.isCurrent?.() === false) return false;\n existingState.container = stored.container;\n existingState.containerWriterProjection = null;\n existingState.metadataWriterProjection = null;\n installContainerMetadataRecord(existingState, stored.record);\n return true;\n}\n"]}
1
+ {"version":3,"file":"heldContainerRebind.js","sourceRoot":"","sources":["heldContainerRebind.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAOvF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAM5C;IACC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC9D,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,CAAC,WAAW,EAAE,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE;QACnE,WAAW,EAAE,QAAQ,CAAC,EAAE;QACxB,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE;YACJ,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;YAC/C,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC;QACD,YAAY,EAAE,KAAK,CAAC,SAAS;KAC9B,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC5D,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,0BAA0B,CAC/D,OAAO,EACP,QAAQ,CAAC,EAAE,CACZ,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACnE,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IAC3C,aAAa,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAC/C,aAAa,CAAC,wBAAwB,GAAG,IAAI,CAAC;IAC9C,8BAA8B,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {\n type HeldContainerBinding,\n rebindsHeldContainer,\n} from \"../../../data/containers/containerBinding\";\nimport { installContainerMetadataRecord } from \"../metadata/metadataStateInstallation\";\nimport type {\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationState,\n} from \"./types\";\n\n/**\n * Apply a re-home verified from the session user's create or the pinned\n * founder's replacement authorization before hydration updates or inserts\n * the folder. Returns false when\n * the held binding changed underneath, leaving the listing unapplied.\n */\nexport async function rebindReHomedContainer(input: {\n existingState: ContainerState | undefined;\n heldBinding: HeldContainerBinding | null;\n isCurrent?: (() => boolean) | undefined;\n state: RemoteContainerHydrationState;\n verified: RemoteContainer;\n}): Promise<boolean> {\n const { existingState, heldBinding, state, verified } = input;\n if (!heldBinding || !rebindsHeldContainer(heldBinding, verified)) return true;\n const execSql = state.runtime.infra.execSql;\n const rebound = await state.persistence.rebindHeldContainer(execSql, {\n containerId: verified.id,\n expected: heldBinding,\n next: {\n metadataDocumentId: verified.metadataDocumentId,\n organizationId: verified.organizationId,\n },\n stillCurrent: input.isCurrent,\n });\n if (!rebound || input.isCurrent?.() === false) return false;\n if (!existingState) return true;\n const stored = await state.persistence.loadContainerMetadataState(\n execSql,\n verified.id,\n );\n if (!stored?.record || input.isCurrent?.() === false) return false;\n existingState.container = stored.container;\n existingState.containerWriterProjection = null;\n existingState.metadataWriterProjection = null;\n installContainerMetadataRecord(existingState, stored.record);\n return true;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { RemoteContainer, RemoteContainerHydrationHost, RemoteContainerHydrationState } from "./remoteHydration/types.js";
2
- export type { ContainerState, PersistContainerStateResult, RemoteContainer, RemoteContainerHydrationHost, } from "./remoteHydration/types.js";
1
+ import type { RemoteContainer, RemoteContainerHydrationHost, RemoteContainerHydrationState } from "./types.js";
2
+ export type { ContainerState, PersistContainerStateResult, RemoteContainer, RemoteContainerHydrationHost, } from "./types.js";
3
3
  export declare class StaleRemoteHydrationError extends Error {
4
4
  }
5
5
  export declare function createGenerationGuardedHydrationHost(input: {
@@ -1,10 +1,10 @@
1
- import { createRuntimePrincipalPolicyWarmer } from "../principals/runtimePolicyWarmer.js";
1
+ import { createRuntimePrincipalPolicyWarmer } from "../../principals/runtimePolicyWarmer.js";
2
+ import { createContainerChildIndex } from "./childIndex.js";
3
+ import { finishRemoteHydration } from "./completeHydration.js";
4
+ import { createContainerParentHydrationQueue } from "./parentLaneQueue.js";
5
+ import { cacheRemoteContainerPrincipalPolicies } from "./principalPolicyCache.js";
2
6
  import { canHydrateRemoteContainers, hydrateContainerParentLanes, } from "./remoteContainerPageHydration.js";
3
7
  import { listRemoteContainerIdsWithPendingMetadataUpdates, listRemoteContainerIdsWithPendingStructuralIntents, upsertIsolatedRemoteContainerState, } from "./remoteContainerState.js";
4
- import { createContainerChildIndex } from "./remoteHydration/childIndex.js";
5
- import { finishRemoteHydration } from "./remoteHydration/completeHydration.js";
6
- import { createContainerParentHydrationQueue } from "./remoteHydration/parentLaneQueue.js";
7
- import { cacheRemoteContainerPrincipalPolicies } from "./remoteHydration/principalPolicyCache.js";
8
8
  export class StaleRemoteHydrationError extends Error {
9
9
  }
10
10
  export function createGenerationGuardedHydrationHost(input) {
@@ -299,4 +299,4 @@ export async function hydrateRemoteContainers(input) {
299
299
  });
300
300
  return changedCount;
301
301
  }
302
- //# sourceMappingURL=remoteHydration.js.map
302
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gDAAgD,EAChD,kDAAkD,EAClD,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAgBhC,MAAM,OAAO,yBAA0B,SAAQ,KAAK;CAAG;AAEvD,MAAM,UAAU,oCAAoC,CAAC,KAGpD;IACC,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,MAAM,IAAI,yBAAyB,EAAE,CAAC;QACxC,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,qBAAqB,EAAE,KAAK,EAC1B,cAAc,EACd,KAAK,EACL,UAAU,EACV,WAAW,EACX,eAA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AI;QACJ,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,gBAAgB;QAChB,KAAK;KACN,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport { createContainerChildIndex } from \"./childIndex\";\nimport { finishRemoteHydration } from \"./completeHydration\";\nimport { createContainerParentHydrationQueue } from \"./parentLaneQueue\";\nimport { cacheRemoteContainerPrincipalPolicies } from \"./principalPolicyCache\";\nimport {\n canHydrateRemoteContainers,\n hydrateContainerParentLanes,\n} from \"./remoteContainerPageHydration\";\nimport {\n listRemoteContainerIdsWithPendingMetadataUpdates,\n listRemoteContainerIdsWithPendingStructuralIntents,\n upsertIsolatedRemoteContainerState,\n} from \"./remoteContainerState\";\nimport type {\n QueueContainerParentLane,\n RemoteContainer,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n RemoteContainerIngestQueue,\n} from \"./types\";\n\nexport type {\n ContainerState,\n PersistContainerStateResult,\n RemoteContainer,\n RemoteContainerHydrationHost,\n} from \"./types\";\n\nexport class StaleRemoteHydrationError extends Error {}\n\nexport function createGenerationGuardedHydrationHost(input: {\n host: RemoteContainerHydrationHost;\n isCurrent: () => boolean;\n}): RemoteContainerHydrationHost {\n const assertCurrent = () => {\n if (!input.isCurrent()) {\n throw new StaleRemoteHydrationError();\n }\n };\n\n return {\n persistContainerState: async (\n containerState,\n patch,\n updateView,\n saveOptions,\n mutationOptions,\n ) => {\n const callerIsCurrent = mutationOptions?.isCurrent;\n const isCurrent = callerIsCurrent\n ? () => input.isCurrent() && callerIsCurrent()\n : input.isCurrent;\n assertCurrent();\n const record = await input.host.persistContainerState(\n containerState,\n patch,\n updateView,\n saveOptions,\n { ...mutationOptions, isCurrent },\n );\n assertCurrent();\n return record;\n },\n ...(input.host.requestDocumentPriming\n ? {\n requestDocumentPriming: () => {\n if (input.isCurrent()) {\n input.host.requestDocumentPriming?.();\n }\n },\n }\n : {}),\n updateSnapshot: () => {\n if (input.isCurrent()) {\n input.host.updateSnapshot();\n }\n },\n };\n}\n\ninterface RemoteContainerIngestGeneration {\n readonly lifecycle: number | undefined;\n readonly structural: number | undefined;\n}\ntype RemoteContainerIngestGenerationMap = Map<\n string,\n RemoteContainerIngestGeneration\n>;\n\nfunction remoteContainerIngestGeneration(\n state: RemoteContainerHydrationState,\n): RemoteContainerIngestGeneration {\n return {\n lifecycle: state.lifecycleGeneration,\n structural: state.structuralGeneration,\n };\n}\n\nfunction remoteContainerIngestGenerationsMatch(\n left: RemoteContainerIngestGeneration | undefined,\n right: RemoteContainerIngestGeneration,\n): boolean {\n return (\n left !== undefined &&\n left.lifecycle === right.lifecycle &&\n left.structural === right.structural\n );\n}\n\nfunction isCurrentQueuedRemoteContainer(\n generation: RemoteContainerIngestGeneration,\n generationByContainerId: RemoteContainerIngestGenerationMap,\n queue: RemoteContainerIngestQueue,\n remoteContainer: RemoteContainer,\n): boolean {\n return (\n queue.get(remoteContainer.id) === remoteContainer &&\n remoteContainerIngestGenerationsMatch(\n generationByContainerId.get(remoteContainer.id),\n generation,\n )\n );\n}\n\nasync function upsertQueuedRemoteContainer(input: {\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n containerIdsWithPendingStructuralIntents: ReadonlySet<string>;\n generation: RemoteContainerIngestGeneration;\n generationByContainerId: RemoteContainerIngestGenerationMap;\n host: RemoteContainerHydrationHost;\n isCurrent: () => boolean;\n queue: RemoteContainerIngestQueue;\n queuedRemoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}): Promise<boolean> {\n const {\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n generation,\n generationByContainerId,\n host,\n queue,\n queuedRemoteContainer,\n state,\n } = input;\n if (\n !input.isCurrent() ||\n !isCurrentQueuedRemoteContainer(\n generation,\n generationByContainerId,\n queue,\n queuedRemoteContainer,\n )\n ) {\n return false;\n }\n\n const tombstones = await state.persistence.loadContainerHydrationTombstones(\n state.runtime.infra.execSql,\n );\n // A refused folder is reported and acknowledged; the batch continues.\n const upserted = await upsertIsolatedRemoteContainerState({\n expectedHydrationTombstone:\n tombstones.find((row) => row.containerId === queuedRemoteContainer.id) ??\n null,\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n host,\n isCurrent: input.isCurrent,\n remoteContainer: queuedRemoteContainer,\n state,\n });\n if (!upserted) {\n return false;\n }\n return true;\n}\n\nfunction acknowledgeRemoteContainerIngestBatch(input: {\n generation: RemoteContainerIngestGeneration;\n generationByContainerId: RemoteContainerIngestGenerationMap;\n isCurrent: () => boolean;\n queue: RemoteContainerIngestQueue;\n queuedRemoteContainers: ReadonlyArray<RemoteContainer>;\n}): void {\n if (!input.isCurrent()) {\n return;\n }\n for (const queuedRemoteContainer of input.queuedRemoteContainers) {\n if (\n isCurrentQueuedRemoteContainer(\n input.generation,\n input.generationByContainerId,\n input.queue,\n queuedRemoteContainer,\n )\n ) {\n input.queue.delete(queuedRemoteContainer.id);\n input.generationByContainerId.delete(queuedRemoteContainer.id);\n }\n }\n}\n\nasync function drainRemoteContainerIngestQueue(input: {\n generation: RemoteContainerIngestGeneration;\n generationByContainerId: RemoteContainerIngestGenerationMap;\n host: RemoteContainerHydrationHost;\n isCurrent: () => boolean;\n queue: RemoteContainerIngestQueue;\n state: RemoteContainerHydrationState;\n}) {\n const { generation, generationByContainerId, host, queue, state } = input;\n let shouldUpdateSnapshot = false;\n\n try {\n while (input.isCurrent()) {\n const queuedRemoteContainers = Array.from(queue.values()).filter(\n (remoteContainer) =>\n remoteContainerIngestGenerationsMatch(\n generationByContainerId.get(remoteContainer.id),\n generation,\n ),\n );\n if (queuedRemoteContainers.length === 0) {\n return;\n }\n await cacheRemoteContainerPrincipalPolicies({\n cacheReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n state.runtime,\n ),\n remoteContainers: queuedRemoteContainers,\n stillCurrent: input.isCurrent,\n });\n if (!input.isCurrent()) {\n return;\n }\n const [\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n ] = await Promise.all([\n listRemoteContainerIdsWithPendingMetadataUpdates({\n remoteContainers: queuedRemoteContainers,\n state,\n }),\n listRemoteContainerIdsWithPendingStructuralIntents({\n remoteContainers: queuedRemoteContainers,\n state,\n }),\n ]);\n if (!input.isCurrent()) {\n return;\n }\n\n for (const queuedRemoteContainer of queuedRemoteContainers) {\n shouldUpdateSnapshot =\n (await upsertQueuedRemoteContainer({\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n generation,\n generationByContainerId,\n host,\n isCurrent: input.isCurrent,\n queue,\n queuedRemoteContainer,\n state,\n })) || shouldUpdateSnapshot;\n }\n acknowledgeRemoteContainerIngestBatch({\n generation,\n generationByContainerId,\n isCurrent: input.isCurrent,\n queue,\n queuedRemoteContainers,\n });\n\n if (shouldUpdateSnapshot) {\n host.updateSnapshot();\n shouldUpdateSnapshot = false;\n }\n }\n } catch (error) {\n if (shouldUpdateSnapshot) {\n host.updateSnapshot();\n }\n throw error;\n }\n}\n\nfunction isRemoteContainerIngestGenerationCurrent(\n state: RemoteContainerHydrationState,\n generation: RemoteContainerIngestGeneration,\n): boolean {\n return remoteContainerIngestGenerationsMatch(\n remoteContainerIngestGeneration(state),\n generation,\n );\n}\n\nfunction settleStaleRemoteContainerIngestGeneration(input: {\n generation: RemoteContainerIngestGeneration;\n generationByContainerId: RemoteContainerIngestGenerationMap;\n queue: RemoteContainerIngestQueue;\n state: RemoteContainerHydrationState;\n}): void {\n const currentGeneration = remoteContainerIngestGeneration(input.state);\n const shouldReplay =\n currentGeneration.lifecycle !== input.generation.lifecycle &&\n currentGeneration.structural === input.generation.structural;\n for (const [containerId, generation] of input.generationByContainerId) {\n if (!remoteContainerIngestGenerationsMatch(generation, input.generation)) {\n continue;\n }\n if (shouldReplay) {\n input.generationByContainerId.set(containerId, currentGeneration);\n } else {\n input.generationByContainerId.delete(containerId);\n input.queue.delete(containerId);\n }\n }\n}\n\ninterface RemoteContainerIngestor {\n (remoteContainer: RemoteContainer): Promise<void>;\n hasPending: () => boolean;\n resume: () => Promise<void>;\n}\n\nexport function createRemoteContainerIngestor(input: {\n getSerializationBarrier?: (() => Promise<void> | null) | undefined;\n host: RemoteContainerHydrationHost;\n state: RemoteContainerHydrationState;\n}): RemoteContainerIngestor {\n const { host, state } = input;\n const pendingRemoteContainersById: RemoteContainerIngestQueue = new Map();\n const generationByContainerId: RemoteContainerIngestGenerationMap = new Map();\n let ingestRemoteContainersPromise: Promise<void> | null = null;\n\n const runNextGeneration = (): Promise<void> => {\n if (ingestRemoteContainersPromise) {\n return ingestRemoteContainersPromise.then(\n runNextGeneration,\n runNextGeneration,\n );\n }\n if (\n state.runtime.infra.dbStatus !== undefined &&\n state.runtime.infra.dbStatus !== \"ready\"\n ) {\n return Promise.resolve();\n }\n const serializationBarrier = input.getSerializationBarrier?.();\n if (serializationBarrier) {\n return serializationBarrier.then(runNextGeneration);\n }\n const nextContainerId = pendingRemoteContainersById.keys().next().value;\n if (typeof nextContainerId !== \"string\") {\n return Promise.resolve();\n }\n const generation = generationByContainerId.get(nextContainerId);\n if (!generation) {\n pendingRemoteContainersById.delete(nextContainerId);\n return runNextGeneration();\n }\n const isCurrent = () =>\n isRemoteContainerIngestGenerationCurrent(state, generation);\n const guardedHost = createGenerationGuardedHydrationHost({\n host,\n isCurrent,\n });\n const nextPromise = Promise.resolve()\n .then(() =>\n drainRemoteContainerIngestQueue({\n generation,\n generationByContainerId,\n host: guardedHost,\n isCurrent,\n queue: pendingRemoteContainersById,\n state,\n }),\n )\n .then(() => {\n if (!isCurrent()) {\n settleStaleRemoteContainerIngestGeneration({\n generation,\n generationByContainerId,\n queue: pendingRemoteContainersById,\n state,\n });\n }\n })\n .catch((error: unknown) => {\n if (!isCurrent() || error instanceof StaleRemoteHydrationError) {\n settleStaleRemoteContainerIngestGeneration({\n generation,\n generationByContainerId,\n queue: pendingRemoteContainersById,\n state,\n });\n return;\n }\n throw error;\n })\n .finally(() => {\n if (ingestRemoteContainersPromise === nextPromise) {\n ingestRemoteContainersPromise = null;\n }\n });\n ingestRemoteContainersPromise = nextPromise;\n return nextPromise.then(() =>\n pendingRemoteContainersById.size > 0 ? runNextGeneration() : undefined,\n );\n };\n\n const ingestRemoteContainer = (remoteContainer: RemoteContainer) => {\n pendingRemoteContainersById.set(remoteContainer.id, remoteContainer);\n generationByContainerId.set(\n remoteContainer.id,\n remoteContainerIngestGeneration(state),\n );\n return runNextGeneration();\n };\n ingestRemoteContainer.hasPending = () => pendingRemoteContainersById.size > 0;\n ingestRemoteContainer.resume = runNextGeneration;\n return ingestRemoteContainer;\n}\n\nexport async function hydrateRemoteContainers(input: {\n followDiscoveredParentLanes?: boolean | undefined;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n state: RemoteContainerHydrationState;\n}): Promise<number> {\n const { host, state } = input;\n if (!canHydrateRemoteContainers(state) || input.isCurrent?.() === false) {\n return 0;\n }\n\n const seenContainerIds = new Set<string>();\n const containerIdsBeforeHydration = new Set(state.containersById.keys());\n const childIdsByParentId = createContainerChildIndex(state.containersById);\n const { lanes, queueParentLane } = createContainerParentHydrationQueue({\n containerIds: state.containersById.keys(),\n parentIds: input.parentIds,\n resetAllLaneWatermarks: input.resetAllLaneWatermarks,\n resetRootLaneWatermark: input.resetRootLaneWatermark,\n });\n // Follow child lanes during an explicit recursive crawl or for containers first\n // discovered in this pass. The latter lets a newly authorized root populate its\n // descendants immediately, while routine ticks keep known subtrees cache-first.\n const queueDiscoveredParentLane: QueueContainerParentLane = (containerId) => {\n if (\n input.followDiscoveredParentLanes ||\n (containerId !== null && !containerIdsBeforeHydration.has(containerId))\n ) {\n queueParentLane(containerId);\n }\n };\n const result = await hydrateContainerParentLanes({\n childIdsByParentId,\n host,\n isCurrent: input.isCurrent,\n lanes,\n queueParentLane: queueDiscoveredParentLane,\n seenContainerIds,\n state,\n });\n const { changedCount } = result;\n await finishRemoteHydration({\n changedCount,\n complete:\n result.complete &&\n canHydrateRemoteContainers(state) &&\n input.isCurrent?.() !== false,\n containerIdsBeforeHydration,\n host,\n isCurrent: input.isCurrent,\n onFullyHydrated: input.onFullyHydrated,\n seenContainerIds,\n state,\n });\n return changedCount;\n}\n"]}
@@ -1,12 +1,12 @@
1
- import { createRuntimePrincipalPolicyWarmer } from "../principals/runtimePolicyWarmer.js";
1
+ import { createRuntimePrincipalPolicyWarmer } from "../../principals/runtimePolicyWarmer.js";
2
+ import { containerStateMatchesFingerprint } from "./containerStateFingerprint.js";
3
+ import { prefetchDestinationProjections } from "./destinationPrefetch.js";
4
+ import { cachedDestinationRole } from "./destinationRoleCache.js";
5
+ import { markContainerParentLaneFetched } from "./laneFetchMarkers.js";
6
+ import { fetchContainerParentLaneBatch } from "./parentLaneFetch.js";
7
+ import { cacheRemoteContainerPrincipalPolicies } from "./principalPolicyCache.js";
2
8
  import { listRemoteContainerIdsWithPendingMetadataUpdates, listRemoteContainerIdsWithPendingStructuralIntents, upsertIsolatedRemoteContainerState, } from "./remoteContainerState.js";
3
- import { containerStateMatchesFingerprint } from "./remoteHydration/containerStateFingerprint.js";
4
- import { prefetchDestinationProjections } from "./remoteHydration/destinationPrefetch.js";
5
- import { cachedDestinationRole } from "./remoteHydration/destinationRoleCache.js";
6
- import { markContainerParentLaneFetched } from "./remoteHydration/laneFetchMarkers.js";
7
- import { fetchContainerParentLaneBatch } from "./remoteHydration/parentLaneFetch.js";
8
- import { cacheRemoteContainerPrincipalPolicies } from "./remoteHydration/principalPolicyCache.js";
9
- import { applyContainerTombstones, getApplicableRemoteContainerItems, } from "./remoteHydration/tombstoneApplication.js";
9
+ import { applyContainerTombstones, getApplicableRemoteContainerItems, } from "./tombstoneApplication.js";
10
10
  const CONTAINER_PARENT_HYDRATION_CONCURRENCY = 4;
11
11
  async function applyRemoteContainerPage(input) {
12
12
  const { childIdsByParentId, expectedContainerStates, expectedHydrationTombstones, host, items, queueParentLane, seenContainerIds, state, } = input;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteContainerPageHydration.js","sourceRoot":"","sources":["remoteContainerPageHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,qCAAqC,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,gDAAgD,EAChD,kDAAkD,EAClD,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,wBAAwB,CAAC;AAYhC,MAAM,sCAAsC,GAAG,CAAC,CAAC;AAOjD,KAAK,UAAU,wBAAwB,CAAC,KAUvC;IACC,MAAM,EACJ,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC3B,IAAI,EACJ,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,GACN,GAAG,KAAK,CAAC;IACV,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,aAAa,GAAG,IAAI,CAAC;IACzB,MAAM,qCAAqC,CAAC;QAC1C,gCAAgC,EAAE,kCAAkC,CAClE,KAAK,CAAC,OAAO,CACd;QACD,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK,CAA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,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import { createRuntimePrincipalPolicyWarmer } from \"../../principals/runtimePolicyWarmer\";\nimport { containerStateMatchesFingerprint } from \"./containerStateFingerprint\";\nimport { prefetchDestinationProjections } from \"./destinationPrefetch\";\nimport { cachedDestinationRole } from \"./destinationRoleCache\";\nimport { markContainerParentLaneFetched } from \"./laneFetchMarkers\";\nimport { fetchContainerParentLaneBatch } from \"./parentLaneFetch\";\nimport { cacheRemoteContainerPrincipalPolicies } from \"./principalPolicyCache\";\nimport {\n listRemoteContainerIdsWithPendingMetadataUpdates,\n listRemoteContainerIdsWithPendingStructuralIntents,\n upsertIsolatedRemoteContainerState,\n} from \"./remoteContainerState\";\nimport {\n applyContainerTombstones,\n getApplicableRemoteContainerItems,\n} from \"./tombstoneApplication\";\nimport type {\n ContainerChildIndex,\n ContainerParentHydrationLane,\n ExpectedContainerState,\n FetchedContainerParentLanePage,\n ListedRemoteContainerPageItem,\n QueueContainerParentLane,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nconst CONTAINER_PARENT_HYDRATION_CONCURRENCY = 4;\n\ninterface HydrationProgress {\n changedCount: number;\n complete: boolean;\n shouldStop: boolean;\n}\nasync function applyRemoteContainerPage(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n expectedHydrationTombstones: FetchedContainerParentLanePage[\"expectedHydrationTombstones\"];\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n items: ReadonlyArray<ListedRemoteContainerPageItem>;\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<{ changedCount: number; completed: boolean }> {\n const {\n childIdsByParentId,\n expectedContainerStates,\n expectedHydrationTombstones,\n host,\n items,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let hydratedCount = 0;\n let pageCompleted = true;\n await cacheRemoteContainerPrincipalPolicies({\n cacheReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n state.runtime,\n ),\n remoteContainers: items,\n stillCurrent: input.isCurrent,\n });\n if (input.isCurrent?.() === false) {\n return { changedCount: 0, completed: false };\n }\n const [\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n ] = await Promise.all([\n listRemoteContainerIdsWithPendingMetadataUpdates({\n remoteContainers: items,\n state,\n }),\n listRemoteContainerIdsWithPendingStructuralIntents({\n remoteContainers: items,\n state,\n }),\n ]);\n if (input.isCurrent?.() === false) {\n return { changedCount: 0, completed: false };\n }\n const prefetchedProjections = await prefetchDestinationProjections({\n containerIds: items.flatMap((item) =>\n seenContainerIds.has(item.id) ||\n state.containersById.has(item.id) ||\n expectedHydrationTombstones.get(item.id) ||\n cachedDestinationRole(state.runtime.infra.execSql, item)\n ? []\n : [item.id],\n ),\n isCurrent: input.isCurrent,\n runtime: state.runtime,\n });\n for (const container of items) {\n if (input.isCurrent?.() === false) {\n return { changedCount: hydratedCount, completed: false };\n }\n if (!seenContainerIds.has(container.id)) {\n if (\n !containerStateMatchesFingerprint({\n currentState: state.containersById.get(container.id),\n expectedFingerprint: expectedContainerStates.get(container.id)\n ?.fingerprint,\n })\n ) {\n pageCompleted = false;\n continue;\n }\n const upserted = await upsertIsolatedRemoteContainerState({\n childIdsByParentId,\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n host,\n isCurrent: input.isCurrent,\n expectedHydrationTombstone:\n expectedHydrationTombstones.get(container.id) ?? null,\n prefetchedProjection: prefetchedProjections.get(container.id),\n remoteContainer: container,\n state,\n });\n if (!upserted) {\n pageCompleted = false;\n continue;\n }\n seenContainerIds.add(container.id);\n hydratedCount += 1;\n if (input.isCurrent?.() === false) {\n return { changedCount: hydratedCount, completed: false };\n }\n }\n queueParentLane(container.id);\n }\n\n return { changedCount: hydratedCount, completed: pageCompleted };\n}\n\nexport function canHydrateRemoteContainers(\n state: RemoteContainerHydrationState,\n): boolean {\n return (\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online &&\n state.runtime.infra.dbStatus === \"ready\"\n );\n}\n\nasync function applyContainerParentLanePage(input: {\n childIdsByParentId: ContainerChildIndex;\n fetchedPage: FetchedContainerParentLanePage;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n queueContinuationLane: (lane: ContainerParentHydrationLane) => void;\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n fetchedPage,\n host,\n queueContinuationLane,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n const {\n expectedContainerStates,\n expectedHydrationTombstones,\n lane,\n response,\n syncLane,\n } = fetchedPage;\n let changedCount = 0;\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const remoteContainerItems = getApplicableRemoteContainerItems(response);\n const tombstoneResult = await applyContainerTombstones({\n childIdsByParentId,\n expectedContainerStates,\n isCurrent: input.isCurrent,\n remoteContainerItems,\n response,\n state,\n });\n if (!tombstoneResult.current) {\n return { changedCount, complete: false, shouldStop: true };\n }\n changedCount += tombstoneResult.changedCount;\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (tombstoneResult.changedCount > 0) {\n // A live tombstone cascade may have orphaned documents (row 3); re-arm\n // document priming so their null-scoped passes run now rather than on\n // the next startup.\n host.requestDocumentPriming?.();\n }\n\n const appliedPage = await applyRemoteContainerPage({\n childIdsByParentId,\n expectedContainerStates,\n expectedHydrationTombstones,\n host,\n isCurrent: input.isCurrent,\n items: remoteContainerItems,\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += appliedPage.changedCount;\n if (!tombstoneResult.completed || !appliedPage.completed) {\n // Keep this page retryable without discarding independent lanes, including\n // children of roots first discovered here. Otherwise the root becomes known\n // but its children are never fetched by subsequent root-only refreshes.\n return { changedCount, complete: false, shouldStop: false };\n }\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const didMarkFetched = await markContainerParentLaneFetched({\n isCurrent: input.isCurrent,\n response,\n state,\n syncLane,\n });\n if (!didMarkFetched) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n if (!response.hasMore) {\n return { changedCount, complete: true, shouldStop: false };\n }\n if (!response.nextWatermark) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n queueContinuationLane({\n parentId: lane.parentId,\n watermark: response.nextWatermark,\n });\n return { changedCount, complete: true, shouldStop: false };\n}\n\nfunction takeContainerParentLaneBatch(input: {\n lanes: ContainerParentHydrationLane[];\n state: RemoteContainerHydrationState;\n}): ContainerParentHydrationLane[] {\n const { lanes, state } = input;\n const batch: ContainerParentHydrationLane[] = [];\n\n while (\n lanes.length > 0 &&\n batch.length < CONTAINER_PARENT_HYDRATION_CONCURRENCY\n ) {\n const lane = lanes.shift();\n if (\n lane &&\n (lane.parentId === null || state.containersById.has(lane.parentId))\n ) {\n batch.push(lane);\n }\n }\n\n return batch;\n}\n\nasync function applyContainerParentLaneBatch(input: {\n childIdsByParentId: ContainerChildIndex;\n fetchedPages: ReadonlyArray<FetchedContainerParentLanePage>;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n lanes: ContainerParentHydrationLane[];\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n fetchedPages,\n host,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let changedCount = 0;\n let complete = true;\n\n for (const fetchedPage of fetchedPages) {\n if (!canHydrateRemoteContainers(state) || input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (\n fetchedPage.lane.parentId !== null &&\n !state.containersById.has(fetchedPage.lane.parentId)\n ) {\n continue;\n }\n\n const result = await applyContainerParentLanePage({\n childIdsByParentId,\n fetchedPage,\n host,\n isCurrent: input.isCurrent,\n queueContinuationLane: (lane) => lanes.push(lane),\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += result.changedCount;\n complete &&= result.complete;\n\n if (result.shouldStop) {\n return { changedCount, complete: false, shouldStop: true };\n }\n }\n\n return { changedCount, complete, shouldStop: false };\n}\n\nexport async function hydrateContainerParentLanes(input: {\n childIdsByParentId: ContainerChildIndex;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n lanes: ContainerParentHydrationLane[];\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n host,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let changedCount = 0;\n let complete = true;\n\n while (lanes.length > 0) {\n if (!canHydrateRemoteContainers(state) || input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const batch = takeContainerParentLaneBatch({ lanes, state });\n if (batch.length === 0) {\n continue;\n }\n\n const fetchedPages = await fetchContainerParentLaneBatch({\n batch,\n isCurrent: input.isCurrent,\n state,\n });\n if (!fetchedPages) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const result = await applyContainerParentLaneBatch({\n childIdsByParentId,\n fetchedPages,\n host,\n isCurrent: input.isCurrent,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += result.changedCount;\n complete &&= result.complete;\n\n if (result.shouldStop) {\n return { changedCount, complete: false, shouldStop: true };\n }\n }\n\n return { changedCount, complete, shouldStop: false };\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { heldContainerBinding, listingRepeatsHeldOrdinaryBinding, } from "../../data/containers/containerBinding.js";
2
- import { isKeyingVerificationError, runWithSecurityIncidentReporting, } from "../../data/keyingProjectionVerification/error.js";
3
- import { isProjectionVerificationCancelledError } from "../../data/keyingProjectionVerification/types.js";
4
- import { installContainerMetadataRecord } from "./metadataPersistence.js";
5
- import { projectionGeneration } from "./projectionGeneration.js";
6
- import { moveIndexedContainerChild, removeIndexedContainerChild, } from "./remoteHydration/childIndex.js";
7
- import { rebindReHomedContainer } from "./remoteHydration/heldContainerRebind.js";
8
- import { insertRemoteContainerState } from "./remoteHydration/insertRemoteContainer.js";
9
- import { reconcileLocalOnlyRootContainers, reconcileLocalOnlySystemContainers, } from "./remoteHydration/reconciliation.js";
10
- import { applyRemoteContainerTimestamps, remoteContainerHydrationSaveOptions, resolveRemoteContainerHydrationLocalUpdatedAt, } from "./remoteHydration/remoteContainerTimestamps.js";
11
- import { verifyRemoteContainerDestination } from "./remoteHydration/verifiedDestination.js";
1
+ import { heldContainerBinding, listingRepeatsHeldOrdinaryBinding, } from "../../../data/containers/containerBinding.js";
2
+ import { isKeyingVerificationError, runWithSecurityIncidentReporting, } from "../../../data/keyingProjectionVerification/error.js";
3
+ import { isProjectionVerificationCancelledError } from "../../../data/keyingProjectionVerification/types.js";
4
+ import { installContainerMetadataRecord } from "../metadata/metadataPersistence.js";
5
+ import { projectionGeneration } from "../projectionGeneration.js";
6
+ import { moveIndexedContainerChild, removeIndexedContainerChild, } from "./childIndex.js";
7
+ import { rebindReHomedContainer } from "./heldContainerRebind.js";
8
+ import { insertRemoteContainerState } from "./insertRemoteContainer.js";
9
+ import { reconcileLocalOnlyRootContainers, reconcileLocalOnlySystemContainers, } from "./reconciliation.js";
10
+ import { applyRemoteContainerTimestamps, remoteContainerHydrationSaveOptions, resolveRemoteContainerHydrationLocalUpdatedAt, } from "./remoteContainerTimestamps.js";
11
+ import { verifyRemoteContainerDestination } from "./verifiedDestination.js";
12
12
  // Container ids (restricted to the inbound page) that carry an unsynced local
13
13
  // create or move intent. Such a container's parent and local-edit timestamp are
14
14
  // owned by its structural-intent lane until that lane reconciles, so inbound
@@ -0,0 +1 @@
1
+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C;QACJ,CAAC,CAAC,0BAA0B,CAAC;YACzB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,IAAI,IAAI;YACpE,2BAA2B;YAC3B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type { AccessManifestCheckpoint } from \"@tearleads/crypto\";\nimport {\n heldContainerBinding,\n listingRepeatsHeldOrdinaryBinding,\n} from \"../../../data/containers/containerBinding\";\nimport {\n isKeyingVerificationError,\n runWithSecurityIncidentReporting,\n} from \"../../../data/keyingProjectionVerification/error\";\nimport { isProjectionVerificationCancelledError } from \"../../../data/keyingProjectionVerification/types\";\nimport type { ContainerHydrationTombstone } from \"../containerPersistence\";\nimport { installContainerMetadataRecord } from \"../metadata/metadataPersistence\";\nimport { projectionGeneration } from \"../projectionGeneration\";\nimport {\n moveIndexedContainerChild,\n removeIndexedContainerChild,\n} from \"./childIndex\";\nimport type { PrefetchedDestinationProjection } from \"./destinationPrefetch\";\nimport { rebindReHomedContainer } from \"./heldContainerRebind\";\nimport { insertRemoteContainerState } from \"./insertRemoteContainer\";\nimport {\n reconcileLocalOnlyRootContainers,\n reconcileLocalOnlySystemContainers,\n} from \"./reconciliation\";\nimport {\n applyRemoteContainerTimestamps,\n remoteContainerHydrationSaveOptions,\n resolveRemoteContainerHydrationLocalUpdatedAt,\n} from \"./remoteContainerTimestamps\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"./types\";\nimport { verifyRemoteContainerDestination } from \"./verifiedDestination\";\n\n// Container ids (restricted to the inbound page) that carry an unsynced local\n// create or move intent. Such a container's parent and local-edit timestamp are\n// owned by its structural-intent lane until that lane reconciles, so inbound\n// hydration must not revert parentId to the server value nor collapse\n// localUpdatedAt — doing so silently undoes a queued move and falsely reads\n// \"synced\". Move intents are read via listUnsyncedMoveIntents so a blocked\n// move — one whose destination parent has not synced yet, the common boot-time\n// case — is protected too. Pending *metadata*\n// updates are handled separately (listRemoteContainerIdsWithPendingMetadataUpdates);\n// structural intents live in the local outbox's container lanes, which that\n// query does not cover.\nexport async function listRemoteContainerIdsWithPendingStructuralIntents(input: {\n remoteContainers: ReadonlyArray<RemoteContainer>;\n state: RemoteContainerHydrationState;\n}): Promise<Set<string>> {\n if (input.remoteContainers.length === 0) {\n return new Set();\n }\n const remoteContainerIds = new Set(\n input.remoteContainers.map((remoteContainer) => remoteContainer.id),\n );\n\n const execSql = input.state.runtime.infra.execSql;\n const [pendingCreateIntents, unsyncedMoveIntents] = await Promise.all([\n input.state.persistence.listPendingCreateIntents(execSql),\n input.state.persistence.listUnsyncedMoveIntents(execSql),\n ]);\n const containerIdsWithPendingStructuralIntents = new Set<string>();\n for (const intent of pendingCreateIntents) {\n if (remoteContainerIds.has(intent.containerId)) {\n containerIdsWithPendingStructuralIntents.add(intent.containerId);\n }\n }\n for (const intent of unsyncedMoveIntents) {\n if (remoteContainerIds.has(intent.containerId)) {\n containerIdsWithPendingStructuralIntents.add(intent.containerId);\n }\n }\n return containerIdsWithPendingStructuralIntents;\n}\n\nexport async function listRemoteContainerIdsWithPendingMetadataUpdates(input: {\n remoteContainers: ReadonlyArray<RemoteContainer>;\n state: RemoteContainerHydrationState;\n}): Promise<Set<string>> {\n const containerIds = input.remoteContainers.flatMap((remoteContainer) => {\n const previousLocalUpdatedAt = input.state.containersById.get(\n remoteContainer.id,\n )?.container.localUpdatedAt;\n\n return previousLocalUpdatedAt &&\n previousLocalUpdatedAt.localeCompare(remoteContainer.updatedAt) > 0\n ? [remoteContainer.id]\n : [];\n });\n if (containerIds.length === 0) {\n return new Set();\n }\n\n const execSql = input.state.runtime.infra.execSql;\n return new Set(\n await input.state.persistence.listContainerIdsWithPendingUpdates(\n execSql,\n containerIds,\n ),\n );\n}\n\nfunction removeMissingHydratedContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n existingState: ContainerState;\n host: RemoteContainerHydrationHost;\n previousParentId: string | null;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}): void {\n const { existingState, remoteContainer, state } = input;\n if (state.containersById.get(remoteContainer.id) !== existingState) {\n return;\n }\n\n state.containersById.delete(remoteContainer.id);\n if (input.childIdsByParentId) {\n removeIndexedContainerChild(\n input.childIdsByParentId,\n remoteContainer.id,\n input.previousParentId,\n );\n input.childIdsByParentId.delete(remoteContainer.id);\n }\n input.host.updateSnapshot();\n}\n\nfunction createUpdatedRemoteContainerState(\n existingState: ContainerState,\n remoteContainer: RemoteContainer,\n): ContainerState {\n return {\n ...existingState,\n container: applyRemoteContainerTimestamps(\n existingState.container,\n remoteContainer,\n ),\n containerWriterProjection: null,\n metadataReferencedPrincipals: remoteContainer.metadataReferencedPrincipals,\n };\n}\n\nfunction installUpdatedRemoteContainerState(\n existingState: ContainerState,\n nextState: ContainerState,\n host: RemoteContainerHydrationHost,\n): void {\n const wasLocalOnly = existingState.container.serverCreatedAt == null;\n existingState.container = nextState.container;\n existingState.containerWriterProjection = nextState.containerWriterProjection;\n existingState.metadataReferencedPrincipals =\n nextState.metadataReferencedPrincipals;\n // The snapshot copied the live generation when it was taken; a hint that\n // landed during the persist leaves the live metadata projection dropped.\n if (projectionGeneration(existingState) === projectionGeneration(nextState))\n existingState.metadataWriterProjection = nextState.metadataWriterProjection;\n installContainerMetadataRecord(existingState, nextState.record);\n // A document pass may have deferred while this root was awaiting proof.\n // The first durable remote acknowledgement makes its pending creates runnable.\n if (wasLocalOnly && existingState.container.serverCreatedAt != null)\n host.requestDocumentPriming?.();\n}\n\nasync function updateExistingRemoteContainerState(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n containerIdsWithPendingStructuralIntents: ReadonlySet<string>;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n existingState: ContainerState;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}): Promise<ContainerState | null> {\n const { childIdsByParentId, existingState, host, remoteContainer, state } =\n input;\n const previousParentId = existingState.container.parentId;\n const previousLocalUpdatedAt = existingState.container.localUpdatedAt;\n // A queued, not-yet-synced local move/create owns this container's parent\n // until its intent lane reconciles. Omit the remote parent when the page scan\n // saw one; persistence also rechecks the intent transactionally so a move\n // created after that scan wins. Both paths preserve the durable local clock.\n const hasPendingStructuralIntent =\n input.containerIdsWithPendingStructuralIntents.has(remoteContainer.id);\n const nextParentId = hasPendingStructuralIntent\n ? undefined\n : remoteContainer.parentId;\n const localUpdatedAt = resolveRemoteContainerHydrationLocalUpdatedAt({\n containerIdsWithPendingMetadataUpdates:\n input.containerIdsWithPendingMetadataUpdates,\n hasPendingStructuralIntent,\n previousLocalUpdatedAt,\n remoteContainer,\n });\n const nextState = createUpdatedRemoteContainerState(\n existingState,\n remoteContainer,\n );\n const persistenceResult = await host.persistContainerState(\n nextState,\n {\n accessEpoch: remoteContainer.metadataAccessEpoch,\n accessStateHash: remoteContainer.metadataAccessStateHash,\n documentId: remoteContainer.metadataDocumentId,\n effectiveAccessLevel: remoteContainer.effectiveAccessLevel,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n systemSlot: remoteContainer.systemSlot ?? null,\n organizationId: remoteContainer.organizationId,\n ...(nextParentId !== undefined ? { parentId: nextParentId } : {}),\n },\n false,\n remoteContainerHydrationSaveOptions({\n localUpdatedAt,\n remoteContainer,\n }),\n {\n preserveDurableStructureWhenPending: true,\n },\n );\n if (persistenceResult.status === \"missing\") {\n // Hydration persists a detached candidate so an in-flight response cannot\n // mutate mapped state before its guards settle. Retire the exact state this\n // hydration read because store-level reference cleanup cannot see the clone.\n removeMissingHydratedContainer({\n childIdsByParentId,\n existingState,\n host,\n previousParentId,\n remoteContainer,\n state,\n });\n return null;\n }\n if (persistenceResult.status !== \"persisted\") return null;\n const { record: nextRecord } = persistenceResult;\n installContainerMetadataRecord(nextState, nextRecord);\n if (input.isCurrent?.() === false) {\n return existingState;\n }\n nextState.container = {\n ...nextState.container,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n organizationId: remoteContainer.organizationId,\n parentId: nextState.container.parentId,\n };\n\n installUpdatedRemoteContainerState(existingState, nextState, host);\n moveIndexedContainerChild(\n childIdsByParentId,\n remoteContainer.id,\n previousParentId,\n existingState.container.parentId,\n );\n await reconcileLocalOnlyRootContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteRootState: existingState,\n requestDocumentPriming: host.requestDocumentPriming,\n state,\n });\n return existingState;\n}\n\ninterface UpsertRemoteContainerStateInput {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n containerIdsWithPendingStructuralIntents: ReadonlySet<string>;\n host: RemoteContainerHydrationHost;\n expectedHydrationTombstone?: ContainerHydrationTombstone | null | undefined;\n isCurrent?: (() => boolean) | undefined;\n prefetchedProjection?: PrefetchedDestinationProjection | undefined;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}\n\nexport async function upsertRemoteContainerState(\n input: UpsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n let expectedPlacementCheckpoint: AccessManifestCheckpoint | undefined;\n const heldState = input.state.containersById.get(input.remoteContainer.id);\n const heldBinding = heldState\n ? heldContainerBinding(heldState)\n : await input.state.persistence.loadHeldContainerBinding(\n input.state.runtime.infra.execSql,\n input.remoteContainer.id,\n );\n const listed = input.remoteContainer;\n // A folder re-homed away from the listed organization never returns there,\n // whatever binding (possibly none, after a reset) the device holds now.\n const supersededListing =\n !listingRepeatsHeldOrdinaryBinding(heldBinding, listed) &&\n (await input.state.persistence.isSupersededContainerBinding(\n input.state.runtime.infra.execSql,\n { containerId: listed.id, organizationId: listed.organizationId },\n ));\n if (input.isCurrent?.() === false) return null;\n const verified = await verifyRemoteContainerDestination({\n ...input,\n heldBinding,\n supersededListing,\n refresh: !!input.expectedHydrationTombstone,\n onVerifiedCheckpoint: (checkpoint) => {\n expectedPlacementCheckpoint = checkpoint;\n },\n });\n if (!verified || input.isCurrent?.() === false) return null;\n input = { ...input, remoteContainer: verified };\n const existingState = input.state.containersById.get(\n input.remoteContainer.id,\n );\n const remoteState = await runWithSecurityIncidentReporting(\n input.state.runtime.util.reportSecurityIncident,\n {\n objectId: verified.id,\n objectKind: \"container\",\n operation: \"container.binding.persist\",\n organizationId: verified.organizationId,\n },\n async () =>\n (await rebindReHomedContainer({\n existingState,\n heldBinding,\n isCurrent: input.isCurrent,\n state: input.state,\n verified,\n }))\n ? persistVerifiedRemoteContainer({\n ...input,\n existingState,\n expectedPlacementCheckpoint,\n })\n : null,\n );\n if (!remoteState) {\n return null;\n }\n await reconcileLocalOnlySystemContainers({\n childIdsByParentId: input.childIdsByParentId,\n isCurrent: input.isCurrent,\n requestDocumentPriming: input.host.requestDocumentPriming,\n remoteSystemState: remoteState,\n state: input.state,\n });\n return remoteState;\n}\n\n/**\n * Upsert one listed folder, isolating a rejected proof or binding. The refusal\n * was already reported; returning no state leaves the item unapplied without\n * blocking independent folders.\n */\nexport async function upsertIsolatedRemoteContainerState(\n input: UpsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n try {\n return await upsertRemoteContainerState(input);\n } catch (error) {\n if (\n !isKeyingVerificationError(error) &&\n !isProjectionVerificationCancelledError(error)\n )\n throw error;\n return null;\n }\n}\n\nfunction persistVerifiedRemoteContainer(\n input: UpsertRemoteContainerStateInput & {\n existingState: ContainerState | undefined;\n expectedPlacementCheckpoint: AccessManifestCheckpoint | undefined;\n },\n): Promise<ContainerState | null> {\n const { existingState, expectedPlacementCheckpoint } = input;\n return existingState\n ? updateExistingRemoteContainerState({\n childIdsByParentId: input.childIdsByParentId,\n containerIdsWithPendingMetadataUpdates:\n input.containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents:\n input.containerIdsWithPendingStructuralIntents,\n existingState,\n host: input.host,\n isCurrent: input.isCurrent,\n remoteContainer: input.remoteContainer,\n state: input.state,\n })\n : insertRemoteContainerState({\n childIdsByParentId: input.childIdsByParentId,\n host: input.host,\n expectedHydrationTombstone: input.expectedHydrationTombstone ?? null,\n expectedPlacementCheckpoint,\n isCurrent: input.isCurrent,\n remoteContainer: input.remoteContainer,\n state: input.state,\n });\n}\n"]}
@@ -6,7 +6,7 @@ import type { createContainerMetadataDocument } from "../../../data/containers/c
6
6
  import type { CurrentPrincipalPolicyReader } from "../../principals/currentPrincipalPolicyReader.js";
7
7
  import type { PrincipalPolicyHistoryReader } from "../../principals/principalPolicyHistoryReader.js";
8
8
  import type { ContainerContentsPersistence, ContainerDocumentRecord, ContainerHydrationTombstone, ContainerRecord, createContainerParentSyncLane } from "../containerPersistence.js";
9
- import type { ContainerMetadataPatch } from "../metadata.js";
9
+ import type { ContainerMetadataPatch } from "../metadata/index.js";
10
10
  import type { ContainerContentsWorkflowRuntime } from "../runtime.js";
11
11
  export type ListedRemoteContainerPageItem = ListContainersResponse["items"][number];
12
12
  export type ContainerChildIndex = Map<string, Set<string>>;
@@ -4,7 +4,7 @@ import type { PrincipalHistoryProtectionLease } from "../../data/principals/prin
4
4
  import type { ExecSql } from "../../data/sqlite/sqlSchema.js";
5
5
  import { type TrustedUserIdentityResolver } from "../../data/trustedUserIdentity/index.js";
6
6
  import { createDocumentsWorkflowRuntime, type DocumentsWorkflowRuntime } from "../documents/index.js";
7
- import type { WorkflowRuntimeAuthInput, WorkflowRuntimeCryptoInput, WorkflowRuntimeInfraInput, WorkflowRuntimeStateInput, WorkflowRuntimeUtilInput } from "../runtimeInput.js";
7
+ import type { WorkflowRuntimeAuthInput, WorkflowRuntimeCryptoInput, WorkflowRuntimeInfraInput, WorkflowRuntimeStateInput, WorkflowRuntimeUtilInput } from "../shared/runtimeInput.js";
8
8
  type DocumentsWorkflowRuntimeInput = Parameters<typeof createDocumentsWorkflowRuntime>[0];
9
9
  type ContainerContentsWorkflowApi = ApiClient & DocumentsWorkflowRuntimeInput["apiClient"];
10
10
  export interface ContainerContentsWorkflowRuntimeAuth extends WorkflowRuntimeAuthInput {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gCAAgC,GACjC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,+CAA+C,CAAC;AAElG,OAAO,EACL,kCAAkC,GAEnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,8BAA8B,GAE/B,MAAM,cAAc,CAAC;AAqGtB,SAAS,qBAAqB,CAC5B,OAAyC,EACzC,WAA0B;IAE1B,OAAO,iCAAiC,CAAC,OAAO,EAAE;QAChD,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;QAC9D,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,OAAyC,EACzC,WAA0B;IAE1B,OAAO,8BAA8B,CACnC,qBAAqB,CAAC,OAAO,EAAE,WAAW,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED,SAAS,qDAAqD,CAC5D,KAA4C,EAC5C,kBAA6D;IAE7D,MAAM,kBAAkB,GAAG,gCAAgC,CACzD,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAC/B,CAAC;IACF,MAAM,KAAK,GAAG;QACZ,GAAG,KAAK,CAAC,KAAK;QACd,kBAAkB;KACnB,CAAC;IAEF,OAAO,iCAAiC,CAAC,KAAK,EAAE;QAC9C,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK;QACL,0BAA0B,EAAE,kCAAkC,CAC5D,KAAK,CAAC,0BAA0B,CACjC;QACD,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sCAAsC,CACpD,KAA4C;IAE5C,OAAO,qDAAqD,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,2CAA2C,CACzD,KAA4C,EAC5C,kBAAgD;IAEhD,OAAO,iCAAiC,CAAC,KAAK,EAAE;QAC9C,GAAG,qDAAqD,CACtD,KAAK,EACL,kBAAkB,CACnB;QACD,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ApiClient } from \"@tearleads/api-client\";\nimport {\n type DocumentProjectorRegistryInput,\n resolveDocumentProjectorRegistry,\n} from \"../../data/documents/documentKinds\";\nimport type { PrincipalHistoryProtectionLease } from \"../../data/principals/principalHistoryProtection\";\nimport { inheritPrincipalHistoryProtection } from \"../../data/principals/principalHistoryRuntime\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n requireTrustedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n} from \"../../data/trustedUserIdentity\";\nimport {\n createDocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntime,\n} from \"../documents\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeInfraInput,\n WorkflowRuntimeStateInput,\n WorkflowRuntimeUtilInput,\n} from \"../runtimeInput\";\n\ntype DocumentsWorkflowRuntimeInput = Parameters<\n typeof createDocumentsWorkflowRuntime\n>[0];\n\ntype ContainerContentsWorkflowApi = ApiClient &\n DocumentsWorkflowRuntimeInput[\"apiClient\"];\n\nexport interface ContainerContentsWorkflowRuntimeAuth\n extends WorkflowRuntimeAuthInput {}\n\nexport interface ContainerContentsWorkflowRuntimeCrypto\n extends WorkflowRuntimeCryptoInput {}\n\nexport interface ContainerContentsWorkflowRuntimeInfra\n extends Omit<WorkflowRuntimeInfraInput, \"dbStatus\"> {\n readonly dbStatus: string;\n}\n\ninterface ContainerContentsWorkflowRuntimeInputInfra\n extends Omit<ContainerContentsWorkflowRuntimeInfra, \"documentProjectors\"> {\n readonly documentProjectors: DocumentProjectorRegistryInput;\n}\n\nexport interface ContainerContentsWorkflowRuntimeState\n extends WorkflowRuntimeStateInput {}\n\nexport interface ContainerContentsWorkflowRuntimeUtil\n extends Omit<WorkflowRuntimeUtilInput, \"logError\"> {\n // Store recovery is best-effort, so hosts may retain the causal error without\n // making structured error logging mandatory for general workflow runtimes.\n readonly logError?: WorkflowRuntimeUtilInput[\"logError\"] | undefined;\n}\n\nexport interface ContainerContentsRootAdoptionInput {\n readonly domainScope: ContainerContentsWorkflowRuntimeState[\"domainScope\"];\n readonly expectedContainerId: string;\n readonly nextContainerId: string;\n readonly organizationId: string;\n readonly userId: string;\n}\n\nexport type ContainerContentsRootAdopter = (\n input: ContainerContentsRootAdoptionInput,\n) => boolean | \"already-adopted\";\n\nexport interface ContainerContentsWorkflowRuntimeGroups {\n readonly auth: ContainerContentsWorkflowRuntimeAuth;\n readonly crypto: ContainerContentsWorkflowRuntimeCrypto;\n readonly infra: ContainerContentsWorkflowRuntimeInfra;\n readonly state: ContainerContentsWorkflowRuntimeState;\n readonly util: ContainerContentsWorkflowRuntimeUtil;\n}\n\nexport interface ContainerContentsWorkflowRuntimeInputGroups {\n readonly auth: ContainerContentsWorkflowRuntimeAuth;\n readonly crypto: ContainerContentsWorkflowRuntimeCrypto;\n readonly infra: ContainerContentsWorkflowRuntimeInputInfra;\n readonly state: ContainerContentsWorkflowRuntimeState;\n readonly util: ContainerContentsWorkflowRuntimeUtil;\n}\n\nexport interface ContainerContentsWorkflowRuntimeInput\n extends ContainerContentsWorkflowRuntimeInputGroups {\n /** Private host custody, inherited by container and derived document runtimes. */\n readonly withPrincipalHistoryProtection?:\n | PrincipalHistoryProtectionLease\n | undefined;\n readonly apiClient: ContainerContentsWorkflowApi;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}\n\nexport interface ContainerContentsWorkflowRuntime\n extends ContainerContentsWorkflowRuntimeGroups,\n Pick<ContainerContentsWorkflowRuntimeInput, \"apiClient\"> {\n readonly adoptRootContainer?: ContainerContentsRootAdopter | undefined;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}\n\nexport interface ContainerContentsStoreWorkflowRuntime\n extends ContainerContentsWorkflowRuntime {\n readonly adoptRootContainer: ContainerContentsRootAdopter;\n}\n\nexport interface ContainerContentsWorkflowSqlRuntime {\n readonly auth?: {\n readonly organizationId?: string | null | undefined;\n };\n readonly infra: {\n readonly execSql: ExecSql;\n };\n}\n\nfunction documentsRuntimeInput(\n runtime: ContainerContentsWorkflowRuntime,\n containerId: string | null,\n): DocumentsWorkflowRuntimeInput {\n return inheritPrincipalHistoryProtection(runtime, {\n apiClient: runtime.apiClient,\n auth: runtime.auth,\n crypto: runtime.crypto,\n infra: runtime.infra,\n resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,\n state: { ...runtime.state, containerId },\n util: runtime.util,\n });\n}\n\nexport function createContainerContentsDocumentsRuntime(\n runtime: ContainerContentsWorkflowRuntime,\n containerId: string | null,\n): DocumentsWorkflowRuntime {\n return createDocumentsWorkflowRuntime(\n documentsRuntimeInput(runtime, containerId),\n );\n}\n\nfunction createContainerContentsWorkflowRuntimeWithRootAdopter(\n input: ContainerContentsWorkflowRuntimeInput,\n adoptRootContainer?: ContainerContentsRootAdopter | undefined,\n): ContainerContentsWorkflowRuntime {\n const documentProjectors = resolveDocumentProjectorRegistry(\n input.infra.documentProjectors,\n );\n const infra = {\n ...input.infra,\n documentProjectors,\n };\n\n return inheritPrincipalHistoryProtection(input, {\n ...(adoptRootContainer ? { adoptRootContainer } : {}),\n apiClient: input.apiClient,\n auth: input.auth,\n crypto: input.crypto,\n infra,\n resolveTrustedUserIdentity: requireTrustedUserIdentityResolver(\n input.resolveTrustedUserIdentity,\n ),\n state: input.state,\n util: input.util,\n });\n}\n\nexport function createContainerContentsWorkflowRuntime(\n input: ContainerContentsWorkflowRuntimeInput,\n): ContainerContentsWorkflowRuntime {\n return createContainerContentsWorkflowRuntimeWithRootAdopter(input);\n}\n\n/** Internal store runtime with the session-root adoption capability wired. */\nexport function createContainerContentsStoreWorkflowRuntime(\n input: ContainerContentsWorkflowRuntimeInput,\n adoptRootContainer: ContainerContentsRootAdopter,\n): ContainerContentsStoreWorkflowRuntime {\n return inheritPrincipalHistoryProtection(input, {\n ...createContainerContentsWorkflowRuntimeWithRootAdopter(\n input,\n adoptRootContainer,\n ),\n adoptRootContainer,\n });\n}\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gCAAgC,GACjC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,+CAA+C,CAAC;AAElG,OAAO,EACL,kCAAkC,GAEnC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,8BAA8B,GAE/B,MAAM,cAAc,CAAC;AAqGtB,SAAS,qBAAqB,CAC5B,OAAyC,EACzC,WAA0B;IAE1B,OAAO,iCAAiC,CAAC,OAAO,EAAE;QAChD,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,0BAA0B,EAAE,OAAO,CAAC,0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iClient } from \"@tearleads/api-client\";\nimport {\n type DocumentProjectorRegistryInput,\n resolveDocumentProjectorRegistry,\n} from \"../../data/documents/documentKinds\";\nimport type { PrincipalHistoryProtectionLease } from \"../../data/principals/principalHistoryProtection\";\nimport { inheritPrincipalHistoryProtection } from \"../../data/principals/principalHistoryRuntime\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n requireTrustedUserIdentityResolver,\n type TrustedUserIdentityResolver,\n} from \"../../data/trustedUserIdentity\";\nimport {\n createDocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntime,\n} from \"../documents\";\nimport type {\n WorkflowRuntimeAuthInput,\n WorkflowRuntimeCryptoInput,\n WorkflowRuntimeInfraInput,\n WorkflowRuntimeStateInput,\n WorkflowRuntimeUtilInput,\n} from \"../shared/runtimeInput\";\n\ntype DocumentsWorkflowRuntimeInput = Parameters<\n typeof createDocumentsWorkflowRuntime\n>[0];\n\ntype ContainerContentsWorkflowApi = ApiClient &\n DocumentsWorkflowRuntimeInput[\"apiClient\"];\n\nexport interface ContainerContentsWorkflowRuntimeAuth\n extends WorkflowRuntimeAuthInput {}\n\nexport interface ContainerContentsWorkflowRuntimeCrypto\n extends WorkflowRuntimeCryptoInput {}\n\nexport interface ContainerContentsWorkflowRuntimeInfra\n extends Omit<WorkflowRuntimeInfraInput, \"dbStatus\"> {\n readonly dbStatus: string;\n}\n\ninterface ContainerContentsWorkflowRuntimeInputInfra\n extends Omit<ContainerContentsWorkflowRuntimeInfra, \"documentProjectors\"> {\n readonly documentProjectors: DocumentProjectorRegistryInput;\n}\n\nexport interface ContainerContentsWorkflowRuntimeState\n extends WorkflowRuntimeStateInput {}\n\nexport interface ContainerContentsWorkflowRuntimeUtil\n extends Omit<WorkflowRuntimeUtilInput, \"logError\"> {\n // Store recovery is best-effort, so hosts may retain the causal error without\n // making structured error logging mandatory for general workflow runtimes.\n readonly logError?: WorkflowRuntimeUtilInput[\"logError\"] | undefined;\n}\n\nexport interface ContainerContentsRootAdoptionInput {\n readonly domainScope: ContainerContentsWorkflowRuntimeState[\"domainScope\"];\n readonly expectedContainerId: string;\n readonly nextContainerId: string;\n readonly organizationId: string;\n readonly userId: string;\n}\n\nexport type ContainerContentsRootAdopter = (\n input: ContainerContentsRootAdoptionInput,\n) => boolean | \"already-adopted\";\n\nexport interface ContainerContentsWorkflowRuntimeGroups {\n readonly auth: ContainerContentsWorkflowRuntimeAuth;\n readonly crypto: ContainerContentsWorkflowRuntimeCrypto;\n readonly infra: ContainerContentsWorkflowRuntimeInfra;\n readonly state: ContainerContentsWorkflowRuntimeState;\n readonly util: ContainerContentsWorkflowRuntimeUtil;\n}\n\nexport interface ContainerContentsWorkflowRuntimeInputGroups {\n readonly auth: ContainerContentsWorkflowRuntimeAuth;\n readonly crypto: ContainerContentsWorkflowRuntimeCrypto;\n readonly infra: ContainerContentsWorkflowRuntimeInputInfra;\n readonly state: ContainerContentsWorkflowRuntimeState;\n readonly util: ContainerContentsWorkflowRuntimeUtil;\n}\n\nexport interface ContainerContentsWorkflowRuntimeInput\n extends ContainerContentsWorkflowRuntimeInputGroups {\n /** Private host custody, inherited by container and derived document runtimes. */\n readonly withPrincipalHistoryProtection?:\n | PrincipalHistoryProtectionLease\n | undefined;\n readonly apiClient: ContainerContentsWorkflowApi;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}\n\nexport interface ContainerContentsWorkflowRuntime\n extends ContainerContentsWorkflowRuntimeGroups,\n Pick<ContainerContentsWorkflowRuntimeInput, \"apiClient\"> {\n readonly adoptRootContainer?: ContainerContentsRootAdopter | undefined;\n readonly resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n}\n\nexport interface ContainerContentsStoreWorkflowRuntime\n extends ContainerContentsWorkflowRuntime {\n readonly adoptRootContainer: ContainerContentsRootAdopter;\n}\n\nexport interface ContainerContentsWorkflowSqlRuntime {\n readonly auth?: {\n readonly organizationId?: string | null | undefined;\n };\n readonly infra: {\n readonly execSql: ExecSql;\n };\n}\n\nfunction documentsRuntimeInput(\n runtime: ContainerContentsWorkflowRuntime,\n containerId: string | null,\n): DocumentsWorkflowRuntimeInput {\n return inheritPrincipalHistoryProtection(runtime, {\n apiClient: runtime.apiClient,\n auth: runtime.auth,\n crypto: runtime.crypto,\n infra: runtime.infra,\n resolveTrustedUserIdentity: runtime.resolveTrustedUserIdentity,\n state: { ...runtime.state, containerId },\n util: runtime.util,\n });\n}\n\nexport function createContainerContentsDocumentsRuntime(\n runtime: ContainerContentsWorkflowRuntime,\n containerId: string | null,\n): DocumentsWorkflowRuntime {\n return createDocumentsWorkflowRuntime(\n documentsRuntimeInput(runtime, containerId),\n );\n}\n\nfunction createContainerContentsWorkflowRuntimeWithRootAdopter(\n input: ContainerContentsWorkflowRuntimeInput,\n adoptRootContainer?: ContainerContentsRootAdopter | undefined,\n): ContainerContentsWorkflowRuntime {\n const documentProjectors = resolveDocumentProjectorRegistry(\n input.infra.documentProjectors,\n );\n const infra = {\n ...input.infra,\n documentProjectors,\n };\n\n return inheritPrincipalHistoryProtection(input, {\n ...(adoptRootContainer ? { adoptRootContainer } : {}),\n apiClient: input.apiClient,\n auth: input.auth,\n crypto: input.crypto,\n infra,\n resolveTrustedUserIdentity: requireTrustedUserIdentityResolver(\n input.resolveTrustedUserIdentity,\n ),\n state: input.state,\n util: input.util,\n });\n}\n\nexport function createContainerContentsWorkflowRuntime(\n input: ContainerContentsWorkflowRuntimeInput,\n): ContainerContentsWorkflowRuntime {\n return createContainerContentsWorkflowRuntimeWithRootAdopter(input);\n}\n\n/** Internal store runtime with the session-root adoption capability wired. */\nexport function createContainerContentsStoreWorkflowRuntime(\n input: ContainerContentsWorkflowRuntimeInput,\n adoptRootContainer: ContainerContentsRootAdopter,\n): ContainerContentsStoreWorkflowRuntime {\n return inheritPrincipalHistoryProtection(input, {\n ...createContainerContentsWorkflowRuntimeWithRootAdopter(\n input,\n adoptRootContainer,\n ),\n adoptRootContainer,\n });\n}\n"]}
@@ -1,9 +1,9 @@
1
- import type { DocumentPurgeResponse } from "../../internal/validators/response/index.js";
2
- import type { StoredDocumentKind } from "../../data/documents/documentKinds.js";
3
- import type { ProjectionUserKeyResolver } from "../../data/keyingProjectionVerification/index.js";
4
- import { type DocumentsPersistence, deletePersistedDocument } from "../documents/index.js";
5
- import type { SubtreePurgeRoot } from "../documents/subtreePurgeScope.js";
6
- import type { ContainerContentsWorkflowRuntime } from "./runtime.js";
1
+ import type { DocumentPurgeResponse } from "../../../internal/validators/response/index.js";
2
+ import type { StoredDocumentKind } from "../../../data/documents/documentKinds.js";
3
+ import type { ProjectionUserKeyResolver } from "../../../data/keyingProjectionVerification/index.js";
4
+ import { type DocumentsPersistence, deletePersistedDocument } from "../../documents/index.js";
5
+ import type { SubtreePurgeRoot } from "../../documents/subtreePurgeScope.js";
6
+ import type { ContainerContentsWorkflowRuntime } from "../runtime.js";
7
7
  type ContainerDocumentPurgeApi = Pick<ContainerContentsWorkflowRuntime["apiClient"], "getPrincipalPolicyPages" | "getProjectionPolicyHistoryPages" | "getDocumentPurgeProof" | "getDocumentWriterProjectionResult" | "purgeDocument">;
8
8
  type DocumentPurgeResult = DocumentPurgeResponse | {
9
9
  readonly documentId: string;