piper-utils 1.1.30 → 1.1.33
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/bin/main.js +1009 -300
- package/bin/main.js.map +1 -1
- package/package.json +1 -1
- package/src/requestResponse/requestResponse.js +292 -286
- package/src/requestResponse/requestResponse.test.js +386 -416
package/bin/main.js
CHANGED
|
@@ -1,88 +1,126 @@
|
|
|
1
|
-
/******/(()=>{// webpackBootstrap
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var __webpack_modules__={
|
|
4
|
-
|
|
5
|
-
/***/
|
|
6
|
-
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ "use strict";
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
4
|
+
|
|
5
|
+
/***/ "./src/database/dbSetup/migrations.js":
|
|
6
|
+
/*!********************************************!*\
|
|
7
|
+
!*** ./src/database/dbSetup/migrations.js ***!
|
|
8
|
+
\********************************************/
|
|
9
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.runMigrations = runMigrations;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _umzug = __webpack_require__(/*! umzug */ "umzug");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };} /**
|
|
7
12
|
* Execute database migrations
|
|
8
13
|
* @param {string} databaseName - name of database to create (or verify existence)
|
|
9
14
|
* @param {object} sequelizeInstance - instance of Sequelize (must be initialized)
|
|
10
15
|
* @param {function} initializeModels - function to run to sync Sequelize models with database
|
|
11
16
|
* @param {string} pathToMigrationFolder - pass in the path if using windows. windows and linux PWD will be different
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
17
|
+
*/async function runMigrations(databaseName, sequelizeInstance, initializeModels, pathToMigrationFolder = `${process.env.PWD}/migrations/*.js`) {const umzug = new _umzug.Umzug({ migrations: { glob: pathToMigrationFolder }, context: sequelizeInstance.getQueryInterface(),
|
|
18
|
+
storage: new _umzug.SequelizeStorage({ sequelize: sequelizeInstance }),
|
|
19
|
+
logger: console
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const pendingMigrations = await umzug.pending();
|
|
23
|
+
console.log('------->UTIL Pending Migrations:', pendingMigrations, pathToMigrationFolder);
|
|
24
|
+
await umzug.up().catch((upError) => {
|
|
25
|
+
console.error('Migration Error: ', upError);
|
|
26
|
+
return umzug.down({
|
|
27
|
+
migrations: _lodash2.default.chain(pendingMigrations).
|
|
28
|
+
map('file').
|
|
29
|
+
reverse().
|
|
30
|
+
value()
|
|
31
|
+
}).then(() => {
|
|
32
|
+
const msg = 'UTIL Error: Error with migrating up:' + upError;
|
|
33
|
+
console.error(msg);
|
|
34
|
+
throw new Error(msg);
|
|
35
|
+
}, (downError) => {
|
|
36
|
+
const msg = 'UTIL Error: Error with migrating down:' + downError;
|
|
37
|
+
console.error(msg);
|
|
38
|
+
throw new Error(msg);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// The following line is needed to sync (create) tables, but not to database updates
|
|
43
|
+
// in the past it worked to leave it in, but now the tags module causes foreign key problems
|
|
44
|
+
// The tables are still initiated by being passed in to run migrations
|
|
45
|
+
await initializeModels();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/***/ }),
|
|
49
|
+
|
|
50
|
+
/***/ "./src/database/dbUtils/queryStringUtils/accessRightsUtils.js":
|
|
51
|
+
/*!********************************************************************!*\
|
|
52
|
+
!*** ./src/database/dbUtils/queryStringUtils/accessRightsUtils.js ***!
|
|
53
|
+
\********************************************************************/
|
|
54
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
55
|
+
|
|
56
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.userRoles = undefined;exports.isSystemUser = isSystemUser;exports.isSuperUser = isSuperUser;exports.checkIsSuper = checkIsSuper;exports.accessRightsUtils = accessRightsUtils;exports.userDefaultBid = userDefaultBid;exports.getRequestedBusinessIds = getRequestedBusinessIds;exports.getAccessRightsInfo = getAccessRightsInfo;exports.getDefaultBusinessIDInfo = getDefaultBusinessIDInfo;exports.getBusinessesInfo = getBusinessesInfo;exports.getModuleInfo = getModuleInfo;exports.checkModule = checkModule;exports.checkWriteAccess = checkWriteAccess;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _errorCodes = __webpack_require__(/*! ../../../requestResponse/errorCodes.js */ "./src/requestResponse/errorCodes.js");var _requestResponse = __webpack_require__(/*! ../../../requestResponse/requestResponse.js */ "./src/requestResponse/requestResponse.js");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}function isSystemUser(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:SYSTEM') || _lodash2.default.get(event, 'requestContext.authorizer.custom:SYSTEM') || 'false';let isSys = false;try {isSys = JSON.parse(jsonToParse);return isSys;} catch (e) {console.error('error with system user:', e);return false;}}function isSuperUser(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:SUPER') || _lodash2.default.get(event, 'requestContext.authorizer.custom:SUPER') || 'false';let isSys = false;try {isSys = JSON.parse(jsonToParse);return isSys;} catch (e) {return false;}} /**
|
|
57
|
+
* Throws unauthorized error if the user is not a super user.
|
|
58
|
+
* Mirrors the behavior and style of checkModule but focused on SUPER role.
|
|
59
|
+
*
|
|
60
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
61
|
+
*/function checkIsSuper(event) {// Super or System users are always allowed
|
|
62
|
+
if (isSuperUser(event)) {return;}if (isSystemUser(event)) {return;} // In local builds allow bypass to ease development and tests
|
|
63
|
+
if (process.env.BUILD_ENV === 'local') {return;}throw _errorCodes.errorList.unauthorized;} /**
|
|
64
|
+
* Get the allowed businessIds for a user from the lambda event, compare it to businessIds, return what user has access to.
|
|
65
|
+
*
|
|
66
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
67
|
+
* @param {{useCognitoBid:boolean}} [options] - An object with options, useCognitoBid prefers the businessId set in cognito if set and does not return the local bid of 1 if a bid is in the claim.
|
|
68
|
+
* @returns {array} A list of businessIds that have been requested and are allowed to for some user.
|
|
69
|
+
*/function accessRightsUtils(event, options) {const useCognitoBid = _lodash2.default.get(options, 'useCognitoBid', false);const requestedBusinessIds = getRequestedBusinessIds(event);const allowedBusinessIds = getAllowedBusinessIds(event, useCognitoBid);if (isSuperUser(event)) {let v = requestedBusinessIds;if (_lodash2.default.isEmpty(requestedBusinessIds)) {v = allowedBusinessIds;}return v;}if (isSystemUser(event)) {return requestedBusinessIds;}if (requestedBusinessIds.length === 0) {return allowedBusinessIds;}return _lodash2.default.intersection(requestedBusinessIds, allowedBusinessIds);} /**
|
|
70
|
+
* Get the businessID set in cognito as custom:DBI.
|
|
71
|
+
*
|
|
72
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
73
|
+
* @returns {string} The businessID set in cognito as custom:DBI
|
|
74
|
+
*/function userDefaultBid(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:DBI') || _lodash2.default.get(event, 'requestContext.authorizer.custom:DBI') || '{}';const dbi = JSON.parse(jsonToParse);return _lodash2.default.get(dbi, 'defaultBid', '') || '1';} /**
|
|
75
|
+
* Get requested businessIds from the query string.
|
|
76
|
+
*
|
|
77
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
78
|
+
* @returns {array} The businessID requested by the query string
|
|
79
|
+
*/function getRequestedBusinessIds(event) {let requestedBusinessIds = _lodash2.default.get(event, 'queryStringParameters.businessIds', null);const body = (0, _requestResponse.parseBody)(event);const bodyBid = body?.businessId;if (requestedBusinessIds) {return requestedBusinessIds ? requestedBusinessIds.split(',') : [];} else if (bodyBid) {return [bodyBid];} else {return [];}} /**
|
|
80
|
+
* Get the allowed businessIds for a user from cognito custom:AR property.
|
|
81
|
+
*
|
|
82
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
83
|
+
* @param useCognitoBid
|
|
84
|
+
* @returns {array} The businessID requested by the query string
|
|
85
|
+
*/function getAllowedBusinessIds(event, useCognitoBid) {const businesses = getBusinessesInfo(event, useCognitoBid);return Object.keys(businesses);}function getAccessRightsInfo(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:AR') || _lodash2.default.get(event, 'requestContext.authorizer.custom:AR') || '{}';const accessRights = JSON.parse(jsonToParse);return _lodash2.default.get(accessRights, 'businessIds', {});}function getDefaultBusinessIDInfo(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:DBI') || _lodash2.default.get(event, 'requestContext.authorizer.custom:DBI') || '{}';const dbi = JSON.parse(jsonToParse);return _lodash2.default.get(dbi, 'defaultBid', '1');}function getBusinessesInfo(event, useCognitoBid = false) {const json = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:AR') || _lodash2.default.get(event, 'requestContext.authorizer.custom:AR') || '{}';let businessIds = _lodash2.default.get(JSON.parse(json), 'businessIds', {}); // Local environment tweaks
|
|
86
|
+
if (process.env.BUILD_ENV === 'local') {let b;try {b = JSON.parse(event?.body);} catch (e) {}const bodyBid = b?.businessId; // Always inject the default local BID “1” unless the caller explicitly wants
|
|
87
|
+
// what Cognito says **and** Cognito actually returned something.
|
|
88
|
+
if (!useCognitoBid) {businessIds = { ...businessIds, '1': 'A' };} // If Cognito gave no BIDs at all, fall back to the local default.
|
|
89
|
+
if ((0, _lodash.isEmpty)(businessIds)) {businessIds = { '1': 'A' };} // a businessId is found on the body for local allow it
|
|
90
|
+
if (bodyBid) {businessIds[bodyBid] = 'A';}}return businessIds;} /**
|
|
91
|
+
* Get the modules listed in custom:MOD.
|
|
92
|
+
*
|
|
93
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
94
|
+
* @returns {array} The Module access list
|
|
95
|
+
*/function getModuleInfo(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:MOD') || _lodash2.default.get(event, 'requestContext.authorizer.custom:MOD') || _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:AR') || _lodash2.default.get(event, 'requestContext.authorizer.custom:AR') || '{}';const moduleRights = JSON.parse(jsonToParse);return _lodash2.default.get(moduleRights, 'module', {});} /**
|
|
96
|
+
* Get the modules listed in custom:MOD.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} moduleName - A sting name for a module.
|
|
99
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
100
|
+
* @returns {array} The Module access list
|
|
101
|
+
*/function checkModule(moduleName, event) {const moduleRights = getModuleInfo(event);let allowAccess = _lodash2.default.get(moduleRights, moduleName, false);if (isSuperUser(event)) {return;}if (isSystemUser(event)) {return;}if (process.env.BUILD_ENV === 'local') {return;}if (!allowAccess) {throw _errorCodes.errorList.unauthorized;}}const userRoles = exports.userRoles = { admin: 'A', read: 'R', write: 'W' }; /**
|
|
102
|
+
* @param {{body: string}} event
|
|
103
|
+
* @param {{useCognitoBid:boolean}} [options] - An object with options, useCognitoBid prefers the businessId set in cognito if set and does not return the local bid of 1 if a bid is in the claim.
|
|
104
|
+
* @returns {string} businessId
|
|
105
|
+
*/function checkWriteAccess(event, options) {const eventBody = (0, _requestResponse.parseBody)(event);const businessIds = accessRightsUtils(event, options) || [];const businessId = businessIds.find((id) => id === eventBody.businessId);const raw = getBusinessesInfo(event);const userRight = raw[businessId];if (isSuperUser(event)) {return eventBody.businessId;}if (isSystemUser(event)) {return eventBody.businessId;}if (process.env.BUILD_ENV === 'local') {return eventBody.businessId;}if (userRight !== userRoles.admin && userRight !== userRoles.write || !userRight) {throw _errorCodes.errorList.unauthorized;}return businessId;}
|
|
106
|
+
|
|
107
|
+
/***/ }),
|
|
108
|
+
|
|
109
|
+
/***/ "./src/database/dbUtils/queryStringUtils/createFilters.js":
|
|
110
|
+
/*!****************************************************************!*\
|
|
111
|
+
!*** ./src/database/dbUtils/queryStringUtils/createFilters.js ***!
|
|
112
|
+
\****************************************************************/
|
|
113
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
114
|
+
|
|
115
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.createFilters = undefined;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);
|
|
116
|
+
var _sequelize = __webpack_require__(/*! sequelize */ "sequelize");var _sequelize2 = _interopRequireDefault(_sequelize);
|
|
117
|
+
var _dayjs = __webpack_require__(/*! dayjs */ "dayjs");var _dayjs2 = _interopRequireDefault(_dayjs);
|
|
118
|
+
var _utc = __webpack_require__(/*! dayjs/plugin/utc.js */ "dayjs/plugin/utc.js");var _utc2 = _interopRequireDefault(_utc);
|
|
119
|
+
var _errorCodes = __webpack_require__(/*! ../../../requestResponse/errorCodes.js */ "./src/requestResponse/errorCodes.js");
|
|
120
|
+
var _accessRightsUtils = __webpack_require__(/*! ./accessRightsUtils.js */ "./src/database/dbUtils/queryStringUtils/accessRightsUtils.js");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
121
|
+
|
|
122
|
+
_dayjs2.default.extend(_utc2.default);
|
|
123
|
+
|
|
86
124
|
/**
|
|
87
125
|
* Create sequelize where clause from query string parameters and default sort object
|
|
88
126
|
*
|
|
@@ -90,87 +128,385 @@ bodyBid&&(businessIds[bodyBid]="A")}return businessIds}
|
|
|
90
128
|
* @param {object} objectFilters - the default filters object created by createDefaultFilters
|
|
91
129
|
* @returns {object} An sequelize where object
|
|
92
130
|
*/
|
|
93
|
-
exports.createFilters=function(event,objectFilters)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//searchString
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
131
|
+
const createFilters = exports.createFilters = function (event, objectFilters) {
|
|
132
|
+
let query = _lodash2.default.get(event, 'queryStringParameters', {}) || {};
|
|
133
|
+
|
|
134
|
+
//searchString, startDate and endDate are bolted on as a convenience
|
|
135
|
+
//startDate and endDate automatically get applied to createdAt
|
|
136
|
+
//searchString allows you to search for a single string against many fields
|
|
137
|
+
const searchString = _lodash2.default.get(query, 'searchString');
|
|
138
|
+
const startDate = _lodash2.default.get(query, 'startDate');
|
|
139
|
+
const endDate = _lodash2.default.get(query, 'endDate');
|
|
140
|
+
|
|
141
|
+
const where = Object.keys(query).reduce((acc, item) => {
|
|
142
|
+
const val = _lodash2.default.get(objectFilters, item, null);
|
|
143
|
+
|
|
144
|
+
if (val) {
|
|
145
|
+
const itemName = item.includes('.') ?
|
|
146
|
+
`$${item}$` :
|
|
147
|
+
item;
|
|
148
|
+
|
|
149
|
+
acc[itemName] = {};
|
|
150
|
+
if (val.filterType === _sequelize2.default.Op.iLike) {
|
|
151
|
+
acc[itemName][val.filterType] = `%${query[item]}%`;
|
|
152
|
+
} else if (val.filterType === _sequelize2.default.Op.or) {
|
|
153
|
+
acc[itemName][val.filterType] = [-1 * +query[item], +query[item]];
|
|
154
|
+
} else if (val.filterType === _sequelize2.default.Op.in) {
|
|
155
|
+
acc[itemName][val.filterType] = query[item].split(',');
|
|
156
|
+
} else if (val.filterType === _sequelize2.default.Op.in) {
|
|
157
|
+
acc[itemName][val.filterType] = query[item].split(',');
|
|
158
|
+
} else {
|
|
159
|
+
let parsedJson;
|
|
160
|
+
try {
|
|
161
|
+
// value is JSON, parse it
|
|
162
|
+
parsedJson = JSON.parse(query[item]);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
// value is not JSON, pass through as a string
|
|
165
|
+
parsedJson = query[item];
|
|
166
|
+
}
|
|
167
|
+
acc[itemName][val.filterType] = parsedJson;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (val.type === _sequelize2.default.BOOLEAN) {
|
|
171
|
+
const queryValue = _lodash2.default.get(query, item, '').toLowerCase();
|
|
172
|
+
|
|
173
|
+
const booleanMap = {
|
|
174
|
+
'false': false,
|
|
175
|
+
'null': null,
|
|
176
|
+
'true': true
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
acc[itemName][val.filterType] = booleanMap[queryValue];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return acc;
|
|
184
|
+
}, {});
|
|
185
|
+
|
|
186
|
+
if (objectFilters?.active && !where?.active) {
|
|
187
|
+
where.active = true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const businessIds = (0, _accessRightsUtils.accessRightsUtils)(event);
|
|
191
|
+
const filterAdds = {
|
|
192
|
+
businessId: businessIds
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (startDate && endDate) {
|
|
196
|
+
const s = _dayjs2.default.utc(startDate);
|
|
197
|
+
const e = _dayjs2.default.utc(endDate);
|
|
198
|
+
const dates = {
|
|
199
|
+
[_sequelize2.default.Op.between]: [s.toDate(), e.toDate()]
|
|
200
|
+
};
|
|
201
|
+
if (!s.isValid()) {
|
|
202
|
+
throw { ..._errorCodes.errorList.invalidStartDate };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!e.isValid()) {
|
|
206
|
+
throw { ..._errorCodes.errorList.invalidEndDate };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
filterAdds.createdAt = dates;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (searchString) {
|
|
213
|
+
const adds = Object.keys(objectFilters).reduce((acc, item) => {
|
|
214
|
+
const type = objectFilters[item].filterType;
|
|
215
|
+
const dataType = objectFilters[item].type;
|
|
216
|
+
|
|
217
|
+
if (type === _sequelize2.default.Op.iLike) {
|
|
218
|
+
const newOr = {};
|
|
219
|
+
const itemName = item.includes('.') ?
|
|
220
|
+
`$${item}$` :
|
|
221
|
+
item;
|
|
222
|
+
newOr[itemName] = {
|
|
223
|
+
[_sequelize2.default.Op.iLike]: `%${query['searchString']}%`
|
|
224
|
+
};
|
|
225
|
+
acc.push(newOr);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (!_lodash2.default.isNaN(Number(query['searchString'])) && !(dataType instanceof _sequelize2.default.BOOLEAN)) {
|
|
229
|
+
|
|
230
|
+
if (type === _sequelize2.default.Op.eq) {
|
|
231
|
+
const newOr = {};
|
|
232
|
+
const itemName = item.includes('.') ? `$${item}$` : item;
|
|
233
|
+
newOr[itemName] = {
|
|
234
|
+
[_sequelize2.default.Op.eq]: `${query['searchString']}`
|
|
235
|
+
};
|
|
236
|
+
acc.push(newOr);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return acc;
|
|
241
|
+
}, []);
|
|
242
|
+
|
|
243
|
+
filterAdds[_sequelize2.default.Op.or] = adds;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const withDate = Object.assign(where, filterAdds);
|
|
247
|
+
|
|
248
|
+
// Build nested objects for any JSONB fields defined in objectFilters
|
|
249
|
+
Object.keys(objectFilters || {}).forEach((k) => {
|
|
250
|
+
const def = objectFilters[k];
|
|
251
|
+
if (def && def.type === 'jsonb' && def.field) {
|
|
252
|
+
const prefix = `${def.field}.`;
|
|
253
|
+
const nestedRoot = {};
|
|
254
|
+
let found = false;
|
|
255
|
+
|
|
256
|
+
Object.keys(query).forEach((qKey) => {
|
|
257
|
+
if (qKey.startsWith(prefix)) {
|
|
258
|
+
const path = qKey.substring(prefix.length);
|
|
259
|
+
_lodash2.default.set(nestedRoot, path.split('.'), query[qKey]);
|
|
260
|
+
found = true;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
if (found) {
|
|
265
|
+
withDate[def.field] = nestedRoot;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return withDate;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/***/ }),
|
|
274
|
+
|
|
275
|
+
/***/ "./src/database/dbUtils/queryStringUtils/createIncludes.js":
|
|
276
|
+
/*!*****************************************************************!*\
|
|
277
|
+
!*** ./src/database/dbUtils/queryStringUtils/createIncludes.js ***!
|
|
278
|
+
\*****************************************************************/
|
|
279
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
280
|
+
|
|
281
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.createIncludes = createIncludes;exports.includeSubItem = includeSubItem;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };} /**
|
|
108
282
|
* Create sequelize includes array from query string parameters and default sequelize model
|
|
109
283
|
*
|
|
110
284
|
* @param {object} event - the query parameters from the event passed by lambda
|
|
111
285
|
* @param {object} objectFilters - the default filters object created by createDefaultFilters
|
|
112
286
|
* @returns {object} A sequelize includes array
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/***/
|
|
117
|
-
|
|
287
|
+
*/function createIncludes(event, objectFilters) {const query = _lodash2.default.get(event, 'queryStringParameters', {}) || {};const keys = Object.keys(objectFilters);const canBeIncluded = keys.reduce((acc, item) => {acc = includeSubItem(item, acc);return acc;}, []);const askedForInQuery = Object.keys(query).reduce((acc, item) => {if (item === 'sort') {query[item].split(',').forEach((sortItem) => {sortItem = sortItem.indexOf('-') === 0 ? sortItem.substr(1) : sortItem;acc = includeSubItem(sortItem, acc);});}acc = includeSubItem(item, acc);return acc;}, []);return _lodash2.default.intersection(canBeIncluded, askedForInQuery);}function includeSubItem(queryStringItem, acc = []) {const dot = queryStringItem.indexOf('.');if (dot > 0) {acc.push(queryStringItem.substring(0, dot));}return acc;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/***/ }),
|
|
291
|
+
|
|
292
|
+
/***/ "./src/database/dbUtils/queryStringUtils/createSort.js":
|
|
293
|
+
/*!*************************************************************!*\
|
|
294
|
+
!*** ./src/database/dbUtils/queryStringUtils/createSort.js ***!
|
|
295
|
+
\*************************************************************/
|
|
296
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
297
|
+
|
|
298
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.createSort = undefined;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
|
|
299
|
+
|
|
118
300
|
/**
|
|
119
301
|
* Create sequelize order clause from query string parameters and default sort object
|
|
120
302
|
*
|
|
121
303
|
* @param {object} event - the event created AWS lambda, it will contain queryStringParameters with sort property a comma seperated list of sortable fields * @param {object} objectFilters - the default filters object created by createDefaultFilters
|
|
122
304
|
* @param {object} defaultFilter - A default filter object as built by createDefault Filters, if items are not on the schema they will not be in the order by
|
|
123
305
|
* @returns {object} An sequelize order by object
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
306
|
+
*/
|
|
307
|
+
const createSort = exports.createSort = function (event, defaultFilter) {
|
|
308
|
+
let copyOfDefaultFilter = _lodash2.default.clone(defaultFilter);
|
|
309
|
+
let query = _lodash2.default.get(event, 'queryStringParameters', {}) || {};
|
|
310
|
+
let sort = _lodash2.default.get(query, 'sort', '-updatedAt') || '-updatedAt';
|
|
311
|
+
|
|
312
|
+
return sort.split(',').reduce((acc, item) => {
|
|
313
|
+
|
|
314
|
+
const testItem = item.indexOf('-') === 0 ? item.substr(1) : item;
|
|
315
|
+
|
|
316
|
+
if (_lodash2.default.get(copyOfDefaultFilter, testItem, null)) {
|
|
317
|
+
const sortItem = [];
|
|
318
|
+
|
|
319
|
+
testItem.split('.').forEach((parentChildList) => {
|
|
320
|
+
sortItem.push(parentChildList);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
if (item.indexOf('-') === 0) {
|
|
324
|
+
sortItem.push('DESC');
|
|
325
|
+
} else {
|
|
326
|
+
sortItem.push('ASC');
|
|
327
|
+
}
|
|
328
|
+
acc.push(sortItem);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return acc;
|
|
332
|
+
}, []);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/***/ }),
|
|
336
|
+
|
|
337
|
+
/***/ "./src/database/dbUtils/queryStringUtils/defaultFilters.js":
|
|
338
|
+
/*!*****************************************************************!*\
|
|
339
|
+
!*** ./src/database/dbUtils/queryStringUtils/defaultFilters.js ***!
|
|
340
|
+
\*****************************************************************/
|
|
341
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
342
|
+
|
|
343
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.defaultFilters = defaultFilters;exports.addFiltersFromSchema = addFiltersFromSchema;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _sequelize = __webpack_require__(/*! sequelize */ "sequelize");var _sequelize2 = _interopRequireDefault(_sequelize);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };} /**
|
|
129
344
|
* Create an object with default filters for a given sequeliaze Schema Object, and set of sub schemas
|
|
130
345
|
*
|
|
131
346
|
* @param {object} schema - type is sequelize data type
|
|
132
347
|
* @param {object} subSchemas - An object with alias as the key and sequelize schema as the value http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#instance-method-define
|
|
133
348
|
* sub schema can be {location: locationSchema} or {location: {as: "asAlias", schema: schema}}
|
|
134
349
|
* @returns {object} An Object with a default filter for each dataType CHAR and TEXT will get a $like operator, INTEGER, DECIMAL and BOOLEAN will get a $eq.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
350
|
+
*/function defaultFilters(schema, subSchemas = {}) {schema = _lodash2.default.clone(schema);const filters = {};addFiltersFromSchema(schema, filters);Object.keys(subSchemas).forEach((key) => {addFiltersFromSchema(subSchemas[key], filters, key);});return filters;}function addFiltersFromSchema(schema, filters, keyPrefix = '') {const asLinkAlias = _lodash2.default.get(schema, 'as', null);schema = _lodash2.default.get(schema, 'schema') || schema;return Object.keys(schema).reduce((acc, item) => {let key = item;if (asLinkAlias) {
|
|
351
|
+
acc[asLinkAlias] = { type: _sequelize2.default.STRING, filterType: _sequelize2.default.Op.eq };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (keyPrefix) {
|
|
355
|
+
key = `${keyPrefix}.${item}`;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (schema[item].filterType) {
|
|
359
|
+
acc[key] = { filterType: schema[item].filterType };
|
|
360
|
+
|
|
361
|
+
return acc;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const itemType = schema[item].type;
|
|
365
|
+
|
|
366
|
+
//new sequelize uses class symbols instead of objects
|
|
367
|
+
if (itemType instanceof _sequelize2.default.STRING) {
|
|
368
|
+
acc[key] = { filterType: _sequelize2.default.Op.iLike };
|
|
369
|
+
} else if (itemType instanceof _sequelize2.default.CHAR) {
|
|
370
|
+
acc[key] = { filterType: _sequelize2.default.Op.iLike };
|
|
371
|
+
} else if (itemType instanceof _sequelize2.default.TEXT) {
|
|
372
|
+
acc[key] = { filterType: _sequelize2.default.Op.iLike };
|
|
373
|
+
} else if (itemType instanceof _sequelize2.default.DECIMAL) {
|
|
374
|
+
acc[key] = { filterType: _sequelize2.default.Op.or };
|
|
375
|
+
} else if (itemType instanceof _sequelize2.default.INTEGER) {
|
|
376
|
+
acc[key] = { filterType: _sequelize2.default.Op.or };
|
|
377
|
+
} else if (itemType instanceof _sequelize2.default.BIGINT) {
|
|
378
|
+
acc[key] = { filterType: _sequelize2.default.Op.or };
|
|
379
|
+
} else if (itemType instanceof _sequelize2.default.BOOLEAN) {
|
|
380
|
+
acc[key] = { type: _sequelize2.default.BOOLEAN, filterType: _sequelize2.default.Op.eq };
|
|
381
|
+
} else if (itemType instanceof _sequelize2.default.JSONB) {
|
|
382
|
+
acc[key] = { type: itemType, filterType: _sequelize2.default.Op.contains };
|
|
383
|
+
} else if (itemType instanceof _sequelize2.default.DATE) {
|
|
384
|
+
acc[key] = { filterType: _sequelize2.default.Op.between };
|
|
385
|
+
} else if (itemType instanceof _sequelize2.default.DATEONLY) {
|
|
386
|
+
acc[key] = { filterType: _sequelize2.default.Op.eq };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
//these are automatically part of the models so add them always
|
|
390
|
+
acc['createdAt'] = { type: _sequelize2.default.DATE, filterType: _sequelize2.default.Op.between };
|
|
391
|
+
acc['updatedAt'] = { type: _sequelize2.default.DATE, filterType: _sequelize2.default.Op.between };
|
|
392
|
+
acc['id'] = { type: _sequelize2.default.INTEGER, filterType: _sequelize2.default.Op.eq };
|
|
393
|
+
|
|
394
|
+
return acc;
|
|
395
|
+
}, filters);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/***/ }),
|
|
399
|
+
|
|
400
|
+
/***/ "./src/database/dbUtils/queryStringUtils/findAll.js":
|
|
401
|
+
/*!**********************************************************!*\
|
|
402
|
+
!*** ./src/database/dbUtils/queryStringUtils/findAll.js ***!
|
|
403
|
+
\**********************************************************/
|
|
404
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
405
|
+
|
|
406
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.getPaginationFromFindAll = getPaginationFromFindAll;exports.findAll = findAll; /**
|
|
145
407
|
* create pagination object from Sequelize findAll
|
|
146
408
|
* @param {object} result - sequelize result
|
|
147
409
|
* @param {number} limit - max number of results to return
|
|
148
410
|
* @param {number} offset - page offset
|
|
149
|
-
*/
|
|
150
|
-
function getPaginationFromFindAll(result,limit,offset){limit=limit||0,offset=offset||0;const hasMore=(result=result||[]).length>limit;hasMore&&result.splice(-1,1);return{offset,limit,rows:result,hasMore}}
|
|
151
|
-
/**
|
|
411
|
+
*/function getPaginationFromFindAll(result, limit, offset) {result = result || [];limit = limit || 0;offset = offset || 0;const hasMore = result.length > limit;if (hasMore) {result.splice(-1, 1);}const pageObject = { offset: offset, limit: limit, rows: result, hasMore: hasMore };return pageObject;} /**
|
|
152
412
|
* wrapper for Sequelize findAll
|
|
153
413
|
* @param {object} model - instance of Sequelize (must be initialized)
|
|
154
414
|
* @param {*&{include: [{model: *}], where: {businessId: Array}, order: [string[]]}} options - instance of Sequelize (must be initialized)
|
|
155
|
-
*/async function findAll(model,options){const limit=options.limit||0
|
|
156
|
-
|
|
157
|
-
|
|
415
|
+
*/async function findAll(model, options) {const limit = options.limit || 0;const includes = options.includes || { all: true, nested: true };const findArgs = Object.assign({ include: includes }, options, { limit: limit + 1 });const results = await model.findAll(findArgs);return getPaginationFromFindAll(results, limit, options.offset);}const findUtils = {
|
|
416
|
+
findAll
|
|
417
|
+
};exports["default"] =
|
|
418
|
+
findUtils;
|
|
419
|
+
|
|
420
|
+
/***/ }),
|
|
421
|
+
|
|
422
|
+
/***/ "./src/dynamo/dynamoUtils.js":
|
|
423
|
+
/*!***********************************!*\
|
|
424
|
+
!*** ./src/dynamo/dynamoUtils.js ***!
|
|
425
|
+
\***********************************/
|
|
426
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
427
|
+
|
|
428
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));var _libDynamodb = __webpack_require__(/*! @aws-sdk/lib-dynamodb */ "@aws-sdk/lib-dynamodb");
|
|
429
|
+
var _clientDynamodb = __webpack_require__(/*! @aws-sdk/client-dynamodb */ "@aws-sdk/client-dynamodb");
|
|
430
|
+
|
|
431
|
+
const dynamoUtil = {
|
|
432
|
+
get: (params) => get(params)
|
|
433
|
+
};
|
|
434
|
+
|
|
158
435
|
/**
|
|
159
436
|
* @param {{TableName:string, Key:{key:string}}} params
|
|
160
437
|
*/
|
|
161
|
-
async function get(params){
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/***/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
438
|
+
async function get(params) {
|
|
439
|
+
const dynamoDb = _libDynamodb.DynamoDBDocument.from(new _clientDynamodb.DynamoDB());
|
|
440
|
+
return dynamoDb.get(params);
|
|
441
|
+
}exports["default"] =
|
|
442
|
+
|
|
443
|
+
dynamoUtil;
|
|
444
|
+
|
|
445
|
+
/***/ }),
|
|
446
|
+
|
|
447
|
+
/***/ "./src/eventManager/handleEvents.js":
|
|
448
|
+
/*!******************************************!*\
|
|
449
|
+
!*** ./src/eventManager/handleEvents.js ***!
|
|
450
|
+
\******************************************/
|
|
451
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
452
|
+
|
|
453
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.handleEvents = handleEvents;exports.handleDirectS3WriteEvent = handleDirectS3WriteEvent;var _handleFile = __webpack_require__(/*! ./handleFile.js */ "./src/eventManager/handleFile.js");var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _bluebird = __webpack_require__(/*! bluebird */ "bluebird");var _bluebird2 = _interopRequireDefault(_bluebird);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}function handleEvents(event, transformer, errorHandlerPerFile, shouldSkipFailedFolders = false, userImportTypes) {if (!event || !event.Records) {return _bluebird2.default.resolve();}let hasErrors = false;return _bluebird2.default.map(event.Records, (record) => {const snsInfo = JSON.parse(_lodash2.default.get(record, 'Sns.Message', '{}'));const s3Bucket = snsInfo.bucket;const files = snsInfo.files || [];return _bluebird2.default.map(files, (file) => {let path = decodeURIComponent(file);if (path) {return (0, _handleFile.handleFile)(path, s3Bucket, transformer, { shouldSkipFailedFolders, userImportTypes }).catch((err) => {if (errorHandlerPerFile && !errorHandlerPerFile(err, path)) {console.error('HANDLE-FILE-CATCH: ', err);hasErrors = true;}});}});}).then(() => {if (hasErrors) {throw new Error('ERROR: HANDLE-FILE');}});}function handleDirectS3WriteEvent(event, transformer, errorHandlerPerFile, shouldSkipFailedFolders = false, userImportTypes) {
|
|
454
|
+
if (!event || !event.Records) {
|
|
455
|
+
return _bluebird2.default.resolve();
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
let hasErrors = false;
|
|
459
|
+
|
|
460
|
+
return _bluebird2.default.map(event.Records, (record) => {
|
|
461
|
+
const s3Bucket = record.s3.bucket.name;
|
|
462
|
+
const file = record.s3.object.key || [];
|
|
463
|
+
|
|
464
|
+
let path = decodeURIComponent(file);
|
|
465
|
+
if (path) {
|
|
466
|
+
return (0, _handleFile.handleFile)(path, s3Bucket, transformer, { shouldSkipFailedFolders, userImportTypes }).catch((err) => {
|
|
467
|
+
if (errorHandlerPerFile && !errorHandlerPerFile(err, path)) {
|
|
468
|
+
console.error('HANDLE-FILE-CATCH:', err);
|
|
469
|
+
hasErrors = true;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
}).then(() => {
|
|
475
|
+
if (hasErrors) {
|
|
476
|
+
throw new Error('ERROR: HANDLE-FILE (DIRECT S3 EVENT)');
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/***/ }),
|
|
482
|
+
|
|
483
|
+
/***/ "./src/eventManager/handleFile.js":
|
|
484
|
+
/*!****************************************!*\
|
|
485
|
+
!*** ./src/eventManager/handleFile.js ***!
|
|
486
|
+
\****************************************/
|
|
487
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
488
|
+
|
|
489
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.handleFile = handleFile;exports.containsError = containsError;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _S3Utils = __webpack_require__(/*! ../s3/S3Utils/S3Utils.js */ "./src/s3/S3Utils/S3Utils.js");var _S3Utils2 = _interopRequireDefault(_S3Utils);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}async function handleFile(path, s3Bucket, transformer, options) {const shouldSkipFailedFolders = _lodash2.default.get(options, 'shouldSkipFailedFolders');const userImportTypes = _lodash2.default.get(options, 'userImportTypes');const params = { Bucket: s3Bucket, Key: path };let body;try {body = await _S3Utils2.default.getObject(params);} catch (e) {if (e.Code === 'NoSuchKey' || e.code === 'NoSuchKey' || e.name === 'NoSuchKey') {return;}console.error('S3 getObject error:', e);throw e;}try {// exit early for null/undefined or blank string bodies
|
|
490
|
+
if (_lodash2.default.isNil(body) || _lodash2.default.isString(body) && _lodash2.default.isEmpty(body.trim())) {await _S3Utils2.default.deleteObject(params);return;}const parsedBody = JSON.parse(body); // exit early for objects like {} or []
|
|
491
|
+
if (_lodash2.default.isEmpty(parsedBody)) {await _S3Utils2.default.deleteObject(params);return;}const returnedValue = await transformer(parsedBody);await _S3Utils2.default.deleteObject(params);return returnedValue;} catch (error) {console.error('HANDLE-FILE-ERROR', error);if (!body) {return;}let newPath = '';if (userImportTypes) {console.log('USER IMPORT'); // look for items in the userImportTypes
|
|
492
|
+
const usersImports = Object.values(userImportTypes);const items = path.split('/');const fileName = _lodash2.default.last(items);const folderName = _lodash2.default.first(items);if (usersImports.indexOf(folderName) > -1) {if (shouldSkipFailedFolders) {newPath = `${folderName}/error/${fileName}`;} else if (_lodash2.default.startsWith(path, `${folderName}/failed-once/`)) {newPath = _lodash2.default.replace(path, `${folderName}/failed-once/`, `${folderName}/failed-twice/`);} else if (_lodash2.default.startsWith(path, `${folderName}/failed-twice/`)) {newPath = _lodash2.default.replace(path, `${folderName}/failed-twice/`, `${folderName}/error/`);} else {newPath = `${folderName}/failed-once/${fileName}`;}} else {newPath = `pathAndEventMisMatchError/${path}`;}} else {if (shouldSkipFailedFolders) {newPath = `error/${path}`;} else if (_lodash2.default.startsWith(path, 'failed-once/')) {newPath = _lodash2.default.replace(path, 'failed-once/', 'failed-twice/');} else if (_lodash2.default.startsWith(path, 'failed-twice/')) {newPath = _lodash2.default.replace(path, 'failed-twice/', 'error/');} else {if (_lodash2.default.includes(path, 'delayUntil/')) {path = _lodash2.default.last(path.split('/'));}newPath = `failed-once/${path}`;}}const newParams = { Bucket: s3Bucket, Key: newPath, Body: body };if (containsError(newPath, 'failed-once') || containsError(newPath, 'failed-twice') || containsError(newPath, 'error')) {throw new Error('NESTING ERROR');}await _S3Utils2.default.putObject(newParams);await _S3Utils2.default.deleteObject(params);throw error;}}function containsError(str, val) {const firstIndex = str.toLowerCase().indexOf(val);if (firstIndex === -1) return false;const secondIndex = str.toLowerCase().indexOf(val, firstIndex + 1);
|
|
493
|
+
return secondIndex !== -1;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/***/ }),
|
|
497
|
+
|
|
498
|
+
/***/ "./src/eventManager/publishEvents.js":
|
|
499
|
+
/*!*******************************************!*\
|
|
500
|
+
!*** ./src/eventManager/publishEvents.js ***!
|
|
501
|
+
\*******************************************/
|
|
502
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
503
|
+
|
|
504
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.loop = loop;exports.publishEvents = publishEvents;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _dayjs = __webpack_require__(/*! dayjs */ "dayjs");var _dayjs2 = _interopRequireDefault(_dayjs);var _customParseFormat = __webpack_require__(/*! dayjs/plugin/customParseFormat */ "dayjs/plugin/customParseFormat");var _customParseFormat2 = _interopRequireDefault(_customParseFormat);var _isSameOrBefore = __webpack_require__(/*! dayjs/plugin/isSameOrBefore */ "dayjs/plugin/isSameOrBefore");var _isSameOrBefore2 = _interopRequireDefault(_isSameOrBefore);var _bluebird = __webpack_require__(/*! bluebird */ "bluebird");var _bluebird2 = _interopRequireDefault(_bluebird);var _S3Utils = __webpack_require__(/*! ../s3/S3Utils/S3Utils.js */ "./src/s3/S3Utils/S3Utils.js");var _S3Utils2 = _interopRequireDefault(_S3Utils);var _SNSUtils = __webpack_require__(/*! ../sns/SNSUtils.js */ "./src/sns/SNSUtils.js");var _SNSUtils2 = _interopRequireDefault(_SNSUtils);var _dynamoUtils = __webpack_require__(/*! ../dynamo/dynamoUtils.js */ "./src/dynamo/dynamoUtils.js");var _dynamoUtils2 = _interopRequireDefault(_dynamoUtils);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}_dayjs2.default.extend(_customParseFormat2.default);_dayjs2.default.extend(_isSameOrBefore2.default); /**
|
|
505
|
+
* @param {string} bucket
|
|
506
|
+
* @param {number} maxKeys
|
|
507
|
+
* @param {Object} userImportTypes
|
|
508
|
+
*/async function loop(bucket, maxKeys, userImportTypes) {let bucketResult = {};let fileList = [];const currentTime = (0, _dayjs2.default)();do {bucketResult = await _S3Utils2.default.listObjectsV2({ Bucket: bucket, MaxKeys: maxKeys, ContinuationToken: _lodash2.default.get(bucketResult, 'NextContinuationToken') });let newFiles = _lodash2.default.filter(bucketResult.Contents, (file) => {if (_lodash2.default.startsWith(_lodash2.default.get(file, 'Key'), 'delayUntil/')) {const fileDelayTime = _lodash2.default.get(file, 'Key').split('/')[1];return (0, _dayjs2.default)(fileDelayTime, 'YYYYMMDDHHmm').isSameOrBefore(currentTime);}if (userImportTypes) {// look for items in the userImportTypes
|
|
509
|
+
const usersImports = Object.values(userImportTypes);const items = file.Key.split('/');const fileName = _lodash2.default.last(items);const folderName = _lodash2.default.first(items);if (_lodash2.default.isEmpty(fileName)) {return false;} else if (usersImports.indexOf(folderName) === -1) {return false;}return !_lodash2.default.startsWith(file.Key, `${folderName}/error`);}return !_lodash2.default.startsWith(file.Key, 'error');});fileList = _lodash2.default.concat(fileList, newFiles);} while (bucketResult.IsTruncated && bucketResult.NextContinuationToken && fileList.length < maxKeys);return fileList;} /**
|
|
174
510
|
* Published SNS events at a steady pace for data in a particular bucket. Should be executed via a cloud watch cron job as a part of a micro service
|
|
175
511
|
*
|
|
176
512
|
* @param {string} configTable - The Dynamo DB table where to get the chunk-size and maxMessage size
|
|
@@ -178,19 +514,39 @@ const usersImports=Object.values(userImportTypes),items=path.split("/"),fileName
|
|
|
178
514
|
* @param {string} bucket - The name of the s3 bucket to watch, when you drop items into this table events will be created
|
|
179
515
|
* @param {string} snsTopic - The name of the snsEvent to publish
|
|
180
516
|
* @param {object} userImportTypes - import types to filter on
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
517
|
+
*/async function publishEvents(configTable, tableKey, bucket, snsTopic, userImportTypes) {let result;try {result = await _dynamoUtils2.default.get({ TableName: configTable, Key: { key: tableKey } });} catch (e) {console.error(`Cannot get config for key: ${tableKey} table: ${configTable} falling back to defaults of 2 and 10`, e);}let chunkSize = _lodash2.default.get(result, 'Item.snsChunkSize', 2);let maxMessages = _lodash2.default.get(result, 'Item.snsMaxMessages', 10);const snsCreateTopicResponse = await _SNSUtils2.default.createTopic({ Name: snsTopic });
|
|
518
|
+
const topicArn = snsCreateTopicResponse.TopicArn;
|
|
519
|
+
const maxKeys = chunkSize * maxMessages;
|
|
520
|
+
|
|
521
|
+
const fileList = await loop(bucket, maxKeys, userImportTypes);
|
|
522
|
+
|
|
523
|
+
const messageList = _lodash2.default.chain(fileList).
|
|
524
|
+
map('Key').
|
|
525
|
+
chunk(chunkSize).
|
|
526
|
+
slice(0, maxMessages).
|
|
527
|
+
value();
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
return _bluebird2.default.map(messageList, (files) => {
|
|
531
|
+
return _SNSUtils2.default.publish({
|
|
532
|
+
Message: JSON.stringify({
|
|
533
|
+
bucket: bucket,
|
|
534
|
+
files: files
|
|
535
|
+
}),
|
|
536
|
+
TopicArn: topicArn
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/***/ }),
|
|
542
|
+
|
|
543
|
+
/***/ "./src/eventManager/watchBucket.js":
|
|
544
|
+
/*!*****************************************!*\
|
|
545
|
+
!*** ./src/eventManager/watchBucket.js ***!
|
|
546
|
+
\*****************************************/
|
|
547
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
548
|
+
|
|
549
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.watchBucket = watchBucket;var _publishEvents = __webpack_require__(/*! ./publishEvents.js */ "./src/eventManager/publishEvents.js");var _handleEvents = __webpack_require__(/*! ./handleEvents.js */ "./src/eventManager/handleEvents.js");var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };} /**
|
|
194
550
|
* bucket watcher watches a s3 bucket and publishes events to a sns topic, this allows you to process files in s3 with a some transformer function
|
|
195
551
|
* prefix objects with DIRECT to listen to direct s3 events
|
|
196
552
|
*
|
|
@@ -204,159 +560,512 @@ const usersImports=Object.values(userImportTypes),items=file.Key.split("/"),file
|
|
|
204
560
|
* @param {function} [params.errorHandlerPerFile] - the function to run on as a catch on each file
|
|
205
561
|
* @param {boolean} [params.shouldSkipFailedFolders] - whether to use the failed-once, failed-twice, error or just error folders
|
|
206
562
|
* @param {object} [params.userImportTypes] - user import subdirectories object map
|
|
207
|
-
*/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
563
|
+
*/function watchBucket({ event, dynamoConfigTable, dynamoConfigKey, s3Bucket, snsTopic, transformer, errorHandlerPerFile = _lodash2.default.noop, shouldSkipFailedFolders = false, userImportTypes }) {if (!event || !dynamoConfigTable || !dynamoConfigKey || !s3Bucket || !snsTopic || !transformer) {throw new Error('Missing required parameters. Need event, dynamoConfigTable, dynamoConfigKey, s3Bucket, snsTopic, transformer');}
|
|
564
|
+
const EventSource = _lodash2.default.get(event, 'Records[0].eventSource') || _lodash2.default.get(event, 'Records[0].EventSource');
|
|
565
|
+
|
|
566
|
+
if (_lodash2.default.isEqual(EventSource, 'aws:sns')) {
|
|
567
|
+
return (0, _handleEvents.handleEvents)(event, transformer, errorHandlerPerFile, shouldSkipFailedFolders, userImportTypes);
|
|
568
|
+
} else if (_lodash2.default.isEqual(EventSource, 'aws:s3')) {
|
|
569
|
+
const failedOnce = 'failed-once';
|
|
570
|
+
const failedTwice = 'failed-twice';
|
|
571
|
+
const error = 'error';
|
|
572
|
+
const direct = 'DIRECT';
|
|
573
|
+
const key = _lodash2.default.get(event, 'Records[0].s3.object.key') || '';
|
|
574
|
+
const startsWithDirect = _lodash2.default.startsWith(key, direct);
|
|
575
|
+
if (key.includes(failedOnce) || key.includes(failedTwice) || key.includes(error)) {
|
|
576
|
+
// this used to throw, but the throw raised useless alarms, I believed turing throw in to a return was ok
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
if (startsWithDirect) {
|
|
581
|
+
console.log('------->DIRECT WRITE FIRE');
|
|
582
|
+
return (0, _handleEvents.handleDirectS3WriteEvent)(event, transformer, errorHandlerPerFile, shouldSkipFailedFolders, userImportTypes);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
} else {
|
|
586
|
+
// the function is being run from the cron job so publish SNS events
|
|
587
|
+
return (0, _publishEvents.publishEvents)(dynamoConfigTable, dynamoConfigKey, s3Bucket, snsTopic, userImportTypes);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/***/ }),
|
|
592
|
+
|
|
593
|
+
/***/ "./src/requestResponse/errorCodes.js":
|
|
594
|
+
/*!*******************************************!*\
|
|
595
|
+
!*** ./src/requestResponse/errorCodes.js ***!
|
|
596
|
+
\*******************************************/
|
|
597
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
598
|
+
|
|
599
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));const errorList = exports.errorList = {
|
|
600
|
+
invalidInventoryReleaseRequest: {
|
|
601
|
+
message: 'NOT ENOUGH INVENTORY TO FULFILL RELEASE',
|
|
602
|
+
errorCode: '4010',
|
|
603
|
+
statusCode: 400
|
|
604
|
+
},
|
|
605
|
+
alreadyReleased: {
|
|
606
|
+
message: 'ALREADY RELEASED',
|
|
607
|
+
errorCode: '4011',
|
|
608
|
+
statusCode: 400
|
|
609
|
+
},
|
|
610
|
+
alreadyReceived: {
|
|
611
|
+
message: 'RECEIVABLE ALREADY RECEIVED',
|
|
612
|
+
errorCode: '4012',
|
|
613
|
+
statusCode: 400
|
|
614
|
+
},
|
|
615
|
+
invalidItemsRequest: {
|
|
616
|
+
message: 'VALID ITEMS MUST BE INCLUDED',
|
|
617
|
+
errorCode: '4013',
|
|
618
|
+
statusCode: 400
|
|
619
|
+
},
|
|
620
|
+
invalidID: {
|
|
621
|
+
message: 'ID is invalid',
|
|
622
|
+
errorCode: '4014',
|
|
623
|
+
statusCode: 400
|
|
624
|
+
},
|
|
625
|
+
invalidReceivable: {
|
|
626
|
+
message: 'MUST CONTAIN AT LEAST ONE RECEIVABLE',
|
|
627
|
+
errorCode: '4015',
|
|
628
|
+
statusCode: 400
|
|
629
|
+
},
|
|
630
|
+
invalidRequest: {
|
|
631
|
+
message: 'INVALID REQUEST DATA',
|
|
632
|
+
errorCode: '4016',
|
|
633
|
+
statusCode: 400
|
|
634
|
+
},
|
|
635
|
+
invalidAPIKey: {
|
|
636
|
+
message: 'INVALID REQUEST - API MAY KEY INVALID',
|
|
637
|
+
errorCode: '4017',
|
|
638
|
+
statusCode: 400
|
|
639
|
+
},
|
|
640
|
+
qbCreationError: {
|
|
641
|
+
message: 'QUICKBOOKS ERROR - ERROR CREATING OBJECT IN QUICKBOOKS',
|
|
642
|
+
errorCode: '4018',
|
|
643
|
+
statusCode: 400
|
|
644
|
+
},
|
|
645
|
+
cannotReopen: {
|
|
646
|
+
message: 'CANNOT REOPEN - THE ORDER HAS ALREADY BEEN OPENED',
|
|
647
|
+
errorCode: '4018',
|
|
648
|
+
statusCode: 400
|
|
649
|
+
},
|
|
650
|
+
invalidDateFormat: {
|
|
651
|
+
message: 'INVALID DATE FORMAT',
|
|
652
|
+
errorCode: '4019',
|
|
653
|
+
statusCode: 400
|
|
654
|
+
},
|
|
655
|
+
invalidStartDate: {
|
|
656
|
+
message: 'INVALID START DATE',
|
|
657
|
+
errorCode: '4020',
|
|
658
|
+
statusCode: 400
|
|
659
|
+
},
|
|
660
|
+
invalidEndDate: {
|
|
661
|
+
message: 'INVALID END DATE',
|
|
662
|
+
errorCode: '4021',
|
|
663
|
+
statusCode: 400
|
|
664
|
+
},
|
|
665
|
+
invalidOrderStatus: {
|
|
666
|
+
message: 'UNABLE TO EDIT ORDER ITEMS UNLESS THE ORDER IS IN ESTIMATE STATUS',
|
|
667
|
+
errorCode: '4022',
|
|
668
|
+
statusCode: 400
|
|
669
|
+
},
|
|
670
|
+
invalidPaymentStatus: {
|
|
671
|
+
message: 'UNABLE TO UPDATE PAYMENT STATUS PAYMENT MUST BE OPEN',
|
|
672
|
+
errorCode: '4023',
|
|
673
|
+
statusCode: 400
|
|
674
|
+
},
|
|
675
|
+
invalidReleaseStatus: {
|
|
676
|
+
message: 'UNABLE TO UPDATE RELEASE, STATUS RELEASE MUST BE OPEN',
|
|
677
|
+
errorCode: '4024',
|
|
678
|
+
statusCode: 400
|
|
679
|
+
},
|
|
680
|
+
invalidReceivableStatus: {
|
|
681
|
+
message: 'UNABLE TO UPDATE RECEIVABLE, STATUS RECEIVABLE MUST BE OPEN',
|
|
682
|
+
errorCode: '40025',
|
|
683
|
+
statusCode: 400
|
|
684
|
+
},
|
|
685
|
+
invalidJson: {
|
|
686
|
+
message: 'INVALID JSON',
|
|
687
|
+
errorCode: '4005',
|
|
688
|
+
statusCode: 400
|
|
689
|
+
},
|
|
690
|
+
invalidFilter: {
|
|
691
|
+
message: 'INVALID FILTER',
|
|
692
|
+
errorCode: '4026',
|
|
693
|
+
statusCode: 400
|
|
694
|
+
},
|
|
695
|
+
invalidUserNameUpdate: {
|
|
696
|
+
message: 'UNABLE TO UPDATE USERNAME',
|
|
697
|
+
errorCode: '4027',
|
|
698
|
+
statusCode: 400
|
|
699
|
+
},
|
|
700
|
+
imageSizeLimit: {
|
|
701
|
+
message: 'IMAGE SIZE LIMIT 100KB EXCEEDED',
|
|
702
|
+
errorCode: '4028',
|
|
703
|
+
statusCode: 400
|
|
704
|
+
},
|
|
705
|
+
unauthorized: {
|
|
706
|
+
message: 'UNAUTHORIZED',
|
|
707
|
+
errorCode: '4111',
|
|
708
|
+
statusCode: 401
|
|
709
|
+
},
|
|
710
|
+
notFound: {
|
|
711
|
+
message: 'ITEM NOT FOUND',
|
|
712
|
+
errorCode: '4004',
|
|
713
|
+
statusCode: 404
|
|
714
|
+
},
|
|
715
|
+
emailRequired: {
|
|
716
|
+
message: 'NO EMAIL PROVIDED, CHECK CUSTOMER EMAIL',
|
|
717
|
+
errorCode: '4004',
|
|
718
|
+
statusCode: 404
|
|
719
|
+
},
|
|
720
|
+
mobilePhoneRequired: {
|
|
721
|
+
message: 'NO MOBILE PHONE PROVIDED, CHECK CUSTOMER CONTACTS',
|
|
722
|
+
errorCode: '4004',
|
|
723
|
+
statusCode: 404
|
|
724
|
+
},
|
|
725
|
+
invalidCadenceType: {
|
|
726
|
+
message: 'INVALID CADENCE TYPE',
|
|
727
|
+
errorCode: '5001',
|
|
728
|
+
statusCode: 500
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
/***/ }),
|
|
733
|
+
|
|
734
|
+
/***/ "./src/requestResponse/requestResponse.js":
|
|
735
|
+
/*!************************************************!*\
|
|
736
|
+
!*** ./src/requestResponse/requestResponse.js ***!
|
|
737
|
+
\************************************************/
|
|
738
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
739
|
+
|
|
740
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.success = success;exports.successHtml = successHtml;exports.getCurrentUserNameFromCognitoEvent = getCurrentUserNameFromCognitoEvent;exports.getCurrentUser = getCurrentUser;exports.failure = failure;exports.parseBody = parseBody;exports.parseEvent = parseEvent;exports.detectSequelizeError = detectSequelizeError;exports.detectJoyError = detectJoyError;exports.detectDynamooseError = detectDynamooseError;var _lodash = __webpack_require__(/*! lodash */ "lodash");var _lodash2 = _interopRequireDefault(_lodash);var _errorCodes = __webpack_require__(/*! ./errorCodes.js */ "./src/requestResponse/errorCodes.js");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };} /**
|
|
741
|
+
* @param {Object} body
|
|
742
|
+
* @param {{dbClose?:function}} [options]
|
|
743
|
+
*/function success(body, options) {const dbClose = _lodash2.default.get(options, 'dbClose', _lodash2.default.noop);dbClose();return buildResponse(200, body);} /**
|
|
744
|
+
* @param {string} html
|
|
745
|
+
* @param {{dbClose:function|undefined}} options
|
|
746
|
+
*/function successHtml(html, options) {const dbClose = _lodash2.default.get(options, 'dbClose', _lodash2.default.noop);dbClose();return { statusCode: 200, headers: { 'Content-Type': 'text/html', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': true }, body: html };} /**
|
|
747
|
+
* @param {string} event
|
|
748
|
+
* @returns string
|
|
749
|
+
*/function getCurrentUserNameFromCognitoEvent(event) {const attributes = _lodash2.default.get(event, 'request.userAttributes');return attributes['cognito:email_alias'] || attributes['email'] || 'UNKNOWN USER';} /**
|
|
750
|
+
* Get the user information from the event object
|
|
751
|
+
*
|
|
752
|
+
* @param event {Object} an event object
|
|
753
|
+
* @returns {{username: string, id: number}}
|
|
754
|
+
*/function getCurrentUser(event) {let jsonToParse = _lodash2.default.get(event, 'requestContext.authorizer.claims.custom:UID') || _lodash2.default.get(event, 'requestContext.authorizer.custom:UID') || '0';const id = JSON.parse(jsonToParse);const username = _lodash2.default.get(event, 'requestContext.authorizer.claims.email') || _lodash2.default.get(event, 'requestContext.authorizer.email') || 'localtestuser@gexample.com';return { username, id };} /**
|
|
755
|
+
* Create a failure response
|
|
756
|
+
*
|
|
757
|
+
* @param body {Object} an event object
|
|
758
|
+
* @param options {Object} an options object
|
|
759
|
+
* @returns {{statusCode:number, headers:object, body:string}} a response object
|
|
760
|
+
*/function failure(body = {}, options) {const dbClose = _lodash2.default.get(options, 'dbClose', _lodash2.default.noop);dbClose();let cleanedErrorBody;if (process.env.UTIL_LOG === 'LOG_ALL' || process.env.BUILD_ENV === 'test') {if (_lodash2.default.isObject(body)) {console.error('------->ALL UTIL ERROR:', JSON.stringify(body, null, 2));}}const NORMAL_ERROR = { statusCode: 500, errorCode: '5XX', message: 'INTERNAL UTIL ERROR' };cleanedErrorBody = body;if (!_lodash2.default.isUndefined(body.details)) {cleanedErrorBody = detectJoyError(body);} else if (_lodash2.default.isUndefined(body.errorCode) || _lodash2.default.isUndefined(body.statusCode)) {cleanedErrorBody = detectSequelizeError(body);}if (_lodash2.default.get(body, 'response.data.message')) {const err = _lodash2.default.get(body, 'response.data.message');if (_lodash2.default.isObject(body)) {console.error('------->MSG UTIL ERROR:', JSON.stringify(err, null, 2));}}const newBody = _lodash2.default.merge(NORMAL_ERROR, cleanedErrorBody);return buildResponse(newBody.statusCode, newBody);} /**
|
|
761
|
+
* Create a failure response object
|
|
762
|
+
*
|
|
763
|
+
* @param statusCode {Number} a status code
|
|
764
|
+
* @param body {Object} an event object
|
|
765
|
+
* @returns {{statusCode:number, headers:object, body:string}} a response object
|
|
766
|
+
*/function buildResponse(statusCode, body) {return { statusCode: statusCode, headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': true }, body: JSON.stringify(body) };} /**
|
|
767
|
+
* parse the body of the event object
|
|
768
|
+
*
|
|
769
|
+
* @param requestEvent {{body:string}} an event object
|
|
770
|
+
* @returns event {*} the json object of the body
|
|
771
|
+
*/function parseBody(requestEvent) {let eventBody = {};if (_lodash2.default.isString(requestEvent.body)) {try {eventBody = JSON.parse(requestEvent.body);} catch (e) {// Invalid JSON
|
|
772
|
+
eventBody = null;throw _errorCodes.errorList.invalidJson;}} else if (_lodash2.default.isObject(requestEvent.body)) {eventBody = requestEvent.body;}return eventBody;} /**
|
|
773
|
+
* parse the body of the event object
|
|
774
|
+
*
|
|
775
|
+
* @param requestEvent {string|object} an event object
|
|
776
|
+
* @param [callback] {function} undefined a call back function
|
|
777
|
+
* @returns event {*} the json object of the body
|
|
778
|
+
*/function parseEvent(requestEvent, callback) {let event = {};if (_lodash2.default.isString(requestEvent)) {try {event = JSON.parse(requestEvent);} catch (e) {// Invalid JSON
|
|
779
|
+
event = null;if (callback) {callback(Error(e));}}} else if (_lodash2.default.isObject(requestEvent)) {event = requestEvent;}return event;} /**
|
|
780
|
+
* parse the body of the event object
|
|
781
|
+
* look for sequelize errors and return a message
|
|
782
|
+
* ERRORS should not be caught here this is a fallback for unknown database errors
|
|
783
|
+
*
|
|
784
|
+
* @param body {object} part of a body response
|
|
785
|
+
* @returns error message object {message:string}
|
|
786
|
+
*/function detectSequelizeError(body) {const errorBody = {};const errorName = _lodash2.default.get(body, 'name', '');if (errorName === 'SequelizeForeignKeyConstraintError') {errorBody.message = 'You cannot delete this item as it is in use';errorBody.statusCode = 409;errorBody.errorCode = '4090';return errorBody;}if (errorName === 'SequelizeUniqueConstraintError') {const fields = _lodash2.default.get(body, 'errors', []).map((err) => _lodash2.default.get(err, 'path')).filter(Boolean);errorBody.message = fields.length ? 'A record with this ' + fields.join(', ') + ' already exists' : 'A record with this value already exists';errorBody.statusCode = 409;errorBody.errorCode = '4091';return errorBody;}if (errorName === 'SequelizeValidationError') {const messages = _lodash2.default.get(body, 'errors', []).map((err) => _lodash2.default.get(err, 'message')).filter(Boolean);errorBody.message = messages.length ? messages.join(', ') : 'Validation error';errorBody.statusCode = 400;errorBody.errorCode = '4001';return errorBody;}let sequelizeError = _lodash2.default.get(body, 'errors', []).reduce((acc, err) => {acc = acc + ' ' + _lodash2.default.get(err, 'message');return acc;}, '');const parentError = _lodash2.default.get(body, 'parent', '');sequelizeError = sequelizeError + _lodash2.default.get(body, 'original.detail', '') + _lodash2.default.get(body, 'TypeError', '') + parentError;errorBody.message = sequelizeError.trim();return errorBody;}function detectJoyError(body) {const errorBody = {};const details = _lodash2.default.get(body, 'details') || [];console.error('USER VALIDATION ERROR:', JSON.stringify(body, null, 2));const messages = extractJoyMessages(details);const msg = messages.join(', ');if (msg) {errorBody.message = msg;}errorBody.statusCode = 400;errorBody.errorCode = '4000';return errorBody;}function extractJoyMessages(details) {const messages = [];for (const detail of details) {const contextDetails = _lodash2.default.get(detail, 'context.details') || [];const directDetails = detail.details || [];const nestedDetails = contextDetails.length > 0 ? contextDetails : directDetails;if (nestedDetails.length > 0) {messages.push(...extractJoyMessages(nestedDetails));} else if (detail.message) {let msg = detail.message;if (detail.context?.value && /does not match/.test(msg)) {const valueStr = JSON.stringify(detail.context.value);const truncated = valueStr.length > 200 ? valueStr.substring(0, 200) + '...' : valueStr;msg += ', received: ' + truncated;}messages.push(msg);}}return messages;} /**
|
|
787
|
+
* Parse the body of a Dynamoose error response.
|
|
788
|
+
* Attempts to extract a human-readable error message from Dynamoose errors.
|
|
789
|
+
* This is a fallback for unknown database errors.
|
|
790
|
+
*
|
|
791
|
+
* @param {object} body - Part of a body response containing error details.
|
|
792
|
+
* @returns {object} - Error message object { message: string }
|
|
793
|
+
*/function detectDynamooseError(body) {const errorBody = {}; // Start with an empty message string.
|
|
794
|
+
let dynamooseError = ''; // If the error body contains an array of errors, concatenate their messages.
|
|
795
|
+
if (Array.isArray(body.errors)) {dynamooseError += body.errors.reduce((acc, err) => {return acc + ' ' + (err.message || '');}, '');} // If there's a top-level message, add it.
|
|
796
|
+
if (body.message) {dynamooseError += ' ' + body.message;} // If there is any additional detail provided, append it.
|
|
797
|
+
if (body.detail) {dynamooseError += ' ' + body.detail;} // Trim the message to remove extra spaces.
|
|
798
|
+
errorBody.message = dynamooseError.trim();return errorBody;}
|
|
799
|
+
|
|
800
|
+
/***/ }),
|
|
801
|
+
|
|
802
|
+
/***/ "./src/s3/S3Utils/S3Utils.js":
|
|
803
|
+
/*!***********************************!*\
|
|
804
|
+
!*** ./src/s3/S3Utils/S3Utils.js ***!
|
|
805
|
+
\***********************************/
|
|
806
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
807
|
+
|
|
808
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.s3Utils = s3Utils;var _clientS = __webpack_require__(/*! @aws-sdk/client-s3 */ "@aws-sdk/client-s3");function s3Utils(action, params) {
|
|
809
|
+
const s3 = new _clientS.S3();
|
|
810
|
+
return s3[action](params);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
const S3Util = {
|
|
814
|
+
getObject: (params) => getS3(params),
|
|
815
|
+
deleteObject: (params) => s3Utils('deleteObject', params),
|
|
816
|
+
putObject: (params) => s3Utils('putObject', params),
|
|
817
|
+
listObjectsV2: (params) => s3Utils('listObjectsV2', params)
|
|
818
|
+
};exports["default"] =
|
|
819
|
+
S3Util;
|
|
820
|
+
|
|
821
|
+
async function getS3(params) {
|
|
822
|
+
const s3 = new _clientS.S3();
|
|
823
|
+
const response = await s3.getObject(params);
|
|
824
|
+
return response?.Body.transformToString('utf-8');
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/***/ }),
|
|
828
|
+
|
|
829
|
+
/***/ "./src/sns/SNSUtils.js":
|
|
830
|
+
/*!*****************************!*\
|
|
831
|
+
!*** ./src/sns/SNSUtils.js ***!
|
|
832
|
+
\*****************************/
|
|
833
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
834
|
+
|
|
835
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));var _clientSns = __webpack_require__(/*! @aws-sdk/client-sns */ "@aws-sdk/client-sns");
|
|
836
|
+
|
|
837
|
+
const SNSUtil = {
|
|
838
|
+
publish: (params) => publish(params),
|
|
839
|
+
createTopic: (params) => createTopic(params)
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
async function publish(params) {
|
|
843
|
+
const sns = new _clientSns.SNS();
|
|
844
|
+
return await sns.publish(params);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
async function createTopic(params) {
|
|
848
|
+
const sns = new _clientSns.SNS();
|
|
849
|
+
return await sns.createTopic(params);
|
|
850
|
+
}exports["default"] =
|
|
851
|
+
|
|
852
|
+
SNSUtil;
|
|
853
|
+
|
|
854
|
+
/***/ }),
|
|
855
|
+
|
|
856
|
+
/***/ "@aws-sdk/client-dynamodb":
|
|
857
|
+
/*!*******************************************!*\
|
|
858
|
+
!*** external "@aws-sdk/client-dynamodb" ***!
|
|
859
|
+
\*******************************************/
|
|
860
|
+
/***/ ((module) => {
|
|
861
|
+
|
|
862
|
+
module.exports = require("@aws-sdk/client-dynamodb");
|
|
863
|
+
|
|
864
|
+
/***/ }),
|
|
865
|
+
|
|
866
|
+
/***/ "@aws-sdk/client-s3":
|
|
867
|
+
/*!*************************************!*\
|
|
868
|
+
!*** external "@aws-sdk/client-s3" ***!
|
|
869
|
+
\*************************************/
|
|
870
|
+
/***/ ((module) => {
|
|
871
|
+
|
|
872
|
+
module.exports = require("@aws-sdk/client-s3");
|
|
873
|
+
|
|
874
|
+
/***/ }),
|
|
875
|
+
|
|
876
|
+
/***/ "@aws-sdk/client-sns":
|
|
877
|
+
/*!**************************************!*\
|
|
878
|
+
!*** external "@aws-sdk/client-sns" ***!
|
|
879
|
+
\**************************************/
|
|
880
|
+
/***/ ((module) => {
|
|
881
|
+
|
|
882
|
+
module.exports = require("@aws-sdk/client-sns");
|
|
883
|
+
|
|
884
|
+
/***/ }),
|
|
885
|
+
|
|
886
|
+
/***/ "@aws-sdk/lib-dynamodb":
|
|
887
|
+
/*!****************************************!*\
|
|
888
|
+
!*** external "@aws-sdk/lib-dynamodb" ***!
|
|
889
|
+
\****************************************/
|
|
890
|
+
/***/ ((module) => {
|
|
891
|
+
|
|
892
|
+
module.exports = require("@aws-sdk/lib-dynamodb");
|
|
893
|
+
|
|
894
|
+
/***/ }),
|
|
895
|
+
|
|
896
|
+
/***/ "bluebird":
|
|
897
|
+
/*!***************************!*\
|
|
898
|
+
!*** external "bluebird" ***!
|
|
899
|
+
\***************************/
|
|
900
|
+
/***/ ((module) => {
|
|
901
|
+
|
|
902
|
+
module.exports = require("bluebird");
|
|
903
|
+
|
|
904
|
+
/***/ }),
|
|
905
|
+
|
|
906
|
+
/***/ "dayjs":
|
|
907
|
+
/*!************************!*\
|
|
908
|
+
!*** external "dayjs" ***!
|
|
909
|
+
\************************/
|
|
910
|
+
/***/ ((module) => {
|
|
911
|
+
|
|
912
|
+
module.exports = require("dayjs");
|
|
913
|
+
|
|
914
|
+
/***/ }),
|
|
915
|
+
|
|
916
|
+
/***/ "dayjs/plugin/customParseFormat":
|
|
917
|
+
/*!*************************************************!*\
|
|
918
|
+
!*** external "dayjs/plugin/customParseFormat" ***!
|
|
919
|
+
\*************************************************/
|
|
920
|
+
/***/ ((module) => {
|
|
921
|
+
|
|
922
|
+
module.exports = require("dayjs/plugin/customParseFormat");
|
|
923
|
+
|
|
924
|
+
/***/ }),
|
|
925
|
+
|
|
926
|
+
/***/ "dayjs/plugin/isSameOrBefore":
|
|
927
|
+
/*!**********************************************!*\
|
|
928
|
+
!*** external "dayjs/plugin/isSameOrBefore" ***!
|
|
929
|
+
\**********************************************/
|
|
930
|
+
/***/ ((module) => {
|
|
931
|
+
|
|
932
|
+
module.exports = require("dayjs/plugin/isSameOrBefore");
|
|
933
|
+
|
|
934
|
+
/***/ }),
|
|
935
|
+
|
|
936
|
+
/***/ "dayjs/plugin/utc.js":
|
|
937
|
+
/*!**************************************!*\
|
|
938
|
+
!*** external "dayjs/plugin/utc.js" ***!
|
|
939
|
+
\**************************************/
|
|
940
|
+
/***/ ((module) => {
|
|
941
|
+
|
|
942
|
+
module.exports = require("dayjs/plugin/utc.js");
|
|
943
|
+
|
|
944
|
+
/***/ }),
|
|
945
|
+
|
|
946
|
+
/***/ "lodash":
|
|
947
|
+
/*!*************************!*\
|
|
948
|
+
!*** external "lodash" ***!
|
|
949
|
+
\*************************/
|
|
950
|
+
/***/ ((module) => {
|
|
951
|
+
|
|
952
|
+
module.exports = require("lodash");
|
|
953
|
+
|
|
954
|
+
/***/ }),
|
|
955
|
+
|
|
956
|
+
/***/ "sequelize":
|
|
957
|
+
/*!****************************!*\
|
|
958
|
+
!*** external "sequelize" ***!
|
|
959
|
+
\****************************/
|
|
960
|
+
/***/ ((module) => {
|
|
961
|
+
|
|
962
|
+
module.exports = require("sequelize");
|
|
963
|
+
|
|
964
|
+
/***/ }),
|
|
965
|
+
|
|
966
|
+
/***/ "umzug":
|
|
967
|
+
/*!************************!*\
|
|
968
|
+
!*** external "umzug" ***!
|
|
969
|
+
\************************/
|
|
970
|
+
/***/ ((module) => {
|
|
971
|
+
|
|
972
|
+
module.exports = require("umzug");
|
|
973
|
+
|
|
974
|
+
/***/ })
|
|
975
|
+
|
|
976
|
+
/******/ });
|
|
977
|
+
/************************************************************************/
|
|
978
|
+
/******/ // The module cache
|
|
979
|
+
/******/ var __webpack_module_cache__ = {};
|
|
980
|
+
/******/
|
|
981
|
+
/******/ // The require function
|
|
982
|
+
/******/ function __webpack_require__(moduleId) {
|
|
983
|
+
/******/ // Check if module is in cache
|
|
984
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
985
|
+
/******/ if (cachedModule !== undefined) {
|
|
986
|
+
/******/ return cachedModule.exports;
|
|
987
|
+
/******/ }
|
|
988
|
+
/******/ // Create a new module (and put it into the cache)
|
|
989
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
990
|
+
/******/ // no module.id needed
|
|
991
|
+
/******/ // no module.loaded needed
|
|
992
|
+
/******/ exports: {}
|
|
993
|
+
/******/ };
|
|
994
|
+
/******/
|
|
995
|
+
/******/ // Execute the module function
|
|
996
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
997
|
+
/******/
|
|
998
|
+
/******/ // Return the exports of the module
|
|
999
|
+
/******/ return module.exports;
|
|
1000
|
+
/******/ }
|
|
1001
|
+
/******/
|
|
333
1002
|
/************************************************************************/
|
|
334
|
-
|
|
335
|
-
/******/
|
|
336
|
-
/******/
|
|
337
|
-
/******/ // The require function
|
|
338
|
-
/******/function __webpack_require__(moduleId){
|
|
339
|
-
/******/ // Check if module is in cache
|
|
340
|
-
/******/var cachedModule=__webpack_module_cache__[moduleId];
|
|
341
|
-
/******/if(void 0!==cachedModule)
|
|
342
|
-
/******/return cachedModule.exports;
|
|
343
|
-
/******/
|
|
344
|
-
/******/ // Create a new module (and put it into the cache)
|
|
345
|
-
/******/var module=__webpack_module_cache__[moduleId]={
|
|
346
|
-
/******/ // no module.id needed
|
|
347
|
-
/******/ // no module.loaded needed
|
|
348
|
-
/******/exports:{}
|
|
349
|
-
/******/};
|
|
350
|
-
/******/
|
|
351
|
-
/******/ // Execute the module function
|
|
352
|
-
/******/
|
|
353
|
-
/******/
|
|
354
|
-
/******/ // Return the exports of the module
|
|
355
|
-
/******/return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports;
|
|
356
|
-
/******/}
|
|
357
|
-
/******/
|
|
358
|
-
/************************************************************************/var __webpack_exports__={};
|
|
1003
|
+
var __webpack_exports__ = {};
|
|
359
1004
|
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
360
|
-
(()=>
|
|
361
|
-
|
|
1005
|
+
(() => {
|
|
1006
|
+
var exports = __webpack_exports__;
|
|
1007
|
+
/*!**********************!*\
|
|
1008
|
+
!*** ./src/index.js ***!
|
|
1009
|
+
\**********************/
|
|
1010
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));exports.isSuperUser = exports.isSystemUser = exports.checkWriteAccess = exports.userDefaultBid = exports.getBusinessesInfo = exports.parseEvent = exports.parseBody = exports.accessRightsUtils = exports.defaultFilters = exports.getCurrentUserNameFromCognitoEvent = exports.successHtml = exports.getCurrentUser = exports.runMigrations = exports.success = exports.failure = exports.getModuleInfo = exports.getDefaultBusinessIDInfo = exports.getAccessRightsInfo = exports.checkIsSuper = exports.checkModule = exports.findAll = exports.createSort = exports.createIncludes = exports.createFilters = exports.publishEvents = exports.watchBucket = exports.handleFile = undefined;var _handleFile = __webpack_require__(/*! ./eventManager/handleFile.js */ "./src/eventManager/handleFile.js");
|
|
1011
|
+
var _watchBucket = __webpack_require__(/*! ./eventManager/watchBucket.js */ "./src/eventManager/watchBucket.js");
|
|
1012
|
+
var _publishEvents = __webpack_require__(/*! ./eventManager/publishEvents.js */ "./src/eventManager/publishEvents.js");
|
|
1013
|
+
var _createIncludes = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/createIncludes.js */ "./src/database/dbUtils/queryStringUtils/createIncludes.js");
|
|
1014
|
+
var _createFilters = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/createFilters.js */ "./src/database/dbUtils/queryStringUtils/createFilters.js");
|
|
1015
|
+
var _createSort = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/createSort.js */ "./src/database/dbUtils/queryStringUtils/createSort.js");
|
|
1016
|
+
var _findAll = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/findAll.js */ "./src/database/dbUtils/queryStringUtils/findAll.js");
|
|
1017
|
+
var _accessRightsUtils = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/accessRightsUtils.js */ "./src/database/dbUtils/queryStringUtils/accessRightsUtils.js");
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
var _requestResponse = __webpack_require__(/*! ./requestResponse/requestResponse.js */ "./src/requestResponse/requestResponse.js");
|
|
1023
|
+
var _migrations = __webpack_require__(/*! ./database/dbSetup/migrations.js */ "./src/database/dbSetup/migrations.js");
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
var _defaultFilters = __webpack_require__(/*! ./database/dbUtils/queryStringUtils/defaultFilters.js */ "./src/database/dbUtils/queryStringUtils/defaultFilters.js");
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
const handleFile = exports.handleFile = _handleFile.handleFile;
|
|
1038
|
+
const watchBucket = exports.watchBucket = _watchBucket.watchBucket;
|
|
1039
|
+
const publishEvents = exports.publishEvents = _publishEvents.publishEvents;
|
|
1040
|
+
const createFilters = exports.createFilters = _createFilters.createFilters;
|
|
1041
|
+
const createIncludes = exports.createIncludes = _createIncludes.createIncludes;
|
|
1042
|
+
const createSort = exports.createSort = _createSort.createSort;
|
|
1043
|
+
const findAll = exports.findAll = _findAll.findAll;
|
|
1044
|
+
const checkModule = exports.checkModule = _accessRightsUtils.checkModule;
|
|
1045
|
+
const checkIsSuper = exports.checkIsSuper = _accessRightsUtils.checkIsSuper;
|
|
1046
|
+
const getAccessRightsInfo = exports.getAccessRightsInfo = _accessRightsUtils.getAccessRightsInfo;
|
|
1047
|
+
const getDefaultBusinessIDInfo = exports.getDefaultBusinessIDInfo = _accessRightsUtils.getDefaultBusinessIDInfo;
|
|
1048
|
+
const getModuleInfo = exports.getModuleInfo = _accessRightsUtils.getModuleInfo;
|
|
1049
|
+
const failure = exports.failure = _requestResponse.failure;
|
|
1050
|
+
const success = exports.success = _requestResponse.success;
|
|
1051
|
+
const runMigrations = exports.runMigrations = _migrations.runMigrations;
|
|
1052
|
+
const getCurrentUser = exports.getCurrentUser = _requestResponse.getCurrentUser;
|
|
1053
|
+
const successHtml = exports.successHtml = _requestResponse.successHtml;
|
|
1054
|
+
const getCurrentUserNameFromCognitoEvent = exports.getCurrentUserNameFromCognitoEvent = _requestResponse.getCurrentUserNameFromCognitoEvent;
|
|
1055
|
+
const defaultFilters = exports.defaultFilters = _defaultFilters.defaultFilters;
|
|
1056
|
+
const accessRightsUtils = exports.accessRightsUtils = _accessRightsUtils.accessRightsUtils;
|
|
1057
|
+
const parseBody = exports.parseBody = _requestResponse.parseBody;
|
|
1058
|
+
const parseEvent = exports.parseEvent = _requestResponse.parseEvent;
|
|
1059
|
+
const getBusinessesInfo = exports.getBusinessesInfo = _accessRightsUtils.getBusinessesInfo;
|
|
1060
|
+
const userDefaultBid = exports.userDefaultBid = _accessRightsUtils.userDefaultBid;
|
|
1061
|
+
const checkWriteAccess = exports.checkWriteAccess = _accessRightsUtils.checkWriteAccess;
|
|
1062
|
+
const isSystemUser = exports.isSystemUser = _accessRightsUtils.isSystemUser;
|
|
1063
|
+
const isSuperUser = exports.isSuperUser = _accessRightsUtils.isSuperUser;
|
|
1064
|
+
})();
|
|
1065
|
+
|
|
1066
|
+
var __webpack_export_target__ = exports;
|
|
1067
|
+
for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
|
|
1068
|
+
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
1069
|
+
/******/ })()
|
|
1070
|
+
;
|
|
362
1071
|
//# sourceMappingURL=main.js.map
|