remult 0.14.2 → 0.14.5
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/assign.js +1 -5
- package/classType.js +1 -2
- package/graphql.js +84 -146
- package/index.d.ts +13 -0
- package/index.js +25 -55
- package/inputTypes.js +9 -16
- package/package.json +6 -1
- package/postgres/index.js +1 -4
- package/postgres/postgres-data-provider.js +165 -364
- package/postgres/postgresColumnSyntax.js +4 -8
- package/remult-express.js +6 -10
- package/remult-knex/index.js +300 -720
- package/remult-middleware.js +24 -30
- package/remult-mongo.js +172 -406
- package/server/JsonEntityFileStorage.js +10 -15
- package/server/expressBridge.js +383 -569
- package/server/index.js +4 -11
- package/server/register-actions-on-server.js +12 -38
- package/server/register-entities-on-server.js +9 -13
- package/src/__EntityValueProvider.js +1 -2
- package/src/__RowsOfDataForTesting.js +1 -2
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +72 -190
- package/src/backend-tests/my-test.backend-spec.js +45 -114
- package/src/column-interfaces.js +2 -6
- package/src/column.js +71 -113
- package/src/context.js +174 -330
- package/src/data-api.js +162 -326
- package/src/data-interfaces.js +7 -11
- package/src/data-providers/array-entity-data-provider.js +171 -286
- package/src/data-providers/in-memory-database.js +12 -27
- package/src/data-providers/json-data-provider.js +41 -77
- package/src/data-providers/rest-data-provider.js +102 -189
- package/src/data-providers/sql-database.js +223 -403
- package/src/data-providers/web-sql-data-provider.js +78 -139
- package/src/entity.js +1 -2
- package/src/filter/filter-consumer-bridge-to-sql-request.js +106 -248
- package/src/filter/filter-consumer-bridge-to-url-builder.js +1 -2
- package/src/filter/filter-interfaces.js +277 -440
- package/src/id-entity.js +8 -17
- package/src/remult3/RepositoryImplementation.js +1191 -2367
- package/src/remult3/index.js +2 -5
- package/src/remult3/remult3.js +1 -2
- package/src/server-action.js +294 -528
- package/src/shared-tests/db-tests-setup.js +49 -153
- package/src/shared-tests/db-tests.db-tests.js +660 -1566
- package/src/shared-tests/deleteAll.js +3 -20
- package/src/shared-tests/entityWithValidations.js +52 -79
- package/src/shared-tests/index.js +4 -6
- package/src/shared-tests/test-custom-id-column.spec.js +37 -85
- package/src/shared-tests/test-special-value.spec.js +64 -104
- package/src/shared-tests/test-update-with-null.spec.js +28 -49
- package/src/sort.js +38 -95
- package/src/sql-command.js +1 -2
- package/src/tests/Done.js +7 -13
- package/src/tests/TestDataApiResponse.js +15 -22
- package/src/tests/c.js +21 -27
- package/src/tests/createData.js +20 -48
- package/src/tests/d.js +19 -27
- package/src/tests/dWithPrefilter.js +31 -44
- package/src/tests/entityForCustomFilter.js +42 -66
- package/src/tests/entityWithValidationsOnColumn.js +21 -29
- package/src/tests/frontend-database-tests-setup.spec.js +35 -98
- package/src/tests/h.js +35 -44
- package/src/tests/remult-3-entities.js +71 -80
- package/src/tests/tasks.js +23 -29
- package/src/tests/testHelper.spec.js +170 -322
- package/src/tests/testModel/models.js +25 -33
- package/src/validators.js +32 -59
- package/urlBuilder.js +8 -14
- package/valueConverters.js +161 -160
package/src/sort.js
CHANGED
|
@@ -1,139 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var column_1 = require("./column");
|
|
6
|
-
var Sort = /** @class */ (function () {
|
|
7
|
-
function Sort() {
|
|
8
|
-
var segments = [];
|
|
9
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
-
segments[_i] = arguments[_i];
|
|
11
|
-
}
|
|
1
|
+
import { CompoundIdField } from "./column";
|
|
2
|
+
export class Sort {
|
|
3
|
+
constructor(...segments) {
|
|
12
4
|
this.Segments = segments;
|
|
13
5
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var seg = _c.value;
|
|
20
|
-
if (seg.isDescending) {
|
|
21
|
-
result[seg.field.key] = "desc";
|
|
22
|
-
}
|
|
23
|
-
else
|
|
24
|
-
result[seg.field.key] = "asc";
|
|
6
|
+
toEntityOrderBy() {
|
|
7
|
+
let result = {};
|
|
8
|
+
for (const seg of this.Segments) {
|
|
9
|
+
if (seg.isDescending) {
|
|
10
|
+
result[seg.field.key] = "desc";
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
finally {
|
|
29
|
-
try {
|
|
30
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
31
|
-
}
|
|
32
|
-
finally { if (e_1) throw e_1.error; }
|
|
12
|
+
else
|
|
13
|
+
result[seg.field.key] = "asc";
|
|
33
14
|
}
|
|
34
15
|
return result;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for (var _b = tslib_1.__values(this.Segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
41
|
-
var s = _c.value;
|
|
42
|
-
r.Segments.push({ field: s.field, isDescending: !s.isDescending });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e_2) throw e_2.error; }
|
|
16
|
+
}
|
|
17
|
+
reverse() {
|
|
18
|
+
let r = new Sort();
|
|
19
|
+
for (const s of this.Segments) {
|
|
20
|
+
r.Segments.push({ field: s.field, isDescending: !s.isDescending });
|
|
51
21
|
}
|
|
52
22
|
return r;
|
|
53
|
-
}
|
|
54
|
-
|
|
23
|
+
}
|
|
24
|
+
static translateOrderByToSort(entityDefs, orderBy) {
|
|
55
25
|
if (!orderBy)
|
|
56
26
|
return undefined;
|
|
57
|
-
|
|
27
|
+
let sort;
|
|
58
28
|
if (orderBy) {
|
|
59
29
|
sort = new Sort();
|
|
60
|
-
for (
|
|
30
|
+
for (const key in orderBy) {
|
|
61
31
|
if (Object.prototype.hasOwnProperty.call(orderBy, key)) {
|
|
62
|
-
|
|
63
|
-
|
|
32
|
+
const element = orderBy[key];
|
|
33
|
+
let field = entityDefs.fields.find(key);
|
|
64
34
|
if (field) {
|
|
65
35
|
switch (element) {
|
|
66
36
|
case "desc":
|
|
67
|
-
sort.Segments.push({ field
|
|
37
|
+
sort.Segments.push({ field, isDescending: true });
|
|
68
38
|
break;
|
|
69
39
|
case "asc":
|
|
70
|
-
sort.Segments.push({ field
|
|
40
|
+
sort.Segments.push({ field });
|
|
71
41
|
}
|
|
72
42
|
}
|
|
73
43
|
}
|
|
74
44
|
}
|
|
75
45
|
}
|
|
76
46
|
return sort;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var e_3, _a;
|
|
47
|
+
}
|
|
48
|
+
static createUniqueSort(entityMetadata, orderBy) {
|
|
80
49
|
if (!orderBy || Object.keys(orderBy).length === 0)
|
|
81
50
|
orderBy = Sort.translateOrderByToSort(entityMetadata, entityMetadata.options.defaultOrderBy);
|
|
82
51
|
if (!orderBy)
|
|
83
52
|
orderBy = new Sort({ field: entityMetadata.idMetadata.field });
|
|
84
|
-
if (entityMetadata.idMetadata.field instanceof
|
|
85
|
-
|
|
86
|
-
if (!orderBy.Segments.find(
|
|
53
|
+
if (entityMetadata.idMetadata.field instanceof CompoundIdField) {
|
|
54
|
+
for (const field of entityMetadata.idMetadata.field.fields) {
|
|
55
|
+
if (!orderBy.Segments.find(x => x.field == field)) {
|
|
87
56
|
orderBy.Segments.push({ field: field });
|
|
88
57
|
}
|
|
89
|
-
};
|
|
90
|
-
try {
|
|
91
|
-
for (var _b = tslib_1.__values(entityMetadata.idMetadata.field.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
92
|
-
var field = _c.value;
|
|
93
|
-
_loop_1(field);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
97
|
-
finally {
|
|
98
|
-
try {
|
|
99
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
100
|
-
}
|
|
101
|
-
finally { if (e_3) throw e_3.error; }
|
|
102
58
|
}
|
|
103
59
|
}
|
|
104
|
-
else if (!orderBy.Segments.find(
|
|
60
|
+
else if (!orderBy.Segments.find(x => x.field == entityMetadata.idMetadata.field)) {
|
|
105
61
|
orderBy.Segments.push({ field: entityMetadata.idMetadata.field });
|
|
106
62
|
}
|
|
107
63
|
return orderBy;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
var _a, e_4, _b;
|
|
64
|
+
}
|
|
65
|
+
static createUniqueEntityOrderBy(entityMetadata, orderBy) {
|
|
111
66
|
if (!orderBy || Object.keys(orderBy).length === 0)
|
|
112
67
|
orderBy = entityMetadata.options.defaultOrderBy;
|
|
113
68
|
if (!orderBy)
|
|
114
|
-
orderBy =
|
|
115
|
-
if (entityMetadata.idMetadata.field instanceof
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!orderBy[field.key]) {
|
|
120
|
-
orderBy[field.key] = "asc";
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
125
|
-
finally {
|
|
126
|
-
try {
|
|
127
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
69
|
+
orderBy = { [entityMetadata.idMetadata.field.key]: "asc" };
|
|
70
|
+
if (entityMetadata.idMetadata.field instanceof CompoundIdField) {
|
|
71
|
+
for (const field of entityMetadata.idMetadata.field.fields) {
|
|
72
|
+
if (!orderBy[field.key]) {
|
|
73
|
+
orderBy[field.key] = "asc";
|
|
128
74
|
}
|
|
129
|
-
finally { if (e_4) throw e_4.error; }
|
|
130
75
|
}
|
|
131
76
|
}
|
|
132
77
|
else if (!orderBy[entityMetadata.idMetadata.field.key]) {
|
|
133
78
|
orderBy[entityMetadata.idMetadata.field.key] = "asc";
|
|
134
79
|
}
|
|
135
80
|
return orderBy;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}());
|
|
139
|
-
exports.Sort = Sort;
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/sql-command.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/src/tests/Done.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Done = void 0;
|
|
4
|
-
var Done = /** @class */ (function () {
|
|
5
|
-
function Done() {
|
|
1
|
+
export class Done {
|
|
2
|
+
constructor() {
|
|
6
3
|
this.happened = false;
|
|
7
4
|
}
|
|
8
|
-
|
|
5
|
+
ok() {
|
|
9
6
|
this.happened = true;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (message === void 0) { message = 'expected to be done'; }
|
|
7
|
+
}
|
|
8
|
+
test(message = 'expected to be done') {
|
|
13
9
|
expect(this.happened).toBe(true, message);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
}());
|
|
17
|
-
exports.Done = Done;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TestDataApiResponse = void 0;
|
|
4
|
-
var TestDataApiResponse = /** @class */ (function () {
|
|
5
|
-
function TestDataApiResponse() {
|
|
1
|
+
export class TestDataApiResponse {
|
|
2
|
+
progress(progress) {
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
TestDataApiResponse.prototype.success = function (data) {
|
|
4
|
+
success(data) {
|
|
10
5
|
throw new Error(('didnt expect success: ' + JSON.stringify(data)));
|
|
11
|
-
}
|
|
12
|
-
|
|
6
|
+
}
|
|
7
|
+
forbidden() {
|
|
13
8
|
throw new Error('didnt expect forbidden:');
|
|
14
|
-
}
|
|
15
|
-
|
|
9
|
+
}
|
|
10
|
+
created(data) {
|
|
16
11
|
throw new Error('didnt expect created: ' + JSON.stringify(data));
|
|
17
|
-
}
|
|
18
|
-
|
|
12
|
+
}
|
|
13
|
+
deleted() {
|
|
19
14
|
throw new Error('didnt expect deleted:');
|
|
20
|
-
}
|
|
21
|
-
|
|
15
|
+
}
|
|
16
|
+
notFound() {
|
|
22
17
|
throw new Error('not found');
|
|
23
|
-
}
|
|
24
|
-
|
|
18
|
+
}
|
|
19
|
+
error(data) {
|
|
25
20
|
throw new Error('error: ' + data + " " + JSON.stringify(data));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}());
|
|
29
|
-
exports.TestDataApiResponse = TestDataApiResponse;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/tests/c.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
tslib_1.__extends(c, _super);
|
|
9
|
-
function c(remult) {
|
|
10
|
-
var _this = _super.call(this) || this;
|
|
11
|
-
_this.remult = remult;
|
|
12
|
-
return _this;
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Remult } from '../context';
|
|
3
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
4
|
+
let c = class c extends EntityBase {
|
|
5
|
+
constructor(remult) {
|
|
6
|
+
super();
|
|
7
|
+
this.remult = remult;
|
|
13
8
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
exports.c = c;
|
|
9
|
+
};
|
|
10
|
+
__decorate([
|
|
11
|
+
Fields.integer(),
|
|
12
|
+
__metadata("design:type", Number)
|
|
13
|
+
], c.prototype, "id", void 0);
|
|
14
|
+
__decorate([
|
|
15
|
+
Fields.string(),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], c.prototype, "name", void 0);
|
|
18
|
+
c = __decorate([
|
|
19
|
+
Entity('c', { allowApiCrud: true }),
|
|
20
|
+
__metadata("design:paramtypes", [Remult])
|
|
21
|
+
], c);
|
|
22
|
+
export { c };
|
package/src/tests/createData.js
CHANGED
|
@@ -1,50 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return [4 /*yield*/, deleteAll_1.deleteAll(remult.repo(entity))];
|
|
21
|
-
case 1:
|
|
22
|
-
rep = _a.sent();
|
|
23
|
-
if (!doInsert) return [3 /*break*/, 3];
|
|
24
|
-
return [4 /*yield*/, doInsert(function (id, name, description, status) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
25
|
-
var c;
|
|
26
|
-
return tslib_1.__generator(this, function (_a) {
|
|
27
|
-
switch (_a.label) {
|
|
28
|
-
case 0:
|
|
29
|
-
c = rep.create();
|
|
30
|
-
c.id = id;
|
|
31
|
-
c.categoryName = name;
|
|
32
|
-
c.description = description;
|
|
33
|
-
if (status)
|
|
34
|
-
c.status = status;
|
|
35
|
-
return [4 /*yield*/, rep.save(c)];
|
|
36
|
-
case 1:
|
|
37
|
-
_a.sent();
|
|
38
|
-
return [2 /*return*/];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}); })];
|
|
42
|
-
case 2:
|
|
43
|
-
_a.sent();
|
|
44
|
-
_a.label = 3;
|
|
45
|
-
case 3: return [2 /*return*/, [rep, remult]];
|
|
46
|
-
}
|
|
1
|
+
import { InMemoryDataProvider } from '../data-providers/in-memory-database';
|
|
2
|
+
import { Remult } from '../context';
|
|
3
|
+
import { Categories as newCategories } from './remult-3-entities';
|
|
4
|
+
import { deleteAll } from '../shared-tests/deleteAll';
|
|
5
|
+
export async function createData(doInsert, entity) {
|
|
6
|
+
let remult = new Remult();
|
|
7
|
+
remult.setDataProvider(new InMemoryDataProvider());
|
|
8
|
+
if (!entity)
|
|
9
|
+
entity = newCategories;
|
|
10
|
+
let rep = await deleteAll(remult.repo(entity));
|
|
11
|
+
if (doInsert)
|
|
12
|
+
await doInsert(async (id, name, description, status) => {
|
|
13
|
+
let c = rep.create();
|
|
14
|
+
c.id = id;
|
|
15
|
+
c.categoryName = name;
|
|
16
|
+
c.description = description;
|
|
17
|
+
if (status)
|
|
18
|
+
c.status = status;
|
|
19
|
+
await rep.save(c);
|
|
47
20
|
});
|
|
48
|
-
|
|
21
|
+
return [rep, remult];
|
|
49
22
|
}
|
|
50
|
-
exports.createData = createData;
|
package/src/tests/d.js
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
d = tslib_1.__decorate([
|
|
21
|
-
remult3_1.Entity('d1', {
|
|
22
|
-
allowApiCrud: true
|
|
23
|
-
})
|
|
24
|
-
], d);
|
|
25
|
-
return d;
|
|
26
|
-
}(remult3_1.EntityBase));
|
|
27
|
-
exports.d = d;
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
3
|
+
let d = class d extends EntityBase {
|
|
4
|
+
};
|
|
5
|
+
d.count = 0;
|
|
6
|
+
__decorate([
|
|
7
|
+
Fields.integer(),
|
|
8
|
+
__metadata("design:type", Number)
|
|
9
|
+
], d.prototype, "id", void 0);
|
|
10
|
+
__decorate([
|
|
11
|
+
Fields.integer(),
|
|
12
|
+
__metadata("design:type", Number)
|
|
13
|
+
], d.prototype, "b", void 0);
|
|
14
|
+
d = __decorate([
|
|
15
|
+
Entity('d1', {
|
|
16
|
+
allowApiCrud: true
|
|
17
|
+
})
|
|
18
|
+
], d);
|
|
19
|
+
export { d };
|
|
@@ -1,45 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function dWithPrefilter() {
|
|
10
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1
|
+
var dWithPrefilter_1;
|
|
2
|
+
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { BackendMethod } from '../server-action';
|
|
4
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
5
|
+
let dWithPrefilter = dWithPrefilter_1 = class dWithPrefilter extends EntityBase {
|
|
6
|
+
async doIt() {
|
|
7
|
+
dWithPrefilter_1.count++;
|
|
8
|
+
return true;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
36
|
-
], dWithPrefilter.prototype, "doIt", null);
|
|
37
|
-
dWithPrefilter = dWithPrefilter_1 = tslib_1.__decorate([
|
|
38
|
-
remult3_1.Entity('d', {
|
|
39
|
-
apiPrefilter: { b: 2 },
|
|
40
|
-
allowApiCrud: true
|
|
41
|
-
})
|
|
42
|
-
], dWithPrefilter);
|
|
43
|
-
return dWithPrefilter;
|
|
44
|
-
}(remult3_1.EntityBase));
|
|
45
|
-
exports.dWithPrefilter = dWithPrefilter;
|
|
10
|
+
};
|
|
11
|
+
dWithPrefilter.count = 0;
|
|
12
|
+
__decorate([
|
|
13
|
+
Fields.integer(),
|
|
14
|
+
__metadata("design:type", Number)
|
|
15
|
+
], dWithPrefilter.prototype, "id", void 0);
|
|
16
|
+
__decorate([
|
|
17
|
+
Fields.integer(),
|
|
18
|
+
__metadata("design:type", Number)
|
|
19
|
+
], dWithPrefilter.prototype, "b", void 0);
|
|
20
|
+
__decorate([
|
|
21
|
+
BackendMethod({ allowed: true }),
|
|
22
|
+
__metadata("design:type", Function),
|
|
23
|
+
__metadata("design:paramtypes", []),
|
|
24
|
+
__metadata("design:returntype", Promise)
|
|
25
|
+
], dWithPrefilter.prototype, "doIt", null);
|
|
26
|
+
dWithPrefilter = dWithPrefilter_1 = __decorate([
|
|
27
|
+
Entity('d', {
|
|
28
|
+
apiPrefilter: { b: 2 },
|
|
29
|
+
allowApiCrud: true
|
|
30
|
+
})
|
|
31
|
+
], dWithPrefilter);
|
|
32
|
+
export { dWithPrefilter };
|
|
@@ -1,68 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
r.push({ id: [1, 3] });
|
|
25
|
-
if (c.two)
|
|
26
|
-
r.push({ id: 2 });
|
|
27
|
-
if (!c.dbOneOrThree) return [3 /*break*/, 2];
|
|
28
|
-
meta_1 = remult.repo(entityForCustomFilter_1).metadata;
|
|
29
|
-
return [4 /*yield*/, filter_consumer_bridge_to_sql_request_1.getDbNameProvider(meta_1)];
|
|
30
|
-
case 1:
|
|
31
|
-
e_1 = _a.sent();
|
|
32
|
-
r.push({
|
|
33
|
-
$and: [
|
|
34
|
-
sql_database_1.SqlDatabase.customFilter(function (x) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
35
|
-
return [2 /*return*/, x.sql = e_1.nameOf(meta_1.fields.id) + ' in (' + x.addParameterAndReturnSqlToken(1) + "," + x.addParameterAndReturnSqlToken(3) + ")"];
|
|
36
|
-
}); }); }),
|
|
37
|
-
array_entity_data_provider_1.ArrayEntityDataProvider.customFilter(function (x) { return x.id == 1 || x.id == 3; })
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
_a.label = 2;
|
|
41
|
-
case 2: return [2 /*return*/, { $and: r }];
|
|
42
|
-
}
|
|
1
|
+
var entityForCustomFilter_1;
|
|
2
|
+
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { SqlDatabase } from '../data-providers/sql-database';
|
|
4
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
5
|
+
import { Filter } from '../filter/filter-interfaces';
|
|
6
|
+
import { ArrayEntityDataProvider } from '../data-providers/array-entity-data-provider';
|
|
7
|
+
import { getDbNameProvider } from '../filter/filter-consumer-bridge-to-sql-request';
|
|
8
|
+
let entityForCustomFilter = entityForCustomFilter_1 = class entityForCustomFilter extends EntityBase {
|
|
9
|
+
};
|
|
10
|
+
entityForCustomFilter.filter = Filter.createCustom(async (remult, c) => {
|
|
11
|
+
let r = [];
|
|
12
|
+
if (c.oneAndThree)
|
|
13
|
+
r.push({ id: [1, 3] });
|
|
14
|
+
if (c.two)
|
|
15
|
+
r.push({ id: 2 });
|
|
16
|
+
if (c.dbOneOrThree) {
|
|
17
|
+
let meta = remult.repo(entityForCustomFilter_1).metadata;
|
|
18
|
+
const e = await getDbNameProvider(meta);
|
|
19
|
+
r.push({
|
|
20
|
+
$and: [
|
|
21
|
+
SqlDatabase.customFilter(async (x) => x.sql = e.nameOf(meta.fields.id) + ' in (' + x.addParameterAndReturnSqlToken(1) + "," + x.addParameterAndReturnSqlToken(3) + ")"),
|
|
22
|
+
ArrayEntityDataProvider.customFilter(x => x.id == 1 || x.id == 3)
|
|
23
|
+
]
|
|
43
24
|
});
|
|
44
|
-
}); });
|
|
45
|
-
entityForCustomFilter.oneAndThree = filter_interfaces_1.Filter.createCustom(function () { return ({ id: [1, 3] }); });
|
|
46
|
-
entityForCustomFilter.testNumericValue = filter_interfaces_1.Filter.createCustom(function (r, val) { return ({ id: val }); });
|
|
47
|
-
entityForCustomFilter.testObjectValue = filter_interfaces_1.Filter.createCustom(function (r, val) { return ({ id: val.val }); });
|
|
48
|
-
tslib_1.__decorate([
|
|
49
|
-
remult3_1.Fields.integer(),
|
|
50
|
-
tslib_1.__metadata("design:type", Number)
|
|
51
|
-
], entityForCustomFilter.prototype, "id", void 0);
|
|
52
|
-
entityForCustomFilter = entityForCustomFilter_1 = tslib_1.__decorate([
|
|
53
|
-
remult3_1.Entity('entityForCustomFilter', { allowApiCrud: true })
|
|
54
|
-
], entityForCustomFilter);
|
|
55
|
-
return entityForCustomFilter;
|
|
56
|
-
}(remult3_1.EntityBase));
|
|
57
|
-
exports.entityForCustomFilter = entityForCustomFilter;
|
|
58
|
-
var entityForCustomFilter1 = /** @class */ (function (_super) {
|
|
59
|
-
tslib_1.__extends(entityForCustomFilter1, _super);
|
|
60
|
-
function entityForCustomFilter1() {
|
|
61
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
62
25
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
26
|
+
return { $and: r };
|
|
27
|
+
});
|
|
28
|
+
entityForCustomFilter.oneAndThree = Filter.createCustom(() => ({ id: [1, 3] }));
|
|
29
|
+
entityForCustomFilter.testNumericValue = Filter.createCustom((r, val) => ({ id: val }));
|
|
30
|
+
entityForCustomFilter.testObjectValue = Filter.createCustom((r, val) => ({ id: val.val }));
|
|
31
|
+
__decorate([
|
|
32
|
+
Fields.integer(),
|
|
33
|
+
__metadata("design:type", Number)
|
|
34
|
+
], entityForCustomFilter.prototype, "id", void 0);
|
|
35
|
+
entityForCustomFilter = entityForCustomFilter_1 = __decorate([
|
|
36
|
+
Entity('entityForCustomFilter', { allowApiCrud: true })
|
|
37
|
+
], entityForCustomFilter);
|
|
38
|
+
export { entityForCustomFilter };
|
|
39
|
+
let entityForCustomFilter1 = class entityForCustomFilter1 extends entityForCustomFilter {
|
|
40
|
+
};
|
|
41
|
+
entityForCustomFilter1 = __decorate([
|
|
42
|
+
Entity('entityForCustomFilter1', { allowApiCrud: true })
|
|
43
|
+
], entityForCustomFilter1);
|
|
44
|
+
export { entityForCustomFilter1 };
|