@magda/auth-api-client 2.2.6 → 2.3.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/dist/index.d.ts +12 -2
- package/dist/index.js +14 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -130,14 +130,19 @@ declare class ApiClient {
|
|
|
130
130
|
createRole(name: string, desc?: string): Promise<Role>;
|
|
131
131
|
createRolePermission(roleId: string, permissionData: CreateRolePermissionInputData): Promise<PermissionRecord>;
|
|
132
132
|
createPermission(permissionData: CreateRolePermissionInputData): Promise<PermissionRecord>;
|
|
133
|
+
updatePermission(id: string, permissionData: UpdateRolePermissionInputData): Promise<PermissionRecord>;
|
|
133
134
|
getOperationByUri(opUri: string): Promise<OperationRecord>;
|
|
134
135
|
getResourceByUri(resUri: string): Promise<ResourceRecord>;
|
|
135
136
|
private handleGetResult;
|
|
136
137
|
}
|
|
137
138
|
export default ApiClient;
|
|
138
139
|
|
|
139
|
-
declare interface CreateRolePermissionInputData extends Omit<PermissionRecord, "id" | "owner_id" | "create_by" | "create_time" | "edit_by" | "edit_time"> {
|
|
140
|
-
operationIds
|
|
140
|
+
declare interface CreateRolePermissionInputData extends Omit<PermissionRecord, "id" | "owner_id" | "create_by" | "create_time" | "edit_by" | "edit_time" | "allow_exemption" | "resource_id"> {
|
|
141
|
+
operationIds?: string[];
|
|
142
|
+
operationUris?: string[];
|
|
143
|
+
resource_id?: string;
|
|
144
|
+
resourceUri?: string;
|
|
145
|
+
allow_exemption?: boolean;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
declare type CreateUserData = Partial<Omit<UserRecord, "email" | "displayName" | "id">> & Pick<UserRecord, "displayName" | "email">;
|
|
@@ -254,6 +259,7 @@ export declare interface Permission {
|
|
|
254
259
|
createTime?: Date;
|
|
255
260
|
editBy?: string;
|
|
256
261
|
editTime?: Date;
|
|
262
|
+
allowExemption: boolean;
|
|
257
263
|
}
|
|
258
264
|
|
|
259
265
|
declare interface PermissionRecord {
|
|
@@ -269,6 +275,7 @@ declare interface PermissionRecord {
|
|
|
269
275
|
create_by: string;
|
|
270
276
|
edit_time: string;
|
|
271
277
|
edit_by: string;
|
|
278
|
+
allow_exemption: boolean;
|
|
272
279
|
}
|
|
273
280
|
|
|
274
281
|
export declare type PublicUser = Partial<Pick<UserRecord, "id" | "photoURL" | "orgUnitId">> & Omit<UserRecord, "id" | "photoURL" | "orgUnitId" | "email" | "source" | "sourceId"> & {
|
|
@@ -298,6 +305,9 @@ export declare interface Role {
|
|
|
298
305
|
editTime?: Date;
|
|
299
306
|
}
|
|
300
307
|
|
|
308
|
+
declare interface UpdateRolePermissionInputData extends Partial<CreateRolePermissionInputData> {
|
|
309
|
+
}
|
|
310
|
+
|
|
301
311
|
export declare type User = PublicUser & Pick<UserRecord, "email" | "source" | "sourceId">;
|
|
302
312
|
|
|
303
313
|
declare interface UserRecord {
|
package/dist/index.js
CHANGED
|
@@ -2621,9 +2621,7 @@ class ApiClient {
|
|
|
2621
2621
|
if (!isUuid_1.default(roleId)) {
|
|
2622
2622
|
throw new ServerError_1.default(`roleId: ${roleId} is not a valid UUID.`);
|
|
2623
2623
|
}
|
|
2624
|
-
const uri = urijs_1.default(`${this.baseUrl}public/roles`)
|
|
2625
|
-
.segmentCoded(roleId)
|
|
2626
|
-
.segmentCoded("permissions");
|
|
2624
|
+
const uri = urijs_1.default(`${this.baseUrl}public/roles/${encodeURIComponent(roleId)}/permissions`);
|
|
2627
2625
|
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2628
2626
|
method: "post",
|
|
2629
2627
|
body: JSON.stringify(permissionData)
|
|
@@ -2641,6 +2639,19 @@ class ApiClient {
|
|
|
2641
2639
|
return yield this.processJsonResponse(res);
|
|
2642
2640
|
});
|
|
2643
2641
|
}
|
|
2642
|
+
updatePermission(id, permissionData) {
|
|
2643
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2644
|
+
if (!permissionData || !Object.keys(permissionData).length) {
|
|
2645
|
+
throw new Error("Empty data supplied to update permission!");
|
|
2646
|
+
}
|
|
2647
|
+
const uri = urijs_1.default(`${this.baseUrl}public/permissions/${encodeURIComponent(id)}`);
|
|
2648
|
+
const res = yield isomorphic_fetch_1.default(uri.toString(), this.getMergeRequestInitOption({
|
|
2649
|
+
method: "put",
|
|
2650
|
+
body: JSON.stringify(permissionData)
|
|
2651
|
+
}));
|
|
2652
|
+
return yield this.processJsonResponse(res);
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2644
2655
|
getOperationByUri(opUri) {
|
|
2645
2656
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2646
2657
|
const uri = urijs_1.default(`${this.baseUrl}public/operations/byUri/${opUri}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magda/auth-api-client",
|
|
3
3
|
"description": "MAGDA Auth API Client",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prebuild": "rimraf dist tsconfig.tsbuildinfo",
|
|
7
7
|
"build": "webpack && api-extractor run -l",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@magda/typescript-common": "^2.
|
|
15
|
+
"@magda/typescript-common": "^2.3.0",
|
|
16
16
|
"@microsoft/api-extractor": "~7.15.2",
|
|
17
17
|
"ts-loader": "^6.2.1",
|
|
18
18
|
"typescript": "~4.2.4",
|