@intuitionrobotics/push-pub-sub 0.47.58 → 1.0.0

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.
Files changed (107) hide show
  1. package/LICENSE +3 -0
  2. package/dist/app-backend/api/_push.d.ts +4 -0
  3. package/dist/app-backend/api/_push.d.ts.map +1 -0
  4. package/dist/app-backend/api/_push.js +3 -0
  5. package/dist/app-backend/api/_push.js.map +1 -0
  6. package/dist/app-backend/api/v1/push/read.d.ts +9 -0
  7. package/dist/app-backend/api/v1/push/read.d.ts.map +1 -0
  8. package/dist/app-backend/api/v1/push/read.js +15 -0
  9. package/dist/app-backend/api/v1/push/read.js.map +1 -0
  10. package/dist/app-backend/api/v1/push/register.d.ts +9 -0
  11. package/dist/app-backend/api/v1/push/register.d.ts.map +1 -0
  12. package/dist/app-backend/api/v1/push/register.js +15 -0
  13. package/dist/app-backend/api/v1/push/register.js.map +1 -0
  14. package/dist/app-backend/core/module-pack.d.ts +5 -0
  15. package/dist/app-backend/core/module-pack.d.ts.map +1 -0
  16. package/dist/app-backend/core/module-pack.js +10 -0
  17. package/dist/app-backend/core/module-pack.js.map +1 -0
  18. package/{app-backend → dist/app-backend}/modules/PushKey.d.ts +3 -2
  19. package/dist/app-backend/modules/PushKey.d.ts.map +1 -0
  20. package/dist/app-backend/modules/PushKey.js +16 -0
  21. package/dist/app-backend/modules/PushKey.js.map +1 -0
  22. package/{app-backend → dist/app-backend}/modules/PushPubSubModule.d.ts +5 -4
  23. package/dist/app-backend/modules/PushPubSubModule.d.ts.map +1 -0
  24. package/dist/app-backend/modules/PushPubSubModule.js +185 -0
  25. package/dist/app-backend/modules/PushPubSubModule.js.map +1 -0
  26. package/{app-backend → dist/app-backend}/modules/ScheduledPushCleanup.d.ts +1 -0
  27. package/dist/app-backend/modules/ScheduledPushCleanup.d.ts.map +1 -0
  28. package/dist/app-backend/modules/ScheduledPushCleanup.js +13 -0
  29. package/dist/app-backend/modules/ScheduledPushCleanup.js.map +1 -0
  30. package/{app-backend → dist/app-backend}/modules/_imports.d.ts +2 -1
  31. package/dist/app-backend/modules/_imports.d.ts.map +1 -0
  32. package/dist/app-backend/modules/_imports.js +4 -0
  33. package/{app-backend → dist/app-backend}/modules/_imports.js.map +1 -1
  34. package/dist/app-frontend/core/module-pack.d.ts +4 -0
  35. package/dist/app-frontend/core/module-pack.d.ts.map +1 -0
  36. package/dist/app-frontend/core/module-pack.js +11 -0
  37. package/dist/app-frontend/core/module-pack.js.map +1 -0
  38. package/{app-frontend → dist/app-frontend}/modules/NotificationModule.d.ts +2 -1
  39. package/dist/app-frontend/modules/NotificationModule.d.ts.map +1 -0
  40. package/dist/app-frontend/modules/NotificationModule.js +52 -0
  41. package/dist/app-frontend/modules/NotificationModule.js.map +1 -0
  42. package/{app-frontend → dist/app-frontend}/modules/PushPubSubModule.d.ts +2 -1
  43. package/dist/app-frontend/modules/PushPubSubModule.d.ts.map +1 -0
  44. package/dist/app-frontend/modules/PushPubSubModule.js +175 -0
  45. package/dist/app-frontend/modules/PushPubSubModule.js.map +1 -0
  46. package/dist/backend.d.ts +2 -0
  47. package/dist/backend.d.ts.map +1 -0
  48. package/dist/backend.js +2 -0
  49. package/dist/backend.js.map +1 -0
  50. package/dist/frontend.d.ts +4 -0
  51. package/dist/frontend.d.ts.map +1 -0
  52. package/dist/frontend.js +7 -0
  53. package/dist/frontend.js.map +1 -0
  54. package/dist/index.d.ts +3 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +3 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/shared/api.d.ts +5 -0
  59. package/dist/shared/api.d.ts.map +1 -0
  60. package/dist/shared/api.js +3 -0
  61. package/dist/shared/api.js.map +1 -0
  62. package/{shared → dist/shared}/types.d.ts +8 -4
  63. package/dist/shared/types.d.ts.map +1 -0
  64. package/dist/shared/types.js +2 -0
  65. package/dist/shared/types.js.map +1 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -0
  67. package/package.json +63 -14
  68. package/app-backend/api/_push.d.ts +0 -1
  69. package/app-backend/api/_push.js +0 -5
  70. package/app-backend/api/_push.js.map +0 -1
  71. package/app-backend/api/v1/push/read.d.ts +0 -1
  72. package/app-backend/api/v1/push/read.js +0 -27
  73. package/app-backend/api/v1/push/read.js.map +0 -1
  74. package/app-backend/api/v1/push/register.d.ts +0 -1
  75. package/app-backend/api/v1/push/register.js +0 -27
  76. package/app-backend/api/v1/push/register.js.map +0 -1
  77. package/app-backend/core/module-pack.d.ts +0 -4
  78. package/app-backend/core/module-pack.js +0 -27
  79. package/app-backend/core/module-pack.js.map +0 -1
  80. package/app-backend/modules/PushKey.js +0 -27
  81. package/app-backend/modules/PushKey.js.map +0 -1
  82. package/app-backend/modules/PushPubSubModule.js +0 -198
  83. package/app-backend/modules/PushPubSubModule.js.map +0 -1
  84. package/app-backend/modules/ScheduledPushCleanup.js +0 -26
  85. package/app-backend/modules/ScheduledPushCleanup.js.map +0 -1
  86. package/app-backend/modules/_imports.js +0 -21
  87. package/app-frontend/core/module-pack.d.ts +0 -3
  88. package/app-frontend/core/module-pack.js +0 -28
  89. package/app-frontend/core/module-pack.js.map +0 -1
  90. package/app-frontend/modules/NotificationModule.js +0 -55
  91. package/app-frontend/modules/NotificationModule.js.map +0 -1
  92. package/app-frontend/modules/PushPubSubModule.js +0 -184
  93. package/app-frontend/modules/PushPubSubModule.js.map +0 -1
  94. package/backend.d.ts +0 -1
  95. package/backend.js +0 -18
  96. package/backend.js.map +0 -1
  97. package/frontend.d.ts +0 -3
  98. package/frontend.js +0 -20
  99. package/frontend.js.map +0 -1
  100. package/index.d.ts +0 -2
  101. package/index.js +0 -19
  102. package/index.js.map +0 -1
  103. package/shared/api.d.ts +0 -4
  104. package/shared/api.js +0 -3
  105. package/shared/api.js.map +0 -1
  106. package/shared/types.js +0 -3
  107. package/shared/types.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuitionrobotics/push-pub-sub",
3
- "version": "0.47.58",
3
+ "version": "1.0.0",
4
4
  "description": "push-pub-sub",
5
5
  "keywords": [
6
6
  "IR",
@@ -17,22 +17,71 @@
17
17
  },
18
18
  "license": "Apache-2.0",
19
19
  "author": "IR",
20
- "main": "./index.js",
21
- "types": "./index.d.ts",
22
- "scripts": {
23
- "build": "tsc -p src/main/tsconfig.json --rootDir ./src/main --outDir dist",
24
- "lint": "tslint -p src/main/tsconfig.json"
25
- },
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
26
  "dependencies": {
27
- "@intuitionrobotics/firebase": "~0.47.0",
28
- "@intuitionrobotics/thunderstorm": "~0.47.0",
29
- "@intuitionrobotics/ts-common": "~0.47.0"
27
+ "@intuitionrobotics/firebase": "1.0.0",
28
+ "@intuitionrobotics/thunderstorm": "1.0.0",
29
+ "@intuitionrobotics/ts-common": "1.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@intuitionrobotics/testelot": "~0.47.0",
33
32
  "@types/node": "^20.0.0",
34
33
  "ts-node": "^8.6.2",
35
- "tslint": "^6.1.3",
36
- "typescript": "^5.3.0"
34
+ "typescript": "^5.3.0",
35
+ "@intuitionrobotics/testelot": "1.0.0"
36
+ },
37
+ "typesVersions": {
38
+ "*": {
39
+ "backend": [
40
+ "dist/backend"
41
+ ],
42
+ "frontend": [
43
+ "dist/frontend"
44
+ ],
45
+ "app-backend/*": [
46
+ "dist/app-backend/*"
47
+ ],
48
+ "app-frontend/*": [
49
+ "dist/app-frontend/*"
50
+ ],
51
+ "shared/*": [
52
+ "dist/shared/*"
53
+ ]
54
+ }
55
+ },
56
+ "exports": {
57
+ ".": {
58
+ "types": "./dist/index.d.ts",
59
+ "default": "./dist/index.js"
60
+ },
61
+ "./frontend": {
62
+ "types": "./dist/frontend.d.ts",
63
+ "default": "./dist/frontend.js"
64
+ },
65
+ "./backend": {
66
+ "types": "./dist/backend.d.ts",
67
+ "default": "./dist/backend.js"
68
+ },
69
+ "./app-frontend/*": {
70
+ "types": "./dist/app-frontend/*.d.ts",
71
+ "default": "./dist/app-frontend/*.js"
72
+ },
73
+ "./app-backend/*": {
74
+ "types": "./dist/app-backend/*.d.ts",
75
+ "default": "./dist/app-backend/*.js"
76
+ },
77
+ "./shared/*": {
78
+ "types": "./dist/shared/*.d.ts",
79
+ "default": "./dist/shared/*.js"
80
+ }
81
+ },
82
+ "sideEffects": false,
83
+ "scripts": {
84
+ "build": "tsc -b src/main/tsconfig.json",
85
+ "lint": "eslint src/main"
37
86
  }
38
- }
87
+ }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
4
- module.exports = new backend_1.RouteResolver(require, __dirname);
5
- //# sourceMappingURL=_push.js.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
13
- const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
14
- const PushPubSubModule_1 = require("../../../modules/PushPubSubModule");
15
- class ServerApi_PushRead extends backend_1.ServerApi {
16
- constructor() {
17
- super(thunderstorm_1.HttpMethod.POST, "read");
18
- }
19
- process(request, response, queryParams, body) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- // const user = await KasperoProxy.validateSession(request);
22
- return yield PushPubSubModule_1.PushPubSubModule.readNotification(body._id, body.read);
23
- });
24
- }
25
- }
26
- module.exports = new ServerApi_PushRead();
27
- //# sourceMappingURL=read.js.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
13
- const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
14
- const PushPubSubModule_1 = require("../../../modules/PushPubSubModule");
15
- class ServerApi_PushRegister extends backend_1.ServerApi {
16
- constructor() {
17
- super(thunderstorm_1.HttpMethod.POST, "register");
18
- }
19
- process(request, response, queryParams, body) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- // const user = await KasperoProxy.validateSession(request);
22
- return yield PushPubSubModule_1.PushPubSubModule.register(body, request);
23
- });
24
- }
25
- }
26
- module.exports = new ServerApi_PushRegister();
27
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
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,4 +0,0 @@
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,27 +0,0 @@
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.Backend_ModulePack_PushPubSub = void 0;
18
- const PushPubSubModule_1 = require("../modules/PushPubSubModule");
19
- const ScheduledPushCleanup_1 = require("../modules/ScheduledPushCleanup");
20
- exports.Backend_ModulePack_PushPubSub = [
21
- PushPubSubModule_1.PushPubSubModule,
22
- ScheduledPushCleanup_1.ScheduledCleanup
23
- ];
24
- __exportStar(require("../modules/PushPubSubModule"), exports);
25
- __exportStar(require("../modules/ScheduledPushCleanup"), exports);
26
- __exportStar(require("../modules/PushKey"), exports);
27
- //# sourceMappingURL=module-pack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-backend/core/module-pack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,kEAA6D;AAC7D,0EAAiE;AAEpD,QAAA,6BAA6B,GAAG;IAC5C,mCAAgB;IAChB,uCAAgB;CAChB,CAAC;AAEF,8DAA2C;AAC3C,kEAA+C;AAC/C,qDAAkC"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PushKey = void 0;
13
- const PushPubSubModule_1 = require("./PushPubSubModule");
14
- class PushKey {
15
- constructor(key, persist = false) {
16
- this.key = key;
17
- this.persist = persist;
18
- }
19
- push(data, props) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- return PushPubSubModule_1.PushPubSubModule.pushToKey(this.key, props, data, this.persist);
22
- });
23
- }
24
- ;
25
- }
26
- exports.PushKey = PushKey;
27
- //# sourceMappingURL=PushKey.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PushKey.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushKey.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,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,198 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PushPubSubModule = exports.PushPubSubModule_Class = void 0;
13
- const ts_common_1 = require("@intuitionrobotics/ts-common");
14
- const backend_1 = require("@intuitionrobotics/firebase/backend");
15
- const backend_2 = require("@intuitionrobotics/thunderstorm/backend");
16
- class PushPubSubModule_Class extends ts_common_1.Module {
17
- constructor() {
18
- super("PushPubSubModule");
19
- this.buildNotification = (pushkey, persistent, data, props, user) => {
20
- const notification = {
21
- _id: (0, ts_common_1.generateHex)(16),
22
- timestamp: (0, ts_common_1.currentTimeMillies)(),
23
- read: false,
24
- pushKey: pushkey,
25
- persistent
26
- };
27
- if (data)
28
- notification.data = data;
29
- if (props)
30
- notification.props = props;
31
- if (user)
32
- notification.userId = user;
33
- return notification;
34
- };
35
- this.sendMessage = (persistent, _messages) => __awaiter(this, void 0, void 0, function* () {
36
- const messages = Object.keys(_messages).map(token => ({ token, data: { messages: (0, ts_common_1.__stringify)(_messages[token]) } }));
37
- if (messages.length === 0)
38
- return;
39
- console.log("sending a message to \n" + Object.keys(_messages).join("\n"));
40
- const response = yield this.messaging.sendAll(messages);
41
- console.log("and this is the response: " + response.responses.map(_response => _response.success));
42
- return { response, messages };
43
- });
44
- this.readNotification = (id, read) => __awaiter(this, void 0, void 0, function* () {
45
- yield this.notifications.patch({ _id: id, read });
46
- });
47
- this.scheduledCleanup = () => __awaiter(this, void 0, void 0, function* () {
48
- var _a, _b;
49
- const sessionsCleanupTime = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionsCleanupTime) || ts_common_1.Hour;
50
- const notificationsCleanupTime = ((_b = this.config) === null || _b === void 0 ? void 0 : _b.notificationsCleanupTime) || 7 * ts_common_1.Day;
51
- const docs = yield this.pushSessions.query({ where: { timestamp: { $lt: (0, ts_common_1.currentTimeMillies)() - sessionsCleanupTime } } });
52
- yield Promise.all([
53
- this.notifications.delete({ where: { timestamp: { $lt: (0, ts_common_1.currentTimeMillies)() - notificationsCleanupTime } } }),
54
- this.cleanUpImpl(docs.map(d => d.firebaseToken))
55
- ]);
56
- });
57
- this.cleanUp = (response, messages) => __awaiter(this, void 0, void 0, function* () {
58
- this.logInfo(`${response.successCount} sent, ${response.failureCount} failed`);
59
- if (response.failureCount > 0)
60
- this.logWarning(response.responses.filter(r => r.error));
61
- const toDelete = response.responses.reduce((carry, resp, i) => {
62
- if (!resp.success && messages[i])
63
- carry.push(messages[i].token);
64
- return carry;
65
- }, []);
66
- //TODO: delete notifications for the user that are older than X
67
- return this.cleanUpImpl(toDelete);
68
- });
69
- }
70
- init() {
71
- const session = backend_1.FirebaseModule.createAdminSession();
72
- const firestore = session.getFirestore();
73
- this.pushSessions = firestore.getCollection("push-sessions", ["pushSessionId"]);
74
- this.pushKeys = firestore.getCollection("push-keys");
75
- this.notifications = firestore.getCollection("notifications", ["_id"]);
76
- this.messaging = session.getMessaging();
77
- }
78
- register(body, request) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- var _a, _b, _c;
81
- const resp = yield backend_2.dispatch_queryRequestInfo.dispatchModuleAsync(request);
82
- 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);
83
- // if (!userId)
84
- // throw new ImplementationMissingException("Missing user from accounts Module");
85
- const session = {
86
- firebaseToken: body.firebaseToken,
87
- pushSessionId: body.pushSessionId,
88
- timestamp: (0, ts_common_1.currentTimeMillies)()
89
- };
90
- if (userId)
91
- session.userId = userId;
92
- const subscriptions = body.subscriptions.map((s) => {
93
- const sub = {
94
- pushSessionId: body.pushSessionId,
95
- pushKey: s.pushKey
96
- };
97
- if (s.props)
98
- sub.props = s.props;
99
- return sub;
100
- });
101
- return this.pushSessions.runInTransaction((transaction) => __awaiter(this, void 0, void 0, function* () {
102
- const pushKeys = subscriptions.map(_sub => _sub.pushKey);
103
- let subscriptionNotifications = pushKeys.length !== 0 ?
104
- 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 } } }); })) : [];
105
- if (subscriptionNotifications.length > 0)
106
- subscriptionNotifications = subscriptionNotifications.filter(_notification => {
107
- var _a;
108
- const x = (_a = subscriptions.find(_sub => _sub.pushKey === _notification.pushKey)) === null || _a === void 0 ? void 0 : _a.props;
109
- return (0, ts_common_1.compare)(x, _notification.props) || _notification.userId;
110
- });
111
- const userNotifications = userId ? yield transaction.query(this.notifications, { where: { userId } }) : [];
112
- const notifications = userNotifications.concat(subscriptionNotifications);
113
- const writePush = yield transaction.upsert_Read(this.pushSessions, session);
114
- const write = yield transaction.delete_Read(this.pushKeys, { where: { pushSessionId: body.pushSessionId } });
115
- yield transaction.insertAll(this.pushKeys, subscriptions);
116
- yield Promise.all([write(), writePush()]);
117
- return (0, ts_common_1.filterDuplicates)(notifications);
118
- }));
119
- });
120
- }
121
- pushToKey(key_1, props_1, data_1) {
122
- return __awaiter(this, arguments, void 0, function* (key, props, data, persistent = false, transaction) {
123
- const processor = (_transaction) => __awaiter(this, void 0, void 0, function* () {
124
- console.log("i am pushing to key...", key, props, data);
125
- let docs = yield _transaction.query(this.pushKeys, { where: { pushKey: key } });
126
- if (props)
127
- docs = docs.filter(doc => !doc.props || (0, ts_common_1.compare)(doc.props, props));
128
- const notification = this.buildNotification(key, persistent, data, props);
129
- // If we need to do read and write for a transaction move this to a callback and rename to pushToKey_Read
130
- if (persistent) {
131
- yield this.notifications.insertAll([notification]);
132
- }
133
- if (docs.length === 0)
134
- return;
135
- const sessionsIds = docs.map(d => d.pushSessionId);
136
- // I get the tokens relative to those sessions (query)
137
- 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 } } }); }));
138
- const _messages = docs.reduce((carry, db_pushKey) => {
139
- const session = sessions.find(s => s.pushSessionId === db_pushKey.pushSessionId);
140
- if (!session)
141
- return carry;
142
- carry[session.firebaseToken] = [notification];
143
- return carry;
144
- }, {});
145
- const resp = yield this.sendMessage(persistent, _messages);
146
- if (!resp)
147
- return this.logInfo('No messages to send. Empty subscriptions');
148
- const { response, messages } = resp;
149
- this.logInfo(`${response.successCount} sent, ${response.failureCount} failed`, "messages", messages);
150
- // return this.cleanUp(response, messages);
151
- });
152
- if (transaction)
153
- return processor(transaction);
154
- return this.pushKeys.runInTransaction(processor);
155
- });
156
- }
157
- pushToUser(user_1, key_1, props_1, data_1) {
158
- return __awaiter(this, arguments, void 0, function* (user, key, props, data, persistent = false) {
159
- console.log("i am pushing to user...", user, props);
160
- const notification = this.buildNotification(key, persistent, data, props, user);
161
- const notifications = [];
162
- if (persistent) {
163
- notifications.push(notification);
164
- yield this.notifications.insertAll(notifications);
165
- }
166
- const docs = yield this.pushSessions.query({ where: { userId: user } });
167
- if (docs.length === 0)
168
- return;
169
- const sessionsIds = docs.map(d => d.pushSessionId);
170
- 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 } } }); }));
171
- const _messages = docs.reduce((carry, db_pushKey) => {
172
- const session = sessions.find(s => s.pushSessionId === db_pushKey.pushSessionId);
173
- if (!session)
174
- return carry;
175
- carry[session.firebaseToken] = [notification];
176
- return carry;
177
- }, {});
178
- yield this.sendMessage(persistent, _messages);
179
- });
180
- }
181
- cleanUpImpl(_toDelete) {
182
- return __awaiter(this, void 0, void 0, function* () {
183
- if (_toDelete.length === 0)
184
- return;
185
- const toDelete = (0, ts_common_1.filterDuplicates)(_toDelete);
186
- 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 } } }); }));
187
- const sessions = (0, ts_common_1.filterDuplicates)(_sessions.map(s => s.pushSessionId));
188
- const async = [
189
- (0, ts_common_1.batchActionParallel)(toDelete, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushSessions.delete({ where: { firebaseToken: { $in: elements } } }); })),
190
- (0, ts_common_1.batchActionParallel)(sessions, 10, (elements) => __awaiter(this, void 0, void 0, function* () { return this.pushKeys.delete({ where: { pushSessionId: { $in: elements } } }); }))
191
- ];
192
- yield Promise.all(async);
193
- });
194
- }
195
- }
196
- exports.PushPubSubModule_Class = PushPubSubModule_Class;
197
- exports.PushPubSubModule = new PushPubSubModule_Class();
198
- //# sourceMappingURL=PushPubSubModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PushPubSubModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/PushPubSubModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4DAYsC;AAEtC,iEAO6C;AAa7C,qEAGiD;AAWjD,MAAa,sBACZ,SAAQ,kBAAc;IAEtB;QACC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAkJnB,sBAAiB,GAAG,CAAC,OAAe,EAAE,UAAmB,EAAE,IAAU,EAAE,KAAW,EAAE,IAAa,EAAE,EAAE;YAC5G,MAAM,YAAY,GAAqB;gBACtC,GAAG,EAAE,IAAA,uBAAW,EAAC,EAAE,CAAC;gBACpB,SAAS,EAAE,IAAA,8BAAkB,GAAE;gBAC/B,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,OAAO;gBAChB,UAAU;aACV,CAAC;YAEF,IAAI,IAAI;gBACP,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;YAE1B,IAAI,KAAK;gBACR,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;YAE5B,IAAI,IAAI;gBACP,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC;YAE5B,OAAO,YAAY,CAAC;QACrB,C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AAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;YACvE,MAAM,KAAK,GAAmB;gBAC7B,IAAA,+BAAmB,EAAC,QAAQ,EAAE,EAAE,EAAE,CAAM,QAAQ,EAAC,EAAE,gDAAC,OAAA,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAC,KAAK,EAAE,EAAC,aAAa,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC,EAAC,EAAC,CAAC,CAAA,GAAA,CAAC;gBACxH,IAAA,+BAAmB,EAAC,QAAQ,EAAE,EAAE,EAAE,CAAM,QAAQ,EAAC,EAAE,gDAAC,OAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAC,KAAK,EAAE,EAAC,aAAa,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC,EAAC,EAAC,CAAC,CAAA,GAAA,CAAC;aACpH,CAAC;YAEF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;KAAA;CACD;AArOD,wDAqOC;AAEY,QAAA,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ScheduledCleanup = exports.ScheduledCleanup_Class = void 0;
13
- const backend_functions_1 = require("@intuitionrobotics/firebase/backend-functions");
14
- const PushPubSubModule_1 = require("./PushPubSubModule");
15
- class ScheduledCleanup_Class extends backend_functions_1.FirebaseScheduledFunction {
16
- constructor() {
17
- super("ScheduledCleanup");
18
- this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
19
- return PushPubSubModule_1.PushPubSubModule.scheduledCleanup();
20
- });
21
- this.setSchedule('every 1 hours');
22
- }
23
- }
24
- exports.ScheduledCleanup_Class = ScheduledCleanup_Class;
25
- exports.ScheduledCleanup = new ScheduledCleanup_Class();
26
- //# sourceMappingURL=ScheduledPushCleanup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScheduledPushCleanup.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ScheduledPushCleanup.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,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"}
@@ -1,21 +0,0 @@
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
@@ -1,3 +0,0 @@
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,28 +0,0 @@
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.Frontend_ModulePack_PushPubSub = void 0;
18
- const PushPubSubModule_1 = require("../modules/PushPubSubModule");
19
- const frontend_1 = require("@intuitionrobotics/firebase/frontend");
20
- const NotificationModule_1 = require("../modules/NotificationModule");
21
- exports.Frontend_ModulePack_PushPubSub = [
22
- frontend_1.FirebaseModule,
23
- PushPubSubModule_1.PushPubSubModule,
24
- NotificationModule_1.NotificationsModule
25
- ];
26
- __exportStar(require("../modules/PushPubSubModule"), exports);
27
- __exportStar(require("../modules/NotificationModule"), exports);
28
- //# sourceMappingURL=module-pack.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,kEAA6D;AAC7D,mEAAoE;AACpE,sEAAkE;AAErD,QAAA,8BAA8B,GAAG;IAC7C,yBAAc;IACd,mCAAgB;IAChB,wCAAmB;CACnB,CAAC;AAEF,8DAA4C;AAC5C,gEAA8C"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotificationsModule = exports.NotificationsModule_Class = exports.dispatch_NotificationsUpdated = void 0;
4
- const thunder_dispatcher_1 = require("@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher");
5
- const ts_common_1 = require("@intuitionrobotics/ts-common");
6
- const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
7
- const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
8
- exports.dispatch_NotificationsUpdated = new thunder_dispatcher_1.ThunderDispatcher('__onNotificationsUpdated');
9
- class NotificationsModule_Class extends ts_common_1.Module {
10
- constructor() {
11
- super("NotificationsModule");
12
- this.notifications = [];
13
- this.setNotificationList = (notifications) => {
14
- this.notifications = notifications;
15
- exports.dispatch_NotificationsUpdated.dispatchUI();
16
- };
17
- this.read = (notification, read) => {
18
- const readNotification = this.notifications.find(_notification => _notification._id === notification._id);
19
- if (!readNotification || !readNotification.persistent)
20
- return;
21
- readNotification.read = read;
22
- this.readNotification(notification._id, read);
23
- };
24
- this.readNotification = (id, read) => {
25
- const body = {
26
- _id: id,
27
- read
28
- };
29
- frontend_1.XhrHttpModule
30
- .createRequest(thunderstorm_1.HttpMethod.POST, 'read-notification')
31
- .setRelativeUrl("/v1/push/read")
32
- .setJsonBody(body)
33
- .setOnError('Something went wrong while reading your notification')
34
- .setTimeout(ts_common_1.Minute)
35
- .execute(() => {
36
- exports.dispatch_NotificationsUpdated.dispatchUI();
37
- });
38
- };
39
- }
40
- getNotifications() {
41
- return this.notifications;
42
- }
43
- addNotification(newNotification) {
44
- this.notifications.push(newNotification);
45
- exports.dispatch_NotificationsUpdated.dispatchUI();
46
- }
47
- removeNotification(notification) {
48
- (0, ts_common_1.removeItemFromArray)(this.notifications, notification);
49
- exports.dispatch_NotificationsUpdated.dispatchUI();
50
- return notification._id;
51
- }
52
- }
53
- exports.NotificationsModule_Class = NotificationsModule_Class;
54
- exports.NotificationsModule = new NotificationsModule_Class();
55
- //# sourceMappingURL=NotificationModule.js.map
@@ -1 +0,0 @@
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;QAC5C,CAAC,CAAC;QAaF,SAAI,GAAG,CAAC,YAA8B,EAAE,IAAa,EAAE,EAAE;YACxD,MAAM,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,CAAC,CAAC;YAC1G,IAAI,CAAC,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,UAAU;gBACpD,OAAO;YAER,gBAAgB,CAAC,IAAI,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEF,qBAAgB,GA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