@sdflc/backend-helpers 1.0.34 → 1.0.35
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/build/BaseGateway.js +21 -7
- package/build/commonValidators.js +2 -2
- package/package.json +2 -2
package/build/BaseGateway.js
CHANGED
|
@@ -115,14 +115,17 @@ var BaseGateway = /** @class */ (function () {
|
|
|
115
115
|
BaseGateway.prototype.onUpdateFilter = function (query, filterParams) {
|
|
116
116
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
117
|
var _a, hasStatus, hasVersion, idName;
|
|
118
|
-
|
|
118
|
+
var _b;
|
|
119
|
+
return __generator(this, function (_c) {
|
|
119
120
|
_a = this.config, hasStatus = _a.hasStatus, hasVersion = _a.hasVersion;
|
|
120
121
|
idName = this.getIdField();
|
|
121
122
|
if (filterParams[idName]) {
|
|
122
123
|
query.where(idName, filterParams[idName]);
|
|
123
124
|
}
|
|
124
|
-
if (hasVersion
|
|
125
|
-
|
|
125
|
+
if (hasVersion) {
|
|
126
|
+
if (filterParams[constants_1.FIELDS.VERSION] != null && !isNaN(filterParams[constants_1.FIELDS.VERSION])) {
|
|
127
|
+
query.where((_b = {}, _b[constants_1.FIELDS.VERSION] = filterParams[constants_1.FIELDS.VERSION], _b));
|
|
128
|
+
}
|
|
126
129
|
}
|
|
127
130
|
if (hasStatus) {
|
|
128
131
|
if (Array.isArray(filterParams === null || filterParams === void 0 ? void 0 : filterParams[constants_1.FIELDS.STATUS])) {
|
|
@@ -152,9 +155,9 @@ var BaseGateway = /** @class */ (function () {
|
|
|
152
155
|
};
|
|
153
156
|
BaseGateway.prototype.transformOnCreate = function (args) {
|
|
154
157
|
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
-
var _a, hasCreatedAt, hasCreatedBy;
|
|
158
|
+
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion;
|
|
156
159
|
return __generator(this, function (_b) {
|
|
157
|
-
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy;
|
|
160
|
+
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasVersion = _a.hasVersion;
|
|
158
161
|
if (hasCreatedAt) {
|
|
159
162
|
args[constants_1.FIELDS.CREATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
160
163
|
}
|
|
@@ -163,15 +166,21 @@ var BaseGateway = /** @class */ (function () {
|
|
|
163
166
|
args[constants_1.FIELDS.CREATED_BY] = this.getContext().userId;
|
|
164
167
|
}
|
|
165
168
|
}
|
|
169
|
+
if (hasSpace) {
|
|
170
|
+
args[constants_1.FIELDS.SPACE_ID] = this.getContext().spaceId;
|
|
171
|
+
}
|
|
172
|
+
if (hasVersion) {
|
|
173
|
+
args[constants_1.FIELDS.VERSION] = 0;
|
|
174
|
+
}
|
|
166
175
|
return [2 /*return*/, args];
|
|
167
176
|
});
|
|
168
177
|
});
|
|
169
178
|
};
|
|
170
179
|
BaseGateway.prototype.transformOnUpdate = function (params, where) {
|
|
171
180
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
-
var _a, hasUpdatedAt, hasUpdatedBy;
|
|
181
|
+
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion;
|
|
173
182
|
return __generator(this, function (_b) {
|
|
174
|
-
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy;
|
|
183
|
+
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion;
|
|
175
184
|
if (hasUpdatedAt) {
|
|
176
185
|
params[constants_1.FIELDS.UPDATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
177
186
|
}
|
|
@@ -180,6 +189,11 @@ var BaseGateway = /** @class */ (function () {
|
|
|
180
189
|
params[constants_1.FIELDS.UPDATED_BY] = this.getContext().userId;
|
|
181
190
|
}
|
|
182
191
|
}
|
|
192
|
+
if (hasVersion) {
|
|
193
|
+
if (params[constants_1.FIELDS.VERSION] != null && !isNaN(params[constants_1.FIELDS.VERSION])) {
|
|
194
|
+
params[constants_1.FIELDS.VERSION] = params[constants_1.FIELDS.VERSION] + 1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
183
197
|
return [2 /*return*/, params];
|
|
184
198
|
});
|
|
185
199
|
});
|
|
@@ -84,7 +84,7 @@ var validateCreate = function (_a) {
|
|
|
84
84
|
return [2 /*return*/, [paramsCheck, {}]];
|
|
85
85
|
}
|
|
86
86
|
result = rules.validateSync(params)[0];
|
|
87
|
-
if (result
|
|
87
|
+
if (result) {
|
|
88
88
|
return [2 /*return*/, [(0, checkItHelpers_1.createErrorOnCheckError)(result), {}]];
|
|
89
89
|
}
|
|
90
90
|
return [2 /*return*/, [true, {}]];
|
|
@@ -107,7 +107,7 @@ var validateUpdate = function (_a) {
|
|
|
107
107
|
return [2 /*return*/, [paramsCheck, {}]];
|
|
108
108
|
}
|
|
109
109
|
result = rules.validateSync(params)[0];
|
|
110
|
-
if (result
|
|
110
|
+
if (result) {
|
|
111
111
|
return [2 /*return*/, [(0, checkItHelpers_1.createErrorOnCheckError)(result), {}]];
|
|
112
112
|
}
|
|
113
113
|
return [2 /*return*/, [true, {}]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdflc/backend-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
},
|
|
23
23
|
"author": "Sergey Demidenko",
|
|
24
24
|
"license": "ISC",
|
|
25
|
-
"peerDependencies": {},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"@types/bcrypt": "^5.0.0",
|
|
28
27
|
"@types/bluebird": "^3.5.36",
|
|
@@ -54,6 +53,7 @@
|
|
|
54
53
|
"@sdflc/utils": "^1.0.19",
|
|
55
54
|
"bcrypt": "^5.0.1",
|
|
56
55
|
"bluebird": "^3.7.2",
|
|
56
|
+
"checkit": "^0.7.0",
|
|
57
57
|
"dataloader": "^2.0.0",
|
|
58
58
|
"dayjs": "^1.10.7",
|
|
59
59
|
"dotenv-safe": "^8.2.0",
|