remult 0.18.1-exp.26 → 0.18.1-exp.28
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/SseSubscriptionServer.js +2 -1
- package/esm/SseSubscriptionServer.js +2 -1
- package/esm/myLog.d.ts +1 -0
- package/esm/myLog.js +5 -0
- package/esm/server/expressBridge.js +3 -3
- package/esm/src/context.js +6 -3
- package/esm/src/data-providers/rest-data-provider.d.ts +1 -1
- package/esm/src/data-providers/rest-data-provider.js +1 -1
- package/esm/src/live-query/SseSubscriptionClient.d.ts +1 -0
- package/esm/src/live-query/SseSubscriptionClient.js +12 -5
- package/myLog.d.ts +1 -0
- package/myLog.js +20 -0
- package/package.json +1 -1
- package/server/expressBridge.js +13 -13
- package/src/context.js +23 -17
- package/src/data-providers/rest-data-provider.d.ts +1 -1
- package/src/data-providers/rest-data-provider.js +1 -1
- package/src/live-query/SseSubscriptionClient.d.ts +1 -0
- package/src/live-query/SseSubscriptionClient.js +22 -7
package/SseSubscriptionServer.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.clientConnection = exports.SseSubscriptionServer = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var uuid_1 = require("uuid");
|
|
6
|
+
var SseSubscriptionClient_1 = require("./src/live-query/SseSubscriptionClient");
|
|
6
7
|
var SseSubscriptionServer = /** @class */ (function () {
|
|
7
8
|
function SseSubscriptionServer(canUserConnectToChannel) {
|
|
8
9
|
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
@@ -49,7 +50,7 @@ var SseSubscriptionServer = /** @class */ (function () {
|
|
|
49
50
|
}
|
|
50
51
|
finally { if (e_1) throw e_1.error; }
|
|
51
52
|
}
|
|
52
|
-
res.
|
|
53
|
+
res.success(SseSubscriptionClient_1.ConnectionNotFoundError);
|
|
53
54
|
};
|
|
54
55
|
SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
55
56
|
var e_2, _a;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v4 as uuid } from 'uuid';
|
|
2
|
+
import { ConnectionNotFoundError } from './src/live-query/SseSubscriptionClient';
|
|
2
3
|
export class SseSubscriptionServer {
|
|
3
4
|
constructor(canUserConnectToChannel) {
|
|
4
5
|
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
@@ -32,7 +33,7 @@ export class SseSubscriptionServer {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
res.
|
|
36
|
+
res.success(ConnectionNotFoundError);
|
|
36
37
|
}
|
|
37
38
|
publishMessage(channel, message) {
|
|
38
39
|
const data = JSON.stringify({ channel, data: message });
|
package/esm/myLog.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeToLog(what: any): Promise<void>;
|
package/esm/myLog.js
ADDED
|
@@ -194,10 +194,10 @@ export class RemultServerImplementation {
|
|
|
194
194
|
r.route(streamPath + '/unsubscribe').post(this.process(async (remult, req, res, origReq, origRes) => {
|
|
195
195
|
remult.subscriptionServer.subscribeToChannel(origReq.body, res, remult, true);
|
|
196
196
|
}));
|
|
197
|
-
r.route(this.options.rootPath + '/' + liveQueryKeepAliveRoute).post(this.process(async (remult, req, res, origReq, origRes) => {
|
|
198
|
-
res.success(await remult.liveQueryStorage.keepAliveAndReturnUnknownQueryIds(origReq.body));
|
|
199
|
-
}));
|
|
200
197
|
}
|
|
198
|
+
r.route(this.options.rootPath + '/' + liveQueryKeepAliveRoute).post(this.process(async (remult, req, res, origReq, origRes) => {
|
|
199
|
+
res.success(await remult.liveQueryStorage.keepAliveAndReturnUnknownQueryIds(origReq.body));
|
|
200
|
+
}));
|
|
201
201
|
}
|
|
202
202
|
this.options.entities.forEach(e => {
|
|
203
203
|
let key = getEntityKey(e);
|
package/esm/src/context.js
CHANGED
|
@@ -196,13 +196,16 @@ export class EventSource {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
export async function doTransaction(remult, what) {
|
|
199
|
-
|
|
199
|
+
const trans = new transactionLiveQueryPublisher(remult.liveQueryPublisher);
|
|
200
|
+
let ok = true;
|
|
201
|
+
const result = await remult.dataProvider.transaction(async (ds) => {
|
|
200
202
|
remult.dataProvider = (ds);
|
|
201
|
-
const trans = new transactionLiveQueryPublisher(remult.liveQueryPublisher);
|
|
202
203
|
remult.liveQueryPublisher = trans;
|
|
203
204
|
await what();
|
|
204
|
-
|
|
205
|
+
ok = true;
|
|
205
206
|
});
|
|
207
|
+
if (ok)
|
|
208
|
+
trans.flush();
|
|
206
209
|
}
|
|
207
210
|
class transactionLiveQueryPublisher {
|
|
208
211
|
constructor(orig) {
|
|
@@ -36,4 +36,4 @@ export declare class RestDataProviderHttpProviderUsingFetch implements RestDataP
|
|
|
36
36
|
}): Promise<any>;
|
|
37
37
|
}
|
|
38
38
|
export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
|
|
39
|
-
export declare const liveQueryAction = "liveQuery
|
|
39
|
+
export declare const liveQueryAction = "liveQuery-";
|
|
@@ -2,3 +2,4 @@ import { SubscriptionClient, SubscriptionClientConnection } from "./Subscription
|
|
|
2
2
|
export declare class SseSubscriptionClient implements SubscriptionClient {
|
|
3
3
|
openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
|
|
4
4
|
}
|
|
5
|
+
export declare const ConnectionNotFoundError = "client connection not found";
|
|
@@ -32,7 +32,7 @@ export class SseSubscriptionClient {
|
|
|
32
32
|
};
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
const createConnectionPromise = () => new Promise((res) => {
|
|
36
36
|
createConnection();
|
|
37
37
|
function createConnection() {
|
|
38
38
|
if (source)
|
|
@@ -69,11 +69,18 @@ export class SseSubscriptionClient {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
+
return createConnectionPromise();
|
|
72
73
|
async function subscribeToChannel(channel) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const result = await actionInfo.runActionWithoutBlockingUI(() => {
|
|
75
|
+
return provider.post(remult.apiClient.url + '/' + streamUrl + '/subscribe', {
|
|
76
|
+
channel: channel,
|
|
77
|
+
clientId: connectionId
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
if (result === ConnectionNotFoundError) {
|
|
81
|
+
await createConnectionPromise();
|
|
82
|
+
}
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
}
|
|
86
|
+
export const ConnectionNotFoundError = "client connection not found";
|
package/myLog.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeToLog(what: any): Promise<void>;
|
package/myLog.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeToLog = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
function writeToLog(what) {
|
|
6
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
7
|
+
return tslib_1.__generator(this, function (_a) {
|
|
8
|
+
switch (_a.label) {
|
|
9
|
+
case 0:
|
|
10
|
+
if (typeof what !== "string")
|
|
11
|
+
what = JSON.stringify(what, undefined, 2);
|
|
12
|
+
return [4 /*yield*/, (Promise.resolve().then(function () { return tslib_1.__importStar(require('fs')); }))];
|
|
13
|
+
case 1:
|
|
14
|
+
(_a.sent()).appendFileSync('./tmp/test.log', what + '\n');
|
|
15
|
+
return [2 /*return*/];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.writeToLog = writeToLog;
|
package/package.json
CHANGED
package/server/expressBridge.js
CHANGED
|
@@ -323,20 +323,20 @@ var RemultServerImplementation = /** @class */ (function () {
|
|
|
323
323
|
return [2 /*return*/];
|
|
324
324
|
});
|
|
325
325
|
}); }));
|
|
326
|
-
r.route(this.options.rootPath + '/' + SubscriptionChannel_1.liveQueryKeepAliveRoute).post(this.process(function (remult, req, res, origReq, origRes) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
327
|
-
var _a, _b;
|
|
328
|
-
return tslib_1.__generator(this, function (_c) {
|
|
329
|
-
switch (_c.label) {
|
|
330
|
-
case 0:
|
|
331
|
-
_b = (_a = res).success;
|
|
332
|
-
return [4 /*yield*/, remult.liveQueryStorage.keepAliveAndReturnUnknownQueryIds(origReq.body)];
|
|
333
|
-
case 1:
|
|
334
|
-
_b.apply(_a, [_c.sent()]);
|
|
335
|
-
return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}); }));
|
|
339
326
|
}
|
|
327
|
+
r.route(this.options.rootPath + '/' + SubscriptionChannel_1.liveQueryKeepAliveRoute).post(this.process(function (remult, req, res, origReq, origRes) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
328
|
+
var _a, _b;
|
|
329
|
+
return tslib_1.__generator(this, function (_c) {
|
|
330
|
+
switch (_c.label) {
|
|
331
|
+
case 0:
|
|
332
|
+
_b = (_a = res).success;
|
|
333
|
+
return [4 /*yield*/, remult.liveQueryStorage.keepAliveAndReturnUnknownQueryIds(origReq.body)];
|
|
334
|
+
case 1:
|
|
335
|
+
_b.apply(_a, [_c.sent()]);
|
|
336
|
+
return [2 /*return*/];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}); }));
|
|
340
340
|
}
|
|
341
341
|
this.options.entities.forEach(function (e) {
|
|
342
342
|
var key = remult3_1.getEntityKey(e);
|
package/src/context.js
CHANGED
|
@@ -286,26 +286,32 @@ var EventSource = /** @class */ (function () {
|
|
|
286
286
|
exports.EventSource = EventSource;
|
|
287
287
|
function doTransaction(remult, what) {
|
|
288
288
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
289
|
+
var trans, ok, result;
|
|
289
290
|
var _this = this;
|
|
290
291
|
return tslib_1.__generator(this, function (_a) {
|
|
291
292
|
switch (_a.label) {
|
|
292
|
-
case 0:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
293
|
+
case 0:
|
|
294
|
+
trans = new transactionLiveQueryPublisher(remult.liveQueryPublisher);
|
|
295
|
+
ok = true;
|
|
296
|
+
return [4 /*yield*/, remult.dataProvider.transaction(function (ds) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
297
|
+
return tslib_1.__generator(this, function (_a) {
|
|
298
|
+
switch (_a.label) {
|
|
299
|
+
case 0:
|
|
300
|
+
remult.dataProvider = (ds);
|
|
301
|
+
remult.liveQueryPublisher = trans;
|
|
302
|
+
return [4 /*yield*/, what()];
|
|
303
|
+
case 1:
|
|
304
|
+
_a.sent();
|
|
305
|
+
ok = true;
|
|
306
|
+
return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}); })];
|
|
310
|
+
case 1:
|
|
311
|
+
result = _a.sent();
|
|
312
|
+
if (ok)
|
|
313
|
+
trans.flush();
|
|
314
|
+
return [2 /*return*/];
|
|
309
315
|
}
|
|
310
316
|
});
|
|
311
317
|
});
|
|
@@ -36,4 +36,4 @@ export declare class RestDataProviderHttpProviderUsingFetch implements RestDataP
|
|
|
36
36
|
}): Promise<any>;
|
|
37
37
|
}
|
|
38
38
|
export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
|
|
39
|
-
export declare const liveQueryAction = "liveQuery
|
|
39
|
+
export declare const liveQueryAction = "liveQuery-";
|
|
@@ -364,4 +364,4 @@ function addFilterToUrlAndReturnTrueIfSuccessful(filter, url) {
|
|
|
364
364
|
return true;
|
|
365
365
|
}
|
|
366
366
|
exports.addFilterToUrlAndReturnTrueIfSuccessful = addFilterToUrlAndReturnTrueIfSuccessful;
|
|
367
|
-
exports.liveQueryAction = "liveQuery
|
|
367
|
+
exports.liveQueryAction = "liveQuery-";
|
|
@@ -2,3 +2,4 @@ import { SubscriptionClient, SubscriptionClientConnection } from "./Subscription
|
|
|
2
2
|
export declare class SseSubscriptionClient implements SubscriptionClient {
|
|
3
3
|
openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
|
|
4
4
|
}
|
|
5
|
+
export declare const ConnectionNotFoundError = "client connection not found";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SseSubscriptionClient = void 0;
|
|
3
|
+
exports.ConnectionNotFoundError = exports.SseSubscriptionClient = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var buildRestDataProvider_1 = require("../buildRestDataProvider");
|
|
6
6
|
var remult_proxy_1 = require("../remult-proxy");
|
|
@@ -49,7 +49,7 @@ var SseSubscriptionClient = /** @class */ (function () {
|
|
|
49
49
|
});
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
|
-
return new Promise(function (res) {
|
|
52
|
+
var createConnectionPromise = function () { return new Promise(function (res) {
|
|
53
53
|
createConnection();
|
|
54
54
|
function createConnection() {
|
|
55
55
|
var _this = this;
|
|
@@ -118,14 +118,28 @@ var SseSubscriptionClient = /** @class */ (function () {
|
|
|
118
118
|
});
|
|
119
119
|
}); });
|
|
120
120
|
}
|
|
121
|
-
});
|
|
121
|
+
}); };
|
|
122
|
+
return createConnectionPromise();
|
|
122
123
|
function subscribeToChannel(channel) {
|
|
123
124
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var result;
|
|
124
126
|
return tslib_1.__generator(this, function (_a) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0: return [4 /*yield*/, server_action_1.actionInfo.runActionWithoutBlockingUI(function () {
|
|
129
|
+
return provider.post(remult_proxy_1.remult.apiClient.url + '/' + SubscriptionChannel_1.streamUrl + '/subscribe', {
|
|
130
|
+
channel: channel,
|
|
131
|
+
clientId: connectionId
|
|
132
|
+
});
|
|
133
|
+
})];
|
|
134
|
+
case 1:
|
|
135
|
+
result = _a.sent();
|
|
136
|
+
if (!(result === exports.ConnectionNotFoundError)) return [3 /*break*/, 3];
|
|
137
|
+
return [4 /*yield*/, createConnectionPromise()];
|
|
138
|
+
case 2:
|
|
139
|
+
_a.sent();
|
|
140
|
+
_a.label = 3;
|
|
141
|
+
case 3: return [2 /*return*/];
|
|
142
|
+
}
|
|
129
143
|
});
|
|
130
144
|
});
|
|
131
145
|
}
|
|
@@ -133,3 +147,4 @@ var SseSubscriptionClient = /** @class */ (function () {
|
|
|
133
147
|
return SseSubscriptionClient;
|
|
134
148
|
}());
|
|
135
149
|
exports.SseSubscriptionClient = SseSubscriptionClient;
|
|
150
|
+
exports.ConnectionNotFoundError = "client connection not found";
|