@chevre/domain 21.18.0-alpha.4 → 21.18.0-alpha.41

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.
Files changed (142) hide show
  1. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
  2. package/example/src/chevre/offerCatalog2offerCatalogItem.ts +4 -0
  3. package/example/src/chevre/searchAcceptedOfferIds.ts +57 -0
  4. package/example/src/chevre/searchOffers.ts +41 -37
  5. package/example/src/chevre/searchOrderAcceptedOffers.ts +12 -12
  6. package/example/src/chevre/searchOrders.ts +36 -19
  7. package/example/src/chevre/searchReservationsByOrder.ts +30 -0
  8. package/example/src/chevre/searchTransactions.ts +41 -0
  9. package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
  10. package/example/src/chevre/upsertMoviesByIdentifier.ts +5 -4
  11. package/example/src/chevre/upsertOfferCatalogsByIdentifier.ts +46 -0
  12. package/example/src/chevre/upsertOffersByIdentifier.ts +94 -0
  13. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +104 -0
  14. package/lib/chevre/credentials.d.ts +0 -3
  15. package/lib/chevre/credentials.js +4 -3
  16. package/lib/chevre/repo/acceptedOffer.d.ts +60 -0
  17. package/lib/chevre/repo/acceptedOffer.js +158 -0
  18. package/lib/chevre/repo/creativeWork.d.ts +12 -2
  19. package/lib/chevre/repo/creativeWork.js +39 -25
  20. package/lib/chevre/repo/event.d.ts +15 -0
  21. package/lib/chevre/repo/event.js +66 -0
  22. package/lib/chevre/repo/offer.d.ts +14 -5
  23. package/lib/chevre/repo/offer.js +94 -19
  24. package/lib/chevre/repo/offerCatalog.d.ts +18 -1
  25. package/lib/chevre/repo/offerCatalog.js +51 -39
  26. package/lib/chevre/repo/order.d.ts +14 -54
  27. package/lib/chevre/repo/order.js +46 -180
  28. package/lib/chevre/repo/paymentService.d.ts +30 -0
  29. package/lib/chevre/repo/paymentService.js +75 -0
  30. package/lib/chevre/repo/place.js +14 -10
  31. package/lib/chevre/repo/product.d.ts +41 -10
  32. package/lib/chevre/repo/product.js +94 -47
  33. package/lib/chevre/repo/transaction.d.ts +5 -4
  34. package/lib/chevre/repository.d.ts +10 -7
  35. package/lib/chevre/repository.js +28 -17
  36. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -1
  37. package/lib/chevre/service/aggregation/event/findEventOffers.js +10 -1
  38. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  39. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +3 -1
  40. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  41. package/lib/chevre/service/assetTransaction/pay.d.ts +2 -0
  42. package/lib/chevre/service/assetTransaction/pay.js +47 -34
  43. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  44. package/lib/chevre/service/assetTransaction/refund/factory.js +0 -5
  45. package/lib/chevre/service/assetTransaction/refund.js +15 -3
  46. package/lib/chevre/service/assetTransaction/registerService.js +18 -2
  47. package/lib/chevre/service/assetTransaction/reserve/factory/price.js +1 -1
  48. package/lib/chevre/service/assetTransaction/reserve.js +32 -2
  49. package/lib/chevre/service/delivery/factory.d.ts +3 -1
  50. package/lib/chevre/service/delivery/factory.js +4 -2
  51. package/lib/chevre/service/delivery.d.ts +1 -2
  52. package/lib/chevre/service/delivery.js +1 -3
  53. package/lib/chevre/service/event.js +1 -1
  54. package/lib/chevre/service/moneyTransfer.js +11 -1
  55. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  56. package/lib/chevre/service/offer/event/factory.js +4 -2
  57. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +40 -5
  58. package/lib/chevre/service/offer/product/factory.js +1 -1
  59. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -1
  60. package/lib/chevre/service/offer/product.d.ts +0 -14
  61. package/lib/chevre/service/offer/product.js +61 -44
  62. package/lib/chevre/service/order/confirmPayTransaction.d.ts +2 -0
  63. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  64. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
  65. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
  66. package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
  67. package/lib/chevre/service/order/deleteOrder.js +15 -4
  68. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
  69. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
  70. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -3
  71. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +15 -9
  72. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +11 -0
  73. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +54 -0
  74. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +10 -0
  75. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +38 -0
  76. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +12 -0
  77. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +111 -0
  78. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +12 -0
  79. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +64 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +10 -0
  81. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +103 -0
  82. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +23 -0
  83. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +180 -0
  84. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +14 -0
  85. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +214 -0
  86. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +10 -0
  87. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +110 -0
  88. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +14 -0
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +164 -0
  90. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +9 -15
  91. package/lib/chevre/service/order/onOrderStatusChanged.js +11 -446
  92. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +6 -0
  93. package/lib/chevre/service/order/onOrderUpdated/factory.js +45 -0
  94. package/lib/chevre/service/order/onOrderUpdated.js +1 -1
  95. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  96. package/lib/chevre/service/order/placeOrder.d.ts +2 -3
  97. package/lib/chevre/service/order/placeOrder.js +65 -22
  98. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  99. package/lib/chevre/service/order/returnOrder.js +34 -13
  100. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  101. package/lib/chevre/service/order/sendOrder.js +19 -6
  102. package/lib/chevre/service/order.d.ts +2 -2
  103. package/lib/chevre/service/order.js +2 -2
  104. package/lib/chevre/service/payment/any.js +1 -1
  105. package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -2
  106. package/lib/chevre/service/payment/paymentCard.js +9 -2
  107. package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
  108. package/lib/chevre/service/reserve/searchByOrder.js +113 -0
  109. package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
  110. package/lib/chevre/service/reserve.d.ts +2 -1
  111. package/lib/chevre/service/reserve.js +3 -1
  112. package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
  113. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  114. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +5 -6
  115. package/lib/chevre/service/task/onAuthorizationCreated.js +9 -18
  116. package/lib/chevre/service/task/onOrderPaymentCompleted.js +5 -6
  117. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +1 -1
  118. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  119. package/lib/chevre/service/task/placeOrder.js +10 -17
  120. package/lib/chevre/service/task/returnOrder.js +10 -17
  121. package/lib/chevre/service/task/sendOrder.js +10 -17
  122. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
  123. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  124. package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
  125. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +0 -4
  126. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -86
  127. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  128. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  129. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
  130. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
  131. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
  132. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
  133. package/lib/chevre/service/transaction/returnOrder.d.ts +3 -0
  134. package/lib/chevre/service/transaction/returnOrder.js +73 -55
  135. package/package.json +3 -3
  136. package/example/src/chevre/transaction/findPaymentCardPermit.ts +0 -29
  137. package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
  138. package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
  139. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -42
  140. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +0 -467
  141. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +0 -26
  142. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +0 -65
@@ -625,7 +625,7 @@ class MongoRepository {
625
625
  }
626
626
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
627
627
  searchScreeningRoomSections(searchConditions) {
628
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
628
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
629
629
  return __awaiter(this, void 0, void 0, function* () {
630
630
  const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
631
631
  const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -722,17 +722,21 @@ class MongoRepository {
722
722
  { $unwind: '$containsPlace' },
723
723
  ...matchStages,
724
724
  {
725
- $project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', containedInPlace: {
726
- typeOf: '$typeOf',
727
- branchCode: '$branchCode',
728
- name: '$name',
725
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
726
+ ? {
729
727
  containedInPlace: {
730
- id: '$containedInPlace.id',
731
- typeOf: '$containedInPlace.typeOf',
732
- branchCode: '$containedInPlace.branchCode',
733
- name: '$containedInPlace.name'
728
+ typeOf: '$typeOf',
729
+ branchCode: '$branchCode',
730
+ name: '$name',
731
+ containedInPlace: {
732
+ id: '$containedInPlace.id',
733
+ typeOf: '$containedInPlace.typeOf',
734
+ branchCode: '$containedInPlace.branchCode',
735
+ name: '$containedInPlace.name'
736
+ }
734
737
  }
735
- }, additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.seatCount) === 1)
738
+ }
739
+ : undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
736
740
  ? {
737
741
  seatCount: {
738
742
  $cond: {
@@ -22,23 +22,49 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import type { Connection } from 'mongoose';
25
+ import type { Connection, FilterQuery } from 'mongoose';
26
26
  import * as factory from '../factory';
27
- export type IProduct = factory.product.IProduct | factory.service.paymentService.IService;
27
+ type IKeyOfProjection4product = keyof factory.product.IProduct | '_id';
28
+ /**
29
+ * プロダクト検索条件
30
+ */
31
+ type ISearchConditions4product = factory.product.ISearchConditions & {
32
+ typeOf?: {
33
+ $eq?: factory.product.ProductType;
34
+ $in?: factory.product.ProductType[];
35
+ };
36
+ };
37
+ /**
38
+ * 決済サービス検索条件
39
+ */
40
+ type ISearchConditions4paymentService = factory.product.ISearchConditions & {
41
+ typeOf?: {
42
+ $eq?: factory.service.paymentService.PaymentServiceType;
43
+ $in?: factory.service.paymentService.PaymentServiceType[];
44
+ };
45
+ };
28
46
  export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'serviceOutput' | 'additionalProperty'> & {
29
47
  provider?: Pick<factory.service.paymentService.IProvider, 'credentials'>;
30
48
  };
49
+ type IUnsetKey = keyof Pick<factory.product.IProduct, 'additionalProperty' | 'availableChannel' | 'hasOfferCatalog' | 'serviceOutput' | 'serviceType'>;
31
50
  /**
32
51
  * プロダクトリポジトリ
33
52
  */
34
53
  export declare class MongoRepository {
35
54
  private readonly productModel;
36
55
  constructor(connection: Connection);
37
- static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): any[];
56
+ static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): FilterQuery<factory.product.IProduct>[];
38
57
  findById(conditions: {
39
58
  id: string;
40
- }, inclusion: string[], exclusion: string[]): Promise<IProduct>;
41
- search(conditions: factory.product.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<IProduct[]>;
59
+ }, inclusion: string[], exclusion: string[]): Promise<factory.product.IProduct | factory.service.paymentService.IService>;
60
+ /**
61
+ * プロダクトを検索する
62
+ */
63
+ searchProducts(conditions: ISearchConditions4product, inclusion: IKeyOfProjection4product[], exclusion: IKeyOfProjection4product[]): Promise<factory.product.IProduct[]>;
64
+ /**
65
+ * 決済サービスを検索する
66
+ */
67
+ searchPaymentServices(conditions: ISearchConditions4paymentService, inclusion: string[], exclusion: string[]): Promise<factory.service.paymentService.IService[]>;
42
68
  deleteById(params: {
43
69
  id: string;
44
70
  }): Promise<void>;
@@ -52,22 +78,26 @@ export declare class MongoRepository {
52
78
  typeOf: factory.service.paymentService.PaymentServiceType;
53
79
  id: string;
54
80
  }): Promise<factory.product.IAvailableChannel>;
55
- searchPaymentServicesByProvider(params: Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
81
+ searchPaymentServicesByProvider(params: Pick<ISearchConditions4paymentService, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
56
82
  /**
57
83
  * プロダクトを保管する
58
- * 作成 or 更新
59
84
  */
60
- save(params: {
85
+ saveProduct(params: {
61
86
  /**
62
87
  * idを指定すれば更新
63
88
  */
64
89
  id?: string;
65
- attributes: factory.product.IProduct | factory.service.paymentService.IService;
90
+ $set: factory.product.IProduct;
91
+ $unset: {
92
+ [key in IUnsetKey]?: 1;
93
+ };
66
94
  /**
67
95
  * 指定プロジェクトの指定プロダクトタイプが存在しなければ作成する
68
96
  */
69
97
  createIfNotExist?: boolean;
70
- }): Promise<factory.product.IProduct>;
98
+ }): Promise<{
99
+ id: string;
100
+ }>;
71
101
  deleteByHasOfferCatalog(params: {
72
102
  project: {
73
103
  id: string;
@@ -86,3 +116,4 @@ export declare class MongoRepository {
86
116
  }): Promise<void>;
87
117
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
88
118
  }
119
+ export {};
@@ -151,10 +151,7 @@ class MongoRepository {
151
151
  }
152
152
  return andConditions;
153
153
  }
154
- findById(conditions,
155
- // inclusion化(2023-07-20~)
156
- // projection?: { [key: string]: number }
157
- inclusion, exclusion) {
154
+ findById(conditions, inclusion, exclusion) {
158
155
  return __awaiter(this, void 0, void 0, function* () {
159
156
  let projection = {};
160
157
  if (Array.isArray(inclusion) && inclusion.length > 0) {
@@ -182,12 +179,63 @@ class MongoRepository {
182
179
  return doc.toObject();
183
180
  });
184
181
  }
185
- search(conditions,
186
- // projection?: { [key: string]: number }
187
- inclusion, exclusion) {
182
+ /**
183
+ * プロダクトを検索する
184
+ */
185
+ searchProducts(conditions, inclusion, exclusion) {
186
+ var _a;
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
189
+ let projection = {};
190
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
191
+ inclusion.forEach((field) => {
192
+ projection[field] = 1;
193
+ });
194
+ }
195
+ else {
196
+ projection = {
197
+ __v: 0,
198
+ createdAt: 0,
199
+ updatedAt: 0
200
+ };
201
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
202
+ exclusion.forEach((field) => {
203
+ projection[field] = 0;
204
+ });
205
+ }
206
+ }
207
+ const query = this.productModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
208
+ if (typeof conditions.limit === 'number' && conditions.limit > 0) {
209
+ const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
210
+ query.limit(conditions.limit)
211
+ .skip(conditions.limit * (page - 1));
212
+ }
213
+ // tslint:disable-next-line:no-single-line-block-comment
214
+ /* istanbul ignore else */
215
+ if (((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.productID) !== undefined) {
216
+ query.sort({ productID: conditions.sort.productID });
217
+ }
218
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
219
+ .exec()
220
+ .then((docs) => docs.map((doc) => doc.toObject()));
221
+ });
222
+ }
223
+ /**
224
+ * 決済サービスを検索する
225
+ */
226
+ searchPaymentServices(conditions, inclusion, exclusion) {
188
227
  var _a;
189
228
  return __awaiter(this, void 0, void 0, function* () {
190
229
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
230
+ // 強制的にtypeOfを絞る
231
+ andConditions.push({
232
+ typeOf: {
233
+ $in: [
234
+ factory.service.paymentService.PaymentServiceType.CreditCard,
235
+ factory.service.paymentService.PaymentServiceType.MovieTicket
236
+ ]
237
+ }
238
+ });
191
239
  let projection = {};
192
240
  if (Array.isArray(inclusion) && inclusion.length > 0) {
193
241
  inclusion.forEach((field) => {
@@ -233,18 +281,29 @@ class MongoRepository {
233
281
  */
234
282
  findAvailableChannel(params) {
235
283
  return __awaiter(this, void 0, void 0, function* () {
236
- const paymentServices = yield this.search({
237
- limit: 1,
238
- page: 1,
239
- project: { id: { $eq: params.project.id } },
240
- typeOf: { $eq: params.typeOf },
241
- id: { $eq: params.id }
242
- }, [], []);
243
- const paymentServiceSetting = paymentServices.shift();
244
- if (paymentServiceSetting === undefined) {
284
+ let paymentService;
285
+ if (params.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard) {
286
+ paymentService = (yield this.searchProducts({
287
+ limit: 1,
288
+ page: 1,
289
+ project: { id: { $eq: params.project.id } },
290
+ typeOf: { $eq: factory.product.ProductType.PaymentCard },
291
+ id: { $eq: params.id }
292
+ }, ['availableChannel'], [])).shift();
293
+ }
294
+ else {
295
+ paymentService = (yield this.searchPaymentServices({
296
+ limit: 1,
297
+ page: 1,
298
+ project: { id: { $eq: params.project.id } },
299
+ typeOf: { $eq: params.typeOf },
300
+ id: { $eq: params.id }
301
+ }, ['availableChannel'], [])).shift();
302
+ }
303
+ if (paymentService === undefined) {
245
304
  throw new factory.errors.NotFound('PaymentService');
246
305
  }
247
- const availableChannel = paymentServiceSetting.availableChannel;
306
+ const availableChannel = paymentService.availableChannel;
248
307
  if (availableChannel === undefined) {
249
308
  throw new factory.errors.NotFound('paymentService.availableChannel');
250
309
  }
@@ -315,60 +374,48 @@ class MongoRepository {
315
374
  }
316
375
  /**
317
376
  * プロダクトを保管する
318
- * 作成 or 更新
319
377
  */
320
- save(params) {
378
+ saveProduct(params) {
321
379
  return __awaiter(this, void 0, void 0, function* () {
322
380
  let doc;
323
- // Documentにidは不要なので念のため除外
324
- if (params.attributes.id !== undefined && params.attributes.id !== null) {
325
- delete params.attributes.id;
326
- }
327
381
  if (typeof params.id === 'string') {
328
- const _a = params.attributes, { id, productID, project } = _a, updateFields = __rest(_a, ["id", "productID", "project"]);
329
- switch (updateFields.typeOf) {
382
+ // 上書き禁止属性を除外
383
+ const _a = params.$set, { id, productID, project, typeOf, offers } = _a, setFields = __rest(_a, ["id", "productID", "project", "typeOf", "offers"]);
384
+ switch (typeOf) {
330
385
  case factory.product.ProductType.EventService:
331
386
  case factory.product.ProductType.MembershipService:
332
387
  case factory.product.ProductType.PaymentCard:
333
388
  case factory.product.ProductType.Product:
334
389
  case factory.product.ProductType.Transportation:
335
- // 上書き禁止属性を除外(2022-08-24~)
336
- const { offers } = updateFields, updateProductFields = __rest(updateFields, ["offers"]);
337
- doc = yield this.productModel.findOneAndUpdate({
338
- _id: { $eq: params.id },
339
- typeOf: { $eq: updateProductFields.typeOf }
340
- }, updateProductFields, { upsert: false, new: true })
341
- .exec();
342
- break;
343
- case factory.service.paymentService.PaymentServiceType.CreditCard:
344
- case factory.service.paymentService.PaymentServiceType.MovieTicket:
345
- // 上書き禁止属性を除外(2022-08-24~)
346
- const { provider } = updateFields, updatePaymentServiceFields = __rest(updateFields, ["provider"]);
347
390
  doc = yield this.productModel.findOneAndUpdate({
348
391
  _id: { $eq: params.id },
349
- typeOf: { $eq: updatePaymentServiceFields.typeOf }
350
- }, updatePaymentServiceFields, { upsert: false, new: true })
392
+ typeOf: { $eq: typeOf }
393
+ }, {
394
+ $set: setFields,
395
+ $unset: params.$unset
396
+ }, { upsert: false, new: true, projection: { _id: 1 } })
351
397
  .exec();
352
398
  break;
353
399
  default:
354
- throw new factory.errors.NotImplemented(`${updateFields.typeOf} not implemented`);
355
- }
356
- if (doc === null) {
357
- throw new factory.errors.NotFound(this.productModel.modelName);
400
+ throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
358
401
  }
359
402
  }
360
403
  else {
404
+ const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
361
405
  if (params.createIfNotExist === true) {
362
406
  doc = yield this.productModel.findOneAndUpdate({
363
- 'project.id': { $eq: params.attributes.project.id },
364
- typeOf: { $eq: params.attributes.typeOf }
365
- }, { $setOnInsert: params.attributes }, { new: true, upsert: true })
407
+ 'project.id': { $eq: createParams.project.id },
408
+ typeOf: { $eq: createParams.typeOf }
409
+ }, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
366
410
  .exec();
367
411
  }
368
412
  else {
369
- doc = yield this.productModel.create(params.attributes);
413
+ doc = yield this.productModel.create(createParams);
370
414
  }
371
415
  }
416
+ if (doc === null) {
417
+ throw new factory.errors.NotFound(this.productModel.modelName);
418
+ }
372
419
  return doc.toObject();
373
420
  });
374
421
  }
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
+ type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
27
28
  interface IAggregationByStatus {
28
29
  transactionCount: number;
29
30
  avgDuration: number;
@@ -64,8 +65,8 @@ export declare class MongoRepository {
64
65
  findById<T extends factory.transactionType>(params: {
65
66
  typeOf: T;
66
67
  id: string;
67
- inclusion?: string[];
68
- exclusion?: string[];
68
+ inclusion?: IKeyOfProjection<T>[];
69
+ exclusion?: IKeyOfProjection<T>[];
69
70
  }): Promise<factory.transaction.ITransaction<T>>;
70
71
  /**
71
72
  * 進行中の取引を取得する
@@ -187,8 +188,8 @@ export declare class MongoRepository {
187
188
  * 取引を検索する
188
189
  */
189
190
  search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T> & {
190
- inclusion: string[];
191
- exclusion: string[];
191
+ inclusion: IKeyOfProjection<T>[];
192
+ exclusion: IKeyOfProjection<T>[];
192
193
  }): Promise<factory.transaction.ITransaction<T>[]>;
193
194
  /**
194
195
  * 特定の取引を更新する(汎用)
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * リポジトリ
3
3
  */
4
+ import type { MongoRepository as AcceptedOfferRepo } from './repo/acceptedOffer';
4
5
  import type { MongoRepository as AccountRepo } from './repo/account';
5
6
  import type { MongoRepository as AccountingReportRepo } from './repo/accountingReport';
6
7
  import type { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
@@ -25,6 +26,7 @@ import type { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalo
25
26
  import type { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
26
27
  import type { MongoRepository as OrderRepo } from './repo/order';
27
28
  import type { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
29
+ import type { MongoRepository as PaymentServiceRepo } from './repo/paymentService';
28
30
  import type { MongoRepository as PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
29
31
  import type { MongoRepository as PermitRepo } from './repo/permit';
30
32
  import type { MongoRepository as PlaceRepo } from './repo/place';
@@ -46,11 +48,14 @@ import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
46
48
  import type { MongoRepository as TransactionRepo } from './repo/transaction';
47
49
  import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
48
50
  import type { MongoRepository as TripRepo } from './repo/trip';
49
- import type { RedisRepository as RegisterServiceActionInProgress } from './repo/action/registerServiceInProgress';
50
51
  import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
51
52
  import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
52
53
  import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
53
54
  import type { CognitoRepository as PersonRepo } from './repo/person';
55
+ export type AcceptedOffer = AcceptedOfferRepo;
56
+ export declare namespace AcceptedOffer {
57
+ function createInstance(...params: ConstructorParameters<typeof AcceptedOfferRepo>): Promise<AcceptedOfferRepo>;
58
+ }
54
59
  export type Account = AccountRepo;
55
60
  export declare namespace Account {
56
61
  function createInstance(...params: ConstructorParameters<typeof AccountRepo>): Promise<AccountRepo>;
@@ -83,12 +88,6 @@ export type Aggregation = AggregationRepo;
83
88
  export declare namespace Aggregation {
84
89
  function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
85
90
  }
86
- export declare namespace action {
87
- type RegisterServiceInProgress = RegisterServiceActionInProgress;
88
- namespace RegisterServiceInProgress {
89
- function createInstance(...params: ConstructorParameters<typeof RegisterServiceActionInProgress>): Promise<RegisterServiceActionInProgress>;
90
- }
91
- }
92
91
  export type AssetTransaction = AssetTransactionRepo;
93
92
  export declare namespace AssetTransaction {
94
93
  function createInstance(...params: ConstructorParameters<typeof AssetTransactionRepo>): Promise<AssetTransactionRepo>;
@@ -161,6 +160,10 @@ export type OwnershipInfo = OwnershipInfoRepo;
161
160
  export declare namespace OwnershipInfo {
162
161
  function createInstance(...params: ConstructorParameters<typeof OwnershipInfoRepo>): Promise<OwnershipInfoRepo>;
163
162
  }
163
+ export type PaymentService = PaymentServiceRepo;
164
+ export declare namespace PaymentService {
165
+ function createInstance(...params: ConstructorParameters<typeof PaymentServiceRepo>): Promise<PaymentServiceRepo>;
166
+ }
164
167
  export type PaymentServiceProvider = PaymentServiceProviderRepo;
165
168
  export declare namespace PaymentServiceProvider {
166
169
  function createInstance(...params: ConstructorParameters<typeof PaymentServiceProviderRepo>): Promise<PaymentServiceProviderRepo>;
@@ -9,7 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
12
+ exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
+ exports.rateLimit = void 0;
14
+ var AcceptedOffer;
15
+ (function (AcceptedOffer) {
16
+ let repo;
17
+ function createInstance(...params) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ if (repo === undefined) {
20
+ repo = (yield Promise.resolve().then(() => require('./repo/acceptedOffer'))).MongoRepository;
21
+ }
22
+ return new repo(...params);
23
+ });
24
+ }
25
+ AcceptedOffer.createInstance = createInstance;
26
+ })(AcceptedOffer = exports.AcceptedOffer || (exports.AcceptedOffer = {}));
13
27
  var Account;
14
28
  (function (Account) {
15
29
  let repo;
@@ -114,22 +128,6 @@ var Aggregation;
114
128
  }
115
129
  Aggregation.createInstance = createInstance;
116
130
  })(Aggregation = exports.Aggregation || (exports.Aggregation = {}));
117
- var action;
118
- (function (action) {
119
- let RegisterServiceInProgress;
120
- (function (RegisterServiceInProgress) {
121
- let repo;
122
- function createInstance(...params) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- if (repo === undefined) {
125
- repo = (yield Promise.resolve().then(() => require('./repo/action/registerServiceInProgress'))).RedisRepository;
126
- }
127
- return new repo(...params);
128
- });
129
- }
130
- RegisterServiceInProgress.createInstance = createInstance;
131
- })(RegisterServiceInProgress = action.RegisterServiceInProgress || (action.RegisterServiceInProgress = {}));
132
- })(action = exports.action || (exports.action = {}));
133
131
  var AssetTransaction;
134
132
  (function (AssetTransaction) {
135
133
  let repo;
@@ -364,6 +362,19 @@ var OwnershipInfo;
364
362
  }
365
363
  OwnershipInfo.createInstance = createInstance;
366
364
  })(OwnershipInfo = exports.OwnershipInfo || (exports.OwnershipInfo = {}));
365
+ var PaymentService;
366
+ (function (PaymentService) {
367
+ let repo;
368
+ function createInstance(...params) {
369
+ return __awaiter(this, void 0, void 0, function* () {
370
+ if (repo === undefined) {
371
+ repo = (yield Promise.resolve().then(() => require('./repo/paymentService'))).MongoRepository;
372
+ }
373
+ return new repo(...params);
374
+ });
375
+ }
376
+ PaymentService.createInstance = createInstance;
377
+ })(PaymentService = exports.PaymentService || (exports.PaymentService = {}));
367
378
  var PaymentServiceProvider;
368
379
  (function (PaymentServiceProvider) {
369
380
  let repo;
@@ -186,7 +186,16 @@ function calculateOfferCount(params) {
186
186
  try {
187
187
  const eventOffers = params.event.offers;
188
188
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
189
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
189
+ // const eventService = <Pick<factory.product.IProduct, 'hasOfferCatalog'>>
190
+ // await repos.product.findProductById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
191
+ const eventService = (yield repos.product.searchProducts({
192
+ limit: 1,
193
+ page: 1,
194
+ id: { $eq: eventOffers.itemOffered.id }
195
+ }, ['hasOfferCatalog'], [])).shift();
196
+ if (eventService === undefined) {
197
+ throw new factory.errors.NotFound(factory.product.ProductType.EventService);
198
+ }
190
199
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
191
200
  const catalogs = yield repos.offerCatalog.search({
192
201
  limit: 1,
@@ -23,7 +23,16 @@ function findEventOffers(params) {
23
23
  // 興行設定があれば興行のカタログを参照する
24
24
  const eventOffers = params.event.offers;
25
25
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
26
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
26
+ // const eventService = <Pick<factory.product.IProduct, 'hasOfferCatalog'>>
27
+ // await repos.product.findProductById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
28
+ const eventService = (yield repos.product.searchProducts({
29
+ limit: 1,
30
+ page: 1,
31
+ id: { $eq: eventOffers.itemOffered.id }
32
+ }, ['hasOfferCatalog'], [])).shift();
33
+ if (eventService === undefined) {
34
+ throw new factory.errors.NotFound(factory.product.ProductType.EventService);
35
+ }
27
36
  const offerCatalogId = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id;
28
37
  if (typeof offerCatalogId === 'string') {
29
38
  // サブカタログIDを決定
@@ -28,7 +28,7 @@ function start(params) {
28
28
  var _a;
29
29
  const issuedThroughId = fixIssuedThroughId(params);
30
30
  // location.issuedThroughIdからプロダクトをfixする
31
- const products = yield repos.product.search({
31
+ const products = yield repos.product.searchProducts({
32
32
  limit: 1,
33
33
  page: 1,
34
34
  project: { id: { $eq: params.project.id } },
@@ -6,5 +6,7 @@ export type IUnitPriceSpecification = factory.unitPriceOffer.IUnitPriceOfferPric
6
6
  export declare function createPotentialActions(params: {
7
7
  transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Pay>;
8
8
  potentialActions?: factory.assetTransaction.pay.IPotentialActionsParams;
9
- order: factory.order.IOrder;
9
+ order: Pick<factory.order.IOrder, 'typeOf' | 'confirmationNumber' | 'orderNumber'> & {
10
+ acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
11
+ };
10
12
  }): factory.assetTransaction.IPotentialActions<factory.assetTransactionType.Pay>;
@@ -214,12 +214,12 @@ function reservationPriceComponent2invoicePriceComponent(component) {
214
214
  }
215
215
  }
216
216
  function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType) {
217
- var _a, _b;
217
+ var _a;
218
218
  let ticketToken;
219
219
  let reservationNumber = '';
220
220
  let priceComponents4invoice = [];
221
221
  // Orderから対象予約を取得
222
- const reservationOffer = (_a = order === null || order === void 0 ? void 0 : order.acceptedOffers) === null || _a === void 0 ? void 0 : _a.find((o) => {
222
+ const reservationOffer = order.acceptedOffers.find((o) => {
223
223
  var _a, _b, _c, _d;
224
224
  let mvtkUnitPriceSpec;
225
225
  // MovieTicket適用単価オファーからidentifierを取り出す
@@ -259,7 +259,7 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
259
259
  ticketToken = ticketTokenByReservationOffer;
260
260
  }
261
261
  reservationNumber = reservationOffer.itemOffered.reservationNumber;
262
- const priceComponent = (_b = reservationOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent;
262
+ const priceComponent = (_a = reservationOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent;
263
263
  if (Array.isArray(priceComponent)) {
264
264
  priceComponents4invoice = priceComponent.map(reservationPriceComponent2invoicePriceComponent);
265
265
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as GMO from '@motionpicture/gmo-service';
5
5
  import * as factory from '../../factory';
6
+ import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
6
7
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
7
8
  import type { MongoRepository as ActionRepo } from '../../repo/action';
8
9
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
@@ -38,6 +39,7 @@ export interface ICancelRepos {
38
39
  }
39
40
  export type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
40
41
  export interface IConfirmRepos {
42
+ acceptedOffer: AcceptedOfferRepo;
41
43
  action: ActionRepo;
42
44
  accountingReport: AccountingReportRepo;
43
45
  assetTransaction: AssetTransactionRepo;