@tearleads/client-sdk 0.1.254 → 0.1.256
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/internal/validators/containerSystemSlot.d.ts +6 -0
- package/internal/validators/containerSystemSlot.js +14 -6
- package/internal/validators/containerSystemSlot.js.map +1 -1
- package/package.json +1 -1
- package/stores/container-contents/hydration/remoteHydrationRequest.js +6 -5
- package/stores/container-contents/hydration/remoteHydrationRequest.js.map +1 -1
- package/stores/container-contents/hydration/trackContainerHydration.js +35 -0
- package/stores/container-contents/hydration/trackContainerHydration.js.map +1 -0
- package/stores/container-contents/operations/index.js +4 -0
- package/stores/container-contents/operations/index.js.map +1 -1
- package/stores/container-contents/state.js +7 -2
- package/stores/container-contents/state.js.map +1 -1
- package/stores/container-contents/syncAgent/syncAgentTypes.d.ts +1 -0
- package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -1
- package/stores/container-contents/types.d.ts +2 -0
- package/stores/container-contents/types.js.map +1 -1
- package/workflows/container-contents/container-state/create/createChild.d.ts +30 -0
- package/workflows/container-contents/container-state/move/moveIntentSync.js +1 -0
- package/workflows/container-contents/container-state/move/moveIntentSync.js.map +1 -1
- package/workflows/container-contents/container-state/remote.js +1 -1
- package/workflows/container-contents/container-state/remote.js.map +1 -1
- package/workflows/container-contents/container-state/types.d.ts +141 -0
- package/workflows/container-contents/index.d.ts +1 -0
- package/workflows/container-contents/index.js +1 -0
- package/workflows/container-contents/index.js.map +1 -1
- package/workflows/container-contents/remoteHydration/destination/destinationSystemTopology.js +16 -0
- package/workflows/container-contents/remoteHydration/destination/destinationSystemTopology.js.map +1 -0
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js +8 -9
- package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -1
- package/workflows/registration/bootstrapRootContainer.d.ts +1 -0
- package/workflows/registration/bootstrapRootContainer.js +9 -0
- package/workflows/registration/bootstrapRootContainer.js.map +1 -1
- package/workflows/registration/index.d.ts +1 -1
- package/workflows/registration/index.js +1 -1
- package/workflows/registration/index.js.map +1 -1
- package/workflows/registration/organizationProvisioning.d.ts +3 -2
- package/workflows/registration/organizationProvisioning.js +1 -2
- package/workflows/registration/organizationProvisioning.js.map +1 -1
- package/workflows/registration/provisioningBootstrapBuilders.d.ts +3 -5
- package/workflows/registration/provisioningBootstrapBuilders.js +11 -5
- package/workflows/registration/provisioningBootstrapBuilders.js.map +1 -1
- package/workflows/registration/registerIdentity.js +2 -0
- package/workflows/registration/registerIdentity.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { abandonJournaledPrincipalMutation, addOrganizationGroupUser, buildIniti
|
|
|
24
24
|
export type { AcknowledgedPrincipalPredecessor, CacheReferencedPrincipalPoliciesOptions, PrincipalHistoryProtectionLease, PrincipalPolicyService, ProjectionPolicyHistoryRecoveryOptions, RecoveredPrincipalPolicyHistory, RecoveredScopedPrincipalPolicyHistory, RecoverPrincipalPolicyHistoryOptions, RecoverScopedPrincipalPolicyHistoryOptions, } from "./workflows/principals/index.js";
|
|
25
25
|
export { cacheReferencedPrincipalPolicies, captureAcknowledgedPrincipalPredecessor, PrincipalPolicyHistoryReadError, recoverPrincipalPolicyHistory, recoverProjectionPolicyHistory, recoverScopedPrincipalPolicyHistory, } from "./workflows/principals/index.js";
|
|
26
26
|
export type { InitialRootMetadataBootstrap, ProvisionedSystemContainerSpec, RegisterIdentityInput, RegistrationApi, } from "./workflows/registration/index.js";
|
|
27
|
-
export { bootstrapRootContainer, buildInitialOrganizationPolicyRequest, createInitialRootMetadataBootstrap, persistRegistrationBootstrap, registerIdentity, } from "./workflows/registration/index.js";
|
|
27
|
+
export { bootstrapRootContainer, buildInitialOrganizationPolicyRequest, createInitialRootMetadataBootstrap, deriveRegistrationOrganizationId, persistRegistrationBootstrap, registerIdentity, } from "./workflows/registration/index.js";
|
|
28
28
|
export type { PendingBlobDeletion, PendingBlobDeletionsPage, PendingBlobDeletionsQueryInput, RootIdentitiesApi, RootIdentitiesPage, RootIdentitiesQueryInput, RootIdentity, RootIdentityDetail, RootIdentityOrganization, RootIdentitySession, RootPendingBlobDeletionsQueryInput, RootRequestOutcome, } from "./workflows/root/index.js";
|
|
29
29
|
export { liftRootIdentitySuspension, listRootAuditEvents, listRootDataUsageReport, listRootIdentities, listRootIdentityOrganizations, listRootOrganizationIdentities, listRootOrganizationRevenuecatEvents, listRootOrganizations, listRootRevenuecatEventsReport, loadRootIdentity, loadRootOpsHealthReport, loadRootOrganization, loadRootOrganizationDataUsage, type RootAuditApi, type RootAuditEvent, type RootAuditEventsPage, type RootAuditEventsQueryInput, type RootDataUsageApi, type RootDataUsageReportPage, type RootOpsHealthApi, type RootOpsHealthReport, type RootOrganization, type RootOrganizationDetail, type RootOrganizationIdentitiesPage, type RootOrganizationIdentity, type RootOrganizationPageQueryInput, type RootOrganizationRevenuecatEvent, type RootOrganizationRevenuecatEventsPage, type RootOrganizationsApi, type RootOrganizationsPage, type RootOrganizationsQueryInput, type RootRevenuecatApi, type RootRevenuecatEvent, type RootRevenuecatEventsQueryInput, type RootRevenuecatEventsReportPage, type RootRevenuecatEventsReportQueryInput, type RootSuspensionApi, suspendRootIdentity, } from "./workflows/root/index.js";
|
|
30
30
|
export type { ClearRemoteSyncStateResult, DomainSyncCoordinator, DomainSyncSnapshot, RemoteResetInput, RemoteResetReplacement, SyncIdleOptions, SyncLane, SyncLaneConfig, SyncLaneLastAction, SyncLanePhase, SyncLaneSnapshot, SyncLaneStatus, } from "./workflows/sync/index.js";
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { buildMaterializedContainerRekeyPlan, buildRootContainerCreatePlan, Cont
|
|
|
13
13
|
export { buildMaterializedDocumentCreatePlan, createDocumentProjectionUserKeyResolver, DOCUMENT_SYNC_TRACE_FRAGMENT, DOCUMENT_SYNC_TRACE_PATTERN, DOCUMENTS_APP_KIND, DocumentRawHistoryUnavailableError, defaultDocumentsPersistence, deletePersistedDocument, deriveStableDocumentId, isDatabaseUnavailableError, isDocumentSyncUpdateIsolationError, isEmptyDocumentHistoryChange, persistedDocumentCreateStateFromResponse, RemoteDocumentService, readPullContinuation, unwrapContainerKekPath, unwrapDocumentContentKeyTarget, validateDocumentSyncUpdateImports, } from "./workflows/documents/index.js";
|
|
14
14
|
export { abandonJournaledPrincipalMutation, addOrganizationGroupUser, buildInitialGroupPolicyRequest, buildInitialMemberGroupPolicyRequest, buildOrganizationGroupPolicyHistory, buildOrganizationProfileDocumentPatch, buildRosterProfileDocumentPatch, checkNativePurchaseEligibility, createInitializedRosterProfileDocument, createOrganizationGroup, DEFAULT_PERSONAL_ORGANIZATION_PROFILE_NAME, deriveOrganizationMetadataContainerSystemSlot, deriveOrganizationRosterProfileContainerSystemSlot, discardUnreadableJournaledPrincipalMutation, GroupMembershipNameMismatchError, GroupShareNameMismatchError, getOrganizationProfileDocumentLocalId, getRosterProfileDocumentLocalId, loadLocalOrganizationDataUsage, loadLocalOrganizationDirectoryAndGroups, loadOrganizationBilling, loadOrganizationBillingHistory, loadOrganizationBillingManagementUrl, ORGANIZATION_DOCUMENT_USAGE_CATEGORIES, ORGANIZATION_METADATA_CONTAINER_NAME, ORGANIZATION_PROFILE_DOCUMENT_KIND, ORGANIZATION_ROSTER_PROFILE_CONTAINER_NAME, PendingPrincipalMutationError, PrincipalMutationOutcomeUnknownError, ROSTER_PROFILE_DOCUMENT_KIND, readJournaledPrincipalMutation, readOrganizationProfileName, reconcileOrganizationDataUsage, reconcileOrganizationDirectoryAndGroups, recoverJournaledPrincipalMutation, removeOrganizationGroupUser, resolveOrganizationBillingView, retainAcknowledgedPrincipalCurrents, revokeOrganizationContainerGrant, shareRemoteContainerWithGroup, startOrganizationTrial, submitJournaledPrincipalMutation, subscribeOrganizationReadModelInvalidation, UnreadablePrincipalMutationError, updateOrganizationProfile, updateOrganizationRosterEntry, } from "./workflows/organizations/index.js";
|
|
15
15
|
export { cacheReferencedPrincipalPolicies, captureAcknowledgedPrincipalPredecessor, PrincipalPolicyHistoryReadError, recoverPrincipalPolicyHistory, recoverProjectionPolicyHistory, recoverScopedPrincipalPolicyHistory, } from "./workflows/principals/index.js";
|
|
16
|
-
export { bootstrapRootContainer, buildInitialOrganizationPolicyRequest, createInitialRootMetadataBootstrap, persistRegistrationBootstrap, registerIdentity, } from "./workflows/registration/index.js";
|
|
16
|
+
export { bootstrapRootContainer, buildInitialOrganizationPolicyRequest, createInitialRootMetadataBootstrap, deriveRegistrationOrganizationId, persistRegistrationBootstrap, registerIdentity, } from "./workflows/registration/index.js";
|
|
17
17
|
export { liftRootIdentitySuspension, listRootAuditEvents, listRootDataUsageReport, listRootIdentities, listRootIdentityOrganizations, listRootOrganizationIdentities, listRootOrganizationRevenuecatEvents, listRootOrganizations, listRootRevenuecatEventsReport, loadRootIdentity, loadRootOpsHealthReport, loadRootOrganization, loadRootOrganizationDataUsage, suspendRootIdentity, } from "./workflows/root/index.js";
|
|
18
18
|
export { clearRemoteSyncState, getDomainSyncCoordinatorSnapshot, getOrCreateDomainSyncCoordinator, hasDomainSyncCoordinatorPendingWork, requestAllDomainSyncLanes, subscribeToDomainSyncCoordinator, waitForDomainSyncCoordinatorToSettle, } from "./workflows/sync/index.js";
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,yEAAyE;AACzE,gEAAgE;AAChE,OAAO,EAGL,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAiL/B,OAAO,EAEL,KAAK,EACL,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,8BAA8B,EAC9B,iBAAiB,EACjB,wCAAwC,EACxC,kCAAkC,EAClC,kBAAkB,EACl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AkB,CAAC","sourcesContent":["// SDK: full-bundle identity trust and bounded Members admission.\n// Exact-head authority; canonical writer domains; restart-safe journals.\n// No pin promotion or legacy adapters. See workflows/README.md.\nexport {\n type ApiRequestCounts,\n type ApiRequestEndpointCounts,\n ApiRequestMetrics,\n type ApiRequestMetricsSnapshot,\n} from \"@tearleads/api-client\";\nexport type {\n AbandonOrganizationPolicyMutationInput,\n AddOrganizationGroupUserInput,\n BlobInfo,\n BlobInfoAttachmentKind,\n BlobInfoDocumentReference,\n BlobInfoInput,\n BlobInfoList,\n BlobInfoSort,\n BlobInfoSortDirection,\n BlobInfoSortKey,\n BrowserLocalKeyringOptions,\n ContainerContents,\n ContainerContentsContextValue,\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerDocumentLinkInput,\n ContainerDocumentLinks,\n ContainerDocumentObjectSyncState,\n ContainerDocumentObjectSyncStatus,\n ContainerDocumentQueries,\n ContainerDocumentSidebarRow,\n ContainerInfo,\n ContainerInfoInput,\n ContainerItemRow,\n ContainerItemSort,\n ContainerItemSortDirection,\n ContainerItemSortKey,\n ContainerNode,\n ContainerShareAccessLevel,\n CreateOrganizationOptions,\n DatabaseListener,\n DatabaseOptions,\n DatabaseSnapshot,\n DatabaseStatus,\n DeviceFirst,\n DeviceFirstContainerContents,\n DiscardUnreadableOrganizationPolicyMutationInput,\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentAttributionRangesInput,\n DocumentAttributionRangesPage,\n DocumentContextValue,\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n DocumentInfo,\n DocumentInfoInput,\n DocumentList,\n DocumentSort,\n DocumentSortDirection,\n DocumentSortKey,\n DocumentStore,\n DocumentSubscriptionOptions,\n Documents,\n DocumentsRuntime,\n DocumentsWorkflowRuntimeInput,\n DomainScope,\n FileSaver,\n Identity,\n IdentityGenerationResult,\n IdentityKeyPackage,\n IdentityListener,\n IdentityOptions,\n IdentitySnapshot,\n IndexedDbLocalKeyringManifestStoreOptions,\n IndexedDbWrappingKeyKeystoreOptions,\n LinkDocumentToContainerInput,\n ListDocumentsInput,\n LocalKeyPurpose,\n LocalKeyring,\n LocalKeyringManifest,\n LocalKeyringManifestFormat,\n LocalKeyringManifestStorage,\n LocalKeyringManifestStore,\n LocalKeyringOptions,\n LocalKeyringPinCode,\n LocalKeyringScope,\n LocalKeyringSession,\n LocalOrganizationSummary,\n LocalProjectionReconciledDelta,\n LocalProjectionSnapshot,\n LocalProjectionView,\n LocalSecretContext,\n LocalStorageLocalKeyringManifestStoreOptions,\n Logger,\n MergeDocumentSummary,\n MoveDocumentToContainerInput,\n NetworkListener,\n NetworkMode,\n NetworkStatusSource,\n NormalizedLocalKeyringScope,\n OpenContainerDocumentInput,\n OpenDocumentInput,\n OpenDocumentOptions,\n OrganizationBilling,\n OrganizationBillingHistory,\n OrganizationBillingHistoryEntry,\n OrganizationBillingManagementUrl,\n OrganizationBillingView,\n OrganizationContainerGrant,\n OrganizationContainerGrants,\n OrganizationDataUsage,\n OrganizationDeviceDataUsage,\n OrganizationDeviceDocumentUsageCategoryBreakdown,\n OrganizationDirectory,\n OrganizationDirectoryAndGroups,\n OrganizationDirectoryUser,\n OrganizationGrantRef,\n OrganizationGroupContainer,\n OrganizationGroupContainers,\n OrganizationGroupDetails,\n OrganizationGroupMember,\n OrganizationGroupMembers,\n OrganizationGroupMutationReceipt,\n OrganizationGroupMutationResult,\n OrganizationGroupPolicyHistory,\n OrganizationGroupSummary,\n OrganizationLeaveRequestResult,\n OrganizationMembership,\n OrganizationMemberships,\n OrganizationPolicyGrantChange,\n OrganizationPolicyGroupChange,\n /** Verified organization display page with an optional older-page cursor. */\n OrganizationPolicyHistory,\n OrganizationPolicyHistoryEntry,\n OrganizationProfile,\n OrganizationSyncPauseResult,\n Organizations,\n OrganizationUserDetail,\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n // Persistence notifications distinguish placement changes from content saves.\n PersistedDocumentListener,\n PinCodeBrowserLocalKeyringOptions,\n PinCodeWrappingKeyKeystoreOptions,\n PurgeDocumentInput,\n PurgeDocumentResult,\n ReconciliationService,\n RemoveOrganizationGroupUserInput,\n ResolvedUserIdentity,\n SaveFileRequest,\n SecurityIncident,\n SecurityIncidentListener,\n SecurityIncidentObjectKind,\n SecurityIncidents,\n Session,\n SessionContext,\n SessionCreateOrganizationResult,\n SessionListener,\n SessionRecoverOrganizationResult,\n SessionRegistrationRefusal,\n SessionRegistrationResult,\n SessionSnapshot,\n SetActiveDocumentContainerInput,\n SetLinkedContainerIdsForDocument,\n UnlinkDocumentFromContainerInput,\n UnwrapLocalSecretInput,\n UserIdentities,\n UserSession,\n WrapLocalSecretInput,\n WrappedLocalSecretEnvelope,\n WrappedLocalSecretFormat,\n WrappingKeyHandle,\n WrappingKeyKeystore,\n WrappingKeyMaterialStorage,\n} from \"./client\";\nexport {\n type BlobStoreFactory,\n Blobs,\n createBrowserLocalKeyring,\n createBrowserLocalKeyringManifestStore,\n createBrowserNetworkStatusSource,\n createContainerContentsStoreWorkflowRuntime,\n createContainerContentsWorkflowRuntime,\n createContainerDocumentObjectSyncState,\n createDocumentsWorkflowRuntime,\n createDomainScope,\n createIndexedDbLocalKeyringManifestStore,\n createIndexedDbWrappingKeyKeystore,\n createLocalKeyring,\n createLocalStorageLocalKeyringManifestStore,\n createMemoryLocalKeyringManifestStore,\n createMemoryWrappingKeyKeystore,\n createPinCodeBrowserLocalKeyring,\n createPinCodeWrappingKeyKeystore,\n createRevenueCatPurchases,\n createUnavailableDirectCheckout,\n createUnavailablePurchases,\n createWebViewLocalKeyring,\n Database,\n DEFAULT_DOCUMENT_ID,\n type DirectCheckoutAppearance,\n type DirectCheckoutCapability,\n type DirectCheckoutConfirmation,\n type DirectCheckoutSession,\n DirectCheckoutUnavailableError,\n decodeLocalKeyringSqliteKey,\n Events,\n type EventsListener,\n type EventsSnapshot,\n encodeLocalKeyringSqliteKey,\n enqueueReconciliationForEvents,\n IDENTITY_KEY_PACKAGE_FORMAT,\n isPinCodeWrappedLocalSecretEnvelope,\n LOCAL_KEYRING_MANIFEST_FORMAT,\n localKeyringScopeKey,\n Network,\n normalizeLocalKeyringScope,\n type PrincipalHistoryKeyProvider,\n type PrincipalHistoryKeyScope,\n PurchaseAbortedError,\n PurchaseAlreadyOwnedError,\n PurchaseCancelledError,\n PurchaseIdentityPendingError,\n PurchaseProviderStalledError,\n type PurchasesCapability,\n PurchasesUnavailableError,\n PurgedOrganizationRecoveryBillingRequiredError,\n parseLocalKeyringManifest,\n type RevenueCatBackend,\n type RevenueCatCustomerInfo,\n type RevenueCatPackage,\n type RevenueCatPurchasesConfig,\n SyncBillingGate,\n type SyncBillingGateListener,\n type SyncPurchaseResult,\n type SyncSubscriptionOption,\n serializeLocalKeyringManifest,\n UnverifiedUserIdentityError,\n WRAPPED_LOCAL_SECRET_FORMAT,\n} from \"./client\";\nexport type {\n DiscoveredDocumentInput,\n DocumentAttachment,\n DocumentClientProjectionDefinition,\n DocumentClientProjectionDeleteInput,\n DocumentClientProjectionSaveInput,\n DocumentFieldValidationIssue,\n DocumentProjection,\n DocumentProjectorDefinition,\n DocumentProjectorInput,\n DocumentProjectorRegistry,\n DocumentProjectorRegistryInput,\n DocumentRestoreContent,\n DocumentRow,\n DocumentRowSummary,\n DocumentSummary,\n EnvFileVariable,\n StoredDocumentKind,\n StoredDocumentState,\n StructuredDocumentMap,\n StructuredDocumentShape,\n StructuredDocumentText,\n ValidatedDocumentFields,\n} from \"./data/documents\";\nexport {\n addDocumentAttachments,\n createDocumentProjectorRegistry,\n createDocumentSignerDeviceId,\n DEFAULT_DOCUMENT_ACCESS_EPOCH,\n DEFAULT_DOCUMENT_KIND,\n defaultDocumentProjectorRegistry,\n deriveStoredDocumentTitle,\n ENV_FILE_DOCUMENT_KIND,\n ENV_FILE_NAME_FIELD,\n ENV_FILE_VARIABLE_KEY_FIELD,\n ENV_FILE_VARIABLE_NAME_PATTERN,\n ENV_FILE_VARIABLE_VALUE_FIELD,\n ensureDocumentAttachmentStructure,\n getDocumentAttachments,\n getDocumentClientProjectionTables,\n getStoredDocumentTypeLabel,\n getUntitledDocumentTitle,\n initializeStoredDocumentKind,\n isValidEnvFileVariableName,\n parseEnvFileText,\n projectStoredDocumentState,\n readStoredDocumentState,\n readStringDocumentField,\n resolveOpIdAttribution,\n sameDocumentAttachments,\n summarizeDocumentContributors,\n writerByPeerId,\n writeStoredDocumentFields,\n} from \"./data/documents\";\nexport type {\n ContainerContentsSnapshot,\n ContainerContentsStoreRuntime,\n ContainerContentsStoreState,\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n ContainerState,\n PurgeMoveSettlement,\n PurgeOptions,\n PurgeProgress,\n} from \"./stores/container-contents\";\nexport {\n createContainerContentsStore,\n createContainerContentsStoreState,\n createContainerContentsStoreSyncAgent,\n getOrCreateContainerContentsStore,\n isSystemContainerNode,\n requestContainerContentsDocumentPriming,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStoreRuntime,\n} from \"./stores/container-contents\";\nexport type {\n DocumentMutationGuard,\n DocumentMutationOptions,\n DocumentSnapshot,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentStoreRelinkInput,\n DocumentStructuredFieldPatch,\n} from \"./stores/documents\";\nexport {\n createDocumentStore,\n discardRegisteredDocumentLocalState,\n getOrCreateDocumentStore,\n hasPendingLocalDocumentWrites,\n openDocumentStore,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./stores/documents\";\nexport { Tearleads } from \"./Tearleads\";\nexport type {\n TearleadsDatabaseOptions,\n TearleadsOptions,\n} from \"./TearleadsOptions\";\nexport type {\n BlobAttachmentCollaborators,\n BlobAttachmentServiceApi,\n BlobByteSource,\n BlobByteSourceInput,\n BlobBytes,\n BlobStore,\n DecryptDocumentAttachmentBlobRequest,\n DetachDocumentAttachmentRequest,\n DetachDocumentAttachmentResult,\n EncryptedBlobStoreCipher,\n EncryptedBlobStoreKey,\n EncryptedBlobStoreOptions,\n HydrateDocumentAttachmentBlobsRequest,\n HydratedDocumentAttachmentBlob,\n UploadDocumentAttachmentRequest,\n UploadDocumentAttachmentResult,\n WrapEncryptedBlobStoreOptions,\n} from \"./workflows/blobs\";\nexport {\n BlobAttachmentService,\n blobByteSourceInputLength,\n createBlobByteSource,\n createBlobStore,\n createEncryptedBlobStore,\n createLazyEncryptedBlobStore,\n createMemoryBlobStore,\n purgeOpfsBlobStore,\n readBlobByteSource,\n wrapEncryptedBlobStore,\n} from \"./workflows/blobs\";\nexport type {\n ContainerContentsRootAdopter,\n ContainerContentsRootAdoptionInput,\n ContainerContentsStoreWorkflowRuntime,\n ContainerContentsWorkflowRuntime,\n // Distinct from the canonical `ContainerDocumentLinkInput` (./client); the\n // documentQueries variant has a different shape, so it keeps a disambiguating\n // alias on the public surface.\n ContainerDocumentLinkInput as ContainerDocumentQueriesLinkInput,\n ContainerSystemSlotDefinition,\n PendingDownloadQueueItem,\n RecoveryFolder,\n} from \"./workflows/container-contents\";\nexport {\n ContainerSyncWatermarkRepository,\n createContainerContentsDocumentsRuntime,\n createContainerContentsProjectionUserKeyResolver,\n createContainerContentsSyncLane,\n createContainerParentSyncLane,\n createInitializedContainerMetadataDocument,\n DocumentContainerProjectionRepository,\n defaultContainerContentsPersistence,\n deriveContainerSystemSlot,\n listBlobInfo,\n loadContainerInfo,\n loadDocumentAttributionRanges,\n loadDocumentInfo,\n syncedContainerDocumentObjectSyncState,\n} from \"./workflows/container-contents\";\nexport type {\n AggregatedContainerKekLog,\n ContainerMutationAuthor,\n ContainerMutationCollaborators,\n ContainerReciteApi,\n ContainerWriteRefusal,\n KeyringRebuildResult,\n MaterializedContainerRekeyPlan,\n} from \"./workflows/containers\";\nexport {\n buildMaterializedContainerRekeyPlan,\n buildRootContainerCreatePlan,\n ContainerAuthorAccessError,\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n ContainerKeyringOverrideStaleError,\n ContainerMutationService,\n ContainerPathTooDeepError,\n classifyContainerWriteRefusal,\n containerWriterProjectionFromRekeyPlan,\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n isProjectionVerificationCancelledError,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./workflows/containers\";\nexport type {\n CreateRemoteDocumentRequest,\n CreateRemoteDocumentResult,\n DocumentBirthResult,\n DocumentRecord,\n DocumentSyncContainerRekeyBuilder,\n DocumentSyncPullContinuation,\n DocumentSyncUpdateIsolationError,\n DocumentsPersistence,\n DocumentsWorkflowRuntime,\n IncomingDocumentSyncUpdateValidator,\n LocalAttachmentRecord,\n PendingAttachmentRecord,\n PendingUpdateInsert,\n PendingUpdateRecord,\n QueuedPendingUpdateRecord,\n RemoteDocumentServiceApi,\n SyncRemoteDocumentRequest,\n SyncRemoteDocumentResult,\n} from \"./workflows/documents\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createDocumentProjectionUserKeyResolver,\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n DOCUMENTS_APP_KIND,\n DocumentRawHistoryUnavailableError,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n deriveStableDocumentId,\n isDatabaseUnavailableError,\n isDocumentSyncUpdateIsolationError,\n isEmptyDocumentHistoryChange,\n persistedDocumentCreateStateFromResponse,\n RemoteDocumentService,\n readPullContinuation,\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n validateDocumentSyncUpdateImports,\n} from \"./workflows/documents\";\n// Nominal identity constructors are available only through the testing subpath\n// for low-level runtime tests.\nexport type {\n AcknowledgedPrincipalCurrentInput,\n AcknowledgedPrincipalCurrentRetirement,\n AuthoredPrincipalMutation,\n OrganizationDocumentUsageCategory,\n OrganizationGroupPolicyHistoryEntry,\n OrganizationNativePurchaseEligibility,\n OrganizationPrincipalMemberChange,\n OrganizationPrincipalMemberChangeType,\n OrganizationPrincipalPolicyHistory,\n OrganizationPrincipalPolicyHistoryEntry,\n PrincipalMutationJournalContext,\n PrincipalMutationJournalScope,\n PrincipalMutationResponse,\n ReconcileOrganizationDataUsageInput,\n} from \"./workflows/organizations\";\nexport {\n abandonJournaledPrincipalMutation,\n addOrganizationGroupUser,\n buildInitialGroupPolicyRequest,\n buildInitialMemberGroupPolicyRequest,\n buildOrganizationGroupPolicyHistory,\n buildOrganizationProfileDocumentPatch,\n buildRosterProfileDocumentPatch,\n checkNativePurchaseEligibility,\n createInitializedRosterProfileDocument,\n createOrganizationGroup,\n DEFAULT_PERSONAL_ORGANIZATION_PROFILE_NAME,\n deriveOrganizationMetadataContainerSystemSlot,\n deriveOrganizationRosterProfileContainerSystemSlot,\n discardUnreadableJournaledPrincipalMutation,\n GroupMembershipNameMismatchError,\n GroupShareNameMismatchError,\n getOrganizationProfileDocumentLocalId,\n getRosterProfileDocumentLocalId,\n loadLocalOrganizationDataUsage,\n loadLocalOrganizationDirectoryAndGroups,\n loadOrganizationBilling,\n loadOrganizationBillingHistory,\n loadOrganizationBillingManagementUrl,\n ORGANIZATION_DOCUMENT_USAGE_CATEGORIES,\n ORGANIZATION_METADATA_CONTAINER_NAME,\n ORGANIZATION_PROFILE_DOCUMENT_KIND,\n ORGANIZATION_ROSTER_PROFILE_CONTAINER_NAME,\n PendingPrincipalMutationError,\n PrincipalMutationOutcomeUnknownError,\n ROSTER_PROFILE_DOCUMENT_KIND,\n readJournaledPrincipalMutation,\n readOrganizationProfileName,\n reconcileOrganizationDataUsage,\n reconcileOrganizationDirectoryAndGroups,\n recoverJournaledPrincipalMutation,\n removeOrganizationGroupUser,\n resolveOrganizationBillingView,\n retainAcknowledgedPrincipalCurrents,\n revokeOrganizationContainerGrant,\n shareRemoteContainerWithGroup,\n startOrganizationTrial,\n submitJournaledPrincipalMutation,\n subscribeOrganizationReadModelInvalidation,\n UnreadablePrincipalMutationError,\n updateOrganizationProfile,\n updateOrganizationRosterEntry,\n} from \"./workflows/organizations\";\nexport type {\n AcknowledgedPrincipalPredecessor,\n CacheReferencedPrincipalPoliciesOptions,\n PrincipalHistoryProtectionLease,\n PrincipalPolicyService,\n ProjectionPolicyHistoryRecoveryOptions,\n RecoveredPrincipalPolicyHistory,\n RecoveredScopedPrincipalPolicyHistory,\n RecoverPrincipalPolicyHistoryOptions,\n RecoverScopedPrincipalPolicyHistoryOptions,\n} from \"./workflows/principals\";\nexport {\n cacheReferencedPrincipalPolicies,\n captureAcknowledgedPrincipalPredecessor,\n PrincipalPolicyHistoryReadError,\n recoverPrincipalPolicyHistory,\n recoverProjectionPolicyHistory,\n recoverScopedPrincipalPolicyHistory,\n} from \"./workflows/principals\";\nexport type {\n InitialRootMetadataBootstrap,\n ProvisionedSystemContainerSpec,\n RegisterIdentityInput,\n RegistrationApi,\n} from \"./workflows/registration\";\nexport {\n bootstrapRootContainer,\n buildInitialOrganizationPolicyRequest,\n createInitialRootMetadataBootstrap,\n persistRegistrationBootstrap,\n registerIdentity,\n} from \"./workflows/registration\";\nexport type {\n PendingBlobDeletion,\n PendingBlobDeletionsPage,\n PendingBlobDeletionsQueryInput,\n RootIdentitiesApi,\n RootIdentitiesPage,\n RootIdentitiesQueryInput,\n RootIdentity,\n RootIdentityDetail,\n RootIdentityOrganization,\n RootIdentitySession,\n RootPendingBlobDeletionsQueryInput,\n RootRequestOutcome,\n} from \"./workflows/root\";\nexport {\n liftRootIdentitySuspension,\n listRootAuditEvents,\n listRootDataUsageReport,\n listRootIdentities,\n listRootIdentityOrganizations,\n listRootOrganizationIdentities,\n listRootOrganizationRevenuecatEvents,\n listRootOrganizations,\n listRootRevenuecatEventsReport,\n loadRootIdentity,\n loadRootOpsHealthReport,\n loadRootOrganization,\n loadRootOrganizationDataUsage,\n type RootAuditApi,\n type RootAuditEvent,\n type RootAuditEventsPage,\n type RootAuditEventsQueryInput,\n type RootDataUsageApi,\n type RootDataUsageReportPage,\n type RootOpsHealthApi,\n type RootOpsHealthReport,\n type RootOrganization,\n type RootOrganizationDetail,\n type RootOrganizationIdentitiesPage,\n type RootOrganizationIdentity,\n type RootOrganizationPageQueryInput,\n type RootOrganizationRevenuecatEvent,\n type RootOrganizationRevenuecatEventsPage,\n type RootOrganizationsApi,\n type RootOrganizationsPage,\n type RootOrganizationsQueryInput,\n type RootRevenuecatApi,\n type RootRevenuecatEvent,\n type RootRevenuecatEventsQueryInput,\n type RootRevenuecatEventsReportPage,\n type RootRevenuecatEventsReportQueryInput,\n type RootSuspensionApi,\n suspendRootIdentity,\n} from \"./workflows/root\";\nexport type {\n ClearRemoteSyncStateResult,\n DomainSyncCoordinator,\n DomainSyncSnapshot,\n RemoteResetInput,\n RemoteResetReplacement,\n SyncIdleOptions,\n SyncLane,\n SyncLaneConfig,\n SyncLaneLastAction,\n SyncLanePhase,\n SyncLaneSnapshot,\n SyncLaneStatus,\n} from \"./workflows/sync\";\nexport {\n clearRemoteSyncState,\n getDomainSyncCoordinatorSnapshot,\n getOrCreateDomainSyncCoordinator,\n hasDomainSyncCoordinatorPendingWork,\n requestAllDomainSyncLanes,\n subscribeToDomainSyncCoordinator,\n waitForDomainSyncCoordinatorToSettle,\n} from \"./workflows/sync\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,yEAAyE;AACzE,gEAAgE;AAChE,OAAO,EAGL,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAiL/B,OAAO,EAEL,KAAK,EACL,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,8BAA8B,EAC9B,iBAAiB,EACjB,wCAAwC,EACxC,kCAAkC,E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,EAChC,oCAAoC,GACrC,MAAM,kBAAkB,CAAC","sourcesContent":["// SDK: full-bundle identity trust and bounded Members admission.\n// Exact-head authority; canonical writer domains; restart-safe journals.\n// No pin promotion or legacy adapters. See workflows/README.md.\nexport {\n type ApiRequestCounts,\n type ApiRequestEndpointCounts,\n ApiRequestMetrics,\n type ApiRequestMetricsSnapshot,\n} from \"@tearleads/api-client\";\nexport type {\n AbandonOrganizationPolicyMutationInput,\n AddOrganizationGroupUserInput,\n BlobInfo,\n BlobInfoAttachmentKind,\n BlobInfoDocumentReference,\n BlobInfoInput,\n BlobInfoList,\n BlobInfoSort,\n BlobInfoSortDirection,\n BlobInfoSortKey,\n BrowserLocalKeyringOptions,\n ContainerContents,\n ContainerContentsContextValue,\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerDocumentLinkInput,\n ContainerDocumentLinks,\n ContainerDocumentObjectSyncState,\n ContainerDocumentObjectSyncStatus,\n ContainerDocumentQueries,\n ContainerDocumentSidebarRow,\n ContainerInfo,\n ContainerInfoInput,\n ContainerItemRow,\n ContainerItemSort,\n ContainerItemSortDirection,\n ContainerItemSortKey,\n ContainerNode,\n ContainerShareAccessLevel,\n CreateOrganizationOptions,\n DatabaseListener,\n DatabaseOptions,\n DatabaseSnapshot,\n DatabaseStatus,\n DeviceFirst,\n DeviceFirstContainerContents,\n DiscardUnreadableOrganizationPolicyMutationInput,\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentAttributionRangesInput,\n DocumentAttributionRangesPage,\n DocumentContextValue,\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n DocumentInfo,\n DocumentInfoInput,\n DocumentList,\n DocumentSort,\n DocumentSortDirection,\n DocumentSortKey,\n DocumentStore,\n DocumentSubscriptionOptions,\n Documents,\n DocumentsRuntime,\n DocumentsWorkflowRuntimeInput,\n DomainScope,\n FileSaver,\n Identity,\n IdentityGenerationResult,\n IdentityKeyPackage,\n IdentityListener,\n IdentityOptions,\n IdentitySnapshot,\n IndexedDbLocalKeyringManifestStoreOptions,\n IndexedDbWrappingKeyKeystoreOptions,\n LinkDocumentToContainerInput,\n ListDocumentsInput,\n LocalKeyPurpose,\n LocalKeyring,\n LocalKeyringManifest,\n LocalKeyringManifestFormat,\n LocalKeyringManifestStorage,\n LocalKeyringManifestStore,\n LocalKeyringOptions,\n LocalKeyringPinCode,\n LocalKeyringScope,\n LocalKeyringSession,\n LocalOrganizationSummary,\n LocalProjectionReconciledDelta,\n LocalProjectionSnapshot,\n LocalProjectionView,\n LocalSecretContext,\n LocalStorageLocalKeyringManifestStoreOptions,\n Logger,\n MergeDocumentSummary,\n MoveDocumentToContainerInput,\n NetworkListener,\n NetworkMode,\n NetworkStatusSource,\n NormalizedLocalKeyringScope,\n OpenContainerDocumentInput,\n OpenDocumentInput,\n OpenDocumentOptions,\n OrganizationBilling,\n OrganizationBillingHistory,\n OrganizationBillingHistoryEntry,\n OrganizationBillingManagementUrl,\n OrganizationBillingView,\n OrganizationContainerGrant,\n OrganizationContainerGrants,\n OrganizationDataUsage,\n OrganizationDeviceDataUsage,\n OrganizationDeviceDocumentUsageCategoryBreakdown,\n OrganizationDirectory,\n OrganizationDirectoryAndGroups,\n OrganizationDirectoryUser,\n OrganizationGrantRef,\n OrganizationGroupContainer,\n OrganizationGroupContainers,\n OrganizationGroupDetails,\n OrganizationGroupMember,\n OrganizationGroupMembers,\n OrganizationGroupMutationReceipt,\n OrganizationGroupMutationResult,\n OrganizationGroupPolicyHistory,\n OrganizationGroupSummary,\n OrganizationLeaveRequestResult,\n OrganizationMembership,\n OrganizationMemberships,\n OrganizationPolicyGrantChange,\n OrganizationPolicyGroupChange,\n /** Verified organization display page with an optional older-page cursor. */\n OrganizationPolicyHistory,\n OrganizationPolicyHistoryEntry,\n OrganizationProfile,\n OrganizationSyncPauseResult,\n Organizations,\n OrganizationUserDetail,\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n // Persistence notifications distinguish placement changes from content saves.\n PersistedDocumentListener,\n PinCodeBrowserLocalKeyringOptions,\n PinCodeWrappingKeyKeystoreOptions,\n PurgeDocumentInput,\n PurgeDocumentResult,\n ReconciliationService,\n RemoveOrganizationGroupUserInput,\n ResolvedUserIdentity,\n SaveFileRequest,\n SecurityIncident,\n SecurityIncidentListener,\n SecurityIncidentObjectKind,\n SecurityIncidents,\n Session,\n SessionContext,\n SessionCreateOrganizationResult,\n SessionListener,\n SessionRecoverOrganizationResult,\n SessionRegistrationRefusal,\n SessionRegistrationResult,\n SessionSnapshot,\n SetActiveDocumentContainerInput,\n SetLinkedContainerIdsForDocument,\n UnlinkDocumentFromContainerInput,\n UnwrapLocalSecretInput,\n UserIdentities,\n UserSession,\n WrapLocalSecretInput,\n WrappedLocalSecretEnvelope,\n WrappedLocalSecretFormat,\n WrappingKeyHandle,\n WrappingKeyKeystore,\n WrappingKeyMaterialStorage,\n} from \"./client\";\nexport {\n type BlobStoreFactory,\n Blobs,\n createBrowserLocalKeyring,\n createBrowserLocalKeyringManifestStore,\n createBrowserNetworkStatusSource,\n createContainerContentsStoreWorkflowRuntime,\n createContainerContentsWorkflowRuntime,\n createContainerDocumentObjectSyncState,\n createDocumentsWorkflowRuntime,\n createDomainScope,\n createIndexedDbLocalKeyringManifestStore,\n createIndexedDbWrappingKeyKeystore,\n createLocalKeyring,\n createLocalStorageLocalKeyringManifestStore,\n createMemoryLocalKeyringManifestStore,\n createMemoryWrappingKeyKeystore,\n createPinCodeBrowserLocalKeyring,\n createPinCodeWrappingKeyKeystore,\n createRevenueCatPurchases,\n createUnavailableDirectCheckout,\n createUnavailablePurchases,\n createWebViewLocalKeyring,\n Database,\n DEFAULT_DOCUMENT_ID,\n type DirectCheckoutAppearance,\n type DirectCheckoutCapability,\n type DirectCheckoutConfirmation,\n type DirectCheckoutSession,\n DirectCheckoutUnavailableError,\n decodeLocalKeyringSqliteKey,\n Events,\n type EventsListener,\n type EventsSnapshot,\n encodeLocalKeyringSqliteKey,\n enqueueReconciliationForEvents,\n IDENTITY_KEY_PACKAGE_FORMAT,\n isPinCodeWrappedLocalSecretEnvelope,\n LOCAL_KEYRING_MANIFEST_FORMAT,\n localKeyringScopeKey,\n Network,\n normalizeLocalKeyringScope,\n type PrincipalHistoryKeyProvider,\n type PrincipalHistoryKeyScope,\n PurchaseAbortedError,\n PurchaseAlreadyOwnedError,\n PurchaseCancelledError,\n PurchaseIdentityPendingError,\n PurchaseProviderStalledError,\n type PurchasesCapability,\n PurchasesUnavailableError,\n PurgedOrganizationRecoveryBillingRequiredError,\n parseLocalKeyringManifest,\n type RevenueCatBackend,\n type RevenueCatCustomerInfo,\n type RevenueCatPackage,\n type RevenueCatPurchasesConfig,\n SyncBillingGate,\n type SyncBillingGateListener,\n type SyncPurchaseResult,\n type SyncSubscriptionOption,\n serializeLocalKeyringManifest,\n UnverifiedUserIdentityError,\n WRAPPED_LOCAL_SECRET_FORMAT,\n} from \"./client\";\nexport type {\n DiscoveredDocumentInput,\n DocumentAttachment,\n DocumentClientProjectionDefinition,\n DocumentClientProjectionDeleteInput,\n DocumentClientProjectionSaveInput,\n DocumentFieldValidationIssue,\n DocumentProjection,\n DocumentProjectorDefinition,\n DocumentProjectorInput,\n DocumentProjectorRegistry,\n DocumentProjectorRegistryInput,\n DocumentRestoreContent,\n DocumentRow,\n DocumentRowSummary,\n DocumentSummary,\n EnvFileVariable,\n StoredDocumentKind,\n StoredDocumentState,\n StructuredDocumentMap,\n StructuredDocumentShape,\n StructuredDocumentText,\n ValidatedDocumentFields,\n} from \"./data/documents\";\nexport {\n addDocumentAttachments,\n createDocumentProjectorRegistry,\n createDocumentSignerDeviceId,\n DEFAULT_DOCUMENT_ACCESS_EPOCH,\n DEFAULT_DOCUMENT_KIND,\n defaultDocumentProjectorRegistry,\n deriveStoredDocumentTitle,\n ENV_FILE_DOCUMENT_KIND,\n ENV_FILE_NAME_FIELD,\n ENV_FILE_VARIABLE_KEY_FIELD,\n ENV_FILE_VARIABLE_NAME_PATTERN,\n ENV_FILE_VARIABLE_VALUE_FIELD,\n ensureDocumentAttachmentStructure,\n getDocumentAttachments,\n getDocumentClientProjectionTables,\n getStoredDocumentTypeLabel,\n getUntitledDocumentTitle,\n initializeStoredDocumentKind,\n isValidEnvFileVariableName,\n parseEnvFileText,\n projectStoredDocumentState,\n readStoredDocumentState,\n readStringDocumentField,\n resolveOpIdAttribution,\n sameDocumentAttachments,\n summarizeDocumentContributors,\n writerByPeerId,\n writeStoredDocumentFields,\n} from \"./data/documents\";\nexport type {\n ContainerContentsSnapshot,\n ContainerContentsStoreRuntime,\n ContainerContentsStoreState,\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n ContainerState,\n PurgeMoveSettlement,\n PurgeOptions,\n PurgeProgress,\n} from \"./stores/container-contents\";\nexport {\n createContainerContentsStore,\n createContainerContentsStoreState,\n createContainerContentsStoreSyncAgent,\n getOrCreateContainerContentsStore,\n isSystemContainerNode,\n requestContainerContentsDocumentPriming,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStoreRuntime,\n} from \"./stores/container-contents\";\nexport type {\n DocumentMutationGuard,\n DocumentMutationOptions,\n DocumentSnapshot,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentStoreRelinkInput,\n DocumentStructuredFieldPatch,\n} from \"./stores/documents\";\nexport {\n createDocumentStore,\n discardRegisteredDocumentLocalState,\n getOrCreateDocumentStore,\n hasPendingLocalDocumentWrites,\n openDocumentStore,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./stores/documents\";\nexport { Tearleads } from \"./Tearleads\";\nexport type {\n TearleadsDatabaseOptions,\n TearleadsOptions,\n} from \"./TearleadsOptions\";\nexport type {\n BlobAttachmentCollaborators,\n BlobAttachmentServiceApi,\n BlobByteSource,\n BlobByteSourceInput,\n BlobBytes,\n BlobStore,\n DecryptDocumentAttachmentBlobRequest,\n DetachDocumentAttachmentRequest,\n DetachDocumentAttachmentResult,\n EncryptedBlobStoreCipher,\n EncryptedBlobStoreKey,\n EncryptedBlobStoreOptions,\n HydrateDocumentAttachmentBlobsRequest,\n HydratedDocumentAttachmentBlob,\n UploadDocumentAttachmentRequest,\n UploadDocumentAttachmentResult,\n WrapEncryptedBlobStoreOptions,\n} from \"./workflows/blobs\";\nexport {\n BlobAttachmentService,\n blobByteSourceInputLength,\n createBlobByteSource,\n createBlobStore,\n createEncryptedBlobStore,\n createLazyEncryptedBlobStore,\n createMemoryBlobStore,\n purgeOpfsBlobStore,\n readBlobByteSource,\n wrapEncryptedBlobStore,\n} from \"./workflows/blobs\";\nexport type {\n ContainerContentsRootAdopter,\n ContainerContentsRootAdoptionInput,\n ContainerContentsStoreWorkflowRuntime,\n ContainerContentsWorkflowRuntime,\n // Distinct from the canonical `ContainerDocumentLinkInput` (./client); the\n // documentQueries variant has a different shape, so it keeps a disambiguating\n // alias on the public surface.\n ContainerDocumentLinkInput as ContainerDocumentQueriesLinkInput,\n ContainerSystemSlotDefinition,\n PendingDownloadQueueItem,\n RecoveryFolder,\n} from \"./workflows/container-contents\";\nexport {\n ContainerSyncWatermarkRepository,\n createContainerContentsDocumentsRuntime,\n createContainerContentsProjectionUserKeyResolver,\n createContainerContentsSyncLane,\n createContainerParentSyncLane,\n createInitializedContainerMetadataDocument,\n DocumentContainerProjectionRepository,\n defaultContainerContentsPersistence,\n deriveContainerSystemSlot,\n listBlobInfo,\n loadContainerInfo,\n loadDocumentAttributionRanges,\n loadDocumentInfo,\n syncedContainerDocumentObjectSyncState,\n} from \"./workflows/container-contents\";\nexport type {\n AggregatedContainerKekLog,\n ContainerMutationAuthor,\n ContainerMutationCollaborators,\n ContainerReciteApi,\n ContainerWriteRefusal,\n KeyringRebuildResult,\n MaterializedContainerRekeyPlan,\n} from \"./workflows/containers\";\nexport {\n buildMaterializedContainerRekeyPlan,\n buildRootContainerCreatePlan,\n ContainerAuthorAccessError,\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n ContainerKeyringOverrideStaleError,\n ContainerMutationService,\n ContainerPathTooDeepError,\n classifyContainerWriteRefusal,\n containerWriterProjectionFromRekeyPlan,\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n isProjectionVerificationCancelledError,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./workflows/containers\";\nexport type {\n CreateRemoteDocumentRequest,\n CreateRemoteDocumentResult,\n DocumentBirthResult,\n DocumentRecord,\n DocumentSyncContainerRekeyBuilder,\n DocumentSyncPullContinuation,\n DocumentSyncUpdateIsolationError,\n DocumentsPersistence,\n DocumentsWorkflowRuntime,\n IncomingDocumentSyncUpdateValidator,\n LocalAttachmentRecord,\n PendingAttachmentRecord,\n PendingUpdateInsert,\n PendingUpdateRecord,\n QueuedPendingUpdateRecord,\n RemoteDocumentServiceApi,\n SyncRemoteDocumentRequest,\n SyncRemoteDocumentResult,\n} from \"./workflows/documents\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createDocumentProjectionUserKeyResolver,\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n DOCUMENTS_APP_KIND,\n DocumentRawHistoryUnavailableError,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n deriveStableDocumentId,\n isDatabaseUnavailableError,\n isDocumentSyncUpdateIsolationError,\n isEmptyDocumentHistoryChange,\n persistedDocumentCreateStateFromResponse,\n RemoteDocumentService,\n readPullContinuation,\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n validateDocumentSyncUpdateImports,\n} from \"./workflows/documents\";\n// Nominal identity constructors are available only through the testing subpath\n// for low-level runtime tests.\nexport type {\n AcknowledgedPrincipalCurrentInput,\n AcknowledgedPrincipalCurrentRetirement,\n AuthoredPrincipalMutation,\n OrganizationDocumentUsageCategory,\n OrganizationGroupPolicyHistoryEntry,\n OrganizationNativePurchaseEligibility,\n OrganizationPrincipalMemberChange,\n OrganizationPrincipalMemberChangeType,\n OrganizationPrincipalPolicyHistory,\n OrganizationPrincipalPolicyHistoryEntry,\n PrincipalMutationJournalContext,\n PrincipalMutationJournalScope,\n PrincipalMutationResponse,\n ReconcileOrganizationDataUsageInput,\n} from \"./workflows/organizations\";\nexport {\n abandonJournaledPrincipalMutation,\n addOrganizationGroupUser,\n buildInitialGroupPolicyRequest,\n buildInitialMemberGroupPolicyRequest,\n buildOrganizationGroupPolicyHistory,\n buildOrganizationProfileDocumentPatch,\n buildRosterProfileDocumentPatch,\n checkNativePurchaseEligibility,\n createInitializedRosterProfileDocument,\n createOrganizationGroup,\n DEFAULT_PERSONAL_ORGANIZATION_PROFILE_NAME,\n deriveOrganizationMetadataContainerSystemSlot,\n deriveOrganizationRosterProfileContainerSystemSlot,\n discardUnreadableJournaledPrincipalMutation,\n GroupMembershipNameMismatchError,\n GroupShareNameMismatchError,\n getOrganizationProfileDocumentLocalId,\n getRosterProfileDocumentLocalId,\n loadLocalOrganizationDataUsage,\n loadLocalOrganizationDirectoryAndGroups,\n loadOrganizationBilling,\n loadOrganizationBillingHistory,\n loadOrganizationBillingManagementUrl,\n ORGANIZATION_DOCUMENT_USAGE_CATEGORIES,\n ORGANIZATION_METADATA_CONTAINER_NAME,\n ORGANIZATION_PROFILE_DOCUMENT_KIND,\n ORGANIZATION_ROSTER_PROFILE_CONTAINER_NAME,\n PendingPrincipalMutationError,\n PrincipalMutationOutcomeUnknownError,\n ROSTER_PROFILE_DOCUMENT_KIND,\n readJournaledPrincipalMutation,\n readOrganizationProfileName,\n reconcileOrganizationDataUsage,\n reconcileOrganizationDirectoryAndGroups,\n recoverJournaledPrincipalMutation,\n removeOrganizationGroupUser,\n resolveOrganizationBillingView,\n retainAcknowledgedPrincipalCurrents,\n revokeOrganizationContainerGrant,\n shareRemoteContainerWithGroup,\n startOrganizationTrial,\n submitJournaledPrincipalMutation,\n subscribeOrganizationReadModelInvalidation,\n UnreadablePrincipalMutationError,\n updateOrganizationProfile,\n updateOrganizationRosterEntry,\n} from \"./workflows/organizations\";\nexport type {\n AcknowledgedPrincipalPredecessor,\n CacheReferencedPrincipalPoliciesOptions,\n PrincipalHistoryProtectionLease,\n PrincipalPolicyService,\n ProjectionPolicyHistoryRecoveryOptions,\n RecoveredPrincipalPolicyHistory,\n RecoveredScopedPrincipalPolicyHistory,\n RecoverPrincipalPolicyHistoryOptions,\n RecoverScopedPrincipalPolicyHistoryOptions,\n} from \"./workflows/principals\";\nexport {\n cacheReferencedPrincipalPolicies,\n captureAcknowledgedPrincipalPredecessor,\n PrincipalPolicyHistoryReadError,\n recoverPrincipalPolicyHistory,\n recoverProjectionPolicyHistory,\n recoverScopedPrincipalPolicyHistory,\n} from \"./workflows/principals\";\nexport type {\n InitialRootMetadataBootstrap,\n ProvisionedSystemContainerSpec,\n RegisterIdentityInput,\n RegistrationApi,\n} from \"./workflows/registration\";\nexport {\n bootstrapRootContainer,\n buildInitialOrganizationPolicyRequest,\n createInitialRootMetadataBootstrap,\n deriveRegistrationOrganizationId,\n persistRegistrationBootstrap,\n registerIdentity,\n} from \"./workflows/registration\";\nexport type {\n PendingBlobDeletion,\n PendingBlobDeletionsPage,\n PendingBlobDeletionsQueryInput,\n RootIdentitiesApi,\n RootIdentitiesPage,\n RootIdentitiesQueryInput,\n RootIdentity,\n RootIdentityDetail,\n RootIdentityOrganization,\n RootIdentitySession,\n RootPendingBlobDeletionsQueryInput,\n RootRequestOutcome,\n} from \"./workflows/root\";\nexport {\n liftRootIdentitySuspension,\n listRootAuditEvents,\n listRootDataUsageReport,\n listRootIdentities,\n listRootIdentityOrganizations,\n listRootOrganizationIdentities,\n listRootOrganizationRevenuecatEvents,\n listRootOrganizations,\n listRootRevenuecatEventsReport,\n loadRootIdentity,\n loadRootOpsHealthReport,\n loadRootOrganization,\n loadRootOrganizationDataUsage,\n type RootAuditApi,\n type RootAuditEvent,\n type RootAuditEventsPage,\n type RootAuditEventsQueryInput,\n type RootDataUsageApi,\n type RootDataUsageReportPage,\n type RootOpsHealthApi,\n type RootOpsHealthReport,\n type RootOrganization,\n type RootOrganizationDetail,\n type RootOrganizationIdentitiesPage,\n type RootOrganizationIdentity,\n type RootOrganizationPageQueryInput,\n type RootOrganizationRevenuecatEvent,\n type RootOrganizationRevenuecatEventsPage,\n type RootOrganizationsApi,\n type RootOrganizationsPage,\n type RootOrganizationsQueryInput,\n type RootRevenuecatApi,\n type RootRevenuecatEvent,\n type RootRevenuecatEventsQueryInput,\n type RootRevenuecatEventsReportPage,\n type RootRevenuecatEventsReportQueryInput,\n type RootSuspensionApi,\n suspendRootIdentity,\n} from \"./workflows/root\";\nexport type {\n ClearRemoteSyncStateResult,\n DomainSyncCoordinator,\n DomainSyncSnapshot,\n RemoteResetInput,\n RemoteResetReplacement,\n SyncIdleOptions,\n SyncLane,\n SyncLaneConfig,\n SyncLaneLastAction,\n SyncLanePhase,\n SyncLaneSnapshot,\n SyncLaneStatus,\n} from \"./workflows/sync\";\nexport {\n clearRemoteSyncState,\n getDomainSyncCoordinatorSnapshot,\n getOrCreateDomainSyncCoordinator,\n hasDomainSyncCoordinatorPendingWork,\n requestAllDomainSyncLanes,\n subscribeToDomainSyncCoordinator,\n waitForDomainSyncCoordinatorToSettle,\n} from \"./workflows/sync\";\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare function formatContainerSystemSlot(digest: Uint8Array): ContainerSystemSlot;
|
|
3
|
+
export declare const ORGANIZATION_TRASH_SLOT_NAMESPACE = "tearleads.organization-trash";
|
|
4
|
+
export declare function deriveOrganizationSystemSlot(input: {
|
|
5
|
+
readonly namespace: string;
|
|
6
|
+
readonly organizationId: string;
|
|
7
|
+
}): ContainerSystemSlot;
|
|
8
|
+
export declare function deriveOrganizationTrashSystemSlot(organizationId: string): ContainerSystemSlot;
|
|
3
9
|
export declare const ContainerSystemSlotSchema: z.ZodCustom<string, string>;
|
|
4
10
|
export type ContainerSystemSlot = z.infer<typeof ContainerSystemSlotSchema>;
|
|
5
11
|
export declare function isContainerSystemSlot(value: unknown): value is ContainerSystemSlot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { registerJsonSchemaFragment } from "./jsonSchema.js";
|
|
3
4
|
const CONTAINER_SYSTEM_SLOT_PATTERN = /^sys_v1_[A-Za-z0-9_-]{43}$/;
|
|
@@ -11,13 +12,20 @@ export function formatContainerSystemSlot(digest) {
|
|
|
11
12
|
.replace(/=+$/g, "");
|
|
12
13
|
return `sys_v1_${encoded}`;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export const ORGANIZATION_TRASH_SLOT_NAMESPACE = "tearleads.organization-trash";
|
|
16
|
+
export function deriveOrganizationSystemSlot(input) {
|
|
17
|
+
const label = JSON.stringify({
|
|
16
18
|
namespace: input.namespace,
|
|
17
19
|
organizationId: input.organizationId,
|
|
18
20
|
version: 1,
|
|
19
|
-
})
|
|
20
|
-
return formatContainerSystemSlot(new
|
|
21
|
+
});
|
|
22
|
+
return formatContainerSystemSlot(sha256(new TextEncoder().encode(label)));
|
|
23
|
+
}
|
|
24
|
+
export function deriveOrganizationTrashSystemSlot(organizationId) {
|
|
25
|
+
return deriveOrganizationSystemSlot({
|
|
26
|
+
namespace: ORGANIZATION_TRASH_SLOT_NAMESPACE,
|
|
27
|
+
organizationId,
|
|
28
|
+
});
|
|
21
29
|
}
|
|
22
30
|
export const ContainerSystemSlotSchema = registerJsonSchemaFragment(z.custom((value) => typeof value === "string" && CONTAINER_SYSTEM_SLOT_PATTERN.test(value)), {
|
|
23
31
|
pattern: CONTAINER_SYSTEM_SLOT_PATTERN.source,
|
|
@@ -29,13 +37,13 @@ export function isContainerSystemSlot(value) {
|
|
|
29
37
|
export function isNullableContainerSystemSlot(value) {
|
|
30
38
|
return value === null || isContainerSystemSlot(value);
|
|
31
39
|
}
|
|
32
|
-
export function deriveOrganizationRosterProfileContainerSystemSlot(input) {
|
|
40
|
+
export async function deriveOrganizationRosterProfileContainerSystemSlot(input) {
|
|
33
41
|
return deriveOrganizationSystemSlot({
|
|
34
42
|
namespace: "tearleads.organization-roster-profiles",
|
|
35
43
|
organizationId: input.organizationId,
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
|
-
export function deriveOrganizationMetadataContainerSystemSlot(input) {
|
|
46
|
+
export async function deriveOrganizationMetadataContainerSystemSlot(input) {
|
|
39
47
|
return deriveOrganizationSystemSlot({
|
|
40
48
|
namespace: "tearleads.organization-metadata",
|
|
41
49
|
organizationId: input.organizationId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerSystemSlot.js","sourceRoot":"","sources":["containerSystemSlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAEnE,MAAM,UAAU,yBAAyB,CACvC,MAAkB;IAElB,IAAI,MAAM,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,CAAC;SACjD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,OAAO,UAAU,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED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BAAyB,GAAG,0BAA0B,CACjE,CAAC,CAAC,MAAM,CACN,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ,IAAI,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,CACzE,EACD;IACE,OAAO,EAAE,6BAA6B,CAAC,MAAM;IAC7C,IAAI,EAAE,QAAQ;CACf,CACF,CAAC;AAIF,MAAM,UAAU,qBAAqB,CACnC,KAAc;IAEd,OAAO,yBAAyB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,KAAc;IAEd,OAAO,KAAK,KAAK,IAAI,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kDAAkD,CAAC,KAExE;IACC,OAAO,4BAA4B,CAAC;QAClC,SAAS,EAAE,wCAAwC;QACnD,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6CAA6C,CAAC,KAEnE;IACC,OAAO,4BAA4B,CAAC;QAClC,SAAS,EAAE,iCAAiC;QAC5C,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { z } from \"zod\";\nimport { registerJsonSchemaFragment } from \"./jsonSchema\";\n\nconst CONTAINER_SYSTEM_SLOT_PATTERN = /^sys_v1_[A-Za-z0-9_-]{43}$/;\n\nexport function formatContainerSystemSlot(\n digest: Uint8Array,\n): ContainerSystemSlot {\n if (digest.byteLength !== 32) {\n throw new Error(\"Container system slot digests must be exactly 32 bytes\");\n }\n const encoded = btoa(String.fromCharCode(...digest))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=+$/g, \"\");\n return `sys_v1_${encoded}`;\n}\n\nexport const ORGANIZATION_TRASH_SLOT_NAMESPACE = \"tearleads.organization-trash\";\n\nexport function deriveOrganizationSystemSlot(input: {\n readonly namespace: string;\n readonly organizationId: string;\n}): ContainerSystemSlot {\n const label = JSON.stringify({\n namespace: input.namespace,\n organizationId: input.organizationId,\n version: 1,\n });\n return formatContainerSystemSlot(sha256(new TextEncoder().encode(label)));\n}\n\nexport function deriveOrganizationTrashSystemSlot(\n organizationId: string,\n): ContainerSystemSlot {\n return deriveOrganizationSystemSlot({\n namespace: ORGANIZATION_TRASH_SLOT_NAMESPACE,\n organizationId,\n });\n}\n\nexport const ContainerSystemSlotSchema = registerJsonSchemaFragment(\n z.custom<string>(\n (value) =>\n typeof value === \"string\" && CONTAINER_SYSTEM_SLOT_PATTERN.test(value),\n ),\n {\n pattern: CONTAINER_SYSTEM_SLOT_PATTERN.source,\n type: \"string\",\n },\n);\n\nexport type ContainerSystemSlot = z.infer<typeof ContainerSystemSlotSchema>;\n\nexport function isContainerSystemSlot(\n value: unknown,\n): value is ContainerSystemSlot {\n return ContainerSystemSlotSchema.safeParse(value).success;\n}\n\nexport function isNullableContainerSystemSlot(\n value: unknown,\n): value is ContainerSystemSlot | null {\n return value === null || isContainerSystemSlot(value);\n}\n\nexport async function deriveOrganizationRosterProfileContainerSystemSlot(input: {\n readonly organizationId: string;\n}): Promise<ContainerSystemSlot> {\n return deriveOrganizationSystemSlot({\n namespace: \"tearleads.organization-roster-profiles\",\n organizationId: input.organizationId,\n });\n}\n\nexport async function deriveOrganizationMetadataContainerSystemSlot(input: {\n readonly organizationId: string;\n}): Promise<ContainerSystemSlot> {\n return deriveOrganizationSystemSlot({\n namespace: \"tearleads.organization-metadata\",\n organizationId: input.organizationId,\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -241,16 +241,17 @@ function bindManualTreeReset(input) {
|
|
|
241
241
|
return { ...input, ownsTreeReset: captureTreeResetOwner(input.state) };
|
|
242
242
|
}
|
|
243
243
|
export function requestContainerContentsRemoteHydration(input) {
|
|
244
|
-
const { host, scheduleSync, state } = input;
|
|
245
244
|
input = bindManualTreeReset(input);
|
|
246
245
|
if (!ownsHydrationRequest(input))
|
|
247
246
|
return Promise.resolve();
|
|
248
247
|
queueRequestedParentIds(input);
|
|
249
248
|
const readinessBarrier = waitForRemoteHydrationReadiness(input);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
const request = readinessBarrier ?? startHydration(prepareTreeReset(input));
|
|
250
|
+
input.state.trackHydration?.(request);
|
|
251
|
+
return request;
|
|
252
|
+
}
|
|
253
|
+
function startHydration(input) {
|
|
254
|
+
const { host, scheduleSync, state } = input;
|
|
254
255
|
const { followDiscoveredParentLanes, parentIds } = consumeQueuedHydrationScope(state, input.followDiscoveredParentLanes);
|
|
255
256
|
let appliedRemoteContainerChange = false;
|
|
256
257
|
let retainInterruptedHydration = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteHydrationRequest.js","sourceRoot":"","sources":["remoteHydrationRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAGvB,yBAAyB,GAC1B,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAEL,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,uBAAuB,EAGvB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC;AA4C5B,SAAS,0BAA0B,CAAC,KAInC;IACC,OAAO,CACL,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,KAAK,CAAC,KAAK,CAAC,mBAAmB,KAAK,KAAK,CAAC,mBAAmB;QAC7D,KAAK,CAAC,KAAK,CAAC,oBAAoB,KAAK,KAAK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AC,gBAAgB,CAAC,CAAC,CAAC;gBAC9D,KAAK,CAAC,0BAA0B,CAAC;YACnC,KAAK,CAAC,QAAQ,CAAC,KAAK;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe;YAClC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAC1B,CAAC;YACD,YAAY,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,8BAA8B,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,0BAA0B,EAAE,CAAC;YAC/B,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,sBAAsB,GAAG,gBAAgB,CAAC;IAEhD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n createGenerationGuardedHydrationHost,\n hydrateRemoteContainers,\n type ReconnectCrawl,\n type RemoteContainerHydrationHost,\n StaleRemoteHydrationError,\n} from \"../../../workflows/container-contents/remoteHydration\";\nimport type { RemoteContainerHydrationState } from \"../../../workflows/container-contents/remoteHydration/types\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\nimport { ownsContainerStore } from \"../containerState/storeScope\";\nimport {\n type LocalContainerRefreshState,\n refreshLocalContainerStates,\n} from \"../localRefresh\";\nimport {\n IDLE_RECOVERY_HYDRATION,\n type RecoveryHydrationEvent,\n type RecoveryHydrationState,\n transitionRecoveryHydration,\n} from \"./recoveryHydrationMachine\";\n\nimport {\n captureTreeResetOwner,\n claimTreeReset,\n queueTreeReset,\n} from \"./treeResetMachine\";\n\ntype RemoteHydrationRequestState = RemoteContainerHydrationState &\n LocalContainerRefreshState & {\n containerParentIdsNeedingHydration: Set<string | null>;\n initializePromise: Promise<void> | null;\n lifecycleGeneration: number;\n remoteHydrationGeneration: number | null;\n remoteHydrationPromise: Promise<void> | null;\n remoteHydrationStructuralGeneration: number | null;\n rootLaneHydrated: boolean;\n snapshot: {\n ready: boolean;\n };\n structuralGeneration: number;\n writeGeneration?: number;\n };\n\ninterface RemoteHydrationRequestInput {\n ownsTreeReset?: () => boolean;\n followDiscoveredParentLanes?: boolean | undefined;\n host: RemoteContainerHydrationHost;\n reconnect?: ReconnectCrawl | undefined;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n recreateOnFullyHydratedAfterReset?:\n | (() => () => Promise<void> | void)\n | undefined;\n recreateOnFullyHydratedAtStart?: boolean | undefined;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSyncAfterHydration?: boolean | undefined;\n scheduleSyncOnHydrationChange?: boolean | undefined;\n scheduleSync: () => void;\n state: RemoteHydrationRequestState;\n}\n\ninterface RecoveryHydrationRequest {\n input: RemoteHydrationRequestInput;\n lifecycleGeneration: number;\n structuralGeneration: number;\n}\n\nfunction isRequestGenerationCurrent(input: {\n lifecycleGeneration: number;\n state: RemoteHydrationRequestState;\n structuralGeneration: number;\n}): boolean {\n return (\n ownsContainerStore(input.state) &&\n input.state.lifecycleGeneration === input.lifecycleGeneration &&\n input.state.structuralGeneration === input.structuralGeneration\n );\n}\n\nconst recoveryHydrationByState = new WeakMap<\n RemoteHydrationRequestState,\n RecoveryHydrationState<RecoveryHydrationRequest>\n>();\n\nfunction dispatchRecoveryHydration(\n state: RemoteHydrationRequestState,\n event: RecoveryHydrationEvent<RecoveryHydrationRequest>,\n): void {\n const next = transitionRecoveryHydration(\n recoveryHydrationByState.get(state) ?? IDLE_RECOVERY_HYDRATION,\n event,\n );\n if (next.status === \"idle\") {\n recoveryHydrationByState.delete(state);\n } else {\n recoveryHydrationByState.set(state, next);\n }\n}\n\nfunction queueRecoveryHydrationRequest(\n input: RemoteHydrationRequestInput,\n): void {\n dispatchRecoveryHydration(input.state, {\n request: {\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n },\n type: \"queued\",\n });\n}\n\nfunction hasRemoteHydrationPrerequisites(\n state: RemoteHydrationRequestState,\n): boolean {\n return (\n (state.runtime.liveHydrationStatus?.() ?? \"ready\") === \"ready\" &&\n state.runtime.infra.dbStatus === \"ready\" &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n );\n}\n\nfunction createResetRecoveryInput(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n return {\n ...input,\n followDiscoveredParentLanes: true,\n onFullyHydrated: undefined,\n parentIds: undefined,\n recreateOnFullyHydratedAtStart: true,\n };\n}\n\nfunction resumeRetainedRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n if (!ownsHydrationRequest(input)) return Promise.resolve();\n queueRecoveryHydrationRequest(input);\n return hasRemoteHydrationPrerequisites(input.state)\n ? input.resumeRecoveryWork()\n : Promise.resolve();\n}\n\nfunction prepareTreeReset(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n const coverReset = claimTreeReset(\n input.state,\n !!input.reconnect || !!input.resetAllLaneWatermarks,\n );\n if (!coverReset) return input;\n const onCovered = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n return {\n ...input,\n followDiscoveredParentLanes: true,\n resetAllLaneWatermarks: true,\n recreateOnFullyHydratedAtStart: false,\n ownsTreeReset: coverReset.isOwned,\n onFullyHydrated: () => {\n coverReset.cover();\n return onCovered?.();\n },\n };\n}\n\nfunction waitForActiveRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeHydration = state.remoteHydrationPromise;\n if (!activeHydration) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n const needsCurrentGenerationHydration =\n state.remoteHydrationGeneration !== state.lifecycleGeneration ||\n state.remoteHydrationStructuralGeneration !== state.structuralGeneration;\n // A restoration owns its sweep callback and its sync scheduling policy.\n // Let it list after prior work settles so its durable claim can complete.\n const needsOwnCrawl =\n !!(input.onFullyHydrated || input.recreateOnFullyHydratedAfterReset) &&\n !!input.resetAllLaneWatermarks &&\n !!input.followDiscoveredParentLanes;\n if (\n !needsOwnCrawl &&\n input.resetAllLaneWatermarks &&\n input.followDiscoveredParentLanes\n ) {\n input = { ...input, ownsTreeReset: queueTreeReset(state) };\n }\n const requestQueuedHydration = () => {\n if (\n !isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ) {\n return retryRemoteHydrationAfterReset(input);\n }\n // Another request's crawl may have taken over this request's queued\n // lanes. Settle with that crawl rather than at once, so the request never\n // resolves before the listing that covers it.\n return needsOwnCrawl ||\n needsCurrentGenerationHydration ||\n state.containerParentIdsNeedingHydration.size > 0\n ? requestContainerContentsRemoteHydration(input)\n : (state.remoteHydrationPromise ?? undefined);\n };\n return activeHydration.then(\n requestQueuedHydration,\n (error: unknown) => requestQueuedHydration() ?? Promise.reject(error),\n );\n}\n\nfunction waitForActiveInitialization(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeInitialization = state.initializePromise;\n if (!activeInitialization) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n return activeInitialization.then(() => {\n const recoveryInput = isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ? input\n : createResetRecoveryInput(input);\n return resumeRetainedRecoveryHydration(recoveryInput);\n });\n}\n\nfunction retryRemoteHydrationAfterReset(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n // The reconnect state machine owns its retry across a reset.\n if (input.reconnect) {\n // A superseded crawl still owes the manual refresh whose reset it consumed.\n // Complete that request under the live store's own generation guard.\n if (\n !input.ownsTreeReset?.() ||\n input.state.runtime.liveHydrationStatus?.() === \"retired\"\n )\n return Promise.resolve();\n input = { ...input, reconnect: undefined };\n }\n return resumeRetainedRecoveryHydration(createResetRecoveryInput(input));\n}\n\nfunction retainResetRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): void {\n queueRecoveryHydrationRequest(createResetRecoveryInput(input));\n}\n\nexport function resumeContainerContentsRecoveryHydration(\n state: RemoteHydrationRequestState,\n): Promise<void> | null {\n const recovery =\n recoveryHydrationByState.get(state) ?? IDLE_RECOVERY_HYDRATION;\n if (recovery.status === \"idle\") return null;\n // Another caller already took this caller's queued request over.\n if (recovery.status === \"running\") return recovery.run;\n const inputs = recovery.requests.map((request) =>\n isRequestGenerationCurrent({\n lifecycleGeneration: request.lifecycleGeneration,\n state,\n structuralGeneration: request.structuralGeneration,\n })\n ? request.input\n : createResetRecoveryInput(request.input),\n );\n let resolveRun: () => void = () => undefined;\n let rejectRun: (error: unknown) => void = () => undefined;\n const run = new Promise<void>((resolve, reject) => {\n resolveRun = resolve;\n rejectRun = reject;\n });\n // The run is current before its requests start, so a request one of them\n // queues meanwhile waits for the next resume instead of being dropped.\n dispatchRecoveryHydration(state, { run, type: \"started\" });\n const settle = () =>\n dispatchRecoveryHydration(state, { run, type: \"settled\" });\n run.then(settle, settle);\n const fail = (error: unknown) => {\n for (const input of inputs) {\n queueRecoveryHydrationRequest(input);\n }\n rejectRun(error);\n };\n try {\n Promise.all(inputs.map(requestContainerContentsRemoteHydration)).then(\n () => resolveRun(),\n fail,\n );\n } catch (error) {\n fail(error);\n }\n return run;\n}\n\nfunction queueRequestedParentIds(input: RemoteHydrationRequestInput): void {\n if (!input.parentIds) {\n return;\n }\n for (const parentId of input.parentIds) {\n input.state.containerParentIdsNeedingHydration.add(parentId);\n }\n}\n\nfunction waitForRemoteHydrationReadiness(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const activeHydration = waitForActiveRemoteHydration(input);\n if (activeHydration) {\n return activeHydration;\n }\n const activeInitialization = waitForActiveInitialization(input);\n if (activeInitialization) {\n return activeInitialization;\n }\n if (!hasRemoteHydrationPrerequisites(input.state)) {\n queueRecoveryHydrationRequest(input);\n return Promise.resolve();\n }\n return null;\n}\n\nfunction consumeQueuedHydrationScope(\n state: RemoteHydrationRequestState,\n followDiscoveredParentLanesOption: boolean | undefined,\n): {\n followDiscoveredParentLanes: boolean;\n parentIds: ReadonlyArray<string | null> | undefined;\n} {\n const queuedParentIds = Array.from(state.containerParentIdsNeedingHydration);\n const followDiscoveredParentLanes =\n followDiscoveredParentLanesOption ?? queuedParentIds.length === 0;\n state.containerParentIdsNeedingHydration.clear();\n return {\n followDiscoveredParentLanes,\n parentIds:\n followDiscoveredParentLanes || queuedParentIds.length === 0\n ? undefined\n : queuedParentIds,\n };\n}\n\nfunction ownsHydrationRequest(input: RemoteHydrationRequestInput): boolean {\n return (\n ownsContainerStore(input.state) &&\n input.ownsTreeReset?.() !== false &&\n input.reconnect?.isCurrent() !== false\n );\n}\n\nfunction captureHydrationScope(\n input: RemoteHydrationRequestInput,\n): () => boolean {\n const { state } = input;\n const { lifecycleGeneration, structuralGeneration } = state;\n return () =>\n ownsHydrationRequest(input) &&\n isRequestGenerationCurrent({\n state,\n lifecycleGeneration,\n structuralGeneration,\n });\n}\n\nfunction bindManualTreeReset(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n if (\n !input.resetAllLaneWatermarks ||\n input.ownsTreeReset ||\n input.onFullyHydrated ||\n input.recreateOnFullyHydratedAfterReset\n )\n return input;\n return { ...input, ownsTreeReset: captureTreeResetOwner(input.state) };\n}\n\nexport function requestContainerContentsRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n const { host, scheduleSync, state } = input;\n input = bindManualTreeReset(input);\n if (!ownsHydrationRequest(input)) return Promise.resolve();\n queueRequestedParentIds(input);\n const readinessBarrier = waitForRemoteHydrationReadiness(input);\n if (readinessBarrier) {\n return readinessBarrier;\n }\n\n input = prepareTreeReset(input);\n const { followDiscoveredParentLanes, parentIds } =\n consumeQueuedHydrationScope(state, input.followDiscoveredParentLanes);\n\n let appliedRemoteContainerChange = false;\n let retainInterruptedHydration = false;\n const { lifecycleGeneration, structuralGeneration } = state;\n const isCurrent = captureHydrationScope(input);\n const onFullyHydrated = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n const hydrationHost = createGenerationGuardedHydrationHost({\n host,\n isCurrent,\n });\n const rootLaneHydratedBeforeRequest = state.rootLaneHydrated;\n state.remoteHydrationGeneration = lifecycleGeneration;\n state.remoteHydrationStructuralGeneration = structuralGeneration;\n const hydrationPromise = refreshLocalContainerStates({\n host: hydrationHost,\n stillCurrent: input.reconnect?.isCurrent,\n state,\n })\n .then(() => {\n if (!isCurrent()) {\n return 0;\n }\n return hydrateRemoteContainers({\n followDiscoveredParentLanes,\n host: hydrationHost,\n isCurrent,\n onFullyHydrated,\n reconnect: input.reconnect,\n parentIds,\n resetAllLaneWatermarks: input.resetAllLaneWatermarks,\n resetRootLaneWatermark: input.resetRootLaneWatermark,\n state,\n });\n })\n .then((changedCount) => {\n appliedRemoteContainerChange = changedCount > 0;\n if (isCurrent() && !hasRemoteHydrationPrerequisites(state)) {\n retainInterruptedHydration = true;\n }\n })\n .catch((error: unknown) => {\n if (isCurrent() && isDatabaseUnavailableError(error)) {\n retainInterruptedHydration = true;\n return;\n }\n if (!isCurrent() || error instanceof StaleRemoteHydrationError) {\n return;\n }\n\n throw error;\n })\n .finally(() => {\n const shouldRetryAfterReset = !isCurrent();\n if (state.remoteHydrationPromise === hydrationPromise) {\n state.remoteHydrationPromise = null;\n state.remoteHydrationGeneration = null;\n state.remoteHydrationStructuralGeneration = null;\n }\n\n if (\n isCurrent() &&\n (((input.scheduleSyncOnHydrationChange ?? true) &&\n (appliedRemoteContainerChange ||\n (!rootLaneHydratedBeforeRequest && state.rootLaneHydrated))) ||\n input.scheduleSyncAfterHydration) &&\n state.snapshot.ready &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n ) {\n scheduleSync();\n }\n if (shouldRetryAfterReset) {\n return retryRemoteHydrationAfterReset(input);\n }\n if (retainInterruptedHydration) {\n retainResetRecoveryHydration(input);\n }\n return undefined;\n });\n state.remoteHydrationPromise = hydrationPromise;\n\n return hydrationPromise;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteHydrationRequest.js","sourceRoot":"","sources":["remoteHydrationRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EAGvB,yBAAyB,GAC1B,MAAM,uDAAuD,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAEL,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,uBAAuB,EAGvB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC;AA6C5B,SAAS,0BAA0B,CAAC,KAInC;IACC,OAAO,CACL,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,KAAK,CAAC,KAAK,CAAC,mBAAmB,KAAK,KAAK,CAAC,mBAAmB;QAC7D,KAAK,CAAC,KAAK,CAAC,oBAAoB,KAAK,KAAK,CAAC,oBAAoB,CAChE,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAGzC,CAAC;AAEJ,SAAS,yBAAyB,CAChC,KAAkC,EAClC,KAAuD;IAEvD,MAAM,IAAI,GAAG,2BAA2B,CACtC,wBAAwB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,uBAAuB,EAC9D,KAAK,CACN,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B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ACD,YAAY,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO,8BAA8B,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,0BAA0B,EAAE,CAAC;YAC/B,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;IACL,KAAK,CAAC,sBAAsB,GAAG,gBAAgB,CAAC;IAChD,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["import {\n createGenerationGuardedHydrationHost,\n hydrateRemoteContainers,\n type ReconnectCrawl,\n type RemoteContainerHydrationHost,\n StaleRemoteHydrationError,\n} from \"../../../workflows/container-contents/remoteHydration\";\nimport type { RemoteContainerHydrationState } from \"../../../workflows/container-contents/remoteHydration/types\";\nimport { isDatabaseUnavailableError } from \"../../../workflows/container-contents/syncLane\";\nimport { ownsContainerStore } from \"../containerState/storeScope\";\nimport {\n type LocalContainerRefreshState,\n refreshLocalContainerStates,\n} from \"../localRefresh\";\nimport {\n IDLE_RECOVERY_HYDRATION,\n type RecoveryHydrationEvent,\n type RecoveryHydrationState,\n transitionRecoveryHydration,\n} from \"./recoveryHydrationMachine\";\n\nimport {\n captureTreeResetOwner,\n claimTreeReset,\n queueTreeReset,\n} from \"./treeResetMachine\";\n\ntype RemoteHydrationRequestState = RemoteContainerHydrationState &\n LocalContainerRefreshState & {\n containerParentIdsNeedingHydration: Set<string | null>;\n initializePromise: Promise<void> | null;\n lifecycleGeneration: number;\n remoteHydrationGeneration: number | null;\n remoteHydrationPromise: Promise<void> | null;\n remoteHydrationStructuralGeneration: number | null;\n rootLaneHydrated: boolean;\n snapshot: {\n ready: boolean;\n };\n structuralGeneration: number;\n trackHydration?: (request: Promise<unknown>) => void;\n writeGeneration?: number;\n };\n\ninterface RemoteHydrationRequestInput {\n ownsTreeReset?: () => boolean;\n followDiscoveredParentLanes?: boolean | undefined;\n host: RemoteContainerHydrationHost;\n reconnect?: ReconnectCrawl | undefined;\n onFullyHydrated?: (() => Promise<void> | void) | undefined;\n parentIds?: ReadonlyArray<string | null> | undefined;\n resetAllLaneWatermarks?: boolean | undefined;\n resetRootLaneWatermark?: boolean | undefined;\n recreateOnFullyHydratedAfterReset?:\n | (() => () => Promise<void> | void)\n | undefined;\n recreateOnFullyHydratedAtStart?: boolean | undefined;\n resumeRecoveryWork: () => Promise<void>;\n scheduleSyncAfterHydration?: boolean | undefined;\n scheduleSyncOnHydrationChange?: boolean | undefined;\n scheduleSync: () => void;\n state: RemoteHydrationRequestState;\n}\n\ninterface RecoveryHydrationRequest {\n input: RemoteHydrationRequestInput;\n lifecycleGeneration: number;\n structuralGeneration: number;\n}\n\nfunction isRequestGenerationCurrent(input: {\n lifecycleGeneration: number;\n state: RemoteHydrationRequestState;\n structuralGeneration: number;\n}): boolean {\n return (\n ownsContainerStore(input.state) &&\n input.state.lifecycleGeneration === input.lifecycleGeneration &&\n input.state.structuralGeneration === input.structuralGeneration\n );\n}\n\nconst recoveryHydrationByState = new WeakMap<\n RemoteHydrationRequestState,\n RecoveryHydrationState<RecoveryHydrationRequest>\n>();\n\nfunction dispatchRecoveryHydration(\n state: RemoteHydrationRequestState,\n event: RecoveryHydrationEvent<RecoveryHydrationRequest>,\n): void {\n const next = transitionRecoveryHydration(\n recoveryHydrationByState.get(state) ?? IDLE_RECOVERY_HYDRATION,\n event,\n );\n if (next.status === \"idle\") {\n recoveryHydrationByState.delete(state);\n } else {\n recoveryHydrationByState.set(state, next);\n }\n}\n\nfunction queueRecoveryHydrationRequest(\n input: RemoteHydrationRequestInput,\n): void {\n dispatchRecoveryHydration(input.state, {\n request: {\n input,\n lifecycleGeneration: input.state.lifecycleGeneration,\n structuralGeneration: input.state.structuralGeneration,\n },\n type: \"queued\",\n });\n}\n\nfunction hasRemoteHydrationPrerequisites(\n state: RemoteHydrationRequestState,\n): boolean {\n return (\n (state.runtime.liveHydrationStatus?.() ?? \"ready\") === \"ready\" &&\n state.runtime.infra.dbStatus === \"ready\" &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n );\n}\n\nfunction createResetRecoveryInput(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n return {\n ...input,\n followDiscoveredParentLanes: true,\n onFullyHydrated: undefined,\n parentIds: undefined,\n recreateOnFullyHydratedAtStart: true,\n };\n}\n\nfunction resumeRetainedRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n if (!ownsHydrationRequest(input)) return Promise.resolve();\n queueRecoveryHydrationRequest(input);\n return hasRemoteHydrationPrerequisites(input.state)\n ? input.resumeRecoveryWork()\n : Promise.resolve();\n}\n\nfunction prepareTreeReset(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n const coverReset = claimTreeReset(\n input.state,\n !!input.reconnect || !!input.resetAllLaneWatermarks,\n );\n if (!coverReset) return input;\n const onCovered = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n return {\n ...input,\n followDiscoveredParentLanes: true,\n resetAllLaneWatermarks: true,\n recreateOnFullyHydratedAtStart: false,\n ownsTreeReset: coverReset.isOwned,\n onFullyHydrated: () => {\n coverReset.cover();\n return onCovered?.();\n },\n };\n}\n\nfunction waitForActiveRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeHydration = state.remoteHydrationPromise;\n if (!activeHydration) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n const needsCurrentGenerationHydration =\n state.remoteHydrationGeneration !== state.lifecycleGeneration ||\n state.remoteHydrationStructuralGeneration !== state.structuralGeneration;\n // A restoration owns its sweep callback and its sync scheduling policy.\n // Let it list after prior work settles so its durable claim can complete.\n const needsOwnCrawl =\n !!(input.onFullyHydrated || input.recreateOnFullyHydratedAfterReset) &&\n !!input.resetAllLaneWatermarks &&\n !!input.followDiscoveredParentLanes;\n if (\n !needsOwnCrawl &&\n input.resetAllLaneWatermarks &&\n input.followDiscoveredParentLanes\n ) {\n input = { ...input, ownsTreeReset: queueTreeReset(state) };\n }\n const requestQueuedHydration = () => {\n if (\n !isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ) {\n return retryRemoteHydrationAfterReset(input);\n }\n // Another request's crawl may have taken over this request's queued\n // lanes. Settle with that crawl rather than at once, so the request never\n // resolves before the listing that covers it.\n return needsOwnCrawl ||\n needsCurrentGenerationHydration ||\n state.containerParentIdsNeedingHydration.size > 0\n ? requestContainerContentsRemoteHydration(input)\n : (state.remoteHydrationPromise ?? undefined);\n };\n return activeHydration.then(\n requestQueuedHydration,\n (error: unknown) => requestQueuedHydration() ?? Promise.reject(error),\n );\n}\n\nfunction waitForActiveInitialization(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const { state } = input;\n const activeInitialization = state.initializePromise;\n if (!activeInitialization) {\n return null;\n }\n const requestLifecycleGeneration = state.lifecycleGeneration;\n const requestStructuralGeneration = state.structuralGeneration;\n return activeInitialization.then(() => {\n const recoveryInput = isRequestGenerationCurrent({\n lifecycleGeneration: requestLifecycleGeneration,\n state,\n structuralGeneration: requestStructuralGeneration,\n })\n ? input\n : createResetRecoveryInput(input);\n return resumeRetainedRecoveryHydration(recoveryInput);\n });\n}\n\nfunction retryRemoteHydrationAfterReset(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n // The reconnect state machine owns its retry across a reset.\n if (input.reconnect) {\n // A superseded crawl still owes the manual refresh whose reset it consumed.\n // Complete that request under the live store's own generation guard.\n if (\n !input.ownsTreeReset?.() ||\n input.state.runtime.liveHydrationStatus?.() === \"retired\"\n )\n return Promise.resolve();\n input = { ...input, reconnect: undefined };\n }\n return resumeRetainedRecoveryHydration(createResetRecoveryInput(input));\n}\n\nfunction retainResetRecoveryHydration(\n input: RemoteHydrationRequestInput,\n): void {\n queueRecoveryHydrationRequest(createResetRecoveryInput(input));\n}\n\nexport function resumeContainerContentsRecoveryHydration(\n state: RemoteHydrationRequestState,\n): Promise<void> | null {\n const recovery =\n recoveryHydrationByState.get(state) ?? IDLE_RECOVERY_HYDRATION;\n if (recovery.status === \"idle\") return null;\n // Another caller already took this caller's queued request over.\n if (recovery.status === \"running\") return recovery.run;\n const inputs = recovery.requests.map((request) =>\n isRequestGenerationCurrent({\n lifecycleGeneration: request.lifecycleGeneration,\n state,\n structuralGeneration: request.structuralGeneration,\n })\n ? request.input\n : createResetRecoveryInput(request.input),\n );\n let resolveRun: () => void = () => undefined;\n let rejectRun: (error: unknown) => void = () => undefined;\n const run = new Promise<void>((resolve, reject) => {\n resolveRun = resolve;\n rejectRun = reject;\n });\n // The run is current before its requests start, so a request one of them\n // queues meanwhile waits for the next resume instead of being dropped.\n dispatchRecoveryHydration(state, { run, type: \"started\" });\n const settle = () =>\n dispatchRecoveryHydration(state, { run, type: \"settled\" });\n run.then(settle, settle);\n const fail = (error: unknown) => {\n for (const input of inputs) {\n queueRecoveryHydrationRequest(input);\n }\n rejectRun(error);\n };\n try {\n Promise.all(inputs.map(requestContainerContentsRemoteHydration)).then(\n () => resolveRun(),\n fail,\n );\n } catch (error) {\n fail(error);\n }\n return run;\n}\n\nfunction queueRequestedParentIds(input: RemoteHydrationRequestInput): void {\n if (!input.parentIds) {\n return;\n }\n for (const parentId of input.parentIds) {\n input.state.containerParentIdsNeedingHydration.add(parentId);\n }\n}\n\nfunction waitForRemoteHydrationReadiness(\n input: RemoteHydrationRequestInput,\n): Promise<void> | null {\n const activeHydration = waitForActiveRemoteHydration(input);\n if (activeHydration) {\n return activeHydration;\n }\n const activeInitialization = waitForActiveInitialization(input);\n if (activeInitialization) {\n return activeInitialization;\n }\n if (!hasRemoteHydrationPrerequisites(input.state)) {\n queueRecoveryHydrationRequest(input);\n return Promise.resolve();\n }\n return null;\n}\n\nfunction consumeQueuedHydrationScope(\n state: RemoteHydrationRequestState,\n followDiscoveredParentLanesOption: boolean | undefined,\n): {\n followDiscoveredParentLanes: boolean;\n parentIds: ReadonlyArray<string | null> | undefined;\n} {\n const queuedParentIds = Array.from(state.containerParentIdsNeedingHydration);\n const followDiscoveredParentLanes =\n followDiscoveredParentLanesOption ?? queuedParentIds.length === 0;\n state.containerParentIdsNeedingHydration.clear();\n return {\n followDiscoveredParentLanes,\n parentIds:\n followDiscoveredParentLanes || queuedParentIds.length === 0\n ? undefined\n : queuedParentIds,\n };\n}\n\nfunction ownsHydrationRequest(input: RemoteHydrationRequestInput): boolean {\n return (\n ownsContainerStore(input.state) &&\n input.ownsTreeReset?.() !== false &&\n input.reconnect?.isCurrent() !== false\n );\n}\n\nfunction captureHydrationScope(\n input: RemoteHydrationRequestInput,\n): () => boolean {\n const { state } = input;\n const { lifecycleGeneration, structuralGeneration } = state;\n return () =>\n ownsHydrationRequest(input) &&\n isRequestGenerationCurrent({\n state,\n lifecycleGeneration,\n structuralGeneration,\n });\n}\n\nfunction bindManualTreeReset(\n input: RemoteHydrationRequestInput,\n): RemoteHydrationRequestInput {\n if (\n !input.resetAllLaneWatermarks ||\n input.ownsTreeReset ||\n input.onFullyHydrated ||\n input.recreateOnFullyHydratedAfterReset\n )\n return input;\n return { ...input, ownsTreeReset: captureTreeResetOwner(input.state) };\n}\n\nexport function requestContainerContentsRemoteHydration(\n input: RemoteHydrationRequestInput,\n): Promise<void> {\n input = bindManualTreeReset(input);\n if (!ownsHydrationRequest(input)) return Promise.resolve();\n queueRequestedParentIds(input);\n const readinessBarrier = waitForRemoteHydrationReadiness(input);\n const request = readinessBarrier ?? startHydration(prepareTreeReset(input));\n input.state.trackHydration?.(request);\n return request;\n}\n\nfunction startHydration(input: RemoteHydrationRequestInput): Promise<void> {\n const { host, scheduleSync, state } = input;\n const { followDiscoveredParentLanes, parentIds } =\n consumeQueuedHydrationScope(state, input.followDiscoveredParentLanes);\n\n let appliedRemoteContainerChange = false;\n let retainInterruptedHydration = false;\n const { lifecycleGeneration, structuralGeneration } = state;\n const isCurrent = captureHydrationScope(input);\n const onFullyHydrated = input.recreateOnFullyHydratedAtStart\n ? input.recreateOnFullyHydratedAfterReset?.()\n : input.onFullyHydrated;\n const hydrationHost = createGenerationGuardedHydrationHost({\n host,\n isCurrent,\n });\n const rootLaneHydratedBeforeRequest = state.rootLaneHydrated;\n state.remoteHydrationGeneration = lifecycleGeneration;\n state.remoteHydrationStructuralGeneration = structuralGeneration;\n const hydrationPromise = refreshLocalContainerStates({\n host: hydrationHost,\n stillCurrent: input.reconnect?.isCurrent,\n state,\n })\n .then(() => {\n if (!isCurrent()) {\n return 0;\n }\n return hydrateRemoteContainers({\n followDiscoveredParentLanes,\n host: hydrationHost,\n isCurrent,\n onFullyHydrated,\n reconnect: input.reconnect,\n parentIds,\n resetAllLaneWatermarks: input.resetAllLaneWatermarks,\n resetRootLaneWatermark: input.resetRootLaneWatermark,\n state,\n });\n })\n .then((changedCount) => {\n appliedRemoteContainerChange = changedCount > 0;\n if (isCurrent() && !hasRemoteHydrationPrerequisites(state)) {\n retainInterruptedHydration = true;\n }\n })\n .catch((error: unknown) => {\n if (isCurrent() && isDatabaseUnavailableError(error)) {\n retainInterruptedHydration = true;\n return;\n }\n if (!isCurrent() || error instanceof StaleRemoteHydrationError) {\n return;\n }\n\n throw error;\n })\n .finally(() => {\n const shouldRetryAfterReset = !isCurrent();\n if (state.remoteHydrationPromise === hydrationPromise) {\n state.remoteHydrationPromise = null;\n state.remoteHydrationGeneration = null;\n state.remoteHydrationStructuralGeneration = null;\n }\n\n if (\n isCurrent() &&\n (((input.scheduleSyncOnHydrationChange ?? true) &&\n (appliedRemoteContainerChange ||\n (!rootLaneHydratedBeforeRequest && state.rootLaneHydrated))) ||\n input.scheduleSyncAfterHydration) &&\n state.snapshot.ready &&\n state.runtime.auth.isAuthenticated &&\n state.runtime.state.online\n ) {\n scheduleSync();\n }\n if (shouldRetryAfterReset) {\n return retryRemoteHydrationAfterReset(input);\n }\n if (retainInterruptedHydration) {\n retainResetRecoveryHydration(input);\n }\n return undefined;\n });\n state.remoteHydrationPromise = hydrationPromise;\n return hydrationPromise;\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ownsContainerStore } from "../containerState/storeScope.js";
|
|
2
|
+
/** Publish background reads separately from the local snapshot used by writers. */
|
|
3
|
+
export function trackContainerHydration(state) {
|
|
4
|
+
let generation = state.lifecycleGeneration;
|
|
5
|
+
let pending = new Set();
|
|
6
|
+
return (request) => {
|
|
7
|
+
if (generation !== state.lifecycleGeneration) {
|
|
8
|
+
generation = state.lifecycleGeneration;
|
|
9
|
+
pending = new Set();
|
|
10
|
+
}
|
|
11
|
+
if (pending.has(request))
|
|
12
|
+
return;
|
|
13
|
+
pending.add(request);
|
|
14
|
+
const requests = pending;
|
|
15
|
+
const owner = generation;
|
|
16
|
+
const finish = () => {
|
|
17
|
+
requests.delete(request);
|
|
18
|
+
if (requests.size > 0 ||
|
|
19
|
+
state.lifecycleGeneration !== owner ||
|
|
20
|
+
!ownsContainerStore(state))
|
|
21
|
+
return;
|
|
22
|
+
const { hydrating: _finished, ...snapshot } = state.snapshot;
|
|
23
|
+
state.snapshot = snapshot;
|
|
24
|
+
for (const notify of state.listeners)
|
|
25
|
+
notify();
|
|
26
|
+
};
|
|
27
|
+
void request.then(finish, finish);
|
|
28
|
+
if (!state.snapshot.hydrating) {
|
|
29
|
+
state.snapshot = { ...state.snapshot, hydrating: true };
|
|
30
|
+
for (const notify of state.listeners)
|
|
31
|
+
notify();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=trackContainerHydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackContainerHydration.js","sourceRoot":"","sources":["trackContainerHydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGlE,mFAAmF;AACnF,MAAM,UAAU,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AAM,EAAE,CAAC;QACjD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { ownsContainerStore } from \"../containerState/storeScope\";\nimport type { ContainerContentsStoreState } from \"../types\";\n\n/** Publish background reads separately from the local snapshot used by writers. */\nexport function trackContainerHydration(state: ContainerContentsStoreState) {\n let generation = state.lifecycleGeneration;\n let pending = new Set<Promise<unknown>>();\n return (request: Promise<unknown>) => {\n if (generation !== state.lifecycleGeneration) {\n generation = state.lifecycleGeneration;\n pending = new Set();\n }\n if (pending.has(request)) return;\n pending.add(request);\n const requests = pending;\n const owner = generation;\n const finish = () => {\n requests.delete(request);\n if (\n requests.size > 0 ||\n state.lifecycleGeneration !== owner ||\n !ownsContainerStore(state)\n )\n return;\n const { hydrating: _finished, ...snapshot } = state.snapshot;\n state.snapshot = snapshot;\n for (const notify of state.listeners) notify();\n };\n void request.then(finish, finish);\n if (!state.snapshot.hydrating) {\n state.snapshot = { ...state.snapshot, hydrating: true };\n for (const notify of state.listeners) notify();\n }\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canWriteEffectiveAccessLevel } from "../../../data/keying/accessLevel.js";
|
|
1
2
|
import { createChildContainerState } from "../../../workflows/container-contents/container-state/create/createChild.js";
|
|
2
3
|
import { deleteContainerState } from "../../../workflows/container-contents/container-state/delete.js";
|
|
3
4
|
import { assertLocalChildPathFits, assertLocalMovePathFits, } from "../../../workflows/container-contents/container-state/localPathDepth.js";
|
|
@@ -270,6 +271,9 @@ export async function moveContainer(state, syncAgent, containerId, parentId, isC
|
|
|
270
271
|
if (existingState.container.parentId === parentId) {
|
|
271
272
|
return toContainerNode(existingState);
|
|
272
273
|
}
|
|
274
|
+
if (existingState.container.effectiveAccessLevel !== "admin" ||
|
|
275
|
+
!canWriteEffectiveAccessLevel(targetParentState.container.effectiveAccessLevel))
|
|
276
|
+
return null;
|
|
273
277
|
assertLocalMovePathFits(state.containersById, containerId, parentId);
|
|
274
278
|
const isRemoteContainer = Boolean(existingState.record.documentId);
|
|
275
279
|
const saveOptions = isRemoteContainer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AACrH,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EACL,8BAA8B,EAC9B,uCAAuC,GACxC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EACL,+BAA+B,EAC/B,oCAAoC,GACrC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AAK3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,yCAAyC,EAAE,MAAM,yDAAyD,CAAC;AACpH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EACL,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,oCAAoC,EAAE,MAAM,8CAA8C,CAAC;AAKpG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAkC,EAClC,SAA0C,EAC1C,QAAgB,EAChB,IAAY,EACZ,YAAiC,GAAG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AO,eAAe,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { ContainerSystemSlot } from \"@tearleads/validators/containerSystemSlot\";\nimport { createChildContainerState } from \"../../../workflows/container-contents/container-state/create/createChild\";\nimport { deleteContainerState } from \"../../../workflows/container-contents/container-state/delete\";\nimport {\n assertLocalChildPathFits,\n assertLocalMovePathFits,\n} from \"../../../workflows/container-contents/container-state/localPathDepth\";\nimport {\n installContainerMetadataRecord,\n renameContainerMetadataStateFromRuntime,\n} from \"../../../workflows/container-contents/metadata\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../../workflows/container-contents/metadata/metadataStateIsolation\";\nimport { persistContainerState } from \"../containerState/containerStatePersistence\";\nimport { removeMissingContainerState } from \"../containerState/missingContainerState\";\nimport { getContainerContentsStoreLogLabel } from \"../logLabel\";\nimport {\n invalidateRemoteContainerWrites,\n invalidateRemoteSystemContainerWrite,\n} from \"../remoteWrites/remoteWriteGuards\";\nimport type { ContainerWriteGuard } from \"../remoteWrites/writeGeneration\";\nimport { updateContainerContentsSnapshot } from \"../state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"../syncAgent\";\nimport { updateExistingSystemContainer } from \"../systemContainers/existingSystemContainer\";\nimport { ensureOrganizationMetadataSystemContainer } from \"../systemContainers/organizationMetadataSystemContainer\";\nimport { createSystemContainer } from \"../systemContainers/systemContainerCreate\";\nimport { probeExistingSystemContainer } from \"../systemContainers/systemContainerHydration\";\nimport {\n findRootContainerState,\n findSystemContainerStateForRoot,\n} from \"../systemContainers/systemContainerLookup\";\nimport { hasAdvancedManagedPrincipalReference } from \"../systemContainers/systemContainerPromotion\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"../types\";\nimport { isContainerInSubtree, toContainerNode } from \"../utils\";\n\nexport async function createChildContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n parentId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const parentState = state.containersById.get(parentId);\n if (!parentState) {\n return null;\n }\n assertLocalChildPathFits(state.containersById, parentId);\n\n const created = await createChildContainerState({\n createRemote: false,\n name: trimmedName,\n parentState,\n persistence: state.persistence,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!created || !isCurrent()) return null;\n\n state.containersById.set(\n created.containerState.container.id,\n created.containerState,\n );\n updateContainerContentsSnapshot(state);\n if (created.shouldRequestSync) {\n syncAgent.scheduleSync();\n }\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: created container \"${trimmedName}\"`,\n );\n return toContainerNode(created.containerState);\n}\n\nfunction canEnsureSystemContainer(\n state: ContainerContentsStoreState,\n name: string,\n): boolean {\n return (\n state.runtime.infra.dbStatus === \"ready\" && state.snapshot.ready && !!name\n );\n}\n\nasync function findOrHydrateSystemContainer(input: {\n isCurrent: ContainerWriteGuard;\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n systemSlot: ContainerSystemSlot;\n}): Promise<ContainerState | null> {\n const { isCurrent, state, syncAgent, systemSlot } = input;\n const existing = findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (\n existing ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n return existing;\n }\n await probeExistingSystemContainer({\n logLabel: getContainerContentsStoreLogLabel(state),\n rootState: findRootContainerState(state),\n state,\n syncAgent,\n systemSlot,\n });\n return isCurrent()\n ? findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n )\n : null;\n}\n\nfunction canCreateSystemContainer(\n state: ContainerContentsStoreState,\n rootState: ContainerState,\n systemSlot: ContainerSystemSlot,\n options: EnsureSystemContainerOptions,\n): boolean {\n if (\n options.skipAdvancedManagedRoot &&\n hasAdvancedManagedPrincipalReference(rootState)\n ) {\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: skipped background system container \"${systemSlot}\" because the root has advanced managed-principal references`,\n );\n return false;\n }\n\n return true;\n}\n\nexport async function ensureSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n name: string,\n options: EnsureSystemContainerOptions = {},\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (!canEnsureSystemContainer(state, trimmedName)) {\n return null;\n }\n\n const metadata = await ensureOrganizationMetadataSystemContainer({\n state,\n syncAgent,\n systemSlot,\n options,\n isCurrent,\n });\n if (!isCurrent()) return null;\n if (metadata.handled) return metadata.container;\n\n return ensureChildSystemContainer(\n state,\n syncAgent,\n systemSlot,\n trimmedName,\n options,\n isCurrent,\n );\n}\n\nasync function ensureChildSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n trimmedName: string,\n options: EnsureSystemContainerOptions,\n isCurrent: ContainerWriteGuard,\n) {\n const allowSynchronousRemoteBootstrap = !options.deferRemoteBootstrap;\n const existing = allowSynchronousRemoteBootstrap\n ? await findOrHydrateSystemContainer({\n isCurrent,\n state,\n syncAgent,\n systemSlot,\n })\n : findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (!isCurrent()) return null;\n if (existing) {\n return updateExistingSystemContainer(\n state,\n syncAgent,\n existing,\n options,\n isCurrent,\n );\n }\n\n const rootState = findRootContainerState(state);\n if (!rootState) {\n return null;\n }\n if (!canCreateSystemContainer(state, rootState, systemSlot, options))\n return null;\n\n if (options.deferRemoteBootstrap) {\n invalidateRemoteSystemContainerWrite(\n state,\n rootState.container.id,\n systemSlot,\n );\n invalidateRemoteContainerWrites(state, [rootState.container.id]);\n }\n const createRemote =\n allowSynchronousRemoteBootstrap &&\n state.runtime.auth.isAuthenticated &&\n Boolean(state.runtime.crypto.encapsulationKeyPair);\n const finalized = await createSystemContainer({\n createRemote,\n isCurrent,\n options,\n rootState,\n state,\n syncAgent,\n systemSlot,\n trimmedName,\n });\n if (!finalized || !isCurrent()) return null;\n if (\n finalized.adopted &&\n !(await updateExistingSystemContainer(\n state,\n syncAgent,\n finalized.containerState,\n options,\n isCurrent,\n ))\n )\n return null;\n return toContainerNode(finalized.containerState);\n}\n\ntype ContainerStateEntry = NonNullable<\n ReturnType<ContainerContentsStoreState[\"containersById\"][\"get\"]>\n>;\n\n/** A leaf, non-root, non-system container this device may delete now. */\nfunction deletableContainerState(\n state: ContainerContentsStoreState,\n containerId: string,\n): ContainerStateEntry | null {\n const existingState = state.containersById.get(containerId);\n if (\n !existingState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n Array.from(state.containersById.values()).some(\n (containerState) => containerState.container.parentId === containerId,\n )\n ) {\n return null;\n }\n const isRemoteContainer = Boolean(existingState.record.documentId);\n if (\n isRemoteContainer &&\n (!state.runtime.auth.isAuthenticated || !state.runtime.state.online)\n ) {\n return null;\n }\n return existingState;\n}\n\n/**\n * The delete committed before this operation lost its generation. Evict only\n * the exact state it deleted: a concurrent replacement with the same id owns a\n * different object and must survive.\n */\nfunction evictSupersededDeletedState(\n state: ContainerContentsStoreState,\n existingState: ContainerStateEntry,\n): void {\n if (state.containersById.get(existingState.container.id) !== existingState) {\n return;\n }\n state.containersById.delete(existingState.container.id);\n state.documentStoresNeedPriming = true;\n if (state.initialized) {\n updateContainerContentsSnapshot(state);\n }\n}\n\nexport async function deleteContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = deletableContainerState(state, containerId);\n if (!existingState) {\n return null;\n }\n const isRemoteContainer = Boolean(existingState.record.documentId);\n\n const deletedNode = toContainerNode(existingState);\n const deleted = await deleteContainerState({\n containerState: existingState,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (deleted === \"remote-failed\") {\n return null;\n }\n if (\n deleted === \"local-conflict\" ||\n deleted === \"remote-deleted\" ||\n !isCurrent()\n ) {\n state.localContainersNeedRefresh = true;\n await syncAgent.refreshLocalContainers();\n if (deleted === \"deleted\") {\n evictSupersededDeletedState(state, existingState);\n }\n if (isRemoteContainer) {\n await syncAgent.requestRemoteHydration({\n followDiscoveredParentLanes: false,\n parentIds: [existingState.container.parentId],\n resetAllLaneWatermarks: true,\n });\n }\n return null;\n }\n\n state.containersById.delete(existingState.container.id);\n // The persistence cascade may have orphaned descendant documents (row 3);\n // re-arm document priming and nudge the lane so their null-scoped passes\n // run now rather than on the next unrelated trigger.\n state.documentStoresNeedPriming = true;\n syncAgent.scheduleSync();\n updateContainerContentsSnapshot(state);\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: deleted container \"${existingState.container.name}\"`,\n );\n return deletedNode;\n}\n\nexport async function renameContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n if (!existingState) {\n return null;\n }\n\n if (existingState.container.name === trimmedName) {\n return toContainerNode(existingState);\n }\n\n const detachedState =\n await createDetachedContainerMetadataState(existingState);\n if (!isCurrent()) return null;\n const renamed = await renameContainerMetadataStateFromRuntime({\n metadataState: detachedState,\n name: trimmedName,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!isCurrent()) return null;\n if (!renamed) {\n removeMissingContainerState(state, existingState);\n return null;\n }\n\n detachedState.container = renamed.container;\n installContainerMetadataRecord(detachedState, renamed.record);\n installDetachedContainerMetadataState(existingState, detachedState);\n updateContainerContentsSnapshot(state);\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: renamed container to \"${trimmedName}\"`,\n );\n return toContainerNode(existingState);\n}\n\nexport async function moveContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n parentId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n const targetParentState = state.containersById.get(parentId);\n if (\n !existingState ||\n !targetParentState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n isContainerInSubtree(state.containersById, parentId, containerId)\n ) {\n return null;\n }\n\n if (existingState.container.parentId === parentId) {\n return toContainerNode(existingState);\n }\n assertLocalMovePathFits(state.containersById, containerId, parentId);\n\n const isRemoteContainer = Boolean(existingState.record.documentId);\n const saveOptions = isRemoteContainer\n ? {\n moveIntent: {\n parentContainerId: parentId,\n previousParentContainerId: existingState.container.parentId,\n },\n }\n : { createIntent: { parentContainerId: parentId } };\n const persisted = await persistContainerState(state, existingState, {\n patch: { parentId },\n saveOptions,\n isCurrent,\n });\n if (persisted.status !== \"persisted\" || !isCurrent()) return null;\n syncAgent.scheduleSync();\n const action = isRemoteContainer\n ? \"queued container move\"\n : \"moved container\";\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${action} ${containerId} under ${parentId}`,\n );\n return toContainerNode(existingState);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAC;AACrH,OAAO,EAAE,oBAAoB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from \"@tearleads/validators/containerSystemSlot\";\nimport { canWriteEffectiveAccessLevel } from \"../../../data/keying/accessLevel\";\nimport { createChildContainerState } from \"../../../workflows/container-contents/container-state/create/createChild\";\nimport { deleteContainerState } from \"../../../workflows/container-contents/container-state/delete\";\nimport {\n assertLocalChildPathFits,\n assertLocalMovePathFits,\n} from \"../../../workflows/container-contents/container-state/localPathDepth\";\nimport {\n installContainerMetadataRecord,\n renameContainerMetadataStateFromRuntime,\n} from \"../../../workflows/container-contents/metadata\";\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../../workflows/container-contents/metadata/metadataStateIsolation\";\nimport { persistContainerState } from \"../containerState/containerStatePersistence\";\nimport { removeMissingContainerState } from \"../containerState/missingContainerState\";\nimport { getContainerContentsStoreLogLabel } from \"../logLabel\";\nimport {\n invalidateRemoteContainerWrites,\n invalidateRemoteSystemContainerWrite,\n} from \"../remoteWrites/remoteWriteGuards\";\nimport type { ContainerWriteGuard } from \"../remoteWrites/writeGeneration\";\nimport { updateContainerContentsSnapshot } from \"../state\";\nimport type {\n ContainerContentsStoreSyncAgent,\n ContainerState,\n} from \"../syncAgent\";\nimport { updateExistingSystemContainer } from \"../systemContainers/existingSystemContainer\";\nimport { ensureOrganizationMetadataSystemContainer } from \"../systemContainers/organizationMetadataSystemContainer\";\nimport { createSystemContainer } from \"../systemContainers/systemContainerCreate\";\nimport { probeExistingSystemContainer } from \"../systemContainers/systemContainerHydration\";\nimport {\n findRootContainerState,\n findSystemContainerStateForRoot,\n} from \"../systemContainers/systemContainerLookup\";\nimport { hasAdvancedManagedPrincipalReference } from \"../systemContainers/systemContainerPromotion\";\nimport type {\n ContainerContentsStoreState,\n EnsureSystemContainerOptions,\n} from \"../types\";\nimport { isContainerInSubtree, toContainerNode } from \"../utils\";\n\nexport async function createChildContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n parentId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const parentState = state.containersById.get(parentId);\n if (!parentState) {\n return null;\n }\n assertLocalChildPathFits(state.containersById, parentId);\n\n const created = await createChildContainerState({\n createRemote: false,\n name: trimmedName,\n parentState,\n persistence: state.persistence,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!created || !isCurrent()) return null;\n\n state.containersById.set(\n created.containerState.container.id,\n created.containerState,\n );\n updateContainerContentsSnapshot(state);\n if (created.shouldRequestSync) {\n syncAgent.scheduleSync();\n }\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: created container \"${trimmedName}\"`,\n );\n return toContainerNode(created.containerState);\n}\n\nfunction canEnsureSystemContainer(\n state: ContainerContentsStoreState,\n name: string,\n): boolean {\n return (\n state.runtime.infra.dbStatus === \"ready\" && state.snapshot.ready && !!name\n );\n}\n\nasync function findOrHydrateSystemContainer(input: {\n isCurrent: ContainerWriteGuard;\n state: ContainerContentsStoreState;\n syncAgent: ContainerContentsStoreSyncAgent;\n systemSlot: ContainerSystemSlot;\n}): Promise<ContainerState | null> {\n const { isCurrent, state, syncAgent, systemSlot } = input;\n const existing = findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (\n existing ||\n !state.runtime.auth.isAuthenticated ||\n !state.runtime.state.online\n ) {\n return existing;\n }\n await probeExistingSystemContainer({\n logLabel: getContainerContentsStoreLogLabel(state),\n rootState: findRootContainerState(state),\n state,\n syncAgent,\n systemSlot,\n });\n return isCurrent()\n ? findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n )\n : null;\n}\n\nfunction canCreateSystemContainer(\n state: ContainerContentsStoreState,\n rootState: ContainerState,\n systemSlot: ContainerSystemSlot,\n options: EnsureSystemContainerOptions,\n): boolean {\n if (\n options.skipAdvancedManagedRoot &&\n hasAdvancedManagedPrincipalReference(rootState)\n ) {\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: skipped background system container \"${systemSlot}\" because the root has advanced managed-principal references`,\n );\n return false;\n }\n\n return true;\n}\n\nexport async function ensureSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n name: string,\n options: EnsureSystemContainerOptions = {},\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (!canEnsureSystemContainer(state, trimmedName)) {\n return null;\n }\n\n const metadata = await ensureOrganizationMetadataSystemContainer({\n state,\n syncAgent,\n systemSlot,\n options,\n isCurrent,\n });\n if (!isCurrent()) return null;\n if (metadata.handled) return metadata.container;\n\n return ensureChildSystemContainer(\n state,\n syncAgent,\n systemSlot,\n trimmedName,\n options,\n isCurrent,\n );\n}\n\nasync function ensureChildSystemContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n systemSlot: ContainerSystemSlot,\n trimmedName: string,\n options: EnsureSystemContainerOptions,\n isCurrent: ContainerWriteGuard,\n) {\n const allowSynchronousRemoteBootstrap = !options.deferRemoteBootstrap;\n const existing = allowSynchronousRemoteBootstrap\n ? await findOrHydrateSystemContainer({\n isCurrent,\n state,\n syncAgent,\n systemSlot,\n })\n : findSystemContainerStateForRoot(\n state,\n systemSlot,\n findRootContainerState(state),\n );\n if (!isCurrent()) return null;\n if (existing) {\n return updateExistingSystemContainer(\n state,\n syncAgent,\n existing,\n options,\n isCurrent,\n );\n }\n\n const rootState = findRootContainerState(state);\n if (!rootState) {\n return null;\n }\n if (!canCreateSystemContainer(state, rootState, systemSlot, options))\n return null;\n\n if (options.deferRemoteBootstrap) {\n invalidateRemoteSystemContainerWrite(\n state,\n rootState.container.id,\n systemSlot,\n );\n invalidateRemoteContainerWrites(state, [rootState.container.id]);\n }\n const createRemote =\n allowSynchronousRemoteBootstrap &&\n state.runtime.auth.isAuthenticated &&\n Boolean(state.runtime.crypto.encapsulationKeyPair);\n const finalized = await createSystemContainer({\n createRemote,\n isCurrent,\n options,\n rootState,\n state,\n syncAgent,\n systemSlot,\n trimmedName,\n });\n if (!finalized || !isCurrent()) return null;\n if (\n finalized.adopted &&\n !(await updateExistingSystemContainer(\n state,\n syncAgent,\n finalized.containerState,\n options,\n isCurrent,\n ))\n )\n return null;\n return toContainerNode(finalized.containerState);\n}\n\ntype ContainerStateEntry = NonNullable<\n ReturnType<ContainerContentsStoreState[\"containersById\"][\"get\"]>\n>;\n\n/** A leaf, non-root, non-system container this device may delete now. */\nfunction deletableContainerState(\n state: ContainerContentsStoreState,\n containerId: string,\n): ContainerStateEntry | null {\n const existingState = state.containersById.get(containerId);\n if (\n !existingState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n Array.from(state.containersById.values()).some(\n (containerState) => containerState.container.parentId === containerId,\n )\n ) {\n return null;\n }\n const isRemoteContainer = Boolean(existingState.record.documentId);\n if (\n isRemoteContainer &&\n (!state.runtime.auth.isAuthenticated || !state.runtime.state.online)\n ) {\n return null;\n }\n return existingState;\n}\n\n/**\n * The delete committed before this operation lost its generation. Evict only\n * the exact state it deleted: a concurrent replacement with the same id owns a\n * different object and must survive.\n */\nfunction evictSupersededDeletedState(\n state: ContainerContentsStoreState,\n existingState: ContainerStateEntry,\n): void {\n if (state.containersById.get(existingState.container.id) !== existingState) {\n return;\n }\n state.containersById.delete(existingState.container.id);\n state.documentStoresNeedPriming = true;\n if (state.initialized) {\n updateContainerContentsSnapshot(state);\n }\n}\n\nexport async function deleteContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = deletableContainerState(state, containerId);\n if (!existingState) {\n return null;\n }\n const isRemoteContainer = Boolean(existingState.record.documentId);\n\n const deletedNode = toContainerNode(existingState);\n const deleted = await deleteContainerState({\n containerState: existingState,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (deleted === \"remote-failed\") {\n return null;\n }\n if (\n deleted === \"local-conflict\" ||\n deleted === \"remote-deleted\" ||\n !isCurrent()\n ) {\n state.localContainersNeedRefresh = true;\n await syncAgent.refreshLocalContainers();\n if (deleted === \"deleted\") {\n evictSupersededDeletedState(state, existingState);\n }\n if (isRemoteContainer) {\n await syncAgent.requestRemoteHydration({\n followDiscoveredParentLanes: false,\n parentIds: [existingState.container.parentId],\n resetAllLaneWatermarks: true,\n });\n }\n return null;\n }\n\n state.containersById.delete(existingState.container.id);\n // The persistence cascade may have orphaned descendant documents (row 3);\n // re-arm document priming and nudge the lane so their null-scoped passes\n // run now rather than on the next unrelated trigger.\n state.documentStoresNeedPriming = true;\n syncAgent.scheduleSync();\n updateContainerContentsSnapshot(state);\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: deleted container \"${existingState.container.name}\"`,\n );\n return deletedNode;\n}\n\nexport async function renameContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n name: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n const trimmedName = name.trim();\n if (\n state.runtime.infra.dbStatus !== \"ready\" ||\n !state.snapshot.ready ||\n !trimmedName\n ) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n if (!existingState) {\n return null;\n }\n\n if (existingState.container.name === trimmedName) {\n return toContainerNode(existingState);\n }\n\n const detachedState =\n await createDetachedContainerMetadataState(existingState);\n if (!isCurrent()) return null;\n const renamed = await renameContainerMetadataStateFromRuntime({\n metadataState: detachedState,\n name: trimmedName,\n persistence: state.persistence,\n runtime: state.runtime,\n stillCurrent: isCurrent,\n });\n if (!isCurrent()) return null;\n if (!renamed) {\n removeMissingContainerState(state, existingState);\n return null;\n }\n\n detachedState.container = renamed.container;\n installContainerMetadataRecord(detachedState, renamed.record);\n installDetachedContainerMetadataState(existingState, detachedState);\n updateContainerContentsSnapshot(state);\n syncAgent.scheduleSync();\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: renamed container to \"${trimmedName}\"`,\n );\n return toContainerNode(existingState);\n}\n\nexport async function moveContainer(\n state: ContainerContentsStoreState,\n syncAgent: ContainerContentsStoreSyncAgent,\n containerId: string,\n parentId: string,\n isCurrent: ContainerWriteGuard = () => true,\n) {\n if (state.runtime.infra.dbStatus !== \"ready\" || !state.snapshot.ready) {\n return null;\n }\n\n const existingState = state.containersById.get(containerId);\n const targetParentState = state.containersById.get(parentId);\n if (\n !existingState ||\n !targetParentState ||\n existingState.container.parentId === null ||\n (existingState.container.systemSlot ?? null) !== null ||\n isContainerInSubtree(state.containersById, parentId, containerId)\n ) {\n return null;\n }\n\n if (existingState.container.parentId === parentId) {\n return toContainerNode(existingState);\n }\n if (\n existingState.container.effectiveAccessLevel !== \"admin\" ||\n !canWriteEffectiveAccessLevel(\n targetParentState.container.effectiveAccessLevel,\n )\n )\n return null;\n assertLocalMovePathFits(state.containersById, containerId, parentId);\n\n const isRemoteContainer = Boolean(existingState.record.documentId);\n const saveOptions = isRemoteContainer\n ? {\n moveIntent: {\n parentContainerId: parentId,\n previousParentContainerId: existingState.container.parentId,\n },\n }\n : { createIntent: { parentContainerId: parentId } };\n const persisted = await persistContainerState(state, existingState, {\n patch: { parentId },\n saveOptions,\n isCurrent,\n });\n if (persisted.status !== \"persisted\" || !isCurrent()) return null;\n syncAgent.scheduleSync();\n const action = isRemoteContainer\n ? \"queued container move\"\n : \"moved container\";\n state.runtime.util.log(\n `${getContainerContentsStoreLogLabel(state)}: ${action} ${containerId} under ${parentId}`,\n );\n return toContainerNode(existingState);\n}\n"]}
|