@chevre/domain 22.0.0-alpha.10 → 22.0.0-alpha.11

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.
@@ -69,6 +69,7 @@ export async function aggregateScreeningEvent() {
69
69
  deliverOrderLimit: 1,
70
70
  transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
71
71
  abortedTasksWithoutReport: [],
72
+ coa: { timeout: 1000 },
72
73
  gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
73
74
  movieticketReserve: { timeout: 1000, timeoutCheck: 1000 },
74
75
  numTryConfirmReserveTransaction: 10,
@@ -1,4 +1,3 @@
1
- import type { COACredentials } from './credentials/coa';
2
1
  import type { CustomSearchCredentials } from './credentials/customSearch';
3
2
  import type { JWTCredentials } from './credentials/jwt';
4
3
  import type { LINENotifyCredentials } from './credentials/lineNotify';
@@ -7,10 +6,6 @@ import type { SendGridCredentials } from './credentials/sendGrid';
7
6
  * 外部サービス認証情報
8
7
  */
9
8
  export declare namespace credentials {
10
- type COA = COACredentials;
11
- namespace COA {
12
- function createInstance(...params: ConstructorParameters<typeof COACredentials>): Promise<COACredentials>;
13
- }
14
9
  type CustomSearch = CustomSearchCredentials;
15
10
  namespace CustomSearch {
16
11
  function createInstance(...params: ConstructorParameters<typeof CustomSearchCredentials>): Promise<CustomSearchCredentials>;
@@ -28,19 +28,6 @@ var credentials;
28
28
  // export const sendGrid = {
29
29
  // apiKey: process.env.SENDGRID_API_KEY
30
30
  // };
31
- let COA;
32
- (function (COA) {
33
- let cred;
34
- function createInstance(...params) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- if (cred === undefined) {
37
- cred = (yield Promise.resolve().then(() => require('./credentials/coa'))).COACredentials;
38
- }
39
- return new cred(...params);
40
- });
41
- }
42
- COA.createInstance = createInstance;
43
- })(COA = credentials.COA || (credentials.COA = {}));
44
31
  let CustomSearch;
45
32
  (function (CustomSearch) {
46
33
  let cred;
@@ -17,15 +17,13 @@ const event_1 = require("../../repo/event");
17
17
  const transaction_1 = require("../../repo/transaction");
18
18
  const transactionProcess_1 = require("../../repo/transactionProcess");
19
19
  const acceptOffer_1 = require("../offer/eventServiceByCOA/acceptOffer");
20
- let coaAuthClient;
21
20
  /**
22
21
  * タスク実行関数
23
22
  */
24
23
  function call(params) {
25
- return (settings, options) => __awaiter(this, void 0, void 0, function* () {
26
- const { connection, credentials, redisClient } = settings;
27
- if (credentials.coa === undefined) {
28
- throw new factory.errors.Argument('settings', 'coaCredentials required');
24
+ return ({ connection, redisClient, settings, coaAuthClient }, options) => __awaiter(this, void 0, void 0, function* () {
25
+ if (coaAuthClient === undefined) {
26
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
29
27
  }
30
28
  if (redisClient === undefined) {
31
29
  throw new factory.errors.Argument('settings', 'redisClient required');
@@ -34,24 +32,17 @@ function call(params) {
34
32
  if (!options.executeById) {
35
33
  return;
36
34
  }
37
- if (coaAuthClient === undefined) {
38
- coaAuthClient = new COA.auth.RefreshToken({
39
- endpoint: credentials.coa.endpoint,
40
- refreshToken: credentials.coa.refreshToken,
41
- useFetch: credentials.coa.useFetch
42
- });
43
- }
44
- const actionRepo = new action_1.ActionRepo(settings.connection);
35
+ const actionRepo = new action_1.ActionRepo(connection);
45
36
  const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
46
37
  try {
47
38
  const reserveService = new COA.service.Reserve({
48
- endpoint: credentials.coa.endpoint,
39
+ endpoint: coaAuthClient.options.endpoint,
49
40
  auth: coaAuthClient
50
- }, { timeout: credentials.coa.timeout });
41
+ }, { timeout: settings.coa.timeout });
51
42
  const masterService = new COA.service.Master({
52
- endpoint: credentials.coa.endpoint,
43
+ endpoint: coaAuthClient.options.endpoint,
53
44
  auth: coaAuthClient
54
- }, { timeout: credentials.coa.timeout });
45
+ }, { timeout: settings.coa.timeout });
55
46
  const { object, potentialActions, purpose } = params.data;
56
47
  if (typeof potentialActions.id === 'string') {
57
48
  yield (0, acceptOffer_1.reAcceptOffer)({
@@ -23,26 +23,18 @@ const task_1 = require("../../repo/task");
23
23
  const ReserveTransactionService = require("../assetTransaction/reserve");
24
24
  const COAReserveService = require("../assetTransaction/reserveCOA");
25
25
  const factory_1 = require("../assetTransaction/reserveCOA/factory");
26
- let coaAuthClient;
27
26
  /**
28
27
  * タスク実行関数
29
28
  */
30
29
  function call(params) {
31
- return ({ connection, credentials, settings }) => __awaiter(this, void 0, void 0, function* () {
32
- if (credentials.coa === undefined) {
33
- throw new factory.errors.Argument('settings', 'coaCredentials required');
34
- }
30
+ return ({ connection, settings, coaAuthClient }) => __awaiter(this, void 0, void 0, function* () {
35
31
  if (coaAuthClient === undefined) {
36
- coaAuthClient = new COA.auth.RefreshToken({
37
- endpoint: credentials.coa.endpoint,
38
- refreshToken: credentials.coa.refreshToken,
39
- useFetch: credentials.coa.useFetch
40
- });
32
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
41
33
  }
42
34
  const reserveService = new COA.service.Reserve({
43
- endpoint: credentials.coa.endpoint,
35
+ endpoint: coaAuthClient.options.endpoint,
44
36
  auth: coaAuthClient
45
- }, { timeout: credentials.coa.timeout });
37
+ }, { timeout: settings.coa.timeout });
46
38
  yield confirmReserveTransaction(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }), {
47
39
  sendOrder: true,
48
40
  useOnOrderStatusChanged: true
@@ -14,26 +14,18 @@ const COA = require("@motionpicture/coa-service");
14
14
  const factory = require("../../factory");
15
15
  const event_1 = require("../../repo/event");
16
16
  const EventAggregationService = require("../aggregation/event");
17
- let coaAuthClient;
18
17
  /**
19
18
  * タスク実行関数
20
19
  */
21
20
  function call(data) {
22
- return ({ connection, credentials }) => __awaiter(this, void 0, void 0, function* () {
23
- if (credentials.coa === undefined) {
24
- throw new factory.errors.Argument('settings', 'coaCredentials required');
25
- }
21
+ return ({ connection, settings, coaAuthClient }) => __awaiter(this, void 0, void 0, function* () {
26
22
  if (coaAuthClient === undefined) {
27
- coaAuthClient = new COA.auth.RefreshToken({
28
- endpoint: credentials.coa.endpoint,
29
- refreshToken: credentials.coa.refreshToken,
30
- useFetch: credentials.coa.useFetch
31
- });
23
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
32
24
  }
33
25
  const reserveService = new COA.service.Reserve({
34
- endpoint: credentials.coa.endpoint,
26
+ endpoint: coaAuthClient.options.endpoint,
35
27
  auth: coaAuthClient
36
- }, { timeout: credentials.coa.timeout });
28
+ }, { timeout: settings.coa.timeout });
37
29
  yield EventAggregationService.importFromCOA(data)({
38
30
  event: new event_1.EventRepo(connection),
39
31
  reserveService
@@ -20,26 +20,18 @@ const movieTheater_1 = require("../../repo/place/movieTheater");
20
20
  const screeningRoom_1 = require("../../repo/place/screeningRoom");
21
21
  const seller_1 = require("../../repo/seller");
22
22
  const EventService = require("../event");
23
- let coaAuthClient;
24
23
  /**
25
24
  * タスク実行関数
26
25
  */
27
26
  function call(data) {
28
- return ({ connection, credentials }) => __awaiter(this, void 0, void 0, function* () {
29
- if (credentials.coa === undefined) {
30
- throw new factory.errors.Argument('settings', 'coaCredentials required');
31
- }
27
+ return ({ connection, settings, coaAuthClient }) => __awaiter(this, void 0, void 0, function* () {
32
28
  if (coaAuthClient === undefined) {
33
- coaAuthClient = new COA.auth.RefreshToken({
34
- endpoint: credentials.coa.endpoint,
35
- refreshToken: credentials.coa.refreshToken,
36
- useFetch: credentials.coa.useFetch
37
- });
29
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
38
30
  }
39
31
  const masterService = new COA.service.Master({
40
- endpoint: credentials.coa.endpoint,
32
+ endpoint: coaAuthClient.options.endpoint,
41
33
  auth: coaAuthClient
42
- }, { timeout: credentials.coa.timeout });
34
+ }, { timeout: settings.coa.timeout });
43
35
  yield EventService.importFromCOA(data)({
44
36
  action: new action_1.ActionRepo(connection),
45
37
  categoryCode: new categoryCode_1.CategoryCodeRepo(connection),
@@ -16,29 +16,21 @@ const categoryCode_1 = require("../../repo/categoryCode");
16
16
  const offer_1 = require("../../repo/offer");
17
17
  const task_1 = require("../../repo/task");
18
18
  const OfferService = require("../offer");
19
- let coaAuthClient;
20
19
  /**
21
20
  * タスク実行関数
22
21
  */
23
22
  function call(data) {
24
- return ({ connection, credentials }) => __awaiter(this, void 0, void 0, function* () {
25
- if (credentials.coa === undefined) {
26
- throw new factory.errors.Argument('settings', 'coaCredentials required');
23
+ return ({ connection, settings, coaAuthClient }) => __awaiter(this, void 0, void 0, function* () {
24
+ if (coaAuthClient === undefined) {
25
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
27
26
  }
28
27
  const categoryCodeRepo = new categoryCode_1.CategoryCodeRepo(connection);
29
28
  const offerRepo = new offer_1.OfferRepo(connection);
30
29
  const taskRepo = new task_1.TaskRepo(connection);
31
- if (coaAuthClient === undefined) {
32
- coaAuthClient = new COA.auth.RefreshToken({
33
- endpoint: credentials.coa.endpoint,
34
- refreshToken: credentials.coa.refreshToken,
35
- useFetch: credentials.coa.useFetch
36
- });
37
- }
38
30
  const masterService = new COA.service.Master({
39
- endpoint: credentials.coa.endpoint,
31
+ endpoint: coaAuthClient.options.endpoint,
40
32
  auth: coaAuthClient
41
- }, { timeout: credentials.coa.timeout });
33
+ }, { timeout: settings.coa.timeout });
42
34
  yield OfferService.event.importFromCOA(data)({
43
35
  categoryCode: categoryCodeRepo,
44
36
  offer: offerRepo,
@@ -21,29 +21,21 @@ const transactionNumber_1 = require("../../repo/transactionNumber");
21
21
  const CancelReservationTransactionService = require("../assetTransaction/cancelReservation");
22
22
  const CancelReservationCOAService = require("../assetTransaction/cancelReservationCOA");
23
23
  const factory_1 = require("../assetTransaction/cancelReservationCOA/factory");
24
- let coaAuthClient;
25
24
  /**
26
25
  * タスク実行関数
27
26
  */
28
27
  function call(params) {
29
- return ({ connection, credentials, redisClient }) => __awaiter(this, void 0, void 0, function* () {
30
- if (credentials.coa === undefined) {
31
- throw new factory.errors.Argument('settings', 'coaCredentials required');
28
+ return ({ connection, redisClient, settings, coaAuthClient }) => __awaiter(this, void 0, void 0, function* () {
29
+ if (coaAuthClient === undefined) {
30
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
32
31
  }
33
32
  if (redisClient === undefined) {
34
33
  throw new factory.errors.Argument('settings', 'redisClient required');
35
34
  }
36
- if (coaAuthClient === undefined) {
37
- coaAuthClient = new COA.auth.RefreshToken({
38
- endpoint: credentials.coa.endpoint,
39
- refreshToken: credentials.coa.refreshToken,
40
- useFetch: credentials.coa.useFetch
41
- });
42
- }
43
35
  const reserveService = new COA.service.Reserve({
44
- endpoint: credentials.coa.endpoint,
36
+ endpoint: coaAuthClient.options.endpoint,
45
37
  auth: coaAuthClient
46
- }, { timeout: credentials.coa.timeout });
38
+ }, { timeout: settings.coa.timeout });
47
39
  yield returnReserve(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
48
40
  action: new action_1.ActionRepo(connection),
49
41
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
@@ -22,15 +22,14 @@ const task_1 = require("../../repo/task");
22
22
  const transaction_1 = require("../../repo/transaction");
23
23
  const transactionProcess_1 = require("../../repo/transactionProcess");
24
24
  const event_1 = require("../offer/event");
25
- let coaAuthClient;
26
25
  /**
27
26
  * タスク実行関数
28
27
  */
29
28
  function call(params) {
30
29
  // export function call(data: factory.task.IData<factory.taskName.VoidReserveTransaction>): IOperationExecute<void> {
31
- return ({ connection, credentials, redisClient, settings }, options) => __awaiter(this, void 0, void 0, function* () {
32
- if (credentials.coa === undefined) {
33
- throw new factory.errors.Argument('settings', 'coaCredentials required');
30
+ return ({ connection, redisClient, settings, coaAuthClient }, options) => __awaiter(this, void 0, void 0, function* () {
31
+ if (coaAuthClient === undefined) {
32
+ throw new factory.errors.Argument('settings', 'coaAuthClient required');
34
33
  }
35
34
  if (redisClient === undefined) {
36
35
  throw new factory.errors.Argument('settings', 'redisClient required');
@@ -42,17 +41,10 @@ function call(params) {
42
41
  return;
43
42
  }
44
43
  }
45
- if (coaAuthClient === undefined) {
46
- coaAuthClient = new COA.auth.RefreshToken({
47
- endpoint: credentials.coa.endpoint,
48
- refreshToken: credentials.coa.refreshToken,
49
- useFetch: credentials.coa.useFetch
50
- });
51
- }
52
44
  const reserveService = new COA.service.Reserve({
53
- endpoint: credentials.coa.endpoint,
45
+ endpoint: coaAuthClient.options.endpoint,
54
46
  auth: coaAuthClient
55
- }, { timeout: credentials.coa.timeout });
47
+ }, { timeout: settings.coa.timeout });
56
48
  const transactionProcessRepo = new transactionProcess_1.TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
57
49
  try {
58
50
  yield (0, event_1.voidTransaction)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
@@ -1,6 +1,9 @@
1
+ /**
2
+ * タスクサービス
3
+ */
4
+ import type * as COA from '@motionpicture/coa-service';
1
5
  import type { Connection } from 'mongoose';
2
6
  import type { RedisClientType } from 'redis';
3
- import { COACredentials } from '../credentials/coa';
4
7
  import { JWTCredentials } from '../credentials/jwt';
5
8
  import { LINENotifyCredentials } from '../credentials/lineNotify';
6
9
  import { SendGridCredentials } from '../credentials/sendGrid';
@@ -8,7 +11,6 @@ import * as factory from '../factory';
8
11
  import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/task';
9
12
  import { Settings } from '../settings';
10
13
  interface ICredentialSettings {
11
- coa?: COACredentials;
12
14
  jwt?: JWTCredentials;
13
15
  sendGrid: SendGridCredentials;
14
16
  }
@@ -23,6 +25,7 @@ interface IExecuteSettings {
23
25
  redisClient?: RedisClientType;
24
26
  credentials: ICredentialSettings;
25
27
  settings: Settings;
28
+ coaAuthClient?: COA.auth.RefreshToken;
26
29
  }
27
30
  interface IExecuteOptions {
28
31
  executeById: boolean;
@@ -10,9 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.notifyAbortedTasks = exports.abort = exports.execute = exports.executeByName = exports.executeById = void 0;
13
- /**
14
- * タスクサービス
15
- */
16
13
  const createDebug = require("debug");
17
14
  const moment = require("moment");
18
15
  const factory = require("../factory");
@@ -35,6 +35,9 @@ interface IOptions {
35
35
  };
36
36
  defaultSenderEmail: string;
37
37
  deliverOrderLimit: number;
38
+ coa: {
39
+ timeout: number;
40
+ };
38
41
  gmo: {
39
42
  timeout: number;
40
43
  timeoutBackground: number;
@@ -99,6 +102,9 @@ declare class Settings {
99
102
  };
100
103
  readonly defaultSenderEmail: string;
101
104
  readonly deliverOrderLimit: number;
105
+ readonly coa: {
106
+ timeout: number;
107
+ };
102
108
  readonly gmo: {
103
109
  timeout: number;
104
110
  timeoutBackground: number;
@@ -14,7 +14,7 @@ exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
14
14
  */
15
15
  class Settings {
16
16
  constructor(options) {
17
- const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, useAggregateEntranceGateProjects, useAggregateOfferProjects, useOfferRateLimitProjects, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
17
+ const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, useAggregateEntranceGateProjects, useAggregateOfferProjects, useOfferRateLimitProjects, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
18
18
  this.onEventChanged = onEventChanged;
19
19
  this.onOrderStatusChanged = onOrderStatusChanged;
20
20
  this.onResourceUpdated = onResourceUpdated;
@@ -29,6 +29,7 @@ class Settings {
29
29
  this.transaction = transaction;
30
30
  this.defaultSenderEmail = defaultSenderEmail;
31
31
  this.deliverOrderLimit = deliverOrderLimit;
32
+ this.coa = coa;
32
33
  this.gmo = gmo;
33
34
  this.movieticketReserve = movieticketReserve;
34
35
  this.useAssetTransactionSyncProcessing = useAssetTransactionSyncProcessing;
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.0.0-alpha.10"
113
+ "version": "22.0.0-alpha.11"
114
114
  }
@@ -1,17 +0,0 @@
1
- interface IOptions {
2
- endpoint: string;
3
- refreshToken: string;
4
- timeout: number;
5
- useFetch: boolean;
6
- }
7
- /**
8
- * COA認証情報
9
- */
10
- declare class COACredentials {
11
- readonly endpoint: string;
12
- readonly refreshToken: string;
13
- readonly timeout: number;
14
- readonly useFetch: boolean;
15
- constructor(options: IOptions);
16
- }
17
- export { COACredentials };
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COACredentials = void 0;
4
- /**
5
- * COA認証情報
6
- */
7
- class COACredentials {
8
- constructor(options) {
9
- this.timeout = 20000;
10
- const { endpoint, refreshToken, timeout, useFetch } = options;
11
- this.endpoint = endpoint;
12
- this.refreshToken = refreshToken;
13
- this.timeout = timeout;
14
- this.useFetch = useFetch;
15
- }
16
- }
17
- exports.COACredentials = COACredentials;