@tearleads/client-sdk 0.1.62 → 0.1.63

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 (653) hide show
  1. package/client/organizations/currentPrincipalMutations.js +5 -5
  2. package/client/organizations/currentPrincipalMutations.js.map +1 -1
  3. package/client/organizations/organizationDataUsage.js +1 -1
  4. package/client/organizations/organizationDataUsage.js.map +1 -1
  5. package/client/organizations/organizationGroupHistory.js +1 -1
  6. package/client/organizations/organizationGroupHistory.js.map +1 -1
  7. package/client/organizations/organizationGroupNameHydration.js +3 -3
  8. package/client/organizations/organizationGroupNameHydration.js.map +1 -1
  9. package/client/organizations/organizationHistory.js +2 -2
  10. package/client/organizations/organizationHistory.js.map +1 -1
  11. package/client/organizations/organizationReadModels.js +1 -1
  12. package/client/organizations/organizationReadModels.js.map +1 -1
  13. package/client/organizations/principalContainerMutations.js +1 -1
  14. package/client/organizations/principalContainerMutations.js.map +1 -1
  15. package/client/organizations/principalMutationRecovery.js.map +1 -1
  16. package/client/organizations/principalMutations.js +5 -5
  17. package/client/organizations/principalMutations.js.map +1 -1
  18. package/client/runtime/principalMutationApi.d.ts +1 -1
  19. package/client/runtime/principalMutationApi.js +2 -2
  20. package/client/runtime/principalMutationApi.js.map +1 -1
  21. package/client/runtime/principalMutationDispatch.js +1 -1
  22. package/client/runtime/principalMutationDispatch.js.map +1 -1
  23. package/client/session/index.js +1 -1
  24. package/client/session/index.js.map +1 -1
  25. package/client/session/sessionOrganizationCreation.js +1 -1
  26. package/client/session/sessionOrganizationCreation.js.map +1 -1
  27. package/client/session/sessionPurgeRecovery.js +2 -2
  28. package/client/session/sessionPurgeRecovery.js.map +1 -1
  29. package/package.json +1 -1
  30. package/stores/documents/documentStore/attachmentHydrationCommit.js +1 -1
  31. package/stores/documents/documentStore/attachmentHydrationCommit.js.map +1 -1
  32. package/stores/documents/documentStore/attachmentUploadAttempt.js +1 -1
  33. package/stores/documents/documentStore/syncRemoteSignals.js +1 -1
  34. package/stores/documents/documentStore/syncRemoteSignals.js.map +1 -1
  35. package/stores/documents/documentStore/syncShared.js +1 -1
  36. package/stores/documents/documentStore/syncShared.js.map +1 -1
  37. package/workflows/blobs/detach.js +1 -1
  38. package/workflows/blobs/detach.js.map +1 -1
  39. package/workflows/blobs/{blobChunkDecryption.js → hydration/blobChunkDecryption.js} +3 -3
  40. package/workflows/blobs/hydration/blobChunkDecryption.js.map +1 -0
  41. package/workflows/blobs/{decrypt.d.ts → hydration/decrypt.d.ts} +2 -2
  42. package/workflows/blobs/{decrypt.js → hydration/decrypt.js} +14 -14
  43. package/workflows/blobs/hydration/decrypt.js.map +1 -0
  44. package/workflows/blobs/{hydrate.d.ts → hydration/hydrate.d.ts} +7 -7
  45. package/workflows/blobs/{hydrate.js → hydration/hydrate.js} +5 -5
  46. package/workflows/blobs/hydration/hydrate.js.map +1 -0
  47. package/workflows/blobs/{hydrationResults.js → hydration/hydrationResults.js} +2 -2
  48. package/workflows/blobs/hydration/hydrationResults.js.map +1 -0
  49. package/workflows/blobs/index.d.ts +3 -3
  50. package/workflows/blobs/index.js +3 -3
  51. package/workflows/blobs/index.js.map +1 -1
  52. package/workflows/blobs/{automaticMultipartUpload.js → upload/automaticMultipartUpload.js} +1 -1
  53. package/workflows/blobs/upload/automaticMultipartUpload.js.map +1 -0
  54. package/workflows/blobs/{upload.d.ts → upload/index.d.ts} +2 -2
  55. package/workflows/blobs/{upload.js → upload/index.js} +14 -14
  56. package/workflows/blobs/upload/index.js.map +1 -0
  57. package/workflows/blobs/{multipartFirstParts.js → upload/multipartFirstParts.js} +4 -4
  58. package/workflows/blobs/upload/multipartFirstParts.js.map +1 -0
  59. package/workflows/blobs/{multipartStageFailures.js → upload/multipartStageFailures.js} +1 -1
  60. package/workflows/blobs/upload/multipartStageFailures.js.map +1 -0
  61. package/workflows/blobs/upload/multipartStageResolution.js.map +1 -0
  62. package/workflows/blobs/{multipartUpload.js → upload/multipartUpload.js} +3 -3
  63. package/workflows/blobs/upload/multipartUpload.js.map +1 -0
  64. package/workflows/blobs/{attachmentBindingVerification.js → verification/attachmentBindingVerification.js} +3 -3
  65. package/workflows/blobs/verification/attachmentBindingVerification.js.map +1 -0
  66. package/workflows/blobs/{attachmentDecryptor.js → verification/attachmentDecryptor.js} +3 -3
  67. package/workflows/blobs/verification/attachmentDecryptor.js.map +1 -0
  68. package/workflows/blobs/{attachmentKeyAuthenticator.js → verification/attachmentKeyAuthenticator.js} +5 -5
  69. package/workflows/blobs/verification/attachmentKeyAuthenticator.js.map +1 -0
  70. package/workflows/blobs/{retainedAttachmentVerification.js → verification/retainedAttachmentVerification.js} +5 -5
  71. package/workflows/blobs/verification/retainedAttachmentVerification.js.map +1 -0
  72. package/workflows/blobs/{verifiedWrapScope.js → verification/verifiedWrapScope.js} +2 -2
  73. package/workflows/blobs/verification/verifiedWrapScope.js.map +1 -0
  74. package/workflows/blobs/{writerProjection.js → verification/writerProjection.js} +3 -3
  75. package/workflows/blobs/verification/writerProjection.js.map +1 -0
  76. package/workflows/container-contents/container-state/purgeTree.js.map +1 -1
  77. package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +1 -1
  78. package/workflows/container-contents/container-state/remote.js +1 -1
  79. package/workflows/container-contents/container-state/remote.js.map +1 -1
  80. package/workflows/container-contents/documentLinks/index.d.ts +1 -1
  81. package/workflows/container-contents/documentLinks/index.js.map +1 -1
  82. package/workflows/container-contents/info/containerInfo.d.ts +1 -1
  83. package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js +1 -1
  84. package/workflows/container-contents/metadata/metadataIncomingUpdateIsolation.js.map +1 -1
  85. package/workflows/container-contents/remoteHydration/destinationRootReload.js +1 -1
  86. package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +1 -1
  87. package/workflows/container-contents/remoteHydration/verifiedDestination.js +1 -1
  88. package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +1 -1
  89. package/workflows/container-contents/tombstones/documentPurge.d.ts +1 -1
  90. package/workflows/container-contents/tombstones/documentPurge.js.map +1 -1
  91. package/workflows/containers/child/currentShareGrantMutation.js +5 -5
  92. package/workflows/containers/child/currentShareGrantMutation.js.map +1 -1
  93. package/workflows/containers/child/currentSharePrincipalPolicy.js +5 -5
  94. package/workflows/containers/child/currentSharePrincipalPolicy.js.map +1 -1
  95. package/workflows/containers/child/runtimeCurrentGroupShare.js +1 -1
  96. package/workflows/containers/child/runtimeCurrentGroupShare.js.map +1 -1
  97. package/workflows/containers/child/share.d.ts +1 -1
  98. package/workflows/containers/child/share.js +4 -4
  99. package/workflows/containers/child/share.js.map +1 -1
  100. package/workflows/containers/child/sharePrincipalPolicy.d.ts +1 -1
  101. package/workflows/containers/child/sharePrincipalPolicy.js +2 -2
  102. package/workflows/containers/child/sharePrincipalPolicy.js.map +1 -1
  103. package/workflows/documents/{attachmentPersistence.d.ts → attachments/attachmentPersistence.d.ts} +2 -2
  104. package/workflows/documents/attachments/attachmentPersistence.js.map +1 -0
  105. package/workflows/documents/{blobMutationLock.d.ts → attachments/blobMutationLock.d.ts} +1 -1
  106. package/workflows/documents/{blobMutationLock.js → attachments/blobMutationLock.js} +1 -1
  107. package/workflows/documents/attachments/blobMutationLock.js.map +1 -0
  108. package/workflows/documents/attachments/orphanBlobReclaimState.js.map +1 -0
  109. package/workflows/documents/{orphanBlobReclaims.d.ts → attachments/orphanBlobReclaims.d.ts} +2 -2
  110. package/workflows/documents/{orphanBlobReclaims.js → attachments/orphanBlobReclaims.js} +3 -3
  111. package/workflows/documents/attachments/orphanBlobReclaims.js.map +1 -0
  112. package/workflows/documents/authorAccessFailure.js.map +1 -1
  113. package/workflows/documents/{createAdoption.js → create/createAdoption.js} +5 -5
  114. package/workflows/documents/create/createAdoption.js.map +1 -0
  115. package/workflows/documents/{createProjection.d.ts → create/createProjection.d.ts} +1 -1
  116. package/workflows/documents/{createProjectionFetch.d.ts → create/createProjectionFetch.d.ts} +2 -2
  117. package/workflows/documents/create/createProjectionFetch.js.map +1 -0
  118. package/workflows/documents/{createResponse.js → create/createResponse.js} +5 -5
  119. package/workflows/documents/create/createResponse.js.map +1 -0
  120. package/workflows/documents/{documentCreationPersistence.js → create/documentCreationPersistence.js} +2 -2
  121. package/workflows/documents/create/documentCreationPersistence.js.map +1 -0
  122. package/workflows/documents/{create.d.ts → create/index.d.ts} +4 -4
  123. package/workflows/documents/{create.js → create/index.js} +10 -10
  124. package/workflows/documents/create/index.js.map +1 -0
  125. package/workflows/documents/documentMutationCommit.js +1 -1
  126. package/workflows/documents/documentMutationCommit.js.map +1 -1
  127. package/workflows/documents/index.d.ts +17 -17
  128. package/workflows/documents/index.js +14 -14
  129. package/workflows/documents/index.js.map +1 -1
  130. package/workflows/documents/{linkSet.d.ts → linkSet/index.d.ts} +5 -5
  131. package/workflows/documents/{linkSet.js → linkSet/index.js} +12 -12
  132. package/workflows/documents/linkSet/index.js.map +1 -0
  133. package/workflows/documents/{linkSetAuthority.js → linkSet/linkSetAuthority.js} +6 -6
  134. package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -0
  135. package/workflows/documents/{linkSetBlobRewraps.js → linkSet/linkSetBlobRewraps.js} +13 -13
  136. package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -0
  137. package/workflows/documents/{linkSetProjectionSeed.js → linkSet/linkSetProjectionSeed.js} +2 -2
  138. package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -0
  139. package/workflows/documents/{linkSetRemote.d.ts → linkSet/linkSetRemote.d.ts} +4 -4
  140. package/workflows/documents/{linkSetRemote.js → linkSet/linkSetRemote.js} +6 -6
  141. package/workflows/documents/linkSet/linkSetRemote.js.map +1 -0
  142. package/workflows/documents/{purge.d.ts → purge/index.d.ts} +5 -5
  143. package/workflows/documents/{purge.js → purge/index.js} +9 -9
  144. package/workflows/documents/purge/index.js.map +1 -0
  145. package/workflows/documents/{persistedDocumentRemoval.d.ts → purge/persistedDocumentRemoval.d.ts} +3 -3
  146. package/workflows/documents/{persistedDocumentRemoval.js → purge/persistedDocumentRemoval.js} +4 -4
  147. package/workflows/documents/purge/persistedDocumentRemoval.js.map +1 -0
  148. package/workflows/documents/{subtreePurgeScope.d.ts → purge/subtreePurgeScope.d.ts} +1 -1
  149. package/workflows/documents/{subtreePurgeScope.js → purge/subtreePurgeScope.js} +2 -2
  150. package/workflows/documents/purge/subtreePurgeScope.js.map +1 -0
  151. package/workflows/documents/rotationBaseline.js +1 -1
  152. package/workflows/documents/rotationBaseline.js.map +1 -1
  153. package/workflows/documents/{sync.d.ts → sync/index.d.ts} +1 -1
  154. package/workflows/documents/{sync.js → sync/index.js} +11 -11
  155. package/workflows/documents/sync/index.js.map +1 -0
  156. package/workflows/documents/{initialSync.js → sync/initialSync.js} +5 -5
  157. package/workflows/documents/sync/initialSync.js.map +1 -0
  158. package/workflows/documents/{readOnlyProjectionFailure.js → sync/readOnlyProjectionFailure.js} +5 -5
  159. package/workflows/documents/sync/readOnlyProjectionFailure.js.map +1 -0
  160. package/workflows/documents/{readOnlySync.d.ts → sync/readOnlySync.d.ts} +9 -9
  161. package/workflows/documents/{readOnlySync.js → sync/readOnlySync.js} +11 -11
  162. package/workflows/documents/sync/readOnlySync.js.map +1 -0
  163. package/workflows/documents/sync/reportDocumentSyncQuarantine.js.map +1 -0
  164. package/workflows/documents/{syncAttemptPlanning.js → sync/syncAttemptPlanning.js} +9 -9
  165. package/workflows/documents/sync/syncAttemptPlanning.js.map +1 -0
  166. package/workflows/documents/{syncAttemptState.d.ts → sync/syncAttemptState.d.ts} +5 -5
  167. package/workflows/documents/sync/syncAttemptState.js.map +1 -0
  168. package/workflows/documents/{syncLane.d.ts → sync/syncLane.d.ts} +3 -3
  169. package/workflows/documents/{syncLane.js → sync/syncLane.js} +2 -2
  170. package/workflows/documents/sync/syncLane.js.map +1 -0
  171. package/workflows/documents/{syncResponseResult.js → sync/syncResponseResult.js} +9 -9
  172. package/workflows/documents/sync/syncResponseResult.js.map +1 -0
  173. package/workflows/documents/{syncSubmittedResult.js → sync/syncSubmittedResult.js} +6 -6
  174. package/workflows/documents/sync/syncSubmittedResult.js.map +1 -0
  175. package/workflows/documents/{syncTrace.js → sync/syncTrace.js} +1 -1
  176. package/workflows/documents/{syncFailures.js → syncFailures/index.js} +5 -5
  177. package/workflows/documents/syncFailures/index.js.map +1 -0
  178. package/workflows/documents/{syncAbandon.js → syncFailures/syncAbandon.js} +1 -1
  179. package/workflows/documents/syncFailures/syncAbandon.js.map +1 -0
  180. package/workflows/documents/{syncFailureClassification.d.ts → syncFailures/syncFailureClassification.d.ts} +2 -2
  181. package/workflows/documents/{syncFailureClassification.js → syncFailures/syncFailureClassification.js} +6 -6
  182. package/workflows/documents/syncFailures/syncFailureClassification.js.map +1 -0
  183. package/workflows/documents/{syncPolicyRepair.js → syncFailures/syncPolicyRepair.js} +3 -3
  184. package/workflows/documents/syncFailures/syncPolicyRepair.js.map +1 -0
  185. package/workflows/documents/syncFailures/syncRepairAbandon.js.map +1 -0
  186. package/workflows/documents/{syncRepairAccess.js → syncFailures/syncRepairAccess.js} +2 -2
  187. package/workflows/documents/syncFailures/syncRepairAccess.js.map +1 -0
  188. package/workflows/documents/{syncContentKeys.d.ts → syncPlan/syncContentKeys.d.ts} +4 -4
  189. package/workflows/documents/{syncContentKeys.js → syncPlan/syncContentKeys.js} +8 -8
  190. package/workflows/documents/syncPlan/syncContentKeys.js.map +1 -0
  191. package/workflows/documents/{syncPlanIdentity.js → syncPlan/syncPlanIdentity.js} +3 -3
  192. package/workflows/documents/syncPlan/syncPlanIdentity.js.map +1 -0
  193. package/workflows/documents/{syncPlanMaterial.js → syncPlan/syncPlanMaterial.js} +9 -9
  194. package/workflows/documents/syncPlan/syncPlanMaterial.js.map +1 -0
  195. package/workflows/documents/syncPlan/syncPlanProjection.js.map +1 -0
  196. package/workflows/documents/{syncPlanRequestBounds.js → syncPlan/syncPlanRequestBounds.js} +1 -1
  197. package/workflows/documents/syncPlan/syncPlanRequestBounds.js.map +1 -0
  198. package/workflows/documents/{syncAutomaticContainerRekeys.js → syncRekeys/syncAutomaticContainerRekeys.js} +10 -10
  199. package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -0
  200. package/workflows/documents/{syncContainerRekeyPreparation.js → syncRekeys/syncContainerRekeyPreparation.js} +11 -11
  201. package/workflows/documents/syncRekeys/syncContainerRekeyPreparation.js.map +1 -0
  202. package/workflows/documents/{syncContainerRekeyProjection.js → syncRekeys/syncContainerRekeyProjection.js} +2 -2
  203. package/workflows/documents/syncRekeys/syncContainerRekeyProjection.js.map +1 -0
  204. package/workflows/documents/{syncContainerRekeys.js → syncRekeys/syncContainerRekeys.js} +3 -3
  205. package/workflows/documents/syncRekeys/syncContainerRekeys.js.map +1 -0
  206. package/workflows/documents/{syncRecoveryRekey.d.ts → syncRekeys/syncRecoveryRekey.d.ts} +4 -4
  207. package/workflows/documents/{syncRecoveryRekey.js → syncRekeys/syncRecoveryRekey.js} +4 -4
  208. package/workflows/documents/syncRekeys/syncRecoveryRekey.js.map +1 -0
  209. package/workflows/documents/{syncRekeyCommit.js → syncRekeys/syncRekeyCommit.js} +1 -1
  210. package/workflows/organizations/{currentGroupMetadataAuthority.js → groupMetadata/currentGroupMetadataAuthority.js} +5 -5
  211. package/workflows/organizations/groupMetadata/currentGroupMetadataAuthority.js.map +1 -0
  212. package/workflows/organizations/{groupMetadataAccess.d.ts → groupMetadata/groupMetadataAccess.d.ts} +5 -5
  213. package/workflows/organizations/{groupMetadataAccess.js → groupMetadata/groupMetadataAccess.js} +6 -6
  214. package/workflows/organizations/groupMetadata/groupMetadataAccess.js.map +1 -0
  215. package/workflows/organizations/{groupMetadataBinding.js → groupMetadata/groupMetadataBinding.js} +1 -1
  216. package/workflows/organizations/groupMetadata/groupMetadataBinding.js.map +1 -0
  217. package/workflows/organizations/{groupMetadataContainerAuthority.js → groupMetadata/groupMetadataContainerAuthority.js} +6 -6
  218. package/workflows/organizations/groupMetadata/groupMetadataContainerAuthority.js.map +1 -0
  219. package/workflows/organizations/{groupMetadataErrors.js → groupMetadata/groupMetadataErrors.js} +1 -1
  220. package/workflows/organizations/{groupMetadataRootBinding.js → groupMetadata/groupMetadataRootBinding.js} +3 -3
  221. package/workflows/organizations/groupMetadata/groupMetadataRootBinding.js.map +1 -0
  222. package/workflows/organizations/{groupMetadataRuntime.js → groupMetadata/groupMetadataRuntime.js} +4 -4
  223. package/workflows/organizations/groupMetadata/groupMetadataRuntime.js.map +1 -0
  224. package/workflows/organizations/{runtimeGroupMetadataAuthority.js → groupMetadata/runtimeGroupMetadataAuthority.js} +2 -2
  225. package/workflows/organizations/groupMetadata/runtimeGroupMetadataAuthority.js.map +1 -0
  226. package/workflows/organizations/{currentOrganizationGroupNames.js → groupNames/currentOrganizationGroupNames.js} +8 -8
  227. package/workflows/organizations/groupNames/currentOrganizationGroupNames.js.map +1 -0
  228. package/workflows/organizations/{groupMembershipName.d.ts → groupNames/groupMembershipName.d.ts} +3 -3
  229. package/workflows/organizations/{groupMembershipName.js → groupNames/groupMembershipName.js} +2 -2
  230. package/workflows/organizations/groupNames/groupMembershipName.js.map +1 -0
  231. package/workflows/organizations/{groupNameUniqueness.js → groupNames/groupNameUniqueness.js} +11 -11
  232. package/workflows/organizations/groupNames/groupNameUniqueness.js.map +1 -0
  233. package/workflows/organizations/{organizationGroupNamePolicies.js → groupNames/organizationGroupNamePolicies.js} +5 -5
  234. package/workflows/organizations/groupNames/organizationGroupNamePolicies.js.map +1 -0
  235. package/workflows/organizations/{organizationGroupNames.js → groupNames/organizationGroupNames.js} +1 -1
  236. package/workflows/organizations/groupNames/organizationGroupNames.js.map +1 -0
  237. package/workflows/organizations/{commitCurrentGroupPolicyMutation.js → groupPolicy/commitCurrentGroupPolicyMutation.js} +4 -4
  238. package/workflows/organizations/groupPolicy/commitCurrentGroupPolicyMutation.js.map +1 -0
  239. package/workflows/organizations/{currentGroupPolicyMutationContext.js → groupPolicy/currentGroupPolicyMutationContext.js} +7 -7
  240. package/workflows/organizations/groupPolicy/currentGroupPolicyMutationContext.js.map +1 -0
  241. package/workflows/organizations/{currentPolicyMutationAcknowledgement.js → groupPolicy/currentPolicyMutationAcknowledgement.js} +3 -3
  242. package/workflows/organizations/groupPolicy/currentPolicyMutationAcknowledgement.js.map +1 -0
  243. package/workflows/organizations/{groupPolicyMutationAcknowledgement.js → groupPolicy/groupPolicyMutationAcknowledgement.js} +4 -4
  244. package/workflows/organizations/groupPolicy/groupPolicyMutationAcknowledgement.js.map +1 -0
  245. package/workflows/organizations/{groupPolicyMutationContext.d.ts → groupPolicy/groupPolicyMutationContext.d.ts} +8 -8
  246. package/workflows/organizations/{groupPolicyMutationContext.js → groupPolicy/groupPolicyMutationContext.js} +5 -5
  247. package/workflows/organizations/groupPolicy/groupPolicyMutationContext.js.map +1 -0
  248. package/workflows/organizations/{groupPolicyMutationEvidence.d.ts → groupPolicy/groupPolicyMutationEvidence.d.ts} +4 -4
  249. package/workflows/organizations/{groupPolicyMutationEvidence.js → groupPolicy/groupPolicyMutationEvidence.js} +3 -3
  250. package/workflows/organizations/groupPolicy/groupPolicyMutationEvidence.js.map +1 -0
  251. package/workflows/organizations/{groupPolicyMutationHead.js → groupPolicy/groupPolicyMutationHead.js} +1 -1
  252. package/workflows/organizations/{groupPolicyRequests.js → groupPolicy/groupPolicyRequests.js} +5 -5
  253. package/workflows/organizations/groupPolicy/groupPolicyRequests.js.map +1 -0
  254. package/workflows/organizations/{groupPolicyVerification.js → groupPolicy/groupPolicyVerification.js} +5 -5
  255. package/workflows/organizations/groupPolicy/groupPolicyVerification.js.map +1 -0
  256. package/workflows/organizations/{submitGroupPolicyCommit.d.ts → groupPolicy/submitGroupPolicyCommit.d.ts} +3 -3
  257. package/workflows/organizations/{submitGroupPolicyCommit.js → groupPolicy/submitGroupPolicyCommit.js} +1 -1
  258. package/workflows/organizations/groupPolicy/submitGroupPolicyCommit.js.map +1 -0
  259. package/workflows/organizations/{createCurrentOrganizationGroup.js → groups/createCurrentOrganizationGroup.js} +9 -9
  260. package/workflows/organizations/groups/createCurrentOrganizationGroup.js.map +1 -0
  261. package/workflows/organizations/{deleteCurrentOrganizationGroup.js → groups/deleteCurrentOrganizationGroup.js} +2 -2
  262. package/workflows/organizations/groups/deleteCurrentOrganizationGroup.js.map +1 -0
  263. package/workflows/organizations/{deleteOrganizationGroup.d.ts → groups/deleteOrganizationGroup.d.ts} +6 -6
  264. package/workflows/organizations/{deleteOrganizationGroup.js → groups/deleteOrganizationGroup.js} +6 -6
  265. package/workflows/organizations/groups/deleteOrganizationGroup.js.map +1 -0
  266. package/workflows/organizations/{groupCreation.d.ts → groups/groupCreation.d.ts} +7 -7
  267. package/workflows/organizations/{groupCreation.js → groups/groupCreation.js} +4 -4
  268. package/workflows/organizations/groups/groupCreation.js.map +1 -0
  269. package/workflows/organizations/{organizationGroupDirectory.js → groups/organizationGroupDirectory.js} +10 -10
  270. package/workflows/organizations/groups/organizationGroupDirectory.js.map +1 -0
  271. package/workflows/organizations/index.d.ts +13 -13
  272. package/workflows/organizations/index.js +12 -12
  273. package/workflows/organizations/index.js.map +1 -1
  274. package/workflows/organizations/policyHistory/groupPolicyHistoryPage.js.map +1 -0
  275. package/workflows/organizations/{loadPolicyHistoryDetails.js → policyHistory/loadPolicyHistoryDetails.js} +5 -5
  276. package/workflows/organizations/policyHistory/loadPolicyHistoryDetails.js.map +1 -0
  277. package/workflows/organizations/{organizationPolicyHistoryDetails.js → policyHistory/organizationPolicyHistoryDetails.js} +2 -2
  278. package/workflows/organizations/policyHistory/organizationPolicyHistoryDetails.js.map +1 -0
  279. package/workflows/organizations/{organizationPolicyHistoryVerification.js → policyHistory/organizationPolicyHistoryVerification.js} +2 -2
  280. package/workflows/organizations/policyHistory/organizationPolicyHistoryVerification.js.map +1 -0
  281. package/workflows/organizations/{policyHistoryAccessDenial.js → policyHistory/policyHistoryAccessDenial.js} +3 -3
  282. package/workflows/organizations/policyHistory/policyHistoryAccessDenial.js.map +1 -0
  283. package/workflows/organizations/{policyHistoryCache.js → policyHistory/policyHistoryCache.js} +1 -1
  284. package/workflows/organizations/policyHistory/policyHistoryCache.js.map +1 -0
  285. package/workflows/organizations/{policyHistoryReadModel.d.ts → policyHistory/policyHistoryReadModel.d.ts} +1 -1
  286. package/workflows/organizations/{policyHistoryTypes.d.ts → policyHistory/policyHistoryTypes.d.ts} +1 -1
  287. package/workflows/organizations/{acknowledgedDirectoryBindings.js → principalMutations/acknowledgedDirectoryBindings.js} +2 -2
  288. package/workflows/organizations/principalMutations/acknowledgedDirectoryBindings.js.map +1 -0
  289. package/workflows/organizations/{currentGroupMutationReferences.js → principalMutations/currentGroupMutationReferences.js} +2 -2
  290. package/workflows/organizations/principalMutations/currentGroupMutationReferences.js.map +1 -0
  291. package/workflows/organizations/{currentOrganizationMutationAuthority.js → principalMutations/currentOrganizationMutationAuthority.js} +3 -3
  292. package/workflows/organizations/principalMutations/currentOrganizationMutationAuthority.js.map +1 -0
  293. package/workflows/organizations/{currentOrganizationMutationRetention.js → principalMutations/currentOrganizationMutationRetention.js} +4 -4
  294. package/workflows/organizations/principalMutations/currentOrganizationMutationRetention.js.map +1 -0
  295. package/workflows/organizations/{currentPrincipalMutationLease.js → principalMutations/currentPrincipalMutationLease.js} +6 -6
  296. package/workflows/organizations/principalMutations/currentPrincipalMutationLease.js.map +1 -0
  297. package/workflows/organizations/{principalMutationJournalManagement.d.ts → principalMutations/principalMutationJournalManagement.d.ts} +1 -1
  298. package/workflows/organizations/{principalMutationJournalManagement.js → principalMutations/principalMutationJournalManagement.js} +7 -7
  299. package/workflows/organizations/principalMutations/principalMutationJournalManagement.js.map +1 -0
  300. package/workflows/organizations/{principalMutationJournalSession.d.ts → principalMutations/principalMutationJournalSession.d.ts} +4 -4
  301. package/workflows/organizations/{principalMutationJournalSession.js → principalMutations/principalMutationJournalSession.js} +4 -4
  302. package/workflows/organizations/principalMutations/principalMutationJournalSession.js.map +1 -0
  303. package/workflows/organizations/{principalMutationReceipt.js → principalMutations/principalMutationReceipt.js} +3 -3
  304. package/workflows/organizations/principalMutations/principalMutationReceipt.js.map +1 -0
  305. package/workflows/organizations/{principalOperationReceipt.d.ts → principalMutations/principalOperationReceipt.d.ts} +2 -2
  306. package/workflows/organizations/{principalOperationReceipt.js → principalMutations/principalOperationReceipt.js} +3 -3
  307. package/workflows/organizations/principalMutations/principalOperationReceipt.js.map +1 -0
  308. package/workflows/organizations/principalMutations/retainAcknowledgedPrincipalCurrents.d.ts +6 -0
  309. package/workflows/organizations/{retainAcknowledgedPrincipalCurrents.js → principalMutations/retainAcknowledgedPrincipalCurrents.js} +4 -4
  310. package/workflows/organizations/principalMutations/retainAcknowledgedPrincipalCurrents.js.map +1 -0
  311. package/workflows/organizations/{runtimeCurrentGroupMutation.js → principalMutations/runtimeCurrentGroupMutation.js} +5 -5
  312. package/workflows/organizations/principalMutations/runtimeCurrentGroupMutation.js.map +1 -0
  313. package/workflows/organizations/{runtimeCurrentOrganizationMutation.js → principalMutations/runtimeCurrentOrganizationMutation.js} +2 -2
  314. package/workflows/organizations/principalMutations/runtimeCurrentOrganizationMutation.js.map +1 -0
  315. package/workflows/organizations/{principalPolicy.d.ts → principalPolicy/index.d.ts} +8 -8
  316. package/workflows/organizations/{principalPolicy.js → principalPolicy/index.js} +9 -9
  317. package/workflows/organizations/principalPolicy/index.js.map +1 -0
  318. package/workflows/organizations/{principalPolicyApi.d.ts → principalPolicy/principalPolicyApi.d.ts} +4 -4
  319. package/workflows/organizations/principalPolicy/principalPolicyApi.js.map +1 -0
  320. package/workflows/organizations/{principalPolicyReceiptArtifacts.js → principalPolicy/principalPolicyReceiptArtifacts.js} +2 -2
  321. package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js.map +1 -0
  322. package/workflows/organizations/{principalPolicyRecipients.js → principalPolicy/principalPolicyRecipients.js} +2 -2
  323. package/workflows/organizations/principalPolicy/principalPolicyRecipients.js.map +1 -0
  324. package/workflows/organizations/{principalPolicyRequest.d.ts → principalPolicy/principalPolicyRequest.d.ts} +3 -3
  325. package/workflows/organizations/{principalPolicyRequest.js → principalPolicy/principalPolicyRequest.js} +2 -2
  326. package/workflows/organizations/{createOrganization.d.ts → provisioning/createOrganization.d.ts} +7 -7
  327. package/workflows/organizations/{createOrganization.js → provisioning/createOrganization.js} +3 -3
  328. package/workflows/organizations/provisioning/createOrganization.js.map +1 -0
  329. package/workflows/organizations/{organizationProvisioningAttempt.d.ts → provisioning/organizationProvisioningAttempt.d.ts} +3 -3
  330. package/workflows/organizations/{organizationProvisioningAttempt.js → provisioning/organizationProvisioningAttempt.js} +6 -6
  331. package/workflows/organizations/provisioning/organizationProvisioningAttempt.js.map +1 -0
  332. package/workflows/organizations/{organizationReplacementVerification.js → provisioning/organizationReplacementVerification.js} +2 -2
  333. package/workflows/organizations/provisioning/organizationReplacementVerification.js.map +1 -0
  334. package/workflows/organizations/{dataUsageReadModel.d.ts → readModel/dataUsageReadModel.d.ts} +3 -3
  335. package/workflows/organizations/{dataUsageReadModel.js → readModel/dataUsageReadModel.js} +2 -2
  336. package/workflows/organizations/readModel/dataUsageReadModel.js.map +1 -0
  337. package/workflows/organizations/{readModel.d.ts → readModel/index.d.ts} +5 -5
  338. package/workflows/organizations/{readModel.js → readModel/index.js} +2 -2
  339. package/workflows/organizations/readModel/index.js.map +1 -0
  340. package/workflows/organizations/{listLocalOrganizations.d.ts → readModel/listLocalOrganizations.d.ts} +1 -1
  341. package/workflows/organizations/{listLocalOrganizations.js → readModel/listLocalOrganizations.js} +8 -8
  342. package/workflows/organizations/readModel/listLocalOrganizations.js.map +1 -0
  343. package/workflows/organizations/{localReadModelDetails.d.ts → readModel/localReadModelDetails.d.ts} +3 -3
  344. package/workflows/organizations/{localReadModelDetails.js → readModel/localReadModelDetails.js} +6 -6
  345. package/workflows/organizations/readModel/localReadModelDetails.js.map +1 -0
  346. package/workflows/organizations/{organizationPresentationAccessState.js → readModel/organizationPresentationAccessState.js} +1 -1
  347. package/workflows/organizations/readModel/organizationPresentationAccessState.js.map +1 -0
  348. package/workflows/organizations/{organizationPresentationFailures.js → readModel/organizationPresentationFailures.js} +1 -1
  349. package/workflows/organizations/{readModelProjection.d.ts → readModel/readModelProjection.d.ts} +5 -5
  350. package/workflows/organizations/{readModelProjection.js → readModel/readModelProjection.js} +6 -6
  351. package/workflows/organizations/readModel/readModelProjection.js.map +1 -0
  352. package/workflows/organizations/{authoredPrincipalPolicyWarmer.js → rematerialization/authoredPrincipalPolicyWarmer.js} +2 -2
  353. package/workflows/organizations/rematerialization/authoredPrincipalPolicyWarmer.js.map +1 -0
  354. package/workflows/organizations/{precedingPrincipalRematerialization.js → rematerialization/precedingPrincipalRematerialization.js} +1 -1
  355. package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -0
  356. package/workflows/organizations/{principalContainerRematerialization.js → rematerialization/principalContainerRematerialization.js} +13 -13
  357. package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -0
  358. package/workflows/organizations/{principalContainerRematerializationPlanning.js → rematerialization/principalContainerRematerializationPlanning.js} +2 -2
  359. package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -0
  360. package/workflows/organizations/{principalContainerRematerializationTargets.js → rematerialization/principalContainerRematerializationTargets.js} +3 -3
  361. package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -0
  362. package/workflows/principals/{acknowledgedPrincipalCurrents.d.ts → acknowledgements/acknowledgedPrincipalCurrents.d.ts} +6 -6
  363. package/workflows/principals/{acknowledgedPrincipalCurrents.js → acknowledgements/acknowledgedPrincipalCurrents.js} +7 -7
  364. package/workflows/principals/acknowledgements/acknowledgedPrincipalCurrents.js.map +1 -0
  365. package/workflows/principals/{acknowledgedPrincipalPredecessor.d.ts → acknowledgements/acknowledgedPrincipalPredecessor.d.ts} +10 -10
  366. package/workflows/principals/{acknowledgedPrincipalPredecessor.js → acknowledgements/acknowledgedPrincipalPredecessor.js} +9 -9
  367. package/workflows/principals/acknowledgements/acknowledgedPrincipalPredecessor.js.map +1 -0
  368. package/workflows/principals/{initialPrincipalCurrentPublication.js → acknowledgements/initialPrincipalCurrentPublication.js} +7 -7
  369. package/workflows/principals/acknowledgements/initialPrincipalCurrentPublication.js.map +1 -0
  370. package/workflows/principals/{principalAcknowledgementChecks.d.ts → acknowledgements/principalAcknowledgementChecks.d.ts} +3 -3
  371. package/workflows/principals/{principalCurrentPublicationSeal.js → acknowledgements/principalCurrentPublicationSeal.js} +3 -3
  372. package/workflows/principals/acknowledgements/principalCurrentPublicationSeal.js.map +1 -0
  373. package/workflows/principals/{reconcileAcknowledgedPrincipalCurrent.js → acknowledgements/reconcileAcknowledgedPrincipalCurrent.js} +6 -6
  374. package/workflows/principals/acknowledgements/reconcileAcknowledgedPrincipalCurrent.js.map +1 -0
  375. package/workflows/principals/{loadRecoveredPrincipalHistoryPage.d.ts → historyRecovery/loadRecoveredPrincipalHistoryPage.d.ts} +1 -1
  376. package/workflows/principals/{loadRecoveredPrincipalHistoryPage.js → historyRecovery/loadRecoveredPrincipalHistoryPage.js} +7 -7
  377. package/workflows/principals/historyRecovery/loadRecoveredPrincipalHistoryPage.js.map +1 -0
  378. package/workflows/principals/{principalHistoryRecoveryAuthority.js → historyRecovery/principalHistoryRecoveryAuthority.js} +2 -2
  379. package/workflows/principals/historyRecovery/principalHistoryRecoveryAuthority.js.map +1 -0
  380. package/workflows/principals/{principalHistoryRecoveryPrefix.js → historyRecovery/principalHistoryRecoveryPrefix.js} +5 -5
  381. package/workflows/principals/historyRecovery/principalHistoryRecoveryPrefix.js.map +1 -0
  382. package/workflows/principals/{principalHistoryRecoveryReferences.js → historyRecovery/principalHistoryRecoveryReferences.js} +4 -4
  383. package/workflows/principals/historyRecovery/principalHistoryRecoveryReferences.js.map +1 -0
  384. package/workflows/principals/{principalHistoryRecoveryStage.js → historyRecovery/principalHistoryRecoveryStage.js} +4 -4
  385. package/workflows/principals/historyRecovery/principalHistoryRecoveryStage.js.map +1 -0
  386. package/workflows/principals/{principalHistoryRecoveryTypes.d.ts → historyRecovery/principalHistoryRecoveryTypes.d.ts} +5 -5
  387. package/workflows/principals/{principalHistoryRecoveryTypes.js → historyRecovery/principalHistoryRecoveryTypes.js} +1 -1
  388. package/workflows/principals/historyRecovery/principalHistoryRecoveryTypes.js.map +1 -0
  389. package/workflows/principals/{principalHistoryRecoveryVerification.js → historyRecovery/principalHistoryRecoveryVerification.js} +1 -1
  390. package/workflows/principals/{recoverCurrentOrganizationPolicy.js → historyRecovery/recoverCurrentOrganizationPolicy.js} +4 -4
  391. package/workflows/principals/historyRecovery/recoverCurrentOrganizationPolicy.js.map +1 -0
  392. package/workflows/principals/{recoverPrincipalHistoryPage.js → historyRecovery/recoverPrincipalHistoryPage.js} +2 -2
  393. package/workflows/principals/{recoverPrincipalPolicyHistory.js → historyRecovery/recoverPrincipalPolicyHistory.js} +8 -8
  394. package/workflows/principals/historyRecovery/recoverPrincipalPolicyHistory.js.map +1 -0
  395. package/workflows/principals/{recoverScopedPrincipalPolicyHistory.d.ts → historyRecovery/recoverScopedPrincipalPolicyHistory.d.ts} +3 -3
  396. package/workflows/principals/{recoverScopedPrincipalPolicyHistory.js → historyRecovery/recoverScopedPrincipalPolicyHistory.js} +7 -7
  397. package/workflows/principals/historyRecovery/recoverScopedPrincipalPolicyHistory.js.map +1 -0
  398. package/workflows/principals/index.d.ts +6 -6
  399. package/workflows/principals/index.js +6 -6
  400. package/workflows/principals/index.js.map +1 -1
  401. package/workflows/principals/{policyCache.d.ts → policyCache/index.d.ts} +5 -5
  402. package/workflows/principals/{policyCache.js → policyCache/index.js} +10 -10
  403. package/workflows/principals/policyCache/index.js.map +1 -0
  404. package/workflows/principals/{principalPolicyCacheAdvance.js → policyCache/principalPolicyCacheAdvance.js} +2 -2
  405. package/workflows/principals/policyCache/principalPolicyCacheAdvance.js.map +1 -0
  406. package/workflows/principals/{principalPolicyCacheValidation.js → policyCache/principalPolicyCacheValidation.js} +3 -3
  407. package/workflows/principals/policyCache/principalPolicyCacheValidation.js.map +1 -0
  408. package/workflows/principals/{principalPolicyOrganizationScope.js → policyCache/principalPolicyOrganizationScope.js} +7 -7
  409. package/workflows/principals/policyCache/principalPolicyOrganizationScope.js.map +1 -0
  410. package/workflows/principals/{publicPrincipalHistoryAuthority.js → publicHistory/publicPrincipalHistoryAuthority.js} +3 -3
  411. package/workflows/principals/publicHistory/publicPrincipalHistoryAuthority.js.map +1 -0
  412. package/workflows/principals/{publicPrincipalHistoryPage.js → publicHistory/publicPrincipalHistoryPage.js} +6 -6
  413. package/workflows/principals/publicHistory/publicPrincipalHistoryPage.js.map +1 -0
  414. package/workflows/principals/{publicPrincipalHistoryProgress.js → publicHistory/publicPrincipalHistoryProgress.js} +8 -8
  415. package/workflows/principals/publicHistory/publicPrincipalHistoryProgress.js.map +1 -0
  416. package/workflows/principals/{publicPrincipalHistoryTypes.d.ts → publicHistory/publicPrincipalHistoryTypes.d.ts} +7 -7
  417. package/workflows/principals/publicHistory/publicPrincipalHistoryTypes.js.map +1 -0
  418. package/workflows/principals/{publicProjectionDirectory.js → publicHistory/publicProjectionDirectory.js} +2 -2
  419. package/workflows/principals/publicHistory/publicProjectionDirectory.js.map +1 -0
  420. package/workflows/principals/{publicProjectionPrincipal.js → publicHistory/publicProjectionPrincipal.js} +4 -4
  421. package/workflows/principals/publicHistory/publicProjectionPrincipal.js.map +1 -0
  422. package/workflows/principals/{recoverProjectionPolicyHistory.d.ts → publicHistory/recoverProjectionPolicyHistory.d.ts} +2 -2
  423. package/workflows/principals/{recoverProjectionPolicyHistory.js → publicHistory/recoverProjectionPolicyHistory.js} +3 -3
  424. package/workflows/principals/publicHistory/recoverProjectionPolicyHistory.js.map +1 -0
  425. package/workflows/principals/{recoverPublicPrincipalHistory.js → publicHistory/recoverPublicPrincipalHistory.js} +7 -7
  426. package/workflows/principals/publicHistory/recoverPublicPrincipalHistory.js.map +1 -0
  427. package/workflows/principals/{selectPublicPrincipalHistory.js → publicHistory/selectPublicPrincipalHistory.js} +5 -5
  428. package/workflows/principals/publicHistory/selectPublicPrincipalHistory.js.map +1 -0
  429. package/workflows/principals/{principalCurrentRecoveryBatch.js → recoveryOperation/principalCurrentRecoveryBatch.js} +2 -2
  430. package/workflows/principals/recoveryOperation/principalCurrentRecoveryBatch.js.map +1 -0
  431. package/workflows/principals/{principalRecoveryDirectory.d.ts → recoveryOperation/principalRecoveryDirectory.d.ts} +3 -3
  432. package/workflows/principals/{principalRecoveryDirectory.js → recoveryOperation/principalRecoveryDirectory.js} +9 -9
  433. package/workflows/principals/recoveryOperation/principalRecoveryDirectory.js.map +1 -0
  434. package/workflows/principals/recoveryOperation/principalRecoveryDiscoveryPage.js.map +1 -0
  435. package/workflows/principals/{principalRecoveryLocalPreference.js → recoveryOperation/principalRecoveryLocalPreference.js} +4 -4
  436. package/workflows/principals/recoveryOperation/principalRecoveryLocalPreference.js.map +1 -0
  437. package/workflows/principals/{principalRecoveryMemo.d.ts → recoveryOperation/principalRecoveryMemo.d.ts} +2 -2
  438. package/workflows/principals/{principalRecoveryMemo.js → recoveryOperation/principalRecoveryMemo.js} +4 -4
  439. package/workflows/principals/recoveryOperation/principalRecoveryMemo.js.map +1 -0
  440. package/workflows/principals/{principalRecoveryMemoValidity.js → recoveryOperation/principalRecoveryMemoValidity.js} +2 -2
  441. package/workflows/principals/recoveryOperation/principalRecoveryMemoValidity.js.map +1 -0
  442. package/workflows/principals/{principalRecoveryOutage.js → recoveryOperation/principalRecoveryOutage.js} +5 -5
  443. package/workflows/principals/recoveryOperation/principalRecoveryOutage.js.map +1 -0
  444. package/workflows/principals/runtimePolicyRecovery.js +3 -3
  445. package/workflows/principals/runtimePolicyRecovery.js.map +1 -1
  446. package/workflows/principals/runtimeProjectionPolicyRecovery.js +3 -3
  447. package/workflows/principals/runtimeProjectionPolicyRecovery.js.map +1 -1
  448. package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
  449. package/workflows/registration/provisionedPrincipalHistory.js +1 -1
  450. package/workflows/registration/provisionedPrincipalHistory.js.map +1 -1
  451. package/workflows/registration/provisionedProfileDocument.js +1 -1
  452. package/workflows/registration/provisionedProfileDocument.js.map +1 -1
  453. package/workflows/registration/provisioningBootstrapBuilders.js +2 -2
  454. package/workflows/registration/provisioningBootstrapBuilders.js.map +1 -1
  455. package/workflows/registration/registerIdentity.js +2 -2
  456. package/workflows/registration/registerIdentity.js.map +1 -1
  457. package/workflows/sync/remoteReset.js +1 -1
  458. package/workflows/sync/remoteReset.js.map +1 -1
  459. package/workflows/blobs/attachmentBindingVerification.js.map +0 -1
  460. package/workflows/blobs/attachmentDecryptor.js.map +0 -1
  461. package/workflows/blobs/attachmentKeyAuthenticator.js.map +0 -1
  462. package/workflows/blobs/automaticMultipartUpload.js.map +0 -1
  463. package/workflows/blobs/blobChunkDecryption.js.map +0 -1
  464. package/workflows/blobs/decrypt.js.map +0 -1
  465. package/workflows/blobs/hydrate.js.map +0 -1
  466. package/workflows/blobs/hydrationResults.js.map +0 -1
  467. package/workflows/blobs/multipartFirstParts.js.map +0 -1
  468. package/workflows/blobs/multipartStageFailures.js.map +0 -1
  469. package/workflows/blobs/multipartStageResolution.js.map +0 -1
  470. package/workflows/blobs/multipartUpload.js.map +0 -1
  471. package/workflows/blobs/retainedAttachmentVerification.js.map +0 -1
  472. package/workflows/blobs/upload.js.map +0 -1
  473. package/workflows/blobs/verifiedWrapScope.js.map +0 -1
  474. package/workflows/blobs/writerProjection.js.map +0 -1
  475. package/workflows/documents/attachmentPersistence.js.map +0 -1
  476. package/workflows/documents/blobMutationLock.js.map +0 -1
  477. package/workflows/documents/create.js.map +0 -1
  478. package/workflows/documents/createAdoption.js.map +0 -1
  479. package/workflows/documents/createProjectionFetch.js.map +0 -1
  480. package/workflows/documents/createResponse.js.map +0 -1
  481. package/workflows/documents/documentCreationPersistence.js.map +0 -1
  482. package/workflows/documents/initialSync.js.map +0 -1
  483. package/workflows/documents/linkSet.js.map +0 -1
  484. package/workflows/documents/linkSetAuthority.js.map +0 -1
  485. package/workflows/documents/linkSetBlobRewraps.js.map +0 -1
  486. package/workflows/documents/linkSetProjectionSeed.js.map +0 -1
  487. package/workflows/documents/linkSetRemote.js.map +0 -1
  488. package/workflows/documents/orphanBlobReclaimState.js.map +0 -1
  489. package/workflows/documents/orphanBlobReclaims.js.map +0 -1
  490. package/workflows/documents/persistedDocumentRemoval.js.map +0 -1
  491. package/workflows/documents/purge.js.map +0 -1
  492. package/workflows/documents/readOnlyProjectionFailure.js.map +0 -1
  493. package/workflows/documents/readOnlySync.js.map +0 -1
  494. package/workflows/documents/reportDocumentSyncQuarantine.js.map +0 -1
  495. package/workflows/documents/subtreePurgeScope.js.map +0 -1
  496. package/workflows/documents/sync.js.map +0 -1
  497. package/workflows/documents/syncAbandon.js.map +0 -1
  498. package/workflows/documents/syncAttemptPlanning.js.map +0 -1
  499. package/workflows/documents/syncAttemptState.js.map +0 -1
  500. package/workflows/documents/syncAutomaticContainerRekeys.js.map +0 -1
  501. package/workflows/documents/syncContainerRekeyPreparation.js.map +0 -1
  502. package/workflows/documents/syncContainerRekeyProjection.js.map +0 -1
  503. package/workflows/documents/syncContainerRekeys.js.map +0 -1
  504. package/workflows/documents/syncContentKeys.js.map +0 -1
  505. package/workflows/documents/syncFailureClassification.js.map +0 -1
  506. package/workflows/documents/syncFailures.js.map +0 -1
  507. package/workflows/documents/syncLane.js.map +0 -1
  508. package/workflows/documents/syncPlanIdentity.js.map +0 -1
  509. package/workflows/documents/syncPlanMaterial.js.map +0 -1
  510. package/workflows/documents/syncPlanProjection.js.map +0 -1
  511. package/workflows/documents/syncPlanRequestBounds.js.map +0 -1
  512. package/workflows/documents/syncPolicyRepair.js.map +0 -1
  513. package/workflows/documents/syncRecoveryRekey.js.map +0 -1
  514. package/workflows/documents/syncRepairAbandon.js.map +0 -1
  515. package/workflows/documents/syncRepairAccess.js.map +0 -1
  516. package/workflows/documents/syncResponseResult.js.map +0 -1
  517. package/workflows/documents/syncSubmittedResult.js.map +0 -1
  518. package/workflows/organizations/acknowledgedDirectoryBindings.js.map +0 -1
  519. package/workflows/organizations/authoredPrincipalPolicyWarmer.js.map +0 -1
  520. package/workflows/organizations/commitCurrentGroupPolicyMutation.js.map +0 -1
  521. package/workflows/organizations/createCurrentOrganizationGroup.js.map +0 -1
  522. package/workflows/organizations/createOrganization.js.map +0 -1
  523. package/workflows/organizations/currentGroupMetadataAuthority.js.map +0 -1
  524. package/workflows/organizations/currentGroupMutationReferences.js.map +0 -1
  525. package/workflows/organizations/currentGroupPolicyMutationContext.js.map +0 -1
  526. package/workflows/organizations/currentOrganizationGroupNames.js.map +0 -1
  527. package/workflows/organizations/currentOrganizationMutationAuthority.js.map +0 -1
  528. package/workflows/organizations/currentOrganizationMutationRetention.js.map +0 -1
  529. package/workflows/organizations/currentPolicyMutationAcknowledgement.js.map +0 -1
  530. package/workflows/organizations/currentPrincipalMutationLease.js.map +0 -1
  531. package/workflows/organizations/dataUsageReadModel.js.map +0 -1
  532. package/workflows/organizations/deleteCurrentOrganizationGroup.js.map +0 -1
  533. package/workflows/organizations/deleteOrganizationGroup.js.map +0 -1
  534. package/workflows/organizations/groupCreation.js.map +0 -1
  535. package/workflows/organizations/groupMembershipName.js.map +0 -1
  536. package/workflows/organizations/groupMetadataAccess.js.map +0 -1
  537. package/workflows/organizations/groupMetadataBinding.js.map +0 -1
  538. package/workflows/organizations/groupMetadataContainerAuthority.js.map +0 -1
  539. package/workflows/organizations/groupMetadataRootBinding.js.map +0 -1
  540. package/workflows/organizations/groupMetadataRuntime.js.map +0 -1
  541. package/workflows/organizations/groupNameUniqueness.js.map +0 -1
  542. package/workflows/organizations/groupPolicyHistoryPage.js.map +0 -1
  543. package/workflows/organizations/groupPolicyMutationAcknowledgement.js.map +0 -1
  544. package/workflows/organizations/groupPolicyMutationContext.js.map +0 -1
  545. package/workflows/organizations/groupPolicyMutationEvidence.js.map +0 -1
  546. package/workflows/organizations/groupPolicyRequests.js.map +0 -1
  547. package/workflows/organizations/groupPolicyVerification.js.map +0 -1
  548. package/workflows/organizations/listLocalOrganizations.js.map +0 -1
  549. package/workflows/organizations/loadPolicyHistoryDetails.js.map +0 -1
  550. package/workflows/organizations/localReadModelDetails.js.map +0 -1
  551. package/workflows/organizations/organizationGroupDirectory.js.map +0 -1
  552. package/workflows/organizations/organizationGroupNamePolicies.js.map +0 -1
  553. package/workflows/organizations/organizationGroupNames.js.map +0 -1
  554. package/workflows/organizations/organizationPolicyHistoryDetails.js.map +0 -1
  555. package/workflows/organizations/organizationPolicyHistoryVerification.js.map +0 -1
  556. package/workflows/organizations/organizationPresentationAccessState.js.map +0 -1
  557. package/workflows/organizations/organizationProvisioningAttempt.js.map +0 -1
  558. package/workflows/organizations/organizationReplacementVerification.js.map +0 -1
  559. package/workflows/organizations/policyHistoryAccessDenial.js.map +0 -1
  560. package/workflows/organizations/policyHistoryCache.js.map +0 -1
  561. package/workflows/organizations/precedingPrincipalRematerialization.js.map +0 -1
  562. package/workflows/organizations/principalContainerRematerialization.js.map +0 -1
  563. package/workflows/organizations/principalContainerRematerializationPlanning.js.map +0 -1
  564. package/workflows/organizations/principalContainerRematerializationTargets.js.map +0 -1
  565. package/workflows/organizations/principalMutationJournalManagement.js.map +0 -1
  566. package/workflows/organizations/principalMutationJournalSession.js.map +0 -1
  567. package/workflows/organizations/principalMutationReceipt.js.map +0 -1
  568. package/workflows/organizations/principalOperationReceipt.js.map +0 -1
  569. package/workflows/organizations/principalPolicy.js.map +0 -1
  570. package/workflows/organizations/principalPolicyApi.js.map +0 -1
  571. package/workflows/organizations/principalPolicyReceiptArtifacts.js.map +0 -1
  572. package/workflows/organizations/principalPolicyRecipients.js.map +0 -1
  573. package/workflows/organizations/readModel.js.map +0 -1
  574. package/workflows/organizations/readModelProjection.js.map +0 -1
  575. package/workflows/organizations/retainAcknowledgedPrincipalCurrents.d.ts +0 -6
  576. package/workflows/organizations/retainAcknowledgedPrincipalCurrents.js.map +0 -1
  577. package/workflows/organizations/runtimeCurrentGroupMutation.js.map +0 -1
  578. package/workflows/organizations/runtimeCurrentOrganizationMutation.js.map +0 -1
  579. package/workflows/organizations/runtimeGroupMetadataAuthority.js.map +0 -1
  580. package/workflows/organizations/submitGroupPolicyCommit.js.map +0 -1
  581. package/workflows/principals/acknowledgedPrincipalCurrents.js.map +0 -1
  582. package/workflows/principals/acknowledgedPrincipalPredecessor.js.map +0 -1
  583. package/workflows/principals/initialPrincipalCurrentPublication.js.map +0 -1
  584. package/workflows/principals/loadRecoveredPrincipalHistoryPage.js.map +0 -1
  585. package/workflows/principals/policyCache.js.map +0 -1
  586. package/workflows/principals/principalCurrentPublicationSeal.js.map +0 -1
  587. package/workflows/principals/principalCurrentRecoveryBatch.js.map +0 -1
  588. package/workflows/principals/principalHistoryRecoveryAuthority.js.map +0 -1
  589. package/workflows/principals/principalHistoryRecoveryPrefix.js.map +0 -1
  590. package/workflows/principals/principalHistoryRecoveryReferences.js.map +0 -1
  591. package/workflows/principals/principalHistoryRecoveryStage.js.map +0 -1
  592. package/workflows/principals/principalHistoryRecoveryTypes.js.map +0 -1
  593. package/workflows/principals/principalPolicyCacheAdvance.js.map +0 -1
  594. package/workflows/principals/principalPolicyCacheValidation.js.map +0 -1
  595. package/workflows/principals/principalPolicyOrganizationScope.js.map +0 -1
  596. package/workflows/principals/principalRecoveryDirectory.js.map +0 -1
  597. package/workflows/principals/principalRecoveryDiscoveryPage.js.map +0 -1
  598. package/workflows/principals/principalRecoveryLocalPreference.js.map +0 -1
  599. package/workflows/principals/principalRecoveryMemo.js.map +0 -1
  600. package/workflows/principals/principalRecoveryMemoValidity.js.map +0 -1
  601. package/workflows/principals/principalRecoveryOutage.js.map +0 -1
  602. package/workflows/principals/publicPrincipalHistoryAuthority.js.map +0 -1
  603. package/workflows/principals/publicPrincipalHistoryPage.js.map +0 -1
  604. package/workflows/principals/publicPrincipalHistoryProgress.js.map +0 -1
  605. package/workflows/principals/publicPrincipalHistoryTypes.js.map +0 -1
  606. package/workflows/principals/publicProjectionDirectory.js.map +0 -1
  607. package/workflows/principals/publicProjectionPrincipal.js.map +0 -1
  608. package/workflows/principals/reconcileAcknowledgedPrincipalCurrent.js.map +0 -1
  609. package/workflows/principals/recoverCurrentOrganizationPolicy.js.map +0 -1
  610. package/workflows/principals/recoverPrincipalPolicyHistory.js.map +0 -1
  611. package/workflows/principals/recoverProjectionPolicyHistory.js.map +0 -1
  612. package/workflows/principals/recoverPublicPrincipalHistory.js.map +0 -1
  613. package/workflows/principals/recoverScopedPrincipalPolicyHistory.js.map +0 -1
  614. package/workflows/principals/selectPublicPrincipalHistory.js.map +0 -1
  615. /package/workflows/blobs/{readAttachmentTransfer.js → hydration/readAttachmentTransfer.js} +0 -0
  616. /package/workflows/blobs/{readAttachmentTransfer.js.map → hydration/readAttachmentTransfer.js.map} +0 -0
  617. /package/workflows/blobs/{multipartStageResolution.js → upload/multipartStageResolution.js} +0 -0
  618. /package/workflows/documents/{attachmentPersistence.js → attachments/attachmentPersistence.js} +0 -0
  619. /package/workflows/documents/{orphanBlobReclaimState.js → attachments/orphanBlobReclaimState.js} +0 -0
  620. /package/workflows/documents/{createProjection.js → create/createProjection.js} +0 -0
  621. /package/workflows/documents/{createProjection.js.map → create/createProjection.js.map} +0 -0
  622. /package/workflows/documents/{createProjectionFetch.js → create/createProjectionFetch.js} +0 -0
  623. /package/workflows/documents/{reportDocumentSyncQuarantine.js → sync/reportDocumentSyncQuarantine.js} +0 -0
  624. /package/workflows/documents/{syncAttemptState.js → sync/syncAttemptState.js} +0 -0
  625. /package/workflows/documents/{syncTrace.d.ts → sync/syncTrace.d.ts} +0 -0
  626. /package/workflows/documents/{syncTrace.js.map → sync/syncTrace.js.map} +0 -0
  627. /package/workflows/documents/{syncFailureClearance.d.ts → syncFailures/syncFailureClearance.d.ts} +0 -0
  628. /package/workflows/documents/{syncFailureClearance.js → syncFailures/syncFailureClearance.js} +0 -0
  629. /package/workflows/documents/{syncFailureClearance.js.map → syncFailures/syncFailureClearance.js.map} +0 -0
  630. /package/workflows/documents/{syncRepairAbandon.js → syncFailures/syncRepairAbandon.js} +0 -0
  631. /package/workflows/documents/{syncPlanProjection.js → syncPlan/syncPlanProjection.js} +0 -0
  632. /package/workflows/documents/{syncRekeyCommit.js.map → syncRekeys/syncRekeyCommit.js.map} +0 -0
  633. /package/workflows/organizations/{groupMetadataErrors.js.map → groupMetadata/groupMetadataErrors.js.map} +0 -0
  634. /package/workflows/organizations/{groupMutationAuthorization.js → groupPolicy/groupMutationAuthorization.js} +0 -0
  635. /package/workflows/organizations/{groupMutationAuthorization.js.map → groupPolicy/groupMutationAuthorization.js.map} +0 -0
  636. /package/workflows/organizations/{groupPolicyMutationHead.js.map → groupPolicy/groupPolicyMutationHead.js.map} +0 -0
  637. /package/workflows/organizations/{groupPolicyHistoryPage.js → policyHistory/groupPolicyHistoryPage.js} +0 -0
  638. /package/workflows/organizations/{policyHistoryReadModel.js → policyHistory/policyHistoryReadModel.js} +0 -0
  639. /package/workflows/organizations/{policyHistoryReadModel.js.map → policyHistory/policyHistoryReadModel.js.map} +0 -0
  640. /package/workflows/organizations/{policyHistoryTypes.js → policyHistory/policyHistoryTypes.js} +0 -0
  641. /package/workflows/organizations/{policyHistoryTypes.js.map → policyHistory/policyHistoryTypes.js.map} +0 -0
  642. /package/workflows/organizations/{principalPolicyApi.js → principalPolicy/principalPolicyApi.js} +0 -0
  643. /package/workflows/organizations/{principalPolicyRequest.js.map → principalPolicy/principalPolicyRequest.js.map} +0 -0
  644. /package/workflows/organizations/{organizationPresentationFailures.js.map → readModel/organizationPresentationFailures.js.map} +0 -0
  645. /package/workflows/principals/{principalAcknowledgementChecks.js → acknowledgements/principalAcknowledgementChecks.js} +0 -0
  646. /package/workflows/principals/{principalAcknowledgementChecks.js.map → acknowledgements/principalAcknowledgementChecks.js.map} +0 -0
  647. /package/workflows/principals/{principalHistoryRecoveryVerification.js.map → historyRecovery/principalHistoryRecoveryVerification.js.map} +0 -0
  648. /package/workflows/principals/{recoverPrincipalHistoryPage.js.map → historyRecovery/recoverPrincipalHistoryPage.js.map} +0 -0
  649. /package/workflows/principals/{recoverPrincipalPolicyHistory.d.ts → historyRecovery/recoverPrincipalPolicyHistory.d.ts} +0 -0
  650. /package/workflows/principals/{principalPolicyCacheScope.js → policyCache/principalPolicyCacheScope.js} +0 -0
  651. /package/workflows/principals/{principalPolicyCacheScope.js.map → policyCache/principalPolicyCacheScope.js.map} +0 -0
  652. /package/workflows/principals/{publicPrincipalHistoryTypes.js → publicHistory/publicPrincipalHistoryTypes.js} +0 -0
  653. /package/workflows/principals/{principalRecoveryDiscoveryPage.js → recoveryOperation/principalRecoveryDiscoveryPage.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"documentMutationCommit.js","sourceRoot":"","sources":["documentMutationCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAGL,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,kCAAkC,EAElC,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAUvE,MAAM,qCAAqC,GAAG,CAAC,CAAC;AAoChD,KAAK,UAAU,oCAAoC,CAAC,KAOnD;IACC,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GACrC,MAAM,KAAK,CAAC,WAAW,CAAC,mCAAmC,CACzD,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CACd,CAAC;IACJ,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,sBAAsB,GAC1B,KAAK,CAAC,sBAAsB;QAC5B,CAAC,kCAAkC,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,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} from \"../../data/documents/documentConstants\";\nimport {\n type DocumentProjectorRegistry,\n type DocumentProjectorRegistryInput,\n readStoredDocumentState,\n} from \"../../data/documents/documentKinds\";\nimport type {\n DocumentsPersistence,\n StoredDocumentRecord,\n} from \"../../data/persistence/documents/documentsPersistence\";\nimport type { PendingUpdateFields } from \"../../data/sqlite/documentPersistence\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport { createInitialDocumentRows } from \"./documentCreationPersistence\";\nimport {\n documentSyncSecurityContextMatches,\n type PrepareDocumentMutationInput,\n prepareDocumentMutation,\n} from \"./documentMutationPreparation\";\nimport { refuseDeletedDocumentPersist } from \"./documentPersistGuards\";\n\ntype DocumentContentState = Parameters<typeof encodeVersionVector>[0];\ntype NullableDocumentRuntimeField =\n | \"accessStateHash\"\n | \"lastCommitLsn\"\n | \"contentKeyBundle\"\n | \"documentKekTargets\"\n | \"documentManifestBundle\";\n\nconst MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS = 8;\n\nexport interface PersistedDocumentState {\n creationSuperseded?: true;\n historyRestoreState?:\n | Awaited<ReturnType<DocumentsPersistence[\"loadHistoryRestoreState\"]>>\n | undefined;\n pullContinuationSuperseded?: true;\n record: StoredDocumentRecord;\n syncIdentitySuperseded?: true;\n updatedAt?: string | undefined;\n}\n\nexport interface PersistDocumentStateInput\n extends PrepareDocumentMutationInput {\n acceptedPendingUpdateIds?: readonly string[] | undefined;\n attachmentRemoval?:\n | Parameters<\n DocumentsPersistence[\"commitDocumentMutation\"]\n >[1][\"attachmentRemoval\"]\n | undefined;\n attachmentStaging?:\n | Parameters<\n DocumentsPersistence[\"commitDocumentMutation\"]\n >[1][\"attachmentStaging\"]\n | undefined;\n canStartDurableMutation?: (() => boolean) | undefined;\n clearSyncFailure?: boolean | undefined;\n commitSideEffect?: (transactionExecSql: ExecSql) => Promise<void>;\n containerId?: string | null | undefined;\n documentProjectors: DocumentProjectorRegistryInput;\n execSql: ExecSql;\n patch?: Partial<StoredDocumentRecord> | undefined;\n pendingUpdate?: PendingUpdateFields | undefined;\n}\n\nasync function loadSupersededPersistedDocumentState(input: {\n creationSuperseded: boolean;\n execSql: ExecSql;\n localId: string;\n persistence: DocumentsPersistence;\n record: StoredDocumentRecord;\n syncIdentitySuperseded: boolean;\n}): Promise<PersistedDocumentState | null> {\n const { document, historyRestoreState } =\n await input.persistence.loadDocumentWithHistoryRestoreState(\n input.execSql,\n input.localId,\n );\n if (!document) return null;\n const syncIdentitySuperseded =\n input.syncIdentitySuperseded ||\n !documentSyncSecurityContextMatches(document, input.record);\n return {\n ...(input.creationSuperseded ? { creationSuperseded: true as const } : {}),\n historyRestoreState,\n pullContinuationSuperseded: true,\n record: document,\n ...(syncIdentitySuperseded\n ? { syncIdentitySuperseded: true as const }\n : {}),\n };\n}\n\nfunction resolveNullableDocumentRuntimeField(\n patch: Partial<StoredDocumentRecord>,\n key: NullableDocumentRuntimeField,\n currentValue: string | null | undefined,\n resetWhenUnpatched = false,\n): string | null {\n if (Object.hasOwn(patch, key)) return patch[key] ?? null;\n return resetWhenUnpatched ? null : (currentValue ?? null);\n}\n\nfunction resolveStoredDocumentContainerId(input: {\n containerId?: string | null | undefined;\n currentRecord: StoredDocumentRecord | null;\n patch: Partial<StoredDocumentRecord>;\n}): string | null {\n if (Object.hasOwn(input.patch, \"containerId\")) {\n return input.patch.containerId ?? null;\n }\n return input.currentRecord?.containerId ?? input.containerId ?? null;\n}\n\nfunction resolveStoredDocumentPullState(input: {\n currentRecord: StoredDocumentRecord | null;\n patch: Partial<StoredDocumentRecord>;\n securityContextChanged: boolean;\n}): Pick<\n StoredDocumentRecord,\n \"pullContinuation\" | \"pullContinuationRecoveryRequired\"\n> {\n if (Object.hasOwn(input.patch, \"pullContinuation\")) {\n return { pullContinuation: input.patch.pullContinuation ?? null };\n }\n if (input.securityContextChanged) return { pullContinuation: null };\n if (input.currentRecord?.pullContinuationRecoveryRequired) {\n return { pullContinuationRecoveryRequired: true };\n }\n return { pullContinuation: input.currentRecord?.pullContinuation ?? null };\n}\n\nfunction buildStoredDocumentRecord(input: {\n containerId?: string | null | undefined;\n currentDoc: DocumentContentState;\n currentRecord: StoredDocumentRecord | null;\n documentProjectors: DocumentProjectorRegistry;\n localId: string;\n patch: Partial<StoredDocumentRecord>;\n}) {\n const { currentDoc, currentRecord, documentProjectors, localId, patch } =\n input;\n const currentDocumentId = currentRecord?.documentId ?? null;\n const nextDocumentId = patch.documentId ?? currentDocumentId;\n const documentIdChanged = nextDocumentId !== currentDocumentId;\n const currentAccessEpoch =\n currentRecord?.accessEpoch ?? DEFAULT_DOCUMENT_ACCESS_EPOCH;\n const nextAccessEpoch = patch.accessEpoch ?? currentAccessEpoch;\n const securityContextChanged =\n documentIdChanged || nextAccessEpoch !== currentAccessEpoch;\n const documentState = readStoredDocumentState(currentDoc, documentProjectors);\n const record: StoredDocumentRecord = {\n id: currentRecord?.id ?? localId,\n accessEpoch: nextAccessEpoch,\n accessStateHash: resolveNullableDocumentRuntimeField(\n patch,\n \"accessStateHash\",\n currentRecord?.accessStateHash,\n securityContextChanged,\n ),\n containerId: resolveStoredDocumentContainerId({\n containerId: input.containerId,\n currentRecord,\n patch,\n }),\n contentKeyBundle: resolveNullableDocumentRuntimeField(\n patch,\n \"contentKeyBundle\",\n currentRecord?.contentKeyBundle,\n securityContextChanged,\n ),\n documentId: nextDocumentId,\n effectiveAccessLevel:\n patch.effectiveAccessLevel ?? currentRecord?.effectiveAccessLevel ?? null,\n documentKekTargets: resolveNullableDocumentRuntimeField(\n patch,\n \"documentKekTargets\",\n currentRecord?.documentKekTargets,\n securityContextChanged,\n ),\n documentKind: patch.documentKind ?? documentState.documentKind,\n documentManifestBundle: resolveNullableDocumentRuntimeField(\n patch,\n \"documentManifestBundle\",\n currentRecord?.documentManifestBundle,\n securityContextChanged,\n ),\n lastCommitLsn: resolveNullableDocumentRuntimeField(\n patch,\n \"lastCommitLsn\",\n currentRecord?.lastCommitLsn,\n documentIdChanged,\n ),\n snapshotEndVersion:\n patch.snapshotEndVersion ?? currentRecord?.snapshotEndVersion ?? \"\",\n pendingBaseVersion:\n patch.pendingBaseVersion !== undefined\n ? patch.pendingBaseVersion\n : (currentRecord?.pendingBaseVersion ?? null),\n recoveryGeneration:\n patch.recoveryGeneration ?? currentRecord?.recoveryGeneration ?? 0,\n ...resolveStoredDocumentPullState({\n currentRecord,\n patch,\n securityContextChanged,\n }),\n text: patch.text ?? getTextValue(currentDoc),\n title: patch.title ?? documentState.title,\n };\n return { documentState, record };\n}\n\nasync function saveDocumentClientProjection(input: {\n currentRecord: StoredDocumentRecord | null;\n documentProjectors: DocumentProjectorRegistry;\n documentState: ReturnType<typeof readStoredDocumentState>;\n execSql: ExecSql;\n localId: string;\n record: StoredDocumentRecord;\n updatedAt: string;\n}): Promise<void> {\n const previousKind =\n input.currentRecord?.documentKind ?? DEFAULT_DOCUMENT_KIND;\n const nextKind = input.record.documentKind ?? DEFAULT_DOCUMENT_KIND;\n if (previousKind !== nextKind) {\n await input.documentProjectors.deleteStoredDocumentClientProjection({\n documentKind: previousKind,\n execSql: input.execSql,\n localId: input.localId,\n });\n }\n await input.documentProjectors.saveStoredDocumentClientProjection({\n containerId: input.record.containerId,\n documentId: input.record.documentId,\n documentKind: nextKind,\n execSql: input.execSql,\n localId: input.record.id,\n structuredFields: input.documentState.structuredFields,\n text: input.record.text,\n title: input.record.title ?? input.documentState.title,\n updatedAt: input.updatedAt,\n });\n}\n\nasync function settleSupersededDocumentMutation(input: {\n acceptedPendingUpdateIds: readonly string[];\n lockedExecSql: ExecSql;\n mutation: Awaited<ReturnType<typeof prepareDocumentMutation>>;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null> {\n const { mutation, persistInput } = input;\n if (!mutation.mutationCurrentRecord) return null;\n const authoritativeRecord = persistInput.expectedSyncState\n ? await persistInput.persistence.settleAcceptedPendingUpdates(\n input.lockedExecSql,\n {\n expectedRecord: persistInput.expectedSyncState.record,\n pendingUpdateIds: input.acceptedPendingUpdateIds,\n },\n )\n : mutation.mutationCurrentRecord;\n if (!authoritativeRecord) return null;\n return loadSupersededPersistedDocumentState({\n creationSuperseded: mutation.creationSuperseded,\n execSql: input.lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n record: authoritativeRecord,\n syncIdentitySuperseded: !mutation.securityContextMatches,\n });\n}\n\nasync function loadConcurrentCreationWinner(input: {\n execSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState> {\n const winningRecord = await input.persistInput.persistence.loadDocument(\n input.execSql,\n input.persistInput.localId,\n );\n if (!winningRecord) {\n throw new Error(\"Concurrent document creation lost without a winner\");\n }\n const winner = await loadSupersededPersistedDocumentState({\n creationSuperseded: true,\n execSql: input.execSql,\n localId: input.persistInput.localId,\n persistence: input.persistInput.persistence,\n record: winningRecord,\n syncIdentitySuperseded: true,\n });\n if (!winner) {\n throw new Error(\"Concurrent document creation winner disappeared\");\n }\n return winner;\n}\n\nasync function resolveInitialDocumentCreation(input: {\n execSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n record: StoredDocumentRecord;\n savedAt: string | null;\n}): Promise<PersistedDocumentState | null> {\n if (input.savedAt !== null) {\n return { record: input.record, updatedAt: input.savedAt };\n }\n if (\n input.persistInput.canStartDurableMutation &&\n !input.persistInput.canStartDurableMutation()\n ) {\n return null;\n }\n return loadConcurrentCreationWinner({\n execSql: input.execSql,\n persistInput: input.persistInput,\n });\n}\n\nasync function resolveDocumentMutationCommit(input: {\n committed: Awaited<\n ReturnType<DocumentsPersistence[\"commitDocumentMutation\"]>\n >;\n lockedExecSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n record: StoredDocumentRecord;\n}): Promise<PersistedDocumentState | null | \"retry\"> {\n const { committed, persistInput, record } = input;\n if (\n persistInput.canStartDurableMutation &&\n !persistInput.canStartDurableMutation()\n ) {\n return null;\n }\n if (committed.committed) return { record, updatedAt: committed.updatedAt };\n if (!committed.currentRecord) return null;\n if (persistInput.expectedSyncState === undefined) return \"retry\";\n return loadSupersededPersistedDocumentState({\n creationSuperseded: false,\n execSql: input.lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n record: committed.currentRecord,\n syncIdentitySuperseded: !documentSyncSecurityContextMatches(\n committed.currentRecord,\n persistInput.expectedSyncState.record,\n ),\n });\n}\n\nasync function commitOnePreparedDocumentMutation(input: {\n acceptedPendingUpdateIds: readonly string[];\n documentProjectors: DocumentProjectorRegistry;\n lockedExecSql: ExecSql;\n mutation: Exclude<\n Awaited<ReturnType<typeof prepareDocumentMutation>>,\n { pullContinuationSuperseded: true }\n >;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null | \"retry\"> {\n const { mutation, persistInput } = input;\n const { documentState, record } = buildStoredDocumentRecord({\n containerId: persistInput.containerId,\n currentDoc: persistInput.currentDoc,\n currentRecord: mutation.mutationCurrentRecord,\n documentProjectors: input.documentProjectors,\n localId: persistInput.localId,\n patch: mutation.resolvedPatch,\n });\n if (!mutation.mutationCurrentRecord) {\n const savedAt = await createInitialDocumentRows({\n currentDoc: persistInput.currentDoc,\n execSql: input.lockedExecSql,\n pendingUpdate: persistInput.pendingUpdate,\n persistence: persistInput.persistence,\n record,\n stillCurrent: persistInput.canStartDurableMutation,\n saveClientProjection: (transactionExecSql, updatedAt) =>\n saveDocumentClientProjection({\n currentRecord: null,\n documentProjectors: input.documentProjectors,\n documentState,\n execSql: transactionExecSql,\n localId: persistInput.localId,\n record,\n updatedAt,\n }),\n });\n return resolveInitialDocumentCreation({\n execSql: input.lockedExecSql,\n persistInput,\n record,\n savedAt,\n });\n }\n\n const committed = await persistInput.persistence.commitDocumentMutation(\n input.lockedExecSql,\n {\n acceptedPendingUpdateIds: input.acceptedPendingUpdateIds,\n clearSyncFailure: persistInput.clearSyncFailure,\n ...(persistInput.attachmentRemoval\n ? { attachmentRemoval: persistInput.attachmentRemoval }\n : {}),\n ...(persistInput.attachmentStaging\n ? { attachmentStaging: persistInput.attachmentStaging }\n : {}),\n document: record,\n expectedRecord: mutation.mutationCurrentRecord,\n ...(persistInput.historyCheckpoint\n ? { historyCheckpoint: persistInput.historyCheckpoint }\n : {}),\n ...(persistInput.historyUpdateOrigin\n ? { historyUpdateOrigin: persistInput.historyUpdateOrigin }\n : {}),\n ...(persistInput.historyUpdates\n ? { historyUpdates: persistInput.historyUpdates }\n : {}),\n ...(persistInput.pendingUpdate\n ? { pendingUpdate: persistInput.pendingUpdate }\n : {}),\n settleAcceptedPendingOnConflict:\n persistInput.expectedSyncState !== undefined,\n ...(persistInput.canStartDurableMutation\n ? { stillCurrent: persistInput.canStartDurableMutation }\n : {}),\n },\n async (transactionExecSql, updatedAt) => {\n await saveDocumentClientProjection({\n currentRecord: mutation.mutationCurrentRecord,\n documentProjectors: input.documentProjectors,\n documentState,\n execSql: transactionExecSql,\n localId: persistInput.localId,\n record,\n updatedAt,\n });\n await persistInput.commitSideEffect?.(transactionExecSql);\n },\n );\n return resolveDocumentMutationCommit({\n committed,\n lockedExecSql: input.lockedExecSql,\n persistInput,\n record,\n });\n}\n\nexport async function commitPreparedDocumentState(input: {\n documentProjectors: DocumentProjectorRegistry;\n lockedExecSql: ExecSql;\n patch: Partial<StoredDocumentRecord>;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null> {\n const { lockedExecSql, persistInput } = input;\n if (\n await refuseDeletedDocumentPersist({\n currentRecord: persistInput.currentRecord,\n documentProjectors: input.documentProjectors,\n execSql: lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n })\n ) {\n return null;\n }\n const acceptedPendingUpdateIds = persistInput.acceptedPendingUpdateIds ?? [];\n for (\n let attempt = 0;\n attempt < MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS;\n attempt += 1\n ) {\n const mutation = await prepareDocumentMutation(\n persistInput,\n lockedExecSql,\n input.patch,\n );\n if (mutation.pullContinuationSuperseded) {\n return settleSupersededDocumentMutation({\n acceptedPendingUpdateIds,\n lockedExecSql,\n mutation,\n persistInput,\n });\n }\n const result = await commitOnePreparedDocumentMutation({\n acceptedPendingUpdateIds,\n documentProjectors: input.documentProjectors,\n lockedExecSql,\n mutation,\n persistInput,\n });\n if (result !== \"retry\") return result;\n }\n throw new Error(\n `Document mutation commit gave up after ${MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS} concurrent conflicts`,\n );\n}\n"]}
1
+ {"version":3,"file":"documentMutationCommit.js","sourceRoot":"","sources":["documentMutationCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAGL,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACL,kCAAkC,EAElC,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAUvE,MAAM,qCAAqC,GAAG,CAAC,CAAC;AAoChD,KAAK,UAAU,oCAAoC,CAAC,KAOnD;IACC,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,GACrC,MAAM,KAAK,CAAC,WAAW,CAAC,mCAAmC,CACzD,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CACd,CAAC;IACJ,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,sBAAsB,GAC1B,KAAK,CAAC,sBAAsB;QAC5B,CAAC,kCAAkC,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9D,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,mBAAmB;QACnB,0BAA0B,E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EAAE,GAAG,KAAK,CAAC;IAC9C,IACE,MAAM,4BAA4B,CAAC;QACjC,aAAa,EAAE,YAAY,CAAC,aAAa;QACzC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,OAAO,EAAE,aAAa;QACtB,OAAO,EAAE,YAAY,CAAC,OAAO;QAC7B,WAAW,EAAE,YAAY,CAAC,WAAW;KACtC,CAAC,EACF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,wBAAwB,GAAG,YAAY,CAAC,wBAAwB,IAAI,EAAE,CAAC;IAC7E,KACE,IAAI,OAAO,GAAG,CAAC,EACf,OAAO,GAAG,qCAAqC,EAC/C,OAAO,IAAI,CAAC,EACZ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAC5C,YAAY,EACZ,aAAa,EACb,KAAK,CAAC,KAAK,CACZ,CAAC;QACF,IAAI,QAAQ,CAAC,0BAA0B,EAAE,CAAC;YACxC,OAAO,gCAAgC,CAAC;gBACtC,wBAAwB;gBACxB,aAAa;gBACb,QAAQ;gBACR,YAAY;aACb,CAAC,CAAC;QACL,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,iCAAiC,CAAC;YACrD,wBAAwB;YACxB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,aAAa;YACb,QAAQ;YACR,YAAY;SACb,CAAC,CAAC;QACH,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,MAAM,CAAC;IACxC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,0CAA0C,qCAAqC,uBAAuB,CACvG,CAAC;AACJ,CAAC","sourcesContent":["import { type encodeVersionVector, getTextValue } from \"@tearleads/loro\";\nimport {\n DEFAULT_DOCUMENT_ACCESS_EPOCH,\n DEFAULT_DOCUMENT_KIND,\n} from \"../../data/documents/documentConstants\";\nimport {\n type DocumentProjectorRegistry,\n type DocumentProjectorRegistryInput,\n readStoredDocumentState,\n} from \"../../data/documents/documentKinds\";\nimport type {\n DocumentsPersistence,\n StoredDocumentRecord,\n} from \"../../data/persistence/documents/documentsPersistence\";\nimport type { PendingUpdateFields } from \"../../data/sqlite/documentPersistence\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport { createInitialDocumentRows } from \"./create/documentCreationPersistence\";\nimport {\n documentSyncSecurityContextMatches,\n type PrepareDocumentMutationInput,\n prepareDocumentMutation,\n} from \"./documentMutationPreparation\";\nimport { refuseDeletedDocumentPersist } from \"./documentPersistGuards\";\n\ntype DocumentContentState = Parameters<typeof encodeVersionVector>[0];\ntype NullableDocumentRuntimeField =\n | \"accessStateHash\"\n | \"lastCommitLsn\"\n | \"contentKeyBundle\"\n | \"documentKekTargets\"\n | \"documentManifestBundle\";\n\nconst MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS = 8;\n\nexport interface PersistedDocumentState {\n creationSuperseded?: true;\n historyRestoreState?:\n | Awaited<ReturnType<DocumentsPersistence[\"loadHistoryRestoreState\"]>>\n | undefined;\n pullContinuationSuperseded?: true;\n record: StoredDocumentRecord;\n syncIdentitySuperseded?: true;\n updatedAt?: string | undefined;\n}\n\nexport interface PersistDocumentStateInput\n extends PrepareDocumentMutationInput {\n acceptedPendingUpdateIds?: readonly string[] | undefined;\n attachmentRemoval?:\n | Parameters<\n DocumentsPersistence[\"commitDocumentMutation\"]\n >[1][\"attachmentRemoval\"]\n | undefined;\n attachmentStaging?:\n | Parameters<\n DocumentsPersistence[\"commitDocumentMutation\"]\n >[1][\"attachmentStaging\"]\n | undefined;\n canStartDurableMutation?: (() => boolean) | undefined;\n clearSyncFailure?: boolean | undefined;\n commitSideEffect?: (transactionExecSql: ExecSql) => Promise<void>;\n containerId?: string | null | undefined;\n documentProjectors: DocumentProjectorRegistryInput;\n execSql: ExecSql;\n patch?: Partial<StoredDocumentRecord> | undefined;\n pendingUpdate?: PendingUpdateFields | undefined;\n}\n\nasync function loadSupersededPersistedDocumentState(input: {\n creationSuperseded: boolean;\n execSql: ExecSql;\n localId: string;\n persistence: DocumentsPersistence;\n record: StoredDocumentRecord;\n syncIdentitySuperseded: boolean;\n}): Promise<PersistedDocumentState | null> {\n const { document, historyRestoreState } =\n await input.persistence.loadDocumentWithHistoryRestoreState(\n input.execSql,\n input.localId,\n );\n if (!document) return null;\n const syncIdentitySuperseded =\n input.syncIdentitySuperseded ||\n !documentSyncSecurityContextMatches(document, input.record);\n return {\n ...(input.creationSuperseded ? { creationSuperseded: true as const } : {}),\n historyRestoreState,\n pullContinuationSuperseded: true,\n record: document,\n ...(syncIdentitySuperseded\n ? { syncIdentitySuperseded: true as const }\n : {}),\n };\n}\n\nfunction resolveNullableDocumentRuntimeField(\n patch: Partial<StoredDocumentRecord>,\n key: NullableDocumentRuntimeField,\n currentValue: string | null | undefined,\n resetWhenUnpatched = false,\n): string | null {\n if (Object.hasOwn(patch, key)) return patch[key] ?? null;\n return resetWhenUnpatched ? null : (currentValue ?? null);\n}\n\nfunction resolveStoredDocumentContainerId(input: {\n containerId?: string | null | undefined;\n currentRecord: StoredDocumentRecord | null;\n patch: Partial<StoredDocumentRecord>;\n}): string | null {\n if (Object.hasOwn(input.patch, \"containerId\")) {\n return input.patch.containerId ?? null;\n }\n return input.currentRecord?.containerId ?? input.containerId ?? null;\n}\n\nfunction resolveStoredDocumentPullState(input: {\n currentRecord: StoredDocumentRecord | null;\n patch: Partial<StoredDocumentRecord>;\n securityContextChanged: boolean;\n}): Pick<\n StoredDocumentRecord,\n \"pullContinuation\" | \"pullContinuationRecoveryRequired\"\n> {\n if (Object.hasOwn(input.patch, \"pullContinuation\")) {\n return { pullContinuation: input.patch.pullContinuation ?? null };\n }\n if (input.securityContextChanged) return { pullContinuation: null };\n if (input.currentRecord?.pullContinuationRecoveryRequired) {\n return { pullContinuationRecoveryRequired: true };\n }\n return { pullContinuation: input.currentRecord?.pullContinuation ?? null };\n}\n\nfunction buildStoredDocumentRecord(input: {\n containerId?: string | null | undefined;\n currentDoc: DocumentContentState;\n currentRecord: StoredDocumentRecord | null;\n documentProjectors: DocumentProjectorRegistry;\n localId: string;\n patch: Partial<StoredDocumentRecord>;\n}) {\n const { currentDoc, currentRecord, documentProjectors, localId, patch } =\n input;\n const currentDocumentId = currentRecord?.documentId ?? null;\n const nextDocumentId = patch.documentId ?? currentDocumentId;\n const documentIdChanged = nextDocumentId !== currentDocumentId;\n const currentAccessEpoch =\n currentRecord?.accessEpoch ?? DEFAULT_DOCUMENT_ACCESS_EPOCH;\n const nextAccessEpoch = patch.accessEpoch ?? currentAccessEpoch;\n const securityContextChanged =\n documentIdChanged || nextAccessEpoch !== currentAccessEpoch;\n const documentState = readStoredDocumentState(currentDoc, documentProjectors);\n const record: StoredDocumentRecord = {\n id: currentRecord?.id ?? localId,\n accessEpoch: nextAccessEpoch,\n accessStateHash: resolveNullableDocumentRuntimeField(\n patch,\n \"accessStateHash\",\n currentRecord?.accessStateHash,\n securityContextChanged,\n ),\n containerId: resolveStoredDocumentContainerId({\n containerId: input.containerId,\n currentRecord,\n patch,\n }),\n contentKeyBundle: resolveNullableDocumentRuntimeField(\n patch,\n \"contentKeyBundle\",\n currentRecord?.contentKeyBundle,\n securityContextChanged,\n ),\n documentId: nextDocumentId,\n effectiveAccessLevel:\n patch.effectiveAccessLevel ?? currentRecord?.effectiveAccessLevel ?? null,\n documentKekTargets: resolveNullableDocumentRuntimeField(\n patch,\n \"documentKekTargets\",\n currentRecord?.documentKekTargets,\n securityContextChanged,\n ),\n documentKind: patch.documentKind ?? documentState.documentKind,\n documentManifestBundle: resolveNullableDocumentRuntimeField(\n patch,\n \"documentManifestBundle\",\n currentRecord?.documentManifestBundle,\n securityContextChanged,\n ),\n lastCommitLsn: resolveNullableDocumentRuntimeField(\n patch,\n \"lastCommitLsn\",\n currentRecord?.lastCommitLsn,\n documentIdChanged,\n ),\n snapshotEndVersion:\n patch.snapshotEndVersion ?? currentRecord?.snapshotEndVersion ?? \"\",\n pendingBaseVersion:\n patch.pendingBaseVersion !== undefined\n ? patch.pendingBaseVersion\n : (currentRecord?.pendingBaseVersion ?? null),\n recoveryGeneration:\n patch.recoveryGeneration ?? currentRecord?.recoveryGeneration ?? 0,\n ...resolveStoredDocumentPullState({\n currentRecord,\n patch,\n securityContextChanged,\n }),\n text: patch.text ?? getTextValue(currentDoc),\n title: patch.title ?? documentState.title,\n };\n return { documentState, record };\n}\n\nasync function saveDocumentClientProjection(input: {\n currentRecord: StoredDocumentRecord | null;\n documentProjectors: DocumentProjectorRegistry;\n documentState: ReturnType<typeof readStoredDocumentState>;\n execSql: ExecSql;\n localId: string;\n record: StoredDocumentRecord;\n updatedAt: string;\n}): Promise<void> {\n const previousKind =\n input.currentRecord?.documentKind ?? DEFAULT_DOCUMENT_KIND;\n const nextKind = input.record.documentKind ?? DEFAULT_DOCUMENT_KIND;\n if (previousKind !== nextKind) {\n await input.documentProjectors.deleteStoredDocumentClientProjection({\n documentKind: previousKind,\n execSql: input.execSql,\n localId: input.localId,\n });\n }\n await input.documentProjectors.saveStoredDocumentClientProjection({\n containerId: input.record.containerId,\n documentId: input.record.documentId,\n documentKind: nextKind,\n execSql: input.execSql,\n localId: input.record.id,\n structuredFields: input.documentState.structuredFields,\n text: input.record.text,\n title: input.record.title ?? input.documentState.title,\n updatedAt: input.updatedAt,\n });\n}\n\nasync function settleSupersededDocumentMutation(input: {\n acceptedPendingUpdateIds: readonly string[];\n lockedExecSql: ExecSql;\n mutation: Awaited<ReturnType<typeof prepareDocumentMutation>>;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null> {\n const { mutation, persistInput } = input;\n if (!mutation.mutationCurrentRecord) return null;\n const authoritativeRecord = persistInput.expectedSyncState\n ? await persistInput.persistence.settleAcceptedPendingUpdates(\n input.lockedExecSql,\n {\n expectedRecord: persistInput.expectedSyncState.record,\n pendingUpdateIds: input.acceptedPendingUpdateIds,\n },\n )\n : mutation.mutationCurrentRecord;\n if (!authoritativeRecord) return null;\n return loadSupersededPersistedDocumentState({\n creationSuperseded: mutation.creationSuperseded,\n execSql: input.lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n record: authoritativeRecord,\n syncIdentitySuperseded: !mutation.securityContextMatches,\n });\n}\n\nasync function loadConcurrentCreationWinner(input: {\n execSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState> {\n const winningRecord = await input.persistInput.persistence.loadDocument(\n input.execSql,\n input.persistInput.localId,\n );\n if (!winningRecord) {\n throw new Error(\"Concurrent document creation lost without a winner\");\n }\n const winner = await loadSupersededPersistedDocumentState({\n creationSuperseded: true,\n execSql: input.execSql,\n localId: input.persistInput.localId,\n persistence: input.persistInput.persistence,\n record: winningRecord,\n syncIdentitySuperseded: true,\n });\n if (!winner) {\n throw new Error(\"Concurrent document creation winner disappeared\");\n }\n return winner;\n}\n\nasync function resolveInitialDocumentCreation(input: {\n execSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n record: StoredDocumentRecord;\n savedAt: string | null;\n}): Promise<PersistedDocumentState | null> {\n if (input.savedAt !== null) {\n return { record: input.record, updatedAt: input.savedAt };\n }\n if (\n input.persistInput.canStartDurableMutation &&\n !input.persistInput.canStartDurableMutation()\n ) {\n return null;\n }\n return loadConcurrentCreationWinner({\n execSql: input.execSql,\n persistInput: input.persistInput,\n });\n}\n\nasync function resolveDocumentMutationCommit(input: {\n committed: Awaited<\n ReturnType<DocumentsPersistence[\"commitDocumentMutation\"]>\n >;\n lockedExecSql: ExecSql;\n persistInput: PersistDocumentStateInput;\n record: StoredDocumentRecord;\n}): Promise<PersistedDocumentState | null | \"retry\"> {\n const { committed, persistInput, record } = input;\n if (\n persistInput.canStartDurableMutation &&\n !persistInput.canStartDurableMutation()\n ) {\n return null;\n }\n if (committed.committed) return { record, updatedAt: committed.updatedAt };\n if (!committed.currentRecord) return null;\n if (persistInput.expectedSyncState === undefined) return \"retry\";\n return loadSupersededPersistedDocumentState({\n creationSuperseded: false,\n execSql: input.lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n record: committed.currentRecord,\n syncIdentitySuperseded: !documentSyncSecurityContextMatches(\n committed.currentRecord,\n persistInput.expectedSyncState.record,\n ),\n });\n}\n\nasync function commitOnePreparedDocumentMutation(input: {\n acceptedPendingUpdateIds: readonly string[];\n documentProjectors: DocumentProjectorRegistry;\n lockedExecSql: ExecSql;\n mutation: Exclude<\n Awaited<ReturnType<typeof prepareDocumentMutation>>,\n { pullContinuationSuperseded: true }\n >;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null | \"retry\"> {\n const { mutation, persistInput } = input;\n const { documentState, record } = buildStoredDocumentRecord({\n containerId: persistInput.containerId,\n currentDoc: persistInput.currentDoc,\n currentRecord: mutation.mutationCurrentRecord,\n documentProjectors: input.documentProjectors,\n localId: persistInput.localId,\n patch: mutation.resolvedPatch,\n });\n if (!mutation.mutationCurrentRecord) {\n const savedAt = await createInitialDocumentRows({\n currentDoc: persistInput.currentDoc,\n execSql: input.lockedExecSql,\n pendingUpdate: persistInput.pendingUpdate,\n persistence: persistInput.persistence,\n record,\n stillCurrent: persistInput.canStartDurableMutation,\n saveClientProjection: (transactionExecSql, updatedAt) =>\n saveDocumentClientProjection({\n currentRecord: null,\n documentProjectors: input.documentProjectors,\n documentState,\n execSql: transactionExecSql,\n localId: persistInput.localId,\n record,\n updatedAt,\n }),\n });\n return resolveInitialDocumentCreation({\n execSql: input.lockedExecSql,\n persistInput,\n record,\n savedAt,\n });\n }\n\n const committed = await persistInput.persistence.commitDocumentMutation(\n input.lockedExecSql,\n {\n acceptedPendingUpdateIds: input.acceptedPendingUpdateIds,\n clearSyncFailure: persistInput.clearSyncFailure,\n ...(persistInput.attachmentRemoval\n ? { attachmentRemoval: persistInput.attachmentRemoval }\n : {}),\n ...(persistInput.attachmentStaging\n ? { attachmentStaging: persistInput.attachmentStaging }\n : {}),\n document: record,\n expectedRecord: mutation.mutationCurrentRecord,\n ...(persistInput.historyCheckpoint\n ? { historyCheckpoint: persistInput.historyCheckpoint }\n : {}),\n ...(persistInput.historyUpdateOrigin\n ? { historyUpdateOrigin: persistInput.historyUpdateOrigin }\n : {}),\n ...(persistInput.historyUpdates\n ? { historyUpdates: persistInput.historyUpdates }\n : {}),\n ...(persistInput.pendingUpdate\n ? { pendingUpdate: persistInput.pendingUpdate }\n : {}),\n settleAcceptedPendingOnConflict:\n persistInput.expectedSyncState !== undefined,\n ...(persistInput.canStartDurableMutation\n ? { stillCurrent: persistInput.canStartDurableMutation }\n : {}),\n },\n async (transactionExecSql, updatedAt) => {\n await saveDocumentClientProjection({\n currentRecord: mutation.mutationCurrentRecord,\n documentProjectors: input.documentProjectors,\n documentState,\n execSql: transactionExecSql,\n localId: persistInput.localId,\n record,\n updatedAt,\n });\n await persistInput.commitSideEffect?.(transactionExecSql);\n },\n );\n return resolveDocumentMutationCommit({\n committed,\n lockedExecSql: input.lockedExecSql,\n persistInput,\n record,\n });\n}\n\nexport async function commitPreparedDocumentState(input: {\n documentProjectors: DocumentProjectorRegistry;\n lockedExecSql: ExecSql;\n patch: Partial<StoredDocumentRecord>;\n persistInput: PersistDocumentStateInput;\n}): Promise<PersistedDocumentState | null> {\n const { lockedExecSql, persistInput } = input;\n if (\n await refuseDeletedDocumentPersist({\n currentRecord: persistInput.currentRecord,\n documentProjectors: input.documentProjectors,\n execSql: lockedExecSql,\n localId: persistInput.localId,\n persistence: persistInput.persistence,\n })\n ) {\n return null;\n }\n const acceptedPendingUpdateIds = persistInput.acceptedPendingUpdateIds ?? [];\n for (\n let attempt = 0;\n attempt < MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS;\n attempt += 1\n ) {\n const mutation = await prepareDocumentMutation(\n persistInput,\n lockedExecSql,\n input.patch,\n );\n if (mutation.pullContinuationSuperseded) {\n return settleSupersededDocumentMutation({\n acceptedPendingUpdateIds,\n lockedExecSql,\n mutation,\n persistInput,\n });\n }\n const result = await commitOnePreparedDocumentMutation({\n acceptedPendingUpdateIds,\n documentProjectors: input.documentProjectors,\n lockedExecSql,\n mutation,\n persistInput,\n });\n if (result !== \"retry\") return result;\n }\n throw new Error(\n `Document mutation commit gave up after ${MAX_DOCUMENT_MUTATION_COMMIT_ATTEMPTS} concurrent conflicts`,\n );\n}\n"]}
@@ -9,27 +9,27 @@ export type { ExecSql } from "../../data/sqlite/sqlSchema.js";
9
9
  export { selectDocumentSyncOutgoingBatch } from "../../data/sync/documentSyncOutgoingBatch.js";
10
10
  export { settleOutgoingPassAndDecideReArm } from "../../data/sync/outgoingUpdateSettlement.js";
11
11
  export { didRegainSyncPrerequisites, isDatabaseUnavailableError, } from "../../data/sync/syncCoordinator.js";
12
- export { deleteLocalDocumentAttachment, deletePendingDocumentAttachment, markLocalDocumentAttachmentDetached, saveLocalDocumentAttachments, savePendingDocumentAttachment, } from "./attachmentPersistence.js";
12
+ export { deleteLocalDocumentAttachment, deletePendingDocumentAttachment, markLocalDocumentAttachmentDetached, saveLocalDocumentAttachments, savePendingDocumentAttachment, } from "./attachments/attachmentPersistence.js";
13
+ export { runSerializedDocumentBlobMutation } from "./attachments/blobMutationLock.js";
14
+ export { reclaimDocumentOrphanBlobs } from "./attachments/orphanBlobReclaims.js";
13
15
  export { resolveDocumentCreateAuthor } from "./author.js";
14
- export { runSerializedDocumentBlobMutation } from "./blobMutationLock.js";
15
- export { buildMaterializedDocumentCreatePlan, createRemoteDocument, documentWriterProjectionFromCreateResponse, } from "./create.js";
16
+ export { buildMaterializedDocumentCreatePlan, createRemoteDocument, documentWriterProjectionFromCreateResponse, } from "./create/index.js";
16
17
  export { importDocumentHistoryTailUpdates, loadPersistedDocumentContent, mergePersistedDocumentHistory, } from "./historyContent.js";
17
- export { buildMaterializedDocumentLinkSetMutationPlan } from "./linkSet.js";
18
- export { relinkRemoteDocument } from "./linkSetRemote.js";
19
- export { reclaimDocumentOrphanBlobs } from "./orphanBlobReclaims.js";
18
+ export { buildMaterializedDocumentLinkSetMutationPlan } from "./linkSet/index.js";
19
+ export { relinkRemoteDocument } from "./linkSet/linkSetRemote.js";
20
20
  export { enqueuePendingDocumentUpdate, listPendingDocumentUpdates, } from "./pendingUpdatePersistence.js";
21
- export { type DiscardedDocumentShellResult, deletePersistedDocument, discardPersistedDocumentToShell, } from "./persistedDocumentRemoval.js";
22
21
  export { type AttachmentRemovalRows, type AttachmentStagingRows, DOCUMENTS_APP_KIND, type DocumentRecord, type DocumentsPersistence, defaultDocumentsPersistence, type LocalAttachmentRecord, loadPersistedDocumentStoreState, type PendingAttachmentRecord, type PendingAttachmentUploadIdentity, type PendingUpdateInsert, type PendingUpdateRecord, persistDocumentState, type RelinkPersistedDocumentInput, runSerializedSqlMutation, } from "./persistence.js";
23
22
  export { createDocumentProjectionUserKeyResolver, type DocumentProjectionKeyRuntime, type DocumentProjectionUserKeyResolver, didDocumentProjectionKeyRuntimeChange, } from "./projectionKeys.js";
24
- export { buildDocumentPurgeRequest, purgeRemoteDocument, } from "./purge.js";
25
- export type { SyncRemoteDocumentInput } from "./readOnlySync.js";
23
+ export { buildDocumentPurgeRequest, purgeRemoteDocument, } from "./purge/index.js";
24
+ export { type DiscardedDocumentShellResult, deletePersistedDocument, discardPersistedDocumentToShell, } from "./purge/persistedDocumentRemoval.js";
26
25
  export { createDocumentsWorkflowRuntime, type DocumentsWorkflowRuntime, type DocumentsWorkflowRuntimeGroups, type DocumentsWorkflowRuntimeInfra, type DocumentsWorkflowRuntimeInput, type DocumentsWorkflowRuntimeInputGroups, } from "./runtime.js";
27
- export { hasDocumentUpdateEvent, syncRemoteDocument, } from "./sync.js";
28
- export type { DocumentSyncContainerRekeyBuilder } from "./syncAttemptState.js";
29
- export { DocumentRawHistoryUnavailableError } from "./syncContentKeys.js";
30
- export { describeDocumentRevalidationFailure, describeDocumentSyncSubmitFailure, type TerminalSubmitFailureHandler, } from "./syncFailureClassification.js";
31
- export { shouldClearDocumentSyncFailureAfterPass } from "./syncFailureClearance.js";
32
- export { type DocumentSyncLane, registerDocumentSyncLane, requestDocumentSyncLaneAndWait, } from "./syncLane.js";
33
- export type { RekeyPendingUpdate } from "./syncRecoveryRekey.js";
34
- export { DOCUMENT_SYNC_TRACE_FRAGMENT, DOCUMENT_SYNC_TRACE_PATTERN, } from "./syncTrace.js";
26
+ export { hasDocumentUpdateEvent, syncRemoteDocument, } from "./sync/index.js";
27
+ export type { SyncRemoteDocumentInput } from "./sync/readOnlySync.js";
28
+ export type { DocumentSyncContainerRekeyBuilder } from "./sync/syncAttemptState.js";
29
+ export { type DocumentSyncLane, registerDocumentSyncLane, requestDocumentSyncLaneAndWait, } from "./sync/syncLane.js";
30
+ export { DOCUMENT_SYNC_TRACE_FRAGMENT, DOCUMENT_SYNC_TRACE_PATTERN, } from "./sync/syncTrace.js";
31
+ export { describeDocumentRevalidationFailure, describeDocumentSyncSubmitFailure, type TerminalSubmitFailureHandler, } from "./syncFailures/syncFailureClassification.js";
32
+ export { shouldClearDocumentSyncFailureAfterPass } from "./syncFailures/syncFailureClearance.js";
33
+ export { DocumentRawHistoryUnavailableError } from "./syncPlan/syncContentKeys.js";
34
+ export type { RekeyPendingUpdate } from "./syncRekeys/syncRecoveryRekey.js";
35
35
  export { createDocumentWriterPublicKeyResolver } from "./writerKeys.js";
@@ -7,25 +7,25 @@ export { clearDocumentSyncFailure, invalidateDocumentSyncPullContinuation, recor
7
7
  export { selectDocumentSyncOutgoingBatch } from "../../data/sync/documentSyncOutgoingBatch.js";
8
8
  export { settleOutgoingPassAndDecideReArm } from "../../data/sync/outgoingUpdateSettlement.js";
9
9
  export { didRegainSyncPrerequisites, isDatabaseUnavailableError, } from "../../data/sync/syncCoordinator.js";
10
- export { deleteLocalDocumentAttachment, deletePendingDocumentAttachment, markLocalDocumentAttachmentDetached, saveLocalDocumentAttachments, savePendingDocumentAttachment, } from "./attachmentPersistence.js";
10
+ export { deleteLocalDocumentAttachment, deletePendingDocumentAttachment, markLocalDocumentAttachmentDetached, saveLocalDocumentAttachments, savePendingDocumentAttachment, } from "./attachments/attachmentPersistence.js";
11
+ export { runSerializedDocumentBlobMutation } from "./attachments/blobMutationLock.js";
12
+ export { reclaimDocumentOrphanBlobs } from "./attachments/orphanBlobReclaims.js";
11
13
  export { resolveDocumentCreateAuthor } from "./author.js";
12
- export { runSerializedDocumentBlobMutation } from "./blobMutationLock.js";
13
- export { buildMaterializedDocumentCreatePlan, createRemoteDocument, documentWriterProjectionFromCreateResponse, } from "./create.js";
14
+ export { buildMaterializedDocumentCreatePlan, createRemoteDocument, documentWriterProjectionFromCreateResponse, } from "./create/index.js";
14
15
  export { importDocumentHistoryTailUpdates, loadPersistedDocumentContent, mergePersistedDocumentHistory, } from "./historyContent.js";
15
- export { buildMaterializedDocumentLinkSetMutationPlan } from "./linkSet.js";
16
- export { relinkRemoteDocument } from "./linkSetRemote.js";
17
- export { reclaimDocumentOrphanBlobs } from "./orphanBlobReclaims.js";
16
+ export { buildMaterializedDocumentLinkSetMutationPlan } from "./linkSet/index.js";
17
+ export { relinkRemoteDocument } from "./linkSet/linkSetRemote.js";
18
18
  export { enqueuePendingDocumentUpdate, listPendingDocumentUpdates, } from "./pendingUpdatePersistence.js";
19
- export { deletePersistedDocument, discardPersistedDocumentToShell, } from "./persistedDocumentRemoval.js";
20
19
  export { DOCUMENTS_APP_KIND, defaultDocumentsPersistence, loadPersistedDocumentStoreState, persistDocumentState, runSerializedSqlMutation, } from "./persistence.js";
21
20
  export { createDocumentProjectionUserKeyResolver, didDocumentProjectionKeyRuntimeChange, } from "./projectionKeys.js";
22
- export { buildDocumentPurgeRequest, purgeRemoteDocument, } from "./purge.js";
21
+ export { buildDocumentPurgeRequest, purgeRemoteDocument, } from "./purge/index.js";
22
+ export { deletePersistedDocument, discardPersistedDocumentToShell, } from "./purge/persistedDocumentRemoval.js";
23
23
  export { createDocumentsWorkflowRuntime, } from "./runtime.js";
24
- export { hasDocumentUpdateEvent, syncRemoteDocument, } from "./sync.js";
25
- export { DocumentRawHistoryUnavailableError } from "./syncContentKeys.js";
26
- export { describeDocumentRevalidationFailure, describeDocumentSyncSubmitFailure, } from "./syncFailureClassification.js";
27
- export { shouldClearDocumentSyncFailureAfterPass } from "./syncFailureClearance.js";
28
- export { registerDocumentSyncLane, requestDocumentSyncLaneAndWait, } from "./syncLane.js";
29
- export { DOCUMENT_SYNC_TRACE_FRAGMENT, DOCUMENT_SYNC_TRACE_PATTERN, } from "./syncTrace.js";
24
+ export { hasDocumentUpdateEvent, syncRemoteDocument, } from "./sync/index.js";
25
+ export { registerDocumentSyncLane, requestDocumentSyncLaneAndWait, } from "./sync/syncLane.js";
26
+ export { DOCUMENT_SYNC_TRACE_FRAGMENT, DOCUMENT_SYNC_TRACE_PATTERN, } from "./sync/syncTrace.js";
27
+ export { describeDocumentRevalidationFailure, describeDocumentSyncSubmitFailure, } from "./syncFailures/syncFailureClassification.js";
28
+ export { shouldClearDocumentSyncFailureAfterPass } from "./syncFailures/syncFailureClearance.js";
29
+ export { DocumentRawHistoryUnavailableError } from "./syncPlan/syncContentKeys.js";
30
30
  export { createDocumentWriterPublicKeyResolver } from "./writerKeys.js";
31
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,wCAAwC,EAAE,MAAM,uCAAuC,CAAC;AACjG,OAAO,EAEL,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,4CAA4C,CAAC;AAOpD,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,wBAAwB,EACxB,sCAAsC,EACtC,yBAAyB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC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,OAAO,EAAE,uCAAuC,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAEL,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qCAAqC,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export {\n type DocumentSyncUpdateIsolationError,\n type IncomingDocumentSyncUpdateValidator,\n isDocumentSyncUpdateIsolationError,\n validateDocumentSyncUpdateImports,\n} from \"../../data/documents/shared/documentSyncUpdateIsolation\";\nexport {\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n} from \"../../data/documents/shared/projection\";\nexport { persistedDocumentCreateStateFromResponse } from \"../../data/documents/shared/responses\";\nexport {\n type DocumentSyncPullContinuation,\n documentSyncPullContinuationsEqual,\n readPullContinuation,\n} from \"../../data/documents/shared/syncPagination\";\nexport type {\n DocumentCreateAuthor,\n DocumentLinkSetFailureHandler,\n DocumentLinkSetMutationFailure,\n RelinkRemoteDocumentResult,\n} from \"../../data/documents/shared/types\";\nexport {\n DOCUMENT_HISTORY_COMPACTION_MAX_BYTES,\n DOCUMENT_HISTORY_COMPACTION_MAX_ROWS,\n} from \"../../data/sqlite/documentHistoryPersistence\";\nexport {\n clearDocumentSyncFailure,\n invalidateDocumentSyncPullContinuation,\n recordDocumentSyncFailure,\n} from \"../../data/sqlite/documentPersistence\";\nexport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nexport { selectDocumentSyncOutgoingBatch } from \"../../data/sync/documentSyncOutgoingBatch\";\nexport { settleOutgoingPassAndDecideReArm } from \"../../data/sync/outgoingUpdateSettlement\";\nexport {\n didRegainSyncPrerequisites,\n isDatabaseUnavailableError,\n} from \"../../data/sync/syncCoordinator\";\nexport {\n deleteLocalDocumentAttachment,\n deletePendingDocumentAttachment,\n markLocalDocumentAttachmentDetached,\n saveLocalDocumentAttachments,\n savePendingDocumentAttachment,\n} from \"./attachmentPersistence\";\nexport { resolveDocumentCreateAuthor } from \"./author\";\nexport { runSerializedDocumentBlobMutation } from \"./blobMutationLock\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createRemoteDocument,\n documentWriterProjectionFromCreateResponse,\n} from \"./create\";\nexport {\n importDocumentHistoryTailUpdates,\n loadPersistedDocumentContent,\n mergePersistedDocumentHistory,\n} from \"./historyContent\";\nexport { buildMaterializedDocumentLinkSetMutationPlan } from \"./linkSet\";\nexport { relinkRemoteDocument } from \"./linkSetRemote\";\nexport { reclaimDocumentOrphanBlobs } from \"./orphanBlobReclaims\";\nexport {\n enqueuePendingDocumentUpdate,\n listPendingDocumentUpdates,\n} from \"./pendingUpdatePersistence\";\nexport {\n type DiscardedDocumentShellResult,\n deletePersistedDocument,\n discardPersistedDocumentToShell,\n} from \"./persistedDocumentRemoval\";\nexport {\n type AttachmentRemovalRows,\n type AttachmentStagingRows,\n DOCUMENTS_APP_KIND,\n type DocumentRecord,\n type DocumentsPersistence,\n defaultDocumentsPersistence,\n type LocalAttachmentRecord,\n loadPersistedDocumentStoreState,\n type PendingAttachmentRecord,\n type PendingAttachmentUploadIdentity,\n type PendingUpdateInsert,\n type PendingUpdateRecord,\n persistDocumentState,\n type RelinkPersistedDocumentInput,\n runSerializedSqlMutation,\n} from \"./persistence\";\nexport {\n createDocumentProjectionUserKeyResolver,\n type DocumentProjectionKeyRuntime,\n type DocumentProjectionUserKeyResolver,\n didDocumentProjectionKeyRuntimeChange,\n} from \"./projectionKeys\";\nexport {\n buildDocumentPurgeRequest,\n purgeRemoteDocument,\n} from \"./purge\";\nexport type { SyncRemoteDocumentInput } from \"./readOnlySync\";\nexport {\n createDocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntimeGroups,\n type DocumentsWorkflowRuntimeInfra,\n type DocumentsWorkflowRuntimeInput,\n type DocumentsWorkflowRuntimeInputGroups,\n} from \"./runtime\";\nexport {\n hasDocumentUpdateEvent,\n syncRemoteDocument,\n} from \"./sync\";\nexport type { DocumentSyncContainerRekeyBuilder } from \"./syncAttemptState\";\nexport { DocumentRawHistoryUnavailableError } from \"./syncContentKeys\";\nexport {\n describeDocumentRevalidationFailure,\n describeDocumentSyncSubmitFailure,\n type TerminalSubmitFailureHandler,\n} from \"./syncFailureClassification\";\nexport { shouldClearDocumentSyncFailureAfterPass } from \"./syncFailureClearance\";\nexport {\n type DocumentSyncLane,\n registerDocumentSyncLane,\n requestDocumentSyncLaneAndWait,\n} from \"./syncLane\";\nexport type { RekeyPendingUpdate } from \"./syncRecoveryRekey\";\nexport {\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n} from \"./syncTrace\";\nexport { createDocumentWriterPublicKeyResolver } from \"./writerKeys\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,wCAAwC,EAAE,MAAM,uCAAuC,CAAC;AACjG,OAAO,EAEL,kCAAkC,EAClC,oBAAoB,GACrB,MAAM,4CAA4C,CAAC;AAOpD,OAAO,EACL,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,wBAAwB,EACxB,sCAAsC,EACtC,yBAAyB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA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E,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,qCAAqC,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export {\n type DocumentSyncUpdateIsolationError,\n type IncomingDocumentSyncUpdateValidator,\n isDocumentSyncUpdateIsolationError,\n validateDocumentSyncUpdateImports,\n} from \"../../data/documents/shared/documentSyncUpdateIsolation\";\nexport {\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n} from \"../../data/documents/shared/projection\";\nexport { persistedDocumentCreateStateFromResponse } from \"../../data/documents/shared/responses\";\nexport {\n type DocumentSyncPullContinuation,\n documentSyncPullContinuationsEqual,\n readPullContinuation,\n} from \"../../data/documents/shared/syncPagination\";\nexport type {\n DocumentCreateAuthor,\n DocumentLinkSetFailureHandler,\n DocumentLinkSetMutationFailure,\n RelinkRemoteDocumentResult,\n} from \"../../data/documents/shared/types\";\nexport {\n DOCUMENT_HISTORY_COMPACTION_MAX_BYTES,\n DOCUMENT_HISTORY_COMPACTION_MAX_ROWS,\n} from \"../../data/sqlite/documentHistoryPersistence\";\nexport {\n clearDocumentSyncFailure,\n invalidateDocumentSyncPullContinuation,\n recordDocumentSyncFailure,\n} from \"../../data/sqlite/documentPersistence\";\nexport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nexport { selectDocumentSyncOutgoingBatch } from \"../../data/sync/documentSyncOutgoingBatch\";\nexport { settleOutgoingPassAndDecideReArm } from \"../../data/sync/outgoingUpdateSettlement\";\nexport {\n didRegainSyncPrerequisites,\n isDatabaseUnavailableError,\n} from \"../../data/sync/syncCoordinator\";\nexport {\n deleteLocalDocumentAttachment,\n deletePendingDocumentAttachment,\n markLocalDocumentAttachmentDetached,\n saveLocalDocumentAttachments,\n savePendingDocumentAttachment,\n} from \"./attachments/attachmentPersistence\";\nexport { runSerializedDocumentBlobMutation } from \"./attachments/blobMutationLock\";\nexport { reclaimDocumentOrphanBlobs } from \"./attachments/orphanBlobReclaims\";\nexport { resolveDocumentCreateAuthor } from \"./author\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createRemoteDocument,\n documentWriterProjectionFromCreateResponse,\n} from \"./create\";\nexport {\n importDocumentHistoryTailUpdates,\n loadPersistedDocumentContent,\n mergePersistedDocumentHistory,\n} from \"./historyContent\";\nexport { buildMaterializedDocumentLinkSetMutationPlan } from \"./linkSet\";\nexport { relinkRemoteDocument } from \"./linkSet/linkSetRemote\";\nexport {\n enqueuePendingDocumentUpdate,\n listPendingDocumentUpdates,\n} from \"./pendingUpdatePersistence\";\nexport {\n type AttachmentRemovalRows,\n type AttachmentStagingRows,\n DOCUMENTS_APP_KIND,\n type DocumentRecord,\n type DocumentsPersistence,\n defaultDocumentsPersistence,\n type LocalAttachmentRecord,\n loadPersistedDocumentStoreState,\n type PendingAttachmentRecord,\n type PendingAttachmentUploadIdentity,\n type PendingUpdateInsert,\n type PendingUpdateRecord,\n persistDocumentState,\n type RelinkPersistedDocumentInput,\n runSerializedSqlMutation,\n} from \"./persistence\";\nexport {\n createDocumentProjectionUserKeyResolver,\n type DocumentProjectionKeyRuntime,\n type DocumentProjectionUserKeyResolver,\n didDocumentProjectionKeyRuntimeChange,\n} from \"./projectionKeys\";\nexport {\n buildDocumentPurgeRequest,\n purgeRemoteDocument,\n} from \"./purge\";\nexport {\n type DiscardedDocumentShellResult,\n deletePersistedDocument,\n discardPersistedDocumentToShell,\n} from \"./purge/persistedDocumentRemoval\";\nexport {\n createDocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntimeGroups,\n type DocumentsWorkflowRuntimeInfra,\n type DocumentsWorkflowRuntimeInput,\n type DocumentsWorkflowRuntimeInputGroups,\n} from \"./runtime\";\nexport {\n hasDocumentUpdateEvent,\n syncRemoteDocument,\n} from \"./sync\";\nexport type { SyncRemoteDocumentInput } from \"./sync/readOnlySync\";\nexport type { DocumentSyncContainerRekeyBuilder } from \"./sync/syncAttemptState\";\nexport {\n type DocumentSyncLane,\n registerDocumentSyncLane,\n requestDocumentSyncLaneAndWait,\n} from \"./sync/syncLane\";\nexport {\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n} from \"./sync/syncTrace\";\nexport {\n describeDocumentRevalidationFailure,\n describeDocumentSyncSubmitFailure,\n type TerminalSubmitFailureHandler,\n} from \"./syncFailures/syncFailureClassification\";\nexport { shouldClearDocumentSyncFailureAfterPass } from \"./syncFailures/syncFailureClearance\";\nexport { DocumentRawHistoryUnavailableError } from \"./syncPlan/syncContentKeys\";\nexport type { RekeyPendingUpdate } from \"./syncRekeys/syncRecoveryRekey\";\nexport { createDocumentWriterPublicKeyResolver } from \"./writerKeys\";\n"]}
@@ -1,8 +1,8 @@
1
- import { type DocumentContentKeyTarget } from "../../internal/crypto/index.js";
2
- import type { ContainerWriterProjectionResponse, DocumentWriterProjectionResponse } from "../../internal/validators/response/index.js";
3
- import { type BuildDocumentLinkSetMutationPlanInput, type DocumentCreateAuthor, type DocumentLinkSetMutationOperation, type MaterializedDocumentLinkSetMutationPlan, type ProjectionVerificationOptions } from "../../data/documents/shared/types.js";
4
- import type { ExecSql } from "../../data/sqlite/sqlSchema.js";
5
- import { type SubtreePurgeRoot } from "./subtreePurgeScope.js";
1
+ import { type DocumentContentKeyTarget } from "../../../internal/crypto/index.js";
2
+ import type { ContainerWriterProjectionResponse, DocumentWriterProjectionResponse } from "../../../internal/validators/response/index.js";
3
+ import { type BuildDocumentLinkSetMutationPlanInput, type DocumentCreateAuthor, type DocumentLinkSetMutationOperation, type MaterializedDocumentLinkSetMutationPlan, type ProjectionVerificationOptions } from "../../../data/documents/shared/types.js";
4
+ import type { ExecSql } from "../../../data/sqlite/sqlSchema.js";
5
+ import { type SubtreePurgeRoot } from "../purge/subtreePurgeScope.js";
6
6
  export declare function assertDocumentLinkTargetCapacity(currentTargetCount: number): void;
7
7
  export declare function assertDocumentLinkAuthorizationPathCapacity(currentPathLengths: readonly number[], targetPathLength: number): void;
8
8
  export declare function buildMaterializedDocumentLinkSetMutationPlan(input: {
@@ -1,15 +1,15 @@
1
- import { computeAccessManifestHash, computeDocumentContentKeyTargetHash, DOCUMENT_CONTENT_KEY_WRAP_SUITE, deriveDocumentLinkSetManifest, wrapContentKey, } from "../../internal/crypto/index.js";
2
- import { bytesToBase64 } from "../../internal/encoding/index.js";
3
- import { isPlainObject as isPlainRecord } from "../../internal/validators/isPlainObject.js";
4
- import { MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS, MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS, } from "../../internal/validators/util/index.js";
5
- import { assertContainerKekPathCurrent, assertDocumentKekPathsCurrent, } from "../../data/documents/shared/containerKekCurrency.js";
6
- import { buildDocumentLinkSetEventPlan } from "../../data/documents/shared/events.js";
7
- import { assertDocumentWriterProjectionConsistent, collectContainerKeksForDocumentSync, containerPathRefs, currentDocumentTargets, deriveDocumentTargetFromProjection, mergeTargetEnvelopes, readLinkedContainerIdsFromDocumentManifest, unwrapContainerKekPath, unwrapDocumentContentKeyFromWriterProjection, verifiedDocumentWrapTargets, } from "../../data/documents/shared/projection.js";
8
- import { assertDocumentManifestBundleConsistent, describeDocumentTargetKek, sortDocumentTargets, targetKey, uniqueSortedStrings, } from "../../data/documents/shared/readers.js";
9
- import { projectionVerificationOptions, } from "../../data/documents/shared/types.js";
10
- import { readCanonicalRecord } from "../../data/keying/canonicalJson.js";
1
+ import { computeAccessManifestHash, computeDocumentContentKeyTargetHash, DOCUMENT_CONTENT_KEY_WRAP_SUITE, deriveDocumentLinkSetManifest, wrapContentKey, } from "../../../internal/crypto/index.js";
2
+ import { bytesToBase64 } from "../../../internal/encoding/index.js";
3
+ import { isPlainObject as isPlainRecord } from "../../../internal/validators/isPlainObject.js";
4
+ import { MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS, MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS, } from "../../../internal/validators/util/index.js";
5
+ import { assertContainerKekPathCurrent, assertDocumentKekPathsCurrent, } from "../../../data/documents/shared/containerKekCurrency.js";
6
+ import { buildDocumentLinkSetEventPlan } from "../../../data/documents/shared/events.js";
7
+ import { assertDocumentWriterProjectionConsistent, collectContainerKeksForDocumentSync, containerPathRefs, currentDocumentTargets, deriveDocumentTargetFromProjection, mergeTargetEnvelopes, readLinkedContainerIdsFromDocumentManifest, unwrapContainerKekPath, unwrapDocumentContentKeyFromWriterProjection, verifiedDocumentWrapTargets, } from "../../../data/documents/shared/projection.js";
8
+ import { assertDocumentManifestBundleConsistent, describeDocumentTargetKek, sortDocumentTargets, targetKey, uniqueSortedStrings, } from "../../../data/documents/shared/readers.js";
9
+ import { projectionVerificationOptions, } from "../../../data/documents/shared/types.js";
10
+ import { readCanonicalRecord } from "../../../data/keying/canonicalJson.js";
11
+ import { assertSubtreePurgePath, } from "../purge/subtreePurgeScope.js";
11
12
  import { assertDocumentLinkAuthorAccess, verifyDocumentLinkSetCurrentPolicies, } from "./linkSetAuthority.js";
12
- import { assertSubtreePurgePath, } from "./subtreePurgeScope.js";
13
13
  function deriveDocumentLinkSetTargetState(input) {
14
14
  const currentTargets = currentDocumentTargets(input.writerProjection);
15
15
  const currentLinkedContainerIds = readLinkedContainerIdsFromDocumentManifest(input.writerProjection);
@@ -287,4 +287,4 @@ function assertLinkSetWriteKeksCurrent(input, linkedContainerIds) {
287
287
  assertContainerKekPathCurrent(input.targetContainerProjection.containerKeks);
288
288
  }
289
289
  }
290
- //# sourceMappingURL=linkSet.js.map
290
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,mCAAmC,EACnC,+BAA+B,EAG/B,6BAA6B,EAC7B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,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,mCAAmC,CAAC;YACxC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,KAAK,CAAC,eAAe;YAChC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;YACxC,GAAG,mBAAmB;SACvB,CAAC,CACH,CAAC,aAAa;QACf,mEAAmE;QACnE,+DAA+D;QAC/D,OAAO,EAAE,2BAA2B,CAAC;YACnC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,kBAAkB;YACvD,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO;YACvC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;SACzC,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,SAAS,6BAA6B,CACpC,KAGC,EACD,kBAAqC;IAErC,0FAA0F;IAC1F,6BAA6B,CAC3B,KAAK,CAAC,gBAAgB,EACtB,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAC5B,CAAC;IACF,IAAI,KAAK,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QAC/B,6BAA6B,CAC3B,KAAK,CAAC,yBAAyB,CAAC,aAAa,CAC9C,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import {\n computeAccessManifestHash,\n computeDocumentContentKeyTargetHash,\n DOCUMENT_CONTENT_KEY_WRAP_SUITE,\n type DocumentContentKeyTarget,\n type DocumentLinkSetManifestState,\n deriveDocumentLinkSetManifest,\n wrapContentKey,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport { isPlainObject as isPlainRecord } from \"@tearleads/validators/isPlainObject\";\nimport type { DocumentContentKeyTargetEnvelope } from \"@tearleads/validators/request\";\nimport type {\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS,\n MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS,\n} from \"@tearleads/validators/util\";\nimport {\n assertContainerKekPathCurrent,\n assertDocumentKekPathsCurrent,\n} from \"../../../data/documents/shared/containerKekCurrency\";\nimport { buildDocumentLinkSetEventPlan } from \"../../../data/documents/shared/events\";\nimport {\n assertDocumentWriterProjectionConsistent,\n collectContainerKeksForDocumentSync,\n containerPathRefs,\n currentDocumentTargets,\n deriveDocumentTargetFromProjection,\n mergeTargetEnvelopes,\n readLinkedContainerIdsFromDocumentManifest,\n unwrapContainerKekPath,\n unwrapDocumentContentKeyFromWriterProjection,\n verifiedDocumentWrapTargets,\n} from \"../../../data/documents/shared/projection\";\nimport {\n assertDocumentManifestBundleConsistent,\n describeDocumentTargetKek,\n sortDocumentTargets,\n targetKey,\n uniqueSortedStrings,\n} from \"../../../data/documents/shared/readers\";\nimport {\n type BuildDocumentLinkSetMutationPlanInput,\n type DocumentCreateAuthor,\n type DocumentLinkSetMutationOperation,\n type DocumentLinkSetMutationPlan,\n type DocumentLinkSetTargetState,\n type MaterializedDocumentLinkSetMutationPlan,\n type ProjectionVerificationOptions,\n projectionVerificationOptions,\n} from \"../../../data/documents/shared/types\";\nimport { readCanonicalRecord } from \"../../../data/keying/canonicalJson\";\nimport type { PrincipalPolicyCache } from \"../../../data/keyingProjectionVerification\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport {\n assertSubtreePurgePath,\n type SubtreePurgeRoot,\n} from \"../purge/subtreePurgeScope\";\nimport {\n assertDocumentLinkAuthorAccess,\n verifyDocumentLinkSetCurrentPolicies,\n} from \"./linkSetAuthority\";\n\nfunction deriveDocumentLinkSetTargetState(input: {\n operation: DocumentLinkSetMutationOperation;\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n}): DocumentLinkSetTargetState {\n const currentTargets = currentDocumentTargets(input.writerProjection);\n const currentLinkedContainerIds = readLinkedContainerIdsFromDocumentManifest(\n input.writerProjection,\n );\n const target = deriveDocumentTargetFromProjection(\n input.targetContainerProjection,\n );\n const currentTarget = currentTargets.find(\n (candidate) => candidate.containerId === target.containerId,\n );\n\n if (input.operation === \"link\") {\n if (currentTarget) {\n throw new Error(\"Document link target is already linked\");\n }\n assertDocumentLinkTargetCapacity(currentTargets.length);\n assertDocumentLinkAuthorizationPathCapacity(\n input.writerProjection.authorizingContainerPaths.map(\n (projection) => projection.path.length,\n ),\n input.targetContainerProjection.path.length,\n );\n\n return {\n currentTargets,\n linkedContainerIds: uniqueSortedStrings([\n ...currentLinkedContainerIds,\n target.containerId,\n ]),\n target,\n targets: sortDocumentTargets([...currentTargets, target]),\n };\n }\n\n if (!currentTarget) {\n throw new Error(\"Document unlink target is not linked\");\n }\n if (targetKey(currentTarget) !== targetKey(target)) {\n throw new Error(\"Document unlink target projection is stale\");\n }\n\n const linkedContainerIds = currentLinkedContainerIds.filter(\n (containerId) => containerId !== target.containerId,\n );\n if (linkedContainerIds.length === 0) {\n throw new Error(\"Document unlink must leave a linked container\");\n }\n\n return {\n currentTargets,\n linkedContainerIds,\n target,\n targets: currentTargets.filter(\n (candidate) => candidate.containerId !== target.containerId,\n ),\n };\n}\n\nexport function assertDocumentLinkTargetCapacity(\n currentTargetCount: number,\n): void {\n if (currentTargetCount >= MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS) {\n throw new RangeError(\n `A document cannot be linked to more than ${MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS} containers`,\n );\n }\n}\n\nexport function assertDocumentLinkAuthorizationPathCapacity(\n currentPathLengths: readonly number[],\n targetPathLength: number,\n): void {\n const totalReferences = currentPathLengths.reduce(\n (total, length) => total + length,\n targetPathLength,\n );\n if (totalReferences > MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS) {\n throw new RangeError(\n `Document links cannot require more than ${MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS} authorization references`,\n );\n }\n}\n\nasync function wrapDocumentContentKeyForTargets(input: {\n contentKey: Uint8Array;\n contentKeyEpoch: number;\n documentId: string;\n keksByEpochId: ReadonlyMap<string, Uint8Array>;\n targets: readonly DocumentContentKeyTarget[];\n}): Promise<DocumentContentKeyTargetEnvelope[]> {\n return Promise.all(\n sortDocumentTargets(input.targets).map(async (target) => {\n const targetKek = input.keksByEpochId.get(target.containerKeyEpochId);\n if (!targetKek) {\n throw new Error(\n `Document target KEK could not be unwrapped for ${describeDocumentTargetKek(target)}`,\n );\n }\n\n const wrapped = await wrapContentKey(input.contentKey, targetKek, {\n kind: \"Document\",\n objectId: input.documentId,\n contentKeyEpoch: input.contentKeyEpoch,\n containerId: target.containerId,\n containerKeyEpochId: target.containerKeyEpochId,\n });\n return {\n ...target,\n wrappedKey: bytesToBase64(wrapped.ciphertext),\n wrappingMetadata: {\n suite: DOCUMENT_CONTENT_KEY_WRAP_SUITE,\n iv: bytesToBase64(wrapped.iv),\n },\n };\n }),\n );\n}\n\n// Resolve the organization a link/unlink mutation belongs to: the document's\n// own org (from its manifest), which must equal the target container's org —\n// both are owned by the same organization. The acting member's personal org is\n// intentionally not part of this check; a member may link documents within any\n// org they belong to. Returns the document org so the plan stamps it onto the\n// signed event and manifest rather than the author's org.\nasync function resolveDocumentLinkSetMutationOrganization(input: {\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n}): Promise<string> {\n const manifestIdentity = await assertDocumentManifestBundleConsistent({\n bundle: input.writerProjection.documentManifest,\n label: \"Document link-set manifest\",\n });\n if (\n manifestIdentity.organizationId !==\n input.targetContainerProjection.organizationId\n ) {\n throw new Error(\"Document target container organization mismatch\");\n }\n\n return manifestIdentity.organizationId;\n}\n\nfunction readDocumentLinkSetPreviousEpoch(\n writerProjection: DocumentWriterProjectionResponse,\n): number {\n const previousState = writerProjection.documentManifest.state;\n const previousEpoch = isPlainRecord(previousState)\n ? Reflect.get(previousState, \"epoch\")\n : undefined;\n if (\n typeof previousEpoch !== \"number\" ||\n !Number.isInteger(previousEpoch) ||\n previousEpoch <= 0\n ) {\n throw new Error(\"Document link-set previous epoch is invalid\");\n }\n\n return previousEpoch;\n}\n\nasync function buildDocumentLinkSetMutationPlan({\n author,\n blobRewraps,\n contentKeyEpoch,\n eventId = crypto.randomUUID(),\n operation,\n signedAt = new Date().toISOString(),\n targetContainerProjection,\n targetEnvelopes,\n writerProjection,\n}: BuildDocumentLinkSetMutationPlanInput): Promise<DocumentLinkSetMutationPlan> {\n const organizationId = await resolveDocumentLinkSetMutationOrganization({\n targetContainerProjection,\n writerProjection,\n });\n const targetState = deriveDocumentLinkSetTargetState({\n operation,\n targetContainerProjection,\n writerProjection,\n });\n const targetEnvelopesForRequest = mergeTargetEnvelopes(\n targetState.targets,\n targetEnvelopes,\n );\n const targetContainerPathRefs = containerPathRefs(\n targetContainerProjection.path,\n );\n const eventPlan = await buildDocumentLinkSetEventPlan({\n author,\n blobRewraps,\n eventId,\n operation,\n organizationId,\n signedAt,\n targetContainerPathRefs,\n targetState,\n writerProjection,\n });\n const previousEpoch = readDocumentLinkSetPreviousEpoch(writerProjection);\n\n const state: DocumentLinkSetManifestState = {\n version: 1,\n documentId: writerProjection.documentId,\n organizationId,\n epoch: previousEpoch + 1,\n previousManifestHash: writerProjection.documentManifest.manifestHash,\n eventHash: eventPlan.eventHash,\n linkedContainerIds: [...targetState.linkedContainerIds],\n };\n const manifest = await deriveDocumentLinkSetManifest(state);\n const manifestHash = await computeAccessManifestHash(manifest);\n const targetHash = await computeDocumentContentKeyTargetHash(\n targetState.targets,\n );\n\n return {\n body: eventPlan.body,\n contentKeyEpoch,\n documentId: writerProjection.documentId,\n event: eventPlan.event,\n eventHash: eventPlan.eventHash,\n manifest,\n manifestHash,\n operation,\n request: {\n event: readCanonicalRecord(eventPlan.event, \"Document link-set event\"),\n body: readCanonicalRecord(eventPlan.body, \"Document link-set body\"),\n expectedManifestHash: manifestHash,\n manifest: readCanonicalRecord(manifest, \"Document link-set manifest\"),\n targetContainerPathRefs,\n authorizingContainerPathRefs: eventPlan.authorizingContainerPathRefs,\n contentKeyBundle: {\n contentKeyEpoch,\n linkSetManifestHash: manifestHash,\n targetHash,\n targets: targetEnvelopesForRequest,\n },\n },\n state,\n targetHash,\n targets: sortDocumentTargets(targetState.targets),\n };\n}\n\nexport async function buildMaterializedDocumentLinkSetMutationPlan(\n input: {\n author: DocumentCreateAuthor;\n expectedSubtreeRoot?: SubtreePurgeRoot | undefined;\n prepareBlobRewraps: (\n targets: readonly DocumentContentKeyTarget[],\n ) => Promise<BuildDocumentLinkSetMutationPlanInput[\"blobRewraps\"]>;\n contentKey?: Uint8Array | undefined;\n eventId?: string | undefined;\n execSql?: ExecSql | undefined;\n operation: DocumentLinkSetMutationOperation;\n signedAt?: string | undefined;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetSecretKey: Uint8Array;\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<MaterializedDocumentLinkSetMutationPlan> {\n const verificationOptions = projectionVerificationOptions(input);\n const principalPolicyCache: PrincipalPolicyCache = new Map();\n await assertDocumentWriterProjectionConsistent(input.writerProjection, {\n execSql: input.execSql,\n principalPolicyCache,\n ...verificationOptions,\n });\n await verifyDocumentLinkSetCurrentPolicies({\n execSql: input.execSql,\n principalPolicyCache,\n targetContainerProjection: input.targetContainerProjection,\n writerProjection: input.writerProjection,\n ...verificationOptions,\n });\n assertSubtreePurgePath(\n input.targetContainerProjection.path,\n input.expectedSubtreeRoot,\n );\n if (input.resolveProjectionUserKey)\n assertDocumentLinkAuthorAccess({\n ...input,\n principalPolicies: [...principalPolicyCache.values()],\n });\n const targetState = deriveDocumentLinkSetTargetState({\n operation: input.operation,\n targetContainerProjection: input.targetContainerProjection,\n writerProjection: input.writerProjection,\n });\n assertLinkSetWriteKeksCurrent(input, targetState.linkedContainerIds);\n const currentContentKey = await unwrapDocumentContentKeyFromWriterProjection({\n execSql: input.execSql,\n secretKey: input.targetSecretKey,\n writerProjection: input.writerProjection,\n ...verificationOptions,\n });\n const contentKeyRotated = input.operation === \"unlink\";\n const contentKey = contentKeyRotated\n ? (input.contentKey ?? crypto.getRandomValues(new Uint8Array(32)))\n : currentContentKey;\n if (contentKey.byteLength !== 32) {\n throw new Error(\"Document content key must be 32 bytes\");\n }\n // A link carries the existing envelopes forward at the same epoch; an\n // unlink rotates to a fresh key at the next one.\n const contentKeyEpoch =\n input.writerProjection.contentKeyBundle.contentKeyEpoch +\n (contentKeyRotated ? 1 : 0);\n const targetEnvelopes = await buildLinkSetTargetEnvelopes(input, {\n contentKey,\n contentKeyEpoch,\n targetState,\n });\n\n const plan = await buildDocumentLinkSetMutationPlan({\n author: input.author,\n blobRewraps: await input.prepareBlobRewraps(targetState.targets),\n contentKeyEpoch,\n eventId: input.eventId,\n operation: input.operation,\n signedAt: input.signedAt,\n targetContainerProjection: input.targetContainerProjection,\n targetEnvelopes,\n writerProjection: input.writerProjection,\n });\n\n return {\n contentKey,\n contentKeyRotated,\n plan,\n };\n}\n\nasync function buildLinkSetTargetEnvelopes(\n input: Parameters<typeof buildMaterializedDocumentLinkSetMutationPlan>[0],\n wrap: {\n contentKey: Uint8Array;\n contentKeyEpoch: number;\n targetState: ReturnType<typeof deriveDocumentLinkSetTargetState>;\n },\n): Promise<DocumentContentKeyTargetEnvelope[]> {\n const verificationOptions = projectionVerificationOptions(input);\n const sealing = {\n contentKey: wrap.contentKey,\n contentKeyEpoch: wrap.contentKeyEpoch,\n documentId: input.writerProjection.documentId,\n };\n if (input.operation === \"link\") {\n return [\n ...input.writerProjection.contentKeyBundle.targets,\n ...(await wrapDocumentContentKeyForTargets({\n ...sealing,\n keksByEpochId: await unwrapContainerKekPath({\n execSql: input.execSql,\n projection: input.targetContainerProjection,\n secretKey: input.targetSecretKey,\n ...verificationOptions,\n }),\n targets: [wrap.targetState.target],\n })),\n ];\n }\n return wrapDocumentContentKeyForTargets({\n ...sealing,\n keksByEpochId: (\n await collectContainerKeksForDocumentSync({\n execSql: input.execSql,\n secretKey: input.targetSecretKey,\n writerProjection: input.writerProjection,\n ...verificationOptions,\n })\n ).keksByEpochId,\n // The rotated key is wrapped only to verified current heads of the\n // remaining linked containers, never to a server-listed epoch.\n targets: verifiedDocumentWrapTargets({\n linkedContainerIds: wrap.targetState.linkedContainerIds,\n serverTargets: wrap.targetState.targets,\n writerProjection: input.writerProjection,\n }),\n });\n}\n\nfunction assertLinkSetWriteKeksCurrent(\n input: Pick<\n Parameters<typeof buildMaterializedDocumentLinkSetMutationPlan>[0],\n \"writerProjection\" | \"targetContainerProjection\" | \"operation\"\n >,\n linkedContainerIds: readonly string[],\n): void {\n // Unlink can escape a stale branch; only recipients of the successor key must be current.\n assertDocumentKekPathsCurrent(\n input.writerProjection,\n new Set(linkedContainerIds),\n );\n if (input.operation === \"link\") {\n assertContainerKekPathCurrent(\n input.targetContainerProjection.containerKeks,\n );\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
- import { assertContainerAuthorAccess, ContainerAuthorAccessError, } from "../../data/containers/shared/authorAccess.js";
2
- import { readLinkedContainerIdsFromDocumentManifest } from "../../data/documents/shared/projection.js";
3
- import { resolveProjectionVerifier, } from "../../data/documents/shared/types.js";
4
- import { collectContainerWriterProjectionPrincipalPolicies, } from "../../data/keyingProjectionVerification/index.js";
5
- import { documentContainerProjections } from "../../data/keyingProjectionVerification/documentContainerProjections.js";
6
- import { throwKeyingVerificationErrorWithContext } from "../../data/keyingProjectionVerification/error.js";
1
+ import { assertContainerAuthorAccess, ContainerAuthorAccessError, } from "../../../data/containers/shared/authorAccess.js";
2
+ import { readLinkedContainerIdsFromDocumentManifest } from "../../../data/documents/shared/projection.js";
3
+ import { resolveProjectionVerifier, } from "../../../data/documents/shared/types.js";
4
+ import { collectContainerWriterProjectionPrincipalPolicies, } from "../../../data/keyingProjectionVerification/index.js";
5
+ import { documentContainerProjections } from "../../../data/keyingProjectionVerification/documentContainerProjections.js";
6
+ import { throwKeyingVerificationErrorWithContext } from "../../../data/keyingProjectionVerification/error.js";
7
7
  /** Both paths have been verified; a readable proof does not authorize a link. */
8
8
  export function assertDocumentLinkAuthorAccess(input) {
9
9
  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BAAE,MAAM,KAAK,CAAC;QAClE,CAAC;IACH,CAAC;IACD,MAAM,IAAI,0BAA0B,CAClC,+DAA+D,CAChE,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,KAKiC;IAEjC,yBAAyB,CAAC,KAAK,EAAE,oCAAoC,CAAC,CAAC;IACvE,IAAI,KAAK,CAAC,sBAAsB,KAAK,IAAI;QAAE,OAAO;IAClD,IAAI,CAAC;QACH,KAAK,MAAM,UAAU,IAAI;YACvB,KAAK,CAAC,yBAAyB;YAC/B,GAAG,4BAA4B,CAAC,KAAK,CAAC,gBAAgB,CAAC;SACxD,EAAE,CAAC;YACF,MAAM,iDAAiD,CAAC;gBACtD,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;gBAChD,UAAU;gBACV,cAAc,EAAE,KAAK,CAAC,wBAAwB;gBAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;aACvE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uCAAuC,CACrC,KAAK,EACL,sDAAsD,CACvD,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type {\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n assertContainerAuthorAccess,\n ContainerAuthorAccessError,\n} from \"../../../data/containers/shared/authorAccess\";\nimport { readLinkedContainerIdsFromDocumentManifest } from \"../../../data/documents/shared/projection\";\nimport type { DocumentCreateAuthor } from \"../../../data/documents/shared/types\";\nimport {\n type ProjectionVerificationOptions,\n resolveProjectionVerifier,\n} from \"../../../data/documents/shared/types\";\nimport {\n collectContainerWriterProjectionPrincipalPolicies,\n type PrincipalPolicyCache,\n} from \"../../../data/keyingProjectionVerification\";\nimport { documentContainerProjections } from \"../../../data/keyingProjectionVerification/documentContainerProjections\";\nimport { throwKeyingVerificationErrorWithContext } from \"../../../data/keyingProjectionVerification/error\";\nimport type { PrincipalPolicyCheckpointEvidence } from \"../../../data/principals/principalPolicyEvidence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\n\n/** Both paths have been verified; a readable proof does not authorize a link. */\nexport function assertDocumentLinkAuthorAccess(input: {\n author: DocumentCreateAuthor;\n principalPolicies: readonly PrincipalPolicyCheckpointEvidence[];\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n}): void {\n const author = {\n ...input.author,\n organizationId: input.targetContainerProjection.organizationId,\n };\n const permission = {\n author,\n minimumAccess: \"write\" as const,\n principalPolicies: input.principalPolicies,\n };\n assertContainerAuthorAccess({\n ...permission,\n projection: input.targetContainerProjection,\n });\n const linked = readLinkedContainerIdsFromDocumentManifest(\n input.writerProjection,\n );\n for (const projection of documentContainerProjections(\n input.writerProjection,\n )) {\n if (!linked.includes(projection.containerId)) continue;\n try {\n assertContainerAuthorAccess({ ...permission, projection });\n return;\n } catch (error) {\n if (!(error instanceof ContainerAuthorAccessError)) throw error;\n }\n }\n throw new ContainerAuthorAccessError(\n \"Document signer lacks write access through a linked container\",\n );\n}\n\n/** Current write authorization needs full policies for the readable paths. */\nexport async function verifyDocumentLinkSetCurrentPolicies(\n input: {\n execSql?: ExecSql | undefined;\n principalPolicyCache: PrincipalPolicyCache;\n targetContainerProjection: ContainerWriterProjectionResponse;\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<void> {\n resolveProjectionVerifier(input, \"Document link-set current policies\");\n if (input.trustedLocalProjection === true) return;\n try {\n for (const projection of [\n input.targetContainerProjection,\n ...documentContainerProjections(input.writerProjection),\n ]) {\n await collectContainerWriterProjectionPrincipalPolicies({\n execSql: input.execSql,\n principalPolicyCache: input.principalPolicyCache,\n projection,\n resolveUserKey: input.resolveProjectionUserKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n });\n }\n } catch (error) {\n throwKeyingVerificationErrorWithContext(\n error,\n \"Document link-set current policy verification failed\",\n );\n }\n}\n"]}
@@ -1,16 +1,16 @@
1
- import { BLOB_CONTENT_KEY_WRAP_SUITE, wrapContentKey, } from "../../internal/crypto/index.js";
2
- import { bytesToBase64 } from "../../internal/encoding/index.js";
3
- import { deriveDocumentTargetFromProjection, unwrapContainerKekPath, } from "../../data/documents/shared/projection.js";
4
- import { assertEqualBytes, targetKey, } from "../../data/documents/shared/readers.js";
5
- import { projectionVerificationOptions } from "../../data/documents/shared/types.js";
6
- import { readCanonicalJson } from "../../data/keying/canonicalJson.js";
7
- import { requireProjectionUserKeyResolver } from "../../data/keyingProjectionVerification/index.js";
8
- import { ProjectionDependencyUnavailableError } from "../../data/keyingProjectionVerification/dependencyUnavailable.js";
9
- import { documentContainerProjections } from "../../data/keyingProjectionVerification/documentContainerProjections.js";
10
- import { assertProjectionVerificationCurrent } from "../../data/keyingProjectionVerification/types.js";
11
- import { createAttachmentProofReader } from "../blobs/attachmentDecryptor.js";
12
- import { createAttachmentKeyAuthenticator } from "../blobs/attachmentKeyAuthenticator.js";
13
- import { verifyRetainedAttachment } from "../blobs/retainedAttachmentVerification.js";
1
+ import { BLOB_CONTENT_KEY_WRAP_SUITE, wrapContentKey, } from "../../../internal/crypto/index.js";
2
+ import { bytesToBase64 } from "../../../internal/encoding/index.js";
3
+ import { deriveDocumentTargetFromProjection, unwrapContainerKekPath, } from "../../../data/documents/shared/projection.js";
4
+ import { assertEqualBytes, targetKey, } from "../../../data/documents/shared/readers.js";
5
+ import { projectionVerificationOptions } from "../../../data/documents/shared/types.js";
6
+ import { readCanonicalJson } from "../../../data/keying/canonicalJson.js";
7
+ import { requireProjectionUserKeyResolver } from "../../../data/keyingProjectionVerification/index.js";
8
+ import { ProjectionDependencyUnavailableError } from "../../../data/keyingProjectionVerification/dependencyUnavailable.js";
9
+ import { documentContainerProjections } from "../../../data/keyingProjectionVerification/documentContainerProjections.js";
10
+ import { assertProjectionVerificationCurrent } from "../../../data/keyingProjectionVerification/types.js";
11
+ import { createAttachmentProofReader } from "../../blobs/verification/attachmentDecryptor.js";
12
+ import { createAttachmentKeyAuthenticator } from "../../blobs/verification/attachmentKeyAuthenticator.js";
13
+ import { verifyRetainedAttachment } from "../../blobs/verification/retainedAttachmentVerification.js";
14
14
  /** Authenticate the existing bytes before propagating their DEK to a new scope. */
15
15
  export async function prepareDocumentLinkBlobRewraps(input) {
16
16
  const documentId = input.writerProjection.documentId;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkSetBlobRewraps.js","sourceRoot":"","sources":["linkSetBlobRewraps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAG3B,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD,OAAO,EACL,kCAAkC,EAClC,sBAAsB,GACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,SAAS,GACV,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC9F,OAAO,EAAE,oCAAoC,EAAE,MAAM,kEAAkE,CAAC;AACxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,yEAAyE,CAAC;AACvH,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAC;AAEvG,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AACvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAC;AAQnG,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU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C,CAAC;YAC9B,IAAI,QAAQ;gBACV,gBAAgB,CACd,QAAQ,EACR,GAAG,EACH,sDAAsD,CACvD,CAAC;YACJ,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,CAAqB,EAAE,CAAqB;IAClE,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import {\n BLOB_CONTENT_KEY_WRAP_SUITE,\n type DocumentContentKeyTarget,\n type DocumentLinkAccessEventBody,\n wrapContentKey,\n} from \"@tearleads/crypto\";\nimport { bytesToBase64 } from \"@tearleads/encoding\";\nimport type {\n BlobAttachmentSummary,\n ContainerWriterProjectionResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport {\n deriveDocumentTargetFromProjection,\n unwrapContainerKekPath,\n} from \"../../../data/documents/shared/projection\";\nimport {\n assertEqualBytes,\n targetKey,\n} from \"../../../data/documents/shared/readers\";\nimport type {\n DocumentLinkSetMutationApi,\n ProjectionVerificationOptions,\n} from \"../../../data/documents/shared/types\";\nimport { projectionVerificationOptions } from \"../../../data/documents/shared/types\";\nimport { readCanonicalJson } from \"../../../data/keying/canonicalJson\";\nimport { requireProjectionUserKeyResolver } from \"../../../data/keyingProjectionVerification\";\nimport { ProjectionDependencyUnavailableError } from \"../../../data/keyingProjectionVerification/dependencyUnavailable\";\nimport { documentContainerProjections } from \"../../../data/keyingProjectionVerification/documentContainerProjections\";\nimport { assertProjectionVerificationCurrent } from \"../../../data/keyingProjectionVerification/types\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\nimport { createAttachmentProofReader } from \"../../blobs/verification/attachmentDecryptor\";\nimport { createAttachmentKeyAuthenticator } from \"../../blobs/verification/attachmentKeyAuthenticator\";\nimport { verifyRetainedAttachment } from \"../../blobs/verification/retainedAttachmentVerification\";\n\ninterface BlobRewrap {\n blobId: string;\n contentKeyEpoch: number;\n targets: DocumentLinkAccessEventBody[\"blobRewraps\"][number][\"targets\"][number][];\n}\n\n/** Authenticate the existing bytes before propagating their DEK to a new scope. */\nexport async function prepareDocumentLinkBlobRewraps(\n input: {\n apiClient: DocumentLinkSetMutationApi;\n execSql: ExecSql;\n targetContainerProjection: ContainerWriterProjectionResponse;\n targetSecretKey: Uint8Array;\n targets: readonly DocumentContentKeyTarget[];\n writerProjection: DocumentWriterProjectionResponse;\n } & ProjectionVerificationOptions,\n): Promise<DocumentLinkAccessEventBody[\"blobRewraps\"]> {\n const documentId = input.writerProjection.documentId;\n const bindings = await input.apiClient.listDocumentAttachments(documentId);\n // The API refuses the link unless every active binding is rewrapped, so an\n // unavailable listing (offline, or a 409 while a bind is mid-flight) is a\n // retryable availability failure of this mutation, not integrity evidence.\n if (!bindings)\n throw new ProjectionDependencyUnavailableError(\n \"Document attachments are unavailable for relinking\",\n );\n assertProjectionVerificationCurrent(input.stillCurrent);\n if (bindings.length === 0) return [];\n const keks = await collectRelinkKeks(input);\n const authenticateKey = createAttachmentKeyAuthenticator(\n input.apiClient,\n documentId,\n );\n const verifyRetained = createAttachmentProofReader(\n input.apiClient,\n documentId,\n verifyRetainedAttachment,\n );\n const rewrapByBlob = new Map<string, BlobRewrap>();\n for (const binding of bindings) {\n const verification = {\n binding,\n expectedDocumentId: documentId,\n expectedSlotId: binding.slotId,\n execSql: input.execSql,\n resolveProjectionUserKey: requireProjectionUserKeyResolver(\n input.resolveProjectionUserKey,\n \"Attachment relink\",\n ),\n targetSecretKey: input.targetSecretKey,\n stillCurrent: input.stillCurrent,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n writerProjection: input.writerProjection,\n };\n const needsKey = input.targets.some(\n (target) => !retainedTarget(binding, target, documentId),\n );\n const contentKey = needsKey ? await authenticateKey(verification) : null;\n if (!needsKey) await verifyRetained(verification);\n const targets = await Promise.all(\n input.targets.map(async (target) => {\n const previous = retainedTarget(binding, target, documentId);\n if (previous)\n return {\n ...previous,\n ...target,\n wrappingMetadata: readCanonicalJson(\n previous.wrappingMetadata,\n \"Attachment wrap metadata\",\n ),\n };\n const kek = keks.get(targetKey(target));\n if (!kek)\n throw new Error(\n \"Attachment destination is not a verified current container head\",\n );\n if (!contentKey)\n throw new Error(\"Attachment content key is unavailable\");\n return wrapBlobKeyForTarget({\n binding,\n contentKey,\n documentId,\n kek,\n target,\n });\n }),\n );\n const rewrap = rewrapByBlob.get(binding.blobId) ?? {\n blobId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n targets: [],\n };\n if (rewrap.contentKeyEpoch !== binding.contentKeyBundle.contentKeyEpoch)\n throw new Error(\"Attachment content epoch changed during relinking\");\n rewrap.targets.push(...targets);\n rewrapByBlob.set(binding.blobId, rewrap);\n assertProjectionVerificationCurrent(input.stillCurrent);\n }\n return [...rewrapByBlob.values()].sort(compareBlobIds);\n}\n\nasync function wrapBlobKeyForTarget(input: {\n binding: BlobAttachmentSummary;\n contentKey: Uint8Array;\n documentId: string;\n kek: Uint8Array;\n target: DocumentContentKeyTarget;\n}) {\n const { binding, target } = input;\n const wrapped = await wrapContentKey(input.contentKey, input.kek, {\n kind: \"Blob\",\n objectId: binding.blobId,\n contentKeyEpoch: binding.contentKeyBundle.contentKeyEpoch,\n containerId: target.containerId,\n containerKeyEpochId: target.containerKeyEpochId,\n });\n return {\n ...target,\n bindingId: binding.bindingId,\n documentId: input.documentId,\n wrappedKey: bytesToBase64(wrapped.ciphertext),\n wrappingMetadata: {\n suite: BLOB_CONTENT_KEY_WRAP_SUITE,\n iv: bytesToBase64(wrapped.iv),\n },\n };\n}\n\nfunction retainedTarget(\n binding: BlobAttachmentSummary,\n target: DocumentContentKeyTarget,\n documentId: string,\n) {\n return binding.contentKeyBundle.targets.find(\n (candidate) =>\n candidate.bindingId === binding.bindingId &&\n candidate.documentId === documentId &&\n candidate.containerId === target.containerId &&\n candidate.containerKeyEpochId === target.containerKeyEpochId,\n );\n}\n\nasync function collectRelinkKeks(\n input: Parameters<typeof prepareDocumentLinkBlobRewraps>[0],\n): Promise<Map<string, Uint8Array>> {\n const keks = new Map<string, Uint8Array>();\n for (const projection of [\n ...documentContainerProjections(input.writerProjection),\n input.targetContainerProjection,\n ]) {\n const keys = await unwrapContainerKekPath({\n projection,\n secretKey: input.targetSecretKey,\n execSql: input.execSql,\n ...projectionVerificationOptions(input),\n });\n // Every node of this verified path has a current signed head. Historical\n // keyring entries may open source bytes, but never enter the destination map.\n for (const [index, head] of projection.containerKeks.entries()) {\n const target = deriveDocumentTargetFromProjection({\n ...projection,\n containerId: head.containerId,\n path: projection.path.slice(0, index + 1),\n containerKeks: projection.containerKeks.slice(0, index + 1),\n });\n const key = keys.get(target.containerKeyEpochId);\n // A direct child grantee need not possess any ancestor secret.\n if (!key) continue;\n const id = targetKey(target);\n const previous = keks.get(id);\n if (previous)\n assertEqualBytes(\n previous,\n key,\n \"Attachment link projections contain conflicting KEKs\",\n );\n keks.set(id, key);\n }\n }\n return keks;\n}\n\nfunction compareBlobIds(a: { blobId: string }, b: { blobId: string }): number {\n return a.blobId < b.blobId ? -1 : a.blobId > b.blobId ? 1 : 0;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { assertDocumentWriterProjectionConsistent } from "../../data/documents/shared/projection.js";
2
- import { mergeProjectionPolicyEvidence } from "../../data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js";
1
+ import { assertDocumentWriterProjectionConsistent } from "../../../data/documents/shared/projection.js";
2
+ import { mergeProjectionPolicyEvidence } from "../../../data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js";
3
3
  function uniqueManifestBundles(bundles) {
4
4
  const byHash = new Map();
5
5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AAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK;QAAE,OAAO;IAC7C,KAAK,CAAC,SAAS,CAAC,6BAA6B,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["import type {\n AccessManifestBundleWireResponse,\n ContainerKeyingPathResponse,\n ContainerWriterProjectionResponse,\n DocumentLinkSetMutationResponse,\n DocumentWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { assertDocumentWriterProjectionConsistent } from \"../../../data/documents/shared/projection\";\nimport type { DocumentLinkSetMutationOperation } from \"../../../data/documents/shared/types\";\nimport { mergeProjectionPolicyEvidence } from \"../../../data/keyingProjectionVerification/mergeProjectionPolicyEvidence\";\nimport type { ExecSql } from \"../../../data/sqlite/sqlSchema\";\n\ninterface DocumentLinkSetProjectionSeedApi {\n primeDocumentWriterProjection(\n documentId: string,\n projection: DocumentWriterProjectionResponse,\n ): void;\n}\n\nfunction uniqueManifestBundles(\n bundles: readonly AccessManifestBundleWireResponse[],\n): AccessManifestBundleWireResponse[] {\n const byHash = new Map<string, AccessManifestBundleWireResponse>();\n for (const bundle of bundles) {\n if (!byHash.has(bundle.manifestHash)) {\n byHash.set(bundle.manifestHash, bundle);\n }\n }\n\n return [...byHash.values()];\n}\n\nfunction uniqueManifestPaths(\n paths: readonly (readonly AccessManifestBundleWireResponse[])[],\n): AccessManifestBundleWireResponse[][] {\n const byLeafHash = new Map<string, AccessManifestBundleWireResponse[]>();\n for (const path of paths) {\n const leafHash = path.at(-1)?.manifestHash;\n if (!leafHash || byLeafHash.has(leafHash)) {\n continue;\n }\n\n byLeafHash.set(leafHash, [...path]);\n }\n\n return [...byLeafHash.values()];\n}\n\nfunction containerProjectionManifestHistory(\n projection: ContainerKeyingPathResponse,\n): AccessManifestBundleWireResponse[] {\n return projection.containerKeks.flatMap(\n (kek) => kek.containerManifestHistory,\n );\n}\n\nfunction documentProjectionContainerPaths(\n projection: DocumentWriterProjectionResponse,\n): AccessManifestBundleWireResponse[][] {\n return uniqueManifestPaths([\n ...projection.documentManifestContainerPaths,\n ...projection.authorizingContainerPaths.map((path) => path.path),\n ]);\n}\n\nfunction documentProjectionContainerHistory(input: {\n priorProjection: DocumentWriterProjectionResponse;\n targetContainerProjection: ContainerWriterProjectionResponse;\n}): AccessManifestBundleWireResponse[] {\n const priorContainerPaths = documentProjectionContainerPaths(\n input.priorProjection,\n );\n const priorAuthorizingContainerProjections =\n input.priorProjection.authorizingContainerPaths;\n\n return uniqueManifestBundles([\n ...input.priorProjection.documentContainerManifestHistory,\n ...priorContainerPaths.flat(),\n ...priorAuthorizingContainerProjections.flatMap((projection) => [\n ...projection.path,\n ...containerProjectionManifestHistory(projection),\n ]),\n ...input.targetContainerProjection.path,\n ...containerProjectionManifestHistory(input.targetContainerProjection),\n ]);\n}\n\n/**\n * Reconstruct the post-mutation writer projection from a link/unlink response.\n * The response carries the fresh manifest, content-key bundle, and KEK targets;\n * the authorizing container paths change by exactly one entry — link appends\n * the target container's projection, unlink drops it (keyed by containerId).\n * Link does not rotate the content key (only unlink does), but either way the\n * bundle/targets the next write needs come straight from the response. The\n * caller verifies this projection for internal consistency before seeding it,\n * so a wrong reconstruction is discarded rather than cached.\n */\nfunction linkSetWriterProjectionFromResponse(input: {\n operation: DocumentLinkSetMutationOperation;\n priorProjection: DocumentWriterProjectionResponse;\n response: DocumentLinkSetMutationResponse;\n targetContainerId: string;\n targetContainerProjection: ContainerWriterProjectionResponse;\n}): DocumentWriterProjectionResponse {\n // The target container's authorizing path is replaced wholesale: link adds\n // the fresh target projection back, unlink leaves it dropped.\n const retainedPaths = input.priorProjection.authorizingContainerPaths.filter(\n (path) => path.containerId !== input.targetContainerId,\n );\n const authorizingContainerPaths =\n input.operation === \"link\"\n ? [...retainedPaths, input.targetContainerProjection]\n : retainedPaths;\n const documentManifestContainerPaths = uniqueManifestPaths([\n ...documentProjectionContainerPaths(input.priorProjection),\n input.targetContainerProjection.path,\n ]);\n return {\n policyEvidence: mergeProjectionPolicyEvidence([\n input.priorProjection.policyEvidence,\n input.targetContainerProjection.policyEvidence,\n ]),\n authorizingContainerPaths,\n contentKeyBundle: input.response.contentKeyBundle,\n documentId: input.response.id,\n documentContainerManifestHistory: documentProjectionContainerHistory({\n priorProjection: input.priorProjection,\n targetContainerProjection: input.targetContainerProjection,\n }),\n documentKekTargets: input.response.documentKekTargets,\n documentManifest: input.response.accessManifest,\n documentManifestContainerPaths,\n documentManifestHistory: [\n input.priorProjection.documentManifest,\n ...input.priorProjection.documentManifestHistory,\n ],\n };\n}\n\n/**\n * Reconstruct and seed the post-mutation writer projection so the first read\n * after a link/unlink resolves locally instead of a cold GET. Gates the seed on\n * the projection's internal consistency (manifest hash ↔ content-key bundle ↔\n * KEK targets ↔ linked containers); on any mismatch the seed is skipped and the\n * next read falls back to a fetch — the seed is an optimization, never a\n * correctness dependency. The expensive per-path signature re-verification is\n * deliberately not run here: the server already verified the mutation, and the\n * next read re-verifies the projection before any write.\n */\nexport async function seedLinkSetWriterProjection(input: {\n apiClient: DocumentLinkSetProjectionSeedApi;\n execSql?: ExecSql | undefined;\n operation: DocumentLinkSetMutationOperation;\n priorProjection: DocumentWriterProjectionResponse;\n response: DocumentLinkSetMutationResponse;\n targetContainerId: string;\n targetContainerProjection: ContainerWriterProjectionResponse;\n stillCurrent?: (() => boolean) | undefined;\n}): Promise<void> {\n const projection = linkSetWriterProjectionFromResponse({\n operation: input.operation,\n priorProjection: input.priorProjection,\n response: input.response,\n targetContainerId: input.targetContainerId,\n targetContainerProjection: input.targetContainerProjection,\n });\n try {\n await assertDocumentWriterProjectionConsistent(projection, {\n execSql: input.execSql,\n trustedLocalProjection: true,\n });\n } catch {\n return;\n }\n if (input.stillCurrent?.() === false) return;\n input.apiClient.primeDocumentWriterProjection(input.response.id, projection);\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { DocumentCreateAuthor, DocumentLinkSetFailureHandler, DocumentLinkSetMutationApi, DocumentLinkSetMutationOperation, RelinkRemoteDocumentResult } from "../../data/documents/shared/types.js";
2
- import { type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "../../data/keyingProjectionVerification/index.js";
3
- import type { ExecSql } from "../../data/sqlite/sqlSchema.js";
4
- import type { SubtreePurgeRoot } from "./subtreePurgeScope.js";
1
+ import type { DocumentCreateAuthor, DocumentLinkSetFailureHandler, DocumentLinkSetMutationApi, DocumentLinkSetMutationOperation, RelinkRemoteDocumentResult } from "../../../data/documents/shared/types.js";
2
+ import { type ProjectionUserKeyResolver, type ReferencedPrincipalPolicyWarmer } from "../../../data/keyingProjectionVerification/index.js";
3
+ import type { ExecSql } from "../../../data/sqlite/sqlSchema.js";
4
+ import type { SubtreePurgeRoot } from "../purge/subtreePurgeScope.js";
5
5
  export declare function relinkRemoteDocument(input: {
6
6
  beforeSubmit?: (() => Promise<boolean>) | undefined;
7
7
  apiClient: DocumentLinkSetMutationApi;
@@ -1,11 +1,11 @@
1
- import { acknowledgeDocumentMutation } from "../../data/documents/shared/mutationAcknowledgement.js";
2
- import { persistedDocumentLinkSetMutationStateFromResponse } from "../../data/documents/shared/responses.js";
3
- import { nullOnProjectionVerificationCancellation, requireProjectionUserKeyResolver, } from "../../data/keyingProjectionVerification/index.js";
4
- import { recordDocumentAuthorAccessFailure } from "./authorAccessFailure.js";
5
- import { buildMaterializedDocumentLinkSetMutationPlan } from "./linkSet.js";
1
+ import { acknowledgeDocumentMutation } from "../../../data/documents/shared/mutationAcknowledgement.js";
2
+ import { persistedDocumentLinkSetMutationStateFromResponse } from "../../../data/documents/shared/responses.js";
3
+ import { nullOnProjectionVerificationCancellation, requireProjectionUserKeyResolver, } from "../../../data/keyingProjectionVerification/index.js";
4
+ import { recordDocumentAuthorAccessFailure } from "../authorAccessFailure.js";
5
+ import { completeLinkSetMutationRequest } from "../rotationBaseline.js";
6
+ import { buildMaterializedDocumentLinkSetMutationPlan } from "./index.js";
6
7
  import { prepareDocumentLinkBlobRewraps } from "./linkSetBlobRewraps.js";
7
8
  import { seedLinkSetWriterProjection } from "./linkSetProjectionSeed.js";
8
- import { completeLinkSetMutationRequest } from "./rotationBaseline.js";
9
9
  async function submitLinkSetMutation(input) {
10
10
  if (input.stillCurrent?.() === false)
11
11
  return null;