gdc-sdk-front-ts 0.6.7 → 0.8.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.
- package/README.md +126 -41
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ Main references:
|
|
|
86
86
|
|
|
87
87
|
Use:
|
|
88
88
|
|
|
89
|
-
- `
|
|
89
|
+
- `BundleEditor` plus `EmployeeEntryEditor` for employee create/search/disable/purge payloads
|
|
90
90
|
- `CommunicationAttachedBundleSession` for `Communication`-carried bundles
|
|
91
91
|
- `createConsentAccessEditor(...)` for consent editing inside a communication bundle
|
|
92
92
|
|
|
@@ -114,24 +114,31 @@ Those actor families should start from their own business flow:
|
|
|
114
114
|
|
|
115
115
|
### Create
|
|
116
116
|
|
|
117
|
-
Use `
|
|
117
|
+
Use `BundleEditor` plus one employee entry editor to prepare one employee create bundle. The browser
|
|
118
118
|
does not send it directly to GW CORE.
|
|
119
119
|
The portal backend wraps it into its own request/envelope, then applies KMS,
|
|
120
120
|
DIDComm, submit, and poll.
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
|
-
import {
|
|
123
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
124
124
|
import {
|
|
125
125
|
EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
|
|
126
126
|
EXAMPLE_PROVIDER_ORGANIZATION_DID,
|
|
127
127
|
} from 'gdc-common-utils-ts/examples';
|
|
128
128
|
import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
|
|
129
|
+
import {
|
|
130
|
+
EmployeeBundleOperations,
|
|
131
|
+
EmployeeResourceTypes,
|
|
132
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
129
133
|
|
|
130
134
|
// This editor lives only in frontend memory.
|
|
131
135
|
// It helps the UI build the canonical employee payload before sending it to
|
|
132
136
|
// the portal backend.
|
|
133
|
-
const
|
|
134
|
-
.
|
|
137
|
+
const employeeEntry = new BundleEditor()
|
|
138
|
+
.setBundleOperation(EmployeeBundleOperations.create)
|
|
139
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
140
|
+
.newEntry()
|
|
141
|
+
.asEmployee()
|
|
135
142
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
136
143
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
137
144
|
.addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
|
|
@@ -139,13 +146,58 @@ const bundleEditor = new EmployeeBundleSession()
|
|
|
139
146
|
// `employeeCreateBatchBundle` is the canonical one-entry employee `_batch` bundle.
|
|
140
147
|
// Your Vite frontend normally sends this bundle to its own backend, not
|
|
141
148
|
// directly to GW CORE.
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
resourceId: EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier,
|
|
145
|
-
});
|
|
149
|
+
const generatedEmployeeIdentifier = employeeEntry.getIdentifier();
|
|
150
|
+
const employeeCreateBatchBundle = employeeEntry.doneEntry().build();
|
|
146
151
|
console.log(employeeCreateBatchBundle);
|
|
147
152
|
```
|
|
148
153
|
|
|
154
|
+
If the frontend does not provide an employee identifier up front, the create
|
|
155
|
+
flow can generate one and keep it in the same editor:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
159
|
+
|
|
160
|
+
const employeeEntry = new BundleEditor()
|
|
161
|
+
.setBundleOperation(EmployeeBundleOperations.create)
|
|
162
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
163
|
+
.newEntry()
|
|
164
|
+
.asEmployee()
|
|
165
|
+
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
166
|
+
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role);
|
|
167
|
+
|
|
168
|
+
const generatedEmployeeIdentifier = employeeEntry.getIdentifier();
|
|
169
|
+
const employeeCreateBatchBundle = employeeEntry.doneEntry().build();
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
If a frontend needs explicit claim-level control instead of only `setEmail()` /
|
|
173
|
+
`setRole()`, the same editor also exposes generic claim methods:
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
177
|
+
import {
|
|
178
|
+
EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
|
|
179
|
+
EXAMPLE_PROVIDER_ORGANIZATION_DID,
|
|
180
|
+
} from 'gdc-common-utils-ts/examples';
|
|
181
|
+
import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
|
|
182
|
+
import {
|
|
183
|
+
EmployeeBundleOperations,
|
|
184
|
+
EmployeeResourceTypes,
|
|
185
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
186
|
+
|
|
187
|
+
const employeeEntry = new BundleEditor()
|
|
188
|
+
.setBundleOperation(EmployeeBundleOperations.create)
|
|
189
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
190
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
191
|
+
.asEmployee()
|
|
192
|
+
.setClaim(ClaimsPersonSchemaorg.email, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
193
|
+
.setClaim(ClaimsPersonSchemaorg.hasOccupationalRoleValue, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
194
|
+
.addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
|
|
195
|
+
|
|
196
|
+
console.log(employeeEntry.getClaim(ClaimsPersonSchemaorg.email));
|
|
197
|
+
|
|
198
|
+
const employeeCreateBatchBundle = employeeEntry.doneEntry().build();
|
|
199
|
+
```
|
|
200
|
+
|
|
149
201
|
### Search
|
|
150
202
|
|
|
151
203
|
Search is a different operation and should be built separately.
|
|
@@ -153,13 +205,22 @@ Search is a different operation and should be built separately.
|
|
|
153
205
|
`email + role` is the recommended exact operational lookup.
|
|
154
206
|
|
|
155
207
|
```ts
|
|
156
|
-
import {
|
|
208
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
157
209
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
158
|
-
|
|
159
|
-
|
|
210
|
+
import {
|
|
211
|
+
EmployeeBundleOperations,
|
|
212
|
+
EmployeeResourceTypes,
|
|
213
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
214
|
+
|
|
215
|
+
const employeeSearchBundle = new BundleEditor()
|
|
216
|
+
.setBundleOperation(EmployeeBundleOperations.search)
|
|
217
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
218
|
+
.newEntry()
|
|
219
|
+
.asEmployee()
|
|
160
220
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
161
221
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
162
|
-
.
|
|
222
|
+
.doneEntry()
|
|
223
|
+
.build();
|
|
163
224
|
|
|
164
225
|
console.log(employeeSearchBundle);
|
|
165
226
|
```
|
|
@@ -177,15 +238,20 @@ Disable is a lifecycle operation. Today the shared employee editor still
|
|
|
177
238
|
produces the canonical `_batch` bundle with inner `request.method = DELETE`.
|
|
178
239
|
|
|
179
240
|
```ts
|
|
180
|
-
import {
|
|
241
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
181
242
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
243
|
+
import {
|
|
244
|
+
EmployeeBundleOperations,
|
|
245
|
+
EmployeeResourceTypes,
|
|
246
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
247
|
+
|
|
248
|
+
const employeeDisableBatchBundle = new BundleEditor()
|
|
249
|
+
.setBundleOperation(EmployeeBundleOperations.disable)
|
|
250
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
251
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
252
|
+
.asEmployee()
|
|
253
|
+
.doneEntry()
|
|
254
|
+
.build();
|
|
189
255
|
|
|
190
256
|
console.log(employeeDisableBatchBundle);
|
|
191
257
|
```
|
|
@@ -202,12 +268,13 @@ Current GW CORE contract vs preferred target:
|
|
|
202
268
|
Conceptual `PATCH` example for state change:
|
|
203
269
|
|
|
204
270
|
```ts
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
271
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
272
|
+
|
|
273
|
+
const employeeDisablePatchBatchBundle = new BundleEditor()
|
|
274
|
+
.setBundleOperation(EmployeeBundleOperations.disable)
|
|
275
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
276
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
277
|
+
.asEmployee();
|
|
211
278
|
```
|
|
212
279
|
|
|
213
280
|
Business meaning:
|
|
@@ -219,19 +286,28 @@ Business meaning:
|
|
|
219
286
|
|
|
220
287
|
### Purge
|
|
221
288
|
|
|
222
|
-
Purge is not the same
|
|
223
|
-
|
|
224
|
-
|
|
289
|
+
Purge is not the same route as create/disable, but the frontend should still
|
|
290
|
+
prepare a `Bundle` for it. The portal backend or runtime later submits that
|
|
291
|
+
bundle to the explicit `Employee/_purge` flow. The canonical purge selector is
|
|
292
|
+
the employee `identifier`.
|
|
225
293
|
|
|
226
294
|
```ts
|
|
227
|
-
import {
|
|
295
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
228
296
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
297
|
+
import {
|
|
298
|
+
EmployeeBundleOperations,
|
|
299
|
+
EmployeeResourceTypes,
|
|
300
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
301
|
+
|
|
302
|
+
const employeePurgeBundle = new BundleEditor()
|
|
303
|
+
.setBundleOperation(EmployeeBundleOperations.purge)
|
|
304
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
305
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
306
|
+
.asEmployee()
|
|
307
|
+
.doneEntry()
|
|
308
|
+
.build();
|
|
309
|
+
|
|
310
|
+
console.log(employeePurgeBundle);
|
|
235
311
|
```
|
|
236
312
|
|
|
237
313
|
Primary references for those employee flows:
|
|
@@ -276,11 +352,15 @@ Minimal confidential-app example:
|
|
|
276
352
|
|
|
277
353
|
```ts
|
|
278
354
|
import { ClientSDK } from 'gdc-sdk-front-ts';
|
|
279
|
-
import {
|
|
355
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
280
356
|
import {
|
|
281
357
|
EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
|
|
282
358
|
EXAMPLE_PROFILE_SESSION_INPUT,
|
|
283
359
|
} from 'gdc-common-utils-ts/examples';
|
|
360
|
+
import {
|
|
361
|
+
EmployeeBundleOperations,
|
|
362
|
+
EmployeeResourceTypes,
|
|
363
|
+
} from 'gdc-common-utils-ts/utils/employee';
|
|
284
364
|
|
|
285
365
|
const appId = frontendAppConfig.appId;
|
|
286
366
|
const client = new ClientSDK({ appId });
|
|
@@ -290,11 +370,16 @@ const client = new ClientSDK({ appId });
|
|
|
290
370
|
// can later expose organization-controller/professional capabilities.
|
|
291
371
|
const session = await client.initializeSession(EXAMPLE_PROFILE_SESSION_INPUT);
|
|
292
372
|
|
|
293
|
-
// The shared editor from sdk-core is still used to model the employee bundle.
|
|
294
|
-
const employeeSearchBundle = new
|
|
373
|
+
// The shared bundle editor from sdk-core is still used to model the employee bundle.
|
|
374
|
+
const employeeSearchBundle = new BundleEditor()
|
|
375
|
+
.setBundleOperation(EmployeeBundleOperations.search)
|
|
376
|
+
.setAllowedResourceType(EmployeeResourceTypes.employee)
|
|
377
|
+
.newEntry()
|
|
378
|
+
.asEmployee()
|
|
295
379
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
296
380
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
297
|
-
.
|
|
381
|
+
.doneEntry()
|
|
382
|
+
.build();
|
|
298
383
|
|
|
299
384
|
console.log(session, employeeSearchBundle);
|
|
300
385
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-sdk-front-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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.
|
|
21
|
-
"gdc-sdk-core-ts": "^0.
|
|
20
|
+
"gdc-common-utils-ts": "^1.16.0",
|
|
21
|
+
"gdc-sdk-core-ts": "^0.8.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.14.10",
|