remult 0.26.21 → 0.26.23-next.0
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/SseSubscriptionServer.d.ts +3 -4
- package/assign.js +1 -2
- package/esm/graphql.js +1 -1
- package/esm/remult-hono.js +3 -1
- package/esm/remult-knex/index.js +3 -1
- package/esm/remult-sqlite3.js +4 -1
- package/esm/remult-sveltekit.js +1 -0
- package/esm/server/index.js +3 -2
- package/esm/server/initAsyncHooks.js +3 -3
- package/esm/server/remult-admin.js +1 -4
- package/esm/server/remult-api-server.js +47 -48
- package/esm/src/CompoundIdField.js +9 -9
- package/esm/src/data-api.js +1 -1
- package/esm/src/data-providers/json-entity-opfs-storage.js +9 -5
- package/esm/src/data-providers/sql-database.js +9 -9
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +3 -1
- package/esm/src/live-query/LiveQueryClient.js +0 -1
- package/esm/src/remult-proxy.js +1 -3
- package/esm/src/remult-static.js +1 -0
- package/esm/src/remult3/Fields.js +4 -3
- package/esm/src/remult3/RepositoryImplementation.js +143 -104
- package/esm/src/remult3/entity.js +1 -1
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/remult3.js +9 -0
- package/esm/src/server-action.js +16 -12
- package/esm/src/sort.js +0 -2
- package/esm/src/validators.js +3 -3
- package/esm/src/valueConverters.js +2 -2
- package/graphql.js +3 -4
- package/index.js +2 -2
- package/live-query/data-provider-live-query-storage.js +6 -6
- package/migrations/compare-migration-snapshots.js +48 -49
- package/migrations/generate-migrations.js +1 -2
- package/migrations/migrate.js +2 -3
- package/migrations/migration-types.d.ts +1 -1
- package/migrations/migration-types.js +4 -4
- package/migrations/update-migrations-ts-file.js +1 -2
- package/myLog.js +1 -2
- package/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +2 -2
- package/postgres/postgres-data-provider.js +5 -5
- package/postgres/schema-builder.js +3 -3
- package/remult-express.js +4 -3
- package/remult-fastify.js +4 -3
- package/remult-fresh.js +1 -2
- package/remult-hapi.js +4 -3
- package/remult-hono.js +6 -3
- package/remult-knex/index.d.ts +1 -1
- package/remult-knex/index.js +7 -5
- package/remult-mongo.d.ts +1 -1
- package/remult-next.d.ts +4 -5
- package/remult-next.js +11 -6
- package/remult-nuxt.js +1 -2
- package/remult-solid-start.js +1 -2
- package/remult-sqlite3.js +4 -1
- package/remult-sveltekit.js +33 -35
- package/server/JsonEntityFileStorage.d.ts +1 -1
- package/server/get-remult-admin-html.js +1 -2
- package/server/index.d.ts +1 -1
- package/server/index.js +4 -3
- package/server/initAsyncHooks.d.ts +10 -10
- package/server/initAsyncHooks.js +5 -2
- package/server/initDataProvider.js +1 -2
- package/server/initDataProviderOrJson.js +1 -2
- package/server/remult-admin.js +3 -7
- package/server/remult-api-server.d.ts +22 -22
- package/server/remult-api-server.js +54 -48
- package/src/CompoundIdField.d.ts +1 -1
- package/src/CompoundIdField.js +9 -0
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +8 -8
- package/src/column-interfaces.d.ts +8 -8
- package/src/column-interfaces.js +1 -2
- package/src/column.d.ts +4 -4
- package/src/column.js +2 -2
- package/src/context.d.ts +4 -4
- package/src/context.js +5 -5
- package/src/data-api.d.ts +2 -2
- package/src/data-api.js +4 -4
- package/src/data-interfaces.js +1 -2
- package/src/data-providers/json-entity-opfs-storage.js +30 -16
- package/src/data-providers/rest-data-provider.d.ts +3 -3
- package/src/data-providers/rest-data-provider.js +4 -4
- package/src/data-providers/sql-database.js +11 -11
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.js +21 -19
- package/src/filter/filter-interfaces.d.ts +1 -1
- package/src/filter/filter-interfaces.js +10 -6
- package/src/isOfType.js +2 -3
- package/src/live-query/SubscriptionServer.js +95 -97
- package/src/remult-proxy.js +1 -3
- package/src/remult-static.d.ts +2 -2
- package/src/remult-static.js +7 -4
- package/src/remult3/Fields.d.ts +2 -2
- package/src/remult3/Fields.js +11 -9
- package/src/remult3/RepositoryImplementation.d.ts +41 -39
- package/src/remult3/RepositoryImplementation.js +416 -365
- package/src/remult3/__updateEntityBasedOnWhere.js +1 -2
- package/src/remult3/addValidator.d.ts +1 -1
- package/src/remult3/addValidator.js +1 -2
- package/src/remult3/classDescribers.d.ts +3 -3
- package/src/remult3/classDescribers.js +3 -4
- package/src/remult3/entity.js +2 -4
- package/src/remult3/getEntityRef.js +4 -4
- package/src/remult3/relation-loader.d.ts +1 -1
- package/src/remult3/relationInfoMember.d.ts +2 -2
- package/src/remult3/relationInfoMember.js +4 -5
- package/src/remult3/remult3.d.ts +13 -10
- package/src/remult3/remult3.js +9 -0
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/remult3/repository-internals.js +2 -2
- package/src/server-action.d.ts +1 -1
- package/src/server-action.js +65 -58
- package/src/sort.d.ts +1 -1
- package/src/sort.js +0 -2
- package/src/sql-command.d.ts +1 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +13 -11
- package/src/valueConverters.js +3 -2
package/src/server-action.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.classBackendMethodsArray = exports.
|
|
3
|
+
exports.classBackendMethodsArray = exports.ProgressListener = exports.myServerAction = exports.ForbiddenError = exports.Action = void 0;
|
|
4
|
+
exports.Controller = Controller;
|
|
5
|
+
exports.BackendMethod = BackendMethod;
|
|
6
|
+
exports.prepareArgsToSend = prepareArgsToSend;
|
|
7
|
+
exports.prepareReceivedArgs = prepareReceivedArgs;
|
|
4
8
|
var tslib_1 = require("tslib");
|
|
5
9
|
require("reflect-metadata");
|
|
6
10
|
var buildRestDataProvider_js_1 = require("./buildRestDataProvider.js");
|
|
@@ -123,7 +127,8 @@ exports.ForbiddenError = ForbiddenError;
|
|
|
123
127
|
var myServerAction = /** @class */ (function (_super) {
|
|
124
128
|
tslib_1.__extends(myServerAction, _super);
|
|
125
129
|
function myServerAction(name, types, options, originalMethod) {
|
|
126
|
-
var
|
|
130
|
+
var _a;
|
|
131
|
+
var _this = _super.call(this, name, (_a = options.queue) !== null && _a !== void 0 ? _a : false, options.allowed) || this;
|
|
127
132
|
_this.types = types;
|
|
128
133
|
_this.options = options;
|
|
129
134
|
_this.originalMethod = originalMethod;
|
|
@@ -183,7 +188,6 @@ function Controller(key) {
|
|
|
183
188
|
return target;
|
|
184
189
|
};
|
|
185
190
|
}
|
|
186
|
-
exports.Controller = Controller;
|
|
187
191
|
/** Indicates that the decorated methods runs on the backend. See: [Backend Methods](https://remult.dev/docs/backendMethods.html) */
|
|
188
192
|
function BackendMethod(options) {
|
|
189
193
|
var _this = this;
|
|
@@ -237,7 +241,9 @@ function BackendMethod(options) {
|
|
|
237
241
|
if (!!(0, context_js_1.isBackend)()) return [3 /*break*/, 2];
|
|
238
242
|
return [4 /*yield*/, serverAction_1.doWork(args, undefined)];
|
|
239
243
|
case 1: return [2 /*return*/, _a.sent()];
|
|
240
|
-
case 2: return [4 /*yield*/, originalMethod.apply(
|
|
244
|
+
case 2: return [4 /*yield*/, originalMethod.apply(
|
|
245
|
+
//@ts-expect-error I specifically referred to the this of the original function - so it'll be sent inside
|
|
246
|
+
this, args)];
|
|
241
247
|
case 3: return [2 /*return*/, _a.sent()];
|
|
242
248
|
}
|
|
243
249
|
});
|
|
@@ -261,6 +267,7 @@ function BackendMethod(options) {
|
|
|
261
267
|
__register: function (reg) {
|
|
262
268
|
var e_1, _a;
|
|
263
269
|
var _this = this;
|
|
270
|
+
var _b;
|
|
264
271
|
var c = new context_js_1.Remult();
|
|
265
272
|
var _loop_1 = function (constructor) {
|
|
266
273
|
var controllerOptions = x.classes.get(constructor);
|
|
@@ -270,7 +277,7 @@ function BackendMethod(options) {
|
|
|
270
277
|
reg(controllerOptions.key +
|
|
271
278
|
'/' +
|
|
272
279
|
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
273
|
-
key, options ? options.queue : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
280
|
+
key, options ? (_b = options.queue) !== null && _b !== void 0 ? _b : false : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
274
281
|
var allowed, remult_1, r_1, err_3;
|
|
275
282
|
var _this = this;
|
|
276
283
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -283,55 +290,57 @@ function BackendMethod(options) {
|
|
|
283
290
|
_a.trys.push([1, 3, , 4]);
|
|
284
291
|
remult_1 = req;
|
|
285
292
|
return [4 /*yield*/, (0, context_js_1.doTransaction)(remult_1, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
286
|
-
var _a, repo, y, rowHelper, rows, defs, err_4, y, controllerRef, err_5;
|
|
293
|
+
var _a, repo, y, rowInfo, rowHelper, rows, defs, err_4, y, controllerRef, err_5;
|
|
287
294
|
var _b, _c, _d;
|
|
288
|
-
|
|
289
|
-
|
|
295
|
+
var _e;
|
|
296
|
+
return tslib_1.__generator(this, function (_f) {
|
|
297
|
+
switch (_f.label) {
|
|
290
298
|
case 0:
|
|
291
299
|
_a = d;
|
|
292
300
|
return [4 /*yield*/, prepareReceivedArgs(getTypes(), d.args, remult_1, remult_1.dataProvider, res)];
|
|
293
301
|
case 1:
|
|
294
|
-
_a.args =
|
|
302
|
+
_a.args = _f.sent();
|
|
295
303
|
if (!remult_static_js_1.remultStatic.allEntities.includes(constructor)) return [3 /*break*/, 13];
|
|
296
304
|
repo = remult_1.repo(constructor);
|
|
297
305
|
y = void 0;
|
|
298
|
-
|
|
306
|
+
rowInfo = d.rowInfo;
|
|
307
|
+
if (!rowInfo.isNewRow) return [3 /*break*/, 3];
|
|
299
308
|
y = repo.create();
|
|
300
309
|
rowHelper = repo.getEntityRef(y);
|
|
301
|
-
return [4 /*yield*/, rowHelper._updateEntityBasedOnApi(
|
|
310
|
+
return [4 /*yield*/, rowHelper._updateEntityBasedOnApi(rowInfo.data)];
|
|
302
311
|
case 2:
|
|
303
|
-
|
|
312
|
+
_f.sent();
|
|
304
313
|
return [3 /*break*/, 6];
|
|
305
314
|
case 3: return [4 /*yield*/, repo.find({
|
|
306
|
-
where: tslib_1.__assign(tslib_1.__assign({}, repo.metadata.idMetadata.getIdFilter(
|
|
315
|
+
where: tslib_1.__assign(tslib_1.__assign({}, repo.metadata.idMetadata.getIdFilter(rowInfo.id)), { $and: [(_e = repo.metadata.options.apiPrefilter) !== null && _e !== void 0 ? _e : {}] }),
|
|
307
316
|
})];
|
|
308
317
|
case 4:
|
|
309
|
-
rows =
|
|
318
|
+
rows = _f.sent();
|
|
310
319
|
if (rows.length != 1)
|
|
311
320
|
throw new Error('not found or too many matches');
|
|
312
321
|
y = rows[0];
|
|
313
|
-
return [4 /*yield*/, repo.getEntityRef(y)._updateEntityBasedOnApi(
|
|
322
|
+
return [4 /*yield*/, repo.getEntityRef(y)._updateEntityBasedOnApi(rowInfo.data)];
|
|
314
323
|
case 5:
|
|
315
|
-
|
|
316
|
-
|
|
324
|
+
_f.sent();
|
|
325
|
+
_f.label = 6;
|
|
317
326
|
case 6:
|
|
318
327
|
if (!remult_1.isAllowedForInstance(y, allowed))
|
|
319
328
|
throw new ForbiddenError();
|
|
320
329
|
defs = (0, getEntityRef_js_1.getEntityRef)(y);
|
|
321
330
|
return [4 /*yield*/, defs.__validateEntity()];
|
|
322
331
|
case 7:
|
|
323
|
-
|
|
324
|
-
|
|
332
|
+
_f.sent();
|
|
333
|
+
_f.label = 8;
|
|
325
334
|
case 8:
|
|
326
|
-
|
|
335
|
+
_f.trys.push([8, 11, , 12]);
|
|
327
336
|
_b = {};
|
|
328
337
|
return [4 /*yield*/, originalMethod.apply(y, d.args)];
|
|
329
338
|
case 9:
|
|
330
|
-
_b.result =
|
|
339
|
+
_b.result = _f.sent();
|
|
331
340
|
_c = {};
|
|
332
341
|
return [4 /*yield*/, defs.toApiJson()];
|
|
333
342
|
case 10:
|
|
334
|
-
r_1 = (_b.rowInfo = (_c.data =
|
|
343
|
+
r_1 = (_b.rowInfo = (_c.data = _f.sent(),
|
|
335
344
|
_c.isNewRow = defs.isNew(),
|
|
336
345
|
_c.wasChanged = defs.wasChanged(),
|
|
337
346
|
_c.id = defs.getOriginalId(),
|
|
@@ -339,7 +348,7 @@ function BackendMethod(options) {
|
|
|
339
348
|
_b);
|
|
340
349
|
return [3 /*break*/, 12];
|
|
341
350
|
case 11:
|
|
342
|
-
err_4 =
|
|
351
|
+
err_4 = _f.sent();
|
|
343
352
|
throw defs.catchSaveErrors(err_4);
|
|
344
353
|
case 12: return [3 /*break*/, 20];
|
|
345
354
|
case 13:
|
|
@@ -347,26 +356,26 @@ function BackendMethod(options) {
|
|
|
347
356
|
controllerRef = (0, RepositoryImplementation_js_1.getControllerRef)(y, remult_1);
|
|
348
357
|
return [4 /*yield*/, controllerRef._updateEntityBasedOnApi(d.fields)];
|
|
349
358
|
case 14:
|
|
350
|
-
|
|
359
|
+
_f.sent();
|
|
351
360
|
if (!remult_1.isAllowedForInstance(y, allowed))
|
|
352
361
|
throw new ForbiddenError();
|
|
353
362
|
return [4 /*yield*/, controllerRef.__validateEntity()];
|
|
354
363
|
case 15:
|
|
355
|
-
|
|
356
|
-
|
|
364
|
+
_f.sent();
|
|
365
|
+
_f.label = 16;
|
|
357
366
|
case 16:
|
|
358
|
-
|
|
367
|
+
_f.trys.push([16, 19, , 20]);
|
|
359
368
|
_d = {};
|
|
360
369
|
return [4 /*yield*/, originalMethod.apply(y, d.args)];
|
|
361
370
|
case 17:
|
|
362
|
-
_d.result =
|
|
371
|
+
_d.result = _f.sent();
|
|
363
372
|
return [4 /*yield*/, controllerRef.toApiJson()];
|
|
364
373
|
case 18:
|
|
365
|
-
r_1 = (_d.fields =
|
|
374
|
+
r_1 = (_d.fields = _f.sent(),
|
|
366
375
|
_d);
|
|
367
376
|
return [3 /*break*/, 20];
|
|
368
377
|
case 19:
|
|
369
|
-
err_5 =
|
|
378
|
+
err_5 = _f.sent();
|
|
370
379
|
throw controllerRef.catchSaveErrors(err_5);
|
|
371
380
|
case 20: return [2 /*return*/];
|
|
372
381
|
}
|
|
@@ -390,15 +399,15 @@ function BackendMethod(options) {
|
|
|
390
399
|
}); });
|
|
391
400
|
};
|
|
392
401
|
try {
|
|
393
|
-
for (var
|
|
394
|
-
var constructor =
|
|
402
|
+
for (var _c = tslib_1.__values(x.classes.keys()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
403
|
+
var constructor = _d.value;
|
|
395
404
|
_loop_1(constructor);
|
|
396
405
|
}
|
|
397
406
|
}
|
|
398
407
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
399
408
|
finally {
|
|
400
409
|
try {
|
|
401
|
-
if (
|
|
410
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
402
411
|
}
|
|
403
412
|
finally { if (e_1) throw e_1.error; }
|
|
404
413
|
}
|
|
@@ -407,22 +416,23 @@ function BackendMethod(options) {
|
|
|
407
416
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
408
417
|
var defs, classOptions_1, r, _a, _b, err_6, defs, r, _c, _d, e_2;
|
|
409
418
|
var _e, _f, _g;
|
|
410
|
-
|
|
411
|
-
|
|
419
|
+
var _h, _j;
|
|
420
|
+
return tslib_1.__generator(this, function (_k) {
|
|
421
|
+
switch (_k.label) {
|
|
412
422
|
case 0:
|
|
413
423
|
args = prepareArgsToSend(getTypes(), args);
|
|
414
424
|
if (!remult_static_js_1.remultStatic.allEntities.includes(target.constructor)) return [3 /*break*/, 8];
|
|
415
425
|
defs = (0, getEntityRef_js_1.getEntityRef)(self);
|
|
416
426
|
return [4 /*yield*/, defs.__validateEntity()];
|
|
417
427
|
case 1:
|
|
418
|
-
|
|
428
|
+
_k.sent();
|
|
419
429
|
classOptions_1 = x.classes.get(self.constructor);
|
|
420
430
|
if (!classOptions_1.key) {
|
|
421
431
|
classOptions_1.key = defs.repository.metadata.key + '_methods';
|
|
422
432
|
}
|
|
423
|
-
|
|
433
|
+
_k.label = 2;
|
|
424
434
|
case 2:
|
|
425
|
-
|
|
435
|
+
_k.trys.push([2, 6, , 7]);
|
|
426
436
|
_b = (_a = new (/** @class */ (function (_super) {
|
|
427
437
|
tslib_1.__extends(class_1, _super);
|
|
428
438
|
function class_1() {
|
|
@@ -432,13 +442,13 @@ function BackendMethod(options) {
|
|
|
432
442
|
}(Action)))(classOptions_1.key +
|
|
433
443
|
'/' +
|
|
434
444
|
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
435
|
-
key, options ? options.queue : false, options.allowed)).run;
|
|
445
|
+
key, (_h = options === null || options === void 0 ? void 0 : options.queue) !== null && _h !== void 0 ? _h : false, options.allowed)).run;
|
|
436
446
|
_e = {
|
|
437
447
|
args: args
|
|
438
448
|
};
|
|
439
449
|
_f = {};
|
|
440
450
|
return [4 /*yield*/, defs.toApiJson()];
|
|
441
|
-
case 3: return [4 /*yield*/, _b.apply(_a, [(_e.rowInfo = (_f.data =
|
|
451
|
+
case 3: return [4 /*yield*/, _b.apply(_a, [(_e.rowInfo = (_f.data = _k.sent(),
|
|
442
452
|
_f.isNewRow = defs.isNew(),
|
|
443
453
|
_f.wasChanged = defs.wasChanged(),
|
|
444
454
|
_f.id = defs.getOriginalId(),
|
|
@@ -446,23 +456,23 @@ function BackendMethod(options) {
|
|
|
446
456
|
_e), baseUrl,
|
|
447
457
|
http])];
|
|
448
458
|
case 4:
|
|
449
|
-
r =
|
|
459
|
+
r = _k.sent();
|
|
450
460
|
return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data, true)];
|
|
451
461
|
case 5:
|
|
452
|
-
|
|
462
|
+
_k.sent();
|
|
453
463
|
return [2 /*return*/, r.result];
|
|
454
464
|
case 6:
|
|
455
|
-
err_6 =
|
|
465
|
+
err_6 = _k.sent();
|
|
456
466
|
throw defs.catchSaveErrors(err_6);
|
|
457
467
|
case 7: return [3 /*break*/, 15];
|
|
458
468
|
case 8:
|
|
459
469
|
defs = (0, RepositoryImplementation_js_1.getControllerRef)(self, undefined);
|
|
460
|
-
|
|
470
|
+
_k.label = 9;
|
|
461
471
|
case 9:
|
|
462
|
-
|
|
472
|
+
_k.trys.push([9, 14, , 15]);
|
|
463
473
|
return [4 /*yield*/, defs.__validateEntity()];
|
|
464
474
|
case 10:
|
|
465
|
-
|
|
475
|
+
_k.sent();
|
|
466
476
|
_d = (_c = new (/** @class */ (function (_super) {
|
|
467
477
|
tslib_1.__extends(class_2, _super);
|
|
468
478
|
function class_2() {
|
|
@@ -472,22 +482,22 @@ function BackendMethod(options) {
|
|
|
472
482
|
}(Action)))(x.classes.get(self.constructor).key +
|
|
473
483
|
'/' +
|
|
474
484
|
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
475
|
-
key, options ? options.queue : false, options.allowed)).run;
|
|
485
|
+
key, (_j = options === null || options === void 0 ? void 0 : options.queue) !== null && _j !== void 0 ? _j : false, options.allowed)).run;
|
|
476
486
|
_g = {
|
|
477
487
|
args: args
|
|
478
488
|
};
|
|
479
489
|
return [4 /*yield*/, defs.toApiJson()];
|
|
480
|
-
case 11: return [4 /*yield*/, _d.apply(_c, [(_g.fields =
|
|
490
|
+
case 11: return [4 /*yield*/, _d.apply(_c, [(_g.fields = _k.sent(),
|
|
481
491
|
_g), baseUrl,
|
|
482
492
|
http])];
|
|
483
493
|
case 12:
|
|
484
|
-
r =
|
|
494
|
+
r = _k.sent();
|
|
485
495
|
return [4 /*yield*/, defs._updateEntityBasedOnApi(r.fields)];
|
|
486
496
|
case 13:
|
|
487
|
-
|
|
497
|
+
_k.sent();
|
|
488
498
|
return [2 /*return*/, r.result];
|
|
489
499
|
case 14:
|
|
490
|
-
e_2 =
|
|
500
|
+
e_2 = _k.sent();
|
|
491
501
|
throw defs.catchSaveErrors(e_2);
|
|
492
502
|
case 15: return [2 /*return*/];
|
|
493
503
|
}
|
|
@@ -501,14 +511,14 @@ function BackendMethod(options) {
|
|
|
501
511
|
args[_i] = arguments[_i];
|
|
502
512
|
}
|
|
503
513
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
504
|
-
var
|
|
514
|
+
var self;
|
|
505
515
|
return tslib_1.__generator(this, function (_a) {
|
|
506
516
|
switch (_a.label) {
|
|
507
517
|
case 0:
|
|
518
|
+
self = this;
|
|
508
519
|
if (!!(0, context_js_1.isBackend)()) return [3 /*break*/, 1];
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
case 1: return [4 /*yield*/, originalMethod.apply(this, args)];
|
|
520
|
+
return [2 /*return*/, serverAction.doWork(args, self)];
|
|
521
|
+
case 1: return [4 /*yield*/, originalMethod.apply(self, args)];
|
|
512
522
|
case 2: return [2 /*return*/, _a.sent()];
|
|
513
523
|
}
|
|
514
524
|
});
|
|
@@ -524,7 +534,6 @@ function BackendMethod(options) {
|
|
|
524
534
|
return result;
|
|
525
535
|
};
|
|
526
536
|
}
|
|
527
|
-
exports.BackendMethod = BackendMethod;
|
|
528
537
|
var customUndefined = {
|
|
529
538
|
_isUndefined: true,
|
|
530
539
|
};
|
|
@@ -583,7 +592,6 @@ function prepareArgsToSend(types, args) {
|
|
|
583
592
|
}
|
|
584
593
|
return args.map(function (x) { return (x !== undefined ? x : customUndefined); });
|
|
585
594
|
}
|
|
586
|
-
exports.prepareArgsToSend = prepareArgsToSend;
|
|
587
595
|
function prepareReceivedArgs(types, args, remult, ds, res) {
|
|
588
596
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
589
597
|
var index, element, i, x, eo, _a, _b;
|
|
@@ -636,5 +644,4 @@ function prepareReceivedArgs(types, args, remult, ds, res) {
|
|
|
636
644
|
});
|
|
637
645
|
});
|
|
638
646
|
}
|
|
639
|
-
exports.prepareReceivedArgs = prepareReceivedArgs;
|
|
640
647
|
exports.classBackendMethodsArray = Symbol.for('classBackendMethodsArray');
|
package/src/sort.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare class Sort {
|
|
|
46
46
|
* @param {EntityOrderBy<T>} [orderBy] The `EntityOrderBy` to be translated.
|
|
47
47
|
* @returns {Sort} A `Sort` instance representing the translated order by.
|
|
48
48
|
*/
|
|
49
|
-
static translateOrderByToSort<T>(entityDefs: EntityMetadata<T>, orderBy
|
|
49
|
+
static translateOrderByToSort<T>(entityDefs: EntityMetadata<T>, orderBy: EntityOrderBy<T>): Sort;
|
|
50
50
|
/**
|
|
51
51
|
* Creates a unique `Sort` instance based on the provided `Sort` and the entity metadata.
|
|
52
52
|
* This ensures that the sort criteria result in a unique ordering of entities.
|
package/src/sort.js
CHANGED
|
@@ -107,8 +107,6 @@ var Sort = /** @class */ (function () {
|
|
|
107
107
|
* @returns {Sort} A `Sort` instance representing the translated order by.
|
|
108
108
|
*/
|
|
109
109
|
Sort.translateOrderByToSort = function (entityDefs, orderBy) {
|
|
110
|
-
if (!orderBy)
|
|
111
|
-
return undefined;
|
|
112
110
|
var sort = new Sort();
|
|
113
111
|
if (orderBy) {
|
|
114
112
|
var _loop_1 = function (key) {
|
package/src/sql-command.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntityMetadata } from './remult3/remult3.js';
|
|
2
2
|
export interface SqlImplementation extends HasWrapIdentifier {
|
|
3
|
-
getLimitSqlSyntax(limit: number, offset: number):
|
|
3
|
+
getLimitSqlSyntax(limit: number, offset: number): string;
|
|
4
4
|
createCommand(): SqlCommand;
|
|
5
5
|
transaction(action: (sql: SqlImplementation) => Promise<void>): Promise<void>;
|
|
6
6
|
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
|
package/src/validators.d.ts
CHANGED
|
@@ -47,4 +47,4 @@ export type ValidatorWithArgs<valueType, argsType> = (args: argsType, message?:
|
|
|
47
47
|
export declare function createValidatorWithArgs<valueType, argsType>(validate: (entity: any, e: ValidateFieldEvent<any, valueType>, args: argsType) => Promise<boolean | string> | boolean | string, defaultMessage: ValidationMessage<valueType, argsType>): ValidatorWithArgs<valueType, argsType> & {
|
|
48
48
|
defaultMessage: ValidationMessage<valueType, argsType>;
|
|
49
49
|
};
|
|
50
|
-
export declare function getEnumValues<theEnum
|
|
50
|
+
export declare function getEnumValues<theEnum extends object>(enumObj: theEnum): any[];
|
package/src/validators.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Validators = void 0;
|
|
4
|
+
exports.createValidator = createValidator;
|
|
5
|
+
exports.valueValidator = valueValidator;
|
|
6
|
+
exports.createValueValidator = createValueValidator;
|
|
7
|
+
exports.createValueValidatorWithArgs = createValueValidatorWithArgs;
|
|
8
|
+
exports.createValidatorWithArgs = createValidatorWithArgs;
|
|
9
|
+
exports.getEnumValues = getEnumValues;
|
|
4
10
|
var tslib_1 = require("tslib");
|
|
5
11
|
var Validators = /** @class */ (function () {
|
|
6
12
|
function Validators() {
|
|
@@ -52,15 +58,17 @@ var Validators = /** @class */ (function () {
|
|
|
52
58
|
return "Value must be one of: ".concat(values
|
|
53
59
|
.map(function (y) {
|
|
54
60
|
return typeof y === 'object'
|
|
55
|
-
? y['id'] !== undefined
|
|
56
|
-
? y['id']
|
|
57
|
-
: y.toString()
|
|
61
|
+
? (y === null || y === void 0 ? void 0 : y['id']) !== undefined
|
|
62
|
+
? y === null || y === void 0 ? void 0 : y['id']
|
|
63
|
+
: y === null || y === void 0 ? void 0 : y.toString()
|
|
58
64
|
: y;
|
|
59
65
|
})
|
|
60
66
|
.join(', '));
|
|
61
67
|
});
|
|
62
68
|
Validators.notNull = createValueValidator(function (val) { return val != null; }, 'Should not be null');
|
|
63
|
-
Validators.enum = createValueValidatorWithArgs(function (value, enumObj) { return Object.values(enumObj).includes(value); }, function (enumObj) {
|
|
69
|
+
Validators.enum = createValueValidatorWithArgs(function (value, enumObj) { return Object.values(enumObj).includes(value); }, function (enumObj) {
|
|
70
|
+
return "Value must be one of ".concat(getEnumValues(enumObj).join(', '));
|
|
71
|
+
});
|
|
64
72
|
Validators.relationExists = createValidator(function (_, e) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
65
73
|
var _b;
|
|
66
74
|
return tslib_1.__generator(_a, function (_c) {
|
|
@@ -136,13 +144,11 @@ function createValidator(validate, defaultMessage) {
|
|
|
136
144
|
},
|
|
137
145
|
});
|
|
138
146
|
}
|
|
139
|
-
exports.createValidator = createValidator;
|
|
140
147
|
function valueValidator(validate, defaultMessage) {
|
|
141
148
|
return function (entity, e) {
|
|
142
149
|
return validate(e.value) || defaultMessage || false;
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
|
-
exports.valueValidator = valueValidator;
|
|
146
152
|
function createValueValidator(validate, defaultMessage) {
|
|
147
153
|
return createValidator(function (_, e) {
|
|
148
154
|
if (e.value === undefined || e.value === null)
|
|
@@ -150,7 +156,6 @@ function createValueValidator(validate, defaultMessage) {
|
|
|
150
156
|
return validate(e.value);
|
|
151
157
|
}, defaultMessage);
|
|
152
158
|
}
|
|
153
|
-
exports.createValueValidator = createValueValidator;
|
|
154
159
|
function createValueValidatorWithArgs(validate, defaultMessage) {
|
|
155
160
|
var result = createValidatorWithArgsInternal(function (_, e, args) {
|
|
156
161
|
if (e.value === undefined || e.value === null)
|
|
@@ -169,11 +174,9 @@ function createValueValidatorWithArgs(validate, defaultMessage) {
|
|
|
169
174
|
},
|
|
170
175
|
});
|
|
171
176
|
}
|
|
172
|
-
exports.createValueValidatorWithArgs = createValueValidatorWithArgs;
|
|
173
177
|
function createValidatorWithArgs(validate, defaultMessage) {
|
|
174
178
|
return createValidatorWithArgsInternal(validate, defaultMessage);
|
|
175
179
|
}
|
|
176
|
-
exports.createValidatorWithArgs = createValidatorWithArgs;
|
|
177
180
|
function createValidatorWithArgsInternal(validate, defaultMessage, isValueValidator) {
|
|
178
181
|
var _this = this;
|
|
179
182
|
if (isValueValidator === void 0) { isValueValidator = false; }
|
|
@@ -216,4 +219,3 @@ function createValidatorWithArgsInternal(validate, defaultMessage, isValueValida
|
|
|
216
219
|
function getEnumValues(enumObj) {
|
|
217
220
|
return Object.values(enumObj).filter(function (x) { return typeof enumObj[x] !== 'number'; });
|
|
218
221
|
}
|
|
219
|
-
exports.getEnumValues = getEnumValues;
|
package/src/valueConverters.js
CHANGED
|
@@ -78,7 +78,7 @@ var ValueConverters = /** @class */ (function () {
|
|
|
78
78
|
if (!val)
|
|
79
79
|
return null;
|
|
80
80
|
return ValueConverters.DateOnly.fromJson(ValueConverters.DateOnly.toJson(val));
|
|
81
|
-
},
|
|
81
|
+
}, //when using date storage, the database expects and returns a date local and every where else we reflect on date iso
|
|
82
82
|
fromDb: function (val) {
|
|
83
83
|
return ValueConverters.Date.fromDb(val);
|
|
84
84
|
},
|
|
@@ -143,7 +143,8 @@ var ValueConverters = /** @class */ (function () {
|
|
|
143
143
|
return r;
|
|
144
144
|
},
|
|
145
145
|
toInput: function (x, type) {
|
|
146
|
-
|
|
146
|
+
var _a;
|
|
147
|
+
return (_a = x === null || x === void 0 ? void 0 : x.toString()) !== null && _a !== void 0 ? _a : '';
|
|
147
148
|
},
|
|
148
149
|
inputType: inputTypes_js_1.InputTypes.number,
|
|
149
150
|
};
|