@sdflc/backend-helpers 1.0.35 → 1.0.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/build/BaseCore.js CHANGED
@@ -752,6 +752,9 @@ var BaseCore = /** @class */ (function () {
752
752
  switch (_a.label) {
753
753
  case 0:
754
754
  context = this.config.context;
755
+ if (context.space) {
756
+ return [2 /*return*/, [true, context.space]];
757
+ }
755
758
  space = null;
756
759
  if (!context.spaceGw) return [3 /*break*/, 2];
757
760
  if (!context.spaceId) {
@@ -204,19 +204,19 @@ var BaseGateway = /** @class */ (function () {
204
204
  return __generator(this, function (_b) {
205
205
  _a = this.config, hasRemovedAt = _a.hasRemovedAt, hasRemovedAtStr = _a.hasRemovedAtStr, hasStatus = _a.hasStatus, hasRemovedBy = _a.hasRemovedBy;
206
206
  removalTime = (0, dayjs_1.default)();
207
- obj = __assign({}, args);
207
+ obj = __assign({}, (args || {}));
208
208
  if (hasRemovedAt) {
209
209
  obj[constants_1.FIELDS.REMOVED_AT] = removalTime.toDate();
210
210
  }
211
211
  if (hasRemovedAtStr === true) {
212
212
  obj[constants_1.FIELDS.REMOVED_AT_STR] = removalTime.format('YYYYMMDDTHHmmssZ');
213
213
  }
214
- if (hasStatus === true) {
214
+ if (hasStatus) {
215
215
  obj[constants_1.FIELDS.STATUS] = utils_1.STATUSES.REMOVED;
216
216
  }
217
217
  if (hasRemovedBy) {
218
- if (args[constants_1.FIELDS.REMOVED_BY] === undefined) {
219
- args[constants_1.FIELDS.REMOVED_BY] = this.getContext().userId;
218
+ if (obj[constants_1.FIELDS.REMOVED_BY] === undefined) {
219
+ obj[constants_1.FIELDS.REMOVED_BY] = this.getContext().userId;
220
220
  }
221
221
  }
222
222
  return [2 /*return*/, obj];
@@ -132,7 +132,7 @@ var createContextDefault = function (args) { return __awaiter(void 0, void 0, vo
132
132
  ipAddress = req.headers[constants_1.HEADERS.IP_ADDRESS] || req.connection.remoteAddress;
133
133
  acceptLanguage = req.headers[constants_1.HEADERS.ACCEPT_LANGUAGE];
134
134
  languages = (0, utils_1.extractLanguages)(acceptLanguage);
135
- requestedLang = req.headers[constants_1.HEADERS.ACCEPT_LANGUAGE] || req.query[constants_1.HEADERS.ACCEPT_LANGUAGE];
135
+ requestedLang = req.headers[constants_1.HEADERS.REQUESTED_LANGUAGE] || (languages === null || languages === void 0 ? void 0 : languages[0]) || 'en';
136
136
  requestId = (0, uuid_1.v4)();
137
137
  db = new Database_1.Database({
138
138
  knexConfig: knexConfig,
@@ -160,11 +160,21 @@ var createContextDefault = function (args) { return __awaiter(void 0, void 0, vo
160
160
  requestId: requestId,
161
161
  extendContext: function (_a) {
162
162
  var context = _a.context, req = _a.req;
163
- context.db = db;
164
- Object.assign(context, sharedContext);
165
- if (typeof extendContext === 'function') {
166
- extendContext({ context: context, req: req });
167
- }
163
+ return __awaiter(void 0, void 0, void 0, function () {
164
+ return __generator(this, function (_b) {
165
+ switch (_b.label) {
166
+ case 0:
167
+ context.db = db;
168
+ Object.assign(context, sharedContext);
169
+ if (!(typeof extendContext === 'function')) return [3 /*break*/, 2];
170
+ return [4 /*yield*/, extendContext({ context: context, req: req })];
171
+ case 1:
172
+ _b.sent();
173
+ _b.label = 2;
174
+ case 2: return [2 /*return*/];
175
+ }
176
+ });
177
+ });
168
178
  },
169
179
  getCoreContext: function (args) { return __awaiter(void 0, void 0, void 0, function () {
170
180
  var extendCoreConext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.35",
3
+ "version": "1.0.38",
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",