gdc-sdk-front-ts 0.6.6 → 0.7.0

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 (2) hide show
  1. package/README.md +308 -2
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -42,7 +42,7 @@ If you are integrating this package for the first time, open these in order:
42
42
  real local GW running for end-to-end checks.
43
43
  5. [gdc-common-utils-ts/src/examples/frontend-session.ts](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/src/examples/frontend-session.ts)
44
44
  Shared profile/session payload source of truth.
45
- 6. [gdc-common-utils-ts/docs/LIFECYCLE_101.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/LIFECYCLE_101.md)
45
+ 6. [gdc-common-utils-ts/docs/101-LIFECYCLE.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/101-LIFECYCLE.md)
46
46
  Canonical lifecycle semantics and reusable placeholders for UI and portal flows.
47
47
 
48
48
  If you need the shortest path:
@@ -57,6 +57,312 @@ If you need the shortest path:
57
57
  - profile/session bootstrap:
58
58
  [`initializeSession(...)`](./docs/101-SDK_INTEGRATION.md)
59
59
 
60
+ ## Frontend Runtime Modes
61
+
62
+ There are two frontend integration modes. New developers should choose the
63
+ mode first, before choosing classes or helpers.
64
+
65
+ ### 1. Portal web / non confidential app
66
+
67
+ Use this mode when:
68
+
69
+ - the frontend is a Vite/web portal
70
+ - the portal backend holds controller/professional keys in AWS KMS
71
+ - the frontend does not send DIDComm directly to GW CORE
72
+
73
+ Recommended entry point:
74
+
75
+ - start from the shared editors/builders in `gdc-sdk-core-ts`
76
+ - send the resulting payload or bundle to the portal backend
77
+ - let the backend handle KMS, DIDComm, submit, and poll
78
+
79
+ Main references:
80
+
81
+ - [gdc-sdk-core-ts/docs/101-EMPLOYEES.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-EMPLOYEES.md)
82
+ - [gdc-sdk-core-ts/docs/101-CONSENT_COMMUNICATION.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-CONSENT_COMMUNICATION.md)
83
+ - [gdc-common-utils-ts/docs/101-CONSENT_ACCESS.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/101-CONSENT_ACCESS.md)
84
+ - [gdc-sdk-core-ts/tests/101-employees.test.mjs](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/tests/101-employees.test.mjs)
85
+ - [gdc-common-utils-ts/__tests__/101-consent-bundle-editor.test.ts](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/__tests__/101-consent-bundle-editor.test.ts)
86
+
87
+ Use:
88
+
89
+ - `BundleEditor` for employee create/search/disable/purge payloads
90
+ - `CommunicationAttachedBundleSession` for `Communication`-carried bundles
91
+ - `createConsentAccessEditor(...)` for consent editing inside a communication bundle
92
+
93
+ Controller-only employee flow in a portal web app:
94
+
95
+ Use this example only when the current frontend screen belongs to the
96
+ organization-controller/admin side.
97
+
98
+ Do not reuse this employee example for:
99
+
100
+ - professional screens
101
+ - individual/family screens
102
+ - generic end-user screens
103
+
104
+ Those actor families should start from their own business flow:
105
+
106
+ - professionals
107
+ - consent-aware access
108
+ - SMART token
109
+ - communication/index flows
110
+ - individuals / family
111
+ - consent editing
112
+ - related-person flows
113
+ - IPS/FHIR import or read flows
114
+
115
+ ### Create
116
+
117
+ Use `BundleEditor` to prepare one employee create bundle. The browser
118
+ does not send it directly to GW CORE.
119
+ The portal backend wraps it into its own request/envelope, then applies KMS,
120
+ DIDComm, submit, and poll.
121
+
122
+ ```ts
123
+ import { BundleEditor } from 'gdc-sdk-core-ts';
124
+ import {
125
+ EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
126
+ EXAMPLE_PROVIDER_ORGANIZATION_DID,
127
+ } from 'gdc-common-utils-ts/examples';
128
+ import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
129
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
130
+
131
+ // This editor lives only in frontend memory.
132
+ // It helps the UI build the canonical employee payload before sending it to
133
+ // the portal backend.
134
+ const bundle = new BundleEditor()
135
+ .setBundleOperation(EmployeeBundleOperations.create)
136
+ .newEntry()
137
+ .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
138
+ .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
139
+ .addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
140
+
141
+ // `employeeCreateBatchBundle` is the canonical one-entry employee `_batch` bundle.
142
+ // Your Vite frontend normally sends this bundle to its own backend, not
143
+ // directly to GW CORE.
144
+ const generatedEmployeeIdentifier = bundle.getIdentifier();
145
+ const employeeCreateBatchBundle = bundle.doneEntry().build();
146
+ console.log(employeeCreateBatchBundle);
147
+ ```
148
+
149
+ If the frontend does not provide an employee identifier up front, the create
150
+ flow can generate one and keep it in the same editor:
151
+
152
+ ```ts
153
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
154
+
155
+ const bundle = new BundleEditor()
156
+ .setBundleOperation(EmployeeBundleOperations.create)
157
+ .newEntry()
158
+ .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
159
+ .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role);
160
+
161
+ const employeeCreateBatchBundle = bundle.doneEntry().build();
162
+ const generatedEmployeeIdentifier = bundle.getIdentifier();
163
+ ```
164
+
165
+ If a frontend needs explicit claim-level control instead of only `setEmail()` /
166
+ `setRole()`, the same editor also exposes generic claim methods:
167
+
168
+ ```ts
169
+ import { BundleEditor } from 'gdc-sdk-core-ts';
170
+ import {
171
+ EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
172
+ EXAMPLE_PROVIDER_ORGANIZATION_DID,
173
+ } from 'gdc-common-utils-ts/examples';
174
+ import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
175
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
176
+
177
+ const bundle = new BundleEditor()
178
+ .setBundleOperation(EmployeeBundleOperations.create)
179
+ .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
180
+ .setClaim(ClaimsPersonSchemaorg.email, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
181
+ .setClaim(ClaimsPersonSchemaorg.hasOccupationalRoleValue, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
182
+ .addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
183
+
184
+ console.log(bundle.getClaim(ClaimsPersonSchemaorg.email));
185
+
186
+ const employeeCreateBatchBundle = bundle.doneEntry().build();
187
+ ```
188
+
189
+ ### Search
190
+
191
+ Search is a different operation and should be built separately.
192
+
193
+ `email + role` is the recommended exact operational lookup.
194
+
195
+ ```ts
196
+ import { BundleEditor } from 'gdc-sdk-core-ts';
197
+ import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
198
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
199
+
200
+ const employeeSearchBundle = new BundleEditor()
201
+ .setBundleOperation(EmployeeBundleOperations.search)
202
+ .newEntry()
203
+ .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
204
+ .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
205
+ .doneEntry()
206
+ .build();
207
+
208
+ console.log(employeeSearchBundle);
209
+ ```
210
+
211
+ Other valid search shapes:
212
+
213
+ - by `email` only: all active profiles for that mailbox
214
+ - by `role` only: all active employees for that role
215
+ - with no filters: all employees
216
+ - by `identifier`: one exact technical or historical profile
217
+
218
+ ### Disable
219
+
220
+ Disable is a lifecycle operation. Today the shared employee editor still
221
+ produces the canonical `_batch` bundle with inner `request.method = DELETE`.
222
+
223
+ ```ts
224
+ import { BundleEditor } from 'gdc-sdk-core-ts';
225
+ import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
226
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
227
+
228
+ const employeeDisableBatchBundle = new BundleEditor()
229
+ .setBundleOperation(EmployeeBundleOperations.disable)
230
+ .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
231
+ .doneEntry()
232
+ .build();
233
+
234
+ console.log(employeeDisableBatchBundle);
235
+ ```
236
+
237
+ Current GW CORE contract vs preferred target:
238
+
239
+ - current live contract
240
+ - disable = `_batch` + inner `request.method = DELETE`
241
+ - purge = `POST .../Employee/_purge`
242
+ - preferred target contract
243
+ - disable/enable = semantic state change via `PATCH`
244
+ - purge = final removal operation kept separate from state changes
245
+
246
+ Conceptual `PATCH` example for state change:
247
+
248
+ ```ts
249
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
250
+
251
+ const employeeDisablePatchBatchBundle = new BundleEditor()
252
+ .setBundleOperation(EmployeeBundleOperations.disable)
253
+ .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier);
254
+ ```
255
+
256
+ Business meaning:
257
+
258
+ - `PATCH` should mean state transition such as enable/disable
259
+ - `DELETE` should be reserved for final removal semantics such as purge
260
+ - future operations like merge/split/destroy should be modeled first as named
261
+ business operations, then mapped to transport
262
+
263
+ ### Purge
264
+
265
+ Purge is not the same route as create/disable, but the frontend should still
266
+ prepare a `Bundle` for it. The portal backend or runtime later submits that
267
+ bundle to the explicit `Employee/_purge` flow. The canonical purge selector is
268
+ the employee `identifier`.
269
+
270
+ ```ts
271
+ import { BundleEditor } from 'gdc-sdk-core-ts';
272
+ import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
273
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
274
+
275
+ const employeePurgeBundle = new BundleEditor()
276
+ .setBundleOperation(EmployeeBundleOperations.purge)
277
+ .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
278
+ .doneEntry()
279
+ .build();
280
+
281
+ console.log(employeePurgeBundle);
282
+ ```
283
+
284
+ Primary references for those employee flows:
285
+
286
+ - [gdc-sdk-core-ts/docs/101-EMPLOYEES.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-EMPLOYEES.md)
287
+ - [gdc-sdk-core-ts/tests/101-employees.test.mjs](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/tests/101-employees.test.mjs)
288
+
289
+ Non-controller frontend references:
290
+
291
+ - professional / individual flow map:
292
+ - [gdc-sdk-core-ts/docs/101-SDK_FLOWS.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-SDK_FLOWS.md)
293
+ - consent editing:
294
+ - [gdc-common-utils-ts/docs/101-CONSENT_ACCESS.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/101-CONSENT_ACCESS.md)
295
+ - consent + communication handoff:
296
+ - [gdc-sdk-core-ts/docs/101-CONSENT_COMMUNICATION.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-CONSENT_COMMUNICATION.md)
297
+
298
+ ### 2. Confidential app / direct client runtime
299
+
300
+ Use this mode when:
301
+
302
+ - the app stores transport keys locally
303
+ - the app can talk directly to GW CORE
304
+ - there is no portal backend doing KMS and DIDComm on behalf of the app
305
+
306
+ Recommended entry point:
307
+
308
+ - start from `ClientSDK`
309
+ - initialize runtime/session state
310
+ - use the same shared editors/builders from `sdk-core` when a flow needs them
311
+
312
+ Main references:
313
+
314
+ - [docs/101-SDK_INTEGRATION.md](./docs/101-SDK_INTEGRATION.md)
315
+ - [gdc-sdk-node-ts/docs/101-LIVE_GW_LOCAL.md](https://github.com/Global-DataCare/gdc-sdk-node-ts/blob/main/docs/101-LIVE_GW_LOCAL.md)
316
+
317
+ Decision rule:
318
+
319
+ - no local key custody: start from `sdk-core` editors and send to your backend
320
+ - local key custody: start from `ClientSDK` runtime/session and use `sdk-core` editors as shared modeling helpers
321
+
322
+ Minimal confidential-app example:
323
+
324
+ ```ts
325
+ import { ClientSDK } from 'gdc-sdk-front-ts';
326
+ import { BundleEditor } from 'gdc-sdk-core-ts';
327
+ import {
328
+ EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
329
+ EXAMPLE_PROFILE_SESSION_INPUT,
330
+ } from 'gdc-common-utils-ts/examples';
331
+ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
332
+
333
+ const appId = frontendAppConfig.appId;
334
+ const client = new ClientSDK({ appId });
335
+
336
+ // `initializeSession(...)` creates the authenticated frontend runtime session.
337
+ // In a confidential app this session owns the actor-facing runtime surface and
338
+ // can later expose organization-controller/professional capabilities.
339
+ const session = await client.initializeSession(EXAMPLE_PROFILE_SESSION_INPUT);
340
+
341
+ // The shared editor from sdk-core is still used to model the employee bundle.
342
+ const employeeSearchBundle = new BundleEditor()
343
+ .setBundleOperation(EmployeeBundleOperations.search)
344
+ .newEntry()
345
+ .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
346
+ .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
347
+ .doneEntry()
348
+ .build();
349
+
350
+ console.log(session, employeeSearchBundle);
351
+ ```
352
+
353
+ Runtime note:
354
+
355
+ - a confidential app still must choose the correct actor surface before using
356
+ an employee flow
357
+ - employee management belongs only to the organization-controller/admin side
358
+ - professional or individual apps should start from their own actor flow, not
359
+ from the employee examples above
360
+
361
+ Primary references for that flow:
362
+
363
+ - [docs/101-SDK_INTEGRATION.md](./docs/101-SDK_INTEGRATION.md)
364
+ - [gdc-sdk-node-ts/docs/101-LIVE_GW_LOCAL.md](https://github.com/Global-DataCare/gdc-sdk-node-ts/blob/main/docs/101-LIVE_GW_LOCAL.md)
365
+
60
366
  ## Executable Usage Examples
61
367
 
62
368
  Open these tests when you want to see exact frontend calls and exact inputs:
@@ -302,7 +608,7 @@ const communication = buildPermissionRequestCommunication({
302
608
  ## Shared Contract Sources
303
609
 
304
610
  - [gdc-sdk-core-ts/README.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/README.md)
305
- - [gdc-common-utils-ts/docs/CONSENT_ACCESS_101.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/CONSENT_ACCESS_101.md)
611
+ - [gdc-common-utils-ts/docs/101-CONSENT_ACCESS.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/101-CONSENT_ACCESS.md)
306
612
 
307
613
  Reusable payload examples:
308
614
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-front-ts",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "Next-generation frontend runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.28.4",
20
- "gdc-common-utils-ts": "^1.14.14",
21
- "gdc-sdk-core-ts": "^0.6.12"
20
+ "gdc-common-utils-ts": "^1.15.0",
21
+ "gdc-sdk-core-ts": "^0.7.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^20.14.10",