remult 0.22.1 → 0.22.3
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/esm/graphql.js +27 -27
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/remult-knex/index.js +2 -2
- package/esm/remult-mongo.js +6 -6
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +30 -0
- package/esm/src/id-entity.d.ts +4 -0
- package/esm/src/id-entity.js +8 -0
- package/esm/src/remult3/RepositoryImplementation.js +7 -5
- package/esm/src/shared-tests/db-tests.db-tests.js +35 -0
- package/package.json +1 -1
- package/postgres/postgresColumnSyntax.d.ts +2 -0
- package/postgres/postgresColumnSyntax.js +34 -0
- package/remult-knex/index.js +2 -2
- package/remult-middleware.d.ts +2 -0
- package/remult-middleware.js +70 -0
- package/remult-mongo.js +6 -6
- package/server/register-actions-on-server.d.ts +3 -0
- package/server/register-actions-on-server.js +50 -0
- package/server/register-entities-on-server.d.ts +3 -0
- package/server/register-entities-on-server.js +19 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +60 -0
- package/{esm/core/src → src}/backend-tests/my-test.backend-spec.d.ts +1 -1
- package/src/backend-tests/my-test.backend-spec.js +217 -0
- package/src/backend-tests/test-http-server.backend-spec.d.ts +6 -0
- package/src/backend-tests/test-http-server.backend-spec.js +342 -0
- package/src/id-entity.d.ts +4 -0
- package/src/id-entity.js +17 -0
- package/src/remult3/RepositoryImplementation.js +15 -13
- package/src/shared-tests/db-tests.db-tests.js +64 -0
- package/{esm/core/src/valueConverters.d.ts → valueConverters.d.ts} +12 -13
- package/valueConverters.js +168 -0
- package/esm/angular/interfaces/index.d.ts +0 -1
- package/esm/angular/interfaces/index.js +0 -1
- package/esm/angular/interfaces/src/column-collection.d.ts +0 -70
- package/esm/angular/interfaces/src/column-collection.js +0 -341
- package/esm/angular/interfaces/src/data-area-settings.d.ts +0 -15
- package/esm/angular/interfaces/src/data-area-settings.js +0 -35
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +0 -36
- package/esm/angular/interfaces/src/data-control-interfaces.js +0 -57
- package/esm/angular/interfaces/src/dataList.d.ts +0 -13
- package/esm/angular/interfaces/src/dataList.js +0 -42
- package/esm/angular/interfaces/src/filter-helper.d.ts +0 -13
- package/esm/angular/interfaces/src/filter-helper.js +0 -59
- package/esm/angular/interfaces/src/grid-settings.d.ts +0 -145
- package/esm/angular/interfaces/src/grid-settings.js +0 -387
- package/esm/angular/interfaces/src/public_api.d.ts +0 -4
- package/esm/angular/interfaces/src/public_api.js +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.js +0 -3
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +0 -49
- package/esm/angular/src/angular/data-control/data-control2.component.js +0 -138
- package/esm/core/SseSubscriptionServer.d.ts +0 -33
- package/esm/core/SseSubscriptionServer.js +0 -107
- package/esm/core/assign.d.ts +0 -1
- package/esm/core/assign.js +0 -5
- package/esm/core/classType.d.ts +0 -3
- package/esm/core/classType.js +0 -1
- package/esm/core/index.d.ts +0 -27
- package/esm/core/index.js +0 -25
- package/esm/core/inputTypes.d.ts +0 -9
- package/esm/core/inputTypes.js +0 -9
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +0 -22
- package/esm/core/live-query/data-provider-live-query-storage.js +0 -71
- package/esm/core/postgres/index.d.ts +0 -2
- package/esm/core/postgres/index.js +0 -2
- package/esm/core/postgres/postgres-data-provider.d.ts +0 -36
- package/esm/core/postgres/postgres-data-provider.js +0 -120
- package/esm/core/postgres/schema-builder.d.ts +0 -17
- package/esm/core/postgres/schema-builder.js +0 -153
- package/esm/core/remult-fresh.d.ts +0 -17
- package/esm/core/remult-fresh.js +0 -29
- package/esm/core/remult-knex/index.d.ts +0 -30
- package/esm/core/remult-knex/index.js +0 -446
- package/esm/core/remult-mongo.d.ts +0 -24
- package/esm/core/remult-mongo.js +0 -254
- package/esm/core/server/JsonEntityFileStorage.d.ts +0 -10
- package/esm/core/server/JsonEntityFileStorage.js +0 -25
- package/esm/core/server/core.d.ts +0 -4
- package/esm/core/server/core.js +0 -4
- package/esm/core/server/expressBridge.d.ts +0 -182
- package/esm/core/server/expressBridge.js +0 -938
- package/esm/core/server/index.d.ts +0 -6
- package/esm/core/server/index.js +0 -9
- package/esm/core/server/initAsyncHooks.d.ts +0 -1
- package/esm/core/server/initAsyncHooks.js +0 -9
- package/esm/core/server/initDataProvider.d.ts +0 -2
- package/esm/core/server/initDataProvider.js +0 -14
- package/esm/core/src/__EntityValueProvider.d.ts +0 -11
- package/esm/core/src/__EntityValueProvider.js +0 -1
- package/esm/core/src/__RowsOfDataForTesting.d.ts +0 -3
- package/esm/core/src/__RowsOfDataForTesting.js +0 -1
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +0 -6
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +0 -147
- package/esm/core/src/backend-tests/my-test.backend-spec.js +0 -197
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +0 -1
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +0 -167
- package/esm/core/src/buildRestDataProvider.d.ts +0 -31
- package/esm/core/src/buildRestDataProvider.js +0 -113
- package/esm/core/src/column-interfaces.d.ts +0 -154
- package/esm/core/src/column-interfaces.js +0 -7
- package/esm/core/src/column.d.ts +0 -58
- package/esm/core/src/column.js +0 -174
- package/esm/core/src/context.d.ts +0 -134
- package/esm/core/src/context.js +0 -286
- package/esm/core/src/data-api.d.ts +0 -39
- package/esm/core/src/data-api.js +0 -279
- package/esm/core/src/data-interfaces.d.ts +0 -41
- package/esm/core/src/data-interfaces.js +0 -12
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +0 -22
- package/esm/core/src/data-providers/array-entity-data-provider.js +0 -252
- package/esm/core/src/data-providers/in-memory-database.d.ts +0 -9
- package/esm/core/src/data-providers/in-memory-database.js +0 -14
- package/esm/core/src/data-providers/json-data-provider.d.ts +0 -12
- package/esm/core/src/data-providers/json-data-provider.js +0 -55
- package/esm/core/src/data-providers/rest-data-provider.d.ts +0 -49
- package/esm/core/src/data-providers/rest-data-provider.js +0 -256
- package/esm/core/src/data-providers/sql-database.d.ts +0 -33
- package/esm/core/src/data-providers/sql-database.js +0 -384
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +0 -24
- package/esm/core/src/data-providers/web-sql-data-provider.js +0 -143
- package/esm/core/src/entity.d.ts +0 -91
- package/esm/core/src/entity.js +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -50
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +0 -150
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +0 -1
- package/esm/core/src/filter/filter-interfaces.d.ts +0 -85
- package/esm/core/src/filter/filter-interfaces.js +0 -477
- package/esm/core/src/live-query/LiveQueryClient.d.ts +0 -20
- package/esm/core/src/live-query/LiveQueryClient.js +0 -188
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +0 -5
- package/esm/core/src/live-query/SseSubscriptionClient.js +0 -86
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +0 -72
- package/esm/core/src/live-query/SubscriptionChannel.js +0 -123
- package/esm/core/src/live-query/SubscriptionServer.d.ts +0 -53
- package/esm/core/src/live-query/SubscriptionServer.js +0 -111
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +0 -6
- package/esm/core/src/live-query/live-query-tests.spec.js +0 -952
- package/esm/core/src/remult-proxy.d.ts +0 -35
- package/esm/core/src/remult-proxy.js +0 -113
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +0 -10
- package/esm/core/src/remult3/DecoratorReplacer.js +0 -20
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +0 -355
- package/esm/core/src/remult3/RepositoryImplementation.js +0 -2109
- package/esm/core/src/remult3/index.d.ts +0 -2
- package/esm/core/src/remult3/index.js +0 -2
- package/esm/core/src/remult3/remult3.d.ts +0 -395
- package/esm/core/src/remult3/remult3.js +0 -2
- package/esm/core/src/server-action.d.ts +0 -81
- package/esm/core/src/server-action.js +0 -394
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +0 -32
- package/esm/core/src/shared-tests/db-tests-setup.js +0 -78
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +0 -25
- package/esm/core/src/shared-tests/db-tests.db-tests.js +0 -810
- package/esm/core/src/shared-tests/deleteAll.d.ts +0 -2
- package/esm/core/src/shared-tests/deleteAll.js +0 -4
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +0 -14
- package/esm/core/src/shared-tests/entityWithValidations.js +0 -43
- package/esm/core/src/shared-tests/index.d.ts +0 -4
- package/esm/core/src/shared-tests/index.js +0 -4
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +0 -67
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +0 -10
- package/esm/core/src/shared-tests/test-special-value.spec.js +0 -73
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +0 -31
- package/esm/core/src/sort.d.ts +0 -16
- package/esm/core/src/sort.js +0 -103
- package/esm/core/src/sql-command.d.ts +0 -19
- package/esm/core/src/sql-command.js +0 -1
- package/esm/core/src/test.d.ts +0 -3
- package/esm/core/src/test.js +0 -12
- package/esm/core/src/tests/Done.d.ts +0 -5
- package/esm/core/src/tests/Done.js +0 -9
- package/esm/core/src/tests/RowProvider.spec.d.ts +0 -16
- package/esm/core/src/tests/RowProvider.spec.js +0 -631
- package/esm/core/src/tests/TestDataApiResponse.d.ts +0 -10
- package/esm/core/src/tests/TestDataApiResponse.js +0 -22
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +0 -8
- package/esm/core/src/tests/basicRowFunctionality.spec.js +0 -2103
- package/esm/core/src/tests/c.d.ts +0 -8
- package/esm/core/src/tests/c.js +0 -13
- package/esm/core/src/tests/createData.d.ts +0 -7
- package/esm/core/src/tests/createData.js +0 -22
- package/esm/core/src/tests/d.d.ts +0 -6
- package/esm/core/src/tests/d.js +0 -11
- package/esm/core/src/tests/dWithPrefilter.d.ts +0 -7
- package/esm/core/src/tests/dWithPrefilter.js +0 -18
- package/esm/core/src/tests/entityForCustomFilter.d.ts +0 -16
- package/esm/core/src/tests/entityForCustomFilter.js +0 -33
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +0 -5
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +0 -13
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +0 -4
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +0 -37
- package/esm/core/src/tests/h.d.ts +0 -6
- package/esm/core/src/tests/h.js +0 -24
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +0 -1
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +0 -236
- package/esm/core/src/tests/remult-3-entities.d.ts +0 -23
- package/esm/core/src/tests/remult-3-entities.js +0 -39
- package/esm/core/src/tests/tasks.d.ts +0 -6
- package/esm/core/src/tests/tasks.js +0 -10
- package/esm/core/src/tests/test-context-as-storage.spec.d.ts +0 -0
- package/esm/core/src/tests/test-context-as-storage.spec.js +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +0 -389
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +0 -5
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +0 -152
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +0 -1
- package/esm/core/src/tests/test-decorator-precedence.spec.js +0 -38
- package/esm/core/src/tests/test-default-value.spec.d.ts +0 -1
- package/esm/core/src/tests/test-default-value.spec.js +0 -33
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +0 -14
- package/esm/core/src/tests/test-entity-inheritance.spec.js +0 -82
- package/esm/core/src/tests/test-exceptions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-exceptions.spec.js +0 -375
- package/esm/core/src/tests/test-json.spec.d.ts +0 -1
- package/esm/core/src/tests/test-json.spec.js +0 -115
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +0 -9
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +0 -809
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +0 -1
- package/esm/core/src/tests/test-non-active-record.spec.js +0 -66
- package/esm/core/src/tests/test-object-column.spec.d.ts +0 -1
- package/esm/core/src/tests/test-object-column.spec.js +0 -189
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +0 -1
- package/esm/core/src/tests/test-paged-foreach.spec.js +0 -328
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +0 -1
- package/esm/core/src/tests/test-remult-angular.spec.js +0 -23
- package/esm/core/src/tests/test-server-controller.spec.d.ts +0 -7
- package/esm/core/src/tests/test-server-controller.spec.js +0 -489
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-expressions.spec.js +0 -178
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +0 -306
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +0 -5
- package/esm/core/src/tests/test-sql-expression.spec.js +0 -205
- package/esm/core/src/tests/test-sql.spec.d.ts +0 -1
- package/esm/core/src/tests/test-sql.spec.js +0 -170
- package/esm/core/src/tests/test-subscribe.spec.d.ts +0 -1
- package/esm/core/src/tests/test-subscribe.spec.js +0 -135
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +0 -1
- package/esm/core/src/tests/test-type-recovery.spec.js +0 -49
- package/esm/core/src/tests/test-where-api.spec.d.ts +0 -1
- package/esm/core/src/tests/test-where-api.spec.js +0 -434
- package/esm/core/src/tests/testHelper.spec.d.ts +0 -36
- package/esm/core/src/tests/testHelper.spec.js +0 -226
- package/esm/core/src/tests/testModel/models.d.ts +0 -16
- package/esm/core/src/tests/testModel/models.js +0 -25
- package/esm/core/src/validators.d.ts +0 -14
- package/esm/core/src/validators.js +0 -33
- package/esm/core/src/valueConverters.js +0 -197
- package/esm/core/urlBuilder.d.ts +0 -6
- package/esm/core/urlBuilder.js +0 -20
- package/esm/test-servers/shared/Task.d.ts +0 -9
- package/esm/test-servers/shared/Task.js +0 -32
- package/esm/test.d.ts +0 -5
- package/esm/test.js +0 -6
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import './frontend-database-tests-setup.spec';
|
|
2
|
-
import { Remult } from "../context";
|
|
3
|
-
import { DataApi, serializeError } from "../data-api";
|
|
4
|
-
import { InMemoryDataProvider } from "../data-providers/in-memory-database";
|
|
5
|
-
import { RestEntityDataProvider } from "../data-providers/rest-data-provider";
|
|
6
|
-
import { SqlDatabase } from "../data-providers/sql-database";
|
|
7
|
-
import { WebSqlDataProvider } from "../data-providers/web-sql-data-provider";
|
|
8
|
-
import { actionInfo, serverActionField } from "../server-action";
|
|
9
|
-
import { testConfiguration } from '../shared-tests/entityWithValidations';
|
|
10
|
-
import { TestDataApiResponse } from './TestDataApiResponse';
|
|
11
|
-
import { remult } from '../remult-proxy';
|
|
12
|
-
import { HttpProviderBridgeToRestDataProviderHttpProvider } from '../buildRestDataProvider';
|
|
13
|
-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999;
|
|
14
|
-
//actionInfo.runningOnServer = false;
|
|
15
|
-
export function itForEach(name, arrayOfT, runAsync) {
|
|
16
|
-
arrayOfT.forEach(i => {
|
|
17
|
-
it(name + ' - ' + i, (done) => {
|
|
18
|
-
runAsync(i).catch(e => {
|
|
19
|
-
fail(e);
|
|
20
|
-
done();
|
|
21
|
-
}).then(done, e => {
|
|
22
|
-
fail(e);
|
|
23
|
-
done();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
export function fitForEach(name, arrayOfT, runAsync) {
|
|
29
|
-
arrayOfT.forEach(i => {
|
|
30
|
-
fit(name + ' - ' + i, (done) => {
|
|
31
|
-
runAsync(i).catch(e => {
|
|
32
|
-
fail(e);
|
|
33
|
-
done();
|
|
34
|
-
}).then(done, e => {
|
|
35
|
-
fail(e);
|
|
36
|
-
done();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export async function testAsIfOnBackend(what) {
|
|
42
|
-
try {
|
|
43
|
-
actionInfo.runningOnServer = true;
|
|
44
|
-
await what();
|
|
45
|
-
}
|
|
46
|
-
finally {
|
|
47
|
-
actionInfo.runningOnServer = false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export const ActionTestConfig = {
|
|
51
|
-
db: new InMemoryDataProvider()
|
|
52
|
-
};
|
|
53
|
-
remult.apiClient.httpClient = {
|
|
54
|
-
delete: () => undefined,
|
|
55
|
-
get: () => undefined,
|
|
56
|
-
post: async (urlreq, data) => {
|
|
57
|
-
return await new Promise((res, r) => {
|
|
58
|
-
let found = false;
|
|
59
|
-
actionInfo.allActions.forEach(action => {
|
|
60
|
-
action[serverActionField].
|
|
61
|
-
__register((url, queue, allowed, what) => {
|
|
62
|
-
if ('/api/' + url == urlreq) {
|
|
63
|
-
found = true;
|
|
64
|
-
let t = new TestDataApiResponse();
|
|
65
|
-
actionInfo.runningOnServer = true;
|
|
66
|
-
t.success = data => {
|
|
67
|
-
res(data);
|
|
68
|
-
actionInfo.runningOnServer = false;
|
|
69
|
-
};
|
|
70
|
-
t.error = data => {
|
|
71
|
-
r(JSON.parse(JSON.stringify(serializeError(data))));
|
|
72
|
-
actionInfo.runningOnServer = false;
|
|
73
|
-
};
|
|
74
|
-
t.forbidden = () => {
|
|
75
|
-
r({ status: 403, message: "forbidden" });
|
|
76
|
-
actionInfo.runningOnServer = false;
|
|
77
|
-
};
|
|
78
|
-
let remult = new Remult();
|
|
79
|
-
remult.dataProvider = (ActionTestConfig.db);
|
|
80
|
-
what(JSON.parse(JSON.stringify(data)), remult, t);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
if (!found) {
|
|
85
|
-
r("did not find " + urlreq);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
put: () => undefined
|
|
90
|
-
};
|
|
91
|
-
export async function testSql(runAsync) {
|
|
92
|
-
let webSql = new WebSqlDataProvider('test');
|
|
93
|
-
const sql = new SqlDatabase(webSql);
|
|
94
|
-
for (const r of await (await sql.execute("select name from sqlite_master where type='table'")).rows) {
|
|
95
|
-
switch (r.name) {
|
|
96
|
-
case "__WebKitDatabaseInfoTable__":
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
await sql.execute("drop table if exists " + r.name);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
let remult = new Remult();
|
|
103
|
-
remult.dataProvider = (sql);
|
|
104
|
-
await runAsync({ db: sql, remult });
|
|
105
|
-
}
|
|
106
|
-
export async function testInMemoryDb(runAsync) {
|
|
107
|
-
let db = new InMemoryDataProvider();
|
|
108
|
-
remult.dataProvider = (db);
|
|
109
|
-
await runAsync({ db, remult });
|
|
110
|
-
}
|
|
111
|
-
export async function testRestDb(runAsync) {
|
|
112
|
-
let r = new Remult();
|
|
113
|
-
r.dataProvider = (new InMemoryDataProvider());
|
|
114
|
-
let remult = new Remult();
|
|
115
|
-
let db = new MockRestDataProvider(r);
|
|
116
|
-
remult.dataProvider = (db);
|
|
117
|
-
await runAsync({ db, remult });
|
|
118
|
-
}
|
|
119
|
-
export async function testAllDataProviders(runAsync) {
|
|
120
|
-
await testSql(runAsync);
|
|
121
|
-
await testInMemoryDb(runAsync);
|
|
122
|
-
await testRestDb(runAsync);
|
|
123
|
-
}
|
|
124
|
-
function urlToReq(url) {
|
|
125
|
-
let args = new Map();
|
|
126
|
-
let params = url?.split('?')[1]?.split('&');
|
|
127
|
-
if (params)
|
|
128
|
-
for (const p of params) {
|
|
129
|
-
if (!p)
|
|
130
|
-
continue;
|
|
131
|
-
let z = p.split('=');
|
|
132
|
-
let key = decodeURIComponent(z[0]);
|
|
133
|
-
let value = decodeURIComponent(z[1]);
|
|
134
|
-
let x = args.get(key);
|
|
135
|
-
if (x === undefined) {
|
|
136
|
-
args.set(key, value);
|
|
137
|
-
}
|
|
138
|
-
else if (Array.isArray(x))
|
|
139
|
-
x.push(value);
|
|
140
|
-
else
|
|
141
|
-
args.set(key, [args.get(key), value]);
|
|
142
|
-
}
|
|
143
|
-
let req = {
|
|
144
|
-
get: (key) => {
|
|
145
|
-
let r = args.get(key);
|
|
146
|
-
if (r !== undefined) {
|
|
147
|
-
r.toString();
|
|
148
|
-
}
|
|
149
|
-
return r;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
return req;
|
|
153
|
-
}
|
|
154
|
-
export class MockRestDataProvider {
|
|
155
|
-
remult;
|
|
156
|
-
constructor(remult) {
|
|
157
|
-
this.remult = remult;
|
|
158
|
-
}
|
|
159
|
-
getEntityDataProvider(metadata) {
|
|
160
|
-
let dataApi = new DataApi(this.remult.repo(metadata.entityType), this.remult);
|
|
161
|
-
return new RestEntityDataProvider(() => "", () => createMockHttpDataProvider(dataApi), metadata);
|
|
162
|
-
}
|
|
163
|
-
transaction(action) {
|
|
164
|
-
throw new Error('Method not implemented.');
|
|
165
|
-
}
|
|
166
|
-
isProxy = true;
|
|
167
|
-
}
|
|
168
|
-
export function createMockHttpDataProvider(dataApi) {
|
|
169
|
-
return new HttpProviderBridgeToRestDataProviderHttpProvider({
|
|
170
|
-
delete: async (url) => {
|
|
171
|
-
let urlSplit = url.split('/');
|
|
172
|
-
let r = new TestDataApiResponse();
|
|
173
|
-
let result;
|
|
174
|
-
r.deleted = () => { };
|
|
175
|
-
try {
|
|
176
|
-
testConfiguration.restDbRunningOnServer = true;
|
|
177
|
-
await dataApi.delete(r, urlSplit[urlSplit.length - 1]);
|
|
178
|
-
}
|
|
179
|
-
finally {
|
|
180
|
-
testConfiguration.restDbRunningOnServer = false;
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
},
|
|
184
|
-
get: async (url) => {
|
|
185
|
-
let r = new TestDataApiResponse();
|
|
186
|
-
let result;
|
|
187
|
-
r.success = data => { result = data; };
|
|
188
|
-
try {
|
|
189
|
-
testConfiguration.restDbRunningOnServer = true;
|
|
190
|
-
await dataApi.httpGet(r, urlToReq(url), async () => "");
|
|
191
|
-
}
|
|
192
|
-
finally {
|
|
193
|
-
testConfiguration.restDbRunningOnServer = false;
|
|
194
|
-
}
|
|
195
|
-
return result;
|
|
196
|
-
},
|
|
197
|
-
post: async (url, data) => {
|
|
198
|
-
let r = new TestDataApiResponse();
|
|
199
|
-
let result;
|
|
200
|
-
r.created = data => { result = data; };
|
|
201
|
-
r.success = data => { result = data; };
|
|
202
|
-
try {
|
|
203
|
-
testConfiguration.restDbRunningOnServer = true;
|
|
204
|
-
await dataApi.httpPost(r, urlToReq(url), data, async () => ({}));
|
|
205
|
-
}
|
|
206
|
-
finally {
|
|
207
|
-
testConfiguration.restDbRunningOnServer = false;
|
|
208
|
-
}
|
|
209
|
-
return result;
|
|
210
|
-
},
|
|
211
|
-
put: async (url, data) => {
|
|
212
|
-
let urlSplit = url.split('/');
|
|
213
|
-
let r = new TestDataApiResponse();
|
|
214
|
-
let result;
|
|
215
|
-
r.success = data => { result = data; };
|
|
216
|
-
try {
|
|
217
|
-
testConfiguration.restDbRunningOnServer = true;
|
|
218
|
-
await dataApi.put(r, urlSplit[urlSplit.length - 1], data);
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
testConfiguration.restDbRunningOnServer = false;
|
|
222
|
-
}
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare class Status {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
static open: Status;
|
|
5
|
-
static closed: Status;
|
|
6
|
-
static hold: Status;
|
|
7
|
-
constructor(id: number, name: string);
|
|
8
|
-
}
|
|
9
|
-
export declare class TestStatus {
|
|
10
|
-
id?: string | undefined;
|
|
11
|
-
caption?: string | undefined;
|
|
12
|
-
static open: TestStatus;
|
|
13
|
-
static closed: TestStatus;
|
|
14
|
-
static hold: TestStatus;
|
|
15
|
-
constructor(id?: string | undefined, caption?: string | undefined);
|
|
16
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ValueListFieldType } from "../../remult3";
|
|
2
|
-
@ValueListFieldType()
|
|
3
|
-
export class Status {
|
|
4
|
-
id;
|
|
5
|
-
name;
|
|
6
|
-
static open = new Status(0, "open");
|
|
7
|
-
static closed = new Status(1, "closed");
|
|
8
|
-
static hold = new Status(2, "hold");
|
|
9
|
-
constructor(id, name) {
|
|
10
|
-
this.id = id;
|
|
11
|
-
this.name = name;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
@ValueListFieldType()
|
|
15
|
-
export class TestStatus {
|
|
16
|
-
id;
|
|
17
|
-
caption;
|
|
18
|
-
static open = new TestStatus();
|
|
19
|
-
static closed = new TestStatus('cc');
|
|
20
|
-
static hold = new TestStatus(undefined, 'hh');
|
|
21
|
-
constructor(id, caption) {
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.caption = caption;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FieldRef } from "./remult3";
|
|
2
|
-
export declare class Validators {
|
|
3
|
-
static required: ((entity: any, col: FieldRef<any, string>, message?: undefined) => void) & {
|
|
4
|
-
withMessage: (message: string) => (entity: any, col: FieldRef<any, string>) => void;
|
|
5
|
-
defaultMessage: string;
|
|
6
|
-
};
|
|
7
|
-
static unique: ((entity: any, col: FieldRef<any, any>, message?: undefined) => Promise<void>) & {
|
|
8
|
-
withMessage: (message: string) => (entity: any, col: FieldRef<any, any>) => Promise<void>;
|
|
9
|
-
defaultMessage: string;
|
|
10
|
-
};
|
|
11
|
-
static uniqueOnBackend: ((entity: any, col: FieldRef<any, any>, message?: undefined) => Promise<void>) & {
|
|
12
|
-
withMessage: (message: string) => (entity: any, col: FieldRef<any, any>) => Promise<void>;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { isBackend } from "./context";
|
|
2
|
-
export class Validators {
|
|
3
|
-
static required = Object.assign((entity, col, message = undefined) => {
|
|
4
|
-
if (!col.value || typeof (col.value) === "string" && col.value.trim().length == 0)
|
|
5
|
-
col.error = message || Validators.required.defaultMessage;
|
|
6
|
-
}, {
|
|
7
|
-
withMessage: (message) => {
|
|
8
|
-
return (entity, col) => Validators.required(entity, col, message);
|
|
9
|
-
},
|
|
10
|
-
defaultMessage: 'Should not be empty'
|
|
11
|
-
});
|
|
12
|
-
static unique = Object.assign(async (entity, col, message = undefined) => {
|
|
13
|
-
if (!col.entityRef)
|
|
14
|
-
throw "unique validation may only work on columns that are attached to an entity";
|
|
15
|
-
if (col.entityRef.isNew() || col.valueChanged()) {
|
|
16
|
-
if (await col.entityRef.repository.count({ [col.metadata.key]: col.value }))
|
|
17
|
-
col.error = message || Validators.unique.defaultMessage;
|
|
18
|
-
}
|
|
19
|
-
}, {
|
|
20
|
-
withMessage: (message) => {
|
|
21
|
-
return (entity, col) => Validators.unique(entity, col, message);
|
|
22
|
-
},
|
|
23
|
-
defaultMessage: 'already exists'
|
|
24
|
-
});
|
|
25
|
-
static uniqueOnBackend = Object.assign(async (entity, col, message = undefined) => {
|
|
26
|
-
if (isBackend())
|
|
27
|
-
return Validators.unique(entity, col, message);
|
|
28
|
-
}, {
|
|
29
|
-
withMessage: (message) => {
|
|
30
|
-
return (entity, col) => Validators.uniqueOnBackend(entity, col, message);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { InputTypes } from "../inputTypes";
|
|
2
|
-
export class ValueConverters {
|
|
3
|
-
static Date = {
|
|
4
|
-
toJson: (val) => {
|
|
5
|
-
if (val === null)
|
|
6
|
-
return null;
|
|
7
|
-
if (!val)
|
|
8
|
-
return '';
|
|
9
|
-
if (typeof (val) === "string")
|
|
10
|
-
val = new Date(val);
|
|
11
|
-
if (val instanceof Date) {
|
|
12
|
-
return val.toISOString();
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
throw new Error("Expected date but got " + val);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
fromJson: (val) => {
|
|
19
|
-
if (val === null)
|
|
20
|
-
return null;
|
|
21
|
-
if (val == undefined)
|
|
22
|
-
return undefined;
|
|
23
|
-
if (val == '')
|
|
24
|
-
return undefined;
|
|
25
|
-
if (val.startsWith('0000-00-00'))
|
|
26
|
-
return undefined;
|
|
27
|
-
return new Date(Date.parse(val));
|
|
28
|
-
},
|
|
29
|
-
toDb: x => x,
|
|
30
|
-
fromDb: val => {
|
|
31
|
-
if (typeof val === "number")
|
|
32
|
-
val = new Date(val);
|
|
33
|
-
if (typeof (val) === "string")
|
|
34
|
-
val = new Date(val);
|
|
35
|
-
if (val && !(val instanceof Date))
|
|
36
|
-
throw "expected date but got " + val;
|
|
37
|
-
return val;
|
|
38
|
-
},
|
|
39
|
-
fromInput: x => ValueConverters.Date.fromJson(x),
|
|
40
|
-
toInput: x => ValueConverters.Date.toJson(x),
|
|
41
|
-
displayValue: (val) => {
|
|
42
|
-
if (!val)
|
|
43
|
-
return '';
|
|
44
|
-
return val.toLocaleString();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
static DateOnly = {
|
|
48
|
-
fromInput: x => ValueConverters.DateOnly.fromJson(x),
|
|
49
|
-
toInput: x => ValueConverters.DateOnly.toJson(x),
|
|
50
|
-
toJson: (val) => {
|
|
51
|
-
var d = val;
|
|
52
|
-
if (typeof d === "string" || typeof (d) === "number")
|
|
53
|
-
d = new Date(d);
|
|
54
|
-
if (!d || d == null)
|
|
55
|
-
return null;
|
|
56
|
-
if (d.getHours() == 0)
|
|
57
|
-
return new Date(d.valueOf() - d.getTimezoneOffset() * 60000).toISOString().substring(0, 10);
|
|
58
|
-
else
|
|
59
|
-
return d.toISOString().substring(0, 10);
|
|
60
|
-
},
|
|
61
|
-
fromJson: (value) => {
|
|
62
|
-
if (!value || value == '' || value == '0000-00-00')
|
|
63
|
-
return null;
|
|
64
|
-
let d = new Date(Date.parse(value));
|
|
65
|
-
d.setMinutes(d.getMinutes() + d.getTimezoneOffset());
|
|
66
|
-
return d;
|
|
67
|
-
},
|
|
68
|
-
inputType: InputTypes.date,
|
|
69
|
-
toDb: (val) => {
|
|
70
|
-
if (!val)
|
|
71
|
-
return null;
|
|
72
|
-
return ValueConverters.DateOnly.fromJson(ValueConverters.DateOnly.toJson(val));
|
|
73
|
-
} //when using date storage, the database expects and returns a date local and every where else we reflect on date iso
|
|
74
|
-
,
|
|
75
|
-
fromDb: (val) => {
|
|
76
|
-
return ValueConverters.Date.fromDb(val);
|
|
77
|
-
},
|
|
78
|
-
fieldTypeInDb: 'date',
|
|
79
|
-
displayValue: (value) => {
|
|
80
|
-
if (!value)
|
|
81
|
-
return '';
|
|
82
|
-
return value.toLocaleDateString(undefined);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
static DateOnlyString = {
|
|
86
|
-
...ValueConverters.DateOnly,
|
|
87
|
-
toDb: (d) => {
|
|
88
|
-
let val = ValueConverters.DateOnly.toJson(d);
|
|
89
|
-
if (!val)
|
|
90
|
-
return undefined;
|
|
91
|
-
return val.replace(/-/g, '');
|
|
92
|
-
},
|
|
93
|
-
fromDb: (val) => {
|
|
94
|
-
if (val === null)
|
|
95
|
-
return null;
|
|
96
|
-
if (!val)
|
|
97
|
-
return undefined;
|
|
98
|
-
return new Date(val.substring(0, 4) + '-' + val.substring(4, 6) + '-' + val.substring(6, 8));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
static Boolean = {
|
|
102
|
-
toDb: (val) => val,
|
|
103
|
-
inputType: InputTypes.checkbox,
|
|
104
|
-
fromDb: (value) => {
|
|
105
|
-
return ValueConverters.Boolean.fromJson(value);
|
|
106
|
-
},
|
|
107
|
-
fromJson: value => {
|
|
108
|
-
if (typeof value === "boolean")
|
|
109
|
-
return value;
|
|
110
|
-
if (value === 1)
|
|
111
|
-
return true;
|
|
112
|
-
if (value !== undefined && value !== null) {
|
|
113
|
-
return value.toString().trim().toLowerCase() == 'true';
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
},
|
|
117
|
-
toJson: x => x,
|
|
118
|
-
fromInput: x => ValueConverters.Boolean.fromJson(x),
|
|
119
|
-
toInput: x => ValueConverters.Boolean.toJson(x)
|
|
120
|
-
};
|
|
121
|
-
static Number = {
|
|
122
|
-
fromDb: value => {
|
|
123
|
-
if (value === null)
|
|
124
|
-
return null;
|
|
125
|
-
if (value !== undefined)
|
|
126
|
-
return +value;
|
|
127
|
-
return undefined;
|
|
128
|
-
},
|
|
129
|
-
toDb: value => value,
|
|
130
|
-
fromJson: value => ValueConverters.Number.fromDb(value),
|
|
131
|
-
toJson: value => ValueConverters.Number.toDb(value),
|
|
132
|
-
fromInput: (x, type) => {
|
|
133
|
-
let r = +x;
|
|
134
|
-
if (!x)
|
|
135
|
-
return undefined;
|
|
136
|
-
return r;
|
|
137
|
-
},
|
|
138
|
-
toInput: (x, type) => {
|
|
139
|
-
return x?.toString();
|
|
140
|
-
},
|
|
141
|
-
inputType: InputTypes.number
|
|
142
|
-
};
|
|
143
|
-
static String = {
|
|
144
|
-
fromDb: enforceString,
|
|
145
|
-
toDb: enforceString,
|
|
146
|
-
fromJson: enforceString,
|
|
147
|
-
toJson: enforceString,
|
|
148
|
-
fromInput: enforceString,
|
|
149
|
-
toInput: enforceString,
|
|
150
|
-
};
|
|
151
|
-
static Integer = {
|
|
152
|
-
...ValueConverters.Number,
|
|
153
|
-
toJson: value => {
|
|
154
|
-
let val = ValueConverters.Number.toDb(value);
|
|
155
|
-
if (!val)
|
|
156
|
-
return val;
|
|
157
|
-
return +(+val).toFixed(0);
|
|
158
|
-
},
|
|
159
|
-
toDb: value => ValueConverters.Integer.toJson(value),
|
|
160
|
-
fieldTypeInDb: 'integer'
|
|
161
|
-
};
|
|
162
|
-
static Default = {
|
|
163
|
-
fromJson: x => x,
|
|
164
|
-
toJson: x => x,
|
|
165
|
-
fromDb: x => ValueConverters.JsonString.fromDb(x),
|
|
166
|
-
toDb: x => ValueConverters.JsonString.toDb(x),
|
|
167
|
-
fromInput: x => ValueConverters.Default.fromJson(x),
|
|
168
|
-
toInput: x => ValueConverters.Default.toJson(x),
|
|
169
|
-
displayValue: x => x + '',
|
|
170
|
-
fieldTypeInDb: '',
|
|
171
|
-
inputType: 'text'
|
|
172
|
-
};
|
|
173
|
-
static JsonString = {
|
|
174
|
-
fromJson: x => x,
|
|
175
|
-
toJson: x => x,
|
|
176
|
-
fromDb: x => x == null ? null : x ? JSON.parse(ValueConverters.JsonString.fromJson(x)) : undefined,
|
|
177
|
-
toDb: x => x !== undefined ? x === null ? null : JSON.stringify(ValueConverters.JsonString.toJson(x)) : undefined,
|
|
178
|
-
fromInput: x => ValueConverters.JsonString.fromJson(x),
|
|
179
|
-
toInput: x => ValueConverters.JsonString.toJson(x)
|
|
180
|
-
};
|
|
181
|
-
static JsonValue = {
|
|
182
|
-
fromJson: x => x,
|
|
183
|
-
toJson: x => x,
|
|
184
|
-
fromDb: x => x,
|
|
185
|
-
toDb: x => x,
|
|
186
|
-
fromInput: x => ValueConverters.JsonString.fromJson(x),
|
|
187
|
-
toInput: x => ValueConverters.JsonString.toJson(x),
|
|
188
|
-
fieldTypeInDb: 'json'
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function enforceString(value) {
|
|
192
|
-
if (value === null || value === undefined)
|
|
193
|
-
return value;
|
|
194
|
-
if (typeof (value) !== "string")
|
|
195
|
-
return value.toString();
|
|
196
|
-
return value;
|
|
197
|
-
}
|
package/esm/core/urlBuilder.d.ts
DELETED
package/esm/core/urlBuilder.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export class UrlBuilder {
|
|
2
|
-
url;
|
|
3
|
-
constructor(url) {
|
|
4
|
-
this.url = url;
|
|
5
|
-
}
|
|
6
|
-
add(key, value) {
|
|
7
|
-
if (this.url.indexOf('?') >= 0)
|
|
8
|
-
this.url += '&';
|
|
9
|
-
else
|
|
10
|
-
this.url += '?';
|
|
11
|
-
this.url += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
|
12
|
-
}
|
|
13
|
-
addObject(object, suffix = '') {
|
|
14
|
-
if (object != undefined)
|
|
15
|
-
for (var key in object) {
|
|
16
|
-
let val = object[key];
|
|
17
|
-
this.add(key + suffix, val);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Remult } from '../../core/src/context';
|
|
2
|
-
export declare class Task {
|
|
3
|
-
id: string;
|
|
4
|
-
title: string;
|
|
5
|
-
completed: boolean;
|
|
6
|
-
static testForbidden(): void;
|
|
7
|
-
static testStaticRemult(): Promise<number>;
|
|
8
|
-
static testInjectedRemult(remult?: Remult): Promise<number>;
|
|
9
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Entity, Fields } from '../../core/src/remult3';
|
|
2
|
-
import { Validators } from '../../core/src/validators';
|
|
3
|
-
import { BackendMethod } from '../../core/src/server-action';
|
|
4
|
-
import { remult } from '../../core/src/remult-proxy';
|
|
5
|
-
import { isBackend } from '../../core/src/context';
|
|
6
|
-
@Entity("tasks", {
|
|
7
|
-
allowApiCrud: true
|
|
8
|
-
})
|
|
9
|
-
export class Task {
|
|
10
|
-
@Fields.uuid()
|
|
11
|
-
id;
|
|
12
|
-
@Fields.string({
|
|
13
|
-
validate: (r, c) => {
|
|
14
|
-
if (isBackend())
|
|
15
|
-
Validators.required(r, c);
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
title = '';
|
|
19
|
-
@Fields.boolean()
|
|
20
|
-
completed = false;
|
|
21
|
-
@BackendMethod({ allowed: false })
|
|
22
|
-
static testForbidden() {
|
|
23
|
-
}
|
|
24
|
-
@BackendMethod({ allowed: true })
|
|
25
|
-
static async testStaticRemult() {
|
|
26
|
-
return await remult.repo(Task).count();
|
|
27
|
-
}
|
|
28
|
-
@BackendMethod({ allowed: true })
|
|
29
|
-
static async testInjectedRemult(remult) {
|
|
30
|
-
return await remult.repo(Task).count();
|
|
31
|
-
}
|
|
32
|
-
}
|
package/esm/test.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type ClassType<T> = {
|
|
2
|
-
new (...args: any[]): T;
|
|
3
|
-
};
|
|
4
|
-
export declare function Field1<valueType>(valueType: () => ClassType<valueType>): (target: any, context: ClassFieldDecoratorContext<any, valueType | undefined> | string) => void;
|
|
5
|
-
export declare function createdAt(): (target: any, context: string | ClassFieldDecoratorContext<any, Date>) => void;
|