@tearleads/client-sdk 0.1.63 → 0.1.64

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 (616) hide show
  1. package/data/documents/blob/shared/projection.js +1 -1
  2. package/data/documents/blob/shared/projection.js.map +1 -1
  3. package/data/documents/shared/projectionContentKeys.js +1 -1
  4. package/data/documents/shared/projectionContentKeys.js.map +1 -1
  5. package/data/documents/shared/syncResponseAuthorization.js +1 -1
  6. package/data/documents/shared/syncResponseAuthorization.js.map +1 -1
  7. package/data/keyingProjectionVerification/{accessManifestCheckpointEnforcement.js → checkpoints/accessManifestCheckpointEnforcement.js} +2 -2
  8. package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
  9. package/data/keyingProjectionVerification/{bundleVerification.js → checkpoints/bundleVerification.js} +5 -5
  10. package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
  11. package/data/keyingProjectionVerification/{checkpointContext.d.ts → checkpoints/checkpointContext.d.ts} +6 -6
  12. package/data/keyingProjectionVerification/{checkpointContext.js → checkpoints/checkpointContext.js} +6 -6
  13. package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
  14. package/data/keyingProjectionVerification/{manifestCheckpointVerification.js → checkpoints/manifestCheckpointVerification.js} +2 -2
  15. package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
  16. package/data/keyingProjectionVerification/{containerAncestorCitations.js → container/containerAncestorCitations.js} +4 -4
  17. package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
  18. package/data/keyingProjectionVerification/{containerCreateManifest.js → container/containerCreateManifest.js} +1 -1
  19. package/data/keyingProjectionVerification/{containerDestinationVerification.js → container/containerDestinationVerification.js} +4 -4
  20. package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
  21. package/data/keyingProjectionVerification/{containerManifestVerification.js → container/containerManifestVerification.js} +7 -7
  22. package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
  23. package/data/keyingProjectionVerification/{containerPathVerification.js → container/containerPathVerification.js} +2 -2
  24. package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
  25. package/data/keyingProjectionVerification/{containerProjectionVerification.d.ts → container/containerProjectionVerification.d.ts} +7 -7
  26. package/data/keyingProjectionVerification/{containerProjectionVerification.js → container/containerProjectionVerification.js} +9 -9
  27. package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
  28. package/data/keyingProjectionVerification/{documentDependencyPaths.d.ts → document/documentDependencyPaths.d.ts} +1 -1
  29. package/data/keyingProjectionVerification/{documentDependencyPaths.js → document/documentDependencyPaths.js} +3 -3
  30. package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
  31. package/data/keyingProjectionVerification/{documentManifestPolicies.js → document/documentManifestPolicies.js} +2 -2
  32. package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
  33. package/data/keyingProjectionVerification/{documentManifestPredecessor.js → document/documentManifestPredecessor.js} +1 -1
  34. package/data/keyingProjectionVerification/{documentManifestVerification.js → document/documentManifestVerification.js} +5 -5
  35. package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
  36. package/data/keyingProjectionVerification/{documentProjectionVerification.d.ts → document/documentProjectionVerification.d.ts} +4 -4
  37. package/data/keyingProjectionVerification/{documentProjectionVerification.js → document/documentProjectionVerification.js} +9 -9
  38. package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
  39. package/data/keyingProjectionVerification/{documentPurgeCheckpointCurrency.js → documentPurge/documentPurgeCheckpointCurrency.js} +12 -12
  40. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
  41. package/data/keyingProjectionVerification/{documentPurgeCheckpointEnforcement.js → documentPurge/documentPurgeCheckpointEnforcement.js} +2 -2
  42. package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
  43. package/data/keyingProjectionVerification/{documentPurgeDocumentChainVerification.js → documentPurge/documentPurgeDocumentChainVerification.js} +8 -8
  44. package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
  45. package/data/keyingProjectionVerification/{documentPurgePolicyCheckpoints.js → documentPurge/documentPurgePolicyCheckpoints.js} +2 -2
  46. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
  47. package/data/keyingProjectionVerification/{documentPurgePolicyCurrency.js → documentPurge/documentPurgePolicyCurrency.js} +4 -4
  48. package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
  49. package/data/keyingProjectionVerification/{documentPurgePrincipalEvidence.js → documentPurge/documentPurgePrincipalEvidence.js} +3 -3
  50. package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
  51. package/data/keyingProjectionVerification/{documentPurgeProofVerification.d.ts → documentPurge/documentPurgeProofVerification.d.ts} +5 -5
  52. package/data/keyingProjectionVerification/{documentPurgeProofVerification.js → documentPurge/documentPurgeProofVerification.js} +10 -10
  53. package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
  54. package/data/keyingProjectionVerification/index.d.ts +4 -4
  55. package/data/keyingProjectionVerification/index.js +4 -4
  56. package/data/keyingProjectionVerification/index.js.map +1 -1
  57. package/data/keyingProjectionVerification/{mergeProjectionPolicyEvidence.js → principalPolicy/mergeProjectionPolicyEvidence.js} +2 -2
  58. package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
  59. package/data/keyingProjectionVerification/{organizationFounderBinding.js → principalPolicy/organizationFounderBinding.js} +3 -3
  60. package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
  61. package/data/keyingProjectionVerification/{principalPolicyCache.js → principalPolicy/principalPolicyCache.js} +6 -6
  62. package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
  63. package/data/keyingProjectionVerification/{principalPolicyVerification.js → principalPolicy/principalPolicyVerification.js} +12 -12
  64. package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
  65. package/data/keyingProjectionVerification/{projectionAuthorizationEvidence.js → principalPolicy/projectionAuthorizationEvidence.js} +3 -3
  66. package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
  67. package/data/keyingProjectionVerification/{projectionPolicyEvidence.js → principalPolicy/projectionPolicyEvidence.js} +3 -3
  68. package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
  69. package/data/keyingProjectionVerification/{resolvedPrincipalPolicy.js → principalPolicy/resolvedPrincipalPolicy.js} +6 -6
  70. package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
  71. package/package.json +1 -1
  72. package/stores/container-contents/accessRestorationSweep.js +1 -1
  73. package/stores/container-contents/accessRestorationSweep.js.map +1 -1
  74. package/stores/container-contents/containerContentsStore.d.ts +1 -1
  75. package/stores/container-contents/containerContentsStore.js +12 -12
  76. package/stores/container-contents/containerContentsStore.js.map +1 -1
  77. package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
  78. package/stores/container-contents/{containerStatePersistence.js → containerState/containerStatePersistence.js} +2 -2
  79. package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
  80. package/stores/container-contents/{missingContainerState.js → containerState/missingContainerState.js} +1 -1
  81. package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
  82. package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
  83. package/stores/container-contents/{reconcilableContainer.d.ts → containerState/reconcilableContainer.d.ts} +1 -1
  84. package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
  85. package/stores/container-contents/{documentRecovery.js → documentWork/documentRecovery.js} +6 -6
  86. package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
  87. package/stores/container-contents/{documentRotation.js → documentWork/documentRotation.js} +2 -2
  88. package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
  89. package/stores/container-contents/{documentWork.js → documentWork/index.js} +1 -1
  90. package/stores/container-contents/documentWork/index.js.map +1 -0
  91. package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js} +3 -3
  92. package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
  93. package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js} +3 -3
  94. package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
  95. package/stores/container-contents/{startupHydration.js → hydration/startupHydration.js} +3 -3
  96. package/stores/container-contents/hydration/startupHydration.js.map +1 -0
  97. package/stores/container-contents/index.d.ts +3 -3
  98. package/stores/container-contents/index.js +2 -2
  99. package/stores/container-contents/index.js.map +1 -1
  100. package/stores/container-contents/localRefresh.js +2 -2
  101. package/stores/container-contents/localRefresh.js.map +1 -1
  102. package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js} +4 -4
  103. package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
  104. package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
  105. package/stores/container-contents/{groupRewrapOperation.js → operations/groupRewrapOperation.js} +2 -2
  106. package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
  107. package/stores/container-contents/{operations.js → operations/index.js} +18 -18
  108. package/stores/container-contents/operations/index.js.map +1 -0
  109. package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
  110. package/stores/container-contents/{reportShareFailure.js → operations/reportShareFailure.js} +4 -4
  111. package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
  112. package/stores/container-contents/{setContainerIconOperation.js → operations/setContainerIconOperation.js} +6 -6
  113. package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
  114. package/stores/container-contents/{shareOperations.js → operations/shareOperations.js} +6 -6
  115. package/stores/container-contents/operations/shareOperations.js.map +1 -0
  116. package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
  117. package/stores/container-contents/{remoteContainerIngestion.js → remoteEvents/remoteContainerIngestion.js} +4 -4
  118. package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
  119. package/stores/container-contents/{remoteEventProjectionInvalidation.js → remoteEvents/remoteEventProjectionInvalidation.js} +1 -1
  120. package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
  121. package/stores/container-contents/{remoteEventSync.js → remoteEvents/remoteEventSync.js} +4 -4
  122. package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
  123. package/stores/container-contents/{remoteWriteGuards.js → remoteWrites/remoteWriteGuards.js} +2 -2
  124. package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
  125. package/stores/container-contents/{remoteWriteQueue.js → remoteWrites/remoteWriteQueue.js} +1 -1
  126. package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
  127. package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
  128. package/stores/container-contents/state.d.ts +1 -1
  129. package/stores/container-contents/state.js +2 -2
  130. package/stores/container-contents/state.js.map +1 -1
  131. package/stores/container-contents/{syncAgent.d.ts → syncAgent/index.d.ts} +2 -2
  132. package/stores/container-contents/{syncAgent.js → syncAgent/index.js} +14 -14
  133. package/stores/container-contents/syncAgent/index.js.map +1 -0
  134. package/stores/container-contents/{metadataSyncSignal.js → syncAgent/metadataSyncSignal.js} +1 -1
  135. package/stores/container-contents/{metadataSyncSignal.js.map → syncAgent/metadataSyncSignal.js.map} +1 -1
  136. package/stores/container-contents/{syncAgentTypes.d.ts → syncAgent/syncAgentTypes.d.ts} +5 -5
  137. package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
  138. package/stores/container-contents/{syncLaneIteration.js → syncAgent/syncLaneIteration.js} +11 -11
  139. package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
  140. package/stores/container-contents/{existingSystemContainer.js → systemContainers/existingSystemContainer.js} +4 -4
  141. package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
  142. package/stores/container-contents/{organizationMetadataSystemContainer.js → systemContainers/organizationMetadataSystemContainer.js} +2 -2
  143. package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
  144. package/stores/container-contents/{systemContainerHydration.js → systemContainers/systemContainerHydration.js} +3 -3
  145. package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
  146. package/stores/container-contents/{systemContainerIcon.js → systemContainers/systemContainerIcon.js} +5 -5
  147. package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
  148. package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
  149. package/stores/container-contents/{systemContainerPostCreate.js → systemContainers/systemContainerPostCreate.js} +2 -2
  150. package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
  151. package/stores/container-contents/{systemContainerPromotion.js → systemContainers/systemContainerPromotion.js} +1 -1
  152. package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
  153. package/stores/container-contents/types.d.ts +2 -2
  154. package/stores/container-contents/types.js.map +1 -1
  155. package/stores/documents/documentStore/{attachmentSourceUpload.js → attachmentUpload/attachmentSourceUpload.js} +4 -4
  156. package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
  157. package/stores/documents/documentStore/{attachmentStaging.js → attachmentUpload/attachmentStaging.js} +5 -5
  158. package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
  159. package/stores/documents/documentStore/{attachmentUploadAttempt.js → attachmentUpload/attachmentUploadAttempt.js} +2 -2
  160. package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
  161. package/stores/documents/documentStore/{attachmentUploadLane.js → attachmentUpload/attachmentUploadLane.js} +1 -1
  162. package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
  163. package/stores/documents/documentStore/{attachmentUploadResume.js → attachmentUpload/attachmentUploadResume.js} +4 -4
  164. package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
  165. package/stores/documents/documentStore/{attachmentDetachState.js → attachments/attachmentDetachState.js} +1 -1
  166. package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
  167. package/stores/documents/documentStore/{attachmentHydration.js → attachments/attachmentHydration.js} +5 -5
  168. package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
  169. package/stores/documents/documentStore/{attachmentHydrationCommit.js → attachments/attachmentHydrationCommit.js} +3 -3
  170. package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
  171. package/stores/documents/documentStore/{attachmentIntents.js → attachments/attachmentIntents.js} +2 -2
  172. package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
  173. package/stores/documents/documentStore/{attachmentMutationPersistence.js → attachments/attachmentMutationPersistence.js} +4 -4
  174. package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
  175. package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
  176. package/stores/documents/documentStore/{attachmentPersistence.js → attachments/attachmentPersistence.js} +4 -4
  177. package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
  178. package/stores/documents/documentStore/{attachmentRemoval.js → attachments/attachmentRemoval.js} +11 -11
  179. package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
  180. package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
  181. package/stores/documents/documentStore/{attachmentWriteGeneration.js → attachments/attachmentWriteGeneration.js} +2 -2
  182. package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
  183. package/stores/documents/documentStore/{attachments.js → attachments/index.js} +11 -11
  184. package/stores/documents/documentStore/attachments/index.js.map +1 -0
  185. package/stores/documents/documentStore/{documentHistoryCompaction.js → history/documentHistoryCompaction.js} +4 -4
  186. package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
  187. package/stores/documents/documentStore/{durableDocumentReload.js → history/durableDocumentReload.js} +6 -6
  188. package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
  189. package/stores/documents/documentStore/{historyRebuild.js → history/historyRebuild.js} +6 -6
  190. package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
  191. package/stores/documents/{documentStore.d.ts → documentStore/index.d.ts} +5 -5
  192. package/stores/documents/{documentStore.js → documentStore/index.js} +18 -18
  193. package/stores/documents/documentStore/index.js.map +1 -0
  194. package/stores/documents/documentStore/{deferredInitialUpdate.js → initialization/deferredInitialUpdate.js} +9 -9
  195. package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
  196. package/stores/documents/documentStore/{initialization.js → initialization/index.js} +14 -14
  197. package/stores/documents/documentStore/initialization/index.js.map +1 -0
  198. package/stores/documents/documentStore/{initializationAttachments.js → initialization/initializationAttachments.js} +1 -1
  199. package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
  200. package/stores/documents/documentStore/{initializationHistory.js → initialization/initializationHistory.js} +3 -3
  201. package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
  202. package/stores/documents/documentStore/{initializationRecovery.js → initialization/initializationRecovery.js} +7 -7
  203. package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
  204. package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
  205. package/stores/documents/documentStore/mutations.js +2 -2
  206. package/stores/documents/documentStore/mutations.js.map +1 -1
  207. package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
  208. package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
  209. package/stores/documents/documentStore/persistence.js +3 -3
  210. package/stores/documents/documentStore/persistence.js.map +1 -1
  211. package/stores/documents/documentStore/{rotation.js → rotation/index.js} +14 -14
  212. package/stores/documents/documentStore/rotation/index.js.map +1 -0
  213. package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js} +2 -2
  214. package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
  215. package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js} +9 -9
  216. package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
  217. package/stores/documents/documentStore/rows.js +2 -2
  218. package/stores/documents/documentStore/rows.js.map +1 -1
  219. package/stores/documents/documentStore/state.js +1 -1
  220. package/stores/documents/documentStore/state.js.map +1 -1
  221. package/stores/documents/documentStore/{sync.js → sync/index.js} +7 -7
  222. package/stores/documents/documentStore/sync/index.js.map +1 -0
  223. package/stores/documents/documentStore/{pullContinuationInvalidation.js → sync/pullContinuationInvalidation.js} +3 -3
  224. package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
  225. package/stores/documents/documentStore/{remoteRevalidationTelemetry.js → sync/remoteRevalidationTelemetry.js} +1 -1
  226. package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
  227. package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
  228. package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
  229. package/stores/documents/documentStore/{syncAttachmentSettlement.js → sync/syncAttachmentSettlement.js} +3 -3
  230. package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
  231. package/stores/documents/documentStore/{syncAttachments.js → sync/syncAttachments.js} +7 -7
  232. package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
  233. package/stores/documents/documentStore/{syncDetachedAttachments.js → sync/syncDetachedAttachments.js} +7 -7
  234. package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
  235. package/stores/documents/documentStore/{syncFinalize.js → sync/syncFinalize.js} +9 -9
  236. package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
  237. package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
  238. package/stores/documents/documentStore/{syncOutgoingCoverage.js → sync/syncOutgoingCoverage.js} +4 -4
  239. package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
  240. package/stores/documents/documentStore/{syncRemoteSignals.js → sync/syncRemoteSignals.js} +4 -4
  241. package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
  242. package/stores/documents/documentStore/{syncRequest.js → sync/syncRequest.js} +8 -8
  243. package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
  244. package/stores/documents/documentStore/{syncShared.js → sync/syncShared.js} +8 -8
  245. package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
  246. package/stores/documents/documentStore/{syncUpdateImport.js → sync/syncUpdateImport.js} +3 -3
  247. package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
  248. package/stores/documents/documentStore/{versionCoverage.js → sync/versionCoverage.js} +1 -1
  249. package/stores/documents/index.d.ts +1 -1
  250. package/stores/documents/index.js +1 -1
  251. package/stores/local-projection/localProjectionStore.d.ts +1 -1
  252. package/stores/local-projection/localProjectionStore.js +1 -1
  253. package/stores/local-projection/localProjectionStore.js.map +1 -1
  254. package/stores/local-projection/registry.d.ts +1 -1
  255. package/stores/local-projection/types.d.ts +1 -1
  256. package/workflows/blobs/hydration/decrypt.js +1 -1
  257. package/workflows/blobs/hydration/decrypt.js.map +1 -1
  258. package/workflows/container-contents/container-state/{createAdoption.js → create/createAdoption.js} +6 -6
  259. package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
  260. package/workflows/container-contents/container-state/{createChild.js → create/createChild.js} +7 -7
  261. package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
  262. package/workflows/container-contents/container-state/{createIntentDepth.js → create/createIntentDepth.js} +2 -2
  263. package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
  264. package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
  265. package/workflows/container-contents/container-state/{createIntentSync.js → create/createIntentSync.js} +7 -7
  266. package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
  267. package/workflows/container-contents/container-state/{createTerminalFailure.js → create/createTerminalFailure.js} +2 -2
  268. package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
  269. package/workflows/container-contents/container-state/{createWithMetadata.js → create/createWithMetadata.js} +9 -9
  270. package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
  271. package/workflows/container-contents/container-state/{createWithMetadataPlan.js → create/createWithMetadataPlan.js} +4 -4
  272. package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
  273. package/workflows/container-contents/container-state/{localPurgeScope.js → purge/localPurgeScope.js} +1 -1
  274. package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
  275. package/workflows/container-contents/container-state/{purgeTree.js → purge/purgeTree.js} +5 -5
  276. package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
  277. package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
  278. package/workflows/container-contents/container-state/{purgeTreeContainerDeletion.js → purge/purgeTreeContainerDeletion.js} +1 -1
  279. package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
  280. package/workflows/container-contents/container-state/{purgeTreeScope.js → purge/purgeTreeScope.js} +8 -8
  281. package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
  282. package/workflows/container-contents/container-state/{readLocalPurgeScope.js → purge/readLocalPurgeScope.js} +3 -3
  283. package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
  284. package/workflows/container-contents/container-state/remote.js +2 -2
  285. package/workflows/container-contents/container-state/remote.js.map +1 -1
  286. package/workflows/container-contents/container-state/{groupGrantVerification.js → share/groupGrantVerification.js} +8 -8
  287. package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
  288. package/workflows/container-contents/container-state/{groupShareEpoch.js → share/groupShareEpoch.js} +2 -2
  289. package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
  290. package/workflows/container-contents/container-state/{share.js → share/index.js} +8 -8
  291. package/workflows/container-contents/container-state/share/index.js.map +1 -0
  292. package/workflows/container-contents/container-state/{sharePersistence.js → share/sharePersistence.js} +3 -3
  293. package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
  294. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
  295. package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
  296. package/workflows/container-contents/documentDiscovery/index.js +1 -1
  297. package/workflows/container-contents/documentDiscovery/index.js.map +1 -1
  298. package/workflows/container-contents/metadata/metadataSyncErrors.js +1 -1
  299. package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
  300. package/workflows/container-contents/remoteHydration/destination/destinationPrefetch.js.map +1 -0
  301. package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
  302. package/workflows/container-contents/remoteHydration/{destinationRootReload.js → destination/destinationRootReload.js} +1 -1
  303. package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
  304. package/workflows/container-contents/remoteHydration/{replacementBinding.js → destination/replacementBinding.js} +5 -5
  305. package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
  306. package/workflows/container-contents/remoteHydration/{verifiedDestination.js → destination/verifiedDestination.js} +9 -9
  307. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
  308. package/workflows/container-contents/remoteHydration/index.js +4 -4
  309. package/workflows/container-contents/remoteHydration/index.js.map +1 -1
  310. package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
  311. package/workflows/container-contents/remoteHydration/{laneFetchMarkers.js → lanes/laneFetchMarkers.js} +1 -1
  312. package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
  313. package/workflows/container-contents/remoteHydration/{parentLaneFetch.js → lanes/parentLaneFetch.js} +2 -2
  314. package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
  315. package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
  316. package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
  317. package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
  318. package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
  319. package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
  320. package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
  321. package/workflows/container-contents/remoteHydration/{insertRemoteContainer.js → remoteContainers/insertRemoteContainer.js} +6 -6
  322. package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
  323. package/workflows/container-contents/remoteHydration/{remoteContainerPageHydration.js → remoteContainers/remoteContainerPageHydration.js} +7 -7
  324. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
  325. package/workflows/container-contents/remoteHydration/{remoteContainerState.js → remoteContainers/remoteContainerState.js} +9 -9
  326. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
  327. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
  328. package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
  329. package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
  330. package/workflows/containers/child/{createProjection.d.ts → create/createProjection.d.ts} +2 -2
  331. package/workflows/containers/child/{createProjection.js → create/createProjection.js} +2 -2
  332. package/workflows/containers/child/create/createProjection.js.map +1 -0
  333. package/workflows/containers/child/{createSubmission.d.ts → create/createSubmission.d.ts} +7 -7
  334. package/workflows/containers/child/{createSubmission.js → create/createSubmission.js} +2 -2
  335. package/workflows/containers/child/create/createSubmission.js.map +1 -0
  336. package/workflows/containers/child/{create.d.ts → create/index.d.ts} +5 -5
  337. package/workflows/containers/child/{create.js → create/index.js} +15 -15
  338. package/workflows/containers/child/create/index.js.map +1 -0
  339. package/workflows/containers/child/{move.d.ts → move/index.d.ts} +5 -5
  340. package/workflows/containers/child/{move.js → move/index.js} +12 -12
  341. package/workflows/containers/child/move/index.js.map +1 -0
  342. package/workflows/containers/child/{moveArtifacts.js → move/moveArtifacts.js} +3 -3
  343. package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
  344. package/workflows/containers/child/{moveRotation.js → move/moveRotation.js} +3 -3
  345. package/workflows/containers/child/move/moveRotation.js.map +1 -0
  346. package/workflows/containers/child/{moveWraps.js → move/moveWraps.js} +5 -5
  347. package/workflows/containers/child/move/moveWraps.js.map +1 -0
  348. package/workflows/containers/child/mutationSubmit.js +1 -1
  349. package/workflows/containers/child/mutationSubmit.js.map +1 -1
  350. package/workflows/containers/child/{carriedDescendantRekeys.js → rekey/carriedDescendantRekeys.js} +4 -4
  351. package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
  352. package/workflows/containers/child/{rekey.d.ts → rekey/index.d.ts} +6 -6
  353. package/workflows/containers/child/{rekey.js → rekey/index.js} +13 -13
  354. package/workflows/containers/child/rekey/index.js.map +1 -0
  355. package/workflows/containers/child/{keyringOverrideLineage.d.ts → rekey/keyringOverrideLineage.d.ts} +1 -1
  356. package/workflows/containers/child/{keyringOverrideLineage.js → rekey/keyringOverrideLineage.js} +1 -1
  357. package/workflows/containers/child/{rekeyProjection.d.ts → rekey/rekeyProjection.d.ts} +2 -2
  358. package/workflows/containers/child/{rekeyProjection.js → rekey/rekeyProjection.js} +3 -3
  359. package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
  360. package/workflows/containers/child/{rekeyRemote.d.ts → rekey/rekeyRemote.d.ts} +6 -6
  361. package/workflows/containers/child/{rekeyRemote.js → rekey/rekeyRemote.js} +2 -2
  362. package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
  363. package/workflows/containers/child/revoke.js +5 -5
  364. package/workflows/containers/child/revoke.js.map +1 -1
  365. package/workflows/containers/child/{replacementPrincipalPolicyReferences.js → rotation/replacementPrincipalPolicyReferences.js} +2 -2
  366. package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
  367. package/workflows/containers/child/{rotationContext.js → rotation/rotationContext.js} +5 -5
  368. package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
  369. package/workflows/containers/child/{rotationPrincipalPolicies.js → rotation/rotationPrincipalPolicies.js} +2 -2
  370. package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
  371. package/workflows/containers/child/{rotationWraps.js → rotation/rotationWraps.js} +1 -1
  372. package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
  373. package/workflows/containers/child/{currentShareGrantMutation.js → share/currentShareGrantMutation.js} +6 -6
  374. package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
  375. package/workflows/containers/child/{currentSharePrincipalPolicy.js → share/currentSharePrincipalPolicy.js} +10 -10
  376. package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
  377. package/workflows/containers/child/{share.d.ts → share/index.d.ts} +8 -8
  378. package/workflows/containers/child/{share.js → share/index.js} +10 -10
  379. package/workflows/containers/child/share/index.js.map +1 -0
  380. package/workflows/containers/child/{runtimeCurrentGroupShare.js → share/runtimeCurrentGroupShare.js} +6 -6
  381. package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
  382. package/workflows/containers/child/{shareAncestorRepair.js → share/shareAncestorRepair.js} +4 -4
  383. package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
  384. package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts} +5 -5
  385. package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js} +7 -7
  386. package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
  387. package/workflows/containers/child/{sharePlanCore.d.ts → share/sharePlanCore.d.ts} +7 -7
  388. package/workflows/containers/child/{sharePlanCore.js → share/sharePlanCore.js} +6 -6
  389. package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
  390. package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts} +9 -9
  391. package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js} +13 -13
  392. package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
  393. package/workflows/containers/child/share/shareProjection.js.map +1 -0
  394. package/workflows/containers/index.d.ts +10 -10
  395. package/workflows/containers/index.js +10 -10
  396. package/workflows/containers/index.js.map +1 -1
  397. package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
  398. package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
  399. package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
  400. package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
  401. package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
  402. package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
  403. package/workflows/documents/purge/index.js +1 -1
  404. package/workflows/documents/purge/index.js.map +1 -1
  405. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
  406. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
  407. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
  408. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
  409. package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
  410. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
  411. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
  412. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
  413. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
  414. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
  415. package/workflows/principals/policyCache/index.js +1 -1
  416. package/workflows/principals/policyCache/index.js.map +1 -1
  417. package/workflows/principals/policyRepair.js +1 -1
  418. package/workflows/principals/policyRepair.js.map +1 -1
  419. package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
  420. package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
  421. package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
  422. package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
  423. package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
  424. package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
  425. package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
  426. package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
  427. package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
  428. package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
  429. package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
  430. package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
  431. package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
  432. package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
  433. package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
  434. package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
  435. package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
  436. package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
  437. package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
  438. package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
  439. package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
  440. package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
  441. package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
  442. package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
  443. package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
  444. package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
  445. package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
  446. package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
  447. package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
  448. package/stores/container-contents/backgroundHydration.js.map +0 -1
  449. package/stores/container-contents/containerPurgeCore.js.map +0 -1
  450. package/stores/container-contents/containerStateMap.js.map +0 -1
  451. package/stores/container-contents/containerStatePersistence.js.map +0 -1
  452. package/stores/container-contents/documentRecovery.js.map +0 -1
  453. package/stores/container-contents/documentRotation.js.map +0 -1
  454. package/stores/container-contents/documentWork.js.map +0 -1
  455. package/stores/container-contents/emptyTrashOperation.js.map +0 -1
  456. package/stores/container-contents/existingSystemContainer.js.map +0 -1
  457. package/stores/container-contents/groupRewrapOperation.js.map +0 -1
  458. package/stores/container-contents/missingContainerState.js.map +0 -1
  459. package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
  460. package/stores/container-contents/operations.js.map +0 -1
  461. package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
  462. package/stores/container-contents/purgeContainerOperation.js.map +0 -1
  463. package/stores/container-contents/reconcilableContainer.js.map +0 -1
  464. package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
  465. package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
  466. package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
  467. package/stores/container-contents/remoteEventSync.js.map +0 -1
  468. package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
  469. package/stores/container-contents/remoteWriteGuards.js.map +0 -1
  470. package/stores/container-contents/remoteWriteQueue.js.map +0 -1
  471. package/stores/container-contents/reportShareFailure.js.map +0 -1
  472. package/stores/container-contents/setContainerIconOperation.js.map +0 -1
  473. package/stores/container-contents/shareOperations.js.map +0 -1
  474. package/stores/container-contents/startupHydration.js.map +0 -1
  475. package/stores/container-contents/syncAgent.js.map +0 -1
  476. package/stores/container-contents/syncAgentTypes.js.map +0 -1
  477. package/stores/container-contents/syncLaneIteration.js.map +0 -1
  478. package/stores/container-contents/systemContainerHydration.js.map +0 -1
  479. package/stores/container-contents/systemContainerIcon.js.map +0 -1
  480. package/stores/container-contents/systemContainerLookup.js.map +0 -1
  481. package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
  482. package/stores/container-contents/systemContainerPromotion.js.map +0 -1
  483. package/stores/container-contents/writeGeneration.js.map +0 -1
  484. package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
  485. package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
  486. package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
  487. package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
  488. package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
  489. package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
  490. package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
  491. package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
  492. package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
  493. package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
  494. package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
  495. package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
  496. package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
  497. package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
  498. package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
  499. package/stores/documents/documentStore/attachments.js.map +0 -1
  500. package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
  501. package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
  502. package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
  503. package/stores/documents/documentStore/historyRebuild.js.map +0 -1
  504. package/stores/documents/documentStore/initialization.js.map +0 -1
  505. package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
  506. package/stores/documents/documentStore/initializationHistory.js.map +0 -1
  507. package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
  508. package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
  509. package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
  510. package/stores/documents/documentStore/remoteWork.js.map +0 -1
  511. package/stores/documents/documentStore/rotation.js.map +0 -1
  512. package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
  513. package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
  514. package/stores/documents/documentStore/sync.js.map +0 -1
  515. package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
  516. package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
  517. package/stores/documents/documentStore/syncAttachments.js.map +0 -1
  518. package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
  519. package/stores/documents/documentStore/syncFinalize.js.map +0 -1
  520. package/stores/documents/documentStore/syncGeneration.js.map +0 -1
  521. package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
  522. package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
  523. package/stores/documents/documentStore/syncRequest.js.map +0 -1
  524. package/stores/documents/documentStore/syncShared.js.map +0 -1
  525. package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
  526. package/stores/documents/documentStore.js.map +0 -1
  527. package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
  528. package/workflows/container-contents/container-state/createChild.js.map +0 -1
  529. package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
  530. package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
  531. package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
  532. package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
  533. package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
  534. package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
  535. package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
  536. package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
  537. package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
  538. package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
  539. package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
  540. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
  541. package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
  542. package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
  543. package/workflows/container-contents/container-state/share.js.map +0 -1
  544. package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
  545. package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
  546. package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
  547. package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
  548. package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
  549. package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
  550. package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
  551. package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
  552. package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
  553. package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
  554. package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
  555. package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
  556. package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
  557. package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
  558. package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
  559. package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
  560. package/workflows/containers/child/create.js.map +0 -1
  561. package/workflows/containers/child/createProjection.js.map +0 -1
  562. package/workflows/containers/child/createSubmission.js.map +0 -1
  563. package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
  564. package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
  565. package/workflows/containers/child/move.js.map +0 -1
  566. package/workflows/containers/child/moveArtifacts.js.map +0 -1
  567. package/workflows/containers/child/moveRotation.js.map +0 -1
  568. package/workflows/containers/child/moveWraps.js.map +0 -1
  569. package/workflows/containers/child/rekey.js.map +0 -1
  570. package/workflows/containers/child/rekeyProjection.js.map +0 -1
  571. package/workflows/containers/child/rekeyRemote.js.map +0 -1
  572. package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
  573. package/workflows/containers/child/rotationContext.js.map +0 -1
  574. package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
  575. package/workflows/containers/child/rotationWraps.js.map +0 -1
  576. package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
  577. package/workflows/containers/child/share.js.map +0 -1
  578. package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
  579. package/workflows/containers/child/shareMaterialization.js.map +0 -1
  580. package/workflows/containers/child/sharePlanCore.js.map +0 -1
  581. package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
  582. package/workflows/containers/child/shareProjection.js.map +0 -1
  583. /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
  584. /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
  585. /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
  586. /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
  587. /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
  588. /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
  589. /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
  590. /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
  591. /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
  592. /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
  593. /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
  594. /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
  595. /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
  596. /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
  597. /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
  598. /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
  599. /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
  600. /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
  601. /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
  602. /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
  603. /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
  604. /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
  605. /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
  606. /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
  607. /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
  608. /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
  609. /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
  610. /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
  611. /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
  612. /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
  613. /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
  614. /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
  615. /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
  616. /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
@@ -1 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BAAkB,KAAK,IAAI;QAC3B,CAAC,CAAC,IAAI,CAAC,cAAc;QACrB,IAAI,CAAC,cAAc,KAAK,kBAAkB;QAC1C,CAAC,IAAI,CAAC,oBAAoB,KAAK,MAAM;YACnC,IAAI,CAAC,oBAAoB,KAAK,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerNode } from \"./types\";\n\n/**\n * Whether a container is a system container — one tagged with a deterministic\n * `systemSlot` for a built-in role such as Contacts, Trash, organization\n * metadata, or the per-organization roster.\n */\nexport function isSystemContainerNode(\n node: Pick<ContainerNode, \"systemSlot\">,\n): boolean {\n return !!node.systemSlot;\n}\n\n/** Whether a container has completed enough remote creation to be listed. */\nexport function isRemoteBackedContainerNode(\n node: Pick<ContainerNode, \"metadataDocumentId\">,\n): boolean {\n return (\n typeof node.metadataDocumentId === \"string\" &&\n node.metadataDocumentId.length > 0\n );\n}\n\n/**\n * Whether generic document reconciliation may safely list this container.\n *\n * Every container joins generic reconciliation only after remote creation has\n * given it a metadata document id. This keeps local-first roots and children\n * out of an HTTP lane that cannot exist yet, while still letting another device\n * rematerialize Contacts, Trash, and other system data.\n */\nexport function isReconcilableContainerNode(\n node: Pick<\n ContainerNode,\n | \"effectiveAccessLevel\"\n | \"metadataDocumentId\"\n | \"organizationId\"\n | \"systemSlot\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n // Document discovery is an HTTP read against the remote container id. A\n // local-first container has no such lane until its metadata create has\n // committed; attempting to list it can only produce a 404. This applies to\n // the pre-auth local root just as much as to a local system container.\n if (!isRemoteBackedContainerNode(node)) {\n return false;\n }\n\n if (!isSystemContainerNode(node)) {\n return true;\n }\n\n return (\n homeOrganizationId !== null &&\n (node.organizationId === homeOrganizationId ||\n isForeignSystemContainerNode(node, homeOrganizationId))\n );\n}\n\n/**\n * Whether a root-lane discovery hint should re-list this container's documents.\n *\n * The server's root discovery lane can return directly granted non-root\n * containers, so every remote-backed regular container remains eligible\n * regardless of its parent. Membership-visible foreign system containers\n * remain eligible for catch-up. Own system children are excluded here because\n * cold/auth backfill and explicit full refresh already reconcile them; sweeping\n * them on every Explorer-open or shared-root hint creates redundant work.\n */\nexport function isAutomaticRootCatchupContainerNode(\n node: Pick<\n ContainerNode,\n | \"effectiveAccessLevel\"\n | \"metadataDocumentId\"\n | \"organizationId\"\n | \"systemSlot\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n return (\n isRemoteBackedContainerNode(node) &&\n (!isSystemContainerNode(node) ||\n isForeignSystemContainerNode(node, homeOrganizationId))\n );\n}\n\n/**\n * Whether a system container belongs to a foreign organization whose contents\n * are visible through membership-level access.\n *\n * Event routing uses this classification for foreign system content whose\n * already-known document updates must still force discovery. It is not the\n * generic sweep predicate: remote-backed own system containers also reconcile\n * via {@link isReconcilableContainerNode}. A foreign system container is one\n * that is:\n *\n * - a different org's (`organizationId !== homeOrganizationId`). Own system\n * containers are outside this foreign-system classification, while a\n * container mid-creation has an empty organization id that matches nothing\n * (as does a null/unhydrated home org).\n * - granted at a *membership* level — `read` (Members group) or `admin`\n * (Admins group). A plain `write` share of a folder does not make the sharee\n * a member, so it does not opt that folder into automatic root catch-up.\n */\nexport function isForeignSystemContainerNode(\n node: Pick<\n ContainerNode,\n \"systemSlot\" | \"organizationId\" | \"effectiveAccessLevel\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n return (\n isSystemContainerNode(node) &&\n homeOrganizationId !== null &&\n !!node.organizationId &&\n node.organizationId !== homeOrganizationId &&\n (node.effectiveAccessLevel === \"read\" ||\n node.effectiveAccessLevel === \"admin\")\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteBackedContainerState.js","sourceRoot":"","sources":["remoteBackedContainerState.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B,CAC1C,cAA8B;IAE9B,OAAO,CACL,OAAO,cAAc,CAAC,SAAS,CAAC,kBAAkB,KAAK,QAAQ;QAC/D,cAAc,CAAC,SAAS,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;QACtD,OAAO,cAAc,CAAC,MAAM,CAAC,UAAU,KAAK,QAAQ;QACpD,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QAC3C,OAAO,cAAc,CAAC,MAAM,CAAC,eAAe,KAAK,QAAQ;QACzD,cAAc,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CACjD,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\n\nexport function isRemoteBackedContainerState(\n containerState: ContainerState,\n): boolean {\n return (\n typeof containerState.container.metadataDocumentId === \"string\" &&\n containerState.container.metadataDocumentId.length > 0 &&\n typeof containerState.record.documentId === \"string\" &&\n containerState.record.documentId.length > 0 &&\n typeof containerState.record.accessStateHash === \"string\" &&\n containerState.record.accessStateHash.length > 0\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteContainerIngestion.js","sourceRoot":"","sources":["remoteContainerIngestion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,6BAA6B,GAG9B,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,wCAAwC,EAAE,MAAM,0BAA0B,CAAC;AAQpF,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,KAKvD;IACC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC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AAC,kDAAkD,YAAY,CAAC,KAAK,CAAC,EAAE,CACnH,CAAC;YACJ,CAAC;YACD,eAAe,EAAE,KAAK,IAAI,EAAE;gBAC1B,MAAM,wCAAwC,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC;YACD,eAAe;SAChB,CAAC;KACL,CAAC;AACJ,CAAC","sourcesContent":["import { errorMessage } from \"../../data/shared/errorMessage\";\nimport {\n createRemoteContainerIngestor,\n type RemoteContainer,\n type RemoteContainerHydrationHost,\n} from \"../../workflows/container-contents/remoteHydration\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { resumeContainerContentsRecoveryHydration } from \"./remoteHydrationRequest\";\nimport type { ContainerContentsStoreSyncState } from \"./syncAgentTypes\";\n\ninterface RemoteContainerIngestionController {\n ingest: (remoteContainer: RemoteContainer) => Promise<void>;\n resumeInterruptedWork: () => Promise<void>;\n}\n\nexport async function resumeRemoteContainerRecoveryWork(input: {\n onIngestionError: (error: unknown) => void;\n onHydrationError: (error: unknown) => void;\n resumeHydration: () => Promise<void>;\n resumeIngestion: () => Promise<void>;\n}): Promise<void> {\n try {\n await input.resumeIngestion();\n } catch (error) {\n input.onIngestionError(error);\n return;\n }\n try {\n await input.resumeHydration();\n } catch (error) {\n input.onHydrationError(error);\n }\n}\n\nexport function createRemoteContainerIngestionController(input: {\n host: RemoteContainerHydrationHost;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}): RemoteContainerIngestionController {\n const { host, scheduleSync, state } = input;\n const remoteContainerIngestor = createRemoteContainerIngestor({\n getSerializationBarrier: () => state.initializePromise,\n host,\n state,\n });\n const scheduleAfterIngestion = () => {\n if (\n state.runtime.infra.dbStatus === \"ready\" &&\n state.documentStoresNeedPriming\n ) {\n scheduleSync();\n }\n };\n const resumeIngestion = async () => {\n const hadPendingIngestion = remoteContainerIngestor.hasPending();\n await remoteContainerIngestor.resume();\n if (hadPendingIngestion) {\n scheduleAfterIngestion();\n }\n };\n\n return {\n ingest: async (remoteContainer) => {\n await remoteContainerIngestor(remoteContainer);\n scheduleAfterIngestion();\n },\n resumeInterruptedWork: () =>\n resumeRemoteContainerRecoveryWork({\n onHydrationError: (error) => {\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: failed to resume remote hydration: ${errorMessage(error)}`,\n );\n },\n onIngestionError: (error) => {\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: failed to resume remote container ingestion: ${errorMessage(error)}`,\n );\n },\n resumeHydration: async () => {\n await resumeContainerContentsRecoveryHydration(state);\n },\n resumeIngestion,\n }),\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteEventProjectionInvalidation.js","sourceRoot":"","sources":["remoteEventProjectionInvalidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oEAAoE,CAAC;AAGpH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAA0E,EAC1E,WAA8B;IAE9B,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACrC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,KAAK,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACxD,IAAI,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC;QACjD,KACE,IAAI,KAAK,GAAG,CAAC,EACb,QAAQ,KAAK,IAAI;YACjB,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;YACpB,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,EACjC,KAAK,EAAE;YAEP,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC;QAC5E,IAAI,QAAQ,KAAK,IAAI;YAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,cAAc;YAAE,8BAA8B,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { invalidateContainerProjections } from \"../../workflows/container-contents/container-state/projectionCache\";\nimport type { ContainerContentsStoreSyncState } from \"./syncAgentTypes\";\n\n/**\n * Drop every cached writer projection a hint invalidates, before hydration\n * lands, so the next share or move fetches a fresh one instead of submitting\n * against a stale manifest and conflicting. Descendants cite the same ancestor\n * manifests in their paths, so the locally known subtree under each invalidated\n * container is dropped too (an unhydrated subtree has nothing cached). Both\n * layers go: the in-memory copies on each container state, and the api-client's\n * cached writer projections that cite an invalidated container. Document\n * projections cite their paths too, so they are found by citation rather than\n * through the links, which live in SQLite; projections citing none of them stay\n * cached (#2395). Each open document store drops its own in-memory copy on the\n * same hint.\n */\nexport function invalidateCachedProjections(\n state: Pick<ContainerContentsStoreSyncState, \"containersById\" | \"runtime\">,\n invalidated: readonly string[],\n): void {\n if (invalidated.length === 0) return;\n const roots = new Set(invalidated);\n const stale = new Set(invalidated);\n for (const [id, containerState] of state.containersById) {\n let parentId = containerState.container.parentId;\n for (\n let depth = 0;\n parentId !== null &&\n !roots.has(parentId) &&\n depth < state.containersById.size;\n depth++\n )\n parentId = state.containersById.get(parentId)?.container.parentId ?? null;\n if (parentId !== null) stale.add(id);\n }\n for (const id of stale) {\n const containerState = state.containersById.get(id);\n if (containerState) invalidateContainerProjections(containerState);\n }\n state.runtime.apiClient.evictWriterProjectionsCiting(invalidated);\n}\n"]}
@@ -1 +0,0 @@
1
- {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mCAAmC,CAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,mBAAmB,GAAG,sCAAsC,CAChE,UAAU,EACV,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,EAC7B,KAAK,CAAC,gCAAgC,CACvC,CAAC;IACF,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,KAAK,CAAC,8BAA8B,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC7D,mBAAmB,CAAC,KAAK,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,YAAY,EAAE,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import {\n listContainerParentIdsForEventHydration,\n listContainerProjectionInvalidationIds,\n} from \"../../workflows/container-contents/containerEvents\";\nimport { listContainerMetadataDocumentUpdateIds } from \"../../workflows/container-contents/metadata\";\nimport { observeContainerBackgroundHydration } from \"./backgroundHydration\";\nimport { bumpMetadataSyncSeq } from \"./metadataSyncSignal\";\nimport { invalidateCachedProjections } from \"./remoteEventProjectionInvalidation\";\nimport type { ContainerContentsStoreSyncState } from \"./syncAgentTypes\";\n\nexport function handleContainerContentsRemoteEvents(input: {\n requestHydration: () => Promise<void>;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}): void {\n const { requestHydration, scheduleSync, state } = input;\n // Metadata events are classified through the initialized container records.\n // Do not consume the cursor while a replacement database is still loading;\n // initialization calls this handler again once those identities exist.\n if (!state.initialized) {\n return;\n }\n const nextEvents = state.runtime.state.events.slice(state.lastEventCount);\n state.lastEventCount = state.runtime.state.events.length;\n // A peer's grant, rekey, or recite changed a manifest this client's cached\n // projections cite, without evicting this subscriber.\n invalidateCachedProjections(\n state,\n listContainerProjectionInvalidationIds(nextEvents),\n );\n let addedHydrationLane = false;\n for (const parentId of listContainerParentIdsForEventHydration(nextEvents)) {\n if (!state.containerParentIdsNeedingHydration.has(parentId)) {\n addedHydrationLane = true;\n }\n state.containerParentIdsNeedingHydration.add(parentId);\n }\n if (addedHydrationLane) {\n observeContainerBackgroundHydration(state, requestHydration());\n }\n\n const metadataDocumentIds = listContainerMetadataDocumentUpdateIds(\n nextEvents,\n state.containersById.values(),\n state.locallyAcceptedMetadataUpdateIds,\n );\n for (const metadataDocumentId of metadataDocumentIds) {\n state.metadataDocumentIdsNeedingSync.add(metadataDocumentId);\n bumpMetadataSyncSeq(state.metadataSyncSignalSeqById, metadataDocumentId);\n }\n if (metadataDocumentIds.length > 0) {\n scheduleSync();\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteHydrationRequest.js","sourceRoot":"","sources":["remoteHydrationRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAEvB,yBAAyB,GAC1B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAEL,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAyCxB,SAAS,0BAA0B,CAAC,KAInC;IACC,OAAO,CACL,KAAK,CAAC,KAAK,CAAC,mBAAmB,KAAK,KAAK,CAAC,mBAAmB;QAC7D,KAAK,CAAC,KAAK,CAAC,oBAAoB,KAAK,KAAK,CAAC,oBAAoB,CAChE,CAAC;AACJ,CAAC;AAED,MAAM,gCAAgC,GAAG,IAAI,OAAO,EAGjD,CAAC;AACJ,SAAS,6BAA6B,CACpC,KAAkC;IAElC,MAAM,QAAQ,GAAG,gCAAgC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnE,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,CAAC;YACzD,QAAQ,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;YACnC,KAAK,CAAC,QAAQ,CAAC,KAAK;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;YAClC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAC1B,CAAC;YACD,YAAY,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,8BAA8B,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,0BAA0B,EAAE,CAAC;YAC/B,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,sBAAsB,GAAG,gBAAgB,CAAC;IAEhD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n createGenerationGuardedHydrationHost,\n hydrateRemoteContainers,\n type RemoteContainerHydrationHost,\n StaleRemoteHydrationError,\n} from \"../../workflows/container-contents/remoteHydration\";\nimport type { RemoteContainerHydrationState } from \"../../workflows/container-contents/remoteHydration/types\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport {\n type LocalContainerRefreshState,\n refreshLocalContainerStates,\n} from \"./localRefresh\";\n\ntype RemoteHydrationRequestState = RemoteContainerHydrationState &\n LocalContainerRefreshState & {\n containerParentIdsNeedingHydration: Set<string | null>;\n initializePromise: Promise<void> | null;\n lifecycleGeneration: number;\n remoteHydrationGeneration: number | null;\n remoteHydrationPromise: Promise<void> | null;\n remoteHydrationStructuralGeneration: number | null;\n rootLaneHydrated: boolean;\n snapshot: {\n ready: boolean;\n };\n structuralGeneration: number;\n };\n\ninterface RemoteHydrationRequestInput {\n followDiscoveredParentLanes?: boolean | undefined;\n host: RemoteContainerHydrationHost;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n recreateOnFullyHydratedAfterReset?:\n | (() => () => Promise<void> | void)\n | undefined;\n recreateOnFullyHydratedAtStart?: boolean | undefined;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSyncAfterHydration?: boolean | undefined;\n scheduleSyncOnHydrationChange?: boolean | undefined;\n scheduleSync: () => void;\n state: RemoteHydrationRequestState;\n}\n\ninterface RecoveryHydrationRequest {\n input: RemoteHydrationRequestInput;\n lifecycleGeneration: number;\n structuralGeneration: number;\n}\n\nfunction isRequestGenerationCurrent(input: {\n lifecycleGeneration: number;\n state: RemoteHydrationRequestState;\n structuralGeneration: number;\n}): boolean {\n return (\n input.state.lifecycleGeneration === input.lifecycleGeneration &&\n input.state.structuralGeneration === input.structuralGeneration\n );\n}\n\nconst recoveryHydrationRequestsByState = new WeakMap<\n RemoteHydrationRequestState,\n RecoveryHydrationRequest[]\n>();\nfunction queueRecoveryHydrationRequest(\n input: RemoteHydrationRequestInput,\n): void {\n const requests = recoveryHydrationRequestsByState.get(input.state);\n if (requests) {\n if (!requests.some((request) => request.input === input)) {\n requests.push({\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n });\n }\n return;\n }\n recoveryHydrationRequestsByState.set(input.state, [\n {\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n },\n ]);\n}\n\nfunction hasRemoteHydrationPrerequisites(\n state: RemoteHydrationRequestState,\n): boolean {\n return (\n state.runtime.infra.dbStatus === \"ready\" &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n );\n}\n\nfunction createResetRecoveryInput(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n return {\n ...input,\n followDiscoveredParentLanes: true,\n onFullyHydrated: undefined,\n parentIds: undefined,\n recreateOnFullyHydratedAtStart: true,\n };\n}\n\nfunction resumeRetainedRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n queueRecoveryHydrationRequest(input);\n return hasRemoteHydrationPrerequisites(input.state)\n ? input.resumeRecoveryWork()\n : Promise.resolve();\n}\n\nfunction waitForActiveRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeHydration = state.remoteHydrationPromise;\n if (!activeHydration) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n const needsCurrentGenerationHydration =\n state.remoteHydrationGeneration !== state.lifecycleGeneration ||\n state.remoteHydrationStructuralGeneration !== state.structuralGeneration;\n const requestQueuedHydration = () => {\n if (\n !isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ) {\n return retryRemoteHydrationAfterReset(input);\n }\n return needsCurrentGenerationHydration ||\n state.containerParentIdsNeedingHydration.size > 0\n ? requestContainerContentsRemoteHydration(input)\n : undefined;\n };\n return activeHydration.then(\n requestQueuedHydration,\n (error: unknown) => requestQueuedHydration() ?? Promise.reject(error),\n );\n}\n\nfunction waitForActiveInitialization(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeInitialization = state.initializePromise;\n if (!activeInitialization) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n return activeInitialization.then(() => {\n const recoveryInput = isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ? input\n : createResetRecoveryInput(input);\n return resumeRetainedRecoveryHydration(recoveryInput);\n });\n}\n\nfunction retryRemoteHydrationAfterReset(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n return resumeRetainedRecoveryHydration(createResetRecoveryInput(input));\n}\n\nfunction retainResetRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): void {\n queueRecoveryHydrationRequest(createResetRecoveryInput(input));\n}\n\nexport function resumeContainerContentsRecoveryHydration(\n state: RemoteHydrationRequestState,\n): Promise<void> | null {\n const requests = recoveryHydrationRequestsByState.get(state);\n if (!requests) {\n return null;\n }\n recoveryHydrationRequestsByState.delete(state);\n const inputs = requests.map((request) =>\n isRequestGenerationCurrent({\n lifecycleGeneration: request.lifecycleGeneration,\n state,\n structuralGeneration: request.structuralGeneration,\n })\n ? request.input\n : createResetRecoveryInput(request.input),\n );\n return Promise.all(inputs.map(requestContainerContentsRemoteHydration))\n .then(() => undefined)\n .catch((error: unknown) => {\n for (const input of inputs) {\n queueRecoveryHydrationRequest(input);\n }\n throw error;\n });\n}\n\nfunction queueRequestedParentIds(input: RemoteHydrationRequestInput): void {\n if (!input.parentIds) {\n return;\n }\n for (const parentId of input.parentIds) {\n input.state.containerParentIdsNeedingHydration.add(parentId);\n }\n}\n\nfunction waitForRemoteHydrationReadiness(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const activeHydration = waitForActiveRemoteHydration(input);\n if (activeHydration) {\n return activeHydration;\n }\n const activeInitialization = waitForActiveInitialization(input);\n if (activeInitialization) {\n return activeInitialization;\n }\n if (!hasRemoteHydrationPrerequisites(input.state)) {\n queueRecoveryHydrationRequest(input);\n return Promise.resolve();\n }\n return null;\n}\n\nfunction consumeQueuedHydrationScope(\n state: RemoteHydrationRequestState,\n followDiscoveredParentLanesOption: boolean | undefined,\n): {\n followDiscoveredParentLanes: boolean;\n parentIds: ReadonlyArray<string | null> | undefined;\n} {\n const queuedParentIds = Array.from(state.containerParentIdsNeedingHydration);\n const followDiscoveredParentLanes =\n followDiscoveredParentLanesOption ?? queuedParentIds.length === 0;\n state.containerParentIdsNeedingHydration.clear();\n return {\n followDiscoveredParentLanes,\n parentIds:\n followDiscoveredParentLanes || queuedParentIds.length === 0\n ? undefined\n : queuedParentIds,\n };\n}\n\nexport function requestContainerContentsRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n const { host, scheduleSync, state } = input;\n queueRequestedParentIds(input);\n const readinessBarrier = waitForRemoteHydrationReadiness(input);\n if (readinessBarrier) {\n return readinessBarrier;\n }\n\n const { followDiscoveredParentLanes, parentIds } =\n consumeQueuedHydrationScope(state, input.followDiscoveredParentLanes);\n\n let appliedRemoteContainerChange = false;\n let retainInterruptedHydration = false;\n const lifecycleGeneration = state.lifecycleGeneration;\n const structuralGeneration = state.structuralGeneration;\n const isCurrent = () =>\n isRequestGenerationCurrent({\n lifecycleGeneration,\n state,\n structuralGeneration,\n });\n const onFullyHydrated = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n const hydrationHost = createGenerationGuardedHydrationHost({\n host,\n isCurrent,\n });\n const rootLaneHydratedBeforeRequest = state.rootLaneHydrated;\n state.remoteHydrationGeneration = lifecycleGeneration;\n state.remoteHydrationStructuralGeneration = structuralGeneration;\n const hydrationPromise = refreshLocalContainerStates({\n host: hydrationHost,\n state,\n })\n .then(() => {\n if (!isCurrent()) {\n return 0;\n }\n return hydrateRemoteContainers({\n followDiscoveredParentLanes,\n host: hydrationHost,\n isCurrent,\n onFullyHydrated,\n parentIds,\n resetAllLaneWatermarks: input.resetAllLaneWatermarks,\n resetRootLaneWatermark: input.resetRootLaneWatermark,\n state,\n });\n })\n .then((changedCount) => {\n appliedRemoteContainerChange = changedCount > 0;\n if (isCurrent() && !hasRemoteHydrationPrerequisites(state)) {\n retainInterruptedHydration = true;\n }\n })\n .catch((error: unknown) => {\n if (isCurrent() && isDatabaseUnavailableError(error)) {\n retainInterruptedHydration = true;\n return;\n }\n if (!isCurrent() || error instanceof StaleRemoteHydrationError) {\n return;\n }\n\n throw error;\n })\n .finally(() => {\n const shouldRetryAfterReset = !isCurrent();\n if (state.remoteHydrationPromise === hydrationPromise) {\n state.remoteHydrationPromise = null;\n state.remoteHydrationGeneration = null;\n state.remoteHydrationStructuralGeneration = null;\n }\n\n if (\n isCurrent() &&\n (((input.scheduleSyncOnHydrationChange ?? true) &&\n (appliedRemoteContainerChange ||\n (!rootLaneHydratedBeforeRequest && state.rootLaneHydrated))) ||\n input.scheduleSyncAfterHydration) &&\n state.snapshot.ready &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n ) {\n scheduleSync();\n }\n if (shouldRetryAfterReset) {\n return retryRemoteHydrationAfterReset(input);\n }\n if (retainInterruptedHydration) {\n retainResetRecoveryHydration(input);\n }\n return undefined;\n });\n state.remoteHydrationPromise = hydrationPromise;\n\n return hydrationPromise;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteWriteGuards.js","sourceRoot":"","sources":["remoteWriteGuards.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAY/C,MAAM,aAAa,GAAG,IAAI,OAAO,EAG9B,CAAC;AAEJ,+EAA+E;AAC/E,MAAM,UAAU,+BAA+B,CAC7C,KAAkC,EAClC,UAAoC,EACpC,OAAgB;IAEhB,IAAI,UAAU,EAAE,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO;IAC9D,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACnD,IAAI,MAA0B,CAAC;QAC/B,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1D,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,GAAG,CACP,+BAA+B,CAC7B,KAAK,EACL,KAAK,CAAC,KAAK,CAAC,UAAU,EACtB,IAAI,CACL;oBACD,+BAA+B,CAC7B,KAAK,EACL,IAAI,CAAC,SAAS,CAAC,cAAc;wBAC3B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc;wBACjC,EAAE,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,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACnD,IACE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;YAC/B,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM;YAC7B,KAAK,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,EACrC,CAAC;YACD,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport {\n findOrganizationSystemRootState,\n findSystemContainerStateForRoot,\n} from \"./systemContainerLookup\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport { isContainerInSubtree } from \"./utils\";\n\nexport type RemoteContainerWriteScope =\n | string\n | {\n rootId: string;\n systemSlot: ContainerSystemSlot;\n };\ninterface ActiveRemoteWrite {\n changed: boolean;\n scope: RemoteContainerWriteScope | undefined;\n}\nconst activeByState = new WeakMap<\n ContainerContentsStoreState,\n Set<ActiveRemoteWrite>\n>();\n\n/** Invalidate remote settlement only when a local edit touches its subtree. */\nexport function invalidateRemoteContainerWrites(\n state: ContainerContentsStoreState,\n changedIds: readonly string[] | null,\n movedId?: string,\n): void {\n if (changedIds?.length === 0 && movedId === undefined) return;\n for (const write of activeByState.get(state) ?? []) {\n let rootId: string | undefined;\n if (typeof write.scope === \"object\") {\n const root = state.containersById.get(write.scope.rootId);\n if (root) {\n rootId = (\n findSystemContainerStateForRoot(\n state,\n write.scope.systemSlot,\n root,\n ) ??\n findOrganizationSystemRootState(\n state,\n root.container.organizationId ||\n state.runtime.auth.organizationId ||\n \"\",\n write.scope.systemSlot,\n )\n )?.container.id;\n }\n } else {\n rootId = write.scope;\n }\n if (\n write.scope === undefined ||\n changedIds === null ||\n (rootId !== undefined &&\n (changedIds.some((id) =>\n isContainerInSubtree(state.containersById, id, rootId),\n ) ||\n (movedId !== undefined &&\n isContainerInSubtree(state.containersById, rootId, movedId))))\n ) {\n write.changed = true;\n }\n }\n}\n\nexport function trackRemoteContainerWrite(\n state: ContainerContentsStoreState,\n scope?: RemoteContainerWriteScope,\n) {\n const active = activeByState.get(state) ?? new Set<ActiveRemoteWrite>();\n activeByState.set(state, active);\n const write: ActiveRemoteWrite = { changed: false, scope };\n active.add(write);\n return {\n changed: () => write.changed,\n dispose: () => {\n active.delete(write);\n },\n };\n}\n\n/** An undiscovered system child has a stable slot before it has a local id. */\nexport function invalidateRemoteSystemContainerWrite(\n state: ContainerContentsStoreState,\n rootId: string,\n systemSlot: ContainerSystemSlot,\n): void {\n for (const write of activeByState.get(state) ?? []) {\n if (\n typeof write.scope === \"object\" &&\n write.scope.rootId === rootId &&\n write.scope.systemSlot === systemSlot\n ) {\n write.changed = true;\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remoteWriteQueue.js","sourceRoot":"","sources":["remoteWriteQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAEL,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEpE,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAGpC,CAAC;AAEJ,mFAAmF;AACnF,MAAM,UAAU,wBAAwB,CACtC,KAAkC,EAClC,SAGC,EACD,WAAc,EACd,IAA8C,EAC9C,KAAiC,EACjC,UAAoD,EAAE;IAEtD,MAAM,cAAc,GAAG,+BAA+B,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,IAA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,CAAC,CAAC;gBACH,SAAS,CAAC,uBAAuB,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE;QAC7B,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI,CACb,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB;KACF,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { errorMessage } from \"../../data/shared/errorMessage\";\nimport {\n type RemoteContainerWriteScope,\n trackRemoteContainerWrite,\n} from \"./remoteWriteGuards\";\nimport type { ContainerContentsStoreSyncAgent } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport { captureContainerWriteGeneration } from \"./writeGeneration\";\n\nconst remoteWritesByState = new WeakMap<\n ContainerContentsStoreState,\n { current: () => boolean; tail: Promise<void> }\n>();\n\n/** Online operations serialize together; local writes never wait for their I/O. */\nexport function chainRemoteContainerTask<T>(\n state: ContainerContentsStoreState,\n syncAgent: Pick<\n ContainerContentsStoreSyncAgent,\n \"refreshLocalContainers\" | \"scheduleRemoteHydration\"\n >,\n staleResult: T,\n work: (isCurrent: () => boolean) => Promise<T>,\n scope?: RemoteContainerWriteScope,\n options: { preserveResultOnLocalWrite?: boolean } = {},\n): Promise<T> {\n const contextCurrent = captureContainerWriteGeneration(state);\n const previous = remoteWritesByState.get(state);\n const tail = previous?.current() ? previous.tail : Promise.resolve();\n const task = tail.then(async () => {\n if (!contextCurrent()) return staleResult;\n // Install the guard at one local queue boundary. New writes can proceed\n // immediately afterward; an ongoing stream cannot starve the remote task.\n const boundary = state.writeChain\n .catch(() => null)\n .then(() => trackRemoteContainerWrite(state, scope));\n state.writeChain = boundary.then(() => null);\n const tracked = await boundary;\n const isCurrent = () => contextCurrent() && !tracked.changed();\n try {\n if (!isCurrent()) return staleResult;\n const result = await work(isCurrent);\n // Only completed operations opt in. A replaced runtime always cancels.\n return contextCurrent() &&\n (!tracked.changed() || options.preserveResultOnLocalWrite)\n ? result\n : staleResult;\n } finally {\n tracked.dispose();\n if (contextCurrent() && tracked.changed()) {\n // The HTTP side may have committed before a new local write invalidated\n // this operation. Reconcile its authoritative result without allowing\n // the older operation to install state over the user's newer write.\n state.localContainersNeedRefresh = true;\n void syncAgent.refreshLocalContainers().catch((error: unknown) => {\n state.runtime.util.log(\n `Container contents: local refresh failed (${errorMessage(error)})`,\n );\n });\n syncAgent.scheduleRemoteHydration();\n }\n }\n });\n remoteWritesByState.set(state, {\n current: contextCurrent,\n tail: task.then(\n () => undefined,\n () => undefined,\n ),\n });\n return task;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"reportShareFailure.js","sourceRoot":"","sources":["reportShareFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,sCAAsC,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAG/D,mEAAmE;AACnE,+EAA+E;AAC/E,wEAAwE;AACxE,SAAS,cAAc,CAAC,IAAmB;IACzC,IAAI,CAAC;QACH,KAAK,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,8DAA8D;IAChE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAkC,EAClC,SAAiB,EACjB,KAAc;IAEd,MAAM,OAAO,GAAG,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,CAAC;IACnF,uEAAuE;IACvE,6EAA6E;IAC7E,2EAA2E;IAC3E,2EAA2E;IAC3E,0EAA0E;IAC1E,oCAAoC;IACpC,IACE,0BAA0B,CAAC,KAAK,CAAC;QACjC,sCAAsC,CAAC,KAAK,CAAC;QAC7C,yBAAyB,CAAC,KAAK,CAAC,EAChC,CAAC;QACD,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAED,cAAc,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { isKeyingVerificationError } from \"../../data/keyingProjectionVerification/error\";\nimport { isProjectionVerificationCancelledError } from \"../../workflows/containers\";\nimport { isDatabaseUnavailableError } from \"../../workflows/documents\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\n// Both host callbacks are declared `=> void` but may be async (see\n// Tearleads.logError), and this runs from a catch that rethrows to the caller,\n// where a throwing logger would replace the share failure with its own.\nfunction dispatchToHost(call: () => unknown): void {\n try {\n void Promise.resolve(call()).catch(() => undefined);\n } catch {\n // Hosts may throw synchronously or return a rejected promise.\n }\n}\n\n/**\n * Report a thrown container share through the host's diagnostics before the\n * failure propagates to the UI. The app can only show a generic label, so this\n * is the one place the actual failure — a persistence error or an invariant\n * throw — is observable off the device.\n * Purely observational: the error is always rethrown by the caller unchanged.\n */\nexport function reportContainerShareFailure(\n state: ContainerContentsStoreState,\n operation: string,\n error: unknown,\n): void {\n const message = `${getContainerContentsStoreLogLabel(state)}: ${operation} failed`;\n // Not an app failure, so it stays local: the runtime is released under\n // in-flight callers on every identity switch and host-driven database retry,\n // a projection verification cancelled by a newer generation re-runs on its\n // own, and a keying verification refusal (a rollback or a relabeled group,\n // which a duplicate grant can race into) belongs to the security-incident\n // path rather than app diagnostics.\n if (\n isDatabaseUnavailableError(error) ||\n isProjectionVerificationCancelledError(error) ||\n isKeyingVerificationError(error)\n ) {\n dispatchToHost(() => state.runtime.util.log(message));\n return;\n }\n\n const { logError } = state.runtime.util;\n if (!logError) {\n dispatchToHost(() => state.runtime.util.log(message));\n return;\n }\n\n dispatchToHost(() => logError(message, error));\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"setContainerIconOperation.js","sourceRoot":"","sources":["setContainerIconOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GACzC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,oEAAoE,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C,+EAA+E;AAC/E,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAkC,EAClC,SAA0C,EAC1C,WAAmB,EACnB,IAAmB,EACnB,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,GA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AAC,CAAC;AACxC,CAAC","sourcesContent":["import {\n installContainerMetadataRecord,\n setContainerIconMetadataStateFromRuntime,\n} from \"../../workflows/container-contents/metadata\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../workflows/container-contents/metadata/metadataStateIsolation\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type { ContainerContentsStoreSyncAgent } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport { toContainerNode } from \"./utils\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\n// Set the icon shown for a container. Mirrors renameContainer's write path: it\n// writes the icon into the container metadata document (CRDT), enqueues the\n// incremental update, persists, and schedules a sync. A null icon clears the\n// custom icon back to the default folder. No-ops when the icon is unchanged.\nexport async function setContainerIcon(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n icon: string | null,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n if (!existingState) {\n return null;\n }\n\n const normalizedIcon = icon?.trim() || null;\n if ((existingState.container.icon ?? null) === normalizedIcon) {\n return toContainerNode(existingState);\n }\n\n const detachedState =\n await createDetachedContainerMetadataState(existingState);\n if (!isCurrent()) return null;\n const updated = await setContainerIconMetadataStateFromRuntime({\n icon: normalizedIcon,\n metadataState: detachedState,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!isCurrent()) return null;\n if (!updated) {\n removeMissingContainerState(state, existingState);\n return null;\n }\n\n detachedState.container = updated.container;\n installContainerMetadataRecord(detachedState, updated.record);\n installDetachedContainerMetadataState(existingState, detachedState);\n updateContainerContentsSnapshot(state);\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: set container ${containerId} icon to \"${normalizedIcon ?? \"folder\"}\"`,\n );\n return toContainerNode(existingState);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shareOperations.js","sourceRoot":"","sources":["shareOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EACL,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,0DAA0D,CAAC;AAElE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAW1D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAAkC,EAClC,SAA0C,EAC1C,WAAmB,EACnB,KAE+C,EAC/C,UAAkB,EAClB,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,IACE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO;QACxC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK;QACrB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;QACnC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM;QAC3B,CAAC,SAAS,EAAE,EACZ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5D,MAAM,uBAAuB,GAAG,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC;IACtE,IACE,CAAC,aAAa,EAAE,MAAM,CAAC,UAAU;QACjC,OAAO,uBAAuB,KAAK,QAAQ;QAC3C,uBAAuB,CAAC,MA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;KACxD,EACD,GAAG,EAAE,CACH,4BAA4B,CAAC;QAC3B,WAAW;QACX,cAAc;QACd,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,gBAAgB,EAAE,OAAO;QACzB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;QACxD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,YAAY,EAAE,SAAS;KACxB,CAAC,CACL,EACH,oBAAoB,WAAW,eAAe,OAAO,EAAE,EACvD,SAAS,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { runWithSecurityIncidentReporting } from \"../../data/keyingProjectionVerification/error\";\nimport {\n shareContainerState,\n shareContainerStateWithGroup,\n} from \"../../workflows/container-contents/container-state/share\";\nimport type { SharedContainerStateResult } from \"../../workflows/container-contents/container-state/types\";\nimport { installContainerMetadataRecord } from \"../../workflows/container-contents/metadata\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\nimport { reportContainerShareFailure } from \"./reportShareFailure\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport type {\n ContainerContentsShareAccessLevel,\n ContainerContentsStoreState,\n} from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nexport async function shareContainerUsing(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n share: (\n containerState: ContainerState,\n ) => Promise<SharedContainerStateResult | null>,\n logMessage: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online ||\n !isCurrent()\n ) {\n return false;\n }\n\n const existingState = state.containersById.get(containerId);\n const expectedAccessStateHash = existingState?.record.accessStateHash;\n if (\n !existingState?.record.documentId ||\n typeof expectedAccessStateHash !== \"string\" ||\n expectedAccessStateHash.length === 0\n ) {\n return false;\n }\n\n let shared: SharedContainerStateResult | null;\n try {\n shared = await share(existingState);\n } catch (error) {\n reportContainerShareFailure(state, \"share\", error);\n throw error;\n }\n if (!shared || !isCurrent() || shared.status === \"confirmed\") {\n if (!isCurrent() || shared?.status === \"confirmed\") {\n state.localContainersNeedRefresh = true;\n state.containerParentIdsNeedingHydration.add(\n existingState.container.parentId,\n );\n void syncAgent.refreshLocalContainers();\n syncAgent.scheduleRemoteHydration();\n }\n return shared?.status === \"confirmed\" || shared?.status === \"persisted\";\n }\n if (shared.status === \"missing\") {\n removeMissingContainerState(state, existingState);\n return false;\n }\n\n existingState.container = shared.container;\n installContainerMetadataRecord(existingState, shared.record);\n updateContainerContentsSnapshot(state);\n if (shared.status === \"identity-superseded\") return false;\n\n await syncAgent.primeDocumentsForSharedSubtree(containerId, isCurrent);\n if (!isCurrent()) return true;\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${logMessage}`,\n );\n return true;\n}\n\nexport async function shareContainerWithUser(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n userId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n return shareContainerUsing(\n state,\n syncAgent,\n containerId,\n (containerState) =>\n shareContainerState({\n accessLevel: \"write\",\n containerState,\n persistence: state.persistence,\n recipientUserId: userId,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n }),\n `shared container ${containerId} with ${userId}`,\n isCurrent,\n );\n}\n\nexport async function shareContainerWithGroup(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n groupId: string,\n accessLevel: ContainerContentsShareAccessLevel,\n options: {\n expectedGroupName?: string | undefined;\n knownContainerKeks?: ReadonlyMap<string, Uint8Array> | undefined;\n requireExistingGrant?: boolean | undefined;\n } = {},\n isCurrent: ContainerWriteGuard = () => true,\n) {\n return shareContainerUsing(\n state,\n syncAgent,\n containerId,\n (containerState) =>\n // A group share is where a relabeled directory row would misdirect a\n // key wrap, so its verification failures (the signed-name mismatch\n // above all) are recorded as security incidents, not just surfaced.\n runWithSecurityIncidentReporting(\n state.runtime.util.reportSecurityIncident,\n {\n objectId: containerId,\n objectKind: \"container\",\n operation: \"container.share.group\",\n organizationId: containerState.container.organizationId,\n },\n () =>\n shareContainerStateWithGroup({\n accessLevel,\n containerState,\n expectedGroupName: options.expectedGroupName,\n knownContainerKeks: options.knownContainerKeks,\n persistence: state.persistence,\n recipientGroupId: groupId,\n requireExistingGrant: options.requireExistingGrant,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n }),\n ),\n `shared container ${containerId} with group ${groupId}`,\n isCurrent,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"startupHydration.js","sourceRoot":"","sources":["startupHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAEzF,MAAM,iCAAiC,GAAG,EAAE,GAAG,MAAM,CAAC;AAwBtD,SAAS,kCAAkC,CACzC,SAAiB,EACjB,KAAa;IAEb,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CACL,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC5B,KAAK,GAAG,WAAW,IAAI,iCAAiC,CACzD,CAAC;AACJ,CAAC;AAED,SAAS,gCAAgC,CACvC,KAA4B;IAE5B,2EAA2E;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E,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,KAAK,CAAC,WAAW,CAAC,kCAAkC,CAClD,OAAO,EACP,YAAY,CACb;QACD,KAAK,CAAC,WAAW,CAAC,qCAAqC,CACrD,OAAO,EACP,YAAY,CACb;KACF,CAAC,CAAC;IACL,OAAO,CACL,6BAA6B,CAAC,MAAM,GAAG,CAAC;QACxC,+BAA+B,CAAC,MAAM,GAAG,CAAC,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type ContainerContentsPersistence,\n createContainerParentSyncLane,\n loadContainerSyncLaneCheckRecords,\n} from \"../../workflows/container-contents/containerPersistence\";\nimport { hasStartupDocumentSyncWork } from \"../../workflows/container-contents/documentPriming\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\n\nconst STARTUP_REMOTE_HYDRATION_FRESH_MS = 15 * 60_000;\ntype StartupHydrationExecSql = Parameters<\n typeof loadContainerSyncLaneCheckRecords\n>[0];\n\ninterface StartupHydrationState {\n containerParentIdsNeedingHydration: Set<string | null>;\n containersById: ReadonlyMap<\n string,\n {\n container: {\n metadataDocumentId?: string | null | undefined;\n parentId: string | null;\n };\n }\n >;\n rootLaneHydrated: boolean;\n runtime: {\n auth: { isAuthenticated: boolean; organizationId?: string | null };\n infra: { execSql: StartupHydrationExecSql };\n state: { containerId: string | null; online: boolean };\n };\n}\n\nfunction isFreshStartupRemoteHydrationCheck(\n checkedAt: string,\n nowMs: number,\n): boolean {\n const checkedAtMs = Date.parse(checkedAt);\n return (\n Number.isFinite(checkedAtMs) &&\n nowMs - checkedAtMs <= STARTUP_REMOTE_HYDRATION_FRESH_MS\n );\n}\n\nfunction shouldHydrateUnmarkedStartupRoot(\n state: StartupHydrationState,\n): boolean {\n // An empty authenticated cache needs one root probe to discover the remote\n // tree. Existing local-only roots are deliberately left cache-first; explicit\n // refresh and remote events can reconcile them without polling every startup.\n return state.containersById.size === 0;\n}\n\nasync function getStaleStartupRemoteHydrationParentIds(\n state: StartupHydrationState,\n isCurrent?: (() => boolean) | undefined,\n): Promise<Array<string | null> | null> {\n const parentIds = [null, ...state.containersById.keys()];\n const syncLanes = parentIds.map((parentId) =>\n createContainerParentSyncLane(parentId),\n );\n const checkRecords = await loadContainerSyncLaneCheckRecords(\n state.runtime.infra.execSql,\n syncLanes,\n );\n if (isCurrent?.() === false) {\n return null;\n }\n const nowMs = Date.now();\n const rootCheckRecord = checkRecords[0];\n state.rootLaneHydrated = rootCheckRecord\n ? isFreshStartupRemoteHydrationCheck(rootCheckRecord.checkedAt, nowMs)\n : false;\n const hydrateUnmarkedRoot = shouldHydrateUnmarkedStartupRoot(state);\n\n return parentIds.filter((_, index) => {\n const checkRecord = checkRecords[index];\n if (!checkRecord) {\n return hydrateUnmarkedRoot && index === 0;\n }\n\n return !isFreshStartupRemoteHydrationCheck(checkRecord.checkedAt, nowMs);\n });\n}\n\nfunction reportStartupHydrationError(message: string, error: unknown) {\n if (isDatabaseUnavailableError(error)) {\n return;\n }\n\n console.error(message, error);\n}\n\nexport async function scheduleStaleStartupRemoteHydration(input: {\n isCurrent?: (() => boolean) | undefined;\n requestHydration: () => Promise<void>;\n state: StartupHydrationState;\n}): Promise<boolean> {\n const { requestHydration, state } = input;\n if (!state.runtime.auth.isAuthenticated || !state.runtime.state.online) {\n return false;\n }\n\n let parentIds: Array<string | null> | null;\n try {\n parentIds = await getStaleStartupRemoteHydrationParentIds(\n state,\n input.isCurrent,\n );\n } catch (error: unknown) {\n if (input.isCurrent?.() === false) {\n return false;\n }\n reportStartupHydrationError(\n \"Failed to inspect startup container contents hydration:\",\n error,\n );\n return false;\n }\n if (!parentIds || input.isCurrent?.() === false) {\n return false;\n }\n const activeContainerId = state.runtime.state.containerId;\n const shouldScheduleStaleRootRecovery =\n state.rootLaneHydrated &&\n activeContainerId !== null &&\n !state.containersById.has(activeContainerId);\n if (parentIds.length === 0) {\n return shouldScheduleStaleRootRecovery;\n }\n\n for (const parentId of parentIds) {\n state.containerParentIdsNeedingHydration.add(parentId);\n }\n // Startup stays cache-first: only the local freshness-marker read is awaited.\n // Missing markers on an existing remote cache do not force a first-open poll;\n // stale checked lanes and empty caches hydrate behind the cached tree.\n // WebSocket events and explicit refresh bypass this.\n void requestHydration().catch((error: unknown) => {\n reportStartupHydrationError(\n \"Failed to schedule startup container contents hydration:\",\n error,\n );\n });\n return shouldScheduleStaleRootRecovery;\n}\n\nexport async function hasStartupContainerSyncWork(state: {\n containersById: ReadonlyMap<string, unknown>;\n persistence: ContainerContentsPersistence;\n runtime: { infra: { execSql: StartupHydrationExecSql } };\n}): Promise<boolean> {\n const execSql = state.runtime.infra.execSql;\n const [createIntents, moveIntents] = await Promise.all([\n state.persistence.listPendingCreateIntents(execSql),\n state.persistence.listUnsyncedMoveIntents(execSql),\n ]);\n if (createIntents.length > 0 || moveIntents.length > 0) {\n return true;\n }\n\n // Durable document-level work (pending creates, queued Loro updates or\n // attachments, pending document move intents) is drained by lane passes too:\n // the pass primes the owning document stores, which register and request\n // their own sync lanes. Without this probe, a relaunch whose only pending\n // work is document-level never schedules any lane and the write queue sits\n // unattempted forever.\n if (await hasStartupDocumentSyncWork(execSql)) {\n return true;\n }\n\n const containerIds = Array.from(state.containersById.keys());\n if (containerIds.length === 0) {\n return false;\n }\n const [containersWithPendingMetadata, containersWithPullContinuations] =\n await Promise.all([\n state.persistence.listContainerIdsWithPendingUpdates(\n execSql,\n containerIds,\n ),\n state.persistence.listContainerIdsWithPullContinuations(\n execSql,\n containerIds,\n ),\n ]);\n return (\n containersWithPendingMetadata.length > 0 ||\n containersWithPullContinuations.length > 0\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncAgent.js","sourceRoot":"","sources":["syncAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,M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EAAE,EAAE;gBACjD,iBAAiB,CAAC;oBAChB,2BAA2B,EAAE,KAAK;oBAClC,SAAS,EAAE,CAAC,iBAAiB,CAAC;iBAC/B,CAAC,CAAC;YACL,CAAC;YACD,KAAK;SACN,CAAC;KACL,CAAC,CAAC;IAEH,OAAO;QACL,iBAAiB,EAAE,GAAG,EAAE;YACtB,uCAAuC,CAAC;gBACtC,kBAAkB;gBAClB,IAAI;gBACJ,qBAAqB,EAAE,OAAO;gBAC9B,kBAAkB;gBAClB,YAAY;gBACZ,KAAK;aACN,CAAC,CAAC;YACH,KAAK,kBAAkB,EAAE,CAAC;QAC5B,CAAC;QACD,kBAAkB;QAClB,qBAAqB,EAAE,wBAAwB,CAAC,MAAM;QACtD,8BAA8B,EAAE,CAAC,eAAe,EAAE,SAAS,EAAE,EAAE,CAC7D,yBAAyB,CAAC,KAAK,EAAE,eAAe,EAAE,SAAS,CAAC;QAC9D,sBAAsB,EAAE,GAAG,EAAE,CAAC,2BAA2B,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC1E,OAAO;QACP,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE,CAC3B,0BAA0B,CAAC;YACzB,0BAA0B,EAAE,OAAO,EAAE,0BAA0B;YAC/D,SAAS,EAAE,OAAO,EAAE,SAAS;YAC7B,gBAAgB,EAAE,uBAAuB;YACzC,KAAK;SACN,CAAC;QACJ,sBAAsB,EAAE,gBAAgB;QACxC,uBAAuB,EAAE,iBAAiB;QAC1C,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { loadLocalContainerStates } from \"../../workflows/container-contents/localState\";\nimport type { RemoteContainerHydrationHost } from \"../../workflows/container-contents/remoteHydration\";\nimport {\n isDatabaseUnavailableError,\n registerContainerContentsSyncLane,\n} from \"../../workflows/container-contents/syncLane\";\nimport { createRestoredAccessReconciler } from \"./accessRestorationSweep\";\nimport { observeContainerBackgroundHydration } from \"./backgroundHydration\";\nimport { primeStoreDocumentSubtree } from \"./documentRecovery\";\nimport { refreshLocalContainerStates } from \"./localRefresh\";\nimport { getContainerContentsStoreLogLabel } from \"./logLabel\";\nimport { createRemoteContainerIngestionController } from \"./remoteContainerIngestion\";\nimport { handleContainerContentsRemoteEvents } from \"./remoteEventSync\";\nimport {\n type RemoteHydrationRefreshOptions,\n refreshAllRemoteHydration,\n refreshRootRemoteHydration,\n} from \"./remoteHydrationRefresh\";\nimport { requestContainerContentsRemoteHydration } from \"./remoteHydrationRequest\";\nimport {\n hasStartupContainerSyncWork,\n scheduleStaleStartupRemoteHydration,\n} from \"./startupHydration\";\nimport { consumePendingContainerContentsReconnectRefresh } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n} from \"./syncAgentTypes\";\nimport { runContainerContentsStoreSyncIteration } from \"./syncLaneIteration\";\n\nexport type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nexport type {\n ContainerContentsStoreRuntime,\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n RefreshRootLaneOptions,\n} from \"./syncAgentTypes\";\n\nfunction requestContainerContentsStoreSync(\n state: ContainerContentsStoreSyncState,\n) {\n state.syncLane?.requestSync();\n}\n\nasync function initializeContainerContentsStore(input: {\n handleRemoteEvents: () => void;\n host: RemoteContainerHydrationHost;\n isCurrent: () => boolean;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}) {\n const {\n handleRemoteEvents,\n host,\n isCurrent,\n resumeRecoveryWork,\n scheduleSync,\n state,\n } = input;\n const persistence = state.persistence;\n const loadRuntime = state.runtime;\n if (loadRuntime.infra.dbStatus !== \"ready\") {\n return;\n }\n\n const localContainerStates = await loadLocalContainerStates({\n persistence,\n runtime: loadRuntime,\n });\n if (!isCurrent()) {\n return;\n }\n\n for (const containerState of localContainerStates) {\n state.containersById.set(containerState.container.id, containerState);\n }\n\n state.initialized = true;\n\n const shouldScheduleStaleRootRecovery =\n await scheduleStaleStartupRemoteHydration({\n isCurrent,\n requestHydration: () =>\n requestContainerContentsRemoteHydration({\n host,\n resumeRecoveryWork,\n scheduleSync,\n state,\n }),\n state,\n });\n if (!isCurrent()) {\n return;\n }\n const runtime = state.runtime;\n const hasPendingRestorationSweep =\n typeof runtime.auth.userId === \"string\" &&\n (\n await persistence.listDormantMetadataSweepRequests(\n loadRuntime.infra.execSql,\n runtime.auth.userId,\n )\n ).length > 0;\n if (!isCurrent()) {\n return;\n }\n\n host.updateSnapshot();\n handleRemoteEvents();\n\n runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: loaded ${state.containersById.size} container(s)`,\n );\n\n const currentRuntime = state.runtime;\n if (currentRuntime.auth.isAuthenticated && currentRuntime.state.online) {\n const hasStartupWork =\n shouldScheduleStaleRootRecovery ||\n hasPendingRestorationSweep ||\n (await hasStartupContainerSyncWork(state));\n if (!isCurrent() || !hasStartupWork) {\n return;\n }\n currentRuntime.util.log(\n shouldScheduleStaleRootRecovery\n ? `${getContainerContentsStoreLogLabel(state)}: startup detected stale root recovery; scheduling lane pass`\n : `${getContainerContentsStoreLogLabel(state)}: startup detected durable sync work; scheduling lane pass`,\n );\n scheduleSync();\n }\n}\n\nfunction waitForStaleLocalRefreshBeforeInitialization(input: {\n handleRemoteEvents: () => void;\n host: RemoteContainerHydrationHost;\n refreshAfterReconnect: () => Promise<boolean>;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}): boolean {\n const { state } = input;\n const activeRefresh = state.localContainerRefreshPromise;\n if (\n !activeRefresh ||\n (state.localContainerRefreshGeneration === state.lifecycleGeneration &&\n state.localContainerRefreshStructuralGeneration ===\n state.structuralGeneration)\n ) {\n return false;\n }\n\n const lifecycleGeneration = state.lifecycleGeneration;\n state.initializeGeneration = lifecycleGeneration;\n const releaseInitializationBarrier = () => {\n if (state.initializePromise !== initializationBarrier) {\n return;\n }\n state.initializePromise = null;\n state.initializeGeneration = null;\n if (state.runtime.infra.dbStatus === \"ready\") {\n ensureContainerContentsStoreInitialized(input);\n }\n };\n const initializationBarrier = activeRefresh.then(\n releaseInitializationBarrier,\n releaseInitializationBarrier,\n );\n state.initializePromise = initializationBarrier;\n return true;\n}\n\nfunction ensureContainerContentsStoreInitialized(input: {\n handleRemoteEvents: () => void;\n host: RemoteContainerHydrationHost;\n refreshAfterReconnect: () => Promise<boolean>;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}) {\n const { handleRemoteEvents, host, resumeRecoveryWork, scheduleSync, state } =\n input;\n if (state.initialized || state.runtime.infra.dbStatus !== \"ready\") {\n return;\n }\n if (state.initializePromise) {\n return;\n }\n if (waitForStaleLocalRefreshBeforeInitialization(input)) {\n return;\n }\n\n const lifecycleGeneration = state.lifecycleGeneration;\n const persistence = state.persistence;\n const execSql = state.runtime.infra.execSql;\n const isCurrent = () =>\n state.lifecycleGeneration === lifecycleGeneration &&\n state.persistence === persistence &&\n state.runtime.infra.execSql === execSql;\n state.initializeGeneration = lifecycleGeneration;\n const initializePromise = initializeContainerContentsStore({\n handleRemoteEvents,\n host,\n isCurrent,\n resumeRecoveryWork,\n scheduleSync,\n state,\n })\n .catch((error: unknown) => {\n if (!isCurrent() || isDatabaseUnavailableError(error)) {\n return;\n }\n\n throw error;\n })\n .finally(() => {\n if (state.initializePromise !== initializePromise) {\n return;\n }\n state.initializePromise = null;\n state.initializeGeneration = null;\n if (isCurrent()) {\n consumePendingContainerContentsReconnectRefresh(\n state,\n input.refreshAfterReconnect,\n );\n } else if (state.runtime.infra.dbStatus === \"ready\") {\n ensureContainerContentsStoreInitialized(input);\n }\n });\n state.initializePromise = initializePromise;\n}\n\n// Read the runtime lazily: updateRuntime replaces state.runtime, so a\n// reference captured at lane registration would report into a dead identity's\n// host. Returns the host's result: both callbacks are declared `=> void` but\n// may be async, and the lane reporter only catches a rejection it is handed.\nfunction logSyncLaneFailure(\n state: ContainerContentsStoreSyncState,\n message: string,\n error: unknown,\n): unknown {\n const { log, logError } = state.runtime.util;\n return logError ? logError(message, error) : log(message);\n}\n\nfunction createHydrationRequester(input: {\n host: RemoteContainerHydrationHost;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSync: () => void;\n state: ContainerContentsStoreSyncState;\n}): ContainerContentsStoreSyncAgent[\"requestRemoteHydration\"] {\n return (options = {}) =>\n requestContainerContentsRemoteHydration({\n ...input,\n followDiscoveredParentLanes: options.followDiscoveredParentLanes,\n parentIds: options.parentIds,\n resetAllLaneWatermarks: options.resetAllLaneWatermarks,\n });\n}\n\nexport function createContainerContentsStoreSyncAgent(input: {\n host: RemoteContainerHydrationHost;\n state: ContainerContentsStoreSyncState;\n}): ContainerContentsStoreSyncAgent {\n const { host, state } = input;\n const scheduleSync = () => requestContainerContentsStoreSync(state);\n const remoteContainerIngestion = createRemoteContainerIngestionController({\n host,\n scheduleSync,\n state,\n });\n const resumeRecoveryWork = remoteContainerIngestion.resumeInterruptedWork;\n\n const requestHydration = createHydrationRequester({\n host,\n resumeRecoveryWork,\n scheduleSync,\n state,\n });\n const requestRefreshHydration = (options: RemoteHydrationRefreshOptions) =>\n requestContainerContentsRemoteHydration({\n ...options,\n host,\n resumeRecoveryWork,\n scheduleSync,\n state,\n });\n const scheduleHydration = (\n options?: Parameters<typeof requestHydration>[0],\n ) => observeContainerBackgroundHydration(state, requestHydration(options));\n const refresh: ContainerContentsStoreSyncAgent[\"refresh\"] = (options) =>\n refreshAllRemoteHydration({\n // Explicit user refresh must rediscover children hidden by unsigned hints.\n resetAllLaneWatermarks: options?.resetAllLaneWatermarks,\n requestHydration: requestRefreshHydration,\n state,\n });\n const handleRemoteEvents = () =>\n handleContainerContentsRemoteEvents({\n requestHydration,\n scheduleSync,\n state,\n });\n const reconcileRestoredAccess = createRestoredAccessReconciler({\n requestHydration: requestRefreshHydration,\n state,\n });\n\n state.syncLane = registerContainerContentsSyncLane({\n domainScope: state.runtime.state.domainScope,\n logError: (message, error) => logSyncLaneFailure(state, message, error),\n run: () =>\n runContainerContentsStoreSyncIteration({\n host,\n reconcileRestoredAccess,\n requestRemoteReconciliation: (parentContainerId) => {\n scheduleHydration({\n followDiscoveredParentLanes: false,\n parentIds: [parentContainerId],\n });\n },\n state,\n }),\n });\n\n return {\n ensureInitialized: () => {\n ensureContainerContentsStoreInitialized({\n handleRemoteEvents,\n host,\n refreshAfterReconnect: refresh,\n resumeRecoveryWork,\n scheduleSync,\n state,\n });\n void resumeRecoveryWork();\n },\n handleRemoteEvents,\n ingestRemoteContainer: remoteContainerIngestion.ingest,\n primeDocumentsForSharedSubtree: (rootContainerId, isCurrent) =>\n primeStoreDocumentSubtree(state, rootContainerId, isCurrent),\n refreshLocalContainers: () => refreshLocalContainerStates({ host, state }),\n refresh,\n refreshRootLane: (options) =>\n refreshRootRemoteHydration({\n includeActiveRootChildLane: options?.includeActiveRootChildLane,\n parentIds: options?.parentIds,\n requestHydration: requestRefreshHydration,\n state,\n }),\n requestRemoteHydration: requestHydration,\n scheduleRemoteHydration: scheduleHydration,\n scheduleSync,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncAgentTypes.js","sourceRoot":"","sources":["syncAgentTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ContainerContentsPersistence } from \"../../workflows/container-contents/containerPersistence\";\nimport type { ContainerContentsProjectionUserKeyResolver } from \"../../workflows/container-contents/projectionKeys\";\nimport type {\n ContainerState,\n RemoteContainer,\n} from \"../../workflows/container-contents/remoteHydration\";\nimport type { ContainerContentsStoreWorkflowRuntime } from \"../../workflows/container-contents/runtime\";\nimport type { ContainerContentsSyncLane } from \"../../workflows/container-contents/syncLane\";\n\nexport type ContainerContentsStoreRuntime =\n ContainerContentsStoreWorkflowRuntime;\n\nexport interface RefreshRootLaneOptions {\n readonly includeActiveRootChildLane?: boolean | undefined;\n // Extra parent lanes to re-list alongside the root lane. Used by the\n // resync_required handler to re-list affected containers' parent lanes so a\n // tombstone only visible there is still applied without the full crawl.\n readonly parentIds?: ReadonlyArray<string | null> | undefined;\n}\n\nexport interface ContainerContentsStoreSyncAgent {\n ensureInitialized: () => void;\n handleRemoteEvents: () => void;\n ingestRemoteContainer: (remoteContainer: RemoteContainer) => Promise<void>;\n primeDocumentsForSharedSubtree: (\n rootContainerId: string,\n isCurrent?: (() => boolean) | undefined,\n ) => Promise<void>;\n refreshLocalContainers: () => Promise<void>;\n refresh: (options?: { resetAllLaneWatermarks?: boolean }) => Promise<boolean>;\n refreshRootLane: (options?: RefreshRootLaneOptions) => Promise<boolean>;\n requestRemoteHydration: (options?: {\n followDiscoveredParentLanes?: boolean | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n }) => Promise<void>;\n scheduleRemoteHydration: () => void;\n scheduleSync: () => void;\n}\n\nexport interface ContainerContentsStoreSyncState {\n containersById: Map<string, ContainerState>;\n documentStoresNeedPriming: boolean;\n initializeGeneration: number | null;\n initializePromise: Promise<void> | null;\n initialized: boolean;\n localContainerRefreshPromise: Promise<void> | null;\n localContainerRefreshGeneration: number | null;\n localContainerRefreshStructuralGeneration: number | null;\n localContainersNeedRefresh: boolean;\n /** Invalidates asynchronous hydration work when this store is reset. */\n lifecycleGeneration: number;\n /** Invalidates structural work when its runtime or persistence is replaced. */\n structuralGeneration: number;\n /** Invalidates writes across write-relevant runtime ABA transitions. */\n writeGeneration: number;\n lastEventCount: number;\n /**\n * Update ids this client sent for container metadata documents, registered\n * before the network await of each metadata sync pass. The author's own\n * `document_update_created` echo consumes its ids here instead of arming a\n * redundant forced read-sync; a genuine peer update always carries unknown\n * ids and still forces one. Shared across all metadata docs in the store —\n * update ids are globally unique.\n */\n locallyAcceptedMetadataUpdateIds: Set<string>;\n logLabel?: string | undefined;\n metadataDocumentIdsNeedingSync: Set<string>;\n /**\n * Per-metadata-document enqueue sequence. Bumped for a specific id whenever a\n * remote event re-queues it in {@link metadataDocumentIdsNeedingSync}. A sync\n * pass snapshots the id's sequence before its GET and only clears the id if it\n * is unchanged at pass end, so a mid-pass re-queue of THIS container is not\n * erased. Keyed per id (not a single global counter) so a remote event for an\n * unrelated container does not force a redundant re-sync of this one. See\n * `clearMetadataSyncQueueIfUnchanged`.\n */\n metadataSyncSignalSeqById: Map<string, number>;\n containerParentIdsNeedingHydration: Set<string | null>;\n persistence: ContainerContentsPersistence;\n remoteHydrationPromise: Promise<void> | null;\n remoteHydrationGeneration: number | null;\n remoteHydrationStructuralGeneration: number | null;\n remoteReconnectRefreshPending: boolean;\n resolveProjectionUserKey: ContainerContentsProjectionUserKeyResolver;\n /** True after this store has fully applied an authoritative root lane. */\n rootLaneHydrated: boolean;\n runtime: ContainerContentsStoreRuntime;\n snapshot: { ready: boolean };\n syncLane: ContainerContentsSyncLane | null;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncLaneIteration.js","sourceRoot":"","sources":["syncLaneIteration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qEAAqE,CAAC;AACxH,OAAO,EAAE,+BAA+B,EAAE,MAAM,mEAAmE,CAAC;AACpH,OAAO,EAEL,8BAA8B,GAC/B,MAAM,wEAAwE,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAKzF,OAAO,EAAE,uCAAuC,EAAE,MAAM,4CAA4C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,iCAAiC,EACjC,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;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;QACH,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;IACH,CAAC;IAED,wEAAwE;IACxE,2EAA2E;IAC3E,2DAA2D;IAC3D,MAAM,wBAAwB,CAAC;QAC7B,SAAS;QACT,gBAAgB,EAAE,GAAG,EAAE;YACrB,IAAI,SAAS,EAAE,EAAE,CAAC;gBAChB,iCAAiC,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,gBAAgB,EAAE,GAAG,EAAE;YACrB,IAAI,SAAS,EAAE,EAAE,CAAC;gBAChB,yBAAyB,CAAC,WAAW,CAAC,CAAC;gBACvC,iCAAiC,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,cAAc,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC;QAC3D,gBAAgB,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC;QAC/D,oBAAoB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,yBAAyB;QAC3D,sEAAsE;QACtE,wEAAwE;QACxE,sEAAsE;QACtE,yDAAyD;QACzD,wBAAwB,EAAE,GAAG,EAAE,CAC7B,6BAA6B,CAAC;YAC5B,eAAe;YACf,SAAS;YACT,mBAAmB,EAAE,qBAAqB;YAC1C,KAAK;SACN,CAAC;KACL,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { syncPendingContainerCreateIntents } from \"../../workflows/container-contents/container-state/createIntentSync\";\nimport { syncPendingContainerMoveIntents } from \"../../workflows/container-contents/container-state/moveIntentSync\";\nimport {\n type DocumentMoveIntentSyncHost,\n syncPendingDocumentMoveIntents,\n} from \"../../workflows/container-contents/documentMove/documentMoveIntentSync\";\nimport { syncContainerMetadataState } from \"../../workflows/container-contents/metadata\";\nimport type {\n ContainerState,\n RemoteContainerHydrationHost,\n} from \"../../workflows/container-contents/remoteHydration\";\nimport { createContainerContentsDocumentsRuntime } from \"../../workflows/container-contents/runtime\";\nimport { openDocumentStore, requestDomainDocumentSync } from \"../documents\";\nimport { relinkDocumentStoreWithCommitSideEffect } from \"../documents/documentStore/internalRelink\";\nimport { DocumentRemoteWorkBusyError } from \"../documents/documentStore/remoteWork\";\nimport { primeStoreDocuments, recoverStoreStaleRoot } from \"./documentRecovery\";\nimport { runContainerDocumentWork } from \"./documentWork\";\nimport {\n bumpMetadataSyncSeq,\n clearMetadataSyncQueueIfUnchanged,\n readMetadataSyncSeq,\n} from \"./metadataSyncSignal\";\nimport { removeMissingSyncedContainerState } from \"./missingSyncedContainerState\";\nimport type {\n ContainerContentsStoreRuntime,\n ContainerContentsStoreSyncState,\n} from \"./syncAgentTypes\";\n\ntype ContainerContentsStorePrimeDocumentRuntime = ReturnType<\n typeof createContainerContentsDocumentsRuntime\n>;\ntype SyncContainerMetadata = typeof syncContainerMetadataState;\n\nfunction requestContainerContentsStoreSync(\n state: ContainerContentsStoreSyncState,\n) {\n state.syncLane?.requestSync();\n}\n\nfunction createRemoteSyncBlocker(runtime: ContainerContentsStoreRuntime) {\n return (organizationId: string) =>\n runtime.util.isRemoteSyncBlocked?.(organizationId) ?? false;\n}\n\nfunction captureStructuralSyncGeneration(\n state: ContainerContentsStoreSyncState,\n runtime: ContainerContentsStoreRuntime,\n) {\n const activeContainerId = runtime.state.containerId;\n const activeOrganizationId = runtime.auth.organizationId;\n const lifecycleGeneration = state.lifecycleGeneration;\n const structuralGeneration = state.structuralGeneration;\n const domainScope = runtime.state.domainScope;\n const execSql = runtime.infra.execSql;\n const resolveProjectionUserKey = state.resolveProjectionUserKey;\n const syncLane = state.syncLane;\n return () =>\n state.lifecycleGeneration === lifecycleGeneration &&\n state.structuralGeneration === structuralGeneration &&\n state.runtime.auth.organizationId === activeOrganizationId &&\n state.runtime.state.containerId === activeContainerId &&\n state.runtime.state.domainScope === domainScope &&\n state.runtime.infra.execSql === execSql &&\n state.resolveProjectionUserKey === resolveProjectionUserKey &&\n state.syncLane === syncLane &&\n !syncLane?.isDisposed?.();\n}\n\nfunction createContainerContentsStoreDocumentMoveHost(\n state: ContainerContentsStoreSyncState,\n isCurrent: () => boolean,\n): DocumentMoveIntentSyncHost<ContainerContentsStorePrimeDocumentRuntime> {\n const runtime = state.runtime;\n const domainScope = runtime.state.domainScope;\n return {\n documentWorkflowRuntime: (containerId) =>\n createContainerContentsDocumentsRuntime(runtime, containerId),\n openDocumentStore: ({ containerId, documentId, localId }) => {\n const store = openDocumentStore(\n domainScope,\n localId,\n createContainerContentsDocumentsRuntime(runtime, containerId),\n documentId,\n );\n return {\n assertCanRotateContentKey: () =>\n store.assertCanRotateContentKey().catch((error: unknown) => {\n if (error instanceof DocumentRemoteWorkBusyError) {\n void error.whenIdle.then(() => {\n if (isCurrent()) requestContainerContentsStoreSync(state);\n });\n }\n throw error;\n }),\n ensureInitialized: () => store.ensureInitialized(),\n relink: ({ commitSideEffect, ...input }) =>\n commitSideEffect\n ? relinkDocumentStoreWithCommitSideEffect(\n store,\n input,\n commitSideEffect,\n )\n : store.relink(input),\n requestSync: () => store.requestSync(),\n updateRuntime: (nextRuntime) => store.updateRuntime(nextRuntime),\n };\n },\n };\n}\n\nfunction syncPendingStoreDocumentMoves(input: {\n isCreatePending: (containerId: string) => boolean;\n isCurrent: () => boolean;\n isRemoteSyncBlocked: (organizationId: string) => boolean;\n state: ContainerContentsStoreSyncState;\n}) {\n return syncPendingDocumentMoveIntents({\n host: createContainerContentsStoreDocumentMoveHost(\n input.state,\n input.isCurrent,\n ),\n isCreatePending: input.isCreatePending,\n isCurrent: input.isCurrent,\n isRemoteSyncBlocked: input.isRemoteSyncBlocked,\n state: input.state,\n });\n}\n\nasync function syncSingleContainerMetadata(input: {\n host: RemoteContainerHydrationHost;\n isCurrent: () => boolean;\n state: ContainerContentsStoreSyncState;\n containerState: ContainerState;\n encapsulationKeyPair: NonNullable<\n ContainerContentsStoreRuntime[\"crypto\"][\"encapsulationKeyPair\"]\n >;\n syncContainerMetadata?: SyncContainerMetadata | undefined;\n}) {\n const { containerState, encapsulationKeyPair, host, isCurrent, state } =\n input;\n const metadataDocumentId = containerState.record.documentId;\n // Snapshot this signal before the GET so a mid-pass event survives clearing.\n const consumedSeqById = new Map<string, number>();\n if (typeof metadataDocumentId === \"string\") {\n consumedSeqById.set(\n metadataDocumentId,\n readMetadataSyncSeq(state.metadataSyncSignalSeqById, metadataDocumentId),\n );\n }\n const synced = await (\n input.syncContainerMetadata ?? syncContainerMetadataState\n )({\n forceReadSync:\n typeof metadataDocumentId === \"string\" &&\n state.metadataDocumentIdsNeedingSync.has(metadataDocumentId),\n locallyAcceptedUpdateIds: state.locallyAcceptedMetadataUpdateIds,\n isCurrent,\n metadataState: containerState,\n onDurableStateNeedsReload: () => {\n const currentDocumentId = state.containersById.get(\n containerState.container.id,\n )?.record.documentId;\n if (typeof currentDocumentId === \"string\") {\n state.metadataDocumentIdsNeedingSync.add(currentDocumentId);\n bumpMetadataSyncSeq(state.metadataSyncSignalSeqById, currentDocumentId);\n }\n requestContainerContentsStoreSync(state);\n },\n persistence: state.persistence,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n targetSecretKey: encapsulationKeyPair.secretKey,\n });\n if (!isCurrent() || !synced) {\n return;\n }\n if (\"missing\" in synced) {\n removeMissingSyncedContainerState(\n state,\n containerState,\n host.updateSnapshot,\n );\n return;\n }\n\n for (const id of [metadataDocumentId, synced.record.documentId]) {\n if (typeof id === \"string\") {\n clearMetadataSyncQueueIfUnchanged({\n consumedSeqById,\n id,\n needingSync: state.metadataDocumentIdsNeedingSync,\n seqById: state.metadataSyncSignalSeqById,\n });\n }\n }\n // syncContainerMetadataState settles its detached candidate into this live\n // object while preserving any metadata edit that completed or queued during\n // the remote pass. Do not install its returned detached record again here:\n // doing so would overwrite that preserved live edit.\n host.updateSnapshot();\n\n if (synced.shouldRequestFollowupSync) {\n requestContainerContentsStoreSync(state);\n }\n}\n\n/**\n * A folder whose create has not settled can carry a listed identity that\n * adoption has not verified, or has refused. Folder moves, document moves and\n * metadata edits wait for it; child and document creates wait in their own\n * create paths.\n */\nasync function loadPendingCreatePredicate(\n state: ContainerContentsStoreSyncState,\n): Promise<(containerId: string) => boolean> {\n const pending = await state.persistence.listPendingCreateIntents(\n state.runtime.infra.execSql,\n );\n const pendingIds = new Set(pending.map((intent) => intent.containerId));\n return (containerId) => pendingIds.has(containerId);\n}\n\ninterface ContainerContentsStoreSyncIterationInput {\n host: RemoteContainerHydrationHost;\n reconcileRestoredAccess: (isCurrent: () => boolean) => Promise<void>;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n state: ContainerContentsStoreSyncState;\n syncContainerMetadata?: SyncContainerMetadata | undefined;\n}\n\nexport async function runContainerContentsStoreSyncIteration(\n input: ContainerContentsStoreSyncIterationInput,\n) {\n const { host, reconcileRestoredAccess, requestRemoteReconciliation, state } =\n input;\n const runtime = state.runtime;\n const encapsulationKeyPair = runtime.crypto.encapsulationKeyPair;\n if (\n runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !runtime.state.online ||\n !runtime.auth.isAuthenticated ||\n !encapsulationKeyPair\n ) {\n return;\n }\n const domainScope = runtime.state.domainScope;\n const isCurrent = captureStructuralSyncGeneration(state, runtime);\n\n await reconcileRestoredAccess(isCurrent);\n if (!isCurrent()) {\n return;\n }\n const isOrganizationBlocked = createRemoteSyncBlocker(runtime);\n\n const createdContainerCount = await syncPendingContainerCreateIntents({\n host,\n isCurrent,\n isRemoteSyncBlocked: isOrganizationBlocked,\n requestRemoteReconciliation,\n state,\n });\n if (!isCurrent()) {\n return;\n }\n if (createdContainerCount > 0) {\n state.documentStoresNeedPriming = true;\n host.updateSnapshot();\n }\n const isCreatePending = await loadPendingCreatePredicate(state);\n if (!isCurrent()) {\n return;\n }\n\n const movedContainerCount = await syncPendingContainerMoveIntents({\n host,\n isCreatePending,\n isCurrent,\n isRemoteSyncBlocked: isOrganizationBlocked,\n requestRemoteReconciliation,\n state,\n });\n if (!isCurrent()) {\n return;\n }\n if (movedContainerCount > 0) {\n state.documentStoresNeedPriming = true;\n host.updateSnapshot();\n requestDomainDocumentSync(domainScope);\n requestContainerContentsStoreSync(state);\n }\n\n for (const containerState of Array.from(state.containersById.values())) {\n if (isCreatePending(containerState.container.id)) continue;\n await syncSingleContainerMetadata({\n containerState,\n encapsulationKeyPair,\n host,\n isCurrent,\n state,\n syncContainerMetadata: input.syncContainerMetadata,\n });\n if (!isCurrent()) {\n return;\n }\n }\n\n // Root adoption notifies session consumers synchronously. Let container\n // metadata converge first so a recovered system container is never exposed\n // under its placeholder name when the active root changes.\n await runContainerDocumentWork({\n isCurrent,\n onContextChanged: () => {\n if (isCurrent()) {\n requestContainerContentsStoreSync(state);\n }\n },\n onDocumentsMoved: () => {\n if (isCurrent()) {\n requestDomainDocumentSync(domainScope);\n requestContainerContentsStoreSync(state);\n }\n },\n primeDocuments: () => primeStoreDocuments(state, isCurrent),\n recoverStaleRoot: () => recoverStoreStaleRoot(state, isCurrent),\n shouldPrimeDocuments: () => state.documentStoresNeedPriming,\n // Document move intents live in the structural phase because they may\n // target containers created locally in the same session, such as Trash.\n // Root recovery rewrites stale endpoints and returns their intents to\n // pending, so replay follows recovery in this same pass.\n syncPendingDocumentMoves: () =>\n syncPendingStoreDocumentMoves({\n isCreatePending,\n isCurrent,\n isRemoteSyncBlocked: isOrganizationBlocked,\n state,\n }),\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemContainerHydration.js","sourceRoot":"","sources":["systemContainerHydration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAOzF,4EAA4E;AAC5E,kEAAkE;AAClE,qEAAqE;AACrE,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,KAOlD;IACC,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC;YAC3C,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,2BAA2B,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxE,SAAS,EACP,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,eAAe;gBACvC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtC,CAAC,CAAC,CAAC,IAAI,CAAC;SACb,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,uCAAuC,CAC3C,KAAK,EACL,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAC/C;YACE,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,IAAI,IAAI;YAC/C,UAAU,EAAE,WAAW;YACvB,SAAS,EAAE,0BAA0B;YACrC,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,cAAc;SAC1D,CACF,CAAC;QACF,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACnC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAC1B,GAAG,KAAK,CAAC,QAAQ,uBAAuB,KAAK,CAAC,UAAU,aAAa,MAAM,GAAG,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport { reportAndRethrowKeyingVerificationError } from \"../../data/keyingProjectionVerification/error\";\nimport { errorMessage } from \"../../data/shared/errorMessage\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\n// Best-effort remote probe for an already-existing system container. System\n// containers occupy root lanes, so this probes those lanes (not a\n// full-tree refresh). Device-first: a network failure must not abort\n// provisioning, or a caller that waits on this container never observes it.\nexport async function probeExistingSystemContainer(input: {\n readonly logLabel: string;\n readonly rootState: ContainerState | null;\n readonly state: ContainerContentsStoreState;\n readonly syncAgent: ContainerContentsStoreSyncAgent;\n readonly systemSlot: ContainerSystemSlot;\n readonly independentRoot?: boolean;\n}): Promise<void> {\n try {\n await input.syncAgent.requestRemoteHydration({\n ...(input.independentRoot ? { followDiscoveredParentLanes: false } : {}),\n parentIds:\n input.rootState && !input.independentRoot\n ? [null, input.rootState.container.id]\n : [null],\n });\n } catch (error) {\n await reportAndRethrowKeyingVerificationError(\n error,\n input.state.runtime.util.reportSecurityIncident,\n {\n objectId: input.rootState?.container.id ?? null,\n objectKind: \"container\",\n operation: \"container.system.hydrate\",\n organizationId: input.rootState?.container.organizationId,\n },\n );\n if (!isDatabaseUnavailableError(error)) {\n const reason = errorMessage(error);\n input.state.runtime.util.log(\n `${input.logLabel}: remote probe for \"${input.systemSlot}\" failed (${reason})`,\n );\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemContainerIcon.js","sourceRoot":"","sources":["systemContainerIcon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,oEAAoE,CAAC;AAE5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAc1D,SAAS,4BAA4B,CACnC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C;IACjE,CAAC;IACD,IAAI,iBAAiB,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,qCAAqC,CACnC,KAAK,CAAC,cAAc,EACpB,oBAAoB,EACpB,EAAE,8BAA8B,EAAE,IAAI,EAAE,CACzC,CAAC;IACF,+BAA+B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC3C,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { encodeVersionVector, exportUpdatesSince } from \"@tearleads/loro\";\nimport {\n getDefaultContainerName,\n readContainerMetadataValue,\n writeContainerMetadataValue,\n} from \"../../data/containers/containerMetadataDocument\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../workflows/container-contents/metadata/metadataStateIsolation\";\nimport type { PersistContainerStateResult } from \"../../workflows/container-contents/remoteHydration\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\ntype PersistSystemContainerIcon = (\n containerState: ContainerState,\n icon: string | null,\n update: Uint8Array,\n) => Promise<PersistContainerStateResult[\"status\"]>;\n\nfunction normalizeSystemContainerIcon(\n icon: string | null | undefined,\n): string | null {\n return icon?.trim() || null;\n}\n\nexport async function applySystemContainerIcon(input: {\n readonly containerState: ContainerState;\n readonly icon: string | null | undefined;\n readonly persistIcon: PersistSystemContainerIcon;\n readonly state: ContainerContentsStoreState;\n readonly syncAgent: ContainerContentsStoreSyncAgent;\n readonly isCurrent?: ContainerWriteGuard | undefined;\n}): Promise<boolean> {\n const isCurrent = input.isCurrent ?? (() => true);\n const icon = normalizeSystemContainerIcon(input.icon);\n const currentIcon = input.containerState.container.icon ?? null;\n if (currentIcon === icon) {\n return true;\n }\n\n if (!isCurrent()) return false;\n const persistenceCandidate = await createDetachedContainerMetadataState(\n input.containerState,\n );\n if (!isCurrent()) return false;\n const metadata = readContainerMetadataValue(\n persistenceCandidate.doc,\n getDefaultContainerName(persistenceCandidate.container.parentId),\n );\n const sourceVersionVector = encodeVersionVector(persistenceCandidate.doc);\n writeContainerMetadataValue(persistenceCandidate.doc, {\n ...metadata,\n icon,\n });\n const update = exportUpdatesSince(\n persistenceCandidate.doc,\n sourceVersionVector,\n );\n const persistenceStatus = await input.persistIcon(\n persistenceCandidate,\n icon,\n update,\n );\n if (persistenceStatus === \"missing\") {\n removeMissingContainerState(input.state, input.containerState);\n }\n if (persistenceStatus !== \"persisted\" || !isCurrent()) {\n return false;\n }\n installDetachedContainerMetadataState(\n input.containerState,\n persistenceCandidate,\n { preserveConcurrentMetadataEdit: true },\n );\n updateContainerContentsSnapshot(input.state);\n if (input.containerState.record.documentId) {\n input.syncAgent.scheduleSync();\n }\n return true;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemContainerLookup.js","sourceRoot":"","sources":["systemContainerLookup.ts"],"names":[],"mappings":"AAIA,SAAS,WAAW,CAAC,cAA8B;IACjD,OAAO,CACL,cAAc,CAAC,SAAS,CAAC,QAAQ,KAAK,IAAI;QAC1C,CAAC,cAAc,CAAC,SAAS,CAAC,UAAU,CACrC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,cAA8B;IACxD,OAAO,CACL,WAAW,CAAC,cAAc,CAAC;QAC3B,CAAC,cAAc,CAAC,SAAS,CAAC,cAAc;QACxC,CAAC,cAAc,CAAC,SAAS,CAAC,kBAAkB,CAC7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAkC;IAElC,MAAM,UAAU,GAAG,KAA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,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport type { ContainerState } from \"./syncAgent\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\nfunction isRootState(containerState: ContainerState): boolean {\n return (\n containerState.container.parentId === null &&\n !containerState.container.systemSlot\n );\n}\n\nfunction isPreAuthRootState(containerState: ContainerState): boolean {\n return (\n isRootState(containerState) &&\n !containerState.container.organizationId &&\n !containerState.container.metadataDocumentId\n );\n}\n\nexport function findRootContainerState(\n state: ContainerContentsStoreState,\n): ContainerState | null {\n const rootStates = Array.from(state.containersById.values()).filter(\n isRootState,\n );\n const defaultRootState =\n rootStates.find(\n (containerState) =>\n containerState.container.id === state.runtime.state.containerId,\n ) ?? null;\n const organizationId = state.runtime.auth.organizationId;\n if (!organizationId) {\n return defaultRootState ?? rootStates[0] ?? null;\n }\n\n // Remote root roles have been verified during hydration. An acknowledgement\n // selects the personal merge destination; other organizations may be first\n // encountered on this device after joining or creating them elsewhere.\n const organizationRoots = rootStates.filter(\n (entry) => entry.container.organizationId === organizationId,\n );\n const acknowledgedRootId = state.runtime.auth.rootContainerId;\n const organizationRootState = acknowledgedRootId\n ? organizationRoots.find(\n (entry) => entry.container.id === acknowledgedRootId,\n )\n : organizationRoots.length === 1\n ? organizationRoots[0]\n : null;\n if (organizationRootState) {\n return organizationRootState;\n }\n\n if (defaultRootState && isPreAuthRootState(defaultRootState)) {\n return defaultRootState;\n }\n return rootStates.find(isPreAuthRootState) ?? null;\n}\n\nexport function findSystemContainerStateForRoot(\n state: ContainerContentsStoreState,\n systemSlot: ContainerSystemSlot,\n rootState: ContainerState | null,\n): ContainerState | null {\n const { rootContainerId } = state.runtime.auth;\n const organizationId =\n rootState?.container.organizationId || state.runtime.auth.organizationId;\n const expectedRootId = rootState?.container.id ?? rootContainerId;\n for (const containerState of state.containersById.values()) {\n const container = containerState.container;\n if (container.systemSlot !== systemSlot) continue;\n if (expectedRootId && container.parentId !== expectedRootId) continue;\n const isLocalCandidate =\n rootState && isPreAuthRootState(rootState) && !container.organizationId;\n if (\n organizationId &&\n !isLocalCandidate &&\n container.organizationId !== organizationId\n )\n continue;\n return containerState;\n }\n return null;\n}\n\n/** Callers must derive the metadata slot before using this as a destination. */\nexport function findOrganizationSystemRootState(\n state: ContainerContentsStoreState,\n organizationId: string,\n systemSlot: ContainerSystemSlot,\n): ContainerState | null {\n for (const entry of state.containersById.values()) {\n const container = entry.container;\n if (\n container.parentId === null &&\n container.organizationId === organizationId &&\n container.systemSlot === systemSlot\n )\n return entry;\n }\n return null;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemContainerPostCreate.js","sourceRoot":"","sources":["systemContainerPostCreate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAK1D,OAAO,EACL,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,yBAAyB,CAAC;AAIjC,SAAS,oDAAoD,CAC3D,KAAkC,EAClC,UAA+B,EAC/B,OAAuB;IAEvB,IAAI,4BAA4B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,+BAA+B,CAClD,KAAK,EACL,UAAU,EACV,WAAW,CACZ,CAAC;IACF,IACE,CAAC,YAAY;QACb,YAAY,CAAC,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAC,EAAE;QAClD,CAAC,4BAA4B,CAAC,YAAY,CAAC,EAC3C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,oCAAoC,CAAC,KAG7C;IACC,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,O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CAA0C,CAAC;YAC/C,OAAO;YACP,SAAS;YACT,UAAU;YACV,KAAK;SACN,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,EAAE;YAAE,OAAO,IAAI,CAAC;QAC9B,YAAY,GAAG,oDAAoD,CACjE,KAAK,EACL,UAAU,EACV,OAAO,CAAC,cAAc,CACvB,CAAC;QACF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,yCAAyC,CAAC;gBAC9C,OAAO;gBACP,SAAS;gBACT,YAAY;gBACZ,KAAK;aACN,CAAC,CAAC;YACH,OAAO,SAAS,EAAE;gBAChB,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE;gBACjD,CAAC,CAAC,IAAI,CAAC;QACX,CAAC;IACH,CAAC;IAED,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,IAAI,CAAC;IAC9B,KAAK,CAAC,cAAc,CAAC,GAAG,CACtB,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,EACnC,OAAO,CAAC,cAAc,CACvB,CAAC;IACF,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;QAC9B,SAAS,CAAC,YAAY,EAAE,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,KAAK,CAAC,QAAQ,+BAA+B,UAAU,GAAG,CAC9D,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport type { CreatedChildContainerState } from \"../../workflows/container-contents/container-state/types\";\nimport { isRemoteBackedContainerState } from \"./remoteBackedContainerState\";\nimport { updateContainerContentsSnapshot } from \"./state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport {\n findRootContainerState,\n findSystemContainerStateForRoot,\n} from \"./systemContainerLookup\";\nimport type { ContainerContentsStoreState } from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nfunction findSystemContainerCreatedAfterRemoteHydrationTarget(\n state: ContainerContentsStoreState,\n systemSlot: ContainerSystemSlot,\n created: ContainerState,\n): ContainerState | null {\n if (isRemoteBackedContainerState(created)) {\n return null;\n }\n\n const currentRoot = findRootContainerState(state);\n const remoteTarget = findSystemContainerStateForRoot(\n state,\n systemSlot,\n currentRoot,\n );\n if (\n !remoteTarget ||\n remoteTarget.container.id === created.container.id ||\n !isRemoteBackedContainerState(remoteTarget)\n ) {\n return null;\n }\n\n return remoteTarget;\n}\n\nfunction findCreatedSystemContainerRebaseRoot(input: {\n created: CreatedChildContainerState;\n state: ContainerContentsStoreState;\n}): ContainerState | null {\n const { containerState } = input.created;\n const currentRoot = findRootContainerState(input.state);\n if (\n !currentRoot ||\n !isRemoteBackedContainerState(currentRoot) ||\n (containerState.container.parentId === currentRoot.container.id &&\n containerState.container.organizationId ===\n currentRoot.container.organizationId)\n ) {\n return null;\n }\n return currentRoot;\n}\n\nasync function rebaseCreatedSystemContainerOntoRemoteRoot(input: {\n created: CreatedChildContainerState;\n isCurrent: ContainerWriteGuard;\n remoteRoot: ContainerState;\n state: ContainerContentsStoreState;\n}): Promise<void> {\n const { created, remoteRoot, state } = input;\n const containerState = created.containerState;\n const rebasedContainer = {\n ...containerState.container,\n organizationId: remoteRoot.container.organizationId,\n parentId: remoteRoot.container.id,\n };\n const persistedContainer = await state.persistence.saveContainer(\n state.runtime.infra.execSql,\n rebasedContainer,\n containerState.record,\n {\n ...(created.shouldRequestSync\n ? { createIntent: { parentContainerId: remoteRoot.container.id } }\n : {}),\n stillCurrent: input.isCurrent,\n },\n );\n if (!input.isCurrent()) return;\n containerState.container = persistedContainer;\n}\n\nasync function reconcileCreatedSystemContainerIntoTarget(input: {\n created: CreatedChildContainerState;\n isCurrent: ContainerWriteGuard;\n remoteTarget: ContainerState;\n state: ContainerContentsStoreState;\n}): Promise<void> {\n if (!input.isCurrent()) return;\n await input.state.persistence.reconcileLocalSystemContainer(\n input.state.runtime.infra.execSql,\n {\n localContainerId: input.created.containerState.container.id,\n remoteContainerId: input.remoteTarget.container.id,\n remoteOrganizationId: input.remoteTarget.container.organizationId,\n stillCurrent: input.isCurrent,\n },\n );\n}\n\nexport async function finalizeCreatedSystemContainer(input: {\n created: CreatedChildContainerState;\n logLabel: string;\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n systemSlot: ContainerSystemSlot;\n isCurrent?: ContainerWriteGuard | undefined;\n}): Promise<{ adopted: boolean; containerState: ContainerState } | null> {\n const { created, state, syncAgent, systemSlot } = input;\n const isCurrent = input.isCurrent ?? (() => true);\n // Keep the no-target check and local insertion in one synchronous turn. If\n // we yielded between them, remote root hydration could delete the captured\n // parent in that gap and this create would land as an orphan afterward.\n let remoteTarget = findSystemContainerCreatedAfterRemoteHydrationTarget(\n state,\n systemSlot,\n created.containerState,\n );\n if (remoteTarget) {\n await reconcileCreatedSystemContainerIntoTarget({\n created,\n isCurrent,\n remoteTarget,\n state,\n });\n return isCurrent() ? { adopted: true, containerState: remoteTarget } : null;\n }\n\n // The remote root can arrive before its system child. Rebase the persisted\n // candidate now so that a later same-slot child matches normal reconciliation\n // instead of leaving the candidate under the deleted pre-auth root.\n const remoteRoot = findCreatedSystemContainerRebaseRoot({ created, state });\n if (remoteRoot) {\n await rebaseCreatedSystemContainerOntoRemoteRoot({\n created,\n isCurrent,\n remoteRoot,\n state,\n });\n if (!isCurrent()) return null;\n remoteTarget = findSystemContainerCreatedAfterRemoteHydrationTarget(\n state,\n systemSlot,\n created.containerState,\n );\n if (remoteTarget) {\n await reconcileCreatedSystemContainerIntoTarget({\n created,\n isCurrent,\n remoteTarget,\n state,\n });\n return isCurrent()\n ? { adopted: true, containerState: remoteTarget }\n : null;\n }\n }\n\n if (!isCurrent()) return null;\n state.containersById.set(\n created.containerState.container.id,\n created.containerState,\n );\n updateContainerContentsSnapshot(state);\n if (created.shouldRequestSync) {\n syncAgent.scheduleSync();\n }\n state.runtime.util.log(\n `${input.logLabel}: ensured system container \"${systemSlot}\"`,\n );\n return { adopted: false, containerState: created.containerState };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemContainerPromotion.js","sourceRoot":"","sources":["systemContainerPromotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWpD,MAAM,UAAU,oCAAoC,CAClD,cAA8B;IAE9B,OAAO,CACL,cAAc,CAAC,4BAA4B,EAAE,IAAI,CAC/C,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CACrC,IAAI,KAAK,CACX,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAAC,KAgB7D;IACC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACvE,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,iBAAiB,GAAG,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC;IAC5D,IACE,OAAO,CAAC,eAAe;QACvB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;QACnC,CAAC,iBAAiB;QAClB,cAAc,CAAC,MAAM,CAAC,UAAU,EAChC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,OAAO,CAAC,uBAAuB;QAC/B,SAAS;QACT,oCAAoC,CAAC,SAAS,CAAC,EAC/C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5C,MAAM,CAAC,o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IAAI,CAAC;AACd,CAAC","sourcesContent":["import { base64ToBytes } from \"@tearleads/encoding\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"./syncAgent\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"./types\";\nimport type { ContainerWriteGuard } from \"./writeGeneration\";\n\nexport function hasAdvancedManagedPrincipalReference(\n containerState: ContainerState,\n): boolean {\n return (\n containerState.metadataReferencedPrincipals?.some(\n (principal) => principal.version > 1,\n ) ?? false\n );\n}\n\nexport async function promoteExistingLocalSystemContainerSync(input: {\n containerState: ContainerState;\n logLabel: string;\n options: EnsureSystemContainerOptions;\n persistPromotion: (\n containerState: ContainerState,\n promotion: {\n metadataUpdate?: Uint8Array | undefined;\n parentContainerId: string;\n queueCreateIntent: boolean;\n },\n ) => Promise<boolean>;\n rootState: ContainerState | null;\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n isCurrent?: ContainerWriteGuard | undefined;\n}): Promise<boolean> {\n const { containerState, options, rootState, state, syncAgent } = input;\n const isCurrent = input.isCurrent ?? (() => true);\n const parentContainerId = containerState.container.parentId;\n if (\n options.deferRemoteSync ||\n !state.runtime.auth.isAuthenticated ||\n !parentContainerId ||\n containerState.record.documentId\n ) {\n return true;\n }\n\n if (\n options.skipAdvancedManagedRoot &&\n rootState &&\n hasAdvancedManagedPrincipalReference(rootState)\n ) {\n return true;\n }\n\n const execSql = state.runtime.infra.execSql;\n const [pendingCreateIntents, pendingUpdates] = await Promise.all([\n state.persistence.listPendingCreateIntents(execSql),\n state.persistence.listPendingUpdates(execSql, containerState.container.id),\n ]);\n if (!isCurrent()) return false;\n const hasPendingCreateIntent = pendingCreateIntents.some(\n (intent) => intent.containerId === containerState.container.id,\n );\n const shouldQueueCreateIntent = !hasPendingCreateIntent;\n const shouldQueueMetadataUpdate = pendingUpdates.length === 0;\n if (!shouldQueueCreateIntent && !shouldQueueMetadataUpdate) {\n return true;\n }\n\n const persisted = await input.persistPromotion(containerState, {\n ...(shouldQueueMetadataUpdate\n ? {\n metadataUpdate: base64ToBytes(containerState.record.metadataUpdates),\n }\n : {}),\n parentContainerId,\n queueCreateIntent: shouldQueueCreateIntent,\n });\n if (!persisted || !isCurrent()) {\n return false;\n }\n\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${input.logLabel}: queued system container \"${containerState.container.systemSlot ?? containerState.container.id}\" for remote sync`,\n );\n return true;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeGeneration.js","sourceRoot":"","sources":["writeGeneration.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,8BAA8B,CAC5C,eAA8C,EAC9C,cAA6C;IAE7C,OAAO,CACL,eAAe,CAAC,kBAAkB,KAAK,cAAc,CAAC,kBAAkB;QACxE,eAAe,CAAC,SAAS,KAAK,cAAc,CAAC,SAAS;QACtD,eAAe,CAAC,IAAI,CAAC,qBAAqB;YACxC,cAAc,CAAC,IAAI,CAAC,qBAAqB;QAC3C,eAAe,CAAC,IAAI,CAAC,eAAe;YAClC,cAAc,CAAC,IAAI,CAAC,eAAe;QACrC,eAAe,CAAC,IAAI,CAAC,cAAc;YACjC,cAAc,CAAC,IAAI,CAAC,cAAc;QACpC,eAAe,CAAC,IAAI,CAAC,MAAM,KAAK,cAAc,CAAC,IAAI,CAAC,MAAM;QAC1D,eAAe,CAAC,MAAM,CAAC,oBAAoB;YACzC,cAAc,CAAC,MAAM,CAAC,oBAAoB;QAC5C,eAAe,CAAC,MAAM,CAAC,kBAAkB;YACvC,cAAc,CAAC,MAAM,CAAC,kBAAkB;QAC1C,eAAe,CAAC,MAAM,CAAC,cAAc;YACnC,cAAc,CAAC,MAAM,CAAC,cAAc;QACtC,eAAe,CAAC,KAAK,CAAC,SAAS,KAAK,cAAc,CAAC,KAAK,CAAC,SAAS;QAClE,eAAe,CAAC,KAAK,CAAC,QAAQ,KAAK,cAAc,CAAC,KAAK,CAAC,QAAQ;QAChE,eAAe,CAAC,KAAK,CAAC,kBAAkB;YACtC,cAAc,CAAC,KAAK,CAAC,kBAAkB;QACzC,eAAe,CAAC,KAAK,CAAC,OAAO,KAAK,cAAc,CAAC,KAAK,CAAC,OAAO;QAC9D,eAAe,CAAC,0BAA0B;YACxC,cAAc,CAAC,0BAA0B;QAC3C,eAAe,CAAC,KAAK,CAAC,WAAW,KAAK,cAAc,CAAC,KAAK,CAAC,WAAW;QACtE,eAAe,CAAC,KAAK,CAAC,WAAW,KAAK,cAAc,CAAC,KAAK,CAAC,WAAW,CACvE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,KAAkC;IAElC,MAAM,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC;IACtD,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IAC9C,OAAO,GAAG,EAAE,CACV,KAAK,CAAC,mBAAmB,KAAK,mBAAmB;QACjD,KAAK,CAAC,WAAW,KAAK,WAAW;QACjC,KAAK,CAAC,eAAe,KAAK,eAAe;QACzC,CAAC,8BAA8B,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import type { ContainerContentsStoreRuntime } from \"./syncAgentTypes\";\nimport type { ContainerContentsStoreState } from \"./types\";\n\nexport type ContainerWriteGuard = () => boolean;\n\nexport function didContainerWriteRuntimeChange(\n previousRuntime: ContainerContentsStoreRuntime,\n currentRuntime: ContainerContentsStoreRuntime,\n): boolean {\n return (\n previousRuntime.adoptRootContainer !== currentRuntime.adoptRootContainer ||\n previousRuntime.apiClient !== currentRuntime.apiClient ||\n previousRuntime.auth.defaultOrganizationId !==\n currentRuntime.auth.defaultOrganizationId ||\n previousRuntime.auth.isAuthenticated !==\n currentRuntime.auth.isAuthenticated ||\n previousRuntime.auth.organizationId !==\n currentRuntime.auth.organizationId ||\n previousRuntime.auth.userId !== currentRuntime.auth.userId ||\n previousRuntime.crypto.encapsulationKeyPair !==\n currentRuntime.crypto.encapsulationKeyPair ||\n previousRuntime.crypto.signingFingerprint !==\n currentRuntime.crypto.signingFingerprint ||\n previousRuntime.crypto.signingKeyPair !==\n currentRuntime.crypto.signingKeyPair ||\n previousRuntime.infra.blobStore !== currentRuntime.infra.blobStore ||\n previousRuntime.infra.dbStatus !== currentRuntime.infra.dbStatus ||\n previousRuntime.infra.documentProjectors !==\n currentRuntime.infra.documentProjectors ||\n previousRuntime.infra.execSql !== currentRuntime.infra.execSql ||\n previousRuntime.resolveTrustedUserIdentity !==\n currentRuntime.resolveTrustedUserIdentity ||\n previousRuntime.state.containerId !== currentRuntime.state.containerId ||\n previousRuntime.state.domainScope !== currentRuntime.state.domainScope\n );\n}\n\nexport function captureContainerWriteGeneration(\n state: ContainerContentsStoreState,\n): ContainerWriteGuard {\n const lifecycleGeneration = state.lifecycleGeneration;\n const persistence = state.persistence;\n const runtime = state.runtime;\n const writeGeneration = state.writeGeneration;\n return () =>\n state.lifecycleGeneration === lifecycleGeneration &&\n state.persistence === persistence &&\n state.writeGeneration === writeGeneration &&\n !didContainerWriteRuntimeChange(runtime, state.runtime);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentDetachState.js","sourceRoot":"","sources":["attachmentDetachState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAIjF,SAAS,cAAc,CAAC,GAAkB;IACxC,OAAO,IAAI,GAAG,CACZ,sBAAsB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CACnE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,WAAiD,EACjD,GAAyB;IAEzB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACpC,UAAU,CAAC,UAAU,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QACnE,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,UAAU,EAAE;QAC/B,CAAC,CAAC,UAAU,CACf,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,WAAiD,EACjD,GAAkB;IAElB,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACxC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,UAAU,KAAK,CAAC,UAAU,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE,CAAC;YACpD,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,CAAC,EAAE,GAAG,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Keeps a local attachment row's detach marker consistent with the document.\n *\n * The invariant is one line: a local blob row is marked detached exactly when\n * its slot is no longer in the document. The read models trust that marker to\n * decide whether a blob is still referenced, so anything that writes these rows\n * has to preserve it rather than restate what it believed the slots were.\n *\n * Two writers can otherwise clear a marker they never meant to touch: an upload\n * that settles after the user removed its slot, and a hydration that captured\n * the attachment list before an unlink and writes it back after. Both read the\n * slot list, await, then save — so the slot they save may already be gone.\n */\nimport { getDocumentAttachments } from \"../../../data/documents/documentContent\";\nimport type { LocalAttachmentRecord } from \"../../../workflows/documents\";\nimport type { DocumentState } from \"./state\";\n\nfunction getLiveSlotIds(doc: DocumentState): ReadonlySet<string> {\n return new Set(\n getDocumentAttachments(doc).map((attachment) => attachment.slotId),\n );\n}\n\n/**\n * Stamp records being written for slots the document no longer has as detached.\n *\n * The document is read here, at write time, rather than trusted from the\n * caller's earlier snapshot — the Loro document is mutated in place, so this\n * sees any unlink that landed while the caller was awaiting.\n */\nexport function withLocalAttachmentDetachState(\n attachments: ReadonlyArray<LocalAttachmentRecord>,\n doc: DocumentState | null,\n): LocalAttachmentRecord[] {\n if (!doc) {\n return [...attachments];\n }\n\n const detachedAt = new Date().toISOString();\n const liveSlotIds = getLiveSlotIds(doc);\n return attachments.map((attachment) =>\n attachment.detachedAt === null && !liveSlotIds.has(attachment.slotId)\n ? { ...attachment, detachedAt }\n : attachment,\n );\n}\n\n/**\n * Report the loaded rows whose marker disagrees with the loaded document.\n *\n * A write can only be interrupted between marking the row and persisting the\n * document, so a restart can find either half applied. Reconciling against the\n * durable document at load makes the marker mean what it claims again: a slot\n * the document still has is live, and a slot it dropped is detached.\n */\nexport function reconcileLocalAttachmentDetachState(\n attachments: ReadonlyArray<LocalAttachmentRecord>,\n doc: DocumentState,\n): LocalAttachmentRecord[] {\n const detachedAt = new Date().toISOString();\n const liveSlotIds = getLiveSlotIds(doc);\n return attachments.flatMap((attachment) => {\n const slotIsLive = liveSlotIds.has(attachment.slotId);\n if (slotIsLive === (attachment.detachedAt === null)) {\n return [];\n }\n\n return [{ ...attachment, detachedAt: slotIsLive ? null : detachedAt }];\n });\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentHydration.js","sourceRoot":"","sources":["attachmentHydration.ts"],"names":[],"m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C,KAAK,CACjB,CAAC,IAAI,EAAE,EAAE,CACP,KAAK,CAAC,wBAAwB,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,MAAM,CACtB,EACD,CAAC;QACD,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE;YACxB,UAAU,EAAE,aAAa,CAAC,UAAU;YACpC,QAAQ,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC;YACjC,QAAQ,EAAE,cAAc;SACzB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAyB,EACzB,UAAyB,EACzB,UAAkB,EAClB,WAAsD,EACtD,cAAsB;IAEtB,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,iBAAiB,GACrB,cAAc;QACd,CAAC,OAAO,EAAE,UAAU,KAAK,UAAU;YACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,UAAU;YACrC,CAAC,CAAC,OAAO,CAAC,QAAQ;YAClB,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,OAAO,CACL,CAAC,iBAAiB;QAClB,WAAW,CAAC,KAAK,CACf,CAAC,UAAU,EAAE,EAAE,CACb,KAAK,CAAC,4BAA4B,CAAC,UAAU,CAAC,MAAM,CAAC;YACrD,KAAK,CAAC,+BAA+B,CAAC,UAAU,CAAC,MAAM,CAAC;gBACtD,UAAU,CAAC,aAAa,CAC7B,CACF,CAAC;AACJ,CAAC","sourcesContent":["/** Hydrate only bytes matching the current document's authenticated attachment intent. */\n\nimport { getDocumentAttachments } from \"../../../data/documents/documentContent\";\nimport { hydrateDocumentAttachmentBlobs } from \"../../../workflows/blobs\";\nimport type { DocumentRecord } from \"../../../workflows/documents\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../../workflows/principals/runtimePolicyWarmer\";\nimport { commitHydratedAttachment } from \"./attachmentHydrationCommit\";\nimport { runDocumentOrphanMaintenance } from \"./orphanMaintenance\";\nimport type { DocumentState, DocumentStoreState } from \"./state\";\nimport {\n type DocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent as isSyncGenerationCurrent,\n} from \"./syncGeneration\";\n\n// A remote probe is evidence that bindings may have moved independently of\n// content. Capture its sequence before I/O so a hint arriving during hydration\n// survives for the trailing pass. Missing or changed local bytes always retry.\nconst checkedSignals = new WeakMap<\n DocumentStoreState,\n { documentId: string; document: WeakRef<DocumentState>; sequence: number }\n>();\n\nexport async function hydrateAttachmentBlobs(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n currentRecord: DocumentRecord | null,\n expectedGeneration?: DocumentStoreSyncGeneration,\n) {\n const generationIsCurrent = () =>\n !expectedGeneration || isSyncGenerationCurrent(state, expectedGeneration);\n if (!generationIsCurrent()) return;\n\n const runtime = state.runtime;\n const encapsulationKeyPair = runtime.crypto.encapsulationKeyPair;\n if (\n !encapsulationKeyPair ||\n !runtime.auth.isAuthenticated ||\n !runtime.state.online ||\n !currentRecord?.documentId\n ) {\n return;\n }\n\n const attachments = getDocumentAttachments(currentDoc);\n if (attachments.length === 0) {\n return;\n }\n\n const signalSequence = state.remoteUpdateSignalSeq;\n if (\n bindingsAlreadyChecked(\n state,\n currentDoc,\n currentRecord.documentId,\n attachments,\n signalSequence,\n )\n )\n return;\n\n const expectedStorageKeys = { ...state.attachmentStorageKeyBySlotId };\n let bindingsChecked = false;\n const hydratedBlobs = await hydrateDocumentAttachmentBlobs({\n apiClient: runtime.apiClient,\n onBindingsChecked: () => {\n bindingsChecked = true;\n },\n attachments,\n documentId: currentRecord.documentId,\n execSql: runtime.infra.execSql,\n localBlobIdBySlotId: state.attachmentBlobIdBySlotId,\n localStorageKeyBySlotId: state.attachmentStorageKeyBySlotId,\n log: runtime.util.log,\n rejectedServedBindings: state.rejectedServedAttachmentBindings,\n reportSecurityIncident: runtime.util.reportSecurityIncident,\n resolveProjectionUserKey:\n expectedGeneration?.resolveProjectionUserKey ??\n state.resolveProjectionUserKey,\n targetSecretKey: encapsulationKeyPair.secretKey,\n stillCurrent: generationIsCurrent,\n warmReferencedPrincipalPolicies:\n createRuntimePrincipalPolicyWarmer(runtime),\n });\n if (!generationIsCurrent()) return;\n if (!hydratedBlobs) {\n return;\n }\n\n for (const hydratedBlob of hydratedBlobs) {\n await commitHydratedAttachment({\n state,\n currentDoc,\n hydratedBlob,\n generationIsCurrent,\n expectedStorageKey:\n expectedStorageKeys[hydratedBlob.attachment.slotId] ?? null,\n });\n }\n if (\n bindingsChecked &&\n generationIsCurrent() &&\n hydratedBlobs.every(\n (blob) =>\n state.attachmentBlobIdBySlotId[blob.attachment.slotId] ===\n blob.binding.blobId,\n )\n ) {\n checkedSignals.set(state, {\n documentId: currentRecord.documentId,\n document: new WeakRef(currentDoc),\n sequence: signalSequence,\n });\n }\n void runDocumentOrphanMaintenance(state);\n}\n\nfunction bindingsAlreadyChecked(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n documentId: string,\n attachments: ReturnType<typeof getDocumentAttachments>,\n signalSequence: number,\n): boolean {\n const checked = checkedSignals.get(state);\n const needsBindingProbe =\n signalSequence >\n (checked?.documentId === documentId &&\n checked.document.deref() === currentDoc\n ? checked.sequence\n : 0);\n return (\n !needsBindingProbe &&\n attachments.every(\n (attachment) =>\n state.attachmentStorageKeyBySlotId[attachment.slotId] &&\n state.attachmentContentSha256BySlotId[attachment.slotId] ===\n attachment.contentSha256,\n )\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentHydrationCommit.js","sourceRoot":"","sources":["attachmentHydrationCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,OAAO,EAEL,iCAAiC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,gEAAgE,CAAC;AAChH,OAA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AAC,UAAU,CAAC,MAAM;YACtC,UAAU,EAAE,YAAY,CAAC,UAAU;SACpC,CAAC;QACF,MAAM,SAAS,GAAG,MAAM,8BAA8B,CAAC;YACrD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;YAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU;YACV,kBAAkB;YAClB,0BAA0B;YAC1B,YAAY;SACb,CAAC,CAAC;QACH,IAAI,SAAS,IAAI,YAAY,EAAE;YAC7B,6BAA6B,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;aAC5D,IAAI,CAAC,SAAS,IAAI,YAAY,EAAE;YACnC,MAAM,4BAA4B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,4BAA4B,CACzC,KAAqD,EACrD,YAA2B;IAE3B,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAClD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,oBAAoB,CACvD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC3B,KAAK,CAAC,OAAO,CACd,CAAC;IACF,IAAI,CAAC,YAAY,EAAE;QAAE,OAAO;IAC5B,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC;IAC9C,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzC,6BAA6B,CAC3B,KAAK,EACL,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,EAC3C,UAAU,CACX,CAAC;AACJ,CAAC","sourcesContent":["import { getDocumentAttachments } from \"../../../data/documents/documentContent\";\nimport type { hydrateDocumentAttachmentBlobs } from \"../../../workflows/blobs\";\nimport {\n type LocalAttachmentRecord,\n runSerializedDocumentBlobMutation,\n} from \"../../../workflows/documents\";\nimport { saveHydratedDocumentAttachment } from \"../../../workflows/documents/attachments/attachmentPersistence\";\nimport {\n installLocalAttachmentRecords,\n removeLocalAttachmentSlot,\n} from \"./attachmentPersistence\";\nimport type { DocumentState, DocumentStoreState } from \"./state\";\n\ntype HydratedBlob = NonNullable<\n Awaited<ReturnType<typeof hydrateDocumentAttachmentBlobs>>\n>[number];\n\nexport async function commitHydratedAttachment(input: {\n state: DocumentStoreState;\n currentDoc: DocumentState;\n hydratedBlob: Pick<\n HydratedBlob,\n \"attachment\" | \"bytes\" | \"contentSha256\" | \"storageKey\"\n > & {\n binding: Pick<HydratedBlob[\"binding\"], \"blobId\">;\n };\n expectedStorageKey: string | null;\n generationIsCurrent: () => boolean;\n}): Promise<void> {\n const {\n state,\n currentDoc,\n hydratedBlob,\n expectedStorageKey,\n generationIsCurrent,\n } = input;\n const runtime = state.runtime;\n const expectedSnapshotEndVersion = state.record?.snapshotEndVersion ?? null;\n const stillCurrent = () =>\n generationIsCurrent() &&\n state.doc === currentDoc &&\n getDocumentAttachments(currentDoc).some(\n (attachment) =>\n attachment.slotId === hydratedBlob.attachment.slotId &&\n attachment.contentSha256 === hydratedBlob.attachment.contentSha256,\n );\n await runSerializedDocumentBlobMutation(\n runtime.infra.execSql,\n hydratedBlob.storageKey,\n async () => {\n if (!stillCurrent()) return;\n await runtime.infra.blobStore.writeBytes(\n hydratedBlob.storageKey,\n hydratedBlob.bytes,\n );\n const attachment: LocalAttachmentRecord = {\n blobId: hydratedBlob.binding.blobId,\n // The held bytes' own size, not the document intent's: a served\n // binding the intent has not recorded yet may differ in length, and\n // preview gating reads the local record.\n byteLength: hydratedBlob.bytes.byteLength,\n contentSha256: hydratedBlob.contentSha256,\n detachedAt: null,\n localId: state.localId,\n mimeType: hydratedBlob.attachment.mimeType,\n slotId: hydratedBlob.attachment.slotId,\n storageKey: hydratedBlob.storageKey,\n };\n const committed = await saveHydratedDocumentAttachment({\n execSql: runtime.infra.execSql,\n persistence: state.persistence,\n attachment,\n expectedStorageKey,\n expectedSnapshotEndVersion,\n stillCurrent,\n });\n if (committed && stillCurrent())\n installLocalAttachmentRecords(state, [attachment], currentDoc);\n else if (!committed && stillCurrent())\n await refreshRefusedAttachmentSlot(input, stillCurrent);\n },\n );\n}\n\nasync function refreshRefusedAttachmentSlot(\n input: Parameters<typeof commitHydratedAttachment>[0],\n stillCurrent: () => boolean,\n): Promise<void> {\n const { state, currentDoc, hydratedBlob } = input;\n const rows = await state.persistence.listLocalAttachments(\n state.runtime.infra.execSql,\n state.localId,\n );\n if (!stillCurrent()) return;\n const slotId = hydratedBlob.attachment.slotId;\n removeLocalAttachmentSlot(state, slotId);\n installLocalAttachmentRecords(\n state,\n rows.filter((row) => row.slotId === slotId),\n currentDoc,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentIntents.js","sourceRoot":"","sources":["attachmentIntents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAIrE,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,KAA8C;IAK9C,MAAM,sBAAsB,GAA8B,EAAE,CAAC;IAC7D,MAAM,eAAe,GAAyB,EAAE,CAAC;IAEjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,GAAG,OAAO,IAAI,MAAM,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChE,sBAAsB,CAAC,IAAI,CAAC;YAC1B,UAAU;YACV,aAAa;YACb,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM;YACN,UAAU;SACX,CAAC,CAAC;QACH,eAAe,CAAC,IAAI,CAAC;YACnB,aAAa;YACb,UAAU;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,IAA8B;IAE9B,OAAO;QACL,aAAa,EAAE,MAAM,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC;QACxD,UAAU,EAAE,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;QACjD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { attachmentContentSha256 } from \"../../../data/documents/attachmentContentIdentity\";\nimport type { DocumentAttachment } from \"../../../data/documents/documentContent\";\nimport { blobByteSourceInputLength } from \"../../../workflows/blobs\";\nimport type { PendingAttachmentRecord } from \"../../../workflows/documents\";\nimport type { DocumentAttachmentUpload } from \"../types\";\n\nexport async function buildPendingAttachments(\n localId: string,\n files: ReadonlyArray<DocumentAttachmentUpload>,\n): Promise<{\n nextAttachments: DocumentAttachment[];\n nextPendingAttachments: PendingAttachmentRecord[];\n}> {\n const nextPendingAttachments: PendingAttachmentRecord[] = [];\n const nextAttachments: DocumentAttachment[] = [];\n\n for (const file of files) {\n const slotId = crypto.randomUUID();\n const storageKey = `${localId}-${slotId}`;\n const byteLength = blobByteSourceInputLength(file.bytes);\n const contentSha256 = await attachmentContentSha256(file.bytes);\n nextPendingAttachments.push({\n byteLength,\n contentSha256,\n localId,\n mimeType: file.mimeType,\n name: file.name,\n slotId,\n storageKey,\n });\n nextAttachments.push({\n contentSha256,\n byteLength,\n mimeType: file.mimeType,\n name: file.name,\n slotId,\n });\n }\n\n return { nextAttachments, nextPendingAttachments };\n}\n\nexport async function buildAttachmentIntent(\n slotId: string,\n file: DocumentAttachmentUpload,\n): Promise<DocumentAttachment> {\n return {\n contentSha256: await attachmentContentSha256(file.bytes),\n byteLength: blobByteSourceInputLength(file.bytes),\n mimeType: file.mimeType,\n name: file.name,\n slotId,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentMutationPersistence.js","sourceRoot":"","sources":["attachmentMutationPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACL,uCAAuC,GAExC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIhD,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,KAMrD;IACC,MAAM,gCAAgC,CAAC;QACrC,kBAAkB,EAAE,KAAK,CAAC,UAAU;QACpC,uCAAuC,EAAE,IAAI;QAC7C,oBAAoB,EAAE,KAAK,CAAC,gBAAgB;QAC5C,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,KAUrD;IACC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAChC,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAC1B,KAAK,EACL,KAAK,CAAC,UAAU,EAChB,EAAE,kBAAkB,EAAE,KAAK,CAAC,cAAc,EAAE,EAC5C;YACE,iBAAiB,EAAE,MAAM;YACzB,aAAa,EACX,yBAAyB,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,SAAS;YAChE,gCAAgC,EAAE,IAAI;YACtC,oBAAoB,EAAE,IAAI;SAC3B,EACD,KAAK,CAAC,UAAU,CACjB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,uCAAuC,CAAC;YAC5C,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,KAAK;SACN,CAAC,CAAC;QACH,MAAM,+BAA+B,CAAC;YACpC,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,KAAK;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { createPendingUpdateFields } from \"../../../data/documents/documentSync\";\nimport {\n deleteUnreferencedStagedAttachmentBytes,\n type stagePendingAttachments,\n} from \"./attachmentStaging\";\nimport { reloadDocumentFromDurableHistory } from \"./durableDocumentReload\";\nimport { persistDocument } from \"./persistence\";\nimport type { DocumentStoreState } from \"./state\";\nimport type { captureDocumentStoreSyncGeneration } from \"./syncGeneration\";\n\nexport async function restoreFailedAttachmentMutation(input: {\n generation: NonNullable<\n ReturnType<typeof captureDocumentStoreSyncGeneration>\n >;\n rollbackSnapshot: Uint8Array;\n state: DocumentStoreState;\n}): Promise<void> {\n await reloadDocumentFromDurableHistory({\n expectedGeneration: input.generation,\n preserveQueuedWritesWhenIdentityMatches: true,\n sameIdentitySnapshot: input.rollbackSnapshot,\n state: input.state,\n });\n}\n\nexport async function persistStagedAttachmentMutation(input: {\n attachmentUpdate: Uint8Array;\n coveredVersion: string;\n currentDoc: NonNullable<DocumentStoreState[\"doc\"]>;\n generation: NonNullable<\n ReturnType<typeof captureDocumentStoreSyncGeneration>\n >;\n rollbackSnapshot: Uint8Array;\n staged: NonNullable<Awaited<ReturnType<typeof stagePendingAttachments>>>;\n state: DocumentStoreState;\n}) {\n const { staged, state } = input;\n try {\n return await persistDocument(\n state,\n input.currentDoc,\n { snapshotEndVersion: input.coveredVersion },\n {\n attachmentStaging: staged,\n pendingUpdate:\n createPendingUpdateFields(input.attachmentUpdate) ?? undefined,\n preserveSnapshotStructuredFields: true,\n preserveSnapshotText: true,\n },\n input.generation,\n );\n } catch (error) {\n await deleteUnreferencedStagedAttachmentBytes({\n generation: input.generation,\n pendingAttachments: staged.pendingAttachments,\n state,\n });\n await restoreFailedAttachmentMutation({\n generation: input.generation,\n rollbackSnapshot: input.rollbackSnapshot,\n state,\n });\n throw error;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentPersistFollowup.js","sourceRoot":"","sources":["attachmentPersistFollowup.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAMlD;IACC,IACE,KAAK,CAAC,2BAA2B,KAAK,KAAK,CAAC,4BAA4B;QACxE,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,kBAAkB,EACpD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,CACL,KAAK,CAAC,SAAS,CAAC,0BAA0B,KAAK,IAAI;QACnD,KAAK,CAAC,SAAS,CAAC,sBAAsB,KAAK,IAAI,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import type { PersistedDocumentRecord } from \"./state\";\n\n/**\n * A same-identity conflict may still leave newer durable work for the current\n * lane to submit. Identity replacement and local teardown deliberately do not\n * schedule the losing document against the replacement generation.\n */\nexport function attachmentPersistNeedsFollowupSync(input: {\n currentDocumentId: string | null | undefined;\n currentLocalWriteGeneration: number;\n expectedDocumentId: string | null;\n expectedLocalWriteGeneration: number;\n persisted: PersistedDocumentRecord | null;\n}): boolean {\n if (\n input.currentLocalWriteGeneration !== input.expectedLocalWriteGeneration ||\n input.currentDocumentId !== input.expectedDocumentId\n ) {\n return false;\n }\n if (!input.persisted) return true;\n return (\n input.persisted.pullContinuationSuperseded === true &&\n input.persisted.syncIdentitySuperseded !== true\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentPersistence.js","sourceRoot":"","sources":["attachmentPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAG/B,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAGL,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,oCAAoC,IAAI,uBAAuB,GAChE,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAyB,EACzB,MAAc,EACd,UAAkB,EAClB,kBAAgD;IAEhD,2EAA2E;IAC3E,mEAAmE;IACnE,aAAa;IACb,MAAM,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE,CACzE,+BAA+B,CAAC;QAC9B,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM;QACN,UAAU;KACX,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,KAAyB,EACzB,MAAc,EACd,UAAkB,EAClB,aAAmC,KAAK,CAAC,GAAG;IAE5C,MAAM,6BAA6B,CAAC;QAClC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM;QACN,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;QAC9D,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAA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U,6BAA6B,CAC3C,KAAyB,EACzB,WAAiD,EACjD,UAAgC;IAEhC,0BAA0B,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAE/C,IAAI,UAAU,IAAI,UAAU,KAAK,KAAK,CAAC,GAAG,EAAE,CAAC;QAC3C,gBAAgB,CACd,KAAK,EACL,UAAU,EACV,KAAK,CAAC,QAAQ,CAAC,OAAO,EACtB,KAAK,CAAC,QAAQ,CAAC,IAAI,EACnB,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAChC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAyB,EACzB,sBAA8D;IAE9D,MAAM,WAAW,GAAG,IAAI,GAAG,CACzB,sBAAsB,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAC5E,CAAC;IACF,KAAK,CAAC,kBAAkB,GAAG;QACzB,GAAG,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAChC,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAClE;QACD,GAAG,sBAAsB;KAC1B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,KAAyB,EACzB,iBAA0C,EAC1C,kBAAgD;IAEhD,yEAAyE;IACzE,uDAAuD;IACvD,MAAM,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE,CACzE,6BAA6B,CAAC;QAC5B,UAAU,EAAE,iBAAiB;QAC7B,OAAO;QACP,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {\n deleteLocalDocumentAttachment,\n deletePendingDocumentAttachment,\n type LocalAttachmentRecord,\n type PendingAttachmentRecord,\n saveLocalDocumentAttachments,\n savePendingDocumentAttachment,\n} from \"../../../workflows/documents\";\nimport { withLocalAttachmentDetachState } from \"./attachmentDetachState\";\nimport { withGenerationGuardedMutation } from \"./persistence\";\nimport {\n type DocumentState,\n type DocumentStoreState,\n setReadySnapshot,\n} from \"./state\";\nimport {\n type DocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent as isSyncGenerationCurrent,\n} from \"./syncGeneration\";\n\nexport async function deletePendingAttachment(\n state: DocumentStoreState,\n slotId: string,\n storageKey: string,\n expectedGeneration?: DocumentStoreSyncGeneration,\n) {\n // After a REFUSED discard the reset store keeps its rows, and a stale pass\n // racing that reset must not delete state the refusal deliberately\n // preserved.\n await withGenerationGuardedMutation(state, expectedGeneration, (execSql) =>\n deletePendingDocumentAttachment({\n execSql,\n localId: state.localId,\n persistence: state.persistence,\n slotId,\n storageKey,\n }),\n );\n}\n\nexport async function deleteLocalAttachmentRecord(\n state: DocumentStoreState,\n slotId: string,\n storageKey: string,\n currentDoc: DocumentState | null = state.doc,\n) {\n await deleteLocalDocumentAttachment({\n execSql: state.runtime.infra.execSql,\n localId: state.localId,\n persistence: state.persistence,\n slotId,\n storageKey,\n });\n\n if (state.attachmentStorageKeyBySlotId[slotId] === storageKey) {\n removeLocalAttachmentSlot(state, slotId);\n }\n\n if (currentDoc && currentDoc === state.doc) {\n setReadySnapshot(\n state,\n currentDoc,\n state.snapshot.syncing,\n state.snapshot.text,\n state.snapshot.structuredFields,\n );\n }\n}\n\nexport async function saveLocalAttachmentRecord(\n state: DocumentStoreState,\n attachment: LocalAttachmentRecord,\n currentDoc: DocumentState | null = state.doc,\n expectedGeneration?: DocumentStoreSyncGeneration,\n) {\n await saveLocalAttachmentRecords(\n state,\n [attachment],\n currentDoc,\n expectedGeneration,\n );\n}\n\nexport async function saveLocalAttachmentRecords(\n state: DocumentStoreState,\n attachments: ReadonlyArray<LocalAttachmentRecord>,\n currentDoc: DocumentState | null = state.doc,\n expectedGeneration?: DocumentStoreSyncGeneration,\n) {\n if (attachments.length === 0) {\n return;\n }\n\n // These rows are upserts, and a stale writer racing a teardown must never\n // re-insert what the teardown just removed.\n const saved = await withGenerationGuardedMutation(\n state,\n expectedGeneration,\n (execSql) =>\n saveLocalDocumentAttachments({\n attachments: withLocalAttachmentDetachState(attachments, currentDoc),\n execSql,\n persistence: state.persistence,\n }),\n );\n if (\n !saved ||\n (expectedGeneration && !isSyncGenerationCurrent(state, expectedGeneration))\n ) {\n return;\n }\n\n installLocalAttachmentRecords(state, attachments, currentDoc);\n}\n\ntype AttachmentSlot = Pick<\n LocalAttachmentRecord,\n \"slotId\" | \"blobId\" | \"contentSha256\" | \"storageKey\"\n>;\n\n/** Publish the held copy of each record's slot to the store's slot maps. */\nexport function assignLocalAttachmentSlots(\n state: DocumentStoreState,\n attachments: ReadonlyArray<AttachmentSlot>,\n): void {\n const entries = <T>(pick: (attachment: AttachmentSlot) => T) =>\n Object.fromEntries(\n attachments.map((attachment) => [attachment.slotId, pick(attachment)]),\n );\n state.attachmentBlobIdBySlotId = {\n ...state.attachmentBlobIdBySlotId,\n ...entries((attachment) => attachment.blobId),\n };\n state.attachmentContentSha256BySlotId = {\n ...state.attachmentContentSha256BySlotId,\n ...entries((attachment) => attachment.contentSha256),\n };\n state.attachmentStorageKeyBySlotId = {\n ...state.attachmentStorageKeyBySlotId,\n ...entries((attachment) => attachment.storageKey),\n };\n}\n\n/** Forget the held copy of one slot without touching its durable row. */\nexport function removeLocalAttachmentSlot(\n state: DocumentStoreState,\n slotId: string,\n): void {\n const { [slotId]: _blobId, ...blobIds } = state.attachmentBlobIdBySlotId;\n const { [slotId]: _contentSha256, ...contentSha256s } =\n state.attachmentContentSha256BySlotId;\n const { [slotId]: _storageKey, ...storageKeys } =\n state.attachmentStorageKeyBySlotId;\n state.attachmentBlobIdBySlotId = blobIds;\n state.attachmentContentSha256BySlotId = contentSha256s;\n state.attachmentStorageKeyBySlotId = storageKeys;\n}\n\nexport function installLocalAttachmentRecords(\n state: DocumentStoreState,\n attachments: ReadonlyArray<LocalAttachmentRecord>,\n currentDoc: DocumentState | null,\n) {\n assignLocalAttachmentSlots(state, attachments);\n\n if (currentDoc && currentDoc === state.doc) {\n setReadySnapshot(\n state,\n currentDoc,\n state.snapshot.syncing,\n state.snapshot.text,\n state.snapshot.structuredFields,\n );\n }\n}\n\nexport function upsertPendingAttachments(\n state: DocumentStoreState,\n nextPendingAttachments: ReadonlyArray<PendingAttachmentRecord>,\n) {\n const nextSlotIds = new Set(\n nextPendingAttachments.map((pendingAttachment) => pendingAttachment.slotId),\n );\n state.pendingAttachments = [\n ...state.pendingAttachments.filter(\n (pendingAttachment) => !nextSlotIds.has(pendingAttachment.slotId),\n ),\n ...nextPendingAttachments,\n ];\n}\n\n/**\n * Persist a pending attachment's upload-resume identity (blob id, content key,\n * IV, and — once staged — the multipart stage id/part size) so a later attempt\n * reuses it instead of orphaning the stage. The caller publishes the saved\n * identity on the live pending record only after this write succeeds.\n */\nexport async function savePendingAttachmentUpload(\n state: DocumentStoreState,\n pendingAttachment: PendingAttachmentRecord,\n expectedGeneration?: DocumentStoreSyncGeneration,\n): Promise<void> {\n // This row is an upsert, and a stale resume racing a teardown must never\n // re-insert the pending row the teardown just removed.\n await withGenerationGuardedMutation(state, expectedGeneration, (execSql) =>\n savePendingDocumentAttachment({\n attachment: pendingAttachment,\n execSql,\n persistence: state.persistence,\n }),\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentRemoval.js","sourceRoot":"","sources":["attachmentRemoval.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;A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E;QACxB,+BAA+B,CAAC,KAAK,EAAE,0BAA0B,EAAE,KAAK,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACL,OAAO,KAAK,CAAC,UAAU,CAAC;AAC1B,CAAC","sourcesContent":["import {\n encodeVersionVector,\n exportFullHistorySnapshot,\n} from \"@tearleads/loro\";\nimport {\n getDocumentAttachments,\n removeDocumentAttachment,\n} from \"../../../data/documents/documentContent\";\nimport { createPendingUpdateFields } from \"../../../data/documents/documentSync\";\nimport { requestDocumentStoreSync } from \"../registry\";\nimport { restoreFailedAttachmentMutation } from \"./attachmentMutationPersistence\";\nimport {\n assignLocalAttachmentSlots,\n removeLocalAttachmentSlot,\n} from \"./attachmentPersistence\";\nimport { ATTACHMENT_FAILURE_MESSAGE } from \"./attachments\";\nimport {\n type AttachmentWriteGeneration,\n captureAttachmentWriteGeneration,\n isAttachmentWriteGenerationCurrent,\n shouldAbortAttachmentPersistFollowup,\n} from \"./attachmentWriteGeneration\";\nimport { ensureDocumentStoreReady } from \"./initialization\";\nimport { runDocumentOrphanMaintenance } from \"./orphanMaintenance\";\nimport {\n advancePendingBaseVersion,\n pendingDeltaSinceBase,\n persistDocument,\n} from \"./persistence\";\nimport { reportDocumentStoreWriteFailure } from \"./reportWriteFailure\";\nimport {\n canWriteDocument,\n type DocumentStoreState,\n setReadySnapshot,\n} from \"./state\";\nimport { captureDocumentStoreSyncGeneration } from \"./syncGeneration\";\n\nfunction installCommittedAttachmentRemoval(input: {\n currentDoc: NonNullable<DocumentStoreState[\"doc\"]>;\n slotId: string;\n state: DocumentStoreState;\n storageKey: string | undefined;\n syncedAttachment: boolean;\n}): void {\n const { slotId, state, storageKey } = input;\n if (!storageKey) return;\n const pending = state.pendingAttachments.find(\n (attachment) =>\n attachment.slotId === slotId && attachment.storageKey === storageKey,\n );\n if (input.syncedAttachment && pending?.upload) {\n assignLocalAttachmentSlots(state, [\n {\n slotId,\n storageKey,\n blobId: pending.upload.blobId,\n contentSha256: pending.contentSha256,\n },\n ]);\n }\n state.pendingAttachments = state.pendingAttachments.filter(\n (attachment) =>\n attachment.slotId !== slotId || attachment.storageKey !== storageKey,\n );\n // The committed removal queued this key. A reset can leave another document\n // uploading from the same copy; a detached marker keeps it until sync.\n void runDocumentOrphanMaintenance(state);\n if (\n input.syncedAttachment ||\n state.attachmentStorageKeyBySlotId[slotId] !== storageKey\n ) {\n return;\n }\n removeLocalAttachmentSlot(state, slotId);\n setReadySnapshot(\n state,\n input.currentDoc,\n state.snapshot.syncing,\n state.snapshot.text,\n state.snapshot.structuredFields,\n );\n}\n\nasync function persistRemovedAttachment(\n state: DocumentStoreState,\n slotId: string,\n writeGeneration: AttachmentWriteGeneration,\n) {\n if (!isAttachmentWriteGenerationCurrent(state, writeGeneration)) return;\n const currentDoc = state.doc;\n if (!currentDoc) {\n return;\n }\n const generation = captureDocumentStoreSyncGeneration(state, currentDoc);\n if (!generation) {\n return;\n }\n\n const existingAttachment = getDocumentAttachments(currentDoc).find(\n (attachment) => attachment.slotId === slotId,\n );\n if (!existingAttachment) {\n return;\n }\n\n // After a reset, a store opened cold holds the slot only as a pending upload.\n const storageKey =\n state.attachmentStorageKeyBySlotId[slotId] ??\n state.pendingAttachments.find((attachment) => attachment.slotId === slotId)\n ?.storageKey;\n if (\n !isAttachmentWriteGenerationCurrent(state, writeGeneration) ||\n state.doc !== currentDoc\n )\n return;\n const rollbackSnapshot = exportFullHistorySnapshot(currentDoc).slice();\n removeDocumentAttachment(currentDoc, slotId);\n const attachmentUpdate = pendingDeltaSinceBase(state, currentDoc);\n const coveredVersion = encodeVersionVector(currentDoc);\n const pendingUpdate = createPendingUpdateFields(attachmentUpdate);\n const syncedAttachment = Boolean(state.record?.documentId);\n\n // Preserve the optimistic text/structured fields (see persistAttachedFiles):\n // removing an attachment while typing must not regress the editor.\n let persisted: Awaited<ReturnType<typeof persistDocument>>;\n try {\n persisted = await persistDocument(\n state,\n currentDoc,\n { snapshotEndVersion: coveredVersion },\n {\n ...(storageKey\n ? {\n attachmentRemoval: {\n mode: syncedAttachment\n ? (\"detach\" as const)\n : (\"delete\" as const),\n slotId,\n storageKey,\n },\n }\n : {}),\n ...(pendingUpdate ? { pendingUpdate } : {}),\n preserveSnapshotStructuredFields: true,\n preserveSnapshotText: true,\n },\n generation,\n );\n } catch (error) {\n await restoreFailedAttachmentMutation({\n generation,\n rollbackSnapshot,\n state,\n });\n throw error;\n }\n if (\n shouldAbortAttachmentPersistFollowup(\n state,\n writeGeneration,\n generation,\n persisted,\n )\n ) {\n // See persistAttachedFiles: only durable same-identity work re-arms sync.\n return;\n }\n installCommittedAttachmentRemoval({\n currentDoc,\n slotId,\n state,\n storageKey,\n syncedAttachment,\n });\n advancePendingBaseVersion(state, currentDoc);\n state.runtime.util.log(\n `Removed attachment ${existingAttachment.name} from document ${state.localId}.`,\n );\n requestDocumentStoreSync(state);\n}\n\nexport async function removeAttachmentFromDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n slotId: string,\n) {\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ATTACHMENT_FAILURE_MESSAGE, error);\n return;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return;\n }\n\n const writeGeneration = captureAttachmentWriteGeneration(state);\n if (!writeGeneration) return;\n state.writeChain = state.writeChain\n .catch(() => undefined)\n .then(async () => persistRemovedAttachment(state, slotId, writeGeneration))\n .catch((error: unknown) => {\n reportDocumentStoreWriteFailure(state, ATTACHMENT_FAILURE_MESSAGE, error);\n });\n return state.writeChain;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachmentSnapshot.js","sourceRoot":"","sources":["attachmentSnapshot.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,wBAAwB,CACtC,kBAAoD,EACpD,WAA8C;IAE9C,MAAM,eAAe,GAA2B,EAAE,CAAC;IAEnD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,kBAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,IAAI,UAAU,EAAE,CAAC;YACf,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;QAClD,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAIrC;IACC,MAAM,YAAY,GAA6C,EAAE,CAAC;IAElE,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QAC3C,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,MAAM,iBAAiB,GAAG,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzE,IACE,iBAAiB,KAAK,SAAS;YAC/B,iBAAiB,KAAK,UAAU,CAAC,aAAa,EAC9C,CAAC;YACD,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC;QACtD,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import type { DocumentAttachment } from \"../../../data/documents/documentContent\";\nimport type { DocumentAttachmentStatus } from \"../types\";\n\nexport function getAttachmentStorageKeys(\n storageKeyBySlotId: Readonly<Record<string, string>>,\n attachments: ReadonlyArray<DocumentAttachment>,\n): Record<string, string> {\n const nextStorageKeys: Record<string, string> = {};\n\n for (const attachment of attachments) {\n const storageKey = storageKeyBySlotId[attachment.slotId];\n if (storageKey) {\n nextStorageKeys[attachment.slotId] = storageKey;\n }\n }\n\n return nextStorageKeys;\n}\n\n/**\n * A slot is `syncing` while its upload is queued. Otherwise it is\n * `intent-mismatch` when the held bytes' digest differs from the digest the\n * document content records: a validly signed served binding the document has\n * not (yet) recorded. The status clears by itself once the content update\n * carrying the digest arrives or a matching binding is hydrated.\n */\nexport function getAttachmentStatuses(input: {\n attachments: ReadonlyArray<DocumentAttachment>;\n contentSha256BySlotId: Readonly<Record<string, string>>;\n pendingSlotIds: ReadonlySet<string>;\n}): Record<string, DocumentAttachmentStatus> {\n const nextStatuses: Record<string, DocumentAttachmentStatus> = {};\n\n for (const attachment of input.attachments) {\n if (input.pendingSlotIds.has(attachment.slotId)) {\n nextStatuses[attachment.slotId] = \"syncing\";\n continue;\n }\n const heldContentSha256 = input.contentSha256BySlotId[attachment.slotId];\n if (\n heldContentSha256 !== undefined &&\n heldContentSha256 !== attachment.contentSha256\n ) {\n nextStatuses[attachment.slotId] = \"intent-mismatch\";\n }\n }\n\n return nextStatuses;\n}\n"]}