gdc-sdk-front-ts 0.6.6 → 0.6.7
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 +257 -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/
|
|
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,261 @@ 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
|
+
- `EmployeeBundleSession` for employee create/search 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 `EmployeeBundleSession` 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 { EmployeeBundleSession } 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
|
+
|
|
130
|
+
// This editor lives only in frontend memory.
|
|
131
|
+
// It helps the UI build the canonical employee payload before sending it to
|
|
132
|
+
// the portal backend.
|
|
133
|
+
const bundleEditor = new EmployeeBundleSession()
|
|
134
|
+
.setIdentifier(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
135
|
+
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
136
|
+
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
137
|
+
.addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
|
|
138
|
+
|
|
139
|
+
// `employeeCreateBatchBundle` is the canonical one-entry employee `_batch` bundle.
|
|
140
|
+
// Your Vite frontend normally sends this bundle to its own backend, not
|
|
141
|
+
// directly to GW CORE.
|
|
142
|
+
const employeeCreateBatchBundle = bundleEditor.toBundleBatch({
|
|
143
|
+
method: 'POST',
|
|
144
|
+
resourceId: EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier,
|
|
145
|
+
});
|
|
146
|
+
console.log(employeeCreateBatchBundle);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Search
|
|
150
|
+
|
|
151
|
+
Search is a different operation and should be built separately.
|
|
152
|
+
|
|
153
|
+
`email + role` is the recommended exact operational lookup.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { EmployeeBundleSession } from 'gdc-sdk-core-ts';
|
|
157
|
+
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
158
|
+
|
|
159
|
+
const employeeSearchBundle = new EmployeeBundleSession()
|
|
160
|
+
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
161
|
+
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
162
|
+
.toBundleSearch();
|
|
163
|
+
|
|
164
|
+
console.log(employeeSearchBundle);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Other valid search shapes:
|
|
168
|
+
|
|
169
|
+
- by `email` only: all active profiles for that mailbox
|
|
170
|
+
- by `role` only: all active employees for that role
|
|
171
|
+
- with no filters: all employees
|
|
172
|
+
- by `identifier`: one exact technical or historical profile
|
|
173
|
+
|
|
174
|
+
### Disable
|
|
175
|
+
|
|
176
|
+
Disable is a lifecycle operation. Today the shared employee editor still
|
|
177
|
+
produces the canonical `_batch` bundle with inner `request.method = DELETE`.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { EmployeeBundleSession } from 'gdc-sdk-core-ts';
|
|
181
|
+
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
182
|
+
|
|
183
|
+
const employeeDisableBatchBundle = new EmployeeBundleSession()
|
|
184
|
+
.setIdentifier(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
185
|
+
.toBundleBatch({
|
|
186
|
+
method: 'DELETE',
|
|
187
|
+
resourceId: EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
console.log(employeeDisableBatchBundle);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Current GW CORE contract vs preferred target:
|
|
194
|
+
|
|
195
|
+
- current live contract
|
|
196
|
+
- disable = `_batch` + inner `request.method = DELETE`
|
|
197
|
+
- purge = `POST .../Employee/_purge`
|
|
198
|
+
- preferred target contract
|
|
199
|
+
- disable/enable = semantic state change via `PATCH`
|
|
200
|
+
- purge = final removal operation kept separate from state changes
|
|
201
|
+
|
|
202
|
+
Conceptual `PATCH` example for state change:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
const employeeDisablePatchBatchBundle = new EmployeeBundleSession()
|
|
206
|
+
.setIdentifier(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
207
|
+
.toBundleBatch({
|
|
208
|
+
method: 'PATCH',
|
|
209
|
+
resourceId: EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier,
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Business meaning:
|
|
214
|
+
|
|
215
|
+
- `PATCH` should mean state transition such as enable/disable
|
|
216
|
+
- `DELETE` should be reserved for final removal semantics such as purge
|
|
217
|
+
- future operations like merge/split/destroy should be modeled first as named
|
|
218
|
+
business operations, then mapped to transport
|
|
219
|
+
|
|
220
|
+
### Purge
|
|
221
|
+
|
|
222
|
+
Purge is not the same contract as create/disable. The portal backend or runtime
|
|
223
|
+
calls the explicit `Employee/_purge` flow and normally identifies the employee
|
|
224
|
+
with `identifier`.
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { EmployeeBundleSession } from 'gdc-sdk-core-ts';
|
|
228
|
+
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
229
|
+
|
|
230
|
+
const employeePurgeSelector = new EmployeeBundleSession()
|
|
231
|
+
.setIdentifier(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
232
|
+
.toClaims();
|
|
233
|
+
|
|
234
|
+
console.log(employeePurgeSelector);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Primary references for those employee flows:
|
|
238
|
+
|
|
239
|
+
- [gdc-sdk-core-ts/docs/101-EMPLOYEES.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-EMPLOYEES.md)
|
|
240
|
+
- [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)
|
|
241
|
+
|
|
242
|
+
Non-controller frontend references:
|
|
243
|
+
|
|
244
|
+
- professional / individual flow map:
|
|
245
|
+
- [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)
|
|
246
|
+
- consent editing:
|
|
247
|
+
- [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)
|
|
248
|
+
- consent + communication handoff:
|
|
249
|
+
- [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)
|
|
250
|
+
|
|
251
|
+
### 2. Confidential app / direct client runtime
|
|
252
|
+
|
|
253
|
+
Use this mode when:
|
|
254
|
+
|
|
255
|
+
- the app stores transport keys locally
|
|
256
|
+
- the app can talk directly to GW CORE
|
|
257
|
+
- there is no portal backend doing KMS and DIDComm on behalf of the app
|
|
258
|
+
|
|
259
|
+
Recommended entry point:
|
|
260
|
+
|
|
261
|
+
- start from `ClientSDK`
|
|
262
|
+
- initialize runtime/session state
|
|
263
|
+
- use the same shared editors/builders from `sdk-core` when a flow needs them
|
|
264
|
+
|
|
265
|
+
Main references:
|
|
266
|
+
|
|
267
|
+
- [docs/101-SDK_INTEGRATION.md](./docs/101-SDK_INTEGRATION.md)
|
|
268
|
+
- [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)
|
|
269
|
+
|
|
270
|
+
Decision rule:
|
|
271
|
+
|
|
272
|
+
- no local key custody: start from `sdk-core` editors and send to your backend
|
|
273
|
+
- local key custody: start from `ClientSDK` runtime/session and use `sdk-core` editors as shared modeling helpers
|
|
274
|
+
|
|
275
|
+
Minimal confidential-app example:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { ClientSDK } from 'gdc-sdk-front-ts';
|
|
279
|
+
import { EmployeeBundleSession } from 'gdc-sdk-core-ts';
|
|
280
|
+
import {
|
|
281
|
+
EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
|
|
282
|
+
EXAMPLE_PROFILE_SESSION_INPUT,
|
|
283
|
+
} from 'gdc-common-utils-ts/examples';
|
|
284
|
+
|
|
285
|
+
const appId = frontendAppConfig.appId;
|
|
286
|
+
const client = new ClientSDK({ appId });
|
|
287
|
+
|
|
288
|
+
// `initializeSession(...)` creates the authenticated frontend runtime session.
|
|
289
|
+
// In a confidential app this session owns the actor-facing runtime surface and
|
|
290
|
+
// can later expose organization-controller/professional capabilities.
|
|
291
|
+
const session = await client.initializeSession(EXAMPLE_PROFILE_SESSION_INPUT);
|
|
292
|
+
|
|
293
|
+
// The shared editor from sdk-core is still used to model the employee bundle.
|
|
294
|
+
const employeeSearchBundle = new EmployeeBundleSession()
|
|
295
|
+
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
296
|
+
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
297
|
+
.toBundleSearch();
|
|
298
|
+
|
|
299
|
+
console.log(session, employeeSearchBundle);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Runtime note:
|
|
303
|
+
|
|
304
|
+
- a confidential app still must choose the correct actor surface before using
|
|
305
|
+
an employee flow
|
|
306
|
+
- employee management belongs only to the organization-controller/admin side
|
|
307
|
+
- professional or individual apps should start from their own actor flow, not
|
|
308
|
+
from the employee examples above
|
|
309
|
+
|
|
310
|
+
Primary references for that flow:
|
|
311
|
+
|
|
312
|
+
- [docs/101-SDK_INTEGRATION.md](./docs/101-SDK_INTEGRATION.md)
|
|
313
|
+
- [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)
|
|
314
|
+
|
|
60
315
|
## Executable Usage Examples
|
|
61
316
|
|
|
62
317
|
Open these tests when you want to see exact frontend calls and exact inputs:
|
|
@@ -302,7 +557,7 @@ const communication = buildPermissionRequestCommunication({
|
|
|
302
557
|
## Shared Contract Sources
|
|
303
558
|
|
|
304
559
|
- [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/
|
|
560
|
+
- [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
561
|
|
|
307
562
|
Reusable payload examples:
|
|
308
563
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-sdk-front-ts",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
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.
|
|
21
|
-
"gdc-sdk-core-ts": "^0.6.
|
|
20
|
+
"gdc-common-utils-ts": "^1.14.15",
|
|
21
|
+
"gdc-sdk-core-ts": "^0.6.14"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.14.10",
|