@tearleads/client-sdk 0.1.63 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/documents/blob/shared/projection.js +1 -1
- package/data/documents/blob/shared/projection.js.map +1 -1
- package/data/documents/shared/projectionContentKeys.js +1 -1
- package/data/documents/shared/projectionContentKeys.js.map +1 -1
- package/data/documents/shared/syncResponseAuthorization.js +1 -1
- package/data/documents/shared/syncResponseAuthorization.js.map +1 -1
- package/data/keyingProjectionVerification/{accessManifestCheckpointEnforcement.js → checkpoints/accessManifestCheckpointEnforcement.js} +2 -2
- package/data/keyingProjectionVerification/checkpoints/accessManifestCheckpointEnforcement.js.map +1 -0
- package/data/keyingProjectionVerification/{bundleVerification.js → checkpoints/bundleVerification.js} +5 -5
- package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{checkpointContext.d.ts → checkpoints/checkpointContext.d.ts} +6 -6
- package/data/keyingProjectionVerification/{checkpointContext.js → checkpoints/checkpointContext.js} +6 -6
- package/data/keyingProjectionVerification/checkpoints/checkpointContext.js.map +1 -0
- package/data/keyingProjectionVerification/{manifestCheckpointVerification.js → checkpoints/manifestCheckpointVerification.js} +2 -2
- package/data/keyingProjectionVerification/checkpoints/manifestCheckpointVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerAncestorCitations.js → container/containerAncestorCitations.js} +4 -4
- package/data/keyingProjectionVerification/container/containerAncestorCitations.js.map +1 -0
- package/data/keyingProjectionVerification/{containerCreateManifest.js → container/containerCreateManifest.js} +1 -1
- package/data/keyingProjectionVerification/{containerDestinationVerification.js → container/containerDestinationVerification.js} +4 -4
- package/data/keyingProjectionVerification/container/containerDestinationVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerManifestVerification.js → container/containerManifestVerification.js} +7 -7
- package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerPathVerification.js → container/containerPathVerification.js} +2 -2
- package/data/keyingProjectionVerification/container/containerPathVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{containerProjectionVerification.d.ts → container/containerProjectionVerification.d.ts} +7 -7
- package/data/keyingProjectionVerification/{containerProjectionVerification.js → container/containerProjectionVerification.js} +9 -9
- package/data/keyingProjectionVerification/container/containerProjectionVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentDependencyPaths.d.ts → document/documentDependencyPaths.d.ts} +1 -1
- package/data/keyingProjectionVerification/{documentDependencyPaths.js → document/documentDependencyPaths.js} +3 -3
- package/data/keyingProjectionVerification/document/documentDependencyPaths.js.map +1 -0
- package/data/keyingProjectionVerification/{documentManifestPolicies.js → document/documentManifestPolicies.js} +2 -2
- package/data/keyingProjectionVerification/document/documentManifestPolicies.js.map +1 -0
- package/data/keyingProjectionVerification/{documentManifestPredecessor.js → document/documentManifestPredecessor.js} +1 -1
- package/data/keyingProjectionVerification/{documentManifestVerification.js → document/documentManifestVerification.js} +5 -5
- package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentProjectionVerification.d.ts → document/documentProjectionVerification.d.ts} +4 -4
- package/data/keyingProjectionVerification/{documentProjectionVerification.js → document/documentProjectionVerification.js} +9 -9
- package/data/keyingProjectionVerification/document/documentProjectionVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeCheckpointCurrency.js → documentPurge/documentPurgeCheckpointCurrency.js} +12 -12
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointCurrency.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeCheckpointEnforcement.js → documentPurge/documentPurgeCheckpointEnforcement.js} +2 -2
- package/data/keyingProjectionVerification/documentPurge/documentPurgeCheckpointEnforcement.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeDocumentChainVerification.js → documentPurge/documentPurgeDocumentChainVerification.js} +8 -8
- package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePolicyCheckpoints.js → documentPurge/documentPurgePolicyCheckpoints.js} +2 -2
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCheckpoints.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePolicyCurrency.js → documentPurge/documentPurgePolicyCurrency.js} +4 -4
- package/data/keyingProjectionVerification/documentPurge/documentPurgePolicyCurrency.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgePrincipalEvidence.js → documentPurge/documentPurgePrincipalEvidence.js} +3 -3
- package/data/keyingProjectionVerification/documentPurge/documentPurgePrincipalEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{documentPurgeProofVerification.d.ts → documentPurge/documentPurgeProofVerification.d.ts} +5 -5
- package/data/keyingProjectionVerification/{documentPurgeProofVerification.js → documentPurge/documentPurgeProofVerification.js} +10 -10
- package/data/keyingProjectionVerification/documentPurge/documentPurgeProofVerification.js.map +1 -0
- package/data/keyingProjectionVerification/index.d.ts +4 -4
- package/data/keyingProjectionVerification/index.js +4 -4
- package/data/keyingProjectionVerification/index.js.map +1 -1
- package/data/keyingProjectionVerification/{mergeProjectionPolicyEvidence.js → principalPolicy/mergeProjectionPolicyEvidence.js} +2 -2
- package/data/keyingProjectionVerification/principalPolicy/mergeProjectionPolicyEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{organizationFounderBinding.js → principalPolicy/organizationFounderBinding.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/organizationFounderBinding.js.map +1 -0
- package/data/keyingProjectionVerification/{principalPolicyCache.js → principalPolicy/principalPolicyCache.js} +6 -6
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyCache.js.map +1 -0
- package/data/keyingProjectionVerification/{principalPolicyVerification.js → principalPolicy/principalPolicyVerification.js} +12 -12
- package/data/keyingProjectionVerification/principalPolicy/principalPolicyVerification.js.map +1 -0
- package/data/keyingProjectionVerification/{projectionAuthorizationEvidence.js → principalPolicy/projectionAuthorizationEvidence.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/projectionAuthorizationEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{projectionPolicyEvidence.js → principalPolicy/projectionPolicyEvidence.js} +3 -3
- package/data/keyingProjectionVerification/principalPolicy/projectionPolicyEvidence.js.map +1 -0
- package/data/keyingProjectionVerification/{resolvedPrincipalPolicy.js → principalPolicy/resolvedPrincipalPolicy.js} +6 -6
- package/data/keyingProjectionVerification/principalPolicy/resolvedPrincipalPolicy.js.map +1 -0
- package/package.json +1 -1
- package/stores/container-contents/accessRestorationSweep.js +1 -1
- package/stores/container-contents/accessRestorationSweep.js.map +1 -1
- package/stores/container-contents/containerContentsStore.d.ts +1 -1
- package/stores/container-contents/containerContentsStore.js +12 -12
- package/stores/container-contents/containerContentsStore.js.map +1 -1
- package/stores/container-contents/containerState/containerStateMap.js.map +1 -0
- package/stores/container-contents/{containerStatePersistence.js → containerState/containerStatePersistence.js} +2 -2
- package/stores/container-contents/containerState/containerStatePersistence.js.map +1 -0
- package/stores/container-contents/{missingContainerState.js → containerState/missingContainerState.js} +1 -1
- package/stores/container-contents/containerState/missingContainerState.js.map +1 -0
- package/stores/container-contents/containerState/missingSyncedContainerState.js.map +1 -0
- package/stores/container-contents/{reconcilableContainer.d.ts → containerState/reconcilableContainer.d.ts} +1 -1
- package/stores/container-contents/containerState/reconcilableContainer.js.map +1 -0
- package/stores/container-contents/{documentRecovery.js → documentWork/documentRecovery.js} +6 -6
- package/stores/container-contents/documentWork/documentRecovery.js.map +1 -0
- package/stores/container-contents/{documentRotation.js → documentWork/documentRotation.js} +2 -2
- package/stores/container-contents/documentWork/documentRotation.js.map +1 -0
- package/stores/container-contents/{documentWork.js → documentWork/index.js} +1 -1
- package/stores/container-contents/documentWork/index.js.map +1 -0
- package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js} +3 -3
- package/stores/container-contents/hydration/backgroundHydration.js.map +1 -0
- package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js} +3 -3
- package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -0
- package/stores/container-contents/{startupHydration.js → hydration/startupHydration.js} +3 -3
- package/stores/container-contents/hydration/startupHydration.js.map +1 -0
- package/stores/container-contents/index.d.ts +3 -3
- package/stores/container-contents/index.js +2 -2
- package/stores/container-contents/index.js.map +1 -1
- package/stores/container-contents/localRefresh.js +2 -2
- package/stores/container-contents/localRefresh.js.map +1 -1
- package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js} +4 -4
- package/stores/container-contents/operations/containerPurgeCore.js.map +1 -0
- package/stores/container-contents/operations/emptyTrashOperation.js.map +1 -0
- package/stores/container-contents/{groupRewrapOperation.js → operations/groupRewrapOperation.js} +2 -2
- package/stores/container-contents/operations/groupRewrapOperation.js.map +1 -0
- package/stores/container-contents/{operations.js → operations/index.js} +18 -18
- package/stores/container-contents/operations/index.js.map +1 -0
- package/stores/container-contents/operations/purgeContainerOperation.js.map +1 -0
- package/stores/container-contents/{reportShareFailure.js → operations/reportShareFailure.js} +4 -4
- package/stores/container-contents/operations/reportShareFailure.js.map +1 -0
- package/stores/container-contents/{setContainerIconOperation.js → operations/setContainerIconOperation.js} +6 -6
- package/stores/container-contents/operations/setContainerIconOperation.js.map +1 -0
- package/stores/container-contents/{shareOperations.js → operations/shareOperations.js} +6 -6
- package/stores/container-contents/operations/shareOperations.js.map +1 -0
- package/stores/container-contents/remoteEvents/remoteBackedContainerState.js.map +1 -0
- package/stores/container-contents/{remoteContainerIngestion.js → remoteEvents/remoteContainerIngestion.js} +4 -4
- package/stores/container-contents/remoteEvents/remoteContainerIngestion.js.map +1 -0
- package/stores/container-contents/{remoteEventProjectionInvalidation.js → remoteEvents/remoteEventProjectionInvalidation.js} +1 -1
- package/stores/container-contents/remoteEvents/remoteEventProjectionInvalidation.js.map +1 -0
- package/stores/container-contents/{remoteEventSync.js → remoteEvents/remoteEventSync.js} +4 -4
- package/stores/container-contents/remoteEvents/remoteEventSync.js.map +1 -0
- package/stores/container-contents/{remoteWriteGuards.js → remoteWrites/remoteWriteGuards.js} +2 -2
- package/stores/container-contents/remoteWrites/remoteWriteGuards.js.map +1 -0
- package/stores/container-contents/{remoteWriteQueue.js → remoteWrites/remoteWriteQueue.js} +1 -1
- package/stores/container-contents/remoteWrites/remoteWriteQueue.js.map +1 -0
- package/stores/container-contents/remoteWrites/writeGeneration.js.map +1 -0
- package/stores/container-contents/state.d.ts +1 -1
- package/stores/container-contents/state.js +2 -2
- package/stores/container-contents/state.js.map +1 -1
- package/stores/container-contents/{syncAgent.d.ts → syncAgent/index.d.ts} +2 -2
- package/stores/container-contents/{syncAgent.js → syncAgent/index.js} +14 -14
- package/stores/container-contents/syncAgent/index.js.map +1 -0
- package/stores/container-contents/{metadataSyncSignal.js → syncAgent/metadataSyncSignal.js} +1 -1
- package/stores/container-contents/{metadataSyncSignal.js.map → syncAgent/metadataSyncSignal.js.map} +1 -1
- package/stores/container-contents/{syncAgentTypes.d.ts → syncAgent/syncAgentTypes.d.ts} +5 -5
- package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -0
- package/stores/container-contents/{syncLaneIteration.js → syncAgent/syncLaneIteration.js} +11 -11
- package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -0
- package/stores/container-contents/{existingSystemContainer.js → systemContainers/existingSystemContainer.js} +4 -4
- package/stores/container-contents/systemContainers/existingSystemContainer.js.map +1 -0
- package/stores/container-contents/{organizationMetadataSystemContainer.js → systemContainers/organizationMetadataSystemContainer.js} +2 -2
- package/stores/container-contents/systemContainers/organizationMetadataSystemContainer.js.map +1 -0
- package/stores/container-contents/{systemContainerHydration.js → systemContainers/systemContainerHydration.js} +3 -3
- package/stores/container-contents/systemContainers/systemContainerHydration.js.map +1 -0
- package/stores/container-contents/{systemContainerIcon.js → systemContainers/systemContainerIcon.js} +5 -5
- package/stores/container-contents/systemContainers/systemContainerIcon.js.map +1 -0
- package/stores/container-contents/systemContainers/systemContainerLookup.js.map +1 -0
- package/stores/container-contents/{systemContainerPostCreate.js → systemContainers/systemContainerPostCreate.js} +2 -2
- package/stores/container-contents/systemContainers/systemContainerPostCreate.js.map +1 -0
- package/stores/container-contents/{systemContainerPromotion.js → systemContainers/systemContainerPromotion.js} +1 -1
- package/stores/container-contents/systemContainers/systemContainerPromotion.js.map +1 -0
- package/stores/container-contents/types.d.ts +2 -2
- package/stores/container-contents/types.js.map +1 -1
- package/stores/documents/documentStore/{attachmentSourceUpload.js → attachmentUpload/attachmentSourceUpload.js} +4 -4
- package/stores/documents/documentStore/attachmentUpload/attachmentSourceUpload.js.map +1 -0
- package/stores/documents/documentStore/{attachmentStaging.js → attachmentUpload/attachmentStaging.js} +5 -5
- package/stores/documents/documentStore/attachmentUpload/attachmentStaging.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadAttempt.js → attachmentUpload/attachmentUploadAttempt.js} +2 -2
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadAttempt.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadLane.js → attachmentUpload/attachmentUploadLane.js} +1 -1
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadLane.js.map +1 -0
- package/stores/documents/documentStore/{attachmentUploadResume.js → attachmentUpload/attachmentUploadResume.js} +4 -4
- package/stores/documents/documentStore/attachmentUpload/attachmentUploadResume.js.map +1 -0
- package/stores/documents/documentStore/{attachmentDetachState.js → attachments/attachmentDetachState.js} +1 -1
- package/stores/documents/documentStore/attachments/attachmentDetachState.js.map +1 -0
- package/stores/documents/documentStore/{attachmentHydration.js → attachments/attachmentHydration.js} +5 -5
- package/stores/documents/documentStore/attachments/attachmentHydration.js.map +1 -0
- package/stores/documents/documentStore/{attachmentHydrationCommit.js → attachments/attachmentHydrationCommit.js} +3 -3
- package/stores/documents/documentStore/attachments/attachmentHydrationCommit.js.map +1 -0
- package/stores/documents/documentStore/{attachmentIntents.js → attachments/attachmentIntents.js} +2 -2
- package/stores/documents/documentStore/attachments/attachmentIntents.js.map +1 -0
- package/stores/documents/documentStore/{attachmentMutationPersistence.js → attachments/attachmentMutationPersistence.js} +4 -4
- package/stores/documents/documentStore/attachments/attachmentMutationPersistence.js.map +1 -0
- package/stores/documents/documentStore/attachments/attachmentPersistFollowup.js.map +1 -0
- package/stores/documents/documentStore/{attachmentPersistence.js → attachments/attachmentPersistence.js} +4 -4
- package/stores/documents/documentStore/attachments/attachmentPersistence.js.map +1 -0
- package/stores/documents/documentStore/{attachmentRemoval.js → attachments/attachmentRemoval.js} +11 -11
- package/stores/documents/documentStore/attachments/attachmentRemoval.js.map +1 -0
- package/stores/documents/documentStore/attachments/attachmentSnapshot.js.map +1 -0
- package/stores/documents/documentStore/{attachmentWriteGeneration.js → attachments/attachmentWriteGeneration.js} +2 -2
- package/stores/documents/documentStore/attachments/attachmentWriteGeneration.js.map +1 -0
- package/stores/documents/documentStore/{attachments.js → attachments/index.js} +11 -11
- package/stores/documents/documentStore/attachments/index.js.map +1 -0
- package/stores/documents/documentStore/{documentHistoryCompaction.js → history/documentHistoryCompaction.js} +4 -4
- package/stores/documents/documentStore/history/documentHistoryCompaction.js.map +1 -0
- package/stores/documents/documentStore/{durableDocumentReload.js → history/durableDocumentReload.js} +6 -6
- package/stores/documents/documentStore/history/durableDocumentReload.js.map +1 -0
- package/stores/documents/documentStore/{historyRebuild.js → history/historyRebuild.js} +6 -6
- package/stores/documents/documentStore/history/historyRebuild.js.map +1 -0
- package/stores/documents/{documentStore.d.ts → documentStore/index.d.ts} +5 -5
- package/stores/documents/{documentStore.js → documentStore/index.js} +18 -18
- package/stores/documents/documentStore/index.js.map +1 -0
- package/stores/documents/documentStore/{deferredInitialUpdate.js → initialization/deferredInitialUpdate.js} +9 -9
- package/stores/documents/documentStore/initialization/deferredInitialUpdate.js.map +1 -0
- package/stores/documents/documentStore/{initialization.js → initialization/index.js} +14 -14
- package/stores/documents/documentStore/initialization/index.js.map +1 -0
- package/stores/documents/documentStore/{initializationAttachments.js → initialization/initializationAttachments.js} +1 -1
- package/stores/documents/documentStore/initialization/initializationAttachments.js.map +1 -0
- package/stores/documents/documentStore/{initializationHistory.js → initialization/initializationHistory.js} +3 -3
- package/stores/documents/documentStore/initialization/initializationHistory.js.map +1 -0
- package/stores/documents/documentStore/{initializationRecovery.js → initialization/initializationRecovery.js} +7 -7
- package/stores/documents/documentStore/initialization/initializationRecovery.js.map +1 -0
- package/stores/documents/documentStore/mutationIdentityRevalidation.js.map +1 -1
- package/stores/documents/documentStore/mutations.js +2 -2
- package/stores/documents/documentStore/mutations.js.map +1 -1
- package/stores/documents/documentStore/pendingUpdateRefusal.js +1 -1
- package/stores/documents/documentStore/pendingUpdateRefusal.js.map +1 -1
- package/stores/documents/documentStore/persistence.js +3 -3
- package/stores/documents/documentStore/persistence.js.map +1 -1
- package/stores/documents/documentStore/{rotation.js → rotation/index.js} +14 -14
- package/stores/documents/documentStore/rotation/index.js.map +1 -0
- package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js} +2 -2
- package/stores/documents/documentStore/rotation/rotationProvenance.js.map +1 -0
- package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js} +9 -9
- package/stores/documents/documentStore/rotation/rotationSettlement.js.map +1 -0
- package/stores/documents/documentStore/rows.js +2 -2
- package/stores/documents/documentStore/rows.js.map +1 -1
- package/stores/documents/documentStore/state.js +1 -1
- package/stores/documents/documentStore/state.js.map +1 -1
- package/stores/documents/documentStore/{sync.js → sync/index.js} +7 -7
- package/stores/documents/documentStore/sync/index.js.map +1 -0
- package/stores/documents/documentStore/{pullContinuationInvalidation.js → sync/pullContinuationInvalidation.js} +3 -3
- package/stores/documents/documentStore/sync/pullContinuationInvalidation.js.map +1 -0
- package/stores/documents/documentStore/{remoteRevalidationTelemetry.js → sync/remoteRevalidationTelemetry.js} +1 -1
- package/stores/documents/documentStore/sync/remoteRevalidationTelemetry.js.map +1 -0
- package/stores/documents/documentStore/sync/remoteWork.js.map +1 -0
- package/stores/documents/documentStore/sync/syncAcceptedUpdateIds.js.map +1 -0
- package/stores/documents/documentStore/{syncAttachmentSettlement.js → sync/syncAttachmentSettlement.js} +3 -3
- package/stores/documents/documentStore/sync/syncAttachmentSettlement.js.map +1 -0
- package/stores/documents/documentStore/{syncAttachments.js → sync/syncAttachments.js} +7 -7
- package/stores/documents/documentStore/sync/syncAttachments.js.map +1 -0
- package/stores/documents/documentStore/{syncDetachedAttachments.js → sync/syncDetachedAttachments.js} +7 -7
- package/stores/documents/documentStore/sync/syncDetachedAttachments.js.map +1 -0
- package/stores/documents/documentStore/{syncFinalize.js → sync/syncFinalize.js} +9 -9
- package/stores/documents/documentStore/sync/syncFinalize.js.map +1 -0
- package/stores/documents/documentStore/sync/syncGeneration.js.map +1 -0
- package/stores/documents/documentStore/{syncOutgoingCoverage.js → sync/syncOutgoingCoverage.js} +4 -4
- package/stores/documents/documentStore/sync/syncOutgoingCoverage.js.map +1 -0
- package/stores/documents/documentStore/{syncRemoteSignals.js → sync/syncRemoteSignals.js} +4 -4
- package/stores/documents/documentStore/sync/syncRemoteSignals.js.map +1 -0
- package/stores/documents/documentStore/{syncRequest.js → sync/syncRequest.js} +8 -8
- package/stores/documents/documentStore/sync/syncRequest.js.map +1 -0
- package/stores/documents/documentStore/{syncShared.js → sync/syncShared.js} +8 -8
- package/stores/documents/documentStore/sync/syncShared.js.map +1 -0
- package/stores/documents/documentStore/{syncUpdateImport.js → sync/syncUpdateImport.js} +3 -3
- package/stores/documents/documentStore/sync/syncUpdateImport.js.map +1 -0
- package/stores/documents/documentStore/{versionCoverage.js → sync/versionCoverage.js} +1 -1
- package/stores/documents/index.d.ts +1 -1
- package/stores/documents/index.js +1 -1
- package/stores/local-projection/localProjectionStore.d.ts +1 -1
- package/stores/local-projection/localProjectionStore.js +1 -1
- package/stores/local-projection/localProjectionStore.js.map +1 -1
- package/stores/local-projection/registry.d.ts +1 -1
- package/stores/local-projection/types.d.ts +1 -1
- package/workflows/blobs/hydration/decrypt.js +1 -1
- package/workflows/blobs/hydration/decrypt.js.map +1 -1
- package/workflows/container-contents/container-state/{createAdoption.js → create/createAdoption.js} +6 -6
- package/workflows/container-contents/container-state/create/createAdoption.js.map +1 -0
- package/workflows/container-contents/container-state/{createChild.js → create/createChild.js} +7 -7
- package/workflows/container-contents/container-state/create/createChild.js.map +1 -0
- package/workflows/container-contents/container-state/{createIntentDepth.js → create/createIntentDepth.js} +2 -2
- package/workflows/container-contents/container-state/create/createIntentDepth.js.map +1 -0
- package/workflows/container-contents/container-state/create/createIntentSettlement.js.map +1 -0
- package/workflows/container-contents/container-state/{createIntentSync.js → create/createIntentSync.js} +7 -7
- package/workflows/container-contents/container-state/create/createIntentSync.js.map +1 -0
- package/workflows/container-contents/container-state/{createTerminalFailure.js → create/createTerminalFailure.js} +2 -2
- package/workflows/container-contents/container-state/create/createTerminalFailure.js.map +1 -0
- package/workflows/container-contents/container-state/{createWithMetadata.js → create/createWithMetadata.js} +9 -9
- package/workflows/container-contents/container-state/create/createWithMetadata.js.map +1 -0
- package/workflows/container-contents/container-state/{createWithMetadataPlan.js → create/createWithMetadataPlan.js} +4 -4
- package/workflows/container-contents/container-state/create/createWithMetadataPlan.js.map +1 -0
- package/workflows/container-contents/container-state/{localPurgeScope.js → purge/localPurgeScope.js} +1 -1
- package/workflows/container-contents/container-state/purge/localPurgeScope.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTree.js → purge/purgeTree.js} +5 -5
- package/workflows/container-contents/container-state/purge/purgeTree.js.map +1 -0
- package/workflows/container-contents/container-state/purge/purgeTreeCollection.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTreeContainerDeletion.js → purge/purgeTreeContainerDeletion.js} +1 -1
- package/workflows/container-contents/container-state/purge/purgeTreeContainerDeletion.js.map +1 -0
- package/workflows/container-contents/container-state/{purgeTreeScope.js → purge/purgeTreeScope.js} +8 -8
- package/workflows/container-contents/container-state/purge/purgeTreeScope.js.map +1 -0
- package/workflows/container-contents/container-state/{readLocalPurgeScope.js → purge/readLocalPurgeScope.js} +3 -3
- package/workflows/container-contents/container-state/purge/readLocalPurgeScope.js.map +1 -0
- package/workflows/container-contents/container-state/remote.js +2 -2
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/{groupGrantVerification.js → share/groupGrantVerification.js} +8 -8
- package/workflows/container-contents/container-state/share/groupGrantVerification.js.map +1 -0
- package/workflows/container-contents/container-state/{groupShareEpoch.js → share/groupShareEpoch.js} +2 -2
- package/workflows/container-contents/container-state/share/groupShareEpoch.js.map +1 -0
- package/workflows/container-contents/container-state/{share.js → share/index.js} +8 -8
- package/workflows/container-contents/container-state/share/index.js.map +1 -0
- package/workflows/container-contents/container-state/{sharePersistence.js → share/sharePersistence.js} +3 -3
- package/workflows/container-contents/container-state/share/sharePersistence.js.map +1 -0
- package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js +1 -1
- package/workflows/container-contents/documentDiscovery/documentDiscoveryApply.js.map +1 -1
- package/workflows/container-contents/documentDiscovery/index.js +1 -1
- package/workflows/container-contents/documentDiscovery/index.js.map +1 -1
- package/workflows/container-contents/metadata/metadataSyncErrors.js +1 -1
- package/workflows/container-contents/metadata/metadataSyncErrors.js.map +1 -1
- package/workflows/container-contents/remoteHydration/destination/destinationPrefetch.js.map +1 -0
- package/workflows/container-contents/remoteHydration/destination/destinationRoleCache.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{destinationRootReload.js → destination/destinationRootReload.js} +1 -1
- package/workflows/container-contents/remoteHydration/destination/destinationRootReload.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{replacementBinding.js → destination/replacementBinding.js} +5 -5
- package/workflows/container-contents/remoteHydration/destination/replacementBinding.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{verifiedDestination.js → destination/verifiedDestination.js} +9 -9
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -0
- package/workflows/container-contents/remoteHydration/index.js +4 -4
- package/workflows/container-contents/remoteHydration/index.js.map +1 -1
- package/workflows/container-contents/remoteHydration/lanes/childIndex.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{laneFetchMarkers.js → lanes/laneFetchMarkers.js} +1 -1
- package/workflows/container-contents/remoteHydration/lanes/laneFetchMarkers.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{parentLaneFetch.js → lanes/parentLaneFetch.js} +2 -2
- package/workflows/container-contents/remoteHydration/lanes/parentLaneFetch.js.map +1 -0
- package/workflows/container-contents/remoteHydration/lanes/parentLaneQueue.js.map +1 -0
- package/workflows/container-contents/remoteHydration/principalPolicyCache.js +1 -1
- package/workflows/container-contents/remoteHydration/principalPolicyCache.js.map +1 -1
- package/workflows/container-contents/remoteHydration/reconciliation.js +2 -2
- package/workflows/container-contents/remoteHydration/reconciliation.js.map +1 -1
- package/workflows/container-contents/remoteHydration/remoteContainers/containerStateFingerprint.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{insertRemoteContainer.js → remoteContainers/insertRemoteContainer.js} +6 -6
- package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{remoteContainerPageHydration.js → remoteContainers/remoteContainerPageHydration.js} +7 -7
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerPageHydration.js.map +1 -0
- package/workflows/container-contents/remoteHydration/{remoteContainerState.js → remoteContainers/remoteContainerState.js} +9 -9
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -0
- package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerTimestamps.js.map +1 -0
- package/workflows/container-contents/remoteHydration/tombstoneApplication.js +2 -2
- package/workflows/container-contents/remoteHydration/tombstoneApplication.js.map +1 -1
- package/workflows/containers/child/{createProjection.d.ts → create/createProjection.d.ts} +2 -2
- package/workflows/containers/child/{createProjection.js → create/createProjection.js} +2 -2
- package/workflows/containers/child/create/createProjection.js.map +1 -0
- package/workflows/containers/child/{createSubmission.d.ts → create/createSubmission.d.ts} +7 -7
- package/workflows/containers/child/{createSubmission.js → create/createSubmission.js} +2 -2
- package/workflows/containers/child/create/createSubmission.js.map +1 -0
- package/workflows/containers/child/{create.d.ts → create/index.d.ts} +5 -5
- package/workflows/containers/child/{create.js → create/index.js} +15 -15
- package/workflows/containers/child/create/index.js.map +1 -0
- package/workflows/containers/child/{move.d.ts → move/index.d.ts} +5 -5
- package/workflows/containers/child/{move.js → move/index.js} +12 -12
- package/workflows/containers/child/move/index.js.map +1 -0
- package/workflows/containers/child/{moveArtifacts.js → move/moveArtifacts.js} +3 -3
- package/workflows/containers/child/move/moveArtifacts.js.map +1 -0
- package/workflows/containers/child/{moveRotation.js → move/moveRotation.js} +3 -3
- package/workflows/containers/child/move/moveRotation.js.map +1 -0
- package/workflows/containers/child/{moveWraps.js → move/moveWraps.js} +5 -5
- package/workflows/containers/child/move/moveWraps.js.map +1 -0
- package/workflows/containers/child/mutationSubmit.js +1 -1
- package/workflows/containers/child/mutationSubmit.js.map +1 -1
- package/workflows/containers/child/{carriedDescendantRekeys.js → rekey/carriedDescendantRekeys.js} +4 -4
- package/workflows/containers/child/rekey/carriedDescendantRekeys.js.map +1 -0
- package/workflows/containers/child/{rekey.d.ts → rekey/index.d.ts} +6 -6
- package/workflows/containers/child/{rekey.js → rekey/index.js} +13 -13
- package/workflows/containers/child/rekey/index.js.map +1 -0
- package/workflows/containers/child/{keyringOverrideLineage.d.ts → rekey/keyringOverrideLineage.d.ts} +1 -1
- package/workflows/containers/child/{keyringOverrideLineage.js → rekey/keyringOverrideLineage.js} +1 -1
- package/workflows/containers/child/{rekeyProjection.d.ts → rekey/rekeyProjection.d.ts} +2 -2
- package/workflows/containers/child/{rekeyProjection.js → rekey/rekeyProjection.js} +3 -3
- package/workflows/containers/child/rekey/rekeyProjection.js.map +1 -0
- package/workflows/containers/child/{rekeyRemote.d.ts → rekey/rekeyRemote.d.ts} +6 -6
- package/workflows/containers/child/{rekeyRemote.js → rekey/rekeyRemote.js} +2 -2
- package/workflows/containers/child/rekey/rekeyRemote.js.map +1 -0
- package/workflows/containers/child/revoke.js +5 -5
- package/workflows/containers/child/revoke.js.map +1 -1
- package/workflows/containers/child/{replacementPrincipalPolicyReferences.js → rotation/replacementPrincipalPolicyReferences.js} +2 -2
- package/workflows/containers/child/rotation/replacementPrincipalPolicyReferences.js.map +1 -0
- package/workflows/containers/child/{rotationContext.js → rotation/rotationContext.js} +5 -5
- package/workflows/containers/child/rotation/rotationContext.js.map +1 -0
- package/workflows/containers/child/{rotationPrincipalPolicies.js → rotation/rotationPrincipalPolicies.js} +2 -2
- package/workflows/containers/child/rotation/rotationPrincipalPolicies.js.map +1 -0
- package/workflows/containers/child/{rotationWraps.js → rotation/rotationWraps.js} +1 -1
- package/workflows/containers/child/rotation/rotationWraps.js.map +1 -0
- package/workflows/containers/child/{currentShareGrantMutation.js → share/currentShareGrantMutation.js} +6 -6
- package/workflows/containers/child/share/currentShareGrantMutation.js.map +1 -0
- package/workflows/containers/child/{currentSharePrincipalPolicy.js → share/currentSharePrincipalPolicy.js} +10 -10
- package/workflows/containers/child/share/currentSharePrincipalPolicy.js.map +1 -0
- package/workflows/containers/child/{share.d.ts → share/index.d.ts} +8 -8
- package/workflows/containers/child/{share.js → share/index.js} +10 -10
- package/workflows/containers/child/share/index.js.map +1 -0
- package/workflows/containers/child/{runtimeCurrentGroupShare.js → share/runtimeCurrentGroupShare.js} +6 -6
- package/workflows/containers/child/share/runtimeCurrentGroupShare.js.map +1 -0
- package/workflows/containers/child/{shareAncestorRepair.js → share/shareAncestorRepair.js} +4 -4
- package/workflows/containers/child/share/shareAncestorRepair.js.map +1 -0
- package/workflows/containers/child/{shareMaterialization.d.ts → share/shareMaterialization.d.ts} +5 -5
- package/workflows/containers/child/{shareMaterialization.js → share/shareMaterialization.js} +7 -7
- package/workflows/containers/child/share/shareMaterialization.js.map +1 -0
- package/workflows/containers/child/{sharePlanCore.d.ts → share/sharePlanCore.d.ts} +7 -7
- package/workflows/containers/child/{sharePlanCore.js → share/sharePlanCore.js} +6 -6
- package/workflows/containers/child/share/sharePlanCore.js.map +1 -0
- package/workflows/containers/child/{sharePrincipalPolicy.d.ts → share/sharePrincipalPolicy.d.ts} +9 -9
- package/workflows/containers/child/{sharePrincipalPolicy.js → share/sharePrincipalPolicy.js} +13 -13
- package/workflows/containers/child/share/sharePrincipalPolicy.js.map +1 -0
- package/workflows/containers/child/share/shareProjection.js.map +1 -0
- package/workflows/containers/index.d.ts +10 -10
- package/workflows/containers/index.js +10 -10
- package/workflows/containers/index.js.map +1 -1
- package/workflows/documents/linkSet/linkSetAuthority.js +1 -1
- package/workflows/documents/linkSet/linkSetAuthority.js.map +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
- package/workflows/documents/linkSet/linkSetProjectionSeed.js +1 -1
- package/workflows/documents/linkSet/linkSetProjectionSeed.js.map +1 -1
- package/workflows/documents/purge/index.js +1 -1
- package/workflows/documents/purge/index.js.map +1 -1
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js +2 -2
- package/workflows/documents/syncRekeys/syncAutomaticContainerRekeys.js.map +1 -1
- package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js +1 -1
- package/workflows/organizations/rematerialization/precedingPrincipalRematerialization.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerialization.js +5 -5
- package/workflows/organizations/rematerialization/principalContainerRematerialization.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationPlanning.js.map +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js +1 -1
- package/workflows/organizations/rematerialization/principalContainerRematerializationTargets.js.map +1 -1
- package/workflows/principals/policyCache/index.js +1 -1
- package/workflows/principals/policyCache/index.js.map +1 -1
- package/workflows/principals/policyRepair.js +1 -1
- package/workflows/principals/policyRepair.js.map +1 -1
- package/workflows/registration/organizationProvisioningArtifacts.d.ts +1 -1
- package/workflows/registration/provisioningBootstrapBuilders.js +1 -1
- package/data/keyingProjectionVerification/accessManifestCheckpointEnforcement.js.map +0 -1
- package/data/keyingProjectionVerification/bundleVerification.js.map +0 -1
- package/data/keyingProjectionVerification/checkpointContext.js.map +0 -1
- package/data/keyingProjectionVerification/containerAncestorCitations.js.map +0 -1
- package/data/keyingProjectionVerification/containerDestinationVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerManifestVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerPathVerification.js.map +0 -1
- package/data/keyingProjectionVerification/containerProjectionVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentDependencyPaths.js.map +0 -1
- package/data/keyingProjectionVerification/documentManifestPolicies.js.map +0 -1
- package/data/keyingProjectionVerification/documentManifestVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentProjectionVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeCheckpointCurrency.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeCheckpointEnforcement.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeDocumentChainVerification.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePolicyCheckpoints.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePolicyCurrency.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgePrincipalEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/documentPurgeProofVerification.js.map +0 -1
- package/data/keyingProjectionVerification/manifestCheckpointVerification.js.map +0 -1
- package/data/keyingProjectionVerification/mergeProjectionPolicyEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/organizationFounderBinding.js.map +0 -1
- package/data/keyingProjectionVerification/principalPolicyCache.js.map +0 -1
- package/data/keyingProjectionVerification/principalPolicyVerification.js.map +0 -1
- package/data/keyingProjectionVerification/projectionAuthorizationEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/projectionPolicyEvidence.js.map +0 -1
- package/data/keyingProjectionVerification/resolvedPrincipalPolicy.js.map +0 -1
- package/stores/container-contents/backgroundHydration.js.map +0 -1
- package/stores/container-contents/containerPurgeCore.js.map +0 -1
- package/stores/container-contents/containerStateMap.js.map +0 -1
- package/stores/container-contents/containerStatePersistence.js.map +0 -1
- package/stores/container-contents/documentRecovery.js.map +0 -1
- package/stores/container-contents/documentRotation.js.map +0 -1
- package/stores/container-contents/documentWork.js.map +0 -1
- package/stores/container-contents/emptyTrashOperation.js.map +0 -1
- package/stores/container-contents/existingSystemContainer.js.map +0 -1
- package/stores/container-contents/groupRewrapOperation.js.map +0 -1
- package/stores/container-contents/missingContainerState.js.map +0 -1
- package/stores/container-contents/missingSyncedContainerState.js.map +0 -1
- package/stores/container-contents/operations.js.map +0 -1
- package/stores/container-contents/organizationMetadataSystemContainer.js.map +0 -1
- package/stores/container-contents/purgeContainerOperation.js.map +0 -1
- package/stores/container-contents/reconcilableContainer.js.map +0 -1
- package/stores/container-contents/remoteBackedContainerState.js.map +0 -1
- package/stores/container-contents/remoteContainerIngestion.js.map +0 -1
- package/stores/container-contents/remoteEventProjectionInvalidation.js.map +0 -1
- package/stores/container-contents/remoteEventSync.js.map +0 -1
- package/stores/container-contents/remoteHydrationRequest.js.map +0 -1
- package/stores/container-contents/remoteWriteGuards.js.map +0 -1
- package/stores/container-contents/remoteWriteQueue.js.map +0 -1
- package/stores/container-contents/reportShareFailure.js.map +0 -1
- package/stores/container-contents/setContainerIconOperation.js.map +0 -1
- package/stores/container-contents/shareOperations.js.map +0 -1
- package/stores/container-contents/startupHydration.js.map +0 -1
- package/stores/container-contents/syncAgent.js.map +0 -1
- package/stores/container-contents/syncAgentTypes.js.map +0 -1
- package/stores/container-contents/syncLaneIteration.js.map +0 -1
- package/stores/container-contents/systemContainerHydration.js.map +0 -1
- package/stores/container-contents/systemContainerIcon.js.map +0 -1
- package/stores/container-contents/systemContainerLookup.js.map +0 -1
- package/stores/container-contents/systemContainerPostCreate.js.map +0 -1
- package/stores/container-contents/systemContainerPromotion.js.map +0 -1
- package/stores/container-contents/writeGeneration.js.map +0 -1
- package/stores/documents/documentStore/attachmentDetachState.js.map +0 -1
- package/stores/documents/documentStore/attachmentHydration.js.map +0 -1
- package/stores/documents/documentStore/attachmentHydrationCommit.js.map +0 -1
- package/stores/documents/documentStore/attachmentIntents.js.map +0 -1
- package/stores/documents/documentStore/attachmentMutationPersistence.js.map +0 -1
- package/stores/documents/documentStore/attachmentPersistFollowup.js.map +0 -1
- package/stores/documents/documentStore/attachmentPersistence.js.map +0 -1
- package/stores/documents/documentStore/attachmentRemoval.js.map +0 -1
- package/stores/documents/documentStore/attachmentSnapshot.js.map +0 -1
- package/stores/documents/documentStore/attachmentSourceUpload.js.map +0 -1
- package/stores/documents/documentStore/attachmentStaging.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadAttempt.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadLane.js.map +0 -1
- package/stores/documents/documentStore/attachmentUploadResume.js.map +0 -1
- package/stores/documents/documentStore/attachmentWriteGeneration.js.map +0 -1
- package/stores/documents/documentStore/attachments.js.map +0 -1
- package/stores/documents/documentStore/deferredInitialUpdate.js.map +0 -1
- package/stores/documents/documentStore/documentHistoryCompaction.js.map +0 -1
- package/stores/documents/documentStore/durableDocumentReload.js.map +0 -1
- package/stores/documents/documentStore/historyRebuild.js.map +0 -1
- package/stores/documents/documentStore/initialization.js.map +0 -1
- package/stores/documents/documentStore/initializationAttachments.js.map +0 -1
- package/stores/documents/documentStore/initializationHistory.js.map +0 -1
- package/stores/documents/documentStore/initializationRecovery.js.map +0 -1
- package/stores/documents/documentStore/pullContinuationInvalidation.js.map +0 -1
- package/stores/documents/documentStore/remoteRevalidationTelemetry.js.map +0 -1
- package/stores/documents/documentStore/remoteWork.js.map +0 -1
- package/stores/documents/documentStore/rotation.js.map +0 -1
- package/stores/documents/documentStore/rotationProvenance.js.map +0 -1
- package/stores/documents/documentStore/rotationSettlement.js.map +0 -1
- package/stores/documents/documentStore/sync.js.map +0 -1
- package/stores/documents/documentStore/syncAcceptedUpdateIds.js.map +0 -1
- package/stores/documents/documentStore/syncAttachmentSettlement.js.map +0 -1
- package/stores/documents/documentStore/syncAttachments.js.map +0 -1
- package/stores/documents/documentStore/syncDetachedAttachments.js.map +0 -1
- package/stores/documents/documentStore/syncFinalize.js.map +0 -1
- package/stores/documents/documentStore/syncGeneration.js.map +0 -1
- package/stores/documents/documentStore/syncOutgoingCoverage.js.map +0 -1
- package/stores/documents/documentStore/syncRemoteSignals.js.map +0 -1
- package/stores/documents/documentStore/syncRequest.js.map +0 -1
- package/stores/documents/documentStore/syncShared.js.map +0 -1
- package/stores/documents/documentStore/syncUpdateImport.js.map +0 -1
- package/stores/documents/documentStore.js.map +0 -1
- package/workflows/container-contents/container-state/createAdoption.js.map +0 -1
- package/workflows/container-contents/container-state/createChild.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentDepth.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentSettlement.js.map +0 -1
- package/workflows/container-contents/container-state/createIntentSync.js.map +0 -1
- package/workflows/container-contents/container-state/createTerminalFailure.js.map +0 -1
- package/workflows/container-contents/container-state/createWithMetadata.js.map +0 -1
- package/workflows/container-contents/container-state/createWithMetadataPlan.js.map +0 -1
- package/workflows/container-contents/container-state/groupGrantVerification.js.map +0 -1
- package/workflows/container-contents/container-state/groupShareEpoch.js.map +0 -1
- package/workflows/container-contents/container-state/localPurgeScope.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTree.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeCollection.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeContainerDeletion.js.map +0 -1
- package/workflows/container-contents/container-state/purgeTreeScope.js.map +0 -1
- package/workflows/container-contents/container-state/readLocalPurgeScope.js.map +0 -1
- package/workflows/container-contents/container-state/share.js.map +0 -1
- package/workflows/container-contents/container-state/sharePersistence.js.map +0 -1
- package/workflows/container-contents/remoteHydration/childIndex.js.map +0 -1
- package/workflows/container-contents/remoteHydration/containerStateFingerprint.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationPrefetch.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationRoleCache.js.map +0 -1
- package/workflows/container-contents/remoteHydration/destinationRootReload.js.map +0 -1
- package/workflows/container-contents/remoteHydration/insertRemoteContainer.js.map +0 -1
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +0 -1
- package/workflows/container-contents/remoteHydration/parentLaneFetch.js.map +0 -1
- package/workflows/container-contents/remoteHydration/parentLaneQueue.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerPageHydration.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerState.js.map +0 -1
- package/workflows/container-contents/remoteHydration/remoteContainerTimestamps.js.map +0 -1
- package/workflows/container-contents/remoteHydration/replacementBinding.js.map +0 -1
- package/workflows/container-contents/remoteHydration/verifiedDestination.js.map +0 -1
- package/workflows/containers/child/carriedDescendantRekeys.js.map +0 -1
- package/workflows/containers/child/create.js.map +0 -1
- package/workflows/containers/child/createProjection.js.map +0 -1
- package/workflows/containers/child/createSubmission.js.map +0 -1
- package/workflows/containers/child/currentShareGrantMutation.js.map +0 -1
- package/workflows/containers/child/currentSharePrincipalPolicy.js.map +0 -1
- package/workflows/containers/child/move.js.map +0 -1
- package/workflows/containers/child/moveArtifacts.js.map +0 -1
- package/workflows/containers/child/moveRotation.js.map +0 -1
- package/workflows/containers/child/moveWraps.js.map +0 -1
- package/workflows/containers/child/rekey.js.map +0 -1
- package/workflows/containers/child/rekeyProjection.js.map +0 -1
- package/workflows/containers/child/rekeyRemote.js.map +0 -1
- package/workflows/containers/child/replacementPrincipalPolicyReferences.js.map +0 -1
- package/workflows/containers/child/rotationContext.js.map +0 -1
- package/workflows/containers/child/rotationPrincipalPolicies.js.map +0 -1
- package/workflows/containers/child/rotationWraps.js.map +0 -1
- package/workflows/containers/child/runtimeCurrentGroupShare.js.map +0 -1
- package/workflows/containers/child/share.js.map +0 -1
- package/workflows/containers/child/shareAncestorRepair.js.map +0 -1
- package/workflows/containers/child/shareMaterialization.js.map +0 -1
- package/workflows/containers/child/sharePlanCore.js.map +0 -1
- package/workflows/containers/child/sharePrincipalPolicy.js.map +0 -1
- package/workflows/containers/child/shareProjection.js.map +0 -1
- /package/data/keyingProjectionVerification/{containerCreateManifest.js.map → container/containerCreateManifest.js.map} +0 -0
- /package/data/keyingProjectionVerification/{documentContainerProjections.js → document/documentContainerProjections.js} +0 -0
- /package/data/keyingProjectionVerification/{documentContainerProjections.js.map → document/documentContainerProjections.js.map} +0 -0
- /package/data/keyingProjectionVerification/{documentManifestPredecessor.js.map → document/documentManifestPredecessor.js.map} +0 -0
- /package/stores/container-contents/{containerStateMap.js → containerState/containerStateMap.js} +0 -0
- /package/stores/container-contents/{missingSyncedContainerState.js → containerState/missingSyncedContainerState.js} +0 -0
- /package/stores/container-contents/{reconcilableContainer.js → containerState/reconcilableContainer.js} +0 -0
- /package/stores/container-contents/{remoteHydrationRefresh.js → hydration/remoteHydrationRefresh.js} +0 -0
- /package/stores/container-contents/{remoteHydrationRefresh.js.map → hydration/remoteHydrationRefresh.js.map} +0 -0
- /package/stores/container-contents/{emptyTrashOperation.js → operations/emptyTrashOperation.js} +0 -0
- /package/stores/container-contents/{purgeContainerOperation.js → operations/purgeContainerOperation.js} +0 -0
- /package/stores/container-contents/{remoteBackedContainerState.js → remoteEvents/remoteBackedContainerState.js} +0 -0
- /package/stores/container-contents/{writeGeneration.js → remoteWrites/writeGeneration.js} +0 -0
- /package/stores/container-contents/{syncAgentTypes.js → syncAgent/syncAgentTypes.js} +0 -0
- /package/stores/container-contents/{systemContainerLookup.js → systemContainers/systemContainerLookup.js} +0 -0
- /package/stores/documents/documentStore/{attachmentPersistFollowup.js → attachments/attachmentPersistFollowup.js} +0 -0
- /package/stores/documents/documentStore/{attachmentSnapshot.js → attachments/attachmentSnapshot.js} +0 -0
- /package/stores/documents/documentStore/{remoteWork.js → sync/remoteWork.js} +0 -0
- /package/stores/documents/documentStore/{syncAcceptedUpdateIds.js → sync/syncAcceptedUpdateIds.js} +0 -0
- /package/stores/documents/documentStore/{syncGeneration.js → sync/syncGeneration.js} +0 -0
- /package/stores/documents/documentStore/{versionCoverage.js.map → sync/versionCoverage.js.map} +0 -0
- /package/workflows/container-contents/container-state/{createIntentSettlement.js → create/createIntentSettlement.js} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.d.ts → purge/purgeProgress.d.ts} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.js → purge/purgeProgress.js} +0 -0
- /package/workflows/container-contents/container-state/{purgeProgress.js.map → purge/purgeProgress.js.map} +0 -0
- /package/workflows/container-contents/container-state/{purgeTreeCollection.js → purge/purgeTreeCollection.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{destinationPrefetch.js → destination/destinationPrefetch.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{destinationRoleCache.js → destination/destinationRoleCache.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{childIndex.js → lanes/childIndex.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{parentLaneQueue.js → lanes/parentLaneQueue.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{containerStateFingerprint.js → remoteContainers/containerStateFingerprint.js} +0 -0
- /package/workflows/container-contents/remoteHydration/{remoteContainerTimestamps.js → remoteContainers/remoteContainerTimestamps.js} +0 -0
- /package/workflows/containers/child/{keyringOverrideLineage.js.map → rekey/keyringOverrideLineage.js.map} +0 -0
- /package/workflows/containers/child/{shareProjection.js → share/shareProjection.js} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { encodeVersionVector, versionVectorsEqual } from "
|
|
2
|
-
import { createDocumentWriterPublicKeyResolver, readPullContinuation, resolveDocumentCreateAuthor, syncRemoteDocument, validateDocumentSyncUpdateImports, } from "
|
|
3
|
-
import { createRuntimePrincipalPolicyWarmer } from "
|
|
4
|
-
import { requestDocumentStoreSync } from "
|
|
5
|
-
import { installRebuiltDocument } from "
|
|
6
|
-
import { chainIdentityWrite } from "
|
|
7
|
-
import { listPendingUpdates } from "
|
|
8
|
-
import {
|
|
1
|
+
import { encodeVersionVector, versionVectorsEqual } from "../../../../internal/loro/index.js";
|
|
2
|
+
import { createDocumentWriterPublicKeyResolver, readPullContinuation, resolveDocumentCreateAuthor, syncRemoteDocument, validateDocumentSyncUpdateImports, } from "../../../../workflows/documents/index.js";
|
|
3
|
+
import { createRuntimePrincipalPolicyWarmer } from "../../../../workflows/principals/runtimePolicyWarmer.js";
|
|
4
|
+
import { requestDocumentStoreSync } from "../../registry.js";
|
|
5
|
+
import { installRebuiltDocument } from "../history/historyRebuild.js";
|
|
6
|
+
import { chainIdentityWrite } from "../identityWriteChain.js";
|
|
7
|
+
import { listPendingUpdates } from "../persistence.js";
|
|
8
|
+
import { createStoredDocument } from "../storedDocument.js";
|
|
9
|
+
import { runDocumentRemoteWork } from "../sync/remoteWork.js";
|
|
10
|
+
import { captureDocumentStoreAttachmentSyncGeneration, captureDocumentStoreSyncLaneGeneration, isDocumentStoreSyncGenerationCurrent, } from "../sync/syncGeneration.js";
|
|
11
|
+
import { deleteUpstreamDeletedDocument } from "../sync/syncRequest.js";
|
|
12
|
+
import { documentIncomingUpdateIsolationFailureHandler } from "../sync/syncShared.js";
|
|
13
|
+
import { importSyncedDocumentUpdates } from "../sync/syncUpdateImport.js";
|
|
9
14
|
import { assertExactDocumentHistory, importProvenOrdinaryPendingHistory, } from "./rotationProvenance.js";
|
|
10
15
|
import { invalidatePullContinuationBeforeRotation, RotationPendingUpdatesChangedError, settleOrdinaryDocumentUpdatesBeforeRotation, } from "./rotationSettlement.js";
|
|
11
|
-
import { createStoredDocument } from "./storedDocument.js";
|
|
12
|
-
import { captureDocumentStoreAttachmentSyncGeneration, captureDocumentStoreSyncLaneGeneration, isDocumentStoreSyncGenerationCurrent, } from "./syncGeneration.js";
|
|
13
|
-
import { deleteUpstreamDeletedDocument } from "./syncRequest.js";
|
|
14
|
-
import { documentIncomingUpdateIsolationFailureHandler } from "./syncShared.js";
|
|
15
|
-
import { importSyncedDocumentUpdates } from "./syncUpdateImport.js";
|
|
16
16
|
function ordinaryRawHistoryUpdates(updates) {
|
|
17
17
|
return updates.filter((update) => update.checkpointKind === undefined);
|
|
18
18
|
}
|
|
@@ -304,4 +304,4 @@ export function assertDocumentStoreCanRotateContentKey(state) {
|
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
//# sourceMappingURL=
|
|
307
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,qCAAqC,EAErC,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,kCAAkC,EAAE,MAAM,sDAAsD,CAAC;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,4CAA4C,EAC5C,sCAAsC,EAGtC,oCAAoC,GACrC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,6CAA6C,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EACL,0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E,gEAAgE;gBAChE,IACE,CAAC,CACC,KAAK,YAAY,kCAAkC;oBACnD,KAAK,YAAY,4BAA4B,CAC9C;oBACD,OAAO,IAAI,CAAC;oBACZ,CAAC,oCAAoC,CAAC,KAAK,EAAE,UAAU,CAAC,EACxD,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { encodeVersionVector, versionVectorsEqual } from \"@tearleads/loro\";\nimport {\n createDocumentWriterPublicKeyResolver,\n type DocumentSyncPullContinuation,\n readPullContinuation,\n resolveDocumentCreateAuthor,\n syncRemoteDocument,\n validateDocumentSyncUpdateImports,\n} from \"../../../../workflows/documents\";\nimport { createRuntimePrincipalPolicyWarmer } from \"../../../../workflows/principals/runtimePolicyWarmer\";\nimport { requestDocumentStoreSync } from \"../../registry\";\nimport { installRebuiltDocument } from \"../history/historyRebuild\";\nimport { chainIdentityWrite } from \"../identityWriteChain\";\nimport { listPendingUpdates } from \"../persistence\";\nimport type { DocumentState, DocumentStoreState } from \"../state\";\nimport { createStoredDocument } from \"../storedDocument\";\nimport { runDocumentRemoteWork } from \"../sync/remoteWork\";\nimport {\n captureDocumentStoreAttachmentSyncGeneration,\n captureDocumentStoreSyncLaneGeneration,\n type DocumentStoreSyncGeneration,\n type DocumentStoreSyncLaneGeneration,\n isDocumentStoreSyncGenerationCurrent,\n} from \"../sync/syncGeneration\";\nimport { deleteUpstreamDeletedDocument } from \"../sync/syncRequest\";\nimport { documentIncomingUpdateIsolationFailureHandler } from \"../sync/syncShared\";\nimport { importSyncedDocumentUpdates } from \"../sync/syncUpdateImport\";\nimport {\n assertExactDocumentHistory,\n importProvenOrdinaryPendingHistory,\n} from \"./rotationProvenance\";\nimport {\n invalidatePullContinuationBeforeRotation,\n RotationPendingUpdatesChangedError,\n settleOrdinaryDocumentUpdatesBeforeRotation,\n} from \"./rotationSettlement\";\n\nfunction ordinaryRawHistoryUpdates<T extends { checkpointKind?: string }>(\n updates: readonly T[],\n): T[] {\n return updates.filter((update) => update.checkpointKind === undefined);\n}\n\nfunction assertRotationRecoveryPrerequisites(state: DocumentStoreState) {\n if (state.persistence.supportsAtomicRecoveryHistoryPruning !== true) {\n throw new Error(\n \"Rotation raw-history recovery requires an adapter with atomic local-history pruning\",\n );\n }\n const author = resolveDocumentCreateAuthor(state.runtime);\n const encapsulationKeyPair = state.runtime.crypto.encapsulationKeyPair;\n const documentId = state.record?.documentId;\n if (\n !author ||\n !encapsulationKeyPair ||\n !documentId ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n throw new Error(\n \"Rotation requires verified full-history recovery, but remote sync prerequisites are unavailable\",\n );\n }\n return { author, documentId, encapsulationKeyPair };\n}\n\nfunction assertRotationRecoveryGeneration(input: {\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}): void {\n if (!isDocumentStoreSyncGenerationCurrent(input.state, input.generation)) {\n throw new Error(\n \"Document changed during rotation recovery; retry key rotation\",\n );\n }\n}\n\nfunction rotationIncomingUpdateIsolation(input: {\n currentDocument: DocumentState;\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}) {\n return {\n onIncomingUpdateIsolationFailure:\n documentIncomingUpdateIsolationFailureHandler(\n input.state,\n input.generation,\n ),\n validateIncomingUpdates: async (\n result: Pick<\n NonNullable<Awaited<ReturnType<typeof syncRemoteDocument>>>,\n \"decryptedUpdates\" | \"response\"\n >,\n ) => {\n await validateDocumentSyncUpdateImports({\n currentDocument: input.currentDocument,\n decryptedUpdates: result.decryptedUpdates,\n responseUpdates: result.response.updates,\n });\n const decryptedUpdates = ordinaryRawHistoryUpdates(\n result.decryptedUpdates,\n );\n const ordinaryUpdateIds = new Set(\n decryptedUpdates.map((update) => update.id),\n );\n await validateDocumentSyncUpdateImports({\n currentDocument: input.currentDocument,\n decryptedUpdates,\n responseUpdates: result.response.updates.filter((update) =>\n ordinaryUpdateIds.has(update.id),\n ),\n });\n },\n };\n}\n\nasync function pullVerifiedRawHistoryForRotation(input: {\n currentRecord: NonNullable<DocumentStoreState[\"record\"]>;\n generation: DocumentStoreSyncGeneration;\n rebuiltDocument: DocumentState;\n state: DocumentStoreState;\n}) {\n const { author, documentId, encapsulationKeyPair } =\n assertRotationRecoveryPrerequisites(input.state);\n let pullContinuation: DocumentSyncPullContinuation | undefined;\n const seenPullCursors = new Set<string>();\n let planningRecord = input.currentRecord;\n let writerProjection =\n input.state.writerProjection?.documentId === documentId\n ? input.state.writerProjection\n : undefined;\n\n while (true) {\n let abandonReason: string | null = null;\n const synced = await syncRemoteDocument({\n apiClient: input.state.runtime.apiClient,\n author,\n documentId,\n execSql: input.state.runtime.infra.execSql,\n historyMode: \"raw\",\n isRemoteSyncBlocked: input.state.runtime.util.isRemoteSyncBlocked,\n localVersionVector: null,\n minLsn: input.currentRecord.lastCommitLsn ?? undefined,\n onRemoteDocumentDeleted: ({ commitPurgeProof, documentId }) =>\n deleteUpstreamDeletedDocument(\n input.state,\n input.generation,\n input.currentRecord,\n documentId,\n commitPurgeProof,\n ),\n // Recorded, never parked: this pass submits no writes, so it plans no\n // ancestor repair and cannot abandon as `inaccessible`.\n onSyncAbandoned: (reason) => {\n abandonReason = reason;\n },\n ...rotationIncomingUpdateIsolation({\n currentDocument: input.rebuiltDocument,\n generation: input.generation,\n state: input.state,\n }),\n onSyncTrace: (line) => input.state.runtime.util.log(`Documents: ${line}`),\n pendingUpdates: [],\n persistedState: planningRecord,\n pullContinuation,\n resolveProjectionUserKey: input.state.resolveProjectionUserKey,\n resolveWriterPublicKey: createDocumentWriterPublicKeyResolver({\n logPrefix: \"Documents\",\n runtime: input.state.runtime,\n writerKeyLabel: \"writer key\",\n }),\n targetSecretKey: encapsulationKeyPair.secretKey,\n warmReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n input.state.runtime,\n ),\n writerProjection,\n });\n if (!synced) {\n throw new Error(\n `Rotation raw-history recovery could not complete (${abandonReason ?? \"sync did not finish\"}); key rotation was not started`,\n );\n }\n\n assertRotationRecoveryGeneration(input);\n\n importSyncedDocumentUpdates(\n input.rebuiltDocument,\n ordinaryRawHistoryUpdates(synced.decryptedUpdates),\n );\n if (!synced.hasIncompletePull) return synced;\n\n const nextContinuation = readPullContinuation(synced.response);\n if (!nextContinuation) {\n throw new Error(\n \"Rotation raw-history recovery ended before the retained history was complete\",\n );\n }\n if (seenPullCursors.has(nextContinuation.cursor)) {\n throw new Error(\n \"Rotation raw-history recovery encountered a repeated pull cursor\",\n );\n }\n seenPullCursors.add(nextContinuation.cursor);\n pullContinuation = nextContinuation;\n planningRecord = { ...planningRecord, ...synced.persistedState };\n writerProjection = synced.writerProjection;\n }\n}\n\nasync function collectVerifiedRawHistoryForRotation(input: {\n currentRecord: NonNullable<DocumentStoreState[\"record\"]>;\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}) {\n const consumedPullContinuation = input.state.pullContinuation;\n const writerProjectionGeneration = input.state.writerProjectionGeneration;\n const rebuiltDocument = await createStoredDocument(input.state);\n try {\n const synced = await pullVerifiedRawHistoryForRotation({\n ...input,\n rebuiltDocument,\n });\n return {\n consumedPullContinuation,\n currentRecord: input.currentRecord,\n rebuiltDocument,\n synced,\n writerProjectionGeneration,\n };\n } catch (error) {\n rebuiltDocument.free();\n throw error;\n }\n}\n\nclass RotationDocumentChangedError extends Error {}\n\nfunction assertCapturedDocumentCurrent(input: {\n capturedVersion: string;\n currentDocument: DocumentState;\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}): void {\n assertRotationRecoveryGeneration(input);\n if (\n !versionVectorsEqual(\n encodeVersionVector(input.currentDocument),\n input.capturedVersion,\n )\n ) {\n throw new RotationDocumentChangedError(\n \"Document changed during rotation recovery; retry key rotation\",\n );\n }\n}\n\nfunction currentRotationRecoveryRecord(\n state: DocumentStoreState,\n): NonNullable<DocumentStoreState[\"record\"]> {\n if (state.record) return state.record;\n throw new Error(\n \"Document changed during rotation recovery; retry key rotation\",\n );\n}\n\nfunction installRotationRecovery(input: {\n capturedVersion: string;\n collection: Awaited<ReturnType<typeof collectVerifiedRawHistoryForRotation>>;\n currentDoc: DocumentState;\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}) {\n const { capturedVersion, collection, currentDoc, generation, state } = input;\n const installation = state.writeChain\n .catch(() => undefined)\n .then(() =>\n chainIdentityWrite(state, async () => {\n assertCapturedDocumentCurrent({\n capturedVersion,\n currentDocument: currentDoc,\n generation,\n state,\n });\n assertExactDocumentHistory({\n currentDocument: currentDoc,\n rebuiltDocument: collection.rebuiltDocument,\n });\n return installRebuiltDocument({\n consumedPullContinuation: collection.consumedPullContinuation,\n currentRecord: collection.currentRecord,\n generation,\n rebuiltDoc: collection.rebuiltDocument,\n state,\n synced: collection.synced,\n writerProjectionGeneration: collection.writerProjectionGeneration,\n });\n }),\n );\n // Only the checked local install occupies the write queue. Network recovery\n // uses the remote queue, so an outage cannot hold new edits hostage.\n state.writeChain = installation.then(\n () => undefined,\n () => undefined,\n );\n return installation;\n}\n\nasync function recoverFullHistoryForRotation(\n state: DocumentStoreState,\n laneGeneration: DocumentStoreSyncLaneGeneration,\n): Promise<Uint8Array> {\n assertRotationRecoveryPrerequisites(state);\n await invalidatePullContinuationBeforeRotation(state);\n const currentDoc = state.doc;\n const currentRecord = state.record;\n if (!currentDoc || !currentRecord) {\n throw new Error(\n \"Document must finish loading before its content key can rotate\",\n );\n }\n // The teardown guard for the recovery's terminal-failure handler: captured\n // before the pull so a discard (row 21) racing this preflight invalidates\n // it, and the stale handler cannot resurrect a deleted failure row.\n const generation = captureDocumentStoreAttachmentSyncGeneration(\n state,\n currentDoc,\n laneGeneration,\n );\n if (!generation) {\n throw new Error(\n \"Document changed during rotation recovery; retry key rotation\",\n );\n }\n\n const capturedVersion = encodeVersionVector(currentDoc);\n let settlementRequiresRetry = false;\n\n // A raw recovery starts from an empty scratch document, bypasses untrusted\n // rotation-baseline redirects, drains every retained page in memory, and\n // publishes nothing until all response updates have validated. Checkpoints\n // are authenticated and decrypted but are not reconstruction inputs: the\n // original ordinary update stream is the source of truth in this mode.\n let collection = await collectVerifiedRawHistoryForRotation({\n currentRecord,\n generation,\n state,\n });\n\n try {\n assertCapturedDocumentCurrent({\n capturedVersion,\n currentDocument: currentDoc,\n generation,\n state,\n });\n const pendingUpdates = await listPendingUpdates(state);\n assertCapturedDocumentCurrent({\n capturedVersion,\n currentDocument: currentDoc,\n generation,\n state,\n });\n const verifiedOrdinaryVersion = importProvenOrdinaryPendingHistory({\n currentDocument: currentDoc,\n pendingUpdates,\n rebuiltDocument: collection.rebuiltDocument,\n });\n if (pendingUpdates.some((update) => update.sourceVersionVector == null)) {\n // The first raw pass proves the exact ordinary frontier before any local\n // row can be published. Pull raw history again after settlement so the\n // installed snapshot also includes remote work that raced that submit.\n await settleOrdinaryDocumentUpdatesBeforeRotation(\n state,\n verifiedOrdinaryVersion,\n pendingUpdates,\n generation,\n );\n assertCapturedDocumentCurrent({\n capturedVersion,\n currentDocument: currentDoc,\n generation,\n state,\n });\n const definitiveCollection = await collectVerifiedRawHistoryForRotation({\n currentRecord: currentRotationRecoveryRecord(state),\n generation,\n state,\n });\n collection.rebuiltDocument.free();\n collection = definitiveCollection;\n }\n const installed = await installRotationRecovery({\n capturedVersion,\n collection,\n currentDoc,\n generation,\n state,\n });\n settlementRequiresRetry = installed.settlementRequiresRetry;\n if (settlementRequiresRetry) {\n throw new Error(\n \"Rotation raw-history recovery was superseded during its atomic install; retry key rotation\",\n );\n }\n return installed.fullHistorySnapshot;\n } finally {\n if (state.doc !== collection.rebuiltDocument) {\n collection.rebuiltDocument.free();\n }\n if (settlementRequiresRetry) {\n requestDocumentStoreSync(state);\n }\n }\n}\n\n/**\n * Wait for prior local writes and serialize with other remote work. Edits can\n * continue during the pull; the checked install rejects a changed document so\n * a stale recovery cannot replace them. This preflight can then be retried.\n */\nexport function assertDocumentStoreCanRotateContentKey(\n state: DocumentStoreState,\n): Promise<Uint8Array> {\n const laneGeneration = captureDocumentStoreSyncLaneGeneration(state);\n const generation = captureDocumentStoreAttachmentSyncGeneration(\n state,\n state.doc,\n laneGeneration,\n );\n return runDocumentRemoteWork(state, async () => {\n await state.writeChain.catch(() => undefined);\n if (\n !generation ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n throw new Error(\n \"Document changed before rotation recovery; retry key rotation\",\n );\n }\n for (let attempt = 0; ; attempt += 1) {\n try {\n return await recoverFullHistoryForRotation(state, laneGeneration);\n } catch (error) {\n // Autosaves and conflict re-keying can invalidate the proven frontier.\n // Repeat the complete proof without blocking new local edits; repeated\n // changes remain bounded and leave the durable queue retryable.\n if (\n !(\n error instanceof RotationPendingUpdatesChangedError ||\n error instanceof RotationDocumentChangedError\n ) ||\n attempt >= 2 ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n throw error;\n }\n }\n }\n });\n}\n"]}
|
package/stores/documents/documentStore/{rotationProvenance.js → rotation/rotationProvenance.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { base64ToBytes } from "
|
|
2
|
-
import { encodeVersionVector, exportFullHistoryIdentity, getImportBlobMetadata, importUpdates, satisfiesVersionVector, updateMatchesDocumentHistory, versionVectorsEqual, } from "
|
|
1
|
+
import { base64ToBytes } from "../../../../internal/encoding/index.js";
|
|
2
|
+
import { encodeVersionVector, exportFullHistoryIdentity, getImportBlobMetadata, importUpdates, satisfiesVersionVector, updateMatchesDocumentHistory, versionVectorsEqual, } from "../../../../internal/loro/index.js";
|
|
3
3
|
function unverifiedLocalHistory(cause) {
|
|
4
4
|
return new Error("Rotation raw-history recovery found unverified local history; key rotation was not started", cause === undefined ? undefined : { cause });
|
|
5
5
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotationProvenance.js","sourceRoot":"","sources":["rotationProvenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,C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,yBAAyB,CAAC,KAAK,CAAC,eAAe,CAAC;YAC9C,yBAAyB,CAAC,KAAK,CAAC,eAAe,EAAE,cAAc,CAAC,EAClE,CAAC;QACD,MAAM,sBAAsB,EAAE,CAAC;IACjC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAIlD;IACC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,0BAA0B,CAAC;YACzC,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,cAAc,EAAE,KAAK,CAAC,cAAc;SACrC,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,aAAa,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtE,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,mBAAmB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACzE,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["import { base64ToBytes } from \"@tearleads/encoding\";\nimport {\n encodeVersionVector,\n exportFullHistoryIdentity,\n getImportBlobMetadata,\n importUpdates,\n satisfiesVersionVector,\n updateMatchesDocumentHistory,\n versionVectorsEqual,\n} from \"@tearleads/loro\";\nimport type { PendingUpdateRecord } from \"../../../../workflows/documents\";\nimport type { DocumentState } from \"../state\";\n\nfunction unverifiedLocalHistory(cause?: unknown): Error {\n return new Error(\n \"Rotation raw-history recovery found unverified local history; key rotation was not started\",\n cause === undefined ? undefined : { cause },\n );\n}\n\nfunction ordinaryPendingUpdateBytes(input: {\n currentDocument: DocumentState;\n pendingUpdates: readonly PendingUpdateRecord[];\n}): Uint8Array[] {\n return input.pendingUpdates.flatMap((update) => {\n if (update.sourceVersionVector != null) return [];\n const bytes = base64ToBytes(update.updateData);\n const metadata = getImportBlobMetadata(bytes);\n if (\n metadata.mode !== \"update\" ||\n !versionVectorsEqual(\n metadata.partialStartVersionVector,\n update.partialStartVersionVector,\n ) ||\n !versionVectorsEqual(\n metadata.partialEndVersionVector,\n update.partialEndVersionVector,\n ) ||\n !updateMatchesDocumentHistory(input.currentDocument, bytes)\n ) {\n throw new Error(\"Ordinary pending-update provenance is inconsistent\");\n }\n return [bytes];\n });\n}\n\nexport function assertExactDocumentHistory(input: {\n currentDocument: DocumentState;\n rebuiltDocument: DocumentState;\n}): void {\n const currentVersion = encodeVersionVector(input.currentDocument);\n if (\n !satisfiesVersionVector(\n encodeVersionVector(input.rebuiltDocument),\n currentVersion,\n ) ||\n exportFullHistoryIdentity(input.currentDocument) !==\n exportFullHistoryIdentity(input.rebuiltDocument, currentVersion)\n ) {\n throw unverifiedLocalHistory();\n }\n}\n\n/**\n * Prove that the live history is exactly raw remote history plus queued local\n * ordinary deltas. Deterministic operation-log comparison detects checkpoint\n * substitutions that reuse the genuine operations' version-vector identities.\n */\nexport function importProvenOrdinaryPendingHistory(input: {\n currentDocument: DocumentState;\n pendingUpdates: readonly PendingUpdateRecord[];\n rebuiltDocument: DocumentState;\n}): string {\n try {\n const updates = ordinaryPendingUpdateBytes({\n currentDocument: input.currentDocument,\n pendingUpdates: input.pendingUpdates,\n });\n if (updates.length > 0) importUpdates(input.rebuiltDocument, updates);\n assertExactDocumentHistory(input);\n return encodeVersionVector(input.currentDocument);\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"unverified local\")) {\n throw error;\n }\n throw unverifiedLocalHistory(error);\n }\n}\n"]}
|
package/stores/documents/documentStore/{rotationSettlement.js → rotation/rotationSettlement.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { encodeVersionVector, satisfiesVersionVector } from "
|
|
2
|
-
import { chainIdentityWrite } from "
|
|
3
|
-
import { listPendingUpdates, persistDocument } from "
|
|
4
|
-
import { invalidateDocumentStorePullContinuation } from "
|
|
5
|
-
import { cleanupPreRegisteredUpdateIdsOnFailure, discardUnacceptedPreRegisteredUpdateIds, preRegisterMaterializedDocumentSyncUpdateIds, } from "
|
|
6
|
-
import { captureDocumentStoreSyncGeneration, isDocumentStoreSyncGenerationCurrent, } from "
|
|
7
|
-
import { prepareDocumentOutgoingCoverage } from "
|
|
8
|
-
import { requestRemoteDocumentSync } from "
|
|
9
|
-
import { extendDocumentVersionCoverage } from "
|
|
1
|
+
import { encodeVersionVector, satisfiesVersionVector } from "../../../../internal/loro/index.js";
|
|
2
|
+
import { chainIdentityWrite } from "../identityWriteChain.js";
|
|
3
|
+
import { listPendingUpdates, persistDocument } from "../persistence.js";
|
|
4
|
+
import { invalidateDocumentStorePullContinuation } from "../sync/pullContinuationInvalidation.js";
|
|
5
|
+
import { cleanupPreRegisteredUpdateIdsOnFailure, discardUnacceptedPreRegisteredUpdateIds, preRegisterMaterializedDocumentSyncUpdateIds, } from "../sync/syncAcceptedUpdateIds.js";
|
|
6
|
+
import { captureDocumentStoreSyncGeneration, isDocumentStoreSyncGenerationCurrent, } from "../sync/syncGeneration.js";
|
|
7
|
+
import { prepareDocumentOutgoingCoverage } from "../sync/syncOutgoingCoverage.js";
|
|
8
|
+
import { requestRemoteDocumentSync } from "../sync/syncRequest.js";
|
|
9
|
+
import { extendDocumentVersionCoverage } from "../sync/versionCoverage.js";
|
|
10
10
|
export class RotationPendingUpdatesChangedError extends Error {
|
|
11
11
|
}
|
|
12
12
|
function ordinaryPendingUpdates(pendingUpdates) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotationSettlement.js","sourceRoot":"","sources":["rotationSettlement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB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CAAC,KAAK,CAAC,CAAC;QAC1D,4BAA4B,CAAC;YAC3B,cAAc,EAAE,iBAAiB;YACjC,iBAAiB;SAClB,CAAC,CAAC;QACH,MAAM,cAAc,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;QACjE,IACE,cAAc,CAAC,MAAM,KAAK,CAAC;YAC3B,sBAAsB,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,EACzE,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,GAAG,gBAAgB,KAAK,mBAAmB,CAAC,cAAc,CAAC,EAAE,CAAC;QACjF,IAAI,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;QACJ,CAAC;QACD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACnC,gBAAgB,GAAG,MAAM,wBAAwB,CAAC;YAChD,UAAU;YACV,cAAc,EAAE,iBAAiB;YACjC,KAAK;YACL,mBAAmB,EAAE,gBAAgB;SACtC,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { encodeVersionVector, satisfiesVersionVector } from \"@tearleads/loro\";\nimport type { PendingUpdateRecord } from \"../../../../workflows/documents\";\nimport { chainIdentityWrite } from \"../identityWriteChain\";\nimport { listPendingUpdates, persistDocument } from \"../persistence\";\nimport type {\n DocumentState,\n DocumentStoreState,\n DocumentSyncAttempt,\n} from \"../state\";\nimport { invalidateDocumentStorePullContinuation } from \"../sync/pullContinuationInvalidation\";\nimport {\n cleanupPreRegisteredUpdateIdsOnFailure,\n discardUnacceptedPreRegisteredUpdateIds,\n preRegisterMaterializedDocumentSyncUpdateIds,\n} from \"../sync/syncAcceptedUpdateIds\";\nimport {\n captureDocumentStoreSyncGeneration,\n type DocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent,\n} from \"../sync/syncGeneration\";\nimport { prepareDocumentOutgoingCoverage } from \"../sync/syncOutgoingCoverage\";\nimport { requestRemoteDocumentSync } from \"../sync/syncRequest\";\nimport { extendDocumentVersionCoverage } from \"../sync/versionCoverage\";\n\nexport class RotationPendingUpdatesChangedError extends Error {}\n\nfunction ordinaryPendingUpdates(\n pendingUpdates: readonly PendingUpdateRecord[],\n): PendingUpdateRecord[] {\n return pendingUpdates.filter(\n (pendingUpdate) => pendingUpdate.sourceVersionVector == null,\n );\n}\n\nfunction pendingUpdateSetKey(pendingUpdates: readonly PendingUpdateRecord[]) {\n return pendingUpdates\n .map((pendingUpdate) => pendingUpdate.id)\n .sort()\n .join(\"\\n\");\n}\n\nfunction pendingUpdateMatchesProvenRow(\n pendingUpdate: PendingUpdateRecord,\n provenUpdate: PendingUpdateRecord,\n): boolean {\n return (\n pendingUpdate.id === provenUpdate.id &&\n pendingUpdate.updateData === provenUpdate.updateData &&\n pendingUpdate.partialStartVersionVector ===\n provenUpdate.partialStartVersionVector &&\n pendingUpdate.partialEndVersionVector ===\n provenUpdate.partialEndVersionVector &&\n pendingUpdate.sourceVersionVector === provenUpdate.sourceVersionVector\n );\n}\n\nfunction assertOrdinaryRowsWereProven(input: {\n pendingUpdates: readonly PendingUpdateRecord[];\n provenUpdatesById: ReadonlyMap<string, PendingUpdateRecord>;\n}): void {\n for (const pendingUpdate of ordinaryPendingUpdates(input.pendingUpdates)) {\n const provenUpdate = input.provenUpdatesById.get(pendingUpdate.id);\n if (\n !provenUpdate ||\n !pendingUpdateMatchesProvenRow(pendingUpdate, provenUpdate)\n ) {\n throw new RotationPendingUpdatesChangedError(\n \"Document local updates changed after rotation provenance verification\",\n );\n }\n }\n}\n\nfunction ordinaryPendingUpdatesWithProvenCoverage(input: {\n currentDocument: DocumentState;\n pendingUpdates: PendingUpdateRecord[];\n verifiedBaseVersion: string;\n}): { coverage: string; pendingUpdates: PendingUpdateRecord[] } {\n const ordinaryUpdates = ordinaryPendingUpdates(input.pendingUpdates);\n const documentVersion = encodeVersionVector(input.currentDocument);\n const ordinaryCoverage = extendDocumentVersionCoverage({\n baseVersion: input.verifiedBaseVersion,\n documentVersion,\n spans: ordinaryUpdates,\n });\n if (!satisfiesVersionVector(ordinaryCoverage, documentVersion)) {\n throw new Error(\n \"Document rotation cannot settle uncovered local history because it may be checkpoint-derived\",\n );\n }\n return { coverage: ordinaryCoverage, pendingUpdates: ordinaryUpdates };\n}\n\nexport async function invalidatePullContinuationBeforeRotation(\n state: DocumentStoreState,\n): Promise<void> {\n const continuation = state.pullContinuation;\n if (!continuation) return;\n const currentDoc = state.doc;\n const currentRecord = state.record;\n if (!currentDoc || !currentRecord) {\n throw new Error(\n \"Document changed while its pull continuation was invalidated for key rotation\",\n );\n }\n const generation = captureDocumentStoreSyncGeneration(state, currentDoc);\n if (!generation) {\n throw new Error(\n \"Document changed while its pull continuation was invalidated for key rotation\",\n );\n }\n await invalidateDocumentStorePullContinuation({\n continuation,\n currentRecord,\n generation,\n state,\n });\n if (\n state.pullContinuation !== null ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n throw new Error(\n \"Document pull continuation could not be invalidated before key rotation\",\n );\n }\n}\n\nasync function persistStagedSettlement(input: {\n currentDocument: DocumentState;\n generation: DocumentStoreSyncGeneration;\n preparedRecord: NonNullable<DocumentStoreState[\"record\"]>;\n sentUpdateIds: string[];\n state: DocumentStoreState;\n syncAttempt: DocumentSyncAttempt;\n}): Promise<void> {\n const { state, syncAttempt } = input;\n discardUnacceptedPreRegisteredUpdateIds(\n state,\n input.sentUpdateIds,\n syncAttempt.synced.response.acceptedOutgoingUpdateIds,\n );\n const persisted = await persistDocument(\n state,\n input.currentDocument,\n {\n lastCommitLsn:\n syncAttempt.synced.response.commitLsn ??\n input.preparedRecord.lastCommitLsn ??\n null,\n pullContinuation: null,\n },\n {\n acceptedPendingUpdateIds: syncAttempt.synced.settledPendingUpdateIds,\n expectedSyncState: {\n pullContinuation: syncAttempt.consumedPullContinuation,\n record: syncAttempt.requestRecord,\n },\n preserveSnapshotStructuredFields: true,\n preserveSnapshotText: true,\n },\n input.generation,\n );\n if (\n !persisted ||\n persisted.pullContinuationSuperseded ||\n persisted.syncIdentitySuperseded ||\n !isDocumentStoreSyncGenerationCurrent(state, input.generation)\n ) {\n throw new Error(\n \"Document changed while local updates were settling for key rotation\",\n );\n }\n}\n\nfunction settledOrdinaryCoverage(input: {\n currentDocument: DocumentState;\n pendingUpdates: PendingUpdateRecord[];\n settledUpdateIds: readonly string[];\n verifiedBaseVersion: string;\n}): string {\n const settled = new Set(input.settledUpdateIds);\n return extendDocumentVersionCoverage({\n baseVersion: input.verifiedBaseVersion,\n documentVersion: encodeVersionVector(input.currentDocument),\n spans: input.pendingUpdates.filter((update) => settled.has(update.id)),\n });\n}\n\nasync function persistStagedSettlementOnIdentityChain(input: {\n currentDocument: DocumentState;\n generation: DocumentStoreSyncGeneration;\n pendingUpdates: PendingUpdateRecord[];\n preparedRecord: NonNullable<DocumentStoreState[\"record\"]>;\n sentUpdateIds: string[];\n state: DocumentStoreState;\n syncAttempt: DocumentSyncAttempt;\n verifiedBaseVersion: string;\n}): Promise<string> {\n return chainIdentityWrite(input.state, async () => {\n if (!isDocumentStoreSyncGenerationCurrent(input.state, input.generation)) {\n throw new Error(\n \"Document changed while local updates were settling for key rotation\",\n );\n }\n await persistStagedSettlement(input);\n return settledOrdinaryCoverage({\n currentDocument: input.currentDocument,\n pendingUpdates: input.pendingUpdates,\n settledUpdateIds: input.syncAttempt.synced.settledPendingUpdateIds,\n verifiedBaseVersion: input.verifiedBaseVersion,\n });\n });\n}\n\nasync function settleOrdinaryUpdatePass(input: {\n generation: DocumentStoreSyncGeneration;\n pendingUpdates: PendingUpdateRecord[];\n state: DocumentStoreState;\n verifiedBaseVersion: string;\n}): Promise<string> {\n const { state } = input;\n const currentDoc = state.doc;\n const currentRecord = state.record;\n const encapsulationKeyPair = state.runtime.crypto.encapsulationKeyPair;\n if (!currentDoc || !currentRecord || !encapsulationKeyPair) {\n throw new Error(\n \"Document changed while local updates were settling for key rotation\",\n );\n }\n const generation = input.generation;\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n throw new Error(\n \"Document changed while local updates were settling for key rotation\",\n );\n }\n const proven = ordinaryPendingUpdatesWithProvenCoverage({\n currentDocument: currentDoc,\n pendingUpdates: input.pendingUpdates,\n verifiedBaseVersion: input.verifiedBaseVersion,\n });\n const prepared = await prepareDocumentOutgoingCoverage({\n coverageBaseVersion: input.verifiedBaseVersion,\n currentDoc,\n generation,\n pendingUpdates: proven.pendingUpdates,\n state,\n });\n if (!prepared || !isDocumentStoreSyncGenerationCurrent(state, generation)) {\n throw new Error(\n \"Document changed while local updates were settling for key rotation\",\n );\n }\n const preparedPendingUpdates = ordinaryPendingUpdates(\n prepared.pendingUpdates,\n );\n if (preparedPendingUpdates.length === 0) return proven.coverage;\n\n const sentUpdateIds: string[] = [];\n return cleanupPreRegisteredUpdateIdsOnFailure(\n state,\n sentUpdateIds,\n async () => {\n const syncAttempt = await requestRemoteDocumentSync({\n allowRecoveryBaseline: false,\n currentDoc,\n currentRecord: prepared.record,\n encapsulationKeyPair,\n generation,\n onOutgoingUpdatesMaterialized: (updateIds) =>\n preRegisterMaterializedDocumentSyncUpdateIds(\n state,\n sentUpdateIds,\n updateIds,\n ),\n pendingUpdates: preparedPendingUpdates,\n queuedUpdateCount: preparedPendingUpdates.length,\n state,\n unavailableWriterLogMessage:\n \"Documents: rotation could not settle local updates because the writer context is unavailable.\",\n });\n if (\n !syncAttempt ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n throw new Error(\n \"Document local updates could not be committed before key rotation\",\n );\n }\n\n return persistStagedSettlementOnIdentityChain({\n currentDocument: currentDoc,\n generation,\n pendingUpdates: preparedPendingUpdates,\n preparedRecord: prepared.record,\n sentUpdateIds,\n state,\n syncAttempt,\n verifiedBaseVersion: input.verifiedBaseVersion,\n });\n },\n );\n}\n\n/**\n * Commit only ordinary local rows before rotation. Server-returned updates are\n * authenticated and decrypted by the workflow but deliberately not imported\n * or persisted; the subsequent raw rebuild owns that all-or-nothing install.\n */\nexport async function settleOrdinaryDocumentUpdatesBeforeRotation(\n state: DocumentStoreState,\n verifiedBaseVersion: string,\n provenPendingUpdates: readonly PendingUpdateRecord[],\n generation: DocumentStoreSyncGeneration,\n): Promise<void> {\n const stalledQueueStates = new Set<string>();\n let verifiedCoverage = verifiedBaseVersion;\n const provenUpdatesById = new Map(\n ordinaryPendingUpdates(provenPendingUpdates).map((update) => [\n update.id,\n update,\n ]),\n );\n\n while (true) {\n const currentDoc = state.doc;\n if (!currentDoc) {\n throw new Error(\"Document rotation requires an initialized document\");\n }\n const allPendingUpdates = await listPendingUpdates(state);\n assertOrdinaryRowsWereProven({\n pendingUpdates: allPendingUpdates,\n provenUpdatesById,\n });\n const pendingUpdates = ordinaryPendingUpdates(allPendingUpdates);\n if (\n pendingUpdates.length === 0 &&\n satisfiesVersionVector(verifiedCoverage, encodeVersionVector(currentDoc))\n ) {\n return;\n }\n\n const queueState = `${verifiedCoverage}\\n${pendingUpdateSetKey(pendingUpdates)}`;\n if (stalledQueueStates.has(queueState)) {\n throw new Error(\n \"Document local updates could not be committed before key rotation\",\n );\n }\n stalledQueueStates.add(queueState);\n verifiedCoverage = await settleOrdinaryUpdatePass({\n generation,\n pendingUpdates: allPendingUpdates,\n state,\n verifiedBaseVersion: verifiedCoverage,\n });\n }\n}\n"]}
|
|
@@ -3,12 +3,12 @@ import { addDocumentRow, createDocumentRowId, removeDocumentRow, setDocumentRowF
|
|
|
3
3
|
import { createPendingUpdateFields } from "../../../data/documents/documentSync.js";
|
|
4
4
|
import { resolveDocumentCreateAuthor } from "../../../workflows/documents/index.js";
|
|
5
5
|
import { requestDocumentStoreSync } from "../registry.js";
|
|
6
|
-
import { ensureDocumentStoreReady } from "./initialization.js";
|
|
6
|
+
import { ensureDocumentStoreReady } from "./initialization/index.js";
|
|
7
7
|
import { revalidateDocumentMutationIdentity } from "./mutationIdentityRevalidation.js";
|
|
8
8
|
import { advancePendingBaseVersion, pendingDeltaSinceBase, persistDocument, } from "./persistence.js";
|
|
9
9
|
import { reportDocumentStoreWriteFailure } from "./reportWriteFailure.js";
|
|
10
10
|
import { canWriteDocument, } from "./state.js";
|
|
11
|
-
import { captureDocumentStoreSyncGeneration, isDocumentStoreSyncGenerationCurrent, } from "./syncGeneration.js";
|
|
11
|
+
import { captureDocumentStoreSyncGeneration, isDocumentStoreSyncGenerationCurrent, } from "./sync/syncGeneration.js";
|
|
12
12
|
// Fixed literal: a reported message must never carry row ids or field values.
|
|
13
13
|
const ROW_FAILURE_MESSAGE = "Documents: row mutation failed";
|
|
14
14
|
// Stamp each row write with the local signing identity (or "" when
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.js","sourceRoot":"","sources":["rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,mBAAmB,EAEnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,gBAAgB,GAGjB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,kBAAkB,CAAC;AAE1B,8EAA8E;AAC9E,MAAM,mBAAmB,GAAG,gCAAgC,CAAC;AA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oB,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAyB,EACzB,YAAwB,EACxB,EAAU;IAEV,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,wBAAwB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+BAA+B,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO;IACT,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { encodeVersionVector } from \"@tearleads/loro\";\nimport {\n addDocumentRow,\n createDocumentRowId,\n type DocumentRowAttribution,\n removeDocumentRow,\n setDocumentRowFields,\n} from \"../../../data/documents/documentRowList\";\nimport { createPendingUpdateFields } from \"../../../data/documents/documentSync\";\nimport { resolveDocumentCreateAuthor } from \"../../../workflows/documents\";\nimport { requestDocumentStoreSync } from \"../registry\";\nimport { ensureDocumentStoreReady } from \"./initialization\";\nimport { revalidateDocumentMutationIdentity } from \"./mutationIdentityRevalidation\";\nimport {\n advancePendingBaseVersion,\n pendingDeltaSinceBase,\n persistDocument,\n} from \"./persistence\";\nimport { reportDocumentStoreWriteFailure } from \"./reportWriteFailure\";\nimport {\n canWriteDocument,\n type DocumentState,\n type DocumentStoreState,\n} from \"./state\";\nimport {\n captureDocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent,\n} from \"./syncGeneration\";\n\n// Fixed literal: a reported message must never carry row ids or field values.\nconst ROW_FAILURE_MESSAGE = \"Documents: row mutation failed\";\n\n// Stamp each row write with the local signing identity (or \"\" when\n// unauthenticated) and an ISO timestamp, matching the keys the edit-attribution\n// layer resolves against.\nfunction resolveRowAttribution(\n state: DocumentStoreState,\n): DocumentRowAttribution {\n return {\n at: new Date().toISOString(),\n userId: resolveDocumentCreateAuthor(state.runtime)?.signerUserId ?? \"\",\n };\n}\n\nasync function persistRowMutation(\n state: DocumentStoreState,\n expectedLocalWriteGeneration: number,\n mutate: (doc: DocumentState) => boolean,\n): Promise<void> {\n if (state.localWriteGeneration !== expectedLocalWriteGeneration) {\n return;\n }\n const currentDoc = state.doc;\n if (!currentDoc || !canWriteDocument(state)) {\n return;\n }\n const generation = captureDocumentStoreSyncGeneration(state, currentDoc);\n if (!generation) {\n return;\n }\n\n if (!mutate(currentDoc)) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n\n const update = pendingDeltaSinceBase(state, currentDoc);\n if (update.byteLength === 0) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n // Captured at delta time: the enqueued row proves coverage up to exactly\n // this version, so it is the frontier the persist below may publish.\n const coveredVersion = encodeVersionVector(currentDoc);\n\n const pendingUpdate = createPendingUpdateFields(update);\n if (!pendingUpdate) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n // Row writes change neither prose nor structured fields; setReadySnapshot\n // always re-derives rows from the doc, so preserve the text/structured fields\n // in case this write overlaps an in-flight keystroke elsewhere.\n const persisted = await persistDocument(\n state,\n currentDoc,\n { snapshotEndVersion: coveredVersion },\n {\n pendingUpdate,\n preserveSnapshotStructuredFields: true,\n preserveSnapshotText: true,\n },\n generation,\n );\n if (\n !persisted ||\n persisted.pullContinuationSuperseded ||\n persisted.syncIdentitySuperseded ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n // Refused: the document was deleted while this persist was queued\n // and the store is cleared — no state advance, no sync request.\n return;\n }\n advancePendingBaseVersion(state, currentDoc);\n requestDocumentStoreSync(state);\n}\n\nfunction queueRowMutation(\n state: DocumentStoreState,\n mutate: (doc: DocumentState) => boolean,\n): Promise<void> {\n const writeGeneration = state.localWriteGeneration;\n // Unlike text/structured-field writes, row writes intentionally do NOT bump\n // `state.pendingLocalWrites`: rows are never in the optimistic-preserve set —\n // `setReadySnapshot` always re-derives them from the doc — so there is no\n // optimistic snapshot for a concurrent sync pass to clobber. Input smoothness\n // during rapid edits is handled in the app layer (useDocumentRowEditing).\n state.writeChain = state.writeChain\n .catch(() => undefined)\n .then(async () => persistRowMutation(state, writeGeneration, mutate))\n .catch((error: unknown) => {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n });\n return state.writeChain;\n}\n\nexport async function addRowToDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n fields: Readonly<Record<string, string>>,\n): Promise<string> {\n const id = createDocumentRowId();\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return id;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return id;\n }\n\n await queueRowMutation(state, (doc) => {\n addDocumentRow(doc, id, fields, resolveRowAttribution(state));\n return true;\n });\n return id;\n}\n\nexport async function updateRowInDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n id: string,\n patch: Readonly<Record<string, string>>,\n): Promise<void> {\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return;\n }\n\n await queueRowMutation(state, (doc) =>\n setDocumentRowFields(doc, id, patch, resolveRowAttribution(state)),\n );\n}\n\nexport async function removeRowFromDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n id: string,\n): Promise<void> {\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return;\n }\n\n await queueRowMutation(state, (doc) => removeDocumentRow(doc, id));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rows.js","sourceRoot":"","sources":["rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,mBAAmB,EAEnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,gBAAgB,GAGjB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,uBAAuB,CAAC;AAE/B,8EAA8E;AAC9E,MAAM,mBAAmB,GAAG,gCAAgC,CAAC;AAE7D,mEAAmE;AACnE,gFAAgF;AAChF,0BAA0B;AAC1B,SAAS,qBAAqB,CAC5B,KAAyB;IAEzB,OAAO;QACL,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC5B,MAAM,EAAE,2BAA2B,CAAC,KAAK,CAAC,OAAO,CAAC,E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IACnB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,wBAAwB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+BAA+B,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO;IACT,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { encodeVersionVector } from \"@tearleads/loro\";\nimport {\n addDocumentRow,\n createDocumentRowId,\n type DocumentRowAttribution,\n removeDocumentRow,\n setDocumentRowFields,\n} from \"../../../data/documents/documentRowList\";\nimport { createPendingUpdateFields } from \"../../../data/documents/documentSync\";\nimport { resolveDocumentCreateAuthor } from \"../../../workflows/documents\";\nimport { requestDocumentStoreSync } from \"../registry\";\nimport { ensureDocumentStoreReady } from \"./initialization\";\nimport { revalidateDocumentMutationIdentity } from \"./mutationIdentityRevalidation\";\nimport {\n advancePendingBaseVersion,\n pendingDeltaSinceBase,\n persistDocument,\n} from \"./persistence\";\nimport { reportDocumentStoreWriteFailure } from \"./reportWriteFailure\";\nimport {\n canWriteDocument,\n type DocumentState,\n type DocumentStoreState,\n} from \"./state\";\nimport {\n captureDocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent,\n} from \"./sync/syncGeneration\";\n\n// Fixed literal: a reported message must never carry row ids or field values.\nconst ROW_FAILURE_MESSAGE = \"Documents: row mutation failed\";\n\n// Stamp each row write with the local signing identity (or \"\" when\n// unauthenticated) and an ISO timestamp, matching the keys the edit-attribution\n// layer resolves against.\nfunction resolveRowAttribution(\n state: DocumentStoreState,\n): DocumentRowAttribution {\n return {\n at: new Date().toISOString(),\n userId: resolveDocumentCreateAuthor(state.runtime)?.signerUserId ?? \"\",\n };\n}\n\nasync function persistRowMutation(\n state: DocumentStoreState,\n expectedLocalWriteGeneration: number,\n mutate: (doc: DocumentState) => boolean,\n): Promise<void> {\n if (state.localWriteGeneration !== expectedLocalWriteGeneration) {\n return;\n }\n const currentDoc = state.doc;\n if (!currentDoc || !canWriteDocument(state)) {\n return;\n }\n const generation = captureDocumentStoreSyncGeneration(state, currentDoc);\n if (!generation) {\n return;\n }\n\n if (!mutate(currentDoc)) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n\n const update = pendingDeltaSinceBase(state, currentDoc);\n if (update.byteLength === 0) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n // Captured at delta time: the enqueued row proves coverage up to exactly\n // this version, so it is the frontier the persist below may publish.\n const coveredVersion = encodeVersionVector(currentDoc);\n\n const pendingUpdate = createPendingUpdateFields(update);\n if (!pendingUpdate) {\n await revalidateDocumentMutationIdentity({ currentDoc, generation, state });\n return;\n }\n // Row writes change neither prose nor structured fields; setReadySnapshot\n // always re-derives rows from the doc, so preserve the text/structured fields\n // in case this write overlaps an in-flight keystroke elsewhere.\n const persisted = await persistDocument(\n state,\n currentDoc,\n { snapshotEndVersion: coveredVersion },\n {\n pendingUpdate,\n preserveSnapshotStructuredFields: true,\n preserveSnapshotText: true,\n },\n generation,\n );\n if (\n !persisted ||\n persisted.pullContinuationSuperseded ||\n persisted.syncIdentitySuperseded ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n // Refused: the document was deleted while this persist was queued\n // and the store is cleared — no state advance, no sync request.\n return;\n }\n advancePendingBaseVersion(state, currentDoc);\n requestDocumentStoreSync(state);\n}\n\nfunction queueRowMutation(\n state: DocumentStoreState,\n mutate: (doc: DocumentState) => boolean,\n): Promise<void> {\n const writeGeneration = state.localWriteGeneration;\n // Unlike text/structured-field writes, row writes intentionally do NOT bump\n // `state.pendingLocalWrites`: rows are never in the optimistic-preserve set —\n // `setReadySnapshot` always re-derives them from the doc — so there is no\n // optimistic snapshot for a concurrent sync pass to clobber. Input smoothness\n // during rapid edits is handled in the app layer (useDocumentRowEditing).\n state.writeChain = state.writeChain\n .catch(() => undefined)\n .then(async () => persistRowMutation(state, writeGeneration, mutate))\n .catch((error: unknown) => {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n });\n return state.writeChain;\n}\n\nexport async function addRowToDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n fields: Readonly<Record<string, string>>,\n): Promise<string> {\n const id = createDocumentRowId();\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return id;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return id;\n }\n\n await queueRowMutation(state, (doc) => {\n addDocumentRow(doc, id, fields, resolveRowAttribution(state));\n return true;\n });\n return id;\n}\n\nexport async function updateRowInDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n id: string,\n patch: Readonly<Record<string, string>>,\n): Promise<void> {\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return;\n }\n\n await queueRowMutation(state, (doc) =>\n setDocumentRowFields(doc, id, patch, resolveRowAttribution(state)),\n );\n}\n\nexport async function removeRowFromDocumentStore(\n state: DocumentStoreState,\n scheduleSync: () => void,\n id: string,\n): Promise<void> {\n let ready: boolean;\n try {\n ready = await ensureDocumentStoreReady(state, scheduleSync);\n } catch (error) {\n reportDocumentStoreWriteFailure(state, ROW_FAILURE_MESSAGE, error);\n return;\n }\n\n if (!ready || !state.doc || !canWriteDocument(state)) {\n return;\n }\n\n await queueRowMutation(state, (doc) => removeDocumentRow(doc, id));\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { projectStoredDocumentState, readStoredDocumentState, } from "../../../d
|
|
|
4
4
|
import { listDocumentRows, sameDocumentRows, } from "../../../data/documents/documentRowList.js";
|
|
5
5
|
import { canWriteEffectiveAccessLevel, normalizeEffectiveAccessLevel, } from "../../../data/keying/accessLevel.js";
|
|
6
6
|
import { createDocumentProjectionUserKeyResolver, resolveDocumentCreateAuthor, } from "../../../workflows/documents/index.js";
|
|
7
|
-
import { getAttachmentStatuses, getAttachmentStorageKeys, } from "./attachmentSnapshot.js";
|
|
7
|
+
import { getAttachmentStatuses, getAttachmentStorageKeys, } from "./attachments/attachmentSnapshot.js";
|
|
8
8
|
const EMPTY_DOCUMENT_SNAPSHOT = {
|
|
9
9
|
attachments: [],
|
|
10
10
|
attachmentStatusBySlotId: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAEL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAGL,uCAAuC,EAOvC,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAgJ9B,MAAM,uBAAuB,GAAqB;IAChD,WAAW,EAAE,EAAE;IACf,wBAAwB,EAAE,EAAE;IAC5B,4BAA4B,EAAE,EAAE;IAChC,SAAS,EAAE,KAAK;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AoB,CACnC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAyB,EACzB,QAAoB;IAEpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,OAAO,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type { createDocument } from \"@tearleads/loro\";\nimport type { DocumentWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport { DEFAULT_DOCUMENT_KIND } from \"../../../data/documents/documentConstants\";\nimport {\n type DocumentAttachment,\n getDocumentAttachments,\n sameDocumentAttachments,\n} from \"../../../data/documents/documentContent\";\nimport {\n projectStoredDocumentState,\n readStoredDocumentState,\n type StoredDocumentKind,\n} from \"../../../data/documents/documentKinds\";\nimport {\n type DocumentRow,\n listDocumentRows,\n sameDocumentRows,\n} from \"../../../data/documents/documentRowList\";\nimport type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport type { DocumentSyncPullContinuation } from \"../../../data/documents/shared/syncPagination\";\nimport type { SyncRemoteDocumentResult } from \"../../../data/documents/shared/types\";\nimport {\n canWriteEffectiveAccessLevel,\n normalizeEffectiveAccessLevel,\n} from \"../../../data/keying/accessLevel\";\nimport type { DomainScope } from \"../../../data/shared/domainScope\";\nimport {\n type AttachmentRemovalRows,\n type AttachmentStagingRows,\n createDocumentProjectionUserKeyResolver,\n type DocumentProjectionUserKeyResolver,\n type DocumentRecord,\n type DocumentSyncLane,\n type DocumentsPersistence,\n type PendingAttachmentRecord,\n type PendingUpdateInsert,\n resolveDocumentCreateAuthor,\n} from \"../../../workflows/documents\";\nimport type { DocumentSnapshot, DocumentsRuntime } from \"../types\";\nimport {\n getAttachmentStatuses,\n getAttachmentStorageKeys,\n} from \"./attachmentSnapshot\";\nexport type DocumentState = Awaited<ReturnType<typeof createDocument>>;\nexport type EncapsulationKeyPair = NonNullable<\n DocumentsRuntime[\"crypto\"][\"encapsulationKeyPair\"]\n>;\nexport type DocumentAttachmentBinding = NonNullable<\n Awaited<ReturnType<DocumentsRuntime[\"apiClient\"][\"listDocumentAttachments\"]>>\n>[number];\nexport type PendingMutationSyncResult = {\n completed: boolean;\n nextRecord: DocumentRecord;\n};\nexport interface PersistedDocumentRecord {\n creationSuperseded?: true;\n historyRestoreState?:\n | Awaited<ReturnType<DocumentsPersistence[\"loadHistoryRestoreState\"]>>\n | undefined;\n pullContinuationSuperseded?: true;\n record: DocumentRecord;\n syncIdentitySuperseded?: true;\n updatedAt?: string | undefined;\n}\nexport interface SaveDocumentRecordOptions {\n acceptedPendingUpdateIds?: readonly string[] | undefined;\n attachmentRemoval?: AttachmentRemovalRows | undefined;\n attachmentStaging?: AttachmentStagingRows | undefined;\n clearSyncFailure?: boolean | undefined;\n expectedSyncState?:\n | {\n pullContinuation: DocumentSyncPullContinuation | null;\n record: DocumentRecord;\n }\n | undefined;\n historyCheckpoint?:\n | {\n coveredTailIds: readonly string[];\n endVersionVector: string;\n pruneCoveredLocalState: boolean;\n snapshot: string;\n }\n | undefined;\n historyUpdateOrigin?: \"local\" | \"remote\" | undefined;\n historyUpdates?: readonly string[] | undefined;\n pendingUpdate?: Omit<PendingUpdateInsert, \"localId\"> | undefined;\n pendingBaseVersionOverride?: string | null | undefined;\n preserveSnapshotStructuredFields?: boolean | undefined;\n preserveSnapshotText?: boolean | undefined;\n stillCurrent?: (() => boolean) | undefined;\n}\nexport interface DocumentSyncAttempt {\n consumedPullContinuation: DocumentSyncPullContinuation | null;\n outgoingUpdateCount: number;\n requestRecord: DocumentRecord;\n synced: SyncRemoteDocumentResult;\n /** `writerProjectionGeneration` when the request left; gates the install. */\n writerProjectionGeneration: number;\n}\nexport interface DocumentStorePersistenceEffects {\n emitPersistedDocument: (\n domainScope: DomainScope,\n persistedDocument: DocumentSummary,\n placementChanged?: boolean | undefined,\n ) => void;\n registerDocumentIdentity: (\n domainScope: DomainScope,\n localId: string,\n documentId: string | null,\n ) => void;\n}\nexport interface DocumentStoreState {\n attachmentBlobIdBySlotId: Record<string, string | null>;\n /** Plaintext digest of the held bytes per slot; see `getAttachmentStatuses`. */\n attachmentContentSha256BySlotId: Record<string, string>;\n attachmentStorageKeyBySlotId: Record<string, string>;\n /** Creation's birth rides the first attach; see `deferredInitialUpdate.ts`. */\n deferInitialUpdate?: boolean;\n doc: DocumentState | null;\n effects: DocumentStorePersistenceEffects;\n initialDocumentId: string | null;\n initialDocumentKind: StoredDocumentKind;\n initialText: string;\n initializePromise: Promise<void> | null;\n initialized: boolean;\n lastEventCount: number;\n /** Invalidates queued local-write closures when this store is cleared. */\n localWriteGeneration: number;\n locallyAcceptedUpdateIds: Set<string>;\n localId: string;\n listeners: Set<() => void>;\n pendingAttachments: PendingAttachmentRecord[];\n /**\n * Oplog version through which every op in `doc` is already durably enqueued as\n * a pending update or synced from a remote peer. It advances only after an\n * edit's enqueue+persist succeeds, so a later edit can recover any orphaned\n * delta left by a failed write instead of silently dropping it from sync.\n * `null` only before initialization sets it to the loaded doc's version.\n */\n pendingBaseVersion: string | null;\n /**\n * Local text/structured writes queued on `writeChain` but not yet drained.\n * While positive, sync MUST preserve the optimistic text/fields because `doc`\n * can lag the latest keystroke. Remote merges remain in `doc` and publish when\n * the final write settles.\n */\n pendingLocalWrites: number;\n persistence: DocumentsPersistence;\n /**\n * Durable continuation for a bounded remote pull, mirrored from the document\n * record so the live lane can advance it without re-reading SQLite.\n */\n pullContinuation: DocumentSyncPullContinuation | null;\n record: DocumentRecord | null;\n /** Served bindings hydration refused for a held copy; see `hydrate.ts`. */\n rejectedServedAttachmentBindings: Set<string>;\n /**\n * Consecutive completed sync passes that re-keyed conflicted pending updates\n * without settling anything. Bounds the rekey-driven self re-arm so a server\n * that keeps conflicting fresh ids cannot drive a network-speed loop; see\n * shouldReArmAfterOutgoingSettlement.\n */\n rekeyOnlyPassCount: number;\n resolveProjectionUserKey: DocumentProjectionUserKeyResolver;\n /** Latest remote-update sequence durably applied by a completed probe. */\n remoteUpdateCompletedSignalSeq: number;\n /** A cancelled remote-only owner blocks late responses until fresh work. */\n remoteSyncBlocked: boolean;\n scheduleStartupRemoteSync: boolean;\n remoteUpdatePending: boolean;\n /** Sequence used to keep an older pass from clearing a newer remote event. */\n remoteUpdateSignalSeq: number;\n runtime: DocumentsRuntime;\n snapshot: DocumentSnapshot;\n syncLane: DocumentSyncLane | null;\n /** Parked behind another member's ancestor repair; a path hint re-runs. */\n awaitingAncestorRepair: boolean;\n writeChain: Promise<void>;\n writerProjection: DocumentWriterProjectionResponse | null;\n /**\n * Bumped whenever a realtime hint drops `writerProjection`; an operation that\n * fetched or was handed a projection installs it only if this is unchanged\n * since it started, so a pre-hint answer never lands after the hint.\n */\n writerProjectionGeneration: number;\n}\nconst EMPTY_DOCUMENT_SNAPSHOT: DocumentSnapshot = {\n attachments: [],\n attachmentStatusBySlotId: {},\n attachmentStorageKeyBySlotId: {},\n canAttach: false,\n canWrite: true,\n currentAuthorId: null,\n documentId: null,\n documentKind: DEFAULT_DOCUMENT_KIND,\n effectiveAccessLevel: \"admin\",\n fieldValidationIssues: [],\n ready: false,\n rows: [],\n structuredFields: {},\n text: \"\",\n title: \"\",\n syncing: false,\n};\nfunction shallowEqualRecord<Value>(\n left: Readonly<Record<string, Value>>,\n right: Readonly<Record<string, Value>>,\n): boolean {\n let leftKeyCount = 0;\n for (const key in left) {\n if (!Object.hasOwn(left, key)) continue;\n\n leftKeyCount += 1;\n if (!Object.hasOwn(right, key) || !Object.is(left[key], right[key])) {\n return false;\n }\n }\n\n let rightKeyCount = 0;\n for (const key in right) {\n if (Object.hasOwn(right, key)) {\n rightKeyCount += 1;\n }\n }\n\n return leftKeyCount === rightKeyCount;\n}\n\nfunction sameValidationIssues(\n left: DocumentSnapshot[\"fieldValidationIssues\"],\n right: DocumentSnapshot[\"fieldValidationIssues\"],\n): boolean {\n return (\n left.length === right.length &&\n left.every((issue, index) => {\n const nextIssue = right[index];\n return (\n nextIssue !== undefined &&\n issue.field === nextIssue.field &&\n issue.message === nextIssue.message &&\n Object.is(issue.value, nextIssue.value)\n );\n })\n );\n}\n\nexport function createDocumentStoreState(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence,\n effects: DocumentStorePersistenceEffects,\n initialDocumentId: string | null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n scheduleStartupRemoteSync = true,\n): DocumentStoreState {\n return {\n attachmentBlobIdBySlotId: {},\n attachmentContentSha256BySlotId: {},\n attachmentStorageKeyBySlotId: {},\n doc: null,\n effects,\n initialDocumentId,\n initialDocumentKind,\n initialText,\n initializePromise: null,\n initialized: false,\n lastEventCount: 0,\n localWriteGeneration: 0,\n locallyAcceptedUpdateIds: new Set(),\n localId,\n listeners: new Set(),\n pendingAttachments: [],\n pendingBaseVersion: null,\n pendingLocalWrites: 0,\n persistence,\n pullContinuation: null,\n record: null,\n rejectedServedAttachmentBindings: new Set(),\n rekeyOnlyPassCount: 0,\n resolveProjectionUserKey:\n createDocumentProjectionUserKeyResolver(initialRuntime),\n remoteUpdateCompletedSignalSeq: 0,\n remoteSyncBlocked: !scheduleStartupRemoteSync,\n scheduleStartupRemoteSync,\n awaitingAncestorRepair: false,\n remoteUpdatePending: false,\n remoteUpdateSignalSeq: 0,\n runtime: initialRuntime,\n snapshot: { ...EMPTY_DOCUMENT_SNAPSHOT },\n syncLane: null,\n writeChain: Promise.resolve(),\n writerProjection: null,\n writerProjectionGeneration: 0,\n };\n}\n\nfunction emitDocumentStore(state: DocumentStoreState) {\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nexport function setDocumentSnapshot(\n state: DocumentStoreState,\n next: DocumentSnapshot,\n) {\n if (\n sameDocumentAttachments(state.snapshot.attachments, next.attachments) &&\n shallowEqualRecord(\n state.snapshot.attachmentStatusBySlotId,\n next.attachmentStatusBySlotId,\n ) &&\n shallowEqualRecord(\n state.snapshot.attachmentStorageKeyBySlotId,\n next.attachmentStorageKeyBySlotId,\n ) &&\n state.snapshot.canAttach === next.canAttach &&\n state.snapshot.canWrite === next.canWrite &&\n state.snapshot.currentAuthorId === next.currentAuthorId &&\n state.snapshot.documentId === next.documentId &&\n state.snapshot.documentKind === next.documentKind &&\n state.snapshot.effectiveAccessLevel === next.effectiveAccessLevel &&\n sameValidationIssues(\n state.snapshot.fieldValidationIssues,\n next.fieldValidationIssues,\n ) &&\n state.snapshot.ready === next.ready &&\n sameDocumentRows(state.snapshot.rows, next.rows) &&\n shallowEqualRecord(\n state.snapshot.structuredFields,\n next.structuredFields,\n ) &&\n state.snapshot.text === next.text &&\n state.snapshot.title === next.title &&\n state.snapshot.syncing === next.syncing\n ) {\n return;\n }\n\n state.snapshot = next;\n emitDocumentStore(state);\n}\n\nfunction clearDocumentStoreState(\n state: DocumentStoreState,\n { initialized }: { initialized: boolean },\n) {\n state.deferInitialUpdate = false;\n state.doc = null;\n state.localWriteGeneration += 1;\n state.record = null;\n state.pendingAttachments = [];\n state.pendingBaseVersion = null;\n state.pendingLocalWrites = 0;\n state.pullContinuation = null;\n state.attachmentBlobIdBySlotId = {};\n state.attachmentContentSha256BySlotId = {};\n state.attachmentStorageKeyBySlotId = {};\n state.locallyAcceptedUpdateIds = new Set();\n state.rejectedServedAttachmentBindings = new Set();\n state.remoteUpdateCompletedSignalSeq = 0;\n state.remoteSyncBlocked = !state.scheduleStartupRemoteSync;\n state.awaitingAncestorRepair = false;\n state.remoteUpdatePending = false;\n state.remoteUpdateSignalSeq = 0;\n state.writerProjection = null;\n state.initialized = initialized;\n state.initializePromise = null;\n state.writeChain = Promise.resolve();\n setDocumentSnapshot(state, { ...EMPTY_DOCUMENT_SNAPSHOT });\n}\n\nexport function resetDocumentStore(state: DocumentStoreState) {\n clearDocumentStoreState(state, { initialized: false });\n}\n\nexport function markDocumentStoreRemoved(state: DocumentStoreState) {\n clearDocumentStoreState(state, { initialized: true });\n}\n\nexport function canAttachFiles(state: DocumentStoreState): boolean {\n return (\n canWriteDocument(state) &&\n state.runtime.infra.dbStatus === \"ready\" &&\n !!state.runtime.crypto.encapsulationKeyPair\n );\n}\n\nexport function canWriteDocument(state: DocumentStoreState): boolean {\n return canWriteEffectiveAccessLevel(state.record?.effectiveAccessLevel);\n}\n\nfunction getSnapshotAttachments(\n state: DocumentStoreState,\n currentDoc: DocumentState | null = state.doc,\n): DocumentAttachment[] {\n return currentDoc ? getDocumentAttachments(currentDoc) : [];\n}\n\nfunction getSnapshotRows(\n state: DocumentStoreState,\n currentDoc: DocumentState | null = state.doc,\n): DocumentRow[] {\n return currentDoc ? listDocumentRows(currentDoc) : [];\n}\n\nfunction resolveCurrentAuthorId(state: DocumentStoreState): string | null {\n return resolveDocumentCreateAuthor(state.runtime)?.signerUserId ?? null;\n}\n\nexport function setReadySnapshot(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n syncing: boolean,\n textOverride?: string,\n structuredFieldsOverride?: DocumentSnapshot[\"structuredFields\"],\n) {\n const attachments = getSnapshotAttachments(state, currentDoc);\n const rows = getSnapshotRows(state, currentDoc);\n const documentState = readStoredDocumentState(\n currentDoc,\n state.runtime.infra.documentProjectors,\n );\n const text = textOverride ?? documentState.text;\n const structuredFields =\n structuredFieldsOverride ?? documentState.structuredFields;\n const projectedState =\n textOverride === undefined && structuredFieldsOverride === undefined\n ? documentState\n : projectStoredDocumentState(\n {\n documentKind: documentState.documentKind,\n structuredFields,\n text,\n rows: rows.map((row) => ({ id: row.id, fields: row.fields })),\n },\n state.runtime.infra.documentProjectors,\n );\n\n setDocumentSnapshot(state, {\n attachments,\n attachmentStatusBySlotId: getAttachmentStatuses({\n attachments,\n contentSha256BySlotId: state.attachmentContentSha256BySlotId,\n pendingSlotIds: new Set(\n state.pendingAttachments.map((attachment) => attachment.slotId),\n ),\n }),\n attachmentStorageKeyBySlotId: getAttachmentStorageKeys(\n state.attachmentStorageKeyBySlotId,\n attachments,\n ),\n canAttach: canAttachFiles(state),\n canWrite: canWriteDocument(state),\n currentAuthorId: resolveCurrentAuthorId(state),\n documentId: state.record?.documentId ?? null,\n documentKind: projectedState.documentKind,\n effectiveAccessLevel: normalizeEffectiveAccessLevel(\n state.record?.effectiveAccessLevel,\n ),\n fieldValidationIssues: projectedState.fieldValidationIssues,\n ready: true,\n rows,\n structuredFields: projectedState.structuredFields,\n text,\n title: projectedState.title,\n syncing,\n });\n}\n\nexport function setDocumentSyncing(\n state: DocumentStoreState,\n syncing: boolean,\n) {\n setDocumentSnapshot(state, { ...state.snapshot, syncing });\n}\n\nexport function refreshAttachabilitySnapshot(state: DocumentStoreState) {\n if (!state.snapshot.ready) {\n return;\n }\n\n setDocumentSnapshot(state, {\n ...state.snapshot,\n canAttach: canAttachFiles(state),\n canWrite: canWriteDocument(state),\n effectiveAccessLevel: normalizeEffectiveAccessLevel(\n state.record?.effectiveAccessLevel,\n ),\n });\n}\n\nexport function subscribeToDocumentStore(\n state: DocumentStoreState,\n listener: () => void,\n) {\n state.listeners.add(listener);\n return () => void state.listeners.delete(listener);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAEL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAGL,uCAAuC,EAOvC,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAgJ1C,MAAM,uBAAuB,GAAqB;IAChD,WAAW,EAAE,EA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CAAC,KAAK,CAAC;QACjC,oBAAoB,EAAE,6BAA6B,CACjD,KAAK,CAAC,MAAM,EAAE,oBAAoB,CACnC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAyB,EACzB,QAAoB;IAEpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,OAAO,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type { createDocument } from \"@tearleads/loro\";\nimport type { DocumentWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport { DEFAULT_DOCUMENT_KIND } from \"../../../data/documents/documentConstants\";\nimport {\n type DocumentAttachment,\n getDocumentAttachments,\n sameDocumentAttachments,\n} from \"../../../data/documents/documentContent\";\nimport {\n projectStoredDocumentState,\n readStoredDocumentState,\n type StoredDocumentKind,\n} from \"../../../data/documents/documentKinds\";\nimport {\n type DocumentRow,\n listDocumentRows,\n sameDocumentRows,\n} from \"../../../data/documents/documentRowList\";\nimport type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport type { DocumentSyncPullContinuation } from \"../../../data/documents/shared/syncPagination\";\nimport type { SyncRemoteDocumentResult } from \"../../../data/documents/shared/types\";\nimport {\n canWriteEffectiveAccessLevel,\n normalizeEffectiveAccessLevel,\n} from \"../../../data/keying/accessLevel\";\nimport type { DomainScope } from \"../../../data/shared/domainScope\";\nimport {\n type AttachmentRemovalRows,\n type AttachmentStagingRows,\n createDocumentProjectionUserKeyResolver,\n type DocumentProjectionUserKeyResolver,\n type DocumentRecord,\n type DocumentSyncLane,\n type DocumentsPersistence,\n type PendingAttachmentRecord,\n type PendingUpdateInsert,\n resolveDocumentCreateAuthor,\n} from \"../../../workflows/documents\";\nimport type { DocumentSnapshot, DocumentsRuntime } from \"../types\";\nimport {\n getAttachmentStatuses,\n getAttachmentStorageKeys,\n} from \"./attachments/attachmentSnapshot\";\nexport type DocumentState = Awaited<ReturnType<typeof createDocument>>;\nexport type EncapsulationKeyPair = NonNullable<\n DocumentsRuntime[\"crypto\"][\"encapsulationKeyPair\"]\n>;\nexport type DocumentAttachmentBinding = NonNullable<\n Awaited<ReturnType<DocumentsRuntime[\"apiClient\"][\"listDocumentAttachments\"]>>\n>[number];\nexport type PendingMutationSyncResult = {\n completed: boolean;\n nextRecord: DocumentRecord;\n};\nexport interface PersistedDocumentRecord {\n creationSuperseded?: true;\n historyRestoreState?:\n | Awaited<ReturnType<DocumentsPersistence[\"loadHistoryRestoreState\"]>>\n | undefined;\n pullContinuationSuperseded?: true;\n record: DocumentRecord;\n syncIdentitySuperseded?: true;\n updatedAt?: string | undefined;\n}\nexport interface SaveDocumentRecordOptions {\n acceptedPendingUpdateIds?: readonly string[] | undefined;\n attachmentRemoval?: AttachmentRemovalRows | undefined;\n attachmentStaging?: AttachmentStagingRows | undefined;\n clearSyncFailure?: boolean | undefined;\n expectedSyncState?:\n | {\n pullContinuation: DocumentSyncPullContinuation | null;\n record: DocumentRecord;\n }\n | undefined;\n historyCheckpoint?:\n | {\n coveredTailIds: readonly string[];\n endVersionVector: string;\n pruneCoveredLocalState: boolean;\n snapshot: string;\n }\n | undefined;\n historyUpdateOrigin?: \"local\" | \"remote\" | undefined;\n historyUpdates?: readonly string[] | undefined;\n pendingUpdate?: Omit<PendingUpdateInsert, \"localId\"> | undefined;\n pendingBaseVersionOverride?: string | null | undefined;\n preserveSnapshotStructuredFields?: boolean | undefined;\n preserveSnapshotText?: boolean | undefined;\n stillCurrent?: (() => boolean) | undefined;\n}\nexport interface DocumentSyncAttempt {\n consumedPullContinuation: DocumentSyncPullContinuation | null;\n outgoingUpdateCount: number;\n requestRecord: DocumentRecord;\n synced: SyncRemoteDocumentResult;\n /** `writerProjectionGeneration` when the request left; gates the install. */\n writerProjectionGeneration: number;\n}\nexport interface DocumentStorePersistenceEffects {\n emitPersistedDocument: (\n domainScope: DomainScope,\n persistedDocument: DocumentSummary,\n placementChanged?: boolean | undefined,\n ) => void;\n registerDocumentIdentity: (\n domainScope: DomainScope,\n localId: string,\n documentId: string | null,\n ) => void;\n}\nexport interface DocumentStoreState {\n attachmentBlobIdBySlotId: Record<string, string | null>;\n /** Plaintext digest of the held bytes per slot; see `getAttachmentStatuses`. */\n attachmentContentSha256BySlotId: Record<string, string>;\n attachmentStorageKeyBySlotId: Record<string, string>;\n /** Creation's birth rides the first attach; see `deferredInitialUpdate.ts`. */\n deferInitialUpdate?: boolean;\n doc: DocumentState | null;\n effects: DocumentStorePersistenceEffects;\n initialDocumentId: string | null;\n initialDocumentKind: StoredDocumentKind;\n initialText: string;\n initializePromise: Promise<void> | null;\n initialized: boolean;\n lastEventCount: number;\n /** Invalidates queued local-write closures when this store is cleared. */\n localWriteGeneration: number;\n locallyAcceptedUpdateIds: Set<string>;\n localId: string;\n listeners: Set<() => void>;\n pendingAttachments: PendingAttachmentRecord[];\n /**\n * Oplog version through which every op in `doc` is already durably enqueued as\n * a pending update or synced from a remote peer. It advances only after an\n * edit's enqueue+persist succeeds, so a later edit can recover any orphaned\n * delta left by a failed write instead of silently dropping it from sync.\n * `null` only before initialization sets it to the loaded doc's version.\n */\n pendingBaseVersion: string | null;\n /**\n * Local text/structured writes queued on `writeChain` but not yet drained.\n * While positive, sync MUST preserve the optimistic text/fields because `doc`\n * can lag the latest keystroke. Remote merges remain in `doc` and publish when\n * the final write settles.\n */\n pendingLocalWrites: number;\n persistence: DocumentsPersistence;\n /**\n * Durable continuation for a bounded remote pull, mirrored from the document\n * record so the live lane can advance it without re-reading SQLite.\n */\n pullContinuation: DocumentSyncPullContinuation | null;\n record: DocumentRecord | null;\n /** Served bindings hydration refused for a held copy; see `hydrate.ts`. */\n rejectedServedAttachmentBindings: Set<string>;\n /**\n * Consecutive completed sync passes that re-keyed conflicted pending updates\n * without settling anything. Bounds the rekey-driven self re-arm so a server\n * that keeps conflicting fresh ids cannot drive a network-speed loop; see\n * shouldReArmAfterOutgoingSettlement.\n */\n rekeyOnlyPassCount: number;\n resolveProjectionUserKey: DocumentProjectionUserKeyResolver;\n /** Latest remote-update sequence durably applied by a completed probe. */\n remoteUpdateCompletedSignalSeq: number;\n /** A cancelled remote-only owner blocks late responses until fresh work. */\n remoteSyncBlocked: boolean;\n scheduleStartupRemoteSync: boolean;\n remoteUpdatePending: boolean;\n /** Sequence used to keep an older pass from clearing a newer remote event. */\n remoteUpdateSignalSeq: number;\n runtime: DocumentsRuntime;\n snapshot: DocumentSnapshot;\n syncLane: DocumentSyncLane | null;\n /** Parked behind another member's ancestor repair; a path hint re-runs. */\n awaitingAncestorRepair: boolean;\n writeChain: Promise<void>;\n writerProjection: DocumentWriterProjectionResponse | null;\n /**\n * Bumped whenever a realtime hint drops `writerProjection`; an operation that\n * fetched or was handed a projection installs it only if this is unchanged\n * since it started, so a pre-hint answer never lands after the hint.\n */\n writerProjectionGeneration: number;\n}\nconst EMPTY_DOCUMENT_SNAPSHOT: DocumentSnapshot = {\n attachments: [],\n attachmentStatusBySlotId: {},\n attachmentStorageKeyBySlotId: {},\n canAttach: false,\n canWrite: true,\n currentAuthorId: null,\n documentId: null,\n documentKind: DEFAULT_DOCUMENT_KIND,\n effectiveAccessLevel: \"admin\",\n fieldValidationIssues: [],\n ready: false,\n rows: [],\n structuredFields: {},\n text: \"\",\n title: \"\",\n syncing: false,\n};\nfunction shallowEqualRecord<Value>(\n left: Readonly<Record<string, Value>>,\n right: Readonly<Record<string, Value>>,\n): boolean {\n let leftKeyCount = 0;\n for (const key in left) {\n if (!Object.hasOwn(left, key)) continue;\n\n leftKeyCount += 1;\n if (!Object.hasOwn(right, key) || !Object.is(left[key], right[key])) {\n return false;\n }\n }\n\n let rightKeyCount = 0;\n for (const key in right) {\n if (Object.hasOwn(right, key)) {\n rightKeyCount += 1;\n }\n }\n\n return leftKeyCount === rightKeyCount;\n}\n\nfunction sameValidationIssues(\n left: DocumentSnapshot[\"fieldValidationIssues\"],\n right: DocumentSnapshot[\"fieldValidationIssues\"],\n): boolean {\n return (\n left.length === right.length &&\n left.every((issue, index) => {\n const nextIssue = right[index];\n return (\n nextIssue !== undefined &&\n issue.field === nextIssue.field &&\n issue.message === nextIssue.message &&\n Object.is(issue.value, nextIssue.value)\n );\n })\n );\n}\n\nexport function createDocumentStoreState(\n localId: string,\n initialRuntime: DocumentsRuntime,\n persistence: DocumentsPersistence,\n effects: DocumentStorePersistenceEffects,\n initialDocumentId: string | null,\n initialText = \"\",\n initialDocumentKind: StoredDocumentKind = DEFAULT_DOCUMENT_KIND,\n scheduleStartupRemoteSync = true,\n): DocumentStoreState {\n return {\n attachmentBlobIdBySlotId: {},\n attachmentContentSha256BySlotId: {},\n attachmentStorageKeyBySlotId: {},\n doc: null,\n effects,\n initialDocumentId,\n initialDocumentKind,\n initialText,\n initializePromise: null,\n initialized: false,\n lastEventCount: 0,\n localWriteGeneration: 0,\n locallyAcceptedUpdateIds: new Set(),\n localId,\n listeners: new Set(),\n pendingAttachments: [],\n pendingBaseVersion: null,\n pendingLocalWrites: 0,\n persistence,\n pullContinuation: null,\n record: null,\n rejectedServedAttachmentBindings: new Set(),\n rekeyOnlyPassCount: 0,\n resolveProjectionUserKey:\n createDocumentProjectionUserKeyResolver(initialRuntime),\n remoteUpdateCompletedSignalSeq: 0,\n remoteSyncBlocked: !scheduleStartupRemoteSync,\n scheduleStartupRemoteSync,\n awaitingAncestorRepair: false,\n remoteUpdatePending: false,\n remoteUpdateSignalSeq: 0,\n runtime: initialRuntime,\n snapshot: { ...EMPTY_DOCUMENT_SNAPSHOT },\n syncLane: null,\n writeChain: Promise.resolve(),\n writerProjection: null,\n writerProjectionGeneration: 0,\n };\n}\n\nfunction emitDocumentStore(state: DocumentStoreState) {\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nexport function setDocumentSnapshot(\n state: DocumentStoreState,\n next: DocumentSnapshot,\n) {\n if (\n sameDocumentAttachments(state.snapshot.attachments, next.attachments) &&\n shallowEqualRecord(\n state.snapshot.attachmentStatusBySlotId,\n next.attachmentStatusBySlotId,\n ) &&\n shallowEqualRecord(\n state.snapshot.attachmentStorageKeyBySlotId,\n next.attachmentStorageKeyBySlotId,\n ) &&\n state.snapshot.canAttach === next.canAttach &&\n state.snapshot.canWrite === next.canWrite &&\n state.snapshot.currentAuthorId === next.currentAuthorId &&\n state.snapshot.documentId === next.documentId &&\n state.snapshot.documentKind === next.documentKind &&\n state.snapshot.effectiveAccessLevel === next.effectiveAccessLevel &&\n sameValidationIssues(\n state.snapshot.fieldValidationIssues,\n next.fieldValidationIssues,\n ) &&\n state.snapshot.ready === next.ready &&\n sameDocumentRows(state.snapshot.rows, next.rows) &&\n shallowEqualRecord(\n state.snapshot.structuredFields,\n next.structuredFields,\n ) &&\n state.snapshot.text === next.text &&\n state.snapshot.title === next.title &&\n state.snapshot.syncing === next.syncing\n ) {\n return;\n }\n\n state.snapshot = next;\n emitDocumentStore(state);\n}\n\nfunction clearDocumentStoreState(\n state: DocumentStoreState,\n { initialized }: { initialized: boolean },\n) {\n state.deferInitialUpdate = false;\n state.doc = null;\n state.localWriteGeneration += 1;\n state.record = null;\n state.pendingAttachments = [];\n state.pendingBaseVersion = null;\n state.pendingLocalWrites = 0;\n state.pullContinuation = null;\n state.attachmentBlobIdBySlotId = {};\n state.attachmentContentSha256BySlotId = {};\n state.attachmentStorageKeyBySlotId = {};\n state.locallyAcceptedUpdateIds = new Set();\n state.rejectedServedAttachmentBindings = new Set();\n state.remoteUpdateCompletedSignalSeq = 0;\n state.remoteSyncBlocked = !state.scheduleStartupRemoteSync;\n state.awaitingAncestorRepair = false;\n state.remoteUpdatePending = false;\n state.remoteUpdateSignalSeq = 0;\n state.writerProjection = null;\n state.initialized = initialized;\n state.initializePromise = null;\n state.writeChain = Promise.resolve();\n setDocumentSnapshot(state, { ...EMPTY_DOCUMENT_SNAPSHOT });\n}\n\nexport function resetDocumentStore(state: DocumentStoreState) {\n clearDocumentStoreState(state, { initialized: false });\n}\n\nexport function markDocumentStoreRemoved(state: DocumentStoreState) {\n clearDocumentStoreState(state, { initialized: true });\n}\n\nexport function canAttachFiles(state: DocumentStoreState): boolean {\n return (\n canWriteDocument(state) &&\n state.runtime.infra.dbStatus === \"ready\" &&\n !!state.runtime.crypto.encapsulationKeyPair\n );\n}\n\nexport function canWriteDocument(state: DocumentStoreState): boolean {\n return canWriteEffectiveAccessLevel(state.record?.effectiveAccessLevel);\n}\n\nfunction getSnapshotAttachments(\n state: DocumentStoreState,\n currentDoc: DocumentState | null = state.doc,\n): DocumentAttachment[] {\n return currentDoc ? getDocumentAttachments(currentDoc) : [];\n}\n\nfunction getSnapshotRows(\n state: DocumentStoreState,\n currentDoc: DocumentState | null = state.doc,\n): DocumentRow[] {\n return currentDoc ? listDocumentRows(currentDoc) : [];\n}\n\nfunction resolveCurrentAuthorId(state: DocumentStoreState): string | null {\n return resolveDocumentCreateAuthor(state.runtime)?.signerUserId ?? null;\n}\n\nexport function setReadySnapshot(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n syncing: boolean,\n textOverride?: string,\n structuredFieldsOverride?: DocumentSnapshot[\"structuredFields\"],\n) {\n const attachments = getSnapshotAttachments(state, currentDoc);\n const rows = getSnapshotRows(state, currentDoc);\n const documentState = readStoredDocumentState(\n currentDoc,\n state.runtime.infra.documentProjectors,\n );\n const text = textOverride ?? documentState.text;\n const structuredFields =\n structuredFieldsOverride ?? documentState.structuredFields;\n const projectedState =\n textOverride === undefined && structuredFieldsOverride === undefined\n ? documentState\n : projectStoredDocumentState(\n {\n documentKind: documentState.documentKind,\n structuredFields,\n text,\n rows: rows.map((row) => ({ id: row.id, fields: row.fields })),\n },\n state.runtime.infra.documentProjectors,\n );\n\n setDocumentSnapshot(state, {\n attachments,\n attachmentStatusBySlotId: getAttachmentStatuses({\n attachments,\n contentSha256BySlotId: state.attachmentContentSha256BySlotId,\n pendingSlotIds: new Set(\n state.pendingAttachments.map((attachment) => attachment.slotId),\n ),\n }),\n attachmentStorageKeyBySlotId: getAttachmentStorageKeys(\n state.attachmentStorageKeyBySlotId,\n attachments,\n ),\n canAttach: canAttachFiles(state),\n canWrite: canWriteDocument(state),\n currentAuthorId: resolveCurrentAuthorId(state),\n documentId: state.record?.documentId ?? null,\n documentKind: projectedState.documentKind,\n effectiveAccessLevel: normalizeEffectiveAccessLevel(\n state.record?.effectiveAccessLevel,\n ),\n fieldValidationIssues: projectedState.fieldValidationIssues,\n ready: true,\n rows,\n structuredFields: projectedState.structuredFields,\n text,\n title: projectedState.title,\n syncing,\n });\n}\n\nexport function setDocumentSyncing(\n state: DocumentStoreState,\n syncing: boolean,\n) {\n setDocumentSnapshot(state, { ...state.snapshot, syncing });\n}\n\nexport function refreshAttachabilitySnapshot(state: DocumentStoreState) {\n if (!state.snapshot.ready) {\n return;\n }\n\n setDocumentSnapshot(state, {\n ...state.snapshot,\n canAttach: canAttachFiles(state),\n canWrite: canWriteDocument(state),\n effectiveAccessLevel: normalizeEffectiveAccessLevel(\n state.record?.effectiveAccessLevel,\n ),\n });\n}\n\nexport function subscribeToDocumentStore(\n state: DocumentStoreState,\n listener: () => void,\n) {\n state.listeners.add(listener);\n return () => void state.listeners.delete(listener);\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { reportAndRethrowKeyingVerificationError } from "
|
|
2
|
-
import { isDatabaseUnavailableError, registerDocumentSyncLane, resolveDocumentCreateAuthor, } from "
|
|
3
|
-
import { requestDocumentStoreSync } from "
|
|
4
|
-
import { awaitInitializationForSync } from "
|
|
5
|
-
import { listPendingUpdates } from "
|
|
1
|
+
import { reportAndRethrowKeyingVerificationError } from "../../../../data/keyingProjectionVerification/error.js";
|
|
2
|
+
import { isDatabaseUnavailableError, registerDocumentSyncLane, resolveDocumentCreateAuthor, } from "../../../../workflows/documents/index.js";
|
|
3
|
+
import { requestDocumentStoreSync } from "../../registry.js";
|
|
4
|
+
import { awaitInitializationForSync } from "../initialization/index.js";
|
|
5
|
+
import { listPendingUpdates } from "../persistence.js";
|
|
6
|
+
import { setDocumentSyncing, } from "../state.js";
|
|
6
7
|
import { logRevalidationUnavailable as logUnavailable } from "./remoteRevalidationTelemetry.js";
|
|
7
8
|
import { getActiveDocumentRemoteWork, runDocumentRemoteWork, } from "./remoteWork.js";
|
|
8
|
-
import { setDocumentSyncing, } from "./state.js";
|
|
9
9
|
import { cleanupPreRegisteredUpdateIdsOnFailure, discardPreRegisteredUpdateIds, preRegisterMaterializedDocumentSyncUpdateIds, } from "./syncAcceptedUpdateIds.js";
|
|
10
10
|
import { syncPendingAttachments } from "./syncAttachments.js";
|
|
11
11
|
import { syncDetachedAttachmentBindings } from "./syncDetachedAttachments.js";
|
|
@@ -296,4 +296,4 @@ export function registerDocumentStoreSyncLane(state, getSyncLaneGeneration) {
|
|
|
296
296
|
},
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
-
//# sourceMappingURL=
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uCAAuC,EAAE,MAAM,qDAAqD,CAAC;AAC9G,OAAO,EAGL,0BAA0B,EAE1B,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAKL,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,0BAA0B,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sCAAsC,EACtC,6BAA6B,EAC7B,4CAA4C,GAC7C,MAAM,yBAAyB,CAAC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AC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC;QACD,GAAG,EAAE,GAAG,EAAE;YACR,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;YACnD,IAAI,CAAC,kBAAkB;gBAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAClD,MAAM,UAAU,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;YACtD,IAAI,UAAU,EAAE,CAAC;gBACf,qEAAqE;gBACrE,uEAAuE;gBACvE,KAAK,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE;oBACxB,IACE,wCAAwC,CAAC,KAAK,EAAE,kBAAkB,CAAC,EACnE,CAAC;wBACD,wBAAwB,CAAC,KAAK,CAAC,CAAC;oBAClC,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;YACD,OAAO,qBAAqB,CAAC,KAAK,EAAE,GAAG,EAAE,CACvC,wCAAwC,CAAC,KAAK,EAAE,kBAAkB,CAAC;gBACjE,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,CAAC;gBACjD,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CACtB,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { reportAndRethrowKeyingVerificationError } from \"../../../../data/keyingProjectionVerification/error\";\nimport {\n type DocumentRecord,\n type DocumentSyncLane,\n isDatabaseUnavailableError,\n type PendingUpdateRecord,\n registerDocumentSyncLane,\n resolveDocumentCreateAuthor,\n} from \"../../../../workflows/documents\";\nimport { requestDocumentStoreSync } from \"../../registry\";\nimport { awaitInitializationForSync } from \"../initialization\";\nimport { listPendingUpdates } from \"../persistence\";\nimport {\n type DocumentState,\n type DocumentStoreState,\n type DocumentSyncAttempt,\n type EncapsulationKeyPair,\n setDocumentSyncing,\n} from \"../state\";\nimport { logRevalidationUnavailable as logUnavailable } from \"./remoteRevalidationTelemetry\";\nimport {\n getActiveDocumentRemoteWork,\n runDocumentRemoteWork,\n} from \"./remoteWork\";\nimport {\n cleanupPreRegisteredUpdateIdsOnFailure,\n discardPreRegisteredUpdateIds,\n preRegisterMaterializedDocumentSyncUpdateIds,\n} from \"./syncAcceptedUpdateIds\";\nimport { syncPendingAttachments } from \"./syncAttachments\";\nimport { syncDetachedAttachmentBindings } from \"./syncDetachedAttachments\";\nimport { finalizeDocumentSync } from \"./syncFinalize\";\nimport {\n captureDocumentStoreAttachmentSyncGeneration,\n captureDocumentStoreRemoteSyncGeneration,\n captureDocumentStoreSyncGeneration,\n type DocumentStoreSyncGeneration,\n type DocumentStoreSyncLaneGeneration,\n isDocumentStoreRemoteSyncBlocked,\n isDocumentStoreSyncGenerationCurrent,\n isDocumentStoreSyncLaneGenerationCurrent,\n} from \"./syncGeneration\";\nimport { prepareDocumentOutgoingCoverage } from \"./syncOutgoingCoverage\";\nimport { requestRemoteDocumentSync } from \"./syncRequest\";\nimport {\n ensureRemoteDocument,\n isContainerAwaitingRemoteCreate,\n shouldSkipCleanScheduledDocumentSync,\n} from \"./syncShared\";\n\nfunction canRunScheduledSync(state: DocumentStoreState): boolean {\n return (\n // A deferred birth waits for its attach to carry it (see\n // deferredInitialUpdate.ts); a pass now would ship it on its own.\n state.deferInitialUpdate !== true &&\n state.doc !== null &&\n state.snapshot.ready &&\n state.runtime.state.online &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.crypto.encapsulationKeyPair !== null &&\n resolveDocumentCreateAuthor(state.runtime) !== null\n );\n}\n\nasync function requestOutgoingDocumentBatch(input: {\n readonly currentDoc: DocumentState;\n readonly encapsulationKeyPair: EncapsulationKeyPair;\n readonly generation: DocumentStoreSyncGeneration;\n readonly pendingUpdates: PendingUpdateRecord[];\n readonly record: DocumentRecord;\n readonly state: DocumentStoreState;\n}): Promise<{\n sentUpdateIds: string[];\n syncAttempt: DocumentSyncAttempt | null;\n}> {\n const { planningUpdates, queuedUpdateCount } = prepareDocumentStoreSyncQueue(\n input.pendingUpdates,\n );\n const sentUpdateIds: string[] = [];\n const syncAttempt = await cleanupPreRegisteredUpdateIdsOnFailure(\n input.state,\n sentUpdateIds,\n () =>\n requestRemoteDocumentSync({\n currentDoc: input.currentDoc,\n currentRecord: input.record,\n encapsulationKeyPair: input.encapsulationKeyPair,\n generation: input.generation,\n onOutgoingUpdatesMaterialized: (updateIds) =>\n preRegisterMaterializedDocumentSyncUpdateIds(\n input.state,\n sentUpdateIds,\n updateIds,\n ),\n pendingUpdates: planningUpdates,\n queuedUpdateCount,\n state: input.state,\n unavailableWriterLogMessage:\n \"Documents: skipped sync because the writer context is unavailable.\",\n }),\n );\n return { sentUpdateIds, syncAttempt };\n}\n\n/**\n * Keep the full durable queue visible to stale-heal/checkpoint classification.\n * The workflow planner owns the final count and byte bounds, and the exact\n * materialized batch is pre-registered immediately before each submit.\n */\nexport function prepareDocumentStoreSyncQueue(\n pendingUpdates: PendingUpdateRecord[],\n): {\n planningUpdates: PendingUpdateRecord[];\n queuedUpdateCount: number;\n} {\n return {\n planningUpdates: pendingUpdates,\n queuedUpdateCount: pendingUpdates.length,\n };\n}\n\nexport function canSyncDetachedAttachmentBindings(\n record: DocumentRecord,\n pendingUpdateCount: number,\n): boolean {\n return (\n pendingUpdateCount === 0 &&\n (record.pullContinuation ?? null) === null &&\n !record.pullContinuationRecoveryRequired\n );\n}\n\nasync function syncDocumentState(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n nextRecord: DocumentRecord,\n encapsulationKeyPair: EncapsulationKeyPair,\n generation: DocumentStoreSyncGeneration,\n): Promise<DocumentRecord> {\n // Snapshot the remote-update signal sequence before any await. The GET below\n // fetches server state as of its own snapshot; any remote event delivered\n // after this point describes an update that may not be in that response, so\n // finalizeDocumentSync must not clear the signal if this sequence has moved.\n const consumedRemoteUpdateSignalSeq = state.remoteUpdateSignalSeq;\n const wasRemoteProbe = state.remoteUpdatePending;\n let pendingUpdates = await listPendingUpdates(state);\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return state.record ?? nextRecord;\n }\n if (pendingUpdates.length === 0 && isDocumentStoreRemoteSyncBlocked(state)) {\n return nextRecord;\n }\n // Create the remote document even when nothing is queued to send: a note\n // created and never edited enqueues no updates, but its local row is still a\n // pending create the write queue reports — it must flush, not sit. Defer\n // while the container itself still awaits its remote create — with OR\n // without queued edits, since the create cannot succeed before its parent\n // exists and attempting it just records a spurious failure. The structural\n // lane primes this store again as soon as the container create lands.\n if (!nextRecord.documentId) {\n const containerAwaitsCreate = await isContainerAwaitingRemoteCreate(state);\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return state.record ?? nextRecord;\n }\n if (containerAwaitsCreate) return nextRecord;\n }\n let nextRemoteRecord = await ensureRemoteDocument(\n state,\n currentDoc,\n nextRecord,\n encapsulationKeyPair,\n generation,\n );\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return state.record ?? nextRecord;\n }\n if (!nextRemoteRecord?.documentId) return nextRecord;\n\n const preparedCoverage = await prepareDocumentOutgoingCoverage({\n currentDoc,\n generation,\n pendingUpdates,\n state,\n });\n if (!preparedCoverage) {\n requestDocumentStoreSync(state);\n return state.record ?? nextRemoteRecord;\n }\n nextRemoteRecord = preparedCoverage.record;\n pendingUpdates = preparedCoverage.pendingUpdates;\n\n if (\n shouldSkipCleanScheduledDocumentSync({\n currentRecord: nextRemoteRecord,\n pendingUpdates,\n state,\n })\n ) {\n return nextRemoteRecord;\n }\n\n // Pre-register the IDs we are about to send so the author's OWN\n // `document_update_created` echo (fanned back over redis) is classified as\n // self-authored and never re-arms a redundant sync. Registering BEFORE the\n // network await closes the race where the echo lands before\n // finalizeDocumentSync records the accepted IDs — the gap that turned every\n // fast keystroke into an extra self-triggered sync.\n const { sentUpdateIds, syncAttempt } = await requestOutgoingDocumentBatch({\n currentDoc,\n encapsulationKeyPair,\n generation,\n pendingUpdates,\n record: nextRemoteRecord,\n state,\n });\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n discardPreRegisteredUpdateIds(state, sentUpdateIds);\n requestDocumentStoreSync(state);\n return state.record ?? nextRemoteRecord;\n }\n if (!syncAttempt) {\n discardPreRegisteredUpdateIds(state, sentUpdateIds);\n logUnavailable(state, wasRemoteProbe);\n return nextRemoteRecord;\n }\n\n return cleanupPreRegisteredUpdateIdsOnFailure(state, sentUpdateIds, () =>\n finalizeDocumentSync(\n state,\n currentDoc,\n nextRemoteRecord,\n syncAttempt,\n consumedRemoteUpdateSignalSeq,\n generation,\n sentUpdateIds,\n wasRemoteProbe,\n ),\n );\n}\n\nasync function revalidateRemoteDocumentBeforeAttachments(\n state: DocumentStoreState,\n currentDoc: DocumentState,\n nextRecord: DocumentRecord,\n encapsulationKeyPair: EncapsulationKeyPair,\n generation: DocumentStoreSyncGeneration,\n): Promise<{ canSyncAttachments: boolean; nextRecord: DocumentRecord }> {\n if (state.pendingAttachments.length === 0 || !nextRecord.documentId) {\n return { canSyncAttachments: true, nextRecord };\n }\n\n const consumedRemoteUpdateSignalSeq = state.remoteUpdateSignalSeq;\n const wasRemoteProbe = state.remoteUpdatePending;\n const syncAttempt = await requestRemoteDocumentSync({\n state,\n currentDoc,\n currentRecord: nextRecord,\n encapsulationKeyPair,\n generation,\n pendingUpdates: [],\n unavailableWriterLogMessage:\n \"Documents: skipped pre-attachment revalidation because the writer context is unavailable.\",\n });\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return { canSyncAttachments: false, nextRecord };\n }\n if (!syncAttempt) {\n logUnavailable(state, wasRemoteProbe);\n return { canSyncAttachments: false, nextRecord };\n }\n\n const refreshedRecord = await finalizeDocumentSync(\n state,\n currentDoc,\n nextRecord,\n syncAttempt,\n consumedRemoteUpdateSignalSeq,\n generation,\n [],\n wasRemoteProbe,\n );\n return {\n canSyncAttachments:\n !syncAttempt.synced.hasIncompletePull &&\n refreshedRecord.pullContinuation == null &&\n refreshedRecord.pullContinuationRecoveryRequired !== true &&\n isDocumentStoreSyncGenerationCurrent(state, generation),\n nextRecord: refreshedRecord,\n };\n}\n\nasync function runDocumentSyncPass(\n state: DocumentStoreState,\n syncLaneGeneration: DocumentStoreSyncLaneGeneration,\n) {\n const currentDoc = state.doc;\n const encapsulationKeyPair = state.runtime.crypto.encapsulationKeyPair;\n let nextRecord = state.record;\n\n if (!currentDoc || !nextRecord || !encapsulationKeyPair) {\n return;\n }\n\n const generation = captureDocumentStoreRemoteSyncGeneration(\n state,\n currentDoc,\n syncLaneGeneration,\n );\n const attachmentGeneration = captureDocumentStoreAttachmentSyncGeneration(\n state,\n currentDoc,\n syncLaneGeneration,\n );\n if (!generation || !attachmentGeneration) {\n requestDocumentStoreSync(state);\n return;\n }\n\n const revalidation = await revalidateRemoteDocumentBeforeAttachments(\n state,\n currentDoc,\n nextRecord,\n encapsulationKeyPair,\n generation,\n );\n nextRecord = revalidation.nextRecord;\n if (!revalidation.canSyncAttachments) {\n return;\n }\n\n const attachmentResult = await syncPendingAttachments(\n state,\n nextRecord,\n encapsulationKeyPair,\n attachmentGeneration,\n );\n nextRecord = attachmentResult.nextRecord;\n if (state.pendingAttachments.length > 0) {\n return;\n }\n // A settled bind and the content update carrying its digest are two server\n // writes. Push the content in this same pass rather than re-arming a later\n // one, so a device lost between them is the only remaining window: peers\n // otherwise see the old digest against the new binding.\n\n nextRecord = await syncDocumentState(\n state,\n currentDoc,\n nextRecord,\n encapsulationKeyPair,\n generation,\n );\n\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return;\n }\n\n if (!state.doc || !state.record) return;\n\n const pendingUpdates = await listPendingUpdates(state);\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n return;\n }\n if (!canSyncDetachedAttachmentBindings(nextRecord, pendingUpdates.length)) {\n return;\n }\n\n await syncDetachedAttachmentBindings(state, nextRecord, generation);\n if (!isDocumentStoreSyncGenerationCurrent(state, generation)) {\n requestDocumentStoreSync(state);\n }\n}\n\nasync function runScheduledSyncIteration(\n state: DocumentStoreState,\n syncLaneGeneration: DocumentStoreSyncLaneGeneration,\n) {\n if (!(await awaitInitializationForSync(state))) {\n return false;\n }\n if (!isDocumentStoreSyncLaneGenerationCurrent(state, syncLaneGeneration)) {\n return true;\n }\n\n if (!canRunScheduledSync(state)) {\n return true;\n }\n\n try {\n await runDocumentSyncPass(state, syncLaneGeneration);\n return true;\n } catch (error) {\n if (isDatabaseUnavailableError(error)) {\n return false;\n }\n\n await reportAndRethrowKeyingVerificationError(\n error,\n state.runtime.util.reportSecurityIncident,\n {\n objectId: state.record?.documentId ?? state.localId,\n objectKind: \"document\",\n operation: \"document.sync\",\n },\n );\n\n throw error;\n }\n}\n\nasync function runScheduledSyncLoop(\n state: DocumentStoreState,\n syncLaneGeneration: DocumentStoreSyncLaneGeneration,\n) {\n const syncingGeneration = captureDocumentStoreSyncGeneration(\n state,\n state.doc,\n );\n setDocumentSyncing(state, true);\n\n try {\n await runScheduledSyncIteration(state, syncLaneGeneration);\n } finally {\n if (\n syncingGeneration &&\n isDocumentStoreSyncGenerationCurrent(state, syncingGeneration) &&\n isDocumentStoreSyncLaneGenerationCurrent(state, syncLaneGeneration)\n ) {\n setDocumentSyncing(state, false);\n }\n }\n}\n\nexport function registerDocumentStoreSyncLane(\n state: DocumentStoreState,\n getSyncLaneGeneration: () => DocumentStoreSyncLaneGeneration | null,\n): DocumentSyncLane {\n return registerDocumentSyncLane({\n domainScope: state.runtime.state.domainScope,\n localId: state.localId,\n priority: () =>\n state.remoteUpdatePending || state.record?.snapshotEndVersion === \"\"\n ? -1\n : 0,\n logError: (message, error) => {\n // Read the runtime lazily: a store's runtime is replaced in place, and a\n // reference captured here would report into a torn-down host.\n const { log, logError } = state.runtime.util;\n // Return the host's result: both callbacks are declared `=> void` but may\n // be async, and the lane reporter only catches a rejection it is handed.\n return logError ? logError(message, error) : log(message);\n },\n run: () => {\n const syncLaneGeneration = getSyncLaneGeneration();\n if (!syncLaneGeneration) return Promise.resolve();\n const activeWork = getActiveDocumentRemoteWork(state);\n if (activeWork) {\n // Re-arm on settlement, not immediately: immediate re-requests would\n // spin this lane and starve other work while the HTTP request is held.\n void activeWork.then(() => {\n if (\n isDocumentStoreSyncLaneGenerationCurrent(state, syncLaneGeneration)\n ) {\n requestDocumentStoreSync(state);\n }\n });\n return Promise.resolve();\n }\n return runDocumentRemoteWork(state, () =>\n isDocumentStoreSyncLaneGenerationCurrent(state, syncLaneGeneration)\n ? runScheduledSyncLoop(state, syncLaneGeneration)\n : Promise.resolve(),\n );\n },\n });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { documentSyncPullContinuationsEqual, runSerializedSqlMutation, } from "
|
|
2
|
-
import { importDurableDocumentHistory } from "
|
|
3
|
-
import { setReadySnapshot } from "
|
|
1
|
+
import { documentSyncPullContinuationsEqual, runSerializedSqlMutation, } from "../../../../workflows/documents/index.js";
|
|
2
|
+
import { importDurableDocumentHistory } from "../history/durableDocumentReload.js";
|
|
3
|
+
import { setReadySnapshot } from "../state.js";
|
|
4
4
|
import { isDocumentStoreSyncGenerationCurrent, } from "./syncGeneration.js";
|
|
5
5
|
import { documentSyncContextMatches } from "./syncUpdateImport.js";
|
|
6
6
|
export async function invalidateDocumentStorePullContinuation(input) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullContinuationInvalidation.js","sourceRoot":"","sources":["pullContinuationInvalidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kCAAkC,EAClC,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAA2B,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,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,KAAK,EACL,OAAO,EACP,KAAK,CAAC,QAAQ,CAAC,OAAO,EACtB,4BAA4B,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC9D,4BAA4B;YAC1B,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB;YACjC,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type DocumentRecord,\n type DocumentSyncPullContinuation,\n documentSyncPullContinuationsEqual,\n runSerializedSqlMutation,\n} from \"../../../../workflows/documents\";\nimport { importDurableDocumentHistory } from \"../history/durableDocumentReload\";\nimport { type DocumentStoreState, setReadySnapshot } from \"../state\";\nimport {\n type DocumentStoreSyncGeneration,\n isDocumentStoreSyncGenerationCurrent,\n} from \"./syncGeneration\";\nimport { documentSyncContextMatches } from \"./syncUpdateImport\";\n\nexport async function invalidateDocumentStorePullContinuation(input: {\n continuation: DocumentSyncPullContinuation;\n currentRecord: DocumentRecord;\n generation: DocumentStoreSyncGeneration;\n state: DocumentStoreState;\n}): Promise<void> {\n const { continuation, currentRecord, generation, state } = input;\n const documentId = currentRecord.documentId;\n const liveDoc = generation.currentDoc;\n if (\n !documentId ||\n !liveDoc ||\n !isDocumentStoreSyncGenerationCurrent(state, generation)\n ) {\n return;\n }\n\n await runSerializedSqlMutation(generation.execSql, async (lockedExecSql) => {\n const invalidated = await state.persistence.invalidatePullContinuation(\n lockedExecSql,\n {\n accessEpoch: currentRecord.accessEpoch,\n accessStateHash: currentRecord.accessStateHash ?? null,\n continuation,\n contentKeyBundle: currentRecord.contentKeyBundle ?? null,\n documentId,\n documentKekTargets: currentRecord.documentKekTargets ?? null,\n documentManifestBundle: currentRecord.documentManifestBundle ?? null,\n lastCommitLsn: currentRecord.lastCommitLsn ?? null,\n localId: currentRecord.id,\n },\n );\n if (!invalidated) return;\n const { historyRestoreState, record: durableRecord } = invalidated;\n const canAdoptDurableRecord = () =>\n isDocumentStoreSyncGenerationCurrent(state, generation) &&\n documentSyncContextMatches(state.record, currentRecord, documentId) &&\n durableRecord.id === currentRecord.id &&\n durableRecord.documentId === documentId &&\n durableRecord.accessEpoch === currentRecord.accessEpoch &&\n (durableRecord.accessStateHash ?? null) ===\n (currentRecord.accessStateHash ?? null) &&\n (durableRecord.contentKeyBundle ?? null) ===\n (currentRecord.contentKeyBundle ?? null) &&\n (durableRecord.documentKekTargets ?? null) ===\n (currentRecord.documentKekTargets ?? null) &&\n (durableRecord.documentManifestBundle ?? null) ===\n (currentRecord.documentManifestBundle ?? null) &&\n documentSyncPullContinuationsEqual(state.pullContinuation, continuation);\n if (!canAdoptDurableRecord()) return;\n importDurableDocumentHistory(liveDoc, historyRestoreState);\n if (!canAdoptDurableRecord()) {\n return;\n }\n const {\n pullContinuation: _stalePullContinuation,\n pullContinuationRecoveryRequired: _staleRecoveryMarker,\n ...liveRecord\n } = state.record ?? currentRecord;\n state.record = { ...liveRecord, ...durableRecord };\n state.pullContinuation = durableRecord.pullContinuation ?? null;\n state.pendingBaseVersion =\n durableRecord.pendingBaseVersion ?? durableRecord.snapshotEndVersion;\n const preserveOptimisticProjection = state.pendingLocalWrites > 0;\n setReadySnapshot(\n state,\n liveDoc,\n state.snapshot.syncing,\n preserveOptimisticProjection ? state.snapshot.text : undefined,\n preserveOptimisticProjection\n ? state.snapshot.structuredFields\n : undefined,\n );\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDocumentAttachments } from "
|
|
1
|
+
import { getDocumentAttachments } from "../../../../data/documents/documentContent.js";
|
|
2
2
|
export function logRevalidationScheduled(runtime, reason) {
|
|
3
3
|
runtime.util.log(`Documents: remote revalidation scheduled reason=${reason}`);
|
|
4
4
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteRevalidationTelemetry.js","sourceRoot":"","sources":["remoteRevalidationTelemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAIpF,MAAM,UAAU,wBAAwB,CACtC,OAAyB,EACzB,MAA+B;IAE/B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,mDAAmD,MAAM,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAyB,EACzB,GAAkB,EAClB,mBAA2B,EAC3B,SAAkB;IAElB,IAAI,CAAC,SAAS;QAAE,OAAO;IACvB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,iEAAiE,mBAAmB,oBAAoB,sBAAsB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAC7I,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAyB,EACzB,SAAkB;IAElB,IAAI,CAAC,SAAS;QAAE,OAAO;IACvB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import { getDocumentAttachments } from \"../../../../data/documents/documentContent\";\nimport type { DocumentsRuntime } from \"../../types\";\nimport type { DocumentState, DocumentStoreState } from \"../state\";\n\nexport function logRevalidationScheduled(\n runtime: DocumentsRuntime,\n reason: \"reconnect\" | \"startup\",\n): void {\n runtime.util.log(`Documents: remote revalidation scheduled reason=${reason}`);\n}\n\nexport function logRevalidationApplied(\n state: DocumentStoreState,\n doc: DocumentState,\n incomingUpdateCount: number,\n requested: boolean,\n): void {\n if (!requested) return;\n state.runtime.util.log(\n `Documents: remote revalidation result=applied incomingUpdates=${incomingUpdateCount} attachmentSlots=${getDocumentAttachments(doc).length}`,\n );\n}\n\nexport function logRevalidationUnavailable(\n state: DocumentStoreState,\n requested: boolean,\n): void {\n if (!requested) return;\n state.runtime.util.log(\"Documents: remote revalidation result=unavailable\");\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteWork.js","sourceRoot":"","sources":["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ClC,CAAC;IACH,CAAC,CAAC,CAAC;IACL,MAAM,MAAM,GAAG;QACb,UAAU;QACV,IAAI,EAAE,IAAI,CAAC,IAAI,CACb,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB;KACF,CAAC;IACF,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { DocumentStoreState } from \"../state\";\nimport {\n captureDocumentStoreGenerationIdentity,\n captureDocumentStoreSyncLaneGeneration,\n type DocumentStoreSyncLaneGeneration,\n isDocumentStoreGenerationIdentityCurrent,\n} from \"./syncGeneration\";\n\nconst remoteWorkByState = new WeakMap<\n DocumentStoreState,\n {\n generation: DocumentStoreSyncLaneGeneration &\n ReturnType<typeof captureDocumentStoreGenerationIdentity>;\n tail: Promise<void>;\n }\n>();\n\nexport class DocumentRemoteWorkBusyError extends Error {\n constructor(readonly whenIdle: Promise<void>) {\n super(\"Document remote work is still running; retry the operation\");\n this.name = \"DocumentRemoteWorkBusyError\";\n }\n}\n\nexport function getActiveDocumentRemoteWork(\n state: DocumentStoreState,\n): Promise<void> | null {\n const active = remoteWorkByState.get(state);\n return active &&\n isDocumentStoreGenerationIdentityCurrent(state, active.generation)\n ? active.tail\n : null;\n}\n\n/** A document lane retries instead of waiting on overlapping remote work. */\nexport function runDocumentRemoteWork<T>(\n state: DocumentStoreState,\n task: () => Promise<T>,\n): Promise<T> {\n const pending = getActiveDocumentRemoteWork(state);\n if (pending) {\n return Promise.reject(new DocumentRemoteWorkBusyError(pending));\n }\n // Database/runtime replacement abandons ownership; ordinary local edits do not.\n const generation = {\n ...captureDocumentStoreGenerationIdentity(state),\n ...captureDocumentStoreSyncLaneGeneration(state),\n };\n const work = Promise.resolve()\n .then(task)\n .finally(() => {\n if (remoteWorkByState.get(state) === active) {\n remoteWorkByState.delete(state);\n }\n });\n const active = {\n generation,\n tail: work.then(\n () => undefined,\n () => undefined,\n ),\n };\n remoteWorkByState.set(state, active);\n return work;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syncAcceptedUpdateIds.js","sourceRoot":"","sources":["syncAcceptedUpdateIds.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,6BAA6B,CAC3C,KAAyB,EACzB,aAAgC;IAEhC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,KAAyB,EACzB,cAAsD;IAEtD,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,KAAK,CAAC,wBAAwB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,4CAA4C,CAC1D,KAAyB,EACzB,mBAA6B,EAC7B,qBAAwC;IAExC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CACjD,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAC/C,CAAC;IACF,mBAAmB,CAAC,IAAI,CACtB,GAAG,oBAAoB,CACrB,KAAK,EACL,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CACrC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,KAAyB,EACzB,aAAgC,EAChC,iBAAoC;IAEpC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC5C,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,KAAyB,EACzB,aAAgC,EAChC,IAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,6BAA6B,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { DocumentStoreState } from \"../state\";\n\nexport function discardPreRegisteredUpdateIds(\n state: DocumentStoreState,\n sentUpdateIds: readonly string[],\n): void {\n for (const sentUpdateId of sentUpdateIds) {\n state.locallyAcceptedUpdateIds.delete(sentUpdateId);\n }\n}\n\nfunction preRegisterUpdateIds(\n state: DocumentStoreState,\n pendingUpdates: ReadonlyArray<{ readonly id: string }>,\n): string[] {\n const sentUpdateIds = pendingUpdates.map((update) => update.id);\n for (const sentUpdateId of sentUpdateIds) {\n state.locallyAcceptedUpdateIds.add(sentUpdateId);\n }\n return sentUpdateIds;\n}\n\nexport function preRegisterMaterializedDocumentSyncUpdateIds(\n state: DocumentStoreState,\n registeredUpdateIds: string[],\n materializedUpdateIds: readonly string[],\n): void {\n const alreadyRegistered = new Set(registeredUpdateIds);\n const freshUpdateIds = materializedUpdateIds.filter(\n (updateId) => !alreadyRegistered.has(updateId),\n );\n registeredUpdateIds.push(\n ...preRegisterUpdateIds(\n state,\n freshUpdateIds.map((id) => ({ id })),\n ),\n );\n}\n\nexport function discardUnacceptedPreRegisteredUpdateIds(\n state: DocumentStoreState,\n sentUpdateIds: readonly string[],\n acceptedUpdateIds: readonly string[],\n): void {\n const accepted = new Set(acceptedUpdateIds);\n for (const sentUpdateId of sentUpdateIds) {\n if (!accepted.has(sentUpdateId)) {\n state.locallyAcceptedUpdateIds.delete(sentUpdateId);\n }\n }\n}\n\nexport async function cleanupPreRegisteredUpdateIdsOnFailure<T>(\n state: DocumentStoreState,\n sentUpdateIds: readonly string[],\n task: () => Promise<T>,\n): Promise<T> {\n try {\n return await task();\n } catch (error) {\n discardPreRegisteredUpdateIds(state, sentUpdateIds);\n throw error;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { deletePendingAttachment, saveLocalAttachmentRecord, } from "
|
|
2
|
-
import { setReadySnapshot, } from "
|
|
1
|
+
import { deletePendingAttachment, saveLocalAttachmentRecord, } from "../attachments/attachmentPersistence.js";
|
|
2
|
+
import { setReadySnapshot, } from "../state.js";
|
|
3
|
+
import { installDocumentWriterProjection } from "../writerProjectionGeneration.js";
|
|
3
4
|
import { isDocumentStoreSyncGenerationCurrent, } from "./syncGeneration.js";
|
|
4
|
-
import { installDocumentWriterProjection } from "./writerProjectionGeneration.js";
|
|
5
5
|
export function removeSettledPendingAttachment(state, currentDoc, pendingAttachment) {
|
|
6
6
|
// Every non-retry outcome removed the durable row: uploaded now, recovered
|
|
7
7
|
// after an ambiguous response, or discarded because local bytes vanished.
|