remult 0.12.8 → 0.13.2
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 +9 -9
- 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/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 +43 -24
- 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
|
@@ -290,11 +290,11 @@ var testDateWithNull = /** @class */ (function (_super) {
|
|
|
290
290
|
return _this;
|
|
291
291
|
}
|
|
292
292
|
tslib_1.__decorate([
|
|
293
|
-
remult3_1.
|
|
293
|
+
remult3_1.Fields.Integer(),
|
|
294
294
|
tslib_1.__metadata("design:type", Number)
|
|
295
295
|
], testDateWithNull.prototype, "id", void 0);
|
|
296
296
|
tslib_1.__decorate([
|
|
297
|
-
remult3_1.
|
|
297
|
+
remult3_1.Fields.DateOnly({ allowNull: true }),
|
|
298
298
|
tslib_1.__metadata("design:type", Date)
|
|
299
299
|
], testDateWithNull.prototype, "d", void 0);
|
|
300
300
|
testDateWithNull = tslib_1.__decorate([
|
|
@@ -778,7 +778,7 @@ db_tests_setup_1.testAll("Test unique Validation,", function (_a) {
|
|
|
778
778
|
return class_1;
|
|
779
779
|
}(remult_3_entities_1.Categories));
|
|
780
780
|
remult3_1.Entity('categories')(type);
|
|
781
|
-
remult3_1.
|
|
781
|
+
remult3_1.Fields.String({
|
|
782
782
|
validate: function (en, col) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
783
783
|
return tslib_1.__generator(this, function (_a) {
|
|
784
784
|
switch (_a.label) {
|
|
@@ -840,7 +840,7 @@ db_tests_setup_1.testAll("Test unique Validation 2", function (_a) {
|
|
|
840
840
|
return class_2;
|
|
841
841
|
}(remult_3_entities_1.Categories));
|
|
842
842
|
remult3_1.Entity('sdfgds')(type);
|
|
843
|
-
remult3_1.
|
|
843
|
+
remult3_1.Fields.String({
|
|
844
844
|
validate: validators_1.Validators.unique
|
|
845
845
|
})(type.prototype, "a");
|
|
846
846
|
return [4 /*yield*/, createEntity(type)];
|
|
@@ -879,11 +879,11 @@ var testNumbers = /** @class */ (function (_super) {
|
|
|
879
879
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
880
880
|
}
|
|
881
881
|
tslib_1.__decorate([
|
|
882
|
-
remult3_1.
|
|
882
|
+
remult3_1.Fields.Integer(),
|
|
883
883
|
tslib_1.__metadata("design:type", Number)
|
|
884
884
|
], testNumbers.prototype, "id", void 0);
|
|
885
885
|
tslib_1.__decorate([
|
|
886
|
-
remult3_1.
|
|
886
|
+
remult3_1.Fields.Number(),
|
|
887
887
|
tslib_1.__metadata("design:type", Number)
|
|
888
888
|
], testNumbers.prototype, "a", void 0);
|
|
889
889
|
testNumbers = tslib_1.__decorate([
|
|
@@ -1123,10 +1123,8 @@ db_tests_setup_1.testAll("saves correctly to db", function (_a) {
|
|
|
1123
1123
|
return class_3;
|
|
1124
1124
|
}(remult3_1.EntityBase));
|
|
1125
1125
|
remult3_1.Entity('asdf', { allowApiCrud: true })(type);
|
|
1126
|
-
remult3_1.
|
|
1127
|
-
|
|
1128
|
-
})(type.prototype, 'id');
|
|
1129
|
-
remult3_1.Field({ valueType: Boolean })(type.prototype, "ok");
|
|
1126
|
+
remult3_1.Fields.Number()(type.prototype, 'id');
|
|
1127
|
+
remult3_1.Fields.Boolean()(type.prototype, "ok");
|
|
1130
1128
|
return [4 /*yield*/, createEntity(type)];
|
|
1131
1129
|
case 1:
|
|
1132
1130
|
r = (_b.sent()).create();
|
|
@@ -1152,15 +1150,15 @@ var autoIncrement = /** @class */ (function (_super) {
|
|
|
1152
1150
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1153
1151
|
}
|
|
1154
1152
|
tslib_1.__decorate([
|
|
1155
|
-
remult3_1.
|
|
1153
|
+
remult3_1.Fields.AutoIncrement(),
|
|
1156
1154
|
tslib_1.__metadata("design:type", Number)
|
|
1157
1155
|
], autoIncrement.prototype, "id", void 0);
|
|
1158
1156
|
tslib_1.__decorate([
|
|
1159
|
-
remult3_1.
|
|
1157
|
+
remult3_1.Fields.Integer(),
|
|
1160
1158
|
tslib_1.__metadata("design:type", Number)
|
|
1161
1159
|
], autoIncrement.prototype, "stam", void 0);
|
|
1162
1160
|
autoIncrement = tslib_1.__decorate([
|
|
1163
|
-
remult3_1.Entity("autoi", { allowApiCrud: true
|
|
1161
|
+
remult3_1.Entity("autoi", { allowApiCrud: true })
|
|
1164
1162
|
], autoIncrement);
|
|
1165
1163
|
return autoIncrement;
|
|
1166
1164
|
}(remult3_1.EntityBase));
|
|
@@ -1234,6 +1232,27 @@ db_tests_setup_1.testAll("filter", function (_a) {
|
|
|
1234
1232
|
});
|
|
1235
1233
|
});
|
|
1236
1234
|
}, false);
|
|
1235
|
+
db_tests_setup_1.testAll("large string field", function (_a) {
|
|
1236
|
+
var createEntity = _a.createEntity;
|
|
1237
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1238
|
+
var s, r;
|
|
1239
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1240
|
+
switch (_b.label) {
|
|
1241
|
+
case 0: return [4 /*yield*/, createEntity(stam)];
|
|
1242
|
+
case 1:
|
|
1243
|
+
s = _b.sent();
|
|
1244
|
+
return [4 /*yield*/, s.insert({ title: "1234567890".repeat(100) })];
|
|
1245
|
+
case 2:
|
|
1246
|
+
_b.sent();
|
|
1247
|
+
return [4 /*yield*/, s.findFirst()];
|
|
1248
|
+
case 3:
|
|
1249
|
+
r = _b.sent();
|
|
1250
|
+
expect(r.title).toBe("1234567890".repeat(100));
|
|
1251
|
+
return [2 /*return*/];
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
});
|
|
1255
|
+
}, false);
|
|
1237
1256
|
var testFilter = /** @class */ (function () {
|
|
1238
1257
|
function testFilter() {
|
|
1239
1258
|
this.id = 0;
|
|
@@ -1251,19 +1270,19 @@ var testFilter = /** @class */ (function () {
|
|
|
1251
1270
|
}]
|
|
1252
1271
|
}); });
|
|
1253
1272
|
tslib_1.__decorate([
|
|
1254
|
-
remult3_1.
|
|
1273
|
+
remult3_1.Fields.Integer(),
|
|
1255
1274
|
tslib_1.__metadata("design:type", Number)
|
|
1256
1275
|
], testFilter.prototype, "id", void 0);
|
|
1257
1276
|
tslib_1.__decorate([
|
|
1258
|
-
remult3_1.
|
|
1277
|
+
remult3_1.Fields.String(),
|
|
1259
1278
|
tslib_1.__metadata("design:type", String)
|
|
1260
1279
|
], testFilter.prototype, "a", void 0);
|
|
1261
1280
|
tslib_1.__decorate([
|
|
1262
|
-
remult3_1.
|
|
1281
|
+
remult3_1.Fields.String(),
|
|
1263
1282
|
tslib_1.__metadata("design:type", String)
|
|
1264
1283
|
], testFilter.prototype, "b", void 0);
|
|
1265
1284
|
tslib_1.__decorate([
|
|
1266
|
-
remult3_1.
|
|
1285
|
+
remult3_1.Fields.String(),
|
|
1267
1286
|
tslib_1.__metadata("design:type", String)
|
|
1268
1287
|
], testFilter.prototype, "c", void 0);
|
|
1269
1288
|
testFilter = tslib_1.__decorate([
|
|
@@ -1279,11 +1298,11 @@ var testStringWithNull = /** @class */ (function (_super) {
|
|
|
1279
1298
|
return _this;
|
|
1280
1299
|
}
|
|
1281
1300
|
tslib_1.__decorate([
|
|
1282
|
-
remult3_1.
|
|
1301
|
+
remult3_1.Fields.Integer(),
|
|
1283
1302
|
tslib_1.__metadata("design:type", Number)
|
|
1284
1303
|
], testStringWithNull.prototype, "id", void 0);
|
|
1285
1304
|
tslib_1.__decorate([
|
|
1286
|
-
remult3_1.
|
|
1305
|
+
remult3_1.Fields.String({ allowNull: true }),
|
|
1287
1306
|
tslib_1.__metadata("design:type", String)
|
|
1288
1307
|
], testStringWithNull.prototype, "d", void 0);
|
|
1289
1308
|
testStringWithNull = tslib_1.__decorate([
|
|
@@ -1300,11 +1319,11 @@ var stam = /** @class */ (function (_super) {
|
|
|
1300
1319
|
return _this;
|
|
1301
1320
|
}
|
|
1302
1321
|
tslib_1.__decorate([
|
|
1303
|
-
remult3_1.
|
|
1322
|
+
remult3_1.Fields.Integer(),
|
|
1304
1323
|
tslib_1.__metadata("design:type", Number)
|
|
1305
1324
|
], stam.prototype, "id", void 0);
|
|
1306
1325
|
tslib_1.__decorate([
|
|
1307
|
-
remult3_1.
|
|
1326
|
+
remult3_1.Fields.String({ maxLength: 1500 }),
|
|
1308
1327
|
tslib_1.__metadata("design:type", String)
|
|
1309
1328
|
], stam.prototype, "title", void 0);
|
|
1310
1329
|
stam = tslib_1.__decorate([
|
|
@@ -1321,15 +1340,15 @@ var p = /** @class */ (function (_super) {
|
|
|
1321
1340
|
return _this;
|
|
1322
1341
|
}
|
|
1323
1342
|
tslib_1.__decorate([
|
|
1324
|
-
remult3_1.
|
|
1343
|
+
remult3_1.Fields.Integer(),
|
|
1325
1344
|
tslib_1.__metadata("design:type", Number)
|
|
1326
1345
|
], p.prototype, "id", void 0);
|
|
1327
1346
|
tslib_1.__decorate([
|
|
1328
|
-
remult3_1.
|
|
1347
|
+
remult3_1.Fields.String(),
|
|
1329
1348
|
tslib_1.__metadata("design:type", String)
|
|
1330
1349
|
], p.prototype, "name", void 0);
|
|
1331
1350
|
tslib_1.__decorate([
|
|
1332
|
-
remult3_1.Field(),
|
|
1351
|
+
remult3_1.Field(function () { return c_1.c; }),
|
|
1333
1352
|
tslib_1.__metadata("design:type", c_1.c)
|
|
1334
1353
|
], p.prototype, "c", void 0);
|
|
1335
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())
|
package/valueConverters.d.ts
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
private info;
|
|
13
|
-
constructor(type: ClassType<T>);
|
|
14
|
-
fromJson(val: any): T;
|
|
15
|
-
toJson(val: T): any;
|
|
16
|
-
fromDb(val: any): T;
|
|
17
|
-
toDb(val: T): any;
|
|
18
|
-
toInput(val: T, inputType: string): string;
|
|
19
|
-
fromInput(val: string, inputType: string): T;
|
|
20
|
-
displayValue?(val: T): string;
|
|
21
|
-
fieldTypeInDb?: string;
|
|
22
|
-
inputType?: string;
|
|
23
|
-
getOptions(): T[];
|
|
24
|
-
byId(key: any): T;
|
|
1
|
+
import { ValueConverter } from "./src/column-interfaces";
|
|
2
|
+
export declare class ValueConverters {
|
|
3
|
+
static readonly Date: ValueConverter<Date>;
|
|
4
|
+
static readonly DateOnly: ValueConverter<Date>;
|
|
5
|
+
static readonly DateOnlyString: ValueConverter<Date>;
|
|
6
|
+
static readonly Boolean: ValueConverter<Boolean>;
|
|
7
|
+
static readonly Number: ValueConverter<number>;
|
|
8
|
+
static readonly Integer: ValueConverter<number>;
|
|
9
|
+
static readonly Default: ValueConverter<any>;
|
|
10
|
+
static readonly JsonString: ValueConverter<any>;
|
|
11
|
+
static readonly JsonValue: ValueConverter<any>;
|
|
25
12
|
}
|