@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerContentsStore.js","sourceRoot":"","sources":["containerContentsStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,oEAAoE,CAAC;AACxH,OAAO,EAEL,mCAAmC,GACpC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EA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AC;IAC3D,OAAO,SAAS,CAAC,KAAK,CAAC;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uCAAuC,CACrD,WAAwB;IAExB,MAAM,KAAK,GAAG,8BAA8B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,sBAAsB,EAAE,CAAC;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { DomainScope } from \"../../data/shared/domainScope\";\nimport { getCachedContainerWriterProjection } from \"../../workflows/container-contents/container-state/projectionCache\";\nimport {\n type ContainerContentsPersistence,\n defaultContainerContentsPersistence,\n} from \"../../workflows/container-contents/containerPersistence\";\nimport { persistContainerState } from \"./containerStatePersistence\";\nimport { emptyTrash } from \"./emptyTrashOperation\";\nimport {\n prepareContainerGroupRewrap,\n verifyContainerGroupRewrapCurrent,\n} from \"./groupRewrapOperation\";\nimport {\n createChildContainer,\n deleteContainer,\n ensureSystemContainer,\n moveContainer,\n renameContainer,\n} from \"./operations\";\nimport { purgeContainer } from \"./purgeContainerOperation\";\nimport { invalidateRemoteContainerWrites } from \"./remoteWriteGuards\";\nimport { chainRemoteContainerTask } from \"./remoteWriteQueue\";\nimport { setContainerIcon } from \"./setContainerIconOperation\";\nimport {\n shareContainerWithGroup,\n shareContainerWithUser,\n} from \"./shareOperations\";\nimport {\n createContainerContentsStoreState,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStorePersistence,\n updateContainerContentsStoreRuntime,\n} from \"./state\";\nimport {\n type ContainerContentsStoreRuntime,\n type ContainerContentsStoreSyncAgent,\n createContainerContentsStoreSyncAgent,\n} from \"./syncAgent\";\nimport { findRootContainerState } from \"./systemContainerLookup\";\nimport type {\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerContentsStoreState,\n} from \"./types\";\nimport { captureContainerWriteGeneration } from \"./writeGeneration\";\n\nconst containerContentsStoresByScope = new WeakMap<\n DomainScope,\n ContainerContentsStoreEntry\n>();\n\ninterface ContainerContentsStoreEntry {\n requestDocumentPriming: () => void;\n store: ContainerContentsStore;\n updateOptions: (options: ContainerContentsStoreOptions) => void;\n}\n\nfunction applyContainerContentsStoreOptions(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n options: ContainerContentsStoreOptions,\n): void {\n if (\"logLabel\" in options) {\n state.logLabel = options.logLabel;\n }\n\n if (\"persistence\" in options) {\n updateContainerContentsStorePersistence(\n state,\n options.persistence ?? defaultContainerContentsPersistence,\n syncAgent,\n );\n }\n}\n\nfunction getCachedContainerWriterProjectionForStore(\n state: ContainerContentsStoreState,\n containerId: string,\n) {\n const containerState = state.containersById.get(containerId);\n return containerState\n ? getCachedContainerWriterProjection(containerState)\n : null;\n}\n\nfunction createContainerContentsStoreSyncHost(\n state: ContainerContentsStoreState,\n): Parameters<typeof createContainerContentsStoreSyncAgent>[0][\"host\"] {\n return {\n persistContainerState: (\n containerState,\n patch,\n updateView,\n saveOptions,\n mutationOptions,\n ) =>\n persistContainerState(state, containerState, {\n patch,\n updateView,\n saveOptions,\n ...mutationOptions,\n }),\n requestDocumentPriming: () => {\n state.documentStoresNeedPriming = true;\n },\n updateSnapshot: () => updateContainerContentsSnapshot(state),\n };\n}\n\n// null marks an unknown mutation scope; [] delegates invalidation to actual writes.\nfunction chainContainerWrite(\n state: ContainerContentsStoreState,\n work: (isCurrent: () => boolean) => ContainerContentsStoreState[\"writeChain\"],\n changedIds: readonly string[] | null = null,\n movedId?: string,\n): ContainerContentsStoreState[\"writeChain\"] {\n const isCurrent = captureContainerWriteGeneration(state);\n invalidateRemoteContainerWrites(state, changedIds, movedId);\n state.writeChain = state.writeChain\n .catch(() => null)\n .then(() => {\n if (!isCurrent()) return null;\n invalidateRemoteContainerWrites(state, changedIds, movedId);\n return work(isCurrent);\n })\n .then((node) => (isCurrent() ? node : null));\n return state.writeChain;\n}\n\ntype ContainerWriteMethods = Pick<\n ContainerContentsStore,\n | \"createChild\"\n | \"deleteContainer\"\n | \"emptyTrash\"\n | \"ensureSystemContainer\"\n | \"moveContainer\"\n | \"prepareGroupRewrap\"\n | \"purgeContainer\"\n | \"renameContainer\"\n | \"setContainerIcon\"\n | \"shareWithGroup\"\n | \"shareWithUser\"\n>;\n\n// The group-rewrap builder verifies any required existing grant before capturing\n// the container KEK, then returns a check/rewrap pair. A verified non-match is\n// distinct from an unavailable preparation so security-critical callers can\n// no-op unrelated groups without failing open for a real grant.\nfunction createPrepareGroupRewrapMethod(\n state: ContainerContentsStoreState,\n syncAgent: ReturnType<typeof createContainerContentsStoreSyncAgent>,\n): ContainerContentsStore[\"prepareGroupRewrap\"] {\n return async (containerId, groupId, accessLevel, options) => {\n const preparation = await chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n (isCurrent) =>\n prepareContainerGroupRewrap(\n state,\n containerId,\n groupId,\n accessLevel,\n options,\n isCurrent,\n ),\n containerId,\n );\n return preparation?.status === \"prepared\"\n ? {\n isCurrent: (\n expectedGroupHead,\n expectedContainerId,\n expectedOrganizationId,\n ) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n verifyContainerGroupRewrapCurrent(\n state,\n containerId,\n groupId,\n accessLevel,\n expectedGroupHead,\n expectedContainerId,\n expectedOrganizationId,\n isCurrent,\n ),\n containerId,\n ),\n rewrap: () =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithGroup(\n state,\n syncAgent,\n containerId,\n groupId,\n accessLevel,\n {\n ...options,\n knownContainerKeks: preparation.knownContainerKeks,\n // A prepared re-wrap is grant-preserving by definition, so\n // it never mints a grant and never needs the chosen name.\n requireExistingGrant: true,\n },\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n status: \"prepared\" as const,\n }\n : (preparation ?? null);\n };\n}\n\nfunction createContainerSharingMethods(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): Pick<ContainerWriteMethods, \"shareWithUser\" | \"shareWithGroup\"> {\n return {\n shareWithUser: (containerId, userId) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithUser(\n state,\n syncAgent,\n containerId,\n userId,\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n shareWithGroup: (containerId, groupId, accessLevel, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithGroup(\n state,\n syncAgent,\n containerId,\n groupId,\n accessLevel,\n options,\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n };\n}\n\nfunction createDeleteContainerMethod(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): ContainerContentsStore[\"deleteContainer\"] {\n return (containerId) => {\n const current = captureContainerWriteGeneration(state);\n const remoteDelete = () =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n (isCurrent) =>\n deleteContainer(state, syncAgent, containerId, isCurrent),\n containerId,\n ).then((node) => node !== null);\n if (state.containersById.get(containerId)?.record.documentId)\n return remoteDelete();\n let promoted = false;\n return chainContainerWrite(\n state,\n (isCurrent) => {\n // Promotion can win while this local operation was queued. Hand it to\n // the remote queue after releasing the local chain, before any HTTP I/O.\n promoted = Boolean(\n state.containersById.get(containerId)?.record.documentId,\n );\n return promoted\n ? Promise.resolve(null)\n : deleteContainer(state, syncAgent, containerId, isCurrent);\n },\n [containerId],\n ).then((node) => (promoted && current() ? remoteDelete() : node !== null));\n };\n}\n\nfunction createEnsureSystemContainerMethod(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): ContainerContentsStore[\"ensureSystemContainer\"] {\n return (systemSlot, name, options) => {\n const work = (isCurrent: () => boolean) =>\n ensureSystemContainer(\n state,\n syncAgent,\n systemSlot,\n name,\n options,\n isCurrent,\n );\n const rootId = findRootContainerState(state)?.container.id;\n return options?.deferRemoteBootstrap\n ? chainContainerWrite(state, work, [])\n : chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n work,\n rootId ? { rootId, systemSlot } : undefined,\n );\n };\n}\n\nexport function createContainerWriteMethods(\n state: ContainerContentsStoreState,\n syncAgent: ReturnType<typeof createContainerContentsStoreSyncAgent>,\n): ContainerWriteMethods {\n return {\n ...createContainerSharingMethods(state, syncAgent),\n createChild: (parentId, name) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n createChildContainer(state, syncAgent, parentId, name, isCurrent),\n [parentId],\n ),\n deleteContainer: createDeleteContainerMethod(state, syncAgent),\n purgeContainer: (containerId, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n purgeContainer(state, syncAgent, containerId, options, isCurrent),\n containerId,\n ),\n emptyTrash: (trashContainerId, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n emptyTrash(state, syncAgent, trashContainerId, options, isCurrent),\n trashContainerId,\n ),\n ensureSystemContainer: createEnsureSystemContainerMethod(state, syncAgent),\n moveContainer: (containerId, parentId) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n moveContainer(state, syncAgent, containerId, parentId, isCurrent),\n [containerId, parentId],\n containerId,\n ),\n prepareGroupRewrap: createPrepareGroupRewrapMethod(state, syncAgent),\n renameContainer: (containerId, name) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n renameContainer(state, syncAgent, containerId, name, isCurrent),\n [containerId],\n ),\n setContainerIcon: (containerId, icon) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n setContainerIcon(state, syncAgent, containerId, icon, isCurrent),\n [containerId],\n ),\n };\n}\n\nfunction createContainerContentsStoreEntry(\n initialRuntime: ContainerContentsStoreRuntime,\n persistence: ContainerContentsPersistence = defaultContainerContentsPersistence,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStoreEntry {\n const state = createContainerContentsStoreState(\n initialRuntime,\n options.persistence ?? persistence,\n options.logLabel,\n );\n const syncAgent = createContainerContentsStoreSyncAgent({\n host: createContainerContentsStoreSyncHost(state),\n state,\n });\n const writeMethods = createContainerWriteMethods(state, syncAgent);\n\n return {\n requestDocumentPriming: () => {\n state.documentStoresNeedPriming = true;\n syncAgent.scheduleSync();\n },\n store: {\n ...writeMethods,\n refresh: () => syncAgent.refresh({ resetAllLaneWatermarks: true }),\n refreshRootLane: (options) => syncAgent.refreshRootLane(options),\n // Force an on-demand local SQLite re-read (see the interface doc): arm the\n // gate refreshLocalContainerStates otherwise requires, which the runtime\n // auto-arms only on a context transition an on-demand caller cannot rely on.\n refreshLocalContainers: () => {\n state.localContainersNeedRefresh = true;\n return syncAgent.refreshLocalContainers();\n },\n requestSync: () => syncAgent.scheduleSync(),\n getCachedContainerWriterProjection: (containerId) =>\n getCachedContainerWriterProjectionForStore(state, containerId),\n getSnapshot: () => state.snapshot,\n subscribe: (listener) =>\n subscribeToContainerContentsStore(state, listener),\n updateRuntime: (runtime) =>\n updateContainerContentsStoreRuntime(state, runtime, syncAgent),\n },\n updateOptions: (nextOptions) =>\n applyContainerContentsStoreOptions(state, syncAgent, nextOptions),\n };\n}\n\nexport function createContainerContentsStore(\n initialRuntime: ContainerContentsStoreRuntime,\n persistence: ContainerContentsPersistence = defaultContainerContentsPersistence,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStore {\n return createContainerContentsStoreEntry(initialRuntime, persistence, options)\n .store;\n}\n\nexport function getOrCreateContainerContentsStore(\n domainScope: DomainScope,\n runtime: ContainerContentsStoreRuntime,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStore {\n const existingEntry = containerContentsStoresByScope.get(domainScope);\n if (existingEntry) {\n existingEntry.updateOptions(options);\n return existingEntry.store;\n }\n\n const nextEntry = createContainerContentsStoreEntry(\n runtime,\n defaultContainerContentsPersistence,\n options,\n );\n containerContentsStoresByScope.set(domainScope, nextEntry);\n return nextEntry.store;\n}\n\n/**\n * Arm the next structural pass's document-priming scan for a domain scope.\n * Priming normally re-arms only on store creation and topology changes, so a\n * caller that just tore down a document's local state uses this to have the\n * still-listed server document re-created without waiting for an app\n * restart. Returns false when the scope has no container-contents store yet;\n * the startup priming pass covers that case.\n */\nexport function requestContainerContentsDocumentPriming(\n domainScope: DomainScope,\n): boolean {\n const entry = containerContentsStoresByScope.get(domainScope);\n if (!entry) {\n return false;\n }\n\n entry.requestDocumentPriming();\n return true;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerContentsStore.js","sourceRoot":"","sources":["containerContentsStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,oEAAoE,CAAC;AACxH,OAAO,EAEL,mCAAmC,GACpC,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,uCAAuC,EACvC,mCAAmC,GACpC,MAAM,SAAS,CAAC;AACjB,OAAO,EAGL,qCAAqC,G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B,CAC1C,cAA6C,EAC7C,cAA4C,mCAAmC,EAC/E,UAAyC,EAAE;IAE3C,OAAO,iCAAiC,CAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC;SAC3E,KAAK,CAAC;AACX,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,WAAwB,EACxB,OAAsC,EACtC,UAAyC,EAAE;IAE3C,MAAM,aAAa,GAAG,8BAA8B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtE,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,MAAM,SAAS,GAAG,iCAAiC,CACjD,OAAO,EACP,mCAAmC,EACnC,OAAO,CACR,CAAC;IACF,8BAA8B,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC,KAAK,CAAC;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uCAAuC,CACrD,WAAwB;IAExB,MAAM,KAAK,GAAG,8BAA8B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,sBAAsB,EAAE,CAAC;IAC/B,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { DomainScope } from \"../../data/shared/domainScope\";\nimport { getCachedContainerWriterProjection } from \"../../workflows/container-contents/container-state/projectionCache\";\nimport {\n type ContainerContentsPersistence,\n defaultContainerContentsPersistence,\n} from \"../../workflows/container-contents/containerPersistence\";\nimport { persistContainerState } from \"./containerState/containerStatePersistence\";\nimport {\n createChildContainer,\n deleteContainer,\n ensureSystemContainer,\n moveContainer,\n renameContainer,\n} from \"./operations\";\nimport { emptyTrash } from \"./operations/emptyTrashOperation\";\nimport {\n prepareContainerGroupRewrap,\n verifyContainerGroupRewrapCurrent,\n} from \"./operations/groupRewrapOperation\";\nimport { purgeContainer } from \"./operations/purgeContainerOperation\";\nimport { setContainerIcon } from \"./operations/setContainerIconOperation\";\nimport {\n shareContainerWithGroup,\n shareContainerWithUser,\n} from \"./operations/shareOperations\";\nimport { invalidateRemoteContainerWrites } from \"./remoteWrites/remoteWriteGuards\";\nimport { chainRemoteContainerTask } from \"./remoteWrites/remoteWriteQueue\";\nimport { captureContainerWriteGeneration } from \"./remoteWrites/writeGeneration\";\nimport {\n createContainerContentsStoreState,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStorePersistence,\n updateContainerContentsStoreRuntime,\n} from \"./state\";\nimport {\n type ContainerContentsStoreRuntime,\n type ContainerContentsStoreSyncAgent,\n createContainerContentsStoreSyncAgent,\n} from \"./syncAgent\";\nimport { findRootContainerState } from \"./systemContainers/systemContainerLookup\";\nimport type {\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerContentsStoreState,\n} from \"./types\";\n\nconst containerContentsStoresByScope = new WeakMap<\n DomainScope,\n ContainerContentsStoreEntry\n>();\n\ninterface ContainerContentsStoreEntry {\n requestDocumentPriming: () => void;\n store: ContainerContentsStore;\n updateOptions: (options: ContainerContentsStoreOptions) => void;\n}\n\nfunction applyContainerContentsStoreOptions(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n options: ContainerContentsStoreOptions,\n): void {\n if (\"logLabel\" in options) {\n state.logLabel = options.logLabel;\n }\n\n if (\"persistence\" in options) {\n updateContainerContentsStorePersistence(\n state,\n options.persistence ?? defaultContainerContentsPersistence,\n syncAgent,\n );\n }\n}\n\nfunction getCachedContainerWriterProjectionForStore(\n state: ContainerContentsStoreState,\n containerId: string,\n) {\n const containerState = state.containersById.get(containerId);\n return containerState\n ? getCachedContainerWriterProjection(containerState)\n : null;\n}\n\nfunction createContainerContentsStoreSyncHost(\n state: ContainerContentsStoreState,\n): Parameters<typeof createContainerContentsStoreSyncAgent>[0][\"host\"] {\n return {\n persistContainerState: (\n containerState,\n patch,\n updateView,\n saveOptions,\n mutationOptions,\n ) =>\n persistContainerState(state, containerState, {\n patch,\n updateView,\n saveOptions,\n ...mutationOptions,\n }),\n requestDocumentPriming: () => {\n state.documentStoresNeedPriming = true;\n },\n updateSnapshot: () => updateContainerContentsSnapshot(state),\n };\n}\n\n// null marks an unknown mutation scope; [] delegates invalidation to actual writes.\nfunction chainContainerWrite(\n state: ContainerContentsStoreState,\n work: (isCurrent: () => boolean) => ContainerContentsStoreState[\"writeChain\"],\n changedIds: readonly string[] | null = null,\n movedId?: string,\n): ContainerContentsStoreState[\"writeChain\"] {\n const isCurrent = captureContainerWriteGeneration(state);\n invalidateRemoteContainerWrites(state, changedIds, movedId);\n state.writeChain = state.writeChain\n .catch(() => null)\n .then(() => {\n if (!isCurrent()) return null;\n invalidateRemoteContainerWrites(state, changedIds, movedId);\n return work(isCurrent);\n })\n .then((node) => (isCurrent() ? node : null));\n return state.writeChain;\n}\n\ntype ContainerWriteMethods = Pick<\n ContainerContentsStore,\n | \"createChild\"\n | \"deleteContainer\"\n | \"emptyTrash\"\n | \"ensureSystemContainer\"\n | \"moveContainer\"\n | \"prepareGroupRewrap\"\n | \"purgeContainer\"\n | \"renameContainer\"\n | \"setContainerIcon\"\n | \"shareWithGroup\"\n | \"shareWithUser\"\n>;\n\n// The group-rewrap builder verifies any required existing grant before capturing\n// the container KEK, then returns a check/rewrap pair. A verified non-match is\n// distinct from an unavailable preparation so security-critical callers can\n// no-op unrelated groups without failing open for a real grant.\nfunction createPrepareGroupRewrapMethod(\n state: ContainerContentsStoreState,\n syncAgent: ReturnType<typeof createContainerContentsStoreSyncAgent>,\n): ContainerContentsStore[\"prepareGroupRewrap\"] {\n return async (containerId, groupId, accessLevel, options) => {\n const preparation = await chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n (isCurrent) =>\n prepareContainerGroupRewrap(\n state,\n containerId,\n groupId,\n accessLevel,\n options,\n isCurrent,\n ),\n containerId,\n );\n return preparation?.status === \"prepared\"\n ? {\n isCurrent: (\n expectedGroupHead,\n expectedContainerId,\n expectedOrganizationId,\n ) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n verifyContainerGroupRewrapCurrent(\n state,\n containerId,\n groupId,\n accessLevel,\n expectedGroupHead,\n expectedContainerId,\n expectedOrganizationId,\n isCurrent,\n ),\n containerId,\n ),\n rewrap: () =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithGroup(\n state,\n syncAgent,\n containerId,\n groupId,\n accessLevel,\n {\n ...options,\n knownContainerKeks: preparation.knownContainerKeks,\n // A prepared re-wrap is grant-preserving by definition, so\n // it never mints a grant and never needs the chosen name.\n requireExistingGrant: true,\n },\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n status: \"prepared\" as const,\n }\n : (preparation ?? null);\n };\n}\n\nfunction createContainerSharingMethods(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): Pick<ContainerWriteMethods, \"shareWithUser\" | \"shareWithGroup\"> {\n return {\n shareWithUser: (containerId, userId) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithUser(\n state,\n syncAgent,\n containerId,\n userId,\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n shareWithGroup: (containerId, groupId, accessLevel, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n shareContainerWithGroup(\n state,\n syncAgent,\n containerId,\n groupId,\n accessLevel,\n options,\n isCurrent,\n ),\n containerId,\n { preserveResultOnLocalWrite: true },\n ),\n };\n}\n\nfunction createDeleteContainerMethod(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): ContainerContentsStore[\"deleteContainer\"] {\n return (containerId) => {\n const current = captureContainerWriteGeneration(state);\n const remoteDelete = () =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n (isCurrent) =>\n deleteContainer(state, syncAgent, containerId, isCurrent),\n containerId,\n ).then((node) => node !== null);\n if (state.containersById.get(containerId)?.record.documentId)\n return remoteDelete();\n let promoted = false;\n return chainContainerWrite(\n state,\n (isCurrent) => {\n // Promotion can win while this local operation was queued. Hand it to\n // the remote queue after releasing the local chain, before any HTTP I/O.\n promoted = Boolean(\n state.containersById.get(containerId)?.record.documentId,\n );\n return promoted\n ? Promise.resolve(null)\n : deleteContainer(state, syncAgent, containerId, isCurrent);\n },\n [containerId],\n ).then((node) => (promoted && current() ? remoteDelete() : node !== null));\n };\n}\n\nfunction createEnsureSystemContainerMethod(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n): ContainerContentsStore[\"ensureSystemContainer\"] {\n return (systemSlot, name, options) => {\n const work = (isCurrent: () => boolean) =>\n ensureSystemContainer(\n state,\n syncAgent,\n systemSlot,\n name,\n options,\n isCurrent,\n );\n const rootId = findRootContainerState(state)?.container.id;\n return options?.deferRemoteBootstrap\n ? chainContainerWrite(state, work, [])\n : chainRemoteContainerTask(\n state,\n syncAgent,\n null,\n work,\n rootId ? { rootId, systemSlot } : undefined,\n );\n };\n}\n\nexport function createContainerWriteMethods(\n state: ContainerContentsStoreState,\n syncAgent: ReturnType<typeof createContainerContentsStoreSyncAgent>,\n): ContainerWriteMethods {\n return {\n ...createContainerSharingMethods(state, syncAgent),\n createChild: (parentId, name) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n createChildContainer(state, syncAgent, parentId, name, isCurrent),\n [parentId],\n ),\n deleteContainer: createDeleteContainerMethod(state, syncAgent),\n purgeContainer: (containerId, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n purgeContainer(state, syncAgent, containerId, options, isCurrent),\n containerId,\n ),\n emptyTrash: (trashContainerId, options) =>\n chainRemoteContainerTask(\n state,\n syncAgent,\n false,\n (isCurrent) =>\n emptyTrash(state, syncAgent, trashContainerId, options, isCurrent),\n trashContainerId,\n ),\n ensureSystemContainer: createEnsureSystemContainerMethod(state, syncAgent),\n moveContainer: (containerId, parentId) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n moveContainer(state, syncAgent, containerId, parentId, isCurrent),\n [containerId, parentId],\n containerId,\n ),\n prepareGroupRewrap: createPrepareGroupRewrapMethod(state, syncAgent),\n renameContainer: (containerId, name) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n renameContainer(state, syncAgent, containerId, name, isCurrent),\n [containerId],\n ),\n setContainerIcon: (containerId, icon) =>\n chainContainerWrite(\n state,\n (isCurrent) =>\n setContainerIcon(state, syncAgent, containerId, icon, isCurrent),\n [containerId],\n ),\n };\n}\n\nfunction createContainerContentsStoreEntry(\n initialRuntime: ContainerContentsStoreRuntime,\n persistence: ContainerContentsPersistence = defaultContainerContentsPersistence,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStoreEntry {\n const state = createContainerContentsStoreState(\n initialRuntime,\n options.persistence ?? persistence,\n options.logLabel,\n );\n const syncAgent = createContainerContentsStoreSyncAgent({\n host: createContainerContentsStoreSyncHost(state),\n state,\n });\n const writeMethods = createContainerWriteMethods(state, syncAgent);\n\n return {\n requestDocumentPriming: () => {\n state.documentStoresNeedPriming = true;\n syncAgent.scheduleSync();\n },\n store: {\n ...writeMethods,\n refresh: () => syncAgent.refresh({ resetAllLaneWatermarks: true }),\n refreshRootLane: (options) => syncAgent.refreshRootLane(options),\n // Force an on-demand local SQLite re-read (see the interface doc): arm the\n // gate refreshLocalContainerStates otherwise requires, which the runtime\n // auto-arms only on a context transition an on-demand caller cannot rely on.\n refreshLocalContainers: () => {\n state.localContainersNeedRefresh = true;\n return syncAgent.refreshLocalContainers();\n },\n requestSync: () => syncAgent.scheduleSync(),\n getCachedContainerWriterProjection: (containerId) =>\n getCachedContainerWriterProjectionForStore(state, containerId),\n getSnapshot: () => state.snapshot,\n subscribe: (listener) =>\n subscribeToContainerContentsStore(state, listener),\n updateRuntime: (runtime) =>\n updateContainerContentsStoreRuntime(state, runtime, syncAgent),\n },\n updateOptions: (nextOptions) =>\n applyContainerContentsStoreOptions(state, syncAgent, nextOptions),\n };\n}\n\nexport function createContainerContentsStore(\n initialRuntime: ContainerContentsStoreRuntime,\n persistence: ContainerContentsPersistence = defaultContainerContentsPersistence,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStore {\n return createContainerContentsStoreEntry(initialRuntime, persistence, options)\n .store;\n}\n\nexport function getOrCreateContainerContentsStore(\n domainScope: DomainScope,\n runtime: ContainerContentsStoreRuntime,\n options: ContainerContentsStoreOptions = {},\n): ContainerContentsStore {\n const existingEntry = containerContentsStoresByScope.get(domainScope);\n if (existingEntry) {\n existingEntry.updateOptions(options);\n return existingEntry.store;\n }\n\n const nextEntry = createContainerContentsStoreEntry(\n runtime,\n defaultContainerContentsPersistence,\n options,\n );\n containerContentsStoresByScope.set(domainScope, nextEntry);\n return nextEntry.store;\n}\n\n/**\n * Arm the next structural pass's document-priming scan for a domain scope.\n * Priming normally re-arms only on store creation and topology changes, so a\n * caller that just tore down a document's local state uses this to have the\n * still-listed server document re-created without waiting for an app\n * restart. Returns false when the scope has no container-contents store yet;\n * the startup priming pass covers that case.\n */\nexport function requestContainerContentsDocumentPriming(\n domainScope: DomainScope,\n): boolean {\n const entry = containerContentsStoresByScope.get(domainScope);\n if (!entry) {\n return false;\n }\n\n entry.requestDocumentPriming();\n return true;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerStateMap.js","sourceRoot":"","sources":["containerStateMap.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAkB,SAAQ,GAA2B;IACvD,uBAAuB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7D,uBAAuB,GAAG,CAAC,CAAC;IAE5B,YAAY,OAA6C;QACvD,KAAK,EAAE,CAAC;QACR,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK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C,OAAO,MAAM,YAAY,iBAAiB;QACxC,CAAC,CAAC,MAAM,CAAC,0BAA0B,EAAE;QACrC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,MAAmC,EACnC,WAAmB,EACnB,QAAqC;IAErC,OAAO,CACL,MAAM,YAAY,iBAAiB;QACnC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerState } from \"../../../workflows/container-contents/remoteHydration\";\n\nexport class ContainerStateMap extends Map<string, ContainerState> {\n readonly #mutationGenerationById = new Map<string, number>();\n #nextMutationGeneration = 0;\n\n constructor(entries?: ReadonlyMap<string, ContainerState>) {\n super();\n for (const [containerId, state] of entries ?? []) {\n super.set(containerId, state);\n }\n }\n\n override clear(): void {\n for (const containerId of this.keys()) {\n this.recordMutation(containerId);\n }\n super.clear();\n }\n\n override delete(containerId: string): boolean {\n const deleted = super.delete(containerId);\n // An absent delete is still an authoritative tombstone observation. A\n // local-refresh query that started before it must not install a stale row\n // merely because no in-memory value existed for Map.delete to remove.\n this.recordMutation(containerId);\n return deleted;\n }\n\n override set(containerId: string, state: ContainerState): this {\n this.recordMutation(containerId);\n return super.set(containerId, state);\n }\n\n captureMutationGenerations(): ReadonlyMap<string, number> {\n return new Map(this.#mutationGenerationById);\n }\n\n hasMutationAfter(\n containerId: string,\n baseline: ReadonlyMap<string, number>,\n ): boolean {\n return (\n (this.#mutationGenerationById.get(containerId) ?? 0) !==\n (baseline.get(containerId) ?? 0)\n );\n }\n\n private recordMutation(containerId: string): void {\n this.#nextMutationGeneration += 1;\n this.#mutationGenerationById.set(containerId, this.#nextMutationGeneration);\n }\n}\n\nexport function captureContainerStateMutationGenerations(\n states: Map<string, ContainerState>,\n): ReadonlyMap<string, number> {\n return states instanceof ContainerStateMap\n ? states.captureMutationGenerations()\n : new Map();\n}\n\nexport function containerStateMutatedAfter(\n states: Map<string, ContainerState>,\n containerId: string,\n baseline: ReadonlyMap<string, number>,\n): boolean {\n return (\n states instanceof ContainerStateMap &&\n states.hasMutationAfter(containerId, baseline)\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { installContainerMetadataRecord, persistContainerMetadataStateFromRuntime, } from "
|
|
1
|
+
import { installContainerMetadataRecord, persistContainerMetadataStateFromRuntime, } from "../../../workflows/container-contents/metadata/index.js";
|
|
2
|
+
import { updateContainerContentsSnapshot } from "../state.js";
|
|
2
3
|
import { removeMissingContainerState } from "./missingContainerState.js";
|
|
3
|
-
import { updateContainerContentsSnapshot } from "./state.js";
|
|
4
4
|
export async function persistContainerState(state, containerState, options = {}) {
|
|
5
5
|
const { expectedStateWhenMissing, isCurrent, updateView = true } = options;
|
|
6
6
|
const persisted = await persistContainerMetadataStateFromRuntime({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerStatePersistence.js","sourceRoot":"","sources":["containerStatePersistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,GACzC,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAG3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAsBtE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAkC,EAClC,cAA8B,EAC9B,UAAwC,EAAE;IAE1C,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC3E,MAAM,SAAS,GAAG,MAAM,wCAAwC,CAAC;QAC/D,aAAa,EAAE,cAAc;QAC7B,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;QAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;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AM,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,MAAM,EAAE,WAAW;QACnB,GAAG,CAAC,SAAS,CAAC,mBAAmB;YAC/B,CAAC,CAAC,EAAE,mBAAmB,EAAE,IAAa,EAAE;YACxC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,SAAS,CAAC,iBAAiB;YAC7B,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAa,EAAE;YACtC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n installContainerMetadataRecord,\n persistContainerMetadataStateFromRuntime,\n} from \"../../../workflows/container-contents/metadata\";\nimport type { PersistContainerStateResult } from \"../../../workflows/container-contents/remoteHydration\";\nimport { updateContainerContentsSnapshot } from \"../state\";\nimport type { ContainerState } from \"../syncAgent\";\nimport type { ContainerContentsStoreState } from \"../types\";\nimport { removeMissingContainerState } from \"./missingContainerState\";\n\ntype MetadataPersistenceInput = Parameters<\n typeof persistContainerMetadataStateFromRuntime\n>[0];\n\ninterface PersistContainerStateOptions\n extends Pick<\n MetadataPersistenceInput,\n | \"patch\"\n | \"saveOptions\"\n | \"localMetadataPatch\"\n | \"localUpdate\"\n | \"createIntentSettlement\"\n | \"moveIntentSettlement\"\n | \"preserveDurableStructureWhenPending\"\n > {\n expectedStateWhenMissing?: ContainerState | undefined;\n isCurrent?: (() => boolean) | undefined;\n updateView?: boolean | undefined;\n}\n\nexport async function persistContainerState(\n state: ContainerContentsStoreState,\n containerState: ContainerState,\n options: PersistContainerStateOptions = {},\n): Promise<PersistContainerStateResult> {\n const { expectedStateWhenMissing, isCurrent, updateView = true } = options;\n const persisted = await persistContainerMetadataStateFromRuntime({\n metadataState: containerState,\n localMetadataPatch: options.localMetadataPatch,\n localUpdate: options.localUpdate,\n patch: options.patch ?? {},\n persistence: state.persistence,\n createIntentSettlement: options.createIntentSettlement,\n moveIntentSettlement: options.moveIntentSettlement,\n preserveDurableStructureWhenPending:\n options.preserveDurableStructureWhenPending,\n runtime: state.runtime,\n saveOptions: options.saveOptions,\n stillCurrent: isCurrent,\n });\n if (isCurrent?.() === false) {\n return { status: \"stale-generation\" };\n }\n if (!persisted) {\n removeMissingContainerState(\n state,\n expectedStateWhenMissing ?? containerState,\n );\n return { status: \"missing\" };\n }\n containerState.container = persisted.container;\n installContainerMetadataRecord(containerState, persisted.record);\n if (persisted.mutationSuperseded || persisted.syncIdentitySuperseded) {\n const cachedState = state.containersById.get(containerState.container.id);\n if (cachedState && cachedState !== containerState) {\n cachedState.container = containerState.container;\n cachedState.doc = containerState.doc;\n cachedState.metadataWriterProjection =\n containerState.metadataWriterProjection;\n installContainerMetadataRecord(cachedState, persisted.record);\n }\n // The requested structural mutation was not applied. Refresh from the\n // authoritative state installed above, but make the caller fail explicitly\n // so it cannot schedule sync or report the dropped mutation as successful.\n updateContainerContentsSnapshot(state);\n return { record: persisted.record, status: \"identity-superseded\" };\n }\n if (updateView) {\n updateContainerContentsSnapshot(state);\n }\n return {\n record: persisted.record,\n status: \"persisted\",\n ...(persisted.createIntentSettled\n ? { createIntentSettled: true as const }\n : {}),\n ...(persisted.moveIntentSettled\n ? { moveIntentSettled: true as const }\n : {}),\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { updateContainerContentsSnapshot } from "
|
|
1
|
+
import { updateContainerContentsSnapshot } from "../state.js";
|
|
2
2
|
export function removeMissingContainerState(state, expectedState) {
|
|
3
3
|
const containerId = expectedState.container.id;
|
|
4
4
|
if (state.containersById.get(containerId) !== expectedState) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missingContainerState.js","sourceRoot":"","sources":["missingContainerState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAG3D,MAAM,UAAU,2BAA2B,CACzC,KAAkC,EAClC,aAA6B;IAE7B,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,aAAa,EAAE,CAAC;QAC5D,OAAO;IACT,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,+BAA+B,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import type { ContainerState } from \"../../../workflows/container-contents/remoteHydration\";\nimport { updateContainerContentsSnapshot } from \"../state\";\nimport type { ContainerContentsStoreState } from \"../types\";\n\nexport function removeMissingContainerState(\n state: ContainerContentsStoreState,\n expectedState: ContainerState,\n): void {\n const containerId = expectedState.container.id;\n if (state.containersById.get(containerId) !== expectedState) {\n return;\n }\n state.containersById.delete(containerId);\n updateContainerContentsSnapshot(state);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missingSyncedContainerState.js","sourceRoot":"","sources":["missingSyncedContainerState.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iCAAiC,CAC/C,KAAsC,EACtC,aAA6B,EAC7B,cAA0B;IAE1B,MAAM,WAAW,GAAG,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,aAAa,EAAE,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACzC,cAAc,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ContainerState } from \"../../../workflows/container-contents/remoteHydration\";\nimport type { ContainerContentsStoreSyncState } from \"../syncAgent/syncAgentTypes\";\n\nexport function removeMissingSyncedContainerState(\n state: ContainerContentsStoreSyncState,\n expectedState: ContainerState,\n updateSnapshot: () => void,\n): boolean {\n const containerId = expectedState.container.id;\n if (state.containersById.get(containerId) !== expectedState) {\n return false;\n }\n\n state.containersById.delete(containerId);\n updateSnapshot();\n return true;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcilableContainer.js","sourceRoot":"","sources":["reconcilableContainer.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAuC;IAEvC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;AAC3B,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,2BAA2B,CACzC,IAA+C;IAE/C,OAAO,CACL,OAAO,IAAI,CAAC,kBAAkB,KAAK,QAAQ;QAC3C,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CACnC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,IAMC,EACD,kBAAiC;IAEjC,wEAAwE;IACxE,uEAAuE;IACvE,2EAA2E;IAC3E,uEAAuE;IACvE,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,kBAAkB,KAAK,IAAI;QAC3B,CAAC,IAAI,CAAC,cAAc,KAAK,kBAAkB;YACzC,4BAA4B,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,IAMC,EACD,kBAAiC;IAEjC,OAAO,CACL,2BAA2B,CAAC,IAAI,CAAC;QACjC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;YAC3B,4BAA4B,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,4BAA4B,CAC1C,IAGC,EACD,kBAAiC;IAEjC,OAAO,CACL,qBAAqB,CAAC,IAAI,CAAC;QAC3B,kBAAkB,KAAK,IAAI;QAC3B,CAAC,CAAC,IAAI,CAAC,cAAc;QACrB,IAAI,CAAC,cAAc,KAAK,kBAAkB;QAC1C,CAAC,IAAI,CAAC,oBAAoB,KAAK,MAAM;YACnC,IAAI,CAAC,oBAAoB,KAAK,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerNode } from \"../types\";\n\n/**\n * Whether a container is a system container — one tagged with a deterministic\n * `systemSlot` for a built-in role such as Contacts, Trash, organization\n * metadata, or the per-organization roster.\n */\nexport function isSystemContainerNode(\n node: Pick<ContainerNode, \"systemSlot\">,\n): boolean {\n return !!node.systemSlot;\n}\n\n/** Whether a container has completed enough remote creation to be listed. */\nexport function isRemoteBackedContainerNode(\n node: Pick<ContainerNode, \"metadataDocumentId\">,\n): boolean {\n return (\n typeof node.metadataDocumentId === \"string\" &&\n node.metadataDocumentId.length > 0\n );\n}\n\n/**\n * Whether generic document reconciliation may safely list this container.\n *\n * Every container joins generic reconciliation only after remote creation has\n * given it a metadata document id. This keeps local-first roots and children\n * out of an HTTP lane that cannot exist yet, while still letting another device\n * rematerialize Contacts, Trash, and other system data.\n */\nexport function isReconcilableContainerNode(\n node: Pick<\n ContainerNode,\n | \"effectiveAccessLevel\"\n | \"metadataDocumentId\"\n | \"organizationId\"\n | \"systemSlot\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n // Document discovery is an HTTP read against the remote container id. A\n // local-first container has no such lane until its metadata create has\n // committed; attempting to list it can only produce a 404. This applies to\n // the pre-auth local root just as much as to a local system container.\n if (!isRemoteBackedContainerNode(node)) {\n return false;\n }\n\n if (!isSystemContainerNode(node)) {\n return true;\n }\n\n return (\n homeOrganizationId !== null &&\n (node.organizationId === homeOrganizationId ||\n isForeignSystemContainerNode(node, homeOrganizationId))\n );\n}\n\n/**\n * Whether a root-lane discovery hint should re-list this container's documents.\n *\n * The server's root discovery lane can return directly granted non-root\n * containers, so every remote-backed regular container remains eligible\n * regardless of its parent. Membership-visible foreign system containers\n * remain eligible for catch-up. Own system children are excluded here because\n * cold/auth backfill and explicit full refresh already reconcile them; sweeping\n * them on every Explorer-open or shared-root hint creates redundant work.\n */\nexport function isAutomaticRootCatchupContainerNode(\n node: Pick<\n ContainerNode,\n | \"effectiveAccessLevel\"\n | \"metadataDocumentId\"\n | \"organizationId\"\n | \"systemSlot\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n return (\n isRemoteBackedContainerNode(node) &&\n (!isSystemContainerNode(node) ||\n isForeignSystemContainerNode(node, homeOrganizationId))\n );\n}\n\n/**\n * Whether a system container belongs to a foreign organization whose contents\n * are visible through membership-level access.\n *\n * Event routing uses this classification for foreign system content whose\n * already-known document updates must still force discovery. It is not the\n * generic sweep predicate: remote-backed own system containers also reconcile\n * via {@link isReconcilableContainerNode}. A foreign system container is one\n * that is:\n *\n * - a different org's (`organizationId !== homeOrganizationId`). Own system\n * containers are outside this foreign-system classification, while a\n * container mid-creation has an empty organization id that matches nothing\n * (as does a null/unhydrated home org).\n * - granted at a *membership* level — `read` (Members group) or `admin`\n * (Admins group). A plain `write` share of a folder does not make the sharee\n * a member, so it does not opt that folder into automatic root catch-up.\n */\nexport function isForeignSystemContainerNode(\n node: Pick<\n ContainerNode,\n \"systemSlot\" | \"organizationId\" | \"effectiveAccessLevel\"\n >,\n homeOrganizationId: string | null,\n): boolean {\n return (\n isSystemContainerNode(node) &&\n homeOrganizationId !== null &&\n !!node.organizationId &&\n node.organizationId !== homeOrganizationId &&\n (node.effectiveAccessLevel === \"read\" ||\n node.effectiveAccessLevel === \"admin\")\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { primeDocumentsForContainerSubtree, primeDocumentsForLoadedRoots, } from "
|
|
2
|
-
import { recoverStaleSessionRoot } from "
|
|
3
|
-
import { createContainerContentsDocumentsRuntime, } from "
|
|
4
|
-
import { isDatabaseUnavailableError } from "
|
|
5
|
-
import { openDocumentStore } from "
|
|
6
|
-
import { getContainerContentsStoreLogLabel } from "
|
|
1
|
+
import { primeDocumentsForContainerSubtree, primeDocumentsForLoadedRoots, } from "../../../workflows/container-contents/documentPriming/index.js";
|
|
2
|
+
import { recoverStaleSessionRoot } from "../../../workflows/container-contents/recovery/staleRootRecovery.js";
|
|
3
|
+
import { createContainerContentsDocumentsRuntime, } from "../../../workflows/container-contents/runtime.js";
|
|
4
|
+
import { isDatabaseUnavailableError } from "../../../workflows/container-contents/syncLane.js";
|
|
5
|
+
import { openDocumentStore } from "../../documents/index.js";
|
|
6
|
+
import { getContainerContentsStoreLogLabel } from "../logLabel.js";
|
|
7
7
|
const staleRootRecoveryLogState = new WeakMap();
|
|
8
8
|
const rejectedAdoptionRuntime = new WeakMap();
|
|
9
9
|
function createPrimeHost(runtime) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentRecovery.js","sourceRoot":"","sources":["documentRecovery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,uDAAuD,CAAC;AAM/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAE3G,OAAO,EAEL,uCAAuC,GACxC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAoBhE,MAAM,yBAAyB,GAAG,IAAI,OAAO,EAG1C,CAAC;AACJ,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAGxC,CAAC;AAEJ,SAAS,eAAe,CAC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CAAC;QACxC,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import type { ContainerContentsPersistence } from \"../../../workflows/container-contents/containerPersistence\";\nimport {\n primeDocumentsForContainerSubtree,\n primeDocumentsForLoadedRoots,\n} from \"../../../workflows/container-contents/documentPriming\";\nimport type {\n ContainerDocumentPrimeHost,\n ContainerDocumentPrimeStore,\n} from \"../../../workflows/container-contents/documentQueries/types\";\nimport type { StaleRootRecoveryStatus } from \"../../../workflows/container-contents/recovery/staleRootRecovery\";\nimport { recoverStaleSessionRoot } from \"../../../workflows/container-contents/recovery/staleRootRecovery\";\nimport type { ContainerState } from \"../../../workflows/container-contents/remoteHydration\";\nimport {\n type ContainerContentsStoreWorkflowRuntime,\n createContainerContentsDocumentsRuntime,\n} from \"../../../workflows/container-contents/runtime\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\nimport { openDocumentStore } from \"../../documents\";\nimport { getContainerContentsStoreLogLabel } from \"../logLabel\";\n\ntype PrimeDocumentRuntime = ReturnType<\n typeof createContainerContentsDocumentsRuntime\n>;\n\ninterface DocumentRecoveryStoreState {\n readonly containersById: Map<string, ContainerState>;\n documentStoresNeedPriming: boolean;\n readonly logLabel?: string | undefined;\n readonly persistence: ContainerContentsPersistence;\n readonly rootLaneHydrated: boolean;\n readonly runtime: ContainerContentsStoreWorkflowRuntime;\n}\n\ninterface StaleRootRecoveryLogState {\n readonly message: string;\n readonly occurrenceCount: number;\n}\n\nconst staleRootRecoveryLogState = new WeakMap<\n DocumentRecoveryStoreState,\n StaleRootRecoveryLogState\n>();\nconst rejectedAdoptionRuntime = new WeakMap<\n DocumentRecoveryStoreState,\n ContainerContentsStoreWorkflowRuntime\n>();\n\nfunction createPrimeHost(\n runtime: ContainerContentsStoreWorkflowRuntime,\n): ContainerDocumentPrimeHost<PrimeDocumentRuntime> {\n return {\n documentWorkflowRuntime: (containerId) =>\n createContainerContentsDocumentsRuntime(runtime, containerId),\n openDocumentStore: ({\n documentId,\n localId,\n runtime,\n }): ContainerDocumentPrimeStore =>\n openDocumentStore(\n runtime.state.domainScope,\n localId,\n runtime,\n documentId,\n ),\n };\n}\n\nexport async function primeStoreDocumentSubtree(\n state: DocumentRecoveryStoreState,\n rootContainerId: string,\n isCurrent: () => boolean = () => true,\n): Promise<void> {\n if (!isCurrent()) return;\n const runtime = state.runtime;\n await primeDocumentsForContainerSubtree({\n containersById: state.containersById,\n host: createPrimeHost(runtime),\n isCurrent,\n rootContainerId,\n runtime,\n });\n}\n\nexport async function primeStoreDocuments(\n state: DocumentRecoveryStoreState,\n isCurrent: () => boolean = () => true,\n): Promise<void> {\n if (!isCurrent()) return;\n const runtime = state.runtime;\n // Consume the current signal before scanning. A topology/root reconciliation\n // that lands during an awaited query can then re-arm the next pass without\n // this pass erasing that newer signal when it completes.\n state.documentStoresNeedPriming = false;\n try {\n const result = await primeDocumentsForLoadedRoots({\n containersById: state.containersById,\n host: createPrimeHost(runtime),\n isCurrent,\n organizationId: runtime.auth?.organizationId ?? null,\n runtime,\n });\n if (!isCurrent()) {\n state.documentStoresNeedPriming = true;\n return;\n }\n runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: document priming candidates=${result.candidateCount} roots=${result.rootCount} primed=${result.primedCount} orphaned=${result.orphanPrimedCount} unroutable=${result.unroutableCount}`,\n );\n } catch (error) {\n if (!isCurrent()) {\n state.documentStoresNeedPriming = true;\n return;\n }\n state.documentStoresNeedPriming = true;\n throw error;\n }\n}\n\nexport async function recoverStoreStaleRoot(\n state: DocumentRecoveryStoreState,\n isCurrent: () => boolean = () => true,\n): Promise<StaleRootRecoveryStatus> {\n if (!isCurrent()) {\n return \"context-changed\";\n }\n const runtime = state.runtime;\n if (rejectedAdoptionRuntime.get(state) === runtime) {\n return \"not-needed\";\n }\n\n let result: Awaited<ReturnType<typeof recoverStaleSessionRoot>>;\n try {\n result = await recoverStaleSessionRoot({ ...state, runtime }, isCurrent);\n } catch (error) {\n if (!isCurrent()) {\n return \"context-changed\";\n }\n if (isDatabaseUnavailableError(error)) {\n throw error;\n }\n const message = `${getContainerContentsStoreLogLabel(state)}: stale root recovery failed`;\n if (state.runtime.util.logError) {\n state.runtime.util.logError(message, error);\n } else {\n state.runtime.util.log(message);\n }\n return \"not-needed\";\n }\n if (!isCurrent()) {\n return \"context-changed\";\n }\n const message = `${getContainerContentsStoreLogLabel(state)}: stale root recovery status=${result.status} candidates=${result.candidateCount}`;\n const previousLogState = staleRootRecoveryLogState.get(state);\n const occurrenceCount =\n previousLogState?.message === message\n ? previousLogState.occurrenceCount + 1\n : 1;\n staleRootRecoveryLogState.set(state, { message, occurrenceCount });\n if (result.status !== \"not-needed\") {\n if (occurrenceCount === 1) {\n runtime.util.log(message);\n } else if ((occurrenceCount & (occurrenceCount - 1)) === 0) {\n runtime.util.log(`${message} occurrences=${occurrenceCount}`);\n }\n }\n if (result.status === \"context-changed\") {\n rejectedAdoptionRuntime.set(state, runtime);\n } else {\n rejectedAdoptionRuntime.delete(state);\n }\n if (result.reassigned) {\n state.documentStoresNeedPriming = true;\n }\n return result.status;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createContainerContentsDocumentsRuntime, } from "
|
|
2
|
-
import { openDocumentStore } from "
|
|
1
|
+
import { createContainerContentsDocumentsRuntime, } from "../../../workflows/container-contents/runtime.js";
|
|
2
|
+
import { openDocumentStore } from "../../documents/index.js";
|
|
3
3
|
export async function prepareContainerDocumentRotationSnapshot(runtime, document) {
|
|
4
4
|
if (!document.documentId || !document.containerId) {
|
|
5
5
|
return null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentRotation.js","sourceRoot":"","sources":["documentRotation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,uCAAuC,GACxC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,OAAyC,EACzC,QAAyB;IAEzB,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAC7B,OAAO,CAAC,KAAK,CAAC,WAAW,EACzB,QAAQ,CAAC,EAAE,EACX,uCAAuC,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,EACtE,QAAQ,CAAC,UAAU,CACpB,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,yBAAyB,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import type { DocumentSummary } from \"../../../data/documents/documentSummary\";\nimport {\n type ContainerContentsWorkflowRuntime,\n createContainerContentsDocumentsRuntime,\n} from \"../../../workflows/container-contents/runtime\";\nimport { openDocumentStore } from \"../../documents\";\n\nexport async function prepareContainerDocumentRotationSnapshot(\n runtime: ContainerContentsWorkflowRuntime,\n document: DocumentSummary,\n): Promise<Uint8Array | null> {\n if (!document.documentId || !document.containerId) {\n return null;\n }\n const store = openDocumentStore(\n runtime.state.domainScope,\n document.id,\n createContainerContentsDocumentsRuntime(runtime, document.containerId),\n document.documentId,\n );\n if (!(await store.ensureInitialized())) {\n return null;\n }\n return store.assertCanRotateContentKey();\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAYA,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAiC;IAEjC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,cAAc,KAAK,iBAAiB,EAAE,CAAC;QACzC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,KAAK,CAAC,wBAAwB,EAAE,CAAC;IAClE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,kBAAkB,GAAG,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAC3B,CAAC;IACD,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACjC,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type { StaleRootRecoveryStatus } from \"../../../workflows/container-contents/recovery/staleRootRecovery\";\n\ninterface ContainerDocumentWorkInput {\n readonly isCurrent: () => boolean;\n readonly onContextChanged: () => void;\n readonly onDocumentsMoved: () => void;\n readonly primeDocuments: () => Promise<void>;\n readonly recoverStaleRoot: () => Promise<StaleRootRecoveryStatus>;\n readonly shouldPrimeDocuments: () => boolean;\n readonly syncPendingDocumentMoves: () => Promise<number>;\n}\n\n/** Runs root repair before any work that consumes its rewritten projections. */\nexport async function runContainerDocumentWork(\n input: ContainerDocumentWorkInput,\n): Promise<\"abandoned\" | \"completed\" | \"context-changed\"> {\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n const recoveryStatus = await input.recoverStaleRoot();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n if (recoveryStatus === \"context-changed\") {\n input.onContextChanged();\n return \"context-changed\";\n }\n\n const movedDocumentCount = await input.syncPendingDocumentMoves();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n if (movedDocumentCount > 0) {\n input.onDocumentsMoved();\n }\n if (input.shouldPrimeDocuments()) {\n await input.primeDocuments();\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n }\n return \"completed\";\n}\n"]}
|
package/stores/container-contents/{backgroundHydration.js → hydration/backgroundHydration.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { reportKeyingVerificationErrorInCauseChain } from "
|
|
2
|
-
import { errorMessage } from "
|
|
3
|
-
import { isDatabaseUnavailableError } from "
|
|
1
|
+
import { reportKeyingVerificationErrorInCauseChain } from "../../../data/keyingProjectionVerification/error.js";
|
|
2
|
+
import { errorMessage } from "../../../data/shared/errorMessage.js";
|
|
3
|
+
import { isDatabaseUnavailableError } from "../../../workflows/container-contents/syncLane.js";
|
|
4
4
|
/** Observe a background refresh without changing the caller's rejection. */
|
|
5
5
|
export function observeContainerBackgroundHydration(state, hydration) {
|
|
6
6
|
const generation = state.lifecycleGeneration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundHydration.js","sourceRoot":"","sources":["backgroundHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,kDAAkD,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAG5F,4EAA4E;AAC5E,MAAM,UAAU,mCAAmC,CACjD,KAAsC,EACtC,SAAwB;IAExB,MAAM,UAAU,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,KAAK,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAc,EAAE,EAAE;QAC5C,IACE,KAAK,CAAC,mBAAmB,KAAK,UAAU;YACxC,0BAA0B,CAAC,KAAK,CAAC;YAEjC,OAAO;QAET,MAAM,yCAAyC,CAC7C,KAAK,EACL,OAAO,CAAC,IAAI,CAAC,sBAAsB,EACnC;YACE,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,WAAW;YACvB,SAAS,EAAE,gCAAgC;YAC3C,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,cAAc;SAC5C,CACF,CAAC;QACF,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,uCAAuC,CAAC;YACxD,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,wEAAwE;QAC1E,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { reportKeyingVerificationErrorInCauseChain } from \"../../../data/keyingProjectionVerification/error\";\nimport { errorMessage } from \"../../../data/shared/errorMessage\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\nimport type { ContainerContentsStoreSyncState } from \"../syncAgent/syncAgentTypes\";\n\n/** Observe a background refresh without changing the caller's rejection. */\nexport function observeContainerBackgroundHydration(\n state: ContainerContentsStoreSyncState,\n hydration: Promise<void>,\n): void {\n const generation = state.lifecycleGeneration;\n const runtime = state.runtime;\n void hydration.catch(async (error: unknown) => {\n if (\n state.lifecycleGeneration !== generation ||\n isDatabaseUnavailableError(error)\n )\n return;\n\n await reportKeyingVerificationErrorInCauseChain(\n error,\n runtime.util.reportSecurityIncident,\n {\n objectId: null,\n objectKind: \"container\",\n operation: \"container.hydration.background\",\n organizationId: runtime.auth.organizationId,\n },\n );\n try {\n const message = \"Container background hydration failed\";\n if (runtime.util.logError) {\n await runtime.util.logError(message, error);\n } else {\n await runtime.util.log(`${message}: ${errorMessage(error)}`);\n }\n } catch {\n // A host logger must not turn an observed refusal into a new rejection.\n }\n });\n}\n"]}
|
package/stores/container-contents/{remoteHydrationRequest.js → hydration/remoteHydrationRequest.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createGenerationGuardedHydrationHost, hydrateRemoteContainers, StaleRemoteHydrationError, } from "
|
|
2
|
-
import { isDatabaseUnavailableError } from "
|
|
3
|
-
import { refreshLocalContainerStates, } from "
|
|
1
|
+
import { createGenerationGuardedHydrationHost, hydrateRemoteContainers, StaleRemoteHydrationError, } from "../../../workflows/container-contents/remoteHydration/index.js";
|
|
2
|
+
import { isDatabaseUnavailableError } from "../../../workflows/container-contents/syncLane.js";
|
|
3
|
+
import { refreshLocalContainerStates, } from "../localRefresh.js";
|
|
4
4
|
function isRequestGenerationCurrent(input) {
|
|
5
5
|
return (input.state.lifecycleGeneration === input.lifecycleGeneration &&
|
|
6
6
|
input.state.structuralGeneration === input.structuralGeneration);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteHydrationRequest.js","sourceRoot":"","sources":["remoteHydrationRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAEvB,yBAAyB,GAC1B,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAEL,2BAA2B,GAC5B,MAAM,iBAAiB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QAED,MAAM,KAAK,CAAC;IACd,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACZ,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,CAAC;QAC3C,IAAI,KAAK,CAAC,sBAAsB,KAAK,gBAAgB,EAAE,CAAC;YACtD,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC;YACpC,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC;YACvC,KAAK,CAAC,mCAAmC,GAAG,IAAI,CAAC;QACnD,CAAC;QAED,IACE,SAAS,EAAE;YACX,CAAC,CAAC,CAAC,KAAK,CAAC,6BAA6B,IAAI,IAAI,CAAC;gBAC7C,CAAC,4BAA4B;oBAC3B,CAAC,CAAC,6BAA6B,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBAC9D,KAAK,CAAC,0BAA0B,CAAC;YACnC,KAAK,CAAC,QAAQ,CAAC,KAAK;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;YAClC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAC1B,CAAC;YACD,YAAY,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,8BAA8B,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,0BAA0B,EAAE,CAAC;YAC/B,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,sBAAsB,GAAG,gBAAgB,CAAC;IAEhD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n createGenerationGuardedHydrationHost,\n hydrateRemoteContainers,\n type RemoteContainerHydrationHost,\n StaleRemoteHydrationError,\n} from \"../../../workflows/container-contents/remoteHydration\";\nimport type { RemoteContainerHydrationState } from \"../../../workflows/container-contents/remoteHydration/types\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\nimport {\n type LocalContainerRefreshState,\n refreshLocalContainerStates,\n} from \"../localRefresh\";\n\ntype RemoteHydrationRequestState = RemoteContainerHydrationState &\n LocalContainerRefreshState & {\n containerParentIdsNeedingHydration: Set<string | null>;\n initializePromise: Promise<void> | null;\n lifecycleGeneration: number;\n remoteHydrationGeneration: number | null;\n remoteHydrationPromise: Promise<void> | null;\n remoteHydrationStructuralGeneration: number | null;\n rootLaneHydrated: boolean;\n snapshot: {\n ready: boolean;\n };\n structuralGeneration: number;\n };\n\ninterface RemoteHydrationRequestInput {\n followDiscoveredParentLanes?: boolean | undefined;\n host: RemoteContainerHydrationHost;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n recreateOnFullyHydratedAfterReset?:\n | (() => () => Promise<void> | void)\n | undefined;\n recreateOnFullyHydratedAtStart?: boolean | undefined;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSyncAfterHydration?: boolean | undefined;\n scheduleSyncOnHydrationChange?: boolean | undefined;\n scheduleSync: () => void;\n state: RemoteHydrationRequestState;\n}\n\ninterface RecoveryHydrationRequest {\n input: RemoteHydrationRequestInput;\n lifecycleGeneration: number;\n structuralGeneration: number;\n}\n\nfunction isRequestGenerationCurrent(input: {\n lifecycleGeneration: number;\n state: RemoteHydrationRequestState;\n structuralGeneration: number;\n}): boolean {\n return (\n input.state.lifecycleGeneration === input.lifecycleGeneration &&\n input.state.structuralGeneration === input.structuralGeneration\n );\n}\n\nconst recoveryHydrationRequestsByState = new WeakMap<\n RemoteHydrationRequestState,\n RecoveryHydrationRequest[]\n>();\nfunction queueRecoveryHydrationRequest(\n input: RemoteHydrationRequestInput,\n): void {\n const requests = recoveryHydrationRequestsByState.get(input.state);\n if (requests) {\n if (!requests.some((request) => request.input === input)) {\n requests.push({\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n });\n }\n return;\n }\n recoveryHydrationRequestsByState.set(input.state, [\n {\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n },\n ]);\n}\n\nfunction hasRemoteHydrationPrerequisites(\n state: RemoteHydrationRequestState,\n): boolean {\n return (\n state.runtime.infra.dbStatus === \"ready\" &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n );\n}\n\nfunction createResetRecoveryInput(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n return {\n ...input,\n followDiscoveredParentLanes: true,\n onFullyHydrated: undefined,\n parentIds: undefined,\n recreateOnFullyHydratedAtStart: true,\n };\n}\n\nfunction resumeRetainedRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n queueRecoveryHydrationRequest(input);\n return hasRemoteHydrationPrerequisites(input.state)\n ? input.resumeRecoveryWork()\n : Promise.resolve();\n}\n\nfunction waitForActiveRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeHydration = state.remoteHydrationPromise;\n if (!activeHydration) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n const needsCurrentGenerationHydration =\n state.remoteHydrationGeneration !== state.lifecycleGeneration ||\n state.remoteHydrationStructuralGeneration !== state.structuralGeneration;\n const requestQueuedHydration = () => {\n if (\n !isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ) {\n return retryRemoteHydrationAfterReset(input);\n }\n return needsCurrentGenerationHydration ||\n state.containerParentIdsNeedingHydration.size > 0\n ? requestContainerContentsRemoteHydration(input)\n : undefined;\n };\n return activeHydration.then(\n requestQueuedHydration,\n (error: unknown) => requestQueuedHydration() ?? Promise.reject(error),\n );\n}\n\nfunction waitForActiveInitialization(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeInitialization = state.initializePromise;\n if (!activeInitialization) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n return activeInitialization.then(() => {\n const recoveryInput = isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ? input\n : createResetRecoveryInput(input);\n return resumeRetainedRecoveryHydration(recoveryInput);\n });\n}\n\nfunction retryRemoteHydrationAfterReset(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n return resumeRetainedRecoveryHydration(createResetRecoveryInput(input));\n}\n\nfunction retainResetRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): void {\n queueRecoveryHydrationRequest(createResetRecoveryInput(input));\n}\n\nexport function resumeContainerContentsRecoveryHydration(\n state: RemoteHydrationRequestState,\n): Promise<void> | null {\n const requests = recoveryHydrationRequestsByState.get(state);\n if (!requests) {\n return null;\n }\n recoveryHydrationRequestsByState.delete(state);\n const inputs = requests.map((request) =>\n isRequestGenerationCurrent({\n lifecycleGeneration: request.lifecycleGeneration,\n state,\n structuralGeneration: request.structuralGeneration,\n })\n ? request.input\n : createResetRecoveryInput(request.input),\n );\n return Promise.all(inputs.map(requestContainerContentsRemoteHydration))\n .then(() => undefined)\n .catch((error: unknown) => {\n for (const input of inputs) {\n queueRecoveryHydrationRequest(input);\n }\n throw error;\n });\n}\n\nfunction queueRequestedParentIds(input: RemoteHydrationRequestInput): void {\n if (!input.parentIds) {\n return;\n }\n for (const parentId of input.parentIds) {\n input.state.containerParentIdsNeedingHydration.add(parentId);\n }\n}\n\nfunction waitForRemoteHydrationReadiness(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const activeHydration = waitForActiveRemoteHydration(input);\n if (activeHydration) {\n return activeHydration;\n }\n const activeInitialization = waitForActiveInitialization(input);\n if (activeInitialization) {\n return activeInitialization;\n }\n if (!hasRemoteHydrationPrerequisites(input.state)) {\n queueRecoveryHydrationRequest(input);\n return Promise.resolve();\n }\n return null;\n}\n\nfunction consumeQueuedHydrationScope(\n state: RemoteHydrationRequestState,\n followDiscoveredParentLanesOption: boolean | undefined,\n): {\n followDiscoveredParentLanes: boolean;\n parentIds: ReadonlyArray<string | null> | undefined;\n} {\n const queuedParentIds = Array.from(state.containerParentIdsNeedingHydration);\n const followDiscoveredParentLanes =\n followDiscoveredParentLanesOption ?? queuedParentIds.length === 0;\n state.containerParentIdsNeedingHydration.clear();\n return {\n followDiscoveredParentLanes,\n parentIds:\n followDiscoveredParentLanes || queuedParentIds.length === 0\n ? undefined\n : queuedParentIds,\n };\n}\n\nexport function requestContainerContentsRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n const { host, scheduleSync, state } = input;\n queueRequestedParentIds(input);\n const readinessBarrier = waitForRemoteHydrationReadiness(input);\n if (readinessBarrier) {\n return readinessBarrier;\n }\n\n const { followDiscoveredParentLanes, parentIds } =\n consumeQueuedHydrationScope(state, input.followDiscoveredParentLanes);\n\n let appliedRemoteContainerChange = false;\n let retainInterruptedHydration = false;\n const lifecycleGeneration = state.lifecycleGeneration;\n const structuralGeneration = state.structuralGeneration;\n const isCurrent = () =>\n isRequestGenerationCurrent({\n lifecycleGeneration,\n state,\n structuralGeneration,\n });\n const onFullyHydrated = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n const hydrationHost = createGenerationGuardedHydrationHost({\n host,\n isCurrent,\n });\n const rootLaneHydratedBeforeRequest = state.rootLaneHydrated;\n state.remoteHydrationGeneration = lifecycleGeneration;\n state.remoteHydrationStructuralGeneration = structuralGeneration;\n const hydrationPromise = refreshLocalContainerStates({\n host: hydrationHost,\n state,\n })\n .then(() => {\n if (!isCurrent()) {\n return 0;\n }\n return hydrateRemoteContainers({\n followDiscoveredParentLanes,\n host: hydrationHost,\n isCurrent,\n onFullyHydrated,\n parentIds,\n resetAllLaneWatermarks: input.resetAllLaneWatermarks,\n resetRootLaneWatermark: input.resetRootLaneWatermark,\n state,\n });\n })\n .then((changedCount) => {\n appliedRemoteContainerChange = changedCount > 0;\n if (isCurrent() && !hasRemoteHydrationPrerequisites(state)) {\n retainInterruptedHydration = true;\n }\n })\n .catch((error: unknown) => {\n if (isCurrent() && isDatabaseUnavailableError(error)) {\n retainInterruptedHydration = true;\n return;\n }\n if (!isCurrent() || error instanceof StaleRemoteHydrationError) {\n return;\n }\n\n throw error;\n })\n .finally(() => {\n const shouldRetryAfterReset = !isCurrent();\n if (state.remoteHydrationPromise === hydrationPromise) {\n state.remoteHydrationPromise = null;\n state.remoteHydrationGeneration = null;\n state.remoteHydrationStructuralGeneration = null;\n }\n\n if (\n isCurrent() &&\n (((input.scheduleSyncOnHydrationChange ?? true) &&\n (appliedRemoteContainerChange ||\n (!rootLaneHydratedBeforeRequest && state.rootLaneHydrated))) ||\n input.scheduleSyncAfterHydration) &&\n state.snapshot.ready &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n ) {\n scheduleSync();\n }\n if (shouldRetryAfterReset) {\n return retryRemoteHydrationAfterReset(input);\n }\n if (retainInterruptedHydration) {\n retainResetRecoveryHydration(input);\n }\n return undefined;\n });\n state.remoteHydrationPromise = hydrationPromise;\n\n return hydrationPromise;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createContainerParentSyncLane, loadContainerSyncLaneCheckRecords, } from "
|
|
2
|
-
import { hasStartupDocumentSyncWork } from "
|
|
3
|
-
import { isDatabaseUnavailableError } from "
|
|
1
|
+
import { createContainerParentSyncLane, loadContainerSyncLaneCheckRecords, } from "../../../workflows/container-contents/containerPersistence.js";
|
|
2
|
+
import { hasStartupDocumentSyncWork } from "../../../workflows/container-contents/documentPriming/index.js";
|
|
3
|
+
import { isDatabaseUnavailableError } from "../../../workflows/container-contents/syncLane.js";
|
|
4
4
|
const STARTUP_REMOTE_HYDRATION_FRESH_MS = 15 * 60_000;
|
|
5
5
|
function isFreshStartupRemoteHydrationCheck(checkedAt, nowMs) {
|
|
6
6
|
const checkedAtMs = Date.parse(checkedAt);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startupHydration.js","sourceRoot":"","sources":["startupHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,4DAA4D,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAE5F,MAAM,iCAAiC,GAAG,EAAE,GAAG,MAAM,CAAC;AAwBtD,SAAS,kCAAkC,CACzC,SAAiB,EACjB,KAAa;IAEb,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CACL,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC5B,KAAK,GAAG,WAAW,IAAI,iCAAiC,CACzD,CAAC;AACJ,CAAC;AAED,SAAS,gCAAgC,CACvC,KAA4B;IAE5B,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,uCAAuC,CACpD,KAA4B,EAC5B,SAAuC;IAEvC,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3C,6BAA6B,CAAC,QAAQ,CAAC,CACxC,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,iCAAiC,CAC1D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAC3B,SAAS,CACV,CAAC;IACF,IAAI,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAC5B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C,GAAG,CAAC;QACrD,KAAK,CAAC,WAAW,CAAC,wBAAwB,CAAC,OAAO,CAAC;QACnD,KAAK,CAAC,WAAW,CAAC,uBAAuB,CAAC,OAAO,CAAC;KACnD,CAAC,CAAC;IACH,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uEAAuE;IACvE,6EAA6E;IAC7E,yEAAyE;IACzE,0EAA0E;IAC1E,2EAA2E;IAC3E,uBAAuB;IACvB,IAAI,MAAM,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,6BAA6B,EAAE,+BAA+B,CAAC,GACpE,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,KAAK,CAAC,WAAW,CAAC,kCAAkC,CAClD,OAAO,EACP,YAAY,CACb;QACD,KAAK,CAAC,WAAW,CAAC,qCAAqC,CACrD,OAAO,EACP,YAAY,CACb;KACF,CAAC,CAAC;IACL,OAAO,CACL,6BAA6B,CAAC,MAAM,GAAG,CAAC;QACxC,+BAA+B,CAAC,MAAM,GAAG,CAAC,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["import {\n type ContainerContentsPersistence,\n createContainerParentSyncLane,\n loadContainerSyncLaneCheckRecords,\n} from \"../../../workflows/container-contents/containerPersistence\";\nimport { hasStartupDocumentSyncWork } from \"../../../workflows/container-contents/documentPriming\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\n\nconst STARTUP_REMOTE_HYDRATION_FRESH_MS = 15 * 60_000;\ntype StartupHydrationExecSql = Parameters<\n typeof loadContainerSyncLaneCheckRecords\n>[0];\n\ninterface StartupHydrationState {\n containerParentIdsNeedingHydration: Set<string | null>;\n containersById: ReadonlyMap<\n string,\n {\n container: {\n metadataDocumentId?: string | null | undefined;\n parentId: string | null;\n };\n }\n >;\n rootLaneHydrated: boolean;\n runtime: {\n auth: { isAuthenticated: boolean; organizationId?: string | null };\n infra: { execSql: StartupHydrationExecSql };\n state: { containerId: string | null; online: boolean };\n };\n}\n\nfunction isFreshStartupRemoteHydrationCheck(\n checkedAt: string,\n nowMs: number,\n): boolean {\n const checkedAtMs = Date.parse(checkedAt);\n return (\n Number.isFinite(checkedAtMs) &&\n nowMs - checkedAtMs <= STARTUP_REMOTE_HYDRATION_FRESH_MS\n );\n}\n\nfunction shouldHydrateUnmarkedStartupRoot(\n state: StartupHydrationState,\n): boolean {\n // An empty authenticated cache needs one root probe to discover the remote\n // tree. Existing local-only roots are deliberately left cache-first; explicit\n // refresh and remote events can reconcile them without polling every startup.\n return state.containersById.size === 0;\n}\n\nasync function getStaleStartupRemoteHydrationParentIds(\n state: StartupHydrationState,\n isCurrent?: (() => boolean) | undefined,\n): Promise<Array<string | null> | null> {\n const parentIds = [null, ...state.containersById.keys()];\n const syncLanes = parentIds.map((parentId) =>\n createContainerParentSyncLane(parentId),\n );\n const checkRecords = await loadContainerSyncLaneCheckRecords(\n state.runtime.infra.execSql,\n syncLanes,\n );\n if (isCurrent?.() === false) {\n return null;\n }\n const nowMs = Date.now();\n const rootCheckRecord = checkRecords[0];\n state.rootLaneHydrated = rootCheckRecord\n ? isFreshStartupRemoteHydrationCheck(rootCheckRecord.checkedAt, nowMs)\n : false;\n const hydrateUnmarkedRoot = shouldHydrateUnmarkedStartupRoot(state);\n\n return parentIds.filter((_, index) => {\n const checkRecord = checkRecords[index];\n if (!checkRecord) {\n return hydrateUnmarkedRoot && index === 0;\n }\n\n return !isFreshStartupRemoteHydrationCheck(checkRecord.checkedAt, nowMs);\n });\n}\n\nfunction reportStartupHydrationError(message: string, error: unknown) {\n if (isDatabaseUnavailableError(error)) {\n return;\n }\n\n console.error(message, error);\n}\n\nexport async function scheduleStaleStartupRemoteHydration(input: {\n isCurrent?: (() => boolean) | undefined;\n requestHydration: () => Promise<void>;\n state: StartupHydrationState;\n}): Promise<boolean> {\n const { requestHydration, state } = input;\n if (!state.runtime.auth.isAuthenticated || !state.runtime.state.online) {\n return false;\n }\n\n let parentIds: Array<string | null> | null;\n try {\n parentIds = await getStaleStartupRemoteHydrationParentIds(\n state,\n input.isCurrent,\n );\n } catch (error: unknown) {\n if (input.isCurrent?.() === false) {\n return false;\n }\n reportStartupHydrationError(\n \"Failed to inspect startup container contents hydration:\",\n error,\n );\n return false;\n }\n if (!parentIds || input.isCurrent?.() === false) {\n return false;\n }\n const activeContainerId = state.runtime.state.containerId;\n const shouldScheduleStaleRootRecovery =\n state.rootLaneHydrated &&\n activeContainerId !== null &&\n !state.containersById.has(activeContainerId);\n if (parentIds.length === 0) {\n return shouldScheduleStaleRootRecovery;\n }\n\n for (const parentId of parentIds) {\n state.containerParentIdsNeedingHydration.add(parentId);\n }\n // Startup stays cache-first: only the local freshness-marker read is awaited.\n // Missing markers on an existing remote cache do not force a first-open poll;\n // stale checked lanes and empty caches hydrate behind the cached tree.\n // WebSocket events and explicit refresh bypass this.\n void requestHydration().catch((error: unknown) => {\n reportStartupHydrationError(\n \"Failed to schedule startup container contents hydration:\",\n error,\n );\n });\n return shouldScheduleStaleRootRecovery;\n}\n\nexport async function hasStartupContainerSyncWork(state: {\n containersById: ReadonlyMap<string, unknown>;\n persistence: ContainerContentsPersistence;\n runtime: { infra: { execSql: StartupHydrationExecSql } };\n}): Promise<boolean> {\n const execSql = state.runtime.infra.execSql;\n const [createIntents, moveIntents] = await Promise.all([\n state.persistence.listPendingCreateIntents(execSql),\n state.persistence.listUnsyncedMoveIntents(execSql),\n ]);\n if (createIntents.length > 0 || moveIntents.length > 0) {\n return true;\n }\n\n // Durable document-level work (pending creates, queued Loro updates or\n // attachments, pending document move intents) is drained by lane passes too:\n // the pass primes the owning document stores, which register and request\n // their own sync lanes. Without this probe, a relaunch whose only pending\n // work is document-level never schedules any lane and the write queue sits\n // unattempted forever.\n if (await hasStartupDocumentSyncWork(execSql)) {\n return true;\n }\n\n const containerIds = Array.from(state.containersById.keys());\n if (containerIds.length === 0) {\n return false;\n }\n const [containersWithPendingMetadata, containersWithPullContinuations] =\n await Promise.all([\n state.persistence.listContainerIdsWithPendingUpdates(\n execSql,\n containerIds,\n ),\n state.persistence.listContainerIdsWithPullContinuations(\n execSql,\n containerIds,\n ),\n ]);\n return (\n containersWithPendingMetadata.length > 0 ||\n containersWithPullContinuations.length > 0\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { PurgeOptions, PurgeProgress, } from "../../workflows/container-contents/container-state/purgeProgress.js";
|
|
1
|
+
export type { PurgeOptions, PurgeProgress, } from "../../workflows/container-contents/container-state/purge/purgeProgress.js";
|
|
2
2
|
export * from "./containerContentsStore.js";
|
|
3
|
-
export { isAutomaticRootCatchupContainerNode, isForeignSystemContainerNode, isReconcilableContainerNode, isRemoteBackedContainerNode, isSystemContainerNode, } from "./reconcilableContainer.js";
|
|
3
|
+
export { isAutomaticRootCatchupContainerNode, isForeignSystemContainerNode, isReconcilableContainerNode, isRemoteBackedContainerNode, isSystemContainerNode, } from "./containerState/reconcilableContainer.js";
|
|
4
4
|
export * from "./state.js";
|
|
5
|
-
export * from "./syncAgent.js";
|
|
5
|
+
export * from "./syncAgent/index.js";
|
|
6
6
|
export * from "./types.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./containerContentsStore.js";
|
|
2
|
-
export { isAutomaticRootCatchupContainerNode, isForeignSystemContainerNode, isReconcilableContainerNode, isRemoteBackedContainerNode, isSystemContainerNode, } from "./reconcilableContainer.js";
|
|
2
|
+
export { isAutomaticRootCatchupContainerNode, isForeignSystemContainerNode, isReconcilableContainerNode, isRemoteBackedContainerNode, isSystemContainerNode, } from "./containerState/reconcilableContainer.js";
|
|
3
3
|
export * from "./state.js";
|
|
4
|
-
export * from "./syncAgent.js";
|
|
4
|
+
export * from "./syncAgent/index.js";
|
|
5
5
|
export * from "./types.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC","sourcesContent":["export type {\n PurgeOptions,\n PurgeProgress,\n} from \"../../workflows/container-contents/container-state/purge/purgeProgress\";\nexport * from \"./containerContentsStore\";\nexport {\n isAutomaticRootCatchupContainerNode,\n isForeignSystemContainerNode,\n isReconcilableContainerNode,\n isRemoteBackedContainerNode,\n isSystemContainerNode,\n} from \"./containerState/reconcilableContainer\";\nexport * from \"./state\";\nexport * from \"./syncAgent\";\nexport * from \"./types\";\n"]}
|
|
@@ -5,8 +5,8 @@ import { installContainerMetadataRecord } from "../../workflows/container-conten
|
|
|
5
5
|
import { currentMetadataPullContinuation } from "../../workflows/container-contents/metadata/metadataPersistence.js";
|
|
6
6
|
import { reconcileLocalOnlyRootContainers } from "../../workflows/container-contents/remoteHydration/reconciliation.js";
|
|
7
7
|
import { isDatabaseUnavailableError } from "../../workflows/container-contents/syncLane.js";
|
|
8
|
-
import { captureContainerStateMutationGenerations, containerStateMutatedAfter, } from "./containerStateMap.js";
|
|
9
|
-
import { isRemoteBackedContainerState } from "./remoteBackedContainerState.js";
|
|
8
|
+
import { captureContainerStateMutationGenerations, containerStateMutatedAfter, } from "./containerState/containerStateMap.js";
|
|
9
|
+
import { isRemoteBackedContainerState } from "./remoteEvents/remoteBackedContainerState.js";
|
|
10
10
|
function readMetadataDocVersion(state) {
|
|
11
11
|
try {
|
|
12
12
|
return encodeVersionVector(state.doc);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localRefresh.js","sourceRoot":"","sources":["localRefresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAC;AAElH,OAAO,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AAErH,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EACL,wCAAwC,EACxC,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AA2B5E,SAAS,sBAAsB,CAAC,KAAqB;IACnD,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,qCAAqC,CAC5C,MAA2C;IAE3C,OAAO,IAAI,GAAG,CACZ,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3C,W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CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,6CAA6C,YAAY,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;QACF,kCAAkC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACZ,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,CAAC;QACjD,IAAI,KAAK,CAAC,4BAA4B,KAAK,cAAc,EAAE,CAAC;YAC1D,KAAK,CAAC,4BAA4B,GAAG,IAAI,CAAC;YAC1C,KAAK,CAAC,+BAA+B,GAAG,IAAI,CAAC;YAC7C,KAAK,CAAC,yCAAyC,GAAG,IAAI,CAAC;QACzD,CAAC;QACD,IAAI,2BAA2B,EAAE,CAAC;YAChC,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC;YACxC,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,4BAA4B,GAAG,cAAc,CAAC;IAEpD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { encodeVersionVector } from \"@tearleads/loro\";\nimport { errorMessage } from \"../../data/shared/errorMessage\";\nimport type { ContainerContentsPersistence } from \"../../workflows/container-contents/containerPersistence\";\nimport { loadLocalContainerStates } from \"../../workflows/container-contents/localState\";\nimport { installContainerMetadataRecord } from \"../../workflows/container-contents/metadata\";\nimport { currentMetadataPullContinuation } from \"../../workflows/container-contents/metadata/metadataPersistence\";\nimport type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nimport { reconcileLocalOnlyRootContainers } from \"../../workflows/container-contents/remoteHydration/reconciliation\";\nimport type { ContainerContentsWorkflowRuntime } from \"../../workflows/container-contents/runtime\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport {\n captureContainerStateMutationGenerations,\n containerStateMutatedAfter,\n} from \"./containerStateMap\";\nimport { isRemoteBackedContainerState } from \"./remoteBackedContainerState\";\n\ninterface LocalContainerRefreshHost {\n updateSnapshot: () => void;\n}\n\nexport interface LocalContainerRefreshState {\n containersById: Map<string, ContainerState>;\n documentStoresNeedPriming: boolean;\n initialized: boolean;\n lifecycleGeneration: number;\n localContainerRefreshGeneration: number | null;\n localContainerRefreshPromise: Promise<void> | null;\n localContainerRefreshStructuralGeneration: number | null;\n localContainersNeedRefresh: boolean;\n persistence: ContainerContentsPersistence;\n runtime: ContainerContentsWorkflowRuntime;\n structuralGeneration: number;\n}\n\ninterface LocalContainerRefreshBaseline {\n container: ContainerState[\"container\"];\n docVersion: string | null;\n pullContinuation: ReturnType<typeof currentMetadataPullContinuation>;\n record: ContainerState[\"record\"];\n}\n\nfunction readMetadataDocVersion(state: ContainerState): string | null {\n try {\n return encodeVersionVector(state.doc);\n } catch {\n return null;\n }\n}\n\nfunction captureLocalContainerRefreshBaselines(\n states: ReadonlyMap<string, ContainerState>,\n): ReadonlyMap<string, LocalContainerRefreshBaseline> {\n return new Map(\n Array.from(states, ([containerId, state]) => [\n containerId,\n {\n container: state.container,\n docVersion: readMetadataDocVersion(state),\n pullContinuation: currentMetadataPullContinuation(state),\n record: state.record,\n },\n ]),\n );\n}\n\nfunction liveContainerStateChangedAfterRefreshStarted(\n state: ContainerState,\n baseline: LocalContainerRefreshBaseline | undefined,\n): boolean {\n // No baseline means this live state was inserted after the refresh began.\n // The loaded snapshot cannot authoritatively replace a state that did not\n // exist when its query started.\n return (\n baseline === undefined ||\n state.container !== baseline.container ||\n state.record !== baseline.record ||\n currentMetadataPullContinuation(state) !== baseline.pullContinuation ||\n readMetadataDocVersion(state) !== baseline.docVersion\n );\n}\n\nfunction mergeLocalContainerStates(input: {\n containerMutationGenerations: ReadonlyMap<string, number>;\n liveStateBaselines: ReadonlyMap<string, LocalContainerRefreshBaseline>;\n localContainerStates: ReadonlyArray<ContainerState>;\n remoteContainerIdsAtLoadStart: ReadonlySet<string>;\n state: LocalContainerRefreshState;\n}): void {\n for (const localContainerState of input.localContainerStates) {\n const containerId = localContainerState.container.id;\n if (\n containerStateMutatedAfter(\n input.state.containersById,\n containerId,\n input.containerMutationGenerations,\n )\n ) {\n continue;\n }\n const existingState = input.state.containersById.get(containerId);\n if (existingState) {\n if (\n liveContainerStateChangedAfterRefreshStarted(\n existingState,\n input.liveStateBaselines.get(containerId),\n )\n ) {\n continue;\n }\n // The load can start before a remote create and finish after it. Its\n // local-only snapshot must not erase the remote identity that the create\n // persisted in the meantime, or the pending create intent is re-queued.\n if (\n !input.remoteContainerIdsAtLoadStart.has(containerId) &&\n existingState.record.documentId &&\n !localContainerState.record.documentId\n ) {\n continue;\n }\n existingState.container = localContainerState.container;\n existingState.doc = localContainerState.doc;\n installContainerMetadataRecord(existingState, localContainerState.record);\n } else if (!input.liveStateBaselines.has(containerId)) {\n // A baseline without a live entry means the state was removed while the\n // load was pending. Do not resurrect that stale snapshot.\n input.state.containersById.set(containerId, localContainerState);\n }\n }\n}\n\nfunction isRemoteBackedRootState(containerState: ContainerState): boolean {\n return (\n containerState.container.parentId === null &&\n isRemoteBackedContainerState(containerState)\n );\n}\n\nasync function reconcileLocalsLoadedAfterRemoteState(\n state: LocalContainerRefreshState,\n isCurrent: () => boolean,\n): Promise<void> {\n const remoteRootStates = Array.from(state.containersById.values()).filter(\n isRemoteBackedRootState,\n );\n for (const remoteRootState of remoteRootStates) {\n if (!isCurrent()) {\n return;\n }\n await reconcileLocalOnlyRootContainers({\n isCurrent,\n remoteRootState,\n state,\n });\n }\n}\n\n/**\n * Hand the tree-rebuild failure to host diagnostics as a real `Error`: the\n * unguarded metadata import inside `loadLocalContainerStates` lands corrupt\n * persisted state here, which the string-only log line cannot carry. That line\n * is the fallback for a host without `logError`, so there is no second copy.\n */\nfunction reportLocalContainerRefreshFailure(\n util: ContainerContentsWorkflowRuntime[\"util\"],\n error: unknown,\n): void {\n // Losing the database mid-flight is the teardown outcome the re-armed refresh\n // already covers, not a defect.\n if (!util.logError || isDatabaseUnavailableError(error)) return;\n try {\n // Callers run `void refreshLocalContainers()`, so a host logger that throws\n // or rejects must not escape as an unhandled rejection carrying app frames.\n void Promise.resolve(\n util.logError(\n \"Container contents: local container refresh failed\",\n error,\n ),\n ).catch(() => undefined);\n } catch {\n // Hosts may throw synchronously or return a rejected promise.\n }\n}\n\nexport function refreshLocalContainerStates(input: {\n host: LocalContainerRefreshHost;\n state: LocalContainerRefreshState;\n}): Promise<void> {\n const { host, state } = input;\n if (state.localContainerRefreshPromise) {\n const activeRefresh = state.localContainerRefreshPromise;\n if (\n state.localContainerRefreshGeneration === state.lifecycleGeneration &&\n state.localContainerRefreshStructuralGeneration ===\n state.structuralGeneration\n ) {\n return activeRefresh;\n }\n // A stale refresh owns its replacement retry in `finally`, so callers can\n // share that promise without scheduling a second replacement load.\n return activeRefresh;\n }\n\n if (\n !state.localContainersNeedRefresh ||\n !state.initialized ||\n state.runtime.infra.dbStatus !== \"ready\"\n ) {\n return Promise.resolve();\n }\n\n const lifecycleGeneration = state.lifecycleGeneration;\n const structuralGeneration = state.structuralGeneration;\n const isCurrent = () =>\n state.lifecycleGeneration === lifecycleGeneration &&\n state.structuralGeneration === structuralGeneration;\n state.localContainersNeedRefresh = false;\n const liveStateBaselines = captureLocalContainerRefreshBaselines(\n state.containersById,\n );\n const containerMutationGenerations = captureContainerStateMutationGenerations(\n state.containersById,\n );\n const remoteContainerIdsAtLoadStart = new Set<string>();\n for (const containerState of state.containersById.values()) {\n if (containerState.record.documentId) {\n remoteContainerIdsAtLoadStart.add(containerState.container.id);\n }\n }\n state.localContainerRefreshGeneration = lifecycleGeneration;\n state.localContainerRefreshStructuralGeneration = structuralGeneration;\n const refreshPromise = loadLocalContainerStates({\n persistence: state.persistence,\n runtime: state.runtime,\n })\n .then(async (localContainerStates) => {\n if (!isCurrent()) {\n return;\n }\n mergeLocalContainerStates({\n containerMutationGenerations,\n liveStateBaselines,\n localContainerStates,\n remoteContainerIdsAtLoadStart,\n state,\n });\n // Remote hydration can win the startup race and ingest the server root\n // before this local read returns. Re-run root/system convergence after\n // merging so that the late local bootstrap rows cannot reintroduce a\n // stale root and same-slot system children into the live tree.\n await reconcileLocalsLoadedAfterRemoteState(state, isCurrent);\n if (!isCurrent()) {\n return;\n }\n state.documentStoresNeedPriming = true;\n host.updateSnapshot();\n })\n .catch((error: unknown) => {\n if (!isCurrent()) {\n return;\n }\n state.localContainersNeedRefresh = true;\n state.runtime.util.log(\n `Failed to refresh local container states: ${errorMessage(error)}`,\n );\n reportLocalContainerRefreshFailure(state.runtime.util, error);\n })\n .finally(() => {\n const shouldRetryAfterReplacement = !isCurrent();\n if (state.localContainerRefreshPromise === refreshPromise) {\n state.localContainerRefreshPromise = null;\n state.localContainerRefreshGeneration = null;\n state.localContainerRefreshStructuralGeneration = null;\n }\n if (shouldRetryAfterReplacement) {\n state.localContainersNeedRefresh = true;\n return refreshLocalContainerStates(input);\n }\n return undefined;\n });\n state.localContainerRefreshPromise = refreshPromise;\n\n return refreshPromise;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localRefresh.js","sourceRoot":"","sources":["localRefresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iEAAiE,CAAC;AAElH,OAAO,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AAErH,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EACL,wCAAwC,EACxC,0BAA0B,GAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,2C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D,MAAM,qCAAqC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC9D,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,KAAK,CAAC,yBAAyB,GAAG,IAAI,CAAC;QACvC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACxB,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,6CAA6C,YAAY,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;QACF,kCAAkC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC;SACD,OAAO,CAAC,GAAG,EAAE;QACZ,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,CAAC;QACjD,IAAI,KAAK,CAAC,4BAA4B,KAAK,cAAc,EAAE,CAAC;YAC1D,KAAK,CAAC,4BAA4B,GAAG,IAAI,CAAC;YAC1C,KAAK,CAAC,+BAA+B,GAAG,IAAI,CAAC;YAC7C,KAAK,CAAC,yCAAyC,GAAG,IAAI,CAAC;QACzD,CAAC;QACD,IAAI,2BAA2B,EAAE,CAAC;YAChC,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC;YACxC,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,4BAA4B,GAAG,cAAc,CAAC;IAEpD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { encodeVersionVector } from \"@tearleads/loro\";\nimport { errorMessage } from \"../../data/shared/errorMessage\";\nimport type { ContainerContentsPersistence } from \"../../workflows/container-contents/containerPersistence\";\nimport { loadLocalContainerStates } from \"../../workflows/container-contents/localState\";\nimport { installContainerMetadataRecord } from \"../../workflows/container-contents/metadata\";\nimport { currentMetadataPullContinuation } from \"../../workflows/container-contents/metadata/metadataPersistence\";\nimport type { ContainerState } from \"../../workflows/container-contents/remoteHydration\";\nimport { reconcileLocalOnlyRootContainers } from \"../../workflows/container-contents/remoteHydration/reconciliation\";\nimport type { ContainerContentsWorkflowRuntime } from \"../../workflows/container-contents/runtime\";\nimport { isDatabaseUnavailableError } from \"../../workflows/container-contents/syncLane\";\nimport {\n captureContainerStateMutationGenerations,\n containerStateMutatedAfter,\n} from \"./containerState/containerStateMap\";\nimport { isRemoteBackedContainerState } from \"./remoteEvents/remoteBackedContainerState\";\n\ninterface LocalContainerRefreshHost {\n updateSnapshot: () => void;\n}\n\nexport interface LocalContainerRefreshState {\n containersById: Map<string, ContainerState>;\n documentStoresNeedPriming: boolean;\n initialized: boolean;\n lifecycleGeneration: number;\n localContainerRefreshGeneration: number | null;\n localContainerRefreshPromise: Promise<void> | null;\n localContainerRefreshStructuralGeneration: number | null;\n localContainersNeedRefresh: boolean;\n persistence: ContainerContentsPersistence;\n runtime: ContainerContentsWorkflowRuntime;\n structuralGeneration: number;\n}\n\ninterface LocalContainerRefreshBaseline {\n container: ContainerState[\"container\"];\n docVersion: string | null;\n pullContinuation: ReturnType<typeof currentMetadataPullContinuation>;\n record: ContainerState[\"record\"];\n}\n\nfunction readMetadataDocVersion(state: ContainerState): string | null {\n try {\n return encodeVersionVector(state.doc);\n } catch {\n return null;\n }\n}\n\nfunction captureLocalContainerRefreshBaselines(\n states: ReadonlyMap<string, ContainerState>,\n): ReadonlyMap<string, LocalContainerRefreshBaseline> {\n return new Map(\n Array.from(states, ([containerId, state]) => [\n containerId,\n {\n container: state.container,\n docVersion: readMetadataDocVersion(state),\n pullContinuation: currentMetadataPullContinuation(state),\n record: state.record,\n },\n ]),\n );\n}\n\nfunction liveContainerStateChangedAfterRefreshStarted(\n state: ContainerState,\n baseline: LocalContainerRefreshBaseline | undefined,\n): boolean {\n // No baseline means this live state was inserted after the refresh began.\n // The loaded snapshot cannot authoritatively replace a state that did not\n // exist when its query started.\n return (\n baseline === undefined ||\n state.container !== baseline.container ||\n state.record !== baseline.record ||\n currentMetadataPullContinuation(state) !== baseline.pullContinuation ||\n readMetadataDocVersion(state) !== baseline.docVersion\n );\n}\n\nfunction mergeLocalContainerStates(input: {\n containerMutationGenerations: ReadonlyMap<string, number>;\n liveStateBaselines: ReadonlyMap<string, LocalContainerRefreshBaseline>;\n localContainerStates: ReadonlyArray<ContainerState>;\n remoteContainerIdsAtLoadStart: ReadonlySet<string>;\n state: LocalContainerRefreshState;\n}): void {\n for (const localContainerState of input.localContainerStates) {\n const containerId = localContainerState.container.id;\n if (\n containerStateMutatedAfter(\n input.state.containersById,\n containerId,\n input.containerMutationGenerations,\n )\n ) {\n continue;\n }\n const existingState = input.state.containersById.get(containerId);\n if (existingState) {\n if (\n liveContainerStateChangedAfterRefreshStarted(\n existingState,\n input.liveStateBaselines.get(containerId),\n )\n ) {\n continue;\n }\n // The load can start before a remote create and finish after it. Its\n // local-only snapshot must not erase the remote identity that the create\n // persisted in the meantime, or the pending create intent is re-queued.\n if (\n !input.remoteContainerIdsAtLoadStart.has(containerId) &&\n existingState.record.documentId &&\n !localContainerState.record.documentId\n ) {\n continue;\n }\n existingState.container = localContainerState.container;\n existingState.doc = localContainerState.doc;\n installContainerMetadataRecord(existingState, localContainerState.record);\n } else if (!input.liveStateBaselines.has(containerId)) {\n // A baseline without a live entry means the state was removed while the\n // load was pending. Do not resurrect that stale snapshot.\n input.state.containersById.set(containerId, localContainerState);\n }\n }\n}\n\nfunction isRemoteBackedRootState(containerState: ContainerState): boolean {\n return (\n containerState.container.parentId === null &&\n isRemoteBackedContainerState(containerState)\n );\n}\n\nasync function reconcileLocalsLoadedAfterRemoteState(\n state: LocalContainerRefreshState,\n isCurrent: () => boolean,\n): Promise<void> {\n const remoteRootStates = Array.from(state.containersById.values()).filter(\n isRemoteBackedRootState,\n );\n for (const remoteRootState of remoteRootStates) {\n if (!isCurrent()) {\n return;\n }\n await reconcileLocalOnlyRootContainers({\n isCurrent,\n remoteRootState,\n state,\n });\n }\n}\n\n/**\n * Hand the tree-rebuild failure to host diagnostics as a real `Error`: the\n * unguarded metadata import inside `loadLocalContainerStates` lands corrupt\n * persisted state here, which the string-only log line cannot carry. That line\n * is the fallback for a host without `logError`, so there is no second copy.\n */\nfunction reportLocalContainerRefreshFailure(\n util: ContainerContentsWorkflowRuntime[\"util\"],\n error: unknown,\n): void {\n // Losing the database mid-flight is the teardown outcome the re-armed refresh\n // already covers, not a defect.\n if (!util.logError || isDatabaseUnavailableError(error)) return;\n try {\n // Callers run `void refreshLocalContainers()`, so a host logger that throws\n // or rejects must not escape as an unhandled rejection carrying app frames.\n void Promise.resolve(\n util.logError(\n \"Container contents: local container refresh failed\",\n error,\n ),\n ).catch(() => undefined);\n } catch {\n // Hosts may throw synchronously or return a rejected promise.\n }\n}\n\nexport function refreshLocalContainerStates(input: {\n host: LocalContainerRefreshHost;\n state: LocalContainerRefreshState;\n}): Promise<void> {\n const { host, state } = input;\n if (state.localContainerRefreshPromise) {\n const activeRefresh = state.localContainerRefreshPromise;\n if (\n state.localContainerRefreshGeneration === state.lifecycleGeneration &&\n state.localContainerRefreshStructuralGeneration ===\n state.structuralGeneration\n ) {\n return activeRefresh;\n }\n // A stale refresh owns its replacement retry in `finally`, so callers can\n // share that promise without scheduling a second replacement load.\n return activeRefresh;\n }\n\n if (\n !state.localContainersNeedRefresh ||\n !state.initialized ||\n state.runtime.infra.dbStatus !== \"ready\"\n ) {\n return Promise.resolve();\n }\n\n const lifecycleGeneration = state.lifecycleGeneration;\n const structuralGeneration = state.structuralGeneration;\n const isCurrent = () =>\n state.lifecycleGeneration === lifecycleGeneration &&\n state.structuralGeneration === structuralGeneration;\n state.localContainersNeedRefresh = false;\n const liveStateBaselines = captureLocalContainerRefreshBaselines(\n state.containersById,\n );\n const containerMutationGenerations = captureContainerStateMutationGenerations(\n state.containersById,\n );\n const remoteContainerIdsAtLoadStart = new Set<string>();\n for (const containerState of state.containersById.values()) {\n if (containerState.record.documentId) {\n remoteContainerIdsAtLoadStart.add(containerState.container.id);\n }\n }\n state.localContainerRefreshGeneration = lifecycleGeneration;\n state.localContainerRefreshStructuralGeneration = structuralGeneration;\n const refreshPromise = loadLocalContainerStates({\n persistence: state.persistence,\n runtime: state.runtime,\n })\n .then(async (localContainerStates) => {\n if (!isCurrent()) {\n return;\n }\n mergeLocalContainerStates({\n containerMutationGenerations,\n liveStateBaselines,\n localContainerStates,\n remoteContainerIdsAtLoadStart,\n state,\n });\n // Remote hydration can win the startup race and ingest the server root\n // before this local read returns. Re-run root/system convergence after\n // merging so that the late local bootstrap rows cannot reintroduce a\n // stale root and same-slot system children into the live tree.\n await reconcileLocalsLoadedAfterRemoteState(state, isCurrent);\n if (!isCurrent()) {\n return;\n }\n state.documentStoresNeedPriming = true;\n host.updateSnapshot();\n })\n .catch((error: unknown) => {\n if (!isCurrent()) {\n return;\n }\n state.localContainersNeedRefresh = true;\n state.runtime.util.log(\n `Failed to refresh local container states: ${errorMessage(error)}`,\n );\n reportLocalContainerRefreshFailure(state.runtime.util, error);\n })\n .finally(() => {\n const shouldRetryAfterReplacement = !isCurrent();\n if (state.localContainerRefreshPromise === refreshPromise) {\n state.localContainerRefreshPromise = null;\n state.localContainerRefreshGeneration = null;\n state.localContainerRefreshStructuralGeneration = null;\n }\n if (shouldRetryAfterReplacement) {\n state.localContainersNeedRefresh = true;\n return refreshLocalContainerStates(input);\n }\n return undefined;\n });\n state.localContainerRefreshPromise = refreshPromise;\n\n return refreshPromise;\n}\n"]}
|
package/stores/container-contents/{containerPurgeCore.js → operations/containerPurgeCore.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { purgeContainerTree } from "
|
|
2
|
-
import { prepareContainerDocumentRotationSnapshot } from "
|
|
3
|
-
import { getContainerContentsStoreLogLabel } from "
|
|
4
|
-
import { updateContainerContentsSnapshot } from "
|
|
1
|
+
import { purgeContainerTree } from "../../../workflows/container-contents/container-state/purge/purgeTree.js";
|
|
2
|
+
import { prepareContainerDocumentRotationSnapshot } from "../documentWork/documentRotation.js";
|
|
3
|
+
import { getContainerContentsStoreLogLabel } from "../logLabel.js";
|
|
4
|
+
import { updateContainerContentsSnapshot } from "../state.js";
|
|
5
5
|
/** @internal Reconciles any completed destructive prefix after expiry. */
|
|
6
6
|
export async function refreshAfterStalePurge(input) {
|
|
7
7
|
const remoteParentIds = new Set();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerPurgeCore.js","sourceRoot":"","sources":["containerPurgeCore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uEAAuE,CAAC;AAC3G,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAW3D,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,KAO5C;IACC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiB,CAAC;IACjD,KAAK,MAAM,wBAAwB,IAAI,KAAK,CAAC,yBAAyB,EAAE,CAAC;QACvE,MAAM,WAAW,GAAG,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAClD,wBAAwB,CACzB,CAAC;QACF,IAAI,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;YACnC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAC9C,MAAM,KAAK,CAAC,SAAS,CAAC,sBAAsB,EAAE,CAAC;IAC/C,IAAI,YAAY,GAAG,KAAK,CAAC;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,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CACtD,CAAC;IACF,IAAI,CAAC,SAAS,EAAE,IAAI,wBAAwB,EAAE,CAAC;QAC7C,MAAM,sBAAsB,CAAC;YAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,sBAAsB;YACtB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,yBAAyB,EAAE,MAAM,CAAC,yBAAyB;YAC3D,KAAK;YACL,SAAS;SACV,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,MAAM,iBAAiB,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC1D,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACjD,CAAC;IACD,0EAA0E;IAC1E,6CAA6C;IAC7C,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,+BAA+B,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAChG,CAAC;IACF,OAAO,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import type { PurgeOptions } from \"../../../workflows/container-contents/container-state/purge/purgeProgress\";\nimport { purgeContainerTree } from \"../../../workflows/container-contents/container-state/purge/purgeTree\";\nimport { prepareContainerDocumentRotationSnapshot } from \"../documentWork/documentRotation\";\nimport { getContainerContentsStoreLogLabel } from \"../logLabel\";\nimport type { ContainerWriteGuard } from \"../remoteWrites/writeGeneration\";\nimport { updateContainerContentsSnapshot } from \"../state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"../syncAgent\";\nimport type { ContainerContentsStoreState } from \"../types\";\n\ntype ContainerPurgeResult = NonNullable<\n Awaited<ReturnType<typeof purgeContainerTree>>\n>;\n\n/** @internal Reconciles any completed destructive prefix after expiry. */\nexport async function refreshAfterStalePurge(input: {\n completedCount: number;\n containerStatesAtStart: ReadonlyMap<string, ContainerState>;\n purgedContainerIds: readonly string[];\n remoteDeletedContainerIds: readonly string[];\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n}): Promise<void> {\n const remoteParentIds = new Set<string | null>();\n for (const remoteDeletedContainerId of input.remoteDeletedContainerIds) {\n const purgedState = input.containerStatesAtStart.get(\n remoteDeletedContainerId,\n );\n if (purgedState?.record.documentId) {\n remoteParentIds.add(purgedState.container.parentId);\n }\n }\n\n input.state.localContainersNeedRefresh = true;\n await input.syncAgent.refreshLocalContainers();\n let removedState = false;\n for (const purgedContainerId of input.purgedContainerIds) {\n const deletedState = input.containerStatesAtStart.get(purgedContainerId);\n if (\n deletedState &&\n input.state.containersById.get(purgedContainerId) === deletedState\n ) {\n input.state.containersById.delete(purgedContainerId);\n removedState = true;\n }\n }\n input.state.documentStoresNeedPriming = true;\n if (removedState && input.state.initialized) {\n updateContainerContentsSnapshot(input.state);\n }\n if (remoteParentIds.size > 0) {\n await input.syncAgent.requestRemoteHydration({\n followDiscoveredParentLanes: false,\n parentIds: [...remoteParentIds],\n resetAllLaneWatermarks: true,\n });\n }\n}\n\n// Shared core of the two recursive purge operations (purgeContainer and\n// emptyTrash): guard readiness and the remote-authority gate, run the\n// recursive purge engine, drop the purged containers from the tree, and log\n// the outcome. The operations differ only in target validation, whether the\n// root container itself survives, and how the result is described/judged.\nexport async function runContainerPurge(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n options: PurgeOptions | undefined,\n isCurrent: ContainerWriteGuard,\n operation: {\n describeResult: (\n target: ContainerState,\n result: ContainerPurgeResult,\n ) => string;\n didSucceed: (result: ContainerPurgeResult) => boolean;\n keepRootContainer?: boolean | undefined;\n validateTarget: (target: ContainerState) => boolean;\n },\n): Promise<boolean> {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return false;\n }\n\n const targetState = state.containersById.get(containerId);\n if (!targetState || !operation.validateTarget(targetState)) {\n return false;\n }\n\n // Any remote container or document in the subtree needs the server, so require\n // auth + online when the target itself is remote (a local-only subtree can be\n // torn down offline, matching deleteContainer's gate).\n const isRemoteContainer = Boolean(targetState.record.documentId);\n if (\n isRemoteContainer &&\n (!state.runtime.auth.isAuthenticated || !state.runtime.state.online)\n ) {\n return false;\n }\n const containerStatesAtStart = new Map(state.containersById);\n\n const result = await purgeContainerTree({\n containersById: state.containersById,\n keepRootContainer: operation.keepRootContainer ?? false,\n onProgress: options?.onProgress,\n persistence: state.persistence,\n prepareDocumentRotationSnapshot: (document) =>\n prepareContainerDocumentRotationSnapshot(state.runtime, document),\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n rootContainerId: containerId,\n runtime: state.runtime,\n signal: options?.signal,\n stillCurrent: isCurrent,\n });\n if (!result) {\n return false;\n }\n const purgedContainerIds = new Set(result.purgedContainerIds);\n const hasUnsettledRemoteDelete = result.remoteDeletedContainerIds.some(\n (containerId) => !purgedContainerIds.has(containerId),\n );\n if (!isCurrent() || hasUnsettledRemoteDelete) {\n await refreshAfterStalePurge({\n completedCount: result.completedCount,\n containerStatesAtStart,\n purgedContainerIds: result.purgedContainerIds,\n remoteDeletedContainerIds: result.remoteDeletedContainerIds,\n state,\n syncAgent,\n });\n return false;\n }\n\n for (const purgedContainerId of result.purgedContainerIds) {\n state.containersById.delete(purgedContainerId);\n }\n // Only re-render when something actually left the tree; a fully-failed or\n // immediately-cancelled run changed nothing.\n if (result.purgedContainerIds.length > 0) {\n updateContainerContentsSnapshot(state);\n }\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${operation.describeResult(targetState, result)}`,\n );\n return operation.didSucceed(result);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyTrashOperation.js","sourceRoot":"","sources":["emptyTrashOperation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,kFAAkF;AAClF,iFAAiF;AACjF,gFAAgF;AAChF,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAAkC,EAClC,SAA0C,EAC1C,gBAAwB,EACxB,OAAsB,EACtB,YAAiC,GAAG,EAAE,CAAC,IAAI;IAE3C,OAAO,iBAAiB,CACtB,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT;QACE,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAClC,kBAAkB,MAAM,CAAC,kBAAkB,CAAC,MAAM,0BAA0B,MAAM,CAAC,WAAW,UAAU;QAC1G,0DAA0D;QAC1D,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,WAAW,KAAK,CAAC;QACnE,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CACzB,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,IAAI;KACjD,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PurgeOptions } from \"../../../workflows/container-contents/container-state/purge/purgeProgress\";\nimport type { ContainerWriteGuard } from \"../remoteWrites/writeGeneration\";\nimport type { ContainerContentsStoreSyncAgent } from \"../syncAgent\";\nimport type { ContainerContentsStoreState } from \"../types\";\nimport { runContainerPurge } from \"./containerPurgeCore\";\n\n// Permanently destroy EVERYTHING under the Trash bin — every trashed folder's\n// whole subtree and every document deleted straight into Trash — while leaving\n// the Trash system container itself in place. This is \"Empty Trash\": it reuses\n// the recursive purge engine with keepRootContainer so the bin survives, and it\n// inherits that engine's semantics — documents also linked outside Trash are\n// unlinked (not destroyed), containers are torn down leaf-first, a failed item is\n// skipped rather than aborting the sweep, and an optional signal cancels between\n// items. The target must be a real system container (the Trash bin); like every\n// purge it is online-only when any of its contents are remote.\nexport async function emptyTrash(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n trashContainerId: string,\n options?: PurgeOptions,\n isCurrent: ContainerWriteGuard = () => true,\n): Promise<boolean> {\n return runContainerPurge(\n state,\n syncAgent,\n trashContainerId,\n options,\n isCurrent,\n {\n describeResult: (_target, result) =>\n `emptied trash (${result.purgedContainerIds.length} container(s) removed, ${result.failedCount} failed)`,\n // A clean empty: nothing failed and it ran to completion.\n didSucceed: (result) => !result.aborted && result.failedCount === 0,\n keepRootContainer: true,\n validateTarget: (target) =>\n (target.container.systemSlot ?? null) !== null,\n },\n );\n}\n"]}
|