@intuitionrobotics/push-pub-sub 0.46.0 → 0.47.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/app-backend/api/_push.js +2 -2
- package/app-backend/api/_push.js.map +1 -1
- package/app-backend/api/v1/push/read.js +4 -4
- package/app-backend/api/v1/push/read.js.map +1 -1
- package/app-backend/api/v1/push/register.js +5 -4
- package/app-backend/api/v1/push/register.js.map +1 -1
- package/app-backend/core/module-pack.d.ts +3 -0
- package/app-backend/core/module-pack.js +35 -0
- package/app-backend/core/module-pack.js.map +1 -1
- package/app-backend/modules/PushKey.d.ts +2 -2
- package/app-backend/modules/PushKey.js +18 -0
- package/app-backend/modules/PushKey.js.map +1 -1
- package/app-backend/modules/PushPubSubModule.d.ts +6 -7
- package/app-backend/modules/PushPubSubModule.js +43 -33
- package/app-backend/modules/PushPubSubModule.js.map +1 -1
- package/app-backend/modules/ScheduledPushCleanup.d.ts +1 -1
- package/app-backend/modules/ScheduledPushCleanup.js +20 -2
- package/app-backend/modules/ScheduledPushCleanup.js.map +1 -1
- package/app-backend/modules/{consts.d.ts → _imports.d.ts} +1 -0
- package/app-backend/modules/_imports.js +21 -0
- package/app-backend/modules/_imports.js.map +1 -0
- package/app-frontend/core/module-pack.d.ts +3 -1
- package/app-frontend/core/module-pack.js +36 -2
- package/app-frontend/core/module-pack.js.map +1 -1
- package/app-frontend/modules/NotificationModule.d.ts +3 -3
- package/app-frontend/modules/NotificationModule.js +12 -14
- package/app-frontend/modules/NotificationModule.js.map +1 -1
- package/app-frontend/modules/PushPubSubModule.d.ts +7 -7
- package/app-frontend/modules/PushPubSubModule.js +35 -25
- package/app-frontend/modules/PushPubSubModule.js.map +1 -1
- package/backend.d.ts +1 -0
- package/backend.js +18 -0
- package/backend.js.map +1 -0
- package/frontend.d.ts +3 -0
- package/frontend.js +20 -0
- package/frontend.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +17 -0
- package/index.js.map +1 -1
- package/package.json +8 -8
- package/shared/api.d.ts +3 -3
- package/shared/types.d.ts +16 -16
- package/app-backend/modules/consts.js +0 -6
- package/app-backend/modules/consts.js.map +0 -1
package/app-backend/api/_push.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
module.exports = new
|
|
3
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
4
|
+
module.exports = new backend_1.RouteResolver(require, __dirname);
|
|
5
5
|
//# sourceMappingURL=_push.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_push.js","sourceRoot":"","sources":["../../../src/main/app-backend/api/_push.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"_push.js","sourceRoot":"","sources":["../../../src/main/app-backend/api/_push.ts"],"names":[],"mappings":";;AAAA,qEAAsE;AAEtE,MAAM,CAAC,OAAO,GAAG,IAAI,uBAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
13
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
12
14
|
const PushPubSubModule_1 = require("../../../modules/PushPubSubModule");
|
|
13
|
-
|
|
14
|
-
const types_1 = require("@intuitionrobotics/thunderstorm/shared/types");
|
|
15
|
-
class ServerApi_PushRead extends server_api_1.ServerApi {
|
|
15
|
+
class ServerApi_PushRead extends backend_1.ServerApi {
|
|
16
16
|
constructor() {
|
|
17
|
-
super(
|
|
17
|
+
super(thunderstorm_1.HttpMethod.POST, "read");
|
|
18
18
|
}
|
|
19
19
|
process(request, response, queryParams, body) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/push/read.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/push/read.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qEAIiD;AAGjD,kEAA2D;AAC3D,wEAAmE;AAMnE,MAAM,kBACL,SAAQ,mBAAiC;IAEzC;QACC,KAAK,CAAC,yBAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAEe,OAAO,CAAC,OAAuB,EAAE,QAAqB,EAAE,WAAe,EAAE,IAAsB;;YAC9G,4DAA4D;YAC5D,OAAO,MAAM,mCAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,CAAC;KAAA;CACD;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -9,15 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
13
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
12
14
|
const PushPubSubModule_1 = require("../../../modules/PushPubSubModule");
|
|
13
|
-
|
|
14
|
-
const types_1 = require("@intuitionrobotics/thunderstorm/shared/types");
|
|
15
|
-
class ServerApi_PushRegister extends server_api_1.ServerApi {
|
|
15
|
+
class ServerApi_PushRegister extends backend_1.ServerApi {
|
|
16
16
|
constructor() {
|
|
17
|
-
super(
|
|
17
|
+
super(thunderstorm_1.HttpMethod.POST, "register");
|
|
18
18
|
}
|
|
19
19
|
process(request, response, queryParams, body) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// const user = await KasperoProxy.validateSession(request);
|
|
21
22
|
return yield PushPubSubModule_1.PushPubSubModule.register(body, request);
|
|
22
23
|
});
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/push/register.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../../src/main/app-backend/api/v1/push/register.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qEAIiD;AAGjD,kEAA2D;AAC3D,wEAAmE;AAMnE,MAAM,sBACL,SAAQ,mBAA+B;IAEvC;QACC,KAAK,CAAC,yBAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IAEe,OAAO,CAAC,OAAuB,EAAE,QAAqB,EAAE,WAAe,EAAE,IAA0B;;YAClH,4DAA4D;YAC5D,OAAO,MAAM,mCAAgB,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;KAAA;CACD;AAED,MAAM,CAAC,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export declare const Backend_ModulePack_PushPubSub: (import("../modules/PushPubSubModule").PushPubSubModule_Class | import("../modules/ScheduledPushCleanup").ScheduledCleanup_Class)[];
|
|
2
|
+
export * from "../modules/PushPubSubModule";
|
|
3
|
+
export * from "../modules/ScheduledPushCleanup";
|
|
4
|
+
export * from "../modules/PushKey";
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.Backend_ModulePack_PushPubSub = void 0;
|
|
4
36
|
const PushPubSubModule_1 = require("../modules/PushPubSubModule");
|
|
@@ -7,4 +39,7 @@ exports.Backend_ModulePack_PushPubSub = [
|
|
|
7
39
|
PushPubSubModule_1.PushPubSubModule,
|
|
8
40
|
ScheduledPushCleanup_1.ScheduledCleanup
|
|
9
41
|
];
|
|
42
|
+
__exportStar(require("../modules/PushPubSubModule"), exports);
|
|
43
|
+
__exportStar(require("../modules/ScheduledPushCleanup"), exports);
|
|
44
|
+
__exportStar(require("../modules/PushKey"), exports);
|
|
10
45
|
//# sourceMappingURL=module-pack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/module-pack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/module-pack.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,kEAA6D;AAC7D,0EAAiE;AAEpD,QAAA,6BAA6B,GAAG;IAC5C,mCAAgB;IAChB,uCAAgB;CAChB,CAAC;AAEF,8DAA2C;AAC3C,kEAA+C;AAC/C,qDAAkC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ObjectTS } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { SubscribeProps } from "./_imports";
|
|
3
3
|
export declare class PushKey<K extends string, P extends SubscribeProps, D extends ObjectTS> {
|
|
4
4
|
private readonly key;
|
|
5
5
|
private readonly persist;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushKey.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushKey.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PushKey.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushKey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAGH,yDAAoD;AAGpD,MAAa,OAAO;IAKnB,YAAY,GAAM,EAAE,OAAO,GAAG,KAAK;QAClC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAEK,IAAI,CAAC,IAAO,EAAE,KAAS;;YAC5B,OAAO,mCAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxE,CAAC;KAAA;IAAA,CAAC;CACF;AAbD,0BAaC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
declare type Config = {
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { FirebaseType_BatchResponse, FirebaseType_Message, FirestoreTransaction } from "@intuitionrobotics/firebase/backend";
|
|
3
|
+
import { DB_Notifications, IFP, ISP, ITP, MessageType, Request_PushRegister, SubscribeProps } from "../../index";
|
|
4
|
+
import { ExpressRequest } from "@intuitionrobotics/thunderstorm/backend";
|
|
5
|
+
type Config = {
|
|
7
6
|
notificationsCleanupTime?: number;
|
|
8
7
|
sessionsCleanupTime?: number;
|
|
9
8
|
};
|
|
10
|
-
|
|
9
|
+
type TempMessages = {
|
|
11
10
|
[token: string]: DB_Notifications[];
|
|
12
11
|
};
|
|
13
12
|
export declare class PushPubSubModule_Class extends Module<Config> {
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,21 +28,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
28
|
};
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
30
|
exports.PushPubSubModule = exports.PushPubSubModule_Class = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const array_tools_1 = require("@intuitionrobotics/ts-common/utils/array-tools");
|
|
18
|
-
const object_tools_1 = require("@intuitionrobotics/ts-common/utils/object-tools");
|
|
19
|
-
const random_tools_1 = require("@intuitionrobotics/ts-common/utils/random-tools");
|
|
20
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
21
|
-
class PushPubSubModule_Class extends module_1.Module {
|
|
31
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
32
|
+
const backend_1 = require("@intuitionrobotics/firebase/backend");
|
|
33
|
+
const backend_2 = require("@intuitionrobotics/thunderstorm/backend");
|
|
34
|
+
class PushPubSubModule_Class extends ts_common_1.Module {
|
|
22
35
|
constructor() {
|
|
23
36
|
super("PushPubSubModule");
|
|
24
37
|
this.buildNotification = (pushkey, persistent, data, props, user) => {
|
|
25
38
|
const notification = {
|
|
26
|
-
_id:
|
|
27
|
-
timestamp:
|
|
39
|
+
_id: (0, ts_common_1.generateHex)(16),
|
|
40
|
+
timestamp: (0, ts_common_1.currentTimeMillies)(),
|
|
28
41
|
read: false,
|
|
29
42
|
pushKey: pushkey,
|
|
30
43
|
persistent
|
|
@@ -38,10 +51,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
38
51
|
return notification;
|
|
39
52
|
};
|
|
40
53
|
this.sendMessage = (persistent, _messages) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const messages = Object.keys(_messages).map(token => ({
|
|
42
|
-
token,
|
|
43
|
-
data: { messages: tools_1.__stringify(_messages[token]) }
|
|
44
|
-
}));
|
|
54
|
+
const messages = Object.keys(_messages).map(token => ({ token, data: { messages: (0, ts_common_1.__stringify)(_messages[token]) } }));
|
|
45
55
|
if (messages.length === 0)
|
|
46
56
|
return;
|
|
47
57
|
console.log("sending a message to \n" + Object.keys(_messages).join("\n"));
|
|
@@ -54,11 +64,11 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
54
64
|
});
|
|
55
65
|
this.scheduledCleanup = () => __awaiter(this, void 0, void 0, function* () {
|
|
56
66
|
var _a, _b;
|
|
57
|
-
const sessionsCleanupTime = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionsCleanupTime) ||
|
|
58
|
-
const notificationsCleanupTime = ((_b = this.config) === null || _b === void 0 ? void 0 : _b.notificationsCleanupTime) || 7 *
|
|
59
|
-
const docs = yield this.pushSessions.query({ where: { timestamp: { $lt:
|
|
67
|
+
const sessionsCleanupTime = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionsCleanupTime) || ts_common_1.Hour;
|
|
68
|
+
const notificationsCleanupTime = ((_b = this.config) === null || _b === void 0 ? void 0 : _b.notificationsCleanupTime) || 7 * ts_common_1.Day;
|
|
69
|
+
const docs = yield this.pushSessions.query({ where: { timestamp: { $lt: (0, ts_common_1.currentTimeMillies)() - sessionsCleanupTime } } });
|
|
60
70
|
yield Promise.all([
|
|
61
|
-
this.notifications.delete({ where: { timestamp: { $lt:
|
|
71
|
+
this.notifications.delete({ where: { timestamp: { $lt: (0, ts_common_1.currentTimeMillies)() - notificationsCleanupTime } } }),
|
|
62
72
|
this.cleanUpImpl(docs.map(d => d.firebaseToken))
|
|
63
73
|
]);
|
|
64
74
|
});
|
|
@@ -76,7 +86,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
76
86
|
});
|
|
77
87
|
}
|
|
78
88
|
init() {
|
|
79
|
-
const session =
|
|
89
|
+
const session = backend_1.FirebaseModule.createAdminSession();
|
|
80
90
|
const firestore = session.getFirestore();
|
|
81
91
|
this.pushSessions = firestore.getCollection("push-sessions", ["pushSessionId"]);
|
|
82
92
|
this.pushKeys = firestore.getCollection("push-keys");
|
|
@@ -86,14 +96,14 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
86
96
|
register(body, request) {
|
|
87
97
|
var _a, _b, _c;
|
|
88
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const resp = yield
|
|
99
|
+
const resp = yield backend_2.dispatch_queryRequestInfo.dispatchModuleAsync(request);
|
|
90
100
|
const userId = ((_b = (_a = resp.find(e => e.key === "AccountsModule")) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b._id) || ((_c = resp.find(e => e.key === "RemoteProxy")) === null || _c === void 0 ? void 0 : _c.data);
|
|
91
101
|
// if (!userId)
|
|
92
102
|
// throw new ImplementationMissingException("Missing user from accounts Module");
|
|
93
103
|
const session = {
|
|
94
104
|
firebaseToken: body.firebaseToken,
|
|
95
105
|
pushSessionId: body.pushSessionId,
|
|
96
|
-
timestamp:
|
|
106
|
+
timestamp: (0, ts_common_1.currentTimeMillies)()
|
|
97
107
|
};
|
|
98
108
|
if (userId)
|
|
99
109
|
session.userId = userId;
|
|
@@ -109,12 +119,12 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
109
119
|
return this.pushSessions.runInTransaction((transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
110
120
|
const pushKeys = subscriptions.map(_sub => _sub.pushKey);
|
|
111
121
|
let subscriptionNotifications = pushKeys.length !== 0 ?
|
|
112
|
-
yield
|
|
122
|
+
yield (0, ts_common_1.batchAction)(pushKeys, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return transaction.query(this.notifications, { where: { pushKey: { $in: elements } } }); })) : [];
|
|
113
123
|
if (subscriptionNotifications.length > 0)
|
|
114
124
|
subscriptionNotifications = subscriptionNotifications.filter(_notification => {
|
|
115
125
|
var _a;
|
|
116
126
|
const x = (_a = subscriptions.find(_sub => _sub.pushKey === _notification.pushKey)) === null || _a === void 0 ? void 0 : _a.props;
|
|
117
|
-
return
|
|
127
|
+
return (0, ts_common_1.compare)(x, _notification.props) || _notification.userId;
|
|
118
128
|
});
|
|
119
129
|
const userNotifications = userId ? yield transaction.query(this.notifications, { where: { userId } }) : [];
|
|
120
130
|
const notifications = userNotifications.concat(subscriptionNotifications);
|
|
@@ -122,7 +132,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
122
132
|
const write = yield transaction.delete_Read(this.pushKeys, { where: { pushSessionId: body.pushSessionId } });
|
|
123
133
|
yield transaction.insertAll(this.pushKeys, subscriptions);
|
|
124
134
|
yield Promise.all([write(), writePush()]);
|
|
125
|
-
return
|
|
135
|
+
return (0, ts_common_1.filterDuplicates)(notifications);
|
|
126
136
|
}));
|
|
127
137
|
});
|
|
128
138
|
}
|
|
@@ -132,7 +142,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
132
142
|
console.log("i am pushing to key...", key, props, data);
|
|
133
143
|
let docs = yield _transaction.query(this.pushKeys, { where: { pushKey: key } });
|
|
134
144
|
if (props)
|
|
135
|
-
docs = docs.filter(doc => !doc.props ||
|
|
145
|
+
docs = docs.filter(doc => !doc.props || (0, ts_common_1.compare)(doc.props, props));
|
|
136
146
|
const notification = this.buildNotification(key, persistent, data, props);
|
|
137
147
|
// If we need to do read and write for a transaction move this to a callback and rename to pushToKey_Read
|
|
138
148
|
if (persistent) {
|
|
@@ -142,7 +152,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
142
152
|
return;
|
|
143
153
|
const sessionsIds = docs.map(d => d.pushSessionId);
|
|
144
154
|
// I get the tokens relative to those sessions (query)
|
|
145
|
-
const sessions = yield
|
|
155
|
+
const sessions = yield (0, ts_common_1.batchAction)(sessionsIds, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return _transaction.query(this.pushSessions, { where: { pushSessionId: { $in: elements } } }); }));
|
|
146
156
|
const _messages = docs.reduce((carry, db_pushKey) => {
|
|
147
157
|
const session = sessions.find(s => s.pushSessionId === db_pushKey.pushSessionId);
|
|
148
158
|
if (!session)
|
|
@@ -175,7 +185,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
175
185
|
if (docs.length === 0)
|
|
176
186
|
return;
|
|
177
187
|
const sessionsIds = docs.map(d => d.pushSessionId);
|
|
178
|
-
const sessions = yield
|
|
188
|
+
const sessions = yield (0, ts_common_1.batchAction)(sessionsIds, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushSessions.query({ where: { pushSessionId: { $in: elements } } }); }));
|
|
179
189
|
const _messages = docs.reduce((carry, db_pushKey) => {
|
|
180
190
|
const session = sessions.find(s => s.pushSessionId === db_pushKey.pushSessionId);
|
|
181
191
|
if (!session)
|
|
@@ -190,12 +200,12 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
190
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
191
201
|
if (_toDelete.length === 0)
|
|
192
202
|
return;
|
|
193
|
-
const toDelete =
|
|
194
|
-
const _sessions = yield
|
|
195
|
-
const sessions =
|
|
203
|
+
const toDelete = (0, ts_common_1.filterDuplicates)(_toDelete);
|
|
204
|
+
const _sessions = yield (0, ts_common_1.batchActionParallel)(toDelete, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushSessions.query({ where: { firebaseToken: { $in: elements } } }); }));
|
|
205
|
+
const sessions = (0, ts_common_1.filterDuplicates)(_sessions.map(s => s.pushSessionId));
|
|
196
206
|
const async = [
|
|
197
|
-
|
|
198
|
-
|
|
207
|
+
(0, ts_common_1.batchActionParallel)(toDelete, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushSessions.delete({ where: { firebaseToken: { $in: elements } } }); })),
|
|
208
|
+
(0, ts_common_1.batchActionParallel)(sessions, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushKeys.delete({ where: { pushSessionId: { $in: elements } } }); }))
|
|
199
209
|
];
|
|
200
210
|
yield Promise.all(async);
|
|
201
211
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushPubSubModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushPubSubModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PushPubSubModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushPubSubModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,4DAYsC;AAEtC,iEAO6C;AAa7C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gB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FirebaseScheduledFunction } from "@intuitionrobotics/firebase/
|
|
1
|
+
import { FirebaseScheduledFunction } from "@intuitionrobotics/firebase/backend-functions";
|
|
2
2
|
export declare class ScheduledCleanup_Class extends FirebaseScheduledFunction {
|
|
3
3
|
constructor();
|
|
4
4
|
onScheduledEvent: () => Promise<any>;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,9 +28,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
28
|
};
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
30
|
exports.ScheduledCleanup = exports.ScheduledCleanup_Class = void 0;
|
|
13
|
-
const
|
|
31
|
+
const backend_functions_1 = require("@intuitionrobotics/firebase/backend-functions");
|
|
14
32
|
const PushPubSubModule_1 = require("./PushPubSubModule");
|
|
15
|
-
class ScheduledCleanup_Class extends
|
|
33
|
+
class ScheduledCleanup_Class extends backend_functions_1.FirebaseScheduledFunction {
|
|
16
34
|
constructor() {
|
|
17
35
|
super("ScheduledCleanup");
|
|
18
36
|
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduledPushCleanup.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ScheduledPushCleanup.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ScheduledPushCleanup.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ScheduledPushCleanup.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,qFAAwF;AACxF,yDAAoD;AAEpD,MAAa,sBACZ,SAAQ,6CAAyB;IAEjC;QACC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAI3B,qBAAgB,GAAG,GAAuB,EAAE;YAC3C,OAAO,mCAAgB,CAAC,gBAAgB,EAAE,CAAA;QAC3C,CAAC,CAAA,CAAC;QALD,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;CAKD;AAXD,wDAWC;AAEY,QAAA,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CollectionName_Tabs = exports.CollectionName_PushSubscribers = void 0;
|
|
18
|
+
__exportStar(require("../../shared/types"), exports);
|
|
19
|
+
exports.CollectionName_PushSubscribers = "push-pub-sub--subscribers";
|
|
20
|
+
exports.CollectionName_Tabs = "push-pub-sub--tabs";
|
|
21
|
+
//# sourceMappingURL=_imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_imports.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/_imports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AAEtB,QAAA,8BAA8B,GAAG,2BAA2B,CAAC;AAC7D,QAAA,mBAAmB,GAAG,oBAAoB,CAAC"}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare const Frontend_ModulePack_PushPubSub: (import("
|
|
1
|
+
export declare const Frontend_ModulePack_PushPubSub: (import("@intuitionrobotics/firebase/frontend").FirebaseModule_Class | import("../modules/NotificationModule").NotificationsModule_Class | import("../modules/PushPubSubModule").PushPubSubModule_Class)[];
|
|
2
|
+
export * from "../modules/PushPubSubModule";
|
|
3
|
+
export * from "../modules/NotificationModule";
|
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.Frontend_ModulePack_PushPubSub = void 0;
|
|
4
36
|
const PushPubSubModule_1 = require("../modules/PushPubSubModule");
|
|
5
|
-
const
|
|
37
|
+
const frontend_1 = require("@intuitionrobotics/firebase/frontend");
|
|
6
38
|
const NotificationModule_1 = require("../modules/NotificationModule");
|
|
7
39
|
exports.Frontend_ModulePack_PushPubSub = [
|
|
8
|
-
|
|
40
|
+
frontend_1.FirebaseModule,
|
|
9
41
|
PushPubSubModule_1.PushPubSubModule,
|
|
10
42
|
NotificationModule_1.NotificationsModule
|
|
11
43
|
];
|
|
44
|
+
__exportStar(require("../modules/PushPubSubModule"), exports);
|
|
45
|
+
__exportStar(require("../modules/NotificationModule"), exports);
|
|
12
46
|
//# sourceMappingURL=module-pack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,kEAA6D;AAC7D,mEAAoE;AACpE,sEAAkE;AAErD,QAAA,8BAA8B,GAAG;IAC7C,yBAAc;IACd,mCAAgB;IAChB,wCAAmB;CACnB,CAAC;AAEF,8DAA4C;AAC5C,gEAA8C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ThunderDispatcher } from "@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher";
|
|
2
|
-
import { Module } from "@intuitionrobotics/ts-common
|
|
3
|
-
import { DB_Notifications } from "
|
|
2
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
3
|
+
import { DB_Notifications } from "../..";
|
|
4
4
|
export interface OnNotificationsUpdated {
|
|
5
5
|
__onNotificationsUpdated(): void;
|
|
6
6
|
}
|
|
7
|
-
export declare const dispatch_NotificationsUpdated: ThunderDispatcher<OnNotificationsUpdated, "__onNotificationsUpdated">;
|
|
7
|
+
export declare const dispatch_NotificationsUpdated: ThunderDispatcher<OnNotificationsUpdated, "__onNotificationsUpdated", [], void>;
|
|
8
8
|
export declare class NotificationsModule_Class extends Module {
|
|
9
9
|
constructor();
|
|
10
10
|
private notifications;
|
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationsModule = exports.NotificationsModule_Class = exports.dispatch_NotificationsUpdated = void 0;
|
|
4
4
|
const thunder_dispatcher_1 = require("@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
9
|
-
const XhrHttpModule_1 = require("@intuitionrobotics/thunderstorm/app-frontend/modules/http/XhrHttpModule");
|
|
5
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
6
|
+
const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
|
|
7
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
10
8
|
exports.dispatch_NotificationsUpdated = new thunder_dispatcher_1.ThunderDispatcher('__onNotificationsUpdated');
|
|
11
|
-
class NotificationsModule_Class extends
|
|
9
|
+
class NotificationsModule_Class extends ts_common_1.Module {
|
|
12
10
|
constructor() {
|
|
13
11
|
super("NotificationsModule");
|
|
14
12
|
this.notifications = [];
|
|
15
13
|
this.setNotificationList = (notifications) => {
|
|
16
14
|
this.notifications = notifications;
|
|
17
|
-
exports.dispatch_NotificationsUpdated.dispatchUI(
|
|
15
|
+
exports.dispatch_NotificationsUpdated.dispatchUI();
|
|
18
16
|
};
|
|
19
17
|
this.read = (notification, read) => {
|
|
20
18
|
const readNotification = this.notifications.find(_notification => _notification._id === notification._id);
|
|
@@ -28,14 +26,14 @@ class NotificationsModule_Class extends module_1.Module {
|
|
|
28
26
|
_id: id,
|
|
29
27
|
read
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
.createRequest(
|
|
29
|
+
frontend_1.XhrHttpModule
|
|
30
|
+
.createRequest(thunderstorm_1.HttpMethod.POST, 'read-notification')
|
|
33
31
|
.setRelativeUrl("/v1/push/read")
|
|
34
32
|
.setJsonBody(body)
|
|
35
33
|
.setOnError('Something went wrong while reading your notification')
|
|
36
|
-
.setTimeout(
|
|
34
|
+
.setTimeout(ts_common_1.Minute)
|
|
37
35
|
.execute(() => {
|
|
38
|
-
exports.dispatch_NotificationsUpdated.dispatchUI(
|
|
36
|
+
exports.dispatch_NotificationsUpdated.dispatchUI();
|
|
39
37
|
});
|
|
40
38
|
};
|
|
41
39
|
}
|
|
@@ -44,11 +42,11 @@ class NotificationsModule_Class extends module_1.Module {
|
|
|
44
42
|
}
|
|
45
43
|
addNotification(newNotification) {
|
|
46
44
|
this.notifications.push(newNotification);
|
|
47
|
-
exports.dispatch_NotificationsUpdated.dispatchUI(
|
|
45
|
+
exports.dispatch_NotificationsUpdated.dispatchUI();
|
|
48
46
|
}
|
|
49
47
|
removeNotification(notification) {
|
|
50
|
-
|
|
51
|
-
exports.dispatch_NotificationsUpdated.dispatchUI(
|
|
48
|
+
(0, ts_common_1.removeItemFromArray)(this.notifications, notification);
|
|
49
|
+
exports.dispatch_NotificationsUpdated.dispatchUI();
|
|
52
50
|
return notification._id;
|
|
53
51
|
}
|
|
54
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/NotificationModule.ts"],"names":[],"mappings":";;;AAAA,6GAAuG;AACvG,
|
|
1
|
+
{"version":3,"file":"NotificationModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/NotificationModule.ts"],"names":[],"mappings":";;;AAAA,6GAAuG;AACvG,4DAIsC;AAKtC,uEAAuE;AACvE,kEAA2D;AAM9C,QAAA,6BAA6B,GAAG,IAAI,sCAAiB,CAAqD,0BAA0B,CAAC,CAAC;AAGnJ,MAAa,yBACZ,SAAQ,kBAAM;IAEd;QACC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAGtB,kBAAa,GAAuB,EAAE,CAAC;QAM/C,wBAAmB,GAAG,CAAC,aAAiC,EAAE,EAAE;YAC3D,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;YACnC,qCAA6B,CAAC,UAAU,EAAE,CAAC;QAC5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CAAC,GAAG,CAAC;IACzB,CAAC;CA4BD;AAvDD,8DAuDC;AAEY,QAAA,mBAAmB,GAAG,IAAI,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Module } from "@intuitionrobotics/ts-common
|
|
2
|
-
import { BaseSubscriptionData, DB_Notifications, IFP, ISP, ITP, MessageType, SubscribeProps } from "../../
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { BaseSubscriptionData, DB_Notifications, IFP, ISP, ITP, MessageType, SubscribeProps } from "../../index";
|
|
3
3
|
export declare const Command_SwToApp = "SwToApp";
|
|
4
4
|
export interface OnPushMessageReceived<M extends MessageType<any, any, any> = never, S extends string = IFP<M>, P extends SubscribeProps = ISP<M>, D = ITP<M>> {
|
|
5
5
|
__onMessageReceived(notification: DB_Notifications): void;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type FirebaseConfig = {
|
|
8
8
|
apiKey: string;
|
|
9
9
|
authDomain: string;
|
|
10
10
|
projectId: string;
|
|
11
11
|
messagingSenderId: string;
|
|
12
12
|
databaseURL?: string;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type PushPubSubConfig = {
|
|
15
15
|
config?: FirebaseConfig;
|
|
16
16
|
publicKeyBase64: string;
|
|
17
17
|
swFileName?: string;
|
|
@@ -31,9 +31,9 @@ export declare class PushPubSubModule_Class extends Module<PushPubSubConfig> {
|
|
|
31
31
|
private registerServiceWorker;
|
|
32
32
|
initApp: () => void;
|
|
33
33
|
getToken: (options?: {
|
|
34
|
-
vapidKey?: string
|
|
35
|
-
serviceWorkerRegistration?: ServiceWorkerRegistration
|
|
36
|
-
}
|
|
34
|
+
vapidKey?: string;
|
|
35
|
+
serviceWorkerRegistration?: ServiceWorkerRegistration;
|
|
36
|
+
}) => Promise<void>;
|
|
37
37
|
private processMessageFromSw;
|
|
38
38
|
private processMessage;
|
|
39
39
|
subscribe: (subscription: BaseSubscriptionData) => void;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* A typescript & react boilerplate with api call example
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2018 Intuition Robotics
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
2
19
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
20
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
21
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,26 +27,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
27
|
};
|
|
11
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
29
|
exports.PushPubSubModule = exports.PushPubSubModule_Class = exports.pushSessionIdKey = exports.Command_SwToApp = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const XhrHttpModule_1 = require("@intuitionrobotics/thunderstorm/app-frontend/modules/http/XhrHttpModule");
|
|
30
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
31
|
+
const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
|
|
32
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
33
|
+
const frontend_2 = require("@intuitionrobotics/firebase/frontend");
|
|
18
34
|
const NotificationModule_1 = require("./NotificationModule");
|
|
19
|
-
const random_tools_1 = require("@intuitionrobotics/ts-common/utils/random-tools");
|
|
20
|
-
const exceptions_1 = require("@intuitionrobotics/ts-common/core/exceptions");
|
|
21
|
-
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-frontend/FirebaseModule");
|
|
22
|
-
const object_tools_1 = require("@intuitionrobotics/ts-common/utils/object-tools");
|
|
23
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
24
|
-
const StorageModule_1 = require("@intuitionrobotics/thunderstorm/app-frontend/modules/StorageModule");
|
|
25
35
|
exports.Command_SwToApp = "SwToApp";
|
|
26
36
|
exports.pushSessionIdKey = "x-push-session-id";
|
|
27
|
-
const pushSessionId = new
|
|
28
|
-
class PushPubSubModule_Class extends
|
|
37
|
+
const pushSessionId = new frontend_1.StorageKey(exports.pushSessionIdKey, false);
|
|
38
|
+
class PushPubSubModule_Class extends ts_common_1.Module {
|
|
29
39
|
constructor() {
|
|
30
40
|
super("PushPubSubModule");
|
|
31
41
|
this.subscriptions = [];
|
|
32
|
-
this.dispatch_pushMessage = new
|
|
42
|
+
this.dispatch_pushMessage = new frontend_1.ThunderDispatcher("__onMessageReceived");
|
|
33
43
|
this.timeout = 800;
|
|
34
44
|
this.registerServiceWorker = () => __awaiter(this, void 0, void 0, function* () {
|
|
35
45
|
console.log("Registering service worker...");
|
|
@@ -38,12 +48,12 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
38
48
|
this.initApp = () => {
|
|
39
49
|
var _a;
|
|
40
50
|
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.publicKeyBase64))
|
|
41
|
-
throw new
|
|
51
|
+
throw new ts_common_1.ImplementationMissingException(`Please specify the right config for the 'PushPubSubModule'`);
|
|
42
52
|
this.runAsync("Initializing Firebase SDK and registering SW", () => __awaiter(this, void 0, void 0, function* () {
|
|
43
53
|
if ("serviceWorker" in navigator) {
|
|
44
54
|
const asyncs = [
|
|
45
55
|
this.registerServiceWorker(),
|
|
46
|
-
|
|
56
|
+
frontend_2.FirebaseModule.createSession()
|
|
47
57
|
];
|
|
48
58
|
const { 0: registration, 1: app } = yield Promise.all(asyncs);
|
|
49
59
|
yield registration.update();
|
|
@@ -72,7 +82,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
72
82
|
if (permission !== "granted")
|
|
73
83
|
return;
|
|
74
84
|
if (!this.messaging)
|
|
75
|
-
throw new
|
|
85
|
+
throw new ts_common_1.BadImplementationException("I literally just set this!");
|
|
76
86
|
this.firebaseToken = yield this.messaging.getToken(options);
|
|
77
87
|
if (!this.firebaseToken)
|
|
78
88
|
return;
|
|
@@ -104,7 +114,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
104
114
|
const arr = JSON.parse(data.messages);
|
|
105
115
|
arr.forEach(s => {
|
|
106
116
|
s.persistent && NotificationModule_1.NotificationsModule.addNotification(s);
|
|
107
|
-
this.dispatch_pushMessage.dispatchModule(
|
|
117
|
+
this.dispatch_pushMessage.dispatchModule(s);
|
|
108
118
|
});
|
|
109
119
|
};
|
|
110
120
|
this.subscribe = (subscription) => {
|
|
@@ -116,7 +126,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
116
126
|
return this.register();
|
|
117
127
|
};
|
|
118
128
|
this.unsubscribe = (subscription) => {
|
|
119
|
-
|
|
129
|
+
(0, ts_common_1.removeFromArray)(this.subscriptions, d => d.pushKey === subscription.pushKey && (0, ts_common_1.compare)(subscription.props, d.props));
|
|
120
130
|
return this.register();
|
|
121
131
|
};
|
|
122
132
|
this.register = () => {
|
|
@@ -131,10 +141,10 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
131
141
|
};
|
|
132
142
|
this.logDebug("Registering subscriptions");
|
|
133
143
|
for (const sub of this.subscriptions) {
|
|
134
|
-
this.logDebug(`${sub.pushKey} => ${sub.props ?
|
|
144
|
+
this.logDebug(`${sub.pushKey} => ${sub.props ? (0, ts_common_1.__stringify)(sub.props) : "no props"}`);
|
|
135
145
|
}
|
|
136
|
-
|
|
137
|
-
.createRequest(
|
|
146
|
+
frontend_1.XhrHttpModule
|
|
147
|
+
.createRequest(thunderstorm_1.HttpMethod.POST, "register-pub-sub-tab")
|
|
138
148
|
.setRelativeUrl("/v1/push/register")
|
|
139
149
|
.setJsonBody(body)
|
|
140
150
|
.setOnError("Failed to register for push")
|
|
@@ -144,7 +154,7 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
144
154
|
});
|
|
145
155
|
}, "debounce-register", this.timeout);
|
|
146
156
|
};
|
|
147
|
-
window.name = window.name ||
|
|
157
|
+
window.name = window.name || (0, ts_common_1.generateHex)(32);
|
|
148
158
|
this.pushSessionId = pushSessionId.set(window.name);
|
|
149
159
|
}
|
|
150
160
|
init() {
|
|
@@ -157,9 +167,9 @@ class PushPubSubModule_Class extends module_1.Module {
|
|
|
157
167
|
return this.pushSessionId;
|
|
158
168
|
}
|
|
159
169
|
subscribeImpl(subscription) {
|
|
160
|
-
if (this.subscriptions.find(d => d.pushKey === subscription.pushKey &&
|
|
170
|
+
if (this.subscriptions.find(d => d.pushKey === subscription.pushKey && (0, ts_common_1.compare)(subscription.props, d.props)))
|
|
161
171
|
return;
|
|
162
|
-
|
|
172
|
+
(0, ts_common_1.addItemToArray)(this.subscriptions, subscription);
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
exports.PushPubSubModule_Class = PushPubSubModule_Class;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushPubSubModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/PushPubSubModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PushPubSubModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/PushPubSubModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAEH,4DAUsC;AAEtC,uEAIkD;AAalD,kEAA2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AAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,YAAY,CAAC,OAAO,IAAI,IAAA,mBAAO,EAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;YAC3G,OAAO;QAER,IAAA,0BAAc,EAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;CA0CD;AA5KD,wDA4KC;AAEY,QAAA,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
package/backend.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./app-backend/core/module-pack";
|
package/backend.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./app-backend/core/module-pack"), exports);
|
|
18
|
+
//# sourceMappingURL=backend.js.map
|
package/backend.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/main/backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA8C"}
|
package/frontend.d.ts
ADDED
package/frontend.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./app-frontend/modules/PushPubSubModule"), exports);
|
|
18
|
+
__exportStar(require("./app-frontend/modules/NotificationModule"), exports);
|
|
19
|
+
__exportStar(require("./app-frontend/core/module-pack"), exports);
|
|
20
|
+
//# sourceMappingURL=frontend.js.map
|
package/frontend.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.js","sourceRoot":"","sources":["../src/main/frontend.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD;AACxD,4EAAyD;AACzD,kEAAgD"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./shared/api"), exports);
|
|
18
|
+
__exportStar(require("./shared/types"), exports);
|
|
2
19
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,iDAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuitionrobotics/push-pub-sub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "push-pub-sub",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"IR",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"main": "./index.js",
|
|
21
21
|
"types": "./index.d.ts",
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "tsc"
|
|
23
|
+
"build": "tsc -v && tsc -p src/main/tsconfig.json --rootDir ./src/main --outDir dist"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@intuitionrobotics/firebase": "~0.
|
|
27
|
-
"@intuitionrobotics/thunderstorm": "~0.
|
|
28
|
-
"@intuitionrobotics/ts-common": "~0.
|
|
26
|
+
"@intuitionrobotics/firebase": "~0.47.0",
|
|
27
|
+
"@intuitionrobotics/thunderstorm": "~0.47.0",
|
|
28
|
+
"@intuitionrobotics/ts-common": "~0.47.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@intuitionrobotics/testelot": "~0.
|
|
32
|
-
"@types/node": "^
|
|
31
|
+
"@intuitionrobotics/testelot": "~0.47.0",
|
|
32
|
+
"@types/node": "^18.0.0",
|
|
33
33
|
"ts-node": "^8.6.2",
|
|
34
34
|
"tslint": "^5.16.0",
|
|
35
|
-
"typescript": "
|
|
35
|
+
"typescript": "^5.3.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/shared/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiWithBody } from "@intuitionrobotics/thunderstorm
|
|
1
|
+
import { ApiWithBody } from "@intuitionrobotics/thunderstorm";
|
|
2
2
|
import { Request_PushRegister, Request_ReadPush, Response_PushRegister } from "./types";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type PubSubRegisterClient = ApiWithBody<'/v1/push/register', Request_PushRegister, Response_PushRegister>;
|
|
4
|
+
export type PubSubReadNotification = ApiWithBody<'/v1/push/read', Request_ReadPush, void>;
|
package/shared/types.d.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { DB_Object } from "@intuitionrobotics/ts-common
|
|
2
|
-
export
|
|
1
|
+
import { DB_Object } from "@intuitionrobotics/ts-common";
|
|
2
|
+
export type SubscribeProps = {
|
|
3
3
|
[prop: string]: string | number;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type BaseSubscriptionData = {
|
|
6
6
|
props?: SubscribeProps;
|
|
7
7
|
pushKey: string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type SubscriptionData = BaseSubscriptionData & {
|
|
10
10
|
data?: any;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Request_PushRegister = FirebaseToken & PushSessionId & {
|
|
13
13
|
subscriptions: BaseSubscriptionData[];
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type Request_ReadPush = DB_Object & {
|
|
16
16
|
read: boolean;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type Response_PushRegister = DB_Notifications[];
|
|
19
|
+
export type DB_PushSession = FirebaseToken & PushSessionId & {
|
|
20
20
|
timestamp: number;
|
|
21
21
|
userId?: string;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type DB_Notifications = DB_Object & SubscriptionData & {
|
|
24
24
|
userId?: string;
|
|
25
25
|
timestamp: number;
|
|
26
26
|
read: boolean;
|
|
27
27
|
persistent?: boolean;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
30
|
-
export
|
|
29
|
+
export type DB_PushKeys = PushSessionId & BaseSubscriptionData;
|
|
30
|
+
export type FirebaseToken = {
|
|
31
31
|
firebaseToken: string;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type PushSessionId = {
|
|
34
34
|
pushSessionId: string;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
36
|
+
export type MessageType<S extends string, P extends SubscribeProps, D> = {};
|
|
37
|
+
export type IFP<Binder extends MessageType<any, any, any>> = Binder extends MessageType<infer S, any, any> ? S extends string ? S : never : never;
|
|
38
|
+
export type ISP<Binder extends MessageType<any, any, any>> = Binder extends MessageType<any, infer P, any> ? P extends SubscribeProps ? P : never : never;
|
|
39
|
+
export type ITP<Binder extends MessageType<any, any, any>> = Binder extends MessageType<any, any, infer D> ? D : never;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CollectionName_Tabs = exports.CollectionName_PushSubscribers = void 0;
|
|
4
|
-
exports.CollectionName_PushSubscribers = "push-pub-sub--subscribers";
|
|
5
|
-
exports.CollectionName_Tabs = "push-pub-sub--tabs";
|
|
6
|
-
//# sourceMappingURL=consts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,2BAA2B,CAAC;AAC7D,QAAA,mBAAmB,GAAG,oBAAoB,CAAC"}
|