@chevre/domain 21.18.0-alpha.9 → 21.18.0

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 (150) hide show
  1. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
  2. package/example/src/chevre/migratePaymentServicesToNewCollection.ts +21 -0
  3. package/example/src/chevre/offerCatalog2offerCatalogItem.ts +4 -0
  4. package/example/src/chevre/searchOffers.ts +41 -37
  5. package/example/src/chevre/searchOrderAcceptedOffers.ts +11 -11
  6. package/example/src/chevre/searchOrders.ts +11 -0
  7. package/example/src/chevre/searchProducts.ts +28 -0
  8. package/example/src/chevre/searchReservationsByOrder.ts +30 -0
  9. package/example/src/chevre/searchTransactions.ts +41 -0
  10. package/example/src/chevre/unsetUnnecessaryFields.ts +12 -6
  11. package/example/src/chevre/upsertMoviesByIdentifier.ts +5 -4
  12. package/example/src/chevre/upsertOfferCatalogsByIdentifier.ts +46 -0
  13. package/example/src/chevre/upsertOffersByIdentifier.ts +94 -0
  14. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +104 -0
  15. package/lib/chevre/credentials.d.ts +0 -3
  16. package/lib/chevre/credentials.js +4 -3
  17. package/lib/chevre/repo/acceptedOffer.d.ts +31 -14
  18. package/lib/chevre/repo/acceptedOffer.js +56 -102
  19. package/lib/chevre/repo/creativeWork.d.ts +12 -2
  20. package/lib/chevre/repo/creativeWork.js +39 -25
  21. package/lib/chevre/repo/event.d.ts +15 -0
  22. package/lib/chevre/repo/event.js +66 -0
  23. package/lib/chevre/repo/mongoose/schemas/paymentService.d.ts +5 -0
  24. package/lib/chevre/repo/mongoose/schemas/paymentService.js +146 -0
  25. package/lib/chevre/repo/offer.d.ts +14 -5
  26. package/lib/chevre/repo/offer.js +94 -19
  27. package/lib/chevre/repo/offerCatalog.d.ts +18 -1
  28. package/lib/chevre/repo/offerCatalog.js +51 -39
  29. package/lib/chevre/repo/order.d.ts +14 -10
  30. package/lib/chevre/repo/order.js +20 -14
  31. package/lib/chevre/repo/paymentService.d.ts +62 -0
  32. package/lib/chevre/repo/paymentService.js +339 -0
  33. package/lib/chevre/repo/paymentServiceProvider.d.ts +27 -4
  34. package/lib/chevre/repo/paymentServiceProvider.js +85 -12
  35. package/lib/chevre/repo/place.js +14 -10
  36. package/lib/chevre/repo/product.d.ts +37 -24
  37. package/lib/chevre/repo/product.js +60 -150
  38. package/lib/chevre/repo/transaction.d.ts +5 -4
  39. package/lib/chevre/repository.d.ts +5 -7
  40. package/lib/chevre/repository.js +14 -17
  41. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -1
  42. package/lib/chevre/service/aggregation/event/findEventOffers.js +10 -1
  43. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  44. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +1 -1
  45. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  46. package/lib/chevre/service/assetTransaction/pay.d.ts +7 -6
  47. package/lib/chevre/service/assetTransaction/pay.js +44 -36
  48. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  49. package/lib/chevre/service/assetTransaction/refund/factory.js +0 -5
  50. package/lib/chevre/service/assetTransaction/refund.d.ts +2 -0
  51. package/lib/chevre/service/assetTransaction/refund.js +16 -4
  52. package/lib/chevre/service/assetTransaction/registerService.js +18 -2
  53. package/lib/chevre/service/assetTransaction/reserve/factory/price.js +1 -1
  54. package/lib/chevre/service/assetTransaction/reserve.d.ts +6 -0
  55. package/lib/chevre/service/assetTransaction/reserve.js +32 -2
  56. package/lib/chevre/service/delivery/factory.d.ts +3 -1
  57. package/lib/chevre/service/delivery/factory.js +4 -2
  58. package/lib/chevre/service/delivery.d.ts +1 -2
  59. package/lib/chevre/service/delivery.js +1 -3
  60. package/lib/chevre/service/event.js +1 -1
  61. package/lib/chevre/service/moneyTransfer.js +11 -1
  62. package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
  63. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  64. package/lib/chevre/service/offer/event/factory.js +4 -2
  65. package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +4 -0
  66. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +40 -5
  67. package/lib/chevre/service/offer/product/factory.js +1 -1
  68. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -1
  69. package/lib/chevre/service/offer/product.d.ts +4 -15
  70. package/lib/chevre/service/offer/product.js +85 -57
  71. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  72. package/lib/chevre/service/order/confirmPayTransaction.js +0 -1
  73. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
  74. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
  75. package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
  76. package/lib/chevre/service/order/deleteOrder.js +15 -4
  77. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
  78. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -0
  80. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +13 -5
  81. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  82. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +2 -2
  83. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
  84. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +2 -4
  85. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +13 -32
  86. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +1 -1
  87. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +12 -12
  88. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +17 -76
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -1
  90. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -3
  91. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +2 -2
  92. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +3 -3
  93. package/lib/chevre/service/order/payOrder.d.ts +2 -0
  94. package/lib/chevre/service/order/placeOrder.d.ts +2 -0
  95. package/lib/chevre/service/order/placeOrder.js +62 -14
  96. package/lib/chevre/service/order/returnOrder.js +28 -10
  97. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  98. package/lib/chevre/service/order/sendOrder.js +16 -4
  99. package/lib/chevre/service/payment/any.d.ts +5 -4
  100. package/lib/chevre/service/payment/any.js +1 -1
  101. package/lib/chevre/service/payment/creditCard.d.ts +5 -5
  102. package/lib/chevre/service/payment/creditCard.js +4 -4
  103. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +5 -3
  104. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +3 -3
  105. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +14 -5
  106. package/lib/chevre/service/payment/movieTicket/getCredentials.js +26 -9
  107. package/lib/chevre/service/payment/movieTicket/validation.d.ts +4 -2
  108. package/lib/chevre/service/payment/movieTicket.d.ts +11 -7
  109. package/lib/chevre/service/payment/movieTicket.js +4 -5
  110. package/lib/chevre/service/payment/paymentCard.js +9 -2
  111. package/lib/chevre/service/payment.d.ts +4 -0
  112. package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
  113. package/lib/chevre/service/reserve/searchByOrder.js +113 -0
  114. package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
  115. package/lib/chevre/service/reserve.d.ts +2 -1
  116. package/lib/chevre/service/reserve.js +3 -1
  117. package/lib/chevre/service/task/confirmPayTransaction.js +0 -2
  118. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  119. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +2 -0
  120. package/lib/chevre/service/task/onAuthorizationCreated.js +0 -19
  121. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -0
  122. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +3 -6
  123. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  124. package/lib/chevre/service/task/pay.js +2 -1
  125. package/lib/chevre/service/task/placeOrder.js +2 -0
  126. package/lib/chevre/service/task/refund.js +2 -1
  127. package/lib/chevre/service/task/returnPayTransaction.js +3 -2
  128. package/lib/chevre/service/task/sendOrder.js +10 -17
  129. package/lib/chevre/service/task/voidPayTransaction.js +2 -3
  130. package/lib/chevre/service/task/voidPayment.js +2 -0
  131. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
  132. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  133. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +0 -4
  134. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +0 -86
  135. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  136. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  137. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
  138. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
  139. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
  140. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
  141. package/lib/chevre/service/transaction/returnOrder.d.ts +1 -0
  142. package/lib/chevre/service/transaction/returnOrder.js +64 -58
  143. package/lib/chevre/settings.d.ts +2 -0
  144. package/lib/chevre/settings.js +3 -1
  145. package/package.json +3 -3
  146. package/example/src/chevre/transaction/findPaymentCardPermit.ts +0 -29
  147. package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
  148. package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
  149. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +0 -26
  150. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +0 -65
@@ -22,52 +22,64 @@
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;
28
- export type IPaymentServiceByProvider = Pick<factory.service.paymentService.IService, 'name' | 'description' | 'typeOf' | 'id' | 'productID' | 'serviceType' | 'serviceOutput' | 'additionalProperty'> & {
29
- provider?: Pick<factory.service.paymentService.IProvider, 'credentials'>;
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
+ };
30
36
  };
37
+ type IUnsetKey = keyof Pick<factory.product.IProduct, 'additionalProperty' | 'availableChannel' | 'hasOfferCatalog' | 'serviceOutput' | 'serviceType'>;
31
38
  /**
32
39
  * プロダクトリポジトリ
33
40
  */
34
41
  export declare class MongoRepository {
35
42
  private readonly productModel;
36
43
  constructor(connection: Connection);
37
- static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): any[];
38
- findById(conditions: {
39
- id: string;
40
- }, inclusion: string[], exclusion: string[]): Promise<IProduct>;
41
- search(conditions: factory.product.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<IProduct[]>;
42
- deleteById(params: {
43
- id: string;
44
- }): Promise<void>;
44
+ static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): FilterQuery<factory.product.IProduct>[];
45
45
  /**
46
- * プロダクトIDからavailableChannelを取得する
46
+ * プロダクトを検索する
47
47
  */
48
- findAvailableChannel(params: {
49
- project: {
50
- id: string;
51
- };
52
- typeOf: factory.service.paymentService.PaymentServiceType;
48
+ searchProducts(conditions: ISearchConditions4product, inclusion: IKeyOfProjection4product[], exclusion: IKeyOfProjection4product[]): Promise<factory.product.IProduct[]>;
49
+ deleteProductById(params: {
53
50
  id: string;
54
- }): Promise<factory.product.IAvailableChannel>;
55
- searchPaymentServicesByProvider(params: Pick<factory.product.ISearchConditions, 'limit' | 'page' | 'sort' | 'project' | 'provider' | 'typeOf'>): Promise<IPaymentServiceByProvider[]>;
51
+ }): Promise<void>;
56
52
  /**
57
53
  * プロダクトを保管する
58
- * 作成 or 更新
59
54
  */
60
- save(params: {
55
+ saveProduct(params: {
61
56
  /**
62
57
  * idを指定すれば更新
63
58
  */
64
59
  id?: string;
65
- attributes: factory.product.IProduct | factory.service.paymentService.IService;
60
+ $set: factory.product.IProduct & {
61
+ offers?: never;
62
+ };
63
+ $unset: {
64
+ [key in IUnsetKey]?: 1;
65
+ };
66
66
  /**
67
67
  * 指定プロジェクトの指定プロダクトタイプが存在しなければ作成する
68
68
  */
69
69
  createIfNotExist?: boolean;
70
- }): Promise<factory.product.IProduct>;
70
+ }): Promise<{
71
+ id: string;
72
+ }>;
73
+ /**
74
+ * プロダクトIDからavailableChannelを取得する
75
+ */
76
+ findAvailableChannel(params: {
77
+ project: {
78
+ id: string;
79
+ };
80
+ typeOf: factory.service.paymentService.PaymentServiceType.PaymentCard;
81
+ id: string;
82
+ }): Promise<factory.product.IAvailableChannel>;
71
83
  deleteByHasOfferCatalog(params: {
72
84
  project: {
73
85
  id: string;
@@ -86,3 +98,4 @@ export declare class MongoRepository {
86
98
  }): Promise<void>;
87
99
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
88
100
  }
101
+ export {};
@@ -151,43 +151,27 @@ 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) {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- let projection = {};
160
- if (Array.isArray(inclusion) && inclusion.length > 0) {
161
- inclusion.forEach((field) => {
162
- projection[field] = 1;
163
- });
164
- }
165
- else {
166
- projection = {
167
- __v: 0,
168
- createdAt: 0,
169
- updatedAt: 0
170
- };
171
- if (Array.isArray(exclusion) && exclusion.length > 0) {
172
- exclusion.forEach((field) => {
173
- projection[field] = 0;
174
- });
175
- }
176
- }
177
- const doc = yield this.productModel.findOne({ _id: conditions.id }, projection)
178
- .exec();
179
- if (doc === null) {
180
- throw new factory.errors.NotFound(this.productModel.modelName);
181
- }
182
- return doc.toObject();
183
- });
184
- }
185
- search(conditions,
186
- // projection?: { [key: string]: number }
187
- inclusion, exclusion) {
154
+ /**
155
+ * プロダクトを検索する
156
+ */
157
+ searchProducts(conditions, inclusion, exclusion) {
188
158
  var _a;
189
159
  return __awaiter(this, void 0, void 0, function* () {
190
160
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
161
+ // 強制的にtypeOfを絞る(2023-12-19~)
162
+ if (settings_1.USE_SEARCH_ONLY_PRODUCTS_FORCIBLY) {
163
+ andConditions.push({
164
+ typeOf: {
165
+ $in: [
166
+ factory.product.ProductType.EventService,
167
+ factory.product.ProductType.MembershipService,
168
+ factory.product.ProductType.PaymentCard,
169
+ factory.product.ProductType.Product,
170
+ factory.product.ProductType.Transportation
171
+ ]
172
+ }
173
+ });
174
+ }
191
175
  let projection = {};
192
176
  if (Array.isArray(inclusion) && inclusion.length > 0) {
193
177
  inclusion.forEach((field) => {
@@ -222,156 +206,82 @@ class MongoRepository {
222
206
  .then((docs) => docs.map((doc) => doc.toObject()));
223
207
  });
224
208
  }
225
- deleteById(params) {
209
+ deleteProductById(params) {
226
210
  return __awaiter(this, void 0, void 0, function* () {
227
211
  yield this.productModel.findOneAndDelete({ _id: params.id })
228
212
  .exec();
229
213
  });
230
214
  }
231
- /**
232
- * プロダクトIDからavailableChannelを取得する
233
- */
234
- findAvailableChannel(params) {
235
- 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) {
245
- throw new factory.errors.NotFound('PaymentService');
246
- }
247
- const availableChannel = paymentServiceSetting.availableChannel;
248
- if (availableChannel === undefined) {
249
- throw new factory.errors.NotFound('paymentService.availableChannel');
250
- }
251
- return availableChannel;
252
- });
253
- }
254
- searchPaymentServicesByProvider(params) {
255
- var _a, _b, _c, _d, _e, _f;
256
- return __awaiter(this, void 0, void 0, function* () {
257
- const matchStages = [];
258
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
259
- if (typeof projectIdEq === 'string') {
260
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
261
- }
262
- const typeOfEq = (_c = params.typeOf) === null || _c === void 0 ? void 0 : _c.$eq;
263
- if (typeof typeOfEq === 'string') {
264
- matchStages.push({ $match: { typeOf: { $eq: typeOfEq } } });
265
- }
266
- const providerIdEq = (_e = (_d = params.provider) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
267
- if (typeof providerIdEq === 'string') {
268
- matchStages.push({ $match: { 'provider.id': { $exists: true, $eq: providerIdEq } } });
269
- }
270
- const aggregate = this.productModel.aggregate([
271
- ...(typeof ((_f = params.sort) === null || _f === void 0 ? void 0 : _f.productID) === 'number')
272
- ? [{ $sort: { productID: params.sort.productID } }]
273
- : [],
274
- {
275
- $unwind: {
276
- path: '$provider'
277
- }
278
- },
279
- ...matchStages,
280
- {
281
- $project: {
282
- _id: 0,
283
- typeOf: '$typeOf',
284
- productID: '$productID',
285
- description: '$description',
286
- name: '$name',
287
- // provider: [ [Object] ],
288
- additionalProperty: '$additionalProperty',
289
- serviceOutput: '$serviceOutput',
290
- serviceType: '$serviceType',
291
- id: { $toString: '$_id' },
292
- // ↓セキュアな情報を隠蔽するように
293
- provider: {
294
- credentials: {
295
- shopId: '$provider.credentials.shopId',
296
- tokenizationCode: '$provider.credentials.tokenizationCode',
297
- paymentUrl: {
298
- expiresInSeconds: '$provider.credentials.paymentUrl.expiresInSeconds',
299
- useCallback: '$provider.credentials.paymentUrl.useCallback',
300
- useWebhook: '$provider.credentials.paymentUrl.useWebhook'
301
- }
302
- }
303
- }
304
- }
305
- }
306
- ]);
307
- if (typeof params.limit === 'number' && params.limit > 0) {
308
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
309
- aggregate.limit(params.limit * page)
310
- .skip(params.limit * (page - 1));
311
- }
312
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
313
- .exec();
314
- });
315
- }
316
215
  /**
317
216
  * プロダクトを保管する
318
- * 作成 or 更新
319
217
  */
320
- save(params) {
218
+ saveProduct(params) {
321
219
  return __awaiter(this, void 0, void 0, function* () {
322
220
  let doc;
323
- // Documentにidは不要なので念のため除外
324
- if (params.attributes.id !== undefined && params.attributes.id !== null) {
325
- delete params.attributes.id;
326
- }
327
221
  if (typeof params.id === 'string') {
328
- const _a = params.attributes, { id, productID, project } = _a, updateFields = __rest(_a, ["id", "productID", "project"]);
329
- switch (updateFields.typeOf) {
222
+ // 上書き禁止属性を除外
223
+ const _a = params.$set, { id, productID, project, typeOf, offers } = _a, setFields = __rest(_a, ["id", "productID", "project", "typeOf", "offers"]);
224
+ switch (typeOf) {
330
225
  case factory.product.ProductType.EventService:
331
226
  case factory.product.ProductType.MembershipService:
332
227
  case factory.product.ProductType.PaymentCard:
333
228
  case factory.product.ProductType.Product:
334
229
  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
230
  doc = yield this.productModel.findOneAndUpdate({
348
231
  _id: { $eq: params.id },
349
- typeOf: { $eq: updatePaymentServiceFields.typeOf }
350
- }, updatePaymentServiceFields, { upsert: false, new: true })
232
+ typeOf: { $eq: typeOf }
233
+ }, {
234
+ $set: setFields,
235
+ $unset: params.$unset
236
+ }, { upsert: false, new: true, projection: { _id: 1 } })
351
237
  .exec();
352
238
  break;
353
239
  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);
240
+ throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
358
241
  }
359
242
  }
360
243
  else {
244
+ const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
361
245
  if (params.createIfNotExist === true) {
362
246
  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 })
247
+ 'project.id': { $eq: createParams.project.id },
248
+ typeOf: { $eq: createParams.typeOf }
249
+ }, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
366
250
  .exec();
367
251
  }
368
252
  else {
369
- doc = yield this.productModel.create(params.attributes);
253
+ doc = yield this.productModel.create(createParams);
370
254
  }
371
255
  }
256
+ if (doc === null) {
257
+ throw new factory.errors.NotFound(this.productModel.modelName);
258
+ }
372
259
  return doc.toObject();
373
260
  });
374
261
  }
262
+ /**
263
+ * プロダクトIDからavailableChannelを取得する
264
+ */
265
+ findAvailableChannel(params) {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ let paymentService;
268
+ paymentService = (yield this.searchProducts({
269
+ limit: 1,
270
+ page: 1,
271
+ project: { id: { $eq: params.project.id } },
272
+ typeOf: { $eq: factory.product.ProductType.PaymentCard },
273
+ id: { $eq: params.id }
274
+ }, ['availableChannel'], [])).shift();
275
+ if (paymentService === undefined) {
276
+ throw new factory.errors.NotFound('PaymentService');
277
+ }
278
+ const availableChannel = paymentService.availableChannel;
279
+ if (availableChannel === undefined) {
280
+ throw new factory.errors.NotFound('paymentService.availableChannel');
281
+ }
282
+ return availableChannel;
283
+ });
284
+ }
375
285
  deleteByHasOfferCatalog(params) {
376
286
  return __awaiter(this, void 0, void 0, function* () {
377
287
  return this.productModel.deleteMany({
@@ -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
  * 特定の取引を更新する(汎用)
@@ -26,6 +26,7 @@ import type { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalo
26
26
  import type { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
27
27
  import type { MongoRepository as OrderRepo } from './repo/order';
28
28
  import type { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
29
+ import type { MongoRepository as PaymentServiceRepo } from './repo/paymentService';
29
30
  import type { MongoRepository as PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
30
31
  import type { MongoRepository as PermitRepo } from './repo/permit';
31
32
  import type { MongoRepository as PlaceRepo } from './repo/place';
@@ -47,7 +48,6 @@ import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
47
48
  import type { MongoRepository as TransactionRepo } from './repo/transaction';
48
49
  import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
49
50
  import type { MongoRepository as TripRepo } from './repo/trip';
50
- import type { RedisRepository as RegisterServiceActionInProgress } from './repo/action/registerServiceInProgress';
51
51
  import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
52
52
  import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
53
53
  import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
@@ -88,12 +88,6 @@ export type Aggregation = AggregationRepo;
88
88
  export declare namespace Aggregation {
89
89
  function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
90
90
  }
91
- export declare namespace action {
92
- type RegisterServiceInProgress = RegisterServiceActionInProgress;
93
- namespace RegisterServiceInProgress {
94
- function createInstance(...params: ConstructorParameters<typeof RegisterServiceActionInProgress>): Promise<RegisterServiceActionInProgress>;
95
- }
96
- }
97
91
  export type AssetTransaction = AssetTransactionRepo;
98
92
  export declare namespace AssetTransaction {
99
93
  function createInstance(...params: ConstructorParameters<typeof AssetTransactionRepo>): Promise<AssetTransactionRepo>;
@@ -166,6 +160,10 @@ export type OwnershipInfo = OwnershipInfoRepo;
166
160
  export declare namespace OwnershipInfo {
167
161
  function createInstance(...params: ConstructorParameters<typeof OwnershipInfoRepo>): Promise<OwnershipInfoRepo>;
168
162
  }
163
+ export type PaymentService = PaymentServiceRepo;
164
+ export declare namespace PaymentService {
165
+ function createInstance(...params: ConstructorParameters<typeof PaymentServiceRepo>): Promise<PaymentServiceRepo>;
166
+ }
169
167
  export type PaymentServiceProvider = PaymentServiceProviderRepo;
170
168
  export declare namespace PaymentServiceProvider {
171
169
  function createInstance(...params: ConstructorParameters<typeof PaymentServiceProviderRepo>): Promise<PaymentServiceProviderRepo>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
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.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 = exports.AcceptedOffer = 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
13
  exports.rateLimit = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
@@ -128,22 +128,6 @@ var Aggregation;
128
128
  }
129
129
  Aggregation.createInstance = createInstance;
130
130
  })(Aggregation = exports.Aggregation || (exports.Aggregation = {}));
131
- var action;
132
- (function (action) {
133
- let RegisterServiceInProgress;
134
- (function (RegisterServiceInProgress) {
135
- let repo;
136
- function createInstance(...params) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- if (repo === undefined) {
139
- repo = (yield Promise.resolve().then(() => require('./repo/action/registerServiceInProgress'))).RedisRepository;
140
- }
141
- return new repo(...params);
142
- });
143
- }
144
- RegisterServiceInProgress.createInstance = createInstance;
145
- })(RegisterServiceInProgress = action.RegisterServiceInProgress || (action.RegisterServiceInProgress = {}));
146
- })(action = exports.action || (exports.action = {}));
147
131
  var AssetTransaction;
148
132
  (function (AssetTransaction) {
149
133
  let repo;
@@ -378,6 +362,19 @@ var OwnershipInfo;
378
362
  }
379
363
  OwnershipInfo.createInstance = createInstance;
380
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 = {}));
381
378
  var PaymentServiceProvider;
382
379
  (function (PaymentServiceProvider) {
383
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,7 +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
10
  acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
11
11
  };
12
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.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
  }
@@ -9,6 +9,7 @@ import type { MongoRepository as ActionRepo } from '../../repo/action';
9
9
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
10
10
  import type { MongoRepository as EventRepo } from '../../repo/event';
11
11
  import type { MongoRepository as OrderRepo } from '../../repo/order';
12
+ import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
12
13
  import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
13
14
  import type { CognitoRepository as PersonRepo } from '../../repo/person';
14
15
  import type { MongoRepository as ProductRepo } from '../../repo/product';
@@ -21,6 +22,7 @@ export interface IStartOperationRepos {
21
22
  action: ActionRepo;
22
23
  event: EventRepo;
23
24
  paymentAccepted: PaymentAcceptedRepo;
25
+ paymentService: PaymentServiceRepo;
24
26
  paymentServiceProvider: PaymentServiceProviderRepo;
25
27
  person: PersonRepo;
26
28
  product: ProductRepo;
@@ -33,7 +35,6 @@ export interface ICancelRepos {
33
35
  action: ActionRepo;
34
36
  accountingReport: AccountingReportRepo;
35
37
  assetTransaction: AssetTransactionRepo;
36
- product: ProductRepo;
37
38
  project: ProjectRepo;
38
39
  task: TaskRepo;
39
40
  }
@@ -45,7 +46,6 @@ export interface IConfirmRepos {
45
46
  assetTransaction: AssetTransactionRepo;
46
47
  event: EventRepo;
47
48
  order: OrderRepo;
48
- product: ProductRepo;
49
49
  project: ProjectRepo;
50
50
  task: TaskRepo;
51
51
  }
@@ -58,22 +58,23 @@ export type ICheckOperation<T> = (repos: {
58
58
  action: ActionRepo;
59
59
  event: EventRepo;
60
60
  paymentAccepted: PaymentAcceptedRepo;
61
- product: ProductRepo;
61
+ paymentService: PaymentServiceRepo;
62
+ paymentServiceProvider: PaymentServiceProviderRepo;
62
63
  project: ProjectRepo;
63
64
  }) => Promise<T>;
64
65
  export type IPublishPaymentUrlOperation<T> = (repos: {
65
66
  paymentAccepted: PaymentAcceptedRepo;
67
+ paymentService: PaymentServiceRepo;
66
68
  paymentServiceProvider: PaymentServiceProviderRepo;
67
69
  person: PersonRepo;
68
- product: ProductRepo;
69
70
  project: ProjectRepo;
70
71
  }) => Promise<T>;
71
72
  export type IInvalidatePaymentUrlOperation<T> = (repos: {
72
73
  accountingReport: AccountingReportRepo;
73
74
  action: ActionRepo;
74
75
  paymentAccepted: PaymentAcceptedRepo;
76
+ paymentService: PaymentServiceRepo;
75
77
  paymentServiceProvider: PaymentServiceProviderRepo;
76
- product: ProductRepo;
77
78
  project: ProjectRepo;
78
79
  task: TaskRepo;
79
80
  assetTransaction: AssetTransactionRepo;
@@ -135,7 +136,7 @@ export declare function searchGMOTrade(params: {
135
136
  transactionNumber: string;
136
137
  }): (repos: {
137
138
  paymentAccepted: PaymentAcceptedRepo;
139
+ paymentService: PaymentServiceRepo;
138
140
  paymentServiceProvider: PaymentServiceProviderRepo;
139
- product: ProductRepo;
140
141
  assetTransaction: AssetTransactionRepo;
141
142
  }) => Promise<GMO.factory.credit.ISearchTradeResult>;