gdc-sdk-node-ts 0.12.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # gdc-sdk-node-ts
2
2
 
3
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) and
4
+ [CONTRIBUTING.md](./CONTRIBUTING.md) before adding node runtime facades,
5
+ execution adapters, or orchestration tests.
6
+
7
+ Short rule:
8
+
9
+ - `101` tests must read like executable tutorials
10
+ - shared fixtures/types belong in `gdc-common-utils-ts`, not as local literals
11
+ in node runtime tests
12
+
3
13
  Node runtime package for consuming the shared GDC SDK contracts against real
4
14
  gateway backends.
5
15
 
@@ -46,6 +56,22 @@ If you are integrating this package for the first time, open these in order:
46
56
  1. [gdc-sdk-core-ts/docs/101-SDK_PACKAGE_BOUNDARIES.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-SDK_PACKAGE_BOUNDARIES.md)
47
57
  Why `core`, `node`, and `front` are separate packages, what belongs in each
48
58
  one, and why actor-scoped facades must stay aligned across runtimes.
59
+ 1. [tests/101-backend-profile-runtime.test.mjs](./tests/101-backend-profile-runtime.test.mjs)
60
+ Minimal backend-generic walkthrough for loading one actor profile,
61
+ registering one trusted device/runtime context, connecting to one subject
62
+ index, reading one subject index composition, and then materializing the
63
+ `IndividualController` facade from the loaded backend session.
64
+ That walkthrough now uses the concrete direct backend runtime over the
65
+ injected `RuntimeClient`, not only one abstract adapter mock, and now also
66
+ demonstrates in-memory `JobManager` usage plus `closeProfile(...)`.
67
+ 1. [tests/101-individual-controller-backend-runtime.test.mjs](./tests/101-individual-controller-backend-runtime.test.mjs)
68
+ First pragmatic backend wrapper over the generic profile runtime for the
69
+ current individual-controller CORE baseline:
70
+ load profile, start registration, confirm order, and search the clinical
71
+ index.
72
+ 1. [docs/V2_INDIVIDUAL_REGISTRATION_RECONCILIATION.md](./docs/V2_INDIVIDUAL_REGISTRATION_RECONCILIATION.md)
73
+ Reconciles the old consumer flow with the current CORE registration baseline
74
+ and separates the stable registration base from later product extensions.
49
75
  1. [docs/101-SDK_END_TO_END.md](./docs/101-SDK_END_TO_END.md)
50
76
  Ordered onboarding guide with end-to-end journeys, copy/paste snippets, and
51
77
  the recommended reading path for new backend integrators.
@@ -89,6 +115,22 @@ If you need the shortest path:
89
115
  - dataspace discovery and fallback/cache boundary:
90
116
  [docs/101-DISCOVERY.md](./docs/101-DISCOVERY.md)
91
117
 
118
+ Immediate live validation target:
119
+
120
+ - the next profile-runtime validation must be treated as an actor-profile suite,
121
+ not as a replay of the GW CORE platform lifecycle
122
+ - the standalone current entry point for that is:
123
+ [tests/live-profile-runtime-individual.e2e.test.mjs](tests/live-profile-runtime-individual.e2e.test.mjs)
124
+ - it should begin with `loadProfile(...)` for the target actor and then prove:
125
+ - `startIndividualOrganization(...)`
126
+ - `confirmIndividualOrganizationOrder(...)`
127
+ - the canonical current index/`Composition` read helper
128
+ - if that actor flow creates lifecycle-owned state, `disable` / `purge` belong
129
+ at the end of that scenario as cleanup
130
+ - until that live proof exists, treat `getLatestIps(...)` and
131
+ `searchClinicalBundle(...)` as candidate read contracts, not yet final
132
+ wording
133
+
92
134
  ## Executable Usage Examples
93
135
 
94
136
  Open these tests when you want to see exact method calls and exact inputs:
@@ -107,6 +149,9 @@ Open these tests when you want to see exact method calls and exact inputs:
107
149
  SMART token request flow.
108
150
  - [tests/live-gw-node-runtime.e2e.test.mjs](tests/live-gw-node-runtime.e2e.test.mjs)
109
151
  End-to-end runtime wiring against a real GW environment.
152
+ - [tests/live-profile-runtime-individual.e2e.test.mjs](tests/live-profile-runtime-individual.e2e.test.mjs)
153
+ Standalone actor-profile E2E for the individual controller on an already
154
+ operational tenant, including scenario-owned cleanup.
110
155
  - [tests/101-dataspace-resolver.test.mjs](tests/101-dataspace-resolver.test.mjs)
111
156
  Minimal `HttpDataspaceResolver` 101 with one host and one published provider.
112
157
  - [tests/101-default-first-dataspace-discovery.test.mjs](tests/101-default-first-dataspace-discovery.test.mjs)
@@ -581,6 +626,7 @@ modules below.
581
626
  ### Node runtime client
582
627
 
583
628
  - [`NodeHttpClient`](src/node-runtime-client.ts)
629
+ - [`NodeHttpClient.submitLegalOrganizationVerificationTransaction(...)`](src/node-runtime-client.ts)
584
630
  - [`NodeHttpClient.ingestCommunicationAndUpdateIndex(...)`](src/node-runtime-client.ts)
585
631
  - [`NodeHttpClient.submitCommunicationAndPoll(...)`](src/node-runtime-client.ts)
586
632
  - [`NodeHttpClient.searchClinicalBundle(...)`](src/node-runtime-client.ts)
@@ -608,3 +654,21 @@ modules below.
608
654
  - README explains backend-facing flows first.
609
655
  - Shared contract shapes must be documented in `gdc-sdk-core-ts`, not duplicated here.
610
656
  - Route details and GW-specific behavior belong in runtime docs and JSDoc, not in app-facing examples.
657
+
658
+ ## Host Onboarding Runtime Flow
659
+
660
+ For legal-organization onboarding from a Node BFF/runtime, keep the host steps separate:
661
+
662
+ 1. `Organization/_transaction`
663
+ 2. legacy `Organization/_activate` after ICA `_verify`
664
+ 3. `Order/_batch`
665
+
666
+ Use `OrganizationControllerSdk.submitLegalOrganizationVerificationTransaction(...)` or
667
+ `NodeHttpClient.submitLegalOrganizationVerificationTransaction(...)` for step 1.
668
+
669
+ Rules:
670
+
671
+ - `_transaction` and `_activate` are different flows
672
+ - transport/runtime communication keys stay outside the business payload
673
+ - controller binding key stays in `body.data[].resource.controller.*`
674
+ - do not mix this path with `requestIcaEnrollment` or Fabric
@@ -0,0 +1,214 @@
1
+ import type { ActorProfileDescriptor, IJobManager, ActorKind, LoadedActorProfile, ProfileLoadRequest, SubjectIndexCompositionRequest, SubjectIndexConnectionRequest, TrustedDeviceRegistrationRequest } from 'gdc-sdk-core-ts';
2
+ import type { ActorSession } from './session.js';
3
+ import type { RuntimeClient } from './orchestration/client-port.js';
4
+ import { IndividualControllerSdk } from './orchestration/individual-controller-sdk.js';
5
+ import type { RouteContext } from './individual-onboarding.js';
6
+ /**
7
+ * Result of registering one trusted backend runtime device/profile context.
8
+ *
9
+ * This is intentionally backend-generic. It does not describe one concrete
10
+ * channel or product flow.
11
+ */
12
+ export type BackendTrustedDeviceRegistrationResult = {
13
+ trustedDeviceId: string;
14
+ status: 'registered' | 'already-trusted';
15
+ };
16
+ /**
17
+ * Result of connecting one loaded actor profile to one subject index.
18
+ */
19
+ export type BackendSubjectIndexConnectionResult = {
20
+ subjectId: string;
21
+ userId: string;
22
+ userRoleCode: string;
23
+ status: 'connected' | 'already-connected';
24
+ };
25
+ /**
26
+ * Result of reading one subject index composition after the relationship is
27
+ * already established.
28
+ */
29
+ export type BackendSubjectIndexCompositionResult = {
30
+ subjectId: string;
31
+ userId: string;
32
+ userRoleCode: string;
33
+ composition: unknown;
34
+ };
35
+ export declare const BackendSubjectIndexReadModes: Readonly<{
36
+ LatestIps: "latest-ips";
37
+ ClinicalBundle: "clinical-bundle";
38
+ }>;
39
+ export type BackendSubjectIndexReadMode = typeof BackendSubjectIndexReadModes[keyof typeof BackendSubjectIndexReadModes];
40
+ /**
41
+ * Backend materialization of one loaded actor profile with runtime sessions
42
+ * ready to expose actor-scoped facades.
43
+ */
44
+ export type BackendLoadedActorProfile = LoadedActorProfile & {
45
+ actorSessions: ActorSession[];
46
+ };
47
+ export type BackendIndividualControllerProfile = {
48
+ profile: BackendLoadedActorProfile;
49
+ session: ActorSession;
50
+ sdk: IndividualControllerSdk;
51
+ };
52
+ /**
53
+ * Canonical backend runtime contract for loading one actor profile after
54
+ * authentication and then working with trusted device registration and subject
55
+ * index access.
56
+ *
57
+ * This surface is intentionally generic for BFF or other backend runtimes.
58
+ * It does not encode one product-specific interaction channel.
59
+ */
60
+ export type BackendProfileRuntimeClient = {
61
+ loadProfile?: (input: ProfileLoadRequest) => Promise<BackendLoadedActorProfile>;
62
+ closeProfile?: (profileKey: string) => Promise<void>;
63
+ registerTrustedDevice?: (input: TrustedDeviceRegistrationRequest) => Promise<BackendTrustedDeviceRegistrationResult>;
64
+ connectToSubjectIndex?: (input: SubjectIndexConnectionRequest) => Promise<BackendSubjectIndexConnectionResult>;
65
+ getSubjectIndexComposition?: (input: SubjectIndexCompositionRequest) => Promise<BackendSubjectIndexCompositionResult>;
66
+ };
67
+ export type BackendProfileRuntimeAdapters = {
68
+ loadProfile(input: ProfileLoadRequest): Promise<LoadedActorProfile>;
69
+ registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise<BackendTrustedDeviceRegistrationResult>;
70
+ connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise<BackendSubjectIndexConnectionResult>;
71
+ getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise<BackendSubjectIndexCompositionResult>;
72
+ };
73
+ export type BackendProfileRuntimeOptions = {
74
+ /**
75
+ * Runtime client injected into the materialized actor sessions so backend
76
+ * consumers can immediately call `asIndividualController()`,
77
+ * `asProfessional()`, and the other actor-specific facades after
78
+ * `loadProfile(...)`.
79
+ */
80
+ facadeClient?: RuntimeClient;
81
+ };
82
+ export type BackendLoadedProfileKey = string;
83
+ export type DirectBackendProfileRuntimeOptions = BackendProfileRuntimeOptions & {
84
+ /**
85
+ * Default route context reused by the current GW CORE subject-index fallback.
86
+ *
87
+ * This is intentionally optional because some integrators only need
88
+ * `loadProfile(...)` plus explicit actor facades first.
89
+ */
90
+ defaultRouteContext?: RouteContext;
91
+ /**
92
+ * Current temporary CORE-facing index read helper to use when the caller asks
93
+ * for one subject index composition through the profile runtime.
94
+ *
95
+ * Until GW CORE freezes one canonical public profile-runtime read contract,
96
+ * keep this selectable instead of hardcoding one final wording.
97
+ */
98
+ subjectIndexReadMode?: BackendSubjectIndexReadMode;
99
+ /**
100
+ * Optional override for trusted-device registration while GW CORE finalizes
101
+ * the backend runtime contract for that step.
102
+ */
103
+ registerTrustedDevice?: (input: TrustedDeviceRegistrationRequest) => Promise<BackendTrustedDeviceRegistrationResult>;
104
+ /**
105
+ * Optional override for backend subject-index connection while GW CORE
106
+ * finalizes the stable contract for that step.
107
+ */
108
+ connectToSubjectIndex?: (input: SubjectIndexConnectionRequest) => Promise<BackendSubjectIndexConnectionResult>;
109
+ /**
110
+ * Optional override for reading the subject index after connection.
111
+ */
112
+ getSubjectIndexComposition?: (input: SubjectIndexCompositionRequest) => Promise<BackendSubjectIndexCompositionResult>;
113
+ /**
114
+ * Optional custom job-manager factory. When omitted, the backend runtime
115
+ * creates one in-memory job manager so `loadProfile(...)` returns one
116
+ * complete v2 profile object immediately.
117
+ */
118
+ createJobManager?: (descriptor: ActorProfileDescriptor, input: ProfileLoadRequest) => IJobManager;
119
+ };
120
+ /**
121
+ * Default backend-generic runtime implementation backed by injected adapters.
122
+ *
123
+ * This class is the first concrete v2 slice intended for backend consumers that
124
+ * need one reusable actor-aware profile runtime after authentication.
125
+ */
126
+ export declare class BackendProfileRuntime implements BackendProfileRuntimeClient {
127
+ private readonly adapters;
128
+ private readonly options;
129
+ constructor(adapters: BackendProfileRuntimeAdapters, options?: BackendProfileRuntimeOptions);
130
+ loadProfile(input: ProfileLoadRequest): Promise<BackendLoadedActorProfile>;
131
+ closeProfile(_profileKey: string): Promise<void>;
132
+ registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise<BackendTrustedDeviceRegistrationResult>;
133
+ connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise<BackendSubjectIndexConnectionResult>;
134
+ getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise<BackendSubjectIndexCompositionResult>;
135
+ }
136
+ /**
137
+ * Current concrete backend profile runtime over one injected runtime client.
138
+ *
139
+ * This is the pragmatic v2 bridge for backend consumers that already possess
140
+ * an authenticated `RuntimeClient` and need `loadProfile(...)` to materialize
141
+ * actor facades immediately against the current GW CORE contract.
142
+ */
143
+ export declare class DirectBackendProfileRuntime implements BackendProfileRuntimeClient {
144
+ private readonly loadedProfiles;
145
+ private readonly options;
146
+ constructor(options: DirectBackendProfileRuntimeOptions);
147
+ loadProfile(input: ProfileLoadRequest): Promise<BackendLoadedActorProfile>;
148
+ closeProfile(profileKey: string): Promise<void>;
149
+ registerTrustedDevice(input: TrustedDeviceRegistrationRequest): Promise<BackendTrustedDeviceRegistrationResult>;
150
+ connectToSubjectIndex(input: SubjectIndexConnectionRequest): Promise<BackendSubjectIndexConnectionResult>;
151
+ getSubjectIndexComposition(input: SubjectIndexCompositionRequest): Promise<BackendSubjectIndexCompositionResult>;
152
+ private rememberLoadedProfile;
153
+ private forgetLoadedProfile;
154
+ private resolveLoadedProfile;
155
+ }
156
+ /**
157
+ * Minimal in-memory `JobManager` for backend runtimes that do not need durable
158
+ * persistence during one live session.
159
+ */
160
+ export declare function createJobManagerInMemory(descriptor: ActorProfileDescriptor): IJobManager;
161
+ /**
162
+ * Requires one backend profile-runtime method from one runtime client.
163
+ */
164
+ export declare function requireBackendProfileRuntimeMethod<T extends keyof BackendProfileRuntimeClient>(client: BackendProfileRuntimeClient, method: T): NonNullable<BackendProfileRuntimeClient[T]>;
165
+ /**
166
+ * Canonical backend helper for loading one actor profile after authentication.
167
+ */
168
+ export declare function loadBackendProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise<BackendLoadedActorProfile>;
169
+ /**
170
+ * Canonical backend helper for closing one loaded actor profile and clearing
171
+ * runtime-owned in-memory state.
172
+ */
173
+ export declare function closeBackendProfile(client: BackendProfileRuntimeClient, profileKey: string): Promise<void>;
174
+ /**
175
+ * Canonical backend helper for registering one trusted device/runtime context.
176
+ */
177
+ export declare function registerBackendTrustedDevice(client: BackendProfileRuntimeClient, input: TrustedDeviceRegistrationRequest): Promise<BackendTrustedDeviceRegistrationResult>;
178
+ /**
179
+ * Canonical backend helper for connecting one actor profile to one subject
180
+ * index after the profile is already loaded.
181
+ */
182
+ export declare function connectBackendToSubjectIndex(client: BackendProfileRuntimeClient, input: SubjectIndexConnectionRequest): Promise<BackendSubjectIndexConnectionResult>;
183
+ /**
184
+ * Canonical backend helper for reading one subject index composition after the
185
+ * relationship is already established.
186
+ */
187
+ export declare function getBackendSubjectIndexComposition(client: BackendProfileRuntimeClient, input: SubjectIndexCompositionRequest): Promise<BackendSubjectIndexCompositionResult>;
188
+ /**
189
+ * Returns one materialized backend actor session by actor kind.
190
+ *
191
+ * Backend callers should use this instead of scanning `actorSessions` manually.
192
+ */
193
+ export declare function requireBackendActorSession(profile: BackendLoadedActorProfile, actorKind: ActorKind): ActorSession;
194
+ /**
195
+ * Returns the individual-controller session from one loaded backend profile.
196
+ *
197
+ * This helper is the first concrete bridge from the generic backend runtime to
198
+ * the current individual bootstrap/index use case.
199
+ */
200
+ export declare function requireBackendIndividualControllerSession(profile: BackendLoadedActorProfile): ActorSession;
201
+ /**
202
+ * Materializes the individual-controller facade directly from one loaded
203
+ * backend profile.
204
+ */
205
+ export declare function requireBackendIndividualControllerSdk(profile: BackendLoadedActorProfile): IndividualControllerSdk;
206
+ /**
207
+ * Loads one backend profile and resolves the individual-controller session in
208
+ * one step.
209
+ *
210
+ * This is the first pragmatic use-case helper on top of the generic backend
211
+ * profile runtime, because the current stable CORE bootstrap baseline starts
212
+ * from the individual-controller flow.
213
+ */
214
+ export declare function loadBackendIndividualControllerProfile(client: BackendProfileRuntimeClient, input: ProfileLoadRequest): Promise<BackendIndividualControllerProfile>;