@chevre/domain 25.0.0-alpha.17 → 25.0.0-alpha.19

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.
@@ -72,6 +72,11 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
72
72
  project: {
73
73
  id: string;
74
74
  };
75
+ }, options: {
76
+ /**
77
+ * 注文取引タイプのドキュメントのみを参照対象にするかどうか
78
+ */
79
+ onlyPlaceOrder: boolean;
75
80
  }): Promise<string>;
76
81
  /**
77
82
  * 注文取引からcustomerを参照する
@@ -49,12 +49,13 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
49
49
  * 注文取引から注文番号を参照する
50
50
  * 存在しなければNotFoundError
51
51
  */
52
- async findOrderNumberByIdentifier(params) {
52
+ async findOrderNumberByIdentifier(params, options) {
53
53
  const { project, identifier } = params;
54
+ const onlyPlaceOrder = options.onlyPlaceOrder === true;
54
55
  const doc = await this.orderModel.findOne({
55
56
  identifier: { $eq: identifier },
56
- typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
57
- 'project.id': { $eq: project.id }
57
+ 'project.id': { $eq: project.id },
58
+ ...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
58
59
  }, {
59
60
  _id: 0,
60
61
  orderNumber: 1
@@ -20,7 +20,6 @@ interface IOptions {
20
20
  secret: string;
21
21
  passportValidator?: IPassportValidator;
22
22
  }
23
- type IStartParams = (factory.transaction.placeOrder.IStartParamsWithoutDetail) & {};
24
23
  /**
25
24
  * 取引許可証リポジトリ
26
25
  */
@@ -34,7 +33,11 @@ export declare class PassportRepo {
34
33
  /**
35
34
  * 許可証トークンがあれば検証する
36
35
  */
37
- validatePassportTokenIfExist(params: Pick<IStartParams, 'object'>): Promise<{
36
+ validatePassportTokenIfExist(params: {
37
+ object?: {
38
+ passport?: factory.transaction.IPassportBeforeStart;
39
+ };
40
+ }): Promise<{
38
41
  passport?: IVerifiedPassport;
39
42
  customerType?: string;
40
43
  }>;
@@ -122,16 +122,18 @@ class PlaceOrderRepo {
122
122
  if (Array.isArray(sellerIdIn)) {
123
123
  andConditions.push({ 'seller.id': { $exists: true, $in: sellerIdIn } });
124
124
  }
125
- const resultOrderNumberIn = params.result?.order?.orderNumbers;
126
- if (Array.isArray(resultOrderNumberIn)) {
127
- andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
128
- }
129
- const resultOrderConfirmationNumberEq = params.result?.order?.confirmationNumber?.$eq;
130
- if (typeof resultOrderConfirmationNumberEq === 'string') {
131
- andConditions.push({
132
- 'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
133
- });
134
- }
125
+ // result.orderは完全に廃止したので検索条件としても廃止(2026-06-26~)
126
+ // const resultOrderNumberIn = params.result?.order?.orderNumbers;
127
+ // if (Array.isArray(resultOrderNumberIn)) {
128
+ // andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
129
+ // }
130
+ // result.orderは完全に廃止したので検索条件としても廃止(2026-06-26~)
131
+ // const resultOrderConfirmationNumberEq = params.result?.order?.confirmationNumber?.$eq;
132
+ // if (typeof resultOrderConfirmationNumberEq === 'string') {
133
+ // andConditions.push({
134
+ // 'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
135
+ // });
136
+ // }
135
137
  const objectOrderNumberEq = params.object?.orderNumber?.$eq;
136
138
  if (typeof objectOrderNumberEq === 'string') {
137
139
  andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
@@ -28,7 +28,7 @@ function authorize(params, options) {
28
28
  const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
29
29
  identifier: transaction.id,
30
30
  project: { id: params.project.id },
31
- });
31
+ }, { onlyPlaceOrder: true });
32
32
  // まず取引番号発行
33
33
  const { transactionNumber } = await repos.transactionNumber.publishByTimestamp({ startDate: now });
34
34
  const actionAttributes = (0, factory_2.createAuthorizeSeatReservationActionAttributes)({
@@ -79,7 +79,7 @@ function createPlacingOrder(params) {
79
79
  throw new factory_1.factory.errors.Internal('object.orderNumber undefined');
80
80
  }
81
81
  if (orderDate === undefined) {
82
- orderDateByTransaction = transaction.result?.order?.orderDate;
82
+ // orderDateByTransaction = transaction.result?.order?.orderDate
83
83
  }
84
84
  else {
85
85
  orderDateByTransaction = orderDate;
@@ -20,7 +20,7 @@ function fixOrderAsNeeded(params) {
20
20
  const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
21
21
  identifier: params.purpose.id,
22
22
  project: { id: params.project.id },
23
- });
23
+ }, { onlyPlaceOrder: true });
24
24
  return { confirmationNumber, orderNumber };
25
25
  };
26
26
  }
@@ -1,4 +1,9 @@
1
1
  import { factory } from '../../../../../factory';
2
+ type IOrderAsResult = Pick<factory.order.IOrder, 'confirmationNumber' | 'orderDate' | 'orderNumber' | 'price' | 'priceCurrency' | 'typeOf'> & {
3
+ orderStatus: factory.orderStatus.OrderPaymentDue;
4
+ identifier?: never;
5
+ url?: never;
6
+ };
2
7
  /**
3
8
  * 注文取引結果としての注文を生成する
4
9
  */
@@ -6,5 +11,5 @@ declare function createOrderAsResult(params: {
6
11
  orderNumber: string;
7
12
  orderDate: Date;
8
13
  price: number;
9
- }): factory.transaction.placeOrder.IOrderAsResult;
10
- export { createOrderAsResult };
14
+ }): IOrderAsResult;
15
+ export { createOrderAsResult, IOrderAsResult };
@@ -1,7 +1,8 @@
1
1
  import { factory } from '../../../../../factory';
2
2
  import type { ISetting } from '../../../../../repo/setting';
3
+ import type { IOrderAsResult } from '../factory/result';
3
4
  export declare function createSendEmailMessageActions(params: {
4
- order: factory.transaction.placeOrder.IOrderAsResult & {
5
+ order: IOrderAsResult & {
5
6
  confirmationNumber: string;
6
7
  orderStatus: factory.orderStatus;
7
8
  price: number;
@@ -1,10 +1,11 @@
1
1
  import { factory } from '../../../../factory';
2
2
  import type { ISetting } from '../../../../repo/setting';
3
+ import { IOrderAsResult } from './factory/result';
3
4
  /**
4
5
  * 取引のポストアクションを作成する
5
6
  */
6
7
  export declare function createPotentialActions(params: {
7
- order: factory.transaction.placeOrder.IOrderAsResult & {
8
+ order: IOrderAsResult & {
8
9
  confirmationNumber: string;
9
10
  orderStatus: factory.orderStatus.OrderPaymentDue;
10
11
  price: number;
@@ -11,6 +11,7 @@ import type { SettingRepo } from '../../../repo/setting';
11
11
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
12
12
  import { factory } from '../../../factory';
13
13
  import { PlaceOrderFactory } from '../../../factory/transaction';
14
+ import { IOrderAsResult } from './confirm/factory/result';
14
15
  interface IConfirmOperationRepos {
15
16
  acceptPayAction: AcceptPayActionRepo;
16
17
  authorizePaymentMethodAction: AuthorizePaymentMethodActionRepo;
@@ -45,7 +46,7 @@ interface IConfirmOptions {
45
46
  }
46
47
  type IConfirmParams = PlaceOrderFactory.IConfirmParams;
47
48
  interface IConfirmResult {
48
- order: Pick<factory.transaction.placeOrder.IOrderAsResult, 'confirmationNumber' | 'orderNumber'>;
49
+ order: Pick<IOrderAsResult, 'confirmationNumber' | 'orderNumber'>;
49
50
  customer: factory.order.ICustomer;
50
51
  code?: string;
51
52
  /**
@@ -19,16 +19,17 @@ const debug = (0, debug_1.default)('chevre-domain:service:transaction');
19
19
  /**
20
20
  * 進行中でない取引を処理する
21
21
  */
22
- function processTransactionNotInProgress(transaction) {
22
+ function processTransactionNotInProgress(params) {
23
23
  return async (repos) => {
24
+ const { transaction, orderNumber } = params;
24
25
  if (transaction.status === factory_1.factory.transactionStatusType.Confirmed) {
25
26
  const resultCustomer = await repos.orderInTransaction.findCustomerByOrderNumber({
26
- orderNumber: { $eq: String(transaction.object.orderNumber) }
27
+ orderNumber: { $eq: orderNumber }
27
28
  });
28
29
  // if (resultCustomer === undefined) {
29
30
  // throw new factory.errors.Internal('resultCustomer undefined'); // impossible process
30
31
  // }
31
- const { confirmationNumber, orderNumber } = transaction.object;
32
+ const { confirmationNumber } = transaction.object;
32
33
  // Confirmedの取引であればobjectには必ず存在するはず
33
34
  if (typeof confirmationNumber !== 'string' || typeof orderNumber !== 'string'
34
35
  || confirmationNumber === '' || orderNumber === '') {
@@ -62,18 +63,24 @@ function confirm(params, options) {
62
63
  object: { orderDate: params.result.order.orderDate }
63
64
  })(repos);
64
65
  const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
65
- const confirmResult = await processTransactionNotInProgress(transaction)(repos);
66
+ // 注文ドキュメントから注文番号を参照(取引開始時に発行済の前提)(2026-06-26~)
67
+ const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
68
+ identifier: params.id,
69
+ project: { id: transaction.project.id }
70
+ }, { onlyPlaceOrder: false } // すでに取引確定済かもしれないのでfalse
71
+ );
72
+ const confirmResult = await processTransactionNotInProgress({ transaction, orderNumber })(repos);
66
73
  if (confirmResult !== undefined) {
67
74
  return confirmResult;
68
75
  }
69
76
  if (typeof params.agent?.id === 'string' && transaction.agent.id !== params.agent.id) {
70
77
  throw new factory_1.factory.errors.Forbidden('Transaction not yours');
71
78
  }
72
- // 注文番号は興行オファー承認時に発行済のはず(2026-06-16~)
73
- const orderNumber = transaction.object.orderNumber;
74
- if (typeof orderNumber !== 'string' || orderNumber === '') {
75
- throw new factory_1.factory.errors.Argument('transactionId', 'orderNumber not issued');
76
- }
79
+ // // 注文番号は興行オファー承認時に発行済のはず(2026-06-16~)
80
+ // const orderNumber = transaction.object.orderNumber;
81
+ // if (typeof orderNumber !== 'string' || orderNumber === '') {
82
+ // throw new factory.errors.Argument('transactionId', 'orderNumber not issued');
83
+ // }
77
84
  // 取引に対する全ての承認アクションをマージ
78
85
  const completedAuthorizeActions = await searchAuthorizeActions(params)(repos);
79
86
  let acceptPayActions = [];
@@ -368,10 +375,10 @@ function createResult(params, options) {
368
375
  result: {
369
376
  authorizeActions, // 追加(2024-01-17~)
370
377
  ...(typeof params.code === 'string') ? { code: params.code } : undefined,
371
- ...((!options.disableResultOrder) && { order: orderAsResult }), // support disableResultOrder(2026-06-15~)
372
- ...((!options.disableResultOrder) && {
373
- numAcceptedOffers: params.acceptedOffers.length, // 追加(2024-01-17~)
374
- }) // support disableResultOrder(2026-06-17~)
378
+ // ...((!options.disableResultOrder) && { order: orderAsResult }), // 完全廃止(2026-06-26~)
379
+ // ...((!options.disableResultOrder) && {
380
+ // numAcceptedOffers: params.acceptedOffers.length,
381
+ // }) // 完全廃止(2026-06-26~)
375
382
  },
376
383
  ...(typeof eventId === 'string') ? { eventId } : undefined,
377
384
  ...(Array.isArray(reservationIds)) ? { reservationIds } : undefined
@@ -6,19 +6,29 @@ type IVerifiedPassport = factory.waiter.passport.IPassport & {
6
6
  */
7
7
  identifier: string;
8
8
  };
9
- type IStartPlaceOrderParams = factory.transaction.placeOrder.IStartParamsWithoutDetail & {
10
- object: factory.transaction.placeOrder.IStartParamsWithoutDetail['object'] & {
9
+ type ICustomerInObject = Pick<factory.order.ICustomer, 'id' | 'identifier' | 'typeOf'>;
10
+ interface IStartPlaceOrderParams {
11
+ project: Pick<factory.project.IProject, 'id' | 'typeOf'>;
12
+ agent: factory.transaction.placeOrder.IAgent;
13
+ seller: {
14
+ id: string;
15
+ };
16
+ object: {
11
17
  /**
12
18
  * api経由で取引が開始されれば必ず存在するはず
13
19
  */
14
20
  clientUser: factory.transaction.placeOrder.IClientUserBeforeStart;
21
+ /**
22
+ * 注文ドキュメントに保管するcustomer
23
+ */
24
+ customer?: ICustomerInObject;
25
+ passport?: factory.transaction.IPassportBeforeStart;
26
+ name?: never;
15
27
  };
16
28
  /**
17
29
  * 注文ドキュメントに保管する代理人
18
30
  */
19
31
  broker?: factory.order.IBroker;
20
- };
21
- declare function createStartParams(params: IStartPlaceOrderParams, expiresInSeconds: number, passport: IVerifiedPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project' | 'additionalProperty'>, options: {
22
- minimizeStartPlaceOrderParams: boolean;
23
- }, customerType?: string): factory.transaction.placeOrder.IStartParams;
32
+ }
33
+ declare function createStartParams(params: IStartPlaceOrderParams, expiresInSeconds: number, passport: IVerifiedPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, customerType?: string): factory.transaction.placeOrder.IStartParams;
24
34
  export { AGENT_IDENTIFIER_NAME_PASSPORT, createStartParams, IStartPlaceOrderParams };
@@ -5,8 +5,8 @@ exports.createStartParams = createStartParams;
5
5
  const factory_1 = require("../../../../factory");
6
6
  const AGENT_IDENTIFIER_NAME_PASSPORT = 'passport';
7
7
  exports.AGENT_IDENTIFIER_NAME_PASSPORT = AGENT_IDENTIFIER_NAME_PASSPORT;
8
- function createStartParams(params, expiresInSeconds, passport, seller, options, customerType) {
9
- const { minimizeStartPlaceOrderParams } = options;
8
+ ;
9
+ function createStartParams(params, expiresInSeconds, passport, seller, customerType) {
10
10
  // const { broker } = params;
11
11
  // let clientUser: Omit<factory.clientUser.IClientUser, 'scope' | 'scopes'> | undefined;
12
12
  let instrument;
@@ -21,7 +21,7 @@ function createStartParams(params, expiresInSeconds, passport, seller, options,
21
21
  // ...(typeof clientUser?.client_id === 'string') ? { clientUser } : undefined, // discontinue(2026-06-10~)
22
22
  // ...(typeof params.object?.name === 'string') ? { name: params.object?.name } : undefined, // discontinue(2026-06-11~)
23
23
  // ...(typeof broker?.typeOf === 'string') ? { broker: broker } : undefined, // discontinue(2026-06-22~)
24
- ...(!minimizeStartPlaceOrderParams && typeof params.object.customer?.typeOf === 'string') ? { customer: params.object.customer } : undefined,
24
+ // ...(!minimizeStartPlaceOrderParams && typeof params.object.customer?.typeOf === 'string') ? { customer: params.object.customer } : undefined, // discontinue(2026-06-26~)
25
25
  ...(typeof customerType === 'string') ? { customerType } : undefined
26
26
  };
27
27
  if (typeof seller.id !== 'string') {
@@ -40,22 +40,28 @@ function createStartParams(params, expiresInSeconds, passport, seller, options,
40
40
  // ...(memeberOfPayload !== undefined) ? { memeberOfPayload } : undefined, // discontinue(2026-06-10~)
41
41
  identifier: agentIdentifier
42
42
  };
43
+ const sellerOfPlaceOrder = {
44
+ id: seller.id,
45
+ name: { ja: String(seller.name.ja) },
46
+ typeOf: seller.typeOf
47
+ };
43
48
  return {
44
49
  project: { typeOf: seller.project.typeOf, id: seller.project.id },
45
50
  typeOf: factory_1.factory.transactionType.PlaceOrder,
46
51
  agent,
47
- seller: (minimizeStartPlaceOrderParams)
48
- ? {
49
- id: seller.id,
50
- name: { ja: String(seller.name.ja) },
51
- typeOf: seller.typeOf
52
- }
53
- : {
54
- id: seller.id,
55
- name: seller.name,
56
- typeOf: seller.typeOf,
57
- additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
58
- },
52
+ seller: sellerOfPlaceOrder, // sellerを最小化(2026-06-26~)
53
+ // seller: (minimizeStartPlaceOrderParams)
54
+ // ? {
55
+ // id: seller.id,
56
+ // name: { ja: String(seller.name.ja) },
57
+ // typeOf: seller.typeOf
58
+ // }
59
+ // : {
60
+ // id: seller.id,
61
+ // name: seller.name,
62
+ // typeOf: seller.typeOf,
63
+ // additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
64
+ // },
59
65
  object: transactionObject,
60
66
  expiresInSeconds,
61
67
  ...(typeof instrument?.id === 'string') ? { instrument } : undefined
@@ -22,11 +22,8 @@ interface IStartOperationRepos {
22
22
  orderNumber: OrderNumberRepo;
23
23
  }
24
24
  type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
25
- interface IStartOptions {
26
- minimizeStartPlaceOrderParams: boolean;
27
- }
28
25
  /**
29
26
  * 取引開始
30
27
  */
31
- declare function start(params: IStartPlaceOrderParams, options: IStartOptions): IStartOperation<IStartedPlaceOrder>;
28
+ declare function start(params: IStartPlaceOrderParams): IStartOperation<IStartedPlaceOrder>;
32
29
  export { start, IStartPlaceOrderParams };
@@ -8,7 +8,7 @@ const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
8
8
  /**
9
9
  * 取引開始
10
10
  */
11
- function start(params, options) {
11
+ function start(params) {
12
12
  return async (repos) => {
13
13
  const { passport, customerType } = await repos.passport.validatePassportTokenIfExist(params);
14
14
  const { sellerMakesOffer, seller } = await (0, validateStartRequest_1.validateStartRequest)({
@@ -23,8 +23,7 @@ function start(params, options) {
23
23
  throw new factory_1.factory.errors.NotFound('eligibleTransactionDuration.maxValue');
24
24
  }
25
25
  // 取引ファクトリーで新しい進行中取引オブジェクトを作成
26
- const { minimizeStartPlaceOrderParams } = options;
27
- const startParams = (0, factory_2.createStartParams)(params, expiresInSeconds, passport, seller, { minimizeStartPlaceOrderParams }, customerType);
26
+ const startParams = (0, factory_2.createStartParams)(params, expiresInSeconds, passport, seller, customerType);
28
27
  let transaction;
29
28
  // lock passport(2024-07-05~)
30
29
  if (passport !== undefined) {
@@ -77,7 +77,7 @@ function updateAgent(params) {
77
77
  const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
78
78
  identifier: params.id,
79
79
  project: { id: transaction.project.id },
80
- });
80
+ }, { onlyPlaceOrder: true });
81
81
  const customerName = (typeof customer.name === 'string' && customer.name !== '')
82
82
  ? customer.name
83
83
  : (typeof customer.givenName === 'string' && typeof customer.familyName === 'string'
package/package.json CHANGED
@@ -11,7 +11,7 @@
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": "9.0.0-alpha.3",
14
+ "@chevre/factory": "9.0.0",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -91,5 +91,5 @@
91
91
  "postversion": "git push origin --tags",
92
92
  "prepublishOnly": "npm run clean && npm run build"
93
93
  },
94
- "version": "25.0.0-alpha.17"
94
+ "version": "25.0.0-alpha.19"
95
95
  }