piper-utils 1.1.33 → 1.1.38
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 +299 -1009
- package/bin/main.js.map +1 -1
- package/package.json +1 -1
- package/src/requestResponse/requestResponse.js +13 -28
- package/src/requestResponse/requestResponse.test.js +1 -24
package/bin/main.js
CHANGED
|
@@ -1,126 +1,88 @@
|
|
|
1
|
-
/******/
|
|
2
|
-
/******/
|
|
3
|
-
/******/
|
|
4
|
-
|
|
5
|
-
/***/
|
|
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 };} /**
|
|
1
|
+
/******/(()=>{// webpackBootstrap
|
|
2
|
+
/******/"use strict";
|
|
3
|
+
/******/var __webpack_modules__={
|
|
4
|
+
/***/871:
|
|
5
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.runMigrations=
|
|
6
|
+
/**
|
|
12
7
|
* Execute database migrations
|
|
13
8
|
* @param {string} databaseName - name of database to create (or verify existence)
|
|
14
9
|
* @param {object} sequelizeInstance - instance of Sequelize (must be initialized)
|
|
15
10
|
* @param {function} initializeModels - function to run to sync Sequelize models with database
|
|
16
11
|
* @param {string} pathToMigrationFolder - pass in the path if using windows. windows and linux PWD will be different
|
|
17
|
-
*/
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
12
|
+
*/
|
|
13
|
+
async function runMigrations(databaseName,sequelizeInstance,initializeModels,pathToMigrationFolder=`${process.env.PWD}/migrations/*.js`){const umzug=new _umzug.Umzug({migrations:{glob:pathToMigrationFolder},context:sequelizeInstance.getQueryInterface(),storage:new _umzug.SequelizeStorage({sequelize:sequelizeInstance}),logger:console}),pendingMigrations=await umzug.pending();console.log("-------\x3eUTIL Pending Migrations:",pendingMigrations,pathToMigrationFolder),await umzug.up().catch(upError=>(console.error("Migration Error: ",upError),umzug.down({migrations:_lodash2.default.chain(pendingMigrations).map("file").reverse().value()}).then(()=>{const msg="UTIL Error: Error with migrating up:"+upError;throw console.error(msg),new Error(msg)},downError=>{const msg="UTIL Error: Error with migrating down:"+downError;throw console.error(msg),new Error(msg)}))),
|
|
14
|
+
// The following line is needed to sync (create) tables, but not to database updates
|
|
15
|
+
// in the past it worked to leave it in, but now the tags module causes foreign key problems
|
|
16
|
+
// The tables are still initiated by being passed in to run migrations
|
|
17
|
+
await initializeModels()}
|
|
18
|
+
/***/;var _lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(__webpack_require__(825)),_umzug=__webpack_require__(920)},
|
|
19
|
+
/***/673:
|
|
20
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.userRoles=void 0,exports.isSystemUser=isSystemUser,exports.isSuperUser=isSuperUser,exports.checkIsSuper=
|
|
21
|
+
/**
|
|
22
|
+
* Throws unauthorized error if the user is not a super user.
|
|
23
|
+
* Mirrors the behavior and style of checkModule but focused on SUPER role.
|
|
24
|
+
*
|
|
25
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
26
|
+
*/
|
|
27
|
+
function checkIsSuper(event){// Super or System users are always allowed
|
|
28
|
+
if(isSuperUser(event))return;if(isSystemUser(event))return;// In local builds allow bypass to ease development and tests
|
|
29
|
+
if("local"===process.env.BUILD_ENV)return;throw _errorCodes.errorList.unauthorized}
|
|
30
|
+
/**
|
|
31
|
+
* Get the allowed businessIds for a user from the lambda event, compare it to businessIds, return what user has access to.
|
|
32
|
+
*
|
|
33
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
34
|
+
* @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.
|
|
35
|
+
* @returns {array} A list of businessIds that have been requested and are allowed to for some user.
|
|
36
|
+
*/,exports.accessRightsUtils=accessRightsUtils,exports.userDefaultBid=
|
|
37
|
+
/**
|
|
38
|
+
* Get the businessID set in cognito as custom:DBI.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
41
|
+
* @returns {string} The businessID set in cognito as custom:DBI
|
|
42
|
+
*/
|
|
43
|
+
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"}
|
|
44
|
+
/**
|
|
45
|
+
* Get requested businessIds from the query string.
|
|
46
|
+
*
|
|
47
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
48
|
+
* @returns {array} The businessID requested by the query string
|
|
49
|
+
*/,exports.getRequestedBusinessIds=getRequestedBusinessIds,exports.getAccessRightsInfo=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",{})},exports.getDefaultBusinessIDInfo=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")},exports.getBusinessesInfo=getBusinessesInfo,exports.getModuleInfo=getModuleInfo,exports.checkModule=
|
|
50
|
+
/**
|
|
51
|
+
* Get the modules listed in custom:MOD.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} moduleName - A sting name for a module.
|
|
54
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
55
|
+
* @returns {array} The Module access list
|
|
56
|
+
*/
|
|
57
|
+
function checkModule(moduleName,event){const moduleRights=getModuleInfo(event);let allowAccess=_lodash2.default.get(moduleRights,moduleName,!1);if(isSuperUser(event))return;if(isSystemUser(event))return;if("local"===process.env.BUILD_ENV)return;if(!allowAccess)throw _errorCodes.errorList.unauthorized},exports.checkWriteAccess=
|
|
58
|
+
/**
|
|
59
|
+
* @param {{body: string}} event
|
|
60
|
+
* @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.
|
|
61
|
+
* @returns {string} businessId
|
|
62
|
+
*/
|
|
63
|
+
function checkWriteAccess(event,options){const eventBody=(0,_requestResponse.parseBody)(event),businessId=(accessRightsUtils(event,options)||[]).find(id=>id===eventBody.businessId),userRight=getBusinessesInfo(event)[businessId];if(isSuperUser(event))return eventBody.businessId;if(isSystemUser(event))return eventBody.businessId;if("local"===process.env.BUILD_ENV)return eventBody.businessId;if(userRight!==userRoles.admin&&userRight!==userRoles.write||!userRight)throw _errorCodes.errorList.unauthorized;return businessId}
|
|
64
|
+
/***/;var _lodash=__webpack_require__(825),_lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(_lodash),_errorCodes=__webpack_require__(953),_requestResponse=__webpack_require__(859);function isSystemUser(event){let jsonToParse=_lodash2.default.get(event,"requestContext.authorizer.claims.custom:SYSTEM")||_lodash2.default.get(event,"requestContext.authorizer.custom:SYSTEM")||"false",isSys=!1;try{return isSys=JSON.parse(jsonToParse),isSys}catch(e){return console.error("error with system user:",e),!1}}function isSuperUser(event){let jsonToParse=_lodash2.default.get(event,"requestContext.authorizer.claims.custom:SUPER")||_lodash2.default.get(event,"requestContext.authorizer.custom:SUPER")||"false",isSys=!1;try{return isSys=JSON.parse(jsonToParse),isSys}catch(e){return!1}}function accessRightsUtils(event,options){const useCognitoBid=_lodash2.default.get(options,"useCognitoBid",!1),requestedBusinessIds=getRequestedBusinessIds(event),allowedBusinessIds=
|
|
65
|
+
/**
|
|
66
|
+
* Get the allowed businessIds for a user from cognito custom:AR property.
|
|
67
|
+
*
|
|
68
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
69
|
+
* @param useCognitoBid
|
|
70
|
+
* @returns {array} The businessID requested by the query string
|
|
71
|
+
*/
|
|
72
|
+
function getAllowedBusinessIds(event,useCognitoBid){const businesses=getBusinessesInfo(event,useCognitoBid);return Object.keys(businesses)}(event,useCognitoBid);if(isSuperUser(event)){let v=requestedBusinessIds;return _lodash2.default.isEmpty(requestedBusinessIds)&&(v=allowedBusinessIds),v}return isSystemUser(event)?requestedBusinessIds:0===requestedBusinessIds.length?allowedBusinessIds:_lodash2.default.intersection(requestedBusinessIds,allowedBusinessIds)}function getRequestedBusinessIds(event){let requestedBusinessIds=_lodash2.default.get(event,"queryStringParameters.businessIds",null);const body=(0,_requestResponse.parseBody)(event),bodyBid=body?.businessId;return requestedBusinessIds?requestedBusinessIds?requestedBusinessIds.split(","):[]:bodyBid?[bodyBid]:[]}function getBusinessesInfo(event,useCognitoBid=!1){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
|
|
73
|
+
if("local"===process.env.BUILD_ENV){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
|
|
74
|
+
// what Cognito says **and** Cognito actually returned something.
|
|
75
|
+
useCognitoBid||(businessIds={...businessIds,1:"A"}),// If Cognito gave no BIDs at all, fall back to the local default.
|
|
76
|
+
(0,_lodash.isEmpty)(businessIds)&&(businessIds={1:"A"}),// a businessId is found on the body for local allow it
|
|
77
|
+
bodyBid&&(businessIds[bodyBid]="A")}return businessIds}
|
|
78
|
+
/**
|
|
79
|
+
* Get the modules listed in custom:MOD.
|
|
80
|
+
*
|
|
81
|
+
* @param {object} event - The lambda event passed in by a validated api request.
|
|
82
|
+
* @returns {array} The Module access list
|
|
83
|
+
*/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",{})}const userRoles=exports.userRoles={admin:"A",read:"R",write:"W"}},
|
|
84
|
+
/***/288:
|
|
85
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFilters=void 0;var _lodash2=_interopRequireDefault(__webpack_require__(825)),_sequelize2=_interopRequireDefault(__webpack_require__(31)),_dayjs2=_interopRequireDefault(__webpack_require__(293)),_utc2=_interopRequireDefault(__webpack_require__(137)),_errorCodes=__webpack_require__(953),_accessRightsUtils=__webpack_require__(673);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}_dayjs2.default.extend(_utc2.default);
|
|
124
86
|
/**
|
|
125
87
|
* Create sequelize where clause from query string parameters and default sort object
|
|
126
88
|
*
|
|
@@ -128,385 +90,87 @@ _dayjs2.default.extend(_utc2.default);
|
|
|
128
90
|
* @param {object} objectFilters - the default filters object created by createDefaultFilters
|
|
129
91
|
* @returns {object} An sequelize where object
|
|
130
92
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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 };} /**
|
|
93
|
+
exports.createFilters=function(event,objectFilters){let query=_lodash2.default.get(event,"queryStringParameters",{})||{};
|
|
94
|
+
//searchString, startDate and endDate are bolted on as a convenience
|
|
95
|
+
//startDate and endDate automatically get applied to createdAt
|
|
96
|
+
//searchString allows you to search for a single string against many fields
|
|
97
|
+
const searchString=_lodash2.default.get(query,"searchString"),startDate=_lodash2.default.get(query,"startDate"),endDate=_lodash2.default.get(query,"endDate"),where=Object.keys(query).reduce((acc,item)=>{const val=_lodash2.default.get(objectFilters,item,null);if(val){const itemName=item.includes(".")?`$${item}$`:item;if(acc[itemName]={},val.filterType===_sequelize2.default.Op.iLike)acc[itemName][val.filterType]=`%${query[item]}%`;else if(val.filterType===_sequelize2.default.Op.or)acc[itemName][val.filterType]=[-1*+query[item],+query[item]];else if(val.filterType===_sequelize2.default.Op.in)acc[itemName][val.filterType]=query[item].split(",");else if(val.filterType===_sequelize2.default.Op.in)acc[itemName][val.filterType]=query[item].split(",");else{let parsedJson;try{
|
|
98
|
+
// value is JSON, parse it
|
|
99
|
+
parsedJson=JSON.parse(query[item])}catch(e){
|
|
100
|
+
// value is not JSON, pass through as a string
|
|
101
|
+
parsedJson=query[item]}acc[itemName][val.filterType]=parsedJson}if(val.type===_sequelize2.default.BOOLEAN){const queryValue=_lodash2.default.get(query,item,"").toLowerCase(),booleanMap={false:!1,null:null,true:!0};acc[itemName][val.filterType]=booleanMap[queryValue]}}return acc},{});objectFilters?.active&&!where?.active&&(where.active=!0);const filterAdds={businessId:(0,_accessRightsUtils.accessRightsUtils)(event)};if(startDate&&endDate){const s=_dayjs2.default.utc(startDate),e=_dayjs2.default.utc(endDate),dates={[_sequelize2.default.Op.between]:[s.toDate(),e.toDate()]};if(!s.isValid())throw{..._errorCodes.errorList.invalidStartDate};if(!e.isValid())throw{..._errorCodes.errorList.invalidEndDate};filterAdds.createdAt=dates}if(searchString){const adds=Object.keys(objectFilters).reduce((acc,item)=>{const type=objectFilters[item].filterType,dataType=objectFilters[item].type;if(type===_sequelize2.default.Op.iLike){const newOr={};newOr[item.includes(".")?`$${item}$`:item]={[_sequelize2.default.Op.iLike]:`%${query.searchString}%`},acc.push(newOr)}if(!(_lodash2.default.isNaN(Number(query.searchString))||dataType instanceof _sequelize2.default.BOOLEAN)&&type===_sequelize2.default.Op.eq){const newOr={};newOr[item.includes(".")?`$${item}$`:item]={[_sequelize2.default.Op.eq]:`${query.searchString}`},acc.push(newOr)}return acc},[]);filterAdds[_sequelize2.default.Op.or]=adds}const withDate=Object.assign(where,filterAdds);
|
|
102
|
+
// Build nested objects for any JSONB fields defined in objectFilters
|
|
103
|
+
return Object.keys(objectFilters||{}).forEach(k=>{const def=objectFilters[k];if(def&&"jsonb"===def.type&&def.field){const prefix=`${def.field}.`,nestedRoot={};let found=!1;Object.keys(query).forEach(qKey=>{if(qKey.startsWith(prefix)){const path=qKey.substring(prefix.length);_lodash2.default.set(nestedRoot,path.split("."),query[qKey]),found=!0}}),found&&(withDate[def.field]=nestedRoot)}}),withDate};
|
|
104
|
+
/***/},
|
|
105
|
+
/***/982:
|
|
106
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.createIncludes=
|
|
107
|
+
/**
|
|
282
108
|
* Create sequelize includes array from query string parameters and default sequelize model
|
|
283
109
|
*
|
|
284
110
|
* @param {object} event - the query parameters from the event passed by lambda
|
|
285
111
|
* @param {object} objectFilters - the default filters object created by createDefaultFilters
|
|
286
112
|
* @returns {object} A sequelize includes array
|
|
287
|
-
*/
|
|
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
|
-
|
|
113
|
+
*/
|
|
114
|
+
function createIncludes(event,objectFilters){const query=_lodash2.default.get(event,"queryStringParameters",{})||{},canBeIncluded=Object.keys(objectFilters).reduce((acc,item)=>acc=includeSubItem(item,acc),[]),askedForInQuery=Object.keys(query).reduce((acc,item)=>("sort"===item&&query[item].split(",").forEach(sortItem=>{sortItem=0===sortItem.indexOf("-")?sortItem.substr(1):sortItem,acc=includeSubItem(sortItem,acc)}),acc=includeSubItem(item,acc)),[]);return _lodash2.default.intersection(canBeIncluded,askedForInQuery)},exports.includeSubItem=includeSubItem;var _lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(__webpack_require__(825));function includeSubItem(queryStringItem,acc=[]){const dot=queryStringItem.indexOf(".");return dot>0&&acc.push(queryStringItem.substring(0,dot)),acc}
|
|
115
|
+
/***/},
|
|
116
|
+
/***/835:
|
|
117
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.createSort=void 0;var _lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}
|
|
300
118
|
/**
|
|
301
119
|
* Create sequelize order clause from query string parameters and default sort object
|
|
302
120
|
*
|
|
303
121
|
* @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
|
|
304
122
|
* @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
|
|
305
123
|
* @returns {object} An sequelize order by object
|
|
306
|
-
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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 };} /**
|
|
124
|
+
*/(__webpack_require__(825));exports.createSort=function(event,defaultFilter){let copyOfDefaultFilter=_lodash2.default.clone(defaultFilter),query=_lodash2.default.get(event,"queryStringParameters",{})||{};return(_lodash2.default.get(query,"sort","-updatedAt")||"-updatedAt").split(",").reduce((acc,item)=>{const testItem=0===item.indexOf("-")?item.substr(1):item;if(_lodash2.default.get(copyOfDefaultFilter,testItem,null)){const sortItem=[];testItem.split(".").forEach(parentChildList=>{sortItem.push(parentChildList)}),0===item.indexOf("-")?sortItem.push("DESC"):sortItem.push("ASC"),acc.push(sortItem)}return acc},[])};
|
|
125
|
+
/***/},
|
|
126
|
+
/***/207:
|
|
127
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultFilters=
|
|
128
|
+
/**
|
|
344
129
|
* Create an object with default filters for a given sequeliaze Schema Object, and set of sub schemas
|
|
345
130
|
*
|
|
346
131
|
* @param {object} schema - type is sequelize data type
|
|
347
132
|
* @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
|
|
348
133
|
* sub schema can be {location: locationSchema} or {location: {as: "asAlias", schema: schema}}
|
|
349
134
|
* @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.
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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; /**
|
|
135
|
+
*/
|
|
136
|
+
function defaultFilters(schema,subSchemas={}){schema=_lodash2.default.clone(schema);const filters={};return addFiltersFromSchema(schema,filters),Object.keys(subSchemas).forEach(key=>{addFiltersFromSchema(subSchemas[key],filters,key)}),filters},exports.addFiltersFromSchema=addFiltersFromSchema;var _lodash2=_interopRequireDefault(__webpack_require__(825)),_sequelize2=_interopRequireDefault(__webpack_require__(31));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function addFiltersFromSchema(schema,filters,keyPrefix=""){const asLinkAlias=_lodash2.default.get(schema,"as",null);return schema=_lodash2.default.get(schema,"schema")||schema,Object.keys(schema).reduce((acc,item)=>{let key=item;if(asLinkAlias&&(acc[asLinkAlias]={type:_sequelize2.default.STRING,filterType:_sequelize2.default.Op.eq}),keyPrefix&&(key=`${keyPrefix}.${item}`),schema[item].filterType)return acc[key]={filterType:schema[item].filterType},acc;const itemType=schema[item].type;
|
|
137
|
+
//new sequelize uses class symbols instead of objects
|
|
138
|
+
return itemType instanceof _sequelize2.default.STRING||itemType instanceof _sequelize2.default.CHAR||itemType instanceof _sequelize2.default.TEXT?acc[key]={filterType:_sequelize2.default.Op.iLike}:itemType instanceof _sequelize2.default.DECIMAL||itemType instanceof _sequelize2.default.INTEGER||itemType instanceof _sequelize2.default.BIGINT?acc[key]={filterType:_sequelize2.default.Op.or}:itemType instanceof _sequelize2.default.BOOLEAN?acc[key]={type:_sequelize2.default.BOOLEAN,filterType:_sequelize2.default.Op.eq}:itemType instanceof _sequelize2.default.JSONB?acc[key]={type:itemType,filterType:_sequelize2.default.Op.contains}:itemType instanceof _sequelize2.default.DATE?acc[key]={filterType:_sequelize2.default.Op.between}:itemType instanceof _sequelize2.default.DATEONLY&&(acc[key]={filterType:_sequelize2.default.Op.eq}),
|
|
139
|
+
//these are automatically part of the models so add them always
|
|
140
|
+
acc.createdAt={type:_sequelize2.default.DATE,filterType:_sequelize2.default.Op.between},acc.updatedAt={type:_sequelize2.default.DATE,filterType:_sequelize2.default.Op.between},acc.id={type:_sequelize2.default.INTEGER,filterType:_sequelize2.default.Op.eq},acc},filters)}
|
|
141
|
+
/***/},
|
|
142
|
+
/***/981:
|
|
143
|
+
/***/(__unused_webpack_module,exports)=>{
|
|
144
|
+
/**
|
|
407
145
|
* create pagination object from Sequelize findAll
|
|
408
146
|
* @param {object} result - sequelize result
|
|
409
147
|
* @param {number} limit - max number of results to return
|
|
410
148
|
* @param {number} offset - page offset
|
|
411
|
-
*/
|
|
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
|
+
/**
|
|
412
152
|
* wrapper for Sequelize findAll
|
|
413
153
|
* @param {object} model - instance of Sequelize (must be initialized)
|
|
414
154
|
* @param {*&{include: [{model: *}], where: {businessId: Array}, order: [string[]]}} options - instance of Sequelize (must be initialized)
|
|
415
|
-
*/async function findAll(model,
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
155
|
+
*/async function findAll(model,options){const limit=options.limit||0,includes=options.includes||{all:!0,nested:!0},findArgs=Object.assign({include:includes},options,{limit:limit+1});return getPaginationFromFindAll(await model.findAll(findArgs),limit,options.offset)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPaginationFromFindAll=getPaginationFromFindAll,exports.findAll=findAll;const findUtils={findAll};exports.default=findUtils},
|
|
156
|
+
/***/64:
|
|
157
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0});var _libDynamodb=__webpack_require__(515),_clientDynamodb=__webpack_require__(929);const dynamoUtil={get:params=>
|
|
435
158
|
/**
|
|
436
159
|
* @param {{TableName:string, Key:{key:string}}} params
|
|
437
160
|
*/
|
|
438
|
-
async function get(params)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
/***/
|
|
448
|
-
|
|
449
|
-
|
|
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;} /**
|
|
161
|
+
async function get(params){return _libDynamodb.DynamoDBDocument.from(new _clientDynamodb.DynamoDB).get(params)}(params)};exports.default=dynamoUtil},
|
|
162
|
+
/***/95:
|
|
163
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleEvents=function handleEvents(event,transformer,errorHandlerPerFile,shouldSkipFailedFolders=!1,userImportTypes){if(!event||!event.Records)return _bluebird2.default.resolve();let hasErrors=!1;return _bluebird2.default.map(event.Records,record=>{const snsInfo=JSON.parse(_lodash2.default.get(record,"Sns.Message","{}")),s3Bucket=snsInfo.bucket,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=>{errorHandlerPerFile&&!errorHandlerPerFile(err,path)&&(console.error("HANDLE-FILE-CATCH: ",err),hasErrors=!0)})})}).then(()=>{if(hasErrors)throw new Error("ERROR: HANDLE-FILE")})},exports.handleDirectS3WriteEvent=function handleDirectS3WriteEvent(event,transformer,errorHandlerPerFile,shouldSkipFailedFolders=!1,userImportTypes){if(!event||!event.Records)return _bluebird2.default.resolve();let hasErrors=!1;return _bluebird2.default.map(event.Records,record=>{const s3Bucket=record.s3.bucket.name,file=record.s3.object.key||[];let path=decodeURIComponent(file);if(path)return(0,_handleFile.handleFile)(path,s3Bucket,transformer,{shouldSkipFailedFolders,userImportTypes}).catch(err=>{errorHandlerPerFile&&!errorHandlerPerFile(err,path)&&(console.error("HANDLE-FILE-CATCH:",err),hasErrors=!0)})}).then(()=>{if(hasErrors)throw new Error("ERROR: HANDLE-FILE (DIRECT S3 EVENT)")})}
|
|
164
|
+
/***/;var _handleFile=__webpack_require__(876),_lodash2=_interopRequireDefault(__webpack_require__(825)),_bluebird2=_interopRequireDefault(__webpack_require__(564));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}},
|
|
165
|
+
/***/876:
|
|
166
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleFile=async function handleFile(path,s3Bucket,transformer,options){const shouldSkipFailedFolders=_lodash2.default.get(options,"shouldSkipFailedFolders"),userImportTypes=_lodash2.default.get(options,"userImportTypes"),params={Bucket:s3Bucket,Key:path};let body;try{body=await _S3Utils2.default.getObject(params)}catch(e){if("NoSuchKey"===e.Code||"NoSuchKey"===e.code||"NoSuchKey"===e.name)return;throw console.error("S3 getObject error:",e),e}try{// exit early for null/undefined or blank string bodies
|
|
167
|
+
if(_lodash2.default.isNil(body)||_lodash2.default.isString(body)&&_lodash2.default.isEmpty(body.trim()))return void await _S3Utils2.default.deleteObject(params);const parsedBody=JSON.parse(body);// exit early for objects like {} or []
|
|
168
|
+
if(_lodash2.default.isEmpty(parsedBody))return void await _S3Utils2.default.deleteObject(params);const returnedValue=await transformer(parsedBody);return await _S3Utils2.default.deleteObject(params),returnedValue}catch(error){if(console.error("HANDLE-FILE-ERROR",error),!body)return;let newPath="";if(userImportTypes){console.log("USER IMPORT");// look for items in the userImportTypes
|
|
169
|
+
const usersImports=Object.values(userImportTypes),items=path.split("/"),fileName=_lodash2.default.last(items),folderName=_lodash2.default.first(items);newPath=usersImports.indexOf(folderName)>-1?shouldSkipFailedFolders?`${folderName}/error/${fileName}`:_lodash2.default.startsWith(path,`${folderName}/failed-once/`)?_lodash2.default.replace(path,`${folderName}/failed-once/`,`${folderName}/failed-twice/`):_lodash2.default.startsWith(path,`${folderName}/failed-twice/`)?_lodash2.default.replace(path,`${folderName}/failed-twice/`,`${folderName}/error/`):`${folderName}/failed-once/${fileName}`:`pathAndEventMisMatchError/${path}`}else shouldSkipFailedFolders?newPath=`error/${path}`:_lodash2.default.startsWith(path,"failed-once/")?newPath=_lodash2.default.replace(path,"failed-once/","failed-twice/"):_lodash2.default.startsWith(path,"failed-twice/")?newPath=_lodash2.default.replace(path,"failed-twice/","error/"):(_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");throw await _S3Utils2.default.putObject(newParams),await _S3Utils2.default.deleteObject(params),error}},exports.containsError=containsError;var _lodash2=_interopRequireDefault(__webpack_require__(825)),_S3Utils2=_interopRequireDefault(__webpack_require__(908));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function containsError(str,val){const firstIndex=str.toLowerCase().indexOf(val);if(-1===firstIndex)return!1;return-1!==str.toLowerCase().indexOf(val,firstIndex+1)}
|
|
170
|
+
/***/},
|
|
171
|
+
/***/864:
|
|
172
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.loop=loop,exports.publishEvents=
|
|
173
|
+
/**
|
|
510
174
|
* 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
|
|
511
175
|
*
|
|
512
176
|
* @param {string} configTable - The Dynamo DB table where to get the chunk-size and maxMessage size
|
|
@@ -514,39 +178,19 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));exports.loop = l
|
|
|
514
178
|
* @param {string} bucket - The name of the s3 bucket to watch, when you drop items into this table events will be created
|
|
515
179
|
* @param {string} snsTopic - The name of the snsEvent to publish
|
|
516
180
|
* @param {object} userImportTypes - import types to filter on
|
|
517
|
-
*/
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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 };} /**
|
|
181
|
+
*/
|
|
182
|
+
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),maxMessages=_lodash2.default.get(result,"Item.snsMaxMessages",10);const topicArn=(await _SNSUtils2.default.createTopic({Name:snsTopic})).TopicArn,maxKeys=chunkSize*maxMessages,fileList=await loop(bucket,maxKeys,userImportTypes),messageList=_lodash2.default.chain(fileList).map("Key").chunk(chunkSize).slice(0,maxMessages).value();return _bluebird2.default.map(messageList,files=>_SNSUtils2.default.publish({Message:JSON.stringify({bucket,files}),TopicArn:topicArn}))}
|
|
183
|
+
/***/;var _lodash2=_interopRequireDefault(__webpack_require__(825)),_dayjs2=_interopRequireDefault(__webpack_require__(293)),_customParseFormat2=_interopRequireDefault(__webpack_require__(59)),_isSameOrBefore2=_interopRequireDefault(__webpack_require__(394)),_bluebird2=_interopRequireDefault(__webpack_require__(564)),_S3Utils2=_interopRequireDefault(__webpack_require__(908)),_SNSUtils2=_interopRequireDefault(__webpack_require__(306)),_dynamoUtils2=_interopRequireDefault(__webpack_require__(64));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}
|
|
184
|
+
/**
|
|
185
|
+
* @param {string} bucket
|
|
186
|
+
* @param {number} maxKeys
|
|
187
|
+
* @param {Object} userImportTypes
|
|
188
|
+
*/
|
|
189
|
+
async function loop(bucket,maxKeys,userImportTypes){let bucketResult={},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
|
|
190
|
+
const usersImports=Object.values(userImportTypes),items=file.Key.split("/"),fileName=_lodash2.default.last(items),folderName=_lodash2.default.first(items);return!_lodash2.default.isEmpty(fileName)&&(-1!==usersImports.indexOf(folderName)&&!_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}_dayjs2.default.extend(_customParseFormat2.default),_dayjs2.default.extend(_isSameOrBefore2.default)},
|
|
191
|
+
/***/183:
|
|
192
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.watchBucket=
|
|
193
|
+
/**
|
|
550
194
|
* 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
|
|
551
195
|
* prefix objects with DIRECT to listen to direct s3 events
|
|
552
196
|
*
|
|
@@ -560,512 +204,158 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));exports.watchBuc
|
|
|
560
204
|
* @param {function} [params.errorHandlerPerFile] - the function to run on as a catch on each file
|
|
561
205
|
* @param {boolean} [params.shouldSkipFailedFolders] - whether to use the failed-once, failed-twice, error or just error folders
|
|
562
206
|
* @param {object} [params.userImportTypes] - user import subdirectories object map
|
|
563
|
-
*/
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
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
|
-
/******/
|
|
207
|
+
*/
|
|
208
|
+
function watchBucket({event,dynamoConfigTable,dynamoConfigKey,s3Bucket,snsTopic,transformer,errorHandlerPerFile=_lodash2.default.noop,shouldSkipFailedFolders=!1,userImportTypes}){if(!(event&&dynamoConfigTable&&dynamoConfigKey&&s3Bucket&&snsTopic&&transformer))throw new Error("Missing required parameters. Need event, dynamoConfigTable, dynamoConfigKey, s3Bucket, snsTopic, transformer");const EventSource=_lodash2.default.get(event,"Records[0].eventSource")||_lodash2.default.get(event,"Records[0].EventSource");if(_lodash2.default.isEqual(EventSource,"aws:sns"))return(0,_handleEvents.handleEvents)(event,transformer,errorHandlerPerFile,shouldSkipFailedFolders,userImportTypes);if(!_lodash2.default.isEqual(EventSource,"aws:s3"))
|
|
209
|
+
// the function is being run from the cron job so publish SNS events
|
|
210
|
+
return(0,_publishEvents.publishEvents)(dynamoConfigTable,dynamoConfigKey,s3Bucket,snsTopic,userImportTypes);{const failedOnce="failed-once",failedTwice="failed-twice",error="error",direct="DIRECT",key=_lodash2.default.get(event,"Records[0].s3.object.key")||"",startsWithDirect=_lodash2.default.startsWith(key,direct);if(key.includes(failedOnce)||key.includes(failedTwice)||key.includes(error))
|
|
211
|
+
// this used to throw, but the throw raised useless alarms, I believed turing throw in to a return was ok
|
|
212
|
+
return;if(startsWithDirect)return console.log("-------\x3eDIRECT WRITE FIRE"),(0,_handleEvents.handleDirectS3WriteEvent)(event,transformer,errorHandlerPerFile,shouldSkipFailedFolders,userImportTypes)}}
|
|
213
|
+
/***/;var _publishEvents=__webpack_require__(864),_handleEvents=__webpack_require__(95),_lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(__webpack_require__(825))},
|
|
214
|
+
/***/953:
|
|
215
|
+
/***/(__unused_webpack_module,exports)=>{Object.defineProperty(exports,"__esModule",{value:!0});exports.errorList={invalidInventoryReleaseRequest:{message:"NOT ENOUGH INVENTORY TO FULFILL RELEASE",errorCode:"4010",statusCode:400},alreadyReleased:{message:"ALREADY RELEASED",errorCode:"4011",statusCode:400},alreadyReceived:{message:"RECEIVABLE ALREADY RECEIVED",errorCode:"4012",statusCode:400},invalidItemsRequest:{message:"VALID ITEMS MUST BE INCLUDED",errorCode:"4013",statusCode:400},invalidID:{message:"ID is invalid",errorCode:"4014",statusCode:400},invalidReceivable:{message:"MUST CONTAIN AT LEAST ONE RECEIVABLE",errorCode:"4015",statusCode:400},invalidRequest:{message:"INVALID REQUEST DATA",errorCode:"4016",statusCode:400},invalidAPIKey:{message:"INVALID REQUEST - API MAY KEY INVALID",errorCode:"4017",statusCode:400},qbCreationError:{message:"QUICKBOOKS ERROR - ERROR CREATING OBJECT IN QUICKBOOKS",errorCode:"4018",statusCode:400},cannotReopen:{message:"CANNOT REOPEN - THE ORDER HAS ALREADY BEEN OPENED",errorCode:"4018",statusCode:400},invalidDateFormat:{message:"INVALID DATE FORMAT",errorCode:"4019",statusCode:400},invalidStartDate:{message:"INVALID START DATE",errorCode:"4020",statusCode:400},invalidEndDate:{message:"INVALID END DATE",errorCode:"4021",statusCode:400},invalidOrderStatus:{message:"UNABLE TO EDIT ORDER ITEMS UNLESS THE ORDER IS IN ESTIMATE STATUS",errorCode:"4022",statusCode:400},invalidPaymentStatus:{message:"UNABLE TO UPDATE PAYMENT STATUS PAYMENT MUST BE OPEN",errorCode:"4023",statusCode:400},invalidReleaseStatus:{message:"UNABLE TO UPDATE RELEASE, STATUS RELEASE MUST BE OPEN",errorCode:"4024",statusCode:400},invalidReceivableStatus:{message:"UNABLE TO UPDATE RECEIVABLE, STATUS RECEIVABLE MUST BE OPEN",errorCode:"40025",statusCode:400},invalidJson:{message:"INVALID JSON",errorCode:"4005",statusCode:400},invalidFilter:{message:"INVALID FILTER",errorCode:"4026",statusCode:400},invalidUserNameUpdate:{message:"UNABLE TO UPDATE USERNAME",errorCode:"4027",statusCode:400},imageSizeLimit:{message:"IMAGE SIZE LIMIT 100KB EXCEEDED",errorCode:"4028",statusCode:400},unauthorized:{message:"UNAUTHORIZED",errorCode:"4111",statusCode:401},notFound:{message:"ITEM NOT FOUND",errorCode:"4004",statusCode:404},emailRequired:{message:"NO EMAIL PROVIDED, CHECK CUSTOMER EMAIL",errorCode:"4004",statusCode:404},mobilePhoneRequired:{message:"NO MOBILE PHONE PROVIDED, CHECK CUSTOMER CONTACTS",errorCode:"4004",statusCode:404},invalidCadenceType:{message:"INVALID CADENCE TYPE",errorCode:"5001",statusCode:500}};
|
|
216
|
+
/***/},
|
|
217
|
+
/***/859:
|
|
218
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.success=
|
|
219
|
+
/**
|
|
220
|
+
* @param {Object} body
|
|
221
|
+
* @param {{dbClose?:function}} [options]
|
|
222
|
+
*/
|
|
223
|
+
function success(body,options){return _lodash2.default.get(options,"dbClose",_lodash2.default.noop)(),buildResponse(200,body)}
|
|
224
|
+
/**
|
|
225
|
+
* @param {string} html
|
|
226
|
+
* @param {{dbClose:function|undefined}} options
|
|
227
|
+
*/,exports.successHtml=function successHtml(html,options){return _lodash2.default.get(options,"dbClose",_lodash2.default.noop)(),{statusCode:200,headers:{"Content-Type":"text/html","Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":!0},body:html}}
|
|
228
|
+
/**
|
|
229
|
+
* @param {string} event
|
|
230
|
+
* @returns string
|
|
231
|
+
*/,exports.getCurrentUserNameFromCognitoEvent=function getCurrentUserNameFromCognitoEvent(event){const attributes=_lodash2.default.get(event,"request.userAttributes");return attributes["cognito:email_alias"]||attributes.email||"UNKNOWN USER"}
|
|
232
|
+
/**
|
|
233
|
+
* Get the user information from the event object
|
|
234
|
+
*
|
|
235
|
+
* @param event {Object} an event object
|
|
236
|
+
* @returns {{username: string, id: number}}
|
|
237
|
+
*/,exports.getCurrentUser=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);return{username:_lodash2.default.get(event,"requestContext.authorizer.claims.email")||_lodash2.default.get(event,"requestContext.authorizer.email")||"localtestuser@gexample.com",id}}
|
|
238
|
+
/**
|
|
239
|
+
* Create a failure response
|
|
240
|
+
*
|
|
241
|
+
* @param body {Object} an event object
|
|
242
|
+
* @param options {Object} an options object
|
|
243
|
+
* @returns {{statusCode:number, headers:object, body:string}} a response object
|
|
244
|
+
*/,exports.failure=function failure(body={},options){let cleanedErrorBody;_lodash2.default.get(options,"dbClose",_lodash2.default.noop)(),("LOG_ALL"===process.env.UTIL_LOG||"test"===process.env.BUILD_ENV)&&_lodash2.default.isObject(body)&&console.error("-------\x3eALL UTIL ERROR:",body,null,2);cleanedErrorBody=body,_lodash2.default.isUndefined(body.details)?_lodash2.default.isUndefined(body.errorCode)||_lodash2.default.isUndefined(body.statusCode)?cleanedErrorBody=detectSequelizeError(body):_lodash2.default.isUndefined(body.message)&&(cleanedErrorBody=detectDynamooseError(body.errors)):cleanedErrorBody=detectJoyError(body);if(_lodash2.default.get(body,"response.data.message")){const err=_lodash2.default.get(body,"response.data.message");_lodash2.default.isObject(body)&&console.error("-------\x3eMSG UTIL ERROR:",JSON.stringify(err,null,2))}const newBody=_lodash2.default.merge({statusCode:500,errorCode:"5XX",message:"INTERNAL UTIL ERROR"},cleanedErrorBody);return buildResponse(newBody.statusCode,newBody)}
|
|
245
|
+
/**
|
|
246
|
+
* Create a failure response object
|
|
247
|
+
*
|
|
248
|
+
* @param statusCode {Number} a status code
|
|
249
|
+
* @param body {Object} an event object
|
|
250
|
+
* @returns {{statusCode:number, headers:object, body:string}} a response object
|
|
251
|
+
*/,exports.parseBody=
|
|
252
|
+
/**
|
|
253
|
+
* parse the body of the event object
|
|
254
|
+
*
|
|
255
|
+
* @param requestEvent {{body:string}} an event object
|
|
256
|
+
* @returns event {*} the json object of the body
|
|
257
|
+
*/
|
|
258
|
+
function parseBody(requestEvent){let eventBody={};if(_lodash2.default.isString(requestEvent.body))try{eventBody=JSON.parse(requestEvent.body)}catch(e){// Invalid JSON
|
|
259
|
+
throw eventBody=null,_errorCodes.errorList.invalidJson}else _lodash2.default.isObject(requestEvent.body)&&(eventBody=requestEvent.body);return eventBody}
|
|
260
|
+
/**
|
|
261
|
+
* parse the body of the event object
|
|
262
|
+
*
|
|
263
|
+
* @param requestEvent {string|object} an event object
|
|
264
|
+
* @param [callback] {function} undefined a call back function
|
|
265
|
+
* @returns event {*} the json object of the body
|
|
266
|
+
*/,exports.parseEvent=function parseEvent(requestEvent,callback){let event={};if(_lodash2.default.isString(requestEvent))try{event=JSON.parse(requestEvent)}catch(e){// Invalid JSON
|
|
267
|
+
event=null,callback&&callback(Error(e))}else _lodash2.default.isObject(requestEvent)&&(event=requestEvent);return event}
|
|
268
|
+
/**
|
|
269
|
+
* parse the body of the event object
|
|
270
|
+
* look for sequelize errors and return a message
|
|
271
|
+
* ERRORS should not be caught here this is a fallback for unknown database errors
|
|
272
|
+
*
|
|
273
|
+
* @param body {object} part of a body response
|
|
274
|
+
* @returns error message object {message:string}
|
|
275
|
+
*/,exports.detectSequelizeError=detectSequelizeError,exports.detectJoyError=detectJoyError,exports.detectDynamooseError=detectDynamooseError;var _lodash2=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(__webpack_require__(825)),_errorCodes=__webpack_require__(953);function buildResponse(statusCode,body){return{statusCode,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Credentials":!0},body:JSON.stringify(body)}}function detectSequelizeError(body){const errorBody={},errorName=_lodash2.default.get(body,"name","");if("SequelizeForeignKeyConstraintError"===errorName)return errorBody.message="You cannot delete this item as it is in use",errorBody.statusCode=409,errorBody.errorCode="4090",errorBody;if("SequelizeUniqueConstraintError"===errorName){const fields=_lodash2.default.get(body,"errors",[]).map(err=>_lodash2.default.get(err,"path")).filter(Boolean);return 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",errorBody}if("SequelizeValidationError"===errorName){const messages=_lodash2.default.get(body,"errors",[]).map(err=>_lodash2.default.get(err,"message")).filter(Boolean);return errorBody.message=messages.length?messages.join(", "):"Validation error",errorBody.statusCode=400,errorBody.errorCode="4001",errorBody}let sequelizeError=_lodash2.default.get(body,"errors",[]).reduce((acc,err)=>acc=acc+" "+_lodash2.default.get(err,"message"),"");const parentError=_lodash2.default.get(body,"parent","");return sequelizeError=sequelizeError+_lodash2.default.get(body,"original.detail","")+_lodash2.default.get(body,"TypeError","")+parentError,errorBody.message=sequelizeError.trim(),errorBody}function detectJoyError(body){const errorBody={},joyError=_lodash2.default.get(body,"details[0]",{}),v=(_lodash2.default.get(body,"details[0].context.details")||[]).reduce((acc,contextItem)=>acc=acc+" "+contextItem?.message||"","");console.error("USER VALIDATION ERROR:",body);const msg=(joyError?.message||"")+v;return msg&&(errorBody.message=_lodash2.default.trim(msg)),errorBody.statusCode=400,errorBody.errorCode="4000",errorBody}
|
|
276
|
+
/**
|
|
277
|
+
* Parse the body of a Dynamoose error response.
|
|
278
|
+
* Attempts to extract a human-readable error message from Dynamoose errors.
|
|
279
|
+
* This is a fallback for unknown database errors.
|
|
280
|
+
*
|
|
281
|
+
* @param {object} body - Part of a body response containing error details.
|
|
282
|
+
* @returns {object} - Error message object { message: string }
|
|
283
|
+
*/function detectDynamooseError(body){const errorBody={};// Start with an empty message string.
|
|
284
|
+
let dynamooseError="";// If the error body contains an array of errors, concatenate their messages.
|
|
285
|
+
return Array.isArray(body.errors)&&(dynamooseError+=body.errors.reduce((acc,err)=>acc+" "+(err.message||""),"")),// If there's a top-level message, add it.
|
|
286
|
+
body.message&&(dynamooseError+=" "+body.message),// If there is any additional detail provided, append it.
|
|
287
|
+
body.detail&&(dynamooseError+=" "+body.detail),// Trim the message to remove extra spaces.
|
|
288
|
+
errorBody.message=dynamooseError.trim(),errorBody}
|
|
289
|
+
/***/},
|
|
290
|
+
/***/908:
|
|
291
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0}),exports.s3Utils=s3Utils;var _clientS=__webpack_require__(43);function s3Utils(action,params){return(new _clientS.S3)[action](params)}const S3Util={getObject:params=>async function getS3(params){const s3=new _clientS.S3,response=await s3.getObject(params);return response?.Body.transformToString("utf-8")}
|
|
292
|
+
/***/(params),deleteObject:params=>s3Utils("deleteObject",params),putObject:params=>s3Utils("putObject",params),listObjectsV2:params=>s3Utils("listObjectsV2",params)};exports.default=S3Util},
|
|
293
|
+
/***/306:
|
|
294
|
+
/***/(__unused_webpack_module,exports,__webpack_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0});var _clientSns=__webpack_require__(793);const SNSUtil={publish:params=>async function publish(params){const sns=new _clientSns.SNS;return await sns.publish(params)}(params),createTopic:params=>async function createTopic(params){const sns=new _clientSns.SNS;return await sns.createTopic(params)}(params)};exports.default=SNSUtil},
|
|
295
|
+
/***/929:
|
|
296
|
+
/***/module=>{module.exports=require("@aws-sdk/client-dynamodb");
|
|
297
|
+
/***/},
|
|
298
|
+
/***/43:
|
|
299
|
+
/***/module=>{module.exports=require("@aws-sdk/client-s3");
|
|
300
|
+
/***/},
|
|
301
|
+
/***/793:
|
|
302
|
+
/***/module=>{module.exports=require("@aws-sdk/client-sns");
|
|
303
|
+
/***/},
|
|
304
|
+
/***/515:
|
|
305
|
+
/***/module=>{module.exports=require("@aws-sdk/lib-dynamodb");
|
|
306
|
+
/***/},
|
|
307
|
+
/***/564:
|
|
308
|
+
/***/module=>{module.exports=require("bluebird");
|
|
309
|
+
/***/},
|
|
310
|
+
/***/293:
|
|
311
|
+
/***/module=>{module.exports=require("dayjs");
|
|
312
|
+
/***/},
|
|
313
|
+
/***/59:
|
|
314
|
+
/***/module=>{module.exports=require("dayjs/plugin/customParseFormat");
|
|
315
|
+
/***/},
|
|
316
|
+
/***/394:
|
|
317
|
+
/***/module=>{module.exports=require("dayjs/plugin/isSameOrBefore");
|
|
318
|
+
/***/},
|
|
319
|
+
/***/137:
|
|
320
|
+
/***/module=>{module.exports=require("dayjs/plugin/utc.js");
|
|
321
|
+
/***/},
|
|
322
|
+
/***/825:
|
|
323
|
+
/***/module=>{module.exports=require("lodash");
|
|
324
|
+
/***/},
|
|
325
|
+
/***/31:
|
|
326
|
+
/***/module=>{module.exports=require("sequelize");
|
|
327
|
+
/***/},
|
|
328
|
+
/***/920:
|
|
329
|
+
/***/module=>{module.exports=require("umzug");
|
|
330
|
+
/***/}
|
|
331
|
+
/******/},__webpack_module_cache__={};
|
|
1002
332
|
/************************************************************************/
|
|
1003
|
-
|
|
333
|
+
/******/ // The module cache
|
|
334
|
+
/******/
|
|
335
|
+
/******/
|
|
336
|
+
/******/ // The require function
|
|
337
|
+
/******/function __webpack_require__(moduleId){
|
|
338
|
+
/******/ // Check if module is in cache
|
|
339
|
+
/******/var cachedModule=__webpack_module_cache__[moduleId];
|
|
340
|
+
/******/if(void 0!==cachedModule)
|
|
341
|
+
/******/return cachedModule.exports;
|
|
342
|
+
/******/
|
|
343
|
+
/******/ // Create a new module (and put it into the cache)
|
|
344
|
+
/******/var module=__webpack_module_cache__[moduleId]={
|
|
345
|
+
/******/ // no module.id needed
|
|
346
|
+
/******/ // no module.loaded needed
|
|
347
|
+
/******/exports:{}
|
|
348
|
+
/******/};
|
|
349
|
+
/******/
|
|
350
|
+
/******/ // Execute the module function
|
|
351
|
+
/******/
|
|
352
|
+
/******/
|
|
353
|
+
/******/ // Return the exports of the module
|
|
354
|
+
/******/return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports;
|
|
355
|
+
/******/}
|
|
356
|
+
/******/
|
|
357
|
+
/************************************************************************/var __webpack_exports__={};
|
|
1004
358
|
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
1005
|
-
(()
|
|
1006
|
-
|
|
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
|
-
;
|
|
359
|
+
(()=>{var exports=__webpack_exports__;Object.defineProperty(exports,"__esModule",{value:!0}),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=void 0;var _handleFile=__webpack_require__(876),_watchBucket=__webpack_require__(183),_publishEvents=__webpack_require__(864),_createIncludes=__webpack_require__(982),_createFilters=__webpack_require__(288),_createSort=__webpack_require__(835),_findAll=__webpack_require__(981),_accessRightsUtils=__webpack_require__(673),_requestResponse=__webpack_require__(859),_migrations=__webpack_require__(871),_defaultFilters=__webpack_require__(207);exports.handleFile=_handleFile.handleFile,exports.watchBucket=_watchBucket.watchBucket,exports.publishEvents=_publishEvents.publishEvents,exports.createFilters=_createFilters.createFilters,exports.createIncludes=_createIncludes.createIncludes,exports.createSort=_createSort.createSort,exports.findAll=_findAll.findAll,exports.checkModule=_accessRightsUtils.checkModule,exports.checkIsSuper=_accessRightsUtils.checkIsSuper,exports.getAccessRightsInfo=_accessRightsUtils.getAccessRightsInfo,exports.getDefaultBusinessIDInfo=_accessRightsUtils.getDefaultBusinessIDInfo,exports.getModuleInfo=_accessRightsUtils.getModuleInfo,exports.failure=_requestResponse.failure,exports.success=_requestResponse.success,exports.runMigrations=_migrations.runMigrations,exports.getCurrentUser=_requestResponse.getCurrentUser,exports.successHtml=_requestResponse.successHtml,exports.getCurrentUserNameFromCognitoEvent=_requestResponse.getCurrentUserNameFromCognitoEvent,exports.defaultFilters=_defaultFilters.defaultFilters,exports.accessRightsUtils=_accessRightsUtils.accessRightsUtils,exports.parseBody=_requestResponse.parseBody,exports.parseEvent=_requestResponse.parseEvent,exports.getBusinessesInfo=_accessRightsUtils.getBusinessesInfo,exports.userDefaultBid=_accessRightsUtils.userDefaultBid,exports.checkWriteAccess=_accessRightsUtils.checkWriteAccess,exports.isSystemUser=_accessRightsUtils.isSystemUser,exports.isSuperUser=_accessRightsUtils.isSuperUser})();var __webpack_export_target__=exports;for(var i in __webpack_exports__)__webpack_export_target__[i]=__webpack_exports__[i];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0})
|
|
360
|
+
/******/})();
|
|
1071
361
|
//# sourceMappingURL=main.js.map
|