import type { ActorProfileDescriptor, IJobManager, ActorKind, LoadedActorProfile, ProfileLoadRequest, SubjectIndexCompositionRequest, SubjectIndexConnectionRequest, TrustedDeviceRegistrationRequest } from 'gdc-sdk-core-ts'; import type { ActorSession } from './session.js'; import type { RuntimeClient } from './orchestration/client-port.js'; import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js'; import { IndividualMemberSdk } from './orchestration/individual-member-sdk.js'; import { PersonalSdk } from './orchestration/personal-sdk.js'; import { OrganizationControllerSdk } from './orchestration/organization-controller-sdk.js'; import { ProfessionalSdk } from './orchestration/professional-sdk.js'; import type { RouteContext } from './individual-onboarding.js'; /** * Result of registering one trusted backend runtime device/profile context. * * This is intentionally backend-generic. It does not describe one concrete * channel or product flow. */ export type BackendTrustedDeviceRegistrationResult = { trustedDeviceId: string; status: 'registered' | 'already-trusted'; }; /** * Result of connecting one loaded actor profile to one subject index. */ export type BackendSubjectIndexConnectionResult = { subjectId: string; userId: string; userRoleCode: string; status: 'connected' | 'already-connected'; }; /** * Result of reading one subject index composition after the relationship is * already established. */ export type BackendSubjectIndexCompositionResult = { subjectId: string; userId: string; userRoleCode: string; composition: unknown; }; export declare const BackendSubjectIndexReadModes: Readonly<{ LatestIps: "latest-ips"; ClinicalBundle: "clinical-bundle"; }>; export type BackendSubjectIndexReadMode = typeof BackendSubjectIndexReadModes[keyof typeof BackendSubjectIndexReadModes]; /** * Backend materialization of one loaded actor profile with runtime sessions * ready to expose actor-scoped facades. */ export type BackendLoadedActorProfile = LoadedActorProfile & { actorSessions: ActorSession[]; }; export type BackendIndividualControllerProfile = { profile: BackendLoadedActorProfile; /** Loaded actor session; its `actorDid` is the operational DID to use as a direct clinical sender. */ session: ActorSession; sdk: IndividualControllerSdk; }; export type BackendPersonalProfile = { profile: BackendLoadedActorProfile; /** Loaded actor session; its `actorDid` is the operational DID to use as a direct clinical sender. */ session: ActorSession; sdk: PersonalSdk; }; export type BackendIndividualMemberProfile = { profile: BackendLoadedActorProfile; /** Loaded caregiver/member session; its `actorDid` is the operational DID for that relationship role. */ session: ActorSession; sdk: IndividualMemberSdk; }; export type BackendOrganizationControllerProfile = { profile: BackendLoadedActorProfile; session: ActorSession; sdk: OrganizationControllerSdk; }; export type BackendProfessionalProfile = { profile: BackendLoadedActorProfile; /** Loaded professional session; its `actorDid` is the operational professional DID. */ session: ActorSession; sdk: ProfessionalSdk; }; /** * Canonical backend runtime contract for loading one actor profile after * authentication and then working with trusted device registration and subject * index access. * * This surface is intentionally generic for BFF or other backend runtimes. * It does not encode one product-specific interaction channel. */ export type BackendProfileRuntimeClient = { loadProfile?: (input: ProfileLoadRequest) => Promise; closeProfile?: (profileKey: string) => Promise; registerTrustedDevice?: (input: TrustedDeviceRegistrationRequest) => Promise; connectToSubjectIndex?: (input: SubjectIndexConnectionRequest) => Promise; getSubjectIndexComposition?: (input: SubjectIndexCompositionRequest) => Promise; }; export type BackendProfileRuntimeAdapters = { loadProfile(input: ProfileLoadRequest): Promise; registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise; connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise; getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise; }; export type BackendProfileRuntimeOptions = { /** * Runtime client injected into the materialized actor sessions so backend * consumers can immediately call `asIndividualController()`, * `asProfessional()`, and the other actor-specific facades after * `loadProfile(...)`. */ facadeClient?: RuntimeClient; }; export type BackendLoadedProfileKey = string; export type DirectBackendProfileRuntimeOptions = BackendProfileRuntimeOptions & { /** * Default route context reused by the current GW CORE subject-index fallback. * * This is intentionally optional because some integrators only need * `loadProfile(...)` plus explicit actor facades first. */ defaultRouteContext?: RouteContext; /** * Current temporary CORE-facing index read helper to use when the caller asks * for one subject index composition through the profile runtime. * * Until GW CORE freezes one canonical public profile-runtime read contract, * keep this selectable instead of hardcoding one final wording. */ subjectIndexReadMode?: BackendSubjectIndexReadMode; /** * Optional override for trusted-device registration while GW CORE finalizes * the backend runtime contract for that step. */ registerTrustedDevice?: (input: TrustedDeviceRegistrationRequest) => Promise; /** * Optional override for backend subject-index connection while GW CORE * finalizes the stable contract for that step. */ connectToSubjectIndex?: (input: SubjectIndexConnectionRequest) => Promise; /** * Optional override for reading the subject index after connection. */ getSubjectIndexComposition?: (input: SubjectIndexCompositionRequest) => Promise; /** * Optional custom job-manager factory. When omitted, the backend runtime * creates one in-memory job manager so `loadProfile(...)` returns one * complete v2 profile object immediately. */ createJobManager?: (descriptor: ActorProfileDescriptor, input: ProfileLoadRequest) => IJobManager; }; /** * Default backend-generic runtime implementation backed by injected adapters. * * This class is the first concrete v2 slice intended for backend consumers that * need one reusable actor-aware profile runtime after authentication. */ export declare class BackendProfileRuntime implements BackendProfileRuntimeClient { private readonly adapters; private readonly options; constructor(adapters: BackendProfileRuntimeAdapters, options?: BackendProfileRuntimeOptions); loadProfile(input: ProfileLoadRequest): Promise; closeProfile(_profileKey: string): Promise; registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise; connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise; getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise; } /** * Current concrete backend profile runtime over one injected runtime client. * * This is the pragmatic v2 bridge for backend consumers that already possess * an authenticated `RuntimeClient` and need `loadProfile(...)` to materialize * actor facades immediately against the current GW CORE contract. */ export declare class DirectBackendProfileRuntime implements BackendProfileRuntimeClient { private readonly loadedProfiles; private readonly options; constructor(options: DirectBackendProfileRuntimeOptions); loadProfile(input: ProfileLoadRequest): Promise; closeProfile(profileKey: string): Promise; registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise; connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise; getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise; private rememberLoadedProfile; private forgetLoadedProfile; private resolveLoadedProfile; } /** * Preferred developer-facing factory for the current backend profile runtime. * * Use this helper in tutorials and app/BFF code when you already have one * configured runtime client and want the canonical * `loadProfile(...) -> session -> actor facade` entrypoint without exposing the * concrete class name in every example. */ export declare function createBackendProfileRuntime(options: DirectBackendProfileRuntimeOptions): BackendProfileRuntimeClient; /** * Minimal in-memory `JobManager` for backend runtimes that do not need durable * persistence during one live session. */ export declare function createJobManagerInMemory(descriptor: ActorProfileDescriptor): IJobManager; /** * Requires one backend profile-runtime method from one runtime client. */ export declare function requireBackendProfileRuntimeMethod(client: BackendProfileRuntimeClient, method: T): NonNullable; /** * Canonical backend helper for loading one actor profile after authentication. */ export declare function loadBackendProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise; /** * Canonical backend helper for closing one loaded actor profile and clearing * runtime-owned in-memory state. */ export declare function closeBackendProfile(client: BackendProfileRuntimeClient, profileKey: string): Promise; /** * Canonical backend helper for registering one trusted device/runtime context. */ export declare function registerBackendTrustedDevice(client: BackendProfileRuntimeClient, input: TrustedDeviceRegistrationRequest): Promise; /** * Canonical backend helper for connecting one actor profile to one subject * index after the profile is already loaded. */ export declare function connectBackendToSubjectIndex(client: BackendProfileRuntimeClient, input: SubjectIndexConnectionRequest): Promise; /** * Canonical backend helper for reading one subject index composition after the * relationship is already established. */ export declare function getBackendSubjectIndexComposition(client: BackendProfileRuntimeClient, input: SubjectIndexCompositionRequest): Promise; /** * Returns one materialized backend actor session by actor kind. * * Backend callers should use this instead of scanning `actorSessions` manually. */ export declare function requireBackendActorSession(profile: BackendLoadedActorProfile, actorKind: ActorKind): ActorSession; /** * Returns the individual-controller session from one loaded backend profile. * * This helper is the first concrete bridge from the generic backend runtime to * the current individual bootstrap/index use case. */ export declare function requireBackendIndividualControllerSession(profile: BackendLoadedActorProfile): ActorSession; /** * Materializes the individual-controller facade directly from one loaded * backend profile. */ export declare function requireBackendIndividualControllerSdk(profile: BackendLoadedActorProfile): IndividualControllerSdk; /** Returns the individual-member session from one loaded backend profile. */ export declare function requireBackendIndividualMemberSession(profile: BackendLoadedActorProfile): ActorSession; /** Materializes the individual-member facade from one loaded backend profile. */ export declare function requireBackendIndividualMemberSdk(profile: BackendLoadedActorProfile): IndividualMemberSdk; /** * Returns the organization-controller session from one loaded backend profile. */ export declare function requireBackendOrganizationControllerSession(profile: BackendLoadedActorProfile): ActorSession; /** * Materializes the organization-controller facade directly from one loaded * backend profile. */ export declare function requireBackendOrganizationControllerSdk(profile: BackendLoadedActorProfile): OrganizationControllerSdk; /** * Returns the professional session from one loaded backend profile. */ export declare function requireBackendProfessionalSession(profile: BackendLoadedActorProfile): ActorSession; /** * Materializes the professional facade directly from one loaded backend * profile. */ export declare function requireBackendProfessionalSdk(profile: BackendLoadedActorProfile): ProfessionalSdk; /** * Loads one backend profile and resolves the individual-controller session in * one step. * * This is the first pragmatic use-case helper on top of the generic backend * profile runtime, because the current stable CORE bootstrap baseline starts * from the individual-controller flow. */ export declare function loadBackendIndividualControllerProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise; /** * Loads a self-managed individual profile. The canonical actor kind remains * individual-controller, while PersonalSdk presents the reduced self surface. */ export declare function loadBackendPersonalProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise; /** Loads an accepted individual-member/RelatedPerson backend profile. */ export declare function loadBackendIndividualMemberProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise; /** * Loads one backend profile and resolves the organization-controller session in * one step. */ export declare function loadBackendOrganizationControllerProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise; /** * Loads one backend profile and resolves the professional session in one step. */ export declare function loadBackendProfessionalProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise;