remult 0.22.3 → 0.22.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/esm/angular/interfaces/index.d.ts +1 -0
- package/esm/angular/interfaces/index.js +1 -0
- package/esm/angular/interfaces/src/column-collection.d.ts +70 -0
- package/esm/angular/interfaces/src/column-collection.js +341 -0
- package/esm/angular/interfaces/src/data-area-settings.d.ts +15 -0
- package/esm/angular/interfaces/src/data-area-settings.js +35 -0
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +36 -0
- package/esm/angular/interfaces/src/data-control-interfaces.js +57 -0
- package/esm/angular/interfaces/src/dataList.d.ts +13 -0
- package/esm/angular/interfaces/src/dataList.js +42 -0
- package/esm/angular/interfaces/src/filter-helper.d.ts +13 -0
- package/esm/angular/interfaces/src/filter-helper.js +59 -0
- package/esm/angular/interfaces/src/grid-settings.d.ts +145 -0
- package/esm/angular/interfaces/src/grid-settings.js +387 -0
- package/esm/angular/interfaces/src/public_api.d.ts +4 -0
- package/esm/angular/interfaces/src/public_api.js +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.js +3 -0
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +49 -0
- package/esm/angular/src/angular/data-control/data-control2.component.js +138 -0
- package/esm/core/SseSubscriptionServer.d.ts +33 -0
- package/esm/core/SseSubscriptionServer.js +107 -0
- package/esm/core/assign.d.ts +1 -0
- package/esm/core/assign.js +5 -0
- package/esm/core/classType.d.ts +3 -0
- package/esm/core/classType.js +1 -0
- package/esm/core/index.d.ts +27 -0
- package/esm/core/index.js +25 -0
- package/esm/core/inputTypes.d.ts +9 -0
- package/esm/core/inputTypes.js +9 -0
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +22 -0
- package/esm/core/live-query/data-provider-live-query-storage.js +71 -0
- package/esm/core/postgres/index.d.ts +2 -0
- package/esm/core/postgres/index.js +2 -0
- package/esm/core/postgres/postgres-data-provider.d.ts +36 -0
- package/esm/core/postgres/postgres-data-provider.js +120 -0
- package/esm/core/postgres/schema-builder.d.ts +17 -0
- package/esm/core/postgres/schema-builder.js +153 -0
- package/esm/core/remult-fresh.d.ts +17 -0
- package/esm/core/remult-fresh.js +29 -0
- package/esm/core/remult-knex/index.d.ts +30 -0
- package/esm/core/remult-knex/index.js +446 -0
- package/esm/core/remult-mongo.d.ts +24 -0
- package/esm/core/remult-mongo.js +254 -0
- package/esm/core/server/JsonEntityFileStorage.d.ts +10 -0
- package/esm/core/server/JsonEntityFileStorage.js +25 -0
- package/esm/core/server/core.d.ts +4 -0
- package/esm/core/server/core.js +4 -0
- package/esm/core/server/expressBridge.d.ts +182 -0
- package/esm/core/server/expressBridge.js +938 -0
- package/esm/core/server/index.d.ts +6 -0
- package/esm/core/server/index.js +9 -0
- package/esm/core/server/initAsyncHooks.d.ts +1 -0
- package/esm/core/server/initAsyncHooks.js +9 -0
- package/esm/core/server/initDataProvider.d.ts +2 -0
- package/esm/core/server/initDataProvider.js +14 -0
- package/esm/core/src/__EntityValueProvider.d.ts +11 -0
- package/esm/core/src/__EntityValueProvider.js +1 -0
- package/esm/core/src/__RowsOfDataForTesting.d.ts +3 -0
- package/esm/core/src/__RowsOfDataForTesting.js +1 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +147 -0
- package/{src → esm/core/src}/backend-tests/my-test.backend-spec.d.ts +1 -1
- package/esm/core/src/backend-tests/my-test.backend-spec.js +197 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +1 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +167 -0
- package/esm/core/src/buildRestDataProvider.d.ts +31 -0
- package/esm/core/src/buildRestDataProvider.js +113 -0
- package/esm/core/src/column-interfaces.d.ts +154 -0
- package/esm/core/src/column-interfaces.js +7 -0
- package/esm/core/src/column.d.ts +58 -0
- package/esm/core/src/column.js +174 -0
- package/esm/core/src/context.d.ts +134 -0
- package/esm/core/src/context.js +286 -0
- package/esm/core/src/data-api.d.ts +39 -0
- package/esm/core/src/data-api.js +279 -0
- package/esm/core/src/data-interfaces.d.ts +41 -0
- package/esm/core/src/data-interfaces.js +12 -0
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +22 -0
- package/esm/core/src/data-providers/array-entity-data-provider.js +252 -0
- package/esm/core/src/data-providers/in-memory-database.d.ts +9 -0
- package/esm/core/src/data-providers/in-memory-database.js +14 -0
- package/esm/core/src/data-providers/json-data-provider.d.ts +12 -0
- package/esm/core/src/data-providers/json-data-provider.js +55 -0
- package/esm/core/src/data-providers/rest-data-provider.d.ts +49 -0
- package/esm/core/src/data-providers/rest-data-provider.js +256 -0
- package/esm/core/src/data-providers/sql-database.d.ts +33 -0
- package/esm/core/src/data-providers/sql-database.js +384 -0
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +24 -0
- package/esm/core/src/data-providers/web-sql-data-provider.js +143 -0
- package/esm/core/src/entity.d.ts +91 -0
- package/esm/core/src/entity.js +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +150 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +1 -0
- package/esm/core/src/filter/filter-interfaces.d.ts +85 -0
- package/esm/core/src/filter/filter-interfaces.js +477 -0
- package/esm/core/src/live-query/LiveQueryClient.d.ts +20 -0
- package/esm/core/src/live-query/LiveQueryClient.js +188 -0
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +5 -0
- package/esm/core/src/live-query/SseSubscriptionClient.js +86 -0
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +72 -0
- package/esm/core/src/live-query/SubscriptionChannel.js +123 -0
- package/esm/core/src/live-query/SubscriptionServer.d.ts +53 -0
- package/esm/core/src/live-query/SubscriptionServer.js +111 -0
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +6 -0
- package/esm/core/src/live-query/live-query-tests.spec.js +952 -0
- package/esm/core/src/remult-proxy.d.ts +35 -0
- package/esm/core/src/remult-proxy.js +113 -0
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/esm/core/src/remult3/DecoratorReplacer.js +20 -0
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +355 -0
- package/esm/core/src/remult3/RepositoryImplementation.js +2109 -0
- package/esm/core/src/remult3/index.d.ts +2 -0
- package/esm/core/src/remult3/index.js +2 -0
- package/esm/core/src/remult3/remult3.d.ts +395 -0
- package/esm/core/src/remult3/remult3.js +2 -0
- package/esm/core/src/server-action.d.ts +81 -0
- package/esm/core/src/server-action.js +394 -0
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +32 -0
- package/esm/core/src/shared-tests/db-tests-setup.js +78 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +25 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.js +810 -0
- package/esm/core/src/shared-tests/deleteAll.d.ts +2 -0
- package/esm/core/src/shared-tests/deleteAll.js +4 -0
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/esm/core/src/shared-tests/entityWithValidations.js +43 -0
- package/esm/core/src/shared-tests/index.d.ts +4 -0
- package/esm/core/src/shared-tests/index.js +4 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +67 -0
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/esm/core/src/shared-tests/test-special-value.spec.js +73 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +31 -0
- package/esm/core/src/sort.d.ts +16 -0
- package/esm/core/src/sort.js +103 -0
- package/esm/core/src/sql-command.d.ts +19 -0
- package/esm/core/src/sql-command.js +1 -0
- package/esm/core/src/test.d.ts +3 -0
- package/esm/core/src/test.js +12 -0
- package/esm/core/src/tests/Done.d.ts +5 -0
- package/esm/core/src/tests/Done.js +9 -0
- package/esm/core/src/tests/RowProvider.spec.d.ts +16 -0
- package/esm/core/src/tests/RowProvider.spec.js +631 -0
- package/esm/core/src/tests/TestDataApiResponse.d.ts +10 -0
- package/esm/core/src/tests/TestDataApiResponse.js +22 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +8 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.js +2103 -0
- package/esm/core/src/tests/c.d.ts +8 -0
- package/esm/core/src/tests/c.js +13 -0
- package/esm/core/src/tests/createData.d.ts +7 -0
- package/esm/core/src/tests/createData.js +22 -0
- package/esm/core/src/tests/d.d.ts +6 -0
- package/esm/core/src/tests/d.js +11 -0
- package/esm/core/src/tests/dWithPrefilter.d.ts +7 -0
- package/esm/core/src/tests/dWithPrefilter.js +18 -0
- package/esm/core/src/tests/entityForCustomFilter.d.ts +16 -0
- package/esm/core/src/tests/entityForCustomFilter.js +33 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +13 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +4 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +37 -0
- package/esm/core/src/tests/h.d.ts +6 -0
- package/esm/core/src/tests/h.js +24 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +1 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +236 -0
- package/esm/core/src/tests/remult-3-entities.d.ts +23 -0
- package/esm/core/src/tests/remult-3-entities.js +39 -0
- package/esm/core/src/tests/tasks.d.ts +6 -0
- package/esm/core/src/tests/tasks.js +10 -0
- 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 +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +389 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +5 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +152 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +1 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.js +38 -0
- package/esm/core/src/tests/test-default-value.spec.d.ts +1 -0
- package/esm/core/src/tests/test-default-value.spec.js +33 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +14 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.js +82 -0
- package/esm/core/src/tests/test-exceptions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-exceptions.spec.js +375 -0
- package/esm/core/src/tests/test-json.spec.d.ts +1 -0
- package/esm/core/src/tests/test-json.spec.js +115 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +9 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +809 -0
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +1 -0
- package/esm/core/src/tests/test-non-active-record.spec.js +66 -0
- package/esm/core/src/tests/test-object-column.spec.d.ts +1 -0
- package/esm/core/src/tests/test-object-column.spec.js +189 -0
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +1 -0
- package/esm/core/src/tests/test-paged-foreach.spec.js +328 -0
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +1 -0
- package/esm/core/src/tests/test-remult-angular.spec.js +23 -0
- package/esm/core/src/tests/test-server-controller.spec.d.ts +7 -0
- package/esm/core/src/tests/test-server-controller.spec.js +489 -0
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-expressions.spec.js +178 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +306 -0
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +5 -0
- package/esm/core/src/tests/test-sql-expression.spec.js +205 -0
- package/esm/core/src/tests/test-sql.spec.d.ts +1 -0
- package/esm/core/src/tests/test-sql.spec.js +170 -0
- package/esm/core/src/tests/test-subscribe.spec.d.ts +1 -0
- package/esm/core/src/tests/test-subscribe.spec.js +135 -0
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +1 -0
- package/esm/core/src/tests/test-type-recovery.spec.js +49 -0
- package/esm/core/src/tests/test-where-api.spec.d.ts +1 -0
- package/esm/core/src/tests/test-where-api.spec.js +434 -0
- package/esm/core/src/tests/testHelper.spec.d.ts +36 -0
- package/esm/core/src/tests/testHelper.spec.js +226 -0
- package/esm/core/src/tests/testModel/models.d.ts +16 -0
- package/esm/core/src/tests/testModel/models.js +25 -0
- package/esm/core/src/validators.d.ts +14 -0
- package/esm/core/src/validators.js +33 -0
- package/{valueConverters.d.ts → esm/core/src/valueConverters.d.ts} +13 -12
- package/esm/core/src/valueConverters.js +197 -0
- package/esm/core/urlBuilder.d.ts +6 -0
- package/esm/core/urlBuilder.js +20 -0
- package/esm/graphql.js +27 -27
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/src/context.d.ts +6 -1
- package/esm/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/esm/src/remult3/RepositoryImplementation.js +27 -4
- package/esm/src/shared-tests/db-tests.db-tests.js +57 -0
- package/esm/test-servers/shared/Task.d.ts +9 -0
- package/esm/test-servers/shared/Task.js +32 -0
- package/esm/test.d.ts +5 -0
- package/esm/test.js +6 -0
- package/package.json +1 -1
- package/src/context.d.ts +6 -1
- package/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/src/remult3/RepositoryImplementation.js +88 -63
- package/src/shared-tests/db-tests.db-tests.js +97 -0
- package/esm/src/id-entity.d.ts +0 -4
- package/esm/src/id-entity.js +0 -8
- package/postgres/postgresColumnSyntax.d.ts +0 -2
- package/postgres/postgresColumnSyntax.js +0 -34
- package/remult-middleware.d.ts +0 -2
- package/remult-middleware.js +0 -70
- package/server/register-actions-on-server.d.ts +0 -3
- package/server/register-actions-on-server.js +0 -50
- package/server/register-entities-on-server.d.ts +0 -3
- package/server/register-entities-on-server.js +0 -19
- package/src/backend-tests/my-test.backend-spec.js +0 -217
- package/src/backend-tests/test-http-server.backend-spec.d.ts +0 -6
- package/src/backend-tests/test-http-server.backend-spec.js +0 -342
- package/src/id-entity.d.ts +0 -4
- package/src/id-entity.js +0 -17
- package/valueConverters.js +0 -168
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { RestDataProviderHttpProviderUsingFetch } from './data-providers/rest-data-provider';
|
|
2
|
+
export function buildRestDataProvider(provider) {
|
|
3
|
+
if (!provider)
|
|
4
|
+
return new RestDataProviderHttpProviderUsingFetch();
|
|
5
|
+
let httpDataProvider;
|
|
6
|
+
if (!httpDataProvider) {
|
|
7
|
+
if (isExternalHttpProvider(provider)) {
|
|
8
|
+
httpDataProvider = new HttpProviderBridgeToRestDataProviderHttpProvider(provider);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (!httpDataProvider) {
|
|
12
|
+
if (typeof provider === "function") {
|
|
13
|
+
httpDataProvider = new RestDataProviderHttpProviderUsingFetch(provider);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return httpDataProvider;
|
|
17
|
+
}
|
|
18
|
+
export function isExternalHttpProvider(item) {
|
|
19
|
+
let http = item;
|
|
20
|
+
if (http && http.get && http.put && http.post && http.delete)
|
|
21
|
+
return true;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
export class HttpProviderBridgeToRestDataProviderHttpProvider {
|
|
25
|
+
http;
|
|
26
|
+
constructor(http) {
|
|
27
|
+
this.http = http;
|
|
28
|
+
}
|
|
29
|
+
async post(url, data) {
|
|
30
|
+
return await retry(() => toPromise(this.http.post(url, data)));
|
|
31
|
+
}
|
|
32
|
+
delete(url) {
|
|
33
|
+
return toPromise(this.http.delete(url));
|
|
34
|
+
}
|
|
35
|
+
put(url, data) {
|
|
36
|
+
return toPromise(this.http.put(url, data));
|
|
37
|
+
}
|
|
38
|
+
async get(url) {
|
|
39
|
+
return await retry(() => toPromise(this.http.get(url)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function retry(what) {
|
|
43
|
+
let i = 0;
|
|
44
|
+
while (true) {
|
|
45
|
+
try {
|
|
46
|
+
return await what();
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if ((err.message?.startsWith("Error occurred while trying to proxy") ||
|
|
50
|
+
err.message?.startsWith("Error occured while trying to proxy") ||
|
|
51
|
+
err.message?.includes("http proxy error") ||
|
|
52
|
+
err.message?.startsWith("Gateway Timeout") ||
|
|
53
|
+
err.status == 500) && i++ < 50) {
|
|
54
|
+
await new Promise((res, req) => {
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
res({});
|
|
57
|
+
}, 250);
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function toPromise(p) {
|
|
66
|
+
let r;
|
|
67
|
+
if (p["toPromise"] !== undefined) {
|
|
68
|
+
r = p["toPromise"]();
|
|
69
|
+
}
|
|
70
|
+
//@ts-ignore
|
|
71
|
+
else
|
|
72
|
+
r = p;
|
|
73
|
+
return r.then((x) => {
|
|
74
|
+
if (x && (x.status == 200 || x.status == 201) && x.headers && x.request && x.data) //for axios
|
|
75
|
+
return x.data;
|
|
76
|
+
return x;
|
|
77
|
+
}).catch(async (ex) => {
|
|
78
|
+
throw await processHttpException(ex);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export async function processHttpException(ex) {
|
|
82
|
+
let z = await ex;
|
|
83
|
+
var error;
|
|
84
|
+
if (z.error)
|
|
85
|
+
error = z.error;
|
|
86
|
+
else if (z.isAxiosError) {
|
|
87
|
+
if (typeof z.response?.data === "string")
|
|
88
|
+
error = z.response.data;
|
|
89
|
+
else
|
|
90
|
+
error = z?.response?.data;
|
|
91
|
+
}
|
|
92
|
+
if (!error)
|
|
93
|
+
error = z.message;
|
|
94
|
+
if (z.status == 0 && z.error.isTrusted)
|
|
95
|
+
error = "Network Error";
|
|
96
|
+
if (typeof error === 'string') {
|
|
97
|
+
error = {
|
|
98
|
+
message: error,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (z.modelState)
|
|
102
|
+
error.modelState = z.modelState;
|
|
103
|
+
let httpStatusCode = z.status;
|
|
104
|
+
if (httpStatusCode === undefined)
|
|
105
|
+
httpStatusCode = z.response?.status;
|
|
106
|
+
if (httpStatusCode !== undefined && httpStatusCode !== null) {
|
|
107
|
+
error.httpStatusCode = httpStatusCode;
|
|
108
|
+
}
|
|
109
|
+
var result = Object.assign(error, {
|
|
110
|
+
// exception: ex disabled for now because JSON.stringify crashed with this
|
|
111
|
+
});
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { ClassType } from '../classType';
|
|
2
|
+
import { Allowed, AllowedForInstance } from './context';
|
|
3
|
+
import { EntityMetadata, FieldRef, OmitEB } from './remult3';
|
|
4
|
+
export interface FieldOptions<entityType = any, valueType = any> {
|
|
5
|
+
/** A human readable name for the field. Can be used to achieve a consistent caption for a field throughout the app
|
|
6
|
+
* @example
|
|
7
|
+
* <input placeholder={taskRepo.metadata.fields.title.caption}/>
|
|
8
|
+
*/
|
|
9
|
+
caption?: string;
|
|
10
|
+
/** If it can store null in the database */
|
|
11
|
+
allowNull?: boolean;
|
|
12
|
+
/** If this field data is included in the api.
|
|
13
|
+
* @see [allowed](http://remult.dev/docs/allowed.html)*/
|
|
14
|
+
includeInApi?: Allowed;
|
|
15
|
+
/** If this field data can be updated in the api.
|
|
16
|
+
* @see [allowed](http://remult.dev/docs/allowed.html)*/
|
|
17
|
+
allowApiUpdate?: AllowedForInstance<entityType>;
|
|
18
|
+
/** An arrow function that'll be used to perform validations on it
|
|
19
|
+
* @example
|
|
20
|
+
* @Fields.string({
|
|
21
|
+
* validate: Validators.required
|
|
22
|
+
* })
|
|
23
|
+
* @example
|
|
24
|
+
* @Fields.string<Task>({
|
|
25
|
+
* validate: task=>{
|
|
26
|
+
* if (task.title.length<3)
|
|
27
|
+
* throw "Too Short";
|
|
28
|
+
* }
|
|
29
|
+
* })
|
|
30
|
+
* @example
|
|
31
|
+
* @Fields.string({
|
|
32
|
+
* validate: (_, fieldRef)=>{
|
|
33
|
+
* if (fieldRef.value.length<3)
|
|
34
|
+
* fieldRef.error = "Too Short";
|
|
35
|
+
* }
|
|
36
|
+
* })
|
|
37
|
+
*/
|
|
38
|
+
validate?: ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => (any | Promise<any>)) | ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => (any | Promise<any>))[];
|
|
39
|
+
/** Will be fired before this field is saved to the server/database */
|
|
40
|
+
saving?: ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => (any | Promise<any>));
|
|
41
|
+
/** An expression that will determine this fields value on the backend and be provided to the front end*/
|
|
42
|
+
serverExpression?: (entity: entityType) => valueType | Promise<valueType>;
|
|
43
|
+
/** The name of the column in the database that holds the data for this field. If no name is set, the key will be used instead. */
|
|
44
|
+
dbName?: string;
|
|
45
|
+
/** Used or fields that are based on an sql expressions, instead of a physical table column
|
|
46
|
+
* @example
|
|
47
|
+
*
|
|
48
|
+
* @Fields.integer({
|
|
49
|
+
* sqlExpression:e=> 'length(title)'
|
|
50
|
+
* })
|
|
51
|
+
* titleLength = 0;
|
|
52
|
+
* @Fields.string()
|
|
53
|
+
* title='';
|
|
54
|
+
*/
|
|
55
|
+
sqlExpression?: string | ((entity: EntityMetadata<entityType>) => string | Promise<string>);
|
|
56
|
+
/** For fields that shouldn't be part of an update or insert statement */
|
|
57
|
+
dbReadOnly?: boolean;
|
|
58
|
+
/** The value converter to be used when loading and saving this field */
|
|
59
|
+
valueConverter?: ValueConverter<valueType>;
|
|
60
|
+
/** an arrow function that translates the value to a display value */
|
|
61
|
+
displayValue?: (entity: entityType, value: valueType) => string;
|
|
62
|
+
/** an arrow function that determines the default value of the field, when the entity is created using the `repo.create` method */
|
|
63
|
+
defaultValue?: (entity: entityType) => valueType | Promise<valueType>;
|
|
64
|
+
/** The html input type for this field */
|
|
65
|
+
inputType?: string;
|
|
66
|
+
/** Determines if the referenced entity will be loaded immediately or on demand.
|
|
67
|
+
* @see[Lazy loading of related entities](http://remult.dev/docs/lazy-loading-of-related-entities.html)
|
|
68
|
+
*/
|
|
69
|
+
lazy?: boolean;
|
|
70
|
+
/** The value type for this field */
|
|
71
|
+
valueType?: any;
|
|
72
|
+
/** The entity type to which this field belongs */
|
|
73
|
+
target?: ClassType<entityType>;
|
|
74
|
+
/** The key to be used for this field */
|
|
75
|
+
key?: string;
|
|
76
|
+
}
|
|
77
|
+
/**Metadata for a `Field`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
78
|
+
export interface FieldMetadata<valueType = any, entityType = any> {
|
|
79
|
+
/** The field's member name in an object.
|
|
80
|
+
* @example
|
|
81
|
+
* const taskRepo = remult.repo(Task);
|
|
82
|
+
* console.log(taskRepo.metadata.fields.title.key);
|
|
83
|
+
* // result: title
|
|
84
|
+
*/
|
|
85
|
+
readonly key: string;
|
|
86
|
+
/** A human readable caption for the field. Can be used to achieve a consistent caption for a field throughout the app
|
|
87
|
+
* @example
|
|
88
|
+
* <input placeholder={taskRepo.metadata.fields.title.caption}/>
|
|
89
|
+
*/
|
|
90
|
+
readonly caption: string;
|
|
91
|
+
/** The field's value type (number,string etc...) */
|
|
92
|
+
readonly valueType: any;
|
|
93
|
+
/** The options sent to this field's decorator */
|
|
94
|
+
readonly options: FieldOptions;
|
|
95
|
+
/** The `inputType` relevant for this field, determined by the options sent to it's decorator and the valueConverter in these options */
|
|
96
|
+
readonly inputType: string;
|
|
97
|
+
/** if null is allowed for this field */
|
|
98
|
+
readonly allowNull: boolean;
|
|
99
|
+
/** The class that contains this field
|
|
100
|
+
* @example
|
|
101
|
+
* const taskRepo = remult.repo(Task);
|
|
102
|
+
* Task == taskRepo.metadata.fields.title.target //will return true
|
|
103
|
+
*/
|
|
104
|
+
readonly target: ClassType<valueType>;
|
|
105
|
+
/** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
|
|
106
|
+
getDbName(): Promise<string>;
|
|
107
|
+
/** Indicates if this field is based on a server express */
|
|
108
|
+
readonly isServerExpression: boolean;
|
|
109
|
+
/** indicates that this field should only be included in select statement, and excluded from update or insert. useful for db generated ids etc... */
|
|
110
|
+
readonly dbReadOnly: boolean;
|
|
111
|
+
/** the Value converter for this field */
|
|
112
|
+
readonly valueConverter: Required<ValueConverter<valueType>>;
|
|
113
|
+
/** Get the display value for a specific item
|
|
114
|
+
* @example
|
|
115
|
+
* repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
|
|
116
|
+
*/
|
|
117
|
+
displayValue(item: Partial<OmitEB<entityType>>): string;
|
|
118
|
+
apiUpdateAllowed(item?: Partial<OmitEB<entityType>>): boolean;
|
|
119
|
+
readonly includedInApi: boolean;
|
|
120
|
+
/** Adapts the value for usage with html input
|
|
121
|
+
* @example
|
|
122
|
+
* @Fields.dateOnly()
|
|
123
|
+
* birthDate = new Date(1976,5,16)
|
|
124
|
+
* //...
|
|
125
|
+
* input.value = repo.fields.birthDate.toInput(person) // will return '1976-06-16'
|
|
126
|
+
*/
|
|
127
|
+
toInput(value: valueType, inputType?: string): string;
|
|
128
|
+
/** Adapts the value for usage with html input
|
|
129
|
+
* @example
|
|
130
|
+
* @Fields.dateOnly()
|
|
131
|
+
* birthDate = new Date(1976,5,16)
|
|
132
|
+
* //...
|
|
133
|
+
* person.birthDate = repo.fields.birthDate.fromInput(personFormState) // will return Date
|
|
134
|
+
*/
|
|
135
|
+
fromInput(inputValue: string, inputType?: string): valueType;
|
|
136
|
+
}
|
|
137
|
+
export interface ValueConverter<valueType> {
|
|
138
|
+
fromJson?(val: any): valueType;
|
|
139
|
+
toJson?(val: valueType): any;
|
|
140
|
+
fromDb?(val: any): valueType;
|
|
141
|
+
toDb?(val: valueType): any;
|
|
142
|
+
toInput?(val: valueType, inputType?: string): string;
|
|
143
|
+
fromInput?(val: string, inputType?: string): valueType;
|
|
144
|
+
displayValue?(val: valueType): string;
|
|
145
|
+
readonly fieldTypeInDb?: string;
|
|
146
|
+
readonly inputType?: string;
|
|
147
|
+
}
|
|
148
|
+
export declare type FieldValidator<entityType = any, valueType = any> = (entity: entityType, fieldRef: FieldRef<entityType, valueType>) => void | Promise<void>;
|
|
149
|
+
export declare type ValueOrExpression<valueType> = valueType | (() => valueType);
|
|
150
|
+
export declare function valueOrExpressionToValue<valueType>(f: ValueOrExpression<valueType>): valueType;
|
|
151
|
+
export interface ValueListItem {
|
|
152
|
+
id?: any;
|
|
153
|
+
caption?: any;
|
|
154
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ClassType } from '../classType';
|
|
2
|
+
import { FieldMetadata, FieldOptions, ValueConverter } from './column-interfaces';
|
|
3
|
+
import { Filter } from './filter/filter-interfaces';
|
|
4
|
+
import { EntityFilter, FindOptions, idType, Repository, RepositoryImplementation } from './remult3';
|
|
5
|
+
export declare function makeTitle(name: string): string;
|
|
6
|
+
export declare class CompoundIdField implements FieldMetadata<string> {
|
|
7
|
+
fields: FieldMetadata[];
|
|
8
|
+
constructor(...columns: FieldMetadata[]);
|
|
9
|
+
apiUpdateAllowed(item: any): boolean;
|
|
10
|
+
displayValue(item: any): string;
|
|
11
|
+
includedInApi: boolean;
|
|
12
|
+
toInput(value: string, inputType?: string): string;
|
|
13
|
+
fromInput(inputValue: string, inputType?: string): string;
|
|
14
|
+
getDbName(): Promise<string>;
|
|
15
|
+
getId(instance: any): string;
|
|
16
|
+
options: FieldOptions<any, any>;
|
|
17
|
+
get valueConverter(): Required<ValueConverter<string>>;
|
|
18
|
+
target: ClassType<any>;
|
|
19
|
+
readonly: true;
|
|
20
|
+
allowNull: boolean;
|
|
21
|
+
dbReadOnly: boolean;
|
|
22
|
+
isServerExpression: boolean;
|
|
23
|
+
key: string;
|
|
24
|
+
caption: string;
|
|
25
|
+
inputType: string;
|
|
26
|
+
dbName: string;
|
|
27
|
+
valueType: any;
|
|
28
|
+
isEqualTo(value: FieldMetadata<string> | string): EntityFilter<any>;
|
|
29
|
+
resultIdFilter(id: string, data: any): Filter;
|
|
30
|
+
}
|
|
31
|
+
export declare class LookupColumn<T> {
|
|
32
|
+
private repository;
|
|
33
|
+
id: idType<T>;
|
|
34
|
+
toJson(): any;
|
|
35
|
+
setId(val: any): void;
|
|
36
|
+
waitLoadOf(id: any): Promise<T> | null;
|
|
37
|
+
get(id: any): any;
|
|
38
|
+
storedItem: {
|
|
39
|
+
item: T;
|
|
40
|
+
};
|
|
41
|
+
set(item: T): void;
|
|
42
|
+
constructor(repository: RepositoryImplementation<T>, id: idType<T>);
|
|
43
|
+
get item(): T;
|
|
44
|
+
waitLoad(): Promise<T | null>;
|
|
45
|
+
}
|
|
46
|
+
export declare class OneToMany<T> {
|
|
47
|
+
private provider;
|
|
48
|
+
private settings?;
|
|
49
|
+
constructor(provider: Repository<T>, settings?: ({
|
|
50
|
+
create?: ((newItem: T) => void) | undefined;
|
|
51
|
+
} & FindOptions<T>) | undefined);
|
|
52
|
+
private _items;
|
|
53
|
+
private _currentPromise;
|
|
54
|
+
get lazyItems(): T[];
|
|
55
|
+
load(): Promise<T[]>;
|
|
56
|
+
private find;
|
|
57
|
+
create(item?: Partial<T>): T;
|
|
58
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { assign } from '../assign';
|
|
2
|
+
import { Filter } from './filter/filter-interfaces';
|
|
3
|
+
import { getEntityRef, __updateEntityBasedOnWhere } from './remult3';
|
|
4
|
+
export function makeTitle(name) {
|
|
5
|
+
// insert a space before all caps
|
|
6
|
+
return name.replace(/([A-Z])/g, ' $1')
|
|
7
|
+
// uppercase the first character
|
|
8
|
+
.replace(/^./, (str) => str.toUpperCase()).replace('Email', 'eMail').replace(" I D", " ID");
|
|
9
|
+
}
|
|
10
|
+
export class CompoundIdField {
|
|
11
|
+
fields;
|
|
12
|
+
constructor(...columns) {
|
|
13
|
+
this.fields = columns;
|
|
14
|
+
}
|
|
15
|
+
apiUpdateAllowed(item) {
|
|
16
|
+
throw new Error('Method not implemented.');
|
|
17
|
+
}
|
|
18
|
+
displayValue(item) {
|
|
19
|
+
throw new Error('Method not implemented.');
|
|
20
|
+
}
|
|
21
|
+
includedInApi;
|
|
22
|
+
toInput(value, inputType) {
|
|
23
|
+
throw new Error('Method not implemented.');
|
|
24
|
+
}
|
|
25
|
+
fromInput(inputValue, inputType) {
|
|
26
|
+
throw new Error('Method not implemented.');
|
|
27
|
+
}
|
|
28
|
+
getDbName() {
|
|
29
|
+
return Promise.resolve("");
|
|
30
|
+
}
|
|
31
|
+
getId(instance) {
|
|
32
|
+
let r = "";
|
|
33
|
+
this.fields.forEach(c => {
|
|
34
|
+
if (r.length > 0)
|
|
35
|
+
r += ',';
|
|
36
|
+
r += instance[c.key];
|
|
37
|
+
});
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
options;
|
|
41
|
+
get valueConverter() {
|
|
42
|
+
throw new Error("cant get value converter of compound id");
|
|
43
|
+
}
|
|
44
|
+
target;
|
|
45
|
+
readonly;
|
|
46
|
+
allowNull;
|
|
47
|
+
dbReadOnly;
|
|
48
|
+
isServerExpression;
|
|
49
|
+
key;
|
|
50
|
+
caption;
|
|
51
|
+
inputType;
|
|
52
|
+
dbName;
|
|
53
|
+
valueType;
|
|
54
|
+
isEqualTo(value) {
|
|
55
|
+
let result = {};
|
|
56
|
+
let val = value.toString();
|
|
57
|
+
let id = val.split(',');
|
|
58
|
+
this.fields.forEach((c, i) => {
|
|
59
|
+
result[c.key] = id[i];
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
resultIdFilter(id, data) {
|
|
64
|
+
return new Filter(add => {
|
|
65
|
+
let idParts = [];
|
|
66
|
+
if (id != undefined)
|
|
67
|
+
idParts = id.split(',');
|
|
68
|
+
this.fields.forEach((c, i) => {
|
|
69
|
+
let val = undefined;
|
|
70
|
+
if (i < idParts.length)
|
|
71
|
+
val = idParts[i];
|
|
72
|
+
if (data[c.key] != undefined)
|
|
73
|
+
val = data[c.key];
|
|
74
|
+
add.isEqualTo(c, val);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class LookupColumn {
|
|
80
|
+
repository;
|
|
81
|
+
id;
|
|
82
|
+
toJson() {
|
|
83
|
+
if (this.item === null)
|
|
84
|
+
return null;
|
|
85
|
+
return this.repository.toJson(this.item);
|
|
86
|
+
}
|
|
87
|
+
setId(val) {
|
|
88
|
+
if (this.repository.metadata.idMetadata.field.valueType == Number)
|
|
89
|
+
val = +val;
|
|
90
|
+
this.id = val;
|
|
91
|
+
}
|
|
92
|
+
waitLoadOf(id) {
|
|
93
|
+
if (id === undefined || id === null)
|
|
94
|
+
return null;
|
|
95
|
+
return this.repository.getCachedByIdAsync(id);
|
|
96
|
+
}
|
|
97
|
+
get(id) {
|
|
98
|
+
if (id === undefined || id === null)
|
|
99
|
+
return null;
|
|
100
|
+
return this.repository.getCachedById(id);
|
|
101
|
+
}
|
|
102
|
+
storedItem;
|
|
103
|
+
set(item) {
|
|
104
|
+
this.storedItem = undefined;
|
|
105
|
+
if (item) {
|
|
106
|
+
if (typeof item === "string" || typeof item === "number")
|
|
107
|
+
this.id = item;
|
|
108
|
+
else {
|
|
109
|
+
let eo = getEntityRef(item, false);
|
|
110
|
+
if (eo) {
|
|
111
|
+
this.repository.addToCache(item);
|
|
112
|
+
this.id = eo.getId();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.storedItem = { item };
|
|
116
|
+
this.id = item[this.repository.metadata.idMetadata.field.key];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (item === null) {
|
|
121
|
+
this.id = null;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.id = undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
constructor(repository, id) {
|
|
128
|
+
this.repository = repository;
|
|
129
|
+
this.id = id;
|
|
130
|
+
}
|
|
131
|
+
get item() {
|
|
132
|
+
if (this.storedItem)
|
|
133
|
+
return this.storedItem.item;
|
|
134
|
+
return this.get(this.id);
|
|
135
|
+
}
|
|
136
|
+
async waitLoad() {
|
|
137
|
+
return this.waitLoadOf(this.id);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
9000;
|
|
141
|
+
export class OneToMany {
|
|
142
|
+
provider;
|
|
143
|
+
settings;
|
|
144
|
+
constructor(provider, settings) {
|
|
145
|
+
this.provider = provider;
|
|
146
|
+
this.settings = settings;
|
|
147
|
+
}
|
|
148
|
+
_items;
|
|
149
|
+
_currentPromise;
|
|
150
|
+
get lazyItems() {
|
|
151
|
+
this.load();
|
|
152
|
+
return this._items;
|
|
153
|
+
}
|
|
154
|
+
async load() {
|
|
155
|
+
if (this._currentPromise != null)
|
|
156
|
+
return this._currentPromise;
|
|
157
|
+
if (this._items === undefined)
|
|
158
|
+
this._items = [];
|
|
159
|
+
return this._currentPromise = this.find().then(x => {
|
|
160
|
+
this._items.splice(0);
|
|
161
|
+
this._items.push(...x);
|
|
162
|
+
return this._items;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async find() {
|
|
166
|
+
return this.provider.find(this.settings);
|
|
167
|
+
}
|
|
168
|
+
create(item) {
|
|
169
|
+
let r = this.provider.create();
|
|
170
|
+
__updateEntityBasedOnWhere(this.provider.metadata, this.settings.where, r);
|
|
171
|
+
assign(r, item);
|
|
172
|
+
return r;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { DataProvider } from "./data-interfaces";
|
|
2
|
+
import { EntityMetadata, EntityRef, FindOptions, Repository } from "./remult3";
|
|
3
|
+
import { ClassType } from "../classType";
|
|
4
|
+
import { LiveQueryClient } from "./live-query/LiveQueryClient";
|
|
5
|
+
import type { LiveQueryStorage, LiveQueryChangesListener, SubscriptionServer } from "./live-query/SubscriptionServer";
|
|
6
|
+
import { ExternalHttpProvider } from "./buildRestDataProvider";
|
|
7
|
+
import { SubscriptionClient, Unsubscribe } from "./live-query/SubscriptionChannel";
|
|
8
|
+
export declare class RemultAsyncLocalStorage {
|
|
9
|
+
private readonly remultObjectStorage;
|
|
10
|
+
static enable(): void;
|
|
11
|
+
static disable(): void;
|
|
12
|
+
constructor(remultObjectStorage: import('async_hooks').AsyncLocalStorage<Remult>);
|
|
13
|
+
run(remult: Remult, callback: VoidFunction): void;
|
|
14
|
+
getRemult(): Remult | undefined;
|
|
15
|
+
static instance: RemultAsyncLocalStorage;
|
|
16
|
+
}
|
|
17
|
+
export declare function isBackend(): boolean;
|
|
18
|
+
export declare class Remult {
|
|
19
|
+
/**Return's a `Repository` of the specific entity type
|
|
20
|
+
* @example
|
|
21
|
+
* const taskRepo = remult.repo(Task);
|
|
22
|
+
* @see [Repository](https://remult.dev/docs/ref_repository.html)
|
|
23
|
+
* @param entity - the entity to use
|
|
24
|
+
* @param dataProvider - an optional alternative data provider to use. Useful for writing to offline storage or an alternative data provider
|
|
25
|
+
*/
|
|
26
|
+
repo<T>(entity: ClassType<T>, dataProvider?: DataProvider): Repository<T>;
|
|
27
|
+
/** Returns the current user's info */
|
|
28
|
+
user?: UserInfo;
|
|
29
|
+
/** Checks if a user was authenticated */
|
|
30
|
+
authenticated(): boolean;
|
|
31
|
+
/** checks if the user has any of the roles specified in the parameters
|
|
32
|
+
* @example
|
|
33
|
+
* remult.isAllowed("admin")
|
|
34
|
+
* @see
|
|
35
|
+
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
36
|
+
*/
|
|
37
|
+
isAllowed(roles?: Allowed): boolean;
|
|
38
|
+
/** checks if the user matches the allowedForInstance callback
|
|
39
|
+
* @see
|
|
40
|
+
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
41
|
+
*/
|
|
42
|
+
isAllowedForInstance(instance: any, allowed?: AllowedForInstance<any>): boolean;
|
|
43
|
+
/** The current data provider */
|
|
44
|
+
dataProvider: DataProvider;
|
|
45
|
+
repCache: Map<DataProvider, Map<ClassType<any>, Repository<any>>>;
|
|
46
|
+
/** Creates a new instance of the `remult` object.
|
|
47
|
+
*
|
|
48
|
+
* Can receive either an HttpProvider or a DataProvider as a parameter - which will be used to fetch data from.
|
|
49
|
+
*
|
|
50
|
+
* If no provider is specified, `fetch` will be used as an http provider
|
|
51
|
+
*/
|
|
52
|
+
constructor(http: ExternalHttpProvider | typeof fetch | ApiClient);
|
|
53
|
+
constructor(p: DataProvider);
|
|
54
|
+
constructor();
|
|
55
|
+
liveQueryStorage?: LiveQueryStorage;
|
|
56
|
+
subscriptionServer?: SubscriptionServer;
|
|
57
|
+
liveQueryPublisher: LiveQueryChangesListener;
|
|
58
|
+
/** Used to call a `backendMethod` using a specific `remult` object
|
|
59
|
+
* @example
|
|
60
|
+
* await remult.call(TasksController.setAll, undefined, true);
|
|
61
|
+
* @param backendMethod - the backend method to call
|
|
62
|
+
* @param classInstance - the class instance of the backend method, for static backend methods use undefined
|
|
63
|
+
* @param args - the arguments to send to the backend method
|
|
64
|
+
*/
|
|
65
|
+
call<T extends ((...args: any[]) => Promise<any>)>(backendMethod: T, classInstance?: any, ...args: GetArguments<T>): ReturnType<T>;
|
|
66
|
+
liveQuerySubscriber: LiveQueryClient;
|
|
67
|
+
/** A helper callback that can be used to debug and trace all find operations. Useful in debugging scenarios */
|
|
68
|
+
static onFind: (metadata: EntityMetadata, options: FindOptions<any>) => void;
|
|
69
|
+
clearAllCache(): any;
|
|
70
|
+
/** A helper callback that is called whenever an entity is created. */
|
|
71
|
+
static entityRefInit?: (ref: EntityRef<any>, row: any) => void;
|
|
72
|
+
/** context information that can be used to store custom information that will be disposed as part of the `remult` object */
|
|
73
|
+
readonly context: RemultContext;
|
|
74
|
+
/** The api client that will be used by `remult` to perform calls to the `api` */
|
|
75
|
+
apiClient: ApiClient;
|
|
76
|
+
static run<T>(callback: () => T, options: {
|
|
77
|
+
dataProvider: DataProvider;
|
|
78
|
+
}): T;
|
|
79
|
+
}
|
|
80
|
+
export type GetArguments<T> = T extends (...args: infer FirstArgument) => any ? FirstArgument : never;
|
|
81
|
+
export interface RemultContext {
|
|
82
|
+
}
|
|
83
|
+
export interface ApiClient {
|
|
84
|
+
/** The http client to use when making api calls.
|
|
85
|
+
* @example
|
|
86
|
+
* remult.apiClient.httpClient = axios;
|
|
87
|
+
* @example
|
|
88
|
+
* remult.apiClient.httpClient = httpClient;//angular http client
|
|
89
|
+
* @example
|
|
90
|
+
* remult.apiClient.httpClient = fetch; //this is the default
|
|
91
|
+
*/
|
|
92
|
+
httpClient?: ExternalHttpProvider | typeof fetch;
|
|
93
|
+
/** The base url to for making api calls */
|
|
94
|
+
url?: string;
|
|
95
|
+
subscriptionClient?: SubscriptionClient;
|
|
96
|
+
wrapMessageHandling?: (x: VoidFunction) => void;
|
|
97
|
+
}
|
|
98
|
+
export declare const allEntities: ClassType<any>[];
|
|
99
|
+
export interface ControllerOptions {
|
|
100
|
+
key: string;
|
|
101
|
+
}
|
|
102
|
+
export declare const classHelpers: Map<any, ClassHelper>;
|
|
103
|
+
export declare class ClassHelper {
|
|
104
|
+
classes: Map<any, ControllerOptions>;
|
|
105
|
+
}
|
|
106
|
+
export declare function setControllerSettings(target: any, options: ControllerOptions): void;
|
|
107
|
+
export interface UserInfo {
|
|
108
|
+
id: string;
|
|
109
|
+
name?: string;
|
|
110
|
+
roles?: string[];
|
|
111
|
+
}
|
|
112
|
+
export declare type Allowed = boolean | string | string[] | ((c?: Remult) => boolean);
|
|
113
|
+
export declare type AllowedForInstance<T> = boolean | string | string[] | ((entity?: T, c?: Remult) => boolean);
|
|
114
|
+
export declare class Allow {
|
|
115
|
+
static everyone: () => boolean;
|
|
116
|
+
static authenticated: (...args: any[]) => any;
|
|
117
|
+
}
|
|
118
|
+
export declare const queryConfig: {
|
|
119
|
+
defaultPageSize: number;
|
|
120
|
+
};
|
|
121
|
+
export interface EventDispatcher {
|
|
122
|
+
observe(what: () => any | Promise<any>): Promise<Unsubscribe>;
|
|
123
|
+
}
|
|
124
|
+
export declare class EventSource {
|
|
125
|
+
listeners: (() => {})[];
|
|
126
|
+
fire(): Promise<void>;
|
|
127
|
+
dispatcher: EventDispatcher;
|
|
128
|
+
}
|
|
129
|
+
export interface itemChange {
|
|
130
|
+
id: any;
|
|
131
|
+
oldId: any;
|
|
132
|
+
deleted: boolean;
|
|
133
|
+
}
|
|
134
|
+
export declare function doTransaction(remult: Remult, what: () => Promise<void>): Promise<void>;
|