@things-factory/auth-base 10.1.241 → 10.1.245
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-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/role/role-query.js +3 -2
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.d.ts +1 -0
- package/dist-server/service/role/role-types.js +5 -1
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role-template/index.d.ts +2 -2
- package/dist-server/service/role-template/index.js +1 -1
- package/dist-server/service/role-template/index.js.map +1 -1
- package/dist-server/service/role-template/role-template-gap-resolver.d.ts +8 -0
- package/dist-server/service/role-template/role-template-gap-resolver.js +24 -1
- package/dist-server/service/role-template/role-template-gap-resolver.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/tests/role-template-gap-db.test.ts +18 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Role } from '../role/role.js';
|
|
2
|
+
import { RoleBrief } from '../role/role-types.js';
|
|
2
3
|
import { RoleTaskCoverageListView, RoleTemplateGapView } from './role-template-types.js';
|
|
3
4
|
/**
|
|
4
5
|
* `Role.templateGap` and `Role.taskCoverage` - the role management screen lays a role against its base template and against
|
|
@@ -12,3 +13,10 @@ export declare class RoleTemplateGapResolver {
|
|
|
12
13
|
templateGap(role: Role): Promise<RoleTemplateGapView | null>;
|
|
13
14
|
taskCoverage(role: Role): Promise<RoleTaskCoverageListView>;
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* `RoleBrief.taskCoverage` - the same reading for one's own roles (ADR-0139 §11-11): the profile says what work each role
|
|
18
|
+
* of the caller holds. `myRoles` returns only the caller's roles, so this reaches no one else's.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RoleBriefTaskResolver {
|
|
21
|
+
taskCoverage(role: RoleBrief): Promise<RoleTaskCoverageListView>;
|
|
22
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoleTemplateGapResolver = void 0;
|
|
3
|
+
exports.RoleBriefTaskResolver = exports.RoleTemplateGapResolver = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
|
7
7
|
const privilege_js_1 = require("../privilege/privilege.js");
|
|
8
8
|
const role_js_1 = require("../role/role.js");
|
|
9
|
+
const role_types_js_1 = require("../role/role-types.js");
|
|
9
10
|
const role_template_js_1 = require("./role-template.js");
|
|
10
11
|
const role_task_js_1 = require("./role-task.js");
|
|
11
12
|
const role_template_types_js_1 = require("./role-template-types.js");
|
|
@@ -51,6 +52,28 @@ tslib_1.__decorate([
|
|
|
51
52
|
exports.RoleTemplateGapResolver = RoleTemplateGapResolver = tslib_1.__decorate([
|
|
52
53
|
(0, type_graphql_1.Resolver)(role_js_1.Role)
|
|
53
54
|
], RoleTemplateGapResolver);
|
|
55
|
+
/**
|
|
56
|
+
* `RoleBrief.taskCoverage` - the same reading for one's own roles (ADR-0139 §11-11): the profile says what work each role
|
|
57
|
+
* of the caller holds. `myRoles` returns only the caller's roles, so this reaches no one else's.
|
|
58
|
+
*/
|
|
59
|
+
let RoleBriefTaskResolver = class RoleBriefTaskResolver {
|
|
60
|
+
async taskCoverage(role) {
|
|
61
|
+
return (0, role_task_js_1.taskCoverageOf)(await heldBy(role));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.RoleBriefTaskResolver = RoleBriefTaskResolver;
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, type_graphql_1.FieldResolver)(type => role_template_types_js_1.RoleTaskCoverageListView, {
|
|
67
|
+
description: "The role's privileges laid against every registered task, and those no task names."
|
|
68
|
+
}),
|
|
69
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
70
|
+
tslib_1.__metadata("design:type", Function),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [role_types_js_1.RoleBrief]),
|
|
72
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
73
|
+
], RoleBriefTaskResolver.prototype, "taskCoverage", null);
|
|
74
|
+
exports.RoleBriefTaskResolver = RoleBriefTaskResolver = tslib_1.__decorate([
|
|
75
|
+
(0, type_graphql_1.Resolver)(role_types_js_1.RoleBrief)
|
|
76
|
+
], RoleBriefTaskResolver);
|
|
54
77
|
async function heldBy(role) {
|
|
55
78
|
const held = await (0, shell_1.getRepository)(privilege_js_1.Privilege)
|
|
56
79
|
.createQueryBuilder('PRIVILEGE')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-template-gap-resolver.js","sourceRoot":"","sources":["../../../server/service/role-template/role-template-gap-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA4D;AAE5D,iDAAqD;AAErD,4DAAqD;AACrD,6CAAsC;AACtC,yDAAkD;AAClD,iDAA+C;AAC/C,qEAAwF;AAExF;;;;;;;GAOG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAM5B,AAAN,KAAK,CAAC,WAAW,CAAS,IAAU;QAClC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,IAAA,gCAAa,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3D,CAAC;IAKK,AAAN,KAAK,CAAC,YAAY,CAAS,IAAU;QACnC,OAAO,IAAA,6BAAc,EAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA;AApBY,0DAAuB;AAM5B;IALL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,4CAAmB,EAAE;QAC1C,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,sMAAsM;KACzM,CAAC;IACiB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,cAAI;;0DAMnC;AAKK;IAHL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,iDAAwB,EAAE;QAC/C,WAAW,EAAE,oFAAoF;KAClG,CAAC;IACkB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,cAAI;;2DAEpC;kCAnBU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,cAAI,CAAC;GACF,uBAAuB,CAoBnC;AAED,KAAK,UAAU,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"role-template-gap-resolver.js","sourceRoot":"","sources":["../../../server/service/role-template/role-template-gap-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA4D;AAE5D,iDAAqD;AAErD,4DAAqD;AACrD,6CAAsC;AACtC,yDAAiD;AACjD,yDAAkD;AAClD,iDAA+C;AAC/C,qEAAwF;AAExF;;;;;;;GAOG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAM5B,AAAN,KAAK,CAAC,WAAW,CAAS,IAAU;QAClC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,IAAA,gCAAa,EAAC,IAAI,CAAC,UAAU,EAAE,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3D,CAAC;IAKK,AAAN,KAAK,CAAC,YAAY,CAAS,IAAU;QACnC,OAAO,IAAA,6BAAc,EAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA;AApBY,0DAAuB;AAM5B;IALL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,4CAAmB,EAAE;QAC1C,QAAQ,EAAE,IAAI;QACd,WAAW,EACT,sMAAsM;KACzM,CAAC;IACiB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,cAAI;;0DAMnC;AAKK;IAHL,IAAA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phql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Privilege } from '../privilege/privilege.js'\nimport { Role } from '../role/role.js'\nimport { RoleBrief } from '../role/role-types.js'\nimport { templateGapOf } from './role-template.js'\nimport { taskCoverageOf } from './role-task.js'\nimport { RoleTaskCoverageListView, RoleTemplateGapView } from './role-template-types.js'\n\n/**\n * `Role.templateGap` and `Role.taskCoverage` - the role management screen lays a role against its base template and against\n * the tasks (ADR-0075 decision 1, ADR-0139 decision 11). The rules are `templateGapAgainst` and `taskCoverageOf`;\n * this only reads the role's privileges.\n *\n * Both are fields of a role, so they are reached only through a door that already returned the role - the same\n * privilege and the same domain the role list asks for. They add no door of their own.\n */\n@Resolver(Role)\nexport class RoleTemplateGapResolver {\n @FieldResolver(type => RoleTemplateGapView, {\n nullable: true,\n description:\n \"What the role's base template grants here that the role does not hold, and what the role holds beyond it. Null when the role has no base template, or its base is not declared in this installation.\"\n })\n async templateGap(@Root() role: Role): Promise<RoleTemplateGapView | null> {\n if (!role.templateId) {\n return null\n }\n\n return templateGapOf(role.templateId, await heldBy(role))\n }\n\n @FieldResolver(type => RoleTaskCoverageListView, {\n description: \"The role's privileges laid against every registered task, and those no task names.\"\n })\n async taskCoverage(@Root() role: Role): Promise<RoleTaskCoverageListView> {\n return taskCoverageOf(await heldBy(role))\n }\n}\n\n/**\n * `RoleBrief.taskCoverage` - the same reading for one's own roles (ADR-0139 §11-11): the profile says what work each role\n * of the caller holds. `myRoles` returns only the caller's roles, so this reaches no one else's.\n */\n@Resolver(RoleBrief)\nexport class RoleBriefTaskResolver {\n @FieldResolver(type => RoleTaskCoverageListView, {\n description: \"The role's privileges laid against every registered task, and those no task names.\"\n })\n async taskCoverage(@Root() role: RoleBrief): Promise<RoleTaskCoverageListView> {\n return taskCoverageOf(await heldBy(role))\n }\n}\n\nasync function heldBy(role: { id?: string }): Promise<Set<string>> {\n const held = await getRepository(Privilege)\n .createQueryBuilder('PRIVILEGE')\n .select(['PRIVILEGE.category', 'PRIVILEGE.name'])\n .innerJoin('PRIVILEGE.roles', 'ROLE')\n .where('ROLE.id = :id', { id: role.id })\n .getMany()\n\n return new Set(held.map(privilege => `${privilege.category} ${privilege.name}`))\n}\n"]}
|