@pgds/api-interface 1.3.0 → 1.3.2
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/models/ReqUser.d.ts +6 -2
- package/lib/models/ReqUser.js.map +1 -1
- package/package.json +101 -101
- package/utils/index.js +3 -0
- package/utils/index.js.map +1 -1
package/lib/models/ReqUser.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export type Activities = {
|
|
2
2
|
[activity: string]: boolean;
|
|
3
3
|
};
|
|
4
|
+
type ChildId = string;
|
|
5
|
+
type ParentId = string;
|
|
6
|
+
type OrganizationHierarchy = Record<ChildId, ParentId>;
|
|
4
7
|
export declare class ReqUser {
|
|
5
8
|
userId: string;
|
|
6
9
|
activities: Activities;
|
|
@@ -8,8 +11,8 @@ export declare class ReqUser {
|
|
|
8
11
|
organizationId: string;
|
|
9
12
|
/** The user account currently active for this login */
|
|
10
13
|
activeLogin: string;
|
|
11
|
-
/** The hierarchy of the user's current organization */
|
|
12
|
-
organizationHierarchy:
|
|
14
|
+
/** The hierarchy of the user's current organization `Record<ChildId, ParentId>` */
|
|
15
|
+
organizationHierarchy: OrganizationHierarchy;
|
|
13
16
|
constructor({ userId, organizationId, activities, activeLogin, organizationHierarchy, }: {
|
|
14
17
|
userId: typeof ReqUser.prototype.userId;
|
|
15
18
|
organizationId: typeof ReqUser.prototype.organizationId;
|
|
@@ -26,3 +29,4 @@ export declare class ReqUser {
|
|
|
26
29
|
*/
|
|
27
30
|
getOrganizationTreeIds(organizationId?: string): string[];
|
|
28
31
|
}
|
|
32
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReqUser.js","sourceRoot":"","sources":["ReqUser.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ReqUser.js","sourceRoot":"","sources":["ReqUser.ts"],"names":[],"mappings":";;;AAMA;IAaE,iBAAY,EAYX;YAXC,MAAM,YAAA,EACN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CAAC,OAAO,CAAC,EAAE,CAAC;oBACvD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,cAAC;AAAD,CAAC,AAtED,IAsEC;AAtEY,0BAAO"}
|
package/package.json
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
],
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@types/restify": "^8.5.12",
|
|
36
|
-
"@types/restify-errors": "^4.3.9",
|
|
37
|
-
"ajv": "8.17.1",
|
|
38
|
-
"ajv-formats": "3.0.1",
|
|
39
|
-
"axios": "1.7.9",
|
|
40
|
-
"bunyan": "1.8.15",
|
|
41
|
-
"bunyan-format": "^0.2.1",
|
|
42
|
-
"mustbe": "0.4.0",
|
|
43
|
-
"nyc": "^17.1.0",
|
|
44
|
-
"prom-client": "^12.0.0",
|
|
45
|
-
"restify": "^11.1.0",
|
|
46
|
-
"restify-errors": "8.0.2",
|
|
47
|
-
"semver": "^7.3.8",
|
|
48
|
-
"ts-node": "^10.9.2",
|
|
49
|
-
"ts-node-test-register": "^10.0.0",
|
|
50
|
-
"uuid": "9.0.1",
|
|
51
|
-
"typescript": "^5.7.2",
|
|
52
|
-
"typescript-json-schema": "0.65.1"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@types/bunyan-format": "0.2.9",
|
|
56
|
-
"@types/chai": "4.3.12",
|
|
57
|
-
"@types/mocha": "^10.0.6",
|
|
58
|
-
"@types/mockery": "^1.4.30",
|
|
59
|
-
"@types/nock": "11.1.0",
|
|
60
|
-
"@types/semver": "^7.3.13",
|
|
61
|
-
"@types/supertest": "^2.0.11",
|
|
62
|
-
"@types/uuid": "^8.3.4",
|
|
63
|
-
"chai": "^4.3.6",
|
|
64
|
-
"chai-subset": "^1.6.0",
|
|
65
|
-
"mocha": "10.2.0",
|
|
66
|
-
"mockery": "2.1.0",
|
|
67
|
-
"supertest": "6.3.4",
|
|
68
|
-
"nock": "13.5.5"
|
|
69
|
-
},
|
|
70
|
-
"directories": {
|
|
71
|
-
"example": "examples",
|
|
72
|
-
"lib": "lib",
|
|
73
|
-
"types": "types"
|
|
74
|
-
},
|
|
75
|
-
"repository": {
|
|
76
|
-
"type": "git",
|
|
77
|
-
"url": "git+https://github.com/hiotlabs/hiot-api-interface.git"
|
|
78
|
-
},
|
|
79
|
-
"keywords": [
|
|
80
|
-
"restify"
|
|
81
|
-
],
|
|
82
|
-
"author": "",
|
|
83
|
-
"license": "ISC",
|
|
84
|
-
"bugs": {
|
|
85
|
-
"url": "https://github.com/hiotlabs/hiot-api-interface/issues"
|
|
86
|
-
},
|
|
87
|
-
"homepage": "https://github.com/hiotlabs/hiot-api-interface#readme",
|
|
88
|
-
"mocha": {
|
|
89
|
-
"extension": [
|
|
90
|
-
"ts",
|
|
91
|
-
"js"
|
|
2
|
+
"name": "@pgds/api-interface",
|
|
3
|
+
"description": "Api interface for pgds services",
|
|
4
|
+
"authors": "Florry",
|
|
5
|
+
"version": "1.3.2",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "types/",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepublish": "npm run build",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"pretest": "npm run build",
|
|
12
|
+
"test": "nyc --require ts-node/register --reporter=html mocha --colors",
|
|
13
|
+
"clean": "git clean -f -x -e node_modules/ -e coverage/"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"**/*.d.ts",
|
|
17
|
+
"./index.js",
|
|
18
|
+
"lib/**/*.js",
|
|
19
|
+
"lib/**/*.js.map",
|
|
20
|
+
"lib/**/*.d.ts",
|
|
21
|
+
"errors/**/*.js",
|
|
22
|
+
"errors/**/*.js.map",
|
|
23
|
+
"errors/**/*.d.ts",
|
|
24
|
+
"constants/**/*.js",
|
|
25
|
+
"constants/**/*.js.map",
|
|
26
|
+
"constants/**/*.d.ts",
|
|
27
|
+
"utils/**/*.js",
|
|
28
|
+
"utils/**/*.js.map",
|
|
29
|
+
"utils/**/*.d.ts",
|
|
30
|
+
"client/**/*.js",
|
|
31
|
+
"client/**/*.js.map",
|
|
32
|
+
"client/**/*.d.ts"
|
|
92
33
|
],
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@types/restify": "^8.5.12",
|
|
36
|
+
"@types/restify-errors": "^4.3.9",
|
|
37
|
+
"ajv": "8.17.1",
|
|
38
|
+
"ajv-formats": "3.0.1",
|
|
39
|
+
"axios": "1.7.9",
|
|
40
|
+
"bunyan": "1.8.15",
|
|
41
|
+
"bunyan-format": "^0.2.1",
|
|
42
|
+
"mustbe": "0.4.0",
|
|
43
|
+
"nyc": "^17.1.0",
|
|
44
|
+
"prom-client": "^12.0.0",
|
|
45
|
+
"restify": "^11.1.0",
|
|
46
|
+
"restify-errors": "8.0.2",
|
|
47
|
+
"semver": "^7.3.8",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
49
|
+
"ts-node-test-register": "^10.0.0",
|
|
50
|
+
"uuid": "9.0.1",
|
|
51
|
+
"typescript": "^5.7.2",
|
|
52
|
+
"typescript-json-schema": "0.65.1"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/bunyan-format": "0.2.9",
|
|
56
|
+
"@types/chai": "4.3.12",
|
|
57
|
+
"@types/mocha": "^10.0.6",
|
|
58
|
+
"@types/mockery": "^1.4.30",
|
|
59
|
+
"@types/nock": "11.1.0",
|
|
60
|
+
"@types/semver": "^7.3.13",
|
|
61
|
+
"@types/supertest": "^2.0.11",
|
|
62
|
+
"@types/uuid": "^8.3.4",
|
|
63
|
+
"chai": "^4.3.6",
|
|
64
|
+
"chai-subset": "^1.6.0",
|
|
65
|
+
"mocha": "10.2.0",
|
|
66
|
+
"mockery": "2.1.0",
|
|
67
|
+
"supertest": "6.3.4",
|
|
68
|
+
"nock": "13.5.5"
|
|
69
|
+
},
|
|
70
|
+
"directories": {
|
|
71
|
+
"example": "examples",
|
|
72
|
+
"lib": "lib",
|
|
73
|
+
"types": "types"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git+https://github.com/hiotlabs/hiot-api-interface.git"
|
|
78
|
+
},
|
|
79
|
+
"keywords": [
|
|
80
|
+
"restify"
|
|
81
|
+
],
|
|
82
|
+
"author": "",
|
|
83
|
+
"license": "ISC",
|
|
84
|
+
"bugs": {
|
|
85
|
+
"url": "https://github.com/hiotlabs/hiot-api-interface/issues"
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://github.com/hiotlabs/hiot-api-interface#readme",
|
|
88
|
+
"mocha": {
|
|
89
|
+
"extension": [
|
|
90
|
+
"ts",
|
|
91
|
+
"js"
|
|
92
|
+
],
|
|
93
|
+
"spec": "test/**/*.test.{ts,js}"
|
|
94
|
+
},
|
|
95
|
+
"nyc": {
|
|
96
|
+
"exclude": [
|
|
97
|
+
"coverage",
|
|
98
|
+
"test",
|
|
99
|
+
"**/*.d.ts",
|
|
100
|
+
"**/*.js.map"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
}
|
package/utils/index.js
CHANGED
|
@@ -36,6 +36,9 @@ function canManageOrganization(reqUser) {
|
|
|
36
36
|
* @param organizationId The organizationId to check for access to.
|
|
37
37
|
*/
|
|
38
38
|
function isOrganizationAccessibleToUser(reqUser, organizationId) {
|
|
39
|
+
if (isGlobal(reqUser)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
39
42
|
return reqUser.getOrganizationTreeIds().includes(organizationId);
|
|
40
43
|
}
|
|
41
44
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,kCAMC;AAED,4BAEC;AAKD,sDAEC;AAOD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,kCAMC;AAED,4BAEC;AAKD,sDAEC;AAOD,wEAMC;AAxCD,0CAAiF;AACjF,yDAA4D;AAG5D;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,OAAgB,EAAE,QAAgB,EAAE,aAA6B;IAA7B,8BAAA,EAAA,oBAA6B;IAC3F,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,IAAA,+BAAgB,EAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED,SAAgB,QAAQ,CAAC,OAAgB;IACvC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,2BAAe,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,OAAgB;IACpD,OAAO,WAAW,CAAC,OAAO,EAAE,4CAAgC,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B,CAAC,OAAgB,EAAE,cAAsB;IACrF,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC,sBAAsB,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AACnE,CAAC"}
|