podverse-external-services 5.1.1-alpha.13 → 5.1.1-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import './module-alias-config';
2
- export * from './config';
3
2
  export * from './services/index';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,cAAc,kBAAkB,CAAA"}
package/dist/index.js CHANGED
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  require("./module-alias-config");
18
- __exportStar(require("./config"), exports);
19
18
  __exportStar(require("./services/index"), exports);
@@ -1,10 +1,16 @@
1
+ import { LoggerService } from 'podverse-helpers/dist/lib/backend/logger';
1
2
  import { SendNotificationOptions } from '@external-services/services/notifications';
2
- type Constructor = {
3
+ type GoogleFCMServiceParams = {
3
4
  authToken: string;
5
+ firebaseProjectId: string;
6
+ loggerService: LoggerService;
4
7
  };
5
8
  export declare class GoogleFCMService {
6
- authToken: string;
7
- constructor({ authToken }: Constructor);
9
+ private authToken;
10
+ private firebaseProjectId;
11
+ private loggerService;
12
+ constructor({ authToken, firebaseProjectId, loggerService }: GoogleFCMServiceParams);
13
+ private getFcmGoogleApiPath;
8
14
  sendFcmNewItemDetectedNotification: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
9
15
  sendFcmLiveItemLiveDetectedNotification: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
10
16
  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>;
@@ -1 +1 @@
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
+ {"version":3,"file":"fcm.d.ts","sourceRoot":"","sources":["../../../src/services/google/fcm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,sBAAsB;IAMnF,OAAO,CAAC,mBAAmB;IAI3B,kCAAkC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,mBAsBxG;IAEF,uCAAuC,GAAU,oBAAoB,MAAM,EAAE,EAAE,SAAS,uBAAuB,mBAsB7G;IAEF,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,mBAsEnB;CACH"}
@@ -11,27 +11,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GoogleFCMService = void 0;
13
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
14
  class GoogleFCMService {
17
- constructor({ authToken }) {
15
+ constructor({ authToken, firebaseProjectId, loggerService }) {
18
16
  this.sendFcmNewItemDetectedNotification = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
19
- const { channelIdText, /* podcastShrunkImageUrl, */ channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
17
+ const { channelIdText, channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
20
18
  const channelTitle = options.channelTitle || 'Untitled';
21
19
  const itemTitle = options.itemTitle || 'Untitled';
22
20
  const title = channelTitle;
23
21
  const body = itemTitle;
24
- const finalPodcastImageUrl = /* podcastShrunkImageUrl || */ channelFullImageUrl;
22
+ const finalPodcastImageUrl = channelFullImageUrl;
25
23
  const finalEpisodeImageUrl = itemFullImageUrl;
26
24
  return this.sendFCMGoogleApiNotification(account_fcm_tokens, title, body, channelIdText, 'new-item', channelTitle, itemTitle, finalPodcastImageUrl, finalEpisodeImageUrl, itemIdText);
27
25
  });
28
26
  this.sendFcmLiveItemLiveDetectedNotification = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
29
- const { channelIdText, /* podcastShrunkImageUrl, */ channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
27
+ const { channelIdText, channelFullImageUrl, itemFullImageUrl, itemIdText } = options;
30
28
  const channelTitle = options.channelTitle || 'Untitled';
31
29
  const itemTitle = options.itemTitle || 'Livestream starting';
32
30
  const title = `LIVE: ${channelTitle}`;
33
31
  const body = itemTitle;
34
- const finalPodcastImageUrl = /* podcastShrunkImageUrl ||*/ channelFullImageUrl;
32
+ const finalPodcastImageUrl = channelFullImageUrl;
35
33
  const finalEpisodeImageUrl = itemFullImageUrl;
36
34
  return this.sendFCMGoogleApiNotification(account_fcm_tokens, title, body, channelIdText, 'live', channelTitle, itemTitle, finalPodcastImageUrl, finalEpisodeImageUrl, itemIdText);
37
35
  });
@@ -43,6 +41,7 @@ class GoogleFCMService {
43
41
  for (let i = 0; i < fcmTokens.length; i += size) {
44
42
  fcmTokenBatches.push(fcmTokens.slice(i, i + size));
45
43
  }
44
+ const fcmGoogleApiPath = this.getFcmGoogleApiPath();
46
45
  for (const fcmTokenBatch of fcmTokenBatches) {
47
46
  if ((fcmTokenBatch === null || fcmTokenBatch === void 0 ? void 0 : fcmTokenBatch.length) > 0) {
48
47
  const imageUrl = itemImage || channelImage;
@@ -97,12 +96,17 @@ class GoogleFCMService {
97
96
  }
98
97
  }
99
98
  catch (error) {
100
- (0, podverse_helpers_1.logError)('sendFCMGoogleApiNotification error', error);
99
+ this.loggerService.logError('sendFCMGoogleApiNotification error', error);
101
100
  }
102
101
  }
103
102
  }
104
103
  });
105
104
  this.authToken = authToken;
105
+ this.firebaseProjectId = firebaseProjectId;
106
+ this.loggerService = loggerService;
107
+ }
108
+ getFcmGoogleApiPath() {
109
+ return `https://fcm.googleapis.com/v1/projects/${this.firebaseProjectId}/messages:send`;
106
110
  }
107
111
  }
108
112
  exports.GoogleFCMService = GoogleFCMService;
@@ -0,0 +1,9 @@
1
+ export interface FirebaseAccessTokenServiceParams {
2
+ keyFilePath: string;
3
+ }
4
+ export declare class FirebaseAccessTokenService {
5
+ private serviceAccount;
6
+ constructor({ keyFilePath }: FirebaseAccessTokenServiceParams);
7
+ generateAccessToken(): Promise<string>;
8
+ }
9
+ //# sourceMappingURL=firebaseAccessTokenService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebaseAccessTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/google/firebaseAccessTokenService.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gCAAgC;IAC/C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,0BAA0B;IACrC,OAAO,CAAC,cAAc,CAAM;gBAEhB,EAAE,WAAW,EAAE,EAAE,gCAAgC;IAavD,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;CAI7C"}
@@ -42,21 +42,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
42
  });
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.firebaseGenerateAccessToken = firebaseGenerateAccessToken;
45
+ exports.FirebaseAccessTokenService = void 0;
46
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
- });
47
+ const fs = __importStar(require("fs"));
48
+ class FirebaseAccessTokenService {
49
+ constructor({ keyFilePath }) {
50
+ if (!keyFilePath) {
51
+ throw new Error('keyFilePath is required');
52
+ }
53
+ this.serviceAccount = JSON.parse(fs.readFileSync(keyFilePath, 'utf8'));
54
+ if (!admin.apps.length) {
55
+ admin.initializeApp({
56
+ credential: admin.credential.cert(this.serviceAccount),
57
+ });
58
+ }
59
+ }
60
+ generateAccessToken() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const token = yield admin.credential.cert(this.serviceAccount).getAccessToken();
63
+ return token.access_token;
64
+ });
65
+ }
62
66
  }
67
+ exports.FirebaseAccessTokenService = FirebaseAccessTokenService;
@@ -1,4 +1,4 @@
1
- export { firebaseGenerateAccessToken } from './google/firebaseGenerateAccessToken';
1
+ export { FirebaseAccessTokenService } from './google/firebaseAccessTokenService';
2
2
  export { NotificationsService } from './notifications';
3
3
  export { PayPalService } from './paypal';
4
4
  export { PodcastIndexService } from './podcast-index';
@@ -1 +1 @@
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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,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,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PodcastIndexService = exports.PayPalService = exports.NotificationsService = exports.firebaseGenerateAccessToken = void 0;
3
+ exports.PodcastIndexService = exports.PayPalService = exports.NotificationsService = exports.FirebaseAccessTokenService = void 0;
4
4
  // export { AWSS3Service, AWSSQSService } from './aws'
5
- var firebaseGenerateAccessToken_1 = require("./google/firebaseGenerateAccessToken");
6
- Object.defineProperty(exports, "firebaseGenerateAccessToken", { enumerable: true, get: function () { return firebaseGenerateAccessToken_1.firebaseGenerateAccessToken; } });
5
+ var firebaseAccessTokenService_1 = require("./google/firebaseAccessTokenService");
6
+ Object.defineProperty(exports, "FirebaseAccessTokenService", { enumerable: true, get: function () { return firebaseAccessTokenService_1.FirebaseAccessTokenService; } });
7
7
  var notifications_1 = require("./notifications");
8
8
  Object.defineProperty(exports, "NotificationsService", { enumerable: true, get: function () { return notifications_1.NotificationsService; } });
9
9
  var paypal_1 = require("./paypal");
@@ -1,4 +1,5 @@
1
1
  import { GoogleFCMService } from '@external-services/services/google/fcm';
2
+ import { LoggerService } from 'podverse-helpers/dist/lib/backend/logger';
2
3
  export interface SendNotificationOptions {
3
4
  itemFullImageUrl?: string | null;
4
5
  itemGuid?: string | null;
@@ -10,10 +11,12 @@ export interface SendNotificationOptions {
10
11
  }
11
12
  type Constructor = {
12
13
  googleAuthToken: string;
14
+ firebaseProjectId: string;
15
+ loggerService: LoggerService;
13
16
  };
14
17
  export declare class NotificationsService {
15
18
  GoogleFCMService: GoogleFCMService;
16
- constructor({ googleAuthToken }: Constructor);
19
+ constructor({ googleAuthToken, firebaseProjectId, loggerService }: Constructor);
17
20
  sendNewItemDetectedNotifications: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
18
21
  sendLiveItemLiveDetectedNotifications: (account_fcm_tokens: string[], options: SendNotificationOptions) => Promise<void>;
19
22
  }
@@ -1 +1 @@
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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;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;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED,qBAAa,oBAAoB;IACvB,gBAAgB,EAAE,gBAAgB,CAAA;gBAG7B,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,WAAW;IAU/E,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"}
@@ -10,11 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.NotificationsService = void 0;
13
- // import { UnifiedPushService } from '..'
14
13
  const fcm_1 = require("@external-services/services/google/fcm");
15
14
  class NotificationsService {
16
15
  // declare UnifiedPushService: UnifiedPushService
17
- constructor({ googleAuthToken }) {
16
+ constructor({ googleAuthToken, firebaseProjectId, loggerService }) {
18
17
  this.sendNewItemDetectedNotifications = (account_fcm_tokens, options) => __awaiter(this, void 0, void 0, function* () {
19
18
  yield Promise.all([
20
19
  this.GoogleFCMService.sendFcmNewItemDetectedNotification(account_fcm_tokens, options),
@@ -28,7 +27,9 @@ class NotificationsService {
28
27
  ]);
29
28
  });
30
29
  this.GoogleFCMService = new fcm_1.GoogleFCMService({
31
- authToken: googleAuthToken
30
+ authToken: googleAuthToken,
31
+ firebaseProjectId,
32
+ loggerService
32
33
  });
33
34
  // this.UnifiedPushService = new UnifiedPushService()
34
35
  }
@@ -1,6 +1,14 @@
1
+ export interface PayPalServiceParams {
2
+ clientId: string;
3
+ clientSecret: string;
4
+ nodeEnv?: string;
5
+ }
1
6
  export declare class PayPalService {
2
7
  private client;
3
- constructor();
8
+ private clientId;
9
+ private clientSecret;
10
+ private nodeEnv;
11
+ constructor({ clientId, clientSecret, nodeEnv }: PayPalServiceParams);
4
12
  private getEnvironment;
5
13
  getPaymentInfo(paymentId: string): Promise<any>;
6
14
  getCaptureInfo(paymentId: string): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/paypal/index.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAM;;IAMpB,OAAO,CAAC,cAAc;IAQhB,cAAc,CAAC,SAAS,EAAE,MAAM;IAMhC,cAAc,CAAC,SAAS,EAAE,MAAM;CAKvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/paypal/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;gBAEZ,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAuB,EAAE,EAAE,mBAAmB;IAOpF,OAAO,CAAC,cAAc;IAQhB,cAAc,CAAC,SAAS,EAAE,MAAM;IAMhC,cAAc,CAAC,SAAS,EAAE,MAAM;CAKvC"}
@@ -10,19 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PayPalService = void 0;
13
- const config_1 = require("@external-services/config");
14
13
  const paypalRestSdk = require('paypal-rest-sdk');
15
14
  const payments = paypalRestSdk.v1.payments;
16
15
  class PayPalService {
17
- constructor() {
16
+ constructor({ clientId, clientSecret, nodeEnv = 'development' }) {
17
+ this.clientId = clientId;
18
+ this.clientSecret = clientSecret;
19
+ this.nodeEnv = nodeEnv;
18
20
  this.client = new paypalRestSdk.core.PayPalHttpClient(this.getEnvironment());
19
21
  }
20
22
  getEnvironment() {
21
- if (config_1.config.nodeEnv === 'production') {
22
- return new paypalRestSdk.core.LiveEnvironment(config_1.config.paypal.clientId, config_1.config.paypal.clientSecret);
23
+ if (this.nodeEnv === 'production') {
24
+ return new paypalRestSdk.core.LiveEnvironment(this.clientId, this.clientSecret);
23
25
  }
24
26
  else {
25
- return new paypalRestSdk.core.SandboxEnvironment(config_1.config.paypal.clientId, config_1.config.paypal.clientSecret);
27
+ return new paypalRestSdk.core.SandboxEnvironment(this.clientId, this.clientSecret);
26
28
  }
27
29
  }
28
30
  getPaymentInfo(paymentId) {
@@ -1,14 +1,17 @@
1
+ import { LoggerService } from 'podverse-helpers/dist/lib/backend/logger';
1
2
  import { PodcastByGuidResponse } from './types/podcastByGuid';
2
3
  type Constructor = {
3
4
  authKey: string;
4
5
  baseUrl: string;
5
6
  secretKey: string;
7
+ loggerService: LoggerService;
6
8
  };
7
9
  export declare class PodcastIndexService {
8
10
  authKey: string;
9
11
  baseUrl: string;
10
12
  secretKey: string;
11
- constructor({ authKey, baseUrl, secretKey }: Constructor);
13
+ loggerService: LoggerService;
14
+ constructor({ authKey, baseUrl, secretKey, loggerService }: Constructor);
12
15
  podcastIndexAPIRequest: (url: string, config?: any) => Promise<any>;
13
16
  deadFeedsDownloadAndExtractCSV: (resolveHandler: (row: string[]) => void) => Promise<void>;
14
17
  deadFeedsExtractRow: (row: string[]) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/podcast-index/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AASD,qBAAa,mBAAmB;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;gBAEZ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,WAAW;IAQzD,sBAAsB,GAAU,KAAK,MAAM,EAAE,SAAS,GAAG,kBA+BxD;IAID,8BAA8B,GAAU,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC,CAsC9F;IAED,mBAAmB,GAAI,KAAK,MAAM,EAAE;;;MAOnC;IAID,cAAc,GAAU,gBAAgB,MAAM,KAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAQnE;IAED,gBAAgB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAYpF;IAID,aAAa,GAAU,YAAY,MAAM,oBA4BxC;IAID,mBAAmB,GACjB,MAAK,MAAW,EAChB,QAAQ,MAAM,EACd,OAAO,MAAM,EACb,MAAM,MAAM,KACX,OAAO,CAAC;QAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAoB/C;IAID,oBAAoB,QAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAMjD;IAED,+BAA+B,GAC7B,4BAA4B,MAAM,EAAE,EAAE,gBAAW,KAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAatE;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/podcast-index/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AASD,qBAAa,mBAAmB;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,aAAa,CAAC;gBAExB,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,WAAW;IASxE,sBAAsB,GAAU,KAAK,MAAM,EAAE,SAAS,GAAG,kBA+BxD;IAID,8BAA8B,GAAU,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC,CAsC9F;IAED,mBAAmB,GAAI,KAAK,MAAM,EAAE;;;MAOnC;IAID,cAAc,GAAU,gBAAgB,MAAM,KAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAQnE;IAED,gBAAgB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAYpF;IAID,aAAa,GAAU,YAAY,MAAM,oBA4BxC;IAID,mBAAmB,GACjB,MAAK,MAAW,EAChB,QAAQ,MAAM,EACd,OAAO,MAAM,EACb,MAAM,MAAM,KACX,OAAO,CAAC;QAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAoB/C;IAID,oBAAoB,QAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAMjD;IAED,+BAA+B,GAC7B,4BAA4B,MAAM,EAAE,EAAE,gBAAW,KAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAatE;CACF"}
@@ -26,7 +26,7 @@ const podverse_helpers_1 = require("podverse-helpers");
26
26
  encoded once again before sending the request to PI API.
27
27
  */
28
28
  class PodcastIndexService {
29
- constructor({ authKey, baseUrl, secretKey }) {
29
+ constructor({ authKey, baseUrl, secretKey, loggerService }) {
30
30
  // Request handler
31
31
  this.podcastIndexAPIRequest = (url, config) => __awaiter(this, void 0, void 0, function* () {
32
32
  var _a, _b, _c;
@@ -45,7 +45,7 @@ class PodcastIndexService {
45
45
  return response;
46
46
  }
47
47
  catch (error) {
48
- podverse_helpers_1.logger.error('[PodcastIndex] Request failed', {
48
+ this.loggerService.logError('[PodcastIndex] Request failed', {
49
49
  url,
50
50
  errorMessage: error === null || error === void 0 ? void 0 : error.message,
51
51
  errorStack: error === null || error === void 0 ? void 0 : error.stack,
@@ -123,11 +123,11 @@ class PodcastIndexService {
123
123
  });
124
124
  // Recent
125
125
  this.recentGetData = (sinceRange) => __awaiter(this, void 0, void 0, function* () {
126
- podverse_helpers_1.logger.info('recentGetData beginning...');
126
+ this.loggerService.info('recentGetData beginning...');
127
127
  const currentTimeInSeconds = Math.floor(Date.now() / 1000);
128
128
  const sinceTimeInSeconds = currentTimeInSeconds - sinceRange;
129
129
  const fetchData = (since_1, ...args_1) => __awaiter(this, [since_1, ...args_1], void 0, function* (since, allData = []) {
130
- podverse_helpers_1.logger.info(`fetchData since: ${since}, allData.length: ${allData.length}`);
130
+ this.loggerService.info(`fetchData since: ${since}, allData.length: ${allData.length}`);
131
131
  const url = `${this.baseUrl}/recent/data?max=5000&since=${since}`;
132
132
  const response = yield this.podcastIndexAPIRequest(url);
133
133
  const updatedFeeds = response.data.feeds;
@@ -135,11 +135,11 @@ class PodcastIndexService {
135
135
  allData = allData.concat(updatedFeeds);
136
136
  if (nextSince && nextSince <= currentTimeInSeconds) {
137
137
  if (nextSince <= since) {
138
- podverse_helpers_1.logger.info(`nextSince (${nextSince}) is not greater than since (${since}). Exiting to avoid infinite loop.`);
138
+ this.loggerService.info(`nextSince (${nextSince}) is not greater than since (${since}). Exiting to avoid infinite loop.`);
139
139
  return allData;
140
140
  }
141
141
  const timeLeft = currentTimeInSeconds - nextSince;
142
- podverse_helpers_1.logger.info(`Time remaining: ${timeLeft} seconds`);
142
+ this.loggerService.info(`Time remaining: ${timeLeft} seconds`);
143
143
  return fetchData(nextSince, allData);
144
144
  }
145
145
  return allData;
@@ -159,7 +159,7 @@ class PodcastIndexService {
159
159
  if (cat) {
160
160
  url += `&cat=${encodeURIComponent(cat)}`;
161
161
  }
162
- podverse_helpers_1.logger.info(`[PodcastIndex] Fetching trending feeds (max: ${safeMax}, since: ${since}, lang: ${lang}, cat: ${cat})`);
162
+ this.loggerService.info(`[PodcastIndex] Fetching trending feeds (max: ${safeMax}, since: ${since}, lang: ${lang}, cat: ${cat})`);
163
163
  const response = yield this.podcastIndexAPIRequest(url);
164
164
  return {
165
165
  feeds: response.feeds || [],
@@ -187,6 +187,7 @@ class PodcastIndexService {
187
187
  this.authKey = authKey;
188
188
  this.baseUrl = baseUrl;
189
189
  this.secretKey = secretKey;
190
+ this.loggerService = loggerService;
190
191
  }
191
192
  }
192
193
  exports.PodcastIndexService = PodcastIndexService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podverse-external-services",
3
- "version": "5.1.1-alpha.13",
3
+ "version": "5.1.1-alpha.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "module-alias": "^2.2.3",
35
35
  "paypal-rest-sdk": "2.0.0-rc.2",
36
36
  "podcast-partytime": "^4.8.3",
37
- "podverse-helpers": "^5.1.2-alpha.6",
37
+ "podverse-helpers": "^5.1.2-alpha.7",
38
38
  "web-push": "^3.6.3"
39
39
  }
40
40
  }
@@ -1,15 +0,0 @@
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
- };
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAalB,CAAA"}
@@ -1,17 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- export declare function firebaseGenerateAccessToken(): Promise<string>;
2
- //# sourceMappingURL=firebaseGenerateAccessToken.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebaseGenerateAccessToken.d.ts","sourceRoot":"","sources":["../../../src/services/google/firebaseGenerateAccessToken.ts"],"names":[],"mappings":"AAgBA,wBAAsB,2BAA2B,oBAGhD"}