@halix/action-sdk 1.0.45 → 1.0.47
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/lib/cjs/access.js +171 -12
- package/lib/cjs/index.js +14 -2
- package/lib/cjs/sdk-general.js +0 -3
- package/lib/cjs/types/access.d.ts +110 -7
- package/lib/cjs/types/access.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +1 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/sdk-general.d.ts +0 -1
- package/lib/cjs/types/sdk-general.d.ts.map +1 -1
- package/lib/esm/access.js +153 -13
- package/lib/esm/access.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +1 -1
- package/lib/esm/sdk-general.js +0 -3
- package/lib/esm/sdk-general.js.map +1 -1
- package/lib/esm/types/access.d.ts +110 -7
- package/lib/esm/types/index.d.ts +1 -1
- package/lib/esm/types/sdk-general.d.ts +0 -1
- package/package.json +1 -1
package/lib/cjs/access.js
CHANGED
|
@@ -35,7 +35,19 @@ exports.updateUserAccessAsObservable = updateUserAccessAsObservable;
|
|
|
35
35
|
exports.removeUserAccess = removeUserAccess;
|
|
36
36
|
exports.removeUserAccessAsObservable = removeUserAccessAsObservable;
|
|
37
37
|
exports.hasBusinessPrivilege = hasBusinessPrivilege;
|
|
38
|
+
exports.hasBusinessPrivilegeAsObservable = hasBusinessPrivilegeAsObservable;
|
|
38
39
|
exports.userPrivileges = userPrivileges;
|
|
40
|
+
exports.userPrivilegesAsObservable = userPrivilegesAsObservable;
|
|
41
|
+
exports.dataElementAccess = dataElementAccess;
|
|
42
|
+
exports.dataElementAccessAsObservable = dataElementAccessAsObservable;
|
|
43
|
+
exports.hasDataElementAccess = hasDataElementAccess;
|
|
44
|
+
exports.hasDataElementAccessAsObservable = hasDataElementAccessAsObservable;
|
|
45
|
+
exports.canReadDataElement = canReadDataElement;
|
|
46
|
+
exports.canReadDataElementAsObservable = canReadDataElementAsObservable;
|
|
47
|
+
exports.canWriteDataElement = canWriteDataElement;
|
|
48
|
+
exports.canWriteDataElementAsObservable = canWriteDataElementAsObservable;
|
|
49
|
+
exports.canDeleteDataElement = canDeleteDataElement;
|
|
50
|
+
exports.canDeleteDataElementAsObservable = canDeleteDataElementAsObservable;
|
|
39
51
|
/**
|
|
40
52
|
* @module @halix/action-sdk/access
|
|
41
53
|
* @description Access, roles, business privileges, invitations, and user scope assignment for the Halix Platform action SDK.
|
|
@@ -45,8 +57,11 @@ exports.userPrivileges = userPrivileges;
|
|
|
45
57
|
* Key concepts:
|
|
46
58
|
* - `Role.id` is the stable semantic role identifier used by configuration and generated code.
|
|
47
59
|
* - `Role.objKey` is the persisted role object key. APIs that accept `roleKeys` require `Role.objKey`, not `Role.id`.
|
|
48
|
-
* - `BusinessPrivilege.id` is the stable privilege identifier used by
|
|
60
|
+
* - `BusinessPrivilege.id` is the stable privilege identifier used by server-validated checks such as `hasBusinessPrivilege`.
|
|
61
|
+
* - Data element access checks use stable data element IDs and resolve to persisted keys on the server.
|
|
49
62
|
* - `ScopeKeyItem` entries define the data scope a user receives for an organization, user proxy, or custom data scope.
|
|
63
|
+
* - `inviteUser` invites an existing unlinked user proxy record. Create or select that record first, then pass its
|
|
64
|
+
* object key as `userProxyKey`.
|
|
50
65
|
*
|
|
51
66
|
* @usage
|
|
52
67
|
* ## When to Use
|
|
@@ -74,8 +89,13 @@ exports.userPrivileges = userPrivileges;
|
|
|
74
89
|
* | `inviteUser` | Invite a new user and assign initial role keys/scopes |
|
|
75
90
|
* | `updateUserAccess` | Add or update one user scope entry |
|
|
76
91
|
* | `removeUserAccess` | Remove one user scope entry |
|
|
77
|
-
* | `hasBusinessPrivilege` |
|
|
78
|
-
* | `userPrivileges` |
|
|
92
|
+
* | `hasBusinessPrivilege` | Server-check whether the current user has a privilege ID |
|
|
93
|
+
* | `userPrivileges` | Server-read the current user's privilege IDs |
|
|
94
|
+
* | `dataElementAccess` | Server-check current user's read/write/delete access to a data element ID |
|
|
95
|
+
* | `hasDataElementAccess` | Server-check one read/write/delete access mode |
|
|
96
|
+
* | `canReadDataElement` | Server-check read access to a data element ID |
|
|
97
|
+
* | `canWriteDataElement` | Server-check write access to a data element ID |
|
|
98
|
+
* | `canDeleteDataElement` | Server-check delete access to a data element ID |
|
|
79
99
|
*
|
|
80
100
|
* @example
|
|
81
101
|
* // Resolve a semantic role ID to the persisted object key before assignment
|
|
@@ -91,9 +111,29 @@ exports.userPrivileges = userPrivileges;
|
|
|
91
111
|
*
|
|
92
112
|
* @example
|
|
93
113
|
* // Check the current user's business privilege
|
|
94
|
-
* if (hx.hasBusinessPrivilege('manageSharedLists')) {
|
|
114
|
+
* if (await hx.hasBusinessPrivilege('manageSharedLists')) {
|
|
95
115
|
* // Show controls for sharing list access
|
|
96
116
|
* }
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Invite an existing unlinked user proxy record
|
|
120
|
+
* const roles = await hx.listRoles();
|
|
121
|
+
* const memberRole = roles.find((role) => role.id === 'householdMember');
|
|
122
|
+
* if (!memberRole?.objKey) {
|
|
123
|
+
* throw new Error('Required role not found.');
|
|
124
|
+
* }
|
|
125
|
+
* await hx.inviteUser({
|
|
126
|
+
* email: 'new-member@example.com',
|
|
127
|
+
* userProxyElementId: 'familyMember',
|
|
128
|
+
* userProxyKey: pendingFamilyMember.objKey,
|
|
129
|
+
* roleKeys: [memberRole.objKey],
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Check current user's data access before showing a CRUD control
|
|
134
|
+
* if (await hx.canWriteDataElement('shoppingList')) {
|
|
135
|
+
* // Show controls that create or update shopping list records
|
|
136
|
+
* }
|
|
97
137
|
*/
|
|
98
138
|
const axios_1 = __importDefault(require("axios"));
|
|
99
139
|
const rxjs_1 = require("rxjs");
|
|
@@ -195,6 +235,9 @@ function getUserAccessAsObservable(userKey) {
|
|
|
195
235
|
/**
|
|
196
236
|
* Invites a user by email and assigns initial sandbox access.
|
|
197
237
|
*
|
|
238
|
+
* The target user proxy record must already exist and be unlinked. Pass that record's persisted object key in
|
|
239
|
+
* `req.userProxyKey` and its data element ID in `req.userProxyElementId`.
|
|
240
|
+
*
|
|
198
241
|
* `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs. Resolve desired
|
|
199
242
|
* semantic IDs with `listRoles` before calling this function.
|
|
200
243
|
*
|
|
@@ -259,21 +302,137 @@ function removeUserAccessAsObservable(userKey, scopeElementId) {
|
|
|
259
302
|
return (0, rxjs_1.from)(removeUserAccess(userKey, scopeElementId));
|
|
260
303
|
}
|
|
261
304
|
/**
|
|
262
|
-
* Checks whether the
|
|
305
|
+
* Checks whether the authenticated user has a business privilege ID by calling the access service.
|
|
306
|
+
*
|
|
307
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
308
|
+
* Treat this as an authorization check and await the server response.
|
|
263
309
|
*
|
|
264
310
|
* @param privilegeId - Stable business privilege ID
|
|
265
|
-
* @returns
|
|
311
|
+
* @returns Promise resolving to true when the current user has the privilege
|
|
266
312
|
*/
|
|
267
313
|
function hasBusinessPrivilege(privilegeId) {
|
|
268
|
-
|
|
269
|
-
|
|
314
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
const response = yield axios_1.default.get(`${sdk_general_1.serviceAddress}/access/sandboxes/${sdk_general_1.sandboxKey}/businessPrivileges/${encodeURIComponent(privilegeId)}/currentUserHasPrivilege`, {
|
|
316
|
+
headers: yield authHeaders(),
|
|
317
|
+
});
|
|
318
|
+
return response.data.hasPrivilege;
|
|
319
|
+
});
|
|
270
320
|
}
|
|
271
321
|
/**
|
|
272
|
-
*
|
|
322
|
+
* Observable version of `hasBusinessPrivilege`. See `hasBusinessPrivilege` for details.
|
|
323
|
+
*/
|
|
324
|
+
function hasBusinessPrivilegeAsObservable(privilegeId) {
|
|
325
|
+
return (0, rxjs_1.from)(hasBusinessPrivilege(privilegeId));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Returns the authenticated user's business privilege IDs by calling the access service.
|
|
273
329
|
*
|
|
274
|
-
*
|
|
330
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
331
|
+
*
|
|
332
|
+
* @returns Promise resolving to business privilege IDs for the current user
|
|
275
333
|
*/
|
|
276
334
|
function userPrivileges() {
|
|
277
|
-
|
|
278
|
-
|
|
335
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
336
|
+
var _a;
|
|
337
|
+
const response = yield axios_1.default.get(`${sdk_general_1.serviceAddress}/access/sandboxes/${sdk_general_1.sandboxKey}/currentBusinessPrivileges`, {
|
|
338
|
+
headers: yield authHeaders(),
|
|
339
|
+
});
|
|
340
|
+
if (Array.isArray(response.data)) {
|
|
341
|
+
return response.data;
|
|
342
|
+
}
|
|
343
|
+
return (_a = response.data.businessPrivileges) !== null && _a !== void 0 ? _a : [];
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Observable version of `userPrivileges`. See `userPrivileges` for details.
|
|
348
|
+
*/
|
|
349
|
+
function userPrivilegesAsObservable() {
|
|
350
|
+
return (0, rxjs_1.from)(userPrivileges());
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Checks the authenticated user's data element read/write/delete access through the access service.
|
|
354
|
+
*
|
|
355
|
+
* The caller passes the stable data element ID. The server resolves that ID to the persisted data element key before
|
|
356
|
+
* checking the user's token, so generated code does not need to manage ID-to-key mappings.
|
|
357
|
+
*
|
|
358
|
+
* @param dataElementId - Stable data element ID
|
|
359
|
+
* @returns Promise resolving to the current user's data element access flags
|
|
360
|
+
*/
|
|
361
|
+
function dataElementAccess(dataElementId) {
|
|
362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
363
|
+
const response = yield axios_1.default.get(`${sdk_general_1.serviceAddress}/access/sandboxes/${sdk_general_1.sandboxKey}/dataElements/${encodeURIComponent(dataElementId)}/currentUserAccess`, {
|
|
364
|
+
headers: yield authHeaders(),
|
|
365
|
+
});
|
|
366
|
+
return response.data;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Observable version of `dataElementAccess`. See `dataElementAccess` for details.
|
|
371
|
+
*/
|
|
372
|
+
function dataElementAccessAsObservable(dataElementId) {
|
|
373
|
+
return (0, rxjs_1.from)(dataElementAccess(dataElementId));
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Checks one data element access mode for the authenticated user through the access service.
|
|
377
|
+
*
|
|
378
|
+
* @param dataElementId - Stable data element ID
|
|
379
|
+
* @param access - Access mode to check: `read`, `write`, or `delete`
|
|
380
|
+
* @returns Promise resolving to true when the current user has the requested data access
|
|
381
|
+
*/
|
|
382
|
+
function hasDataElementAccess(dataElementId, access) {
|
|
383
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
+
const result = yield dataElementAccess(dataElementId);
|
|
385
|
+
switch (access) {
|
|
386
|
+
case 'read':
|
|
387
|
+
return result.canRead;
|
|
388
|
+
case 'write':
|
|
389
|
+
return result.canWrite;
|
|
390
|
+
case 'delete':
|
|
391
|
+
return result.canDelete;
|
|
392
|
+
default:
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Observable version of `hasDataElementAccess`. See `hasDataElementAccess` for details.
|
|
399
|
+
*/
|
|
400
|
+
function hasDataElementAccessAsObservable(dataElementId, access) {
|
|
401
|
+
return (0, rxjs_1.from)(hasDataElementAccess(dataElementId, access));
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Checks whether the authenticated user can read records for a data element ID.
|
|
405
|
+
*/
|
|
406
|
+
function canReadDataElement(dataElementId) {
|
|
407
|
+
return hasDataElementAccess(dataElementId, 'read');
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Observable version of `canReadDataElement`. See `canReadDataElement` for details.
|
|
411
|
+
*/
|
|
412
|
+
function canReadDataElementAsObservable(dataElementId) {
|
|
413
|
+
return (0, rxjs_1.from)(canReadDataElement(dataElementId));
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Checks whether the authenticated user can create or update records for a data element ID.
|
|
417
|
+
*/
|
|
418
|
+
function canWriteDataElement(dataElementId) {
|
|
419
|
+
return hasDataElementAccess(dataElementId, 'write');
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Observable version of `canWriteDataElement`. See `canWriteDataElement` for details.
|
|
423
|
+
*/
|
|
424
|
+
function canWriteDataElementAsObservable(dataElementId) {
|
|
425
|
+
return (0, rxjs_1.from)(canWriteDataElement(dataElementId));
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Checks whether the authenticated user can delete records for a data element ID.
|
|
429
|
+
*/
|
|
430
|
+
function canDeleteDataElement(dataElementId) {
|
|
431
|
+
return hasDataElementAccess(dataElementId, 'delete');
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Observable version of `canDeleteDataElement`. See `canDeleteDataElement` for details.
|
|
435
|
+
*/
|
|
436
|
+
function canDeleteDataElementAsObservable(dataElementId) {
|
|
437
|
+
return (0, rxjs_1.from)(canDeleteDataElement(dataElementId));
|
|
279
438
|
}
|
package/lib/cjs/index.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// Unauthorized use outside the Halix platform is prohibited.
|
|
9
9
|
// Full license terms available in the LICENSE file.
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
exports.debounceFn = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.sendAIMessageAsObservable = exports.sendAIMessage = exports.submitStandalonePaymentAsObservable = exports.submitStandalonePayment = exports.getAggregateDataAsObservable = exports.getAggregateData = exports.AggregationResponse = exports.massDeleteAsObservable = exports.massDelete = exports.massEditAsObservable = exports.massEdit = exports.getListDataAsObservable = exports.getListData = exports.getOrganizationPreferenceAsObservable = exports.getUserPreferenceAsObservable = exports.getOrganizationPreference = exports.getUserPreference = exports.sendMessageAsObservable = exports.sendMessage = exports.MessageMethod = exports.downloadResourceAsObservable = exports.downloadResource = exports.createOrUpdateResourceAsObservable = exports.createOrUpdateResource = void 0;
|
|
11
|
+
exports.hasDataElementAccessAsObservable = exports.hasDataElementAccess = exports.dataElementAccessAsObservable = exports.dataElementAccess = exports.userPrivilegesAsObservable = exports.userPrivileges = exports.hasBusinessPrivilegeAsObservable = exports.hasBusinessPrivilege = exports.removeUserAccessAsObservable = exports.removeUserAccess = exports.updateUserAccessAsObservable = exports.updateUserAccess = exports.inviteUserAsObservable = exports.inviteUser = exports.getUserAccessAsObservable = exports.getUserAccess = exports.listSandboxUsersAsObservable = exports.listSandboxUsers = exports.listBusinessPrivilegesAsObservable = exports.listBusinessPrivileges = exports.listRolesAsObservable = exports.listRoles = exports.deleteRelatedObjectsAsObservable = exports.deleteRelatedObjects = exports.deleteRelatedObjectAsObservable = exports.deleteRelatedObject = exports.deleteObjectAsObservable = exports.deleteObject = exports.saveRelatedObjectAsObservable = exports.saveRelatedObject = exports.saveObjectAsObservable = exports.saveObject = exports.getObjectsAsObservable = exports.getObjects = exports.getAccessibleObjectsAsObservable = exports.getAccessibleObjects = exports.getRelatedObjectsAsObservable = exports.getRelatedObjects = exports.getObjectAsObservable = exports.getObject = exports.prepareErrorResponse = exports.prepareSuccessResponse = exports.initialize = exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.getAuthToken = void 0;
|
|
12
|
+
exports.debounceFn = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.sendAIMessageAsObservable = exports.sendAIMessage = exports.submitStandalonePaymentAsObservable = exports.submitStandalonePayment = exports.getAggregateDataAsObservable = exports.getAggregateData = exports.AggregationResponse = exports.massDeleteAsObservable = exports.massDelete = exports.massEditAsObservable = exports.massEdit = exports.getListDataAsObservable = exports.getListData = exports.getOrganizationPreferenceAsObservable = exports.getUserPreferenceAsObservable = exports.getOrganizationPreference = exports.getUserPreference = exports.sendMessageAsObservable = exports.sendMessage = exports.MessageMethod = exports.downloadResourceAsObservable = exports.downloadResource = exports.createOrUpdateResourceAsObservable = exports.createOrUpdateResource = exports.sendFileContentsAsObservable = exports.sendFileContents = exports.saveResourceAsObservable = exports.saveResource = exports.getOrCreateResourceAsObservable = exports.getOrCreateResource = exports.canDeleteDataElementAsObservable = exports.canDeleteDataElement = exports.canWriteDataElementAsObservable = exports.canWriteDataElement = exports.canReadDataElementAsObservable = exports.canReadDataElement = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* @module @halix/action-sdk
|
|
15
15
|
* @description Halix Platform action SDK for developing NodeJS Lambda-based actions on the Halix
|
|
@@ -76,7 +76,19 @@ Object.defineProperty(exports, "updateUserAccessAsObservable", { enumerable: tru
|
|
|
76
76
|
Object.defineProperty(exports, "removeUserAccess", { enumerable: true, get: function () { return access_1.removeUserAccess; } });
|
|
77
77
|
Object.defineProperty(exports, "removeUserAccessAsObservable", { enumerable: true, get: function () { return access_1.removeUserAccessAsObservable; } });
|
|
78
78
|
Object.defineProperty(exports, "hasBusinessPrivilege", { enumerable: true, get: function () { return access_1.hasBusinessPrivilege; } });
|
|
79
|
+
Object.defineProperty(exports, "hasBusinessPrivilegeAsObservable", { enumerable: true, get: function () { return access_1.hasBusinessPrivilegeAsObservable; } });
|
|
79
80
|
Object.defineProperty(exports, "userPrivileges", { enumerable: true, get: function () { return access_1.userPrivileges; } });
|
|
81
|
+
Object.defineProperty(exports, "userPrivilegesAsObservable", { enumerable: true, get: function () { return access_1.userPrivilegesAsObservable; } });
|
|
82
|
+
Object.defineProperty(exports, "dataElementAccess", { enumerable: true, get: function () { return access_1.dataElementAccess; } });
|
|
83
|
+
Object.defineProperty(exports, "dataElementAccessAsObservable", { enumerable: true, get: function () { return access_1.dataElementAccessAsObservable; } });
|
|
84
|
+
Object.defineProperty(exports, "hasDataElementAccess", { enumerable: true, get: function () { return access_1.hasDataElementAccess; } });
|
|
85
|
+
Object.defineProperty(exports, "hasDataElementAccessAsObservable", { enumerable: true, get: function () { return access_1.hasDataElementAccessAsObservable; } });
|
|
86
|
+
Object.defineProperty(exports, "canReadDataElement", { enumerable: true, get: function () { return access_1.canReadDataElement; } });
|
|
87
|
+
Object.defineProperty(exports, "canReadDataElementAsObservable", { enumerable: true, get: function () { return access_1.canReadDataElementAsObservable; } });
|
|
88
|
+
Object.defineProperty(exports, "canWriteDataElement", { enumerable: true, get: function () { return access_1.canWriteDataElement; } });
|
|
89
|
+
Object.defineProperty(exports, "canWriteDataElementAsObservable", { enumerable: true, get: function () { return access_1.canWriteDataElementAsObservable; } });
|
|
90
|
+
Object.defineProperty(exports, "canDeleteDataElement", { enumerable: true, get: function () { return access_1.canDeleteDataElement; } });
|
|
91
|
+
Object.defineProperty(exports, "canDeleteDataElementAsObservable", { enumerable: true, get: function () { return access_1.canDeleteDataElementAsObservable; } });
|
|
80
92
|
// ================================================================================
|
|
81
93
|
// CONTENT FUNCTIONS
|
|
82
94
|
// ================================================================================
|
package/lib/cjs/sdk-general.js
CHANGED
|
@@ -39,9 +39,6 @@ function initialize(event) {
|
|
|
39
39
|
}
|
|
40
40
|
if (body) {
|
|
41
41
|
({ sandboxKey: exports.sandboxKey, serviceAddress: exports.serviceAddress, actionSubject: exports.actionSubject, userContext: exports.userContext, params: exports.params } = body);
|
|
42
|
-
if (exports.userContext && !exports.userContext.businessPrivileges) {
|
|
43
|
-
exports.userContext.businessPrivileges = [];
|
|
44
|
-
}
|
|
45
42
|
if (body.authToken) {
|
|
46
43
|
exports.getAuthToken = () => (0, rxjs_1.of)(body.authToken);
|
|
47
44
|
}
|
|
@@ -92,7 +92,9 @@ export interface InviteUserRequest {
|
|
|
92
92
|
lastName?: string;
|
|
93
93
|
/** User proxy data element ID used to create or link the user proxy record. */
|
|
94
94
|
userProxyElementId: string;
|
|
95
|
-
/**
|
|
95
|
+
/** Existing unlinked user proxy object key to invite or link. */
|
|
96
|
+
userProxyKey: string;
|
|
97
|
+
/** Optional organization proxy object key for context; this is not a substitute for `userProxyKey`. */
|
|
96
98
|
orgProxyKey?: string;
|
|
97
99
|
/** Persisted role object keys (`Role.objKey`). Never pass semantic `Role.id` values here. */
|
|
98
100
|
roleKeys: string[];
|
|
@@ -126,6 +128,41 @@ export interface UpdateAccessRequest {
|
|
|
126
128
|
/** Whether this scope entry should apply globally instead of being limited to the provided scopes. */
|
|
127
129
|
globalAccess?: boolean;
|
|
128
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Server response for current-user business privilege checks.
|
|
133
|
+
*/
|
|
134
|
+
export interface BusinessPrivilegeCheckResult {
|
|
135
|
+
/** Checked business privilege ID. */
|
|
136
|
+
businessPrivilegeId: string;
|
|
137
|
+
/** Whether the authenticated user has the privilege in the current sandbox. */
|
|
138
|
+
hasPrivilege: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Server response for current-user business privilege lists.
|
|
142
|
+
*/
|
|
143
|
+
export interface CurrentBusinessPrivilegesResult {
|
|
144
|
+
/** Business privilege IDs granted to the authenticated user in the current sandbox. */
|
|
145
|
+
businessPrivileges: string[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Data element access mode for current-user R/W/D privilege checks.
|
|
149
|
+
*/
|
|
150
|
+
export type DataElementAccessMode = 'read' | 'write' | 'delete';
|
|
151
|
+
/**
|
|
152
|
+
* Server response for current-user data element access checks.
|
|
153
|
+
*/
|
|
154
|
+
export interface DataElementAccessResult {
|
|
155
|
+
/** Stable data element ID requested by the caller. */
|
|
156
|
+
dataElementId: string;
|
|
157
|
+
/** Persisted data element object key resolved by the server. */
|
|
158
|
+
dataElementKey: string;
|
|
159
|
+
/** Whether the authenticated user can read records for this data element. */
|
|
160
|
+
canRead: boolean;
|
|
161
|
+
/** Whether the authenticated user can create or update records for this data element. */
|
|
162
|
+
canWrite: boolean;
|
|
163
|
+
/** Whether the authenticated user can delete records for this data element. */
|
|
164
|
+
canDelete: boolean;
|
|
165
|
+
}
|
|
129
166
|
/**
|
|
130
167
|
* Lists roles available in the current sandbox.
|
|
131
168
|
*
|
|
@@ -178,6 +215,9 @@ export declare function getUserAccessAsObservable(userKey: string): Observable<U
|
|
|
178
215
|
/**
|
|
179
216
|
* Invites a user by email and assigns initial sandbox access.
|
|
180
217
|
*
|
|
218
|
+
* The target user proxy record must already exist and be unlinked. Pass that record's persisted object key in
|
|
219
|
+
* `req.userProxyKey` and its data element ID in `req.userProxyElementId`.
|
|
220
|
+
*
|
|
181
221
|
* `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs. Resolve desired
|
|
182
222
|
* semantic IDs with `listRoles` before calling this function.
|
|
183
223
|
*
|
|
@@ -215,16 +255,79 @@ export declare function removeUserAccess(userKey: string, scopeElementId: string
|
|
|
215
255
|
*/
|
|
216
256
|
export declare function removeUserAccessAsObservable(userKey: string, scopeElementId: string): Observable<void>;
|
|
217
257
|
/**
|
|
218
|
-
* Checks whether the
|
|
258
|
+
* Checks whether the authenticated user has a business privilege ID by calling the access service.
|
|
259
|
+
*
|
|
260
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
261
|
+
* Treat this as an authorization check and await the server response.
|
|
219
262
|
*
|
|
220
263
|
* @param privilegeId - Stable business privilege ID
|
|
221
|
-
* @returns
|
|
264
|
+
* @returns Promise resolving to true when the current user has the privilege
|
|
265
|
+
*/
|
|
266
|
+
export declare function hasBusinessPrivilege(privilegeId: string): Promise<boolean>;
|
|
267
|
+
/**
|
|
268
|
+
* Observable version of `hasBusinessPrivilege`. See `hasBusinessPrivilege` for details.
|
|
269
|
+
*/
|
|
270
|
+
export declare function hasBusinessPrivilegeAsObservable(privilegeId: string): Observable<boolean>;
|
|
271
|
+
/**
|
|
272
|
+
* Returns the authenticated user's business privilege IDs by calling the access service.
|
|
273
|
+
*
|
|
274
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
275
|
+
*
|
|
276
|
+
* @returns Promise resolving to business privilege IDs for the current user
|
|
277
|
+
*/
|
|
278
|
+
export declare function userPrivileges(): Promise<string[]>;
|
|
279
|
+
/**
|
|
280
|
+
* Observable version of `userPrivileges`. See `userPrivileges` for details.
|
|
222
281
|
*/
|
|
223
|
-
export declare function
|
|
282
|
+
export declare function userPrivilegesAsObservable(): Observable<string[]>;
|
|
224
283
|
/**
|
|
225
|
-
*
|
|
284
|
+
* Checks the authenticated user's data element read/write/delete access through the access service.
|
|
285
|
+
*
|
|
286
|
+
* The caller passes the stable data element ID. The server resolves that ID to the persisted data element key before
|
|
287
|
+
* checking the user's token, so generated code does not need to manage ID-to-key mappings.
|
|
226
288
|
*
|
|
227
|
-
* @
|
|
289
|
+
* @param dataElementId - Stable data element ID
|
|
290
|
+
* @returns Promise resolving to the current user's data element access flags
|
|
291
|
+
*/
|
|
292
|
+
export declare function dataElementAccess(dataElementId: string): Promise<DataElementAccessResult>;
|
|
293
|
+
/**
|
|
294
|
+
* Observable version of `dataElementAccess`. See `dataElementAccess` for details.
|
|
295
|
+
*/
|
|
296
|
+
export declare function dataElementAccessAsObservable(dataElementId: string): Observable<DataElementAccessResult>;
|
|
297
|
+
/**
|
|
298
|
+
* Checks one data element access mode for the authenticated user through the access service.
|
|
299
|
+
*
|
|
300
|
+
* @param dataElementId - Stable data element ID
|
|
301
|
+
* @param access - Access mode to check: `read`, `write`, or `delete`
|
|
302
|
+
* @returns Promise resolving to true when the current user has the requested data access
|
|
303
|
+
*/
|
|
304
|
+
export declare function hasDataElementAccess(dataElementId: string, access: DataElementAccessMode): Promise<boolean>;
|
|
305
|
+
/**
|
|
306
|
+
* Observable version of `hasDataElementAccess`. See `hasDataElementAccess` for details.
|
|
307
|
+
*/
|
|
308
|
+
export declare function hasDataElementAccessAsObservable(dataElementId: string, access: DataElementAccessMode): Observable<boolean>;
|
|
309
|
+
/**
|
|
310
|
+
* Checks whether the authenticated user can read records for a data element ID.
|
|
311
|
+
*/
|
|
312
|
+
export declare function canReadDataElement(dataElementId: string): Promise<boolean>;
|
|
313
|
+
/**
|
|
314
|
+
* Observable version of `canReadDataElement`. See `canReadDataElement` for details.
|
|
315
|
+
*/
|
|
316
|
+
export declare function canReadDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Checks whether the authenticated user can create or update records for a data element ID.
|
|
319
|
+
*/
|
|
320
|
+
export declare function canWriteDataElement(dataElementId: string): Promise<boolean>;
|
|
321
|
+
/**
|
|
322
|
+
* Observable version of `canWriteDataElement`. See `canWriteDataElement` for details.
|
|
323
|
+
*/
|
|
324
|
+
export declare function canWriteDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
|
325
|
+
/**
|
|
326
|
+
* Checks whether the authenticated user can delete records for a data element ID.
|
|
327
|
+
*/
|
|
328
|
+
export declare function canDeleteDataElement(dataElementId: string): Promise<boolean>;
|
|
329
|
+
/**
|
|
330
|
+
* Observable version of `canDeleteDataElement`. See `canDeleteDataElement` for details.
|
|
228
331
|
*/
|
|
229
|
-
export declare function
|
|
332
|
+
export declare function canDeleteDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
|
230
333
|
//# sourceMappingURL=access.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/access.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/access.ts"],"names":[],"mappings":"AAkGA,OAAO,EAAuB,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,W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E,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYjH;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC5C,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,qBAAqB,GAC9B,UAAU,CAAC,OAAO,CAAC,CAErB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1E;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAEzF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3E;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAE1F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5E;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAE3F"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { getAuthToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody, initialize, type UserContext, type IncomingEventBody, type BaseActionResponse, type ActionResponse, type NotificationConfig, type ListActionResponse, type FormTemplateActionResponse, type PageTemplateActionResponse, type ObjectSaveActionResponse, type CalculatedFieldActionResponse, type SingleValueActionResponse, type ErrorResponse, prepareSuccessResponse, prepareErrorResponse } from './sdk-general';
|
|
7
7
|
export { type SaveOptions, getObject, getObjectAsObservable, getRelatedObjects, getRelatedObjectsAsObservable, getAccessibleObjects, getAccessibleObjectsAsObservable, getObjects, getObjectsAsObservable, saveObject, saveObjectAsObservable, saveRelatedObject, saveRelatedObjectAsObservable, deleteObject, deleteObjectAsObservable, deleteRelatedObject, deleteRelatedObjectAsObservable, deleteRelatedObjects, deleteRelatedObjectsAsObservable } from './data-crud';
|
|
8
|
-
export { type ScopeKeyItem, type Role, type BusinessPrivilege, type SandboxUser, type UserAccessWrapper, type InviteUserRequest, type InviteResult, type UpdateAccessRequest, listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, userPrivileges, } from './access';
|
|
8
|
+
export { type ScopeKeyItem, type Role, type BusinessPrivilege, type SandboxUser, type UserAccessWrapper, type InviteUserRequest, type InviteResult, type UpdateAccessRequest, type BusinessPrivilegeCheckResult, type CurrentBusinessPrivilegesResult, type DataElementAccessMode, type DataElementAccessResult, listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, hasBusinessPrivilegeAsObservable, userPrivileges, userPrivilegesAsObservable, dataElementAccess, dataElementAccessAsObservable, hasDataElementAccess, hasDataElementAccessAsObservable, canReadDataElement, canReadDataElementAsObservable, canWriteDataElement, canWriteDataElementAsObservable, canDeleteDataElement, canDeleteDataElementAsObservable, } from './access';
|
|
9
9
|
export { type ContentResource, getOrCreateResource, getOrCreateResourceAsObservable, saveResource, saveResourceAsObservable, sendFileContents, sendFileContentsAsObservable, createOrUpdateResource, createOrUpdateResourceAsObservable, downloadResource, downloadResourceAsObservable } from './content';
|
|
10
10
|
export { MessageMethod, type MessageRequest, sendMessage, sendMessageAsObservable } from './messaging';
|
|
11
11
|
export { getUserPreference, getOrganizationPreference, getUserPreferenceAsObservable, getOrganizationPreferenceAsObservable } from './preferences';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AASA;;;;GAIG;AAMH,OAAO,EAEH,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO,EAGP,UAAU,EAGV,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAGtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAGlB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAMvB,OAAO,EAEH,KAAK,WAAW,EAGhB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EAGtB,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,6BAA6B,EAG7B,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,EAC/B,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,aAAa,CAAC;AAMrB,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,SAAS,EACT,qBAAqB,EACrB,sBAAsB,EACtB,kCAAkC,EAClC,gBAAgB,EAChB,4BAA4B,EAC5B,aAAa,EACb,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,4BAA4B,EAC5B,oBAAoB,EACpB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AASA;;;;GAIG;AAMH,OAAO,EAEH,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO,EAGP,UAAU,EAGV,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAGtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAGlB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAMvB,OAAO,EAEH,KAAK,WAAW,EAGhB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EAGtB,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,6BAA6B,EAG7B,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,EAC/B,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,aAAa,CAAC;AAMrB,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACpC,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,SAAS,EACT,qBAAqB,EACrB,sBAAsB,EACtB,kCAAkC,EAClC,gBAAgB,EAChB,4BAA4B,EAC5B,aAAa,EACb,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,EAC5B,gBAAgB,EAChB,4B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EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAG5B,uBAAuB,EACvB,mCAAmC,EACtC,MAAM,YAAY,CAAC;AAMpB,OAAO,EAEH,KAAK,gBAAgB,EAGrB,aAAa,EACb,yBAAyB,EAC5B,MAAM,MAAM,CAAC;AAMd,OAAO,EACH,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,UAAU,EACb,MAAM,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-general.d.ts","sourceRoot":"","sources":["../../../src/sdk-general.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAM,MAAM,MAAM,CAAC;AAMtC;;GAEG;AACH,eAAO,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAElD;;GAEG;AACH,eAAO,IAAI,UAAU,EAAE,MAAM,CAAC;AAE9B;;GAEG;AACH,eAAO,IAAI,cAAc,EAAE,MAAM,CAAC;AAElC;;GAEG;AACH,eAAO,IAAI,aAAa,EAAE,GAAG,CAAC;AAE9B;;GAEG;AACH,eAAO,IAAI,WAAW,EAAE,WAAW,CAAC;AAEpC;;GAEG;AACH,eAAO,IAAI,MAAM,EAAE,MAAM,CAAC;AAE1B;;GAEG;AACH,eAAO,IAAI,OAAO,EAAE,OAAO,CAAC;AAE5B;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,iBAAiB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"sdk-general.d.ts","sourceRoot":"","sources":["../../../src/sdk-general.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAM,MAAM,MAAM,CAAC;AAMtC;;GAEG;AACH,eAAO,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAElD;;GAEG;AACH,eAAO,IAAI,UAAU,EAAE,M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AAC;CACxB;AAMD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,cAAc,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAS7H;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAS/G"}
|
package/lib/esm/access.js
CHANGED
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
* Key concepts:
|
|
16
16
|
* - `Role.id` is the stable semantic role identifier used by configuration and generated code.
|
|
17
17
|
* - `Role.objKey` is the persisted role object key. APIs that accept `roleKeys` require `Role.objKey`, not `Role.id`.
|
|
18
|
-
* - `BusinessPrivilege.id` is the stable privilege identifier used by
|
|
18
|
+
* - `BusinessPrivilege.id` is the stable privilege identifier used by server-validated checks such as `hasBusinessPrivilege`.
|
|
19
|
+
* - Data element access checks use stable data element IDs and resolve to persisted keys on the server.
|
|
19
20
|
* - `ScopeKeyItem` entries define the data scope a user receives for an organization, user proxy, or custom data scope.
|
|
21
|
+
* - `inviteUser` invites an existing unlinked user proxy record. Create or select that record first, then pass its
|
|
22
|
+
* object key as `userProxyKey`.
|
|
20
23
|
*
|
|
21
24
|
* @usage
|
|
22
25
|
* ## When to Use
|
|
@@ -44,8 +47,13 @@
|
|
|
44
47
|
* | `inviteUser` | Invite a new user and assign initial role keys/scopes |
|
|
45
48
|
* | `updateUserAccess` | Add or update one user scope entry |
|
|
46
49
|
* | `removeUserAccess` | Remove one user scope entry |
|
|
47
|
-
* | `hasBusinessPrivilege` |
|
|
48
|
-
* | `userPrivileges` |
|
|
50
|
+
* | `hasBusinessPrivilege` | Server-check whether the current user has a privilege ID |
|
|
51
|
+
* | `userPrivileges` | Server-read the current user's privilege IDs |
|
|
52
|
+
* | `dataElementAccess` | Server-check current user's read/write/delete access to a data element ID |
|
|
53
|
+
* | `hasDataElementAccess` | Server-check one read/write/delete access mode |
|
|
54
|
+
* | `canReadDataElement` | Server-check read access to a data element ID |
|
|
55
|
+
* | `canWriteDataElement` | Server-check write access to a data element ID |
|
|
56
|
+
* | `canDeleteDataElement` | Server-check delete access to a data element ID |
|
|
49
57
|
*
|
|
50
58
|
* @example
|
|
51
59
|
* // Resolve a semantic role ID to the persisted object key before assignment
|
|
@@ -61,13 +69,33 @@
|
|
|
61
69
|
*
|
|
62
70
|
* @example
|
|
63
71
|
* // Check the current user's business privilege
|
|
64
|
-
* if (hx.hasBusinessPrivilege('manageSharedLists')) {
|
|
72
|
+
* if (await hx.hasBusinessPrivilege('manageSharedLists')) {
|
|
65
73
|
* // Show controls for sharing list access
|
|
66
74
|
* }
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Invite an existing unlinked user proxy record
|
|
78
|
+
* const roles = await hx.listRoles();
|
|
79
|
+
* const memberRole = roles.find((role) => role.id === 'householdMember');
|
|
80
|
+
* if (!memberRole?.objKey) {
|
|
81
|
+
* throw new Error('Required role not found.');
|
|
82
|
+
* }
|
|
83
|
+
* await hx.inviteUser({
|
|
84
|
+
* email: 'new-member@example.com',
|
|
85
|
+
* userProxyElementId: 'familyMember',
|
|
86
|
+
* userProxyKey: pendingFamilyMember.objKey,
|
|
87
|
+
* roleKeys: [memberRole.objKey],
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Check current user's data access before showing a CRUD control
|
|
92
|
+
* if (await hx.canWriteDataElement('shoppingList')) {
|
|
93
|
+
* // Show controls that create or update shopping list records
|
|
94
|
+
* }
|
|
67
95
|
*/
|
|
68
96
|
import axios from 'axios';
|
|
69
97
|
import { from, lastValueFrom } from 'rxjs';
|
|
70
|
-
import { getAuthToken, sandboxKey, serviceAddress
|
|
98
|
+
import { getAuthToken, sandboxKey, serviceAddress } from './sdk-general';
|
|
71
99
|
async function authHeaders() {
|
|
72
100
|
if (!getAuthToken) {
|
|
73
101
|
throw new Error('SDK not initialized.');
|
|
@@ -155,6 +183,9 @@ export function getUserAccessAsObservable(userKey) {
|
|
|
155
183
|
/**
|
|
156
184
|
* Invites a user by email and assigns initial sandbox access.
|
|
157
185
|
*
|
|
186
|
+
* The target user proxy record must already exist and be unlinked. Pass that record's persisted object key in
|
|
187
|
+
* `req.userProxyKey` and its data element ID in `req.userProxyElementId`.
|
|
188
|
+
*
|
|
158
189
|
* `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs. Resolve desired
|
|
159
190
|
* semantic IDs with `listRoles` before calling this function.
|
|
160
191
|
*
|
|
@@ -213,20 +244,129 @@ export function removeUserAccessAsObservable(userKey, scopeElementId) {
|
|
|
213
244
|
return from(removeUserAccess(userKey, scopeElementId));
|
|
214
245
|
}
|
|
215
246
|
/**
|
|
216
|
-
* Checks whether the
|
|
247
|
+
* Checks whether the authenticated user has a business privilege ID by calling the access service.
|
|
248
|
+
*
|
|
249
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
250
|
+
* Treat this as an authorization check and await the server response.
|
|
217
251
|
*
|
|
218
252
|
* @param privilegeId - Stable business privilege ID
|
|
219
|
-
* @returns
|
|
253
|
+
* @returns Promise resolving to true when the current user has the privilege
|
|
254
|
+
*/
|
|
255
|
+
export async function hasBusinessPrivilege(privilegeId) {
|
|
256
|
+
const response = await axios.get(`${serviceAddress}/access/sandboxes/${sandboxKey}/businessPrivileges/${encodeURIComponent(privilegeId)}/currentUserHasPrivilege`, {
|
|
257
|
+
headers: await authHeaders(),
|
|
258
|
+
});
|
|
259
|
+
return response.data.hasPrivilege;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Observable version of `hasBusinessPrivilege`. See `hasBusinessPrivilege` for details.
|
|
263
|
+
*/
|
|
264
|
+
export function hasBusinessPrivilegeAsObservable(privilegeId) {
|
|
265
|
+
return from(hasBusinessPrivilege(privilegeId));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Returns the authenticated user's business privilege IDs by calling the access service.
|
|
269
|
+
*
|
|
270
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
271
|
+
*
|
|
272
|
+
* @returns Promise resolving to business privilege IDs for the current user
|
|
220
273
|
*/
|
|
221
|
-
export function
|
|
222
|
-
|
|
274
|
+
export async function userPrivileges() {
|
|
275
|
+
const response = await axios.get(`${serviceAddress}/access/sandboxes/${sandboxKey}/currentBusinessPrivileges`, {
|
|
276
|
+
headers: await authHeaders(),
|
|
277
|
+
});
|
|
278
|
+
if (Array.isArray(response.data)) {
|
|
279
|
+
return response.data;
|
|
280
|
+
}
|
|
281
|
+
return response.data.businessPrivileges ?? [];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Observable version of `userPrivileges`. See `userPrivileges` for details.
|
|
285
|
+
*/
|
|
286
|
+
export function userPrivilegesAsObservable() {
|
|
287
|
+
return from(userPrivileges());
|
|
223
288
|
}
|
|
224
289
|
/**
|
|
225
|
-
*
|
|
290
|
+
* Checks the authenticated user's data element read/write/delete access through the access service.
|
|
226
291
|
*
|
|
227
|
-
*
|
|
292
|
+
* The caller passes the stable data element ID. The server resolves that ID to the persisted data element key before
|
|
293
|
+
* checking the user's token, so generated code does not need to manage ID-to-key mappings.
|
|
294
|
+
*
|
|
295
|
+
* @param dataElementId - Stable data element ID
|
|
296
|
+
* @returns Promise resolving to the current user's data element access flags
|
|
297
|
+
*/
|
|
298
|
+
export async function dataElementAccess(dataElementId) {
|
|
299
|
+
const response = await axios.get(`${serviceAddress}/access/sandboxes/${sandboxKey}/dataElements/${encodeURIComponent(dataElementId)}/currentUserAccess`, {
|
|
300
|
+
headers: await authHeaders(),
|
|
301
|
+
});
|
|
302
|
+
return response.data;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Observable version of `dataElementAccess`. See `dataElementAccess` for details.
|
|
306
|
+
*/
|
|
307
|
+
export function dataElementAccessAsObservable(dataElementId) {
|
|
308
|
+
return from(dataElementAccess(dataElementId));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Checks one data element access mode for the authenticated user through the access service.
|
|
312
|
+
*
|
|
313
|
+
* @param dataElementId - Stable data element ID
|
|
314
|
+
* @param access - Access mode to check: `read`, `write`, or `delete`
|
|
315
|
+
* @returns Promise resolving to true when the current user has the requested data access
|
|
316
|
+
*/
|
|
317
|
+
export async function hasDataElementAccess(dataElementId, access) {
|
|
318
|
+
const result = await dataElementAccess(dataElementId);
|
|
319
|
+
switch (access) {
|
|
320
|
+
case 'read':
|
|
321
|
+
return result.canRead;
|
|
322
|
+
case 'write':
|
|
323
|
+
return result.canWrite;
|
|
324
|
+
case 'delete':
|
|
325
|
+
return result.canDelete;
|
|
326
|
+
default:
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Observable version of `hasDataElementAccess`. See `hasDataElementAccess` for details.
|
|
332
|
+
*/
|
|
333
|
+
export function hasDataElementAccessAsObservable(dataElementId, access) {
|
|
334
|
+
return from(hasDataElementAccess(dataElementId, access));
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Checks whether the authenticated user can read records for a data element ID.
|
|
338
|
+
*/
|
|
339
|
+
export function canReadDataElement(dataElementId) {
|
|
340
|
+
return hasDataElementAccess(dataElementId, 'read');
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Observable version of `canReadDataElement`. See `canReadDataElement` for details.
|
|
344
|
+
*/
|
|
345
|
+
export function canReadDataElementAsObservable(dataElementId) {
|
|
346
|
+
return from(canReadDataElement(dataElementId));
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Checks whether the authenticated user can create or update records for a data element ID.
|
|
350
|
+
*/
|
|
351
|
+
export function canWriteDataElement(dataElementId) {
|
|
352
|
+
return hasDataElementAccess(dataElementId, 'write');
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Observable version of `canWriteDataElement`. See `canWriteDataElement` for details.
|
|
356
|
+
*/
|
|
357
|
+
export function canWriteDataElementAsObservable(dataElementId) {
|
|
358
|
+
return from(canWriteDataElement(dataElementId));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Checks whether the authenticated user can delete records for a data element ID.
|
|
362
|
+
*/
|
|
363
|
+
export function canDeleteDataElement(dataElementId) {
|
|
364
|
+
return hasDataElementAccess(dataElementId, 'delete');
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Observable version of `canDeleteDataElement`. See `canDeleteDataElement` for details.
|
|
228
368
|
*/
|
|
229
|
-
export function
|
|
230
|
-
return
|
|
369
|
+
export function canDeleteDataElementAsObservable(dataElementId) {
|
|
370
|
+
return from(canDeleteDataElement(dataElementId));
|
|
231
371
|
}
|
|
232
372
|
//# sourceMappingURL=access.js.map
|
package/lib/esm/access.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/access.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/access.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,aAAa,EAAc,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EA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AA6B;IAE7B,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqB;IACpD,OAAO,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,aAAqB;IAChE,OAAO,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,aAAqB;IACrD,OAAO,oBAAoB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAAC,aAAqB;IACjE,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACtD,OAAO,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAAC,aAAqB;IAClE,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;GAIG;AAEH,mFAAmF;AACnF,sDAAsD;AACtD,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO;AAEP,iBAAiB;AACjB,UAAU;AAkBV,mBAAmB;AACnB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAIH,iBAAiB;AACjB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,gCAAgC,EAChC,UAAU,EACV,sBAAsB;AAEtB,YAAY;AACZ,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,6BAA6B;AAE7B,cAAc;AACd,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,EAC/B,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,mBAAmB;AACnB,mFAAmF;AAEnF,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;GAIG;AAEH,mFAAmF;AACnF,sDAAsD;AACtD,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO;AAEP,iBAAiB;AACjB,UAAU;AAkBV,mBAAmB;AACnB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAIH,iBAAiB;AACjB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACpB,gCAAgC,EAChC,UAAU,EACV,sBAAsB;AAEtB,YAAY;AACZ,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,6BAA6B;AAE7B,cAAc;AACd,YAAY,EACZ,wBAAw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,UAAU,EACV,sBAAsB,EACzB,MAAM,SAAS,CAAC;AAEjB,mFAAmF;AACnF,2BAA2B;AAC3B,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,mBAAmB;AAYnB,YAAY;AACZ,gBAAgB,EAChB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B,mFAAmF;AACnF,oBAAoB;AACpB,mFAAmF;AAEnF,OAAO;AAMH,YAAY;AACZ,uBAAuB,EACvB,mCAAmC,EACtC,MAAM,YAAY,CAAC;AAEpB,mFAAmF;AACnF,eAAe;AACf,mFAAmF;AAEnF,OAAO;AAIH,eAAe;AACf,aAAa,EACb,yBAAyB,EAC5B,MAAM,MAAM,CAAC;AAEd,mFAAmF;AACnF,oBAAoB;AACpB,mFAAmF;AAEnF,OAAO,EACH,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,UAAU,EACb,MAAM,aAAa,CAAC"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -34,7 +34,7 @@ deleteObject, deleteObjectAsObservable, deleteRelatedObject, deleteRelatedObject
|
|
|
34
34
|
// ================================================================================
|
|
35
35
|
// ACCESS FUNCTIONS
|
|
36
36
|
// ================================================================================
|
|
37
|
-
export { listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, userPrivileges, } from './access';
|
|
37
|
+
export { listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, hasBusinessPrivilegeAsObservable, userPrivileges, userPrivilegesAsObservable, dataElementAccess, dataElementAccessAsObservable, hasDataElementAccess, hasDataElementAccessAsObservable, canReadDataElement, canReadDataElementAsObservable, canWriteDataElement, canWriteDataElementAsObservable, canDeleteDataElement, canDeleteDataElementAsObservable, } from './access';
|
|
38
38
|
// ================================================================================
|
|
39
39
|
// CONTENT FUNCTIONS
|
|
40
40
|
// ================================================================================
|
package/lib/esm/sdk-general.js
CHANGED
|
@@ -64,9 +64,6 @@ export function initialize(event) {
|
|
|
64
64
|
}
|
|
65
65
|
if (body) {
|
|
66
66
|
({ sandboxKey, serviceAddress, actionSubject, userContext, params } = body);
|
|
67
|
-
if (userContext && !userContext.businessPrivileges) {
|
|
68
|
-
userContext.businessPrivileges = [];
|
|
69
|
-
}
|
|
70
67
|
if (body.authToken) {
|
|
71
68
|
getAuthToken = () => of(body.authToken);
|
|
72
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-general.js","sourceRoot":"","sources":["../../src/sdk-general.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,EAAE,EAAE,MAAM,MAAM,CAAC;AAEtC,mFAAmF;AACnF,sCAAsC;AACtC,mFAAmF;AAEnF;;GAEG;AACH,MAAM,CAAC,IAAI,YAAsC,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,IAAI,UAAkB,CAAC;AAE9B;;GAEG;AACH,MAAM,CAAC,IAAI,cAAsB,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,IAAI,aAAkB,CAAC;AAE9B;;GAEG;AACH,MAAM,CAAC,IAAI,WAAwB,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,IAAI,MAAc,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,IAAI,OAAgB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAmC;IAE1D,I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aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAE5E,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,YAAY,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACjC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC3C,CAAC;IACL,CAAC;AACL,CAAC;AAwKD,mFAAmF;AACnF,4BAA4B;AAC5B,mFAAmF;AAEnF;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,eAA+B;IAClE,IAAI,OAAO,EAAE,CAAC;QACV,OAAO;YACH,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;SACxC,CAAC;IACN,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACrD,IAAI,OAAO,EAAE,CAAC;QACV,OAAO;YACH,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;SACzC,CAAC;IACN,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -92,7 +92,9 @@ export interface InviteUserRequest {
|
|
|
92
92
|
lastName?: string;
|
|
93
93
|
/** User proxy data element ID used to create or link the user proxy record. */
|
|
94
94
|
userProxyElementId: string;
|
|
95
|
-
/**
|
|
95
|
+
/** Existing unlinked user proxy object key to invite or link. */
|
|
96
|
+
userProxyKey: string;
|
|
97
|
+
/** Optional organization proxy object key for context; this is not a substitute for `userProxyKey`. */
|
|
96
98
|
orgProxyKey?: string;
|
|
97
99
|
/** Persisted role object keys (`Role.objKey`). Never pass semantic `Role.id` values here. */
|
|
98
100
|
roleKeys: string[];
|
|
@@ -126,6 +128,41 @@ export interface UpdateAccessRequest {
|
|
|
126
128
|
/** Whether this scope entry should apply globally instead of being limited to the provided scopes. */
|
|
127
129
|
globalAccess?: boolean;
|
|
128
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Server response for current-user business privilege checks.
|
|
133
|
+
*/
|
|
134
|
+
export interface BusinessPrivilegeCheckResult {
|
|
135
|
+
/** Checked business privilege ID. */
|
|
136
|
+
businessPrivilegeId: string;
|
|
137
|
+
/** Whether the authenticated user has the privilege in the current sandbox. */
|
|
138
|
+
hasPrivilege: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Server response for current-user business privilege lists.
|
|
142
|
+
*/
|
|
143
|
+
export interface CurrentBusinessPrivilegesResult {
|
|
144
|
+
/** Business privilege IDs granted to the authenticated user in the current sandbox. */
|
|
145
|
+
businessPrivileges: string[];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Data element access mode for current-user R/W/D privilege checks.
|
|
149
|
+
*/
|
|
150
|
+
export type DataElementAccessMode = 'read' | 'write' | 'delete';
|
|
151
|
+
/**
|
|
152
|
+
* Server response for current-user data element access checks.
|
|
153
|
+
*/
|
|
154
|
+
export interface DataElementAccessResult {
|
|
155
|
+
/** Stable data element ID requested by the caller. */
|
|
156
|
+
dataElementId: string;
|
|
157
|
+
/** Persisted data element object key resolved by the server. */
|
|
158
|
+
dataElementKey: string;
|
|
159
|
+
/** Whether the authenticated user can read records for this data element. */
|
|
160
|
+
canRead: boolean;
|
|
161
|
+
/** Whether the authenticated user can create or update records for this data element. */
|
|
162
|
+
canWrite: boolean;
|
|
163
|
+
/** Whether the authenticated user can delete records for this data element. */
|
|
164
|
+
canDelete: boolean;
|
|
165
|
+
}
|
|
129
166
|
/**
|
|
130
167
|
* Lists roles available in the current sandbox.
|
|
131
168
|
*
|
|
@@ -178,6 +215,9 @@ export declare function getUserAccessAsObservable(userKey: string): Observable<U
|
|
|
178
215
|
/**
|
|
179
216
|
* Invites a user by email and assigns initial sandbox access.
|
|
180
217
|
*
|
|
218
|
+
* The target user proxy record must already exist and be unlinked. Pass that record's persisted object key in
|
|
219
|
+
* `req.userProxyKey` and its data element ID in `req.userProxyElementId`.
|
|
220
|
+
*
|
|
181
221
|
* `req.roleKeys` must contain persisted role object keys from `Role.objKey`, not semantic role IDs. Resolve desired
|
|
182
222
|
* semantic IDs with `listRoles` before calling this function.
|
|
183
223
|
*
|
|
@@ -215,15 +255,78 @@ export declare function removeUserAccess(userKey: string, scopeElementId: string
|
|
|
215
255
|
*/
|
|
216
256
|
export declare function removeUserAccessAsObservable(userKey: string, scopeElementId: string): Observable<void>;
|
|
217
257
|
/**
|
|
218
|
-
* Checks whether the
|
|
258
|
+
* Checks whether the authenticated user has a business privilege ID by calling the access service.
|
|
259
|
+
*
|
|
260
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
261
|
+
* Treat this as an authorization check and await the server response.
|
|
219
262
|
*
|
|
220
263
|
* @param privilegeId - Stable business privilege ID
|
|
221
|
-
* @returns
|
|
264
|
+
* @returns Promise resolving to true when the current user has the privilege
|
|
265
|
+
*/
|
|
266
|
+
export declare function hasBusinessPrivilege(privilegeId: string): Promise<boolean>;
|
|
267
|
+
/**
|
|
268
|
+
* Observable version of `hasBusinessPrivilege`. See `hasBusinessPrivilege` for details.
|
|
269
|
+
*/
|
|
270
|
+
export declare function hasBusinessPrivilegeAsObservable(privilegeId: string): Observable<boolean>;
|
|
271
|
+
/**
|
|
272
|
+
* Returns the authenticated user's business privilege IDs by calling the access service.
|
|
273
|
+
*
|
|
274
|
+
* This intentionally does not read browser-local context, because local state can be manipulated.
|
|
275
|
+
*
|
|
276
|
+
* @returns Promise resolving to business privilege IDs for the current user
|
|
277
|
+
*/
|
|
278
|
+
export declare function userPrivileges(): Promise<string[]>;
|
|
279
|
+
/**
|
|
280
|
+
* Observable version of `userPrivileges`. See `userPrivileges` for details.
|
|
222
281
|
*/
|
|
223
|
-
export declare function
|
|
282
|
+
export declare function userPrivilegesAsObservable(): Observable<string[]>;
|
|
224
283
|
/**
|
|
225
|
-
*
|
|
284
|
+
* Checks the authenticated user's data element read/write/delete access through the access service.
|
|
285
|
+
*
|
|
286
|
+
* The caller passes the stable data element ID. The server resolves that ID to the persisted data element key before
|
|
287
|
+
* checking the user's token, so generated code does not need to manage ID-to-key mappings.
|
|
226
288
|
*
|
|
227
|
-
* @
|
|
289
|
+
* @param dataElementId - Stable data element ID
|
|
290
|
+
* @returns Promise resolving to the current user's data element access flags
|
|
291
|
+
*/
|
|
292
|
+
export declare function dataElementAccess(dataElementId: string): Promise<DataElementAccessResult>;
|
|
293
|
+
/**
|
|
294
|
+
* Observable version of `dataElementAccess`. See `dataElementAccess` for details.
|
|
295
|
+
*/
|
|
296
|
+
export declare function dataElementAccessAsObservable(dataElementId: string): Observable<DataElementAccessResult>;
|
|
297
|
+
/**
|
|
298
|
+
* Checks one data element access mode for the authenticated user through the access service.
|
|
299
|
+
*
|
|
300
|
+
* @param dataElementId - Stable data element ID
|
|
301
|
+
* @param access - Access mode to check: `read`, `write`, or `delete`
|
|
302
|
+
* @returns Promise resolving to true when the current user has the requested data access
|
|
303
|
+
*/
|
|
304
|
+
export declare function hasDataElementAccess(dataElementId: string, access: DataElementAccessMode): Promise<boolean>;
|
|
305
|
+
/**
|
|
306
|
+
* Observable version of `hasDataElementAccess`. See `hasDataElementAccess` for details.
|
|
307
|
+
*/
|
|
308
|
+
export declare function hasDataElementAccessAsObservable(dataElementId: string, access: DataElementAccessMode): Observable<boolean>;
|
|
309
|
+
/**
|
|
310
|
+
* Checks whether the authenticated user can read records for a data element ID.
|
|
311
|
+
*/
|
|
312
|
+
export declare function canReadDataElement(dataElementId: string): Promise<boolean>;
|
|
313
|
+
/**
|
|
314
|
+
* Observable version of `canReadDataElement`. See `canReadDataElement` for details.
|
|
315
|
+
*/
|
|
316
|
+
export declare function canReadDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Checks whether the authenticated user can create or update records for a data element ID.
|
|
319
|
+
*/
|
|
320
|
+
export declare function canWriteDataElement(dataElementId: string): Promise<boolean>;
|
|
321
|
+
/**
|
|
322
|
+
* Observable version of `canWriteDataElement`. See `canWriteDataElement` for details.
|
|
323
|
+
*/
|
|
324
|
+
export declare function canWriteDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
|
325
|
+
/**
|
|
326
|
+
* Checks whether the authenticated user can delete records for a data element ID.
|
|
327
|
+
*/
|
|
328
|
+
export declare function canDeleteDataElement(dataElementId: string): Promise<boolean>;
|
|
329
|
+
/**
|
|
330
|
+
* Observable version of `canDeleteDataElement`. See `canDeleteDataElement` for details.
|
|
228
331
|
*/
|
|
229
|
-
export declare function
|
|
332
|
+
export declare function canDeleteDataElementAsObservable(dataElementId: string): Observable<boolean>;
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { getAuthToken, sandboxKey, serviceAddress, actionSubject, userContext, params, useBody, initialize, type UserContext, type IncomingEventBody, type BaseActionResponse, type ActionResponse, type NotificationConfig, type ListActionResponse, type FormTemplateActionResponse, type PageTemplateActionResponse, type ObjectSaveActionResponse, type CalculatedFieldActionResponse, type SingleValueActionResponse, type ErrorResponse, prepareSuccessResponse, prepareErrorResponse } from './sdk-general';
|
|
7
7
|
export { type SaveOptions, getObject, getObjectAsObservable, getRelatedObjects, getRelatedObjectsAsObservable, getAccessibleObjects, getAccessibleObjectsAsObservable, getObjects, getObjectsAsObservable, saveObject, saveObjectAsObservable, saveRelatedObject, saveRelatedObjectAsObservable, deleteObject, deleteObjectAsObservable, deleteRelatedObject, deleteRelatedObjectAsObservable, deleteRelatedObjects, deleteRelatedObjectsAsObservable } from './data-crud';
|
|
8
|
-
export { type ScopeKeyItem, type Role, type BusinessPrivilege, type SandboxUser, type UserAccessWrapper, type InviteUserRequest, type InviteResult, type UpdateAccessRequest, listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, userPrivileges, } from './access';
|
|
8
|
+
export { type ScopeKeyItem, type Role, type BusinessPrivilege, type SandboxUser, type UserAccessWrapper, type InviteUserRequest, type InviteResult, type UpdateAccessRequest, type BusinessPrivilegeCheckResult, type CurrentBusinessPrivilegesResult, type DataElementAccessMode, type DataElementAccessResult, listRoles, listRolesAsObservable, listBusinessPrivileges, listBusinessPrivilegesAsObservable, listSandboxUsers, listSandboxUsersAsObservable, getUserAccess, getUserAccessAsObservable, inviteUser, inviteUserAsObservable, updateUserAccess, updateUserAccessAsObservable, removeUserAccess, removeUserAccessAsObservable, hasBusinessPrivilege, hasBusinessPrivilegeAsObservable, userPrivileges, userPrivilegesAsObservable, dataElementAccess, dataElementAccessAsObservable, hasDataElementAccess, hasDataElementAccessAsObservable, canReadDataElement, canReadDataElementAsObservable, canWriteDataElement, canWriteDataElementAsObservable, canDeleteDataElement, canDeleteDataElementAsObservable, } from './access';
|
|
9
9
|
export { type ContentResource, getOrCreateResource, getOrCreateResourceAsObservable, saveResource, saveResourceAsObservable, sendFileContents, sendFileContentsAsObservable, createOrUpdateResource, createOrUpdateResourceAsObservable, downloadResource, downloadResourceAsObservable } from './content';
|
|
10
10
|
export { MessageMethod, type MessageRequest, sendMessage, sendMessageAsObservable } from './messaging';
|
|
11
11
|
export { getUserPreference, getOrganizationPreference, getUserPreferenceAsObservable, getOrganizationPreferenceAsObservable } from './preferences';
|