@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":"principalPolicyCache.js","sourceRoot":"","sources":["principalPolicyCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"principalPolicyCache.js","sourceRoot":"","sources":["principalPolicyCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iFAAiF,CAAC;AAU/H,MAAM,CAAC,KAAK,UAAU,qCAAqC,CAAC,KAM3D;IACC,MAAM,gCAAgC,GACpC,KAAK,CAAC,gCAAgC,CAAC;IACzC,IAAI,CAAC,gCAAgC,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IAED,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAGvC,CAAC;IAEJ,KAAK,MAAM,eAAe,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACrD,MAAM,UAAU,GAAG,eAAe,CAAC,4BAA4B,CAAC;QAChE,MAAM,EAAE,cAAc,EAAE,GAAG,eAAe,CAAC;QAC3C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YAC/C,SAAS;QACX,CAAC;QAED,MAAM,sBAAsB,GAC1B,0BAA0B,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QAC9D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,sBAAsB,CAAC,GAAG,CACxB,4BAA4B,CAAC,SAAS,CAAC,EACvC,SAAS,CACV,CAAC;QACJ,CAAC;QACD,0BAA0B,CAAC,GAAG,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CACf,CAAC,GAAG,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,eAAe,CAAC,EAAE,EAAE,CACxE,gCAAgC,CAAC;QAC/B,cAAc;QACd,UAAU,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;QACzC,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ReferencedPrincipalPolicyWarmer } from \"../../../data/keyingProjectionVerification\";\nimport { referencedPrincipalPolicyKey } from \"../../../data/keyingProjectionVerification/principalPolicy/principalPolicyCache\";\nimport type { RemoteContainer } from \"./types\";\n\ntype RemoteContainerPrincipalReferences = Pick<\n RemoteContainer,\n \"metadataReferencedPrincipals\" | \"organizationId\"\n>;\ntype PrincipalReference =\n RemoteContainer[\"metadataReferencedPrincipals\"][number];\n\nexport async function cacheRemoteContainerPrincipalPolicies(input: {\n readonly cacheReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n readonly remoteContainers: readonly RemoteContainerPrincipalReferences[];\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<void> {\n const cacheReferencedPrincipalPolicies =\n input.cacheReferencedPrincipalPolicies;\n if (!cacheReferencedPrincipalPolicies) {\n return;\n }\n\n const referencesByOrganizationId = new Map<\n string,\n Map<string, PrincipalReference>\n >();\n\n for (const remoteContainer of input.remoteContainers) {\n const references = remoteContainer.metadataReferencedPrincipals;\n const { organizationId } = remoteContainer;\n if (references.length === 0 || !organizationId) {\n continue;\n }\n\n const organizationReferences =\n referencesByOrganizationId.get(organizationId) ?? new Map();\n for (const reference of references) {\n organizationReferences.set(\n referencedPrincipalPolicyKey(reference),\n reference,\n );\n }\n referencesByOrganizationId.set(organizationId, organizationReferences);\n }\n\n await Promise.all(\n [...referencesByOrganizationId].map(([organizationId, referencesByKey]) =>\n cacheReferencedPrincipalPolicies({\n organizationId,\n references: [...referencesByKey.values()],\n stillCurrent: input.stillCurrent,\n }),\n ),\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isSessionRootState, isVerifiedLocalRootReconciliationTarget, } from "./destination/verifiedDestination.js";
|
|
2
|
+
import { createContainerChildIndex, moveIndexedContainerChild, removeIndexedContainerChild, } from "./lanes/childIndex.js";
|
|
3
3
|
export function hasRemoteContainerMetadataState(containerState) {
|
|
4
4
|
return (typeof containerState.record.documentId === "string" &&
|
|
5
5
|
containerState.record.documentId.length > 0 &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciliation.js","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AAK;KACN,CAAC,CAAC;IAEH,IAAI,8BAA8B,GAAG,CAAC,CAAC;IACvC,KAAK,MAAM,gBAAgB,IAAI,iBAAiB,EAAE,CAAC;QACjD,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,8BAA8B,CAAC;QACxC,CAAC;QACD,MAAM,iCAAiC,CAAC;YACtC,kBAAkB;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,gBAAgB;YAChB,iBAAiB;YACjB,KAAK;SACN,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,8BAA8B,CAAC;QACxC,CAAC;QACD,8BAA8B,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,8BAA8B,GAAG,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,8BAA8B,CAAC;AACxC,CAAC","sourcesContent":["import type { LocalRootDescendantReparentInput } from \"../containerPersistence\";\nimport {\n createContainerChildIndex,\n moveIndexedContainerChild,\n removeIndexedContainerChild,\n} from \"./childIndex\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainerHydrationState,\n} from \"./types\";\nimport {\n isSessionRootState,\n isVerifiedLocalRootReconciliationTarget,\n} from \"./verifiedDestination\";\n\nexport function hasRemoteContainerMetadataState(\n containerState: ContainerState,\n): boolean {\n return (\n typeof containerState.record.documentId === \"string\" &&\n containerState.record.documentId.length > 0 &&\n typeof containerState.record.accessStateHash === \"string\" &&\n containerState.record.accessStateHash.length > 0 &&\n typeof containerState.container.metadataDocumentId === \"string\" &&\n containerState.container.metadataDocumentId.length > 0\n );\n}\n\nfunction isLocalOnlyRootContainerState(\n containerState: ContainerState,\n): boolean {\n return (\n containerState.container.parentId === null &&\n !containerState.container.systemSlot &&\n !hasRemoteContainerMetadataState(containerState)\n );\n}\n\nfunction collectContainerSubtreeStates(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containersById: ReadonlyMap<string, ContainerState>;\n rootContainerId: string;\n}): ContainerState[] {\n const { childIdsByParentId, containersById, rootContainerId } = input;\n const subtreeStates: ContainerState[] = [];\n const pendingContainerIds = [rootContainerId];\n const enqueuedContainerIds = new Set<string>([rootContainerId]);\n const index = childIdsByParentId ?? createContainerChildIndex(containersById);\n\n while (pendingContainerIds.length > 0) {\n const containerId = pendingContainerIds.pop();\n if (!containerId) {\n continue;\n }\n\n const childIds = index.get(containerId);\n if (!childIds) {\n continue;\n }\n\n for (const childId of childIds) {\n if (enqueuedContainerIds.has(childId)) {\n continue;\n }\n const childState = containersById.get(childId);\n if (!childState) {\n continue;\n }\n\n enqueuedContainerIds.add(childId);\n subtreeStates.push(childState);\n pendingContainerIds.push(childId);\n }\n }\n\n return subtreeStates;\n}\n\nfunction buildLocalRootDescendantReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): {\n descendantReparents: LocalRootDescendantReparentInput[];\n descendants: ContainerState[];\n} {\n const { childIdsByParentId, localRootState, remoteRootState, state } = input;\n const descendants = collectContainerSubtreeStates({\n childIdsByParentId,\n containersById: state.containersById,\n rootContainerId: localRootState.container.id,\n });\n const descendantReparents = descendants.map((descendant) => {\n const previousParentId = descendant.container.parentId;\n const parentContainerId =\n previousParentId === localRootState.container.id\n ? remoteRootState.container.id\n : previousParentId;\n\n return {\n containerId: descendant.container.id,\n parentContainerId,\n updateCreateIntent: !descendant.record.documentId && !!parentContainerId,\n };\n });\n\n return { descendantReparents, descendants };\n}\n\nfunction applyLocalRootDescendantReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n descendantReparents: ReadonlyArray<LocalRootDescendantReparentInput>;\n descendants: ReadonlyArray<ContainerState>;\n remoteRootState: ContainerState;\n updatedAt: string;\n}): void {\n const {\n childIdsByParentId,\n descendantReparents,\n descendants,\n remoteRootState,\n updatedAt,\n } = input;\n const reparentByContainerId = new Map(\n descendantReparents.map((reparent) => [reparent.containerId, reparent]),\n );\n\n for (const descendant of descendants) {\n const previousParentId = descendant.container.parentId;\n const reparent = reparentByContainerId.get(descendant.container.id);\n if (!reparent) {\n continue;\n }\n\n descendant.container = {\n ...descendant.container,\n organizationId: remoteRootState.container.organizationId,\n parentId: reparent.parentContainerId,\n localUpdatedAt: updatedAt,\n updatedAt: descendant.container.serverUpdatedAt ?? updatedAt,\n };\n moveIndexedContainerChild(\n childIdsByParentId,\n descendant.container.id,\n previousParentId,\n reparent.parentContainerId,\n );\n }\n}\n\nfunction adoptReconciledSessionRoot(input: {\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): void {\n const { localRootState, remoteRootState, state } = input;\n const adopter = state.runtime.adoptRootContainer;\n const defaultOrganizationId = state.runtime.auth.defaultOrganizationId;\n const userId = state.runtime.auth.userId;\n if (\n !adopter ||\n !defaultOrganizationId ||\n defaultOrganizationId === remoteRootState.container.organizationId ||\n !userId\n ) {\n return;\n }\n\n // Personal-org adoption waits for the complete root lane so hydration cannot\n // re-enter the store before its child lanes are applied. The heuristic is\n // intentionally personal-only, so use this exact durable identity pair to\n // close the corresponding recovery gap for an active secondary organization.\n adopter({\n domainScope: state.runtime.state.domainScope,\n expectedContainerId: localRootState.container.id,\n nextContainerId: remoteRootState.container.id,\n organizationId: remoteRootState.container.organizationId,\n userId,\n });\n}\n\nasync function reconcileLocalOnlyRootContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n const { childIdsByParentId, localRootState, remoteRootState, state } = input;\n const execSql = state.runtime.infra.execSql;\n const updatedAt = new Date().toISOString();\n const { descendantReparents, descendants } =\n buildLocalRootDescendantReparents({\n childIdsByParentId,\n localRootState,\n remoteRootState,\n state,\n });\n\n await state.persistence.reconcileLocalRootContainer(execSql, {\n descendantReparents,\n localRootContainerId: localRootState.container.id,\n remoteOrganizationId: remoteRootState.container.organizationId,\n remoteRootContainerId: remoteRootState.container.id,\n stillCurrent: input.isCurrent,\n updatedAt,\n });\n if (input.isCurrent?.() === false) {\n return;\n }\n applyLocalRootDescendantReparents({\n childIdsByParentId,\n descendantReparents,\n descendants,\n remoteRootState,\n updatedAt,\n });\n\n if (childIdsByParentId) {\n removeIndexedContainerChild(\n childIdsByParentId,\n localRootState.container.id,\n localRootState.container.parentId,\n );\n childIdsByParentId.delete(localRootState.container.id);\n }\n state.containersById.delete(localRootState.container.id);\n adoptReconciledSessionRoot({ localRootState, remoteRootState, state });\n state.runtime.util.log(\n `Container contents: reconciled local root ${localRootState.container.id} into remote root ${remoteRootState.container.id}`,\n );\n}\n\nexport async function reconcileLocalOnlyRootContainers(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n requestDocumentPriming?: (() => void) | undefined;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<number> {\n const { childIdsByParentId, remoteRootState, state } = input;\n if (\n input.isCurrent?.() === false ||\n !isSessionRootState(remoteRootState, state)\n ) {\n return 0;\n }\n\n const localRootStates = Array.from(state.containersById.values()).filter(\n (containerState) =>\n containerState.container.id !== remoteRootState.container.id &&\n isLocalOnlyRootContainerState(containerState),\n );\n // The unsigned login answer names the root; only the verified root created\n // by the session user may absorb local content (see verifiedDestination).\n // Checked only when there is local root content to merge, from the cached\n // role alone, so a local refresh never waits on the network.\n if (\n localRootStates.length > 0 &&\n !(await isVerifiedLocalRootReconciliationTarget({ remoteRootState, state }))\n ) {\n return 0;\n }\n\n let reconciledRootContainerCount = 0;\n for (const localRootState of localRootStates) {\n if (input.isCurrent?.() === false) {\n return reconciledRootContainerCount;\n }\n await reconcileLocalOnlyRootContainer({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n localRootState,\n remoteRootState,\n state,\n });\n if (input.isCurrent?.() === false) {\n return reconciledRootContainerCount;\n }\n reconciledRootContainerCount += 1;\n }\n // A remote system child can be applied before its remote root (for example,\n // from an earlier page/pass). Its local twin does not match while it is still\n // parented to the pre-auth root. Root reconciliation fixes the parent and\n // organization, so retry every already-known remote system sibling now. The\n // normal root-first ordering still reconciles when the remote system arrives.\n let reconciledSystemContainerCount = 0;\n for (const knownRemoteSystemState of Array.from(\n state.containersById.values(),\n )) {\n if (\n (knownRemoteSystemState.container.systemSlot ?? null) !== null &&\n hasRemoteContainerMetadataState(knownRemoteSystemState)\n ) {\n reconciledSystemContainerCount +=\n await reconcileLocalOnlySystemContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteSystemState: knownRemoteSystemState,\n state,\n });\n }\n }\n if (reconciledRootContainerCount + reconciledSystemContainerCount > 0) {\n input.requestDocumentPriming?.();\n }\n\n return reconciledRootContainerCount;\n}\n\nfunction isLocalOnlySystemContainerState(input: {\n containerState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): boolean {\n const { containerState, remoteSystemState, state } = input;\n const localSystemSlot = containerState.container.systemSlot ?? null;\n const remoteSystemSlot = remoteSystemState.container.systemSlot ?? null;\n\n if (\n remoteSystemSlot === null ||\n localSystemSlot !== remoteSystemSlot ||\n containerState.container.id === remoteSystemState.container.id ||\n hasRemoteContainerMetadataState(containerState)\n ) {\n return false;\n }\n\n const sharesRemoteLocation =\n containerState.container.organizationId ===\n remoteSystemState.container.organizationId &&\n containerState.container.parentId === remoteSystemState.container.parentId;\n if (sharesRemoteLocation) {\n return true;\n }\n\n const homeOrganizationId = state.runtime.auth.organizationId;\n if (\n !homeOrganizationId ||\n remoteSystemState.container.organizationId !== homeOrganizationId ||\n containerState.container.organizationId !== \"\"\n ) {\n return false;\n }\n\n const localParentId = containerState.container.parentId;\n const localParentState = localParentId\n ? state.containersById.get(localParentId)\n : null;\n\n return !localParentState || isLocalOnlyRootContainerState(localParentState);\n}\n\nfunction findLocalOnlySystemContainerStates(input: {\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): ContainerState[] {\n const { remoteSystemState, state } = input;\n if ((remoteSystemState.container.systemSlot ?? null) === null) {\n return [];\n }\n\n return Array.from(state.containersById.values()).filter((containerState) =>\n isLocalOnlySystemContainerState({\n containerState,\n remoteSystemState,\n state,\n }),\n );\n}\n\nfunction applyLocalSystemContainerChildReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n localSystemState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n updatedAt: string;\n}): void {\n const { childIdsByParentId, localSystemState, remoteSystemState, state } =\n input;\n const localContainerId = localSystemState.container.id;\n const childContainerIds = childIdsByParentId\n ? Array.from(childIdsByParentId.get(localContainerId) ?? [])\n : Array.from(state.containersById.values()).flatMap((containerState) =>\n containerState.container.parentId === localContainerId\n ? [containerState.container.id]\n : [],\n );\n\n for (const childContainerId of childContainerIds) {\n const childState = state.containersById.get(childContainerId);\n if (!childState) {\n continue;\n }\n\n const previousParentId = childState.container.parentId;\n childState.container = {\n ...childState.container,\n organizationId: remoteSystemState.container.organizationId,\n parentId: remoteSystemState.container.id,\n localUpdatedAt: input.updatedAt,\n updatedAt: childState.container.serverUpdatedAt ?? input.updatedAt,\n };\n moveIndexedContainerChild(\n childIdsByParentId,\n childState.container.id,\n previousParentId,\n remoteSystemState.container.id,\n );\n }\n}\n\nasync function reconcileLocalOnlySystemContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n localSystemState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n const { childIdsByParentId, localSystemState, remoteSystemState, state } =\n input;\n const updatedAt = new Date().toISOString();\n const execSql = state.runtime.infra.execSql;\n\n await state.persistence.reconcileLocalSystemContainer(execSql, {\n localContainerId: localSystemState.container.id,\n remoteContainerId: remoteSystemState.container.id,\n remoteOrganizationId: remoteSystemState.container.organizationId,\n stillCurrent: input.isCurrent,\n updatedAt,\n });\n if (input.isCurrent?.() === false) {\n return;\n }\n applyLocalSystemContainerChildReparents({\n childIdsByParentId,\n localSystemState,\n remoteSystemState,\n state,\n updatedAt,\n });\n\n if (childIdsByParentId) {\n removeIndexedContainerChild(\n childIdsByParentId,\n localSystemState.container.id,\n localSystemState.container.parentId,\n );\n childIdsByParentId.delete(localSystemState.container.id);\n }\n state.containersById.delete(localSystemState.container.id);\n state.runtime.util.log(\n `Container contents: reconciled local system container ${localSystemState.container.id} into remote system container ${remoteSystemState.container.id}`,\n );\n}\n\nexport async function reconcileLocalOnlySystemContainers(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n requestDocumentPriming?: (() => void) | undefined;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<number> {\n const { childIdsByParentId, remoteSystemState, state } = input;\n if (input.isCurrent?.() === false) {\n return 0;\n }\n const localSystemStates = findLocalOnlySystemContainerStates({\n remoteSystemState,\n state,\n });\n\n let reconciledSystemContainerCount = 0;\n for (const localSystemState of localSystemStates) {\n if (input.isCurrent?.() === false) {\n return reconciledSystemContainerCount;\n }\n await reconcileLocalOnlySystemContainer({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n localSystemState,\n remoteSystemState,\n state,\n });\n if (input.isCurrent?.() === false) {\n return reconciledSystemContainerCount;\n }\n reconciledSystemContainerCount += 1;\n }\n if (reconciledSystemContainerCount > 0) {\n input.requestDocumentPriming?.();\n }\n\n return reconciledSystemContainerCount;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reconciliation.js","sourceRoot":"","sources":["reconciliation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,uCAAuC,GACxC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,oB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AAC;YAClC,OAAO,8BAA8B,CAAC;QACxC,CAAC;QACD,MAAM,iCAAiC,CAAC;YACtC,kBAAkB;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,gBAAgB;YAChB,iBAAiB;YACjB,KAAK;SACN,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,8BAA8B,CAAC;QACxC,CAAC;QACD,8BAA8B,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,8BAA8B,GAAG,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,8BAA8B,CAAC;AACxC,CAAC","sourcesContent":["import type { LocalRootDescendantReparentInput } from \"../containerPersistence\";\nimport {\n isSessionRootState,\n isVerifiedLocalRootReconciliationTarget,\n} from \"./destination/verifiedDestination\";\nimport {\n createContainerChildIndex,\n moveIndexedContainerChild,\n removeIndexedContainerChild,\n} from \"./lanes/childIndex\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nexport function hasRemoteContainerMetadataState(\n containerState: ContainerState,\n): boolean {\n return (\n typeof containerState.record.documentId === \"string\" &&\n containerState.record.documentId.length > 0 &&\n typeof containerState.record.accessStateHash === \"string\" &&\n containerState.record.accessStateHash.length > 0 &&\n typeof containerState.container.metadataDocumentId === \"string\" &&\n containerState.container.metadataDocumentId.length > 0\n );\n}\n\nfunction isLocalOnlyRootContainerState(\n containerState: ContainerState,\n): boolean {\n return (\n containerState.container.parentId === null &&\n !containerState.container.systemSlot &&\n !hasRemoteContainerMetadataState(containerState)\n );\n}\n\nfunction collectContainerSubtreeStates(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containersById: ReadonlyMap<string, ContainerState>;\n rootContainerId: string;\n}): ContainerState[] {\n const { childIdsByParentId, containersById, rootContainerId } = input;\n const subtreeStates: ContainerState[] = [];\n const pendingContainerIds = [rootContainerId];\n const enqueuedContainerIds = new Set<string>([rootContainerId]);\n const index = childIdsByParentId ?? createContainerChildIndex(containersById);\n\n while (pendingContainerIds.length > 0) {\n const containerId = pendingContainerIds.pop();\n if (!containerId) {\n continue;\n }\n\n const childIds = index.get(containerId);\n if (!childIds) {\n continue;\n }\n\n for (const childId of childIds) {\n if (enqueuedContainerIds.has(childId)) {\n continue;\n }\n const childState = containersById.get(childId);\n if (!childState) {\n continue;\n }\n\n enqueuedContainerIds.add(childId);\n subtreeStates.push(childState);\n pendingContainerIds.push(childId);\n }\n }\n\n return subtreeStates;\n}\n\nfunction buildLocalRootDescendantReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): {\n descendantReparents: LocalRootDescendantReparentInput[];\n descendants: ContainerState[];\n} {\n const { childIdsByParentId, localRootState, remoteRootState, state } = input;\n const descendants = collectContainerSubtreeStates({\n childIdsByParentId,\n containersById: state.containersById,\n rootContainerId: localRootState.container.id,\n });\n const descendantReparents = descendants.map((descendant) => {\n const previousParentId = descendant.container.parentId;\n const parentContainerId =\n previousParentId === localRootState.container.id\n ? remoteRootState.container.id\n : previousParentId;\n\n return {\n containerId: descendant.container.id,\n parentContainerId,\n updateCreateIntent: !descendant.record.documentId && !!parentContainerId,\n };\n });\n\n return { descendantReparents, descendants };\n}\n\nfunction applyLocalRootDescendantReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n descendantReparents: ReadonlyArray<LocalRootDescendantReparentInput>;\n descendants: ReadonlyArray<ContainerState>;\n remoteRootState: ContainerState;\n updatedAt: string;\n}): void {\n const {\n childIdsByParentId,\n descendantReparents,\n descendants,\n remoteRootState,\n updatedAt,\n } = input;\n const reparentByContainerId = new Map(\n descendantReparents.map((reparent) => [reparent.containerId, reparent]),\n );\n\n for (const descendant of descendants) {\n const previousParentId = descendant.container.parentId;\n const reparent = reparentByContainerId.get(descendant.container.id);\n if (!reparent) {\n continue;\n }\n\n descendant.container = {\n ...descendant.container,\n organizationId: remoteRootState.container.organizationId,\n parentId: reparent.parentContainerId,\n localUpdatedAt: updatedAt,\n updatedAt: descendant.container.serverUpdatedAt ?? updatedAt,\n };\n moveIndexedContainerChild(\n childIdsByParentId,\n descendant.container.id,\n previousParentId,\n reparent.parentContainerId,\n );\n }\n}\n\nfunction adoptReconciledSessionRoot(input: {\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): void {\n const { localRootState, remoteRootState, state } = input;\n const adopter = state.runtime.adoptRootContainer;\n const defaultOrganizationId = state.runtime.auth.defaultOrganizationId;\n const userId = state.runtime.auth.userId;\n if (\n !adopter ||\n !defaultOrganizationId ||\n defaultOrganizationId === remoteRootState.container.organizationId ||\n !userId\n ) {\n return;\n }\n\n // Personal-org adoption waits for the complete root lane so hydration cannot\n // re-enter the store before its child lanes are applied. The heuristic is\n // intentionally personal-only, so use this exact durable identity pair to\n // close the corresponding recovery gap for an active secondary organization.\n adopter({\n domainScope: state.runtime.state.domainScope,\n expectedContainerId: localRootState.container.id,\n nextContainerId: remoteRootState.container.id,\n organizationId: remoteRootState.container.organizationId,\n userId,\n });\n}\n\nasync function reconcileLocalOnlyRootContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n localRootState: ContainerState;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n const { childIdsByParentId, localRootState, remoteRootState, state } = input;\n const execSql = state.runtime.infra.execSql;\n const updatedAt = new Date().toISOString();\n const { descendantReparents, descendants } =\n buildLocalRootDescendantReparents({\n childIdsByParentId,\n localRootState,\n remoteRootState,\n state,\n });\n\n await state.persistence.reconcileLocalRootContainer(execSql, {\n descendantReparents,\n localRootContainerId: localRootState.container.id,\n remoteOrganizationId: remoteRootState.container.organizationId,\n remoteRootContainerId: remoteRootState.container.id,\n stillCurrent: input.isCurrent,\n updatedAt,\n });\n if (input.isCurrent?.() === false) {\n return;\n }\n applyLocalRootDescendantReparents({\n childIdsByParentId,\n descendantReparents,\n descendants,\n remoteRootState,\n updatedAt,\n });\n\n if (childIdsByParentId) {\n removeIndexedContainerChild(\n childIdsByParentId,\n localRootState.container.id,\n localRootState.container.parentId,\n );\n childIdsByParentId.delete(localRootState.container.id);\n }\n state.containersById.delete(localRootState.container.id);\n adoptReconciledSessionRoot({ localRootState, remoteRootState, state });\n state.runtime.util.log(\n `Container contents: reconciled local root ${localRootState.container.id} into remote root ${remoteRootState.container.id}`,\n );\n}\n\nexport async function reconcileLocalOnlyRootContainers(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n requestDocumentPriming?: (() => void) | undefined;\n remoteRootState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<number> {\n const { childIdsByParentId, remoteRootState, state } = input;\n if (\n input.isCurrent?.() === false ||\n !isSessionRootState(remoteRootState, state)\n ) {\n return 0;\n }\n\n const localRootStates = Array.from(state.containersById.values()).filter(\n (containerState) =>\n containerState.container.id !== remoteRootState.container.id &&\n isLocalOnlyRootContainerState(containerState),\n );\n // The unsigned login answer names the root; only the verified root created\n // by the session user may absorb local content (see verifiedDestination).\n // Checked only when there is local root content to merge, from the cached\n // role alone, so a local refresh never waits on the network.\n if (\n localRootStates.length > 0 &&\n !(await isVerifiedLocalRootReconciliationTarget({ remoteRootState, state }))\n ) {\n return 0;\n }\n\n let reconciledRootContainerCount = 0;\n for (const localRootState of localRootStates) {\n if (input.isCurrent?.() === false) {\n return reconciledRootContainerCount;\n }\n await reconcileLocalOnlyRootContainer({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n localRootState,\n remoteRootState,\n state,\n });\n if (input.isCurrent?.() === false) {\n return reconciledRootContainerCount;\n }\n reconciledRootContainerCount += 1;\n }\n // A remote system child can be applied before its remote root (for example,\n // from an earlier page/pass). Its local twin does not match while it is still\n // parented to the pre-auth root. Root reconciliation fixes the parent and\n // organization, so retry every already-known remote system sibling now. The\n // normal root-first ordering still reconciles when the remote system arrives.\n let reconciledSystemContainerCount = 0;\n for (const knownRemoteSystemState of Array.from(\n state.containersById.values(),\n )) {\n if (\n (knownRemoteSystemState.container.systemSlot ?? null) !== null &&\n hasRemoteContainerMetadataState(knownRemoteSystemState)\n ) {\n reconciledSystemContainerCount +=\n await reconcileLocalOnlySystemContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteSystemState: knownRemoteSystemState,\n state,\n });\n }\n }\n if (reconciledRootContainerCount + reconciledSystemContainerCount > 0) {\n input.requestDocumentPriming?.();\n }\n\n return reconciledRootContainerCount;\n}\n\nfunction isLocalOnlySystemContainerState(input: {\n containerState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): boolean {\n const { containerState, remoteSystemState, state } = input;\n const localSystemSlot = containerState.container.systemSlot ?? null;\n const remoteSystemSlot = remoteSystemState.container.systemSlot ?? null;\n\n if (\n remoteSystemSlot === null ||\n localSystemSlot !== remoteSystemSlot ||\n containerState.container.id === remoteSystemState.container.id ||\n hasRemoteContainerMetadataState(containerState)\n ) {\n return false;\n }\n\n const sharesRemoteLocation =\n containerState.container.organizationId ===\n remoteSystemState.container.organizationId &&\n containerState.container.parentId === remoteSystemState.container.parentId;\n if (sharesRemoteLocation) {\n return true;\n }\n\n const homeOrganizationId = state.runtime.auth.organizationId;\n if (\n !homeOrganizationId ||\n remoteSystemState.container.organizationId !== homeOrganizationId ||\n containerState.container.organizationId !== \"\"\n ) {\n return false;\n }\n\n const localParentId = containerState.container.parentId;\n const localParentState = localParentId\n ? state.containersById.get(localParentId)\n : null;\n\n return !localParentState || isLocalOnlyRootContainerState(localParentState);\n}\n\nfunction findLocalOnlySystemContainerStates(input: {\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): ContainerState[] {\n const { remoteSystemState, state } = input;\n if ((remoteSystemState.container.systemSlot ?? null) === null) {\n return [];\n }\n\n return Array.from(state.containersById.values()).filter((containerState) =>\n isLocalOnlySystemContainerState({\n containerState,\n remoteSystemState,\n state,\n }),\n );\n}\n\nfunction applyLocalSystemContainerChildReparents(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n localSystemState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n updatedAt: string;\n}): void {\n const { childIdsByParentId, localSystemState, remoteSystemState, state } =\n input;\n const localContainerId = localSystemState.container.id;\n const childContainerIds = childIdsByParentId\n ? Array.from(childIdsByParentId.get(localContainerId) ?? [])\n : Array.from(state.containersById.values()).flatMap((containerState) =>\n containerState.container.parentId === localContainerId\n ? [containerState.container.id]\n : [],\n );\n\n for (const childContainerId of childContainerIds) {\n const childState = state.containersById.get(childContainerId);\n if (!childState) {\n continue;\n }\n\n const previousParentId = childState.container.parentId;\n childState.container = {\n ...childState.container,\n organizationId: remoteSystemState.container.organizationId,\n parentId: remoteSystemState.container.id,\n localUpdatedAt: input.updatedAt,\n updatedAt: childState.container.serverUpdatedAt ?? input.updatedAt,\n };\n moveIndexedContainerChild(\n childIdsByParentId,\n childState.container.id,\n previousParentId,\n remoteSystemState.container.id,\n );\n }\n}\n\nasync function reconcileLocalOnlySystemContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n localSystemState: ContainerState;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<void> {\n const { childIdsByParentId, localSystemState, remoteSystemState, state } =\n input;\n const updatedAt = new Date().toISOString();\n const execSql = state.runtime.infra.execSql;\n\n await state.persistence.reconcileLocalSystemContainer(execSql, {\n localContainerId: localSystemState.container.id,\n remoteContainerId: remoteSystemState.container.id,\n remoteOrganizationId: remoteSystemState.container.organizationId,\n stillCurrent: input.isCurrent,\n updatedAt,\n });\n if (input.isCurrent?.() === false) {\n return;\n }\n applyLocalSystemContainerChildReparents({\n childIdsByParentId,\n localSystemState,\n remoteSystemState,\n state,\n updatedAt,\n });\n\n if (childIdsByParentId) {\n removeIndexedContainerChild(\n childIdsByParentId,\n localSystemState.container.id,\n localSystemState.container.parentId,\n );\n childIdsByParentId.delete(localSystemState.container.id);\n }\n state.containersById.delete(localSystemState.container.id);\n state.runtime.util.log(\n `Container contents: reconciled local system container ${localSystemState.container.id} into remote system container ${remoteSystemState.container.id}`,\n );\n}\n\nexport async function reconcileLocalOnlySystemContainers(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n isCurrent?: (() => boolean) | undefined;\n requestDocumentPriming?: (() => void) | undefined;\n remoteSystemState: ContainerState;\n state: RemoteContainerHydrationState;\n}): Promise<number> {\n const { childIdsByParentId, remoteSystemState, state } = input;\n if (input.isCurrent?.() === false) {\n return 0;\n }\n const localSystemStates = findLocalOnlySystemContainerStates({\n remoteSystemState,\n state,\n });\n\n let reconciledSystemContainerCount = 0;\n for (const localSystemState of localSystemStates) {\n if (input.isCurrent?.() === false) {\n return reconciledSystemContainerCount;\n }\n await reconcileLocalOnlySystemContainer({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n localSystemState,\n remoteSystemState,\n state,\n });\n if (input.isCurrent?.() === false) {\n return reconciledSystemContainerCount;\n }\n reconciledSystemContainerCount += 1;\n }\n if (reconciledSystemContainerCount > 0) {\n input.requestDocumentPriming?.();\n }\n\n return reconciledSystemContainerCount;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerStateFingerprint.js","sourceRoot":"","sources":["containerStateFingerprint.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAqB;IACnE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,KAGhD;IACC,OAAO,CACL,CAAC,KAAK,CAAC,YAAY;QACjB,CAAC,CAAC,+BAA+B,CAAC,KAAK,CAAC,YAAY,CAAC;QACrD,CAAC,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,mBAAmB,CAC7C,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerState } from \"../types\";\n\n/**\n * Immutable request-time identity for one live container state. Hydration\n * mutates ContainerState objects in place, so retaining the object reference is\n * not enough to detect a newer local or remote commit while a page is fetched.\n */\nexport function createContainerStateFingerprint(state: ContainerState): string {\n return JSON.stringify([state.container, state.record]);\n}\n\nexport function containerStateMatchesFingerprint(input: {\n currentState: ContainerState | undefined;\n expectedFingerprint: string | undefined;\n}): boolean {\n return (\n (input.currentState\n ? createContainerStateFingerprint(input.currentState)\n : undefined) === input.expectedFingerprint\n );\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { assertHeldContainerBinding, heldContainerBinding, } from "
|
|
2
|
-
import { createContainerMetadataDocument, getDefaultContainerName, } from "
|
|
3
|
-
import { materializeStoredContainerStateReadOnly } from "
|
|
4
|
-
import { addIndexedContainerChild } from "
|
|
5
|
-
import { reattachDormantContainerMetadata } from "
|
|
6
|
-
import { reconcileLocalOnlyRootContainers } from "
|
|
1
|
+
import { assertHeldContainerBinding, heldContainerBinding, } from "../../../../data/containers/containerBinding.js";
|
|
2
|
+
import { createContainerMetadataDocument, getDefaultContainerName, } from "../../../../data/containers/containerMetadataDocument.js";
|
|
3
|
+
import { materializeStoredContainerStateReadOnly } from "../../storedContainerState.js";
|
|
4
|
+
import { addIndexedContainerChild } from "../lanes/childIndex.js";
|
|
5
|
+
import { reattachDormantContainerMetadata } from "../reattachMetadata.js";
|
|
6
|
+
import { reconcileLocalOnlyRootContainers } from "../reconciliation.js";
|
|
7
7
|
import { applyRemoteContainerTimestamps, remoteContainerHydrationSaveOptions, } from "./remoteContainerTimestamps.js";
|
|
8
8
|
function createInsertedRemoteContainerState(input) {
|
|
9
9
|
const { doc, dormantRecord, remoteContainer } = input;
|
package/workflows/container-contents/remoteHydration/remoteContainers/insertRemoteContainer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertRemoteContainer.js","sourceRoot":"","sources":["insertRemoteContainer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAQrE,OAAO,EACL,8BAA8B,EAC9B,mCAAmC,GACpC,MAAM,6BAA6B,CAAC;AAYrC,SAAS,kCAAkC,CAAC,KAQ3C;IACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,UAAU,GAAG,gCAAgC,CAAC;QAClD,WAAW,EAAE,uBAAuB,CAAC,eAAe,CAAC,QAAQ,CAAC;QAC9D,GAAG;QACH,aAAa;QACb,wBAAwB,EAAE,eAAe,CAAC,kBAAkB;KAC7D,CAAC,CAAC;IACH,OAAO;QACL,SAAS,EAAE,8BAA8B,CACvC;YACE,EAAE,EAAE,eAAe,CAAC,EAAE;YACtB,oBAAoB,EAAE,eAAe,CAAC,oBAAoB;YAC1D,cAAc,EAAE,eAAe,CAAC,cAAc;YAC9C,QAAQ,EAAE,eAAe,CAAC,QAAQ;YAClC,kBAAkB,EAAE,eAAe,CAAC,kBAAkB;YACtD,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,IAAI;YAC9C,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;SACtB,EACD,eAAe,CAChB;QACD,4BAA4B,EAAE,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AAC;QACrC,oEAAoE;QACpE,0BAA0B,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,EAAE;YACnE,cAAc,EAAE,eAAe,CAAC,cAAc;YAC9C,mBAAmB,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC;SAC1D,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,uCAAuC,CAAC;YACjE,eAAe,EAAE,kBAAkB;SACpC,CAAC,CAAC;QACH,IACE,CAAC,YAAY;YACb,CAAC,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,EACjE,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,cAAc,GAAG,YAAY,CAAC;QAC9B,cAAc,CAAC,4BAA4B;YACzC,eAAe,CAAC,4BAA4B,CAAC;IACjD,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC7D,IAAI,kBAAkB,EAAE,CAAC;QACvB,wBAAwB,CACtB,kBAAkB,EAClB,eAAe,CAAC,EAAE,EAClB,cAAc,CAAC,SAAS,CAAC,QAAQ,CAClC,CAAC;IACJ,CAAC;IACD,MAAM,gCAAgC,CAAC;QACrC,kBAAkB;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,eAAe,EAAE,cAAc;QAC/B,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,KAAK;KACN,CAAC,CAAC;IACH,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import type { AccessManifestCheckpoint } from \"@tearleads/crypto\";\nimport {\n assertHeldContainerBinding,\n heldContainerBinding,\n} from \"../../../../data/containers/containerBinding\";\nimport {\n createContainerMetadataDocument,\n getDefaultContainerName,\n} from \"../../../../data/containers/containerMetadataDocument\";\nimport type { ContainerHydrationTombstone } from \"../../containerPersistence\";\nimport { materializeStoredContainerStateReadOnly } from \"../../storedContainerState\";\nimport { addIndexedContainerChild } from \"../lanes/childIndex\";\nimport { reattachDormantContainerMetadata } from \"../reattachMetadata\";\nimport { reconcileLocalOnlyRootContainers } from \"../reconciliation\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"../types\";\nimport {\n applyRemoteContainerTimestamps,\n remoteContainerHydrationSaveOptions,\n} from \"./remoteContainerTimestamps\";\n\ninterface InsertRemoteContainerStateInput {\n childIdsByParentId?: ContainerChildIndex | undefined;\n host: RemoteContainerHydrationHost;\n expectedHydrationTombstone: ContainerHydrationTombstone | null;\n expectedPlacementCheckpoint?: AccessManifestCheckpoint | undefined;\n isCurrent?: (() => boolean) | undefined;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}\n\nfunction createInsertedRemoteContainerState(input: {\n doc: ContainerState[\"doc\"];\n dormantRecord: Awaited<\n ReturnType<\n RemoteContainerHydrationState[\"persistence\"][\"loadContainerMetadataRecord\"]\n >\n >;\n remoteContainer: RemoteContainer;\n}): ContainerState {\n const { doc, dormantRecord, remoteContainer } = input;\n const reattached = reattachDormantContainerMetadata({\n defaultName: getDefaultContainerName(remoteContainer.parentId),\n doc,\n dormantRecord,\n remoteMetadataDocumentId: remoteContainer.metadataDocumentId,\n });\n return {\n container: applyRemoteContainerTimestamps(\n {\n id: remoteContainer.id,\n effectiveAccessLevel: remoteContainer.effectiveAccessLevel,\n organizationId: remoteContainer.organizationId,\n parentId: remoteContainer.parentId,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n systemSlot: remoteContainer.systemSlot ?? null,\n name: reattached.name,\n icon: reattached.icon,\n },\n remoteContainer,\n ),\n metadataReferencedPrincipals: remoteContainer.metadataReferencedPrincipals,\n doc,\n record: {\n accessEpoch: remoteContainer.metadataAccessEpoch,\n accessStateHash: remoteContainer.metadataAccessStateHash,\n documentId: remoteContainer.metadataDocumentId,\n id: remoteContainer.id,\n lastCommitLsn: reattached.lastCommitLsn,\n metadataUpdates: reattached.initialSnapshot,\n ...(reattached.pullContinuation === undefined\n ? {}\n : { pullContinuation: reattached.pullContinuation }),\n ...(reattached.pullContinuationRecoveryRequired\n ? { pullContinuationRecoveryRequired: true as const }\n : {}),\n snapshotEndVersion: reattached.snapshotEndVersion,\n contentKeyBundle: null,\n documentKekTargets: null,\n documentManifestBundle: null,\n },\n };\n}\n\n/**\n * Insert a verified container the device holds no live row for, re-attaching\n * retained dormant metadata whose binding matches.\n */\nexport async function insertRemoteContainerState(\n input: InsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n const { childIdsByParentId, host, remoteContainer, state } = input;\n const execSql = state.runtime.infra.execSql;\n const persistence = state.persistence;\n const doc = await createContainerMetadataDocument(remoteContainer.id);\n if (input.isCurrent?.() === false) {\n return null;\n }\n // A container inserted with dormant retained metadata (row 4's\n // access_revoked branch) is a re-attach, not a fresh discovery: import the\n // retained content and markers instead of overwriting them with an empty\n // document. Access and keying fields still come from the remote container —\n // revocation may have rotated them.\n const dormantRecord = await persistence.loadContainerMetadataRecord(\n execSql,\n remoteContainer.id,\n );\n if (input.isCurrent?.() === false) {\n return null;\n }\n // Destination verification refused a relisting that conflicts with the\n // retained organization or metadata target. A record committed since then\n // by a concurrent hydration is refused here; commit rechecks both durably.\n assertHeldContainerBinding(\n {\n organizationId: \"\",\n metadataDocumentId: dormantRecord?.documentId ?? null,\n },\n {\n organizationId: remoteContainer.organizationId,\n metadataDocumentIds: [remoteContainer.metadataDocumentId],\n },\n );\n const containerState = createInsertedRemoteContainerState({\n doc,\n dormantRecord,\n remoteContainer,\n });\n\n const committed = await persistence.commitHydratedContainer(execSql, {\n container: containerState.container,\n expectedDormantRecord: dormantRecord,\n expectedHydrationTombstone: input.expectedHydrationTombstone,\n expectedPlacementCheckpoint: input.expectedPlacementCheckpoint,\n record: containerState.record,\n remoteUpdatedAt: remoteContainer.updatedAt,\n saveOptions: remoteContainerHydrationSaveOptions({ remoteContainer }),\n stillCurrent: input.isCurrent,\n });\n let installedState = containerState;\n if (committed.committed) {\n installedState.container = committed.container;\n } else {\n const winningStoredState = await persistence.loadContainerMetadataState(\n execSql,\n remoteContainer.id,\n );\n if (!winningStoredState) return null;\n // A concurrent hydration that won the insert holds the binding now.\n assertHeldContainerBinding(heldContainerBinding(winningStoredState), {\n organizationId: remoteContainer.organizationId,\n metadataDocumentIds: [remoteContainer.metadataDocumentId],\n });\n const winningState = await materializeStoredContainerStateReadOnly({\n storedContainer: winningStoredState,\n });\n if (\n !winningState ||\n !(await persistence.containerExists(execSql, remoteContainer.id))\n ) {\n return null;\n }\n installedState = winningState;\n installedState.metadataReferencedPrincipals =\n remoteContainer.metadataReferencedPrincipals;\n }\n if (input.isCurrent?.() === false) {\n return null;\n }\n state.containersById.set(remoteContainer.id, installedState);\n if (childIdsByParentId) {\n addIndexedContainerChild(\n childIdsByParentId,\n remoteContainer.id,\n installedState.container.parentId,\n );\n }\n await reconcileLocalOnlyRootContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteRootState: installedState,\n requestDocumentPriming: host.requestDocumentPriming,\n state,\n });\n return installedState;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createRuntimePrincipalPolicyWarmer } from "
|
|
1
|
+
import { createRuntimePrincipalPolicyWarmer } from "../../../principals/runtimePolicyWarmer.js";
|
|
2
|
+
import { prefetchDestinationProjections } from "../destination/destinationPrefetch.js";
|
|
3
|
+
import { cachedDestinationRole } from "../destination/destinationRoleCache.js";
|
|
4
|
+
import { markContainerParentLaneFetched } from "../lanes/laneFetchMarkers.js";
|
|
5
|
+
import { fetchContainerParentLaneBatch } from "../lanes/parentLaneFetch.js";
|
|
6
|
+
import { cacheRemoteContainerPrincipalPolicies } from "../principalPolicyCache.js";
|
|
7
|
+
import { applyContainerTombstones, getApplicableRemoteContainerItems, } from "../tombstoneApplication.js";
|
|
2
8
|
import { containerStateMatchesFingerprint } from "./containerStateFingerprint.js";
|
|
3
|
-
import { prefetchDestinationProjections } from "./destinationPrefetch.js";
|
|
4
|
-
import { cachedDestinationRole } from "./destinationRoleCache.js";
|
|
5
|
-
import { markContainerParentLaneFetched } from "./laneFetchMarkers.js";
|
|
6
|
-
import { fetchContainerParentLaneBatch } from "./parentLaneFetch.js";
|
|
7
|
-
import { cacheRemoteContainerPrincipalPolicies } from "./principalPolicyCache.js";
|
|
8
9
|
import { listRemoteContainerIdsWithPendingMetadataUpdates, listRemoteContainerIdsWithPendingStructuralIntents, upsertIsolatedRemoteContainerState, } from "./remoteContainerState.js";
|
|
9
|
-
import { applyContainerTombstones, getApplicableRemoteContainerItems, } from "./tombstoneApplication.js";
|
|
10
10
|
const CONTAINER_PARENT_HYDRATION_CONCURRENCY = 4;
|
|
11
11
|
async function applyRemoteContainerPage(input) {
|
|
12
12
|
const { childIdsByParentId, expectedContainerStates, expectedHydrationTombstones, host, items, queueParentLane, seenContainerIds, state, } = input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteContainerPageHydration.js","sourceRoot":"","sources":["remoteContainerPageHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,yBAAyB,CAAC;AAWjC,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC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QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC7D,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC;YACjD,kBAAkB;YAClB,YAAY;YACZ,IAAI;YACJ,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,KAAK;YACL,eAAe;YACf,gBAAgB;YAChB,KAAK;SACN,CAAC,CAAC;QACH,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC;QACpC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;QAE7B,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import { createRuntimePrincipalPolicyWarmer } from \"../../../principals/runtimePolicyWarmer\";\nimport { prefetchDestinationProjections } from \"../destination/destinationPrefetch\";\nimport { cachedDestinationRole } from \"../destination/destinationRoleCache\";\nimport { markContainerParentLaneFetched } from \"../lanes/laneFetchMarkers\";\nimport { fetchContainerParentLaneBatch } from \"../lanes/parentLaneFetch\";\nimport { cacheRemoteContainerPrincipalPolicies } from \"../principalPolicyCache\";\nimport {\n applyContainerTombstones,\n getApplicableRemoteContainerItems,\n} from \"../tombstoneApplication\";\nimport type {\n ContainerChildIndex,\n ContainerParentHydrationLane,\n ExpectedContainerState,\n FetchedContainerParentLanePage,\n ListedRemoteContainerPageItem,\n QueueContainerParentLane,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"../types\";\nimport { containerStateMatchesFingerprint } from \"./containerStateFingerprint\";\nimport {\n listRemoteContainerIdsWithPendingMetadataUpdates,\n listRemoteContainerIdsWithPendingStructuralIntents,\n upsertIsolatedRemoteContainerState,\n} from \"./remoteContainerState\";\n\nconst CONTAINER_PARENT_HYDRATION_CONCURRENCY = 4;\n\ninterface HydrationProgress {\n changedCount: number;\n complete: boolean;\n shouldStop: boolean;\n}\nasync function applyRemoteContainerPage(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n expectedHydrationTombstones: FetchedContainerParentLanePage[\"expectedHydrationTombstones\"];\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n items: ReadonlyArray<ListedRemoteContainerPageItem>;\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<{ changedCount: number; completed: boolean }> {\n const {\n childIdsByParentId,\n expectedContainerStates,\n expectedHydrationTombstones,\n host,\n items,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let hydratedCount = 0;\n let pageCompleted = true;\n await cacheRemoteContainerPrincipalPolicies({\n cacheReferencedPrincipalPolicies: createRuntimePrincipalPolicyWarmer(\n state.runtime,\n ),\n remoteContainers: items,\n stillCurrent: input.isCurrent,\n });\n if (input.isCurrent?.() === false) {\n return { changedCount: 0, completed: false };\n }\n const [\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n ] = await Promise.all([\n listRemoteContainerIdsWithPendingMetadataUpdates({\n remoteContainers: items,\n state,\n }),\n listRemoteContainerIdsWithPendingStructuralIntents({\n remoteContainers: items,\n state,\n }),\n ]);\n if (input.isCurrent?.() === false) {\n return { changedCount: 0, completed: false };\n }\n const prefetchedProjections = await prefetchDestinationProjections({\n containerIds: items.flatMap((item) =>\n seenContainerIds.has(item.id) ||\n state.containersById.has(item.id) ||\n expectedHydrationTombstones.get(item.id) ||\n cachedDestinationRole(state.runtime.infra.execSql, item)\n ? []\n : [item.id],\n ),\n isCurrent: input.isCurrent,\n runtime: state.runtime,\n });\n for (const container of items) {\n if (input.isCurrent?.() === false) {\n return { changedCount: hydratedCount, completed: false };\n }\n if (!seenContainerIds.has(container.id)) {\n if (\n !containerStateMatchesFingerprint({\n currentState: state.containersById.get(container.id),\n expectedFingerprint: expectedContainerStates.get(container.id)\n ?.fingerprint,\n })\n ) {\n pageCompleted = false;\n continue;\n }\n const upserted = await upsertIsolatedRemoteContainerState({\n childIdsByParentId,\n containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents,\n host,\n isCurrent: input.isCurrent,\n expectedHydrationTombstone:\n expectedHydrationTombstones.get(container.id) ?? null,\n prefetchedProjection: prefetchedProjections.get(container.id),\n remoteContainer: container,\n state,\n });\n if (!upserted) {\n pageCompleted = false;\n continue;\n }\n seenContainerIds.add(container.id);\n hydratedCount += 1;\n if (input.isCurrent?.() === false) {\n return { changedCount: hydratedCount, completed: false };\n }\n }\n queueParentLane(container.id);\n }\n\n return { changedCount: hydratedCount, completed: pageCompleted };\n}\n\nexport function canHydrateRemoteContainers(\n state: RemoteContainerHydrationState,\n): boolean {\n return (\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online &&\n state.runtime.infra.dbStatus === \"ready\"\n );\n}\n\nasync function applyContainerParentLanePage(input: {\n childIdsByParentId: ContainerChildIndex;\n fetchedPage: FetchedContainerParentLanePage;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n queueContinuationLane: (lane: ContainerParentHydrationLane) => void;\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n fetchedPage,\n host,\n queueContinuationLane,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n const {\n expectedContainerStates,\n expectedHydrationTombstones,\n lane,\n response,\n syncLane,\n } = fetchedPage;\n let changedCount = 0;\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const remoteContainerItems = getApplicableRemoteContainerItems(response);\n const tombstoneResult = await applyContainerTombstones({\n childIdsByParentId,\n expectedContainerStates,\n isCurrent: input.isCurrent,\n remoteContainerItems,\n response,\n state,\n });\n if (!tombstoneResult.current) {\n return { changedCount, complete: false, shouldStop: true };\n }\n changedCount += tombstoneResult.changedCount;\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (tombstoneResult.changedCount > 0) {\n // A live tombstone cascade may have orphaned documents (row 3); re-arm\n // document priming so their null-scoped passes run now rather than on\n // the next startup.\n host.requestDocumentPriming?.();\n }\n\n const appliedPage = await applyRemoteContainerPage({\n childIdsByParentId,\n expectedContainerStates,\n expectedHydrationTombstones,\n host,\n isCurrent: input.isCurrent,\n items: remoteContainerItems,\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += appliedPage.changedCount;\n if (!tombstoneResult.completed || !appliedPage.completed) {\n // Keep this page retryable without discarding independent lanes, including\n // children of roots first discovered here. Otherwise the root becomes known\n // but its children are never fetched by subsequent root-only refreshes.\n return { changedCount, complete: false, shouldStop: false };\n }\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const didMarkFetched = await markContainerParentLaneFetched({\n isCurrent: input.isCurrent,\n response,\n state,\n syncLane,\n });\n if (!didMarkFetched) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n if (!response.hasMore) {\n return { changedCount, complete: true, shouldStop: false };\n }\n if (!response.nextWatermark) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n queueContinuationLane({\n parentId: lane.parentId,\n watermark: response.nextWatermark,\n });\n return { changedCount, complete: true, shouldStop: false };\n}\n\nfunction takeContainerParentLaneBatch(input: {\n lanes: ContainerParentHydrationLane[];\n state: RemoteContainerHydrationState;\n}): ContainerParentHydrationLane[] {\n const { lanes, state } = input;\n const batch: ContainerParentHydrationLane[] = [];\n\n while (\n lanes.length > 0 &&\n batch.length < CONTAINER_PARENT_HYDRATION_CONCURRENCY\n ) {\n const lane = lanes.shift();\n if (\n lane &&\n (lane.parentId === null || state.containersById.has(lane.parentId))\n ) {\n batch.push(lane);\n }\n }\n\n return batch;\n}\n\nasync function applyContainerParentLaneBatch(input: {\n childIdsByParentId: ContainerChildIndex;\n fetchedPages: ReadonlyArray<FetchedContainerParentLanePage>;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n lanes: ContainerParentHydrationLane[];\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n fetchedPages,\n host,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let changedCount = 0;\n let complete = true;\n\n for (const fetchedPage of fetchedPages) {\n if (!canHydrateRemoteContainers(state) || input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (\n fetchedPage.lane.parentId !== null &&\n !state.containersById.has(fetchedPage.lane.parentId)\n ) {\n continue;\n }\n\n const result = await applyContainerParentLanePage({\n childIdsByParentId,\n fetchedPage,\n host,\n isCurrent: input.isCurrent,\n queueContinuationLane: (lane) => lanes.push(lane),\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += result.changedCount;\n complete &&= result.complete;\n\n if (result.shouldStop) {\n return { changedCount, complete: false, shouldStop: true };\n }\n }\n\n return { changedCount, complete, shouldStop: false };\n}\n\nexport async function hydrateContainerParentLanes(input: {\n childIdsByParentId: ContainerChildIndex;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n lanes: ContainerParentHydrationLane[];\n queueParentLane: QueueContainerParentLane;\n seenContainerIds: Set<string>;\n state: RemoteContainerHydrationState;\n}): Promise<HydrationProgress> {\n const {\n childIdsByParentId,\n host,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n } = input;\n let changedCount = 0;\n let complete = true;\n\n while (lanes.length > 0) {\n if (!canHydrateRemoteContainers(state) || input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const batch = takeContainerParentLaneBatch({ lanes, state });\n if (batch.length === 0) {\n continue;\n }\n\n const fetchedPages = await fetchContainerParentLaneBatch({\n batch,\n isCurrent: input.isCurrent,\n state,\n });\n if (!fetchedPages) {\n return { changedCount, complete: false, shouldStop: true };\n }\n if (input.isCurrent?.() === false) {\n return { changedCount, complete: false, shouldStop: true };\n }\n\n const result = await applyContainerParentLaneBatch({\n childIdsByParentId,\n fetchedPages,\n host,\n isCurrent: input.isCurrent,\n lanes,\n queueParentLane,\n seenContainerIds,\n state,\n });\n changedCount += result.changedCount;\n complete &&= result.complete;\n\n if (result.shouldStop) {\n return { changedCount, complete: false, shouldStop: true };\n }\n }\n\n return { changedCount, complete, shouldStop: false };\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { heldContainerBinding, listingRepeatsHeldOrdinaryBinding, } from "
|
|
2
|
-
import { isKeyingVerificationError, runWithSecurityIncidentReporting, } from "
|
|
3
|
-
import { isProjectionVerificationCancelledError } from "
|
|
4
|
-
import { installContainerMetadataRecord } from "
|
|
5
|
-
import { projectionGeneration } from "
|
|
6
|
-
import {
|
|
7
|
-
import { rebindReHomedContainer } from "
|
|
1
|
+
import { heldContainerBinding, listingRepeatsHeldOrdinaryBinding, } from "../../../../data/containers/containerBinding.js";
|
|
2
|
+
import { isKeyingVerificationError, runWithSecurityIncidentReporting, } from "../../../../data/keyingProjectionVerification/error.js";
|
|
3
|
+
import { isProjectionVerificationCancelledError } from "../../../../data/keyingProjectionVerification/types.js";
|
|
4
|
+
import { installContainerMetadataRecord } from "../../metadata/metadataPersistence.js";
|
|
5
|
+
import { projectionGeneration } from "../../projectionGeneration.js";
|
|
6
|
+
import { verifyRemoteContainerDestination } from "../destination/verifiedDestination.js";
|
|
7
|
+
import { rebindReHomedContainer } from "../heldContainerRebind.js";
|
|
8
|
+
import { moveIndexedContainerChild, removeIndexedContainerChild, } from "../lanes/childIndex.js";
|
|
9
|
+
import { reconcileLocalOnlyRootContainers, reconcileLocalOnlySystemContainers, } from "../reconciliation.js";
|
|
8
10
|
import { insertRemoteContainerState } from "./insertRemoteContainer.js";
|
|
9
|
-
import { reconcileLocalOnlyRootContainers, reconcileLocalOnlySystemContainers, } from "./reconciliation.js";
|
|
10
11
|
import { applyRemoteContainerTimestamps, remoteContainerHydrationSaveOptions, resolveRemoteContainerHydrationLocalUpdatedAt, } from "./remoteContainerTimestamps.js";
|
|
11
|
-
import { verifyRemoteContainerDestination } from "./verifiedDestination.js";
|
|
12
12
|
// Container ids (restricted to the inbound page) that carry an unsynced local
|
|
13
13
|
// create or move intent. Such a container's parent and local-edit timestamp are
|
|
14
14
|
// owned by its structural-intent lane until that lane reconciles, so inbound
|
package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteContainerState.js","sourceRoot":"","sources":["remoteContainerState.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,sCAAsC,EAAE,MAAM,qDAAqD,CAAC;AAE7G,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,8BAA8B,EAC9B,mCAAmC,EACnC,6CAA6C,GAC9C,MAAM,6BAA6B,CAAC;AAErC,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA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AC;AACH,CAAC;AAED,SAAS,8BAA8B,CACrC,KAGC;IAED,MAAM,EAAE,aAAa,EAAE,2BAA2B,EAAE,GAAG,KAAK,CAAC;IAC7D,OAAO,aAAa;QAClB,CAAC,CAAC,kCAAkC,CAAC;YACjC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,sCAAsC,EACpC,KAAK,CAAC,sCAAsC;YAC9C,wCAAwC,EACtC,KAAK,CAAC,wCAAwC;YAChD,aAAa;YACb,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACJ,CAAC,CAAC,0BAA0B,CAAC;YACzB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,IAAI,IAAI;YACpE,2BAA2B;YAC3B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;AACT,CAAC","sourcesContent":["import type { AccessManifestCheckpoint } from \"@tearleads/crypto\";\nimport {\n heldContainerBinding,\n listingRepeatsHeldOrdinaryBinding,\n} from \"../../../../data/containers/containerBinding\";\nimport {\n isKeyingVerificationError,\n runWithSecurityIncidentReporting,\n} from \"../../../../data/keyingProjectionVerification/error\";\nimport { isProjectionVerificationCancelledError } from \"../../../../data/keyingProjectionVerification/types\";\nimport type { ContainerHydrationTombstone } from \"../../containerPersistence\";\nimport { installContainerMetadataRecord } from \"../../metadata/metadataPersistence\";\nimport { projectionGeneration } from \"../../projectionGeneration\";\nimport type { PrefetchedDestinationProjection } from \"../destination/destinationPrefetch\";\nimport { verifyRemoteContainerDestination } from \"../destination/verifiedDestination\";\nimport { rebindReHomedContainer } from \"../heldContainerRebind\";\nimport {\n moveIndexedContainerChild,\n removeIndexedContainerChild,\n} from \"../lanes/childIndex\";\nimport {\n reconcileLocalOnlyRootContainers,\n reconcileLocalOnlySystemContainers,\n} from \"../reconciliation\";\nimport type {\n ContainerChildIndex,\n ContainerState,\n RemoteContainer,\n RemoteContainerHydrationHost,\n RemoteContainerHydrationState,\n} from \"../types\";\nimport { insertRemoteContainerState } from \"./insertRemoteContainer\";\nimport {\n applyRemoteContainerTimestamps,\n remoteContainerHydrationSaveOptions,\n resolveRemoteContainerHydrationLocalUpdatedAt,\n} from \"./remoteContainerTimestamps\";\n\n// Container ids (restricted to the inbound page) that carry an unsynced local\n// create or move intent. Such a container's parent and local-edit timestamp are\n// owned by its structural-intent lane until that lane reconciles, so inbound\n// hydration must not revert parentId to the server value nor collapse\n// localUpdatedAt — doing so silently undoes a queued move and falsely reads\n// \"synced\". Move intents are read via listUnsyncedMoveIntents so a blocked\n// move — one whose destination parent has not synced yet, the common boot-time\n// case — is protected too. Pending *metadata*\n// updates are handled separately (listRemoteContainerIdsWithPendingMetadataUpdates);\n// structural intents live in the local outbox's container lanes, which that\n// query does not cover.\nexport async function listRemoteContainerIdsWithPendingStructuralIntents(input: {\n remoteContainers: ReadonlyArray<RemoteContainer>;\n state: RemoteContainerHydrationState;\n}): Promise<Set<string>> {\n if (input.remoteContainers.length === 0) {\n return new Set();\n }\n const remoteContainerIds = new Set(\n input.remoteContainers.map((remoteContainer) => remoteContainer.id),\n );\n\n const execSql = input.state.runtime.infra.execSql;\n const [pendingCreateIntents, unsyncedMoveIntents] = await Promise.all([\n input.state.persistence.listPendingCreateIntents(execSql),\n input.state.persistence.listUnsyncedMoveIntents(execSql),\n ]);\n const containerIdsWithPendingStructuralIntents = new Set<string>();\n for (const intent of pendingCreateIntents) {\n if (remoteContainerIds.has(intent.containerId)) {\n containerIdsWithPendingStructuralIntents.add(intent.containerId);\n }\n }\n for (const intent of unsyncedMoveIntents) {\n if (remoteContainerIds.has(intent.containerId)) {\n containerIdsWithPendingStructuralIntents.add(intent.containerId);\n }\n }\n return containerIdsWithPendingStructuralIntents;\n}\n\nexport async function listRemoteContainerIdsWithPendingMetadataUpdates(input: {\n remoteContainers: ReadonlyArray<RemoteContainer>;\n state: RemoteContainerHydrationState;\n}): Promise<Set<string>> {\n const containerIds = input.remoteContainers.flatMap((remoteContainer) => {\n const previousLocalUpdatedAt = input.state.containersById.get(\n remoteContainer.id,\n )?.container.localUpdatedAt;\n\n return previousLocalUpdatedAt &&\n previousLocalUpdatedAt.localeCompare(remoteContainer.updatedAt) > 0\n ? [remoteContainer.id]\n : [];\n });\n if (containerIds.length === 0) {\n return new Set();\n }\n\n const execSql = input.state.runtime.infra.execSql;\n return new Set(\n await input.state.persistence.listContainerIdsWithPendingUpdates(\n execSql,\n containerIds,\n ),\n );\n}\n\nfunction removeMissingHydratedContainer(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n existingState: ContainerState;\n host: RemoteContainerHydrationHost;\n previousParentId: string | null;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}): void {\n const { existingState, remoteContainer, state } = input;\n if (state.containersById.get(remoteContainer.id) !== existingState) {\n return;\n }\n\n state.containersById.delete(remoteContainer.id);\n if (input.childIdsByParentId) {\n removeIndexedContainerChild(\n input.childIdsByParentId,\n remoteContainer.id,\n input.previousParentId,\n );\n input.childIdsByParentId.delete(remoteContainer.id);\n }\n input.host.updateSnapshot();\n}\n\nfunction createUpdatedRemoteContainerState(\n existingState: ContainerState,\n remoteContainer: RemoteContainer,\n): ContainerState {\n return {\n ...existingState,\n container: applyRemoteContainerTimestamps(\n existingState.container,\n remoteContainer,\n ),\n containerWriterProjection: null,\n metadataReferencedPrincipals: remoteContainer.metadataReferencedPrincipals,\n };\n}\n\nfunction installUpdatedRemoteContainerState(\n existingState: ContainerState,\n nextState: ContainerState,\n host: RemoteContainerHydrationHost,\n): void {\n const wasLocalOnly = existingState.container.serverCreatedAt == null;\n existingState.container = nextState.container;\n existingState.containerWriterProjection = nextState.containerWriterProjection;\n existingState.metadataReferencedPrincipals =\n nextState.metadataReferencedPrincipals;\n // The snapshot copied the live generation when it was taken; a hint that\n // landed during the persist leaves the live metadata projection dropped.\n if (projectionGeneration(existingState) === projectionGeneration(nextState))\n existingState.metadataWriterProjection = nextState.metadataWriterProjection;\n installContainerMetadataRecord(existingState, nextState.record);\n // A document pass may have deferred while this root was awaiting proof.\n // The first durable remote acknowledgement makes its pending creates runnable.\n if (wasLocalOnly && existingState.container.serverCreatedAt != null)\n host.requestDocumentPriming?.();\n}\n\nasync function updateExistingRemoteContainerState(input: {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n containerIdsWithPendingStructuralIntents: ReadonlySet<string>;\n host: RemoteContainerHydrationHost;\n isCurrent?: (() => boolean) | undefined;\n existingState: ContainerState;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}): Promise<ContainerState | null> {\n const { childIdsByParentId, existingState, host, remoteContainer, state } =\n input;\n const previousParentId = existingState.container.parentId;\n const previousLocalUpdatedAt = existingState.container.localUpdatedAt;\n // A queued, not-yet-synced local move/create owns this container's parent\n // until its intent lane reconciles. Omit the remote parent when the page scan\n // saw one; persistence also rechecks the intent transactionally so a move\n // created after that scan wins. Both paths preserve the durable local clock.\n const hasPendingStructuralIntent =\n input.containerIdsWithPendingStructuralIntents.has(remoteContainer.id);\n const nextParentId = hasPendingStructuralIntent\n ? undefined\n : remoteContainer.parentId;\n const localUpdatedAt = resolveRemoteContainerHydrationLocalUpdatedAt({\n containerIdsWithPendingMetadataUpdates:\n input.containerIdsWithPendingMetadataUpdates,\n hasPendingStructuralIntent,\n previousLocalUpdatedAt,\n remoteContainer,\n });\n const nextState = createUpdatedRemoteContainerState(\n existingState,\n remoteContainer,\n );\n const persistenceResult = await host.persistContainerState(\n nextState,\n {\n accessEpoch: remoteContainer.metadataAccessEpoch,\n accessStateHash: remoteContainer.metadataAccessStateHash,\n documentId: remoteContainer.metadataDocumentId,\n effectiveAccessLevel: remoteContainer.effectiveAccessLevel,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n systemSlot: remoteContainer.systemSlot ?? null,\n organizationId: remoteContainer.organizationId,\n ...(nextParentId !== undefined ? { parentId: nextParentId } : {}),\n },\n false,\n remoteContainerHydrationSaveOptions({\n localUpdatedAt,\n remoteContainer,\n }),\n {\n preserveDurableStructureWhenPending: true,\n },\n );\n if (persistenceResult.status === \"missing\") {\n // Hydration persists a detached candidate so an in-flight response cannot\n // mutate mapped state before its guards settle. Retire the exact state this\n // hydration read because store-level reference cleanup cannot see the clone.\n removeMissingHydratedContainer({\n childIdsByParentId,\n existingState,\n host,\n previousParentId,\n remoteContainer,\n state,\n });\n return null;\n }\n if (persistenceResult.status !== \"persisted\") return null;\n const { record: nextRecord } = persistenceResult;\n installContainerMetadataRecord(nextState, nextRecord);\n if (input.isCurrent?.() === false) {\n return existingState;\n }\n nextState.container = {\n ...nextState.container,\n metadataDocumentId: remoteContainer.metadataDocumentId,\n organizationId: remoteContainer.organizationId,\n parentId: nextState.container.parentId,\n };\n\n installUpdatedRemoteContainerState(existingState, nextState, host);\n moveIndexedContainerChild(\n childIdsByParentId,\n remoteContainer.id,\n previousParentId,\n existingState.container.parentId,\n );\n await reconcileLocalOnlyRootContainers({\n childIdsByParentId,\n isCurrent: input.isCurrent,\n remoteRootState: existingState,\n requestDocumentPriming: host.requestDocumentPriming,\n state,\n });\n return existingState;\n}\n\ninterface UpsertRemoteContainerStateInput {\n childIdsByParentId?: ContainerChildIndex | undefined;\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n containerIdsWithPendingStructuralIntents: ReadonlySet<string>;\n host: RemoteContainerHydrationHost;\n expectedHydrationTombstone?: ContainerHydrationTombstone | null | undefined;\n isCurrent?: (() => boolean) | undefined;\n prefetchedProjection?: PrefetchedDestinationProjection | undefined;\n remoteContainer: RemoteContainer;\n state: RemoteContainerHydrationState;\n}\n\nexport async function upsertRemoteContainerState(\n input: UpsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n let expectedPlacementCheckpoint: AccessManifestCheckpoint | undefined;\n const heldState = input.state.containersById.get(input.remoteContainer.id);\n const heldBinding = heldState\n ? heldContainerBinding(heldState)\n : await input.state.persistence.loadHeldContainerBinding(\n input.state.runtime.infra.execSql,\n input.remoteContainer.id,\n );\n const listed = input.remoteContainer;\n // A folder re-homed away from the listed organization never returns there,\n // whatever binding (possibly none, after a reset) the device holds now.\n const supersededListing =\n !listingRepeatsHeldOrdinaryBinding(heldBinding, listed) &&\n (await input.state.persistence.isSupersededContainerBinding(\n input.state.runtime.infra.execSql,\n { containerId: listed.id, organizationId: listed.organizationId },\n ));\n if (input.isCurrent?.() === false) return null;\n const verified = await verifyRemoteContainerDestination({\n ...input,\n heldBinding,\n supersededListing,\n refresh: !!input.expectedHydrationTombstone,\n onVerifiedCheckpoint: (checkpoint) => {\n expectedPlacementCheckpoint = checkpoint;\n },\n });\n if (!verified || input.isCurrent?.() === false) return null;\n input = { ...input, remoteContainer: verified };\n const existingState = input.state.containersById.get(\n input.remoteContainer.id,\n );\n const remoteState = await runWithSecurityIncidentReporting(\n input.state.runtime.util.reportSecurityIncident,\n {\n objectId: verified.id,\n objectKind: \"container\",\n operation: \"container.binding.persist\",\n organizationId: verified.organizationId,\n },\n async () =>\n (await rebindReHomedContainer({\n existingState,\n heldBinding,\n isCurrent: input.isCurrent,\n state: input.state,\n verified,\n }))\n ? persistVerifiedRemoteContainer({\n ...input,\n existingState,\n expectedPlacementCheckpoint,\n })\n : null,\n );\n if (!remoteState) {\n return null;\n }\n await reconcileLocalOnlySystemContainers({\n childIdsByParentId: input.childIdsByParentId,\n isCurrent: input.isCurrent,\n requestDocumentPriming: input.host.requestDocumentPriming,\n remoteSystemState: remoteState,\n state: input.state,\n });\n return remoteState;\n}\n\n/**\n * Upsert one listed folder, isolating a rejected proof or binding. The refusal\n * was already reported; returning no state leaves the item unapplied without\n * blocking independent folders.\n */\nexport async function upsertIsolatedRemoteContainerState(\n input: UpsertRemoteContainerStateInput,\n): Promise<ContainerState | null> {\n try {\n return await upsertRemoteContainerState(input);\n } catch (error) {\n if (\n !isKeyingVerificationError(error) &&\n !isProjectionVerificationCancelledError(error)\n )\n throw error;\n return null;\n }\n}\n\nfunction persistVerifiedRemoteContainer(\n input: UpsertRemoteContainerStateInput & {\n existingState: ContainerState | undefined;\n expectedPlacementCheckpoint: AccessManifestCheckpoint | undefined;\n },\n): Promise<ContainerState | null> {\n const { existingState, expectedPlacementCheckpoint } = input;\n return existingState\n ? updateExistingRemoteContainerState({\n childIdsByParentId: input.childIdsByParentId,\n containerIdsWithPendingMetadataUpdates:\n input.containerIdsWithPendingMetadataUpdates,\n containerIdsWithPendingStructuralIntents:\n input.containerIdsWithPendingStructuralIntents,\n existingState,\n host: input.host,\n isCurrent: input.isCurrent,\n remoteContainer: input.remoteContainer,\n state: input.state,\n })\n : insertRemoteContainerState({\n childIdsByParentId: input.childIdsByParentId,\n host: input.host,\n expectedHydrationTombstone: input.expectedHydrationTombstone ?? null,\n expectedPlacementCheckpoint,\n isCurrent: input.isCurrent,\n remoteContainer: input.remoteContainer,\n state: input.state,\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteContainerTimestamps.js","sourceRoot":"","sources":["remoteContainerTimestamps.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,8BAA8B,CAC5C,SAA0B,EAC1B,eAAgC;IAEhC,OAAO;QACL,GAAG,SAAS;QACZ,SAAS,EAAE,eAAe,CAAC,SAAS;QACpC,oBAAoB,EAAE,eAAe,CAAC,oBAAoB;QAC1D,eAAe,EAAE,eAAe,CAAC,SAAS;QAC1C,eAAe,EAAE,eAAe,CAAC,SAAS;QAC1C,SAAS,EAAE,eAAe,CAAC,SAAS;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,KAGnD;IACC,OAAO;QACL,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,eAAe,CAAC,SAAS;QACvE,gBAAgB,EAAE;YAChB,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,SAAS;YAC1C,SAAS,EAAE,KAAK,CAAC,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6CAA6C,CAAC,KAK7D;IACC,MAAM,EACJ,sCAAsC,EACtC,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,GAChB,GAAG,KAAK,CAAC;IACV,IACE,CAAC,sBAAsB;QACvB,sBAAsB,CAAC,aAAa,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,EACpE,CAAC;QACD,OAAO,eAAe,CAAC,SAAS,CAAC;IACnC,CAAC;IAED,OAAO,sCAAsC,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;QACnE,0BAA0B;QAC1B,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC;AAChC,CAAC","sourcesContent":["import type { ContainerRecord } from \"../../containerPersistence\";\nimport type { RemoteContainer, SaveContainerOptions } from \"../types\";\n\nexport function applyRemoteContainerTimestamps(\n container: ContainerRecord,\n remoteContainer: RemoteContainer,\n): ContainerRecord {\n return {\n ...container,\n createdAt: remoteContainer.createdAt,\n effectiveAccessLevel: remoteContainer.effectiveAccessLevel,\n serverCreatedAt: remoteContainer.createdAt,\n serverUpdatedAt: remoteContainer.updatedAt,\n updatedAt: remoteContainer.updatedAt,\n };\n}\n\nexport function remoteContainerHydrationSaveOptions(input: {\n localUpdatedAt?: string | null | undefined;\n remoteContainer: RemoteContainer;\n}): NonNullable<SaveContainerOptions> {\n return {\n localUpdatedAt: input.localUpdatedAt ?? input.remoteContainer.updatedAt,\n serverTimestamps: {\n createdAt: input.remoteContainer.createdAt,\n updatedAt: input.remoteContainer.updatedAt,\n },\n };\n}\n\nexport function resolveRemoteContainerHydrationLocalUpdatedAt(input: {\n containerIdsWithPendingMetadataUpdates: ReadonlySet<string>;\n hasPendingStructuralIntent: boolean;\n previousLocalUpdatedAt: string | null | undefined;\n remoteContainer: RemoteContainer;\n}): string {\n const {\n containerIdsWithPendingMetadataUpdates,\n hasPendingStructuralIntent,\n previousLocalUpdatedAt,\n remoteContainer,\n } = input;\n if (\n !previousLocalUpdatedAt ||\n previousLocalUpdatedAt.localeCompare(remoteContainer.updatedAt) <= 0\n ) {\n return remoteContainer.updatedAt;\n }\n\n return containerIdsWithPendingMetadataUpdates.has(remoteContainer.id) ||\n hasPendingStructuralIntent\n ? previousLocalUpdatedAt\n : remoteContainer.updatedAt;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isCanonicalSignedAt } from "../../../internal/validators/util/index.js";
|
|
2
|
-
import { removeIndexedContainerChild } from "./childIndex.js";
|
|
3
|
-
import { containerStateMatchesFingerprint } from "./containerStateFingerprint.js";
|
|
2
|
+
import { removeIndexedContainerChild } from "./lanes/childIndex.js";
|
|
3
|
+
import { containerStateMatchesFingerprint } from "./remoteContainers/containerStateFingerprint.js";
|
|
4
4
|
import { collectRemovedContainers } from "./tombstoneReasons.js";
|
|
5
5
|
function latestContainerItemsById(items) {
|
|
6
6
|
const latestItems = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tombstoneApplication.js","sourceRoot":"","sources":["tombstoneApplication.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAQ9D,SAAS,wBAAwB,CAC/B,KAAmD;IAEnD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyC,CAAC;IACrE,KAAK,MAAM,IAAI,IAA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K,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;SACV,CAAC,CAAC;QACH,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC;QACpC,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import type {\n ContainerSyncTombstone,\n ListContainersResponse,\n} from \"@tearleads/validators/response\";\nimport { isCanonicalSignedAt } from \"@tearleads/validators/util\";\nimport { removeIndexedContainerChild } from \"./childIndex\";\nimport { containerStateMatchesFingerprint } from \"./containerStateFingerprint\";\nimport { collectRemovedContainers } from \"./tombstoneReasons\";\nimport type {\n ContainerChildIndex,\n ExpectedContainerState,\n ListedRemoteContainerPageItem,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nfunction latestContainerItemsById(\n items: ReadonlyArray<ListedRemoteContainerPageItem>,\n): Map<string, ListedRemoteContainerPageItem> {\n const latestItems = new Map<string, ListedRemoteContainerPageItem>();\n for (const item of items) {\n const current = latestItems.get(item.id);\n if (!current || current.updatedAt < item.updatedAt) {\n latestItems.set(item.id, item);\n }\n }\n\n return latestItems;\n}\n\nfunction latestContainerTombstonesById(\n tombstones: ReadonlyArray<ContainerSyncTombstone>,\n): Map<string, ContainerSyncTombstone> {\n const latestTombstones = new Map<string, ContainerSyncTombstone>();\n for (const tombstone of tombstones) {\n if (!isCanonicalSignedAt(tombstone.updatedAt))\n throw new Error(\"Container tombstone timestamp is not canonical\");\n const current = latestTombstones.get(tombstone.containerId);\n if (\n !current ||\n current.updatedAt < tombstone.updatedAt ||\n (current.updatedAt === tombstone.updatedAt &&\n current.reason === \"access_revoked\" &&\n tombstone.reason === \"deleted\")\n ) {\n latestTombstones.set(tombstone.containerId, tombstone);\n }\n }\n\n return latestTombstones;\n}\n\nfunction getApplicableContainerTombstones(\n response: ListContainersResponse,\n): ContainerSyncTombstone[] {\n const latestItems = latestContainerItemsById(response.items);\n return Array.from(\n latestContainerTombstonesById(response.tombstones).values(),\n ).filter((tombstone) => {\n const item = latestItems.get(tombstone.containerId);\n return (\n !item ||\n item.updatedAt < tombstone.updatedAt ||\n (item.updatedAt === tombstone.updatedAt && tombstone.reason === \"deleted\")\n );\n });\n}\n\nexport function getApplicableRemoteContainerItems(\n response: ListContainersResponse,\n): ListedRemoteContainerPageItem[] {\n const latestTombstones = latestContainerTombstonesById(response.tombstones);\n return response.items.filter((item) => {\n const tombstone = latestTombstones.get(item.id);\n return (\n !tombstone ||\n tombstone.updatedAt < item.updatedAt ||\n (tombstone.updatedAt === item.updatedAt &&\n tombstone.reason === \"access_revoked\")\n );\n });\n}\n\nasync function applyContainerTombstoneCascade(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n isCurrent?: (() => boolean) | undefined;\n preservedContainerIds: ReadonlySet<string>;\n state: RemoteContainerHydrationState;\n tombstone: ContainerSyncTombstone;\n}): Promise<{ current: boolean; removedCount: number; settled: boolean }> {\n const {\n childIdsByParentId,\n expectedContainerStates,\n preservedContainerIds,\n state,\n tombstone,\n } = input;\n const {\n fenceOnlyContainerIds,\n absentDeletedContainerIds,\n removalByContainerId,\n removedContainerIds,\n } = collectRemovedContainers({\n childIdsByParentId,\n containersById: state.containersById,\n preservedContainerIds,\n tombstones: [tombstone],\n });\n const affectedContainerIds = new Set([\n ...removedContainerIds,\n ...absentDeletedContainerIds,\n ...fenceOnlyContainerIds,\n ]);\n for (const containerId of affectedContainerIds) {\n if (\n !containerStateMatchesFingerprint({\n currentState: state.containersById.get(containerId),\n expectedFingerprint:\n expectedContainerStates.get(containerId)?.fingerprint,\n })\n ) {\n return { current: true, removedCount: 0, settled: false };\n }\n }\n\n const deletedContainerIds = await state.persistence.deleteContainers(\n state.runtime.infra.execSql,\n [\n ...removedContainerIds,\n ...absentDeletedContainerIds,\n ...fenceOnlyContainerIds,\n ].flatMap((containerId) => {\n const removal = removalByContainerId.get(containerId);\n return removal ? [{ containerId, ...removal }] : [];\n }),\n {\n discoveryOnly: true,\n expectedContainers: Array.from(affectedContainerIds, (containerId) => ({\n containerId,\n expectedContainer:\n expectedContainerStates.get(containerId)?.container ?? null,\n })),\n stillCurrent: input.isCurrent,\n },\n );\n if (deletedContainerIds.length !== affectedContainerIds.size) {\n return { current: true, removedCount: 0, settled: false };\n }\n if (input.isCurrent?.() === false) {\n return { current: false, removedCount: 0, settled: false };\n }\n for (const containerId of removedContainerIds) {\n const parentId =\n state.containersById.get(containerId)?.container.parentId ?? null;\n removeIndexedContainerChild(childIdsByParentId, containerId, parentId);\n childIdsByParentId.delete(containerId);\n state.containersById.delete(containerId);\n }\n\n return {\n current: true,\n removedCount: removedContainerIds.length,\n settled: true,\n };\n}\n\nexport async function applyContainerTombstones(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n isCurrent?: (() => boolean) | undefined;\n remoteContainerItems: ReadonlyArray<ListedRemoteContainerPageItem>;\n response: ListContainersResponse;\n state: RemoteContainerHydrationState;\n}): Promise<{ changedCount: number; completed: boolean; current: boolean }> {\n const tombstones = getApplicableContainerTombstones(input.response);\n if (tombstones.length === 0 || input.isCurrent?.() === false) {\n return {\n changedCount: 0,\n completed: true,\n current: input.isCurrent?.() !== false,\n };\n }\n\n const tombstoneRootIds = new Set(\n tombstones.map((tombstone) => tombstone.containerId),\n );\n const liveContainerIds = input.remoteContainerItems.map((item) => item.id);\n let changedCount = 0;\n let completed = true;\n for (const tombstone of tombstones) {\n if (input.isCurrent?.() === false) {\n return { changedCount, completed: false, current: false };\n }\n // Apply each root as its own CAS-protected cascade. Other explicit roots\n // stay out of this cascade so their own reason wins and one stale root\n // cannot block independent tombstones or live items on the page.\n const preservedContainerIds = new Set([\n ...liveContainerIds,\n ...tombstoneRootIds,\n ...Array.from(input.state.containersById, ([id, state]) =>\n state.container.metadataDocumentId === null ? id : null,\n ).filter((id): id is string => id !== null),\n ]);\n if (\n input.state.containersById.get(tombstone.containerId)?.container\n .metadataDocumentId !== null\n ) {\n preservedContainerIds.delete(tombstone.containerId);\n }\n const result = await applyContainerTombstoneCascade({\n childIdsByParentId: input.childIdsByParentId,\n expectedContainerStates: input.expectedContainerStates,\n isCurrent: input.isCurrent,\n preservedContainerIds,\n state: input.state,\n tombstone,\n });\n changedCount += result.removedCount;\n completed = completed && result.settled;\n if (!result.current) {\n return { changedCount, completed: false, current: false };\n }\n }\n\n return { changedCount, completed, current: true };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tombstoneApplication.js","sourceRoot":"","sources":["tombstoneApplication.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAQ9D,SAAS,wBAAwB,CAC/B,KAAmD;IAEnD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyC,CAAC;IACrE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YACnD,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,6BA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Y,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import type {\n ContainerSyncTombstone,\n ListContainersResponse,\n} from \"@tearleads/validators/response\";\nimport { isCanonicalSignedAt } from \"@tearleads/validators/util\";\nimport { removeIndexedContainerChild } from \"./lanes/childIndex\";\nimport { containerStateMatchesFingerprint } from \"./remoteContainers/containerStateFingerprint\";\nimport { collectRemovedContainers } from \"./tombstoneReasons\";\nimport type {\n ContainerChildIndex,\n ExpectedContainerState,\n ListedRemoteContainerPageItem,\n RemoteContainerHydrationState,\n} from \"./types\";\n\nfunction latestContainerItemsById(\n items: ReadonlyArray<ListedRemoteContainerPageItem>,\n): Map<string, ListedRemoteContainerPageItem> {\n const latestItems = new Map<string, ListedRemoteContainerPageItem>();\n for (const item of items) {\n const current = latestItems.get(item.id);\n if (!current || current.updatedAt < item.updatedAt) {\n latestItems.set(item.id, item);\n }\n }\n\n return latestItems;\n}\n\nfunction latestContainerTombstonesById(\n tombstones: ReadonlyArray<ContainerSyncTombstone>,\n): Map<string, ContainerSyncTombstone> {\n const latestTombstones = new Map<string, ContainerSyncTombstone>();\n for (const tombstone of tombstones) {\n if (!isCanonicalSignedAt(tombstone.updatedAt))\n throw new Error(\"Container tombstone timestamp is not canonical\");\n const current = latestTombstones.get(tombstone.containerId);\n if (\n !current ||\n current.updatedAt < tombstone.updatedAt ||\n (current.updatedAt === tombstone.updatedAt &&\n current.reason === \"access_revoked\" &&\n tombstone.reason === \"deleted\")\n ) {\n latestTombstones.set(tombstone.containerId, tombstone);\n }\n }\n\n return latestTombstones;\n}\n\nfunction getApplicableContainerTombstones(\n response: ListContainersResponse,\n): ContainerSyncTombstone[] {\n const latestItems = latestContainerItemsById(response.items);\n return Array.from(\n latestContainerTombstonesById(response.tombstones).values(),\n ).filter((tombstone) => {\n const item = latestItems.get(tombstone.containerId);\n return (\n !item ||\n item.updatedAt < tombstone.updatedAt ||\n (item.updatedAt === tombstone.updatedAt && tombstone.reason === \"deleted\")\n );\n });\n}\n\nexport function getApplicableRemoteContainerItems(\n response: ListContainersResponse,\n): ListedRemoteContainerPageItem[] {\n const latestTombstones = latestContainerTombstonesById(response.tombstones);\n return response.items.filter((item) => {\n const tombstone = latestTombstones.get(item.id);\n return (\n !tombstone ||\n tombstone.updatedAt < item.updatedAt ||\n (tombstone.updatedAt === item.updatedAt &&\n tombstone.reason === \"access_revoked\")\n );\n });\n}\n\nasync function applyContainerTombstoneCascade(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n isCurrent?: (() => boolean) | undefined;\n preservedContainerIds: ReadonlySet<string>;\n state: RemoteContainerHydrationState;\n tombstone: ContainerSyncTombstone;\n}): Promise<{ current: boolean; removedCount: number; settled: boolean }> {\n const {\n childIdsByParentId,\n expectedContainerStates,\n preservedContainerIds,\n state,\n tombstone,\n } = input;\n const {\n fenceOnlyContainerIds,\n absentDeletedContainerIds,\n removalByContainerId,\n removedContainerIds,\n } = collectRemovedContainers({\n childIdsByParentId,\n containersById: state.containersById,\n preservedContainerIds,\n tombstones: [tombstone],\n });\n const affectedContainerIds = new Set([\n ...removedContainerIds,\n ...absentDeletedContainerIds,\n ...fenceOnlyContainerIds,\n ]);\n for (const containerId of affectedContainerIds) {\n if (\n !containerStateMatchesFingerprint({\n currentState: state.containersById.get(containerId),\n expectedFingerprint:\n expectedContainerStates.get(containerId)?.fingerprint,\n })\n ) {\n return { current: true, removedCount: 0, settled: false };\n }\n }\n\n const deletedContainerIds = await state.persistence.deleteContainers(\n state.runtime.infra.execSql,\n [\n ...removedContainerIds,\n ...absentDeletedContainerIds,\n ...fenceOnlyContainerIds,\n ].flatMap((containerId) => {\n const removal = removalByContainerId.get(containerId);\n return removal ? [{ containerId, ...removal }] : [];\n }),\n {\n discoveryOnly: true,\n expectedContainers: Array.from(affectedContainerIds, (containerId) => ({\n containerId,\n expectedContainer:\n expectedContainerStates.get(containerId)?.container ?? null,\n })),\n stillCurrent: input.isCurrent,\n },\n );\n if (deletedContainerIds.length !== affectedContainerIds.size) {\n return { current: true, removedCount: 0, settled: false };\n }\n if (input.isCurrent?.() === false) {\n return { current: false, removedCount: 0, settled: false };\n }\n for (const containerId of removedContainerIds) {\n const parentId =\n state.containersById.get(containerId)?.container.parentId ?? null;\n removeIndexedContainerChild(childIdsByParentId, containerId, parentId);\n childIdsByParentId.delete(containerId);\n state.containersById.delete(containerId);\n }\n\n return {\n current: true,\n removedCount: removedContainerIds.length,\n settled: true,\n };\n}\n\nexport async function applyContainerTombstones(input: {\n childIdsByParentId: ContainerChildIndex;\n expectedContainerStates: ReadonlyMap<string, ExpectedContainerState>;\n isCurrent?: (() => boolean) | undefined;\n remoteContainerItems: ReadonlyArray<ListedRemoteContainerPageItem>;\n response: ListContainersResponse;\n state: RemoteContainerHydrationState;\n}): Promise<{ changedCount: number; completed: boolean; current: boolean }> {\n const tombstones = getApplicableContainerTombstones(input.response);\n if (tombstones.length === 0 || input.isCurrent?.() === false) {\n return {\n changedCount: 0,\n completed: true,\n current: input.isCurrent?.() !== false,\n };\n }\n\n const tombstoneRootIds = new Set(\n tombstones.map((tombstone) => tombstone.containerId),\n );\n const liveContainerIds = input.remoteContainerItems.map((item) => item.id);\n let changedCount = 0;\n let completed = true;\n for (const tombstone of tombstones) {\n if (input.isCurrent?.() === false) {\n return { changedCount, completed: false, current: false };\n }\n // Apply each root as its own CAS-protected cascade. Other explicit roots\n // stay out of this cascade so their own reason wins and one stale root\n // cannot block independent tombstones or live items on the page.\n const preservedContainerIds = new Set([\n ...liveContainerIds,\n ...tombstoneRootIds,\n ...Array.from(input.state.containersById, ([id, state]) =>\n state.container.metadataDocumentId === null ? id : null,\n ).filter((id): id is string => id !== null),\n ]);\n if (\n input.state.containersById.get(tombstone.containerId)?.container\n .metadataDocumentId !== null\n ) {\n preservedContainerIds.delete(tombstone.containerId);\n }\n const result = await applyContainerTombstoneCascade({\n childIdsByParentId: input.childIdsByParentId,\n expectedContainerStates: input.expectedContainerStates,\n isCurrent: input.isCurrent,\n preservedContainerIds,\n state: input.state,\n tombstone,\n });\n changedCount += result.removedCount;\n completed = completed && result.settled;\n if (!result.current) {\n return { changedCount, completed: false, current: false };\n }\n }\n\n return { changedCount, completed, current: true };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContainerWriterProjectionResponse } from "
|
|
2
|
-
import type { MaterializedContainerCreatePlan } from "
|
|
1
|
+
import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
|
|
2
|
+
import type { MaterializedContainerCreatePlan } from "../../../../data/containers/shared/types.js";
|
|
3
3
|
export declare function childContainerWriterProjectionFromCreatePlan(input: {
|
|
4
4
|
materializedPlan: MaterializedContainerCreatePlan;
|
|
5
5
|
parentProjection: ContainerWriterProjectionResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getParentCreateContext } from "
|
|
2
|
-
import { readCanonicalRecord, readCanonicalRecords, } from "
|
|
1
|
+
import { getParentCreateContext } from "../../../../data/containers/shared/projection.js";
|
|
2
|
+
import { readCanonicalRecord, readCanonicalRecords, } from "../../../../data/keying/canonicalJson.js";
|
|
3
3
|
export function childContainerWriterProjectionFromCreatePlan(input) {
|
|
4
4
|
const { materializedPlan, parentProjection } = input;
|
|
5
5
|
const { plan } = materializedPlan;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProjection.js","sourceRoot":"","sources":["createProjection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAE/C,MAAM,UAAU,4CAA4C,CAAC,KAG5D;IACC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC;IAClC,MAAM,SAAS,GAA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AAI,CAAC,KAAK,EAAE,uBAAuB,CAAC;aACjE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { ContainerWriterProjectionResponse } from \"@tearleads/validators/response\";\nimport { getParentCreateContext } from \"../../../../data/containers/shared/projection\";\nimport type { MaterializedContainerCreatePlan } from \"../../../../data/containers/shared/types\";\nimport {\n readCanonicalRecord,\n readCanonicalRecords,\n} from \"../../../../data/keying/canonicalJson\";\n\nexport function childContainerWriterProjectionFromCreatePlan(input: {\n materializedPlan: MaterializedContainerCreatePlan;\n parentProjection: ContainerWriterProjectionResponse;\n}): ContainerWriterProjectionResponse {\n const { materializedPlan, parentProjection } = input;\n const { plan } = materializedPlan;\n const parentKek = getParentCreateContext(parentProjection).kek;\n\n return {\n policyEvidence: parentProjection.policyEvidence,\n containerId: plan.containerId,\n organizationId: plan.state.organizationId,\n path: [\n ...parentProjection.path,\n {\n event: {\n event: readCanonicalRecord(plan.event, \"Container child event\"),\n body: readCanonicalRecord(plan.body, \"Container child body\"),\n eventHash: plan.eventHash,\n },\n manifest: readCanonicalRecord(\n plan.manifest,\n \"Container child manifest\",\n ),\n manifestHash: plan.manifestHash,\n state: readCanonicalRecord(plan.state, \"Container child state\"),\n },\n ],\n containerKeks: [\n ...parentProjection.containerKeks,\n {\n containerId: plan.containerId,\n accessManifestHash: plan.manifestHash,\n containerKeyEpochId: plan.containerKeyEpochId,\n containerKeyEpoch: plan.keyEpoch.keyEpoch,\n keyEpoch: readCanonicalRecord(\n plan.keyEpoch,\n \"Container child key epoch\",\n ),\n keyEpochHash: plan.keyEpochHash,\n keyTargetHash: plan.keyTargetHash,\n containerManifestHistory: [],\n parentContainerKeyEpochId: parentKek.containerKeyEpochId,\n keyring: null,\n recipientTargets: readCanonicalRecords(\n plan.recipientTargets,\n \"Container child recipient targets\",\n ),\n wraps: readCanonicalRecords(plan.wraps, \"Container child wraps\"),\n },\n ],\n };\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ContainerMutationResponse, ContainerWriterProjectionResponse } from "
|
|
2
|
-
import type { ContainerCreateApi, ContainerCreatePlan, ContainerMutationAuthor, ContainerMutationSubmitFailure } from "
|
|
3
|
-
import type { ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "
|
|
4
|
-
import type { SecurityIncidentReporter } from "
|
|
5
|
-
import type { ExecSql } from "
|
|
6
|
-
import type { TrustedUserIdentityResolver } from "
|
|
7
|
-
import type { PrincipalPolicyRepairBudget } from "
|
|
1
|
+
import type { ContainerMutationResponse, ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
|
|
2
|
+
import type { ContainerCreateApi, ContainerCreatePlan, ContainerMutationAuthor, ContainerMutationSubmitFailure } from "../../../../data/containers/shared/types.js";
|
|
3
|
+
import type { ProjectionUserKeyResolver, ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
|
|
4
|
+
import type { SecurityIncidentReporter } from "../../../../data/shared/securityIncidents.js";
|
|
5
|
+
import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
|
|
6
|
+
import type { TrustedUserIdentityResolver } from "../../../../data/trustedUserIdentity/index.js";
|
|
7
|
+
import type { PrincipalPolicyRepairBudget } from "../../../principals/policyRepairBudget.js";
|
|
8
8
|
export interface ContainerCreateRepairState {
|
|
9
9
|
didRepairStaleParent: boolean;
|
|
10
10
|
policyRepairs: PrincipalPolicyRepairBudget;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isStaleParentContainerPathFailure } from "
|
|
2
|
-
import { recoverPrincipalPolicyRepair } from "
|
|
1
|
+
import { isStaleParentContainerPathFailure } from "../../../../data/containers/shared/mutationFailures.js";
|
|
2
|
+
import { recoverPrincipalPolicyRepair } from "../../../principals/policyRepair.js";
|
|
3
3
|
export async function submitRemoteContainerCreate(input) {
|
|
4
4
|
if (input.stillCurrent?.() === false)
|
|
5
5
|
return null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create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AC;QACrC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IACE,KAAK,CAAC,KAAK,CAAC,oBAAoB;YAChC,CAAC,iCAAiC,CAAC,KAAK,CAAC,OAAO,CAAC;YAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,KAAK,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAC1C,CAAC;IACD,8EAA8E;IAC9E,yEAAyE;IACzE,KAAK,CAAC,SAAS,CAAC,8BAA8B,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,CACzE,KAAK,CAAC,iBAAiB,CACxB,CAAC;IACF,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QACrC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,gBAAgB;QACrB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE;QACrC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type {\n ContainerMutationResponse,\n ContainerWriterProjectionResponse,\n} from \"@tearleads/validators/response\";\nimport { isStaleParentContainerPathFailure } from \"../../../../data/containers/shared/mutationFailures\";\nimport type {\n ContainerCreateApi,\n ContainerCreatePlan,\n ContainerMutationAuthor,\n ContainerMutationSubmitFailure,\n} from \"../../../../data/containers/shared/types\";\nimport type {\n ProjectionUserKeyResolver,\n ReferencedPrincipalPolicyWarmer,\n} from \"../../../../data/keyingProjectionVerification\";\nimport type { SecurityIncidentReporter } from \"../../../../data/shared/securityIncidents\";\nimport type { ExecSql } from \"../../../../data/sqlite/sqlSchema\";\nimport type { TrustedUserIdentityResolver } from \"../../../../data/trustedUserIdentity\";\nimport { recoverPrincipalPolicyRepair } from \"../../../principals/policyRepair\";\nimport type { PrincipalPolicyRepairBudget } from \"../../../principals/policyRepairBudget\";\n\nexport interface ContainerCreateRepairState {\n didRepairStaleParent: boolean;\n policyRepairs: PrincipalPolicyRepairBudget;\n}\n\nexport interface RemoteContainerCreateInput {\n apiClient: ContainerCreateApi;\n author: ContainerMutationAuthor;\n containerId?: string | undefined;\n containerKey?: Uint8Array | undefined;\n containerKeyEpochId?: string | undefined;\n eventId?: string | undefined;\n execSql: ExecSql;\n metadataDocumentId?: string | undefined;\n parentContainerId: string;\n parentProjection?: ContainerWriterProjectionResponse | undefined;\n parentSecretKey: Uint8Array;\n reportSecurityIncident: SecurityIncidentReporter;\n resolveProjectionUserKey: ProjectionUserKeyResolver;\n resolveTrustedUserIdentity: TrustedUserIdentityResolver;\n signedAt?: string | undefined;\n stillCurrent?: (() => boolean) | undefined;\n warmReferencedPrincipalPolicies?: ReferencedPrincipalPolicyWarmer | undefined;\n}\n\ntype ContainerCreateFailureRepair =\n | { readonly kind: \"none\" }\n | { readonly kind: \"unavailable\" }\n | {\n readonly kind: \"retry\";\n readonly parentProjection: ContainerWriterProjectionResponse;\n };\n\nexport async function submitRemoteContainerCreate(input: {\n readonly apiClient: ContainerCreateApi;\n readonly plan: ContainerCreatePlan;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<\n | {\n readonly ok: true;\n readonly response: ContainerMutationResponse;\n }\n | ContainerMutationSubmitFailure\n | null\n> {\n if (input.stillCurrent?.() === false) return null;\n const result = await input.apiClient.createContainerResult(\n input.plan.request,\n {\n expectedPaymentRequiredOrganizationId: input.plan.state.organizationId,\n reportErrors: false,\n },\n );\n return result.ok ? { ok: true, response: result.data } : result;\n}\n\nexport async function repairContainerCreateFailure(input: {\n readonly apiClient: ContainerCreateApi;\n readonly failure: ContainerMutationSubmitFailure;\n readonly parentContainerId: string;\n readonly parentProjection: ContainerWriterProjectionResponse;\n readonly state: ContainerCreateRepairState;\n readonly warmReferencedPrincipalPolicies?:\n | ReferencedPrincipalPolicyWarmer\n | undefined;\n readonly stillCurrent?: (() => boolean) | undefined;\n}): Promise<ContainerCreateFailureRepair> {\n if (input.stillCurrent?.() === false) {\n return { kind: \"unavailable\" };\n }\n const repairedPolicy =\n input.state.policyRepairs.take(input.failure.stalePrincipalHeads) &&\n (await recoverPrincipalPolicyRepair({\n heads: input.failure.stalePrincipalHeads,\n organizationId: input.parentProjection.organizationId,\n warmReferencedPrincipalPolicies: input.warmReferencedPrincipalPolicies,\n stillCurrent: input.stillCurrent,\n }));\n if (input.stillCurrent?.() === false) {\n return { kind: \"unavailable\" };\n }\n if (!repairedPolicy) {\n if (\n input.state.didRepairStaleParent ||\n !isStaleParentContainerPathFailure(input.failure)\n )\n return { kind: \"none\" };\n input.state.didRepairStaleParent = true;\n }\n // Recovery may select newer policies. Rebuild against a fresh public evidence\n // source so the old projection cannot conflict with newly admitted pins.\n input.apiClient.evictContainerWriterProjection(input.parentContainerId);\n const parentProjection = await input.apiClient.getContainerWriterProjection(\n input.parentContainerId,\n );\n if (input.stillCurrent?.() === false) {\n return { kind: \"unavailable\" };\n }\n return parentProjection\n ? { kind: \"retry\", parentProjection }\n : { kind: \"unavailable\" };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ContainerWriterProjectionResponse } from "
|
|
2
|
-
import type { BuildContainerCreatePlanInput, ContainerCreatePlan, ContainerMutationAuthor, CreateRemoteContainerResult, MaterializedContainerCreatePlan } from "
|
|
3
|
-
import { type ProjectionVerificationOptions } from "
|
|
4
|
-
import type { ReferencedPrincipalPolicyWarmer } from "
|
|
5
|
-
import type { ExecSql } from "
|
|
1
|
+
import type { ContainerWriterProjectionResponse } from "../../../../internal/validators/response/index.js";
|
|
2
|
+
import type { BuildContainerCreatePlanInput, ContainerCreatePlan, ContainerMutationAuthor, CreateRemoteContainerResult, MaterializedContainerCreatePlan } from "../../../../data/containers/shared/types.js";
|
|
3
|
+
import { type ProjectionVerificationOptions } from "../../../../data/documents/shared/types.js";
|
|
4
|
+
import type { ReferencedPrincipalPolicyWarmer } from "../../../../data/keyingProjectionVerification/index.js";
|
|
5
|
+
import type { ExecSql } from "../../../../data/sqlite/sqlSchema.js";
|
|
6
6
|
import { type RemoteContainerCreateInput } from "./createSubmission.js";
|
|
7
7
|
export declare function buildContainerCreatePlan(input: BuildContainerCreatePlanInput): Promise<ContainerCreatePlan>;
|
|
8
8
|
export declare function buildMaterializedContainerCreatePlan(input: {
|