gdc-sdk-front-ts 0.7.0 → 0.8.1

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
@@ -78,6 +78,7 @@ Recommended entry point:
78
78
 
79
79
  Main references:
80
80
 
81
+ - [gdc-common-utils-ts/docs/101-EMPLOYEE_ENTRY_EDITOR.md](https://github.com/Global-DataCare/gdc-common-utils-ts/blob/main/docs/101-EMPLOYEE_ENTRY_EDITOR.md)
81
82
  - [gdc-sdk-core-ts/docs/101-EMPLOYEES.md](https://github.com/Global-DataCare/gdc-sdk-core-ts/blob/main/docs/101-EMPLOYEES.md)
82
83
  - [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
84
  - [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)
@@ -86,7 +87,7 @@ Main references:
86
87
 
87
88
  Use:
88
89
 
89
- - `BundleEditor` for employee create/search/disable/purge payloads
90
+ - `BundleEditor` plus `EmployeeEntryEditor` for employee create/search/disable/purge payloads
90
91
  - `CommunicationAttachedBundleSession` for `Communication`-carried bundles
91
92
  - `createConsentAccessEditor(...)` for consent editing inside a communication bundle
92
93
 
@@ -114,7 +115,7 @@ Those actor families should start from their own business flow:
114
115
 
115
116
  ### Create
116
117
 
117
- Use `BundleEditor` to prepare one employee create bundle. The browser
118
+ Use `BundleEditor` plus one employee entry editor to prepare one employee create bundle. The browser
118
119
  does not send it directly to GW CORE.
119
120
  The portal backend wraps it into its own request/envelope, then applies KMS,
120
121
  DIDComm, submit, and poll.
@@ -126,14 +127,21 @@ import {
126
127
  EXAMPLE_PROVIDER_ORGANIZATION_DID,
127
128
  } from 'gdc-common-utils-ts/examples';
128
129
  import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
129
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
130
+ import {
131
+ EmployeeBundleOperations,
132
+ EmployeeResourceTypes,
133
+ } from 'gdc-common-utils-ts/utils/employee';
130
134
 
131
135
  // This editor lives only in frontend memory.
132
136
  // It helps the UI build the canonical employee payload before sending it to
133
137
  // the portal backend.
134
138
  const bundle = new BundleEditor()
135
139
  .setBundleOperation(EmployeeBundleOperations.create)
140
+ .setAllowedResourceType(EmployeeResourceTypes.employee);
141
+
142
+ const employeeEntry = bundle
136
143
  .newEntry()
144
+ .asEmployee()
137
145
  .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
138
146
  .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
139
147
  .addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
@@ -141,8 +149,10 @@ const bundle = new BundleEditor()
141
149
  // `employeeCreateBatchBundle` is the canonical one-entry employee `_batch` bundle.
142
150
  // Your Vite frontend normally sends this bundle to its own backend, not
143
151
  // directly to GW CORE.
144
- const generatedEmployeeIdentifier = bundle.getIdentifier();
145
- const employeeCreateBatchBundle = bundle.doneEntry().build();
152
+ const generatedEmployeeIdentifier = employeeEntry.getIdentifier();
153
+ employeeEntry.doneEntry();
154
+
155
+ const employeeCreateBatchBundle = bundle.build();
146
156
  console.log(employeeCreateBatchBundle);
147
157
  ```
148
158
 
@@ -154,12 +164,18 @@ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
154
164
 
155
165
  const bundle = new BundleEditor()
156
166
  .setBundleOperation(EmployeeBundleOperations.create)
167
+ .setAllowedResourceType(EmployeeResourceTypes.employee);
168
+
169
+ const employeeEntry = bundle
157
170
  .newEntry()
171
+ .asEmployee()
158
172
  .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
159
173
  .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role);
160
174
 
161
- const employeeCreateBatchBundle = bundle.doneEntry().build();
162
- const generatedEmployeeIdentifier = bundle.getIdentifier();
175
+ const generatedEmployeeIdentifier = employeeEntry.getIdentifier();
176
+ employeeEntry.doneEntry();
177
+
178
+ const employeeCreateBatchBundle = bundle.build();
163
179
  ```
164
180
 
165
181
  If a frontend needs explicit claim-level control instead of only `setEmail()` /
@@ -172,18 +188,27 @@ import {
172
188
  EXAMPLE_PROVIDER_ORGANIZATION_DID,
173
189
  } from 'gdc-common-utils-ts/examples';
174
190
  import { ClaimsPersonSchemaorg } from 'gdc-common-utils-ts/constants/schemaorg';
175
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
191
+ import {
192
+ EmployeeBundleOperations,
193
+ EmployeeResourceTypes,
194
+ } from 'gdc-common-utils-ts/utils/employee';
176
195
 
177
196
  const bundle = new BundleEditor()
178
197
  .setBundleOperation(EmployeeBundleOperations.create)
198
+ .setAllowedResourceType(EmployeeResourceTypes.employee);
199
+
200
+ const employeeEntry = bundle
179
201
  .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
202
+ .asEmployee()
180
203
  .setClaim(ClaimsPersonSchemaorg.email, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
181
204
  .setClaim(ClaimsPersonSchemaorg.hasOccupationalRoleValue, EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
182
205
  .addClaim(ClaimsPersonSchemaorg.memberOf, EXAMPLE_PROVIDER_ORGANIZATION_DID);
183
206
 
184
- console.log(bundle.getClaim(ClaimsPersonSchemaorg.email));
207
+ console.log(employeeEntry.getClaim(ClaimsPersonSchemaorg.email));
208
+
209
+ employeeEntry.doneEntry();
185
210
 
186
- const employeeCreateBatchBundle = bundle.doneEntry().build();
211
+ const employeeCreateBatchBundle = bundle.build();
187
212
  ```
188
213
 
189
214
  ### Search
@@ -195,15 +220,23 @@ Search is a different operation and should be built separately.
195
220
  ```ts
196
221
  import { BundleEditor } from 'gdc-sdk-core-ts';
197
222
  import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
198
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
223
+ import {
224
+ EmployeeBundleOperations,
225
+ EmployeeResourceTypes,
226
+ } from 'gdc-common-utils-ts/utils/employee';
199
227
 
200
- const employeeSearchBundle = new BundleEditor()
228
+ const bundle = new BundleEditor()
201
229
  .setBundleOperation(EmployeeBundleOperations.search)
230
+ .setAllowedResourceType(EmployeeResourceTypes.employee);
231
+
232
+ bundle
202
233
  .newEntry()
234
+ .asEmployee()
203
235
  .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
204
236
  .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
205
- .doneEntry()
206
- .build();
237
+ .doneEntry();
238
+
239
+ const employeeSearchBundle = bundle.build();
207
240
 
208
241
  console.log(employeeSearchBundle);
209
242
  ```
@@ -223,13 +256,21 @@ produces the canonical `_batch` bundle with inner `request.method = DELETE`.
223
256
  ```ts
224
257
  import { BundleEditor } from 'gdc-sdk-core-ts';
225
258
  import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
226
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
259
+ import {
260
+ EmployeeBundleOperations,
261
+ EmployeeResourceTypes,
262
+ } from 'gdc-common-utils-ts/utils/employee';
227
263
 
228
- const employeeDisableBatchBundle = new BundleEditor()
264
+ const bundle = new BundleEditor()
229
265
  .setBundleOperation(EmployeeBundleOperations.disable)
266
+ .setAllowedResourceType(EmployeeResourceTypes.employee);
267
+
268
+ bundle
230
269
  .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
231
- .doneEntry()
232
- .build();
270
+ .asEmployee()
271
+ .doneEntry();
272
+
273
+ const employeeDisableBatchBundle = bundle.build();
233
274
 
234
275
  console.log(employeeDisableBatchBundle);
235
276
  ```
@@ -250,7 +291,9 @@ import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
250
291
 
251
292
  const employeeDisablePatchBatchBundle = new BundleEditor()
252
293
  .setBundleOperation(EmployeeBundleOperations.disable)
253
- .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier);
294
+ .setAllowedResourceType(EmployeeResourceTypes.employee)
295
+ .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
296
+ .asEmployee();
254
297
  ```
255
298
 
256
299
  Business meaning:
@@ -270,11 +313,16 @@ the employee `identifier`.
270
313
  ```ts
271
314
  import { BundleEditor } from 'gdc-sdk-core-ts';
272
315
  import { EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE } from 'gdc-common-utils-ts/examples';
273
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
316
+ import {
317
+ EmployeeBundleOperations,
318
+ EmployeeResourceTypes,
319
+ } from 'gdc-common-utils-ts/utils/employee';
274
320
 
275
321
  const employeePurgeBundle = new BundleEditor()
276
322
  .setBundleOperation(EmployeeBundleOperations.purge)
323
+ .setAllowedResourceType(EmployeeResourceTypes.employee)
277
324
  .newEntry(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.identifier)
325
+ .asEmployee()
278
326
  .doneEntry()
279
327
  .build();
280
328
 
@@ -328,7 +376,10 @@ import {
328
376
  EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE,
329
377
  EXAMPLE_PROFILE_SESSION_INPUT,
330
378
  } from 'gdc-common-utils-ts/examples';
331
- import { EmployeeBundleOperations } from 'gdc-common-utils-ts/utils/employee';
379
+ import {
380
+ EmployeeBundleOperations,
381
+ EmployeeResourceTypes,
382
+ } from 'gdc-common-utils-ts/utils/employee';
332
383
 
333
384
  const appId = frontendAppConfig.appId;
334
385
  const client = new ClientSDK({ appId });
@@ -338,10 +389,12 @@ const client = new ClientSDK({ appId });
338
389
  // can later expose organization-controller/professional capabilities.
339
390
  const session = await client.initializeSession(EXAMPLE_PROFILE_SESSION_INPUT);
340
391
 
341
- // The shared editor from sdk-core is still used to model the employee bundle.
392
+ // The shared bundle editor from sdk-core is still used to model the employee bundle.
342
393
  const employeeSearchBundle = new BundleEditor()
343
394
  .setBundleOperation(EmployeeBundleOperations.search)
395
+ .setAllowedResourceType(EmployeeResourceTypes.employee)
344
396
  .newEntry()
397
+ .asEmployee()
345
398
  .setEmail(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.email)
346
399
  .setRole(EXAMPLE_EMPLOYEE_DOCTOR_ACTIVE.role)
347
400
  .doneEntry()
@@ -198,6 +198,9 @@ export class ProfileManager {
198
198
  return new OrganizationControllerSdk(this.runtimeClient);
199
199
  }
200
200
  asOrganizationEmployee() {
201
+ if (this.profile.appType !== 'Organization') {
202
+ throw new Error('OrganizationEmployeeSdk is not available for this profile.');
203
+ }
201
204
  return new OrganizationEmployeeSdk(this.runtimeClient);
202
205
  }
203
206
  asIndividualController() {
@@ -217,7 +220,7 @@ export class ProfileManager {
217
220
  return new PersonalSdk(this.runtimeClient);
218
221
  }
219
222
  asProfessional() {
220
- if (!this.professional?.physician && !this.professional?.paramedic && !this.individual?.service) {
223
+ if (!this.professional?.physician && !this.professional?.paramedic) {
221
224
  throw new Error('ProfessionalSdk is not available for this profile.');
222
225
  }
223
226
  return new ProfessionalSdk(this.runtimeClient);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-front-ts",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
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.15.0",
21
- "gdc-sdk-core-ts": "^0.7.0"
20
+ "gdc-common-utils-ts": "^1.16.0",
21
+ "gdc-sdk-core-ts": "^0.8.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^20.14.10",