@chevre/domain 25.2.0-alpha.10 → 25.2.0-alpha.11

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.
@@ -214,19 +214,19 @@ const indexes = [
214
214
  alternateName: { $exists: true }
215
215
  }
216
216
  }
217
+ ],
218
+ // add unique index(dev)(2025-03-28~)
219
+ // add unique index(test,prod)(2026-07-08~)
220
+ [
221
+ { identifier: 1 },
222
+ {
223
+ unique: true,
224
+ name: 'uniqueIdentifier',
225
+ partialFilterExpression: {
226
+ identifier: { $exists: true }
227
+ }
228
+ }
217
229
  ]
218
- // eslint-disable-next-line no-warning-comments
219
- // TODO add unique index(2025-03-28~)
220
- // [
221
- // { identifier: 1 },
222
- // {
223
- // unique: true,
224
- // name: 'uniqueIdentifier',
225
- // partialFilterExpression: {
226
- // identifier: { $exists: true }
227
- // }
228
- // }
229
- // ]
230
230
  ];
231
231
  exports.indexes = indexes;
232
232
  /**
@@ -127,6 +127,19 @@ export declare class OrderInTransactionRepo extends AcceptedOfferInReserveRepo {
127
127
  setCustomerByIdentifier(params: Pick<IOrderInTransaction, 'project' | 'identifier'> & {
128
128
  customer: factory.order.ICustomer;
129
129
  }): Promise<import("mongoose").UpdateWriteOpResult>;
130
+ /**
131
+ * 注文ドキュメントに確認番号を保管する
132
+ * 確認番号未発行の場合のみ保管される
133
+ */
134
+ saveConfirmationNumberIfNotExist(params: {
135
+ identifier: string;
136
+ confirmationNumber: string;
137
+ }, options: {
138
+ /**
139
+ * 注文取引タイプのドキュメントのみを参照対象にするかどうか
140
+ */
141
+ onlyPlaceOrder: boolean;
142
+ }): Promise<void>;
130
143
  deleteByIdentifier(params: {
131
144
  identifier: string;
132
145
  }): Promise<import("mongodb").DeleteResult>;
@@ -241,6 +241,23 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
241
241
  }
242
242
  return result;
243
243
  }
244
+ /**
245
+ * 注文ドキュメントに確認番号を保管する
246
+ * 確認番号未発行の場合のみ保管される
247
+ */
248
+ async saveConfirmationNumberIfNotExist(params, options) {
249
+ const { identifier, confirmationNumber } = params;
250
+ const onlyPlaceOrder = options.onlyPlaceOrder === true;
251
+ if (typeof confirmationNumber !== 'string' || confirmationNumber === '') {
252
+ throw new factory_1.factory.errors.ArgumentNull('confirmationNumber');
253
+ }
254
+ await this.orderModel.updateOne({
255
+ identifier: { $eq: identifier },
256
+ confirmationNumber: { $exists: false },
257
+ ...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
258
+ }, { $set: { confirmationNumber } })
259
+ .exec();
260
+ }
244
261
  async deleteByIdentifier(params) {
245
262
  return this.orderModel.deleteOne({
246
263
  typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
@@ -125,6 +125,7 @@ export declare class PlaceOrderRepo {
125
125
  object: {
126
126
  orderDate: Date;
127
127
  orderNumber: string;
128
+ confirmationNumber: string;
128
129
  };
129
130
  result: factory.transaction.IResult<factory.transactionType.PlaceOrder>;
130
131
  potentialActions: factory.transaction.IPotentialActions<factory.transactionType.PlaceOrder>;
@@ -441,6 +441,7 @@ class PlaceOrderRepo {
441
441
  endDate,
442
442
  'object.orderDate': params.object.orderDate, // add(2026-06-15~)
443
443
  'object.orderNumber': params.object.orderNumber, // add(2026-06-27~)
444
+ 'object.confirmationNumber': params.object.confirmationNumber, // add(2026-07-08~)
444
445
  result: params.result, // resultを更新
445
446
  potentialActions: params.potentialActions // resultを更新
446
447
  }, {
@@ -58,7 +58,7 @@ function processTransactionNotInProgress(params) {
58
58
  function confirm(params, options) {
59
59
  return async (repos) => {
60
60
  // 確認番号を事前発行
61
- await (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
61
+ const confirmationNumber = await (0, publishConfirmationNumberIfNotExist_1.publishConfirmationNumberIfNotExist)({
62
62
  id: params.id,
63
63
  status: { $in: [factory_1.factory.transactionStatusType.Confirmed, factory_1.factory.transactionStatusType.InProgress] },
64
64
  object: { orderDate: params.result.order.orderDate }
@@ -142,7 +142,9 @@ function confirm(params, options) {
142
142
  const seller = (0, factory_2.createSeller)({ transaction });
143
143
  const { paymentMethods, placingOrder, result, eventId, reservationIds } = createResult({
144
144
  ...params,
145
- orderNumber, transaction,
145
+ orderNumber,
146
+ confirmationNumber,
147
+ transaction,
146
148
  acceptPayActions,
147
149
  authorizePaymentActions, authorizeEventServiceOfferActions,
148
150
  acceptedOffers, payTransactions, customer,
@@ -178,7 +180,8 @@ function confirm(params, options) {
178
180
  id: transaction.id,
179
181
  object: {
180
182
  orderDate: params.result.order.orderDate,
181
- orderNumber
183
+ orderNumber,
184
+ confirmationNumber: placingOrder.confirmationNumber
182
185
  },
183
186
  result: result,
184
187
  potentialActions: potentialActions
@@ -341,8 +344,10 @@ function createResult(params, options) {
341
344
  result: params.result
342
345
  });
343
346
  (0, validation_1.validatePaymentMethods)({ order: { paymentMethods } }, options);
344
- // 確認番号を発行
345
- const { confirmationNumber } = createConfirmationNumber({ transaction });
347
+ // 取引のobjectへの依存を排除する(2026-07-08~)
348
+ const { confirmationNumber } = params;
349
+ // // 確認番号を発行
350
+ // const { confirmationNumber } = createConfirmationNumber({ transaction });
346
351
  // 注文作成
347
352
  const orderAsResult = (0, result_1.createOrderAsResult)({
348
353
  orderNumber: params.orderNumber,
@@ -433,14 +438,3 @@ function searchAuthorizeActions(params) {
433
438
  return authorizeActions;
434
439
  };
435
440
  }
436
- function createConfirmationNumber(params) {
437
- const confirmationNumber = params.transaction.object.confirmationNumber;
438
- // 取引に確認番号が保管されていなければ、確認番号を発行
439
- if (typeof confirmationNumber !== 'string') {
440
- // 事前に発行済なはずなので、ありえないフロー
441
- throw new factory_1.factory.errors.Internal('object.confirmationNumber undefined');
442
- }
443
- return {
444
- confirmationNumber,
445
- };
446
- }
@@ -1,4 +1,5 @@
1
1
  import type { ConfirmationNumberRepo } from '../../../repo/confirmationNumber';
2
+ import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
2
3
  import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
3
4
  import { factory } from '../../../factory';
4
5
  /**
@@ -18,5 +19,6 @@ declare function publishConfirmationNumberIfNotExist(params: {
18
19
  }): (repos: {
19
20
  placeOrder: PlaceOrderRepo;
20
21
  confirmationNumber: ConfirmationNumberRepo;
22
+ orderInTransaction: OrderInTransactionRepo;
21
23
  }) => Promise<string>;
22
24
  export { publishConfirmationNumberIfNotExist };
@@ -23,6 +23,11 @@ function publishConfirmationNumberIfNotExist(params) {
23
23
  status: { $in: params.status.$in },
24
24
  confirmationNumber
25
25
  });
26
+ // 注文ドキュメントにも保管(2026-07-08~)
27
+ await repos.orderInTransaction.saveConfirmationNumberIfNotExist({
28
+ identifier: params.id,
29
+ confirmationNumber
30
+ }, { onlyPlaceOrder: true });
26
31
  // 確認番号を取引から再取得
27
32
  confirmationNumber = await repos.placeOrder.findInProgressConfirmationNumberById({
28
33
  id: params.id,
package/package.json CHANGED
@@ -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.2.0-alpha.10"
94
+ "version": "25.2.0-alpha.11"
95
95
  }