@sdflc/backend-helpers 1.0.36 → 1.0.39
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) {
|
package/build/BaseGateway.js
CHANGED
|
@@ -155,9 +155,9 @@ var BaseGateway = /** @class */ (function () {
|
|
|
155
155
|
};
|
|
156
156
|
BaseGateway.prototype.transformOnCreate = function (args) {
|
|
157
157
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion;
|
|
158
|
+
var _a, hasCreatedAt, hasCreatedBy, hasSpace, hasVersion, hasLang, localizationForField;
|
|
159
159
|
return __generator(this, function (_b) {
|
|
160
|
-
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasVersion = _a.hasVersion;
|
|
160
|
+
_a = this.config, hasCreatedAt = _a.hasCreatedAt, hasCreatedBy = _a.hasCreatedBy, hasSpace = _a.hasSpace, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
161
161
|
if (hasCreatedAt) {
|
|
162
162
|
args[constants_1.FIELDS.CREATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
163
163
|
}
|
|
@@ -172,15 +172,18 @@ var BaseGateway = /** @class */ (function () {
|
|
|
172
172
|
if (hasVersion) {
|
|
173
173
|
args[constants_1.FIELDS.VERSION] = 0;
|
|
174
174
|
}
|
|
175
|
+
if (hasLang && localizationForField) {
|
|
176
|
+
args[constants_1.FIELDS.ID] = (0, utils_1.buildKey)([args[localizationForField], args[constants_1.FIELDS.LANG]]);
|
|
177
|
+
}
|
|
175
178
|
return [2 /*return*/, args];
|
|
176
179
|
});
|
|
177
180
|
});
|
|
178
181
|
};
|
|
179
182
|
BaseGateway.prototype.transformOnUpdate = function (params, where) {
|
|
180
183
|
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
-
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion;
|
|
184
|
+
var _a, hasUpdatedAt, hasUpdatedBy, hasVersion, hasLang, localizationForField;
|
|
182
185
|
return __generator(this, function (_b) {
|
|
183
|
-
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion;
|
|
186
|
+
_a = this.config, hasUpdatedAt = _a.hasUpdatedAt, hasUpdatedBy = _a.hasUpdatedBy, hasVersion = _a.hasVersion, hasLang = _a.hasLang, localizationForField = _a.localizationForField;
|
|
184
187
|
if (hasUpdatedAt) {
|
|
185
188
|
params[constants_1.FIELDS.UPDATED_AT] = this.dateTime.dbFormat(this.dateTimeNow);
|
|
186
189
|
}
|
|
@@ -194,6 +197,9 @@ var BaseGateway = /** @class */ (function () {
|
|
|
194
197
|
params[constants_1.FIELDS.VERSION] = params[constants_1.FIELDS.VERSION] + 1;
|
|
195
198
|
}
|
|
196
199
|
}
|
|
200
|
+
if (hasLang && localizationForField) {
|
|
201
|
+
params[constants_1.FIELDS.ID] = (0, utils_1.buildKey)([params[localizationForField], params[constants_1.FIELDS.LANG]]);
|
|
202
|
+
}
|
|
197
203
|
return [2 /*return*/, params];
|
|
198
204
|
});
|
|
199
205
|
});
|
|
@@ -204,19 +210,19 @@ var BaseGateway = /** @class */ (function () {
|
|
|
204
210
|
return __generator(this, function (_b) {
|
|
205
211
|
_a = this.config, hasRemovedAt = _a.hasRemovedAt, hasRemovedAtStr = _a.hasRemovedAtStr, hasStatus = _a.hasStatus, hasRemovedBy = _a.hasRemovedBy;
|
|
206
212
|
removalTime = (0, dayjs_1.default)();
|
|
207
|
-
obj = __assign({}, args);
|
|
213
|
+
obj = __assign({}, (args || {}));
|
|
208
214
|
if (hasRemovedAt) {
|
|
209
215
|
obj[constants_1.FIELDS.REMOVED_AT] = removalTime.toDate();
|
|
210
216
|
}
|
|
211
217
|
if (hasRemovedAtStr === true) {
|
|
212
218
|
obj[constants_1.FIELDS.REMOVED_AT_STR] = removalTime.format('YYYYMMDDTHHmmssZ');
|
|
213
219
|
}
|
|
214
|
-
if (hasStatus
|
|
220
|
+
if (hasStatus) {
|
|
215
221
|
obj[constants_1.FIELDS.STATUS] = utils_1.STATUSES.REMOVED;
|
|
216
222
|
}
|
|
217
223
|
if (hasRemovedBy) {
|
|
218
|
-
if (
|
|
219
|
-
|
|
224
|
+
if (obj[constants_1.FIELDS.REMOVED_BY] === undefined) {
|
|
225
|
+
obj[constants_1.FIELDS.REMOVED_BY] = this.getContext().userId;
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
return [2 /*return*/, obj];
|
package/build/apiContext.js
CHANGED
|
@@ -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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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;
|
|
@@ -17,6 +17,7 @@ export interface BaseGatewayPropsInterface extends CacheInterface {
|
|
|
17
17
|
hasSpace?: boolean;
|
|
18
18
|
hasVersion?: boolean;
|
|
19
19
|
hasLang?: boolean;
|
|
20
|
+
localizationForField: string;
|
|
20
21
|
defaultSorting?: SortItemInterface[];
|
|
21
22
|
fieldForKeyword?: string;
|
|
22
23
|
insertChunkSize?: number;
|
package/package.json
CHANGED