gdc-sdk-front-ts 0.6.7 → 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.
- package/README.md +87 -36
- 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` 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,26 @@ Those actor families should start from their own business flow:
|
|
|
114
114
|
|
|
115
115
|
### Create
|
|
116
116
|
|
|
117
|
-
Use `
|
|
117
|
+
Use `BundleEditor` 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 { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
129
130
|
|
|
130
131
|
// This editor lives only in frontend memory.
|
|
131
132
|
// It helps the UI build the canonical employee payload before sending it to
|
|
132
133
|
// the portal backend.
|
|
133
|
-
const
|
|
134
|
-
.
|
|
134
|
+
const bundle = new BundleEditor()
|
|
135
|
+
.setBundleOperation(EmployeeBundleOperations.create)
|
|
136
|
+
.newEntry()
|
|
135
137
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
136
138
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
137
139
|
.addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
|
|
@@ -139,13 +141,51 @@ const bundleEditor = new EmployeeBundleSession()
|
|
|
139
141
|
// `employeeCreateBatchBundle` is the canonical one-entry employee `_batch` bundle.
|
|
140
142
|
// Your Vite frontend normally sends this bundle to its own backend, not
|
|
141
143
|
// directly to GW CORE.
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
resourceId: EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier,
|
|
145
|
-
});
|
|
144
|
+
const generatedEmployeeIdentifier = bundle.getIdentifier();
|
|
145
|
+
const employeeCreateBatchBundle = bundle.doneEntry().build();
|
|
146
146
|
console.log(employeeCreateBatchBundle);
|
|
147
147
|
```
|
|
148
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
|
+
|
|
149
189
|
### Search
|
|
150
190
|
|
|
151
191
|
Search is a different operation and should be built separately.
|
|
@@ -153,13 +193,17 @@ Search is a different operation and should be built separately.
|
|
|
153
193
|
`email + role` is the recommended exact operational lookup.
|
|
154
194
|
|
|
155
195
|
```ts
|
|
156
|
-
import {
|
|
196
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
157
197
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
198
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
158
199
|
|
|
159
|
-
const employeeSearchBundle = new
|
|
200
|
+
const employeeSearchBundle = new BundleEditor()
|
|
201
|
+
.setBundleOperation(EmployeeBundleOperations.search)
|
|
202
|
+
.newEntry()
|
|
160
203
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
161
204
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
162
|
-
.
|
|
205
|
+
.doneEntry()
|
|
206
|
+
.build();
|
|
163
207
|
|
|
164
208
|
console.log(employeeSearchBundle);
|
|
165
209
|
```
|
|
@@ -177,15 +221,15 @@ Disable is a lifecycle operation. Today the shared employee editor still
|
|
|
177
221
|
produces the canonical `_batch` bundle with inner `request.method = DELETE`.
|
|
178
222
|
|
|
179
223
|
```ts
|
|
180
|
-
import {
|
|
224
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
181
225
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
226
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
182
227
|
|
|
183
|
-
const employeeDisableBatchBundle = new
|
|
184
|
-
.
|
|
185
|
-
.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
228
|
+
const employeeDisableBatchBundle = new BundleEditor()
|
|
229
|
+
.setBundleOperation(EmployeeBundleOperations.disable)
|
|
230
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
231
|
+
.doneEntry()
|
|
232
|
+
.build();
|
|
189
233
|
|
|
190
234
|
console.log(employeeDisableBatchBundle);
|
|
191
235
|
```
|
|
@@ -202,12 +246,11 @@ Current GW CORE contract vs preferred target:
|
|
|
202
246
|
Conceptual `PATCH` example for state change:
|
|
203
247
|
|
|
204
248
|
```ts
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
});
|
|
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);
|
|
211
254
|
```
|
|
212
255
|
|
|
213
256
|
Business meaning:
|
|
@@ -219,19 +262,23 @@ Business meaning:
|
|
|
219
262
|
|
|
220
263
|
### Purge
|
|
221
264
|
|
|
222
|
-
Purge is not the same
|
|
223
|
-
|
|
224
|
-
|
|
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`.
|
|
225
269
|
|
|
226
270
|
```ts
|
|
227
|
-
import {
|
|
271
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
228
272
|
import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
|
|
273
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
229
274
|
|
|
230
|
-
const
|
|
231
|
-
.
|
|
232
|
-
.
|
|
275
|
+
const employeePurgeBundle = new BundleEditor()
|
|
276
|
+
.setBundleOperation(EmployeeBundleOperations.purge)
|
|
277
|
+
.newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
|
|
278
|
+
.doneEntry()
|
|
279
|
+
.build();
|
|
233
280
|
|
|
234
|
-
console.log(
|
|
281
|
+
console.log(employeePurgeBundle);
|
|
235
282
|
```
|
|
236
283
|
|
|
237
284
|
Primary references for those employee flows:
|
|
@@ -276,11 +323,12 @@ Minimal confidential-app example:
|
|
|
276
323
|
|
|
277
324
|
```ts
|
|
278
325
|
import { ClientSDK } from 'gdc-sdk-front-ts';
|
|
279
|
-
import {
|
|
326
|
+
import { BundleEditor } from 'gdc-sdk-core-ts';
|
|
280
327
|
import {
|
|
281
328
|
EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
|
|
282
329
|
EXAMPLE_PROFILE_SESSION_INPUT,
|
|
283
330
|
} from 'gdc-common-utils-ts/examples';
|
|
331
|
+
import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
|
|
284
332
|
|
|
285
333
|
const appId = frontendAppConfig.appId;
|
|
286
334
|
const client = new ClientSDK({ appId });
|
|
@@ -291,10 +339,13 @@ const client = new ClientSDK({ appId });
|
|
|
291
339
|
const session = await client.initializeSession(EXAMPLE_PROFILE_SESSION_INPUT);
|
|
292
340
|
|
|
293
341
|
// The shared editor from sdk-core is still used to model the employee bundle.
|
|
294
|
-
const employeeSearchBundle = new
|
|
342
|
+
const employeeSearchBundle = new BundleEditor()
|
|
343
|
+
.setBundleOperation(EmployeeBundleOperations.search)
|
|
344
|
+
.newEntry()
|
|
295
345
|
.setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
|
|
296
346
|
.setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
|
|
297
|
-
.
|
|
347
|
+
.doneEntry()
|
|
348
|
+
.build();
|
|
298
349
|
|
|
299
350
|
console.log(session, employeeSearchBundle);
|
|
300
351
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-sdk-front-ts",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
21
|
-
"gdc-sdk-core-ts": "^0.
|
|
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",
|