@flowerforce/flowerbase 1.0.1-beta.3
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/CHANGELOG.md +0 -0
- package/LICENSE +3 -0
- package/README.md +18 -0
- package/dist/auth/controller.d.ts +8 -0
- package/dist/auth/controller.d.ts.map +1 -0
- package/dist/auth/controller.js +76 -0
- package/dist/auth/dtos.d.ts +6 -0
- package/dist/auth/dtos.d.ts.map +1 -0
- package/dist/auth/dtos.js +2 -0
- package/dist/auth/plugins/jwt.d.ts +14 -0
- package/dist/auth/plugins/jwt.d.ts.map +1 -0
- package/dist/auth/plugins/jwt.js +68 -0
- package/dist/auth/providers/local-userpass/controller.d.ts +8 -0
- package/dist/auth/providers/local-userpass/controller.d.ts.map +1 -0
- package/dist/auth/providers/local-userpass/controller.js +184 -0
- package/dist/auth/providers/local-userpass/dtos.d.ts +35 -0
- package/dist/auth/providers/local-userpass/dtos.d.ts.map +1 -0
- package/dist/auth/providers/local-userpass/dtos.js +2 -0
- package/dist/auth/utils.d.ts +126 -0
- package/dist/auth/utils.d.ts.map +1 -0
- package/dist/auth/utils.js +122 -0
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +34 -0
- package/dist/features/endpoints/index.d.ts +10 -0
- package/dist/features/endpoints/index.d.ts.map +1 -0
- package/dist/features/endpoints/index.js +31 -0
- package/dist/features/endpoints/interface.d.ts +27 -0
- package/dist/features/endpoints/interface.d.ts.map +1 -0
- package/dist/features/endpoints/interface.js +2 -0
- package/dist/features/endpoints/utils.d.ts +31 -0
- package/dist/features/endpoints/utils.d.ts.map +1 -0
- package/dist/features/endpoints/utils.js +85 -0
- package/dist/features/functions/controller.d.ts +9 -0
- package/dist/features/functions/controller.d.ts.map +1 -0
- package/dist/features/functions/controller.js +88 -0
- package/dist/features/functions/dtos.d.ts +34 -0
- package/dist/features/functions/dtos.d.ts.map +1 -0
- package/dist/features/functions/dtos.js +2 -0
- package/dist/features/functions/index.d.ts +9 -0
- package/dist/features/functions/index.d.ts.map +1 -0
- package/dist/features/functions/index.js +28 -0
- package/dist/features/functions/interface.d.ts +32 -0
- package/dist/features/functions/interface.d.ts.map +1 -0
- package/dist/features/functions/interface.js +2 -0
- package/dist/features/functions/utils.d.ts +23 -0
- package/dist/features/functions/utils.d.ts.map +1 -0
- package/dist/features/functions/utils.js +75 -0
- package/dist/features/rules/index.d.ts +1 -0
- package/dist/features/rules/index.d.ts.map +1 -0
- package/dist/features/rules/index.js +1 -0
- package/dist/features/rules/interface.d.ts +22 -0
- package/dist/features/rules/interface.d.ts.map +1 -0
- package/dist/features/rules/interface.js +2 -0
- package/dist/features/rules/utils.d.ts +3 -0
- package/dist/features/rules/utils.d.ts.map +1 -0
- package/dist/features/rules/utils.js +31 -0
- package/dist/features/triggers/dtos.d.ts +9 -0
- package/dist/features/triggers/dtos.d.ts.map +1 -0
- package/dist/features/triggers/dtos.js +2 -0
- package/dist/features/triggers/index.d.ts +10 -0
- package/dist/features/triggers/index.d.ts.map +1 -0
- package/dist/features/triggers/index.js +57 -0
- package/dist/features/triggers/interface.d.ts +44 -0
- package/dist/features/triggers/interface.d.ts.map +1 -0
- package/dist/features/triggers/interface.js +2 -0
- package/dist/features/triggers/utils.d.ts +16 -0
- package/dist/features/triggers/utils.d.ts.map +1 -0
- package/dist/features/triggers/utils.js +153 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +2 -0
- package/dist/services/api/index.d.ts +36 -0
- package/dist/services/api/index.d.ts.map +1 -0
- package/dist/services/api/index.js +36 -0
- package/dist/services/api/model.d.ts +33 -0
- package/dist/services/api/model.d.ts.map +1 -0
- package/dist/services/api/model.js +2 -0
- package/dist/services/api/utils.d.ts +16 -0
- package/dist/services/api/utils.d.ts.map +1 -0
- package/dist/services/api/utils.js +45 -0
- package/dist/services/aws/index.d.ts +13 -0
- package/dist/services/aws/index.d.ts.map +1 -0
- package/dist/services/aws/index.js +50 -0
- package/dist/services/index.d.ts +41 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +14 -0
- package/dist/services/interface.d.ts +3 -0
- package/dist/services/interface.d.ts.map +1 -0
- package/dist/services/interface.js +2 -0
- package/dist/services/mongodb-atlas/index.d.ts +4 -0
- package/dist/services/mongodb-atlas/index.d.ts.map +1 -0
- package/dist/services/mongodb-atlas/index.js +483 -0
- package/dist/services/mongodb-atlas/model.d.ts +39 -0
- package/dist/services/mongodb-atlas/model.d.ts.map +1 -0
- package/dist/services/mongodb-atlas/model.js +2 -0
- package/dist/services/mongodb-atlas/utils.d.ts +8 -0
- package/dist/services/mongodb-atlas/utils.d.ts.map +1 -0
- package/dist/services/mongodb-atlas/utils.js +33 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +18 -0
- package/dist/utils/context/helpers.d.ts +74 -0
- package/dist/utils/context/helpers.d.ts.map +1 -0
- package/dist/utils/context/helpers.js +60 -0
- package/dist/utils/context/index.d.ts +14 -0
- package/dist/utils/context/index.d.ts.map +1 -0
- package/dist/utils/context/index.js +50 -0
- package/dist/utils/context/interface.d.ts +18 -0
- package/dist/utils/context/interface.d.ts.map +1 -0
- package/dist/utils/context/interface.js +2 -0
- package/dist/utils/crypto/index.d.ts +19 -0
- package/dist/utils/crypto/index.d.ts.map +1 -0
- package/dist/utils/crypto/index.js +50 -0
- package/dist/utils/helpers/someAsync.d.ts +12 -0
- package/dist/utils/helpers/someAsync.d.ts.map +1 -0
- package/dist/utils/helpers/someAsync.js +56 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/initializer/exposeRoutes.d.ts +8 -0
- package/dist/utils/initializer/exposeRoutes.d.ts.map +1 -0
- package/dist/utils/initializer/exposeRoutes.js +41 -0
- package/dist/utils/initializer/registerPlugins.d.ts +19 -0
- package/dist/utils/initializer/registerPlugins.d.ts.map +1 -0
- package/dist/utils/initializer/registerPlugins.js +84 -0
- package/dist/utils/roles/helpers.d.ts +4 -0
- package/dist/utils/roles/helpers.d.ts.map +1 -0
- package/dist/utils/roles/helpers.js +47 -0
- package/dist/utils/roles/interface.d.ts +33 -0
- package/dist/utils/roles/interface.d.ts.map +1 -0
- package/dist/utils/roles/interface.js +2 -0
- package/dist/utils/roles/machines/commonValidators.d.ts +6 -0
- package/dist/utils/roles/machines/commonValidators.d.ts.map +1 -0
- package/dist/utils/roles/machines/commonValidators.js +34 -0
- package/dist/utils/roles/machines/index.d.ts +14 -0
- package/dist/utils/roles/machines/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/index.js +27 -0
- package/dist/utils/roles/machines/interface.d.ts +46 -0
- package/dist/utils/roles/machines/interface.d.ts.map +1 -0
- package/dist/utils/roles/machines/interface.js +2 -0
- package/dist/utils/roles/machines/machine.d.ts +15 -0
- package/dist/utils/roles/machines/machine.d.ts.map +1 -0
- package/dist/utils/roles/machines/machine.js +97 -0
- package/dist/utils/roles/machines/read/A/index.d.ts +3 -0
- package/dist/utils/roles/machines/read/A/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/A/index.js +27 -0
- package/dist/utils/roles/machines/read/B/index.d.ts +3 -0
- package/dist/utils/roles/machines/read/B/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/B/index.js +36 -0
- package/dist/utils/roles/machines/read/C/index.d.ts +3 -0
- package/dist/utils/roles/machines/read/C/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/C/index.js +38 -0
- package/dist/utils/roles/machines/read/D/index.d.ts +3 -0
- package/dist/utils/roles/machines/read/D/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/D/index.js +26 -0
- package/dist/utils/roles/machines/read/D/validators.d.ts +4 -0
- package/dist/utils/roles/machines/read/D/validators.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/D/validators.js +24 -0
- package/dist/utils/roles/machines/read/index.d.ts +2 -0
- package/dist/utils/roles/machines/read/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/read/index.js +8 -0
- package/dist/utils/roles/machines/utils.d.ts +37 -0
- package/dist/utils/roles/machines/utils.d.ts.map +1 -0
- package/dist/utils/roles/machines/utils.js +54 -0
- package/dist/utils/roles/machines/write/A/index.d.ts +3 -0
- package/dist/utils/roles/machines/write/A/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/write/A/index.js +29 -0
- package/dist/utils/roles/machines/write/B/index.d.ts +3 -0
- package/dist/utils/roles/machines/write/B/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/write/B/index.js +47 -0
- package/dist/utils/roles/machines/write/C/index.d.ts +3 -0
- package/dist/utils/roles/machines/write/C/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/write/C/index.js +26 -0
- package/dist/utils/roles/machines/write/C/validators.d.ts +4 -0
- package/dist/utils/roles/machines/write/C/validators.d.ts.map +1 -0
- package/dist/utils/roles/machines/write/C/validators.js +24 -0
- package/dist/utils/roles/machines/write/index.d.ts +2 -0
- package/dist/utils/roles/machines/write/index.d.ts.map +1 -0
- package/dist/utils/roles/machines/write/index.js +7 -0
- package/dist/utils/rules-matcher/interface.d.ts +338 -0
- package/dist/utils/rules-matcher/interface.d.ts.map +1 -0
- package/dist/utils/rules-matcher/interface.js +26 -0
- package/dist/utils/rules-matcher/utils.d.ts +11 -0
- package/dist/utils/rules-matcher/utils.d.ts.map +1 -0
- package/dist/utils/rules-matcher/utils.js +214 -0
- package/dist/utils/rules.d.ts +2 -0
- package/dist/utils/rules.d.ts.map +1 -0
- package/dist/utils/rules.js +22 -0
- package/jest.config.ts +24 -0
- package/package.json +63 -0
- package/project.json +10 -0
- package/rollup.config.js +17 -0
- package/src/auth/controller.ts +78 -0
- package/src/auth/dtos.ts +6 -0
- package/src/auth/plugins/jwt.ts +68 -0
- package/src/auth/providers/local-userpass/controller.ts +226 -0
- package/src/auth/providers/local-userpass/dtos.ts +40 -0
- package/src/auth/utils.ts +165 -0
- package/src/babel.config.json +3 -0
- package/src/constants.ts +22 -0
- package/src/fastify.d.ts +28 -0
- package/src/features/endpoints/index.ts +27 -0
- package/src/features/endpoints/interface.ts +29 -0
- package/src/features/endpoints/utils.ts +72 -0
- package/src/features/functions/controller.ts +102 -0
- package/src/features/functions/dtos.ts +41 -0
- package/src/features/functions/index.ts +21 -0
- package/src/features/functions/interface.ts +38 -0
- package/src/features/functions/utils.ts +82 -0
- package/src/features/rules/index.tsx +0 -0
- package/src/features/rules/interface.ts +24 -0
- package/src/features/rules/utils.ts +20 -0
- package/src/features/triggers/dtos.ts +9 -0
- package/src/features/triggers/index.ts +34 -0
- package/src/features/triggers/interface.ts +44 -0
- package/src/features/triggers/utils.ts +157 -0
- package/src/global.d.ts +0 -0
- package/src/index.ts +75 -0
- package/src/model.ts +1 -0
- package/src/services/api/index.ts +50 -0
- package/src/services/api/model.ts +38 -0
- package/src/services/api/utils.ts +39 -0
- package/src/services/aws/index.ts +48 -0
- package/src/services/index.ts +9 -0
- package/src/services/interface.ts +3 -0
- package/src/services/mongodb-atlas/index.ts +569 -0
- package/src/services/mongodb-atlas/model.ts +67 -0
- package/src/services/mongodb-atlas/utils.ts +44 -0
- package/src/state.ts +24 -0
- package/src/utils/__tests__/STEP_A_STATES.test.ts +54 -0
- package/src/utils/__tests__/STEP_B_STATES.test.ts +113 -0
- package/src/utils/__tests__/STEP_C_STATES.test.ts +87 -0
- package/src/utils/__tests__/STEP_D_STATES.test.ts +93 -0
- package/src/utils/__tests__/checkAdditionalFieldsFn.test.ts +45 -0
- package/src/utils/__tests__/checkApplyWhen.test.ts +49 -0
- package/src/utils/__tests__/checkFieldsPropertyExists.test.ts +47 -0
- package/src/utils/__tests__/checkIsValidFieldNameFn.test.ts +190 -0
- package/src/utils/__tests__/comparePassword.test.ts +38 -0
- package/src/utils/__tests__/evaluateDocumentsFiltersReadFn.test.ts +57 -0
- package/src/utils/__tests__/evaluateDocumentsFiltersWriteFn.test.ts +57 -0
- package/src/utils/__tests__/evaluateTopLevelReadFn.test.ts +58 -0
- package/src/utils/__tests__/evaluateTopLevelWriteFn.test.ts +66 -0
- package/src/utils/__tests__/exposeRoutes.test.ts +65 -0
- package/src/utils/__tests__/generateContextData.test.ts +75 -0
- package/src/utils/__tests__/getDefaultRule.test.ts +29 -0
- package/src/utils/__tests__/getKey.test.ts +12 -0
- package/src/utils/__tests__/getKeys.test.ts +11 -0
- package/src/utils/__tests__/getWinningRole.test.ts +66 -0
- package/src/utils/__tests__/hashPassword.test.ts +28 -0
- package/src/utils/__tests__/isEmpty.test.ts +17 -0
- package/src/utils/__tests__/logMachineInfo.test.ts +15 -0
- package/src/utils/__tests__/operators.test.ts +99 -0
- package/src/utils/__tests__/readFileContent.test.ts +35 -0
- package/src/utils/__tests__/registerPlugins.test.ts +59 -0
- package/src/utils/__tests__/rule.test.ts +51 -0
- package/src/utils/__tests__/rulesMatcherInterfaces.test.ts +57 -0
- package/src/utils/__tests__/rulesMatcherUtils.test.ts +56 -0
- package/src/utils/__tests__/someAsync.test.ts +55 -0
- package/src/utils/context/helpers.ts +71 -0
- package/src/utils/context/index.ts +52 -0
- package/src/utils/context/interface.ts +19 -0
- package/src/utils/crypto/index.ts +36 -0
- package/src/utils/helpers/someAsync.ts +24 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/initializer/exposeRoutes.ts +26 -0
- package/src/utils/initializer/registerPlugins.ts +97 -0
- package/src/utils/roles/helpers.ts +47 -0
- package/src/utils/roles/interface.ts +42 -0
- package/src/utils/roles/machines/commonValidators.ts +24 -0
- package/src/utils/roles/machines/index.ts +20 -0
- package/src/utils/roles/machines/interface.ts +46 -0
- package/src/utils/roles/machines/machine.ts +85 -0
- package/src/utils/roles/machines/read/A/index.ts +19 -0
- package/src/utils/roles/machines/read/B/index.ts +31 -0
- package/src/utils/roles/machines/read/C/index.ts +30 -0
- package/src/utils/roles/machines/read/D/index.ts +20 -0
- package/src/utils/roles/machines/read/D/validators.ts +24 -0
- package/src/utils/roles/machines/read/index.ts +6 -0
- package/src/utils/roles/machines/utils.ts +54 -0
- package/src/utils/roles/machines/write/A/index.ts +25 -0
- package/src/utils/roles/machines/write/B/index.ts +43 -0
- package/src/utils/roles/machines/write/C/index.ts +20 -0
- package/src/utils/roles/machines/write/C/validators.ts +24 -0
- package/src/utils/roles/machines/write/index.ts +5 -0
- package/src/utils/rules-matcher/interface.ts +365 -0
- package/src/utils/rules-matcher/utils.ts +281 -0
- package/src/utils/rules.ts +19 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
/**
|
|
15
|
+
* > This service is the Api Client that can be imported from the context
|
|
16
|
+
*/
|
|
17
|
+
const Api = () => ({
|
|
18
|
+
get: (_a) => __awaiter(void 0, [_a], void 0, function* ({ url, headers = {} }) {
|
|
19
|
+
return (0, utils_1.makeRequest)({ method: 'GET', url, headers });
|
|
20
|
+
}),
|
|
21
|
+
post: (_a) => __awaiter(void 0, [_a], void 0, function* ({ scheme = constants_1.HTTPS_SCHEMA, host, path, url: currentUrl, headers = {}, body, encodeBodyAsJSON = false }) {
|
|
22
|
+
const formattedBody = encodeBodyAsJSON ? JSON.stringify(body) : body;
|
|
23
|
+
const url = currentUrl ? currentUrl : `${scheme}://${host}/${path}`;
|
|
24
|
+
return (0, utils_1.makeRequest)({ method: 'POST', url, headers: Object.assign({ "Content-Type": "application/json" }, headers), body: formattedBody });
|
|
25
|
+
}),
|
|
26
|
+
put: (_a) => __awaiter(void 0, [_a], void 0, function* ({ scheme = constants_1.HTTPS_SCHEMA, host, path, url: currentUrl, headers = {}, body, encodeBodyAsJSON = false }) {
|
|
27
|
+
const formattedBody = encodeBodyAsJSON ? JSON.stringify(body) : body;
|
|
28
|
+
const url = currentUrl ? currentUrl : `${scheme}://${host}/${path}`;
|
|
29
|
+
return (0, utils_1.makeRequest)({ method: 'PUT', url, headers, body: formattedBody });
|
|
30
|
+
}),
|
|
31
|
+
delete: (_a) => __awaiter(void 0, [_a], void 0, function* ({ scheme = constants_1.HTTPS_SCHEMA, host, path, url: currentUrl, headers = {} }) {
|
|
32
|
+
const url = currentUrl ? currentUrl : `${scheme}://${host}/${path}`;
|
|
33
|
+
return (0, utils_1.makeRequest)({ method: 'DELETE', url, headers });
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
exports.default = Api;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Dispatcher } from 'undici';
|
|
2
|
+
type RequestOptions = Dispatcher.RequestOptions;
|
|
3
|
+
type HTTP_METHODS = RequestOptions['method'];
|
|
4
|
+
type Headers = RequestOptions['headers'];
|
|
5
|
+
type Body = RequestOptions['body'];
|
|
6
|
+
export interface MakeRequestParams {
|
|
7
|
+
method: HTTP_METHODS;
|
|
8
|
+
url: string;
|
|
9
|
+
headers: Headers;
|
|
10
|
+
body?: Body;
|
|
11
|
+
}
|
|
12
|
+
export interface GetParams {
|
|
13
|
+
url: string;
|
|
14
|
+
headers: Headers;
|
|
15
|
+
}
|
|
16
|
+
export interface PostParams {
|
|
17
|
+
scheme?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
host: string;
|
|
20
|
+
path: string;
|
|
21
|
+
encodeBodyAsJSON?: boolean;
|
|
22
|
+
body: Body;
|
|
23
|
+
headers?: Headers;
|
|
24
|
+
}
|
|
25
|
+
export type PutParams = PostParams;
|
|
26
|
+
export type DeleteParams = Omit<PostParams, 'body' | 'encodeBodyAsJSON'>;
|
|
27
|
+
export interface Error {
|
|
28
|
+
message: string;
|
|
29
|
+
statusCode: Dispatcher.ResponseData['statusCode'];
|
|
30
|
+
headers?: Dispatcher.ResponseData['headers'];
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/services/api/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,KAAK,cAAc,GAAG,UAAU,CAAC,cAAc,CAAA;AAC/C,KAAK,YAAY,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAA;AAC5C,KAAK,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAA;AACxC,KAAK,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;AAElC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAA;AAElC,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAAC,CAAA;AAExE,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IACjD,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;CAC7C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MakeRequestParams } from './model';
|
|
2
|
+
/**
|
|
3
|
+
* > Creates the http request
|
|
4
|
+
* @param method -> the HTTP METHOD
|
|
5
|
+
* @param url -> url string
|
|
6
|
+
* @param headers -> request headers
|
|
7
|
+
* @param body -> request body
|
|
8
|
+
*/
|
|
9
|
+
export declare const makeRequest: <T = null>({ method, url, headers, body }: MakeRequestParams) => Promise<import("undici").Dispatcher.ResponseData<T> | {
|
|
10
|
+
status: number;
|
|
11
|
+
headers: import("undici/types/header").IncomingHttpHeaders;
|
|
12
|
+
body: {
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/api/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,GAAG,IAAI,EAAE,gCAKzC,iBAAiB;;;;;;EAWnB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makeRequest = void 0;
|
|
13
|
+
const undici_1 = require("undici");
|
|
14
|
+
/**
|
|
15
|
+
* > Creates the http request
|
|
16
|
+
* @param method -> the HTTP METHOD
|
|
17
|
+
* @param url -> url string
|
|
18
|
+
* @param headers -> request headers
|
|
19
|
+
* @param body -> request body
|
|
20
|
+
*/
|
|
21
|
+
const makeRequest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ method, url, headers, body }) {
|
|
22
|
+
try {
|
|
23
|
+
const response = yield (0, undici_1.request)(url, {
|
|
24
|
+
method,
|
|
25
|
+
headers,
|
|
26
|
+
body
|
|
27
|
+
});
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return _handleError(error);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.makeRequest = makeRequest;
|
|
35
|
+
/**
|
|
36
|
+
* > Formats the request error
|
|
37
|
+
* @param error -> the request error
|
|
38
|
+
*/
|
|
39
|
+
const _handleError = (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
return {
|
|
41
|
+
status: error.statusCode || 500,
|
|
42
|
+
headers: error.headers || {},
|
|
43
|
+
body: { message: error.message }
|
|
44
|
+
};
|
|
45
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AWSError } from 'aws-sdk';
|
|
2
|
+
import Lambda from 'aws-sdk/clients/lambda';
|
|
3
|
+
import S3 from 'aws-sdk/clients/s3';
|
|
4
|
+
import { PromiseResult } from 'aws-sdk/lib/request';
|
|
5
|
+
declare const Aws: () => {
|
|
6
|
+
lambda: (region: string) => Lambda & {
|
|
7
|
+
Invoke: (...args: Parameters<Lambda["invoke"]>) => Promise<PromiseResult<Lambda.InvocationResponse, AWSError>>;
|
|
8
|
+
InvokeAsync: Lambda["invokeAsync"];
|
|
9
|
+
};
|
|
10
|
+
s3: (region: string) => S3;
|
|
11
|
+
};
|
|
12
|
+
export default Aws;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAC3C,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAMnD,QAAA,MAAM,GAAG;qBAEY,MAAM;gBAQX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;qBACjG,MAAM,CAAC,aAAa,CAAC;;iBAczB,MAAM;CAWtB,CAAA;AAED,eAAe,GAAG,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const lambda_1 = __importDefault(require("aws-sdk/clients/lambda"));
|
|
16
|
+
const s3_1 = __importDefault(require("aws-sdk/clients/s3"));
|
|
17
|
+
const accessKeyId = "GET_THIS_FROM_CONFIG";
|
|
18
|
+
const secretAccessKey = "GET_THIS_FROM_CONFIG";
|
|
19
|
+
const Aws = () => {
|
|
20
|
+
return {
|
|
21
|
+
lambda: (region) => {
|
|
22
|
+
const lambda = new lambda_1.default({
|
|
23
|
+
region: region,
|
|
24
|
+
credentials: {
|
|
25
|
+
accessKeyId,
|
|
26
|
+
secretAccessKey,
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
lambda.Invoke = (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const res = yield lambda.invoke(...args).promise();
|
|
31
|
+
return Object.assign(Object.assign({}, res), { Payload: {
|
|
32
|
+
text: () => res.Payload
|
|
33
|
+
} });
|
|
34
|
+
});
|
|
35
|
+
lambda.InvokeAsync = lambda.invokeAsync;
|
|
36
|
+
return lambda;
|
|
37
|
+
},
|
|
38
|
+
s3: (region) => new s3_1.default({
|
|
39
|
+
region,
|
|
40
|
+
apiVersion: '2006-03-01',
|
|
41
|
+
credentials: {
|
|
42
|
+
accessKeyId,
|
|
43
|
+
secretAccessKey,
|
|
44
|
+
},
|
|
45
|
+
s3ForcePathStyle: true,
|
|
46
|
+
signatureVersion: 'v4',
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.default = Aws;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const services: {
|
|
2
|
+
api: () => {
|
|
3
|
+
get: <T = null>({ url, headers }: import("./api/model").GetParams) => Promise<{
|
|
4
|
+
status: number;
|
|
5
|
+
headers: import("undici/types/header").IncomingHttpHeaders;
|
|
6
|
+
body: {
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
} | import("undici").Dispatcher.ResponseData<T>>;
|
|
10
|
+
post: <T = null>({ scheme, host, path, url: currentUrl, headers, body, encodeBodyAsJSON }: import("./api/model").PostParams) => Promise<{
|
|
11
|
+
status: number;
|
|
12
|
+
headers: import("undici/types/header").IncomingHttpHeaders;
|
|
13
|
+
body: {
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
} | import("undici").Dispatcher.ResponseData<T>>;
|
|
17
|
+
put: <T = null>({ scheme, host, path, url: currentUrl, headers, body, encodeBodyAsJSON }: import("./api/model").PutParams) => Promise<{
|
|
18
|
+
status: number;
|
|
19
|
+
headers: import("undici/types/header").IncomingHttpHeaders;
|
|
20
|
+
body: {
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
} | import("undici").Dispatcher.ResponseData<T>>;
|
|
24
|
+
delete: <T = null>({ scheme, host, path, url: currentUrl, headers }: import("./api/model").DeleteParams) => Promise<{
|
|
25
|
+
status: number;
|
|
26
|
+
headers: import("undici/types/header").IncomingHttpHeaders;
|
|
27
|
+
body: {
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
} | import("undici").Dispatcher.ResponseData<T>>;
|
|
31
|
+
};
|
|
32
|
+
aws: () => {
|
|
33
|
+
lambda: (region: string) => import("aws-sdk").Lambda & {
|
|
34
|
+
Invoke: (...args: Parameters<import("aws-sdk").Lambda["invoke"]>) => Promise<import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/lambda").InvocationResponse, import("aws-sdk").AWSError>>;
|
|
35
|
+
InvokeAsync: import("aws-sdk").Lambda["invokeAsync"];
|
|
36
|
+
};
|
|
37
|
+
s3: (region: string) => import("aws-sdk").S3;
|
|
38
|
+
};
|
|
39
|
+
'mongodb-atlas': import("./mongodb-atlas/model").MongodbAtlasFunction;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAKqT,GAAG;;;;;;CAD5U,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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.services = void 0;
|
|
7
|
+
const api_1 = __importDefault(require("./api"));
|
|
8
|
+
const aws_1 = __importDefault(require("./aws"));
|
|
9
|
+
const mongodb_atlas_1 = __importDefault(require("./mongodb-atlas"));
|
|
10
|
+
exports.services = {
|
|
11
|
+
api: api_1.default,
|
|
12
|
+
aws: aws_1.default,
|
|
13
|
+
'mongodb-atlas': mongodb_atlas_1.default
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/services/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;AAE5B,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwB,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAmiBpE,QAAA,MAAM,YAAY,EAAE,oBAclB,CAAA;AAEF,eAAe,YAAY,CAAA"}
|