podverse-external-services 5.0.2 → 5.1.0-alpha.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.
Files changed (44) hide show
  1. package/README.md +26 -8
  2. package/dist/config/index.d.ts +18 -0
  3. package/dist/config/index.d.ts.map +1 -0
  4. package/dist/config/index.js +20 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -0
  8. package/dist/module-alias-config.d.ts +2 -0
  9. package/dist/module-alias-config.d.ts.map +1 -0
  10. package/dist/module-alias-config.js +7 -0
  11. package/dist/services/google/fcm.d.ts +12 -0
  12. package/dist/services/google/fcm.d.ts.map +1 -1
  13. package/dist/services/google/fcm.js +107 -154
  14. package/dist/services/google/firebaseGenerateAccessToken.d.ts +2 -0
  15. package/dist/services/google/firebaseGenerateAccessToken.d.ts.map +1 -0
  16. package/dist/services/google/firebaseGenerateAccessToken.js +62 -0
  17. package/dist/services/index.d.ts +3 -0
  18. package/dist/services/index.d.ts.map +1 -1
  19. package/dist/services/index.js +7 -3
  20. package/dist/services/notifications/index.d.ts +20 -0
  21. package/dist/services/notifications/index.d.ts.map +1 -1
  22. package/dist/services/notifications/index.js +34 -40
  23. package/dist/services/paypal/index.d.ts +8 -0
  24. package/dist/services/paypal/index.d.ts.map +1 -0
  25. package/dist/services/paypal/index.js +43 -0
  26. package/dist/services/podcast-index/index.d.ts +6 -30
  27. package/dist/services/podcast-index/index.d.ts.map +1 -1
  28. package/dist/services/podcast-index/index.js +62 -76
  29. package/dist/services/podcast-index/types/podcastByGuid.d.ts +73 -0
  30. package/dist/services/podcast-index/types/podcastByGuid.d.ts.map +1 -0
  31. package/dist/services/podcast-index/types/podcastByGuid.js +2 -0
  32. package/dist/services/podcast-index/types/podcastsByTag.d.ts +68 -0
  33. package/dist/services/podcast-index/types/podcastsByTag.d.ts.map +1 -0
  34. package/dist/services/podcast-index/types/podcastsByTag.js +2 -0
  35. package/dist/services/podcast-index/types/valueBatchByEpisodeGuid.d.ts +37 -0
  36. package/dist/services/podcast-index/types/valueBatchByEpisodeGuid.d.ts.map +1 -0
  37. package/dist/services/podcast-index/types/valueBatchByEpisodeGuid.js +2 -0
  38. package/dist/services/podcast-index/types/valueByEpisodeGuid.d.ts +32 -0
  39. package/dist/services/podcast-index/types/valueByEpisodeGuid.d.ts.map +1 -0
  40. package/dist/services/podcast-index/types/valueByEpisodeGuid.js +2 -0
  41. package/package.json +7 -4
  42. package/dist/services/google/index.d.ts +0 -1
  43. package/dist/services/google/index.d.ts.map +0 -1
  44. package/dist/services/google/index.js +0 -13
package/README.md CHANGED
@@ -2,18 +2,36 @@
2
2
 
3
3
  A collection of helpers for interacting with 3rd party external services, like AWS and Podcast Index API.
4
4
 
5
- ## Developing Podverse modules
5
+ ## Dev Setup
6
6
 
7
- Podverse maintains several different modules which are imported across apps. Please read [Developing Podverse modules](https://github.com/podverse/podverse-ops/blob/master/docs/how-to-develop-podverse-modules.md) for a workflow you can use to make code changes to this module locally.
7
+ ### Environment Variables
8
8
 
9
- ## Setup
9
+ The environment variables for this module must be set within the app that consumes this module (ex. `podverse-api` or `podverse-workers`). See `podverse-external-services/config/index.ts` for a list of the env vars expected.
10
10
 
11
- ```sh
12
- yarn
11
+ ### Local Dev Workflow
12
+
13
+ Podverse uses many modules that are maintained in separate repos, and they need to be linked and running for a local dev workflow. Please read the `podverse-ops/dev/local-dev-setup.md` file to set up the required dependencies and module linking.
14
+
15
+ ### Running Locally
16
+
17
+ Install the node_modules:
18
+
19
+ ```
20
+ npm install
21
+ ```
22
+
23
+ Then to build:
24
+
25
+ ```
26
+ npm run build
13
27
  ```
14
28
 
15
- ## Development
29
+ Or if you want the app to auto-build on saved changes:
16
30
 
17
- ```sh
18
- yarn dev:watch
19
31
  ```
32
+ npm run build:watch
33
+ ```
34
+
35
+ ## Publishing
36
+
37
+ To publish your changes to npm, increment the version number is `package.json` then run `npm publish`.
@@ -0,0 +1,18 @@
1
+ export declare const config: {
2
+ nodeEnv: string;
3
+ google: {
4
+ firebase: {
5
+ projectId: string;
6
+ patoToAuthJson: string;
7
+ };
8
+ };
9
+ paypal: {
10
+ clientId: string;
11
+ clientSecret: string;
12
+ mode: string;
13
+ };
14
+ podcastIndex: {
15
+ recentlyUpdatedDataInterval: number;
16
+ };
17
+ };
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;CAgBlB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ exports.config = {
5
+ nodeEnv: process.env.NODE_ENV || 'development',
6
+ google: {
7
+ firebase: {
8
+ projectId: process.env.GOOGLE_FIREBASE_PROJECT_ID || '',
9
+ patoToAuthJson: process.env.GOOGLE_FIREBASE_PATH_TO_AUTH_JSON || '',
10
+ }
11
+ },
12
+ paypal: {
13
+ clientId: process.env.PAYPAL_CLIENT_ID || '',
14
+ clientSecret: process.env.PAYPAL_CLIENT_SECRET || '',
15
+ mode: process.env.PAYPAL_MODE || 'sandbox'
16
+ },
17
+ podcastIndex: {
18
+ recentlyUpdatedDataInterval: parseInt(process.env.PODCAST_INDEX_RECENTLY_UPDATED_DATA_INTERVAL || '1800', 10)
19
+ }
20
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ import './module-alias-config';
2
+ export * from './config';
1
3
  export * from './services/index';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA"}
package/dist/index.js CHANGED
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ require("./module-alias-config");
18
+ __exportStar(require("./config"), exports);
17
19
  __exportStar(require("./services/index"), exports);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=module-alias-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-alias-config.d.ts","sourceRoot":"","sources":["../src/module-alias-config.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const moduleAlias = require('module-alias');
4
+ const path = require('path');
5
+ moduleAlias.addAliases({
6
+ '@external-services': path.join(__dirname, '')
7
+ });
@@ -1 +1,13 @@
1
+ import { SendNotificationOptions } from '@external-services/services/notifications';
2
+ type Constructor = {
3
+ authToken: string;
4
+ };
5
+ export declare class GoogleFCMService {
6
+ authToken: string;
7
+ constructor({ authToken }: Constructor);
8
+ sendFcmNewItemDetectedNotification: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
9
+ sendFcmLiveItemLiveDetectedNotification: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
10
+ sendFCMGoogleApiNotification: (fcmTokens: string[], title: string, body: string, channelIdText: string, notificationType: "live" | "new-item", channelTitle: string, itemTitle: string, channelImage?: string | null, itemImage?: string | null, itemIdText?: string) => Promise<void>;
11
+ }
12
+ export {};
1
13
  //# sourceMappingURL=fcm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fcm.d.ts","sourceRoot":"","sources":["../../../src/services/google/fcm.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"fcm.d.ts","sourceRoot":"","sources":["../../../src/services/google/fcm.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAIpF,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,qBAAa,gBAAgB;IACnB,SAAS,EAAE,MAAM,CAAA;gBAEZ,EAAE,SAAS,EAAE,EAAE,WAAW;IAIvC,kCAAkC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,mBAsBzG;IAED,uCAAuC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,mBAsB9G;IAED,4BAA4B,GAC1B,WAAW,MAAM,EAAE,EACnB,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,eAAe,MAAM,EACrB,kBAAkB,MAAM,GAAG,UAAU,EACrC,cAAc,MAAM,EACpB,WAAW,MAAM,EACjB,eAAe,MAAM,GAAG,IAAI,EAC5B,YAAY,MAAM,GAAG,IAAI,EACzB,aAAa,MAAM,mBAoEpB;CACF"}
@@ -1,155 +1,108 @@
1
1
  "use strict";
2
- // import axios, { AxiosRequestConfig } from 'axios'
3
- // import { getFCMTokensForPodcastId } from 'podverse-orm'
4
- // import { SendNotificationOptions } from '../notifications'
5
- // import { GoogleService } from '.'
6
- // const fcmGoogleApiPath = 'https://fcm.googleapis.com/fcm/send'
7
- // type Constructor = {
8
- // authToken: string
9
- // userAgent: string
10
- // }
11
- // export class GoogleFCMService extends GoogleService {
12
- // declare authToken: string
13
- // declare userAgent: string
14
- // constructor ({ authToken, userAgent }: Constructor) {
15
- // super({ authToken, userAgent })
16
- // this.authToken = authToken
17
- // this.userAgent = userAgent
18
- // }
19
- // request = (options: AxiosRequestConfig) => {
20
- // return axios({
21
- // ...options,
22
- // headers: {
23
- // ...options.headers,
24
- // "User-Agent": this.userAgent
25
- // }
26
- // })
27
- // }
28
- // sendFcmNewEpisodeDetectedNotification = async (options: SendNotificationOptions) => {
29
- // const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
30
- // const fcmTokens = await getFCMTokensForPodcastId(podcastId)
31
- // const podcastTitle = options.podcastTitle || 'Untitled Podcast'
32
- // const episodeTitle = options.episodeTitle || 'Untitled Episode'
33
- // const title = podcastTitle
34
- // const body = episodeTitle
35
- // const finalPodcastImageUrl = podcastShrunkImageUrl || podcastFullImageUrl
36
- // const finalEpisodeImageUrl = episodeFullImageUrl
37
- // return this.sendFCMGoogleApiNotification(
38
- // fcmTokens,
39
- // title,
40
- // body,
41
- // podcastId,
42
- // 'new-episode',
43
- // podcastTitle,
44
- // episodeTitle,
45
- // finalPodcastImageUrl,
46
- // finalEpisodeImageUrl,
47
- // episodeId
48
- // )
49
- // }
50
- // sendFcmLiveItemLiveDetectedNotification = async (options: SendNotificationOptions) => {
51
- // const { podcastId, podcastShrunkImageUrl, podcastFullImageUrl, episodeFullImageUrl, episodeId } = options
52
- // const fcmTokens = await getFCMTokensForPodcastId(podcastId)
53
- // const podcastTitle = options.podcastTitle || 'Untitled Podcast'
54
- // const episodeTitle = options.episodeTitle || 'Livestream starting'
55
- // const title = `LIVE: ${podcastTitle}`
56
- // const body = episodeTitle
57
- // const finalPodcastImageUrl = podcastShrunkImageUrl || podcastFullImageUrl
58
- // const finalEpisodeImageUrl = episodeFullImageUrl
59
- // return this.sendFCMGoogleApiNotification(
60
- // fcmTokens,
61
- // title,
62
- // body,
63
- // podcastId,
64
- // 'live',
65
- // podcastTitle,
66
- // episodeTitle,
67
- // finalPodcastImageUrl,
68
- // finalEpisodeImageUrl,
69
- // episodeId
70
- // )
71
- // }
72
- // sendFCMGoogleApiNotification = async (
73
- // fcmTokens: string[],
74
- // title: string,
75
- // body: string,
76
- // podcastId: string,
77
- // notificationType: 'live' | 'new-episode',
78
- // podcastTitle: string,
79
- // episodeTitle: string,
80
- // podcastImage?: string | null,
81
- // episodeImage?: string | null,
82
- // episodeId?: string
83
- // ) => {
84
- // if (!fcmTokens || fcmTokens.length === 0) return
85
- // const fcmTokenBatches: any[] = []
86
- // const size = 1000
87
- // for (let i = 0; i < fcmTokens.length; i += size) {
88
- // fcmTokenBatches.push(fcmTokens.slice(i, i + size))
89
- // }
90
- // for (const fcmTokenBatch of fcmTokenBatches) {
91
- // if (fcmTokenBatch?.length > 0) {
92
- // const imageUrl = episodeImage || podcastImage
93
- // try {
94
- // await this.request({
95
- // url: fcmGoogleApiPath,
96
- // method: 'POST',
97
- // headers: {
98
- // Authorization: `key=${this.authToken}`,
99
- // 'Content-Type': 'application/json'
100
- // },
101
- // data: {
102
- // // eslint-disable-next-line @typescript-eslint/camelcase
103
- // registration_ids: fcmTokenBatch || [],
104
- // notification: {
105
- // body,
106
- // title,
107
- // podcastId,
108
- // episodeId,
109
- // podcastTitle: podcastTitle,
110
- // episodeTitle: episodeTitle,
111
- // notificationType,
112
- // timeSent: new Date(),
113
- // image: imageUrl
114
- // },
115
- // data: {
116
- // body,
117
- // title,
118
- // podcastId,
119
- // episodeId,
120
- // podcastTitle: podcastTitle,
121
- // episodeTitle: episodeTitle,
122
- // notificationType,
123
- // timeSent: new Date()
124
- // },
125
- // android: {
126
- // notification: {
127
- // imageUrl
128
- // }
129
- // },
130
- // apns: {
131
- // payload: {
132
- // aps: {
133
- // 'mutable-content': 1
134
- // }
135
- // },
136
- // // eslint-disable-next-line @typescript-eslint/camelcase
137
- // fcm_options: {
138
- // image: imageUrl
139
- // }
140
- // },
141
- // webpush: {
142
- // headers: {
143
- // image: imageUrl
144
- // }
145
- // }
146
- // },
147
- // responseType: 'json'
148
- // })
149
- // } catch (error) {
150
- // console.log('sendFCMGoogleApiNotification error', error)
151
- // }
152
- // }
153
- // }
154
- // }
155
- // }
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.GoogleFCMService = void 0;
13
+ const podverse_helpers_1 = require("podverse-helpers");
14
+ const config_1 = require("@external-services/config");
15
+ const fcmGoogleApiPath = `https://fcm.googleapis.com/v1/projects/${config_1.config.google.firebase.projectId}/messages:send`;
16
+ class GoogleFCMService {
17
+ constructor({ authToken }) {
18
+ this.sendFcmNewItemDetectedNotification = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
19
+ const { channelIdText, /* podcastShrunkImageUrl, */ channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
20
+ const channelTitle = options.channelTitle || 'Untitled';
21
+ const itemTitle = options.itemTitle || 'Untitled';
22
+ const title = channelTitle;
23
+ const body = itemTitle;
24
+ const finalPodcastImageUrl = /* podcastShrunkImageUrl || */ channelFullImageUrl;
25
+ const finalEpisodeImageUrl = itemFullImageUrl;
26
+ return this.sendFCMGoogleApiNotification(account_fcm_tokens, title, body, channelIdText, 'new-item', channelTitle, itemTitle, finalPodcastImageUrl, finalEpisodeImageUrl, itemIdText);
27
+ });
28
+ this.sendFcmLiveItemLiveDetectedNotification = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
29
+ const { channelIdText, /* podcastShrunkImageUrl, */ channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
30
+ const channelTitle = options.channelTitle || 'Untitled';
31
+ const itemTitle = options.itemTitle || 'Livestream starting';
32
+ const title = `LIVE: ${channelTitle}`;
33
+ const body = itemTitle;
34
+ const finalPodcastImageUrl = /* podcastShrunkImageUrl ||*/ channelFullImageUrl;
35
+ const finalEpisodeImageUrl = itemFullImageUrl;
36
+ return this.sendFCMGoogleApiNotification(account_fcm_tokens, title, body, channelIdText, 'live', channelTitle, itemTitle, finalPodcastImageUrl, finalEpisodeImageUrl, itemIdText);
37
+ });
38
+ this.sendFCMGoogleApiNotification = (fcmTokens, title, body, channelIdText, notificationType, channelTitle, itemTitle, channelImage, itemImage, itemIdText) => __awaiter(this, void 0, void 0, function* () {
39
+ if (!fcmTokens || fcmTokens.length === 0)
40
+ return;
41
+ const fcmTokenBatches = [];
42
+ const size = 1000;
43
+ for (let i = 0; i < fcmTokens.length; i += size) {
44
+ fcmTokenBatches.push(fcmTokens.slice(i, i + size));
45
+ }
46
+ for (const fcmTokenBatch of fcmTokenBatches) {
47
+ if ((fcmTokenBatch === null || fcmTokenBatch === void 0 ? void 0 : fcmTokenBatch.length) > 0) {
48
+ const imageUrl = itemImage || channelImage;
49
+ try {
50
+ for (const token of fcmTokenBatch) {
51
+ yield (0, podverse_helpers_1.request)(fcmGoogleApiPath, {
52
+ method: 'POST',
53
+ headers: {
54
+ Authorization: `Bearer ${this.authToken}`,
55
+ 'Content-Type': 'application/json'
56
+ },
57
+ data: {
58
+ message: {
59
+ token,
60
+ notification: {
61
+ title,
62
+ body,
63
+ image: imageUrl
64
+ },
65
+ data: {
66
+ podcastId: channelIdText,
67
+ episodeId: itemIdText,
68
+ podcastTitle: channelTitle,
69
+ episodeTitle: itemTitle,
70
+ notificationType,
71
+ timeSent: new Date().toISOString()
72
+ },
73
+ android: {
74
+ notification: {
75
+ image: imageUrl
76
+ }
77
+ },
78
+ apns: {
79
+ payload: {
80
+ aps: {
81
+ 'mutable-content': 1
82
+ }
83
+ },
84
+ fcm_options: {
85
+ image: imageUrl
86
+ }
87
+ },
88
+ webpush: {
89
+ notification: {
90
+ image: imageUrl
91
+ }
92
+ }
93
+ }
94
+ },
95
+ responseType: 'json'
96
+ });
97
+ }
98
+ }
99
+ catch (error) {
100
+ (0, podverse_helpers_1.logError)('sendFCMGoogleApiNotification error', error);
101
+ }
102
+ }
103
+ }
104
+ });
105
+ this.authToken = authToken;
106
+ }
107
+ }
108
+ exports.GoogleFCMService = GoogleFCMService;
@@ -0,0 +1,2 @@
1
+ export declare function firebaseGenerateAccessToken(): Promise<string>;
2
+ //# sourceMappingURL=firebaseGenerateAccessToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebaseGenerateAccessToken.d.ts","sourceRoot":"","sources":["../../../src/services/google/firebaseGenerateAccessToken.ts"],"names":[],"mappings":"AAgBA,wBAAsB,2BAA2B,oBAGhD"}
@@ -0,0 +1,62 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.firebaseGenerateAccessToken = firebaseGenerateAccessToken;
46
+ const admin = __importStar(require("firebase-admin"));
47
+ const config_1 = require("@external-services/config");
48
+ const fs = require('fs');
49
+ const keyFilePath = config_1.config.google.firebase.patoToAuthJson;
50
+ let serviceAccount = null;
51
+ if (keyFilePath) {
52
+ serviceAccount = JSON.parse(fs.readFileSync(keyFilePath, 'utf8'));
53
+ admin.initializeApp({
54
+ credential: admin.credential.cert(serviceAccount),
55
+ });
56
+ }
57
+ function firebaseGenerateAccessToken() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const token = yield admin.credential.cert(serviceAccount).getAccessToken();
60
+ return token.access_token;
61
+ });
62
+ }
@@ -1,2 +1,5 @@
1
+ export { firebaseGenerateAccessToken } from './google/firebaseGenerateAccessToken';
2
+ export { NotificationsService } from './notifications';
3
+ export { PayPalService } from './paypal';
1
4
  export { PodcastIndexService } from './podcast-index';
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PodcastIndexService = void 0;
3
+ exports.PodcastIndexService = exports.PayPalService = exports.NotificationsService = exports.firebaseGenerateAccessToken = void 0;
4
4
  // export { AWSS3Service, AWSSQSService } from './aws'
5
- // export { GoogleService } from './google'
6
- // export * from './notifications'
5
+ var firebaseGenerateAccessToken_1 = require("./google/firebaseGenerateAccessToken");
6
+ Object.defineProperty(exports, "firebaseGenerateAccessToken", { enumerable: true, get: function () { return firebaseGenerateAccessToken_1.firebaseGenerateAccessToken; } });
7
+ var notifications_1 = require("./notifications");
8
+ Object.defineProperty(exports, "NotificationsService", { enumerable: true, get: function () { return notifications_1.NotificationsService; } });
9
+ var paypal_1 = require("./paypal");
10
+ Object.defineProperty(exports, "PayPalService", { enumerable: true, get: function () { return paypal_1.PayPalService; } });
7
11
  var podcast_index_1 = require("./podcast-index");
8
12
  Object.defineProperty(exports, "PodcastIndexService", { enumerable: true, get: function () { return podcast_index_1.PodcastIndexService; } });
9
13
  // export { UnifiedPushService } from './unifiedpush'
@@ -1 +1,21 @@
1
+ import { GoogleFCMService } from '@external-services/services/google/fcm';
2
+ export interface SendNotificationOptions {
3
+ itemFullImageUrl?: string | null;
4
+ itemGuid?: string | null;
5
+ itemIdText?: string;
6
+ itemTitle?: string | null;
7
+ channelIdText: string;
8
+ channelFullImageUrl?: string | null;
9
+ channelTitle?: string | null;
10
+ }
11
+ type Constructor = {
12
+ googleAuthToken: string;
13
+ };
14
+ export declare class NotificationsService {
15
+ GoogleFCMService: GoogleFCMService;
16
+ constructor({ googleAuthToken }: Constructor);
17
+ sendNewItemDetectedNotifications: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
18
+ sendLiveItemLiveDetectedNotifications: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
19
+ }
20
+ export {};
1
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAEzE,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEnC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,qBAAa,oBAAoB;IACvB,gBAAgB,EAAE,gBAAgB,CAAA;gBAG7B,EAAE,eAAe,EAAE,EAAE,WAAW;IAQ7C,gCAAgC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,KAAG,OAAO,CAAC,IAAI,CAAC,CAKvH;IAED,qCAAqC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,KAAG,OAAO,CAAC,IAAI,CAAC,CAK5H;CACF"}
@@ -1,42 +1,36 @@
1
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.NotificationsService = void 0;
2
13
  // import { UnifiedPushService } from '..'
3
- // import { GoogleFCMService } from '../google/fcm'
4
- // export interface SendNotificationOptions {
5
- // episodeFullImageUrl?: string | null
6
- // episodeGuid?: string
7
- // episodeId?: string
8
- // episodeTitle?: string | null
9
- // podcastId: string
10
- // podcastFullImageUrl?: string | null
11
- // podcastShrunkImageUrl?: string | null
12
- // podcastTitle?: string | null
13
- // }
14
- // type Constructor = {
15
- // googleAuthToken: string
16
- // userAgent: string
17
- // }
18
- // export class NotificationsService {
19
- // declare fcmAuthToken: string
20
- // declare userAgent: string
21
- // declare GoogleFCMService: GoogleFCMService
22
- // declare UnifiedPushService: UnifiedPushService
23
- // constructor ({ googleAuthToken, userAgent }: Constructor) {
24
- // this.GoogleFCMService = new GoogleFCMService({
25
- // authToken: googleAuthToken,
26
- // userAgent
27
- // })
28
- // this.UnifiedPushService = new UnifiedPushService()
29
- // }
30
- // sendNewEpisodeDetectedNotification = async (options: SendNotificationOptions) => {
31
- // return Promise.all([
32
- // this.GoogleFCMService.sendFcmNewEpisodeDetectedNotification(options),
33
- // this.UnifiedPushService.sendUpNewEpisodeDetectedNotification(options)
34
- // ])
35
- // }
36
- // sendLiveItemLiveDetectedNotification = async (options: SendNotificationOptions) => {
37
- // return Promise.all([
38
- // this.GoogleFCMService.sendFcmLiveItemLiveDetectedNotification(options),
39
- // this.UnifiedPushService.sendUpLiveItemLiveDetectedNotification(options)
40
- // ])
41
- // }
42
- // }
14
+ const fcm_1 = require("@external-services/services/google/fcm");
15
+ class NotificationsService {
16
+ // declare UnifiedPushService: UnifiedPushService
17
+ constructor({ googleAuthToken }) {
18
+ this.sendNewItemDetectedNotifications = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
19
+ yield Promise.all([
20
+ this.GoogleFCMService.sendFcmNewItemDetectedNotification(account_fcm_tokens, options),
21
+ // this.UnifiedPushService.sendUpNewEpisodeDetectedNotification(options)
22
+ ]);
23
+ });
24
+ this.sendLiveItemLiveDetectedNotifications = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
25
+ yield Promise.all([
26
+ this.GoogleFCMService.sendFcmLiveItemLiveDetectedNotification(account_fcm_tokens, options),
27
+ // this.UnifiedPushService.sendUpLiveItemLiveDetectedNotification(options)
28
+ ]);
29
+ });
30
+ this.GoogleFCMService = new fcm_1.GoogleFCMService({
31
+ authToken: googleAuthToken
32
+ });
33
+ // this.UnifiedPushService = new UnifiedPushService()
34
+ }
35
+ }
36
+ exports.NotificationsService = NotificationsService;
@@ -0,0 +1,8 @@
1
+ export declare class PayPalService {
2
+ private client;
3
+ constructor();
4
+ private getEnvironment;
5
+ getPaymentInfo(paymentId: string): Promise<any>;
6
+ getCaptureInfo(paymentId: string): Promise<any>;
7
+ }
8
+ //# sourceMappingURL=index.d.ts.map