@chevre/domain 24.0.0-alpha.24 → 24.0.0-alpha.26

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.
@@ -1,8 +1,33 @@
1
1
  import * as factory from '../../factory';
2
- import { IActionRecipe, ActionProcessRepo } from './actionProcess';
2
+ import { IKeyOfProjection, IActionRecipe, ActionProcessRepo } from './actionProcess';
3
3
  export type IAcceptPayAction = factory.action.accept.pay.IAction;
4
4
  /**
5
5
  * 決済採用リポジトリ
6
6
  */
7
7
  export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAction, IActionRecipe<factory.recipe.RecipeCategory.publishPaymentUrl>> {
8
+ /**
9
+ * 注文取引から検索する
10
+ */
11
+ findAcceptActionsByPurpose(params: {
12
+ project: {
13
+ id: string;
14
+ };
15
+ purpose: {
16
+ id: string;
17
+ };
18
+ }, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
19
+ /**
20
+ * 決済取引番号から完了済の決済採用アクションを参照する
21
+ */
22
+ findCompletedAcceptActionsByTransactionNumber(params: {
23
+ project: {
24
+ id: string;
25
+ };
26
+ purpose: {
27
+ id: string;
28
+ };
29
+ object: {
30
+ transactionNumber: string;
31
+ };
32
+ }, inclusion: IKeyOfProjection[]): Promise<IAcceptPayAction[]>;
8
33
  }
@@ -1,7 +1,31 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.AcceptPayActionRepo = void 0;
4
- // import { MONGO_MAX_TIME_MS } from '../settings';
27
+ const factory = __importStar(require("../../factory"));
28
+ const settings_1 = require("../../settings");
5
29
  // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
6
30
  // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
7
31
  const actionProcess_1 = require("./actionProcess");
@@ -9,5 +33,67 @@ const actionProcess_1 = require("./actionProcess");
9
33
  * 決済採用リポジトリ
10
34
  */
11
35
  class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
36
+ /**
37
+ * 注文取引から検索する
38
+ */
39
+ async findAcceptActionsByPurpose(params, inclusion) {
40
+ const andConditions = [
41
+ { typeOf: { $eq: factory.actionType.AcceptAction } },
42
+ { 'project.id': { $eq: params.project.id } },
43
+ { 'object.typeOf': { $exists: true, $eq: factory.assetTransactionType.Pay } },
44
+ { 'purpose.id': { $exists: true, $eq: params.purpose.id } }
45
+ ];
46
+ let positiveProjectionFields = actionProcess_1.AVAILABLE_PROJECT_FIELDS;
47
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
48
+ positiveProjectionFields = inclusion.filter((key) => actionProcess_1.AVAILABLE_PROJECT_FIELDS.includes(key));
49
+ }
50
+ const projection = {
51
+ _id: 0,
52
+ id: { $toString: '$_id' },
53
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
54
+ };
55
+ const query = this.actionModel.find({ $and: andConditions }, projection);
56
+ // if (typeof params.limit === 'number' && params.limit > 0) {
57
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
58
+ // query.limit(params.limit)
59
+ // .skip(params.limit * (page - 1));
60
+ // }
61
+ // /* istanbul ignore else */
62
+ // if (params.sort?.startDate !== undefined) {
63
+ // query.sort({ startDate: params.sort.startDate });
64
+ // }
65
+ // const explainResult = await (<any>query).explain();
66
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
67
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
68
+ .lean()
69
+ .exec();
70
+ }
71
+ /**
72
+ * 決済取引番号から完了済の決済採用アクションを参照する
73
+ */
74
+ async findCompletedAcceptActionsByTransactionNumber(params, inclusion) {
75
+ const andConditions = [
76
+ { typeOf: { $eq: factory.actionType.AcceptAction } },
77
+ { actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus } },
78
+ { 'project.id': { $eq: params.project.id } },
79
+ { 'purpose.id': { $exists: true, $eq: params.purpose.id } },
80
+ { 'object.typeOf': { $exists: true, $eq: factory.assetTransactionType.Pay } },
81
+ { 'object.transactionNumber': { $exists: true, $eq: params.object.transactionNumber } }
82
+ ];
83
+ let positiveProjectionFields = actionProcess_1.AVAILABLE_PROJECT_FIELDS;
84
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
85
+ positiveProjectionFields = inclusion.filter((key) => actionProcess_1.AVAILABLE_PROJECT_FIELDS.includes(key));
86
+ }
87
+ const projection = {
88
+ _id: 0,
89
+ id: { $toString: '$_id' },
90
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
91
+ };
92
+ const query = this.actionModel.find({ $and: andConditions }, projection);
93
+ query.limit(1); // ひとまず1つだけでよい
94
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
95
+ .lean()
96
+ .exec();
97
+ }
12
98
  }
13
99
  exports.AcceptPayActionRepo = AcceptPayActionRepo;
@@ -0,0 +1,36 @@
1
+ import * as factory from '../../factory';
2
+ import { ActionProcessRepo } from './actionProcess';
3
+ export type IAuthorizePaymentMethodAction = factory.action.authorize.paymentMethod.any.IAction;
4
+ export type IActionRecipe = never;
5
+ /**
6
+ * 決済承認リポジトリ
7
+ */
8
+ export declare class AuthorizePaymentMethodActionRepo extends ActionProcessRepo<IAuthorizePaymentMethodAction, IActionRecipe> {
9
+ /**
10
+ * 取引に対する決済承認アクションを検索する
11
+ */
12
+ findAuthorizePaymentMethodActionsByPurpose(params: {
13
+ /**
14
+ * 注文取引でフィルター
15
+ */
16
+ purpose: {
17
+ typeOf: factory.transactionType;
18
+ id: string;
19
+ };
20
+ /**
21
+ * 決済取引番号でフィルター
22
+ */
23
+ object?: {
24
+ paymentMethodId?: {
25
+ $eq?: string;
26
+ };
27
+ };
28
+ /**
29
+ * アクションステータスでフィルター
30
+ */
31
+ actionStatus?: {
32
+ $eq?: factory.actionStatusType.CompletedActionStatus;
33
+ };
34
+ sort?: factory.action.ISortOrder;
35
+ }): Promise<IAuthorizePaymentMethodAction[]>;
36
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.AuthorizePaymentMethodActionRepo = void 0;
27
+ const factory = __importStar(require("../../factory"));
28
+ const settings_1 = require("../../settings");
29
+ // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
30
+ // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
31
+ const actionProcess_1 = require("./actionProcess");
32
+ /**
33
+ * 決済承認リポジトリ
34
+ */
35
+ class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo {
36
+ /**
37
+ * 取引に対する決済承認アクションを検索する
38
+ */
39
+ async findAuthorizePaymentMethodActionsByPurpose(params) {
40
+ const andConditions = [
41
+ { typeOf: { $eq: factory.actionType.AuthorizeAction } },
42
+ { 'purpose.typeOf': { $exists: true, $eq: params.purpose.typeOf } },
43
+ { 'purpose.id': { $exists: true, $eq: params.purpose.id } },
44
+ { 'object.typeOf': { $exists: true, $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } }
45
+ ];
46
+ const objectPaymentMethodIdEq = params.object?.paymentMethodId?.$eq;
47
+ if (typeof objectPaymentMethodIdEq === 'string') {
48
+ andConditions.push({ 'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq } });
49
+ }
50
+ const actionStatusEq = params.actionStatus?.$eq;
51
+ if (typeof actionStatusEq === 'string') {
52
+ andConditions.push({ actionStatus: { $eq: actionStatusEq } });
53
+ }
54
+ const positiveProjectionFields = [
55
+ 'project',
56
+ 'actionStatus',
57
+ 'typeOf',
58
+ 'description',
59
+ 'agent',
60
+ 'recipient',
61
+ 'result',
62
+ 'error',
63
+ 'object',
64
+ 'startDate',
65
+ 'endDate',
66
+ 'purpose',
67
+ 'potentialActions',
68
+ 'instrument',
69
+ 'location',
70
+ 'sameAs',
71
+ 'cancelAction',
72
+ 'identifier'
73
+ ];
74
+ const projection = {
75
+ _id: 0,
76
+ id: { $toString: '$_id' },
77
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
78
+ };
79
+ const query = this.actionModel.find({ $and: andConditions }, projection);
80
+ if (typeof params.sort?.startDate === 'number') {
81
+ query.sort({ startDate: params.sort.startDate });
82
+ }
83
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
84
+ .lean()
85
+ .exec();
86
+ }
87
+ }
88
+ exports.AuthorizePaymentMethodActionRepo = AuthorizePaymentMethodActionRepo;
@@ -16,7 +16,7 @@ export declare class ActionRepo extends ActionProcessRepo<IAction<StartableActio
16
16
  /**
17
17
  * アクション検索
18
18
  */
19
- search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAction<T>[]>;
19
+ search<T extends StartableActionType>(params: factory.action.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAction<T>[]>;
20
20
  findPayAction(params: {
21
21
  project: {
22
22
  id: string;
@@ -12,6 +12,7 @@ import type { AcceptCOAOfferActionRepo } from './repo/action/acceptCOAOffer';
12
12
  import type { AcceptPayActionRepo } from './repo/action/acceptPay';
13
13
  import type { AuthorizeInvoiceActionRepo } from './repo/action/authorizeInvoice';
14
14
  import type { AuthorizeOfferActionRepo } from './repo/action/authorizeOffer';
15
+ import type { AuthorizePaymentMethodActionRepo } from './repo/action/authorizePaymentMethod';
15
16
  import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
16
17
  import type { CheckThingActionRepo } from './repo/action/checkThing';
17
18
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
@@ -147,6 +148,10 @@ export declare namespace action {
147
148
  namespace AuthorizeOffer {
148
149
  function createInstance(...params: ConstructorParameters<typeof AuthorizeOfferActionRepo>): Promise<AuthorizeOfferActionRepo>;
149
150
  }
151
+ type AuthorizePaymentMethodAction = AuthorizePaymentMethodActionRepo;
152
+ namespace AuthorizePaymentMethodAction {
153
+ function createInstance(...params: ConstructorParameters<typeof AuthorizePaymentMethodActionRepo>): Promise<AuthorizePaymentMethodActionRepo>;
154
+ }
150
155
  type CheckMovieTicket = CheckMovieTicketActionRepo;
151
156
  namespace CheckMovieTicket {
152
157
  function createInstance(...params: ConstructorParameters<typeof CheckMovieTicketActionRepo>): Promise<CheckMovieTicketActionRepo>;
@@ -148,6 +148,17 @@ var action;
148
148
  }
149
149
  AuthorizeOffer.createInstance = createInstance;
150
150
  })(AuthorizeOffer = action.AuthorizeOffer || (action.AuthorizeOffer = {}));
151
+ let AuthorizePaymentMethodAction;
152
+ (function (AuthorizePaymentMethodAction) {
153
+ let repo;
154
+ async function createInstance(...params) {
155
+ if (repo === undefined) {
156
+ repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/authorizePaymentMethod')))).AuthorizePaymentMethodActionRepo;
157
+ }
158
+ return new repo(...params);
159
+ }
160
+ AuthorizePaymentMethodAction.createInstance = createInstance;
161
+ })(AuthorizePaymentMethodAction = action.AuthorizePaymentMethodAction || (action.AuthorizePaymentMethodAction = {}));
151
162
  let CheckMovieTicket;
152
163
  (function (CheckMovieTicket) {
153
164
  let repo;
@@ -1,5 +1,6 @@
1
1
  import * as factory from '../../../../factory';
2
- import type { ActionRepo } from '../../../../repo/action';
2
+ import type { AcceptPayActionRepo } from '../../../../repo/action/acceptPay';
3
+ import type { AuthorizePaymentMethodActionRepo } from '../../../../repo/action/authorizePaymentMethod';
3
4
  import type { AuthorizationRepo } from '../../../../repo/authorization';
4
5
  import type { TicketRepo } from '../../../../repo/ticket';
5
6
  import type { ITransactionInProgress, PlaceOrderRepo } from '../../../../repo/transaction/placeOrder';
@@ -7,7 +8,9 @@ import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
7
8
  import * as PayTransactionService from '../../../assetTransaction/pay';
8
9
  import { IInvoiceByTicketToken } from '../factory';
9
10
  interface IFixTransactionNumberRepos {
10
- action: ActionRepo;
11
+ action?: never;
12
+ acceptPayAction: AcceptPayActionRepo;
13
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
11
14
  authorization: AuthorizationRepo;
12
15
  ticket: TicketRepo;
13
16
  placeOrder: PlaceOrderRepo;
@@ -1,5 +1,6 @@
1
1
  import * as factory from '../../../../factory';
2
- import type { ActionRepo } from '../../../../repo/action';
2
+ import type { AcceptPayActionRepo } from '../../../../repo/action/acceptPay';
3
+ import type { AuthorizePaymentMethodActionRepo } from '../../../../repo/action/authorizePaymentMethod';
3
4
  import type { AuthorizationRepo } from '../../../../repo/authorization';
4
5
  import type { TicketRepo } from '../../../../repo/ticket';
5
6
  import type { ITransactionInProgress, PlaceOrderRepo } from '../../../../repo/transaction/placeOrder';
@@ -10,6 +11,14 @@ interface IAcceptAction2ticketResult {
10
11
  invoiceByTicketToken: IInvoiceByTicketToken;
11
12
  ticketToken: string;
12
13
  }
14
+ interface IHandlePrePublishedPaymentMethodIdOnAuthorizingRepos {
15
+ action?: never;
16
+ acceptPayAction: AcceptPayActionRepo;
17
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
18
+ authorization: AuthorizationRepo;
19
+ ticket: TicketRepo;
20
+ placeOrder: PlaceOrderRepo;
21
+ }
13
22
  /**
14
23
  * 決済承認前の決済採用アクションを参照する
15
24
  */
@@ -17,12 +26,7 @@ declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
17
26
  object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod' | 'referencesOrder'>;
18
27
  prePublishedPaymentMethodId: string;
19
28
  transaction: Pick<ITransactionInProgress, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
20
- }): (repos: {
21
- action: ActionRepo;
22
- authorization: AuthorizationRepo;
23
- ticket: TicketRepo;
24
- placeOrder: PlaceOrderRepo;
25
- }) => Promise<{
29
+ }): (repos: IHandlePrePublishedPaymentMethodIdOnAuthorizingRepos) => Promise<{
26
30
  authorizeParams?: {
27
31
  creditCard: factory.action.authorize.paymentMethod.any.ICreditCard;
28
32
  paymentMethodByTransaction: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
@@ -37,4 +41,4 @@ declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
37
41
  authorizeParams?: never;
38
42
  acceptAction2ticketResult?: never;
39
43
  }>;
40
- export { handlePrePublishedPaymentMethodIdOnAuthorizing };
44
+ export { IHandlePrePublishedPaymentMethodIdOnAuthorizingRepos, handlePrePublishedPaymentMethodIdOnAuthorizing };
@@ -125,24 +125,32 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
125
125
  const paymentMethodByTransaction = await repos.placeOrder.findInProgressPaymentMethodId({ id: params.transaction.id });
126
126
  if (params.prePublishedPaymentMethodId === paymentMethodByTransaction?.paymentMethodId) {
127
127
  // check existence of acceptAction when authorizing payment(2024-06-01~)
128
- acceptPayAction = (await repos.action.search({
129
- limit: 1,
130
- page: 1,
131
- project: { id: { $eq: params.transaction.project.id } },
132
- typeOf: { $eq: factory.actionType.AcceptAction },
133
- actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
134
- purpose: { id: { $in: [params.transaction.id] } },
135
- object: {
136
- transactionNumber: { $eq: params.prePublishedPaymentMethodId },
137
- typeOf: { $eq: factory.assetTransactionType.Pay }
138
- }
128
+ // acceptPayAction = (<Pick<IAcceptPayAction, 'object' | 'result' | 'id' | 'instrument'>[]>await repos.action.search<factory.actionType.AcceptAction>(
129
+ // {
130
+ // limit: 1,
131
+ // page: 1,
132
+ // project: { id: { $eq: params.transaction.project.id } },
133
+ // typeOf: { $eq: factory.actionType.AcceptAction },
134
+ // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] },
135
+ // purpose: { id: { $in: [params.transaction.id] } },
136
+ // object: {
137
+ // transactionNumber: { $eq: params.prePublishedPaymentMethodId },
138
+ // typeOf: { $eq: factory.assetTransactionType.Pay }
139
+ // }
140
+ // },
141
+ // ['object', 'result', 'instrument']
142
+ // )).shift();
143
+ acceptPayAction = (await repos.acceptPayAction.findCompletedAcceptActionsByTransactionNumber({
144
+ project: { id: params.transaction.project.id },
145
+ purpose: { id: params.transaction.id },
146
+ object: { transactionNumber: params.prePublishedPaymentMethodId }
139
147
  }, ['object', 'result', 'instrument'])).shift();
140
148
  if (acceptPayAction === undefined) {
141
149
  throw new factory.errors.NotFound(factory.actionType.AcceptAction);
142
150
  }
143
151
  debug('acceptPayAction found:', acceptPayAction.id);
144
152
  // find recipe(2024-06-02~)
145
- const actionRecipe = await repos.action.findRecipeByAction({
153
+ const actionRecipe = await repos.acceptPayAction.findRecipeByAction({
146
154
  project: { id: params.transaction.project.id },
147
155
  recipeFor: { id: acceptPayAction.id }
148
156
  });
@@ -169,13 +177,22 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
169
177
  throw new factory.errors.Argument('paymentMethodId', 'pendingPaymentAgencyTransaction not found');
170
178
  }
171
179
  // 既に承認済であれば何もしない(2023-05-15~)
172
- const existingCompletedAuthorizeActions = await repos.action.searchByPurpose({
173
- typeOf: factory.actionType.AuthorizeAction,
180
+ // const existingCompletedAuthorizeActions = <IAuthorizePaymentAction[]>
181
+ // await repos.action.searchByPurpose<factory.actionType.AuthorizeAction>({
182
+ // typeOf: factory.actionType.AuthorizeAction,
183
+ // purpose: { id: params.transaction.id, typeOf: params.transaction.typeOf },
184
+ // actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus },
185
+ // object: {
186
+ // paymentMethodId: { $eq: params.prePublishedPaymentMethodId },
187
+ // typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
188
+ // },
189
+ // sort: { startDate: factory.sortType.Ascending }
190
+ // });
191
+ const existingCompletedAuthorizeActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodActionsByPurpose({
174
192
  purpose: { id: params.transaction.id, typeOf: params.transaction.typeOf },
175
193
  actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus },
176
194
  object: {
177
- paymentMethodId: { $eq: params.prePublishedPaymentMethodId },
178
- typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
195
+ paymentMethodId: { $eq: params.prePublishedPaymentMethodId }
179
196
  },
180
197
  sort: { startDate: factory.sortType.Ascending }
181
198
  });
@@ -4,7 +4,9 @@ import type { AcceptedPaymentMethodRepo } from '../../../repo/acceptedPaymentMet
4
4
  import type { AccountingReportRepo } from '../../../repo/accountingReport';
5
5
  import type { ActionRepo } from '../../../repo/action';
6
6
  import type { CheckMovieTicketActionRepo } from '../../../repo/action/checkMovieTicket';
7
+ import type { AcceptPayActionRepo } from '../../../repo/action/acceptPay';
7
8
  import type { AuthorizeInvoiceActionRepo } from '../../../repo/action/authorizeInvoice';
9
+ import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
8
10
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
9
11
  import type { AuthorizationRepo } from '../../../repo/authorization';
10
12
  import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
@@ -27,7 +29,9 @@ interface IAuthorizeRepos {
27
29
  accountingReport: AccountingReportRepo;
28
30
  action: ActionRepo;
29
31
  checkMovieTicketAction: CheckMovieTicketActionRepo;
32
+ acceptPayAction: AcceptPayActionRepo;
30
33
  authorizeInvoiceAction: AuthorizeInvoiceActionRepo;
34
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
31
35
  assetTransaction: AssetTransactionRepo;
32
36
  authorization: AuthorizationRepo;
33
37
  confirmationNumber: ConfirmationNumberRepo;
@@ -63,7 +63,14 @@ function authorize(params) {
63
63
  object: params.object,
64
64
  transaction,
65
65
  paymentServiceType
66
- })(repos);
66
+ })({
67
+ acceptPayAction: repos.acceptPayAction,
68
+ authorizePaymentMethodAction: repos.authorizePaymentMethodAction,
69
+ authorization: repos.authorization,
70
+ ticket: repos.ticket,
71
+ placeOrder: repos.placeOrder,
72
+ transactionNumber: repos.transactionNumber
73
+ });
67
74
  if (typeof fixTransactionNumberResult.id === 'string') {
68
75
  return { id: fixTransactionNumberResult.id };
69
76
  }
@@ -112,7 +119,7 @@ function authorize(params) {
112
119
  identifier: uniqueActionIdentifier, // add unique identifier(2025-02-25~)
113
120
  ...(typeof taskId === 'string') ? { sameAs: { id: taskId, typeOf: 'Task' } } : undefined // タスク関連付け(2024-04-22~)
114
121
  };
115
- const action = await repos.action.start(actionAttributes);
122
+ const action = await repos.authorizePaymentMethodAction.start(actionAttributes);
116
123
  let payTransaction;
117
124
  try {
118
125
  const startParams = (0, factory_1.creatPayTransactionStartParams)({
@@ -139,7 +146,7 @@ function authorize(params) {
139
146
  }
140
147
  catch (error) {
141
148
  try {
142
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
149
+ await repos.authorizePaymentMethodAction.giveUp({ typeOf: action.typeOf, id: action.id, error });
143
150
  }
144
151
  catch (__) {
145
152
  // no op
@@ -158,7 +165,14 @@ function authorize(params) {
158
165
  project: actionAttributes.project,
159
166
  id: action.id,
160
167
  purpose: actionAttributes.purpose
161
- })(repos);
168
+ })({
169
+ authorizePaymentMethodAction: repos.authorizePaymentMethodAction,
170
+ accountingReport: repos.accountingReport,
171
+ assetTransaction: repos.assetTransaction,
172
+ task: repos.task,
173
+ placeOrder: repos.placeOrder,
174
+ // transaction: TransactionRepo;
175
+ });
162
176
  }
163
177
  }
164
178
  // 複数対応(決済代行IFの場合、0:ChevreError,1:rawError)(2024-03-27~)
@@ -174,7 +188,7 @@ function authorize(params) {
174
188
  object: authorizeObjectIncludingPaymentMethodDetails,
175
189
  invoiceByTicketToken
176
190
  });
177
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
191
+ await repos.authorizePaymentMethodAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
178
192
  return { id: action.id };
179
193
  };
180
194
  }
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
- import type { ActionRepo } from '../../../repo/action';
2
+ import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
3
3
  import type { TaskRepo } from '../../../repo/task';
4
4
  interface IFindAuthorizeActionResult {
5
5
  /**
@@ -18,6 +18,10 @@ interface IFindAuthorizeActionResult {
18
18
  message?: string;
19
19
  };
20
20
  }
21
+ interface IFindAuthorizeActionRepos {
22
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
23
+ task: TaskRepo;
24
+ }
21
25
  declare function findAuthorizeAction(params: {
22
26
  project: {
23
27
  id: string;
@@ -34,8 +38,5 @@ declare function findAuthorizeAction(params: {
34
38
  */
35
39
  id: string;
36
40
  };
37
- }): (repos: {
38
- action: ActionRepo;
39
- task: TaskRepo;
40
- }) => Promise<IFindAuthorizeActionResult>;
41
- export { findAuthorizeAction, };
41
+ }): (repos: IFindAuthorizeActionRepos) => Promise<IFindAuthorizeActionResult>;
42
+ export { IFindAuthorizeActionRepos, findAuthorizeAction, };
@@ -55,7 +55,7 @@ function findAuthorizeAction(params) {
55
55
  break;
56
56
  default:
57
57
  // タスクがReadyでなければアクション検索
58
- const authorizeAction = (await repos.action.searchBySameAs({
58
+ const authorizeAction = (await repos.authorizePaymentMethodAction.searchBySameAs({
59
59
  sameAs: { id: { $eq: task.id } },
60
60
  typeOf: { $eq: factory.actionType.AuthorizeAction }
61
61
  // purpose: { id: { $eq: String(params.purpose.id) } }
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { AccountingReportRepo } from '../../../repo/accountingReport';
3
- import type { ActionRepo } from '../../../repo/action';
3
+ import type { AcceptPayActionRepo } from '../../../repo/action/acceptPay';
4
4
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
5
  import type { PaymentServiceRepo } from '../../../repo/paymentService';
6
6
  import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
@@ -9,7 +9,8 @@ import type { TaskRepo } from '../../../repo/task';
9
9
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
10
10
  interface IInvalidatePaymentUrlRepos {
11
11
  accountingReport: AccountingReportRepo;
12
- action: ActionRepo;
12
+ action?: never;
13
+ acceptPayAction: AcceptPayActionRepo;
13
14
  assetTransaction: AssetTransactionRepo;
14
15
  paymentAccepted: SellerPaymentAcceptedRepo;
15
16
  paymentService: PaymentServiceRepo;
@@ -47,15 +47,17 @@ function invalidatePaymentUrl(params) {
47
47
  // }
48
48
  // }
49
49
  // support multiple accept actions(2025-02-25~)
50
- let acceptPayActions = await repos.action.search({
51
- project: { id: { $eq: transaction.project.id } },
52
- typeOf: { $eq: factory.actionType.AcceptAction },
53
- // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }, // all statuses(2025-02-26~)
54
- purpose: { id: { $in: [transaction.id] } },
55
- object: {
56
- // transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
57
- typeOf: { $eq: factory.assetTransactionType.Pay }
58
- }
50
+ let acceptPayActions = await repos.acceptPayAction.findAcceptActionsByPurpose({
51
+ // project: { id: { $eq: transaction.project.id } },
52
+ // typeOf: { $eq: factory.actionType.AcceptAction },
53
+ // // actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }, // all statuses(2025-02-26~)
54
+ // purpose: { id: { $in: [transaction.id] } },
55
+ // object: {
56
+ // // transactionNumber: { $eq: paymentMethodIdByPaymentUrl },
57
+ // typeOf: { $eq: factory.assetTransactionType.Pay }
58
+ // }
59
+ project: { id: transaction.project.id },
60
+ purpose: { id: transaction.id },
59
61
  }, ['object']);
60
62
  switch (transaction.status) {
61
63
  case factory.transactionStatusType.InProgress:
@@ -1,11 +1,12 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { AccountingReportRepo } from '../../../repo/accountingReport';
3
- import type { ActionRepo } from '../../../repo/action';
3
+ import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
4
4
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
5
  import type { TaskRepo } from '../../../repo/task';
6
6
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
7
7
  interface IProcessVoidPayTransactionRepos {
8
- action: ActionRepo;
8
+ action?: never;
9
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
9
10
  accountingReport: AccountingReportRepo;
10
11
  assetTransaction: AssetTransactionRepo;
11
12
  task: TaskRepo;
@@ -48,7 +48,7 @@ function processVoidPayTransaction(params) {
48
48
  // 承認アクションを取得
49
49
  let authorizeActions;
50
50
  if (typeof params.id === 'string') {
51
- const authorizeAction = await repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
51
+ const authorizeAction = await repos.authorizePaymentMethodAction.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
52
52
  // 取引内のアクションかどうか確認
53
53
  if (authorizeAction.purpose.typeOf !== transaction.typeOf || authorizeAction.purpose.id !== transaction.id) {
54
54
  throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
@@ -56,10 +56,10 @@ function processVoidPayTransaction(params) {
56
56
  authorizeActions = [authorizeAction];
57
57
  }
58
58
  else {
59
- authorizeActions = await repos.action.searchByPurpose({
60
- typeOf: factory.actionType.AuthorizeAction,
59
+ authorizeActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodActionsByPurpose({
60
+ // typeOf: factory.actionType.AuthorizeAction,
61
61
  purpose: { typeOf: transaction.typeOf, id: transaction.id },
62
- object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } }
62
+ // object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } }
63
63
  });
64
64
  switch (transaction.status) {
65
65
  case factory.transactionStatusType.InProgress:
@@ -94,7 +94,7 @@ function processVoidPayTransaction(params) {
94
94
  for (const action of authorizeActions) {
95
95
  // 失敗するケースがあっても、残りが少なくとも処理されるようにエラーハンドリング
96
96
  try {
97
- await repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id, cancelAction });
97
+ await repos.authorizePaymentMethodAction.cancelWithVoid({ typeOf: action.typeOf, id: action.id, cancelAction });
98
98
  // 取引が存在すれば中止
99
99
  const transactionNumber = action.object.paymentMethodId;
100
100
  if (typeof transactionNumber === 'string' && transactionNumber.length > 0) {
@@ -1,6 +1,7 @@
1
1
  import * as factory from '../../../factory';
2
2
  import type { AccountingReportRepo } from '../../../repo/accountingReport';
3
- import type { ActionRepo } from '../../../repo/action';
3
+ import type { AcceptPayActionRepo } from '../../../repo/action/acceptPay';
4
+ import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
4
5
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
5
6
  import type { PaymentServiceRepo } from '../../../repo/paymentService';
6
7
  import type { PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
@@ -20,7 +21,9 @@ declare function voidPayTransaction(params: factory.task.IData<factory.taskName.
20
21
  };
21
22
  }): (repos: {
22
23
  accountingReport: AccountingReportRepo;
23
- action: ActionRepo;
24
+ action?: never;
25
+ acceptPayAction: AcceptPayActionRepo;
26
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
24
27
  assetTransaction: AssetTransactionRepo;
25
28
  paymentAccepted: SellerPaymentAcceptedRepo;
26
29
  paymentService: PaymentServiceRepo;
@@ -29,7 +29,9 @@ const acceptedPaymentMethod_1 = require("../../repo/acceptedPaymentMethod");
29
29
  const accountingReport_1 = require("../../repo/accountingReport");
30
30
  const action_1 = require("../../repo/action");
31
31
  const checkMovieTicket_1 = require("../../repo/action/checkMovieTicket");
32
+ const acceptPay_1 = require("../../repo/action/acceptPay");
32
33
  const authorizeInvoice_1 = require("../../repo/action/authorizeInvoice");
34
+ const authorizePaymentMethod_1 = require("../../repo/action/authorizePaymentMethod");
33
35
  const assetTransaction_1 = require("../../repo/assetTransaction");
34
36
  const authorization_1 = require("../../repo/authorization");
35
37
  const confirmationNumber_1 = require("../../repo/confirmationNumber");
@@ -63,7 +65,8 @@ function call(params) {
63
65
  return;
64
66
  }
65
67
  let callResult;
66
- const actionRepo = new action_1.ActionRepo(connection);
68
+ // const actionRepo = new ActionRepo(connection);
69
+ const authorizePaymentMethodActionRepo = new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection);
67
70
  // const transactionProcessRepo = new TransactionProcessRepo(redisClient, { lockExpiresInSeconds: 120 });
68
71
  const paymentServiceId = params.data.object.issuedThrough.id;
69
72
  const credentialsExpireInSeconds = settings.movieticketReserve.credentialsExpireInSeconds;
@@ -77,9 +80,11 @@ function call(params) {
77
80
  })({
78
81
  acceptedPaymentMethod: new acceptedPaymentMethod_1.AcceptedPaymentMethodRepo(connection),
79
82
  accountingReport: new accountingReport_1.AccountingReportRepo(connection),
80
- action: actionRepo,
83
+ action: new action_1.ActionRepo(connection),
81
84
  checkMovieTicketAction: new checkMovieTicket_1.CheckMovieTicketActionRepo(connection),
85
+ acceptPayAction: new acceptPay_1.AcceptPayActionRepo(connection),
82
86
  authorizeInvoiceAction: new authorizeInvoice_1.AuthorizeInvoiceActionRepo(connection),
87
+ authorizePaymentMethodAction: authorizePaymentMethodActionRepo,
83
88
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
84
89
  authorization: new authorization_1.AuthorizationRepo(connection),
85
90
  confirmationNumber: new confirmationNumber_1.ConfirmationNumberRepo({ connection }),
@@ -107,7 +112,7 @@ function call(params) {
107
112
  catch (error) {
108
113
  let throwsError = true;
109
114
  // アクションが存在すればタスクを実行済扱いにする
110
- const action = (await actionRepo.searchBySameAs({
115
+ const action = (await authorizePaymentMethodActionRepo.searchBySameAs({
111
116
  sameAs: { id: { $eq: params.id } },
112
117
  purpose: { id: { $eq: params.data.purpose.id } },
113
118
  typeOf: { $eq: factory.actionType.AuthorizeAction }
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.call = call;
4
4
  const accountingReport_1 = require("../../repo/accountingReport");
5
- const action_1 = require("../../repo/action");
5
+ // import { ActionRepo } from '../../repo/action';
6
+ const acceptPay_1 = require("../../repo/action/acceptPay");
7
+ const authorizePaymentMethod_1 = require("../../repo/action/authorizePaymentMethod");
6
8
  const assetTransaction_1 = require("../../repo/assetTransaction");
7
9
  const paymentService_1 = require("../../repo/paymentService");
8
10
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
@@ -22,7 +24,9 @@ function call(params) {
22
24
  sameAs: { id: params.id }
23
25
  })({
24
26
  accountingReport: new accountingReport_1.AccountingReportRepo(connection),
25
- action: new action_1.ActionRepo(connection),
27
+ // action: new ActionRepo(connection),
28
+ acceptPayAction: new acceptPay_1.AcceptPayActionRepo(connection),
29
+ authorizePaymentMethodAction: new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection),
26
30
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
27
31
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
28
32
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
package/package.json CHANGED
@@ -99,5 +99,5 @@
99
99
  "postversion": "git push origin --tags",
100
100
  "prepublishOnly": "npm run clean && npm run build"
101
101
  },
102
- "version": "24.0.0-alpha.24"
102
+ "version": "24.0.0-alpha.26"
103
103
  }