@tearleads/client-sdk 0.1.254 → 0.1.255

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -1
  3. package/index.js.map +1 -1
  4. package/internal/validators/containerSystemSlot.d.ts +6 -0
  5. package/internal/validators/containerSystemSlot.js +14 -6
  6. package/internal/validators/containerSystemSlot.js.map +1 -1
  7. package/package.json +1 -1
  8. package/stores/container-contents/operations/index.js +4 -0
  9. package/stores/container-contents/operations/index.js.map +1 -1
  10. package/workflows/container-contents/container-state/create/createChild.d.ts +30 -0
  11. package/workflows/container-contents/container-state/move/moveIntentSync.js +1 -0
  12. package/workflows/container-contents/container-state/move/moveIntentSync.js.map +1 -1
  13. package/workflows/container-contents/container-state/remote.js +1 -1
  14. package/workflows/container-contents/container-state/remote.js.map +1 -1
  15. package/workflows/container-contents/container-state/types.d.ts +141 -0
  16. package/workflows/container-contents/index.d.ts +1 -0
  17. package/workflows/container-contents/index.js +1 -0
  18. package/workflows/container-contents/index.js.map +1 -1
  19. package/workflows/container-contents/remoteHydration/destination/destinationSystemTopology.js +16 -0
  20. package/workflows/container-contents/remoteHydration/destination/destinationSystemTopology.js.map +1 -0
  21. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js +8 -9
  22. package/workflows/container-contents/remoteHydration/destination/verifiedDestination.js.map +1 -1
  23. package/workflows/registration/bootstrapRootContainer.d.ts +1 -0
  24. package/workflows/registration/bootstrapRootContainer.js +9 -0
  25. package/workflows/registration/bootstrapRootContainer.js.map +1 -1
  26. package/workflows/registration/index.d.ts +1 -1
  27. package/workflows/registration/index.js +1 -1
  28. package/workflows/registration/index.js.map +1 -1
  29. package/workflows/registration/organizationProvisioning.d.ts +3 -2
  30. package/workflows/registration/organizationProvisioning.js +1 -2
  31. package/workflows/registration/organizationProvisioning.js.map +1 -1
  32. package/workflows/registration/provisioningBootstrapBuilders.d.ts +3 -5
  33. package/workflows/registration/provisioningBootstrapBuilders.js +11 -5
  34. package/workflows/registration/provisioningBootstrapBuilders.js.map +1 -1
  35. package/workflows/registration/registerIdentity.js +2 -0
  36. 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,EAClB,2CAA2C,EAC3C,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,yBAAyB,EACzB,QAAQ,EACR,mBAAmB,EAKnB,8BAA8B,EAC9B,2BAA2B,EAC3B,MAAM,EAGN,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,mCAAmC,EACnC,6BAA6B,EAC7B,oBAAoB,EACpB,OAAO,EACP,0BAA0B,EAG1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B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B,8BAA8B,EAC9B,uCAAuC,EACvC,iCAAiC,EACjC,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,gCAAgC,EAChC,6BAA6B,EAC7B,sBAAsB,EACtB,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AAYnC,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACrC,kCAAkC,EAClC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAelC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAyB7B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,gCAAgC,EAChC,mCAAmC,EACnC,yBAAyB,EACzB,gCAAgC,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 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,EAClC,kBAAkB,EAClB,2CAA2C,EAC3C,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,yBAAyB,EACzB,QAAQ,EACR,mBAAmB,EAKnB,8BAA8B,EAC9B,2BAA2B,EAC3B,MAAM,EAGN,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,mCAAmC,EACnC,6BAA6B,EAC7B,oBAAoB,EACpB,OAAO,EACP,0BAA0B,EAG1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA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A2B,EAC3B,8BAA8B,EAC9B,uCAAuC,EACvC,iCAAiC,EACjC,2BAA2B,EAC3B,8BAA8B,EAC9B,mCAAmC,EACnC,gCAAgC,EAChC,6BAA6B,EAC7B,sBAAsB,EACtB,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AAYnC,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACrC,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAelC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAyB7B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,gCAAgC,EAChC,mCAAmC,EACnC,yBAAyB,EACzB,gCAAgC,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
- async function deriveOrganizationSystemSlot(input) {
15
- const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify({
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 Uint8Array(digest));
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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AAC,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,UAAU,kDAAkD,CAAC,KAElE;IACC,OAAO,4BAA4B,CAAC;QAClC,SAAS,EAAE,wCAAwC;QACnD,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,6CAA6C,CAAC,KAE7D;IACC,OAAO,4BAA4B,CAAC;QAClC,SAAS,EAAE,iCAAiC;QAC5C,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { 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\nasync function deriveOrganizationSystemSlot(input: {\n readonly namespace: string;\n readonly organizationId: string;\n}): Promise<ContainerSystemSlot> {\n const digest = await crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(\n JSON.stringify({\n namespace: input.namespace,\n organizationId: input.organizationId,\n version: 1,\n }),\n ),\n );\n return formatContainerSystemSlot(new Uint8Array(digest));\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 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 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"]}
1
+ {"version":3,"file":"containerSystemSlot.js","sourceRoot":"","sources":["containerSystemSlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,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,CAA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,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tearleads/client-sdk",
3
- "version": "0.1.254",
3
+ "version": "0.1.255",
4
4
  "description": "React-free Tearleads client runtime: local SQLite persistence, keys, sync, encrypted blobs, and domain workflows.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -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,O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IAED,IAAI,aAAa,CAAC,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;IACD,uBAAuB,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAErE,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC;YACE,UAAU,EAAE;gBACV,iBAAiB,EAAE,QAAQ;gBAC3B,yBAAyB,EAAE,aAAa,CAAC,SAAS,CAAC,QAAQ;aAC5D;SACF;QACH,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE;QAClE,KAAK,EAAE,EAAE,QAAQ,EAAE;QACnB,WAAW;QACX,SAAS;KACV,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,IAAI,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,iBAAiB;QAC9B,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,iBAAiB,CAAC;IACtB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,MAAM,IAAI,WAAW,UAAU,QAAQ,EAAE,CAC1F,CAAC;IACF,OAAO,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,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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AAC,oBAAoB,CACjD;QAED,OAAO,IAAI,CAAC;IACd,uBAAuB,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAErE,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC;YACE,UAAU,EAAE;gBACV,iBAAiB,EAAE,QAAQ;gBAC3B,yBAAyB,EAAE,aAAa,CAAC,SAAS,CAAC,QAAQ;aAC5D;SACF;QACH,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,CAAC;IACtD,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE;QAClE,KAAK,EAAE,EAAE,QAAQ,EAAE;QACnB,WAAW;QACX,SAAS;KACV,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,IAAI,CAAC;IAClE,SAAS,CAAC,YAAY,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,iBAAiB;QAC9B,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,iBAAiB,CAAC;IACtB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CACpB,GAAG,iCAAiC,CAAC,KAAK,CAAC,KAAK,MAAM,IAAI,WAAW,UAAU,QAAQ,EAAE,CAC1F,CAAC;IACF,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { ContainerSystemSlot } 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"]}
@@ -0,0 +1,30 @@
1
+ import type { ContainerSystemSlot } from "../../../../internal/validators/containerSystemSlot.js";
2
+ import type { ProjectionUserKeyResolver } from "../../../../data/keyingProjectionVerification/index.js";
3
+ import type { ContainerContentsPersistence } from "../../containerPersistence.js";
4
+ import type { ContainerState } from "../../remoteHydration/index.js";
5
+ import type { ContainerWorkflowRuntime, CreatedChildContainerState } from "../types.js";
6
+ /**
7
+ * Derives a stable, UUID-shaped container id for a built-in system slot.
8
+ *
9
+ * The namespace digest makes each slot idempotent across stale store snapshots.
10
+ * The UUID version and variant bits are normalized to a v4 shape because remote
11
+ * container APIs currently validate container ids with the same v4 UUID contract
12
+ * they use for random user-created containers.
13
+ */
14
+ export declare function deriveSystemContainerId(input: {
15
+ parentContainerId: string;
16
+ systemSlot: ContainerSystemSlot;
17
+ }): Promise<string>;
18
+ export declare function createChildContainerState(input: {
19
+ systemSlot?: ContainerSystemSlot | null | undefined;
20
+ createRemote: boolean;
21
+ icon?: string | null | undefined;
22
+ locallyAcceptedMetadataUpdateIds?: Set<string> | undefined;
23
+ name: string;
24
+ parentState: ContainerState;
25
+ persistence: ContainerContentsPersistence;
26
+ queueRemoteSync?: boolean | undefined;
27
+ resolveProjectionUserKey: ProjectionUserKeyResolver;
28
+ runtime: ContainerWorkflowRuntime;
29
+ stillCurrent?: (() => boolean) | undefined;
30
+ }): Promise<CreatedChildContainerState | null>;
@@ -211,6 +211,7 @@ async function movePendingRemoteContainer(input) {
211
211
  try {
212
212
  const replayed = await moveRemoteContainer({
213
213
  containerId: intent.containerId,
214
+ organizationId: containerState.container.organizationId,
214
215
  onAccepted: () => {
215
216
  remoteMoveApplied = true;
216
217
  },
@@ -1 +1 @@
1
- {"version":3,"file":"moveIntentSync.js","sourceRoot":"","sources":["moveIntentSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AAEpG,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOhD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,0BAA0B,CAA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YAC1B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;YAC9C,MAAM;YACN,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;YAC9D,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,KAAK;SACN,CAAC,CAAC;QACH,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;YAC3B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,UAAU,IAAI,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,mEAAmE;YACnE,8BAA8B;YAC9B,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { ContainerPathTooDeepError } from \"../../../../data/containers/shared/containerPathLimits\";\nimport { errorMessage } from \"../../../../data/shared/errorMessage\";\nimport { reportAndRethrowKeyingVerificationError } from \"../../../../data/shared/securityIncidents\";\n\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../metadata/metadataStateIsolation\";\nimport type { ContainerState, RemoteContainer } from \"../../remoteHydration\";\nimport { hasRemoteContainerMetadataState } from \"../../remoteHydration/reconciliation\";\nimport { moveRemoteContainer } from \"../remote\";\nimport type {\n AcceptedMoveRetry,\n ContainerMoveIntentSyncHost,\n ContainerMoveIntentSyncInput,\n ContainerMoveIntentSyncState,\n} from \"../types\";\nimport {\n appliedRemoteContainer,\n leaveAcceptedMoveQueued,\n STALE_ACCEPTED_MOVE,\n unacknowledgedAcceptedMove,\n unpersistedAcceptedMove,\n} from \"./acceptedMoveSettlement\";\nimport { settleRefusedContainerMove } from \"./moveIntentRefusal\";\n\ntype MoveIntentSyncResult = \"abandoned\" | \"blocked\" | \"failed\" | \"moved\";\n\nfunction currentMoveResult<\n Result extends Exclude<MoveIntentSyncResult, \"abandoned\">,\n>(isCurrent: () => boolean, result: Result): \"abandoned\" | Result {\n return isCurrent() ? result : \"abandoned\";\n}\n\nasync function recordPendingMoveIntentError(input: {\n blocked?: boolean | undefined;\n containerId: string;\n expectedIntentId: string;\n expectedUpdatedAt: string;\n isCurrent: () => boolean;\n message: string;\n state: ContainerMoveIntentSyncState;\n}): Promise<boolean> {\n if (!input.isCurrent()) {\n return false;\n }\n const execSql = input.state.runtime.infra.execSql;\n await input.state.persistence.recordMoveIntentError(execSql, {\n blocked: input.blocked,\n containerId: input.containerId,\n expectedIntentId: input.expectedIntentId,\n expectedUpdatedAt: input.expectedUpdatedAt,\n message: input.message,\n stillCurrent: input.isCurrent,\n });\n return input.isCurrent();\n}\n\nasync function resolveMoveIntentLocalUpdatedAt(input: {\n containerId: string;\n isCurrent: () => boolean;\n remoteUpdatedAt: string;\n state: ContainerMoveIntentSyncState;\n}): Promise<string | null> {\n if (!input.isCurrent()) {\n return null;\n }\n const previousLocalUpdatedAt =\n input.state.containersById.get(input.containerId)?.container\n .localUpdatedAt ?? null;\n if (\n !previousLocalUpdatedAt ||\n previousLocalUpdatedAt.localeCompare(input.remoteUpdatedAt) <= 0\n ) {\n return input.remoteUpdatedAt;\n }\n\n const execSql = input.state.runtime.infra.execSql;\n const containersWithPendingMetadataUpdates =\n await input.state.persistence.listContainerIdsWithPendingUpdates(execSql, [\n input.containerId,\n ]);\n if (!input.isCurrent()) {\n return null;\n }\n\n return containersWithPendingMetadataUpdates.includes(input.containerId)\n ? previousLocalUpdatedAt\n : input.remoteUpdatedAt;\n}\n\nexport async function persistAcceptedMoveIntent(input: {\n host: ContainerMoveIntentSyncHost;\n isCurrent: () => boolean;\n intent: ContainerMoveIntentSyncInput[\"intent\"];\n moved: RemoteContainer;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n state: ContainerMoveIntentSyncState;\n}): Promise<boolean> {\n const { host, intent, moved, state } = input;\n const abandon = () => {\n input.requestRemoteReconciliation(moved.parentId);\n return false;\n };\n if (!input.isCurrent()) return abandon();\n const containerState = state.containersById.get(intent.containerId);\n if (!containerState) {\n return false;\n }\n\n await state.runtime.principalPolicies.createWarmer()({\n organizationId: moved.organizationId,\n references: moved.metadataReferencedPrincipals,\n stillCurrent: input.isCurrent,\n });\n if (!input.isCurrent()) {\n return abandon();\n }\n const localUpdatedAt = await resolveMoveIntentLocalUpdatedAt({\n containerId: intent.containerId,\n isCurrent: input.isCurrent,\n remoteUpdatedAt: moved.updatedAt,\n state,\n });\n if (!input.isCurrent() || localUpdatedAt === null) {\n return abandon();\n }\n const persistenceCandidate =\n await createDetachedContainerMetadataState(containerState);\n if (!input.isCurrent()) {\n return abandon();\n }\n persistenceCandidate.container = {\n ...persistenceCandidate.container,\n createdAt: moved.createdAt,\n serverCreatedAt: moved.createdAt,\n serverUpdatedAt: moved.updatedAt,\n updatedAt: moved.updatedAt,\n };\n const persistenceResult = await host.persistContainerState(\n persistenceCandidate,\n {\n accessEpoch: moved.metadataAccessEpoch,\n accessStateHash: moved.metadataAccessStateHash,\n documentId: moved.metadataDocumentId,\n metadataDocumentId: moved.metadataDocumentId,\n organizationId: moved.organizationId,\n parentId: moved.parentId,\n systemSlot: moved.systemSlot ?? null,\n },\n false,\n {\n localUpdatedAt,\n serverTimestamps: {\n createdAt: moved.createdAt,\n updatedAt: moved.updatedAt,\n },\n },\n {\n expectedStateWhenMissing: containerState,\n isCurrent: input.isCurrent,\n moveIntentSettlement: {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n },\n },\n );\n if (!input.isCurrent() || persistenceResult.status !== \"persisted\") {\n return abandon();\n }\n if (persistenceResult.moveIntentSettled !== true) {\n throw new Error(\n \"Container move persistence must settle the intent atomically\",\n );\n }\n if (!input.isCurrent()) return abandon();\n const { record: nextRecord } = persistenceResult;\n installDetachedContainerMetadataState(containerState, persistenceCandidate, {\n candidateRecord: nextRecord,\n preserveConcurrentMetadataEdit: true,\n });\n containerState.container = {\n ...containerState.container,\n metadataDocumentId: moved.metadataDocumentId,\n organizationId: moved.organizationId,\n parentId: moved.parentId,\n };\n return true;\n}\n\n/**\n * A move refused for path length never succeeds; the queue-time check saw only\n * the descendants this device holds. Drop the queued move and restore the\n * previous parent together: the server row never changed, so no listing would\n * ever put the folder back.\n */\nasync function abandonTooDeepMove(\n syncInput: ContainerMoveIntentSyncInput,\n): Promise<MoveIntentSyncResult> {\n const { host, intent, state } = syncInput;\n const previousParentId = intent.previousParentContainerId;\n if (previousParentId === null) {\n throw new Error(\"A queued container move must name its previous parent\");\n }\n const abandoned = await state.persistence.abandonMoveIntentRevision(\n state.runtime.infra.execSql,\n {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n previousParentContainerId: previousParentId,\n stillCurrent: syncInput.isCurrent,\n },\n );\n if (!syncInput.isCurrent()) return \"abandoned\";\n // A newer local move superseded this revision; it replays on its own.\n if (!abandoned) return \"failed\";\n const containerState = state.containersById.get(intent.containerId);\n if (containerState) {\n containerState.container = {\n ...containerState.container,\n parentId: previousParentId,\n };\n }\n host.updateSnapshot();\n state.runtime.util.log(\n `Container contents: abandoned queued move of ${intent.containerId}; its path would exceed the maximum depth`,\n );\n return \"failed\";\n}\n\n/** A replay that threw: refused for depth, tampered, or left unsettled. */\nasync function failedMoveReplay(input: {\n abandonAppliedMove: () => \"abandoned\";\n error: unknown;\n parentState: ContainerState;\n remoteMoveApplied: boolean;\n syncInput: ContainerMoveIntentSyncInput;\n}): Promise<MoveIntentSyncResult> {\n const {\n abandonAppliedMove,\n error,\n parentState,\n remoteMoveApplied,\n syncInput,\n } = input;\n const { intent, state } = syncInput;\n if (!syncInput.isCurrent()) {\n return abandonAppliedMove();\n }\n if (error instanceof ContainerPathTooDeepError)\n return abandonTooDeepMove(syncInput);\n // Even a refused acknowledgement leaves the move on the server; its replay\n // verifies the head again before settling.\n if (remoteMoveApplied && error instanceof Error)\n leaveAcceptedMoveQueued(\n syncInput,\n \"Container contents: an accepted container move failed to settle\",\n error,\n );\n await reportAndRethrowKeyingVerificationError(\n error,\n state.runtime.util.reportSecurityIncident,\n {\n objectId: intent.containerId,\n objectKind: \"container\",\n operation: \"container.move.replay\",\n organizationId: parentState.container.organizationId,\n },\n );\n if (!syncInput.isCurrent()) {\n return abandonAppliedMove();\n }\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: syncInput.isCurrent,\n message: `Failed to sync container move: ${errorMessage(error)}`,\n state,\n });\n return currentMoveResult(syncInput.isCurrent, \"failed\");\n}\n\nasync function movePendingRemoteContainer(input: {\n containerState: ContainerState;\n parentState: ContainerState;\n syncInput: ContainerMoveIntentSyncInput;\n}): Promise<MoveIntentSyncResult> {\n const { containerState, parentState, syncInput } = input;\n const { host, intent, state } = syncInput;\n let remoteMoveApplied = false;\n let remoteParentId: string | null = intent.parentContainerId;\n const abandonAppliedMove = () => {\n if (remoteMoveApplied) {\n leaveAcceptedMoveQueued(\n syncInput,\n STALE_ACCEPTED_MOVE,\n new Error(\"Stale pass dropped an accepted container move\"),\n );\n syncInput.requestRemoteReconciliation(remoteParentId);\n }\n return \"abandoned\" as const;\n };\n try {\n const replayed = await moveRemoteContainer({\n containerId: intent.containerId,\n onAccepted: () => {\n remoteMoveApplied = true;\n },\n parentContainerId: intent.parentContainerId,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: syncInput.isCurrent,\n });\n if (!replayed) {\n if (!syncInput.isCurrent()) {\n if (!remoteMoveApplied)\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return abandonAppliedMove();\n }\n if (remoteMoveApplied) return unacknowledgedAcceptedMove(syncInput);\n const { organizationId } = containerState.container;\n return currentMoveResult(\n syncInput.isCurrent,\n await settleRefusedContainerMove(syncInput, organizationId),\n );\n }\n remoteMoveApplied = true;\n const moved =\n \"applied\" in replayed\n ? appliedRemoteContainer(containerState, replayed.applied)\n : replayed.moved;\n remoteParentId = moved.parentId;\n if (!syncInput.isCurrent()) return abandonAppliedMove();\n\n const persisted = await persistAcceptedMoveIntent({\n host,\n isCurrent: syncInput.isCurrent,\n intent,\n moved,\n requestRemoteReconciliation: syncInput.requestRemoteReconciliation,\n state,\n });\n if (!persisted) return unpersistedAcceptedMove(syncInput);\n state.runtime.util.log(\n \"applied\" in replayed\n ? `Container contents: settled queued container move ${intent.containerId} the server already held`\n : `Container contents: synced queued container move ${intent.containerId}`,\n );\n return \"moved\";\n } catch (error: unknown) {\n return failedMoveReplay({\n abandonAppliedMove,\n error,\n parentState,\n remoteMoveApplied,\n syncInput,\n });\n }\n}\n\nasync function trySyncPendingContainerMoveIntent(\n input: ContainerMoveIntentSyncInput,\n): Promise<MoveIntentSyncResult> {\n const { intent, state } = input;\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n const containerState = state.containersById.get(intent.containerId);\n const parentState = state.containersById.get(intent.parentContainerId);\n\n if (!containerState) {\n await recordPendingMoveIntentError({\n blocked: true,\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move intent references a missing local container\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"failed\");\n }\n if (!parentState) {\n await recordPendingMoveIntentError({\n blocked: true,\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message:\n \"Container move intent references a missing destination parent container\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"failed\");\n }\n if (input.isRemoteSyncBlocked(containerState.container.organizationId)) {\n return \"blocked\";\n }\n if (\n !hasRemoteContainerMetadataState(containerState) ||\n input.isCreatePending(intent.containerId)\n ) {\n // Source not synced yet is TRANSIENT, exactly like the destination case\n // below: the source's own create intent syncs first (createIntentSync runs\n // before moveIntentSync in a pass), but if that create fails on this pass\n // the source still lacks remote metadata here. Keep the intent 'pending'\n // (not 'blocked') so the queue reports a retryable failure rather than a\n // missing-dependency block; either way listUnsyncedMoveIntents replays it\n // once the create lands.\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move source is not synced yet\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"blocked\");\n }\n if (\n !hasRemoteContainerMetadataState(parentState) ||\n input.isCreatePending(intent.parentContainerId)\n ) {\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move destination parent is not synced yet\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"blocked\");\n }\n\n return movePendingRemoteContainer({\n containerState,\n parentState,\n syncInput: input,\n });\n}\n\nexport async function syncPendingContainerMoveIntents(input: {\n host: ContainerMoveIntentSyncHost;\n isCreatePending: (containerId: string) => boolean;\n isCurrent: () => boolean;\n isRemoteSyncBlocked: (organizationId: string) => boolean;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n acceptedMoveRetry: AcceptedMoveRetry;\n state: ContainerMoveIntentSyncState;\n}): Promise<number> {\n if (!input.isCurrent()) {\n return 0;\n }\n const { host } = input;\n const state = { ...input.state };\n const execSql = state.runtime.infra.execSql;\n const pendingIntents =\n await state.persistence.listUnsyncedMoveIntents(execSql);\n if (!input.isCurrent()) {\n return 0;\n }\n let movedCount = 0;\n\n for (const intent of pendingIntents) {\n if (!input.isCurrent()) {\n return movedCount;\n }\n const result = await trySyncPendingContainerMoveIntent({\n host,\n isCurrent: input.isCurrent,\n isCreatePending: input.isCreatePending,\n isRemoteSyncBlocked: input.isRemoteSyncBlocked,\n intent,\n requestRemoteReconciliation: input.requestRemoteReconciliation,\n acceptedMoveRetry: input.acceptedMoveRetry,\n state,\n });\n if (result === \"abandoned\") {\n return movedCount;\n }\n\n if (result === \"moved\") {\n movedCount += 1;\n } else {\n // A replay that failed before reaching the server keeps an earlier\n // acceptance's retries going.\n input.acceptedMoveRetry.resume(intent.id);\n }\n }\n\n return movedCount;\n}\n"]}
1
+ {"version":3,"file":"moveIntentSync.js","sourceRoot":"","sources":["moveIntentSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wDAAwD,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AAEpG,OAAO,EACL,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOhD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAIjE,SAAS,iBAAiB,CAExB,SAAwB,EAAE,MAAc;IACxC,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,4BAA4B,CAAC,KAQ3C;IACC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;IAClD,MAAM,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,qBAAqB,CAAC,OAAO,EAAE;QAC3D,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,iBAAiB,EAA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Error } from \"../../../../data/containers/shared/containerPathLimits\";\nimport { errorMessage } from \"../../../../data/shared/errorMessage\";\nimport { reportAndRethrowKeyingVerificationError } from \"../../../../data/shared/securityIncidents\";\n\nimport {\n createDetachedContainerMetadataState,\n installDetachedContainerMetadataState,\n} from \"../../metadata/metadataStateIsolation\";\nimport type { ContainerState, RemoteContainer } from \"../../remoteHydration\";\nimport { hasRemoteContainerMetadataState } from \"../../remoteHydration/reconciliation\";\nimport { moveRemoteContainer } from \"../remote\";\nimport type {\n AcceptedMoveRetry,\n ContainerMoveIntentSyncHost,\n ContainerMoveIntentSyncInput,\n ContainerMoveIntentSyncState,\n} from \"../types\";\nimport {\n appliedRemoteContainer,\n leaveAcceptedMoveQueued,\n STALE_ACCEPTED_MOVE,\n unacknowledgedAcceptedMove,\n unpersistedAcceptedMove,\n} from \"./acceptedMoveSettlement\";\nimport { settleRefusedContainerMove } from \"./moveIntentRefusal\";\n\ntype MoveIntentSyncResult = \"abandoned\" | \"blocked\" | \"failed\" | \"moved\";\n\nfunction currentMoveResult<\n Result extends Exclude<MoveIntentSyncResult, \"abandoned\">,\n>(isCurrent: () => boolean, result: Result): \"abandoned\" | Result {\n return isCurrent() ? result : \"abandoned\";\n}\n\nasync function recordPendingMoveIntentError(input: {\n blocked?: boolean | undefined;\n containerId: string;\n expectedIntentId: string;\n expectedUpdatedAt: string;\n isCurrent: () => boolean;\n message: string;\n state: ContainerMoveIntentSyncState;\n}): Promise<boolean> {\n if (!input.isCurrent()) {\n return false;\n }\n const execSql = input.state.runtime.infra.execSql;\n await input.state.persistence.recordMoveIntentError(execSql, {\n blocked: input.blocked,\n containerId: input.containerId,\n expectedIntentId: input.expectedIntentId,\n expectedUpdatedAt: input.expectedUpdatedAt,\n message: input.message,\n stillCurrent: input.isCurrent,\n });\n return input.isCurrent();\n}\n\nasync function resolveMoveIntentLocalUpdatedAt(input: {\n containerId: string;\n isCurrent: () => boolean;\n remoteUpdatedAt: string;\n state: ContainerMoveIntentSyncState;\n}): Promise<string | null> {\n if (!input.isCurrent()) {\n return null;\n }\n const previousLocalUpdatedAt =\n input.state.containersById.get(input.containerId)?.container\n .localUpdatedAt ?? null;\n if (\n !previousLocalUpdatedAt ||\n previousLocalUpdatedAt.localeCompare(input.remoteUpdatedAt) <= 0\n ) {\n return input.remoteUpdatedAt;\n }\n\n const execSql = input.state.runtime.infra.execSql;\n const containersWithPendingMetadataUpdates =\n await input.state.persistence.listContainerIdsWithPendingUpdates(execSql, [\n input.containerId,\n ]);\n if (!input.isCurrent()) {\n return null;\n }\n\n return containersWithPendingMetadataUpdates.includes(input.containerId)\n ? previousLocalUpdatedAt\n : input.remoteUpdatedAt;\n}\n\nexport async function persistAcceptedMoveIntent(input: {\n host: ContainerMoveIntentSyncHost;\n isCurrent: () => boolean;\n intent: ContainerMoveIntentSyncInput[\"intent\"];\n moved: RemoteContainer;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n state: ContainerMoveIntentSyncState;\n}): Promise<boolean> {\n const { host, intent, moved, state } = input;\n const abandon = () => {\n input.requestRemoteReconciliation(moved.parentId);\n return false;\n };\n if (!input.isCurrent()) return abandon();\n const containerState = state.containersById.get(intent.containerId);\n if (!containerState) {\n return false;\n }\n\n await state.runtime.principalPolicies.createWarmer()({\n organizationId: moved.organizationId,\n references: moved.metadataReferencedPrincipals,\n stillCurrent: input.isCurrent,\n });\n if (!input.isCurrent()) {\n return abandon();\n }\n const localUpdatedAt = await resolveMoveIntentLocalUpdatedAt({\n containerId: intent.containerId,\n isCurrent: input.isCurrent,\n remoteUpdatedAt: moved.updatedAt,\n state,\n });\n if (!input.isCurrent() || localUpdatedAt === null) {\n return abandon();\n }\n const persistenceCandidate =\n await createDetachedContainerMetadataState(containerState);\n if (!input.isCurrent()) {\n return abandon();\n }\n persistenceCandidate.container = {\n ...persistenceCandidate.container,\n createdAt: moved.createdAt,\n serverCreatedAt: moved.createdAt,\n serverUpdatedAt: moved.updatedAt,\n updatedAt: moved.updatedAt,\n };\n const persistenceResult = await host.persistContainerState(\n persistenceCandidate,\n {\n accessEpoch: moved.metadataAccessEpoch,\n accessStateHash: moved.metadataAccessStateHash,\n documentId: moved.metadataDocumentId,\n metadataDocumentId: moved.metadataDocumentId,\n organizationId: moved.organizationId,\n parentId: moved.parentId,\n systemSlot: moved.systemSlot ?? null,\n },\n false,\n {\n localUpdatedAt,\n serverTimestamps: {\n createdAt: moved.createdAt,\n updatedAt: moved.updatedAt,\n },\n },\n {\n expectedStateWhenMissing: containerState,\n isCurrent: input.isCurrent,\n moveIntentSettlement: {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n },\n },\n );\n if (!input.isCurrent() || persistenceResult.status !== \"persisted\") {\n return abandon();\n }\n if (persistenceResult.moveIntentSettled !== true) {\n throw new Error(\n \"Container move persistence must settle the intent atomically\",\n );\n }\n if (!input.isCurrent()) return abandon();\n const { record: nextRecord } = persistenceResult;\n installDetachedContainerMetadataState(containerState, persistenceCandidate, {\n candidateRecord: nextRecord,\n preserveConcurrentMetadataEdit: true,\n });\n containerState.container = {\n ...containerState.container,\n metadataDocumentId: moved.metadataDocumentId,\n organizationId: moved.organizationId,\n parentId: moved.parentId,\n };\n return true;\n}\n\n/**\n * A move refused for path length never succeeds; the queue-time check saw only\n * the descendants this device holds. Drop the queued move and restore the\n * previous parent together: the server row never changed, so no listing would\n * ever put the folder back.\n */\nasync function abandonTooDeepMove(\n syncInput: ContainerMoveIntentSyncInput,\n): Promise<MoveIntentSyncResult> {\n const { host, intent, state } = syncInput;\n const previousParentId = intent.previousParentContainerId;\n if (previousParentId === null) {\n throw new Error(\"A queued container move must name its previous parent\");\n }\n const abandoned = await state.persistence.abandonMoveIntentRevision(\n state.runtime.infra.execSql,\n {\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n previousParentContainerId: previousParentId,\n stillCurrent: syncInput.isCurrent,\n },\n );\n if (!syncInput.isCurrent()) return \"abandoned\";\n // A newer local move superseded this revision; it replays on its own.\n if (!abandoned) return \"failed\";\n const containerState = state.containersById.get(intent.containerId);\n if (containerState) {\n containerState.container = {\n ...containerState.container,\n parentId: previousParentId,\n };\n }\n host.updateSnapshot();\n state.runtime.util.log(\n `Container contents: abandoned queued move of ${intent.containerId}; its path would exceed the maximum depth`,\n );\n return \"failed\";\n}\n\n/** A replay that threw: refused for depth, tampered, or left unsettled. */\nasync function failedMoveReplay(input: {\n abandonAppliedMove: () => \"abandoned\";\n error: unknown;\n parentState: ContainerState;\n remoteMoveApplied: boolean;\n syncInput: ContainerMoveIntentSyncInput;\n}): Promise<MoveIntentSyncResult> {\n const {\n abandonAppliedMove,\n error,\n parentState,\n remoteMoveApplied,\n syncInput,\n } = input;\n const { intent, state } = syncInput;\n if (!syncInput.isCurrent()) {\n return abandonAppliedMove();\n }\n if (error instanceof ContainerPathTooDeepError)\n return abandonTooDeepMove(syncInput);\n // Even a refused acknowledgement leaves the move on the server; its replay\n // verifies the head again before settling.\n if (remoteMoveApplied && error instanceof Error)\n leaveAcceptedMoveQueued(\n syncInput,\n \"Container contents: an accepted container move failed to settle\",\n error,\n );\n await reportAndRethrowKeyingVerificationError(\n error,\n state.runtime.util.reportSecurityIncident,\n {\n objectId: intent.containerId,\n objectKind: \"container\",\n operation: \"container.move.replay\",\n organizationId: parentState.container.organizationId,\n },\n );\n if (!syncInput.isCurrent()) {\n return abandonAppliedMove();\n }\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: syncInput.isCurrent,\n message: `Failed to sync container move: ${errorMessage(error)}`,\n state,\n });\n return currentMoveResult(syncInput.isCurrent, \"failed\");\n}\n\nasync function movePendingRemoteContainer(input: {\n containerState: ContainerState;\n parentState: ContainerState;\n syncInput: ContainerMoveIntentSyncInput;\n}): Promise<MoveIntentSyncResult> {\n const { containerState, parentState, syncInput } = input;\n const { host, intent, state } = syncInput;\n let remoteMoveApplied = false;\n let remoteParentId: string | null = intent.parentContainerId;\n const abandonAppliedMove = () => {\n if (remoteMoveApplied) {\n leaveAcceptedMoveQueued(\n syncInput,\n STALE_ACCEPTED_MOVE,\n new Error(\"Stale pass dropped an accepted container move\"),\n );\n syncInput.requestRemoteReconciliation(remoteParentId);\n }\n return \"abandoned\" as const;\n };\n try {\n const replayed = await moveRemoteContainer({\n containerId: intent.containerId,\n organizationId: containerState.container.organizationId,\n onAccepted: () => {\n remoteMoveApplied = true;\n },\n parentContainerId: intent.parentContainerId,\n resolveProjectionUserKey: state.resolveProjectionUserKey,\n runtime: state.runtime,\n stillCurrent: syncInput.isCurrent,\n });\n if (!replayed) {\n if (!syncInput.isCurrent()) {\n if (!remoteMoveApplied)\n syncInput.requestRemoteReconciliation(intent.parentContainerId);\n return abandonAppliedMove();\n }\n if (remoteMoveApplied) return unacknowledgedAcceptedMove(syncInput);\n const { organizationId } = containerState.container;\n return currentMoveResult(\n syncInput.isCurrent,\n await settleRefusedContainerMove(syncInput, organizationId),\n );\n }\n remoteMoveApplied = true;\n const moved =\n \"applied\" in replayed\n ? appliedRemoteContainer(containerState, replayed.applied)\n : replayed.moved;\n remoteParentId = moved.parentId;\n if (!syncInput.isCurrent()) return abandonAppliedMove();\n\n const persisted = await persistAcceptedMoveIntent({\n host,\n isCurrent: syncInput.isCurrent,\n intent,\n moved,\n requestRemoteReconciliation: syncInput.requestRemoteReconciliation,\n state,\n });\n if (!persisted) return unpersistedAcceptedMove(syncInput);\n state.runtime.util.log(\n \"applied\" in replayed\n ? `Container contents: settled queued container move ${intent.containerId} the server already held`\n : `Container contents: synced queued container move ${intent.containerId}`,\n );\n return \"moved\";\n } catch (error: unknown) {\n return failedMoveReplay({\n abandonAppliedMove,\n error,\n parentState,\n remoteMoveApplied,\n syncInput,\n });\n }\n}\n\nasync function trySyncPendingContainerMoveIntent(\n input: ContainerMoveIntentSyncInput,\n): Promise<MoveIntentSyncResult> {\n const { intent, state } = input;\n if (!input.isCurrent()) {\n return \"abandoned\";\n }\n const containerState = state.containersById.get(intent.containerId);\n const parentState = state.containersById.get(intent.parentContainerId);\n\n if (!containerState) {\n await recordPendingMoveIntentError({\n blocked: true,\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move intent references a missing local container\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"failed\");\n }\n if (!parentState) {\n await recordPendingMoveIntentError({\n blocked: true,\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message:\n \"Container move intent references a missing destination parent container\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"failed\");\n }\n if (input.isRemoteSyncBlocked(containerState.container.organizationId)) {\n return \"blocked\";\n }\n if (\n !hasRemoteContainerMetadataState(containerState) ||\n input.isCreatePending(intent.containerId)\n ) {\n // Source not synced yet is TRANSIENT, exactly like the destination case\n // below: the source's own create intent syncs first (createIntentSync runs\n // before moveIntentSync in a pass), but if that create fails on this pass\n // the source still lacks remote metadata here. Keep the intent 'pending'\n // (not 'blocked') so the queue reports a retryable failure rather than a\n // missing-dependency block; either way listUnsyncedMoveIntents replays it\n // once the create lands.\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move source is not synced yet\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"blocked\");\n }\n if (\n !hasRemoteContainerMetadataState(parentState) ||\n input.isCreatePending(intent.parentContainerId)\n ) {\n await recordPendingMoveIntentError({\n containerId: intent.containerId,\n expectedIntentId: intent.id,\n expectedUpdatedAt: intent.updatedAt,\n isCurrent: input.isCurrent,\n message: \"Container move destination parent is not synced yet\",\n state,\n });\n return currentMoveResult(input.isCurrent, \"blocked\");\n }\n\n return movePendingRemoteContainer({\n containerState,\n parentState,\n syncInput: input,\n });\n}\n\nexport async function syncPendingContainerMoveIntents(input: {\n host: ContainerMoveIntentSyncHost;\n isCreatePending: (containerId: string) => boolean;\n isCurrent: () => boolean;\n isRemoteSyncBlocked: (organizationId: string) => boolean;\n requestRemoteReconciliation: (parentContainerId: string | null) => void;\n acceptedMoveRetry: AcceptedMoveRetry;\n state: ContainerMoveIntentSyncState;\n}): Promise<number> {\n if (!input.isCurrent()) {\n return 0;\n }\n const { host } = input;\n const state = { ...input.state };\n const execSql = state.runtime.infra.execSql;\n const pendingIntents =\n await state.persistence.listUnsyncedMoveIntents(execSql);\n if (!input.isCurrent()) {\n return 0;\n }\n let movedCount = 0;\n\n for (const intent of pendingIntents) {\n if (!input.isCurrent()) {\n return movedCount;\n }\n const result = await trySyncPendingContainerMoveIntent({\n host,\n isCurrent: input.isCurrent,\n isCreatePending: input.isCreatePending,\n isRemoteSyncBlocked: input.isRemoteSyncBlocked,\n intent,\n requestRemoteReconciliation: input.requestRemoteReconciliation,\n acceptedMoveRetry: input.acceptedMoveRetry,\n state,\n });\n if (result === \"abandoned\") {\n return movedCount;\n }\n\n if (result === \"moved\") {\n movedCount += 1;\n } else {\n // A replay that failed before reaching the server keeps an earlier\n // acceptance's retries going.\n input.acceptedMoveRetry.resume(intent.id);\n }\n }\n\n return movedCount;\n}\n"]}
@@ -118,7 +118,7 @@ export async function moveRemoteContainer(input) {
118
118
  return null;
119
119
  }
120
120
  const replayed = await writer.containers.replayRemoteContainerMove({
121
- author: writer.author,
121
+ author: { ...writer.author, organizationId: input.organizationId },
122
122
  containerId: input.containerId,
123
123
  destinationParentContainerId: input.parentContainerId,
124
124
  onAccepted: input.onAccepted,