@chevre/domain 21.33.0-alpha.21 → 21.33.0-alpha.23

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.
@@ -14,7 +14,8 @@ async function main() {
14
14
 
15
15
  const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
16
  const actions = await actionRepo.searchBySameAs({
17
- sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } }
17
+ sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } },
18
+ typeOf: { $eq: chevre.factory.actionType.AuthorizeAction }
18
19
  });
19
20
  console.log('actions:', actions);
20
21
  }
@@ -185,6 +185,12 @@ export declare class MongoRepository {
185
185
  $eq: string;
186
186
  };
187
187
  };
188
+ /**
189
+ * 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
190
+ */
191
+ typeOf: {
192
+ $eq: factory.actionType;
193
+ };
188
194
  }): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
189
195
  deleteByProject(params: {
190
196
  project: {
@@ -709,7 +709,7 @@ class MongoRepository {
709
709
  searchBySameAs(params) {
710
710
  var _a;
711
711
  return __awaiter(this, void 0, void 0, function* () {
712
- const query = this.actionModel.find(Object.assign({ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
712
+ const query = this.actionModel.find(Object.assign({ typeOf: { $eq: params.typeOf.$eq }, 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq } }, (typeof ((_a = params.purpose) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
713
713
  ? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
714
714
  : undefined))
715
715
  .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
@@ -189,7 +189,7 @@ exports.check = check;
189
189
  */
190
190
  function start(params, options) {
191
191
  return (repos) => __awaiter(this, void 0, void 0, function* () {
192
- var _a, _b, _c;
192
+ var _a, _b, _c, _d;
193
193
  // 金額をfix
194
194
  const amount = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.amount;
195
195
  if (typeof amount !== 'number') {
@@ -225,7 +225,9 @@ function start(params, options) {
225
225
  break;
226
226
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
227
227
  transaction =
228
- yield processAuthorizeMovieTicket(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.useCheckMovieTicketBeforePay, options.useCheckByIdentifierIfNotYet)(repos);
228
+ yield processAuthorizeMovieTicket(params, transaction, String(paymentService === null || paymentService === void 0 ? void 0 : paymentService.id), options.useCheckMovieTicketBeforePay, options.useCheckByIdentifierIfNotYet, {
229
+ executor: (typeof ((_d = options.executor) === null || _d === void 0 ? void 0 : _d.id) === 'string') ? { id: options.executor.id } : {}
230
+ })(repos);
229
231
  break;
230
232
  default:
231
233
  throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
@@ -389,9 +391,9 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId, optio
389
391
  })(repos);
390
392
  });
391
393
  }
392
- function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
394
+ function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet, options) {
393
395
  return (repos) => __awaiter(this, void 0, void 0, function* () {
394
- const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
396
+ const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet, options)(repos);
395
397
  const payActionInObject = {
396
398
  actionStatus: payAction.actionStatus,
397
399
  id: payAction.id,
@@ -43,7 +43,8 @@ function findAcceptAction(params) {
43
43
  default:
44
44
  // タスクがReadyでなければアクション検索
45
45
  const acceptAction = (yield repos.action.searchBySameAs({
46
- sameAs: { id: { $eq: task.id } }
46
+ sameAs: { id: { $eq: task.id } },
47
+ typeOf: { $eq: factory.actionType.AcceptAction }
47
48
  // purpose: { id: { $eq: String(params.purpose.id) } }
48
49
  })).shift();
49
50
  if (acceptAction !== undefined) {
@@ -476,7 +476,8 @@ function findAuthorizeAction(params) {
476
476
  default:
477
477
  // タスクがReadyでなければアクション検索
478
478
  const authorizeAction = (yield repos.action.searchBySameAs({
479
- sameAs: { id: { $eq: task.id } }
479
+ sameAs: { id: { $eq: task.id } },
480
+ typeOf: { $eq: factory.actionType.AuthorizeAction }
480
481
  // purpose: { id: { $eq: String(params.purpose.id) } }
481
482
  })).shift();
482
483
  if (authorizeAction !== undefined) {
@@ -529,7 +530,8 @@ function findCheckAction(params) {
529
530
  default:
530
531
  // タスクがReadyでなければアクション検索
531
532
  const authorizeAction = (yield repos.action.searchBySameAs({
532
- sameAs: { id: { $eq: task.id } }
533
+ sameAs: { id: { $eq: task.id } },
534
+ typeOf: { $eq: factory.actionType.CheckAction }
533
535
  // purpose: { id: { $eq: String(params.purpose.id) } }
534
536
  })).shift();
535
537
  if (authorizeAction !== undefined) {
@@ -604,7 +606,8 @@ function findAcceptAction(params) {
604
606
  default:
605
607
  // タスクがReadyでなければアクション検索
606
608
  const acceptAction = (yield repos.action.searchBySameAs({
607
- sameAs: { id: { $eq: task.id } }
609
+ sameAs: { id: { $eq: task.id } },
610
+ typeOf: { $eq: factory.actionType.AcceptAction }
608
611
  // purpose: { id: { $eq: String(params.purpose.id) } }
609
612
  })).shift();
610
613
  if (acceptAction !== undefined) {
@@ -36,7 +36,7 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
36
36
  executor?: {
37
37
  /**
38
38
  * task ID
39
- * taskによって実行されている場合値が存在する
39
+ * taskによって実行されている場合値が存在する(taskName: authorizePayment)
40
40
  */
41
41
  id?: string;
42
42
  };
@@ -56,7 +56,7 @@ declare function voidTransaction(params: factory.task.voidPayment.IData): (repos
56
56
  /**
57
57
  * クレジットカード決済
58
58
  */
59
- declare function payCreditCard(params: factory.task.pay.IPayActionData): (repos: {
59
+ declare function payCreditCard(params: factory.action.trade.pay.IAttributes): (repos: {
60
60
  action: ActionRepo;
61
61
  actionRecipe: ActionRecipeRepo;
62
62
  accountingReport: AccountingReportRepo;
@@ -9,7 +9,7 @@ import type { MongoRepository as TaskRepo } from '../../repo/task';
9
9
  declare function voidTransaction(__: factory.task.voidPayment.IData): (___: {
10
10
  product: ProductRepo;
11
11
  }) => Promise<void>;
12
- declare function payFaceToFace(params: factory.task.pay.IPayActionData): (repos: {
12
+ declare function payFaceToFace(params: factory.action.trade.pay.IAttributes): (repos: {
13
13
  action: ActionRepo;
14
14
  accountingReport: AccountingReportRepo;
15
15
  product: ProductRepo;
@@ -49,7 +49,18 @@ interface IAuthorizeResult {
49
49
  * MovieTicket承認
50
50
  * オーソリサービスが存在するわけではないので、実質着券する
51
51
  */
52
- declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean): (repos: {
52
+ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, transaction: factory.assetTransaction.pay.ITransaction, paymentServiceId: string, useCheckMovieTicketBeforePay: boolean, useCheckByIdentifierIfNotYet: boolean, options: {
53
+ /**
54
+ * 実行者
55
+ */
56
+ executor?: {
57
+ /**
58
+ * task ID
59
+ * taskによって実行されている場合値が存在する(taskName: authorizePayment)
60
+ */
61
+ id?: string;
62
+ };
63
+ }): (repos: {
53
64
  action: ActionRepo;
54
65
  actionRecipe: ActionRecipeRepo;
55
66
  accountingReport: AccountingReportRepo;
@@ -69,7 +80,7 @@ type IPayAction = factory.action.trade.pay.IAction;
69
80
  /**
70
81
  * MovieTicket着券
71
82
  */
72
- declare function payMovieTicket(params: factory.task.pay.IPayActionData): IPayOperation<IPayAction>;
83
+ declare function payMovieTicket(params: factory.action.trade.pay.IAttributes): IPayOperation<IPayAction>;
73
84
  /**
74
85
  * MovieTicket着券取消
75
86
  */
@@ -127,9 +127,9 @@ exports.checkMovieTicket = checkMovieTicket;
127
127
  * MovieTicket承認
128
128
  * オーソリサービスが存在するわけではないので、実質着券する
129
129
  */
130
- function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
130
+ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet, options) {
131
131
  return (repos) => __awaiter(this, void 0, void 0, function* () {
132
- var _a;
132
+ var _a, _b;
133
133
  let accountId;
134
134
  let payAction;
135
135
  let accountsReceivablesByServiceType = [];
@@ -156,9 +156,11 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
156
156
  }, typeOf: paymentMethodType }, (typeof accountId === 'string') ? { accountId } : undefined),
157
157
  movieTickets: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets
158
158
  };
159
- const payActionAttributes = Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
159
+ const payActionAttributes = Object.assign(Object.assign({ project: transaction.project, typeOf: factory.actionType.PayAction, object: [payObject], agent: transaction.project, recipient: transaction.recipient }, (params.purpose !== undefined)
160
160
  ? { purpose: params.purpose }
161
- : { purpose: { typeOf: transaction.typeOf, transactionNumber: transaction.transactionNumber, id: transaction.id } });
161
+ : { purpose: { typeOf: transaction.typeOf, transactionNumber: transaction.transactionNumber, id: transaction.id } }), (typeof ((_b = options.executor) === null || _b === void 0 ? void 0 : _b.id) === 'string')
162
+ ? { sameAs: { id: options.executor.id, typeOf: 'Task' } } // link sameAs(2024-06-04~)
163
+ : undefined);
162
164
  // 着券させざるをえないが、informPaymentはしない(注文がまだ存在しないため)
163
165
  payAction = yield payMovieTicket(payActionAttributes)(repos);
164
166
  }
@@ -16,7 +16,7 @@ declare function authorize(params: factory.assetTransaction.pay.IStartParamsWith
16
16
  declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
17
17
  product: ProductRepo;
18
18
  }) => Promise<void>;
19
- declare function payPaymentCard(params: factory.task.pay.IPayActionData): (repos: {
19
+ declare function payPaymentCard(params: factory.action.trade.pay.IAttributes): (repos: {
20
20
  action: ActionRepo;
21
21
  accountingReport: AccountingReportRepo;
22
22
  product: ProductRepo;
@@ -19,7 +19,15 @@ import * as factory from '../factory';
19
19
  /**
20
20
  * 決済確定
21
21
  */
22
- export declare function pay(params: factory.task.pay.IData): (repos: {
22
+ export declare function pay(params: factory.task.pay.IData & {
23
+ sameAs?: {
24
+ /**
25
+ * 実行元タスクID
26
+ */
27
+ id: string;
28
+ typeOf: 'Task';
29
+ };
30
+ }): (repos: {
23
31
  acceptedOffer: AcceptedOfferRepo;
24
32
  action: ActionRepo;
25
33
  actionRecipe: ActionRecipeRepo;
@@ -19,6 +19,7 @@ const MovieTicketPaymentService = require("./payment/movieTicket");
19
19
  const PaymentCardPaymentService = require("./payment/paymentCard");
20
20
  function payTask2payActionAttributes(params) {
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
+ var _a;
22
23
  let transaction;
23
24
  if (typeof params.object.paymentMethod.paymentMethodId === 'string') {
24
25
  transaction = yield repos.assetTransaction.findByTransactionNumber({
@@ -38,7 +39,7 @@ function payTask2payActionAttributes(params) {
38
39
  potentialActions: { pay: { purpose: params.purpose } },
39
40
  order
40
41
  });
41
- return payActions[0];
42
+ return Object.assign(Object.assign({}, payActions[0]), (typeof ((_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { sameAs: params.sameAs } : undefined);
42
43
  });
43
44
  }
44
45
  /**
@@ -84,7 +84,8 @@ function call(params) {
84
84
  // アクションが存在すればタスクを実行済扱いにする
85
85
  const action = (yield actionRepo.searchBySameAs({
86
86
  sameAs: { id: { $eq: params.id } },
87
- purpose: { id: { $eq: params.data.purpose.id } }
87
+ purpose: { id: { $eq: params.data.purpose.id } },
88
+ typeOf: { $eq: factory.actionType.AcceptAction }
88
89
  })).shift();
89
90
  if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
90
91
  throwsError = false;
@@ -69,7 +69,8 @@ function call(params) {
69
69
  // アクションが存在すればタスクを実行済扱いにする
70
70
  const action = (yield actionRepo.searchBySameAs({
71
71
  sameAs: { id: { $eq: params.id } },
72
- purpose: { id: { $eq: params.data.purpose.id } }
72
+ purpose: { id: { $eq: params.data.purpose.id } },
73
+ typeOf: { $eq: factory.actionType.AuthorizeAction }
73
74
  })).shift();
74
75
  if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
75
76
  throwsError = false;
@@ -45,7 +45,7 @@ function call(params) {
45
45
  catch (error) {
46
46
  let throwsError = true;
47
47
  // アクションが存在すればタスクを実行済扱いにする
48
- const action = (yield actionRepo.searchBySameAs(Object.assign({ sameAs: { id: { $eq: params.id } } }, (typeof ((_a = params.data.purpose) === null || _a === void 0 ? void 0 : _a.id) === 'string')
48
+ const action = (yield actionRepo.searchBySameAs(Object.assign({ sameAs: { id: { $eq: params.id } }, typeOf: { $eq: factory.actionType.CheckAction } }, (typeof ((_a = params.data.purpose) === null || _a === void 0 ? void 0 : _a.id) === 'string')
49
49
  ? { purpose: { id: { $eq: params.data.purpose.id } } }
50
50
  : undefined))).shift();
51
51
  if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
@@ -1,6 +1,6 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
6
- export declare function call(data: factory.task.pay.IData): IOperationExecute<void>;
6
+ export declare function call(params: Pick<factory.task.pay.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
@@ -27,9 +27,10 @@ const PaymentService = require("../payment");
27
27
  /**
28
28
  * タスク実行関数
29
29
  */
30
- function call(data) {
30
+ function call(params) {
31
31
  return (settings) => __awaiter(this, void 0, void 0, function* () {
32
- yield PaymentService.pay(data)({
32
+ yield PaymentService.pay(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id, typeOf: 'Task' } // タスクIDを関連付け(2024-04-20~)
33
+ }))({
33
34
  acceptedOffer: new acceptedOffer_1.MongoRepository(settings.connection),
34
35
  accountingReport: new accountingReport_1.MongoRepository(settings.connection),
35
36
  action: new action_1.MongoRepository(settings.connection),
@@ -52,7 +52,8 @@ function call(params) {
52
52
  // アクションが存在すればタスクを実行済扱いにする
53
53
  const action = (yield actionRepo.searchBySameAs({
54
54
  sameAs: { id: { $eq: params.id } },
55
- purpose: { id: { $eq: params.data.purpose.id } }
55
+ purpose: { id: { $eq: params.data.purpose.id } },
56
+ typeOf: { $eq: factory.actionType.AcceptAction }
56
57
  })).shift();
57
58
  if (typeof (action === null || action === void 0 ? void 0 : action.id) === 'string') {
58
59
  throwsError = false;
@@ -107,6 +107,7 @@ function execute(task) {
107
107
  case factory.taskName.AcceptCOAOffer:
108
108
  case factory.taskName.AuthorizePayment:
109
109
  case factory.taskName.CheckMovieTicket:
110
+ case factory.taskName.Pay:
110
111
  case factory.taskName.PublishPaymentUrl:
111
112
  case factory.taskName.Refund:
112
113
  case factory.taskName.VoidReserveTransaction:
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.374.0-alpha.1",
13
+ "@chevre/factory": "4.374.0-alpha.2",
14
14
  "@cinerino/sdk": "7.0.0",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
@@ -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": "21.33.0-alpha.21"
113
+ "version": "21.33.0-alpha.23"
114
114
  }