remult 0.22.7-exp.0 → 0.22.7
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.d.ts +25 -25
- package/SseSubscriptionServer.js +145 -145
- package/ably.d.ts +13 -13
- package/ably.js +59 -59
- package/assign.d.ts +1 -1
- package/assign.js +9 -9
- package/classType.d.ts +3 -3
- package/classType.js +2 -2
- package/esm/SseSubscriptionServer.d.ts +25 -25
- package/esm/SseSubscriptionServer.js +107 -104
- package/esm/ably.d.ts +13 -13
- package/esm/ably.js +30 -28
- package/esm/assign.d.ts +1 -1
- package/esm/assign.js +5 -5
- package/esm/classType.d.ts +3 -3
- package/esm/classType.js +1 -1
- package/esm/graphql.d.ts +14 -14
- package/esm/graphql.js +785 -785
- package/esm/index.d.ts +31 -31
- package/esm/index.js +25 -25
- package/esm/inputTypes.d.ts +9 -9
- package/esm/inputTypes.js +9 -9
- package/esm/live-query/data-provider-live-query-storage.d.ts +23 -23
- package/esm/live-query/data-provider-live-query-storage.js +91 -93
- package/esm/myLog.d.ts +1 -1
- package/esm/myLog.js +5 -5
- package/esm/postgres/index.d.ts +2 -2
- package/esm/postgres/index.js +2 -2
- package/esm/postgres/postgres-data-provider.d.ts +36 -36
- package/esm/postgres/postgres-data-provider.js +126 -122
- package/esm/postgres/schema-builder.d.ts +19 -19
- package/esm/postgres/schema-builder.js +197 -196
- package/esm/remult-express.d.ts +9 -9
- package/esm/remult-express.js +26 -25
- package/esm/remult-fastify.d.ts +6 -6
- package/esm/remult-fastify.js +68 -68
- package/esm/remult-fresh.d.ts +17 -17
- package/esm/remult-fresh.js +26 -26
- package/esm/remult-knex/index.d.ts +30 -30
- package/esm/remult-knex/index.js +466 -460
- package/esm/remult-mongo.d.ts +24 -24
- package/esm/remult-mongo.js +269 -262
- package/esm/remult-next.d.ts +25 -25
- package/esm/remult-next.js +114 -114
- package/esm/remult-sveltekit.d.ts +4 -4
- package/esm/remult-sveltekit.js +71 -71
- package/esm/server/JsonEntityFileStorage.d.ts +11 -11
- package/esm/server/JsonEntityFileStorage.js +27 -26
- package/esm/server/core.d.ts +4 -4
- package/esm/server/core.js +4 -4
- package/esm/server/expressBridge.d.ts +128 -128
- package/esm/server/expressBridge.js +988 -971
- package/esm/server/index.d.ts +6 -6
- package/esm/server/index.js +12 -12
- package/esm/server/initAsyncHooks.d.ts +1 -1
- package/esm/server/initAsyncHooks.js +9 -9
- package/esm/server/initDataProvider.d.ts +2 -2
- package/esm/server/initDataProvider.js +14 -14
- package/esm/src/CompoundIdField.d.ts +27 -27
- package/esm/src/CompoundIdField.js +54 -41
- package/esm/src/__EntityValueProvider.d.ts +11 -11
- package/esm/src/__EntityValueProvider.js +1 -1
- package/esm/src/__RowsOfDataForTesting.d.ts +3 -3
- package/esm/src/__RowsOfDataForTesting.js +1 -1
- package/esm/src/buildRestDataProvider.d.ts +31 -31
- package/esm/src/buildRestDataProvider.js +121 -120
- package/esm/src/column-interfaces.d.ts +160 -160
- package/esm/src/column-interfaces.js +7 -7
- package/esm/src/column.d.ts +31 -31
- package/esm/src/column.js +108 -101
- package/esm/src/context.d.ts +134 -134
- package/esm/src/context.js +287 -282
- package/esm/src/data-api.d.ts +38 -38
- package/esm/src/data-api.js +281 -279
- package/esm/src/data-interfaces.d.ts +41 -41
- package/esm/src/data-interfaces.js +12 -12
- package/esm/src/data-providers/array-entity-data-provider.d.ts +22 -22
- package/esm/src/data-providers/array-entity-data-provider.js +252 -249
- package/esm/src/data-providers/in-memory-database.d.ts +9 -9
- package/esm/src/data-providers/in-memory-database.js +16 -18
- package/esm/src/data-providers/json-data-provider.d.ts +12 -12
- package/esm/src/data-providers/json-data-provider.js +55 -52
- package/esm/src/data-providers/rest-data-provider.d.ts +39 -39
- package/esm/src/data-providers/rest-data-provider.js +272 -267
- package/esm/src/data-providers/sql-database.d.ts +33 -33
- package/esm/src/data-providers/sql-database.js +401 -394
- package/esm/src/data-providers/web-sql-data-provider.d.ts +21 -21
- package/esm/src/data-providers/web-sql-data-provider.js +145 -137
- package/esm/src/entity.d.ts +95 -95
- package/esm/src/entity.js +1 -1
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +165 -162
- package/esm/src/filter/filter-interfaces.d.ts +86 -86
- package/esm/src/filter/filter-interfaces.js +524 -515
- package/esm/src/live-query/LiveQueryClient.d.ts +1 -1
- package/esm/src/live-query/LiveQueryClient.js +196 -192
- package/esm/src/live-query/SseSubscriptionClient.d.ts +5 -5
- package/esm/src/live-query/SseSubscriptionClient.js +86 -86
- package/esm/src/live-query/SubscriptionChannel.d.ts +41 -41
- package/esm/src/live-query/SubscriptionChannel.js +126 -121
- package/esm/src/live-query/SubscriptionServer.d.ts +38 -38
- package/esm/src/live-query/SubscriptionServer.js +114 -112
- package/esm/src/remult-proxy.d.ts +2 -2
- package/esm/src/remult-proxy.js +177 -178
- package/esm/src/remult3/DecoratorReplacer.d.ts +10 -10
- package/esm/src/remult3/DecoratorReplacer.js +20 -20
- package/esm/src/remult3/RepositoryImplementation.d.ts +332 -332
- package/esm/src/remult3/RepositoryImplementation.js +2122 -2051
- package/esm/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -2
- package/esm/src/remult3/__updateEntityBasedOnWhere.js +24 -24
- package/esm/src/remult3/entity.d.ts +28 -28
- package/esm/src/remult3/entity.js +70 -70
- package/esm/src/remult3/getEntityRef.d.ts +9 -9
- package/esm/src/remult3/getEntityRef.js +27 -27
- package/esm/src/remult3/remult3.d.ts +397 -397
- package/esm/src/remult3/remult3.js +1 -1
- package/esm/src/resultCompoundIdFilter.d.ts +3 -3
- package/esm/src/resultCompoundIdFilter.js +16 -16
- package/esm/src/server-action-info.d.ts +10 -10
- package/esm/src/server-action-info.js +12 -12
- package/esm/src/server-action.d.ts +79 -79
- package/esm/src/server-action.js +397 -387
- package/esm/src/sort.d.ts +16 -16
- package/esm/src/sort.js +105 -104
- package/esm/src/sql-command.d.ts +19 -19
- package/esm/src/sql-command.js +1 -1
- package/esm/src/validators.d.ts +14 -14
- package/esm/src/validators.js +36 -36
- package/esm/src/valueConverters.d.ts +13 -13
- package/esm/src/valueConverters.js +210 -210
- package/esm/urlBuilder.d.ts +6 -6
- package/esm/urlBuilder.js +20 -19
- package/graphql.d.ts +14 -14
- package/graphql.js +953 -953
- package/index.d.ts +31 -31
- package/index.js +67 -67
- package/inputTypes.d.ts +9 -9
- package/inputTypes.js +16 -16
- package/live-query/data-provider-live-query-storage.d.ts +23 -23
- package/live-query/data-provider-live-query-storage.js +263 -263
- package/myLog.d.ts +1 -1
- package/myLog.js +20 -20
- package/package.json +1 -1
- package/postgres/index.d.ts +2 -2
- package/postgres/index.js +5 -5
- package/postgres/postgres-data-provider.d.ts +36 -36
- package/postgres/postgres-data-provider.js +191 -191
- package/postgres/schema-builder.d.ts +19 -19
- package/postgres/schema-builder.js +369 -369
- package/remult-express.d.ts +9 -9
- package/remult-express.js +34 -33
- package/remult-fastify.d.ts +6 -6
- package/remult-fastify.js +79 -79
- package/remult-fresh.d.ts +17 -17
- package/remult-fresh.js +41 -41
- package/remult-knex/index.d.ts +30 -30
- package/remult-knex/index.js +917 -915
- package/remult-mongo.d.ts +24 -24
- package/remult-mongo.js +515 -515
- package/remult-next.d.ts +25 -25
- package/remult-next.js +171 -171
- package/remult-sveltekit.d.ts +4 -4
- package/remult-sveltekit.js +110 -110
- package/server/JsonEntityFileStorage.d.ts +11 -11
- package/server/JsonEntityFileStorage.js +35 -35
- package/server/core.d.ts +4 -4
- package/server/core.js +12 -12
- package/server/expressBridge.d.ts +128 -128
- package/server/expressBridge.js +1401 -1402
- package/server/index.d.ts +6 -6
- package/server/index.js +24 -24
- package/server/initAsyncHooks.d.ts +1 -1
- package/server/initAsyncHooks.js +13 -13
- package/server/initDataProvider.d.ts +2 -2
- package/server/initDataProvider.js +26 -26
- package/src/CompoundIdField.d.ts +27 -27
- package/src/CompoundIdField.js +54 -54
- package/src/__EntityValueProvider.d.ts +11 -11
- package/src/__EntityValueProvider.js +2 -2
- package/src/__RowsOfDataForTesting.d.ts +3 -3
- package/src/__RowsOfDataForTesting.js +2 -2
- package/src/buildRestDataProvider.d.ts +31 -31
- package/src/buildRestDataProvider.js +177 -174
- package/src/column-interfaces.d.ts +160 -160
- package/src/column-interfaces.js +11 -11
- package/src/column.d.ts +31 -31
- package/src/column.js +132 -132
- package/src/context.d.ts +134 -134
- package/src/context.js +451 -451
- package/src/data-api.d.ts +38 -38
- package/src/data-api.js +524 -524
- package/src/data-interfaces.d.ts +41 -41
- package/src/data-interfaces.js +16 -16
- package/src/data-providers/array-entity-data-provider.d.ts +22 -22
- package/src/data-providers/array-entity-data-provider.js +364 -364
- package/src/data-providers/in-memory-database.d.ts +9 -9
- package/src/data-providers/in-memory-database.js +33 -33
- package/src/data-providers/json-data-provider.d.ts +12 -12
- package/src/data-providers/json-data-provider.js +106 -106
- package/src/data-providers/rest-data-provider.d.ts +39 -39
- package/src/data-providers/rest-data-provider.js +388 -388
- package/src/data-providers/sql-database.d.ts +33 -33
- package/src/data-providers/sql-database.js +653 -653
- package/src/data-providers/web-sql-data-provider.d.ts +21 -21
- package/src/data-providers/web-sql-data-provider.js +229 -229
- package/src/entity.d.ts +95 -95
- package/src/entity.js +2 -2
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
- package/src/filter/filter-consumer-bridge-to-sql-request.js +307 -307
- package/src/filter/filter-interfaces.d.ts +86 -86
- package/src/filter/filter-interfaces.js +693 -685
- package/src/live-query/LiveQueryClient.d.ts +1 -1
- package/src/live-query/LiveQueryClient.js +293 -293
- package/src/live-query/SseSubscriptionClient.d.ts +5 -5
- package/src/live-query/SseSubscriptionClient.js +154 -154
- package/src/live-query/SubscriptionChannel.d.ts +41 -41
- package/src/live-query/SubscriptionChannel.js +189 -189
- package/src/live-query/SubscriptionServer.d.ts +38 -38
- package/src/live-query/SubscriptionServer.js +264 -264
- package/src/remult-proxy.d.ts +2 -2
- package/src/remult-proxy.js +307 -307
- package/src/remult3/DecoratorReplacer.d.ts +10 -10
- package/src/remult3/DecoratorReplacer.js +24 -24
- package/src/remult3/RepositoryImplementation.d.ts +332 -332
- package/src/remult3/RepositoryImplementation.js +3391 -3373
- package/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -2
- package/src/remult3/__updateEntityBasedOnWhere.js +28 -28
- package/src/remult3/entity.d.ts +28 -28
- package/src/remult3/entity.js +88 -88
- package/src/remult3/getEntityRef.d.ts +9 -9
- package/src/remult3/getEntityRef.js +35 -35
- package/src/remult3/remult3.d.ts +397 -397
- package/src/remult3/remult3.js +2 -2
- package/src/resultCompoundIdFilter.d.ts +3 -3
- package/src/resultCompoundIdFilter.js +20 -20
- package/src/server-action-info.d.ts +10 -10
- package/src/server-action-info.js +15 -15
- package/src/server-action.d.ts +79 -79
- package/src/server-action.js +632 -632
- package/src/sort.d.ts +16 -16
- package/src/sort.js +161 -161
- package/src/sql-command.d.ts +19 -19
- package/src/sql-command.js +2 -2
- package/src/validators.d.ts +14 -14
- package/src/validators.js +71 -69
- package/src/valueConverters.d.ts +13 -13
- package/src/valueConverters.js +213 -213
- package/urlBuilder.d.ts +6 -6
- package/urlBuilder.js +25 -25
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { GenericResponse } from './server/index';
|
|
3
|
-
import type { Remult } from './src/context';
|
|
4
|
-
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
5
|
-
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
|
-
private canUserConnectToChannel?;
|
|
7
|
-
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
8
|
-
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export interface ResponseRequiredForSSE {
|
|
11
|
-
write(data: string): void;
|
|
12
|
-
writeHead(status: number, headers: any): void;
|
|
13
|
-
flush?(): void;
|
|
14
|
-
}
|
|
15
|
-
export declare class clientConnection {
|
|
16
|
-
response: GenericResponse & ResponseRequiredForSSE;
|
|
17
|
-
channels: Record<string, boolean>;
|
|
18
|
-
timeOutRef: NodeJS.Timeout;
|
|
19
|
-
close(): void;
|
|
20
|
-
closed: boolean;
|
|
21
|
-
write(eventData: string, eventType?: string): void;
|
|
22
|
-
connectionId: any;
|
|
23
|
-
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
24
|
-
sendLiveMessage(): void;
|
|
25
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { GenericResponse } from './server/index';
|
|
3
|
+
import type { Remult } from './src/context';
|
|
4
|
+
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
5
|
+
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
|
+
private canUserConnectToChannel?;
|
|
7
|
+
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
8
|
+
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ResponseRequiredForSSE {
|
|
11
|
+
write(data: string): void;
|
|
12
|
+
writeHead(status: number, headers: any): void;
|
|
13
|
+
flush?(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class clientConnection {
|
|
16
|
+
response: GenericResponse & ResponseRequiredForSSE;
|
|
17
|
+
channels: Record<string, boolean>;
|
|
18
|
+
timeOutRef: NodeJS.Timeout;
|
|
19
|
+
close(): void;
|
|
20
|
+
closed: boolean;
|
|
21
|
+
write(eventData: string, eventType?: string): void;
|
|
22
|
+
connectionId: any;
|
|
23
|
+
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
24
|
+
sendLiveMessage(): void;
|
|
25
|
+
}
|
package/SseSubscriptionServer.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clientConnection = exports.SseSubscriptionServer = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var uuid_1 = require("uuid");
|
|
6
|
-
var SseSubscriptionClient_1 = require("./src/live-query/SseSubscriptionClient");
|
|
7
|
-
var SseSubscriptionServer = /** @class */ (function () {
|
|
8
|
-
function SseSubscriptionServer(canUserConnectToChannel) {
|
|
9
|
-
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
10
|
-
//@internal
|
|
11
|
-
this.connections = [];
|
|
12
|
-
//@internal
|
|
13
|
-
this.debugMessageFileSaver = function (id, channel, message) { };
|
|
14
|
-
//@internal
|
|
15
|
-
this.debugFileSaver = function () { };
|
|
16
|
-
if (!this.canUserConnectToChannel) {
|
|
17
|
-
this.canUserConnectToChannel = function () { return true; };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//@internal
|
|
21
|
-
SseSubscriptionServer.prototype.subscribeToChannel = function (_a, res, remult, remove) {
|
|
22
|
-
var e_1, _b;
|
|
23
|
-
var channel = _a.channel, clientId = _a.clientId;
|
|
24
|
-
if (remove === void 0) { remove = false; }
|
|
25
|
-
try {
|
|
26
|
-
for (var _c = tslib_1.__values(this.connections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
27
|
-
var c = _d.value;
|
|
28
|
-
if (c.connectionId === clientId) {
|
|
29
|
-
if (this.canUserConnectToChannel(channel, remult)) {
|
|
30
|
-
if (remove)
|
|
31
|
-
delete c.channels[channel];
|
|
32
|
-
else
|
|
33
|
-
c.channels[channel] = true;
|
|
34
|
-
res.success({ status: 'ok' });
|
|
35
|
-
this.debug();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
res.forbidden();
|
|
40
|
-
this.debug();
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
47
|
-
finally {
|
|
48
|
-
try {
|
|
49
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
50
|
-
}
|
|
51
|
-
finally { if (e_1) throw e_1.error; }
|
|
52
|
-
}
|
|
53
|
-
res.success(SseSubscriptionClient_1.ConnectionNotFoundError);
|
|
54
|
-
};
|
|
55
|
-
SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
56
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var data, _a, _b, sc;
|
|
58
|
-
var e_2, _c;
|
|
59
|
-
return tslib_1.__generator(this, function (_d) {
|
|
60
|
-
data = JSON.stringify({ channel: channel, data: message });
|
|
61
|
-
try {
|
|
62
|
-
for (_a = tslib_1.__values(this.connections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
63
|
-
sc = _b.value;
|
|
64
|
-
if (sc.channels[channel]) {
|
|
65
|
-
this.debugMessageFileSaver(sc.connectionId, channel, message);
|
|
66
|
-
sc.write(data);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
71
|
-
finally {
|
|
72
|
-
try {
|
|
73
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
74
|
-
}
|
|
75
|
-
finally { if (e_2) throw e_2.error; }
|
|
76
|
-
}
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
//@internal
|
|
82
|
-
SseSubscriptionServer.prototype.openHttpServerStream = function (req, res) {
|
|
83
|
-
var _this = this;
|
|
84
|
-
res.writeHead(200, {
|
|
85
|
-
'Content-Type': 'text/event-stream',
|
|
86
|
-
'Cache-Control': 'no-cache',
|
|
87
|
-
Connection: 'keep-alive',
|
|
88
|
-
});
|
|
89
|
-
var cc = new clientConnection(res);
|
|
90
|
-
//const lastEventId = req.headers['last-event-id'];
|
|
91
|
-
this.connections.push(cc);
|
|
92
|
-
this.debug();
|
|
93
|
-
//@ts-ignore
|
|
94
|
-
req.on('close', function () {
|
|
95
|
-
cc.close();
|
|
96
|
-
_this.connections = _this.connections.filter(function (s) { return s !== cc; });
|
|
97
|
-
_this.debug();
|
|
98
|
-
});
|
|
99
|
-
return cc;
|
|
100
|
-
};
|
|
101
|
-
//@internal
|
|
102
|
-
SseSubscriptionServer.prototype.debug = function () {
|
|
103
|
-
this.debugFileSaver(this.connections.map(function (x) { return ({
|
|
104
|
-
id: x.connectionId,
|
|
105
|
-
channels: x.channels,
|
|
106
|
-
}); }));
|
|
107
|
-
};
|
|
108
|
-
return SseSubscriptionServer;
|
|
109
|
-
}());
|
|
110
|
-
exports.SseSubscriptionServer = SseSubscriptionServer;
|
|
111
|
-
var clientConnection = /** @class */ (function () {
|
|
112
|
-
function clientConnection(response) {
|
|
113
|
-
this.response = response;
|
|
114
|
-
this.channels = {};
|
|
115
|
-
this.closed = false;
|
|
116
|
-
this.connectionId = uuid_1.v4();
|
|
117
|
-
this.write(this.connectionId, 'connectionId');
|
|
118
|
-
this.sendLiveMessage();
|
|
119
|
-
}
|
|
120
|
-
clientConnection.prototype.close = function () {
|
|
121
|
-
if (this.timeOutRef)
|
|
122
|
-
clearTimeout(this.timeOutRef);
|
|
123
|
-
this.closed = true;
|
|
124
|
-
};
|
|
125
|
-
clientConnection.prototype.write = function (eventData, eventType) {
|
|
126
|
-
if (eventType === void 0) { eventType = 'message'; }
|
|
127
|
-
var event = 'event:' + eventType;
|
|
128
|
-
// if (id != undefined)
|
|
129
|
-
// event += "\nid:" + id;
|
|
130
|
-
this.response.write(event + '\ndata:' + eventData + '\n\n');
|
|
131
|
-
if (this.response.flush)
|
|
132
|
-
this.response.flush();
|
|
133
|
-
};
|
|
134
|
-
clientConnection.prototype.sendLiveMessage = function () {
|
|
135
|
-
var _this = this;
|
|
136
|
-
if (this.closed)
|
|
137
|
-
return;
|
|
138
|
-
this.write('', 'keep-alive');
|
|
139
|
-
this.timeOutRef = setTimeout(function () {
|
|
140
|
-
_this.sendLiveMessage();
|
|
141
|
-
}, 45000);
|
|
142
|
-
};
|
|
143
|
-
return clientConnection;
|
|
144
|
-
}());
|
|
145
|
-
exports.clientConnection = clientConnection;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clientConnection = exports.SseSubscriptionServer = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var uuid_1 = require("uuid");
|
|
6
|
+
var SseSubscriptionClient_1 = require("./src/live-query/SseSubscriptionClient");
|
|
7
|
+
var SseSubscriptionServer = /** @class */ (function () {
|
|
8
|
+
function SseSubscriptionServer(canUserConnectToChannel) {
|
|
9
|
+
this.canUserConnectToChannel = canUserConnectToChannel;
|
|
10
|
+
//@internal
|
|
11
|
+
this.connections = [];
|
|
12
|
+
//@internal
|
|
13
|
+
this.debugMessageFileSaver = function (id, channel, message) { };
|
|
14
|
+
//@internal
|
|
15
|
+
this.debugFileSaver = function () { };
|
|
16
|
+
if (!this.canUserConnectToChannel) {
|
|
17
|
+
this.canUserConnectToChannel = function () { return true; };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//@internal
|
|
21
|
+
SseSubscriptionServer.prototype.subscribeToChannel = function (_a, res, remult, remove) {
|
|
22
|
+
var e_1, _b;
|
|
23
|
+
var channel = _a.channel, clientId = _a.clientId;
|
|
24
|
+
if (remove === void 0) { remove = false; }
|
|
25
|
+
try {
|
|
26
|
+
for (var _c = tslib_1.__values(this.connections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
27
|
+
var c = _d.value;
|
|
28
|
+
if (c.connectionId === clientId) {
|
|
29
|
+
if (this.canUserConnectToChannel(channel, remult)) {
|
|
30
|
+
if (remove)
|
|
31
|
+
delete c.channels[channel];
|
|
32
|
+
else
|
|
33
|
+
c.channels[channel] = true;
|
|
34
|
+
res.success({ status: 'ok' });
|
|
35
|
+
this.debug();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
res.forbidden();
|
|
40
|
+
this.debug();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
47
|
+
finally {
|
|
48
|
+
try {
|
|
49
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
50
|
+
}
|
|
51
|
+
finally { if (e_1) throw e_1.error; }
|
|
52
|
+
}
|
|
53
|
+
res.success(SseSubscriptionClient_1.ConnectionNotFoundError);
|
|
54
|
+
};
|
|
55
|
+
SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
56
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var data, _a, _b, sc;
|
|
58
|
+
var e_2, _c;
|
|
59
|
+
return tslib_1.__generator(this, function (_d) {
|
|
60
|
+
data = JSON.stringify({ channel: channel, data: message });
|
|
61
|
+
try {
|
|
62
|
+
for (_a = tslib_1.__values(this.connections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
63
|
+
sc = _b.value;
|
|
64
|
+
if (sc.channels[channel]) {
|
|
65
|
+
this.debugMessageFileSaver(sc.connectionId, channel, message);
|
|
66
|
+
sc.write(data);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
71
|
+
finally {
|
|
72
|
+
try {
|
|
73
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
74
|
+
}
|
|
75
|
+
finally { if (e_2) throw e_2.error; }
|
|
76
|
+
}
|
|
77
|
+
return [2 /*return*/];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
//@internal
|
|
82
|
+
SseSubscriptionServer.prototype.openHttpServerStream = function (req, res) {
|
|
83
|
+
var _this = this;
|
|
84
|
+
res.writeHead(200, {
|
|
85
|
+
'Content-Type': 'text/event-stream',
|
|
86
|
+
'Cache-Control': 'no-cache',
|
|
87
|
+
Connection: 'keep-alive',
|
|
88
|
+
});
|
|
89
|
+
var cc = new clientConnection(res);
|
|
90
|
+
//const lastEventId = req.headers['last-event-id'];
|
|
91
|
+
this.connections.push(cc);
|
|
92
|
+
this.debug();
|
|
93
|
+
//@ts-ignore
|
|
94
|
+
req.on('close', function () {
|
|
95
|
+
cc.close();
|
|
96
|
+
_this.connections = _this.connections.filter(function (s) { return s !== cc; });
|
|
97
|
+
_this.debug();
|
|
98
|
+
});
|
|
99
|
+
return cc;
|
|
100
|
+
};
|
|
101
|
+
//@internal
|
|
102
|
+
SseSubscriptionServer.prototype.debug = function () {
|
|
103
|
+
this.debugFileSaver(this.connections.map(function (x) { return ({
|
|
104
|
+
id: x.connectionId,
|
|
105
|
+
channels: x.channels,
|
|
106
|
+
}); }));
|
|
107
|
+
};
|
|
108
|
+
return SseSubscriptionServer;
|
|
109
|
+
}());
|
|
110
|
+
exports.SseSubscriptionServer = SseSubscriptionServer;
|
|
111
|
+
var clientConnection = /** @class */ (function () {
|
|
112
|
+
function clientConnection(response) {
|
|
113
|
+
this.response = response;
|
|
114
|
+
this.channels = {};
|
|
115
|
+
this.closed = false;
|
|
116
|
+
this.connectionId = (0, uuid_1.v4)();
|
|
117
|
+
this.write(this.connectionId, 'connectionId');
|
|
118
|
+
this.sendLiveMessage();
|
|
119
|
+
}
|
|
120
|
+
clientConnection.prototype.close = function () {
|
|
121
|
+
if (this.timeOutRef)
|
|
122
|
+
clearTimeout(this.timeOutRef);
|
|
123
|
+
this.closed = true;
|
|
124
|
+
};
|
|
125
|
+
clientConnection.prototype.write = function (eventData, eventType) {
|
|
126
|
+
if (eventType === void 0) { eventType = 'message'; }
|
|
127
|
+
var event = 'event:' + eventType;
|
|
128
|
+
// if (id != undefined)
|
|
129
|
+
// event += "\nid:" + id;
|
|
130
|
+
this.response.write(event + '\ndata:' + eventData + '\n\n');
|
|
131
|
+
if (this.response.flush)
|
|
132
|
+
this.response.flush();
|
|
133
|
+
};
|
|
134
|
+
clientConnection.prototype.sendLiveMessage = function () {
|
|
135
|
+
var _this = this;
|
|
136
|
+
if (this.closed)
|
|
137
|
+
return;
|
|
138
|
+
this.write('', 'keep-alive');
|
|
139
|
+
this.timeOutRef = setTimeout(function () {
|
|
140
|
+
_this.sendLiveMessage();
|
|
141
|
+
}, 45000);
|
|
142
|
+
};
|
|
143
|
+
return clientConnection;
|
|
144
|
+
}());
|
|
145
|
+
exports.clientConnection = clientConnection;
|
package/ably.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type * as Ably from '../../node_modules/ably';
|
|
2
|
-
import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel';
|
|
3
|
-
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
4
|
-
export declare class AblySubscriptionClient implements SubscriptionClient {
|
|
5
|
-
private ably;
|
|
6
|
-
constructor(ably: Ably.Types.RealtimePromise);
|
|
7
|
-
openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
|
|
8
|
-
}
|
|
9
|
-
export declare class AblySubscriptionServer implements SubscriptionServer {
|
|
10
|
-
private ably;
|
|
11
|
-
constructor(ably: Ably.Types.RestPromise);
|
|
12
|
-
publishMessage<T>(channel: string, message: T): Promise<void>;
|
|
13
|
-
}
|
|
1
|
+
import type * as Ably from '../../node_modules/ably';
|
|
2
|
+
import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel';
|
|
3
|
+
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
4
|
+
export declare class AblySubscriptionClient implements SubscriptionClient {
|
|
5
|
+
private ably;
|
|
6
|
+
constructor(ably: Ably.Types.RealtimePromise);
|
|
7
|
+
openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
|
|
8
|
+
}
|
|
9
|
+
export declare class AblySubscriptionServer implements SubscriptionServer {
|
|
10
|
+
private ably;
|
|
11
|
+
constructor(ably: Ably.Types.RestPromise);
|
|
12
|
+
publishMessage<T>(channel: string, message: T): Promise<void>;
|
|
13
|
+
}
|
package/ably.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AblySubscriptionServer = exports.AblySubscriptionClient = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var AblySubscriptionClient = /** @class */ (function () {
|
|
6
|
-
function AblySubscriptionClient(ably) {
|
|
7
|
-
this.ably = ably;
|
|
8
|
-
}
|
|
9
|
-
AblySubscriptionClient.prototype.openConnection = function (onReconnect) {
|
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
11
|
-
var _this = this;
|
|
12
|
-
return tslib_1.__generator(this, function (_a) {
|
|
13
|
-
return [2 /*return*/, {
|
|
14
|
-
close: function () {
|
|
15
|
-
// Since we did not open the connection, we do not close it
|
|
16
|
-
},
|
|
17
|
-
subscribe: function (channel, handler) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
18
|
-
var myHandler;
|
|
19
|
-
var _this = this;
|
|
20
|
-
return tslib_1.__generator(this, function (_a) {
|
|
21
|
-
switch (_a.label) {
|
|
22
|
-
case 0:
|
|
23
|
-
myHandler = function (y) { return handler(y.data); };
|
|
24
|
-
return [4 /*yield*/, this.ably.channels.get(channel).subscribe(function (y) { return myHandler(y); })];
|
|
25
|
-
case 1:
|
|
26
|
-
_a.sent();
|
|
27
|
-
return [2 /*return*/, function () {
|
|
28
|
-
myHandler = function () { };
|
|
29
|
-
_this.ably.channels.get(channel).unsubscribe();
|
|
30
|
-
}];
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}); },
|
|
34
|
-
}];
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
return AblySubscriptionClient;
|
|
39
|
-
}());
|
|
40
|
-
exports.AblySubscriptionClient = AblySubscriptionClient;
|
|
41
|
-
var AblySubscriptionServer = /** @class */ (function () {
|
|
42
|
-
function AblySubscriptionServer(ably) {
|
|
43
|
-
this.ably = ably;
|
|
44
|
-
}
|
|
45
|
-
AblySubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
46
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
47
|
-
return tslib_1.__generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0: return [4 /*yield*/, this.ably.channels.get(channel).publish({ data: message })];
|
|
50
|
-
case 1:
|
|
51
|
-
_a.sent();
|
|
52
|
-
return [2 /*return*/];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
return AblySubscriptionServer;
|
|
58
|
-
}());
|
|
59
|
-
exports.AblySubscriptionServer = AblySubscriptionServer;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AblySubscriptionServer = exports.AblySubscriptionClient = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var AblySubscriptionClient = /** @class */ (function () {
|
|
6
|
+
function AblySubscriptionClient(ably) {
|
|
7
|
+
this.ably = ably;
|
|
8
|
+
}
|
|
9
|
+
AblySubscriptionClient.prototype.openConnection = function (onReconnect) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
11
|
+
var _this = this;
|
|
12
|
+
return tslib_1.__generator(this, function (_a) {
|
|
13
|
+
return [2 /*return*/, {
|
|
14
|
+
close: function () {
|
|
15
|
+
// Since we did not open the connection, we do not close it
|
|
16
|
+
},
|
|
17
|
+
subscribe: function (channel, handler) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
18
|
+
var myHandler;
|
|
19
|
+
var _this = this;
|
|
20
|
+
return tslib_1.__generator(this, function (_a) {
|
|
21
|
+
switch (_a.label) {
|
|
22
|
+
case 0:
|
|
23
|
+
myHandler = function (y) { return handler(y.data); };
|
|
24
|
+
return [4 /*yield*/, this.ably.channels.get(channel).subscribe(function (y) { return myHandler(y); })];
|
|
25
|
+
case 1:
|
|
26
|
+
_a.sent();
|
|
27
|
+
return [2 /*return*/, function () {
|
|
28
|
+
myHandler = function () { };
|
|
29
|
+
_this.ably.channels.get(channel).unsubscribe();
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}); },
|
|
34
|
+
}];
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return AblySubscriptionClient;
|
|
39
|
+
}());
|
|
40
|
+
exports.AblySubscriptionClient = AblySubscriptionClient;
|
|
41
|
+
var AblySubscriptionServer = /** @class */ (function () {
|
|
42
|
+
function AblySubscriptionServer(ably) {
|
|
43
|
+
this.ably = ably;
|
|
44
|
+
}
|
|
45
|
+
AblySubscriptionServer.prototype.publishMessage = function (channel, message) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
47
|
+
return tslib_1.__generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, this.ably.channels.get(channel).publish({ data: message })];
|
|
50
|
+
case 1:
|
|
51
|
+
_a.sent();
|
|
52
|
+
return [2 /*return*/];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return AblySubscriptionServer;
|
|
58
|
+
}());
|
|
59
|
+
exports.AblySubscriptionServer = AblySubscriptionServer;
|
package/assign.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function assign<T>(item: T, valuesToSet: Partial<T>): T;
|
|
1
|
+
export declare function assign<T>(item: T, valuesToSet: Partial<T>): T;
|
package/assign.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assign = void 0;
|
|
4
|
-
function assign(item, valuesToSet) {
|
|
5
|
-
if (valuesToSet)
|
|
6
|
-
Object.assign(item, valuesToSet);
|
|
7
|
-
return item;
|
|
8
|
-
}
|
|
9
|
-
exports.assign = assign;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assign = void 0;
|
|
4
|
+
function assign(item, valuesToSet) {
|
|
5
|
+
if (valuesToSet)
|
|
6
|
+
Object.assign(item, valuesToSet);
|
|
7
|
+
return item;
|
|
8
|
+
}
|
|
9
|
+
exports.assign = assign;
|
package/classType.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
new (...args: any[]): T;
|
|
3
|
-
};
|
|
1
|
+
export type ClassType<T> = {
|
|
2
|
+
new (...args: any[]): T;
|
|
3
|
+
};
|
package/classType.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { GenericResponse } from './server/index';
|
|
3
|
-
import type { Remult } from './src/context';
|
|
4
|
-
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
5
|
-
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
|
-
private canUserConnectToChannel?;
|
|
7
|
-
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
8
|
-
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export interface ResponseRequiredForSSE {
|
|
11
|
-
write(data: string): void;
|
|
12
|
-
writeHead(status: number, headers: any): void;
|
|
13
|
-
flush?(): void;
|
|
14
|
-
}
|
|
15
|
-
export declare class clientConnection {
|
|
16
|
-
response: GenericResponse & ResponseRequiredForSSE;
|
|
17
|
-
channels: Record<string, boolean>;
|
|
18
|
-
timeOutRef: NodeJS.Timeout;
|
|
19
|
-
close(): void;
|
|
20
|
-
closed: boolean;
|
|
21
|
-
write(eventData: string, eventType?: string): void;
|
|
22
|
-
connectionId: any;
|
|
23
|
-
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
24
|
-
sendLiveMessage(): void;
|
|
25
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { GenericResponse } from './server/index';
|
|
3
|
+
import type { Remult } from './src/context';
|
|
4
|
+
import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
|
|
5
|
+
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
|
+
private canUserConnectToChannel?;
|
|
7
|
+
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
8
|
+
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ResponseRequiredForSSE {
|
|
11
|
+
write(data: string): void;
|
|
12
|
+
writeHead(status: number, headers: any): void;
|
|
13
|
+
flush?(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class clientConnection {
|
|
16
|
+
response: GenericResponse & ResponseRequiredForSSE;
|
|
17
|
+
channels: Record<string, boolean>;
|
|
18
|
+
timeOutRef: NodeJS.Timeout;
|
|
19
|
+
close(): void;
|
|
20
|
+
closed: boolean;
|
|
21
|
+
write(eventData: string, eventType?: string): void;
|
|
22
|
+
connectionId: any;
|
|
23
|
+
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
24
|
+
sendLiveMessage(): void;
|
|
25
|
+
}
|