@chevre/domain 22.9.0-alpha.44 → 22.9.0-alpha.46

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.
@@ -83,11 +83,11 @@ async function main() {
83
83
  } else {
84
84
  if (paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.CreditCard
85
85
  || paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.MovieTicket) {
86
- await paymentServiceRepo.migrateChannelId({
87
- project: { id: paymentService.project.id },
88
- id: paymentService.id,
89
- typeOf: paymentService.typeOf
90
- });
86
+ // await paymentServiceRepo.migrateChannelId({
87
+ // project: { id: paymentService.project.id },
88
+ // id: paymentService.id,
89
+ // typeOf: paymentService.typeOf
90
+ // });
91
91
  updateCount += 1;
92
92
  console.log(
93
93
  'updated.',
@@ -69,20 +69,6 @@ export declare class PaymentServiceRepo {
69
69
  id: string;
70
70
  credentials: factory.serviceChannel.ICredentialsMovieTicket;
71
71
  }>;
72
- saveChannelByServiceUrl(params: Omit<factory.serviceChannel.IServiceChannel, 'id'>): Promise<void>;
73
- /**
74
- * for migrate(2025-02-20~)
75
- */
76
- migrateChannelId(params: {
77
- project: {
78
- id: string;
79
- };
80
- /**
81
- * payment service ID
82
- */
83
- id: string;
84
- typeOf: factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
85
- }): Promise<void>;
86
72
  unsetUnnecessaryFields(params: {
87
73
  filter: any;
88
74
  $unset: any;
@@ -317,12 +317,13 @@ class PaymentServiceRepo {
317
317
  if (availableChannel === undefined) {
318
318
  throw new factory.errors.NotFound('paymentService.availableChannel');
319
319
  }
320
- if (typeof availableChannel.serviceUrl !== 'string' || availableChannel.serviceUrl === '') {
321
- throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
320
+ if (typeof availableChannel.id !== 'string' || availableChannel.id === '') {
321
+ throw new factory.errors.NotFound('paymentService.availableChannel.id');
322
322
  }
323
323
  const serviceChannel = yield this.paymentServiceChannelModel.findOne({
324
324
  'project.id': { $eq: params.project.id },
325
- serviceUrl: { $eq: availableChannel.serviceUrl },
325
+ _id: { $eq: availableChannel.id },
326
+ // serviceUrl: { $eq: availableChannel.serviceUrl },
326
327
  'providesService.typeOf': { $eq: factory.service.paymentService.PaymentServiceType.CreditCard }
327
328
  }, {
328
329
  credentials: 1,
@@ -356,12 +357,13 @@ class PaymentServiceRepo {
356
357
  if (availableChannel === undefined) {
357
358
  throw new factory.errors.NotFound('paymentService.availableChannel');
358
359
  }
359
- if (typeof availableChannel.serviceUrl !== 'string' || availableChannel.serviceUrl === '') {
360
- throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
360
+ if (typeof availableChannel.id !== 'string' || availableChannel.id === '') {
361
+ throw new factory.errors.NotFound('paymentService.availableChannel.id');
361
362
  }
362
363
  const serviceChannel = yield this.paymentServiceChannelModel.findOne({
363
364
  'project.id': { $eq: '*' },
364
- serviceUrl: { $eq: availableChannel.serviceUrl },
365
+ _id: { $eq: availableChannel.id },
366
+ // serviceUrl: { $eq: availableChannel.serviceUrl },
365
367
  'providesService.typeOf': { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket }
366
368
  }, {
367
369
  credentials: 1,
@@ -377,49 +379,61 @@ class PaymentServiceRepo {
377
379
  return Object.assign(Object.assign({}, availableChannel), { id: serviceChannel.id, serviceUrl: serviceChannel.serviceUrl, credentials: serviceChannel.credentials });
378
380
  });
379
381
  }
380
- saveChannelByServiceUrl(params) {
381
- return __awaiter(this, void 0, void 0, function* () {
382
- yield this.paymentServiceChannelModel.findOneAndUpdate({
383
- 'project.id': { $eq: params.project.id },
384
- serviceUrl: { $eq: params.serviceUrl }
385
- }, {
386
- $setOnInsert: params
387
- }, { upsert: true })
388
- .exec();
389
- });
390
- }
391
- /**
392
- * for migrate(2025-02-20~)
393
- */
394
- migrateChannelId(params) {
395
- return __awaiter(this, void 0, void 0, function* () {
396
- let existingChannel;
397
- if (params.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
398
- existingChannel = yield this.findAvailableChannelCreditCard(params);
399
- }
400
- else if (params.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
401
- existingChannel = yield this.findAvailableChannelMovieTicket(params);
402
- }
403
- else {
404
- throw new factory.errors.Argument('typeOf', `not implemented`);
405
- }
406
- if (typeof existingChannel.id !== 'string' || existingChannel.id === '') {
407
- throw new factory.errors.NotFound('existingChannel.id');
408
- }
409
- // tslint:disable-next-line:no-console
410
- console.log('updating paymentService...', existingChannel.id, existingChannel.serviceUrl, params.project.id, params.id);
411
- const doc = yield this.paymentServiceModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
412
- $set: {
413
- 'availableChannel.id': existingChannel.id
414
- }
415
- }, { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } })
416
- .lean()
417
- .exec();
418
- if (doc === null) {
419
- throw new factory.errors.NotFound(this.paymentServiceModel.modelName);
420
- }
421
- });
422
- }
382
+ // public async saveChannelByServiceUrl(
383
+ // params: Omit<factory.serviceChannel.IServiceChannel, 'id'>
384
+ // ): Promise<void> {
385
+ // await this.paymentServiceChannelModel.findOneAndUpdate(
386
+ // {
387
+ // 'project.id': { $eq: params.project.id },
388
+ // serviceUrl: { $eq: params.serviceUrl }
389
+ // },
390
+ // {
391
+ // $setOnInsert: params
392
+ // },
393
+ // { upsert: true }
394
+ // )
395
+ // .exec();
396
+ // }
397
+ // public async migrateChannelId(params: {
398
+ // project: { id: string };
399
+ // /**
400
+ // * payment service ID
401
+ // */
402
+ // id: string;
403
+ // typeOf: factory.service.paymentService.PaymentServiceType.CreditCard
404
+ // | factory.service.paymentService.PaymentServiceType.MovieTicket;
405
+ // }): Promise<void> {
406
+ // let existingChannel: Pick<
407
+ // factory.service.paymentService.IAvailableChannel,
408
+ // 'serviceUrl' | 'typeOf' | 'id'
409
+ // >;
410
+ // if (params.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard) {
411
+ // existingChannel = await this.findAvailableChannelCreditCard(params);
412
+ // } else if (params.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
413
+ // existingChannel = await this.findAvailableChannelMovieTicket(params);
414
+ // } else {
415
+ // throw new factory.errors.Argument('typeOf', `not implemented`);
416
+ // }
417
+ // if (typeof existingChannel.id !== 'string' || existingChannel.id === '') {
418
+ // throw new factory.errors.NotFound('existingChannel.id');
419
+ // }
420
+ // // tslint:disable-next-line:no-console
421
+ // console.log('updating paymentService...', existingChannel.id, existingChannel.serviceUrl, params.project.id, params.id);
422
+ // const doc = await this.paymentServiceModel.findOneAndUpdate(
423
+ // { _id: { $eq: params.id } },
424
+ // {
425
+ // $set: {
426
+ // 'availableChannel.id': existingChannel.id
427
+ // }
428
+ // },
429
+ // { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } }
430
+ // )
431
+ // .lean<{ id: string }>()
432
+ // .exec();
433
+ // if (doc === null) {
434
+ // throw new factory.errors.NotFound(this.paymentServiceModel.modelName);
435
+ // }
436
+ // }
423
437
  unsetUnnecessaryFields(params) {
424
438
  return __awaiter(this, void 0, void 0, function* () {
425
439
  return this.paymentServiceModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
@@ -2,6 +2,7 @@ import type * as COA from '@motionpicture/coa-service';
2
2
  import * as factory from '../../../factory';
3
3
  import { ActionRepo } from '../../../repo/action';
4
4
  type ICancelOperation<T> = (repos: {
5
+ action: ActionRepo;
5
6
  reserveService: COA.service.Reserve;
6
7
  }) => Promise<T>;
7
8
  declare function cancel(params: {
@@ -9,8 +10,5 @@ declare function cancel(params: {
9
10
  }): ICancelOperation<void>;
10
11
  declare function cancelByAcceptAction(params: {
11
12
  action: factory.action.accept.coaOffer.IAction;
12
- }): (repos: {
13
- action: ActionRepo;
14
- reserveService: COA.service.Reserve;
15
- }) => Promise<void>;
13
+ }): ICancelOperation<void>;
16
14
  export { cancel, cancelByAcceptAction };
@@ -14,7 +14,7 @@ exports.cancelByAcceptAction = cancelByAcceptAction;
14
14
  const cancelReservation_1 = require("../../reserveCOA/cancelReservation");
15
15
  function cancel(params) {
16
16
  return (repos) => __awaiter(this, void 0, void 0, function* () {
17
- yield (0, cancelReservation_1.cancelPendingReservation)(params)(repos);
17
+ yield (0, cancelReservation_1.cancelPendingReservationByAuthorizeAction)(params)(repos);
18
18
  });
19
19
  }
20
20
  function cancelByAcceptAction(params) {
@@ -4,6 +4,7 @@ import { ActionRepo } from '../../../../repo/action';
4
4
  declare function processVoidTransaction4coa(params: {
5
5
  action: factory.action.authorize.offer.eventService.IAction;
6
6
  }): (repos: {
7
+ action: ActionRepo;
7
8
  reserveService: COA.service.Reserve;
8
9
  }) => Promise<void>;
9
10
  declare function processVoidTransactionByAcceptAction4coa(params: {
@@ -85,7 +85,10 @@ function voidTransaction(params) {
85
85
  yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
86
86
  // action: <factory.action.authorize.offer.eventService.IAction<WebAPIIdentifier.COA>>action
87
87
  action
88
- })({ reserveService });
88
+ })({
89
+ action: repos.action,
90
+ reserveService
91
+ });
89
92
  break;
90
93
  default:
91
94
  yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
@@ -59,7 +59,10 @@ function voidTransactionByActionId(params) {
59
59
  }
60
60
  yield (0, processVoidTransaction4coa_1.processVoidTransaction4coa)({
61
61
  action
62
- })({ reserveService });
62
+ })({
63
+ action: repos.action,
64
+ reserveService
65
+ });
63
66
  break;
64
67
  default:
65
68
  yield (0, processVoidTransaction4chevre_1.processVoidTransaction4chevre)({
@@ -9,7 +9,7 @@ import type { TaskRepo } from '../../repo/task';
9
9
  /**
10
10
  * 保留予約取消
11
11
  */
12
- declare function cancelPendingReservation(actionAttributes: factory.task.cancelPendingReservation.IData): (repos: {
12
+ declare function cancelPendingReservation(actionAttributes: factory.task.cancelPendingReservation.IPotentialCancelAction): (repos: {
13
13
  action: ActionRepo;
14
14
  assetTransaction: AssetTransactionRepo;
15
15
  stockHolder: StockHolderRepo;
@@ -1,9 +1,18 @@
1
1
  import type * as COA from '@motionpicture/coa-service';
2
2
  import * as factory from '../../factory';
3
3
  import { ActionRepo } from '../../repo/action';
4
- declare function cancelPendingReservation(params: {
4
+ declare function cancelPendingReservation(params: factory.task.cancelPendingReservation.IPotentialCancelCOAReserveAction & {
5
+ project: {
6
+ id: string;
7
+ };
8
+ }): (repos: {
9
+ action: ActionRepo;
10
+ reserveService: COA.service.Reserve;
11
+ }) => Promise<void>;
12
+ declare function cancelPendingReservationByAuthorizeAction(params: {
5
13
  action: factory.action.authorize.offer.eventService.IAction;
6
14
  }): (repos: {
15
+ action: ActionRepo;
7
16
  reserveService: COA.service.Reserve;
8
17
  }) => Promise<void>;
9
18
  declare function cancelPendingReservationByAcceptAction(params: {
@@ -12,4 +21,4 @@ declare function cancelPendingReservationByAcceptAction(params: {
12
21
  action: ActionRepo;
13
22
  reserveService: COA.service.Reserve;
14
23
  }) => Promise<void>;
15
- export { cancelPendingReservation, cancelPendingReservationByAcceptAction };
24
+ export { cancelPendingReservation, cancelPendingReservationByAuthorizeAction, cancelPendingReservationByAcceptAction };
@@ -10,28 +10,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.cancelPendingReservation = cancelPendingReservation;
13
+ exports.cancelPendingReservationByAuthorizeAction = cancelPendingReservationByAuthorizeAction;
13
14
  exports.cancelPendingReservationByAcceptAction = cancelPendingReservationByAcceptAction;
14
15
  const http_status_1 = require("http-status");
16
+ const factory = require("../../factory");
17
+ const factory_1 = require("./factory");
18
+ function createCancelPendingReservationAction(params) {
19
+ const { object, instrument, project } = params;
20
+ return {
21
+ project: { id: project.id, typeOf: factory.organizationType.Project },
22
+ typeOf: factory.actionType.CancelAction,
23
+ agent: { id: project.id, typeOf: factory.organizationType.Project },
24
+ object,
25
+ instrument
26
+ };
27
+ }
15
28
  function cancelPendingReservation(params) {
16
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
17
- // object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
18
- let delTmpReserveParams;
19
- // objectに進行中取引情報があれば利用する(2023-09-11~)
20
- const pendingTransaction = params.action.object.pendingTransaction;
21
- if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
22
- delTmpReserveParams = {
23
- theaterCode: pendingTransaction.theaterCode,
24
- dateJouei: pendingTransaction.dateJouei,
25
- titleCode: pendingTransaction.titleCode,
26
- titleBranchNum: pendingTransaction.titleBranchNum,
27
- timeBegin: pendingTransaction.timeBegin,
28
- tmpReserveNum: pendingTransaction.tmpReserveNum
29
- };
30
- }
31
- if (delTmpReserveParams !== undefined) {
32
- // COAで仮予約取消
30
+ const actionAttributes = createCancelPendingReservationAction(params);
31
+ const { theaterCode, dateJouei, titleCode, titleBranchNum, timeBegin, tmpReserveNum } = actionAttributes.object;
32
+ const delTmpReserveArgs = { theaterCode, dateJouei, titleCode, titleBranchNum, timeBegin, tmpReserveNum };
33
+ let recipe = (0, factory_1.processCancelPendingCOAReserveResult2recipe)({
34
+ processCancelPendingCOAReserveResult: { delTmpReserveArgs },
35
+ project: { id: params.project.id }
36
+ });
37
+ const action = yield repos.action.start(actionAttributes, { recipe });
38
+ try {
33
39
  try {
34
- yield repos.reserveService.delTmpReserve(delTmpReserveParams);
40
+ yield repos.reserveService.delTmpReserve(delTmpReserveArgs);
35
41
  }
36
42
  catch (error) {
37
43
  let deleted = false;
@@ -43,6 +49,13 @@ function cancelPendingReservation(params) {
43
49
  && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
44
50
  // すでに取消済の場合こうなるので、okとする
45
51
  if (error.message === '座席取消失敗') {
52
+ recipe = (0, factory_1.processCancelPendingCOAReserveResult2recipe)({
53
+ processCancelPendingCOAReserveResult: {
54
+ delTmpReserveArgs,
55
+ delTmpReserveResult: Object.assign(Object.assign({}, error), { message: error.message })
56
+ },
57
+ project: { id: params.project.id }
58
+ });
46
59
  deleted = true;
47
60
  }
48
61
  }
@@ -52,6 +65,42 @@ function cancelPendingReservation(params) {
52
65
  }
53
66
  }
54
67
  }
68
+ catch (error) {
69
+ try {
70
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
71
+ }
72
+ catch (__) {
73
+ // 失敗したら仕方ない
74
+ }
75
+ throw error;
76
+ }
77
+ const actionResult = {};
78
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult, recipe });
79
+ });
80
+ }
81
+ function cancelPendingReservationByAuthorizeAction(params) {
82
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
83
+ // object.pendingTransactionに連携内容情報が記録されているので、その情報を元に仮予約を取り消す
84
+ let delTmpReserveParams;
85
+ // objectに進行中取引情報があれば利用する(2023-09-11~)
86
+ const pendingTransaction = params.action.object.pendingTransaction;
87
+ if (typeof (pendingTransaction === null || pendingTransaction === void 0 ? void 0 : pendingTransaction.typeOf) === 'string') {
88
+ delTmpReserveParams = {
89
+ theaterCode: pendingTransaction.theaterCode,
90
+ dateJouei: pendingTransaction.dateJouei,
91
+ titleCode: pendingTransaction.titleCode,
92
+ titleBranchNum: pendingTransaction.titleBranchNum,
93
+ timeBegin: pendingTransaction.timeBegin,
94
+ tmpReserveNum: pendingTransaction.tmpReserveNum
95
+ };
96
+ }
97
+ if (delTmpReserveParams !== undefined) {
98
+ yield cancelPendingReservation({
99
+ project: { id: params.action.project.id },
100
+ object: Object.assign(Object.assign({}, delTmpReserveParams), { reservationStatus: factory.reservationStatusType.ReservationPending, transactionNumber: delTmpReserveParams.tmpReserveNum, typeOf: factory.assetTransactionType.COAReserveTransaction }),
101
+ instrument: [params.action.purpose]
102
+ })(repos);
103
+ }
55
104
  });
56
105
  }
57
106
  function cancelPendingReservationByAcceptAction(params) {
@@ -63,9 +112,6 @@ function cancelPendingReservationByAcceptAction(params) {
63
112
  });
64
113
  if (recipe !== null) {
65
114
  let delTmpReserveParams;
66
- // instrument,resultに連携内容情報が保管されているので、その情報を元に仮予約を取り消す
67
- // const coaRequestBody = params.action.instrument?.requestBody;
68
- // const coaResponseBody = params.action.result?.result?.responseBody;
69
115
  // recipeから連携情報取得に変更(2024-06-11~)
70
116
  const coaRequestBody = (_c = (_b = (_a = recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
71
117
  const coaResponseBody = (_f = (_e = (_d = recipe.step[0]) === null || _d === void 0 ? void 0 : _d.itemListElement[0]) === null || _e === void 0 ? void 0 : _e.itemListElement[0]) === null || _f === void 0 ? void 0 : _f.afterMedia;
@@ -80,28 +126,11 @@ function cancelPendingReservationByAcceptAction(params) {
80
126
  };
81
127
  }
82
128
  if (delTmpReserveParams !== undefined) {
83
- // COAで仮予約取消
84
- try {
85
- yield repos.reserveService.delTmpReserve(delTmpReserveParams);
86
- }
87
- catch (error) {
88
- let deleted = false;
89
- // COAサービスエラーの場合ハンドリング
90
- // tslint:disable-next-line:no-single-line-block-comment
91
- /* istanbul ignore if */
92
- if (error.name === 'COAServiceError') {
93
- if (typeof error.code === 'number'
94
- && error.code < http_status_1.INTERNAL_SERVER_ERROR) {
95
- // すでに取消済の場合こうなるので、okとする
96
- if (error.message === '座席取消失敗') {
97
- deleted = true;
98
- }
99
- }
100
- }
101
- if (!deleted) {
102
- throw error;
103
- }
104
- }
129
+ yield cancelPendingReservation({
130
+ project: { id: params.action.project.id },
131
+ object: Object.assign(Object.assign({}, delTmpReserveParams), { reservationStatus: factory.reservationStatusType.ReservationPending, transactionNumber: delTmpReserveParams.tmpReserveNum, typeOf: factory.assetTransactionType.COAReserveTransaction }),
132
+ instrument: [params.action.purpose]
133
+ })(repos);
105
134
  }
106
135
  }
107
136
  });
@@ -0,0 +1,13 @@
1
+ import type * as COA from '@motionpicture/coa-service';
2
+ import * as factory from '../../factory';
3
+ interface IProcessCancelPendingCOAReserveResult {
4
+ delTmpReserveArgs?: COA.factory.reserve.IDelTmpReserveArgs;
5
+ delTmpReserveResult?: factory.action.cancel.coaReserve.IDelTmpReserveResultAsError;
6
+ }
7
+ declare function processCancelPendingCOAReserveResult2recipe(params: {
8
+ processCancelPendingCOAReserveResult: IProcessCancelPendingCOAReserveResult;
9
+ project: {
10
+ id: string;
11
+ };
12
+ }): factory.action.cancel.coaReserve.ICancelPendingCOAReserveRecipe;
13
+ export { IProcessCancelPendingCOAReserveResult, processCancelPendingCOAReserveResult2recipe };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processCancelPendingCOAReserveResult2recipe = processCancelPendingCOAReserveResult2recipe;
4
+ const factory = require("../../factory");
5
+ function processCancelPendingCOAReserveResult2recipe(params) {
6
+ const { processCancelPendingCOAReserveResult, project } = params;
7
+ const { delTmpReserveArgs, delTmpReserveResult } = processCancelPendingCOAReserveResult;
8
+ return {
9
+ project: { id: project.id, typeOf: factory.organizationType.Project },
10
+ typeOf: 'Recipe',
11
+ recipeCategory: factory.recipe.RecipeCategory.cancelPendingCOAReserve,
12
+ step: [{
13
+ typeOf: 'HowToSection',
14
+ itemListElement: [
15
+ {
16
+ typeOf: 'HowToStep',
17
+ identifier: factory.recipe.StepIdentifier.delTmpReserve,
18
+ itemListElement: [Object.assign(Object.assign({ typeOf: 'HowToDirection' }, (delTmpReserveArgs !== undefined) ? { beforeMedia: delTmpReserveArgs } : undefined), (delTmpReserveResult !== undefined) ? { afterMedia: delTmpReserveResult } : undefined)]
19
+ }
20
+ ]
21
+ }]
22
+ };
23
+ }
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
6
- export declare function call(data: factory.task.cancelPendingReservation.IData): IOperationExecute<void>;
6
+ export declare function call(params: Pick<factory.task.cancelPendingReservation.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
@@ -10,37 +10,76 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = call;
13
+ // import * as COA from '@motionpicture/coa-service';
13
14
  const factory = require("../../factory");
14
15
  const action_1 = require("../../repo/action");
15
16
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
17
  const offer_1 = require("../../repo/rateLimit/offer");
17
18
  const reservation_1 = require("../../repo/reservation");
19
+ // import { ReserveInterfaceRepo } from '../../repo/reserveInterface';
18
20
  const setting_1 = require("../../repo/setting");
19
21
  const stockHolder_1 = require("../../repo/stockHolder");
20
22
  const task_1 = require("../../repo/task");
21
23
  const cancelReservation_1 = require("../reserve/cancelReservation");
24
+ // import { cancelPendingReservation as cancelPendingCOAReserve } from '../reserveCOA/cancelReservation';
25
+ // let coaAuthClientCreated: boolean = false;
26
+ // let coaAuthClient: COA.auth.RefreshToken = new COA.auth.RefreshToken({
27
+ // endpoint: '', // 使用されないので空文字でok
28
+ // refreshToken: '', // 使用されないので空文字でok
29
+ // useFetch: true
30
+ // });
22
31
  /**
23
32
  * タスク実行関数
24
33
  */
25
- function call(data) {
34
+ function call(params) {
26
35
  return (_a) => __awaiter(this, [_a], void 0, function* ({ connection, redisClient }) {
36
+ var _b, _c, _d, _e;
27
37
  if (redisClient === undefined) {
28
38
  throw new factory.errors.Argument('settings', 'redisClient required');
29
39
  }
30
- // アクション数は予約番号単位で1しかありえないはず(2023-06-05~)
31
- // if (data.actionAttributes.length !== 1) {
32
- // throw new factory.errors.Argument('data.actionAttributes', 'data.actionAttributes.length must be 1');
33
- // }
34
- yield (0, cancelReservation_1.cancelPendingReservation)(data)({
35
- action: new action_1.ActionRepo(connection),
36
- assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
37
- stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
38
- offerRateLimit: new offer_1.OfferRateLimitRepo(redisClient),
39
- reservation: new reservation_1.ReservationRepo(connection),
40
- setting: new setting_1.SettingRepo(connection),
41
- task: new task_1.TaskRepo(connection)
40
+ const { data } = params;
41
+ // support COAReserve(2025-03-01~)
42
+ if (((_b = data.purpose) === null || _b === void 0 ? void 0 : _b.typeOf) === factory.assetTransactionType.Reserve) {
43
+ yield (0, cancelReservation_1.cancelPendingReservation)({ purpose: data.purpose })({
44
+ action: new action_1.ActionRepo(connection),
45
+ assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
46
+ stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
47
+ offerRateLimit: new offer_1.OfferRateLimitRepo(redisClient),
48
+ reservation: new reservation_1.ReservationRepo(connection),
49
+ setting: new setting_1.SettingRepo(connection),
50
+ task: new task_1.TaskRepo(connection)
51
+ });
52
+ }
53
+ else if (((_c = data.object) === null || _c === void 0 ? void 0 : _c.typeOf) === factory.assetTransactionType.COAReserveTransaction) {
54
+ throw new factory.errors.NotImplemented(`object.typeOf ${(_d = data.object) === null || _d === void 0 ? void 0 : _d.typeOf} not implemented`);
55
+ // if (!coaAuthClientCreated) {
56
+ // const reserveInterfaceRepo = new ReserveInterfaceRepo(connection);
57
+ // const coaAPI = await reserveInterfaceRepo.findOne({ project: { id: { $eq: params.project.id } } });
58
+ // const credentials = coaAPI?.availableChannel?.credentials;
59
+ // if (typeof credentials?.refreshToken === 'string') {
60
+ // coaAuthClient = new COA.auth.RefreshToken(credentials);
61
+ // coaAuthClientCreated = true;
62
+ // }
63
+ // }
64
+ // const reserveService = new COA.service.Reserve(
65
+ // {
66
+ // endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
67
+ // auth: coaAuthClient
68
+ // },
69
+ // { timeout: settings.coa.timeout }
70
+ // );
71
+ // const { object, instrument } = data;
72
+ // await cancelPendingCOAReserve({
73
+ // object,
74
+ // instrument,
75
+ // project: { id: params.project.id }
76
+ // })({
77
+ // action: new ActionRepo(connection),
78
+ // reserveService
79
+ // });
80
+ }
81
+ else {
82
+ throw new factory.errors.NotImplemented(`purpose.typeOf ${(_e = data.purpose) === null || _e === void 0 ? void 0 : _e.typeOf} not implemented`);
42
83
  }
43
- // settings
44
- );
45
84
  });
46
85
  }
@@ -101,6 +101,7 @@ function execute(task) {
101
101
  case factory.taskName.AcceptCOAOffer:
102
102
  case factory.taskName.AggregateOnSystem:
103
103
  case factory.taskName.AuthorizePayment:
104
+ case factory.taskName.CancelPendingReservation:
104
105
  case factory.taskName.CheckMovieTicket:
105
106
  case factory.taskName.DeletePerson:
106
107
  case factory.taskName.HandleNotification:
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.393.0-alpha.33",
15
- "@cinerino/sdk": "10.21.0-alpha.22",
14
+ "@chevre/factory": "4.393.0-alpha.35",
15
+ "@cinerino/sdk": "10.21.0-alpha.23",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
18
18
  "@sendgrid/mail": "6.4.0",
@@ -112,5 +112,5 @@
112
112
  "postversion": "git push origin --tags",
113
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
114
114
  },
115
- "version": "22.9.0-alpha.44"
115
+ "version": "22.9.0-alpha.46"
116
116
  }
@@ -1,104 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
- // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
-
9
- // tslint:disable-next-line:max-func-body-length
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
14
-
15
- const cursor = paymentServiceRepo.getCursor(
16
- {
17
- typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
18
- // _id: { $eq: 'cinerino' }
19
- },
20
- {
21
- _id: 1,
22
- availableChannel: 1,
23
- productID: 1,
24
- project: 1,
25
- typeOf: 1
26
- }
27
- );
28
- console.log('docs found');
29
-
30
- let i = 0;
31
- let updateCount = 0;
32
- let serviceUrls: string[] = [];
33
- const unexpectedProjectIds: string[] = [];
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const paymentService: Pick<
37
- chevre.factory.service.paymentService.IService,
38
- 'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
39
- > = doc.toObject();
40
-
41
- console.log(
42
- 'alreadyMigrated?', paymentService.project.id, i);
43
- if (typeof paymentService.id !== 'string') {
44
- throw new Error('id must be string');
45
- }
46
-
47
- let alreadyMigrated = false;
48
- try {
49
- const existingChannel = await paymentServiceRepo.findAvailableChannelCreditCard({
50
- project: { id: paymentService.project.id },
51
- id: paymentService.id
52
- });
53
- if (typeof existingChannel.credentials?.siteId === 'string'
54
- && typeof existingChannel.credentials?.sitePass === 'string') {
55
- alreadyMigrated = true;
56
- }
57
- } catch (error) {
58
- // no op
59
- }
60
-
61
- const serviceUrl = paymentService.availableChannel?.serviceUrl;
62
- if (typeof serviceUrl === 'string') {
63
- serviceUrls.push(serviceUrl);
64
- } else {
65
- throw new Error('serviceUrl must be string');
66
- }
67
-
68
- // docs(same serviceUrl and different siteId,sitePass ) exist?
69
- // const credentials =
70
- // <chevre.factory.serviceChannel.ICredentialsCreditCard | undefined>paymentService.availableChannel?.credentials;
71
- // if (typeof credentials?.siteId !== 'string') {
72
- // throw new Error('siteId must be string');
73
- // }
74
- // if (typeof credentials?.sitePass !== 'string') {
75
- // throw new Error('sitePass must be string');
76
- // }
77
-
78
- if (alreadyMigrated) {
79
- console.log(
80
- 'already migrated.', paymentService.project.id, i);
81
- } else {
82
- console.log(
83
- 'updating...',
84
- paymentService.project.id, i);
85
- // await paymentServiceRepo.saveChannelByServiceUrl(newChannel);
86
- updateCount += 1;
87
- console.log(
88
- 'updated.',
89
- paymentService.project.id, i);
90
- }
91
- });
92
-
93
- serviceUrls = [...new Set(serviceUrls)];
94
- console.log('unexpectedProjectIds:', unexpectedProjectIds);
95
- // console.log(serviceUrls);
96
- console.log(serviceUrls);
97
- console.log(serviceUrls.length, 'serviceUrls found');
98
- console.log(i, 'docs checked');
99
- console.log(updateCount, 'docs updated');
100
- }
101
-
102
- main()
103
- .then()
104
- .catch(console.error);
@@ -1,112 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
- // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
-
9
- // tslint:disable-next-line:max-func-body-length
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
14
-
15
- const cursor = paymentServiceRepo.getCursor(
16
- {
17
- typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
18
- // _id: { $eq: 'cinerino' }
19
- },
20
- {
21
- _id: 1,
22
- availableChannel: 1,
23
- productID: 1,
24
- project: 1,
25
- typeOf: 1
26
- }
27
- );
28
- console.log('docs found');
29
-
30
- let i = 0;
31
- let updateCount = 0;
32
- let serviceUrls: string[] = [];
33
- const unexpectedProjectIds: string[] = [];
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const paymentService: Pick<
37
- chevre.factory.service.paymentService.IService,
38
- 'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
39
- > = doc.toObject();
40
-
41
- console.log(
42
- 'alreadyMigrated?', paymentService.project.id, i);
43
- if (typeof paymentService.id !== 'string') {
44
- throw new Error('id must be string');
45
- }
46
-
47
- let alreadyMigrated = false;
48
- try {
49
- const existingChannel = await paymentServiceRepo.findAvailableChannelMovieTicket({
50
- project: { id: paymentService.project.id },
51
- id: paymentService.id
52
- });
53
- if (typeof existingChannel.credentials?.authorizeServerDomain === 'string') {
54
- alreadyMigrated = true;
55
- }
56
- } catch (error) {
57
- // no op
58
- }
59
-
60
- const serviceUrl = paymentService.availableChannel?.serviceUrl;
61
- if (typeof serviceUrl === 'string') {
62
- serviceUrls.push(serviceUrl);
63
- } else {
64
- throw new Error('serviceUrl must be string');
65
- }
66
-
67
- if (alreadyMigrated) {
68
- console.log(
69
- 'already migrated.', paymentService.project.id, i);
70
- } else {
71
- const credentials =
72
- <chevre.factory.serviceChannel.ICredentialsMovieTicket | undefined>paymentService.availableChannel?.credentials;
73
- if (typeof credentials?.authorizeServerDomain !== 'string') {
74
- throw new Error('authorizeServerDomain must be string');
75
- }
76
- if (typeof credentials?.clientId !== 'string') {
77
- throw new Error('clientId must be string');
78
- }
79
- if (typeof credentials?.clientSecret !== 'string') {
80
- throw new Error('clientSecret must be string');
81
- }
82
- const newChannel: chevre.factory.serviceChannel.IServiceChannelMovieTicket = {
83
- credentials,
84
- project: { id: '*', typeOf: chevre.factory.organizationType.Project },
85
- providesService: {
86
- typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
87
- },
88
- serviceUrl,
89
- typeOf: 'ServiceChannel'
90
- };
91
- console.log(
92
- 'updating...',
93
- paymentService.project.id, i, newChannel);
94
- await paymentServiceRepo.saveChannelByServiceUrl(newChannel);
95
- updateCount += 1;
96
- console.log(
97
- 'updated.',
98
- paymentService.project.id, i);
99
- }
100
- });
101
-
102
- serviceUrls = [...new Set(serviceUrls)];
103
- console.log('unexpectedProjectIds:', unexpectedProjectIds);
104
- console.log(serviceUrls);
105
- console.log(serviceUrls.length, 'serviceUrls found');
106
- console.log(i, 'docs checked');
107
- console.log(updateCount, 'docs updated');
108
- }
109
-
110
- main()
111
- .then()
112
- .catch(console.error);
@@ -1,111 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
- // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
-
9
- // tslint:disable-next-line:max-func-body-length
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
14
- // const potentialActionRepo = await chevre.repository.PotentialAction.createInstance(mongoose.connection);
15
- // const identityProviderRepo = await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
16
- const webSiteRepo = await chevre.repository.WebSite.createInstance(mongoose.connection);
17
-
18
- let webSiteIdentifiers: string[] = [];
19
-
20
- const cursor = paymentServiceRepo.getCursor(
21
- {
22
- typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
23
- },
24
- {
25
- _id: 1,
26
- availableChannel: 1,
27
- productID: 1,
28
- project: 1,
29
- typeOf: 1
30
- }
31
- );
32
- console.log('docs found');
33
-
34
- let i = 0;
35
- let updateCount = 0;
36
-
37
- await cursor.eachAsync(async (doc) => {
38
- i += 1;
39
-
40
- const paymentService: Pick<
41
- chevre.factory.service.paymentService.IService,
42
- 'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
43
- > = doc.toObject();
44
-
45
- let webSiteIdentifier: string | undefined;
46
- const serviceUrl = paymentService.availableChannel?.serviceUrl;
47
- if (typeof serviceUrl === 'string') {
48
- if (/appspot.com/.test(serviceUrl)) {
49
- webSiteIdentifier = new URL(serviceUrl).hostname;
50
- webSiteIdentifiers.push(webSiteIdentifier);
51
- }
52
- } else {
53
- throw new Error('serviceUrl must be string');
54
- }
55
-
56
- if (typeof webSiteIdentifier !== 'string') {
57
- console.log(
58
- 'already migrated.', serviceUrl, webSiteIdentifier, i);
59
- } else {
60
- let alreadyMigrated = false;
61
- const existingWebSites = await webSiteRepo.projectFields(
62
- {
63
- about: { identifier: { $eq: webSiteIdentifier } },
64
- project: { id: { $eq: paymentService.project.id } }
65
- },
66
- ['about']
67
- );
68
- alreadyMigrated = existingWebSites.length === 1;
69
-
70
- if (alreadyMigrated) {
71
- console.log(
72
- 'already migrated.', webSiteIdentifier, i);
73
- } else {
74
- const creatingWebSite: Pick<
75
- chevre.factory.creativeWork.certification.webSite.ICertification,
76
- 'about' | 'certificationStatus' | 'project' | 'auditDate'
77
- > = {
78
- project: { id: paymentService.project.id, typeOf: chevre.factory.organizationType.Project },
79
- about: { identifier: webSiteIdentifier, typeOf: chevre.factory.creativeWorkType.WebSite },
80
- certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
81
- };
82
- console.log(
83
- 'updating...', i, creatingWebSite);
84
- const { id } = await webSiteRepo.save({
85
- attributes: creatingWebSite
86
- });
87
- await webSiteRepo.save({
88
- id,
89
- attributes: {
90
- ...creatingWebSite,
91
- auditDate: new Date(),
92
- certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationActive
93
- }
94
- });
95
- updateCount += 1;
96
- console.log(
97
- 'updated.', i);
98
- }
99
- }
100
- });
101
-
102
- webSiteIdentifiers = [...new Set(webSiteIdentifiers)];
103
- console.log(webSiteIdentifiers);
104
- console.log(webSiteIdentifiers.length, 'webSiteIdentifiers found');
105
- console.log(i, 'docs checked');
106
- console.log(updateCount, 'docs updated');
107
- }
108
-
109
- main()
110
- .then()
111
- .catch(console.error);