remult 0.14.4 → 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.js +25 -73
- package/inputTypes.js +9 -16
- package/package.json +2 -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
|
@@ -1,379 +1,264 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var filter_interfaces_1 = require("../filter/filter-interfaces");
|
|
6
|
-
var column_1 = require("../column");
|
|
7
|
-
var ArrayEntityDataProvider = /** @class */ (function () {
|
|
8
|
-
function ArrayEntityDataProvider(entity, rows) {
|
|
9
|
-
var e_1, _a;
|
|
1
|
+
import { customDatabaseFilterToken, Filter } from '../filter/filter-interfaces';
|
|
2
|
+
import { CompoundIdField } from '../column';
|
|
3
|
+
export class ArrayEntityDataProvider {
|
|
4
|
+
constructor(entity, rows) {
|
|
10
5
|
this.entity = entity;
|
|
11
6
|
this.rows = rows;
|
|
12
7
|
if (!rows)
|
|
13
8
|
rows = [];
|
|
14
9
|
else {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var r = rows_1_1.value;
|
|
18
|
-
this.verifyThatRowHasAllNotNullColumns(r);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
22
|
-
finally {
|
|
23
|
-
try {
|
|
24
|
-
if (rows_1_1 && !rows_1_1.done && (_a = rows_1.return)) _a.call(rows_1);
|
|
25
|
-
}
|
|
26
|
-
finally { if (e_1) throw e_1.error; }
|
|
10
|
+
for (const r of rows) {
|
|
11
|
+
this.verifyThatRowHasAllNotNullColumns(r);
|
|
27
12
|
}
|
|
28
13
|
}
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_a[filter_interfaces_1.customDatabaseFilterToken] = {
|
|
15
|
+
static customFilter(filter) {
|
|
16
|
+
return {
|
|
17
|
+
[customDatabaseFilterToken]: {
|
|
34
18
|
arrayFilter: filter
|
|
35
|
-
},
|
|
36
|
-
_a;
|
|
37
|
-
};
|
|
38
|
-
ArrayEntityDataProvider.prototype.verifyThatRowHasAllNotNullColumns = function (r) {
|
|
39
|
-
var e_2, _a;
|
|
40
|
-
try {
|
|
41
|
-
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
42
|
-
var f = _c.value;
|
|
43
|
-
if (!f.isServerExpression)
|
|
44
|
-
if (!f.allowNull) {
|
|
45
|
-
if (r[f.key] === undefined || r[f.key] === null) {
|
|
46
|
-
var val = undefined;
|
|
47
|
-
if (f.valueType === Boolean)
|
|
48
|
-
val = false;
|
|
49
|
-
else if (f.valueType === Number)
|
|
50
|
-
val = 0;
|
|
51
|
-
else if (f.valueType === String)
|
|
52
|
-
val = '';
|
|
53
|
-
r[f.key] = val;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (r[f.key] === undefined)
|
|
57
|
-
r[f.key] = null;
|
|
58
19
|
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
verifyThatRowHasAllNotNullColumns(r) {
|
|
23
|
+
for (const f of this.entity.fields) {
|
|
24
|
+
if (!f.isServerExpression)
|
|
25
|
+
if (!f.allowNull) {
|
|
26
|
+
if (r[f.key] === undefined || r[f.key] === null) {
|
|
27
|
+
let val = undefined;
|
|
28
|
+
if (f.valueType === Boolean)
|
|
29
|
+
val = false;
|
|
30
|
+
else if (f.valueType === Number)
|
|
31
|
+
val = 0;
|
|
32
|
+
else if (f.valueType === String)
|
|
33
|
+
val = '';
|
|
34
|
+
r[f.key] = val;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (r[f.key] === undefined)
|
|
38
|
+
r[f.key] = null;
|
|
59
39
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
}
|
|
41
|
+
async count(where) {
|
|
42
|
+
let rows = this.rows;
|
|
43
|
+
let j = 0;
|
|
44
|
+
for (let i = 0; i < rows.length; i++) {
|
|
45
|
+
if (!where) {
|
|
46
|
+
j++;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
let x = new FilterConsumerBridgeToObject(rows[i]);
|
|
50
|
+
where.__applyToConsumer(x);
|
|
51
|
+
if (x.ok)
|
|
52
|
+
j++;
|
|
64
53
|
}
|
|
65
|
-
finally { if (e_2) throw e_2.error; }
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return tslib_1.__generator(this, function (_a) {
|
|
94
|
-
rows = this.rows;
|
|
95
|
-
if (options) {
|
|
96
|
-
if (options.where) {
|
|
97
|
-
rows = rows.filter(function (i) {
|
|
98
|
-
var x = new FilterConsumerBridgeToObject(i);
|
|
99
|
-
options.where.__applyToConsumer(x);
|
|
100
|
-
return x.ok;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (options.orderBy) {
|
|
104
|
-
rows = rows.sort(function (a, b) {
|
|
105
|
-
var r = 0;
|
|
106
|
-
for (var i = 0; i < options.orderBy.Segments.length; i++) {
|
|
107
|
-
var seg = options.orderBy.Segments[i];
|
|
108
|
-
var left = a[seg.field.key];
|
|
109
|
-
var right = b[seg.field.key];
|
|
110
|
-
if (left > right)
|
|
111
|
-
r = 1;
|
|
112
|
-
else if (left < right)
|
|
113
|
-
r = -1;
|
|
114
|
-
if (r != 0) {
|
|
115
|
-
if (seg.isDescending)
|
|
116
|
-
r *= -1;
|
|
117
|
-
return r;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
55
|
+
return j;
|
|
56
|
+
}
|
|
57
|
+
async find(options) {
|
|
58
|
+
let rows = this.rows;
|
|
59
|
+
if (options) {
|
|
60
|
+
if (options.where) {
|
|
61
|
+
rows = rows.filter(i => {
|
|
62
|
+
let x = new FilterConsumerBridgeToObject(i);
|
|
63
|
+
options.where.__applyToConsumer(x);
|
|
64
|
+
return x.ok;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (options.orderBy) {
|
|
68
|
+
rows = rows.sort((a, b) => {
|
|
69
|
+
let r = 0;
|
|
70
|
+
for (let i = 0; i < options.orderBy.Segments.length; i++) {
|
|
71
|
+
let seg = options.orderBy.Segments[i];
|
|
72
|
+
let left = a[seg.field.key];
|
|
73
|
+
let right = b[seg.field.key];
|
|
74
|
+
if (left > right)
|
|
75
|
+
r = 1;
|
|
76
|
+
else if (left < right)
|
|
77
|
+
r = -1;
|
|
78
|
+
if (r != 0) {
|
|
79
|
+
if (seg.isDescending)
|
|
80
|
+
r *= -1;
|
|
120
81
|
return r;
|
|
121
|
-
}
|
|
82
|
+
}
|
|
122
83
|
}
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
if (rows)
|
|
126
|
-
return [2 /*return*/, rows.map(function (i) {
|
|
127
|
-
return _this.translateFromJson(i);
|
|
128
|
-
})];
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
ArrayEntityDataProvider.prototype.translateFromJson = function (row) {
|
|
134
|
-
var e_3, _a;
|
|
135
|
-
var result = {};
|
|
136
|
-
try {
|
|
137
|
-
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
138
|
-
var col = _c.value;
|
|
139
|
-
result[col.key] = col.valueConverter.fromJson(row[col.key]);
|
|
84
|
+
return r;
|
|
85
|
+
});
|
|
140
86
|
}
|
|
87
|
+
rows = pageArray(rows, options);
|
|
141
88
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
89
|
+
if (rows)
|
|
90
|
+
return rows.map(i => {
|
|
91
|
+
return this.translateFromJson(i);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
translateFromJson(row) {
|
|
95
|
+
let result = {};
|
|
96
|
+
for (const col of this.entity.fields) {
|
|
97
|
+
result[col.key] = col.valueConverter.fromJson(row[col.key]);
|
|
148
98
|
}
|
|
149
99
|
return result;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
156
|
-
var col = _c.value;
|
|
157
|
-
result[col.key] = col.valueConverter.toJson(row[col.key]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
161
|
-
finally {
|
|
162
|
-
try {
|
|
163
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
164
|
-
}
|
|
165
|
-
finally { if (e_4) throw e_4.error; }
|
|
100
|
+
}
|
|
101
|
+
translateToJson(row) {
|
|
102
|
+
let result = {};
|
|
103
|
+
for (const col of this.entity.fields) {
|
|
104
|
+
result[col.key] = col.valueConverter.toJson(row[col.key]);
|
|
166
105
|
}
|
|
167
106
|
return result;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
filter_interfaces_1.Filter.fromEntityFilter(_this.entity, _this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(x);
|
|
107
|
+
}
|
|
108
|
+
idMatches(id) {
|
|
109
|
+
return item => {
|
|
110
|
+
let x = new FilterConsumerBridgeToObject(item);
|
|
111
|
+
Filter.fromEntityFilter(this.entity, this.entity.idMetadata.getIdFilter(id)).__applyToConsumer(x);
|
|
174
112
|
return x.ok;
|
|
175
113
|
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
var r = this.rows[i];
|
|
114
|
+
}
|
|
115
|
+
update(id, data) {
|
|
116
|
+
let idMatches = this.idMatches(id);
|
|
117
|
+
let keys = Object.keys(data);
|
|
118
|
+
for (let i = 0; i < this.rows.length; i++) {
|
|
119
|
+
let r = this.rows[i];
|
|
183
120
|
if (idMatches(r)) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (keys.includes(f.key)) {
|
|
190
|
-
newR[f.key] = f.valueConverter.toJson(data[f.key]);
|
|
191
|
-
}
|
|
121
|
+
let newR = { ...r };
|
|
122
|
+
for (const f of this.entity.fields) {
|
|
123
|
+
if (!f.dbReadOnly && !f.isServerExpression) {
|
|
124
|
+
if (keys.includes(f.key)) {
|
|
125
|
+
newR[f.key] = f.valueConverter.toJson(data[f.key]);
|
|
192
126
|
}
|
|
193
127
|
}
|
|
194
128
|
}
|
|
195
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
196
|
-
finally {
|
|
197
|
-
try {
|
|
198
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
199
|
-
}
|
|
200
|
-
finally { if (e_5) throw e_5.error; }
|
|
201
|
-
}
|
|
202
129
|
this.verifyThatRowHasAllNotNullColumns(newR);
|
|
203
130
|
this.rows[i] = newR;
|
|
204
131
|
return Promise.resolve(this.translateFromJson(this.rows[i]));
|
|
205
132
|
}
|
|
206
133
|
}
|
|
207
134
|
throw new Error("couldn't find id to update: " + id);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
for (
|
|
135
|
+
}
|
|
136
|
+
delete(id) {
|
|
137
|
+
let idMatches = this.idMatches(id);
|
|
138
|
+
for (let i = 0; i < this.rows.length; i++) {
|
|
212
139
|
if (idMatches(this.rows[i])) {
|
|
213
140
|
this.rows.splice(i, 1);
|
|
214
141
|
return Promise.resolve();
|
|
215
142
|
}
|
|
216
143
|
}
|
|
217
144
|
throw new Error("couldn't find id to delete: " + id);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (((_a = idf.options.valueConverter) === null || _a === void 0 ? void 0 : _a.fieldTypeInDb) === 'autoincrement') {
|
|
228
|
-
data[idf.key] = 1;
|
|
229
|
-
try {
|
|
230
|
-
for (_b = tslib_1.__values(this.rows), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
231
|
-
row = _c.value;
|
|
232
|
-
if (row[idf.key] >= data[idf.key])
|
|
233
|
-
data[idf.key] = row[idf.key] + 1;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
237
|
-
finally {
|
|
238
|
-
try {
|
|
239
|
-
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
240
|
-
}
|
|
241
|
-
finally { if (e_6) throw e_6.error; }
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (data[idf.key])
|
|
245
|
-
this.rows.forEach(function (i) {
|
|
246
|
-
if (data[idf.key] == i[idf.key])
|
|
247
|
-
throw Error("id already exists");
|
|
248
|
-
});
|
|
145
|
+
}
|
|
146
|
+
async insert(data) {
|
|
147
|
+
let idf = this.entity.idMetadata.field;
|
|
148
|
+
if (!(idf instanceof CompoundIdField)) {
|
|
149
|
+
if (idf.options.valueConverter?.fieldTypeInDb === 'autoincrement') {
|
|
150
|
+
data[idf.key] = 1;
|
|
151
|
+
for (const row of this.rows) {
|
|
152
|
+
if (row[idf.key] >= data[idf.key])
|
|
153
|
+
data[idf.key] = row[idf.key] + 1;
|
|
249
154
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
this.rows.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
155
|
+
}
|
|
156
|
+
if (data[idf.key])
|
|
157
|
+
this.rows.forEach(i => {
|
|
158
|
+
if (data[idf.key] == i[idf.key])
|
|
159
|
+
throw Error("id already exists");
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
let j = this.translateToJson(data);
|
|
163
|
+
this.verifyThatRowHasAllNotNullColumns(j);
|
|
164
|
+
this.rows.push(j);
|
|
165
|
+
return Promise.resolve(this.translateFromJson(j));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
260
168
|
function pageArray(rows, options) {
|
|
261
169
|
if (!options)
|
|
262
170
|
return rows;
|
|
263
171
|
if (!options.limit)
|
|
264
172
|
return rows;
|
|
265
|
-
|
|
173
|
+
let page = 1;
|
|
266
174
|
if (options.page)
|
|
267
175
|
page = options.page;
|
|
268
176
|
if (page < 1)
|
|
269
177
|
page = 1;
|
|
270
|
-
|
|
271
|
-
return rows.filter(
|
|
178
|
+
let x = 0;
|
|
179
|
+
return rows.filter(i => {
|
|
272
180
|
x++;
|
|
273
|
-
|
|
274
|
-
|
|
181
|
+
let max = page * options.limit;
|
|
182
|
+
let min = max - options.limit;
|
|
275
183
|
return x > min && x <= max;
|
|
276
184
|
});
|
|
277
185
|
}
|
|
278
|
-
|
|
279
|
-
|
|
186
|
+
class FilterConsumerBridgeToObject {
|
|
187
|
+
constructor(row) {
|
|
280
188
|
this.row = row;
|
|
281
189
|
this.ok = true;
|
|
282
190
|
}
|
|
283
|
-
|
|
191
|
+
databaseCustom(databaseCustom) {
|
|
284
192
|
if (databaseCustom && databaseCustom.arrayFilter) {
|
|
285
193
|
if (!databaseCustom.arrayFilter(this.row))
|
|
286
194
|
this.ok = false;
|
|
287
195
|
}
|
|
288
|
-
}
|
|
289
|
-
|
|
196
|
+
}
|
|
197
|
+
custom(key, customItem) {
|
|
290
198
|
throw new Error('Custom Filter should be translated before it gets here');
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
element.__applyToConsumer(filter);
|
|
299
|
-
if (filter.ok) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
305
|
-
finally {
|
|
306
|
-
try {
|
|
307
|
-
if (orElements_1_1 && !orElements_1_1.done && (_a = orElements_1.return)) _a.call(orElements_1);
|
|
199
|
+
}
|
|
200
|
+
or(orElements) {
|
|
201
|
+
for (const element of orElements) {
|
|
202
|
+
let filter = new FilterConsumerBridgeToObject(this.row);
|
|
203
|
+
element.__applyToConsumer(filter);
|
|
204
|
+
if (filter.ok) {
|
|
205
|
+
return;
|
|
308
206
|
}
|
|
309
|
-
finally { if (e_7) throw e_7.error; }
|
|
310
207
|
}
|
|
311
208
|
this.ok = false;
|
|
312
|
-
}
|
|
313
|
-
|
|
209
|
+
}
|
|
210
|
+
isNull(col) {
|
|
314
211
|
if (this.row[col.key] != null)
|
|
315
212
|
this.ok = false;
|
|
316
|
-
}
|
|
317
|
-
|
|
213
|
+
}
|
|
214
|
+
isNotNull(col) {
|
|
318
215
|
if (this.row[col.key] == null)
|
|
319
216
|
this.ok = false;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
var v = val_1_1.value;
|
|
326
|
-
if (this.row[col.key] == col.valueConverter.toJson(v)) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
332
|
-
finally {
|
|
333
|
-
try {
|
|
334
|
-
if (val_1_1 && !val_1_1.done && (_a = val_1.return)) _a.call(val_1);
|
|
217
|
+
}
|
|
218
|
+
isIn(col, val) {
|
|
219
|
+
for (const v of val) {
|
|
220
|
+
if (this.row[col.key] == col.valueConverter.toJson(v)) {
|
|
221
|
+
return;
|
|
335
222
|
}
|
|
336
|
-
finally { if (e_8) throw e_8.error; }
|
|
337
223
|
}
|
|
338
224
|
this.ok = false;
|
|
339
|
-
}
|
|
340
|
-
|
|
225
|
+
}
|
|
226
|
+
isEqualTo(col, val) {
|
|
341
227
|
if (this.row[col.key] != col.valueConverter.toJson(val))
|
|
342
228
|
this.ok = false;
|
|
343
|
-
}
|
|
344
|
-
|
|
229
|
+
}
|
|
230
|
+
isDifferentFrom(col, val) {
|
|
345
231
|
if (this.row[col.key] == col.valueConverter.toJson(val))
|
|
346
232
|
this.ok = false;
|
|
347
|
-
}
|
|
348
|
-
|
|
233
|
+
}
|
|
234
|
+
isGreaterOrEqualTo(col, val) {
|
|
349
235
|
if (this.row[col.key] < col.valueConverter.toJson(val))
|
|
350
236
|
this.ok = false;
|
|
351
|
-
}
|
|
352
|
-
|
|
237
|
+
}
|
|
238
|
+
isGreaterThan(col, val) {
|
|
353
239
|
if (this.row[col.key] <= col.valueConverter.toJson(val))
|
|
354
240
|
this.ok = false;
|
|
355
|
-
}
|
|
356
|
-
|
|
241
|
+
}
|
|
242
|
+
isLessOrEqualTo(col, val) {
|
|
357
243
|
if (this.row[col.key] > col.valueConverter.toJson(val))
|
|
358
244
|
this.ok = false;
|
|
359
|
-
}
|
|
360
|
-
|
|
245
|
+
}
|
|
246
|
+
isLessThan(col, val) {
|
|
361
247
|
if (this.row[col.key] >= col.valueConverter.toJson(val))
|
|
362
248
|
this.ok = false;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
249
|
+
}
|
|
250
|
+
containsCaseInsensitive(col, val) {
|
|
251
|
+
let v = this.row[col.key];
|
|
366
252
|
if (!v) {
|
|
367
253
|
this.ok = false;
|
|
368
254
|
return;
|
|
369
255
|
}
|
|
370
|
-
|
|
256
|
+
let s = '' + v;
|
|
371
257
|
if (val)
|
|
372
258
|
val = col.valueConverter.toJson(val);
|
|
373
259
|
if (val)
|
|
374
260
|
val = val.toString().toLowerCase();
|
|
375
261
|
if (s.toLowerCase().indexOf(val) < 0)
|
|
376
262
|
this.ok = false;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
}());
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var array_entity_data_provider_1 = require("./array-entity-data-provider");
|
|
6
|
-
var InMemoryDataProvider = /** @class */ (function () {
|
|
7
|
-
function InMemoryDataProvider() {
|
|
1
|
+
import { ArrayEntityDataProvider } from './array-entity-data-provider';
|
|
2
|
+
export class InMemoryDataProvider {
|
|
3
|
+
constructor() {
|
|
8
4
|
this.rows = {};
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
case 1:
|
|
16
|
-
_a.sent();
|
|
17
|
-
return [2 /*return*/];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
InMemoryDataProvider.prototype.getEntityDataProvider = function (entity) {
|
|
23
|
-
var name = entity.key;
|
|
6
|
+
async transaction(action) {
|
|
7
|
+
await action(this);
|
|
8
|
+
}
|
|
9
|
+
getEntityDataProvider(entity) {
|
|
10
|
+
let name = entity.key;
|
|
24
11
|
if (!this.rows[name])
|
|
25
12
|
this.rows[name] = [];
|
|
26
|
-
return new
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}());
|
|
31
|
-
exports.InMemoryDataProvider = InMemoryDataProvider;
|
|
13
|
+
return new ArrayEntityDataProvider(entity, this.rows[name]);
|
|
14
|
+
}
|
|
15
|
+
toString() { return "InMemoryDataProvider"; }
|
|
16
|
+
}
|