@chevre/domain 22.0.0-alpha.8 → 22.0.0-alpha.9

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 (38) hide show
  1. package/example/src/chevre/aggregateAllEvents2.ts +10 -5
  2. package/lib/chevre/credentials/customSearch.d.ts +13 -0
  3. package/lib/chevre/credentials/customSearch.js +14 -0
  4. package/lib/chevre/credentials/lineNotify.d.ts +17 -0
  5. package/lib/chevre/credentials/lineNotify.js +16 -0
  6. package/lib/chevre/credentials/sendGrid.d.ts +11 -0
  7. package/lib/chevre/credentials/sendGrid.js +13 -0
  8. package/lib/chevre/credentials.d.ts +16 -14
  9. package/lib/chevre/credentials.js +50 -67
  10. package/lib/chevre/service/assetTransaction/reserve/confirm.js +1 -2
  11. package/lib/chevre/service/assetTransaction/reserve/exportTasksById.d.ts +2 -1
  12. package/lib/chevre/service/assetTransaction/reserve/exportTasksById.js +4 -4
  13. package/lib/chevre/service/assetTransaction.d.ts +2 -1
  14. package/lib/chevre/service/assetTransaction.js +2 -2
  15. package/lib/chevre/service/notification.d.ts +14 -6
  16. package/lib/chevre/service/notification.js +24 -24
  17. package/lib/chevre/service/offer/factory.js +2 -3
  18. package/lib/chevre/service/offer/onEventChanged.js +20 -22
  19. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -6
  20. package/lib/chevre/service/payment/factory/createPayObjectServiceOutput.js +3 -6
  21. package/lib/chevre/service/payment/movieTicket/validation.js +1 -2
  22. package/lib/chevre/service/task/acceptCOAOffer.js +9 -9
  23. package/lib/chevre/service/task/authorizePayment.js +3 -3
  24. package/lib/chevre/service/task/confirmReserveTransaction.js +7 -7
  25. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +7 -8
  26. package/lib/chevre/service/task/importEventsFromCOA.js +7 -8
  27. package/lib/chevre/service/task/importOffersFromCOA.js +7 -8
  28. package/lib/chevre/service/task/returnReserveTransaction.js +7 -8
  29. package/lib/chevre/service/task/sendEmailMessage.js +5 -5
  30. package/lib/chevre/service/task/triggerWebhook.js +5 -5
  31. package/lib/chevre/service/task/voidReserveTransaction.js +7 -7
  32. package/lib/chevre/service/task.d.ts +14 -6
  33. package/lib/chevre/service/task.js +4 -8
  34. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateMovieTicket.js +60 -71
  35. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -1
  36. package/lib/chevre/settings.d.ts +28 -13
  37. package/lib/chevre/settings.js +5 -54
  38. package/package.json +1 -2
@@ -39,8 +39,10 @@ export async function aggregateScreeningEvent() {
39
39
  })({
40
40
  connection: mongoose.connection,
41
41
  redisClient,
42
+ credentials: {
43
+ sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
44
+ },
42
45
  settings: new chevre.settings.Settings({
43
- transactionWebhookUrls: [],
44
46
  onEventChanged: {
45
47
  informEvent: []
46
48
  },
@@ -53,8 +55,9 @@ export async function aggregateScreeningEvent() {
53
55
  onReservationStatusChanged: {
54
56
  informReservation: []
55
57
  },
56
- webhook: {
57
- timeout: 1000
58
+ notification: {
59
+ timeout: 1000,
60
+ useFetchAPI: true
58
61
  },
59
62
  userPoolIdOld: '',
60
63
  userPoolIdNew: '',
@@ -63,11 +66,13 @@ export async function aggregateScreeningEvent() {
63
66
  useOfferRateLimitProjects: [],
64
67
  defaultSenderEmail: 'test@example.com',
65
68
  deliverOrderLimit: 1,
66
- transaction: { confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
69
+ transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
67
70
  abortedTasksWithoutReport: [],
68
71
  gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
69
72
  movieticketReserve: { timeout: 1000, timeoutCheck: 1000 },
70
- numTryConfirmReserveTransaction: 10
73
+ numTryConfirmReserveTransaction: 10,
74
+ useAssetTransactionSyncProcessing: true,
75
+ useExperimentalFeature: false
71
76
  })
72
77
  });
73
78
  console.log('executed', count);
@@ -0,0 +1,13 @@
1
+ interface IOptions {
2
+ engineId: string;
3
+ apiKey: string;
4
+ }
5
+ /**
6
+ * GoogleCustomSearch認証情報
7
+ */
8
+ declare class CustomSearchCredentials {
9
+ readonly engineId: string;
10
+ readonly apiKey: string;
11
+ constructor(options: IOptions);
12
+ }
13
+ export { CustomSearchCredentials };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomSearchCredentials = void 0;
4
+ /**
5
+ * GoogleCustomSearch認証情報
6
+ */
7
+ class CustomSearchCredentials {
8
+ constructor(options) {
9
+ const { engineId, apiKey } = options;
10
+ this.engineId = engineId;
11
+ this.apiKey = apiKey;
12
+ }
13
+ }
14
+ exports.CustomSearchCredentials = CustomSearchCredentials;
@@ -0,0 +1,17 @@
1
+ interface IOptions {
2
+ url: string;
3
+ accessToken: string;
4
+ accessTokenAlert: string;
5
+ accessTokenInfo: string;
6
+ }
7
+ /**
8
+ * 通知認証情報
9
+ */
10
+ declare class LINENotifyCredentials {
11
+ readonly url: string;
12
+ readonly accessToken: string;
13
+ readonly accessTokenAlert: string;
14
+ readonly accessTokenInfo: string;
15
+ constructor(options: IOptions);
16
+ }
17
+ export { LINENotifyCredentials };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LINENotifyCredentials = void 0;
4
+ /**
5
+ * 通知認証情報
6
+ */
7
+ class LINENotifyCredentials {
8
+ constructor(options) {
9
+ const { url, accessToken, accessTokenAlert, accessTokenInfo } = options;
10
+ this.url = url;
11
+ this.accessToken = accessToken;
12
+ this.accessTokenAlert = accessTokenAlert;
13
+ this.accessTokenInfo = accessTokenInfo;
14
+ }
15
+ }
16
+ exports.LINENotifyCredentials = LINENotifyCredentials;
@@ -0,0 +1,11 @@
1
+ interface IOptions {
2
+ apiKey: string;
3
+ }
4
+ /**
5
+ * SendGrid認証情報
6
+ */
7
+ declare class SendGridCredentials {
8
+ readonly apiKey: string;
9
+ constructor(options: IOptions);
10
+ }
11
+ export { SendGridCredentials };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SendGridCredentials = void 0;
4
+ /**
5
+ * SendGrid認証情報
6
+ */
7
+ class SendGridCredentials {
8
+ constructor(options) {
9
+ const { apiKey } = options;
10
+ this.apiKey = apiKey;
11
+ }
12
+ }
13
+ exports.SendGridCredentials = SendGridCredentials;
@@ -1,28 +1,30 @@
1
1
  import type { COACredentials } from './credentials/coa';
2
+ import type { CustomSearchCredentials } from './credentials/customSearch';
2
3
  import type { JWTCredentials } from './credentials/jwt';
4
+ import type { LINENotifyCredentials } from './credentials/lineNotify';
5
+ import type { SendGridCredentials } from './credentials/sendGrid';
3
6
  /**
4
- * 外部サービスを使用するための認証情報
7
+ * 外部サービス認証情報
5
8
  */
6
9
  export declare namespace credentials {
7
- const customSearch: {
8
- engineId: string;
9
- apiKey: string;
10
- };
11
- const lineNotify: {
12
- url: string | undefined;
13
- accessToken: string | undefined;
14
- accessTokenAlert: string | undefined;
15
- accessTokenInfo: string | undefined;
16
- };
17
- const sendGrid: {
18
- apiKey: string | undefined;
19
- };
20
10
  type COA = COACredentials;
21
11
  namespace COA {
22
12
  function createInstance(...params: ConstructorParameters<typeof COACredentials>): Promise<COACredentials>;
23
13
  }
14
+ type CustomSearch = CustomSearchCredentials;
15
+ namespace CustomSearch {
16
+ function createInstance(...params: ConstructorParameters<typeof CustomSearchCredentials>): Promise<CustomSearchCredentials>;
17
+ }
24
18
  type JWT = JWTCredentials;
25
19
  namespace JWT {
26
20
  function createInstance(...params: ConstructorParameters<typeof JWTCredentials>): Promise<JWTCredentials>;
27
21
  }
22
+ type LINENotify = LINENotifyCredentials;
23
+ namespace LINENotify {
24
+ function createInstance(...params: ConstructorParameters<typeof LINENotifyCredentials>): Promise<LINENotifyCredentials>;
25
+ }
26
+ type SendGrid = SendGridCredentials;
27
+ namespace SendGrid {
28
+ function createInstance(...params: ConstructorParameters<typeof SendGridCredentials>): Promise<SendGridCredentials>;
29
+ }
28
30
  }
@@ -10,80 +10,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.credentials = void 0;
13
- // export const credentials = {
14
- // migrate to JWTCredentials(2024-07-11~)
15
- // jwt: {
16
- // secret: <string>process.env.TOKEN_SECRET,
17
- // // RESOURCE_SERVER_IDENTIFIERとは分離して指定可能に拡張(2024-05-02~)
18
- // // issuer: (typeof process.env.TOKEN_ISSUER_BY_AUTHORIZATION === 'string')
19
- // // ? process.env.TOKEN_ISSUER_BY_AUTHORIZATION
20
- // // : <string>process.env.RESOURCE_SERVER_IDENTIFIER,
21
- // /**
22
- // * トークン検証時の発行者リスト
23
- // */
24
- // issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
25
- // ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
26
- // : [], // 追加(2024-05-02~)
27
- // version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02', // 追加(2024-05-02~)
28
- // payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
29
- // }
30
- // };
31
13
  /**
32
- * 外部サービスを使用するための認証情報
14
+ * 外部サービス認証情報
33
15
  */
34
16
  var credentials;
35
17
  (function (credentials) {
36
- // export const aws = {
37
- // accessKeyId: <string>process.env.AWS_ACCESS_KEY_ID,
38
- // secretAccessKey: <string>process.env.AWS_SECRET_ACCESS_KEY,
39
- // tokenIssuerEndpoint: <string>process.env.TOKEN_ISSUER_ENDPOINT
18
+ // export const customSearch = {
19
+ // engineId: <string>process.env.CUSTOM_SEARCH_ENGINE_ID,
20
+ // apiKey: <string>process.env.GOOGLE_API_KEY
40
21
  // };
41
- // export const chevre = {
42
- // authorizeServerDomain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
43
- // clientId: <string>process.env.CHEVRE_CLIENT_ID,
44
- // clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
45
- // endpoint: <string>process.env.CHEVRE_ENDPOINT
22
+ // export const lineNotify = {
23
+ // url: process.env.LINE_NOTIFY_URL,
24
+ // accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
25
+ // accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT,
26
+ // accessTokenInfo: process.env.LINE_NOTIFY_ACCESS_TOKEN_INFO
46
27
  // };
47
- // export const coa = {
48
- // endpoint: <string>process.env.COA_ENDPOINT,
49
- // refreshToken: <string>process.env.COA_REFRESH_TOKEN,
50
- // // tslint:disable-next-line:no-magic-numbers
51
- // timeout: (typeof process.env.COA_TIMEOUT === 'string') ? Number(process.env.COA_TIMEOUT) : 20000,
52
- // useFetch: process.env.COA_USE_FETCH === '1'
28
+ // export const sendGrid = {
29
+ // apiKey: process.env.SENDGRID_API_KEY
53
30
  // };
54
- credentials.customSearch = {
55
- engineId: process.env.CUSTOM_SEARCH_ENGINE_ID,
56
- apiKey: process.env.GOOGLE_API_KEY
57
- };
58
- // export const gmo = {
59
- // // tslint:disable-next-line:no-magic-numbers
60
- // timeout: (typeof process.env.GMO_TIMEOUT === 'string') ? Number(process.env.GMO_TIMEOUT) : 5000,
61
- // timeoutBackground: (typeof process.env.GMO_TIMEOUT_BACKGROUND === 'string')
62
- // ? Number(process.env.GMO_TIMEOUT_BACKGROUND)
63
- // : undefined,
64
- // useFetch: process.env.GMO_USE_FETCH === '1'
65
- // };
66
- credentials.lineNotify = {
67
- url: process.env.LINE_NOTIFY_URL,
68
- accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
69
- accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT,
70
- accessTokenInfo: process.env.LINE_NOTIFY_ACCESS_TOKEN_INFO
71
- };
72
- // export const movieticketReserve = {
73
- // /**
74
- // * 着券時タイムアウト
75
- // */
76
- // // tslint:disable-next-line:no-magic-numbers
77
- // timeout: (typeof process.env.MVTK_TIMEOUT === 'string') ? Number(process.env.MVTK_TIMEOUT) : 5000,
78
- // /**
79
- // * 認証時タイムアウト
80
- // */
81
- // // tslint:disable-next-line:no-magic-numbers
82
- // timeoutCheck: (typeof process.env.MVTK_TIMEOUT_CHECK === 'string') ? Number(process.env.MVTK_TIMEOUT_CHECK) : 5000
83
- // };
84
- credentials.sendGrid = {
85
- apiKey: process.env.SENDGRID_API_KEY
86
- };
87
31
  let COA;
88
32
  (function (COA) {
89
33
  let cred;
@@ -97,6 +41,19 @@ var credentials;
97
41
  }
98
42
  COA.createInstance = createInstance;
99
43
  })(COA = credentials.COA || (credentials.COA = {}));
44
+ let CustomSearch;
45
+ (function (CustomSearch) {
46
+ let cred;
47
+ function createInstance(...params) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ if (cred === undefined) {
50
+ cred = (yield Promise.resolve().then(() => require('./credentials/customSearch'))).CustomSearchCredentials;
51
+ }
52
+ return new cred(...params);
53
+ });
54
+ }
55
+ CustomSearch.createInstance = createInstance;
56
+ })(CustomSearch = credentials.CustomSearch || (credentials.CustomSearch = {}));
100
57
  let JWT;
101
58
  (function (JWT) {
102
59
  let cred;
@@ -110,4 +67,30 @@ var credentials;
110
67
  }
111
68
  JWT.createInstance = createInstance;
112
69
  })(JWT = credentials.JWT || (credentials.JWT = {}));
70
+ let LINENotify;
71
+ (function (LINENotify) {
72
+ let cred;
73
+ function createInstance(...params) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ if (cred === undefined) {
76
+ cred = (yield Promise.resolve().then(() => require('./credentials/lineNotify'))).LINENotifyCredentials;
77
+ }
78
+ return new cred(...params);
79
+ });
80
+ }
81
+ LINENotify.createInstance = createInstance;
82
+ })(LINENotify = credentials.LINENotify || (credentials.LINENotify = {}));
83
+ let SendGrid;
84
+ (function (SendGrid) {
85
+ let cred;
86
+ function createInstance(...params) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ if (cred === undefined) {
89
+ cred = (yield Promise.resolve().then(() => require('./credentials/sendGrid'))).SendGridCredentials;
90
+ }
91
+ return new cred(...params);
92
+ });
93
+ }
94
+ SendGrid.createInstance = createInstance;
95
+ })(SendGrid = credentials.SendGrid || (credentials.SendGrid = {}));
113
96
  })(credentials = exports.credentials || (exports.credentials = {}));
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.confirm = void 0;
13
13
  const factory = require("../../../factory");
14
- const settings_1 = require("../../../settings");
15
14
  const confirmReservation_1 = require("../../reserve/confirmReservation");
16
15
  const factory_1 = require("./confirm/factory");
17
16
  /**
@@ -53,7 +52,7 @@ function confirm(params) {
53
52
  potentialActions }, (typeof (underName === null || underName === void 0 ? void 0 : underName.typeOf) === 'string')
54
53
  ? { object: { underName } }
55
54
  : undefined));
56
- if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
55
+ if (settings.useAssetTransactionSyncProcessing) {
57
56
  // sync対応(2023-01-13~)
58
57
  yield (0, confirmReservation_1.confirmReservation)({
59
58
  // optimize(2024-07-01~)
@@ -1,9 +1,10 @@
1
+ import { Settings } from '../../../settings';
1
2
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
2
3
  import type { TaskRepo } from '../../../repo/task';
3
4
  type ITaskAndTransactionOperation<T> = (repos: {
4
5
  task: TaskRepo;
5
6
  assetTransaction: AssetTransactionRepo;
6
- }) => Promise<T>;
7
+ }, settings: Settings) => Promise<T>;
7
8
  /**
8
9
  * 取引タスク出力
9
10
  */
@@ -11,13 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.exportTasksById = void 0;
13
13
  const factory = require("../../../factory");
14
- const settings_1 = require("../../../settings");
15
14
  /**
16
15
  * 取引タスク出力
17
16
  */
18
17
  function exportTasksById(params) {
19
18
  // tslint:disable-next-line:max-func-body-length
20
- return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
20
+ const { useAssetTransactionSyncProcessing } = settings;
21
21
  const transaction = yield repos.assetTransaction.findById({
22
22
  typeOf: factory.assetTransactionType.Reserve,
23
23
  id: params.id
@@ -33,7 +33,7 @@ function exportTasksById(params) {
33
33
  // if (Array.isArray(potentialActions.reserve) && potentialActions.reserve.length > 0) {
34
34
  // }
35
35
  // }
36
- if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
36
+ if (!useAssetTransactionSyncProcessing) {
37
37
  const reserveTask = {
38
38
  project: transaction.project,
39
39
  name: factory.taskName.Reserve,
@@ -49,7 +49,7 @@ function exportTasksById(params) {
49
49
  break;
50
50
  case factory.transactionStatusType.Canceled:
51
51
  // sync対応(2023-01-13~)
52
- if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
52
+ if (!useAssetTransactionSyncProcessing) {
53
53
  // const cancelActionAttributes4canceled = createCancelPendingReservationAction({ transaction });
54
54
  // if (cancelActionAttributes4canceled !== undefined) {
55
55
  // }
@@ -2,6 +2,7 @@
2
2
  * 取引サービス
3
3
  */
4
4
  import * as factory from '../factory';
5
+ import { Settings } from '../settings';
5
6
  import type { AssetTransactionRepo } from '../repo/assetTransaction';
6
7
  import type { TaskRepo } from '../repo/task';
7
8
  import * as CancelReservationTransactionService from './assetTransaction/cancelReservation';
@@ -37,6 +38,6 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
37
38
  }): (repos: {
38
39
  task: TaskRepo;
39
40
  assetTransaction: AssetTransactionRepo;
40
- }) => Promise<{
41
+ }, settings: Settings) => Promise<{
41
42
  id: string;
42
43
  }[] | undefined>;
@@ -30,7 +30,7 @@ exports.reserve = ReserveTransactionService;
30
30
  * ひとつの取引のタスクをエクスポートする
31
31
  */
32
32
  function exportTasks(params) {
33
- return (repos) => __awaiter(this, void 0, void 0, function* () {
33
+ return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
34
34
  const transaction = yield repos.assetTransaction.startExportTasks(Object.assign({ typeOf: params.typeOf, status: params.status, tasksExportAction: {
35
35
  agent: { name: params.tasksExportAction.agent.name }
36
36
  } }, (typeof params.id === 'string') ? { id: params.id } : undefined));
@@ -74,7 +74,7 @@ function exportTasks(params) {
74
74
  createdTasks = yield ReserveTransactionService.exportTasksById({
75
75
  id: transaction.id
76
76
  // runsTasksAfterInSeconds: params.runsTasksAfterInSeconds
77
- })(repos);
77
+ })(repos, settings);
78
78
  break;
79
79
  default:
80
80
  }
@@ -1,11 +1,12 @@
1
- import { Settings } from '../settings';
1
+ import { LINENotifyCredentials } from '../credentials/lineNotify';
2
+ import { SendGridCredentials } from '../credentials/sendGrid';
2
3
  import * as factory from '../factory';
3
4
  import type { ActionRepo } from '../repo/action';
4
5
  import type { MessageRepo } from '../repo/message';
5
6
  import type { ProjectRepo } from '../repo/project';
6
- type ILineNotifyOperation<T> = (repos: {
7
- useFetchAPI: boolean;
8
- }, settings: Settings) => Promise<T>;
7
+ type ILineNotifyOperation<T> = (repos: {}, credentials: {
8
+ lineNotify: LINENotifyCredentials;
9
+ }) => Promise<T>;
9
10
  /**
10
11
  * Eメールメッセージを送信する
11
12
  * https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
@@ -18,6 +19,8 @@ declare function sendEmailMessage(params: factory.task.sendEmailMessage.IActionA
18
19
  action: ActionRepo;
19
20
  message: MessageRepo;
20
21
  project: ProjectRepo;
22
+ }, credentials: {
23
+ sendGrid: SendGridCredentials;
21
24
  }) => Promise<void>;
22
25
  type LineNotifyLogLevel = 'log' | 'error' | 'info';
23
26
  declare function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }: {
@@ -26,13 +29,18 @@ declare function lineNotify({ subject, content, imageThumbnail, imageFullsize, l
26
29
  imageThumbnail?: string;
27
30
  imageFullsize?: string;
28
31
  logLevel: LineNotifyLogLevel;
32
+ }, options: {
33
+ timeout: number;
34
+ useFetchAPI: boolean;
29
35
  }): ILineNotifyOperation<void>;
30
36
  declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook> & {
31
37
  project: {
32
38
  id: string;
33
39
  };
40
+ }, options: {
41
+ timeout: number;
42
+ useFetchAPI: boolean;
34
43
  }): (repos: {
35
44
  action: ActionRepo;
36
- useFetchAPI: boolean;
37
- }, settings: Settings) => Promise<void>;
45
+ }) => Promise<void>;
38
46
  export { lineNotify, sendEmailMessage, triggerWebhook };
@@ -14,7 +14,6 @@ const sgMail = require("@sendgrid/mail");
14
14
  const http_status_1 = require("http-status");
15
15
  // import * as request from 'request';
16
16
  const util = require("util");
17
- const credentials_1 = require("../credentials");
18
17
  const factory = require("../factory");
19
18
  function createSendEmailMessageActionAttributes(params) {
20
19
  var _a;
@@ -27,7 +26,7 @@ function createSendEmailMessageActionAttributes(params) {
27
26
  */
28
27
  function sendEmailMessage(params) {
29
28
  // tslint:disable-next-line:max-func-body-length
30
- return (repos) => __awaiter(this, void 0, void 0, function* () {
29
+ return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
31
30
  var _a, _b, _c, _d, _e;
32
31
  const project = yield repos.project.findById({
33
32
  id: params.project.id,
@@ -37,7 +36,7 @@ function sendEmailMessage(params) {
37
36
  const action = yield repos.action.start(createSendEmailMessageActionAttributes(params));
38
37
  let result = {};
39
38
  try {
40
- let apiKey = credentials_1.credentials.sendGrid.apiKey;
39
+ let apiKey = credentials.sendGrid.apiKey;
41
40
  // プロジェクト固有のSendGrid設定があれば、そちらを使用
42
41
  if (typeof ((_a = project.settings) === null || _a === void 0 ? void 0 : _a.sendgridApiKey) === 'string' && project.settings.sendgridApiKey.length > 0) {
43
42
  apiKey = project.settings.sendgridApiKey;
@@ -124,23 +123,23 @@ function sendEmailMessage(params) {
124
123
  }
125
124
  exports.sendEmailMessage = sendEmailMessage;
126
125
  const MAX_LINE_NOTIFY_SUBJECT_LENGTH = 100;
127
- function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }) {
128
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
129
- var _a;
130
- const LINE_NOTIFY_URL = credentials_1.credentials.lineNotify.url;
126
+ function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }, options) {
127
+ return (__, credentials) => __awaiter(this, void 0, void 0, function* () {
128
+ const { timeout, useFetchAPI } = options;
129
+ const LINE_NOTIFY_URL = credentials.lineNotify.url;
131
130
  if (typeof LINE_NOTIFY_URL !== 'string') {
132
131
  throw new factory.errors.Internal('Environment variable LINE_NOTIFY_URL not set');
133
132
  }
134
133
  let accessToken;
135
134
  switch (logLevel) {
136
135
  case 'error':
137
- accessToken = credentials_1.credentials.lineNotify.accessTokenAlert;
136
+ accessToken = credentials.lineNotify.accessTokenAlert;
138
137
  break;
139
138
  case 'info':
140
- accessToken = credentials_1.credentials.lineNotify.accessTokenInfo;
139
+ accessToken = credentials.lineNotify.accessTokenInfo;
141
140
  break;
142
141
  default:
143
- accessToken = credentials_1.credentials.lineNotify.accessToken;
142
+ accessToken = credentials.lineNotify.accessToken;
144
143
  }
145
144
  if (typeof accessToken !== 'string') {
146
145
  throw new factory.errors.Internal('credentials.lineNotify.accessToken not set');
@@ -151,7 +150,7 @@ function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel
151
150
  const message = util.format('\n%s\n%s\n%s\n%s\n%s\n\n%s', `[${logLevel}] ${shortSubject}`, `now:${(new Date()).toISOString()}`, `pid:${process.pid}`, `GAE_APPLICATION:${process.env.GAE_APPLICATION}`,
152
151
  // `GAE_INSTANCE:${process.env.GAE_INSTANCE}`,
153
152
  `GAE_SERVICE:${process.env.GAE_SERVICE}`, content);
154
- if (repos.useFetchAPI) {
153
+ if (useFetchAPI) {
155
154
  try {
156
155
  const form = new FormData();
157
156
  form.set('message', message);
@@ -163,8 +162,8 @@ function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel
163
162
  }
164
163
  const res = yield fetch(LINE_NOTIFY_URL, Object.assign({ method: 'POST', headers: {
165
164
  Authorization: `Bearer ${accessToken}`
166
- }, body: form }, (typeof ((_a = settings.webhook) === null || _a === void 0 ? void 0 : _a.timeout) === 'number')
167
- ? { signal: AbortSignal.timeout(settings.webhook.timeout) }
165
+ }, body: form }, (typeof timeout === 'number')
166
+ ? { signal: AbortSignal.timeout(timeout) }
168
167
  : undefined));
169
168
  let body;
170
169
  try {
@@ -193,8 +192,8 @@ exports.lineNotify = lineNotify;
193
192
  const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
194
193
  const TRIGGER_WEBHOOK_MAX_RETRY_COUNT = 2;
195
194
  const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = 1000;
196
- function triggerWebhook(params) {
197
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
195
+ function triggerWebhook(params, options) {
196
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
198
197
  // retryableにする(2023-05-12~)
199
198
  let retry = true;
200
199
  let numberOfTry = 0;
@@ -208,7 +207,7 @@ function triggerWebhook(params) {
208
207
  if (numberOfTry > 1) {
209
208
  yield sleep(TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS * (numberOfTry - 1));
210
209
  }
211
- yield processInformAction(params)(repos, settings);
210
+ yield processInformAction(params, options)(repos);
212
211
  break;
213
212
  }
214
213
  catch (error) {
@@ -236,22 +235,23 @@ function createInformActionAttributes(params) {
236
235
  const { object, purpose, recipient, project } = params;
237
236
  return Object.assign({ agent: { id: project.id, typeOf: factory.organizationType.Project }, object, project: { id: project.id, typeOf: factory.organizationType.Project }, recipient, typeOf: factory.actionType.InformAction }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined);
238
237
  }
239
- function processInformAction(params) {
240
- return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
241
- var _a, _b, _c;
238
+ function processInformAction(params, options) {
239
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
240
+ var _a, _b;
241
+ const { timeout, useFetchAPI } = options;
242
242
  const action = yield repos.action.start(createInformActionAttributes(params));
243
243
  let result = {};
244
244
  try {
245
245
  if (typeof ((_a = params.recipient) === null || _a === void 0 ? void 0 : _a.url) === 'string') {
246
246
  const url = params.recipient.url;
247
- if (repos.useFetchAPI) {
247
+ if (useFetchAPI) {
248
248
  try {
249
249
  const res = yield fetch(url, Object.assign({ method: 'POST', headers: {
250
250
  'Content-Type': 'application/json'
251
251
  }, body: JSON.stringify({
252
252
  data: params.object
253
- }) }, (typeof ((_b = settings.webhook) === null || _b === void 0 ? void 0 : _b.timeout) === 'number')
254
- ? { signal: AbortSignal.timeout(settings.webhook.timeout) }
253
+ }) }, (typeof timeout === 'number')
254
+ ? { signal: AbortSignal.timeout(timeout) }
255
255
  : undefined));
256
256
  let body;
257
257
  try {
@@ -267,7 +267,7 @@ function processInformAction(params) {
267
267
  case http_status_1.NO_CONTENT:
268
268
  result = {
269
269
  statusCode: res.status,
270
- useFetchAPI: repos.useFetchAPI
270
+ useFetchAPI
271
271
  };
272
272
  break;
273
273
  default:
@@ -286,7 +286,7 @@ function processInformAction(params) {
286
286
  catch (error) {
287
287
  let throwsError = true;
288
288
  // プロジェクト固有の特別対応
289
- if (error.statusCode === http_status_1.INTERNAL_SERVER_ERROR && ((_c = error.body) === null || _c === void 0 ? void 0 : _c.message) === USERNAME_ARGUMENT_REQUIRED_MESSAGE) {
289
+ if (error.statusCode === http_status_1.INTERNAL_SERVER_ERROR && ((_b = error.body) === null || _b === void 0 ? void 0 : _b.message) === USERNAME_ARGUMENT_REQUIRED_MESSAGE) {
290
290
  throwsError = false;
291
291
  }
292
292
  if (throwsError) {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCompoundPriceSpec4event = void 0;
4
4
  const factory = require("../../factory");
5
- const settings_1 = require("../../settings");
6
5
  function categoryCodeChargePriceSpec2component(params) {
7
6
  var _a;
8
7
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToCategoryCode: params.appliesToCategoryCode }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
@@ -77,11 +76,11 @@ function createCompoundPriceSpec4event(params) {
77
76
  };
78
77
  // 必要な属性のみに限定(2023-02-24~)
79
78
  const { acceptedPaymentMethod, name, description, alternateName, color, typeOf, id, availability, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
80
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
79
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
81
80
  category,
82
81
  eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
83
82
  priceCurrency,
84
83
  validFrom, validThrough, validRateLimit, additionalProperty,
85
- identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined), (Array.isArray(acceptedPaymentMethod)) ? { acceptedPaymentMethod } : undefined), (!settings_1.USE_OPTIMIZE_TICKET_OFFER) ? {} : undefined);
84
+ identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined), (Array.isArray(acceptedPaymentMethod)) ? { acceptedPaymentMethod } : undefined);
86
85
  }
87
86
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;