@sdflc/backend-helpers 1.0.43 → 1.0.46
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
CHANGED
|
@@ -160,22 +160,29 @@ var BaseGateway = /** @class */ (function () {
|
|
|
160
160
|
};
|
|
161
161
|
BaseGateway.prototype.transformOnCreate = function (params) {
|
|
162
162
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion, hasLang, localizationForField;
|
|
163
|
+
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion, hasLang, localizationForField, hasUserId, createdBy, userId;
|
|
164
164
|
return __generator(this, function (_b) {
|
|
165
|
-
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
165
|
+
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField, hasUserId = _a.hasUserId;
|
|
166
166
|
if (hasCreatedAt) {
|
|
167
|
-
params[constants_1.FIELDS.CREATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
167
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.CREATED_AT)] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
168
168
|
}
|
|
169
169
|
if (hasCreatedBy) {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
createdBy = (0, lodash_1.camelCase)(constants_1.FIELDS.CREATED_BY);
|
|
171
|
+
if (params[createdBy] === undefined) {
|
|
172
|
+
params[createdBy] = this.getContext().userId;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (hasUserId) {
|
|
176
|
+
userId = (0, lodash_1.camelCase)(constants_1.FIELDS.USER_ID);
|
|
177
|
+
if (params[userId] === undefined) {
|
|
178
|
+
params[userId] = this.getContext().userId;
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
if (hasSpace) {
|
|
175
|
-
params[constants_1.FIELDS.SPACE_ID] = this.getContext().spaceId;
|
|
182
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.SPACE_ID)] = this.getContext().spaceId;
|
|
176
183
|
}
|
|
177
184
|
if (hasVersion) {
|
|
178
|
-
params[constants_1.FIELDS.VERSION] = 0;
|
|
185
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.VERSION)] = 0;
|
|
179
186
|
}
|
|
180
187
|
if (hasLang && localizationForField) {
|
|
181
188
|
params[this.getIdField()] = (0, utils_1.buildKey)([params[(0, lodash_1.camelCase)(localizationForField)], params[(0, lodash_1.camelCase)(constants_1.FIELDS.LANG)]]);
|
|
@@ -187,20 +194,22 @@ var BaseGateway = /** @class */ (function () {
|
|
|
187
194
|
// eslint-disable-next-line
|
|
188
195
|
BaseGateway.prototype.transformOnUpdate = function (params, where) {
|
|
189
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField;
|
|
197
|
+
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField, updatedBy, version;
|
|
191
198
|
return __generator(this, function (_b) {
|
|
192
199
|
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
193
200
|
if (hasUpdatedAt) {
|
|
194
|
-
params[constants_1.FIELDS.UPDATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
201
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_AT)] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
195
202
|
}
|
|
196
203
|
if (hasUpdatedBy) {
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
updatedBy = (0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_BY);
|
|
205
|
+
if (params[updatedBy] === undefined) {
|
|
206
|
+
params[updatedBy] = this.getContext().userId;
|
|
199
207
|
}
|
|
200
208
|
}
|
|
201
209
|
if (hasVersion) {
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
version = (0, lodash_1.camelCase)(constants_1.FIELDS.VERSION);
|
|
211
|
+
if (params[version] != null && !isNaN(params[version])) {
|
|
212
|
+
params[version] = params[version] + 1;
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
if (hasLang && localizationForField) {
|
|
@@ -212,34 +221,43 @@ var BaseGateway = /** @class */ (function () {
|
|
|
212
221
|
};
|
|
213
222
|
BaseGateway.prototype.transformOnSet = function (params) {
|
|
214
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
-
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField;
|
|
224
|
+
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField, hasUserId, createdBy, userId, updatedBy, version;
|
|
216
225
|
return __generator(this, function (_b) {
|
|
217
|
-
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
226
|
+
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField, hasUserId = _a.hasUserId;
|
|
218
227
|
if (hasCreatedAt) {
|
|
219
|
-
params[constants_1.FIELDS.CREATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
228
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.CREATED_AT)] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
220
229
|
}
|
|
221
230
|
if (hasCreatedBy) {
|
|
222
|
-
|
|
223
|
-
|
|
231
|
+
createdBy = (0, lodash_1.camelCase)(constants_1.FIELDS.CREATED_BY);
|
|
232
|
+
if (params[createdBy] === undefined) {
|
|
233
|
+
params[createdBy] = this.getContext().userId;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (hasUserId) {
|
|
237
|
+
userId = (0, lodash_1.camelCase)(constants_1.FIELDS.USER_ID);
|
|
238
|
+
if (params[userId] === undefined) {
|
|
239
|
+
params[userId] = this.getContext().userId;
|
|
224
240
|
}
|
|
225
241
|
}
|
|
226
242
|
if (hasSpace) {
|
|
227
|
-
params[constants_1.FIELDS.SPACE_ID] = this.getContext().spaceId;
|
|
243
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.SPACE_ID)] = this.getContext().spaceId;
|
|
228
244
|
}
|
|
229
245
|
if (hasUpdatedAt) {
|
|
230
|
-
params[constants_1.FIELDS.UPDATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
246
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_AT)] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
231
247
|
}
|
|
232
248
|
if (hasUpdatedBy) {
|
|
233
|
-
|
|
234
|
-
|
|
249
|
+
updatedBy = (0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_BY);
|
|
250
|
+
if (params[updatedBy] === undefined) {
|
|
251
|
+
params[updatedBy] = this.getContext().userId;
|
|
235
252
|
}
|
|
236
253
|
}
|
|
237
254
|
if (hasVersion) {
|
|
238
|
-
|
|
239
|
-
|
|
255
|
+
version = (0, lodash_1.camelCase)(constants_1.FIELDS.VERSION);
|
|
256
|
+
if (params[version] != null && !isNaN(params[version])) {
|
|
257
|
+
params[version] = params[version] + 1;
|
|
240
258
|
}
|
|
241
259
|
else {
|
|
242
|
-
params[
|
|
260
|
+
params[version] = 0;
|
|
243
261
|
}
|
|
244
262
|
}
|
|
245
263
|
if (hasLang && localizationForField) {
|
|
@@ -18,6 +18,7 @@ export interface BaseGatewayPropsInterface extends CacheInterface {
|
|
|
18
18
|
hasSpace?: boolean;
|
|
19
19
|
hasVersion?: boolean;
|
|
20
20
|
hasLang?: boolean;
|
|
21
|
+
hasUserId?: boolean;
|
|
21
22
|
localizationForField?: string;
|
|
22
23
|
defaultSorting?: SortItemInterface[];
|
|
23
24
|
fieldForKeyword?: string;
|
package/package.json
CHANGED