@flink-app/management-actions-plugin 0.7.0-alpha.1 → 0.11.4-next.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/handlers/Get.js +26 -28
- package/dist/handlers/PostById.js +50 -52
- package/dist/index.js +5 -1
- package/dist/schemas/Action.js +2 -2
- package/package.json +7 -7
package/dist/handlers/Get.js
CHANGED
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
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]) {
|
|
@@ -36,34 +36,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var getHandler = function (_a) {
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (((_b = module.data) === null || _b === void 0 ? void 0 : _b.actions) == null) {
|
|
48
|
-
return [2 /*return*/, {
|
|
49
|
-
data: [],
|
|
50
|
-
status: 200,
|
|
51
|
-
}];
|
|
52
|
-
}
|
|
53
|
-
actions = (_c = module.data) === null || _c === void 0 ? void 0 : _c.actions;
|
|
54
|
-
data = actions.map(function (a) {
|
|
55
|
-
var av = {
|
|
56
|
-
id: a.id,
|
|
57
|
-
description: a.description,
|
|
58
|
-
arguments: a.arguments,
|
|
59
|
-
};
|
|
60
|
-
return av;
|
|
61
|
-
});
|
|
39
|
+
var getHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
40
|
+
var modules, module, actions, data;
|
|
41
|
+
var _c, _d;
|
|
42
|
+
var ctx = _b.ctx, req = _b.req, origin = _b.origin;
|
|
43
|
+
return __generator(this, function (_e) {
|
|
44
|
+
modules = ctx.plugins.managementApi.moduleList.modules;
|
|
45
|
+
module = modules.find(function (p) { return p.id == origin; });
|
|
46
|
+
if (((_c = module.data) === null || _c === void 0 ? void 0 : _c.actions) == null) {
|
|
62
47
|
return [2 /*return*/, {
|
|
63
|
-
data:
|
|
48
|
+
data: [],
|
|
64
49
|
status: 200,
|
|
65
50
|
}];
|
|
51
|
+
}
|
|
52
|
+
actions = (_d = module.data) === null || _d === void 0 ? void 0 : _d.actions;
|
|
53
|
+
data = actions.map(function (a) {
|
|
54
|
+
var av = {
|
|
55
|
+
id: a.id,
|
|
56
|
+
description: a.description,
|
|
57
|
+
arguments: a.arguments,
|
|
58
|
+
};
|
|
59
|
+
return av;
|
|
66
60
|
});
|
|
61
|
+
return [2 /*return*/, {
|
|
62
|
+
data: data,
|
|
63
|
+
status: 200,
|
|
64
|
+
}];
|
|
67
65
|
});
|
|
68
|
-
};
|
|
66
|
+
}); };
|
|
69
67
|
exports.default = getHandler;
|
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
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,56 +38,54 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var flink_1 = require("@flink-app/flink");
|
|
40
40
|
var Action_1 = require("../schemas/Action");
|
|
41
|
-
var postHandler = function (_a) {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (arg.
|
|
62
|
-
|
|
63
|
-
return [2 /*return*/, flink_1.badRequest(arg.id + " is missing ")];
|
|
64
|
-
}
|
|
41
|
+
var postHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
|
+
var modules, module, actions, action, i, arg, resp, ex_1;
|
|
43
|
+
var _c;
|
|
44
|
+
var ctx = _b.ctx, req = _b.req, origin = _b.origin;
|
|
45
|
+
return __generator(this, function (_d) {
|
|
46
|
+
switch (_d.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
modules = ctx.plugins.managementApi.moduleList.modules;
|
|
49
|
+
module = modules.find(function (p) { return p.id == origin; });
|
|
50
|
+
if (((_c = module.data) === null || _c === void 0 ? void 0 : _c.actions) == null) {
|
|
51
|
+
return [2 /*return*/, (0, flink_1.notFound)("Action not found")];
|
|
52
|
+
}
|
|
53
|
+
actions = module.data.actions;
|
|
54
|
+
action = actions.find(function (a) { return a.id == req.params.actionId; });
|
|
55
|
+
if (action == null) {
|
|
56
|
+
return [2 /*return*/, (0, flink_1.notFound)("Action not found")];
|
|
57
|
+
}
|
|
58
|
+
for (i in action.arguments) {
|
|
59
|
+
arg = action.arguments[i];
|
|
60
|
+
if (arg.required) {
|
|
61
|
+
if (req.body[arg.id] == null) {
|
|
62
|
+
return [2 /*return*/, (0, flink_1.badRequest)("".concat(arg.id, " is missing "))];
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
65
|
+
}
|
|
66
|
+
_d.label = 1;
|
|
67
|
+
case 1:
|
|
68
|
+
_d.trys.push([1, 3, , 4]);
|
|
69
|
+
return [4 /*yield*/, action.handler(ctx, req.body)];
|
|
70
|
+
case 2:
|
|
71
|
+
resp = _d.sent();
|
|
72
|
+
if (resp.status == Action_1.ActionReturnStatus.success) {
|
|
73
|
+
return [2 /*return*/, {
|
|
74
|
+
data: resp,
|
|
75
|
+
status: 200,
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return [2 /*return*/, (0, flink_1.internalServerError)(resp.error)];
|
|
80
|
+
}
|
|
81
|
+
return [3 /*break*/, 4];
|
|
82
|
+
case 3:
|
|
83
|
+
ex_1 = _d.sent();
|
|
84
|
+
console.log("EXCEPTIOIN managementActionsPlugin:");
|
|
85
|
+
console.log(ex_1);
|
|
86
|
+
return [2 /*return*/, (0, flink_1.internalServerError)()];
|
|
87
|
+
case 4: return [2 /*return*/];
|
|
88
|
+
}
|
|
91
89
|
});
|
|
92
|
-
};
|
|
90
|
+
}); };
|
|
93
91
|
exports.default = postHandler;
|
package/dist/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];
|
package/dist/schemas/Action.js
CHANGED
|
@@ -5,8 +5,8 @@ var ActionReturnStatus;
|
|
|
5
5
|
(function (ActionReturnStatus) {
|
|
6
6
|
ActionReturnStatus["success"] = "SUCCESS";
|
|
7
7
|
ActionReturnStatus["error"] = "ERROR";
|
|
8
|
-
})(ActionReturnStatus
|
|
8
|
+
})(ActionReturnStatus || (exports.ActionReturnStatus = ActionReturnStatus = {}));
|
|
9
9
|
var ActionArugmentType;
|
|
10
10
|
(function (ActionArugmentType) {
|
|
11
11
|
ActionArugmentType["text"] = "TEXT";
|
|
12
|
-
})(ActionArugmentType
|
|
12
|
+
})(ActionArugmentType || (exports.ActionArugmentType = ActionArugmentType = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/management-actions-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.4-next.0",
|
|
4
4
|
"description": "Flink plugin that makes it possible create actions that can be run trought the management-api",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\"",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"types": "dist/src/index.d.ts",
|
|
16
16
|
"main": "dist/src/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@flink-app/management-api-plugin": "^0.
|
|
18
|
+
"@flink-app/management-api-plugin": "^0.11.4-next.0",
|
|
19
19
|
"express": "^4.17.1",
|
|
20
20
|
"node-color-log": "^5.3.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@flink-app/flink": "^0.
|
|
23
|
+
"@flink-app/flink": "^0.11.4-next.0",
|
|
24
24
|
"@types/express": "4.17.11",
|
|
25
|
-
"@types/node": "^
|
|
26
|
-
"ts-node": "^9.
|
|
27
|
-
"typescript": "
|
|
25
|
+
"@types/node": "^22.10.1",
|
|
26
|
+
"ts-node": "^10.9.2",
|
|
27
|
+
"typescript": "5.6.2"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "6a44df1b6601c86ea3402750b939784d003202c3"
|
|
30
30
|
}
|