@chevre/domain 24.0.0-alpha.25 → 24.0.0-alpha.27

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,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import { IActionRecipe, ActionProcessRepo } from './actionProcess';
2
+ import { IKeyOfProjection, IActionRecipe, ActionProcessRepo } from './actionProcess';
3
3
  export type IAuthorizeInvoiceAction = factory.action.authorize.invoice.IAction & {
4
4
  /**
5
5
  * 実際存在しない属性だが、ActionProcessRepoのTActionに適合させるために補完
@@ -10,4 +10,17 @@ export type IAuthorizeInvoiceAction = factory.action.authorize.invoice.IAction &
10
10
  * インボイス承認リポジトリ
11
11
  */
12
12
  export declare class AuthorizeInvoiceActionRepo extends ActionProcessRepo<IAuthorizeInvoiceAction, IActionRecipe<factory.recipe.RecipeCategory.authorizeInvoice | factory.recipe.RecipeCategory.authorizeInvoice3ds>> {
13
+ /**
14
+ * 決済取引からインボイス承認アクションをひとつ参照する
15
+ */
16
+ findAuthorizeInvoiceActionsByPayTransaction(params: {
17
+ /**
18
+ * 決済方法ID
19
+ */
20
+ paymentMethodId: string;
21
+ /**
22
+ * 決済取引ID
23
+ */
24
+ payTransactionId: string;
25
+ }, inclusion: IKeyOfProjection[]): Promise<IAuthorizeInvoiceAction[]>;
13
26
  }
@@ -1,6 +1,30 @@
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.AuthorizeInvoiceActionRepo = void 0;
27
+ const factory = __importStar(require("../../factory"));
4
28
  // import { MONGO_MAX_TIME_MS } from '../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';
@@ -9,5 +33,17 @@ const actionProcess_1 = require("./actionProcess");
9
33
  * インボイス承認リポジトリ
10
34
  */
11
35
  class AuthorizeInvoiceActionRepo extends actionProcess_1.ActionProcessRepo {
36
+ /**
37
+ * 決済取引からインボイス承認アクションをひとつ参照する
38
+ */
39
+ async findAuthorizeInvoiceActionsByPayTransaction(params, inclusion) {
40
+ return this.findAnyActions({
41
+ limit: 1, // ひとまず1でok
42
+ page: 1,
43
+ typeOf: { $eq: factory.actionType.AuthorizeAction },
44
+ object: { paymentMethodId: { $eq: params.paymentMethodId } },
45
+ sameAs: { id: { $eq: params.payTransactionId } } // sameAsが決済取引
46
+ }, inclusion);
47
+ }
12
48
  }
13
49
  exports.AuthorizeInvoiceActionRepo = AuthorizeInvoiceActionRepo;
@@ -7,18 +7,27 @@ export type IActionRecipe = never;
7
7
  */
8
8
  export declare class AuthorizePaymentMethodActionRepo extends ActionProcessRepo<IAuthorizePaymentMethodAction, IActionRecipe> {
9
9
  /**
10
- * 取引に対するアクションを検索する
10
+ * 取引に対する決済承認アクションを検索する
11
11
  */
12
12
  findAuthorizePaymentMethodActionsByPurpose(params: {
13
+ /**
14
+ * 注文取引でフィルター
15
+ */
13
16
  purpose: {
14
17
  typeOf: factory.transactionType;
15
18
  id: string;
16
19
  };
20
+ /**
21
+ * 決済取引番号でフィルター
22
+ */
17
23
  object?: {
18
24
  paymentMethodId?: {
19
25
  $eq?: string;
20
26
  };
21
27
  };
28
+ /**
29
+ * アクションステータスでフィルター
30
+ */
22
31
  actionStatus?: {
23
32
  $eq?: factory.actionStatusType.CompletedActionStatus;
24
33
  };
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.AuthorizePaymentMethodActionRepo = void 0;
27
27
  const factory = __importStar(require("../../factory"));
28
- const settings_1 = require("../../settings");
28
+ // import { MONGO_MAX_TIME_MS } from '../../settings';
29
29
  // import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
30
30
  // import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
31
31
  const actionProcess_1 = require("./actionProcess");
@@ -34,55 +34,17 @@ const actionProcess_1 = require("./actionProcess");
34
34
  */
35
35
  class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo {
36
36
  /**
37
- * 取引に対するアクションを検索する
37
+ * 取引に対する決済承認アクションを検索する
38
38
  */
39
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((andConditions.length > 0) ? { $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();
40
+ return this.findAnyActionsByPurpose({
41
+ ...params,
42
+ typeOf: factory.actionType.AuthorizeAction,
43
+ object: {
44
+ ...params.object,
45
+ typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment }
46
+ }
47
+ });
86
48
  }
87
49
  }
88
50
  exports.AuthorizePaymentMethodActionRepo = AuthorizePaymentMethodActionRepo;
@@ -12,7 +12,6 @@ type IAvailableActionRecipe = IActionRecipe<Exclude<factory.recipe.RecipeCategor
12
12
  * アクションリポジトリ
13
13
  */
14
14
  export declare class ActionRepo extends ActionProcessRepo<IAction<StartableActionType>, IAvailableActionRecipe> {
15
- static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): any[];
16
15
  /**
17
16
  * アクション検索
18
17
  */