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
|
@@ -1,170 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var context_1 = require("../context");
|
|
6
|
-
var in_memory_database_1 = require("../data-providers/in-memory-database");
|
|
7
|
-
var remult_3_entities_1 = require("../tests/remult-3-entities");
|
|
8
|
-
function itWithFocus(key, what, focus) {
|
|
9
|
-
if (focus === void 0) { focus = false; }
|
|
1
|
+
import { Remult } from "../context";
|
|
2
|
+
import { InMemoryDataProvider } from "../data-providers/in-memory-database";
|
|
3
|
+
import { Categories } from "../tests/remult-3-entities";
|
|
4
|
+
export function itWithFocus(key, what, focus = false) {
|
|
10
5
|
if (focus)
|
|
11
6
|
fit(key, what);
|
|
12
7
|
else
|
|
13
8
|
it(key, what);
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (focus === void 0) { focus = false; }
|
|
19
|
-
try {
|
|
20
|
-
for (var databasesTesters_1 = tslib_1.__values(databasesTesters), databasesTesters_1_1 = databasesTesters_1.next(); !databasesTesters_1_1.done; databasesTesters_1_1 = databasesTesters_1.next()) {
|
|
21
|
-
var test_1 = databasesTesters_1_1.value;
|
|
22
|
-
test_1(key, what, focus);
|
|
23
|
-
}
|
|
10
|
+
export function testAll(key, what, focus = false) {
|
|
11
|
+
for (const test of databasesTesters) {
|
|
12
|
+
test(key, what, focus);
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
finally {
|
|
27
|
-
try {
|
|
28
|
-
if (databasesTesters_1_1 && !databasesTesters_1_1.done && (_a = databasesTesters_1.return)) _a.call(databasesTesters_1);
|
|
29
|
-
}
|
|
30
|
-
finally { if (e_1) throw e_1.error; }
|
|
31
|
-
}
|
|
32
|
-
loadedTests.push(function (x) {
|
|
14
|
+
loadedTests.push(x => {
|
|
33
15
|
x(key, what, focus);
|
|
34
16
|
});
|
|
35
17
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
for (var loadedTests_1 = tslib_1.__values(loadedTests), loadedTests_1_1 = loadedTests_1.next(); !loadedTests_1_1.done; loadedTests_1_1 = loadedTests_1.next()) {
|
|
43
|
-
var test_2 = loadedTests_1_1.value;
|
|
44
|
-
test_2(tester);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
48
|
-
finally {
|
|
49
|
-
try {
|
|
50
|
-
if (loadedTests_1_1 && !loadedTests_1_1.done && (_a = loadedTests_1.return)) _a.call(loadedTests_1);
|
|
51
|
-
}
|
|
52
|
-
finally { if (e_2) throw e_2.error; }
|
|
18
|
+
const databasesTesters = [];
|
|
19
|
+
const loadedTests = [];
|
|
20
|
+
export function addDatabaseToTest(tester) {
|
|
21
|
+
for (const test of loadedTests) {
|
|
22
|
+
test(tester);
|
|
53
23
|
}
|
|
54
24
|
databasesTesters.push(tester);
|
|
55
25
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return tslib_1.__generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
remult = new context_1.Remult();
|
|
67
|
-
db = new in_memory_database_1.InMemoryDataProvider();
|
|
68
|
-
remult.setDataProvider(db);
|
|
69
|
-
return [4 /*yield*/, what({ db: db, remult: remult, createEntity: function (x) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
70
|
-
return [2 /*return*/, remult.repo(x)];
|
|
71
|
-
}); }); } })];
|
|
72
|
-
case 1:
|
|
73
|
-
_a.sent();
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); }, focus);
|
|
26
|
+
export function testInMemory(key, what, focus = false) {
|
|
27
|
+
itWithFocus(key + " - in memory", async () => {
|
|
28
|
+
let remult = new Remult();
|
|
29
|
+
let db = new InMemoryDataProvider();
|
|
30
|
+
remult.setDataProvider(db);
|
|
31
|
+
await what({ db, remult, createEntity: async (x) => remult.repo(x) });
|
|
32
|
+
}, focus);
|
|
78
33
|
}
|
|
79
|
-
exports.testInMemory = testInMemory;
|
|
80
34
|
databasesTesters.push(testInMemory);
|
|
81
|
-
function testAllDbs(key, doTest, focus) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var _this = this;
|
|
97
|
-
return tslib_1.__generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0:
|
|
100
|
-
if (!entity)
|
|
101
|
-
entity = remult_3_entities_1.Categories;
|
|
102
|
-
return [4 /*yield*/, createEntity(entity)];
|
|
103
|
-
case 1:
|
|
104
|
-
rep = _a.sent();
|
|
105
|
-
if (!doInsert) return [3 /*break*/, 3];
|
|
106
|
-
return [4 /*yield*/, doInsert(function (id, name, description, status) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
107
|
-
var c;
|
|
108
|
-
return tslib_1.__generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0:
|
|
111
|
-
c = rep.create();
|
|
112
|
-
c.id = id;
|
|
113
|
-
c.categoryName = name;
|
|
114
|
-
c.description = description;
|
|
115
|
-
if (status)
|
|
116
|
-
c.status = status;
|
|
117
|
-
return [4 /*yield*/, rep.save(c)];
|
|
118
|
-
case 1:
|
|
119
|
-
_a.sent();
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); })];
|
|
124
|
-
case 2:
|
|
125
|
-
_a.sent();
|
|
126
|
-
_a.label = 3;
|
|
127
|
-
case 3: return [2 /*return*/, rep];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}); };
|
|
131
|
-
return [4 /*yield*/, doTest({
|
|
132
|
-
remult: remult,
|
|
133
|
-
createData: createData,
|
|
134
|
-
insertFourRows: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
135
|
-
var _this = this;
|
|
136
|
-
return tslib_1.__generator(this, function (_a) {
|
|
137
|
-
return [2 /*return*/, createData(function (i) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
138
|
-
return tslib_1.__generator(this, function (_a) {
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0: return [4 /*yield*/, i(1, 'noam', 'x')];
|
|
141
|
-
case 1:
|
|
142
|
-
_a.sent();
|
|
143
|
-
return [4 /*yield*/, i(4, 'yael', 'x')];
|
|
144
|
-
case 2:
|
|
145
|
-
_a.sent();
|
|
146
|
-
return [4 /*yield*/, i(2, 'yoni', 'y')];
|
|
147
|
-
case 3:
|
|
148
|
-
_a.sent();
|
|
149
|
-
return [4 /*yield*/, i(3, 'maayan', 'y')];
|
|
150
|
-
case 4:
|
|
151
|
-
_a.sent();
|
|
152
|
-
return [2 /*return*/];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}); })];
|
|
156
|
-
});
|
|
157
|
-
}); }
|
|
158
|
-
})];
|
|
159
|
-
case 1:
|
|
160
|
-
_b.sent();
|
|
161
|
-
return [2 /*return*/];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
35
|
+
export async function testAllDbs(key, doTest, focus = false) {
|
|
36
|
+
testAll(key, async ({ remult, createEntity }) => {
|
|
37
|
+
let createData = async (doInsert, entity) => {
|
|
38
|
+
if (!entity)
|
|
39
|
+
entity = Categories;
|
|
40
|
+
let rep = await createEntity(entity);
|
|
41
|
+
if (doInsert)
|
|
42
|
+
await doInsert(async (id, name, description, status) => {
|
|
43
|
+
let c = rep.create();
|
|
44
|
+
c.id = id;
|
|
45
|
+
c.categoryName = name;
|
|
46
|
+
c.description = description;
|
|
47
|
+
if (status)
|
|
48
|
+
c.status = status;
|
|
49
|
+
await rep.save(c);
|
|
164
50
|
});
|
|
165
|
-
|
|
166
|
-
|
|
51
|
+
return rep;
|
|
52
|
+
};
|
|
53
|
+
await doTest({
|
|
54
|
+
remult,
|
|
55
|
+
createData,
|
|
56
|
+
insertFourRows: async () => {
|
|
57
|
+
return createData(async (i) => {
|
|
58
|
+
await i(1, 'noam', 'x');
|
|
59
|
+
await i(4, 'yael', 'x');
|
|
60
|
+
await i(2, 'yoni', 'y');
|
|
61
|
+
await i(3, 'maayan', 'y');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
167
64
|
});
|
|
168
|
-
});
|
|
65
|
+
}, focus);
|
|
169
66
|
}
|
|
170
|
-
exports.testAllDbs = testAllDbs;
|