@abyss-project/console 1.0.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/.eslintrc.js +34 -0
- package/README.md +2 -0
- package/USAGE_EXAMPLES.md +257 -0
- package/dist/api/application-cron-task.admin.api.d.ts +10 -0
- package/dist/api/application-cron-task.admin.api.js +40 -0
- package/dist/api/application-cron-task.api.d.ts +10 -0
- package/dist/api/application-cron-task.api.js +40 -0
- package/dist/api/application-event.admin.api.d.ts +4 -0
- package/dist/api/application-event.admin.api.js +16 -0
- package/dist/api/application-event.api.d.ts +8 -0
- package/dist/api/application-event.api.js +32 -0
- package/dist/api/application-log.admin.api.d.ts +3 -0
- package/dist/api/application-log.admin.api.js +12 -0
- package/dist/api/application-log.api.d.ts +4 -0
- package/dist/api/application-log.api.js +16 -0
- package/dist/api/application-sentinel.admin.api.d.ts +9 -0
- package/dist/api/application-sentinel.admin.api.js +36 -0
- package/dist/api/application-sentinel.api.d.ts +10 -0
- package/dist/api/application-sentinel.api.js +40 -0
- package/dist/api/application-stats.admin.api.d.ts +3 -0
- package/dist/api/application-stats.admin.api.js +12 -0
- package/dist/api/application-stats.api.d.ts +4 -0
- package/dist/api/application-stats.api.js +16 -0
- package/dist/api/application-webhook-history.admin.api.d.ts +3 -0
- package/dist/api/application-webhook-history.admin.api.js +12 -0
- package/dist/api/application-webhook-history.api.d.ts +3 -0
- package/dist/api/application-webhook-history.api.js +12 -0
- package/dist/api/application-webhook.admin.api.d.ts +7 -0
- package/dist/api/application-webhook.admin.api.js +28 -0
- package/dist/api/application-webhook.api.d.ts +7 -0
- package/dist/api/application-webhook.api.js +28 -0
- package/dist/api/application.admin.api.d.ts +7 -0
- package/dist/api/application.admin.api.js +28 -0
- package/dist/api/application.api.d.ts +10 -0
- package/dist/api/application.api.js +40 -0
- package/dist/api/domain-verification.admin.api.d.ts +2 -0
- package/dist/api/domain-verification.admin.api.js +9 -0
- package/dist/api/domain-verification.api.d.ts +7 -0
- package/dist/api/domain-verification.api.js +28 -0
- package/dist/api/hourly-metrics.api.d.ts +2 -0
- package/dist/api/hourly-metrics.api.js +8 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +21 -0
- package/dist/api/infrastructure.admin.api.d.ts +3 -0
- package/dist/api/infrastructure.admin.api.js +12 -0
- package/dist/api/metrics.api.d.ts +4 -0
- package/dist/api/metrics.api.js +16 -0
- package/dist/api/monitor.api.d.ts +2 -0
- package/dist/api/monitor.api.js +8 -0
- package/dist/api/report.admin.api.d.ts +2 -0
- package/dist/api/report.admin.api.js +9 -0
- package/dist/api/workflow.admin.api.d.ts +8 -0
- package/dist/api/workflow.admin.api.js +34 -0
- package/dist/api/workflow.api.d.ts +15 -0
- package/dist/api/workflow.api.js +62 -0
- package/dist/frameworks/express/decorators.d.ts +52 -0
- package/dist/frameworks/express/decorators.js +163 -0
- package/dist/frameworks/express/index.d.ts +17 -0
- package/dist/frameworks/express/index.js +173 -0
- package/dist/frameworks/express/metadata.d.ts +9 -0
- package/dist/frameworks/express/metadata.js +12 -0
- package/dist/frameworks/index.d.ts +1 -0
- package/dist/frameworks/index.js +17 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +163 -0
- package/dist/middlewares/context.middleware.d.ts +12 -0
- package/dist/middlewares/context.middleware.js +39 -0
- package/dist/middlewares/index.d.ts +3 -0
- package/dist/middlewares/index.js +19 -0
- package/dist/middlewares/logger-endpoint.middleware.d.ts +5 -0
- package/dist/middlewares/logger-endpoint.middleware.js +86 -0
- package/dist/middlewares/logger-setup.middleware.d.ts +5 -0
- package/dist/middlewares/logger-setup.middleware.js +16 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +17 -0
- package/dist/models/logger.model.d.ts +61 -0
- package/dist/models/logger.model.js +201 -0
- package/dist/models/stats-publisher.model.d.ts +20 -0
- package/dist/models/stats-publisher.model.js +113 -0
- package/dist/types/dto/domain-verification.dto.d.ts +19 -0
- package/dist/types/dto/domain-verification.dto.js +2 -0
- package/dist/types/dto/index.d.ts +1 -0
- package/dist/types/dto/index.js +17 -0
- package/dist/types/enum/api-error.enum.d.ts +20 -0
- package/dist/types/enum/api-error.enum.js +25 -0
- package/dist/types/enum/api-method.enum.d.ts +7 -0
- package/dist/types/enum/api-method.enum.js +11 -0
- package/dist/types/enum/application-alert-type.enum.d.ts +5 -0
- package/dist/types/enum/application-alert-type.enum.js +9 -0
- package/dist/types/enum/application-sentinel-type.enum.d.ts +5 -0
- package/dist/types/enum/application-sentinel-type.enum.js +9 -0
- package/dist/types/enum/application-stats-type.enum.d.ts +5 -0
- package/dist/types/enum/application-stats-type.enum.js +9 -0
- package/dist/types/enum/application-webhook-scope.enum.d.ts +4 -0
- package/dist/types/enum/application-webhook-scope.enum.js +8 -0
- package/dist/types/enum/index.d.ts +1 -0
- package/dist/types/enum/index.js +17 -0
- package/dist/types/enum/log-level.enum.d.ts +6 -0
- package/dist/types/enum/log-level.enum.js +10 -0
- package/dist/types/enum/log-scenario.enum.d.ts +5 -0
- package/dist/types/enum/log-scenario.enum.js +9 -0
- package/dist/types/enum/time-period.enum.d.ts +0 -0
- package/dist/types/enum/time-period.enum.js +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/interface/api/index.d.ts +13 -0
- package/dist/types/interface/api/index.js +29 -0
- package/dist/types/interface/api/requests/application-cron-task.admin.request.d.ts +50 -0
- package/dist/types/interface/api/requests/application-cron-task.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-cron-task.request.d.ts +61 -0
- package/dist/types/interface/api/requests/application-cron-task.request.js +2 -0
- package/dist/types/interface/api/requests/application-event.admin.request.d.ts +16 -0
- package/dist/types/interface/api/requests/application-event.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-event.request.d.ts +50 -0
- package/dist/types/interface/api/requests/application-event.request.js +2 -0
- package/dist/types/interface/api/requests/application-log.admin.request.d.ts +19 -0
- package/dist/types/interface/api/requests/application-log.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-log.request.d.ts +59 -0
- package/dist/types/interface/api/requests/application-log.request.js +2 -0
- package/dist/types/interface/api/requests/application-sentinel.admin.request.d.ts +52 -0
- package/dist/types/interface/api/requests/application-sentinel.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-sentinel.request.d.ts +71 -0
- package/dist/types/interface/api/requests/application-sentinel.request.js +2 -0
- package/dist/types/interface/api/requests/application-stats.admin.request.d.ts +13 -0
- package/dist/types/interface/api/requests/application-stats.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-stats.request.d.ts +31 -0
- package/dist/types/interface/api/requests/application-stats.request.js +2 -0
- package/dist/types/interface/api/requests/application-webhook-history.admin.request.d.ts +16 -0
- package/dist/types/interface/api/requests/application-webhook-history.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-webhook-history.request.d.ts +21 -0
- package/dist/types/interface/api/requests/application-webhook-history.request.js +2 -0
- package/dist/types/interface/api/requests/application-webhook.admin.request.d.ts +39 -0
- package/dist/types/interface/api/requests/application-webhook.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application-webhook.request.d.ts +45 -0
- package/dist/types/interface/api/requests/application-webhook.request.js +2 -0
- package/dist/types/interface/api/requests/application.admin.request.d.ts +23 -0
- package/dist/types/interface/api/requests/application.admin.request.js +2 -0
- package/dist/types/interface/api/requests/application.request.d.ts +64 -0
- package/dist/types/interface/api/requests/application.request.js +2 -0
- package/dist/types/interface/api/requests/domain-verification.admin.request.d.ts +5 -0
- package/dist/types/interface/api/requests/domain-verification.admin.request.js +2 -0
- package/dist/types/interface/api/requests/domain-verification.request.d.ts +29 -0
- package/dist/types/interface/api/requests/domain-verification.request.js +2 -0
- package/dist/types/interface/api/requests/hourly-metrics.request.d.ts +10 -0
- package/dist/types/interface/api/requests/hourly-metrics.request.js +2 -0
- package/dist/types/interface/api/requests/infrastructure.admin.request.d.ts +4 -0
- package/dist/types/interface/api/requests/infrastructure.admin.request.js +2 -0
- package/dist/types/interface/api/requests/metrics.admin.request.d.ts +14 -0
- package/dist/types/interface/api/requests/metrics.admin.request.js +2 -0
- package/dist/types/interface/api/requests/metrics.request.d.ts +23 -0
- package/dist/types/interface/api/requests/metrics.request.js +2 -0
- package/dist/types/interface/api/requests/report.admin.request.d.ts +6 -0
- package/dist/types/interface/api/requests/report.admin.request.js +2 -0
- package/dist/types/interface/api/requests/workflow.admin.request.d.ts +35 -0
- package/dist/types/interface/api/requests/workflow.admin.request.js +2 -0
- package/dist/types/interface/api/requests/workflow.request.d.ts +114 -0
- package/dist/types/interface/api/requests/workflow.request.js +2 -0
- package/dist/types/interface/api/responses/application-cron-task.admin.response.d.ts +30 -0
- package/dist/types/interface/api/responses/application-cron-task.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-cron-task.response.d.ts +30 -0
- package/dist/types/interface/api/responses/application-cron-task.response.js +2 -0
- package/dist/types/interface/api/responses/application-event.admin.response.d.ts +9 -0
- package/dist/types/interface/api/responses/application-event.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-event.response.d.ts +33 -0
- package/dist/types/interface/api/responses/application-event.response.js +2 -0
- package/dist/types/interface/api/responses/application-log.admin.response.d.ts +10 -0
- package/dist/types/interface/api/responses/application-log.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-log.response.d.ts +10 -0
- package/dist/types/interface/api/responses/application-log.response.js +2 -0
- package/dist/types/interface/api/responses/application-sentinel.admin.response.d.ts +26 -0
- package/dist/types/interface/api/responses/application-sentinel.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-sentinel.response.d.ts +33 -0
- package/dist/types/interface/api/responses/application-sentinel.response.js +2 -0
- package/dist/types/interface/api/responses/application-stats.admin.response.d.ts +6 -0
- package/dist/types/interface/api/responses/application-stats.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-stats.response.d.ts +10 -0
- package/dist/types/interface/api/responses/application-stats.response.js +2 -0
- package/dist/types/interface/api/responses/application-webhook-history.admin.response.d.ts +7 -0
- package/dist/types/interface/api/responses/application-webhook-history.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-webhook-history.response.d.ts +7 -0
- package/dist/types/interface/api/responses/application-webhook-history.response.js +2 -0
- package/dist/types/interface/api/responses/application-webhook.admin.response.d.ts +21 -0
- package/dist/types/interface/api/responses/application-webhook.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application-webhook.response.d.ts +21 -0
- package/dist/types/interface/api/responses/application-webhook.response.js +2 -0
- package/dist/types/interface/api/responses/application.admin.response.d.ts +34 -0
- package/dist/types/interface/api/responses/application.admin.response.js +2 -0
- package/dist/types/interface/api/responses/application.response.d.ts +130 -0
- package/dist/types/interface/api/responses/application.response.js +2 -0
- package/dist/types/interface/api/responses/domain-verification.admin.response.d.ts +6 -0
- package/dist/types/interface/api/responses/domain-verification.admin.response.js +2 -0
- package/dist/types/interface/api/responses/domain-verification.response.d.ts +29 -0
- package/dist/types/interface/api/responses/domain-verification.response.js +2 -0
- package/dist/types/interface/api/responses/hourly-metrics.response.d.ts +70 -0
- package/dist/types/interface/api/responses/hourly-metrics.response.js +2 -0
- package/dist/types/interface/api/responses/infrastructure.admin.response.d.ts +18 -0
- package/dist/types/interface/api/responses/infrastructure.admin.response.js +2 -0
- package/dist/types/interface/api/responses/metrics.admin.response.d.ts +19 -0
- package/dist/types/interface/api/responses/metrics.admin.response.js +2 -0
- package/dist/types/interface/api/responses/metrics.response.d.ts +29 -0
- package/dist/types/interface/api/responses/metrics.response.js +2 -0
- package/dist/types/interface/api/responses/monitor.response.d.ts +7 -0
- package/dist/types/interface/api/responses/monitor.response.js +2 -0
- package/dist/types/interface/api/responses/report.admin.response.d.ts +87 -0
- package/dist/types/interface/api/responses/report.admin.response.js +2 -0
- package/dist/types/interface/api/responses/workflow.admin.response.d.ts +24 -0
- package/dist/types/interface/api/responses/workflow.admin.response.js +2 -0
- package/dist/types/interface/api/responses/workflow.response.d.ts +54 -0
- package/dist/types/interface/api/responses/workflow.response.js +2 -0
- package/dist/types/interface/api/type-message/api-error.d.ts +8 -0
- package/dist/types/interface/api/type-message/api-error.js +2 -0
- package/dist/types/interface/api/type-message/base-order.d.ts +4 -0
- package/dist/types/interface/api/type-message/base-order.js +2 -0
- package/dist/types/interface/api/type-message/base-paginate.d.ts +10 -0
- package/dist/types/interface/api/type-message/base-paginate.js +2 -0
- package/dist/types/interface/api/type-message/response.d.ts +5 -0
- package/dist/types/interface/api/type-message/response.js +2 -0
- package/dist/types/interface/dto/application-sentinel-configuration.dto.d.ts +68 -0
- package/dist/types/interface/dto/application-sentinel-configuration.dto.js +4 -0
- package/dist/types/interface/dto/index.d.ts +2 -0
- package/dist/types/interface/dto/index.js +18 -0
- package/dist/types/interface/dto/webhook.dto.d.ts +27 -0
- package/dist/types/interface/dto/webhook.dto.js +2 -0
- package/dist/types/interface/index.d.ts +6 -0
- package/dist/types/interface/index.js +22 -0
- package/dist/types/interface/models/application-cron-task-history.model.d.ts +17 -0
- package/dist/types/interface/models/application-cron-task-history.model.js +2 -0
- package/dist/types/interface/models/application-cron-task.model.d.ts +14 -0
- package/dist/types/interface/models/application-cron-task.model.js +2 -0
- package/dist/types/interface/models/application-event.model.d.ts +19 -0
- package/dist/types/interface/models/application-event.model.js +2 -0
- package/dist/types/interface/models/application-hourly-metrics.model.d.ts +14 -0
- package/dist/types/interface/models/application-hourly-metrics.model.js +2 -0
- package/dist/types/interface/models/application-lifetime-metrics.model.d.ts +8 -0
- package/dist/types/interface/models/application-lifetime-metrics.model.js +2 -0
- package/dist/types/interface/models/application-log-endpoint.model.d.ts +20 -0
- package/dist/types/interface/models/application-log-endpoint.model.js +2 -0
- package/dist/types/interface/models/application-log.model.d.ts +23 -0
- package/dist/types/interface/models/application-log.model.js +2 -0
- package/dist/types/interface/models/application-sentinel-history.model.d.ts +16 -0
- package/dist/types/interface/models/application-sentinel-history.model.js +2 -0
- package/dist/types/interface/models/application-sentinel.model.d.ts +20 -0
- package/dist/types/interface/models/application-sentinel.model.js +2 -0
- package/dist/types/interface/models/application-stats.model.d.ts +14 -0
- package/dist/types/interface/models/application-stats.model.js +2 -0
- package/dist/types/interface/models/application-webhook-history.model.d.ts +22 -0
- package/dist/types/interface/models/application-webhook-history.model.js +2 -0
- package/dist/types/interface/models/application-webhook.model.d.ts +32 -0
- package/dist/types/interface/models/application-webhook.model.js +3 -0
- package/dist/types/interface/models/application.model.d.ts +19 -0
- package/dist/types/interface/models/application.model.js +2 -0
- package/dist/types/interface/models/domain-verification.model.d.ts +42 -0
- package/dist/types/interface/models/domain-verification.model.js +14 -0
- package/dist/types/interface/models/partition-optimization-history.model.d.ts +11 -0
- package/dist/types/interface/models/partition-optimization-history.model.js +2 -0
- package/dist/types/interface/models/project.model.d.ts +11 -0
- package/dist/types/interface/models/project.model.js +2 -0
- package/dist/types/interface/models/workflow-execution-step.model.d.ts +59 -0
- package/dist/types/interface/models/workflow-execution-step.model.js +12 -0
- package/dist/types/interface/models/workflow-execution.model.d.ts +76 -0
- package/dist/types/interface/models/workflow-execution.model.js +13 -0
- package/dist/types/interface/models/workflow-step.model.d.ts +106 -0
- package/dist/types/interface/models/workflow-step.model.js +44 -0
- package/dist/types/interface/models/workflow.model.d.ts +90 -0
- package/dist/types/interface/models/workflow.model.js +24 -0
- package/dist/typing-examples.d.ts +1 -0
- package/dist/typing-examples.js +48 -0
- package/dist/utils/alert.utils.d.ts +35 -0
- package/dist/utils/alert.utils.js +138 -0
- package/dist/utils/discord-webhook-log-formatter.utils.d.ts +48 -0
- package/dist/utils/discord-webhook-log-formatter.utils.js +332 -0
- package/dist/utils/error.utils.d.ts +15 -0
- package/dist/utils/error.utils.js +24 -0
- package/dist/utils/import.utils.d.ts +1 -0
- package/dist/utils/import.utils.js +7 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/json.utils.d.ts +1 -0
- package/dist/utils/json.utils.js +13 -0
- package/dist/utils/non-blocking-promise.utils.d.ts +2 -0
- package/dist/utils/non-blocking-promise.utils.js +11 -0
- package/package.json +49 -0
- package/tsconfig.json +105 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Query = exports.Params = exports.Body = exports.Middlewares = exports.Middleware = exports.Controller = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
7
|
+
const types_1 = require("../../types");
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
const joi_to_swagger_1 = __importDefault(require("joi-to-swagger"));
|
|
10
|
+
function Route(options) {
|
|
11
|
+
return function (target, propertyKey, descriptor) {
|
|
12
|
+
Reflect.defineMetadata(_1.ROUTE_WATERMARK, true, target, propertyKey);
|
|
13
|
+
Reflect.defineMetadata(_1.PATH_WATERMARK, options.path, target, propertyKey);
|
|
14
|
+
Reflect.defineMetadata(_1.METHOD_WATERMARK, options.method, target, propertyKey);
|
|
15
|
+
Reflect.defineMetadata(_1.OPTIONS_WATERMARK, options, target, propertyKey);
|
|
16
|
+
if (options.docs) {
|
|
17
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, options.docs, target, propertyKey);
|
|
18
|
+
}
|
|
19
|
+
const originalMethod = descriptor.value;
|
|
20
|
+
descriptor.value = function (...args) {
|
|
21
|
+
args[1].locals.shouldNotPublishLog =
|
|
22
|
+
typeof options === 'string' ? false : options.shouldNotPublishLog;
|
|
23
|
+
return originalMethod.apply(target, args);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function Get(options, docs) {
|
|
28
|
+
return Route({
|
|
29
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
30
|
+
docs,
|
|
31
|
+
method: types_1.APIMethod.GET,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.Get = Get;
|
|
35
|
+
function Post(options, docs) {
|
|
36
|
+
return Route({
|
|
37
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
38
|
+
docs,
|
|
39
|
+
method: types_1.APIMethod.POST,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.Post = Post;
|
|
43
|
+
function Put(options, docs) {
|
|
44
|
+
return Route({
|
|
45
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
46
|
+
docs,
|
|
47
|
+
method: types_1.APIMethod.PUT,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.Put = Put;
|
|
51
|
+
function Delete(options, docs) {
|
|
52
|
+
return Route({
|
|
53
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
54
|
+
docs,
|
|
55
|
+
method: types_1.APIMethod.DELETE,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.Delete = Delete;
|
|
59
|
+
function Patch(options, docs) {
|
|
60
|
+
return Route({
|
|
61
|
+
...(typeof options === 'string' ? { path: options } : options),
|
|
62
|
+
docs,
|
|
63
|
+
method: types_1.APIMethod.PATCH,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.Patch = Patch;
|
|
67
|
+
function Controller(options) {
|
|
68
|
+
const defaultPath = '/';
|
|
69
|
+
return function (target) {
|
|
70
|
+
var _a;
|
|
71
|
+
Reflect.defineMetadata(_1.CONTROLLER_WATERMARK, true, target);
|
|
72
|
+
Reflect.defineMetadata(_1.MASKED_WATERMARK, (typeof options === 'string' ? false : options.isMasked) || false, target);
|
|
73
|
+
Reflect.defineMetadata(_1.PATH_WATERMARK, (typeof options === 'string' ? options : options.prefixPath) || defaultPath, target);
|
|
74
|
+
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
75
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, (typeof options === 'string'
|
|
76
|
+
? existingMiddlewares
|
|
77
|
+
: [
|
|
78
|
+
...existingMiddlewares,
|
|
79
|
+
...(((_a = options.middlewares) === null || _a === void 0 ? void 0 : _a.map((middleware) => middleware.name)) || []),
|
|
80
|
+
]) || existingMiddlewares, target);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.Controller = Controller;
|
|
84
|
+
function Middleware() {
|
|
85
|
+
return function (target) {
|
|
86
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_WATERMARK, true, target);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.Middleware = Middleware;
|
|
90
|
+
function Middlewares(middlewares) {
|
|
91
|
+
return function (target, propertyKey) {
|
|
92
|
+
const existingMiddlewares = Reflect.getMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, target) || [];
|
|
93
|
+
Reflect.defineMetadata(_1.MIDDLEWARE_HOOK_WATERMARK, [...existingMiddlewares, ...((middlewares === null || middlewares === void 0 ? void 0 : middlewares.map((middleware) => middleware.name)) || [])] ||
|
|
94
|
+
existingMiddlewares, target, propertyKey);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
exports.Middlewares = Middlewares;
|
|
98
|
+
function Body(schema, options) {
|
|
99
|
+
return function (target, propertyKey, descriptor) {
|
|
100
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
101
|
+
if (!existingDocs.body) {
|
|
102
|
+
existingDocs.body = {};
|
|
103
|
+
}
|
|
104
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
105
|
+
existingDocs.body.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
106
|
+
}
|
|
107
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
108
|
+
const originalMethod = descriptor.value;
|
|
109
|
+
descriptor.value = function (...args) {
|
|
110
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].body);
|
|
111
|
+
if (result.error) {
|
|
112
|
+
throw result.error;
|
|
113
|
+
}
|
|
114
|
+
args[0].body = result.value;
|
|
115
|
+
return originalMethod.apply(target, args);
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.Body = Body;
|
|
120
|
+
function Params(schema, options) {
|
|
121
|
+
return function (target, propertyKey, descriptor) {
|
|
122
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
123
|
+
if (!existingDocs.params) {
|
|
124
|
+
existingDocs.params = {};
|
|
125
|
+
}
|
|
126
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
127
|
+
existingDocs.params.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
128
|
+
}
|
|
129
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
130
|
+
const originalMethod = descriptor.value;
|
|
131
|
+
descriptor.value = function (...args) {
|
|
132
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].params);
|
|
133
|
+
if (result.error) {
|
|
134
|
+
throw result.error;
|
|
135
|
+
}
|
|
136
|
+
args[0].params = result.value;
|
|
137
|
+
return originalMethod.apply(target, args);
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.Params = Params;
|
|
142
|
+
function Query(schema, options) {
|
|
143
|
+
return function (target, propertyKey, descriptor) {
|
|
144
|
+
const existingDocs = Reflect.getMetadata(_1.DOCS_WATERMARK, target, propertyKey) || {};
|
|
145
|
+
if (!existingDocs.query) {
|
|
146
|
+
existingDocs.query = {};
|
|
147
|
+
}
|
|
148
|
+
if (!(options === null || options === void 0 ? void 0 : options.shouldNotGenerateSwagger)) {
|
|
149
|
+
existingDocs.query.content = (0, joi_to_swagger_1.default)(schema).swagger;
|
|
150
|
+
}
|
|
151
|
+
Reflect.defineMetadata(_1.DOCS_WATERMARK, existingDocs, target, propertyKey);
|
|
152
|
+
const originalMethod = descriptor.value;
|
|
153
|
+
descriptor.value = function (...args) {
|
|
154
|
+
const result = schema.options({ presence: 'required' }).validate(args[0].query);
|
|
155
|
+
if (result.error) {
|
|
156
|
+
throw result.error;
|
|
157
|
+
}
|
|
158
|
+
args[0].query = result.value;
|
|
159
|
+
return originalMethod.apply(target, args);
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
exports.Query = Query;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './decorators';
|
|
2
|
+
export * from './metadata';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import express, { Router } from 'express-serve-static-core';
|
|
5
|
+
type Options = {
|
|
6
|
+
prefix: string;
|
|
7
|
+
middlewares: any[];
|
|
8
|
+
controllers: any[];
|
|
9
|
+
router: (option: any) => Router;
|
|
10
|
+
disableTrustProxy?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const controllerLoader: (app: express.Application, options: Options) => Promise<{
|
|
13
|
+
swagger: {
|
|
14
|
+
tags: string[];
|
|
15
|
+
paths: Record<string, any>;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.controllerLoader = void 0;
|
|
18
|
+
__exportStar(require("./decorators"), exports);
|
|
19
|
+
__exportStar(require("./metadata"), exports);
|
|
20
|
+
const metadata_1 = require("./metadata");
|
|
21
|
+
require("reflect-metadata");
|
|
22
|
+
const types_1 = require("../../types");
|
|
23
|
+
const controllerLoader = async (app, options) => {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
try {
|
|
26
|
+
if (options.disableTrustProxy !== true) {
|
|
27
|
+
app.set('trust proxy', true);
|
|
28
|
+
}
|
|
29
|
+
const middlewares = options.middlewares.map((middleware) => new middleware());
|
|
30
|
+
const controllers = options.controllers;
|
|
31
|
+
const tags = [];
|
|
32
|
+
const paths = {};
|
|
33
|
+
const mainRouter = options.router({ mergeParams: true });
|
|
34
|
+
for (const controller of controllers) {
|
|
35
|
+
const instance = new controller();
|
|
36
|
+
const isMasked = Reflect.getMetadata(metadata_1.MASKED_WATERMARK, controller);
|
|
37
|
+
const middlewareHooks = Reflect.getMetadata(metadata_1.MIDDLEWARE_HOOK_WATERMARK, controller) || [];
|
|
38
|
+
const controllerPrefix = Reflect.getMetadata(metadata_1.PATH_WATERMARK, controller);
|
|
39
|
+
const tag = controller.name;
|
|
40
|
+
if (!isMasked) {
|
|
41
|
+
tags.push(tag);
|
|
42
|
+
}
|
|
43
|
+
const router = options.router({ mergeParams: true });
|
|
44
|
+
const middlewaresToUseOnController = middlewareHooks.map((element) => {
|
|
45
|
+
const middleware = middlewares.find((middleware) => {
|
|
46
|
+
return middleware.constructor.name === element;
|
|
47
|
+
});
|
|
48
|
+
if (!middleware) {
|
|
49
|
+
console.error(`Middleware ${element} on controller ${controller} do not exist`);
|
|
50
|
+
}
|
|
51
|
+
return middleware;
|
|
52
|
+
});
|
|
53
|
+
for (const method of Object.getOwnPropertyNames(controller.prototype)) {
|
|
54
|
+
if (!isRoute(instance, method)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const routeOptions = Reflect.getMetadata(metadata_1.OPTIONS_WATERMARK, instance, method);
|
|
58
|
+
const path = Reflect.getMetadata(metadata_1.PATH_WATERMARK, instance, method);
|
|
59
|
+
const docs = Reflect.getMetadata(metadata_1.DOCS_WATERMARK, instance, method) || {};
|
|
60
|
+
const apiMethod = Reflect.getMetadata(metadata_1.METHOD_WATERMARK, instance, method);
|
|
61
|
+
const routeMiddlewareHooks = Reflect.getMetadata(metadata_1.MIDDLEWARE_HOOK_WATERMARK, instance, method) || [];
|
|
62
|
+
const fullPath = `${routeOptions.shouldSkipController ? '' : controllerPrefix}${path}`;
|
|
63
|
+
if (!paths[fullPath]) {
|
|
64
|
+
paths[fullPath] = {};
|
|
65
|
+
}
|
|
66
|
+
if (!docs.isMasked && !isMasked) {
|
|
67
|
+
paths[fullPath][types_1.APIMethod[apiMethod].toLowerCase()] = {
|
|
68
|
+
tags: [tag],
|
|
69
|
+
description: docs.description || '',
|
|
70
|
+
requestBody: {
|
|
71
|
+
description: (_a = docs.body) === null || _a === void 0 ? void 0 : _a.description,
|
|
72
|
+
content: {
|
|
73
|
+
'application/json': {
|
|
74
|
+
schema: (_b = docs === null || docs === void 0 ? void 0 : docs.body) === null || _b === void 0 ? void 0 : _b.content,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
parameters: [
|
|
79
|
+
...Object.entries(((_c = docs.params) === null || _c === void 0 ? void 0 : _c.content.properties) || {}).map(([key, entry]) => {
|
|
80
|
+
return {
|
|
81
|
+
name: key,
|
|
82
|
+
in: 'path',
|
|
83
|
+
description: entry.description || '',
|
|
84
|
+
required: true,
|
|
85
|
+
schema: entry,
|
|
86
|
+
};
|
|
87
|
+
}),
|
|
88
|
+
...Object.entries(((_d = docs.query) === null || _d === void 0 ? void 0 : _d.content.properties) || {}).map(([key, entry]) => {
|
|
89
|
+
return {
|
|
90
|
+
name: key,
|
|
91
|
+
in: 'query',
|
|
92
|
+
description: entry.description || '',
|
|
93
|
+
required: true,
|
|
94
|
+
schema: entry,
|
|
95
|
+
};
|
|
96
|
+
}),
|
|
97
|
+
],
|
|
98
|
+
responses: {},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const middlewaresToUseOnRoute = routeMiddlewareHooks.map((element) => {
|
|
102
|
+
const middleware = middlewares.find((middleware) => middleware.constructor.name === element);
|
|
103
|
+
if (!middleware) {
|
|
104
|
+
console.error(`Middleware ${element} on controller ${controller} on route ${path} do not exist`);
|
|
105
|
+
}
|
|
106
|
+
return middleware;
|
|
107
|
+
});
|
|
108
|
+
const routerToUse = routeOptions.shouldSkipController ? mainRouter : router;
|
|
109
|
+
switch (apiMethod) {
|
|
110
|
+
case types_1.APIMethod.DELETE:
|
|
111
|
+
routerToUse.delete(path, ...(routeOptions.shouldSkipController
|
|
112
|
+
? []
|
|
113
|
+
: middlewaresToUseOnController.map((middleware) => middleware.run)), setLocalsMiddleware(controller, options, fullPath, null), ...middlewaresToUseOnRoute.map((middleware) => middleware.run), instance[method]);
|
|
114
|
+
break;
|
|
115
|
+
case types_1.APIMethod.GET:
|
|
116
|
+
routerToUse.get(path, ...(routeOptions.shouldSkipController
|
|
117
|
+
? []
|
|
118
|
+
: middlewaresToUseOnController.map((middleware) => middleware.run)), setLocalsMiddleware(controller, options, fullPath, null), ...middlewaresToUseOnRoute.map((middleware) => middleware.run), instance[method]);
|
|
119
|
+
break;
|
|
120
|
+
case types_1.APIMethod.POST:
|
|
121
|
+
routerToUse.post(path, ...(routeOptions.shouldSkipController
|
|
122
|
+
? []
|
|
123
|
+
: middlewaresToUseOnController.map((middleware) => middleware.run)), setLocalsMiddleware(controller, options, fullPath, null), ...middlewaresToUseOnRoute.map((middleware) => middleware.run), instance[method]);
|
|
124
|
+
break;
|
|
125
|
+
case types_1.APIMethod.PUT:
|
|
126
|
+
routerToUse.put(path, ...(routeOptions.shouldSkipController
|
|
127
|
+
? []
|
|
128
|
+
: middlewaresToUseOnController.map((middleware) => middleware.run)), setLocalsMiddleware(controller, options, fullPath, null), ...middlewaresToUseOnRoute.map((middleware) => middleware.run), instance[method]);
|
|
129
|
+
break;
|
|
130
|
+
case types_1.APIMethod.PATCH:
|
|
131
|
+
routerToUse.patch(path, ...(routeOptions.shouldSkipController
|
|
132
|
+
? []
|
|
133
|
+
: middlewaresToUseOnController.map((middleware) => middleware.run)), setLocalsMiddleware(controller, options, fullPath, null), ...middlewaresToUseOnRoute.map((middleware) => middleware.run), instance[method]);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
console.error(`Method ${apiMethod} on route ${path} of controller ${controller} do not exist`);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
mainRouter.use(`${controllerPrefix}`, setLocalsMiddleware(controller, options, controllerPrefix), router);
|
|
141
|
+
}
|
|
142
|
+
app.use(options.prefix, mainRouter);
|
|
143
|
+
return {
|
|
144
|
+
swagger: {
|
|
145
|
+
tags,
|
|
146
|
+
paths,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.error(error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
exports.controllerLoader = controllerLoader;
|
|
156
|
+
const isRoute = (target, propertyKey) => {
|
|
157
|
+
try {
|
|
158
|
+
if (Reflect.getMetadata(metadata_1.ROUTE_WATERMARK, target, propertyKey)) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const setLocalsMiddleware = (controller, options = { prefix: '/' }, controllerPrefix, path) => (req, res, next) => {
|
|
170
|
+
res.locals.controller = controller.name;
|
|
171
|
+
res.locals.path = `${options.prefix}${controllerPrefix}${path !== null ? path || req.path : ''}`;
|
|
172
|
+
next();
|
|
173
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CONTROLLER_WATERMARK = "__controller__";
|
|
2
|
+
export declare const MASKED_WATERMARK = "__masked__";
|
|
3
|
+
export declare const PATH_WATERMARK = "__path__";
|
|
4
|
+
export declare const METHOD_WATERMARK = "__method__";
|
|
5
|
+
export declare const OPTIONS_WATERMARK = "__OPTIONS__";
|
|
6
|
+
export declare const ROUTE_WATERMARK = "__route__";
|
|
7
|
+
export declare const DOCS_WATERMARK = "__docs__";
|
|
8
|
+
export declare const MIDDLEWARE_WATERMARK = "__middleware__";
|
|
9
|
+
export declare const MIDDLEWARE_HOOK_WATERMARK = "__middleware_hook__";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MIDDLEWARE_HOOK_WATERMARK = exports.MIDDLEWARE_WATERMARK = exports.DOCS_WATERMARK = exports.ROUTE_WATERMARK = exports.OPTIONS_WATERMARK = exports.METHOD_WATERMARK = exports.PATH_WATERMARK = exports.MASKED_WATERMARK = exports.CONTROLLER_WATERMARK = void 0;
|
|
4
|
+
exports.CONTROLLER_WATERMARK = '__controller__';
|
|
5
|
+
exports.MASKED_WATERMARK = '__masked__';
|
|
6
|
+
exports.PATH_WATERMARK = '__path__';
|
|
7
|
+
exports.METHOD_WATERMARK = '__method__';
|
|
8
|
+
exports.OPTIONS_WATERMARK = '__OPTIONS__';
|
|
9
|
+
exports.ROUTE_WATERMARK = '__route__';
|
|
10
|
+
exports.DOCS_WATERMARK = '__docs__';
|
|
11
|
+
exports.MIDDLEWARE_WATERMARK = '__middleware__';
|
|
12
|
+
exports.MIDDLEWARE_HOOK_WATERMARK = '__middleware_hook__';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './express';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./express"), exports);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { IAxiosRetryConfig } from 'axios-retry';
|
|
2
|
+
import * as workflowApi from './api/workflow.api';
|
|
3
|
+
import * as workflowAdminApi from './api/workflow.admin.api';
|
|
4
|
+
import * as domainVerificationApi from './api/domain-verification.api';
|
|
5
|
+
import * as domainVerificationAdminApi from './api/domain-verification.admin.api';
|
|
6
|
+
import * as monitorApi from './api/monitor.api';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export declare const API_KEY_APPLICATION_HEADER = "abyss-console-api-key-application";
|
|
10
|
+
export declare const ADMIN_TOKEN_HEADER = "abyss-admin-token";
|
|
11
|
+
export declare const HEADER_WEBHOOK_SIGNATURE_NAME = "abyss-console-webhook-signature";
|
|
12
|
+
export declare const WEBHOOK_SIGNATURE_ALGORITHM = "sha256";
|
|
13
|
+
type CoreConfig<TAdmin extends boolean = false> = {
|
|
14
|
+
token?: string;
|
|
15
|
+
applicationApiKey?: string;
|
|
16
|
+
applicationId?: string;
|
|
17
|
+
adminToken?: string;
|
|
18
|
+
baseURL?: string;
|
|
19
|
+
admin?: TAdmin;
|
|
20
|
+
};
|
|
21
|
+
type WorkflowAdminSDK = {
|
|
22
|
+
paginate: typeof workflowAdminApi.paginateWorkflowAdmin;
|
|
23
|
+
get: typeof workflowAdminApi.getWorkflowAdmin;
|
|
24
|
+
updateStatus: typeof workflowAdminApi.updateStatusWorkflowAdmin;
|
|
25
|
+
delete: typeof workflowAdminApi.deleteWorkflowAdmin;
|
|
26
|
+
trigger: typeof workflowAdminApi.triggerWorkflowAdmin;
|
|
27
|
+
execution: {
|
|
28
|
+
paginate: typeof workflowAdminApi.paginateWorkflowExecutionAdmin;
|
|
29
|
+
cancel: typeof workflowAdminApi.cancelWorkflowExecutionAdmin;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
type DomainVerificationAdminSDK = {
|
|
33
|
+
runCron: typeof domainVerificationAdminApi.runCron;
|
|
34
|
+
};
|
|
35
|
+
type AbyssConsoleCoreSDK<TAdmin extends boolean = false> = {
|
|
36
|
+
workflow: {
|
|
37
|
+
create: typeof workflowApi.createWorkflow;
|
|
38
|
+
paginate: typeof workflowApi.paginateWorkflow;
|
|
39
|
+
get: typeof workflowApi.getWorkflow;
|
|
40
|
+
update: typeof workflowApi.updateWorkflow;
|
|
41
|
+
updateStatus: typeof workflowApi.updateStatusWorkflow;
|
|
42
|
+
delete: typeof workflowApi.deleteWorkflow;
|
|
43
|
+
step: {
|
|
44
|
+
create: typeof workflowApi.createWorkflowStep;
|
|
45
|
+
list: typeof workflowApi.listWorkflowSteps;
|
|
46
|
+
update: typeof workflowApi.updateWorkflowStep;
|
|
47
|
+
delete: typeof workflowApi.deleteWorkflowStep;
|
|
48
|
+
};
|
|
49
|
+
execution: {
|
|
50
|
+
paginate: typeof workflowApi.paginateWorkflowExecution;
|
|
51
|
+
get: typeof workflowApi.getWorkflowExecution;
|
|
52
|
+
stats: typeof workflowApi.getStatsWorkflowExecution;
|
|
53
|
+
cancel: typeof workflowApi.cancelWorkflowExecution;
|
|
54
|
+
};
|
|
55
|
+
} & (TAdmin extends true ? {
|
|
56
|
+
admin: WorkflowAdminSDK;
|
|
57
|
+
} : {});
|
|
58
|
+
domainVerification: {
|
|
59
|
+
create: typeof domainVerificationApi.createDomainVerification;
|
|
60
|
+
list: typeof domainVerificationApi.listDomainVerification;
|
|
61
|
+
get: typeof domainVerificationApi.getDomainVerification;
|
|
62
|
+
verify: typeof domainVerificationApi.verifyDomainVerification;
|
|
63
|
+
regenerate: typeof domainVerificationApi.regenerateDomainVerification;
|
|
64
|
+
delete: typeof domainVerificationApi.deleteDomainVerification;
|
|
65
|
+
} & (TAdmin extends true ? {
|
|
66
|
+
admin: DomainVerificationAdminSDK;
|
|
67
|
+
} : {});
|
|
68
|
+
monitor: {
|
|
69
|
+
up: typeof monitorApi.upMonitor;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare class AbyssConsoleCore {
|
|
73
|
+
private static config;
|
|
74
|
+
static axios: import("axios").AxiosInstance;
|
|
75
|
+
private static _sdk;
|
|
76
|
+
static get sdk(): AbyssConsoleCoreSDK<false> | AbyssConsoleCoreSDK<true>;
|
|
77
|
+
private static buildSDK;
|
|
78
|
+
static setConfig<TAdmin extends boolean = false>(config: CoreConfig<TAdmin>): void;
|
|
79
|
+
static getConfig(): CoreConfig & {
|
|
80
|
+
admin: boolean;
|
|
81
|
+
};
|
|
82
|
+
static enableAxiosRetry(axiosRetryConfig?: IAxiosRetryConfig): void;
|
|
83
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
var _a;
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.AbyssConsoleCore = exports.WEBHOOK_SIGNATURE_ALGORITHM = exports.HEADER_WEBHOOK_SIGNATURE_NAME = exports.ADMIN_TOKEN_HEADER = exports.API_KEY_APPLICATION_HEADER = void 0;
|
|
34
|
+
const axios_1 = __importDefault(require("axios"));
|
|
35
|
+
const axios_retry_1 = __importStar(require("axios-retry"));
|
|
36
|
+
const workflowApi = __importStar(require("./api/workflow.api"));
|
|
37
|
+
const workflowAdminApi = __importStar(require("./api/workflow.admin.api"));
|
|
38
|
+
const domainVerificationApi = __importStar(require("./api/domain-verification.api"));
|
|
39
|
+
const domainVerificationAdminApi = __importStar(require("./api/domain-verification.admin.api"));
|
|
40
|
+
const monitorApi = __importStar(require("./api/monitor.api"));
|
|
41
|
+
__exportStar(require("./types"), exports);
|
|
42
|
+
__exportStar(require("./utils"), exports);
|
|
43
|
+
const MONITOR_DEFAULT_BASE_URL = 'https://console-api.abyss-project.fr/api/';
|
|
44
|
+
exports.API_KEY_APPLICATION_HEADER = 'abyss-console-api-key-application';
|
|
45
|
+
exports.ADMIN_TOKEN_HEADER = 'abyss-admin-token';
|
|
46
|
+
exports.HEADER_WEBHOOK_SIGNATURE_NAME = 'abyss-console-webhook-signature';
|
|
47
|
+
exports.WEBHOOK_SIGNATURE_ALGORITHM = 'sha256';
|
|
48
|
+
const NUMBER_RETRY_API = 10;
|
|
49
|
+
const BASE_DELAY_BETWEEN_RETRY = 5000;
|
|
50
|
+
const RETRY_CODES = [
|
|
51
|
+
502,
|
|
52
|
+
503,
|
|
53
|
+
];
|
|
54
|
+
class AbyssConsoleCore {
|
|
55
|
+
static get sdk() {
|
|
56
|
+
if (!_a._sdk) {
|
|
57
|
+
_a._sdk = _a.buildSDK();
|
|
58
|
+
}
|
|
59
|
+
return _a._sdk;
|
|
60
|
+
}
|
|
61
|
+
static buildSDK() {
|
|
62
|
+
const workflowSDK = {
|
|
63
|
+
create: workflowApi.createWorkflow,
|
|
64
|
+
paginate: workflowApi.paginateWorkflow,
|
|
65
|
+
get: workflowApi.getWorkflow,
|
|
66
|
+
update: workflowApi.updateWorkflow,
|
|
67
|
+
updateStatus: workflowApi.updateStatusWorkflow,
|
|
68
|
+
delete: workflowApi.deleteWorkflow,
|
|
69
|
+
step: {
|
|
70
|
+
create: workflowApi.createWorkflowStep,
|
|
71
|
+
list: workflowApi.listWorkflowSteps,
|
|
72
|
+
update: workflowApi.updateWorkflowStep,
|
|
73
|
+
delete: workflowApi.deleteWorkflowStep,
|
|
74
|
+
},
|
|
75
|
+
execution: {
|
|
76
|
+
paginate: workflowApi.paginateWorkflowExecution,
|
|
77
|
+
get: workflowApi.getWorkflowExecution,
|
|
78
|
+
stats: workflowApi.getStatsWorkflowExecution,
|
|
79
|
+
cancel: workflowApi.cancelWorkflowExecution,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
if (_a.config.admin) {
|
|
83
|
+
workflowSDK.admin = {
|
|
84
|
+
paginate: workflowAdminApi.paginateWorkflowAdmin,
|
|
85
|
+
get: workflowAdminApi.getWorkflowAdmin,
|
|
86
|
+
updateStatus: workflowAdminApi.updateStatusWorkflowAdmin,
|
|
87
|
+
delete: workflowAdminApi.deleteWorkflowAdmin,
|
|
88
|
+
trigger: workflowAdminApi.triggerWorkflowAdmin,
|
|
89
|
+
execution: {
|
|
90
|
+
paginate: workflowAdminApi.paginateWorkflowExecutionAdmin,
|
|
91
|
+
cancel: workflowAdminApi.cancelWorkflowExecutionAdmin,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const domainVerificationSDK = {
|
|
96
|
+
create: domainVerificationApi.createDomainVerification,
|
|
97
|
+
list: domainVerificationApi.listDomainVerification,
|
|
98
|
+
get: domainVerificationApi.getDomainVerification,
|
|
99
|
+
verify: domainVerificationApi.verifyDomainVerification,
|
|
100
|
+
regenerate: domainVerificationApi.regenerateDomainVerification,
|
|
101
|
+
delete: domainVerificationApi.deleteDomainVerification,
|
|
102
|
+
};
|
|
103
|
+
if (_a.config.admin) {
|
|
104
|
+
domainVerificationSDK.admin = {
|
|
105
|
+
runCron: domainVerificationAdminApi.runCron,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const baseSDK = {
|
|
109
|
+
workflow: workflowSDK,
|
|
110
|
+
domainVerification: domainVerificationSDK,
|
|
111
|
+
monitor: {
|
|
112
|
+
up: monitorApi.upMonitor,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
return baseSDK;
|
|
116
|
+
}
|
|
117
|
+
static setConfig(config) {
|
|
118
|
+
_a.config = { ..._a.config, ...config, admin: config.admin || false };
|
|
119
|
+
_a._sdk = null;
|
|
120
|
+
if (config.baseURL) {
|
|
121
|
+
_a.axios.defaults.baseURL = config.baseURL;
|
|
122
|
+
}
|
|
123
|
+
if (config.token) {
|
|
124
|
+
_a.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
|
|
125
|
+
}
|
|
126
|
+
if (config.adminToken) {
|
|
127
|
+
_a.axios.defaults.headers.common[exports.ADMIN_TOKEN_HEADER] = `${config.adminToken}`;
|
|
128
|
+
}
|
|
129
|
+
if (config.applicationApiKey) {
|
|
130
|
+
_a.axios.defaults.headers.common[exports.API_KEY_APPLICATION_HEADER] = `${config.applicationApiKey}`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
static getConfig() {
|
|
134
|
+
return _a.config;
|
|
135
|
+
}
|
|
136
|
+
static enableAxiosRetry(axiosRetryConfig) {
|
|
137
|
+
(0, axios_retry_1.default)(_a.axios, {
|
|
138
|
+
retries: NUMBER_RETRY_API,
|
|
139
|
+
retryDelay: (retryCount) => retryCount * BASE_DELAY_BETWEEN_RETRY,
|
|
140
|
+
retryCondition: (error) => {
|
|
141
|
+
var _b;
|
|
142
|
+
return (0, axios_retry_1.isNetworkOrIdempotentRequestError)(error) ||
|
|
143
|
+
RETRY_CODES.includes(((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 502);
|
|
144
|
+
},
|
|
145
|
+
...axiosRetryConfig,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.AbyssConsoleCore = AbyssConsoleCore;
|
|
150
|
+
_a = AbyssConsoleCore;
|
|
151
|
+
AbyssConsoleCore.config = {
|
|
152
|
+
token: '',
|
|
153
|
+
applicationApiKey: '',
|
|
154
|
+
applicationId: '',
|
|
155
|
+
adminToken: '',
|
|
156
|
+
baseURL: MONITOR_DEFAULT_BASE_URL,
|
|
157
|
+
admin: false,
|
|
158
|
+
};
|
|
159
|
+
AbyssConsoleCore.axios = axios_1.default.create({
|
|
160
|
+
baseURL: _a.config.baseURL,
|
|
161
|
+
withCredentials: true,
|
|
162
|
+
});
|
|
163
|
+
AbyssConsoleCore._sdk = null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express-serve-static-core';
|
|
2
|
+
type StoreEntry = {
|
|
3
|
+
requestId: string;
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export declare const contextMiddleware: (req: Request, res: Response<any, any>, next: NextFunction) => void;
|
|
7
|
+
export declare const createRequestContext: (data: Record<string, unknown>, requestId?: string) => {
|
|
8
|
+
requestId: string;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export declare const getRequestContext: () => StoreEntry;
|
|
12
|
+
export {};
|