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,138 +0,0 @@
|
|
|
1
|
-
import { Component, Input, ViewChild, ViewContainerRef } from '@angular/core';
|
|
2
|
-
import { ErrorStateMatcher } from '@angular/material/core';
|
|
3
|
-
import { decorateDataSettings, FieldCollection } from '../../../interfaces';
|
|
4
|
-
@Component({
|
|
5
|
-
selector: 'data-control',
|
|
6
|
-
templateUrl: './data-control2.component.html',
|
|
7
|
-
styleUrls: ['./data-control2.component.scss']
|
|
8
|
-
})
|
|
9
|
-
export class DataControl2Component {
|
|
10
|
-
plugin;
|
|
11
|
-
componentFactoryResolver;
|
|
12
|
-
@Input()
|
|
13
|
-
map;
|
|
14
|
-
@Input()
|
|
15
|
-
set field(value) {
|
|
16
|
-
this.map = {
|
|
17
|
-
field: value
|
|
18
|
-
};
|
|
19
|
-
decorateDataSettings(this.map.field, this.map);
|
|
20
|
-
this.settings.augment(this.plugin.dataControlAugmenter, this.map);
|
|
21
|
-
this.initCustomComponent();
|
|
22
|
-
}
|
|
23
|
-
constructor(plugin, componentFactoryResolver) {
|
|
24
|
-
this.plugin = plugin;
|
|
25
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
26
|
-
}
|
|
27
|
-
@ViewChild('theId', { read: ViewContainerRef, static: true })
|
|
28
|
-
theId;
|
|
29
|
-
done = false;
|
|
30
|
-
initCustomComponent() {
|
|
31
|
-
if (this.map?.customComponent?.component) {
|
|
32
|
-
if (this.done)
|
|
33
|
-
return;
|
|
34
|
-
const fieldRef = this.map.field;
|
|
35
|
-
if (!fieldRef.metadata) {
|
|
36
|
-
this.map.customComponent = undefined;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.done = true;
|
|
40
|
-
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.map.customComponent.component);
|
|
41
|
-
const viewContainerRef = this.theId;
|
|
42
|
-
viewContainerRef.clear();
|
|
43
|
-
const componentRef = viewContainerRef.createComponent(componentFactory);
|
|
44
|
-
componentRef.instance.args = {
|
|
45
|
-
fieldRef,
|
|
46
|
-
settings: this.map
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
@Input()
|
|
51
|
-
record;
|
|
52
|
-
@Input()
|
|
53
|
-
notReadonly = false;
|
|
54
|
-
@Input()
|
|
55
|
-
settings = new FieldCollection(undefined, () => true, undefined, undefined, () => undefined);
|
|
56
|
-
showDescription() {
|
|
57
|
-
return (this.map.field) && this.map.getValue || !this._getEditable();
|
|
58
|
-
}
|
|
59
|
-
getDropDown() {
|
|
60
|
-
return this.map.valueList;
|
|
61
|
-
}
|
|
62
|
-
showClick() {
|
|
63
|
-
if (!this.map.click)
|
|
64
|
-
return false;
|
|
65
|
-
if (!this._getEditable())
|
|
66
|
-
return false;
|
|
67
|
-
if (this.map.allowClick === undefined) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
return this.settings.allowClick(this.map, this.record);
|
|
71
|
-
}
|
|
72
|
-
click() {
|
|
73
|
-
if (this.showClick())
|
|
74
|
-
this.settings._click(this.map, this.record);
|
|
75
|
-
}
|
|
76
|
-
getClickIcon() {
|
|
77
|
-
if (this.map.clickIcon)
|
|
78
|
-
return this.map.clickIcon;
|
|
79
|
-
return 'keyboard_arrow_down';
|
|
80
|
-
}
|
|
81
|
-
dataControlStyle() {
|
|
82
|
-
return this.settings.__dataControlStyle(this.map);
|
|
83
|
-
}
|
|
84
|
-
dummy = { inputValue: '' };
|
|
85
|
-
_getColumn() {
|
|
86
|
-
if (!this.map.field)
|
|
87
|
-
return this.dummy;
|
|
88
|
-
return this.settings.__getColumn(this.map, this.record);
|
|
89
|
-
}
|
|
90
|
-
_getEditable() {
|
|
91
|
-
if (this.notReadonly)
|
|
92
|
-
return true;
|
|
93
|
-
return this.settings._getEditable(this.map, this.record);
|
|
94
|
-
}
|
|
95
|
-
ngOnChanges() {
|
|
96
|
-
this.initCustomComponent();
|
|
97
|
-
}
|
|
98
|
-
isSelect() {
|
|
99
|
-
if (this.map.valueList && this._getEditable())
|
|
100
|
-
return true;
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
showTextBox() {
|
|
104
|
-
return !this.isSelect() && !this.showCheckbox();
|
|
105
|
-
}
|
|
106
|
-
showCheckbox() {
|
|
107
|
-
return this.settings._getColDataType(this.map) == 'checkbox';
|
|
108
|
-
}
|
|
109
|
-
getError() {
|
|
110
|
-
return this.settings._getError(this.map, this.record);
|
|
111
|
-
}
|
|
112
|
-
getStyle() {
|
|
113
|
-
if (this.showDescription()) {
|
|
114
|
-
if (this.map.hideDataOnInput || !this._getEditable()) {
|
|
115
|
-
return { display: 'none' };
|
|
116
|
-
}
|
|
117
|
-
return { width: '50px' };
|
|
118
|
-
}
|
|
119
|
-
return {};
|
|
120
|
-
}
|
|
121
|
-
getFloatLabel() {
|
|
122
|
-
if (this.showDescription()) {
|
|
123
|
-
if (this.settings._getColDisplayValue(this.map, this.record))
|
|
124
|
-
return 'always';
|
|
125
|
-
}
|
|
126
|
-
return 'auto';
|
|
127
|
-
}
|
|
128
|
-
ngErrorStateMatches = new class extends ErrorStateMatcher {
|
|
129
|
-
parent;
|
|
130
|
-
constructor(parent) {
|
|
131
|
-
super();
|
|
132
|
-
this.parent = parent;
|
|
133
|
-
}
|
|
134
|
-
isErrorState() {
|
|
135
|
-
return !!this.parent.getError();
|
|
136
|
-
}
|
|
137
|
-
}(this);
|
|
138
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { GenericRequestInfo, GenericResponse } from './server/index';
|
|
3
|
-
import { Remult } from './src/context';
|
|
4
|
-
import { ServerEventChannelSubscribeDTO } from './src/live-query/SubscriptionChannel';
|
|
5
|
-
import { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
6
|
-
import { DataApiResponse } from './src/data-api';
|
|
7
|
-
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
8
|
-
private canUserConnectToChannel?;
|
|
9
|
-
subscribeToChannel({ channel, clientId }: ServerEventChannelSubscribeDTO, res: DataApiResponse, remult: Remult, remove?: boolean): void;
|
|
10
|
-
private connections;
|
|
11
|
-
constructor(canUserConnectToChannel?: ((channel: string, remult: Remult) => boolean) | undefined);
|
|
12
|
-
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
13
|
-
debugMessageFileSaver: (id: any, channel: any, message: any) => void;
|
|
14
|
-
openHttpServerStream(req: GenericRequestInfo, res: GenericResponse & ResponseRequiredForSSE): clientConnection;
|
|
15
|
-
debug(): void;
|
|
16
|
-
debugFileSaver: (x: any) => void;
|
|
17
|
-
}
|
|
18
|
-
export interface ResponseRequiredForSSE {
|
|
19
|
-
write(data: string): void;
|
|
20
|
-
writeHead(status: number, headers: any): void;
|
|
21
|
-
flush?(): void;
|
|
22
|
-
}
|
|
23
|
-
export declare class clientConnection {
|
|
24
|
-
response: GenericResponse & ResponseRequiredForSSE;
|
|
25
|
-
channels: Record<string, boolean>;
|
|
26
|
-
timeOutRef: NodeJS.Timeout;
|
|
27
|
-
close(): void;
|
|
28
|
-
closed: boolean;
|
|
29
|
-
write(eventData: string, eventType?: string): void;
|
|
30
|
-
connectionId: any;
|
|
31
|
-
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
32
|
-
sendLiveMessage(): void;
|
|
33
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
|
2
|
-
import { ConnectionNotFoundError } from './src/live-query/SseSubscriptionClient';
|
|
3
|
-
export class SseSubscriptionServer {
|
|
4
|
-
canUserConnectToChannel;
|
|
5
|
-
//@internal
|
|
6
|
-
subscribeToChannel({ channel, clientId }, res, remult, remove = false) {
|
|
7
|
-
for (const c of this.connections) {
|
|
8
|
-
if (c.connectionId === clientId) {
|
|
9
|
-
if (this.canUserConnectToChannel(channel, remult)) {
|
|
10
|
-
if (remove)
|
|
11
|
-
delete c.channels[channel];
|
|
12
|
-
else
|
|
13
|
-
c.channels[channel] = true;
|
|
14
|
-
res.success({ status: "ok" });
|
|
15
|
-
this.debug();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
res.forbidden();
|
|
20
|
-
this.debug();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
res.success(ConnectionNotFoundError);
|
|
26
|
-
}
|
|
27
|
-
//@internal
|
|
28
|
-
connections = [];
|
|
29
|
-
constructor(canUserConnectToChannel) {
|
|
30
|
-
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
31
|
-
if (!this.canUserConnectToChannel) {
|
|
32
|
-
this.canUserConnectToChannel = () => true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async publishMessage(channel, message) {
|
|
36
|
-
const data = JSON.stringify({ channel, data: message });
|
|
37
|
-
for (const sc of this.connections) {
|
|
38
|
-
if (sc.channels[channel]) {
|
|
39
|
-
this.debugMessageFileSaver(sc.connectionId, channel, message);
|
|
40
|
-
sc.write(data);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//@internal
|
|
45
|
-
debugMessageFileSaver = (id, channel, message) => { };
|
|
46
|
-
//@internal
|
|
47
|
-
openHttpServerStream(req, res) {
|
|
48
|
-
res.writeHead(200, {
|
|
49
|
-
'Content-Type': 'text/event-stream',
|
|
50
|
-
'Cache-Control': 'no-cache',
|
|
51
|
-
'Connection': 'keep-alive'
|
|
52
|
-
});
|
|
53
|
-
const cc = new clientConnection(res);
|
|
54
|
-
//const lastEventId = req.headers['last-event-id'];
|
|
55
|
-
this.connections.push(cc);
|
|
56
|
-
this.debug();
|
|
57
|
-
//@ts-ignore
|
|
58
|
-
req.on("close", () => {
|
|
59
|
-
cc.close();
|
|
60
|
-
this.connections = this.connections.filter(s => s !== cc);
|
|
61
|
-
this.debug();
|
|
62
|
-
});
|
|
63
|
-
return cc;
|
|
64
|
-
}
|
|
65
|
-
//@internal
|
|
66
|
-
debug() {
|
|
67
|
-
this.debugFileSaver(this.connections.map(x => ({
|
|
68
|
-
id: x.connectionId,
|
|
69
|
-
channels: x.channels
|
|
70
|
-
})));
|
|
71
|
-
}
|
|
72
|
-
//@internal
|
|
73
|
-
debugFileSaver = () => { };
|
|
74
|
-
}
|
|
75
|
-
export class clientConnection {
|
|
76
|
-
response;
|
|
77
|
-
channels = {};
|
|
78
|
-
timeOutRef;
|
|
79
|
-
close() {
|
|
80
|
-
if (this.timeOutRef)
|
|
81
|
-
clearTimeout(this.timeOutRef);
|
|
82
|
-
this.closed = true;
|
|
83
|
-
}
|
|
84
|
-
closed = false;
|
|
85
|
-
write(eventData, eventType = "message") {
|
|
86
|
-
let event = "event:" + eventType;
|
|
87
|
-
// if (id != undefined)
|
|
88
|
-
// event += "\nid:" + id;
|
|
89
|
-
this.response.write(event + "\ndata:" + eventData + "\n\n");
|
|
90
|
-
if (this.response.flush)
|
|
91
|
-
this.response.flush();
|
|
92
|
-
}
|
|
93
|
-
connectionId = uuid();
|
|
94
|
-
constructor(response) {
|
|
95
|
-
this.response = response;
|
|
96
|
-
this.write(this.connectionId, "connectionId");
|
|
97
|
-
this.sendLiveMessage();
|
|
98
|
-
}
|
|
99
|
-
sendLiveMessage() {
|
|
100
|
-
if (this.closed)
|
|
101
|
-
return;
|
|
102
|
-
this.write("", "keep-alive");
|
|
103
|
-
this.timeOutRef = setTimeout(() => {
|
|
104
|
-
this.sendLiveMessage();
|
|
105
|
-
}, 45000);
|
|
106
|
-
}
|
|
107
|
-
}
|
package/esm/core/assign.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function assign<T>(item: T, valuesToSet: Partial<T>): T;
|
package/esm/core/assign.js
DELETED
package/esm/core/classType.d.ts
DELETED
package/esm/core/classType.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/core/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export { Field, Fields, FieldsMetadata, Entity, IdEntity, EntityBase, ControllerBase, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FieldType, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, getFields, EntityRef, getEntityRef, SortSegments, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, OmitEB, Paginator, CaptionTransformer, LiveQuery, LiveQueryChangeInfo } from './src/remult3';
|
|
2
|
-
export { StringFieldOptions } from './src/remult3/RepositoryImplementation';
|
|
3
|
-
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
4
|
-
export { EntityOptions } from './src/entity';
|
|
5
|
-
export { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo, RestDataProviderHttpProvider } from './src/data-interfaces';
|
|
6
|
-
export { SqlCommand, SqlImplementation, SqlResult } from './src/sql-command';
|
|
7
|
-
export { FieldMetadata, FieldOptions, FieldValidator, ValueConverter, ValueListItem, // reconsider, maybe it should go to remult angular as the abstraction ?
|
|
8
|
-
ValueOrExpression } from './src/column-interfaces';
|
|
9
|
-
export { RestDataProvider } from './src/data-providers/rest-data-provider';
|
|
10
|
-
export { InMemoryDataProvider } from './src/data-providers/in-memory-database';
|
|
11
|
-
export { ArrayEntityDataProvider } from './src/data-providers/array-entity-data-provider';
|
|
12
|
-
export { WebSqlDataProvider } from './src/data-providers/web-sql-data-provider';
|
|
13
|
-
export { SqlDatabase, } from './src/data-providers/sql-database';
|
|
14
|
-
export { CustomSqlFilterObject, CustomSqlFilterBuilder, dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
15
|
-
export { JsonDataProvider, JsonEntityStorage } from './src/data-providers/json-data-provider';
|
|
16
|
-
export { Controller, BackendMethodOptions, BackendMethod, ProgressListener } from './src/server-action';
|
|
17
|
-
export { Allowed, Allow, Remult, RemultContext, ApiClient, isBackend, AllowedForInstance, EventDispatcher, EventSource, UserInfo } from './src/context';
|
|
18
|
-
export { ExternalHttpProvider } from './src/buildRestDataProvider';
|
|
19
|
-
export { SortSegment, Sort } from './src/sort';
|
|
20
|
-
export { OneToMany, CompoundIdField } from './src/column';
|
|
21
|
-
export { Filter } from './src/filter/filter-interfaces';
|
|
22
|
-
export { UrlBuilder } from './urlBuilder';
|
|
23
|
-
export { Validators } from './src/validators';
|
|
24
|
-
export { ValueConverters } from './src/valueConverters';
|
|
25
|
-
export { remult } from './src/remult-proxy';
|
|
26
|
-
export { SubscriptionServer, LiveQueryStorage, StoredQuery, InMemoryLiveQueryStorage } from "./src/live-query/SubscriptionServer";
|
|
27
|
-
export { SubscriptionListener, SubscriptionClientConnection, SubscriptionClient, SubscriptionChannel, LiveQueryChange, Unsubscribe } from './src/live-query/SubscriptionChannel';
|
package/esm/core/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Public API Surface of remult
|
|
3
|
-
*/
|
|
4
|
-
export { Field, Fields, Entity, IdEntity, EntityBase, ControllerBase, FieldType, getFields, getEntityRef, ValueListFieldType, getValueList, ValueListInfo, CaptionTransformer } from './src/remult3';
|
|
5
|
-
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
6
|
-
export { RestDataProvider } from './src/data-providers/rest-data-provider'; //V
|
|
7
|
-
export { InMemoryDataProvider } from './src/data-providers/in-memory-database'; //V
|
|
8
|
-
export { ArrayEntityDataProvider } from './src/data-providers/array-entity-data-provider'; //V
|
|
9
|
-
export { WebSqlDataProvider } from './src/data-providers/web-sql-data-provider'; //V
|
|
10
|
-
export { SqlDatabase, } from './src/data-providers/sql-database'; //V
|
|
11
|
-
export { CustomSqlFilterBuilder, dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
12
|
-
export { JsonDataProvider } from './src/data-providers/json-data-provider'; //V
|
|
13
|
-
//export * from './src/data-api'; //reconsider if to make internal
|
|
14
|
-
export { Controller, BackendMethod, ProgressListener } from './src/server-action';
|
|
15
|
-
export { Allow, Remult, isBackend, EventSource } from './src/context';
|
|
16
|
-
export { Sort } from './src/sort';
|
|
17
|
-
export { OneToMany, CompoundIdField } from './src/column';
|
|
18
|
-
export { Filter } from './src/filter/filter-interfaces';
|
|
19
|
-
export { UrlBuilder } from './urlBuilder';
|
|
20
|
-
export { Validators } from './src/validators';
|
|
21
|
-
export { ValueConverters } from './src/valueConverters';
|
|
22
|
-
export { remult } from './src/remult-proxy';
|
|
23
|
-
//export { getId } from './src/remult3/getId';
|
|
24
|
-
export { InMemoryLiveQueryStorage } from "./src/live-query/SubscriptionServer";
|
|
25
|
-
export { SubscriptionChannel } from './src/live-query/SubscriptionChannel';
|
package/esm/core/inputTypes.d.ts
DELETED
package/esm/core/inputTypes.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Storage, DataProvider } from "../src/data-interfaces";
|
|
2
|
-
import { LiveQueryStorage, StoredQuery } from "../src/live-query/SubscriptionServer";
|
|
3
|
-
import { EntityBase, Repository } from "../src/remult3";
|
|
4
|
-
export declare class DataProviderLiveQueryStorage implements LiveQueryStorage, Storage {
|
|
5
|
-
repo: Promise<Repository<LiveQueryStorageEntity>>;
|
|
6
|
-
dataProvider: Promise<DataProvider>;
|
|
7
|
-
constructor(dataProvider: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>));
|
|
8
|
-
ensureSchema(): Promise<void>;
|
|
9
|
-
add({ id, entityKey, data }: StoredQuery): Promise<void>;
|
|
10
|
-
remove(queryId: string): Promise<void>;
|
|
11
|
-
forEach(entityKey: string, callback: (args: {
|
|
12
|
-
query: StoredQuery;
|
|
13
|
-
setData(data: any): Promise<void>;
|
|
14
|
-
}) => Promise<void>): Promise<void>;
|
|
15
|
-
keepAliveAndReturnUnknownQueryIds(queryIds: string[]): Promise<string[]>;
|
|
16
|
-
}
|
|
17
|
-
export declare class LiveQueryStorageEntity extends EntityBase {
|
|
18
|
-
id: string;
|
|
19
|
-
entityKey: string;
|
|
20
|
-
data: any;
|
|
21
|
-
lastUsedIso: string;
|
|
22
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { initDataProvider } from "../server/initDataProvider";
|
|
2
|
-
import { allEntities, Remult } from "../src/context";
|
|
3
|
-
import { Entity, EntityBase, Fields } from "../src/remult3";
|
|
4
|
-
export class DataProviderLiveQueryStorage {
|
|
5
|
-
repo;
|
|
6
|
-
dataProvider;
|
|
7
|
-
constructor(dataProvider) {
|
|
8
|
-
this.dataProvider = initDataProvider(dataProvider);
|
|
9
|
-
this.repo = this.dataProvider.then(dp => new Remult(dp).repo(LiveQueryStorageEntity));
|
|
10
|
-
}
|
|
11
|
-
async ensureSchema() {
|
|
12
|
-
const dp = await this.dataProvider;
|
|
13
|
-
if (dp.ensureSchema)
|
|
14
|
-
await dp.ensureSchema([(await this.repo).metadata]);
|
|
15
|
-
}
|
|
16
|
-
async add({ id, entityKey, data }) {
|
|
17
|
-
await this.repo.then(async (repo) => {
|
|
18
|
-
const q = await repo.findId(id, { createIfNotFound: true });
|
|
19
|
-
await q.assign({ entityKey, data }).save();
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async remove(queryId) {
|
|
23
|
-
await this.repo.then(async (repo) => {
|
|
24
|
-
const r = await repo.findId(queryId);
|
|
25
|
-
if (r)
|
|
26
|
-
await repo.delete(r);
|
|
27
|
-
}).catch(() => { });
|
|
28
|
-
}
|
|
29
|
-
async forEach(entityKey, callback) {
|
|
30
|
-
const repo = await this.repo;
|
|
31
|
-
let d = new Date();
|
|
32
|
-
d.setMinutes(d.getMinutes() - 5);
|
|
33
|
-
const iso = d.toISOString();
|
|
34
|
-
for (const query of await repo.find({ where: { entityKey } })) {
|
|
35
|
-
if (query.lastUsedIso < iso)
|
|
36
|
-
await repo.delete(query);
|
|
37
|
-
else {
|
|
38
|
-
await callback({
|
|
39
|
-
query, setData: async (data) => {
|
|
40
|
-
query.data = data;
|
|
41
|
-
await repo.save(query);
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async keepAliveAndReturnUnknownQueryIds(queryIds) {
|
|
48
|
-
const repo = await this.repo;
|
|
49
|
-
for (const query of await repo.find({ where: { id: queryIds } })) {
|
|
50
|
-
query.lastUsedIso = new Date().toISOString();
|
|
51
|
-
await repo.save(query);
|
|
52
|
-
queryIds = queryIds.filter(x => x !== query.id);
|
|
53
|
-
}
|
|
54
|
-
return queryIds;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
@Entity(undefined, {
|
|
58
|
-
dbName: 'remult_live_query_storage'
|
|
59
|
-
})
|
|
60
|
-
/*@internal */
|
|
61
|
-
export class LiveQueryStorageEntity extends EntityBase {
|
|
62
|
-
@Fields.string()
|
|
63
|
-
id = '';
|
|
64
|
-
@Fields.string()
|
|
65
|
-
entityKey = '';
|
|
66
|
-
@Fields.object()
|
|
67
|
-
data;
|
|
68
|
-
@Fields.string()
|
|
69
|
-
lastUsedIso = new Date().toISOString();
|
|
70
|
-
}
|
|
71
|
-
allEntities.splice(allEntities.indexOf(LiveQueryStorageEntity), 1);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ClientBase, PoolConfig, QueryResult } from 'pg';
|
|
2
|
-
import { Remult } from '../src/context';
|
|
3
|
-
import { EntityMetadata } from '../src/remult3';
|
|
4
|
-
import { SqlCommand, SqlImplementation } from '../src/sql-command';
|
|
5
|
-
import { SqlDatabase } from '../src/data-providers/sql-database';
|
|
6
|
-
export interface PostgresPool extends PostgresCommandSource {
|
|
7
|
-
connect(): Promise<PostgresClient>;
|
|
8
|
-
}
|
|
9
|
-
export interface PostgresClient extends PostgresCommandSource {
|
|
10
|
-
release(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class PostgresDataProvider implements SqlImplementation {
|
|
13
|
-
private pool;
|
|
14
|
-
supportsJsonColumnType: boolean;
|
|
15
|
-
static getDb(remult?: Remult): ClientBase;
|
|
16
|
-
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
|
|
17
|
-
getLimitSqlSyntax(limit: number, offset: number): string;
|
|
18
|
-
createCommand(): SqlCommand;
|
|
19
|
-
constructor(pool: PostgresPool);
|
|
20
|
-
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
21
|
-
transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export interface PostgresCommandSource {
|
|
24
|
-
query(queryText: string, values?: any[]): Promise<QueryResult>;
|
|
25
|
-
}
|
|
26
|
-
export declare function createPostgresConnection(options?: {
|
|
27
|
-
connectionString?: string;
|
|
28
|
-
sslInDev?: boolean;
|
|
29
|
-
configuration?: "heroku" | PoolConfig;
|
|
30
|
-
}): Promise<SqlDatabase>;
|
|
31
|
-
export declare function createPostgresDataProvider(options?: {
|
|
32
|
-
connectionString?: string;
|
|
33
|
-
sslInDev?: boolean;
|
|
34
|
-
configuration?: "heroku" | PoolConfig;
|
|
35
|
-
}): Promise<SqlDatabase>;
|
|
36
|
-
export declare function preparePostgresQueueStorage(sql: SqlDatabase): Promise<import("../server/expressBridge").EntityQueueStorage>;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Pool } from 'pg';
|
|
2
|
-
import { Remult } from '../src/context';
|
|
3
|
-
import { PostgresSchemaBuilder } from './schema-builder';
|
|
4
|
-
import { SqlDatabase } from '../src/data-providers/sql-database';
|
|
5
|
-
export class PostgresDataProvider {
|
|
6
|
-
pool;
|
|
7
|
-
supportsJsonColumnType = true;
|
|
8
|
-
static getDb(remult) {
|
|
9
|
-
const sql = SqlDatabase.getDb(remult);
|
|
10
|
-
const me = sql._getSourceSql();
|
|
11
|
-
if (!me.pool) {
|
|
12
|
-
throw "the data provider is not a PostgresDataProvider";
|
|
13
|
-
}
|
|
14
|
-
return me.pool;
|
|
15
|
-
}
|
|
16
|
-
async entityIsUsedForTheFirstTime(entity) {
|
|
17
|
-
}
|
|
18
|
-
getLimitSqlSyntax(limit, offset) {
|
|
19
|
-
return ' limit ' + limit + ' offset ' + offset;
|
|
20
|
-
}
|
|
21
|
-
createCommand() {
|
|
22
|
-
return new PostgresBridgeToSQLCommand(this.pool);
|
|
23
|
-
}
|
|
24
|
-
constructor(pool) {
|
|
25
|
-
this.pool = pool;
|
|
26
|
-
}
|
|
27
|
-
async ensureSchema(entities) {
|
|
28
|
-
var db = new SqlDatabase(this);
|
|
29
|
-
var sb = new PostgresSchemaBuilder(db);
|
|
30
|
-
await sb.ensureSchema(entities);
|
|
31
|
-
}
|
|
32
|
-
async transaction(action) {
|
|
33
|
-
let client = await this.pool.connect();
|
|
34
|
-
try {
|
|
35
|
-
await client.query('BEGIN');
|
|
36
|
-
await action({
|
|
37
|
-
createCommand: () => new PostgresBridgeToSQLCommand(client),
|
|
38
|
-
entityIsUsedForTheFirstTime: this.entityIsUsedForTheFirstTime,
|
|
39
|
-
transaction: () => { throw "nested transactions not allowed"; },
|
|
40
|
-
getLimitSqlSyntax: this.getLimitSqlSyntax,
|
|
41
|
-
supportsJsonColumnType: this.supportsJsonColumnType,
|
|
42
|
-
//@ts-ignore
|
|
43
|
-
pool: client
|
|
44
|
-
});
|
|
45
|
-
await client.query('COMMIT');
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
await client.query('ROLLBACK');
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
await client.release();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
class PostgresBridgeToSQLCommand {
|
|
57
|
-
source;
|
|
58
|
-
constructor(source) {
|
|
59
|
-
this.source = source;
|
|
60
|
-
}
|
|
61
|
-
values = [];
|
|
62
|
-
addParameterAndReturnSqlToken(val) {
|
|
63
|
-
if (Array.isArray(val))
|
|
64
|
-
val = JSON.stringify(val);
|
|
65
|
-
this.values.push(val);
|
|
66
|
-
return '$' + this.values.length;
|
|
67
|
-
}
|
|
68
|
-
execute(sql) {
|
|
69
|
-
return this.source.query(sql, this.values).then(r => new PostgresBridgeToSQLQueryResult(r));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
class PostgresBridgeToSQLQueryResult {
|
|
73
|
-
r;
|
|
74
|
-
getColumnKeyInResultForIndexInSelect(index) {
|
|
75
|
-
return this.r.fields[index].name;
|
|
76
|
-
}
|
|
77
|
-
constructor(r) {
|
|
78
|
-
this.r = r;
|
|
79
|
-
this.rows = r.rows;
|
|
80
|
-
}
|
|
81
|
-
rows;
|
|
82
|
-
}
|
|
83
|
-
export async function createPostgresConnection(options) {
|
|
84
|
-
return createPostgresDataProvider(options);
|
|
85
|
-
}
|
|
86
|
-
export async function createPostgresDataProvider(options) {
|
|
87
|
-
if (!options)
|
|
88
|
-
options = {};
|
|
89
|
-
let config = {};
|
|
90
|
-
if (options.configuration)
|
|
91
|
-
if (options.configuration == "heroku") {
|
|
92
|
-
config = {
|
|
93
|
-
connectionString: process.env.DATABASE_URL,
|
|
94
|
-
ssl: process.env.NODE_ENV !== "production" && !options.sslInDev ? false : {
|
|
95
|
-
rejectUnauthorized: false
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
else
|
|
100
|
-
config = options.configuration;
|
|
101
|
-
else {
|
|
102
|
-
if (!options.connectionString)
|
|
103
|
-
options.connectionString = process.env.DATABASE_URL;
|
|
104
|
-
}
|
|
105
|
-
if (!config.connectionString && options.connectionString) {
|
|
106
|
-
config.connectionString = options.connectionString;
|
|
107
|
-
}
|
|
108
|
-
const db = new SqlDatabase(new PostgresDataProvider(new Pool(config)));
|
|
109
|
-
let remult = new Remult();
|
|
110
|
-
remult.dataProvider = (db);
|
|
111
|
-
return db;
|
|
112
|
-
}
|
|
113
|
-
export async function preparePostgresQueueStorage(sql) {
|
|
114
|
-
let c = new Remult();
|
|
115
|
-
c.dataProvider = (sql);
|
|
116
|
-
let JobsInQueueEntity = (await import('../server/expressBridge')).JobsInQueueEntity;
|
|
117
|
-
let e = c.repo(JobsInQueueEntity);
|
|
118
|
-
await sql.ensureSchema([e.metadata]);
|
|
119
|
-
return new (await import('../server/expressBridge')).EntityQueueStorage(c.repo(JobsInQueueEntity));
|
|
120
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FieldMetadata } from '../src/column-interfaces';
|
|
2
|
-
import { Remult } from '../src/context';
|
|
3
|
-
import { SqlDatabase } from '../src/data-providers/sql-database';
|
|
4
|
-
import { EntityMetadata } from '../src/remult3';
|
|
5
|
-
export declare function postgresColumnSyntax(x: FieldMetadata, dbName: string): string;
|
|
6
|
-
export declare function verifyStructureOfAllEntities(db: SqlDatabase, remult: Remult): Promise<void>;
|
|
7
|
-
export declare class PostgresSchemaBuilder {
|
|
8
|
-
private pool;
|
|
9
|
-
static logToConsole: boolean;
|
|
10
|
-
verifyStructureOfAllEntities(remult?: Remult): Promise<void>;
|
|
11
|
-
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
12
|
-
createIfNotExist(entity: EntityMetadata): Promise<void>;
|
|
13
|
-
addColumnIfNotExist<T extends EntityMetadata>(entity: T, c: ((e: T) => FieldMetadata)): Promise<void>;
|
|
14
|
-
verifyAllColumns<T extends EntityMetadata>(entity: T): Promise<void>;
|
|
15
|
-
additionalWhere: string;
|
|
16
|
-
constructor(pool: SqlDatabase, schema?: string);
|
|
17
|
-
}
|