@flink-app/management-api-plugin 0.11.14 → 0.12.1-alpha.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/.flink/generatedHandlers.ts +1 -1
- package/.flink/generatedJobs.ts +1 -1
- package/.flink/generatedRepos.ts +1 -1
- package/.flink/schemas/schemas.json +6 -6
- package/.flink/schemas/schemas.ts +7 -7
- package/.flink/start.ts +1 -1
- package/dist/.flink/generatedHandlers.js +6 -2
- package/dist/.flink/generatedJobs.js +1 -1
- package/dist/.flink/generatedRepos.js +1 -1
- package/dist/.flink/schemas/schemas.d.ts +6 -6
- package/dist/.flink/schemas/schemas.json +6 -6
- package/dist/.flink/start.js +1 -1
- package/dist/src/handlers/Management/GetManagement.js +9 -11
- package/dist/src/handlers/User/DeleteByUserid.js +18 -20
- package/dist/src/handlers/User/GetByUserid.js +18 -20
- package/dist/src/handlers/User/GetList.d.ts +2 -2
- package/dist/src/handlers/User/GetList.js +19 -21
- package/dist/src/handlers/User/GetMe.js +21 -23
- package/dist/src/handlers/User/Post.d.ts +1 -1
- package/dist/src/handlers/User/Post.js +37 -39
- package/dist/src/handlers/User/PostLogin.d.ts +1 -1
- package/dist/src/handlers/User/PostLogin.js +31 -33
- package/dist/src/handlers/User/PutByUserid.js +42 -44
- package/dist/src/index.js +6 -2
- package/dist/src/models/ManagementApi.js +1 -1
- package/package.json +5 -6
- package/src/handlers/Management/GetManagement.ts +6 -13
- package/src/handlers/User/GetList.ts +14 -18
- package/src/handlers/User/Post.ts +19 -24
- package/src/schemas/ManagementUser.ts +6 -6
- package/src/schemas/ManagementUserViewModel.ts +3 -5
- package/src/schemas/ModuleList.ts +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
|
|
3
3
|
import * as GetManagement_0 from "../src/handlers/Management/GetManagement";
|
|
4
4
|
import * as DeleteByUserid_0 from "../src/handlers/User/DeleteByUserid";
|
package/.flink/generatedJobs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredJobs } from "@flink-app/flink";
|
|
3
3
|
export const jobs = [];
|
|
4
4
|
autoRegisteredJobs.push(...jobs);
|
package/.flink/generatedRepos.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredRepos } from "@flink-app/flink";
|
|
3
3
|
import ManagementUserRepo from "../src/repos/ManagementUserRepo";
|
|
4
4
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$ref": "#/definitions/Schemas",
|
|
4
4
|
"definitions": {
|
|
5
|
-
"
|
|
5
|
+
"GetManagement_6_ReqSchema": {
|
|
6
6
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
9
9
|
"properties": {},
|
|
10
10
|
"definitions": {}
|
|
11
11
|
},
|
|
12
|
-
"
|
|
12
|
+
"GetManagement_6_ResSchema": {
|
|
13
13
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
14
14
|
"type": "object",
|
|
15
15
|
"additionalProperties": false,
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
],
|
|
118
118
|
"definitions": {}
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"GetList_9_ReqSchema": {
|
|
121
121
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
122
122
|
"type": "object",
|
|
123
123
|
"additionalProperties": false,
|
|
124
124
|
"properties": {},
|
|
125
125
|
"definitions": {}
|
|
126
126
|
},
|
|
127
|
-
"
|
|
127
|
+
"GetList_9_ResSchema": {
|
|
128
128
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
129
129
|
"type": "object",
|
|
130
130
|
"additionalProperties": false,
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
],
|
|
193
193
|
"definitions": {}
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"Post_14_ReqSchema": {
|
|
196
196
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
197
197
|
"type": "object",
|
|
198
198
|
"additionalProperties": false,
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
],
|
|
211
211
|
"definitions": {}
|
|
212
212
|
},
|
|
213
|
-
"
|
|
213
|
+
"Post_14_ResSchema": {
|
|
214
214
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
215
215
|
"type": "object",
|
|
216
216
|
"additionalProperties": false,
|
|
@@ -15,10 +15,10 @@ import { PostUserLoginRes } from "../../src/schemas/User/PostLoginRes";
|
|
|
15
15
|
import { PutUserByUseridReq } from "../../src/schemas/User/PutByUseridReq";
|
|
16
16
|
import { PutUserByUseridRes } from "../../src/schemas/User/PutByUseridRes";
|
|
17
17
|
|
|
18
|
-
// Generated
|
|
19
|
-
export interface
|
|
18
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
19
|
+
export interface GetManagement_6_ReqSchema extends GetManagementReq {}
|
|
20
20
|
|
|
21
|
-
export interface
|
|
21
|
+
export interface GetManagement_6_ResSchema extends GetManagementRes {}
|
|
22
22
|
|
|
23
23
|
export interface DeleteByUserid_15_ReqSchema extends DeleteUserByUseridReq {}
|
|
24
24
|
|
|
@@ -28,17 +28,17 @@ export interface GetByUserid_15_ReqSchema extends GetUserByUseridReq {}
|
|
|
28
28
|
|
|
29
29
|
export interface GetByUserid_15_ResSchema extends GetUserByUseridRes {}
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface GetList_9_ReqSchema extends GetUserListReq {}
|
|
32
32
|
|
|
33
|
-
export interface
|
|
33
|
+
export interface GetList_9_ResSchema extends GetUserListRes {}
|
|
34
34
|
|
|
35
35
|
export interface GetMe_8_ReqSchema extends GetUserMeReq {}
|
|
36
36
|
|
|
37
37
|
export interface GetMe_8_ResSchema extends GetUserMeRes {}
|
|
38
38
|
|
|
39
|
-
export interface
|
|
39
|
+
export interface Post_14_ReqSchema extends PostUserReq {}
|
|
40
40
|
|
|
41
|
-
export interface
|
|
41
|
+
export interface Post_14_ResSchema extends PostUserRes {}
|
|
42
42
|
|
|
43
43
|
export interface PostLogin_21_ReqSchema extends PostUserLoginReq {}
|
|
44
44
|
|
package/.flink/start.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -20,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
26
|
exports.handlers = void 0;
|
|
23
|
-
// Generated
|
|
27
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
24
28
|
var flink_1 = require("@flink-app/flink");
|
|
25
29
|
var DeleteByUserid_0 = __importStar(require("../src/handlers/User/DeleteByUserid"));
|
|
26
30
|
var GetByUserid_1 = __importStar(require("../src/handlers/User/GetByUserid"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jobs = void 0;
|
|
4
|
-
// Generated
|
|
4
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
5
5
|
var flink_1 = require("@flink-app/flink");
|
|
6
6
|
exports.jobs = [];
|
|
7
7
|
flink_1.autoRegisteredJobs.push.apply(flink_1.autoRegisteredJobs, exports.jobs);
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.repos = void 0;
|
|
7
|
-
// Generated
|
|
7
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
8
8
|
var flink_1 = require("@flink-app/flink");
|
|
9
9
|
var ManagementUserRepo_1 = __importDefault(require("../src/repos/ManagementUserRepo"));
|
|
10
10
|
exports.repos = [{ collectionName: "managementuser", repoInstanceName: "managementUserRepo", Repo: ManagementUserRepo_1.default }];
|
|
@@ -14,9 +14,9 @@ import { PostUserLoginReq } from "../../src/schemas/User/PostLoginReq";
|
|
|
14
14
|
import { PostUserLoginRes } from "../../src/schemas/User/PostLoginRes";
|
|
15
15
|
import { PutUserByUseridReq } from "../../src/schemas/User/PutByUseridReq";
|
|
16
16
|
import { PutUserByUseridRes } from "../../src/schemas/User/PutByUseridRes";
|
|
17
|
-
export interface
|
|
17
|
+
export interface GetManagement_6_ReqSchema extends GetManagementReq {
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
19
|
+
export interface GetManagement_6_ResSchema extends GetManagementRes {
|
|
20
20
|
}
|
|
21
21
|
export interface DeleteByUserid_15_ReqSchema extends DeleteUserByUseridReq {
|
|
22
22
|
}
|
|
@@ -26,17 +26,17 @@ export interface GetByUserid_15_ReqSchema extends GetUserByUseridReq {
|
|
|
26
26
|
}
|
|
27
27
|
export interface GetByUserid_15_ResSchema extends GetUserByUseridRes {
|
|
28
28
|
}
|
|
29
|
-
export interface
|
|
29
|
+
export interface GetList_9_ReqSchema extends GetUserListReq {
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface GetList_9_ResSchema extends GetUserListRes {
|
|
32
32
|
}
|
|
33
33
|
export interface GetMe_8_ReqSchema extends GetUserMeReq {
|
|
34
34
|
}
|
|
35
35
|
export interface GetMe_8_ResSchema extends GetUserMeRes {
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface Post_14_ReqSchema extends PostUserReq {
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface Post_14_ResSchema extends PostUserRes {
|
|
40
40
|
}
|
|
41
41
|
export interface PostLogin_21_ReqSchema extends PostUserLoginReq {
|
|
42
42
|
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$ref": "#/definitions/Schemas",
|
|
4
4
|
"definitions": {
|
|
5
|
-
"
|
|
5
|
+
"GetManagement_6_ReqSchema": {
|
|
6
6
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
9
9
|
"properties": {},
|
|
10
10
|
"definitions": {}
|
|
11
11
|
},
|
|
12
|
-
"
|
|
12
|
+
"GetManagement_6_ResSchema": {
|
|
13
13
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
14
14
|
"type": "object",
|
|
15
15
|
"additionalProperties": false,
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
],
|
|
118
118
|
"definitions": {}
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"GetList_9_ReqSchema": {
|
|
121
121
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
122
122
|
"type": "object",
|
|
123
123
|
"additionalProperties": false,
|
|
124
124
|
"properties": {},
|
|
125
125
|
"definitions": {}
|
|
126
126
|
},
|
|
127
|
-
"
|
|
127
|
+
"GetList_9_ResSchema": {
|
|
128
128
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
129
129
|
"type": "object",
|
|
130
130
|
"additionalProperties": false,
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
],
|
|
193
193
|
"definitions": {}
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"Post_14_ReqSchema": {
|
|
196
196
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
197
197
|
"type": "object",
|
|
198
198
|
"additionalProperties": false,
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
],
|
|
211
211
|
"definitions": {}
|
|
212
212
|
},
|
|
213
|
-
"
|
|
213
|
+
"Post_14_ResSchema": {
|
|
214
214
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
215
215
|
"type": "object",
|
|
216
216
|
"additionalProperties": false,
|
package/dist/.flink/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated
|
|
3
|
+
// Generated Wed Mar 19 2025 22:58:37 GMT+0100 (Central European Standard Time)
|
|
4
4
|
require("./generatedHandlers");
|
|
5
5
|
require("./generatedRepos");
|
|
6
6
|
require("./generatedJobs");
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -37,17 +37,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
40
|
-
var GetManagement = function (_a) {
|
|
41
|
-
var ctx =
|
|
42
|
-
return
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}];
|
|
48
|
-
});
|
|
40
|
+
var GetManagement = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
41
|
+
var ctx = _b.ctx, req = _b.req;
|
|
42
|
+
return __generator(this, function (_c) {
|
|
43
|
+
return [2 /*return*/, {
|
|
44
|
+
data: ctx.plugins.managementApi.moduleList,
|
|
45
|
+
status: 200,
|
|
46
|
+
}];
|
|
49
47
|
});
|
|
50
|
-
};
|
|
48
|
+
}); };
|
|
51
49
|
exports.default = GetManagement;
|
|
52
50
|
exports.__assumedHttpMethod = "get", exports.__file = "GetManagement.ts", exports.__query = [], exports.__params = [];
|
|
53
51
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "modules": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "type": { "type": "string" }, "features": { "type": "array", "items": { "type": "string" } }, "title": { "type": "string" }, "ui": { "type": "string" }, "data": { "type": "object" }, "endpoints": { "type": "array", "items": { "type": "object", "properties": { "method": { "type": "string" }, "url": { "type": "string" } }, "required": ["method", "url"], "additionalProperties": false } } }, "required": ["id", "type", "features", "title", "ui", "data", "endpoints"], "additionalProperties": false } } }, "required": ["modules"], "definitions": {} } };
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -45,26 +45,24 @@ exports.Route = {
|
|
|
45
45
|
// type Params = {
|
|
46
46
|
// userid: string;
|
|
47
47
|
// };
|
|
48
|
-
var DeleteUserByUserid = function (_a) {
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
});
|
|
48
|
+
var DeleteUserByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
49
|
+
var count;
|
|
50
|
+
var ctx = _b.ctx, req = _b.req;
|
|
51
|
+
return __generator(this, function (_c) {
|
|
52
|
+
switch (_c.label) {
|
|
53
|
+
case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.deleteById(req.params.userid)];
|
|
54
|
+
case 1:
|
|
55
|
+
count = _c.sent();
|
|
56
|
+
if (count == 0) {
|
|
57
|
+
return [2 /*return*/, (0, flink_1.notFound)()];
|
|
58
|
+
}
|
|
59
|
+
return [2 /*return*/, {
|
|
60
|
+
data: {},
|
|
61
|
+
status: 200,
|
|
62
|
+
}];
|
|
63
|
+
}
|
|
66
64
|
});
|
|
67
|
-
};
|
|
65
|
+
}); };
|
|
68
66
|
exports.default = DeleteUserByUserid;
|
|
69
67
|
exports.__assumedHttpMethod = "delete", exports.__file = "DeleteByUserid.ts", exports.__query = [], exports.__params = [];
|
|
70
68
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} } };
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -46,26 +46,24 @@ exports.Route = {
|
|
|
46
46
|
// type Params = {
|
|
47
47
|
// userid: string;
|
|
48
48
|
// };
|
|
49
|
-
var GetUserByUserid = function (_a) {
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
});
|
|
49
|
+
var GetUserByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
50
|
+
var user;
|
|
51
|
+
var ctx = _b.ctx, req = _b.req;
|
|
52
|
+
return __generator(this, function (_c) {
|
|
53
|
+
switch (_c.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getById(req.params.userid)];
|
|
55
|
+
case 1:
|
|
56
|
+
user = _c.sent();
|
|
57
|
+
if (user == null) {
|
|
58
|
+
return [2 /*return*/, (0, flink_1.notFound)()];
|
|
59
|
+
}
|
|
60
|
+
return [2 /*return*/, {
|
|
61
|
+
data: (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user),
|
|
62
|
+
status: 200,
|
|
63
|
+
}];
|
|
64
|
+
}
|
|
67
65
|
});
|
|
68
|
-
};
|
|
66
|
+
}); };
|
|
69
67
|
exports.default = GetUserByUserid;
|
|
70
68
|
exports.__assumedHttpMethod = "get", exports.__file = "GetByUserid.ts", exports.__query = [], exports.__params = [];
|
|
71
69
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"], "definitions": {} } };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Handler } from "@flink-app/flink";
|
|
2
|
+
import { Ctx } from "../../Ctx";
|
|
2
3
|
import { GetUserListReq } from "../../schemas/User/GetListReq";
|
|
3
4
|
import { GetUserListRes } from "../../schemas/User/GetListRes";
|
|
4
|
-
|
|
5
|
-
declare type Params = {};
|
|
5
|
+
type Params = {};
|
|
6
6
|
declare const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params>;
|
|
7
7
|
export default GetUserList;
|
|
8
8
|
export declare const __assumedHttpMethod = "get", __file = "GetList.ts", __query: never[], __params: never[];
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -38,27 +38,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
40
40
|
var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
|
|
41
|
-
var GetUserList = function (_a) {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
});
|
|
41
|
+
var GetUserList = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
|
+
var repo, users;
|
|
43
|
+
var ctx = _b.ctx, req = _b.req;
|
|
44
|
+
return __generator(this, function (_c) {
|
|
45
|
+
switch (_c.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
repo = ctx.repos.managementuserRepo;
|
|
48
|
+
return [4 /*yield*/, repo.findAll()];
|
|
49
|
+
case 1:
|
|
50
|
+
users = _c.sent();
|
|
51
|
+
return [2 /*return*/, {
|
|
52
|
+
data: {
|
|
53
|
+
users: users.map(ManagementUserViewModel_1.GetManagementUserViewModel),
|
|
54
|
+
},
|
|
55
|
+
status: 200,
|
|
56
|
+
}];
|
|
57
|
+
}
|
|
60
58
|
});
|
|
61
|
-
};
|
|
59
|
+
}); };
|
|
62
60
|
exports.default = GetUserList;
|
|
63
61
|
exports.__assumedHttpMethod = "get", exports.__file = "GetList.ts", exports.__query = [], exports.__params = [];
|
|
64
62
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "users": { "type": "array", "items": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] } } }, "required": ["users"], "definitions": {} } };
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -53,29 +53,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
54
54
|
var flink_1 = require("@flink-app/flink");
|
|
55
55
|
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
56
|
-
var GetUserMe = function (_a) {
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
-
});
|
|
56
|
+
var GetUserMe = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
+
var user, iat, rest;
|
|
58
|
+
var ctx = _b.ctx, req = _b.req;
|
|
59
|
+
return __generator(this, function (_c) {
|
|
60
|
+
try {
|
|
61
|
+
user = jsonwebtoken_1.default.verify(req.headers["management-token"], ctx.plugins.managementApi.jwtSecret);
|
|
62
|
+
iat = user.iat, rest = __rest(user, ["iat"]);
|
|
63
|
+
return [2 /*return*/, {
|
|
64
|
+
data: {
|
|
65
|
+
token: req.headers["management-token"],
|
|
66
|
+
user: rest
|
|
67
|
+
},
|
|
68
|
+
status: 200
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
catch (ex) {
|
|
72
|
+
return [2 /*return*/, (0, flink_1.unauthorized)()];
|
|
73
|
+
}
|
|
74
|
+
return [2 /*return*/];
|
|
77
75
|
});
|
|
78
|
-
};
|
|
76
|
+
}); };
|
|
79
77
|
exports.default = GetUserMe;
|
|
80
78
|
exports.__assumedHttpMethod = "get", exports.__file = "GetMe.ts", exports.__query = [], exports.__params = [];
|
|
81
79
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": {}, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"], "definitions": {} } };
|
|
@@ -3,7 +3,7 @@ import { Ctx } from "../../Ctx";
|
|
|
3
3
|
import { PostUserReq } from "../../schemas/User/PostReq";
|
|
4
4
|
import { PostUserRes } from "../../schemas/User/PostRes";
|
|
5
5
|
export declare const Route: RouteProps;
|
|
6
|
-
|
|
6
|
+
type Params = {};
|
|
7
7
|
declare const PostUser: Handler<Ctx, PostUserReq, PostUserRes, Params>;
|
|
8
8
|
export default PostUser;
|
|
9
9
|
export declare const __assumedHttpMethod = "post", __file = "Post.ts", __query: never[], __params: never[];
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -38,50 +38,48 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.Route = void 0;
|
|
40
40
|
var flink_1 = require("@flink-app/flink");
|
|
41
|
-
var bcrypt_1 = require("../../utils/bcrypt");
|
|
42
41
|
var ManagementUserViewModel_1 = require("../../schemas/ManagementUserViewModel");
|
|
42
|
+
var bcrypt_1 = require("../../utils/bcrypt");
|
|
43
43
|
exports.Route = {
|
|
44
44
|
path: "/user",
|
|
45
45
|
method: flink_1.HttpMethod.post,
|
|
46
46
|
};
|
|
47
|
-
var PostUser = function (_a) {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
});
|
|
47
|
+
var PostUser = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
48
|
+
var existingUser, salt, hash, obj, user;
|
|
49
|
+
var ctx = _b.ctx, req = _b.req;
|
|
50
|
+
return __generator(this, function (_c) {
|
|
51
|
+
switch (_c.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
if (req.body.username.length == 0 || req.body.password.length == 0) {
|
|
54
|
+
return [2 /*return*/, (0, flink_1.badRequest)("Username and password must be specified")];
|
|
55
|
+
}
|
|
56
|
+
return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({ username: req.body.username })];
|
|
57
|
+
case 1:
|
|
58
|
+
existingUser = _c.sent();
|
|
59
|
+
if (existingUser != null) {
|
|
60
|
+
return [2 /*return*/, (0, flink_1.conflict)("Username already taken")];
|
|
61
|
+
}
|
|
62
|
+
return [4 /*yield*/, (0, bcrypt_1.genSalt)(10)];
|
|
63
|
+
case 2:
|
|
64
|
+
salt = _c.sent();
|
|
65
|
+
return [4 /*yield*/, (0, bcrypt_1.encrypt)(req.body.password, salt)];
|
|
66
|
+
case 3:
|
|
67
|
+
hash = _c.sent();
|
|
68
|
+
obj = {
|
|
69
|
+
username: req.body.username,
|
|
70
|
+
password: hash,
|
|
71
|
+
salt: salt,
|
|
72
|
+
};
|
|
73
|
+
return [4 /*yield*/, ctx.repos.managementuserRepo.create(obj)];
|
|
74
|
+
case 4:
|
|
75
|
+
user = _c.sent();
|
|
76
|
+
return [2 /*return*/, {
|
|
77
|
+
data: (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user),
|
|
78
|
+
status: 200,
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
83
81
|
});
|
|
84
|
-
};
|
|
82
|
+
}); };
|
|
85
83
|
exports.default = PostUser;
|
|
86
84
|
exports.__assumedHttpMethod = "post", exports.__file = "Post.ts", exports.__query = [], exports.__params = [];
|
|
87
85
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"], "definitions": {} } };
|
|
@@ -3,7 +3,7 @@ import { Ctx } from "../../Ctx";
|
|
|
3
3
|
import { PostUserLoginReq } from "../../schemas/User/PostLoginReq";
|
|
4
4
|
import { PostUserLoginRes } from "../../schemas/User/PostLoginRes";
|
|
5
5
|
export declare const Route: RouteProps;
|
|
6
|
-
|
|
6
|
+
type Params = {};
|
|
7
7
|
declare const PostUserLogin: Handler<Ctx, PostUserLoginReq, PostUserLoginRes, Params>;
|
|
8
8
|
export default PostUserLogin;
|
|
9
9
|
export declare const __assumedHttpMethod = "post", __file = "PostLogin.ts", __query: never[], __params: never[];
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -48,39 +48,37 @@ exports.Route = {
|
|
|
48
48
|
path: "/user/login",
|
|
49
49
|
method: flink_1.HttpMethod.post,
|
|
50
50
|
};
|
|
51
|
-
var PostUserLogin = function (_a) {
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
});
|
|
51
|
+
var PostUserLogin = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
52
|
+
var user, hashCandidate, viewUser, token;
|
|
53
|
+
var ctx = _b.ctx, req = _b.req;
|
|
54
|
+
return __generator(this, function (_c) {
|
|
55
|
+
switch (_c.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
|
|
57
|
+
username: req.body.username,
|
|
58
|
+
})];
|
|
59
|
+
case 1:
|
|
60
|
+
user = _c.sent();
|
|
61
|
+
if (user == null) {
|
|
62
|
+
return [2 /*return*/, (0, flink_1.unauthorized)("Username or password invalid")];
|
|
63
|
+
}
|
|
64
|
+
return [4 /*yield*/, (0, bcrypt_1.encrypt)(req.body.password, user.salt)];
|
|
65
|
+
case 2:
|
|
66
|
+
hashCandidate = _c.sent();
|
|
67
|
+
if (hashCandidate !== user.password) {
|
|
68
|
+
return [2 /*return*/, (0, flink_1.unauthorized)("Username or password invalid")];
|
|
69
|
+
}
|
|
70
|
+
viewUser = (0, ManagementUserViewModel_1.GetManagementUserViewModel)(user);
|
|
71
|
+
token = jsonwebtoken_1.default.sign(viewUser, ctx.plugins.managementApi.jwtSecret);
|
|
72
|
+
return [2 /*return*/, {
|
|
73
|
+
data: {
|
|
74
|
+
user: viewUser,
|
|
75
|
+
token: token,
|
|
76
|
+
},
|
|
77
|
+
status: 200,
|
|
78
|
+
}];
|
|
79
|
+
}
|
|
82
80
|
});
|
|
83
|
-
};
|
|
81
|
+
}); };
|
|
84
82
|
exports.default = PostUserLogin;
|
|
85
83
|
exports.__assumedHttpMethod = "post", exports.__file = "PostLogin.ts", exports.__query = [], exports.__params = [];
|
|
86
84
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": ["password", "username"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "user": { "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"] }, "token": { "type": "string" } }, "required": ["token", "user"], "definitions": {} } };
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -47,51 +47,49 @@ exports.Route = {
|
|
|
47
47
|
// type Params = {
|
|
48
48
|
// userid: string;
|
|
49
49
|
// };
|
|
50
|
-
var PutUserByUserid = function (_a) {
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (existingUser !=
|
|
65
|
-
|
|
66
|
-
return [2 /*return*/, flink_1.conflict("Username already taken")];
|
|
67
|
-
}
|
|
50
|
+
var PutUserByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
51
|
+
var model, existingUser, salt, hash, updated;
|
|
52
|
+
var ctx = _b.ctx, req = _b.req;
|
|
53
|
+
return __generator(this, function (_c) {
|
|
54
|
+
switch (_c.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
model = req.body;
|
|
57
|
+
if (!(model.username != null)) return [3 /*break*/, 2];
|
|
58
|
+
return [4 /*yield*/, ctx.repos.managementuserRepo.getOne({
|
|
59
|
+
username: model.username,
|
|
60
|
+
})];
|
|
61
|
+
case 1:
|
|
62
|
+
existingUser = _c.sent();
|
|
63
|
+
if (existingUser != null) {
|
|
64
|
+
if (existingUser._id != req.params.userid) {
|
|
65
|
+
return [2 /*return*/, (0, flink_1.conflict)("Username already taken")];
|
|
68
66
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
67
|
+
}
|
|
68
|
+
_c.label = 2;
|
|
69
|
+
case 2:
|
|
70
|
+
if (!(model.password != null)) return [3 /*break*/, 5];
|
|
71
|
+
return [4 /*yield*/, (0, bcrypt_1.genSalt)(10)];
|
|
72
|
+
case 3:
|
|
73
|
+
salt = _c.sent();
|
|
74
|
+
return [4 /*yield*/, (0, bcrypt_1.encrypt)(model.password, salt)];
|
|
75
|
+
case 4:
|
|
76
|
+
hash = _c.sent();
|
|
77
|
+
model.password = hash;
|
|
78
|
+
model.salt = salt;
|
|
79
|
+
_c.label = 5;
|
|
80
|
+
case 5: return [4 /*yield*/, ctx.repos.managementuserRepo.updateOne(req.params.userid, model)];
|
|
81
|
+
case 6:
|
|
82
|
+
updated = _c.sent();
|
|
83
|
+
if (updated == null) {
|
|
84
|
+
return [2 /*return*/, (0, flink_1.notFound)()];
|
|
85
|
+
}
|
|
86
|
+
return [2 /*return*/, {
|
|
87
|
+
data: (0, ManagementUserViewModel_1.GetManagementUserViewModel)(updated),
|
|
88
|
+
status: 200,
|
|
89
|
+
}];
|
|
90
|
+
}
|
|
93
91
|
});
|
|
94
|
-
};
|
|
92
|
+
}); };
|
|
95
93
|
exports.default = PutUserByUserid;
|
|
96
94
|
exports.__assumedHttpMethod = "put", exports.__file = "PutByUserid.ts", exports.__query = [], exports.__params = [];
|
|
97
95
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "_id": { "type": "string" }, "username": { "type": "string" } }, "required": ["_id", "username"], "definitions": {} } };
|
package/dist/src/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -166,7 +170,7 @@ function init(app, options) {
|
|
|
166
170
|
next();
|
|
167
171
|
}
|
|
168
172
|
catch (ex) {
|
|
169
|
-
res.status(401).json(flink_1.unauthorized());
|
|
173
|
+
res.status(401).json((0, flink_1.unauthorized)());
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
});
|
|
@@ -8,4 +8,4 @@ var ManagementApiType;
|
|
|
8
8
|
ManagementApiType["action"] = "ACTION";
|
|
9
9
|
ManagementApiType["debug"] = "DEBUG";
|
|
10
10
|
ManagementApiType["notification"] = "NOTIFICATION";
|
|
11
|
-
})(ManagementApiType
|
|
11
|
+
})(ManagementApiType || (exports.ManagementApiType = ManagementApiType = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/management-api-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1-alpha.1",
|
|
4
4
|
"description": "Flink plugin that makes it possible to expose management api:s for other plugins",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -16,20 +16,19 @@
|
|
|
16
16
|
"types": "dist/src/index.d.ts",
|
|
17
17
|
"main": "dist/src/index.js",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/mongodb": "3.6.12",
|
|
20
19
|
"bcrypt": "^5.0.1",
|
|
21
20
|
"express": "^4.17.1",
|
|
22
21
|
"jsonwebtoken": "^8.5.1"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@flink-app/flink": "^0.
|
|
24
|
+
"@flink-app/flink": "^0.12.1-alpha.1",
|
|
26
25
|
"@types/bcrypt": "^5.0.0",
|
|
27
26
|
"@types/express": "4.17.11",
|
|
28
27
|
"@types/express-fileupload": "^1.1.7",
|
|
29
28
|
"@types/jsonwebtoken": "^8.5.4",
|
|
30
|
-
"@types/node": "
|
|
29
|
+
"@types/node": "22.13.10",
|
|
31
30
|
"ts-node": "^9.1.1",
|
|
32
|
-
"typescript": "
|
|
31
|
+
"typescript": "5.4.5"
|
|
33
32
|
},
|
|
34
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "040e670be372c0cc47d9c7106bed55780910cf39"
|
|
35
34
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Handler } from "@flink-app/flink";
|
|
2
2
|
import { Ctx } from "../../Ctx";
|
|
3
3
|
import { GetManagementReq } from "../../schemas/Management/GetReq";
|
|
4
4
|
import { GetManagementRes } from "../../schemas/Management/GetRes";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
GetManagementReq,
|
|
12
|
-
GetManagementRes
|
|
13
|
-
> = async ({ ctx, req }) => {
|
|
14
|
-
return {
|
|
15
|
-
data: ctx.plugins.managementApi.moduleList,
|
|
16
|
-
status: 200,
|
|
17
|
-
};
|
|
6
|
+
const GetManagement: Handler<Ctx, GetManagementReq, GetManagementRes> = async ({ ctx, req }) => {
|
|
7
|
+
return {
|
|
8
|
+
data: ctx.plugins.managementApi.moduleList,
|
|
9
|
+
status: 200,
|
|
10
|
+
};
|
|
18
11
|
};
|
|
19
12
|
export default GetManagement;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { Handler
|
|
1
|
+
import { Handler } from "@flink-app/flink";
|
|
2
|
+
import { Ctx } from "../../Ctx";
|
|
3
|
+
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
2
4
|
import { GetUserListReq } from "../../schemas/User/GetListReq";
|
|
3
5
|
import { GetUserListRes } from "../../schemas/User/GetListRes";
|
|
4
|
-
import { Ctx } from "../../Ctx";
|
|
5
|
-
import { GetManagementUserViewModel} from "../../schemas/ManagementUserViewModel";
|
|
6
6
|
|
|
7
|
-
type Params = {
|
|
8
|
-
};
|
|
7
|
+
type Params = {};
|
|
9
8
|
|
|
10
9
|
const GetUserList: Handler<Ctx, GetUserListReq, GetUserListRes, Params> = async ({ ctx, req }) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const users = await repo.findAll();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
data: {
|
|
18
|
-
users : users.map(GetManagementUserViewModel)
|
|
19
|
-
},
|
|
20
|
-
status : 200
|
|
21
|
-
};
|
|
10
|
+
const repo = ctx.repos.managementuserRepo;
|
|
11
|
+
const users = await repo.findAll();
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
return {
|
|
14
|
+
data: {
|
|
15
|
+
users: users.map(GetManagementUserViewModel),
|
|
16
|
+
},
|
|
17
|
+
status: 200,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default GetUserList;
|
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
import { badRequest, conflict, Handler, HttpMethod,
|
|
1
|
+
import { badRequest, conflict, Handler, HttpMethod, RouteProps } from "@flink-app/flink";
|
|
2
2
|
import { Ctx } from "../../Ctx";
|
|
3
|
+
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
3
4
|
import { PostUserReq } from "../../schemas/User/PostReq";
|
|
4
5
|
import { PostUserRes } from "../../schemas/User/PostRes";
|
|
5
|
-
import { encrypt, genSalt } from "../../utils/bcrypt"
|
|
6
|
-
import { GetManagementUserViewModel } from "../../schemas/ManagementUserViewModel";
|
|
6
|
+
import { encrypt, genSalt } from "../../utils/bcrypt";
|
|
7
7
|
export const Route: RouteProps = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
path: "/user",
|
|
9
|
+
method: HttpMethod.post,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
type Params = {
|
|
13
|
-
};
|
|
12
|
+
type Params = {};
|
|
14
13
|
|
|
15
14
|
const PostUser: Handler<Ctx, PostUserReq, PostUserRes, Params> = async ({ ctx, req }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if(req.body.username.length == 0 || req.body.password.length == 0){
|
|
20
|
-
return badRequest("Username and password must be specified");
|
|
15
|
+
if (req.body.username.length == 0 || req.body.password.length == 0) {
|
|
16
|
+
return badRequest("Username and password must be specified");
|
|
21
17
|
}
|
|
22
|
-
const existingUser = await ctx.repos.managementuserRepo.getOne({ username
|
|
23
|
-
if(existingUser!=null){
|
|
24
|
-
|
|
18
|
+
const existingUser = await ctx.repos.managementuserRepo.getOne({ username: req.body.username });
|
|
19
|
+
if (existingUser != null) {
|
|
20
|
+
return conflict("Username already taken");
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
const salt = await genSalt(10);
|
|
28
24
|
const hash = await encrypt(req.body.password, salt);
|
|
29
25
|
|
|
30
26
|
var obj = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
27
|
+
username: req.body.username,
|
|
28
|
+
password: hash,
|
|
29
|
+
salt: salt,
|
|
30
|
+
};
|
|
35
31
|
|
|
36
32
|
const user = await ctx.repos.managementuserRepo.create(obj);
|
|
37
33
|
|
|
38
34
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
data: GetManagementUserViewModel(user),
|
|
36
|
+
status: 200,
|
|
41
37
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export default PostUser;
|
|
38
|
+
};
|
|
39
|
+
export default PostUser;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface ManagementUser{
|
|
2
|
-
_id
|
|
3
|
-
username
|
|
4
|
-
password
|
|
5
|
-
salt
|
|
6
|
-
}
|
|
1
|
+
export interface ManagementUser {
|
|
2
|
+
_id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
salt: string;
|
|
6
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ManagementUser } from "./ManagementUser";
|
|
2
|
-
export interface ManagementUserViewModel extends Omit<ManagementUser, "password" | "salt">{
|
|
2
|
+
export interface ManagementUserViewModel extends Omit<ManagementUser, "password" | "salt"> {}
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const GetManagementUserViewModel = (user : ManagementUser) : ManagementUserViewModel => {
|
|
4
|
+
export const GetManagementUserViewModel = (user: ManagementUser): ManagementUserViewModel => {
|
|
7
5
|
const { password, salt, ...resp } = user;
|
|
8
6
|
return resp;
|
|
9
|
-
}
|
|
7
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export interface ModuleList {
|
|
2
|
-
|
|
2
|
+
modules: Module[];
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export interface Module {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
features: string[];
|
|
9
|
+
title: string;
|
|
10
|
+
ui: string;
|
|
11
|
+
data: { [key: string]: any };
|
|
12
|
+
endpoints: ModuleEndpoint[];
|
|
13
13
|
}
|
|
14
14
|
export interface ModuleEndpoint {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
method: string;
|
|
16
|
+
url: string;
|
|
17
17
|
}
|