@chevre/domain 24.0.0-alpha.33 → 24.0.0-alpha.34

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,10 +1,25 @@
1
1
  import * as factory from '../../factory';
2
2
  import { ActionProcessRepo } from './actionProcess';
3
- export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
3
+ export type IAuthorizeEventServiceOfferAction = factory.action.authorize.offer.eventService.IAction;
4
+ export type IAuthorizeProductOfferAction = factory.action.authorize.offer.product.IAction;
5
+ export type IAuthorizeOfferAction = IAuthorizeEventServiceOfferAction | IAuthorizeProductOfferAction;
6
+ export type IAuthorizeOfferActionWithInstrument = Pick<IAuthorizeEventServiceOfferAction | IAuthorizeProductOfferAction, 'instrument'>;
4
7
  /**
5
8
  * オファー承認リポジトリ
6
9
  */
7
10
  export declare class AuthorizeOfferActionRepo extends ActionProcessRepo<IAuthorizeOfferAction, never> {
11
+ findAuthorizeOfferInstrumentsByIds(params: {
12
+ /**
13
+ * 注文取引
14
+ */
15
+ purpose: {
16
+ id: string;
17
+ };
18
+ /**
19
+ * アクションIDリスト
20
+ */
21
+ ids: string[];
22
+ }): Promise<IAuthorizeOfferActionWithInstrument[]>;
8
23
  /**
9
24
  * アクション再開
10
25
  */
@@ -26,13 +26,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.AuthorizeOfferActionRepo = void 0;
27
27
  const factory = __importStar(require("../../factory"));
28
28
  // import { MONGO_MAX_TIME_MS } from '../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
29
  const actionProcess_1 = require("./actionProcess");
32
30
  /**
33
31
  * オファー承認リポジトリ
34
32
  */
35
33
  class AuthorizeOfferActionRepo extends actionProcess_1.ActionProcessRepo {
34
+ async findAuthorizeOfferInstrumentsByIds(params) {
35
+ if (!Array.isArray(params.ids)) {
36
+ throw new factory.errors.Argument('ids', 'must be Array');
37
+ }
38
+ return this.findAnyActions({
39
+ typeOf: factory.actionType.AuthorizeAction,
40
+ purpose: {
41
+ typeOf: { $in: [factory.transactionType.PlaceOrder] },
42
+ id: { $in: [params.purpose.id] }
43
+ },
44
+ object: {
45
+ typeOf: {
46
+ $in: [
47
+ factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
48
+ factory.offerType.Offer
49
+ ]
50
+ }
51
+ },
52
+ id: { $in: params.ids }
53
+ }, ['instrument']);
54
+ }
36
55
  /**
37
56
  * アクション再開
38
57
  */
@@ -33,4 +33,16 @@ export declare class AuthorizePaymentMethodActionRepo extends ActionProcessRepo<
33
33
  };
34
34
  sort?: factory.action.ISortOrder;
35
35
  }): Promise<IAuthorizePaymentMethodAction[]>;
36
+ findAuthorizePaymentMethodResultsById(params: {
37
+ /**
38
+ * 注文取引
39
+ */
40
+ purpose: {
41
+ id: string;
42
+ };
43
+ /**
44
+ * アクションIDリスト
45
+ */
46
+ ids: string[];
47
+ }): Promise<Pick<IAuthorizePaymentMethodAction, 'result'>[]>;
36
48
  }
@@ -46,5 +46,19 @@ class AuthorizePaymentMethodActionRepo extends actionProcess_1.ActionProcessRepo
46
46
  }
47
47
  });
48
48
  }
49
+ async findAuthorizePaymentMethodResultsById(params) {
50
+ if (!Array.isArray(params.ids)) {
51
+ throw new factory.errors.Argument('ids', 'must be Array');
52
+ }
53
+ return this.findAnyActions({
54
+ typeOf: factory.actionType.AuthorizeAction,
55
+ purpose: {
56
+ typeOf: { $in: [factory.transactionType.PlaceOrder] },
57
+ id: { $in: [params.purpose.id] }
58
+ },
59
+ object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } },
60
+ id: { $in: params.ids }
61
+ }, ['result']);
62
+ }
49
63
  }
50
64
  exports.AuthorizePaymentMethodActionRepo = AuthorizePaymentMethodActionRepo;
@@ -0,0 +1,8 @@
1
+ import * as factory from '../../factory';
2
+ import { ActionProcessRepo } from './actionProcess';
3
+ export type IAuthorizeTicketedObjectAction = factory.action.authorize.ticketedObject.IAction;
4
+ /**
5
+ * 決済とオファー以外に対する汎用承認リポジトリ
6
+ */
7
+ export declare class AuthorizeTicketedObjectActionRepo extends ActionProcessRepo<IAuthorizeTicketedObjectAction, never> {
8
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizeTicketedObjectActionRepo = void 0;
4
+ // import { MONGO_MAX_TIME_MS } from '../settings';
5
+ const actionProcess_1 = require("./actionProcess");
6
+ /**
7
+ * 決済とオファー以外に対する汎用承認リポジトリ
8
+ */
9
+ class AuthorizeTicketedObjectActionRepo extends actionProcess_1.ActionProcessRepo {
10
+ }
11
+ exports.AuthorizeTicketedObjectActionRepo = AuthorizeTicketedObjectActionRepo;
@@ -7,7 +7,7 @@ export { ICancelActionAction };
7
7
  /**
8
8
  * 汎用アクションリポジトリで開始可能なアクションタイプ
9
9
  */
10
- type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction>;
10
+ type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction | factory.actionType.AuthorizeAction>;
11
11
  type IAvailableActionRecipe = IActionRecipe<Exclude<factory.recipe.RecipeCategory, factory.recipe.RecipeCategory.publishPaymentUrl | factory.recipe.RecipeCategory.checkMovieTicket | factory.recipe.RecipeCategory.acceptCOAOffer | factory.recipe.RecipeCategory.authorizeInvoice | factory.recipe.RecipeCategory.authorizeInvoice3ds>>;
12
12
  /**
13
13
  * アクションリポジトリ
@@ -14,6 +14,7 @@ import type { AuthorizeInvoiceActionRepo } from './repo/action/authorizeInvoice'
14
14
  import type { AuthorizeOfferActionRepo } from './repo/action/authorizeOffer';
15
15
  import type { AuthorizeProductOfferActionRepo } from './repo/action/authorizeProductOffer';
16
16
  import type { AuthorizePaymentMethodActionRepo } from './repo/action/authorizePaymentMethod';
17
+ import type { AuthorizeTicketedObjectActionRepo } from './repo/action/authorizeTicketedObject';
17
18
  import type { CheckMovieTicketActionRepo } from './repo/action/checkMovieTicket';
18
19
  import type { CheckThingActionRepo } from './repo/action/checkThing';
19
20
  import type { AdditionalPropertyRepo } from './repo/additionalProperty';
@@ -155,6 +156,10 @@ export declare namespace action {
155
156
  namespace AuthorizePaymentMethod {
156
157
  function createInstance(...params: ConstructorParameters<typeof AuthorizePaymentMethodActionRepo>): Promise<AuthorizePaymentMethodActionRepo>;
157
158
  }
159
+ type AuthorizeTicketedObject = AuthorizeTicketedObjectActionRepo;
160
+ namespace AuthorizeTicketedObject {
161
+ function createInstance(...params: ConstructorParameters<typeof AuthorizeTicketedObjectActionRepo>): Promise<AuthorizeTicketedObjectActionRepo>;
162
+ }
158
163
  type CheckMovieTicket = CheckMovieTicketActionRepo;
159
164
  namespace CheckMovieTicket {
160
165
  function createInstance(...params: ConstructorParameters<typeof CheckMovieTicketActionRepo>): Promise<CheckMovieTicketActionRepo>;
@@ -170,6 +170,17 @@ var action;
170
170
  }
171
171
  AuthorizePaymentMethod.createInstance = createInstance;
172
172
  })(AuthorizePaymentMethod = action.AuthorizePaymentMethod || (action.AuthorizePaymentMethod = {}));
173
+ let AuthorizeTicketedObject;
174
+ (function (AuthorizeTicketedObject) {
175
+ let repo;
176
+ async function createInstance(...params) {
177
+ if (repo === undefined) {
178
+ repo = (await Promise.resolve().then(() => __importStar(require('./repo/action/authorizeTicketedObject')))).AuthorizeTicketedObjectActionRepo;
179
+ }
180
+ return new repo(...params);
181
+ }
182
+ AuthorizeTicketedObject.createInstance = createInstance;
183
+ })(AuthorizeTicketedObject = action.AuthorizeTicketedObject || (action.AuthorizeTicketedObject = {}));
173
184
  let CheckMovieTicket;
174
185
  (function (CheckMovieTicket) {
175
186
  let repo;
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
- import type { ActionRepo } from '../../../repo/action';
2
+ import type { AuthorizeTicketedObjectActionRepo } from '../../../repo/action/authorizeTicketedObject';
3
3
  import type { AuthorizationRepo } from '../../../repo/authorization';
4
4
  import type { EventRepo } from '../../../repo/event';
5
5
  import type { EventOfferRepo } from '../../../repo/eventOffer';
@@ -9,6 +9,19 @@ import type { MemberProgramRepo } from '../../../repo/memberProgram';
9
9
  import type { ProductOfferRepo } from '../../../repo/productOffer';
10
10
  import type { TicketRepo } from '../../../repo/ticket';
11
11
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
12
+ interface IIssueEventOfferTicketRepos {
13
+ action?: never;
14
+ authorizeTicketedObjectAction: AuthorizeTicketedObjectActionRepo;
15
+ authorization: AuthorizationRepo;
16
+ event: EventRepo;
17
+ eventOffer: EventOfferRepo;
18
+ issuer: IssuerRepo;
19
+ member: MemberRepo;
20
+ memberProgram: MemberProgramRepo;
21
+ productOffer: ProductOfferRepo;
22
+ ticket: TicketRepo;
23
+ placeOrder: PlaceOrderRepo;
24
+ }
12
25
  declare function issueEventOfferTicket(params: {
13
26
  now: Date;
14
27
  audience: Pick<factory.action.authorize.offer.eventService.IPurpose, 'id'>;
@@ -31,18 +44,7 @@ declare function issueEventOfferTicket(params: {
31
44
  */
32
45
  id: string;
33
46
  };
34
- }): (repos: {
35
- action: ActionRepo;
36
- authorization: AuthorizationRepo;
37
- event: EventRepo;
38
- eventOffer: EventOfferRepo;
39
- issuer: IssuerRepo;
40
- member: MemberRepo;
41
- memberProgram: MemberProgramRepo;
42
- productOffer: ProductOfferRepo;
43
- ticket: TicketRepo;
44
- placeOrder: PlaceOrderRepo;
45
- }) => Promise<{
47
+ }): (repos: IIssueEventOfferTicketRepos) => Promise<{
46
48
  ticketToken: string;
47
49
  }>;
48
- export { issueEventOfferTicket };
50
+ export { IIssueEventOfferTicketRepos, issueEventOfferTicket };
@@ -44,7 +44,7 @@ function createOfferTicket(params) {
44
44
  id: instrument.id
45
45
  }
46
46
  };
47
- const action = await repos.action.start(actionAttributes);
47
+ const action = await repos.authorizeTicketedObjectAction.start(actionAttributes);
48
48
  let authorizations;
49
49
  try {
50
50
  authorizations = await repos.authorization.issueAuthorization([{
@@ -59,7 +59,7 @@ function createOfferTicket(params) {
59
59
  }
60
60
  catch (error) {
61
61
  try {
62
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
62
+ await repos.authorizeTicketedObjectAction.giveUp({ typeOf: action.typeOf, id: action.id, error });
63
63
  }
64
64
  catch (__) {
65
65
  // 失敗したら仕方ない
@@ -67,7 +67,7 @@ function createOfferTicket(params) {
67
67
  throw error;
68
68
  }
69
69
  const result = authorizations.map(({ code, typeOf }) => ({ code, typeOf }));
70
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
70
+ await repos.authorizeTicketedObjectAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
71
71
  const ticketToken = authorizations.shift()?.code;
72
72
  if (typeof ticketToken !== 'string') {
73
73
  // 基本的にありえないフロー
@@ -1,10 +1,13 @@
1
- import type { ActionRepo } from '../../../repo/action';
1
+ import type { AuthorizeOfferActionRepo } from '../../../repo/action/authorizeOffer';
2
+ import type { AuthorizePaymentMethodActionRepo } from '../../../repo/action/authorizePaymentMethod';
2
3
  import type { IPlacingOrder, OrderInTransactionRepo } from '../../../repo/orderInTransaction';
3
4
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
4
5
  import * as factory from '../../../factory';
5
6
  type IPlaceOrderTransaction = Pick<factory.transaction.placeOrder.ITransaction, 'id' | 'project' | 'typeOf' | 'result' | 'object' | 'seller'>;
6
7
  interface ICreatePlacingOrderFromExistingTransactionRepos {
7
- action: ActionRepo;
8
+ action?: never;
9
+ authorizeOfferAction: AuthorizeOfferActionRepo;
10
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
8
11
  orderInTransaction: OrderInTransactionRepo;
9
12
  placeOrder: PlaceOrderRepo;
10
13
  }
@@ -54,31 +54,46 @@ function createPlacingOrderFromExistingTransaction(params) {
54
54
  if (Array.isArray(authorizeActionsAsResult) && authorizeActionsAsResult.length > 0) {
55
55
  const completedAuthorizeActionIds = authorizeActionsAsResult.map(({ id }) => id);
56
56
  if (completedAuthorizeActionIds.length > 0) {
57
- authorizePaymentActions = await repos.action.search({
58
- typeOf: factory.actionType.AuthorizeAction,
59
- purpose: {
60
- typeOf: { $in: [factory.transactionType.PlaceOrder] },
61
- id: { $in: [placeOrderTransactionWithResult.id] }
62
- },
63
- object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } },
64
- id: { $in: completedAuthorizeActionIds }
65
- }, ['result']);
66
- authorizeOfferActionsWithInstrument = await repos.action.search({
67
- typeOf: factory.actionType.AuthorizeAction,
68
- purpose: {
69
- typeOf: { $in: [factory.transactionType.PlaceOrder] },
70
- id: { $in: [placeOrderTransactionWithResult.id] }
71
- },
72
- object: {
73
- typeOf: {
74
- $in: [
75
- factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
76
- factory.offerType.Offer
77
- ]
78
- }
79
- },
80
- id: { $in: completedAuthorizeActionIds }
81
- }, ['instrument']);
57
+ // authorizePaymentActions = <Pick<factory.action.authorize.paymentMethod.any.IAction, 'result'>[]>
58
+ // await repos.action.search<factory.actionType.AuthorizeAction>(
59
+ // {
60
+ // typeOf: factory.actionType.AuthorizeAction,
61
+ // purpose: {
62
+ // typeOf: { $in: [factory.transactionType.PlaceOrder] },
63
+ // id: { $in: [placeOrderTransactionWithResult.id] }
64
+ // },
65
+ // object: { typeOf: { $eq: factory.action.authorize.paymentMethod.any.ResultType.Payment } },
66
+ // id: { $in: completedAuthorizeActionIds }
67
+ // },
68
+ // ['result']
69
+ // );
70
+ authorizePaymentActions = await repos.authorizePaymentMethodAction.findAuthorizePaymentMethodResultsById({
71
+ purpose: { id: placeOrderTransactionWithResult.id },
72
+ ids: completedAuthorizeActionIds
73
+ });
74
+ // authorizeOfferActionsWithInstrument = <IAuthorizeActionWithInstrument[]>await repos.action.search<factory.actionType.AuthorizeAction>(
75
+ // {
76
+ // typeOf: factory.actionType.AuthorizeAction,
77
+ // purpose: {
78
+ // typeOf: { $in: [factory.transactionType.PlaceOrder] },
79
+ // id: { $in: [placeOrderTransactionWithResult.id] }
80
+ // },
81
+ // object: {
82
+ // typeOf: {
83
+ // $in: [
84
+ // factory.action.authorize.offer.eventService.ObjectType.SeatReservation,
85
+ // factory.offerType.Offer
86
+ // ]
87
+ // }
88
+ // },
89
+ // id: { $in: completedAuthorizeActionIds }
90
+ // },
91
+ // ['instrument']
92
+ // );
93
+ authorizeOfferActionsWithInstrument = await repos.authorizeOfferAction.findAuthorizeOfferInstrumentsByIds({
94
+ purpose: { id: placeOrderTransactionWithResult.id },
95
+ ids: completedAuthorizeActionIds
96
+ });
82
97
  }
83
98
  }
84
99
  // orderedItem生成のためにacceptedOffersを取得
@@ -1,6 +1,8 @@
1
1
  import type { AcceptedOfferRepo } from '../../repo/acceptedOffer';
2
2
  import type { AccountingReportRepo } from '../../repo/accountingReport';
3
3
  import type { ActionRepo } from '../../repo/action';
4
+ import type { AuthorizeOfferActionRepo } from '../../repo/action/authorizeOffer';
5
+ import type { AuthorizePaymentMethodActionRepo } from '../../repo/action/authorizePaymentMethod';
4
6
  import type { OrderRepo } from '../../repo/order';
5
7
  import type { OrderInTransactionRepo } from '../../repo/orderInTransaction';
6
8
  import type { SettingRepo } from '../../repo/setting';
@@ -12,6 +14,8 @@ interface IPlaceOrderRepos {
12
14
  acceptedOffer: AcceptedOfferRepo;
13
15
  accountingReport: AccountingReportRepo;
14
16
  action: ActionRepo;
17
+ authorizeOfferAction: AuthorizeOfferActionRepo;
18
+ authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
15
19
  order: OrderRepo;
16
20
  orderInTransaction: OrderInTransactionRepo;
17
21
  setting: SettingRepo;
@@ -42,7 +42,12 @@ function placeOrder(params) {
42
42
  project: { id: params.project.id },
43
43
  confirmationNumber: params.object.confirmationNumber,
44
44
  orderNumber: params.object.orderNumber
45
- })(repos);
45
+ })({
46
+ authorizeOfferAction: repos.authorizeOfferAction,
47
+ authorizePaymentMethodAction: repos.authorizePaymentMethodAction,
48
+ orderInTransaction: repos.orderInTransaction,
49
+ placeOrder: repos.placeOrder,
50
+ });
46
51
  // USE_ORDER_PAYMENT_DUE_ON_PLACED設定を廃止したので、必ずOrderPaymentDueのはず(2024-01-10~)
47
52
  if (order.orderStatus !== factory.orderStatus.OrderPaymentDue) {
48
53
  throw new factory.errors.Internal(`orderStatus must be ${factory.orderStatus.OrderPaymentDue}`);
@@ -4,6 +4,8 @@ exports.call = call;
4
4
  const acceptedOffer_1 = require("../../repo/acceptedOffer");
5
5
  const accountingReport_1 = require("../../repo/accountingReport");
6
6
  const action_1 = require("../../repo/action");
7
+ const authorizeOffer_1 = require("../../repo/action/authorizeOffer");
8
+ const authorizePaymentMethod_1 = require("../../repo/action/authorizePaymentMethod");
7
9
  const order_1 = require("../../repo/order");
8
10
  const orderInTransaction_1 = require("../../repo/orderInTransaction");
9
11
  const setting_1 = require("../../repo/setting");
@@ -23,6 +25,8 @@ function call(data) {
23
25
  acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
24
26
  accountingReport: new accountingReport_1.AccountingReportRepo(connection),
25
27
  action: new action_1.ActionRepo(connection),
28
+ authorizeOfferAction: new authorizeOffer_1.AuthorizeOfferActionRepo(connection),
29
+ authorizePaymentMethodAction: new authorizePaymentMethod_1.AuthorizePaymentMethodActionRepo(connection),
26
30
  order: new order_1.OrderRepo(connection),
27
31
  orderInTransaction: new orderInTransaction_1.OrderInTransactionRepo(connection),
28
32
  setting: new setting_1.SettingRepo(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.33"
102
+ "version": "24.0.0-alpha.34"
103
103
  }