@flowerforce/flowerbase 1.0.2 → 1.0.3-beta.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/dist/auth/controller.js +3 -3
- package/dist/auth/providers/local-userpass/controller.d.ts.map +1 -1
- package/dist/auth/providers/local-userpass/controller.js +48 -4
- package/dist/auth/utils.d.ts +1 -0
- package/dist/auth/utils.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -2
- package/dist/features/endpoints/index.d.ts +1 -1
- package/dist/features/endpoints/index.d.ts.map +1 -1
- package/dist/features/endpoints/index.js +3 -3
- package/dist/features/endpoints/interface.d.ts +4 -0
- package/dist/features/endpoints/interface.d.ts.map +1 -1
- package/dist/features/endpoints/utils.d.ts +1 -1
- package/dist/features/endpoints/utils.d.ts.map +1 -1
- package/dist/features/endpoints/utils.js +18 -10
- package/dist/features/functions/utils.d.ts +3 -2
- package/dist/features/functions/utils.d.ts.map +1 -1
- package/dist/features/functions/utils.js +5 -2
- package/dist/features/rules/interface.d.ts +42 -0
- package/dist/features/rules/interface.d.ts.map +1 -1
- package/dist/features/rules/interface.js +7 -0
- package/dist/features/rules/utils.js +41 -0
- package/dist/features/triggers/utils.d.ts.map +1 -1
- package/dist/features/triggers/utils.js +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -1
- package/dist/services/mongodb-atlas/index.d.ts.map +1 -1
- package/dist/services/mongodb-atlas/index.js +45 -2
- package/dist/services/mongodb-atlas/model.d.ts +7 -1
- package/dist/services/mongodb-atlas/model.d.ts.map +1 -1
- package/dist/services/mongodb-atlas/model.js +8 -0
- package/dist/services/mongodb-atlas/utils.d.ts +9 -2
- package/dist/services/mongodb-atlas/utils.d.ts.map +1 -1
- package/dist/services/mongodb-atlas/utils.js +104 -1
- package/dist/utils/rules.d.ts.map +1 -1
- package/dist/utils/rules.js +6 -1
- package/package.json +3 -1
- package/src/auth/controller.ts +3 -3
- package/src/auth/providers/local-userpass/controller.ts +54 -4
- package/src/auth/utils.ts +1 -0
- package/src/constants.ts +4 -2
- package/src/features/endpoints/index.ts +4 -3
- package/src/features/endpoints/interface.ts +4 -0
- package/src/features/endpoints/utils.ts +28 -11
- package/src/features/functions/utils.ts +7 -3
- package/src/features/rules/interface.ts +35 -1
- package/src/features/rules/utils.ts +46 -0
- package/src/features/triggers/utils.ts +9 -4
- package/src/index.ts +20 -1
- package/src/services/mongodb-atlas/index.ts +60 -5
- package/src/services/mongodb-atlas/model.ts +10 -1
- package/src/services/mongodb-atlas/utils.ts +129 -2
- package/src/utils/rules.ts +8 -3
package/dist/auth/controller.js
CHANGED
|
@@ -65,9 +65,9 @@ function authController(app) {
|
|
|
65
65
|
if (!auth_user) {
|
|
66
66
|
throw new Error(`User with ID ${req.user.sub} not found`);
|
|
67
67
|
}
|
|
68
|
-
const user =
|
|
69
|
-
.collection(userCollection)
|
|
70
|
-
|
|
68
|
+
const user = userCollection && constants_1.AUTH_CONFIG.user_id_field
|
|
69
|
+
? (yield db.collection(userCollection).findOne({ [constants_1.AUTH_CONFIG.user_id_field]: req.user.sub }))
|
|
70
|
+
: {};
|
|
71
71
|
res.status(201);
|
|
72
72
|
return {
|
|
73
73
|
access_token: this.createAccessToken(Object.assign(Object.assign({}, auth_user), { user_data: user }))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/local-userpass/controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/local-userpass/controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAuBzC;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,eAAe,iBA8PjE"}
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.localUserPassController = localUserPassController;
|
|
16
16
|
const mail_1 = __importDefault(require("@sendgrid/mail"));
|
|
17
17
|
const constants_1 = require("../../../constants");
|
|
18
|
+
const services_1 = require("../../../services");
|
|
18
19
|
const state_1 = require("../../../state");
|
|
19
20
|
const context_1 = require("../../../utils/context");
|
|
20
21
|
const crypto_1 = require("../../../utils/crypto");
|
|
@@ -26,7 +27,8 @@ const utils_1 = require("../../utils");
|
|
|
26
27
|
*/
|
|
27
28
|
function localUserPassController(app) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const
|
|
30
|
+
const functionsList = state_1.StateManager.select('functions');
|
|
31
|
+
const { authCollection, userCollection, user_id_field, on_user_creation_function_name } = constants_1.AUTH_CONFIG;
|
|
30
32
|
const db = app.mongo.client.db(constants_1.DB_NAME);
|
|
31
33
|
/**
|
|
32
34
|
* Endpoint for user registration.
|
|
@@ -54,8 +56,9 @@ function localUserPassController(app) {
|
|
|
54
56
|
const result = yield db.collection(authCollection).insertOne({
|
|
55
57
|
email: email,
|
|
56
58
|
password: hashedPassword,
|
|
59
|
+
status: 'pending',
|
|
57
60
|
custom_data: {
|
|
58
|
-
//
|
|
61
|
+
// TODO da aggiungere in fase di registrazione utente, funzionalità utile che realm non permetteva
|
|
59
62
|
}
|
|
60
63
|
});
|
|
61
64
|
yield (db === null || db === void 0 ? void 0 : db.collection(authCollection).updateOne({
|
|
@@ -99,9 +102,50 @@ function localUserPassController(app) {
|
|
|
99
102
|
if (!passwordMatches) {
|
|
100
103
|
throw new Error(utils_1.AUTH_ERRORS.INVALID_CREDENTIALS);
|
|
101
104
|
}
|
|
105
|
+
const user = user_id_field && userCollection
|
|
106
|
+
? (yield db.collection(userCollection).findOne({ [user_id_field]: storedUser._id.toString() }))
|
|
107
|
+
: {};
|
|
108
|
+
const userWithCustomData = Object.assign(Object.assign({}, storedUser), { user_data: user });
|
|
109
|
+
if (storedUser && storedUser.status === 'pending') {
|
|
110
|
+
try {
|
|
111
|
+
yield (db === null || db === void 0 ? void 0 : db.collection(authCollection).updateOne({ _id: storedUser._id }, {
|
|
112
|
+
$set: {
|
|
113
|
+
status: 'confirmed'
|
|
114
|
+
}
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.log(">>> 🚀 ~ localUserPassController ~ error:", error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (storedUser && storedUser.status === 'pending' && on_user_creation_function_name && functionsList[on_user_creation_function_name]) {
|
|
122
|
+
storedUser === null || storedUser === void 0 ? true : delete storedUser.password;
|
|
123
|
+
try {
|
|
124
|
+
yield (0, context_1.GenerateContext)({
|
|
125
|
+
args: [{
|
|
126
|
+
operationType: 'CREATE',
|
|
127
|
+
providers: 'local-userpass',
|
|
128
|
+
user,
|
|
129
|
+
time: new Date().getTime()
|
|
130
|
+
}],
|
|
131
|
+
app,
|
|
132
|
+
rules: {},
|
|
133
|
+
user: undefined,
|
|
134
|
+
currentFunction: functionsList[on_user_creation_function_name],
|
|
135
|
+
functionsList,
|
|
136
|
+
services: services_1.services
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.log("🚀 ~ error:", error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.error('Error function on_user_creation_function_name: ', on_user_creation_function_name);
|
|
145
|
+
}
|
|
102
146
|
return {
|
|
103
|
-
access_token: this.createAccessToken(
|
|
104
|
-
refresh_token: this.createRefreshToken(
|
|
147
|
+
access_token: this.createAccessToken(userWithCustomData),
|
|
148
|
+
refresh_token: this.createRefreshToken(userWithCustomData),
|
|
105
149
|
device_id: '',
|
|
106
150
|
user_id: storedUser._id.toString()
|
|
107
151
|
};
|
package/dist/auth/utils.d.ts
CHANGED
package/dist/auth/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
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,OAAO,CAAA;IAChC,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,8BAA8B,EAAE,MAAM,CAAA;CACvC;AAED,eAAO,MAAM,aAAa,mBAAmB,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,cAAc,QAAO,UAGjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,oBAGrC,CAAA;AAED,eAAO,MAAM,aAAa,GACxB,qBAAqB,MAAM,EAC3B,OAAO,MAAM,EACb,SAAS,MAAM;;;;;CA4ChB,CAAA"}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc;;;;;;;;CAQ1B,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AACpC,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -13,7 +13,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.AUTH_CONFIG = exports.DB_NAME = exports.HTTPS_SCHEMA = exports.API_VERSION = exports.DEFAULT_CONFIG = void 0;
|
|
15
15
|
const utils_1 = require("./auth/utils");
|
|
16
|
-
const { database_name, collection_name = 'users', user_id_field = 'id' } = (0, utils_1.loadCustomUserData)();
|
|
16
|
+
const { database_name, collection_name = 'users', user_id_field = 'id', on_user_creation_function_name } = (0, utils_1.loadCustomUserData)();
|
|
17
17
|
const _a = (0, utils_1.loadAuthConfig)(), { auth_collection = 'auth_users' } = _a, configuration = __rest(_a, ["auth_collection"]);
|
|
18
18
|
exports.DEFAULT_CONFIG = {
|
|
19
19
|
PORT: Number(process.env.PORT) || 3000,
|
|
@@ -32,5 +32,6 @@ exports.AUTH_CONFIG = {
|
|
|
32
32
|
userCollection: collection_name,
|
|
33
33
|
resetPasswordCollection: 'reset-password-requests',
|
|
34
34
|
resetPasswordConfig: configuration['local-userpass'].config,
|
|
35
|
-
user_id_field
|
|
35
|
+
user_id_field,
|
|
36
|
+
on_user_creation_function_name
|
|
36
37
|
};
|
|
@@ -6,5 +6,5 @@ import { GenerateEndpointsParams } from './interface';
|
|
|
6
6
|
* @param functionsList -> the list of all functions
|
|
7
7
|
* @param endpointsList -> the list of all endpoints
|
|
8
8
|
*/
|
|
9
|
-
export declare const generateEndpoints: ({ app, functionsList, endpointsList }: GenerateEndpointsParams) => Promise<void>;
|
|
9
|
+
export declare const generateEndpoints: ({ app, functionsList, endpointsList, rulesList }: GenerateEndpointsParams) => Promise<void>;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,kDAKrC,uBAAuB,kBAYzB,CAAA"}
|
|
@@ -18,13 +18,13 @@ const utils_1 = require("./utils");
|
|
|
18
18
|
* @param functionsList -> the list of all functions
|
|
19
19
|
* @param endpointsList -> the list of all endpoints
|
|
20
20
|
*/
|
|
21
|
-
const generateEndpoints = (_a) => __awaiter(void 0, [_a], void 0, function* ({ app, functionsList, endpointsList }) {
|
|
21
|
+
const generateEndpoints = (_a) => __awaiter(void 0, [_a], void 0, function* ({ app, functionsList, endpointsList, rulesList }) {
|
|
22
22
|
endpointsList.forEach(({ http_method, route, disabled, function_name }) => {
|
|
23
23
|
const currentFunction = functionsList[function_name];
|
|
24
24
|
if (disabled || !currentFunction)
|
|
25
25
|
return;
|
|
26
|
-
const handler = (0, utils_1.generateHandler)({ app, currentFunction, functionsList });
|
|
27
|
-
const currentMethod = (0, utils_1.getMethodsConfig)(app, handler, `/app/:appId/endpoint/${route}`)[http_method];
|
|
26
|
+
const handler = (0, utils_1.generateHandler)({ app, rulesList, currentFunction, functionsList, http_method });
|
|
27
|
+
const currentMethod = (0, utils_1.getMethodsConfig)(app, handler, `/app/:appId/endpoint/${route.replace(/^\//, "")}`)[http_method];
|
|
28
28
|
currentMethod();
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { FastifyInstance } from 'fastify';
|
|
2
2
|
import { Function, Functions } from '../functions/interface';
|
|
3
|
+
import { Rules } from '../rules/interface';
|
|
3
4
|
export type GenerateEndpointsParams = {
|
|
4
5
|
app: FastifyInstance;
|
|
5
6
|
functionsList: Functions;
|
|
6
7
|
endpointsList: Endpoints;
|
|
8
|
+
rulesList: Rules;
|
|
7
9
|
};
|
|
8
10
|
export type GenerateHandlerParams = {
|
|
9
11
|
app: FastifyInstance;
|
|
10
12
|
currentFunction: Function;
|
|
11
13
|
functionsList: Functions;
|
|
14
|
+
http_method: string;
|
|
15
|
+
rulesList: Rules;
|
|
12
16
|
};
|
|
13
17
|
type HTTP_METHOD<T> = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | T;
|
|
14
18
|
export type Endpoint<T = 'ALL'> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,eAAe,CAAA;IACpB,aAAa,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;IACxB,SAAS,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,eAAe,CAAA;IACpB,eAAe,EAAE,QAAQ,CAAA;IACzB,aAAa,EAAE,SAAS,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,CAAC,CAAA;AAErE,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,KAAK,IAAI;IAChC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,iBAAiB,EAAE,MAAM,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,mBAAmB,EAAE,OAAO,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AACD,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -27,5 +27,5 @@ export declare const getMethodsConfig: (app: FastifyInstance, handler: ReturnTyp
|
|
|
27
27
|
* @param currentFunction -> the name of the function that should be called for that endpoint
|
|
28
28
|
* @param functionsList -> the list of all functions
|
|
29
29
|
*/
|
|
30
|
-
export declare const generateHandler: ({ app, currentFunction, functionsList }: GenerateHandlerParams) => (req: FastifyRequest, res: FastifyReply) => Promise<{}>;
|
|
30
|
+
export declare const generateHandler: ({ app, currentFunction, functionsList, rulesList }: GenerateHandlerParams) => (req: FastifyRequest, res: FastifyReply) => Promise<{}>;
|
|
31
31
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/endpoints/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAKvE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAmB9E,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,KAAK,eAAe,EACpB,SAAS,UAAU,CAAC,OAAO,eAAe,CAAC,EAC3C,UAAU,MAAM;;;;;;;CAQhB,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,oDAK7B,qBAAqB,MACR,KAAK,cAAc,EAAE,KAAK,YAAY,gBAuBrD,CAAA"}
|
|
@@ -33,13 +33,20 @@ const context_1 = require("../../utils/context");
|
|
|
33
33
|
* @testable
|
|
34
34
|
*/
|
|
35
35
|
const loadEndpoints = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (rootDir = process.cwd()) {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const endpoints = [];
|
|
37
|
+
const folders = ['https_endpoints', 'http_endpoints'];
|
|
38
|
+
folders.forEach((endpointsDir) => {
|
|
39
|
+
const endPointsFile = node_path_1.default.join(rootDir, endpointsDir, 'config.json');
|
|
40
|
+
if (fs_1.default.existsSync(endPointsFile)) {
|
|
41
|
+
const config = JSON.parse(fs_1.default.readFileSync(endPointsFile, 'utf-8'));
|
|
42
|
+
const configRemap = config.map((_a) => {
|
|
43
|
+
var { http_method } = _a, endpoint = __rest(_a, ["http_method"]);
|
|
44
|
+
return (Object.assign({ http_method: http_method === '*' ? 'ALL' : http_method }, endpoint));
|
|
45
|
+
});
|
|
46
|
+
endpoints.push(...configRemap);
|
|
47
|
+
}
|
|
42
48
|
});
|
|
49
|
+
return endpoints;
|
|
43
50
|
});
|
|
44
51
|
exports.loadEndpoints = loadEndpoints;
|
|
45
52
|
/**
|
|
@@ -65,19 +72,20 @@ exports.getMethodsConfig = getMethodsConfig;
|
|
|
65
72
|
* @param currentFunction -> the name of the function that should be called for that endpoint
|
|
66
73
|
* @param functionsList -> the list of all functions
|
|
67
74
|
*/
|
|
68
|
-
const generateHandler = ({ app, currentFunction, functionsList }) => {
|
|
75
|
+
const generateHandler = ({ app, currentFunction, functionsList, rulesList }) => {
|
|
69
76
|
return (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
77
|
try {
|
|
78
|
+
// TODO gestire tramite http_method le args da passare
|
|
71
79
|
const response = yield (0, context_1.GenerateContext)({
|
|
72
|
-
args: [
|
|
80
|
+
args: [], // TODO passare solo body e query ???
|
|
73
81
|
app,
|
|
74
|
-
rules:
|
|
82
|
+
rules: rulesList,
|
|
75
83
|
user: req.user,
|
|
76
84
|
currentFunction,
|
|
77
85
|
functionsList,
|
|
78
86
|
services: services_1.services
|
|
79
87
|
});
|
|
80
|
-
res.send(response);
|
|
88
|
+
return res.send(response);
|
|
81
89
|
}
|
|
82
90
|
catch (e) {
|
|
83
91
|
console.log(e);
|
|
@@ -15,9 +15,10 @@ export declare const executeQuery: ({ currentMethod, query, update, document, do
|
|
|
15
15
|
findOne: () => Promise<unknown>;
|
|
16
16
|
deleteOne: () => Promise<unknown>;
|
|
17
17
|
insertOne: () => Promise<import("mongodb/mongodb").InsertOneResult<import("bson").Document>>;
|
|
18
|
-
updateOne: () => Promise<unknown> | import("mongodb/mongodb").FindCursor<any> | import("mongodb/mongodb").ChangeStream<import("bson").Document, import("bson").Document
|
|
19
|
-
aggregate: () =>
|
|
18
|
+
updateOne: () => Promise<unknown> | import("mongodb/mongodb").FindCursor<any> | import("mongodb/mongodb").ChangeStream<import("bson").Document, import("bson").Document>;
|
|
19
|
+
aggregate: () => Promise<import("bson").Document[]>;
|
|
20
20
|
insertMany: () => Promise<import("mongodb/mongodb").InsertManyResult<import("bson").Document>>;
|
|
21
21
|
updateMany: () => Promise<import("mongodb/mongodb").UpdateResult<import("bson").Document>>;
|
|
22
|
+
deleteMany: () => Promise<import("mongodb/mongodb").DeleteResult>;
|
|
22
23
|
}>;
|
|
23
24
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/functions/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAwB9E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,uDAMhC,kBAAkB
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/functions/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAwB9E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,uDAMhC,kBAAkB;;;;;;;;;;EAqCpB,CAAA"}
|
|
@@ -67,9 +67,12 @@ const executeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ curren
|
|
|
67
67
|
deleteOne: () => currentMethod(bson_1.EJSON.deserialize(query)),
|
|
68
68
|
insertOne: () => currentMethod(bson_1.EJSON.deserialize(document)),
|
|
69
69
|
updateOne: () => currentMethod(bson_1.EJSON.deserialize(query), bson_1.EJSON.deserialize(update)),
|
|
70
|
-
aggregate: () =>
|
|
70
|
+
aggregate: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
return (yield currentMethod(bson_1.EJSON.deserialize(query))).toArray();
|
|
72
|
+
}),
|
|
71
73
|
insertMany: () => currentMethod(bson_1.EJSON.deserialize(documents)),
|
|
72
|
-
updateMany: () => currentMethod(bson_1.EJSON.deserialize(query), bson_1.EJSON.deserialize(update))
|
|
74
|
+
updateMany: () => currentMethod(bson_1.EJSON.deserialize(query), bson_1.EJSON.deserialize(update)),
|
|
75
|
+
deleteMany: () => currentMethod(bson_1.EJSON.deserialize(query))
|
|
73
76
|
};
|
|
74
77
|
});
|
|
75
78
|
exports.executeQuery = executeQuery;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { Document } from 'mongodb';
|
|
1
2
|
export interface Filter {
|
|
2
3
|
name: string;
|
|
3
4
|
query: Record<string, unknown>;
|
|
4
5
|
apply_when: Record<string, unknown>;
|
|
6
|
+
projection?: Projection;
|
|
5
7
|
}
|
|
8
|
+
export type Projection = Record<string, 0 | 1>;
|
|
6
9
|
export interface Role {
|
|
7
10
|
name: string;
|
|
8
11
|
apply_when: Record<string, unknown>;
|
|
@@ -19,4 +22,43 @@ export interface RulesConfig {
|
|
|
19
22
|
roles: Role[];
|
|
20
23
|
}
|
|
21
24
|
export type Rules = Record<string, RulesConfig>;
|
|
25
|
+
export type AggregationPipelineStage = {
|
|
26
|
+
$match: Record<string, unknown>;
|
|
27
|
+
} | {
|
|
28
|
+
$project: Record<string, unknown>;
|
|
29
|
+
} | {
|
|
30
|
+
$sort: Record<string, unknown>;
|
|
31
|
+
} | {
|
|
32
|
+
$limit: number;
|
|
33
|
+
} | {
|
|
34
|
+
$skip: number;
|
|
35
|
+
} | {
|
|
36
|
+
$group: Record<string, unknown>;
|
|
37
|
+
} | {
|
|
38
|
+
$lookup: LookupStage;
|
|
39
|
+
} | {
|
|
40
|
+
$facet: Record<string, AggregationPipelineStage[]>;
|
|
41
|
+
} | {
|
|
42
|
+
$unionWith: UnionWithStage;
|
|
43
|
+
};
|
|
44
|
+
export interface LookupStage {
|
|
45
|
+
from: string;
|
|
46
|
+
localField?: string;
|
|
47
|
+
foreignField?: string;
|
|
48
|
+
as: string;
|
|
49
|
+
let?: Record<string, unknown>;
|
|
50
|
+
pipeline?: AggregationPipelineStage[];
|
|
51
|
+
}
|
|
52
|
+
export type AggregationPipeline = Document[];
|
|
53
|
+
export type UnionWithStage = string | UnionWithNestedStage;
|
|
54
|
+
type UnionWithNestedStage = {
|
|
55
|
+
coll: string;
|
|
56
|
+
pipeline: AggregationPipelineStage[];
|
|
57
|
+
};
|
|
58
|
+
export declare enum STAGES_TO_SEARCH {
|
|
59
|
+
LOOKUP = "$lookup",
|
|
60
|
+
UNION_WITH = "$unionWith",
|
|
61
|
+
FACET = "$facet"
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
22
64
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/rules/interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/rules/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB;AACD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9C,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,O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AAG,MAAM,GAAG,oBAAoB,CAAA;AAC1D,KAAK,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,wBAAwB,EAAE,CAAA;CAAE,CAAA;AAElF,oBAAY,gBAAgB;IAC1B,MAAM,YAAY;IAClB,UAAU,eAAe;IACzB,KAAK,WAAW;CACjB"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STAGES_TO_SEARCH = void 0;
|
|
4
|
+
var STAGES_TO_SEARCH;
|
|
5
|
+
(function (STAGES_TO_SEARCH) {
|
|
6
|
+
STAGES_TO_SEARCH["LOOKUP"] = "$lookup";
|
|
7
|
+
STAGES_TO_SEARCH["UNION_WITH"] = "$unionWith";
|
|
8
|
+
STAGES_TO_SEARCH["FACET"] = "$facet";
|
|
9
|
+
})(STAGES_TO_SEARCH || (exports.STAGES_TO_SEARCH = STAGES_TO_SEARCH = {}));
|
|
@@ -29,3 +29,44 @@ const loadRules = (...args_1) => __awaiter(void 0, [...args_1], void 0, function
|
|
|
29
29
|
return rulesByCollection;
|
|
30
30
|
});
|
|
31
31
|
exports.loadRules = loadRules;
|
|
32
|
+
// export const getNestedPipelines = (pipeline: AggregationPipelineStage[]) => {
|
|
33
|
+
// return pipeline.reduce(
|
|
34
|
+
// (acc, stage) => {
|
|
35
|
+
// const [stageKey] = Object.keys(stage);
|
|
36
|
+
// const stageValue = stage[stageKey as keyof typeof stage];
|
|
37
|
+
// const pipeline = stageValue?.["pipeline"]
|
|
38
|
+
// if (stageKey === '$lookup') {
|
|
39
|
+
// acc.pipelines.push(stageValue);
|
|
40
|
+
// if (pipeline) {
|
|
41
|
+
// const { collections, pipelines } = getNestedPipelines(pipeline);
|
|
42
|
+
// acc.collections.push(...new Set([(stageValue as LookupStage).from, ...collections]));
|
|
43
|
+
// acc.pipelines.push(...pipelines);
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// if (stageKey === '$facet') {
|
|
47
|
+
// for (const subPipeline of Object.values(stageValue)) {
|
|
48
|
+
// const { collections, pipelines } = getNestedPipelines(subPipeline as AggregationPipelineStage[]);
|
|
49
|
+
// acc.collections.push(...collections);
|
|
50
|
+
// acc.pipelines.push(...pipelines);
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
// if (
|
|
54
|
+
// stageKey === '$unionWith' &&
|
|
55
|
+
// typeof stageValue === 'object' &&
|
|
56
|
+
// pipeline
|
|
57
|
+
// ) {
|
|
58
|
+
// const { collections, pipelines } = getNestedPipelines(pipeline);
|
|
59
|
+
// acc.collections.push(...new Set([(stageValue as UnionWithStage).coll, ...collections]));
|
|
60
|
+
// acc.pipelines.push(...pipelines);
|
|
61
|
+
// }
|
|
62
|
+
// return acc;
|
|
63
|
+
// },
|
|
64
|
+
// {
|
|
65
|
+
// collections: [],
|
|
66
|
+
// pipelines: [],
|
|
67
|
+
// } as {
|
|
68
|
+
// collections: string[],
|
|
69
|
+
// pipelines: AggregationPipelineStage[]
|
|
70
|
+
// }
|
|
71
|
+
// );
|
|
72
|
+
// }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;AAuJD,eAAO,MAAM,gBAAgB;0EAnI1B,aAAa;yEAwFb,aAAa;+EApEb,aAAa;CAmHf,CAAA"}
|
|
@@ -75,12 +75,12 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
75
75
|
const pipeline = [
|
|
76
76
|
{
|
|
77
77
|
$match: {
|
|
78
|
-
operationType: { $in: ['
|
|
78
|
+
operationType: { $in: ['insert'] }
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
];
|
|
82
82
|
const changeStream = app.mongo.client
|
|
83
|
-
.db(database)
|
|
83
|
+
.db(database || constants_1.DB_NAME)
|
|
84
84
|
.collection(constants_1.AUTH_CONFIG.authCollection)
|
|
85
85
|
.watch(pipeline, {
|
|
86
86
|
fullDocument: 'whenAvailable'
|
|
@@ -93,7 +93,9 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
93
93
|
const currentUser = Object.assign({}, document);
|
|
94
94
|
delete currentUser.password;
|
|
95
95
|
yield (0, context_1.GenerateContext)({
|
|
96
|
-
args: [{
|
|
96
|
+
args: [{
|
|
97
|
+
user: Object.assign(Object.assign({}, currentUser), { id: currentUser._id.toString() })
|
|
98
|
+
}],
|
|
97
99
|
app,
|
|
98
100
|
rules: {},
|
|
99
101
|
user: {},
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAA;AAEvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAAI,EACJ,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACxC,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAA;AAEvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAAI,EACJ,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACxC,EAAE,gBAAgB,iBAwElB"}
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,31 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
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
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
16
38
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
39
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
40
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -77,6 +99,22 @@ function initialize(_a) {
|
|
|
77
99
|
services: services_1.services
|
|
78
100
|
};
|
|
79
101
|
Object.entries(stateConfig).forEach(([key, value]) => state_1.StateManager.setData(key, value));
|
|
102
|
+
yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger'))));
|
|
103
|
+
yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger-ui'))), {
|
|
104
|
+
routePrefix: '/documentation',
|
|
105
|
+
uiConfig: {
|
|
106
|
+
docExpansion: 'full',
|
|
107
|
+
deepLinking: false
|
|
108
|
+
},
|
|
109
|
+
uiHooks: {
|
|
110
|
+
onRequest: function (request, reply, next) { next(); },
|
|
111
|
+
preHandler: function (request, reply, next) { next(); }
|
|
112
|
+
},
|
|
113
|
+
staticCSP: true,
|
|
114
|
+
transformStaticCSP: (header) => header,
|
|
115
|
+
transformSpecification: (swaggerObject) => { return swaggerObject; },
|
|
116
|
+
transformSpecificationClone: true
|
|
117
|
+
});
|
|
80
118
|
yield (0, registerPlugins_1.registerPlugins)({
|
|
81
119
|
register: fastify.register,
|
|
82
120
|
mongodbUrl,
|
|
@@ -88,7 +126,7 @@ function initialize(_a) {
|
|
|
88
126
|
console.log('APP Routes registration COMPLETED');
|
|
89
127
|
yield (0, functions_1.registerFunctions)({ app: fastify, functionsList, rulesList });
|
|
90
128
|
console.log('Functions registration COMPLETED');
|
|
91
|
-
yield (0, endpoints_1.generateEndpoints)({ app: fastify, functionsList, endpointsList });
|
|
129
|
+
yield (0, endpoints_1.generateEndpoints)({ app: fastify, functionsList, endpointsList, rulesList });
|
|
92
130
|
console.log('HTTP Endpoints registration COMPLETED');
|
|
93
131
|
fastify.ready(() => {
|
|
94
132
|
console.log("FASTIFY IS READY");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyC,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAioBrF,QAAA,MAAM,YAAY,EAAE,oBAgBlB,CAAA;AAEF,eAAe,YAAY,CAAA"}
|