@chevre/domain 21.9.0-alpha.8 → 21.9.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 (32) hide show
  1. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +4 -1
  2. package/example/src/chevre/searchEventTicketOffers.ts +1 -0
  3. package/example/src/chevre/searchOfferCatalogItemAvailability.ts +38 -0
  4. package/example/src/chevre/searchOfferCatalogItems.ts +41 -26
  5. package/example/src/chevre/searchOffers.ts +16 -4
  6. package/example/src/chevre/searchOffersByCatalog.ts +9 -3
  7. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +23 -21
  8. package/lib/chevre/repo/aggregateOffer.d.ts +19 -3
  9. package/lib/chevre/repo/aggregateOffer.js +227 -27
  10. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +45 -45
  11. package/lib/chevre/repo/offer.d.ts +21 -13
  12. package/lib/chevre/repo/offer.js +145 -58
  13. package/lib/chevre/repo/offerCatalog.d.ts +11 -3
  14. package/lib/chevre/repo/offerCatalog.js +30 -15
  15. package/lib/chevre/repo/offerCatalogItem.d.ts +20 -1
  16. package/lib/chevre/repo/offerCatalogItem.js +67 -23
  17. package/lib/chevre/repo/task.d.ts +1 -1
  18. package/lib/chevre/service/assetTransaction/reserve.js +1 -0
  19. package/lib/chevre/service/offer/event/authorize.js +1 -0
  20. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +53 -7
  21. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +127 -6
  22. package/lib/chevre/service/offer/event.d.ts +2 -2
  23. package/lib/chevre/service/offer/event.js +3 -1
  24. package/lib/chevre/service/offer/product/searchProductOffers.js +4 -3
  25. package/lib/chevre/service/offer/product.js +3 -30
  26. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +3 -3
  27. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +20 -0
  28. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +28 -0
  29. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +15 -5
  30. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +45 -33
  31. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  32. package/package.json +3 -3
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.onOfferCatalogUpdated = void 0;
13
+ const syncOfferCatalog_1 = require("./syncOfferCatalog");
14
+ /**
15
+ * オファーカタログ変更時処理
16
+ */
17
+ function onOfferCatalogUpdated(params) {
18
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ yield (0, syncOfferCatalog_1.syncOfferCatalog)({
20
+ project: { id: params.project.id },
21
+ ids: params.ids,
22
+ typeOf: params.typeOf,
23
+ isDeleted: false,
24
+ isOfferCatalogItem: params.isOfferCatalogItem === true
25
+ })(repos);
26
+ });
27
+ }
28
+ exports.onOfferCatalogUpdated = onOfferCatalogUpdated;
@@ -42,11 +42,16 @@ function onResourceDeleted(params) {
42
42
  ids: params.id
43
43
  })(repos);
44
44
  break;
45
- case factory.offerType.Offer:
46
- yield deleteResourcesByOffer({
45
+ case factory.offerType.AggregateOffer:
46
+ yield deleteResourcesByAggregateOffer({
47
47
  project: { id: params.project.id },
48
48
  ids: params.id
49
49
  })(repos);
50
+ // case factory.offerType.Offer:
51
+ // await deleteResourcesByOffer({
52
+ // project: { id: params.project.id },
53
+ // ids: params.id
54
+ // })(repos);
50
55
  break;
51
56
  case 'OfferCatalog':
52
57
  yield deleteResourcesByOfferCatalog({
@@ -258,7 +263,7 @@ function deleteResourcesBySeller(params) {
258
263
  }
259
264
  });
260
265
  }
261
- function deleteResourcesByOffer(params) {
266
+ function deleteResourcesByAggregateOffer(params) {
262
267
  return (repos) => __awaiter(this, void 0, void 0, function* () {
263
268
  if (params.ids.length !== 1) {
264
269
  throw new factory.errors.Argument('id', 'id.length must be 1');
@@ -266,7 +271,7 @@ function deleteResourcesByOffer(params) {
266
271
  for (const offerId of params.ids) {
267
272
  const deleteActionAttributes = {
268
273
  agent: { id: params.project.id, typeOf: factory.organizationType.Project },
269
- object: { id: offerId, typeOf: factory.offerType.Offer },
274
+ object: { id: offerId, typeOf: factory.offerType.AggregateOffer },
270
275
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
271
276
  typeOf: factory.actionType.DeleteAction
272
277
  };
@@ -278,7 +283,12 @@ function deleteResourcesByOffer(params) {
278
283
  project: { id: params.project.id },
279
284
  $pull: { itemListElement: { $elemMatch: { id: { $in: [offerId] } } } }
280
285
  });
281
- deleteResult = { updateCatalogResult };
286
+ // サブカタログ対応
287
+ const updateCatalogItemResult = yield repos.offerCatalogItem.pullItemListElement({
288
+ project: { id: params.project.id },
289
+ $pull: { itemListElement: { $elemMatch: { id: { $in: [offerId] } } } }
290
+ });
291
+ deleteResult = { updateCatalogResult, updateCatalogItemResult };
282
292
  }
283
293
  catch (error) {
284
294
  try {
@@ -22,8 +22,6 @@ function syncOfferCatalog(params) {
22
22
  var _a;
23
23
  if (params.isDeleted) {
24
24
  for (const offerCatalogId of params.ids) {
25
- // 検索しても存在しない
26
- // const offerCatalogs = await repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
27
25
  // カタログを含む全集計オファーからカタログを除外
28
26
  yield repos.aggregateOffer.pullIncludedInDataCatalog({
29
27
  project: { id: params.project.id },
@@ -37,7 +35,7 @@ function syncOfferCatalog(params) {
37
35
  for (const offerCatalogId of params.ids) {
38
36
  let offerCatalogs = [];
39
37
  if (params.isOfferCatalogItem) {
40
- offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } });
38
+ offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } }, {});
41
39
  }
42
40
  else {
43
41
  offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
@@ -45,36 +43,12 @@ function syncOfferCatalog(params) {
45
43
  const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
46
44
  switch (itemListElementTypeOf) {
47
45
  case factory.offerType.Offer:
48
- // 集計オファーIDリストを検索
49
- let aggregateOfferIds;
50
- if (params.isOfferCatalogItem) {
51
- const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
52
- id: offerCatalogId,
53
- project: { id: params.project.id }
54
- });
55
- aggregateOfferIds = itemListElement.map((element) => element.id);
56
- }
57
- else {
58
- const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
59
- id: offerCatalogId,
60
- project: { id: params.project.id }
61
- });
62
- aggregateOfferIds = itemListElement.map((element) => element.id);
63
- }
64
- // カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
65
- yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
66
- includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
67
- } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
68
- if (aggregateOfferIds.length > 0) {
69
- // 新しいカタログに含まれる全集計オファーにカタログを追加
70
- yield repos.aggregateOffer.pushIncludedInDataCatalog({
71
- project: { id: params.project.id },
72
- id: { $in: aggregateOfferIds },
73
- $push: {
74
- includedInDataCatalog: { $each: [{ id: offerCatalogId }] }
75
- }
76
- });
77
- }
46
+ // includedInDataCatalogを単価オファーへ同期
47
+ yield syncOfferCatalogOfOffer2offer({
48
+ id: offerCatalogId,
49
+ project: { id: params.project.id },
50
+ isOfferCatalogItem: params.isOfferCatalogItem
51
+ })(repos);
78
52
  // 同期済記録を補完
79
53
  if (params.isOfferCatalogItem) {
80
54
  yield repos.offerCatalogItem.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
@@ -83,6 +57,10 @@ function syncOfferCatalog(params) {
83
57
  yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
84
58
  }
85
59
  break;
60
+ case 'OfferCatalog':
61
+ // 特に何もしない
62
+ yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
63
+ break;
86
64
  default:
87
65
  // no op
88
66
  }
@@ -91,3 +69,37 @@ function syncOfferCatalog(params) {
91
69
  });
92
70
  }
93
71
  exports.syncOfferCatalog = syncOfferCatalog;
72
+ function syncOfferCatalogOfOffer2offer(params) {
73
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
74
+ // 集計オファーIDリストを検索
75
+ let aggregateOfferIds;
76
+ if (params.isOfferCatalogItem) {
77
+ const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
78
+ id: params.id,
79
+ project: { id: params.project.id }
80
+ });
81
+ aggregateOfferIds = itemListElement.map((element) => element.id);
82
+ }
83
+ else {
84
+ const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
85
+ id: params.id,
86
+ project: { id: params.project.id }
87
+ });
88
+ aggregateOfferIds = itemListElement.map((element) => element.id);
89
+ }
90
+ // カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
91
+ yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
92
+ includedInDataCatalog: { $elemMatch: { id: { $eq: params.id } } }
93
+ } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
94
+ if (aggregateOfferIds.length > 0) {
95
+ // 新しいカタログに含まれる全集計オファーにカタログを追加
96
+ yield repos.aggregateOffer.pushIncludedInDataCatalog({
97
+ project: { id: params.project.id },
98
+ id: { $in: aggregateOfferIds },
99
+ $push: {
100
+ includedInDataCatalog: { $each: [{ id: params.id }] }
101
+ }
102
+ });
103
+ }
104
+ });
105
+ }
@@ -26,8 +26,8 @@ const place_1 = require("../../repo/place");
26
26
  const product_1 = require("../../repo/product");
27
27
  const productOffer_1 = require("../../repo/productOffer");
28
28
  const task_1 = require("../../repo/task");
29
+ const onOfferCatalogUpdated_1 = require("./onResourceUpdated/onOfferCatalogUpdated");
29
30
  const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
30
- const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
31
31
  const settings_1 = require("../../settings");
32
32
  const informResources = settings_1.settings.onResourceUpdated.informResource;
33
33
  /**
@@ -114,7 +114,7 @@ function onResourceUpdated(params) {
114
114
  break;
115
115
  // カタログに対応(2023-09-12~)
116
116
  case 'OfferCatalog':
117
- yield (0, syncOfferCatalog_1.syncOfferCatalog)({
117
+ yield (0, onOfferCatalogUpdated_1.onOfferCatalogUpdated)({
118
118
  project: { id: params.project.id },
119
119
  ids: params.id,
120
120
  typeOf: params.typeOf,
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.330.0-alpha.1",
13
- "@cinerino/sdk": "3.167.0-alpha.9",
12
+ "@chevre/factory": "4.330.0",
13
+ "@cinerino/sdk": "3.169.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.9.0-alpha.8"
120
+ "version": "21.9.0"
121
121
  }