@sdflc/backend-helpers 1.0.44 → 1.0.47
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/BaseCore.js +1 -0
- package/build/BaseGateway.js +39 -26
- package/build/interfaces/ApiContext.d.ts +1 -0
- package/package.json +1 -1
package/build/BaseCore.js
CHANGED
|
@@ -804,6 +804,7 @@ var BaseCore = /** @class */ (function () {
|
|
|
804
804
|
context.roleId = token.roleId;
|
|
805
805
|
context.userId = token.userId;
|
|
806
806
|
context.spaceId = token.spaceId || context.spaceId;
|
|
807
|
+
context.lang = token.lang || context.requestedLang;
|
|
807
808
|
authByToken = true;
|
|
808
809
|
}
|
|
809
810
|
if (!authByToken) {
|
package/build/BaseGateway.js
CHANGED
|
@@ -160,27 +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, hasUserId;
|
|
163
|
+
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion, hasLang, localizationForField, hasUserId, createdBy, userId;
|
|
164
164
|
return __generator(this, function (_b) {
|
|
165
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;
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
if (hasUserId) {
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
userId = (0, lodash_1.camelCase)(constants_1.FIELDS.USER_ID);
|
|
177
|
+
if (params[userId] === undefined) {
|
|
178
|
+
params[userId] = this.getContext().userId;
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
if (hasSpace) {
|
|
180
|
-
params[constants_1.FIELDS.SPACE_ID] = this.getContext().spaceId;
|
|
182
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.SPACE_ID)] = this.getContext().spaceId;
|
|
181
183
|
}
|
|
182
184
|
if (hasVersion) {
|
|
183
|
-
params[constants_1.FIELDS.VERSION] = 0;
|
|
185
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.VERSION)] = 0;
|
|
184
186
|
}
|
|
185
187
|
if (hasLang && localizationForField) {
|
|
186
188
|
params[this.getIdField()] = (0, utils_1.buildKey)([params[(0, lodash_1.camelCase)(localizationForField)], params[(0, lodash_1.camelCase)(constants_1.FIELDS.LANG)]]);
|
|
@@ -192,20 +194,22 @@ var BaseGateway = /** @class */ (function () {
|
|
|
192
194
|
// eslint-disable-next-line
|
|
193
195
|
BaseGateway.prototype.transformOnUpdate = function (params, where) {
|
|
194
196
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField;
|
|
197
|
+
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField, updatedBy, version;
|
|
196
198
|
return __generator(this, function (_b) {
|
|
197
199
|
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
198
200
|
if (hasUpdatedAt) {
|
|
199
|
-
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);
|
|
200
202
|
}
|
|
201
203
|
if (hasUpdatedBy) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
updatedBy = (0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_BY);
|
|
205
|
+
if (params[updatedBy] === undefined) {
|
|
206
|
+
params[updatedBy] = this.getContext().userId;
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
if (hasVersion) {
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
version = (0, lodash_1.camelCase)(constants_1.FIELDS.VERSION);
|
|
211
|
+
if (params[version] != null && !isNaN(params[version])) {
|
|
212
|
+
params[version] = params[version] + 1;
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
if (hasLang && localizationForField) {
|
|
@@ -217,34 +221,43 @@ var BaseGateway = /** @class */ (function () {
|
|
|
217
221
|
};
|
|
218
222
|
BaseGateway.prototype.transformOnSet = function (params) {
|
|
219
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
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;
|
|
221
225
|
return __generator(this, function (_b) {
|
|
222
|
-
_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;
|
|
223
227
|
if (hasCreatedAt) {
|
|
224
|
-
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);
|
|
225
229
|
}
|
|
226
230
|
if (hasCreatedBy) {
|
|
227
|
-
|
|
228
|
-
|
|
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;
|
|
229
240
|
}
|
|
230
241
|
}
|
|
231
242
|
if (hasSpace) {
|
|
232
|
-
params[constants_1.FIELDS.SPACE_ID] = this.getContext().spaceId;
|
|
243
|
+
params[(0, lodash_1.camelCase)(constants_1.FIELDS.SPACE_ID)] = this.getContext().spaceId;
|
|
233
244
|
}
|
|
234
245
|
if (hasUpdatedAt) {
|
|
235
|
-
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);
|
|
236
247
|
}
|
|
237
248
|
if (hasUpdatedBy) {
|
|
238
|
-
|
|
239
|
-
|
|
249
|
+
updatedBy = (0, lodash_1.camelCase)(constants_1.FIELDS.UPDATED_BY);
|
|
250
|
+
if (params[updatedBy] === undefined) {
|
|
251
|
+
params[updatedBy] = this.getContext().userId;
|
|
240
252
|
}
|
|
241
253
|
}
|
|
242
254
|
if (hasVersion) {
|
|
243
|
-
|
|
244
|
-
|
|
255
|
+
version = (0, lodash_1.camelCase)(constants_1.FIELDS.VERSION);
|
|
256
|
+
if (params[version] != null && !isNaN(params[version])) {
|
|
257
|
+
params[version] = params[version] + 1;
|
|
245
258
|
}
|
|
246
259
|
else {
|
|
247
|
-
params[
|
|
260
|
+
params[version] = 0;
|
|
248
261
|
}
|
|
249
262
|
}
|
|
250
263
|
if (hasLang && localizationForField) {
|
package/package.json
CHANGED