remult 0.12.7 → 0.13.1
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/graphql.js +2 -2
- package/index.d.ts +2 -1
- package/index.js +6 -5
- package/package.json +1 -1
- package/postgres/postgres-data-provider.js +3 -2
- package/postgres/postgresColumnSyntax.js +1 -1
- package/readme.md +7 -1
- package/remult-knex/index.js +6 -5
- package/remult-mongo.js +1 -1
- package/server/expressBridge.js +8 -8
- package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +1 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +1 -1
- package/src/backend-tests/my-test.backend-spec.js +112 -0
- package/src/context.js +1 -1
- package/src/data-api.js +73 -52
- package/src/data-providers/array-entity-data-provider.js +8 -7
- package/src/data-providers/web-sql-data-provider.js +12 -6
- package/src/entity.d.ts +0 -1
- package/src/filter/filter-interfaces.d.ts +2 -2
- package/src/filter/filter-interfaces.js +5 -2
- package/src/id-entity.js +1 -5
- package/src/remult3/RepositoryImplementation.d.ts +53 -16
- package/src/remult3/RepositoryImplementation.js +224 -78
- package/src/remult3/remult3.d.ts +4 -4
- package/src/shared-tests/db-tests.db-tests.js +34 -127
- package/src/shared-tests/entityWithValidations.js +2 -2
- package/src/shared-tests/test-custom-id-column.spec.js +26 -4
- package/src/shared-tests/test-special-value.spec.js +2 -2
- package/src/shared-tests/test-update-with-null.spec.js +2 -2
- package/src/tests/c.js +2 -2
- package/src/tests/d.js +2 -2
- package/src/tests/dWithPrefilter.js +2 -2
- package/src/tests/entityForCustomFilter.js +1 -1
- package/src/tests/entityWithValidationsOnColumn.js +2 -2
- package/src/tests/h.js +6 -4
- package/src/tests/remult-3-entities.js +11 -11
- package/src/tests/tasks.js +3 -3
- package/src/validators.d.ts +5 -3
- package/src/validators.js +9 -7
- package/valueConverters.d.ts +11 -24
- package/valueConverters.js +148 -210
|
@@ -20,9 +20,6 @@ var entityForCustomFilter_1 = require("../tests/entityForCustomFilter");
|
|
|
20
20
|
var entityWithValidationsOnColumn_1 = require("../tests/entityWithValidationsOnColumn");
|
|
21
21
|
var validators_1 = require("../validators");
|
|
22
22
|
var models_1 = require("../tests/testModel/models");
|
|
23
|
-
var backend_database_test_setup_backend_spec_1 = require("../backend-tests/backend-database-test-setup.backend-spec");
|
|
24
|
-
var __1 = require("../..");
|
|
25
|
-
var remult_knex_1 = require("../../remult-knex");
|
|
26
23
|
db_tests_setup_1.testAll("what", function (_a) {
|
|
27
24
|
var remult = _a.remult, createEntity = _a.createEntity;
|
|
28
25
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
@@ -293,11 +290,11 @@ var testDateWithNull = /** @class */ (function (_super) {
|
|
|
293
290
|
return _this;
|
|
294
291
|
}
|
|
295
292
|
tslib_1.__decorate([
|
|
296
|
-
remult3_1.
|
|
293
|
+
remult3_1.Fields.Integer(),
|
|
297
294
|
tslib_1.__metadata("design:type", Number)
|
|
298
295
|
], testDateWithNull.prototype, "id", void 0);
|
|
299
296
|
tslib_1.__decorate([
|
|
300
|
-
remult3_1.
|
|
297
|
+
remult3_1.Fields.DateOnly({ allowNull: true }),
|
|
301
298
|
tslib_1.__metadata("design:type", Date)
|
|
302
299
|
], testDateWithNull.prototype, "d", void 0);
|
|
303
300
|
testDateWithNull = tslib_1.__decorate([
|
|
@@ -781,7 +778,7 @@ db_tests_setup_1.testAll("Test unique Validation,", function (_a) {
|
|
|
781
778
|
return class_1;
|
|
782
779
|
}(remult_3_entities_1.Categories));
|
|
783
780
|
remult3_1.Entity('categories')(type);
|
|
784
|
-
remult3_1.
|
|
781
|
+
remult3_1.Fields.String({
|
|
785
782
|
validate: function (en, col) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
786
783
|
return tslib_1.__generator(this, function (_a) {
|
|
787
784
|
switch (_a.label) {
|
|
@@ -843,7 +840,7 @@ db_tests_setup_1.testAll("Test unique Validation 2", function (_a) {
|
|
|
843
840
|
return class_2;
|
|
844
841
|
}(remult_3_entities_1.Categories));
|
|
845
842
|
remult3_1.Entity('sdfgds')(type);
|
|
846
|
-
remult3_1.
|
|
843
|
+
remult3_1.Fields.String({
|
|
847
844
|
validate: validators_1.Validators.unique
|
|
848
845
|
})(type.prototype, "a");
|
|
849
846
|
return [4 /*yield*/, createEntity(type)];
|
|
@@ -882,11 +879,11 @@ var testNumbers = /** @class */ (function (_super) {
|
|
|
882
879
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
883
880
|
}
|
|
884
881
|
tslib_1.__decorate([
|
|
885
|
-
remult3_1.
|
|
882
|
+
remult3_1.Fields.Integer(),
|
|
886
883
|
tslib_1.__metadata("design:type", Number)
|
|
887
884
|
], testNumbers.prototype, "id", void 0);
|
|
888
885
|
tslib_1.__decorate([
|
|
889
|
-
remult3_1.
|
|
886
|
+
remult3_1.Fields.Number(),
|
|
890
887
|
tslib_1.__metadata("design:type", Number)
|
|
891
888
|
], testNumbers.prototype, "a", void 0);
|
|
892
889
|
testNumbers = tslib_1.__decorate([
|
|
@@ -1126,10 +1123,8 @@ db_tests_setup_1.testAll("saves correctly to db", function (_a) {
|
|
|
1126
1123
|
return class_3;
|
|
1127
1124
|
}(remult3_1.EntityBase));
|
|
1128
1125
|
remult3_1.Entity('asdf', { allowApiCrud: true })(type);
|
|
1129
|
-
remult3_1.
|
|
1130
|
-
|
|
1131
|
-
})(type.prototype, 'id');
|
|
1132
|
-
remult3_1.Field({ valueType: Boolean })(type.prototype, "ok");
|
|
1126
|
+
remult3_1.Fields.Number()(type.prototype, 'id');
|
|
1127
|
+
remult3_1.Fields.Boolean()(type.prototype, "ok");
|
|
1133
1128
|
return [4 /*yield*/, createEntity(type)];
|
|
1134
1129
|
case 1:
|
|
1135
1130
|
r = (_b.sent()).create();
|
|
@@ -1155,15 +1150,15 @@ var autoIncrement = /** @class */ (function (_super) {
|
|
|
1155
1150
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1156
1151
|
}
|
|
1157
1152
|
tslib_1.__decorate([
|
|
1158
|
-
remult3_1.
|
|
1153
|
+
remult3_1.Fields.AutoIncrement(),
|
|
1159
1154
|
tslib_1.__metadata("design:type", Number)
|
|
1160
1155
|
], autoIncrement.prototype, "id", void 0);
|
|
1161
1156
|
tslib_1.__decorate([
|
|
1162
|
-
remult3_1.
|
|
1157
|
+
remult3_1.Fields.Integer(),
|
|
1163
1158
|
tslib_1.__metadata("design:type", Number)
|
|
1164
1159
|
], autoIncrement.prototype, "stam", void 0);
|
|
1165
1160
|
autoIncrement = tslib_1.__decorate([
|
|
1166
|
-
remult3_1.Entity("autoi", { allowApiCrud: true
|
|
1161
|
+
remult3_1.Entity("autoi", { allowApiCrud: true })
|
|
1167
1162
|
], autoIncrement);
|
|
1168
1163
|
return autoIncrement;
|
|
1169
1164
|
}(remult3_1.EntityBase));
|
|
@@ -1237,110 +1232,22 @@ db_tests_setup_1.testAll("filter", function (_a) {
|
|
|
1237
1232
|
});
|
|
1238
1233
|
});
|
|
1239
1234
|
}, false);
|
|
1240
|
-
|
|
1235
|
+
db_tests_setup_1.testAll("large string field", function (_a) {
|
|
1241
1236
|
var createEntity = _a.createEntity;
|
|
1242
1237
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1243
|
-
var s,
|
|
1244
|
-
return tslib_1.__generator(this, function (
|
|
1245
|
-
switch (
|
|
1246
|
-
case 0: return [4 /*yield*/,
|
|
1247
|
-
case 1:
|
|
1248
|
-
s = _c.sent();
|
|
1249
|
-
_b = expect;
|
|
1250
|
-
return [4 /*yield*/, s.find({
|
|
1251
|
-
where: __1.SqlDatabase.customFilter(function (build) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1252
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1253
|
-
build.sql = s.metadata.fields.myId.options.dbName + ' in (1,3)';
|
|
1254
|
-
return [2 /*return*/];
|
|
1255
|
-
});
|
|
1256
|
-
}); })
|
|
1257
|
-
})];
|
|
1258
|
-
case 2:
|
|
1259
|
-
_b.apply(void 0, [(_c.sent()).length]).toBe(2);
|
|
1260
|
-
return [2 /*return*/];
|
|
1261
|
-
}
|
|
1262
|
-
});
|
|
1263
|
-
});
|
|
1264
|
-
}, false);
|
|
1265
|
-
backend_database_test_setup_backend_spec_1.testPostgresImplementation("sql filter2", function (_a) {
|
|
1266
|
-
var createEntity = _a.createEntity;
|
|
1267
|
-
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1268
|
-
var s, _b;
|
|
1269
|
-
return tslib_1.__generator(this, function (_c) {
|
|
1270
|
-
switch (_c.label) {
|
|
1271
|
-
case 0: return [4 /*yield*/, entityWithValidations_1.entityWithValidations.create4RowsInDp(createEntity)];
|
|
1272
|
-
case 1:
|
|
1273
|
-
s = _c.sent();
|
|
1274
|
-
_b = expect;
|
|
1275
|
-
return [4 /*yield*/, s.find({
|
|
1276
|
-
where: {
|
|
1277
|
-
$or: [
|
|
1278
|
-
__1.SqlDatabase.customFilter(function (build) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1279
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1280
|
-
build.sql = s.metadata.fields.myId.options.dbName + ' in (1,3)';
|
|
1281
|
-
return [2 /*return*/];
|
|
1282
|
-
});
|
|
1283
|
-
}); }),
|
|
1284
|
-
{
|
|
1285
|
-
myId: 2
|
|
1286
|
-
}
|
|
1287
|
-
]
|
|
1288
|
-
}
|
|
1289
|
-
})];
|
|
1290
|
-
case 2:
|
|
1291
|
-
_b.apply(void 0, [(_c.sent()).length]).toBe(3);
|
|
1292
|
-
return [2 /*return*/];
|
|
1293
|
-
}
|
|
1294
|
-
});
|
|
1295
|
-
});
|
|
1296
|
-
}, false);
|
|
1297
|
-
backend_database_test_setup_backend_spec_1.testKnexPGSqlImpl("knex filter", function (_a) {
|
|
1298
|
-
var createEntity = _a.createEntity;
|
|
1299
|
-
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1300
|
-
var s, _b;
|
|
1301
|
-
return tslib_1.__generator(this, function (_c) {
|
|
1302
|
-
switch (_c.label) {
|
|
1303
|
-
case 0: return [4 /*yield*/, entityWithValidations_1.entityWithValidations.create4RowsInDp(createEntity)];
|
|
1304
|
-
case 1:
|
|
1305
|
-
s = _c.sent();
|
|
1306
|
-
_b = expect;
|
|
1307
|
-
return [4 /*yield*/, s.find({
|
|
1308
|
-
where: remult_knex_1.KnexDataProvider.customFilter(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1309
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1310
|
-
return [2 /*return*/, function (build) { return build.whereIn(s.metadata.fields.myId.options.dbName, [1, 3]); }];
|
|
1311
|
-
});
|
|
1312
|
-
}); })
|
|
1313
|
-
})];
|
|
1314
|
-
case 2:
|
|
1315
|
-
_b.apply(void 0, [(_c.sent()).length]).toBe(2);
|
|
1316
|
-
return [2 /*return*/];
|
|
1317
|
-
}
|
|
1318
|
-
});
|
|
1319
|
-
});
|
|
1320
|
-
}, false);
|
|
1321
|
-
backend_database_test_setup_backend_spec_1.testKnexPGSqlImpl("knex filter2", function (_a) {
|
|
1322
|
-
var createEntity = _a.createEntity;
|
|
1323
|
-
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1324
|
-
var s, _b;
|
|
1325
|
-
return tslib_1.__generator(this, function (_c) {
|
|
1326
|
-
switch (_c.label) {
|
|
1327
|
-
case 0: return [4 /*yield*/, entityWithValidations_1.entityWithValidations.create4RowsInDp(createEntity)];
|
|
1238
|
+
var s, r;
|
|
1239
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1240
|
+
switch (_b.label) {
|
|
1241
|
+
case 0: return [4 /*yield*/, createEntity(stam)];
|
|
1328
1242
|
case 1:
|
|
1329
|
-
s =
|
|
1330
|
-
|
|
1331
|
-
return [4 /*yield*/, s.find({
|
|
1332
|
-
where: {
|
|
1333
|
-
$or: [remult_knex_1.KnexDataProvider.customFilter(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1334
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1335
|
-
return [2 /*return*/, function (build) { return build.whereIn(s.metadata.fields.myId.options.dbName, [1, 3]); }];
|
|
1336
|
-
});
|
|
1337
|
-
}); }), {
|
|
1338
|
-
myId: 4
|
|
1339
|
-
}]
|
|
1340
|
-
}
|
|
1341
|
-
})];
|
|
1243
|
+
s = _b.sent();
|
|
1244
|
+
return [4 /*yield*/, s.insert({ title: "1234567890".repeat(100) })];
|
|
1342
1245
|
case 2:
|
|
1343
|
-
_b.
|
|
1246
|
+
_b.sent();
|
|
1247
|
+
return [4 /*yield*/, s.findFirst()];
|
|
1248
|
+
case 3:
|
|
1249
|
+
r = _b.sent();
|
|
1250
|
+
expect(r.title).toBe("1234567890".repeat(100));
|
|
1344
1251
|
return [2 /*return*/];
|
|
1345
1252
|
}
|
|
1346
1253
|
});
|
|
@@ -1363,19 +1270,19 @@ var testFilter = /** @class */ (function () {
|
|
|
1363
1270
|
}]
|
|
1364
1271
|
}); });
|
|
1365
1272
|
tslib_1.__decorate([
|
|
1366
|
-
remult3_1.
|
|
1273
|
+
remult3_1.Fields.Integer(),
|
|
1367
1274
|
tslib_1.__metadata("design:type", Number)
|
|
1368
1275
|
], testFilter.prototype, "id", void 0);
|
|
1369
1276
|
tslib_1.__decorate([
|
|
1370
|
-
remult3_1.
|
|
1277
|
+
remult3_1.Fields.String(),
|
|
1371
1278
|
tslib_1.__metadata("design:type", String)
|
|
1372
1279
|
], testFilter.prototype, "a", void 0);
|
|
1373
1280
|
tslib_1.__decorate([
|
|
1374
|
-
remult3_1.
|
|
1281
|
+
remult3_1.Fields.String(),
|
|
1375
1282
|
tslib_1.__metadata("design:type", String)
|
|
1376
1283
|
], testFilter.prototype, "b", void 0);
|
|
1377
1284
|
tslib_1.__decorate([
|
|
1378
|
-
remult3_1.
|
|
1285
|
+
remult3_1.Fields.String(),
|
|
1379
1286
|
tslib_1.__metadata("design:type", String)
|
|
1380
1287
|
], testFilter.prototype, "c", void 0);
|
|
1381
1288
|
testFilter = tslib_1.__decorate([
|
|
@@ -1391,11 +1298,11 @@ var testStringWithNull = /** @class */ (function (_super) {
|
|
|
1391
1298
|
return _this;
|
|
1392
1299
|
}
|
|
1393
1300
|
tslib_1.__decorate([
|
|
1394
|
-
remult3_1.
|
|
1301
|
+
remult3_1.Fields.Integer(),
|
|
1395
1302
|
tslib_1.__metadata("design:type", Number)
|
|
1396
1303
|
], testStringWithNull.prototype, "id", void 0);
|
|
1397
1304
|
tslib_1.__decorate([
|
|
1398
|
-
remult3_1.
|
|
1305
|
+
remult3_1.Fields.String({ allowNull: true }),
|
|
1399
1306
|
tslib_1.__metadata("design:type", String)
|
|
1400
1307
|
], testStringWithNull.prototype, "d", void 0);
|
|
1401
1308
|
testStringWithNull = tslib_1.__decorate([
|
|
@@ -1412,11 +1319,11 @@ var stam = /** @class */ (function (_super) {
|
|
|
1412
1319
|
return _this;
|
|
1413
1320
|
}
|
|
1414
1321
|
tslib_1.__decorate([
|
|
1415
|
-
remult3_1.
|
|
1322
|
+
remult3_1.Fields.Integer(),
|
|
1416
1323
|
tslib_1.__metadata("design:type", Number)
|
|
1417
1324
|
], stam.prototype, "id", void 0);
|
|
1418
1325
|
tslib_1.__decorate([
|
|
1419
|
-
remult3_1.
|
|
1326
|
+
remult3_1.Fields.String({ maxLength: 1500 }),
|
|
1420
1327
|
tslib_1.__metadata("design:type", String)
|
|
1421
1328
|
], stam.prototype, "title", void 0);
|
|
1422
1329
|
stam = tslib_1.__decorate([
|
|
@@ -1433,15 +1340,15 @@ var p = /** @class */ (function (_super) {
|
|
|
1433
1340
|
return _this;
|
|
1434
1341
|
}
|
|
1435
1342
|
tslib_1.__decorate([
|
|
1436
|
-
remult3_1.
|
|
1343
|
+
remult3_1.Fields.Integer(),
|
|
1437
1344
|
tslib_1.__metadata("design:type", Number)
|
|
1438
1345
|
], p.prototype, "id", void 0);
|
|
1439
1346
|
tslib_1.__decorate([
|
|
1440
|
-
remult3_1.
|
|
1347
|
+
remult3_1.Fields.String(),
|
|
1441
1348
|
tslib_1.__metadata("design:type", String)
|
|
1442
1349
|
], p.prototype, "name", void 0);
|
|
1443
1350
|
tslib_1.__decorate([
|
|
1444
|
-
remult3_1.Field(),
|
|
1351
|
+
remult3_1.Field(function () { return c_1.c; }),
|
|
1445
1352
|
tslib_1.__metadata("design:type", c_1.c)
|
|
1446
1353
|
], p.prototype, "c", void 0);
|
|
1447
1354
|
p = tslib_1.__decorate([
|
|
@@ -53,11 +53,11 @@ var entityWithValidations = /** @class */ (function (_super) {
|
|
|
53
53
|
var entityWithValidations_1;
|
|
54
54
|
entityWithValidations.savingRowCount = 0;
|
|
55
55
|
tslib_1.__decorate([
|
|
56
|
-
remult3_1.
|
|
56
|
+
remult3_1.Fields.Integer(),
|
|
57
57
|
tslib_1.__metadata("design:type", Number)
|
|
58
58
|
], entityWithValidations.prototype, "myId", void 0);
|
|
59
59
|
tslib_1.__decorate([
|
|
60
|
-
remult3_1.
|
|
60
|
+
remult3_1.Fields.String(),
|
|
61
61
|
tslib_1.__metadata("design:type", String)
|
|
62
62
|
], entityWithValidations.prototype, "name", void 0);
|
|
63
63
|
entityWithValidations = entityWithValidations_1 = tslib_1.__decorate([
|
|
@@ -19,8 +19,8 @@ describe("custom id column", function () {
|
|
|
19
19
|
return class_1;
|
|
20
20
|
}(remult3_1.EntityBase));
|
|
21
21
|
remult3_1.BuildEntity(type, 'custom', {
|
|
22
|
-
a: remult3_1.
|
|
23
|
-
b: remult3_1.
|
|
22
|
+
a: remult3_1.Fields.Number(),
|
|
23
|
+
b: remult3_1.Fields.Number()
|
|
24
24
|
}, { allowApiCrud: true });
|
|
25
25
|
return [4 /*yield*/, createEntity(type)];
|
|
26
26
|
case 1:
|
|
@@ -58,8 +58,8 @@ describe("custom id column", function () {
|
|
|
58
58
|
return class_2;
|
|
59
59
|
}(remult3_1.EntityBase));
|
|
60
60
|
remult3_1.Entity('custom2', { allowApiCrud: true })(type);
|
|
61
|
-
remult3_1.
|
|
62
|
-
remult3_1.
|
|
61
|
+
remult3_1.Fields.Number()(type.prototype, 'a');
|
|
62
|
+
remult3_1.Fields.Number()(type.prototype, 'id');
|
|
63
63
|
return [4 /*yield*/, createEntity(type)];
|
|
64
64
|
case 1:
|
|
65
65
|
c = _c.sent();
|
|
@@ -86,3 +86,25 @@ describe("custom id column", function () {
|
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
|
+
//typing game
|
|
90
|
+
// var z = <Z>(y: Z) => {
|
|
91
|
+
// }
|
|
92
|
+
// z<number>(1);
|
|
93
|
+
// function myBackendMethod<T>(types: T, values: values<T>) {
|
|
94
|
+
// }
|
|
95
|
+
// type values<T> = {
|
|
96
|
+
// [Property in keyof T]: T[Property] extends new (...args: any[]) => infer R ? R : any;
|
|
97
|
+
// };
|
|
98
|
+
// const a1 = AccountManager;
|
|
99
|
+
// const a = {
|
|
100
|
+
// a: String.prototype,
|
|
101
|
+
// b: AccountManager.prototype
|
|
102
|
+
// };
|
|
103
|
+
// var zzz: AccountManager = undefined!;
|
|
104
|
+
// myBackendMethod({
|
|
105
|
+
// a: String,
|
|
106
|
+
// b: AccountManager
|
|
107
|
+
// }, {
|
|
108
|
+
// b: new AccountManager(),
|
|
109
|
+
// a: "asdf"
|
|
110
|
+
// })
|
|
@@ -66,11 +66,11 @@ var testGroups = /** @class */ (function (_super) {
|
|
|
66
66
|
return _this;
|
|
67
67
|
}
|
|
68
68
|
tslib_1.__decorate([
|
|
69
|
-
remult3_1.
|
|
69
|
+
remult3_1.Fields.Integer(),
|
|
70
70
|
tslib_1.__metadata("design:type", Number)
|
|
71
71
|
], testGroups.prototype, "id", void 0);
|
|
72
72
|
tslib_1.__decorate([
|
|
73
|
-
remult3_1.Field(),
|
|
73
|
+
remult3_1.Field(function () { return GroupsValue; }),
|
|
74
74
|
tslib_1.__metadata("design:type", GroupsValue)
|
|
75
75
|
], testGroups.prototype, "g", void 0);
|
|
76
76
|
testGroups = tslib_1.__decorate([
|
|
@@ -11,11 +11,11 @@ var testNull = /** @class */ (function (_super) {
|
|
|
11
11
|
return _this;
|
|
12
12
|
}
|
|
13
13
|
tslib_1.__decorate([
|
|
14
|
-
remult3_1.
|
|
14
|
+
remult3_1.Fields.Integer(),
|
|
15
15
|
tslib_1.__metadata("design:type", Number)
|
|
16
16
|
], testNull.prototype, "id", void 0);
|
|
17
17
|
tslib_1.__decorate([
|
|
18
|
-
remult3_1.Field({ allowNull: true }),
|
|
18
|
+
remult3_1.Field(undefined, { allowNull: true }),
|
|
19
19
|
tslib_1.__metadata("design:type", Object)
|
|
20
20
|
], testNull.prototype, "myCol", void 0);
|
|
21
21
|
testNull = tslib_1.__decorate([
|
package/src/tests/c.js
CHANGED
|
@@ -12,11 +12,11 @@ var c = /** @class */ (function (_super) {
|
|
|
12
12
|
return _this;
|
|
13
13
|
}
|
|
14
14
|
tslib_1.__decorate([
|
|
15
|
-
remult3_1.
|
|
15
|
+
remult3_1.Fields.Integer(),
|
|
16
16
|
tslib_1.__metadata("design:type", Number)
|
|
17
17
|
], c.prototype, "id", void 0);
|
|
18
18
|
tslib_1.__decorate([
|
|
19
|
-
remult3_1.
|
|
19
|
+
remult3_1.Fields.String(),
|
|
20
20
|
tslib_1.__metadata("design:type", String)
|
|
21
21
|
], c.prototype, "name", void 0);
|
|
22
22
|
c = tslib_1.__decorate([
|
package/src/tests/d.js
CHANGED
|
@@ -20,11 +20,11 @@ var d = /** @class */ (function (_super) {
|
|
|
20
20
|
};
|
|
21
21
|
d.count = 0;
|
|
22
22
|
tslib_1.__decorate([
|
|
23
|
-
remult3_1.
|
|
23
|
+
remult3_1.Fields.Integer(),
|
|
24
24
|
tslib_1.__metadata("design:type", Number)
|
|
25
25
|
], d.prototype, "id", void 0);
|
|
26
26
|
tslib_1.__decorate([
|
|
27
|
-
remult3_1.
|
|
27
|
+
remult3_1.Fields.Integer(),
|
|
28
28
|
tslib_1.__metadata("design:type", Number)
|
|
29
29
|
], d.prototype, "b", void 0);
|
|
30
30
|
tslib_1.__decorate([
|
|
@@ -21,11 +21,11 @@ var dWithPrefilter = /** @class */ (function (_super) {
|
|
|
21
21
|
var dWithPrefilter_1;
|
|
22
22
|
dWithPrefilter.count = 0;
|
|
23
23
|
tslib_1.__decorate([
|
|
24
|
-
remult3_1.
|
|
24
|
+
remult3_1.Fields.Integer(),
|
|
25
25
|
tslib_1.__metadata("design:type", Number)
|
|
26
26
|
], dWithPrefilter.prototype, "id", void 0);
|
|
27
27
|
tslib_1.__decorate([
|
|
28
|
-
remult3_1.
|
|
28
|
+
remult3_1.Fields.Integer(),
|
|
29
29
|
tslib_1.__metadata("design:type", Number)
|
|
30
30
|
], dWithPrefilter.prototype, "b", void 0);
|
|
31
31
|
tslib_1.__decorate([
|
|
@@ -46,7 +46,7 @@ var entityForCustomFilter = /** @class */ (function (_super) {
|
|
|
46
46
|
entityForCustomFilter.testNumericValue = filter_interfaces_1.Filter.createCustom(function (r, val) { return ({ id: val }); });
|
|
47
47
|
entityForCustomFilter.testObjectValue = filter_interfaces_1.Filter.createCustom(function (r, val) { return ({ id: val.val }); });
|
|
48
48
|
tslib_1.__decorate([
|
|
49
|
-
remult3_1.
|
|
49
|
+
remult3_1.Fields.Integer(),
|
|
50
50
|
tslib_1.__metadata("design:type", Number)
|
|
51
51
|
], entityForCustomFilter.prototype, "id", void 0);
|
|
52
52
|
entityForCustomFilter = entityForCustomFilter_1 = tslib_1.__decorate([
|
|
@@ -9,11 +9,11 @@ var entityWithValidationsOnColumn = /** @class */ (function (_super) {
|
|
|
9
9
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
10
|
}
|
|
11
11
|
tslib_1.__decorate([
|
|
12
|
-
remult3_1.
|
|
12
|
+
remult3_1.Fields.Integer(),
|
|
13
13
|
tslib_1.__metadata("design:type", Number)
|
|
14
14
|
], entityWithValidationsOnColumn.prototype, "myId", void 0);
|
|
15
15
|
tslib_1.__decorate([
|
|
16
|
-
remult3_1.
|
|
16
|
+
remult3_1.Fields.String({
|
|
17
17
|
validate: function (t, c) {
|
|
18
18
|
if (!t.name || t.name.length < 3)
|
|
19
19
|
c.error = 'invalid on column';
|
package/src/tests/h.js
CHANGED
|
@@ -8,19 +8,21 @@ var h = /** @class */ (function (_super) {
|
|
|
8
8
|
function h() {
|
|
9
9
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
10
10
|
}
|
|
11
|
+
h_1 = h;
|
|
12
|
+
var h_1;
|
|
11
13
|
tslib_1.__decorate([
|
|
12
|
-
remult3_1.
|
|
14
|
+
remult3_1.Fields.String(),
|
|
13
15
|
tslib_1.__metadata("design:type", String)
|
|
14
16
|
], h.prototype, "id", void 0);
|
|
15
17
|
tslib_1.__decorate([
|
|
16
|
-
remult3_1.Field(),
|
|
18
|
+
remult3_1.Field(function () { return h_1; }),
|
|
17
19
|
tslib_1.__metadata("design:type", h)
|
|
18
20
|
], h.prototype, "refH", void 0);
|
|
19
21
|
tslib_1.__decorate([
|
|
20
|
-
remult3_1.
|
|
22
|
+
remult3_1.Fields.String(),
|
|
21
23
|
tslib_1.__metadata("design:type", String)
|
|
22
24
|
], h.prototype, "refHId", void 0);
|
|
23
|
-
h = tslib_1.__decorate([
|
|
25
|
+
h = h_1 = tslib_1.__decorate([
|
|
24
26
|
remult3_1.FieldType({
|
|
25
27
|
valueConverter: {
|
|
26
28
|
toJson: function (x) { return x != undefined ? x : ''; },
|
|
@@ -8,23 +8,23 @@ var Products = /** @class */ (function () {
|
|
|
8
8
|
function Products() {
|
|
9
9
|
}
|
|
10
10
|
tslib_1.__decorate([
|
|
11
|
-
remult3_1.
|
|
11
|
+
remult3_1.Fields.Integer(),
|
|
12
12
|
tslib_1.__metadata("design:type", Number)
|
|
13
13
|
], Products.prototype, "id", void 0);
|
|
14
14
|
tslib_1.__decorate([
|
|
15
|
-
remult3_1.
|
|
15
|
+
remult3_1.Fields.String(),
|
|
16
16
|
tslib_1.__metadata("design:type", String)
|
|
17
17
|
], Products.prototype, "name", void 0);
|
|
18
18
|
tslib_1.__decorate([
|
|
19
|
-
remult3_1.
|
|
19
|
+
remult3_1.Fields.Number(),
|
|
20
20
|
tslib_1.__metadata("design:type", Number)
|
|
21
21
|
], Products.prototype, "price", void 0);
|
|
22
22
|
tslib_1.__decorate([
|
|
23
|
-
remult3_1.
|
|
23
|
+
remult3_1.Fields.Boolean(),
|
|
24
24
|
tslib_1.__metadata("design:type", Boolean)
|
|
25
25
|
], Products.prototype, "archived", void 0);
|
|
26
26
|
tslib_1.__decorate([
|
|
27
|
-
remult3_1.
|
|
27
|
+
remult3_1.Fields.Date(),
|
|
28
28
|
tslib_1.__metadata("design:type", Date)
|
|
29
29
|
], Products.prototype, "availableFrom", void 0);
|
|
30
30
|
Products = tslib_1.__decorate([
|
|
@@ -42,33 +42,33 @@ var Categories = /** @class */ (function (_super) {
|
|
|
42
42
|
return _this;
|
|
43
43
|
}
|
|
44
44
|
tslib_1.__decorate([
|
|
45
|
-
remult3_1.
|
|
45
|
+
remult3_1.Fields.Number({
|
|
46
46
|
dbName: 'CategoryID'
|
|
47
47
|
}),
|
|
48
48
|
tslib_1.__metadata("design:type", Number)
|
|
49
49
|
], Categories.prototype, "id", void 0);
|
|
50
50
|
tslib_1.__decorate([
|
|
51
|
-
remult3_1.
|
|
51
|
+
remult3_1.Fields.String({ allowNull: true }),
|
|
52
52
|
tslib_1.__metadata("design:type", String)
|
|
53
53
|
], Categories.prototype, "categoryName", void 0);
|
|
54
54
|
tslib_1.__decorate([
|
|
55
|
-
remult3_1.
|
|
55
|
+
remult3_1.Fields.String(),
|
|
56
56
|
tslib_1.__metadata("design:type", String)
|
|
57
57
|
], Categories.prototype, "description", void 0);
|
|
58
58
|
tslib_1.__decorate([
|
|
59
|
-
remult3_1.
|
|
59
|
+
remult3_1.Fields.Number({
|
|
60
60
|
serverExpression: function (c) { return c.categoryName ? c.categoryName.length : undefined; }
|
|
61
61
|
}),
|
|
62
62
|
tslib_1.__metadata("design:type", Number)
|
|
63
63
|
], Categories.prototype, "categoryNameLength", void 0);
|
|
64
64
|
tslib_1.__decorate([
|
|
65
|
-
remult3_1.
|
|
65
|
+
remult3_1.Fields.Number({
|
|
66
66
|
serverExpression: function (c) { return Promise.resolve(c.categoryName ? c.categoryName.length : undefined); }
|
|
67
67
|
}),
|
|
68
68
|
tslib_1.__metadata("design:type", Number)
|
|
69
69
|
], Categories.prototype, "categoryNameLengthAsync", void 0);
|
|
70
70
|
tslib_1.__decorate([
|
|
71
|
-
remult3_1.Field(),
|
|
71
|
+
remult3_1.Field(function () { return models_1.Status; }),
|
|
72
72
|
tslib_1.__metadata("design:type", models_1.Status)
|
|
73
73
|
], Categories.prototype, "status", void 0);
|
|
74
74
|
Categories = tslib_1.__decorate([
|
package/src/tests/tasks.js
CHANGED
|
@@ -11,15 +11,15 @@ var tasks = /** @class */ (function (_super) {
|
|
|
11
11
|
return _this;
|
|
12
12
|
}
|
|
13
13
|
tslib_1.__decorate([
|
|
14
|
-
remult3_1.
|
|
14
|
+
remult3_1.Fields.Integer(),
|
|
15
15
|
tslib_1.__metadata("design:type", Number)
|
|
16
16
|
], tasks.prototype, "id", void 0);
|
|
17
17
|
tslib_1.__decorate([
|
|
18
|
-
remult3_1.
|
|
18
|
+
remult3_1.Fields.String(),
|
|
19
19
|
tslib_1.__metadata("design:type", String)
|
|
20
20
|
], tasks.prototype, "name", void 0);
|
|
21
21
|
tslib_1.__decorate([
|
|
22
|
-
remult3_1.
|
|
22
|
+
remult3_1.Fields.Boolean(),
|
|
23
23
|
tslib_1.__metadata("design:type", Boolean)
|
|
24
24
|
], tasks.prototype, "completed", void 0);
|
|
25
25
|
tasks = tslib_1.__decorate([
|
package/src/validators.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { FieldRef } from "./remult3";
|
|
2
2
|
export declare class Validators {
|
|
3
|
-
static required: ((entity: any, col: FieldRef<any, string>, message?:
|
|
3
|
+
static required: ((entity: any, col: FieldRef<any, string>, message?: any) => void) & {
|
|
4
4
|
withMessage: (message: string) => (entity: any, col: FieldRef<any, string>) => void;
|
|
5
|
+
defaultMessage: string;
|
|
5
6
|
};
|
|
6
|
-
static unique: ((entity: any, col: FieldRef<any, any>, message?:
|
|
7
|
+
static unique: ((entity: any, col: FieldRef<any, any>, message?: any) => Promise<void>) & {
|
|
7
8
|
withMessage: (message: string) => (entity: any, col: FieldRef<any, any>) => Promise<void>;
|
|
9
|
+
defaultMessage: string;
|
|
8
10
|
};
|
|
9
|
-
static uniqueOnBackend: ((entity: any, col: FieldRef<any, any>, message?:
|
|
11
|
+
static uniqueOnBackend: ((entity: any, col: FieldRef<any, any>, message?: any) => Promise<void>) & {
|
|
10
12
|
withMessage: (message: string) => (entity: any, col: FieldRef<any, any>) => Promise<void>;
|
|
11
13
|
};
|
|
12
14
|
}
|
package/src/validators.js
CHANGED
|
@@ -7,16 +7,17 @@ var Validators = /** @class */ (function () {
|
|
|
7
7
|
function Validators() {
|
|
8
8
|
}
|
|
9
9
|
Validators.required = Object.assign(function (entity, col, message) {
|
|
10
|
-
if (message === void 0) { message =
|
|
10
|
+
if (message === void 0) { message = undefined; }
|
|
11
11
|
if (!col.value || typeof (col.value) === "string" && col.value.trim().length == 0)
|
|
12
|
-
col.error = message;
|
|
12
|
+
col.error = message || Validators.required.defaultMessage;
|
|
13
13
|
}, {
|
|
14
14
|
withMessage: function (message) {
|
|
15
15
|
return function (entity, col) { return Validators.required(entity, col, message); };
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
defaultMessage: 'Should not be empty'
|
|
17
18
|
});
|
|
18
19
|
Validators.unique = Object.assign(function (entity, col, message) {
|
|
19
|
-
if (message === void 0) { message =
|
|
20
|
+
if (message === void 0) { message = undefined; }
|
|
20
21
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
21
22
|
var _a;
|
|
22
23
|
return tslib_1.__generator(this, function (_b) {
|
|
@@ -28,7 +29,7 @@ var Validators = /** @class */ (function () {
|
|
|
28
29
|
return [4 /*yield*/, col.entityRef.repository.count((_a = {}, _a[col.metadata.key] = col.value, _a))];
|
|
29
30
|
case 1:
|
|
30
31
|
if (_b.sent())
|
|
31
|
-
col.error = message;
|
|
32
|
+
col.error = message || Validators.unique.defaultMessage;
|
|
32
33
|
_b.label = 2;
|
|
33
34
|
case 2: return [2 /*return*/];
|
|
34
35
|
}
|
|
@@ -37,10 +38,11 @@ var Validators = /** @class */ (function () {
|
|
|
37
38
|
}, {
|
|
38
39
|
withMessage: function (message) {
|
|
39
40
|
return function (entity, col) { return Validators.unique(entity, col, message); };
|
|
40
|
-
}
|
|
41
|
+
},
|
|
42
|
+
defaultMessage: 'already exists'
|
|
41
43
|
});
|
|
42
44
|
Validators.uniqueOnBackend = Object.assign(function (entity, col, message) {
|
|
43
|
-
if (message === void 0) { message =
|
|
45
|
+
if (message === void 0) { message = undefined; }
|
|
44
46
|
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
45
47
|
return tslib_1.__generator(this, function (_a) {
|
|
46
48
|
if (__1.isBackend())
|