remult 0.18.1-exp.0 → 0.18.1-exp.1
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/remult-express.d.ts +1 -0
- package/esm/remult-express.js +2 -0
- package/esm/src/data-providers/rest-data-provider.js +11 -6
- package/esm/src/live-query/LiveQueryPublisher.js +1 -1
- package/package.json +1 -1
- package/remult-express.d.ts +1 -0
- package/remult-express.js +2 -0
- package/src/data-providers/rest-data-provider.js +34 -18
- package/src/live-query/LiveQueryPublisher.js +4 -3
package/esm/remult-express.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class ServerEventsController implements ServerEventDispatcher {
|
|
|
14
14
|
connections: clientConnection[];
|
|
15
15
|
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
16
16
|
sendChannelMessage<T>(channel: string, message: any): void;
|
|
17
|
+
debugMessageFileSaver: (id: any, channel: any, message: any) => void;
|
|
17
18
|
openHttpServerStream(req: import('express').Request, res: import('express').Response): clientConnection;
|
|
18
19
|
debug(): void;
|
|
19
20
|
debugFileSaver: (x: any) => void;
|
package/esm/remult-express.js
CHANGED
|
@@ -53,6 +53,7 @@ export class ServerEventsController {
|
|
|
53
53
|
constructor(canUserConnectToChannel) {
|
|
54
54
|
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
55
55
|
this.connections = [];
|
|
56
|
+
this.debugMessageFileSaver = (id, channel, message) => { };
|
|
56
57
|
this.debugFileSaver = () => { };
|
|
57
58
|
if (!this.canUserConnectToChannel) {
|
|
58
59
|
this.canUserConnectToChannel = () => true;
|
|
@@ -83,6 +84,7 @@ export class ServerEventsController {
|
|
|
83
84
|
const data = JSON.stringify({ channel, data: message });
|
|
84
85
|
for (const sc of this.connections) {
|
|
85
86
|
if (sc.channels[channel]) {
|
|
87
|
+
this.debugMessageFileSaver(sc.connectionId, channel, message);
|
|
86
88
|
sc.write(data);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
@@ -29,12 +29,17 @@ export function findOptionsToJson(options, meta) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
export function findOptionsFromJson(json, meta) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
let r = {};
|
|
33
|
+
for (const key of ["limit", "page", "where", "orderBy"]) {
|
|
34
|
+
if (json[key] !== undefined) {
|
|
35
|
+
if (key === "where") {
|
|
36
|
+
r[key] = Filter.entityFilterFromJson(meta, json.where);
|
|
37
|
+
}
|
|
38
|
+
else
|
|
39
|
+
r[key] = json[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return r;
|
|
38
43
|
}
|
|
39
44
|
export class RestEntityDataProvider {
|
|
40
45
|
constructor(url, http, entity) {
|
|
@@ -70,9 +70,9 @@ export class LiveQueryPublisher {
|
|
|
70
70
|
runPromise(p) {
|
|
71
71
|
}
|
|
72
72
|
itemChanged(entityKey, changes) {
|
|
73
|
-
const messages = [];
|
|
74
73
|
this.runPromise(this.storage.provideListeners(entityKey, async ({ query, setLastIds }) => {
|
|
75
74
|
await this.performWithRequest(query.requestJson, entityKey, async (repo) => {
|
|
75
|
+
const messages = [];
|
|
76
76
|
const currentItems = await repo.find(findOptionsFromJson(query.findOptionsJson, repo.metadata));
|
|
77
77
|
const currentIds = currentItems.map(x => repo.getEntityRef(x).getId());
|
|
78
78
|
for (const id of query.lastIds.filter(y => !currentIds.includes(y))) {
|
package/package.json
CHANGED
package/remult-express.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class ServerEventsController implements ServerEventDispatcher {
|
|
|
14
14
|
connections: clientConnection[];
|
|
15
15
|
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
16
16
|
sendChannelMessage<T>(channel: string, message: any): void;
|
|
17
|
+
debugMessageFileSaver: (id: any, channel: any, message: any) => void;
|
|
17
18
|
openHttpServerStream(req: import('express').Request, res: import('express').Response): clientConnection;
|
|
18
19
|
debug(): void;
|
|
19
20
|
debugFileSaver: (x: any) => void;
|
package/remult-express.js
CHANGED
|
@@ -126,6 +126,7 @@ var ServerEventsController = /** @class */ (function () {
|
|
|
126
126
|
function ServerEventsController(canUserConnectToChannel) {
|
|
127
127
|
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
128
128
|
this.connections = [];
|
|
129
|
+
this.debugMessageFileSaver = function (id, channel, message) { };
|
|
129
130
|
this.debugFileSaver = function () { };
|
|
130
131
|
if (!this.canUserConnectToChannel) {
|
|
131
132
|
this.canUserConnectToChannel = function () { return true; };
|
|
@@ -172,6 +173,7 @@ var ServerEventsController = /** @class */ (function () {
|
|
|
172
173
|
for (var _b = tslib_1.__values(this.connections), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
173
174
|
var sc = _c.value;
|
|
174
175
|
if (sc.channels[channel]) {
|
|
176
|
+
this.debugMessageFileSaver(sc.connectionId, channel, message);
|
|
175
177
|
sc.write(data);
|
|
176
178
|
}
|
|
177
179
|
}
|
|
@@ -42,12 +42,28 @@ function findOptionsToJson(options, meta) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.findOptionsToJson = findOptionsToJson;
|
|
44
44
|
function findOptionsFromJson(json, meta) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
var e_1, _a;
|
|
46
|
+
var r = {};
|
|
47
|
+
try {
|
|
48
|
+
for (var _b = tslib_1.__values(["limit", "page", "where", "orderBy"]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
49
|
+
var key = _c.value;
|
|
50
|
+
if (json[key] !== undefined) {
|
|
51
|
+
if (key === "where") {
|
|
52
|
+
r[key] = filter_interfaces_1.Filter.entityFilterFromJson(meta, json.where);
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
r[key] = json[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
63
|
+
}
|
|
64
|
+
finally { if (e_1) throw e_1.error; }
|
|
65
|
+
}
|
|
66
|
+
return r;
|
|
51
67
|
}
|
|
52
68
|
exports.findOptionsFromJson = findOptionsFromJson;
|
|
53
69
|
var RestEntityDataProvider = /** @class */ (function () {
|
|
@@ -57,7 +73,7 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
57
73
|
this.entity = entity;
|
|
58
74
|
}
|
|
59
75
|
RestEntityDataProvider.prototype.translateFromJson = function (row) {
|
|
60
|
-
var
|
|
76
|
+
var e_2, _a;
|
|
61
77
|
var result = {};
|
|
62
78
|
try {
|
|
63
79
|
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -65,17 +81,17 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
65
81
|
result[col.key] = col.valueConverter.fromJson(row[col.key]);
|
|
66
82
|
}
|
|
67
83
|
}
|
|
68
|
-
catch (
|
|
84
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
69
85
|
finally {
|
|
70
86
|
try {
|
|
71
87
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
72
88
|
}
|
|
73
|
-
finally { if (
|
|
89
|
+
finally { if (e_2) throw e_2.error; }
|
|
74
90
|
}
|
|
75
91
|
return result;
|
|
76
92
|
};
|
|
77
93
|
RestEntityDataProvider.prototype.translateToJson = function (row) {
|
|
78
|
-
var
|
|
94
|
+
var e_3, _a;
|
|
79
95
|
var result = {};
|
|
80
96
|
try {
|
|
81
97
|
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -83,12 +99,12 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
83
99
|
result[col.key] = col.valueConverter.toJson(row[col.key]);
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
|
-
catch (
|
|
102
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
87
103
|
finally {
|
|
88
104
|
try {
|
|
89
105
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
90
106
|
}
|
|
91
|
-
finally { if (
|
|
107
|
+
finally { if (e_3) throw e_3.error; }
|
|
92
108
|
}
|
|
93
109
|
return result;
|
|
94
110
|
};
|
|
@@ -153,7 +169,7 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
153
169
|
return { filterObject: filterObject, url: url };
|
|
154
170
|
};
|
|
155
171
|
RestEntityDataProvider.prototype.update = function (id, data) {
|
|
156
|
-
var
|
|
172
|
+
var e_4, _a;
|
|
157
173
|
var _this = this;
|
|
158
174
|
var result = {};
|
|
159
175
|
var keys = Object.keys(data);
|
|
@@ -164,12 +180,12 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
164
180
|
result[col.key] = col.valueConverter.toJson(data[col.key]);
|
|
165
181
|
}
|
|
166
182
|
}
|
|
167
|
-
catch (
|
|
183
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
168
184
|
finally {
|
|
169
185
|
try {
|
|
170
186
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
171
187
|
}
|
|
172
|
-
finally { if (
|
|
188
|
+
finally { if (e_4) throw e_4.error; }
|
|
173
189
|
}
|
|
174
190
|
return this.http().put(this.url() + '/' + encodeURIComponent(id), result).then(function (y) { return _this.translateFromJson(y); });
|
|
175
191
|
};
|
|
@@ -228,7 +244,7 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
228
244
|
});
|
|
229
245
|
};
|
|
230
246
|
RestDataProviderHttpProviderUsingFetch.prototype.myFetch = function (url, options) {
|
|
231
|
-
var
|
|
247
|
+
var e_5, _a;
|
|
232
248
|
var _this = this;
|
|
233
249
|
var headers = {
|
|
234
250
|
"Content-type": "application/json"
|
|
@@ -242,12 +258,12 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
242
258
|
}
|
|
243
259
|
}
|
|
244
260
|
}
|
|
245
|
-
catch (
|
|
261
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
246
262
|
finally {
|
|
247
263
|
try {
|
|
248
264
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
249
265
|
}
|
|
250
|
-
finally { if (
|
|
266
|
+
finally { if (e_5) throw e_5.error; }
|
|
251
267
|
}
|
|
252
268
|
return (this.fetch || fetch)(url, {
|
|
253
269
|
credentials: 'include',
|
|
@@ -146,7 +146,6 @@ var LiveQueryPublisher = /** @class */ (function () {
|
|
|
146
146
|
};
|
|
147
147
|
LiveQueryPublisher.prototype.itemChanged = function (entityKey, changes) {
|
|
148
148
|
var _this = this;
|
|
149
|
-
var messages = [];
|
|
150
149
|
this.runPromise(this.storage.provideListeners(entityKey, function (_a) {
|
|
151
150
|
var query = _a.query, setLastIds = _a.setLastIds;
|
|
152
151
|
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -154,11 +153,13 @@ var LiveQueryPublisher = /** @class */ (function () {
|
|
|
154
153
|
return tslib_1.__generator(this, function (_b) {
|
|
155
154
|
switch (_b.label) {
|
|
156
155
|
case 0: return [4 /*yield*/, this.performWithRequest(query.requestJson, entityKey, function (repo) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
157
|
-
var currentItems, currentIds, _loop_3, _a, _b, id, _loop_4, currentItems_1, currentItems_1_1, item;
|
|
156
|
+
var messages, currentItems, currentIds, _loop_3, _a, _b, id, _loop_4, currentItems_1, currentItems_1_1, item;
|
|
158
157
|
var e_3, _c, e_4, _d;
|
|
159
158
|
return tslib_1.__generator(this, function (_e) {
|
|
160
159
|
switch (_e.label) {
|
|
161
|
-
case 0:
|
|
160
|
+
case 0:
|
|
161
|
+
messages = [];
|
|
162
|
+
return [4 /*yield*/, repo.find(rest_data_provider_1.findOptionsFromJson(query.findOptionsJson, repo.metadata))];
|
|
162
163
|
case 1:
|
|
163
164
|
currentItems = _e.sent();
|
|
164
165
|
currentIds = currentItems.map(function (x) { return repo.getEntityRef(x).getId(); });
|