@rocketmakers/orbit-notify-firebase 2.0.4 → 3.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 (64) hide show
  1. package/README.md +2 -2
  2. package/lib/config/environment.generated.js +5 -1
  3. package/lib/config/environment.generated.js.map +1 -1
  4. package/lib/ioc/register.d.ts +2 -2
  5. package/lib/ioc/register.d.ts.map +1 -1
  6. package/lib/ioc/register.js +18 -22
  7. package/lib/ioc/register.js.map +1 -1
  8. package/lib/ioc/types.d.ts +1 -1
  9. package/lib/ioc/types.d.ts.map +1 -1
  10. package/lib/services/firebaseService.d.ts +2 -18
  11. package/lib/services/firebaseService.d.ts.map +1 -1
  12. package/lib/services/firebaseService.js +51 -57
  13. package/lib/services/firebaseService.js.map +1 -1
  14. package/lib/services/index.d.ts +1 -0
  15. package/lib/services/index.d.ts.map +1 -1
  16. package/lib/services/index.js +1 -0
  17. package/lib/services/index.js.map +1 -1
  18. package/lib/services/types.d.ts +19 -0
  19. package/lib/services/types.d.ts.map +1 -0
  20. package/lib/services/types.js +3 -0
  21. package/lib/services/types.js.map +1 -0
  22. package/lib/validation/index.d.ts +1 -1
  23. package/lib/validation/index.d.ts.map +1 -1
  24. package/lib/validation/index.js +12 -15
  25. package/lib/validation/index.js.map +1 -1
  26. package/package.json +33 -36
  27. package/lib/_tests_/manualTest/index.test.d.ts +0 -2
  28. package/lib/_tests_/manualTest/index.test.d.ts.map +0 -1
  29. package/lib/_tests_/manualTest/index.test.js +0 -7
  30. package/lib/_tests_/manualTest/index.test.js.map +0 -1
  31. package/lib/_tests_/manualTest/sendNotification.d.ts +0 -2
  32. package/lib/_tests_/manualTest/sendNotification.d.ts.map +0 -1
  33. package/lib/_tests_/manualTest/sendNotification.js +0 -47
  34. package/lib/_tests_/manualTest/sendNotification.js.map +0 -1
  35. package/lib/_tests_/manualTest/serviceInstance.d.ts +0 -9
  36. package/lib/_tests_/manualTest/serviceInstance.d.ts.map +0 -1
  37. package/lib/_tests_/manualTest/serviceInstance.js +0 -26
  38. package/lib/_tests_/manualTest/serviceInstance.js.map +0 -1
  39. package/lib/_tests_/unit/validation/index.test.d.ts +0 -2
  40. package/lib/_tests_/unit/validation/index.test.d.ts.map +0 -1
  41. package/lib/_tests_/unit/validation/index.test.js +0 -7
  42. package/lib/_tests_/unit/validation/index.test.js.map +0 -1
  43. package/lib/_tests_/unit/validation/mockedService.d.ts +0 -13
  44. package/lib/_tests_/unit/validation/mockedService.d.ts.map +0 -1
  45. package/lib/_tests_/unit/validation/mockedService.js +0 -20
  46. package/lib/_tests_/unit/validation/mockedService.js.map +0 -1
  47. package/lib/_tests_/unit/validation/sendNotification.d.ts +0 -2
  48. package/lib/_tests_/unit/validation/sendNotification.d.ts.map +0 -1
  49. package/lib/_tests_/unit/validation/sendNotification.js +0 -39
  50. package/lib/_tests_/unit/validation/sendNotification.js.map +0 -1
  51. package/lib/_tests_/validation/index.test.d.ts +0 -2
  52. package/lib/_tests_/validation/index.test.d.ts.map +0 -1
  53. package/lib/_tests_/validation/index.test.js +0 -7
  54. package/lib/_tests_/validation/index.test.js.map +0 -1
  55. package/lib/_tests_/validation/mockedService.d.ts +0 -14
  56. package/lib/_tests_/validation/mockedService.d.ts.map +0 -1
  57. package/lib/_tests_/validation/mockedService.js +0 -20
  58. package/lib/_tests_/validation/mockedService.js.map +0 -1
  59. package/lib/_tests_/validation/sendNotification.d.ts +0 -2
  60. package/lib/_tests_/validation/sendNotification.d.ts.map +0 -1
  61. package/lib/_tests_/validation/sendNotification.js +0 -39
  62. package/lib/_tests_/validation/sendNotification.js.map +0 -1
  63. package/lib/environment.json +0 -11
  64. package/lib/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -42,6 +42,6 @@ Hosted docs covering types, interfaces and the `firebaseService` within this pac
42
42
 
43
43
  Source code for this package can be found using the link below:
44
44
 
45
- [Source code](https://gitlab.com/rocketmakers/microservices/orbit-packages/-/tree/develop/packages/notify/orbit-notify-firebase)
45
+ [Source code](https://gitlab.com/rocketmakers/core/orbit/-/tree/develop/packages/notify/orbit-notify-firebase)
46
46
 
47
- Contributing docs can be found in the [README.md](https://gitlab.com/rocketmakers/microservices/orbit-packages/-/blob/develop/README.md)
47
+ Contributing docs can be found in the [README.md](https://gitlab.com/rocketmakers/core/orbit/-/blob/develop/README.md)
@@ -4,7 +4,12 @@ exports.FirebaseEnvironment = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const environment_1 = require("@rocketmakers/environment");
6
6
  class FirebaseEnvironment {
7
+ firebaseClientEmail;
8
+ firebasePrivateKey;
9
+ firebaseProjectId;
10
+ rootTemplateRepoUrl;
7
11
  }
12
+ exports.FirebaseEnvironment = FirebaseEnvironment;
8
13
  tslib_1.__decorate([
9
14
  environment_1.environmentVariable.string('FIREBASE_CLIENT_EMAIL'),
10
15
  tslib_1.__metadata("design:type", String)
@@ -21,5 +26,4 @@ tslib_1.__decorate([
21
26
  environment_1.environmentVariable.string('ROOT_TEMPLATE_REPO_URL'),
22
27
  tslib_1.__metadata("design:type", String)
23
28
  ], FirebaseEnvironment.prototype, "rootTemplateRepoUrl", void 0);
24
- exports.FirebaseEnvironment = FirebaseEnvironment;
25
29
  //# sourceMappingURL=environment.generated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.generated.js","sourceRoot":"","sources":["../../src/config/environment.generated.ts"],"names":[],"mappings":";;;;AAKA,2DAAgE;AAEhE,MAAa,mBAAmB;CAa/B;AAVG;IADC,iCAAmB,CAAC,MAAM,CAAC,uBAAuB,CAAC;;gEACvB;AAG7B;IADC,iCAAmB,CAAC,MAAM,CAAC,sBAAsB,CAAC;;+DACvB;AAG5B;IADC,iCAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC;;8DACvB;AAG3B;IADC,iCAAmB,CAAC,MAAM,CAAC,wBAAwB,CAAC;;gEACxB;AAZjC,kDAaC"}
1
+ {"version":3,"file":"environment.generated.js","sourceRoot":"","sources":["../../src/config/environment.generated.ts"],"names":[],"mappings":";;;;AAKA,2DAAgE;AAEhE,MAAa,mBAAmB;IAG5B,mBAAmB,CAAU;IAG7B,kBAAkB,CAAU;IAG5B,iBAAiB,CAAU;IAG3B,mBAAmB,CAAU;CAChC;AAbD,kDAaC;AAVG;IADC,iCAAmB,CAAC,MAAM,CAAC,uBAAuB,CAAC;;gEACvB;AAG7B;IADC,iCAAmB,CAAC,MAAM,CAAC,sBAAsB,CAAC;;+DACvB;AAG5B;IADC,iCAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC;;8DACvB;AAG3B;IADC,iCAAmB,CAAC,MAAM,CAAC,wBAAwB,CAAC;;gEACxB"}
@@ -1,8 +1,8 @@
1
1
  import { IContainer } from '@rocketmakers/ioc';
2
2
  import { ICoreContainerTypes } from '@rocketmakers/orbit-core';
3
3
  import { TemplateServiceIoC } from '@rocketmakers/orbit-template-service';
4
- import { IServicesContainerTypes } from './types';
5
- declare type ServiceName = 'firebase';
4
+ import type { IServicesContainerTypes } from './types';
5
+ type ServiceName = 'firebase';
6
6
  export declare function registerFirebaseIoC(container: IContainer<ICoreContainerTypes>): Promise<IContainer<IServicesContainerTypes & TemplateServiceIoC<ServiceName>>>;
7
7
  export {};
8
8
  //# sourceMappingURL=register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/ioc/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAY,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAA8B,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAItG,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD,aAAK,WAAW,GAAG,UAAU,CAAC;AAqC9B,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,UAAU,CAAC,mBAAmB,CAAC,GACzC,OAAO,CAAC,UAAU,CAAC,uBAAuB,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CA4BhF"}
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/ioc/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAY,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAA8B,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAItG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,KAAK,WAAW,GAAG,UAAU,CAAC;AAqC9B,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,UAAU,CAAC,mBAAmB,CAAC,GACzC,OAAO,CAAC,UAAU,CAAC,uBAAuB,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CA4BhF"}
@@ -1,31 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerFirebaseIoC = void 0;
4
- const tslib_1 = require("tslib");
3
+ exports.registerFirebaseIoC = registerFirebaseIoC;
5
4
  const environment_1 = require("@rocketmakers/environment");
6
5
  const ioc_1 = require("@rocketmakers/ioc");
7
6
  const orbit_template_http_repository_1 = require("@rocketmakers/orbit-template-http-repository");
8
7
  const orbit_template_service_1 = require("@rocketmakers/orbit-template-service");
9
8
  const config_1 = require("../config");
10
- const services_1 = require("../services");
11
- function registerFirebaseIoC(container) {
12
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- const env = yield (0, environment_1.readFromEnvironment)(config_1.FirebaseEnvironment);
14
- const serviceName = 'firebase';
15
- const templateRepoContainer = yield (0, orbit_template_http_repository_1.registerTemplateRepositoryIoC)(serviceName, container);
16
- const templateServicesContainer = (0, orbit_template_service_1.registerTemplateServiceIoC)(serviceName, templateRepoContainer);
17
- const { firebaseClientEmail, firebasePrivateKey, firebaseProjectId } = env;
18
- return (0, ioc_1.register)({
19
- firebaseNotifyConfig: builder => builder.constant({
20
- client_email: firebaseClientEmail,
21
- private_key: firebasePrivateKey,
22
- project_id: firebaseProjectId,
23
- }),
24
- firebaseService: builder => builder
25
- .class(services_1.FirebaseService, ['firebaseTemplateService', 'firebaseNotifyConfig', 'logger'])
26
- .inSingletonScope(),
27
- }, templateServicesContainer);
28
- });
9
+ const firebaseService_1 = require("../services/firebaseService");
10
+ async function registerFirebaseIoC(container) {
11
+ const env = await (0, environment_1.readFromEnvironment)(config_1.FirebaseEnvironment);
12
+ const serviceName = 'firebase';
13
+ const templateRepoContainer = await (0, orbit_template_http_repository_1.registerTemplateRepositoryIoC)(serviceName, container);
14
+ const templateServicesContainer = (0, orbit_template_service_1.registerTemplateServiceIoC)(serviceName, templateRepoContainer);
15
+ const { firebaseClientEmail, firebasePrivateKey, firebaseProjectId } = env;
16
+ return (0, ioc_1.register)({
17
+ firebaseNotifyConfig: builder => builder.constant({
18
+ client_email: firebaseClientEmail,
19
+ private_key: firebasePrivateKey,
20
+ project_id: firebaseProjectId,
21
+ }),
22
+ firebaseService: builder => builder
23
+ .class(firebaseService_1.FirebaseService, ['firebaseTemplateService', 'firebaseNotifyConfig', 'logger'])
24
+ .inSingletonScope(),
25
+ }, templateServicesContainer);
29
26
  }
30
- exports.registerFirebaseIoC = registerFirebaseIoC;
31
27
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/ioc/register.ts"],"names":[],"mappings":";;;;AAAA,2DAAgE;AAChE,2CAAyD;AAEzD,iGAA6F;AAC7F,iFAAsG;AAEtG,sCAAgD;AAChD,0CAA8C;AAwC9C,SAAsB,mBAAmB,CACvC,SAA0C;;QAE1C,MAAM,GAAG,GAAG,MAAM,IAAA,iCAAmB,EAAC,4BAAmB,CAAC,CAAC;QAE3D,MAAM,WAAW,GAAgB,UAAU,CAAC;QAE5C,MAAM,qBAAqB,GAAG,MAAM,IAAA,8DAA6B,EAAC,WAAW,EAAE,SAAS,CAAC,C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CAC9B,OAAO,CAAC,QAAQ,CAAC;YACf,YAAY,EAAE,mBAAmB;YACjC,WAAW,EAAE,kBAAkB;YAC/B,UAAU,EAAE,iBAAiB;SAC9B,CAAC;QAEJ,eAAe,EAAE,OAAO,CAAC,EAAE,CACzB,OAAO;aACJ,KAAK,CAAC,iCAAe,EAAE,CAAC,yBAAyB,EAAE,sBAAsB,EAAE,QAAQ,CAAC,CAAC;aACrF,gBAAgB,EAAE;KACxB,EACD,yBAAyB,CAC1B,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IGoogleServiceAccount } from '..';
1
+ import { IGoogleServiceAccount } from '../config';
2
2
  import { FirebaseService } from '../services';
3
3
  export interface IServicesContainerTypes {
4
4
  firebaseNotifyConfig: IGoogleServiceAccount;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ioc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,uBAAuB;IAEtC,oBAAoB,EAAE,qBAAqB,CAAC;IAG5C,eAAe,EAAE,eAAe,CAAC;CAClC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ioc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,uBAAuB;IAEtC,oBAAoB,EAAE,qBAAqB,CAAC;IAG5C,eAAe,EAAE,eAAe,CAAC;CAClC"}
@@ -1,25 +1,9 @@
1
- /// <reference types="bunyan" />
2
1
  import { Logger } from '@rocketmakers/log';
3
2
  import { IOrbitResponse } from '@rocketmakers/orbit-core';
4
3
  import { ILayoutNotFound, ITemplateNotFound } from '@rocketmakers/orbit-template-core';
5
4
  import { TemplateService } from '@rocketmakers/orbit-template-service';
6
- import { IGoogleServiceAccount } from '..';
7
- export declare namespace FirebaseServiceParams {
8
- interface ISendNotification<TPayloadData> {
9
- firebaseDeviceToken: string;
10
- layoutId: string;
11
- templateName: string;
12
- payload: IFirebasePayload<TPayloadData>;
13
- }
14
- }
15
- export interface IFirebasePayload<TPayloadData> {
16
- data: TPayloadData;
17
- title?: string;
18
- imageUrl?: string;
19
- }
20
- export interface IFirebaseService {
21
- sendNotification<TPayloadData>(params: FirebaseServiceParams.ISendNotification<TPayloadData>): IOrbitResponse<boolean, ITemplateNotFound | ILayoutNotFound>;
22
- }
5
+ import { IGoogleServiceAccount } from '../config';
6
+ import { FirebaseServiceParams, IFirebaseService } from './types';
23
7
  export declare class FirebaseService implements IFirebaseService {
24
8
  private templateService;
25
9
  private serviceAccount;
@@ -1 +1 @@
1
- {"version":3,"file":"firebaseService.d.ts","sourceRoot":"","sources":["../../src/services/firebaseService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAwC,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAY,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGvE,OAAO,EAAE,qBAAqB,EAAc,MAAM,IAAI,CAAC;AAEvD,yBAAiB,qBAAqB,CAAC;IACrC,UAAiB,iBAAiB,CAAC,YAAY;QAC7C,mBAAmB,EAAE,MAAM,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;KACzC;CACF;AAED,MAAM,WAAW,gBAAgB,CAAC,YAAY;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACn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,MAAM,EAAE,MAAM,EACd,cAAc,UAAQ;IAqBnB,gBAAgB,CAAC,YAAY,EACxC,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAC5D,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC;CAyEhE"}
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FirebaseService = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const orbit_core_1 = require("@rocketmakers/orbit-core");
6
- const FirebaseAdmin = require("firebase-admin");
7
- const __1 = require("..");
6
+ const FirebaseAdmin = tslib_1.__importStar(require("firebase-admin"));
7
+ const validation_1 = require("../validation");
8
8
  class FirebaseService {
9
+ templateService;
10
+ serviceAccount;
11
+ logger;
12
+ isTestInstance;
13
+ app;
9
14
  constructor(templateService, serviceAccount, logger, isTestInstance = false) {
10
15
  this.templateService = templateService;
11
16
  this.serviceAccount = serviceAccount;
@@ -24,70 +29,59 @@ class FirebaseService {
24
29
  this.app = 'TEST_INIT_APP';
25
30
  }
26
31
  }
27
- sendNotification(params) {
28
- var _a;
29
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
- const { firebaseDeviceToken, layoutId, templateName, payload } = params;
31
- const { validatedDeviceToken, validatedLayoutId, validatedTemplateName, validatedPayload } = yield __1.Validation.sendNotification(firebaseDeviceToken, layoutId, templateName, payload);
32
- const templatesResponse = yield this.templateService.renderLayoutTemplates(validatedLayoutId, validatedPayload.data);
33
- if (templatesResponse.kind !== 'ok') {
34
- return templatesResponse;
35
- }
36
- const txtNotification = (_a = templatesResponse.result.find(template => template.name === validatedTemplateName)) === null || _a === void 0 ? void 0 : _a.compiled;
37
- if (!txtNotification) {
38
- return (0, orbit_core_1.buildNotFoundResponse)('Template', this.logger, `Failed to find Firebase txt template for layout: ${layoutId}`);
39
- }
40
- const notification = {
41
- title: validatedPayload.title,
42
- body: txtNotification,
43
- imageUrl: validatedPayload.imageUrl,
44
- };
45
- let firebaseMessaging;
46
- try {
47
- firebaseMessaging = this.app.messaging();
48
- const result = yield firebaseMessaging.sendAll([
49
- {
50
- token: validatedDeviceToken,
51
- notification,
52
- data: {
53
- event: JSON.stringify(notification),
54
- payload: JSON.stringify(validatedPayload),
55
- },
56
- },
57
- ]);
58
- const errors = [];
59
- if (result.responses) {
60
- for (let i = 0; i < result.responses.length; i += 1) {
61
- const response = result.responses[i];
62
- if (!response.success) {
63
- if (response.error &&
64
- (response.error.code === 'messaging/invalid-registration-token' ||
65
- response.error.code === 'messaging/registration-token-not-registered' ||
66
- response.error.code === 'messaging/mismatched-credential')) {
67
- this.logger.info('Removed contact device token');
68
- }
69
- errors.push(`${validatedDeviceToken}: ${JSON.stringify(response.error)}`);
70
- }
32
+ async sendNotification(params) {
33
+ const { firebaseDeviceToken, layoutId, templateName, payload } = params;
34
+ const { validatedDeviceToken, validatedLayoutId, validatedTemplateName, validatedPayload } = await validation_1.Validation.sendNotification(firebaseDeviceToken, layoutId, templateName, payload);
35
+ const templatesResponse = await this.templateService.renderLayoutTemplates(validatedLayoutId, validatedPayload.data);
36
+ if (templatesResponse.kind !== 'ok') {
37
+ return templatesResponse;
38
+ }
39
+ const txtNotification = templatesResponse.result.find(template => template.name === validatedTemplateName)?.compiled;
40
+ if (!txtNotification) {
41
+ return (0, orbit_core_1.buildNotFoundResponse)('Template', this.logger, `Failed to find Firebase txt template for layout: ${layoutId}`);
42
+ }
43
+ const notification = {
44
+ title: validatedPayload.title,
45
+ body: txtNotification,
46
+ imageUrl: validatedPayload.imageUrl,
47
+ };
48
+ const firebaseMessaging = this.app.messaging();
49
+ const result = await firebaseMessaging.sendEach([
50
+ {
51
+ token: validatedDeviceToken,
52
+ notification,
53
+ data: {
54
+ event: JSON.stringify(notification),
55
+ payload: JSON.stringify(validatedPayload),
56
+ },
57
+ },
58
+ ]);
59
+ const errors = [];
60
+ if (result.responses) {
61
+ for (let i = 0; i < result.responses.length; i += 1) {
62
+ const response = result.responses[i];
63
+ if (!response.success) {
64
+ if (response.error &&
65
+ (response.error.code === 'messaging/invalid-registration-token' ||
66
+ response.error.code === 'messaging/registration-token-not-registered' ||
67
+ response.error.code === 'messaging/mismatched-credential')) {
68
+ this.logger.info('Removed contact device token');
71
69
  }
70
+ errors.push(`${validatedDeviceToken}: ${JSON.stringify(response.error)}`);
72
71
  }
73
- if (errors && errors.length > 0) {
74
- throw new Error(JSON.stringify(errors));
75
- }
76
- return { kind: 'ok', result: true };
77
72
  }
78
- finally {
79
- if (firebaseMessaging) {
80
- yield firebaseMessaging.app.delete();
81
- }
82
- }
83
- });
73
+ }
74
+ if (errors && errors.length > 0) {
75
+ throw new Error(JSON.stringify(errors));
76
+ }
77
+ return { kind: 'ok', result: true };
84
78
  }
85
79
  }
80
+ exports.FirebaseService = FirebaseService;
86
81
  tslib_1.__decorate([
87
82
  orbit_core_1.ensureNoError,
88
83
  tslib_1.__metadata("design:type", Function),
89
84
  tslib_1.__metadata("design:paramtypes", [Object]),
90
85
  tslib_1.__metadata("design:returntype", Object)
91
86
  ], FirebaseService.prototype, "sendNotification", null);
92
- exports.FirebaseService = FirebaseService;
93
87
  //# sourceMappingURL=firebaseService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebaseService.js","sourceRoot":"","sources":["../../src/services/firebaseService.ts"],"names":[],"mappings":";;;;AACA,yDAAgG;AAGhG,gDAAgD;AAEhD,0BAAuD;AA4BvD,MAAa,eAAe;IAG1B,YACU,eAAgC,EAChC,cAAqC,EACrC,MAAc,EACd,iBAAiB,KAAK;QAHtB,oBAAe,GAAf,eAAe,CAAiB;QAChC,mBAAc,GAAd,cAAc,CAAuB;QACrC,WAAM,GAAN,MAAM,CAAQ;QACd,mBAAc,GAAd,cAAc,CAAQ;QAE9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,CAAC,GAAG,GAAG,aAAa,CAAC,aAAa,CAAC;gBACrC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,IAAI,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AAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpD,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAErC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;oBACtB,IACE,QAAQ,CAAC,KAAK;wBACd,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,sCAAsC;4BAC7D,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,6CAA6C;4BACrE,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,iCAAiC,CAAC,EAC5D,CAAC;wBACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;oBACnD,CAAC;oBAED,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC;QACH,CAAC;QAGD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACtC,CAAC;CACF;AAvGD,0CAuGC;AA3Ec;IADZ,0BAAa;;;;uDA2Eb"}
@@ -1,2 +1,3 @@
1
1
  export * from './firebaseService';
2
+ export * from './types';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
@@ -2,4 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./firebaseService"), exports);
5
+ tslib_1.__exportStar(require("./types"), exports);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,kDAAwB"}
@@ -0,0 +1,19 @@
1
+ import { IOrbitResponse } from '@rocketmakers/orbit-core';
2
+ import { ILayoutNotFound, ITemplateNotFound } from '@rocketmakers/orbit-template-core';
3
+ export declare namespace FirebaseServiceParams {
4
+ interface ISendNotification<TPayloadData> {
5
+ firebaseDeviceToken: string;
6
+ layoutId: string;
7
+ templateName: string;
8
+ payload: IFirebasePayload<TPayloadData>;
9
+ }
10
+ }
11
+ export interface IFirebasePayload<TPayloadData> {
12
+ data: TPayloadData;
13
+ title?: string;
14
+ imageUrl?: string;
15
+ }
16
+ export interface IFirebaseService {
17
+ sendNotification<TPayloadData>(params: FirebaseServiceParams.ISendNotification<TPayloadData>): IOrbitResponse<boolean, ITemplateNotFound | ILayoutNotFound>;
18
+ }
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEvF,yBAAiB,qBAAqB,CAAC;IACrC,UAAiB,iBAAiB,CAAC,YAAY;QAC7C,mBAAmB,EAAE,MAAM,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;KACzC;CACF;AAED,MAAM,WAAW,gBAAgB,CAAC,YAAY;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAM/B,gBAAgB,CAAC,YAAY,EAC3B,MAAM,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,YAAY,CAAC,GAC5D,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC;CACjE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { LayoutId } from '@rocketmakers/orbit-template-core';
2
- import { IFirebasePayload } from '../services';
2
+ import type { IFirebasePayload } from '../services/types';
3
3
  export declare namespace Validation {
4
4
  function sendNotification<TPayload>(firebaseDeviceToken: string, layoutId: LayoutId, templateName: string, payload: IFirebasePayload<TPayload>): Promise<{
5
5
  validatedDeviceToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,yBAAiB,UAAU,CAAC;IAC1B,SAAsB,gBAAgB,CAAC,QAAQ,EAC7C,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC;;;;;;;;;OAepC;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,yBAAiB,UAAU,CAAC;IAC1B,SAAsB,gBAAgB,CAAC,QAAQ,EAC7C,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC;;;;;;;;;OAepC;CACF"}
@@ -1,24 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Validation = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const orbit_core_1 = require("@rocketmakers/orbit-core");
6
5
  var Validation;
7
6
  (function (Validation) {
8
- function sendNotification(firebaseDeviceToken, layoutId, templateName, payload) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- return {
11
- validatedDeviceToken: yield (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.string(true).minLength(1).build(), firebaseDeviceToken),
12
- validatedLayoutId: yield (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.opaque(true).minLength(1).build(), layoutId),
13
- validatedTemplateName: yield (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.string(true).minLength(1).build(), templateName),
14
- validatedPayload: yield (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.objectMandatory({
15
- data: orbit_core_1.CommonValidators.any(true),
16
- title: orbit_core_1.CommonValidators.string(false),
17
- imageUrl: orbit_core_1.CommonValidators.string(false),
18
- }).build(), payload),
19
- };
20
- });
7
+ async function sendNotification(firebaseDeviceToken, layoutId, templateName, payload) {
8
+ return {
9
+ validatedDeviceToken: await (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.string(true).minLength(1).build(), firebaseDeviceToken),
10
+ validatedLayoutId: await (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.opaque(true).minLength(1).build(), layoutId),
11
+ validatedTemplateName: await (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.string(true).minLength(1).build(), templateName),
12
+ validatedPayload: await (0, orbit_core_1.validate)(orbit_core_1.CommonValidators.objectMandatory({
13
+ data: orbit_core_1.CommonValidators.any(true),
14
+ title: orbit_core_1.CommonValidators.string(false),
15
+ imageUrl: orbit_core_1.CommonValidators.string(false),
16
+ }).build(), payload),
17
+ };
21
18
  }
22
19
  Validation.sendNotification = sendNotification;
23
- })(Validation = exports.Validation || (exports.Validation = {}));
20
+ })(Validation || (exports.Validation = Validation = {}));
24
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":";;;;AAAA,yDAAsE;AAKtE,IAAiB,UAAU,CAqB1B;AArBD,WAAiB,UAAU;IACzB,SAAsB,gBAAgB,CACpC,mBAA2B,EAC3B,QAAkB,EAClB,YAAoB,EACpB,OAAmC;;YAEnC,OAAO;gBACL,oBAAoB,EAAE,MAAM,IAAA,qBAAQ,EAAC,6BAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,mBAAmB,CAAC;gBAC7G,iBAAiB,EAAE,MAAM,IAAA,qBAAQ,EAAC,6BAAgB,CAAC,MAAM,CAAW,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC;gBACzG,qBAAqB,EAAE,MAAM,IAAA,qBAAQ,EAAC,6BAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,YAAY,CAAC;gBACvG,gBAAgB,EAAE,MAAM,IAAA,qBAAQ,EAC9B,6BAAgB,CAAC,eAAe,CAAC;oBAC/B,IAAI,EAAE,6BAAgB,CAAC,GAAG,CAAC,IAAI,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,CAAC,CAAC,KAAK,EAAE,EACV,OAAO,CACR;SACF,CAAC;IACJ,CAAC;IAnBqB,2BAAgB,mBAmBrC,CAAA;AACH,CAAC,EArBgB,UAAU,0BAAV,UAAU,QAqB1B"}
package/package.json CHANGED
@@ -1,49 +1,46 @@
1
1
  {
2
2
  "name": "@rocketmakers/orbit-notify-firebase",
3
- "version": "2.0.4",
4
- "description": "> TODO: description",
3
+ "description": "Firebase implementation of Orbit Notify",
4
+ "version": "3.0.0",
5
5
  "author": "Product team <product-team@rocketmakers.com>",
6
- "homepage": "https://gitlab.com/rocketmakers/microservices/orbit-packages#readme",
7
- "license": "ISC",
8
- "main": "lib/index.js",
9
- "types": "lib/index.d.ts",
6
+ "bugs": "https://gitlab.com/rocketmakers/core/orbit/issues",
7
+ "dependencies": {
8
+ "@rocketmakers/log": "0.1.0",
9
+ "firebase-admin": "13.1.0",
10
+ "@rocketmakers/ioc": "0.3.6",
11
+ "@rocketmakers/orbit-core": "3.0.0",
12
+ "@rocketmakers/orbit-notify-core": "3.0.0",
13
+ "@rocketmakers/orbit-template-core": "3.0.0",
14
+ "@rocketmakers/orbit-template-http-repository": "3.0.0",
15
+ "@rocketmakers/orbit-template-service": "3.0.0",
16
+ "@rocketmakers/environment": "0.5.3"
17
+ },
18
+ "devDependencies": {
19
+ "eslint": "8.57.1",
20
+ "tslib": "2.8.1",
21
+ "typescript": "5.7.3",
22
+ "@rocketmakers/environment-generate-v5": "0.5.3",
23
+ "eslint-config-orbit": "0.0.0",
24
+ "tsconfig-orbit": "0.0.0"
25
+ },
10
26
  "directories": {
11
27
  "lib": "lib"
12
28
  },
13
29
  "files": [
14
30
  "lib/**/*"
15
31
  ],
16
- "repository": {
17
- "type": "git",
18
- "url": "https://gitlab.com/rocketmakers/microservices/orbit-packages"
19
- },
32
+ "homepage": "https://github.com/rocketmakers/rocketmakers-packages#readme",
33
+ "license": "ISC",
34
+ "main": "lib/index.js",
20
35
  "publishConfig": {
21
36
  "access": "public"
22
37
  },
38
+ "repository": "https://github.com/rocketmakers/rocketmakers-packages",
39
+ "types": "lib/index.d.ts",
23
40
  "scripts": {
24
- "env-config": "npx environment-generate ./src/environment.json ./src/config/environment.generated.ts",
25
- "build": "npm run env-config && tsc -p src",
26
- "build-watch": "npm run build -- --watch",
27
- "test": "mocha -r ts-node/register --recursive \"./src/_tests_/unit/**/*.test.ts\"",
28
- "manual-test-firebase": "mocha --timeout 15000 -r ts-node/register --recursive \"./{,!(node_modules)/**/}*.test.ts\""
29
- },
30
- "bugs": {
31
- "url": "https://gitlab.com/rocketmakers/microservices/orbit-packages/issues"
32
- },
33
- "dependencies": {
34
- "@rocketmakers/environment": "0.3.10",
35
- "@rocketmakers/ioc": "0.3.5",
36
- "@rocketmakers/log": "^0.1.0",
37
- "@rocketmakers/orbit-core": "2.0.4",
38
- "@rocketmakers/orbit-notify-core": "2.0.4",
39
- "@rocketmakers/orbit-template-core": "2.0.4",
40
- "@rocketmakers/orbit-template-http-repository": "2.0.4",
41
- "@rocketmakers/orbit-template-service": "2.0.4",
42
- "@rocketmakers/shell-commands": "6.0.0",
43
- "firebase-admin": "^9.12.0"
44
- },
45
- "devDependencies": {
46
- "@rocketmakers/orbit-testing-core": "^2.0.4"
47
- },
48
- "gitHead": "7f7ae330651a3a75683fe441a7c4c43685eb523a"
49
- }
41
+ "build": "tsc -p .",
42
+ "dev": "pnpm run build --watch",
43
+ "env-config": "environment-generate ./environment.json ./src/config/environment.generated.ts",
44
+ "lint": "eslint . --ext .ts"
45
+ }
46
+ }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/_tests_/manualTest/index.test.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sendNotification_1 = require("./sendNotification");
4
- describe('FirebaseService - manual', () => {
5
- (0, sendNotification_1.sendNotificationTests)();
6
- });
7
- //# sourceMappingURL=index.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../src/_tests_/manualTest/index.test.ts"],"names":[],"mappings":";;AAAA,yDAA2D;AAE3D,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAA,wCAAqB,GAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function sendNotificationTests(): void;
2
- //# sourceMappingURL=sendNotification.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendNotification.d.ts","sourceRoot":"","sources":["../../../src/_tests_/manualTest/sendNotification.ts"],"names":[],"mappings":"AAiDA,wBAAgB,qBAAqB,SAQpC"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendNotificationTests = void 0;
4
- const tslib_1 = require("tslib");
5
- const orbit_core_1 = require("@rocketmakers/orbit-core");
6
- const FirebaseAdmin = require("firebase-admin");
7
- const serviceInstance_1 = require("./serviceInstance");
8
- function send() {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const { firebaseService, templateService } = (0, serviceInstance_1.getServiceInstance)();
11
- const layoutId = 'login';
12
- const payload = {
13
- name: 'product team',
14
- username: 'football_tuesdays_21',
15
- loginDateTime: 'Sometime in the early 90s',
16
- deviceId: '123ABC',
17
- };
18
- yield templateService.initCache();
19
- const someUid = new orbit_core_1.UuidGeneratorService().generate();
20
- const firebaseDeviceToken = yield FirebaseAdmin.auth().createCustomToken(someUid);
21
- try {
22
- return yield firebaseService.sendNotification({
23
- firebaseDeviceToken,
24
- layoutId,
25
- templateName: 'txt',
26
- payload: {
27
- data: payload,
28
- title: 'Test push',
29
- imageUrl: 'https://placekitten.com/200/300',
30
- },
31
- });
32
- }
33
- catch (error) {
34
- throw new Error(error);
35
- }
36
- });
37
- }
38
- function sendNotificationTests() {
39
- describe('sendNotification', () => {
40
- it('can send notification', () => tslib_1.__awaiter(this, void 0, void 0, function* () {
41
- const res = yield send();
42
- expect(res).toBe(true);
43
- }));
44
- });
45
- }
46
- exports.sendNotificationTests = sendNotificationTests;
47
- //# sourceMappingURL=sendNotification.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sendNotification.js","sourceRoot":"","sources":["../../../src/_tests_/manualTest/sendNotification.ts"],"names":[],"mappings":";;;;AAAA,yDAAgE;AAEhE,gDAAgD;AAEhD,uDAAuD;AASvD,SAAe,IAAI;;QAIjB,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,IAAA,oCAAkB,GAAE,CAAC;QAElE,MAAM,QAAQ,GAAG,OAAmB,CAAC;QACrC,MAAM,OAAO,GAAkB;YAC7B,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,sBAAsB;YAChC,aAAa,EAAE,2BAA2B;YAC1C,QAAQ,EAAE,QAAQ;SACnB,CAAC;QAGF,MAAM,eAAe,CAAC,SAAS,EAAE,CAAC;QAElC,MAAM,OAAO,GAAG,IAAI,iCAAoB,EAAE,CAAC,QAAQ,EAAE,CAAC;QACtD,MAAM,mBAAmB,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAElF,IAAI;YACF,OAAO,MAAM,eAAe,CAAC,gBAAgB,CAAgB;gBAC3D,mBAAmB;gBACnB,QAAQ;gBACR,YAAY,EAAE,KAAK;gBACnB,OAAO,EAAE;oBACP,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,WAAW;oBAClB,QAAQ,EAAE,iCAAiC;iBAC5C;aACF,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;SACxB;IACH,CAAC;CAAA;AAED,SAAgB,qBAAqB;IACnC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,uBAAuB,EAAE,GAAS,EAAE;YACrC,MAAM,GAAG,GAAG,MAAM,IAAI,EAAE,CAAC;YAEzB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AARD,sDAQC"}
@@ -1,9 +0,0 @@
1
- import { TemplateRepository } from '@rocketmakers/orbit-template-http-repository';
2
- import { TemplateService } from '@rocketmakers/orbit-template-service';
3
- import { FirebaseService } from '../../services';
4
- export declare function getServiceInstance(): {
5
- templateRepo: TemplateRepository;
6
- templateService: TemplateService;
7
- firebaseService: FirebaseService;
8
- };
9
- //# sourceMappingURL=serviceInstance.d.ts.map