@chevre/domain 25.2.0-alpha.13 → 25.2.0-alpha.15

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.
@@ -10,6 +10,7 @@ export { ICancelActionAction };
10
10
  type StartableActionType = Exclude<factory.actionType, factory.actionType.AcceptAction | factory.actionType.CheckAction | factory.actionType.AuthorizeAction | factory.actionType.PayAction | factory.actionType.RefundAction>;
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 | factory.recipe.RecipeCategory.payCreditCard | factory.recipe.RecipeCategory.payMovieTicket | factory.recipe.RecipeCategory.refundCreditCard | factory.recipe.RecipeCategory.refundMovieTicket>>;
12
12
  export interface IDeleteActionResult {
13
+ identifier: string;
13
14
  deletedCount?: number;
14
15
  }
15
16
  /**
@@ -325,35 +325,48 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
325
325
  }
326
326
  const filters = [
327
327
  {
328
- 'project.id': { $eq: project.id },
329
- 'object.orderNumber': { $exists: true, $eq: orderNumber }
328
+ identifier: 'byObject',
329
+ filter: {
330
+ 'project.id': { $eq: project.id },
331
+ 'object.orderNumber': { $exists: true, $eq: orderNumber }
332
+ }
330
333
  },
331
334
  {
332
- 'project.id': { $eq: project.id },
333
- 'purpose.orderNumber': { $exists: true, $eq: orderNumber }
335
+ identifier: 'byPurpose',
336
+ filter: {
337
+ 'project.id': { $eq: project.id },
338
+ 'purpose.orderNumber': { $exists: true, $eq: orderNumber }
339
+ }
334
340
  },
335
341
  {
336
- 'project.id': { $eq: project.id },
337
- 'about.orderNumber': { $exists: true, $eq: orderNumber }
342
+ identifier: 'byAbout',
343
+ filter: {
344
+ 'project.id': { $eq: project.id },
345
+ 'about.orderNumber': { $exists: true, $eq: orderNumber }
346
+ }
338
347
  },
339
348
  {
340
- 'project.id': { $eq: project.id },
341
- 'instrument.orderNumber': { $exists: true, $eq: orderNumber }
349
+ identifier: 'byInstrument',
350
+ filter: {
351
+ 'project.id': { $eq: project.id },
352
+ 'instrument.orderNumber': { $exists: true, $eq: orderNumber }
353
+ }
342
354
  },
343
355
  ];
344
- const results = await Promise.all(filters.map(async (filter) => {
356
+ return Promise.all(filters.map(async ({ identifier, filter }) => {
345
357
  return this.actionModel.deleteMany(filter)
346
- .exec();
358
+ .exec()
359
+ .then((result) => {
360
+ return {
361
+ identifier,
362
+ // n: result?.n,
363
+ // opTime: result.opTime,
364
+ // ok: result?.ok,
365
+ // operationTime,
366
+ deletedCount: result?.deletedCount
367
+ };
368
+ });
347
369
  }));
348
- return results.map((result) => {
349
- return {
350
- // n: result?.n,
351
- // opTime: result.opTime,
352
- // ok: result?.ok,
353
- // operationTime,
354
- deletedCount: result?.deletedCount
355
- };
356
- });
357
370
  }
358
371
  async deleteByProject(params) {
359
372
  await this.actionModel.deleteMany({
@@ -408,32 +421,39 @@ class ActionRepo extends actionProcess_1.ActionProcessRepo {
408
421
  }
409
422
  const filters = [
410
423
  {
411
- 'project.id': { $eq: project.id },
412
- typeOf: { $in: params.typeOf.$in },
413
- 'purpose.id': { $exists: true, $eq: transaction.id },
414
- 'purpose.typeOf': { $exists: true, $eq: transaction.typeOf }
424
+ identifier: 'byPurpose',
425
+ filter: {
426
+ 'project.id': { $eq: project.id },
427
+ typeOf: { $in: params.typeOf.$in },
428
+ 'purpose.id': { $exists: true, $eq: transaction.id },
429
+ 'purpose.typeOf': { $exists: true, $eq: transaction.typeOf }
430
+ }
415
431
  },
416
432
  // instrumentによるアクション削除にも対応(2026-07-10~)
417
433
  {
418
- 'project.id': { $eq: project.id },
419
- // typeOf: { $in: params.typeOf.$in }, // typOfでフィルターしない
420
- 'instrument.id': { $exists: true, $eq: transaction.id },
421
- 'instrument.typeOf': { $exists: true, $eq: transaction.typeOf }
434
+ identifier: 'byInstrument',
435
+ filter: {
436
+ 'project.id': { $eq: project.id },
437
+ // typeOf: { $in: params.typeOf.$in }, // typOfでフィルターしない
438
+ 'instrument.id': { $exists: true, $eq: transaction.id },
439
+ 'instrument.typeOf': { $exists: true, $eq: transaction.typeOf }
440
+ }
422
441
  }
423
442
  ];
424
- const results = await Promise.all(filters.map(async (filter) => {
443
+ return Promise.all(filters.map(async ({ identifier, filter }) => {
425
444
  return this.actionModel.deleteMany(filter)
426
- .exec();
445
+ .exec()
446
+ .then((result) => {
447
+ return {
448
+ identifier,
449
+ // n: result?.n,
450
+ // opTime: result.opTime,
451
+ // ok: result?.ok,
452
+ // operationTime,
453
+ deletedCount: result?.deletedCount
454
+ };
455
+ });
427
456
  }));
428
- return results.map((result) => {
429
- return {
430
- // n: result?.n,
431
- // opTime: result.opTime,
432
- // ok: result?.ok,
433
- // operationTime,
434
- deletedCount: result?.deletedCount
435
- };
436
- });
437
457
  }
438
458
  getCursor(conditions, projection) {
439
459
  return this.actionModel.find(conditions, projection)
@@ -31,7 +31,11 @@ declare function acceptedOffers2authorizeResult(params: {
31
31
  acceptedOffers4result: IResultAcceptedOffer[];
32
32
  noOfferSpecified: boolean;
33
33
  ticketOffers: factory.product.ITicketOffer[];
34
- }): factory.action.authorize.offer.eventService.IResult;
34
+ }, options: {
35
+ useLegacyAuthorizeOfferResult: boolean;
36
+ }): factory.action.authorize.offer.eventService.IResult & {
37
+ onlyPrice?: boolean;
38
+ };
35
39
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
36
40
  export type IResultAcceptedOffer = Omit<factory.order.IOptimizedAcceptedOffer, 'priceSpecification'> & {
37
41
  itemOffered: factory.order.IEventReservation;
@@ -172,7 +172,8 @@ function acceptedOffers2programMembershipUsed(params) {
172
172
  });
173
173
  return programMembershipUsed;
174
174
  }
175
- function acceptedOffers2authorizeResult(params) {
175
+ function acceptedOffers2authorizeResult(params, options) {
176
+ const { useLegacyAuthorizeOfferResult } = options;
176
177
  const { acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
177
178
  // const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
178
179
  let offers;
@@ -211,16 +212,25 @@ function acceptedOffers2authorizeResult(params) {
211
212
  };
212
213
  });
213
214
  }
214
- return {
215
- typeOf: factory_1.factory.offerType.AggregateOffer,
216
- // priceCurrency, // discontinue(2026-07-06~)
217
- // amount: [], // discontinue(2026-07-06~)
218
- itemOffered: {
219
- serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
220
- },
221
- ...(typeof price === 'number') ? { price } : undefined,
222
- ...(Array.isArray(offers)) ? { offers } : undefined
223
- };
215
+ if (useLegacyAuthorizeOfferResult) {
216
+ return {
217
+ typeOf: factory_1.factory.offerType.AggregateOffer,
218
+ // priceCurrency, // discontinue(2026-07-06~)
219
+ // amount: [], // discontinue(2026-07-06~)
220
+ itemOffered: {
221
+ serviceOutput: { programMembershipUsed } // add programMembershipUsed required(2024-08-15~)
222
+ },
223
+ ...(typeof price === 'number') ? { price } : undefined,
224
+ ...(Array.isArray(offers)) ? { offers } : undefined
225
+ };
226
+ }
227
+ else {
228
+ return {
229
+ typeOf: factory_1.factory.offerType.AggregateOffer,
230
+ onlyPrice: true,
231
+ ...(typeof price === 'number') ? { price } : undefined,
232
+ };
233
+ }
224
234
  }
225
235
  function responseBody2acceptedOffers4result(params) {
226
236
  let acceptedOffers4result = [];
@@ -67,6 +67,10 @@ interface IAuthorizeOptions {
67
67
  * 2026-07-04~
68
68
  */
69
69
  useLegacyAuthorizeOfferObject: boolean;
70
+ /**
71
+ * 2026-07-10~
72
+ */
73
+ useLegacyAuthorizeOfferResult: boolean;
70
74
  }
71
75
  /**
72
76
  * 興行オファー承認
@@ -78,7 +78,7 @@ function authorize(params, options) {
78
78
  }
79
79
  throw error;
80
80
  }
81
- const result = (0, factory_2.acceptedOffers2authorizeResult)({ acceptedOffers4result, noOfferSpecified, ticketOffers });
81
+ const result = (0, factory_2.acceptedOffers2authorizeResult)({ acceptedOffers4result, noOfferSpecified, ticketOffers }, options);
82
82
  await repos.authorizeOfferAction.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
83
83
  return { id: action.id, result };
84
84
  };
@@ -1,6 +1,10 @@
1
1
  import { factory } from '../../../../../factory';
2
2
  export type IAcceptPayAction = Pick<factory.action.accept.pay.IAction, 'object' | 'result' | 'endDate'>;
3
- export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction;
3
+ export type IAuthorizeEventServiceOffer = factory.action.authorize.offer.eventService.IAction & {
4
+ result?: factory.action.authorize.offer.eventService.IResult & {
5
+ onlyPrice?: boolean;
6
+ };
7
+ };
4
8
  export type IAuthorizePaymentAction = Pick<factory.action.authorize.paymentMethod.any.IAction, 'id' | 'result' | 'endDate'> & {
5
9
  object: Pick<factory.action.authorize.paymentMethod.any.IObject, 'typeOf' | 'paymentMethodId'>;
6
10
  instrument?: never;
@@ -305,7 +305,15 @@ function validateEventOffers(params) {
305
305
  const everyActionsMatched = unitPriceOfferConditions.length === params.authorizeOfferActions.length
306
306
  && params.authorizeOfferActions.every((authorizeEventServiceOfferAction) => {
307
307
  const conditionExpected = unitPriceOfferConditions.find(({ id }) => id === authorizeEventServiceOfferAction.id);
308
- const resultMatched = (0, util_1.isDeepStrictEqual)(conditionExpected?.result, authorizeEventServiceOfferAction.result);
308
+ let resultMatched;
309
+ // 承認アクションのresultが最適化済の場合,price以外を比較しても意味がないので比較しない(2026-07-10~)
310
+ if (authorizeEventServiceOfferAction.result?.onlyPrice === true) {
311
+ resultMatched = typeof conditionExpected?.result?.price === 'number'
312
+ && conditionExpected?.result.price === authorizeEventServiceOfferAction.result.price;
313
+ }
314
+ else {
315
+ resultMatched = (0, util_1.isDeepStrictEqual)(conditionExpected?.result, authorizeEventServiceOfferAction.result);
316
+ }
309
317
  debug('validateEventOffers: unitPriceOfferConditions: resultMatched?', resultMatched, params.project.id, authorizeEventServiceOfferAction.id);
310
318
  if (!resultMatched) {
311
319
  console.error('validateEventOffers: unitPriceOfferConditions not matched!', params.project.id, authorizeEventServiceOfferAction.id, conditionExpected?.result, authorizeEventServiceOfferAction.result);
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.13"
94
+ "version": "25.2.0-alpha.15"
95
95
  }