@chevre/domain 22.14.0-alpha.9 → 23.0.0-alpha.1

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 (87) hide show
  1. package/example/src/chevre/{createEventBySchedule.ts → addEventBySchedule.ts} +2 -2
  2. package/example/src/chevre/aggregateEventPublicFields.ts +1 -1
  3. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +2 -2
  4. package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
  5. package/example/src/chevre/checkEventDuration.ts +1 -1
  6. package/example/src/chevre/findAnyEventById.ts +1 -1
  7. package/example/src/chevre/findReservationByCode.ts +0 -1
  8. package/example/src/chevre/productOffer/publishMemberTierToken.ts +92 -0
  9. package/example/src/chevre/reIndex.ts +3 -1
  10. package/example/src/chevre/roles/addAdminProductOfferPermissionIfNotExists.ts +48 -0
  11. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -2
  12. package/example/src/chevre/updateEventPartiallyById.ts +1 -1
  13. package/lib/chevre/factory/event.d.ts +2 -4
  14. package/lib/chevre/repo/accountingReport.d.ts +4 -4
  15. package/lib/chevre/repo/accountingReport.js +1 -1
  16. package/lib/chevre/repo/action.d.ts +1 -1
  17. package/lib/chevre/repo/aggregateReservation.d.ts +2 -2
  18. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  19. package/lib/chevre/repo/creativeWork.js +65 -47
  20. package/lib/chevre/repo/event.d.ts +47 -51
  21. package/lib/chevre/repo/event.js +13 -112
  22. package/lib/chevre/repo/eventSeries.d.ts +14 -14
  23. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +2 -15
  24. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +1 -1
  25. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -6
  26. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +1 -1
  27. package/lib/chevre/repo/mongoose/schemas/place.js +13 -14
  28. package/lib/chevre/repo/mongoose/schemas/product.js +14 -4
  29. package/lib/chevre/repo/mongoose/schemas/{offer/event.d.ts → productOffer.d.ts} +6 -3
  30. package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +26 -29
  31. package/lib/chevre/repo/mongoose/schemas/seller.js +17 -6
  32. package/lib/chevre/repo/productOffer.d.ts +36 -61
  33. package/lib/chevre/repo/productOffer.js +163 -157
  34. package/lib/chevre/repository.d.ts +0 -5
  35. package/lib/chevre/repository.js +2 -15
  36. package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +1 -1
  37. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -6
  38. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -19
  39. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +1 -3
  40. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +1 -1
  41. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +1 -1
  42. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +1 -6
  43. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
  44. package/lib/chevre/service/assetTransaction/reserve/start.js +4 -4
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +3 -3
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +57 -32
  47. package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
  48. package/lib/chevre/service/offer/event/authorize/factory.js +2 -2
  49. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -4
  50. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  51. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  52. package/lib/chevre/service/offer/event/authorize.js +2 -2
  53. package/lib/chevre/service/offer/event/checkAvailability.d.ts +1 -1
  54. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -1
  55. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
  56. package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +1 -1
  57. package/lib/chevre/service/offer/event/searchOffersByIds.js +1 -1
  58. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
  59. package/lib/chevre/service/offer/onEventChanged.js +2 -19
  60. package/lib/chevre/service/offer/product.d.ts +0 -3
  61. package/lib/chevre/service/offer/product.js +29 -38
  62. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +0 -1
  63. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  64. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
  65. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -2
  66. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
  67. package/lib/chevre/service/reserve/useReservation.js +2 -3
  68. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -2
  69. package/lib/chevre/service/task/checkResource.d.ts +2 -2
  70. package/lib/chevre/service/task/checkResource.js +8 -6
  71. package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
  72. package/lib/chevre/service/task/createAccountingReport.js +15 -15
  73. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  74. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
  75. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -1
  76. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
  77. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -6
  78. package/lib/chevre/service/task/useReservation.js +1 -2
  79. package/lib/chevre/service/taskHandler.js +2 -0
  80. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -1
  81. package/lib/chevre/service/validation/validateEvent.js +1 -1
  82. package/package.json +3 -3
  83. package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
  84. package/example/src/chevre/roles/addPermissionIfNotExists.ts +0 -48
  85. package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
  86. package/lib/chevre/repo/offer/event.d.ts +0 -38
  87. package/lib/chevre/repo/offer/event.js +0 -142
@@ -10,189 +10,195 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProductOfferRepo = void 0;
13
- const mongoose_1 = require("mongoose");
14
- const product_1 = require("./mongoose/schemas/product");
15
13
  const factory = require("../factory");
16
14
  const settings_1 = require("../settings");
15
+ const productOffer_1 = require("./mongoose/schemas/productOffer");
16
+ const AVAILABLE_PROJECT_FIELDS = [
17
+ 'identifier',
18
+ 'project',
19
+ 'itemOffered',
20
+ 'offeredBy',
21
+ 'typeOf',
22
+ 'validFrom',
23
+ 'validThrough',
24
+ 'availability',
25
+ 'acceptedPaymentMethod',
26
+ 'validForMemberTier'
27
+ ];
17
28
  /**
18
29
  * プロダクトオファーリポジトリ
19
30
  */
20
31
  class ProductOfferRepo {
21
32
  constructor(connection) {
22
- this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
33
+ this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
23
34
  }
24
- /**
25
- * プロダクトオファー検索
26
- */
27
- search(params) {
35
+ static CREATE_MONGO_CONDITIONS(params) {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
37
+ const andConditions = [];
38
+ const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
39
+ if (typeof idEq === 'string') {
40
+ andConditions.push({ _id: { $eq: idEq } });
41
+ }
42
+ const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
43
+ if (typeof projectIdEq === 'string') {
44
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
45
+ }
46
+ const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
47
+ if (typeof identifierEq === 'string') {
48
+ andConditions.push({ identifier: { $eq: identifierEq } });
49
+ }
50
+ const identifierIn = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$in;
51
+ if (Array.isArray(identifierIn)) {
52
+ andConditions.push({ identifier: { $in: identifierIn } });
53
+ }
54
+ const itemOfferedIdentifierEq = (_g = (_f = params.itemOffered) === null || _f === void 0 ? void 0 : _f.identifier) === null || _g === void 0 ? void 0 : _g.$eq;
55
+ if (typeof itemOfferedIdentifierEq === 'string') {
56
+ andConditions.push({ 'itemOffered.identifier': { $eq: itemOfferedIdentifierEq } });
57
+ }
58
+ const itemOfferedIdentifierIn = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.identifier) === null || _j === void 0 ? void 0 : _j.$in;
59
+ if (Array.isArray(itemOfferedIdentifierIn)) {
60
+ andConditions.push({ 'itemOffered.identifier': { $in: itemOfferedIdentifierIn } });
61
+ }
62
+ const offeredByIdEq = (_l = (_k = params.offeredBy) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
63
+ if (typeof offeredByIdEq === 'string') {
64
+ andConditions.push({ 'offeredBy.id': { $eq: offeredByIdEq } });
65
+ }
66
+ const sellerByIdEq = (_o = (_m = params.seller) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
67
+ if (typeof sellerByIdEq === 'string') {
68
+ andConditions.push({ 'offeredBy.id': { $eq: sellerByIdEq } });
69
+ }
70
+ const validForMemberTierIdentifierEq = (_q = (_p = params.validForMemberTier) === null || _p === void 0 ? void 0 : _p.identifier) === null || _q === void 0 ? void 0 : _q.$eq;
71
+ if (typeof validForMemberTierIdentifierEq === 'string') {
72
+ andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
73
+ }
74
+ const validFromLte = (_r = params.validFrom) === null || _r === void 0 ? void 0 : _r.$lte;
75
+ if (validFromLte instanceof Date) {
76
+ andConditions.push({ validFrom: { $lte: validFromLte } });
77
+ }
78
+ const validThroughGte = (_s = params.validThrough) === null || _s === void 0 ? void 0 : _s.$gte;
79
+ if (validThroughGte instanceof Date) {
80
+ andConditions.push({ validThrough: { $gte: validThroughGte } });
81
+ }
82
+ return andConditions;
83
+ }
84
+ findProductOffers(params, inclusion) {
28
85
  return __awaiter(this, void 0, void 0, function* () {
29
- var _a, _b, _c, _d, _e, _f;
30
- const matchStages = [{
31
- $match: {
32
- typeOf: {
33
- $in: [
34
- factory.product.ProductType.MembershipService,
35
- factory.product.ProductType.PaymentCard
36
- ]
37
- }
38
- }
39
- }];
40
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
41
- if (typeof projectIdEq === 'string') {
42
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
86
+ var _a;
87
+ const conditions = ProductOfferRepo.CREATE_MONGO_CONDITIONS(params);
88
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
89
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
90
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
43
91
  }
44
- const itemOfferedIdEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
45
- if (typeof itemOfferedIdEq === 'string') {
46
- matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(itemOfferedIdEq) } } });
92
+ else {
93
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
47
94
  }
48
- const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
49
- if (typeof sellerIdEq === 'string') {
50
- matchStages.push({ $match: { 'offers.seller.id': { $exists: true, $eq: sellerIdEq } } });
95
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
96
+ const query = this.productOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
97
+ if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
98
+ query.sort({ validFrom: params.sort.validFrom });
51
99
  }
52
- const aggregate = this.productModel.aggregate([
53
- { $sort: { productID: factory.sortType.Ascending } },
54
- {
55
- $unwind: {
56
- path: '$offers'
57
- }
58
- },
59
- ...matchStages,
60
- {
61
- $project: {
62
- _id: 0,
63
- itemOffered: {
64
- id: { $toString: '$_id' },
65
- name: '$name',
66
- typeOf: '$typeOf'
67
- },
68
- availabilityEnds: '$offers.availabilityEnds',
69
- availabilityStarts: '$offers.availabilityStarts',
70
- validFrom: '$offers.validFrom',
71
- validThrough: '$offers.validThrough',
72
- seller: '$offers.seller'
73
- }
74
- }
75
- ]);
76
100
  if (typeof params.limit === 'number' && params.limit > 0) {
77
101
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
78
- aggregate.limit(params.limit * page)
102
+ query.limit(params.limit)
79
103
  .skip(params.limit * (page - 1));
80
104
  }
81
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
82
- .exec();
83
- });
84
- }
85
- create(params) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- var _a;
88
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
89
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
90
- throw new factory.errors.ArgumentNull('seller.id');
91
- }
92
- // プロダクト存在確認
93
- let doc = yield this.productModel.findOne({
94
- 'project.id': { $eq: params.project.id },
95
- _id: { $eq: params.itemOffered.id }
96
- }, { _id: 1 })
97
- .exec();
98
- if (doc === null) {
99
- throw new factory.errors.NotFound('Product');
100
- }
101
- const creatingOffer = {
102
- priceCurrency: factory.priceCurrency.JPY,
103
- availabilityEnds: params.availabilityEnds,
104
- availabilityStarts: params.availabilityStarts,
105
- validFrom: params.validFrom,
106
- validThrough: params.validThrough,
107
- seller: { id: sellerId },
108
- typeOf: factory.offerType.Offer
109
- };
110
- doc = yield this.productModel.findOneAndUpdate({
111
- 'project.id': { $eq: params.project.id },
112
- _id: { $eq: params.itemOffered.id },
113
- 'offers.seller.id': { $ne: sellerId }
114
- }, {
115
- $push: { offers: creatingOffer }
116
- }, {
117
- new: true,
118
- projection: { _id: 1 }
119
- })
120
- .exec();
121
- // 存在しなければプロバイダーID重複
122
- if (doc === null) {
123
- throw new factory.errors.AlreadyInUse('offers.seller', ['id']);
124
- }
125
- return doc.toObject();
126
- });
127
- }
128
- update(params) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- var _a;
131
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
132
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
133
- throw new factory.errors.ArgumentNull('seller.id');
134
- }
135
- const doc = yield this.productModel.findOneAndUpdate({
136
- 'project.id': { $eq: params.project.id },
137
- _id: { $eq: params.itemOffered.id },
138
- 'offers.seller.id': { $exists: true, $eq: sellerId }
139
- }, Object.assign(Object.assign(Object.assign(Object.assign({}, (params.availabilityEnds instanceof Date)
140
- ? { 'offers.$[offerBySeller].availabilityEnds': params.availabilityEnds }
141
- : undefined), (params.availabilityStarts instanceof Date)
142
- ? { 'offers.$[offerBySeller].availabilityStarts': params.availabilityStarts }
143
- : undefined), (params.validFrom instanceof Date)
144
- ? { 'offers.$[offerBySeller].validFrom': params.validFrom }
145
- : undefined), (params.validThrough instanceof Date)
146
- ? { 'offers.$[offerBySeller].validThrough': params.validThrough }
147
- : undefined), {
148
- new: true,
149
- arrayFilters: [
150
- { 'offerBySeller.seller.id': { $eq: sellerId } }
151
- ],
152
- projection: { _id: 1 }
153
- })
105
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
106
+ .lean()
154
107
  .exec();
155
- if (doc === null) {
156
- throw new factory.errors.NotFound('Product');
157
- }
158
- return doc.toObject();
159
108
  });
160
109
  }
161
- deleteOne(params) {
110
+ /**
111
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
112
+ */
113
+ upsertOffersByIdentifier(params, options) {
162
114
  return __awaiter(this, void 0, void 0, function* () {
163
- var _a;
164
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
165
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
166
- throw new factory.errors.ArgumentNull('seller.id');
115
+ const { update } = options;
116
+ const bulkWriteOps = [];
117
+ const queryFilters = [];
118
+ if (Array.isArray(params)) {
119
+ params.forEach(({ $set, $unset }) => {
120
+ const { availability, identifier, itemOffered, offeredBy, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
121
+ if (typeof identifier !== 'string' || identifier === '') {
122
+ throw new factory.errors.ArgumentNull('identifier');
123
+ }
124
+ if (typeof itemOffered.identifier !== 'string' || itemOffered.identifier === '') {
125
+ throw new factory.errors.ArgumentNull('itemOffered.identifier');
126
+ }
127
+ // リソースのユニークネスを保証するfilter
128
+ const filter = {
129
+ 'project.id': { $eq: project.id },
130
+ 'itemOffered.identifier': { $eq: itemOffered.identifier },
131
+ identifier: { $eq: identifier }
132
+ };
133
+ queryFilters.push({
134
+ 'project.id': { $eq: project.id },
135
+ 'itemOffered.identifier': { $eq: itemOffered.identifier },
136
+ identifier: { $eq: identifier }
137
+ });
138
+ if (update === true) {
139
+ const setFields = Object.assign(Object.assign({ availability,
140
+ validFrom,
141
+ validThrough }, (typeof (acceptedPaymentMethod === null || acceptedPaymentMethod === void 0 ? void 0 : acceptedPaymentMethod.typeOf) === 'string') ? { acceptedPaymentMethod } : undefined), (typeof (validForMemberTier === null || validForMemberTier === void 0 ? void 0 : validForMemberTier.typeOf) === 'string') ? { validForMemberTier } : undefined);
142
+ const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
143
+ const updateOne = {
144
+ filter,
145
+ update: updateFilter,
146
+ upsert: false
147
+ };
148
+ bulkWriteOps.push({ updateOne });
149
+ }
150
+ else {
151
+ const setOnInsert = Object.assign(Object.assign({ itemOffered, offeredBy, identifier, project, typeOf: factory.offerType.Offer, availability,
152
+ validFrom,
153
+ validThrough }, (typeof (acceptedPaymentMethod === null || acceptedPaymentMethod === void 0 ? void 0 : acceptedPaymentMethod.typeOf) === 'string') ? { acceptedPaymentMethod } : undefined), (typeof (validForMemberTier === null || validForMemberTier === void 0 ? void 0 : validForMemberTier.typeOf) === 'string') ? { validForMemberTier } : undefined);
154
+ const updateFilter = {
155
+ $setOnInsert: setOnInsert
156
+ };
157
+ const updateOne = {
158
+ filter,
159
+ update: updateFilter,
160
+ upsert: true
161
+ };
162
+ bulkWriteOps.push({ updateOne });
163
+ }
164
+ });
167
165
  }
168
- const doc = yield this.productModel.findOneAndUpdate({
169
- 'project.id': { $eq: params.project.id },
170
- _id: { $eq: params.itemOffered.id },
171
- 'offers.seller.id': { $exists: true, $eq: sellerId }
172
- }, {
173
- $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
174
- }, {
175
- projection: { _id: 1 }
176
- })
177
- .exec();
178
- if (doc === null) {
179
- throw new factory.errors.NotFound('Product');
166
+ if (bulkWriteOps.length > 0) {
167
+ const bulkWriteResult = yield this.productOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
168
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
169
+ const modifiedProductOffers = yield this.productOfferModel.find({ $or: queryFilters }, {
170
+ _id: 0,
171
+ id: { $toString: '$_id' }
172
+ })
173
+ .lean()
174
+ .exec();
175
+ return { bulkWriteResult, modifiedProductOffers };
180
176
  }
181
- return doc.toObject();
182
177
  });
183
178
  }
184
- deleteManyBySellerId(params) {
179
+ // public async deleteProductOffersByIds(params: {
180
+ // project: { id: string };
181
+ // ids: string[];
182
+ // }): Promise<DeleteResult | void> {
183
+ // const { project, ids } = params;
184
+ // if (Array.isArray(ids) && ids.length > 0) {
185
+ // return this.productOfferModel.deleteMany(
186
+ // {
187
+ // 'project.id': { $eq: project.id },
188
+ // _id: { $in: ids }
189
+ // }
190
+ // )
191
+ // .exec();
192
+ // }
193
+ // }
194
+ /**
195
+ * 販売者の提供するプロダクトオファーを削除する
196
+ */
197
+ deleteProductOffersBySeller(params) {
185
198
  return __awaiter(this, void 0, void 0, function* () {
186
- var _a;
187
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
188
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
189
- throw new factory.errors.ArgumentNull('seller.id');
190
- }
191
- return this.productModel.updateMany({
199
+ return this.productOfferModel.deleteMany({
192
200
  'project.id': { $eq: params.project.id },
193
- 'offers.seller.id': { $exists: true, $eq: sellerId }
194
- }, {
195
- $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
201
+ 'offeredBy.id': { $eq: params.offeredBy.id }
196
202
  })
197
203
  .exec();
198
204
  });
@@ -34,7 +34,6 @@ import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
34
34
  import type { MessageRepo } from './repo/message';
35
35
  import type { NoteRepo } from './repo/note';
36
36
  import type { NoteAboutOrderRepo } from './repo/noteAboutOrder';
37
- import type { EventOfferRepo } from './repo/offer/event';
38
37
  import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
39
38
  import type { OfferCatalogRepo } from './repo/offerCatalog';
40
39
  import type { OfferCatalogItemRepo } from './repo/offerCatalogItem';
@@ -180,10 +179,6 @@ export type Event = EventRepo;
180
179
  export declare namespace Event {
181
180
  function createInstance(...params: ConstructorParameters<typeof EventRepo>): Promise<EventRepo>;
182
181
  }
183
- export type EventOffer = EventOfferRepo;
184
- export declare namespace EventOffer {
185
- function createInstance(...params: ConstructorParameters<typeof EventOfferRepo>): Promise<EventOfferRepo>;
186
- }
187
182
  export type EventSellerMakesOffer = EventSellerMakesOfferRepo;
188
183
  export declare namespace EventSellerMakesOffer {
189
184
  function createInstance(...params: ConstructorParameters<typeof EventSellerMakesOfferRepo>): Promise<EventSellerMakesOfferRepo>;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = void 0;
12
+ exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
+ exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -310,19 +310,6 @@ var Event;
310
310
  }
311
311
  Event.createInstance = createInstance;
312
312
  })(Event || (exports.Event = Event = {}));
313
- var EventOffer;
314
- (function (EventOffer) {
315
- let repo;
316
- function createInstance(...params) {
317
- return __awaiter(this, void 0, void 0, function* () {
318
- if (repo === undefined) {
319
- repo = (yield Promise.resolve().then(() => require('./repo/offer/event'))).EventOfferRepo;
320
- }
321
- return new repo(...params);
322
- });
323
- }
324
- EventOffer.createInstance = createInstance;
325
- })(EventOffer || (exports.EventOffer = EventOffer = {}));
326
313
  var EventSellerMakesOffer;
327
314
  (function (EventSellerMakesOffer) {
328
315
  let repo;
@@ -24,6 +24,6 @@ type IAggregateOffersOperation<T> = (repos: {
24
24
  */
25
25
  declare function aggregateOffers(params: {
26
26
  id: string;
27
- typeOf: factory.eventType.ScreeningEvent | factory.eventType.Event;
27
+ typeOf: factory.eventType.ScreeningEvent;
28
28
  }): IAggregateOffersOperation<void>;
29
29
  export { aggregateOffers };
@@ -43,7 +43,6 @@ function aggregateOffers(params) {
43
43
  }
44
44
  function aggregateOffersByEvent(params) {
45
45
  return (repos) => __awaiter(this, void 0, void 0, function* () {
46
- var _a;
47
46
  const now = new Date();
48
47
  const event = params.event;
49
48
  // 施設取得は冗長なので、ルーム検索に変更(2023-01-30~)
@@ -52,7 +51,7 @@ function aggregateOffersByEvent(params) {
52
51
  movieTheaterId = params.event.superEvent.location.id;
53
52
  }
54
53
  else {
55
- movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
54
+ throw new factory.errors.NotImplemented(`typeOf: ${params.event.typeOf}`);
56
55
  }
57
56
  const screeningRoom = yield repos.screeningRoom.findScreeningRoomsByBranchCode({
58
57
  project: { id: event.project.id },
@@ -123,10 +122,7 @@ function aggregateReservationByOffer(params) {
123
122
  let reservationCount4offer;
124
123
  // let attendeeCount4offer: number | undefined;
125
124
  // let checkInCount4offer: number | undefined;
126
- let reservationType = factory.reservationType.EventReservation;
127
- if (params.event.typeOf === factory.eventType.Event) {
128
- reservationType = factory.reservationType.BusReservation;
129
- }
125
+ const reservationType = factory.reservationType.EventReservation;
130
126
  const offerIdsWithSameCategory = params.availableOffers.filter(({ category }) => {
131
127
  var _a;
132
128
  return typeof (category === null || category === void 0 ? void 0 : category.codeValue) === 'string' && category.codeValue === ((_a = params.offer.category) === null || _a === void 0 ? void 0 : _a.codeValue);
@@ -56,19 +56,7 @@ function aggregateScreeningEvent(params) {
56
56
  .add(1, 'hour')
57
57
  .add(-1, 'second')
58
58
  .toDate();
59
- if (event.typeOf === factory.eventType.Event) {
60
- aggregatingEvents = yield repos.event.projectEventFields({
61
- limit: 100,
62
- page: 1,
63
- project: { id: { $eq: event.project.id } },
64
- typeOf: event.typeOf,
65
- eventStatuses: [factory.eventStatusType.EventScheduled],
66
- startFrom: startFrom,
67
- startThrough: startThrough,
68
- location: { branchCode: { $eq: event.location.branchCode } }
69
- }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
70
- }
71
- else if (event.typeOf === factory.eventType.ScreeningEvent) {
59
+ if (event.typeOf === factory.eventType.ScreeningEvent) {
72
60
  aggregatingEvents = yield repos.event.projectEventFields({
73
61
  limit: 100,
74
62
  page: 1,
@@ -95,7 +83,6 @@ function aggregateByEvent(params, options) {
95
83
  return (repos
96
84
  // settings: Settings
97
85
  ) => __awaiter(this, void 0, void 0, function* () {
98
- var _a;
99
86
  const now = new Date();
100
87
  const event = params.event;
101
88
  // 施設取得は冗長なので、ルーム検索に変更(2023-01-30~)
@@ -104,7 +91,7 @@ function aggregateByEvent(params, options) {
104
91
  movieTheaterId = params.event.superEvent.location.id;
105
92
  }
106
93
  else {
107
- movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
94
+ throw new factory.errors.NotImplemented(`typeOf: ${params.event.typeOf}`);
108
95
  }
109
96
  const screeningRoom = yield repos.screeningRoom.findScreeningRoomsByBranchCode({
110
97
  project: { id: event.project.id },
@@ -224,10 +211,7 @@ function aggregateReservationByEvent(params) {
224
211
  let attendeeCount;
225
212
  let checkInCount;
226
213
  let reservationCount;
227
- let reservationType = factory.reservationType.EventReservation;
228
- if (params.event.typeOf === factory.eventType.Event) {
229
- reservationType = factory.reservationType.BusReservation;
230
- }
214
+ const reservationType = factory.reservationType.EventReservation;
231
215
  reservationCount = yield repos.reservation.count({
232
216
  typeOf: reservationType,
233
217
  reservationFor: { id: { $eq: params.event.id } },
@@ -5,14 +5,13 @@ import type { OfferRepo } from '../../../../repo/offer/unitPriceInCatalog';
5
5
  import type { OfferCatalogRepo } from '../../../../repo/offerCatalog';
6
6
  import type { PaymentServiceRepo } from '../../../../repo/paymentService';
7
7
  import type { ProductRepo } from '../../../../repo/product';
8
- import type { ProductOfferRepo } from '../../../../repo/productOffer';
9
8
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
10
9
  declare function createSubReservations(params: {
11
10
  acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
12
11
  ticketOffers: factory.product.ITicketOffer[];
13
12
  availableOffers: factory.unitPriceOffer.IUnitPriceOffer[];
14
13
  now: Date;
15
- event: IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>;
14
+ event: IMinimizedIndividualEvent;
16
15
  availableSeatOffers: factory.place.seat.IPlaceWithOffer[];
17
16
  reservationNumber: string;
18
17
  availableAtOrFrom?: {
@@ -25,6 +24,5 @@ declare function createSubReservations(params: {
25
24
  offerCatalog: OfferCatalogRepo;
26
25
  paymentService: PaymentServiceRepo;
27
26
  product: ProductRepo;
28
- productOffer: ProductOfferRepo;
29
27
  }) => Promise<IObjectSubReservation[]>;
30
28
  export { createSubReservations };
@@ -42,7 +42,7 @@ declare function createReservation(params: {
42
42
  typeOf: factory.organizationType.Project;
43
43
  };
44
44
  id: string;
45
- reservationFor: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent> | IMinimizedIndividualEvent<factory.eventType.Event>;
45
+ reservationFor: IMinimizedIndividualEvent;
46
46
  reservedTicket: IReservedTicket;
47
47
  additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
48
48
  additionalTicketText?: string;
@@ -13,7 +13,7 @@ declare function createStartParams(params: factory.assetTransaction.reserve.ISta
13
13
  id: string;
14
14
  };
15
15
  reservationNumber: string;
16
- event: IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>;
16
+ event: IMinimizedIndividualEvent;
17
17
  acceptedOffers4transactionObject: factory.assetTransaction.reserve.IAcceptedOffer4object[];
18
18
  objectSubReservations: IObjectSubReservation[];
19
19
  instrument: factory.assetTransaction.reserve.IInstrument[];
@@ -25,18 +25,13 @@ function createStartParams(params) {
25
25
  };
26
26
  }
27
27
  function createReservationFor(params, useOptimizeReservation) {
28
- var _a, _b;
29
28
  if (params.typeOf === factory.eventType.ScreeningEvent) {
30
29
  return Object.assign({ endDate: params.endDate, id: params.id, location: params.location, name: params.name, startDate: params.startDate, superEvent: optimizeReservationSuperEvent(params, useOptimizeReservation), typeOf: params.typeOf }, (params.doorTime instanceof Date)
31
30
  ? { doorTime: params.doorTime }
32
31
  : undefined);
33
32
  }
34
33
  else {
35
- const tripByEvent = (_b = (_a = params.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservationFor;
36
- if (typeof (tripByEvent === null || tripByEvent === void 0 ? void 0 : tripByEvent.typeOf) !== 'string') {
37
- throw new factory.errors.NotFound('event.offers.itemOffered.serviceOutput?.reservationFor');
38
- }
39
- return Object.assign(Object.assign({}, tripByEvent), { arrivalTime: params.endDate, id: params.id, name: params.name, departureTime: params.startDate });
34
+ throw new factory.errors.NotImplemented(`typeOf: ${params.typeOf}`);
40
35
  }
41
36
  }
42
37
  function optimizeReservationSuperEvent(params, useOptimizeReservation) {
@@ -6,7 +6,6 @@ import type { EventRepo } from '../../../repo/event';
6
6
  import type { EventSeriesRepo } from '../../../repo/eventSeries';
7
7
  import type { IssuerRepo } from '../../../repo/issuer';
8
8
  import type { MemberProgramRepo } from '../../../repo/memberProgram';
9
- import type { EventOfferRepo } from '../../../repo/offer/event';
10
9
  import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
11
10
  import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
12
11
  import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
@@ -24,7 +23,6 @@ interface IStartOperationRepos {
24
23
  advanceBookingRequirement: AdvanceBookingRequirementRepo;
25
24
  stockHolder: StockHolderRepo;
26
25
  event: EventRepo;
27
- eventOffer: EventOfferRepo;
28
26
  eventSeries: EventSeriesRepo;
29
27
  issuer: IssuerRepo;
30
28
  memberProgram: MemberProgramRepo;
@@ -47,9 +47,9 @@ function start(params, options) {
47
47
  now,
48
48
  store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id }
49
49
  })({
50
- eventOffer: repos.eventOffer,
51
50
  issuer: repos.issuer,
52
- memberProgram: repos.memberProgram
51
+ memberProgram: repos.memberProgram,
52
+ productOffer: repos.productOffer
53
53
  });
54
54
  // objectに必要な情報をそろえる
55
55
  const { acceptedOffers4transactionObject, objectSubReservations } = yield createObjectAttributes({
@@ -117,10 +117,10 @@ function createObjectAttributes(params, options) {
117
117
  const { event, now } = params;
118
118
  const reservationNumber = params.transaction.transactionNumber;
119
119
  const acceptedOffers = (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer : [];
120
- if (event.typeOf !== factory.eventType.ScreeningEvent && event.typeOf !== factory.eventType.Event) {
120
+ if (event.typeOf !== factory.eventType.ScreeningEvent) {
121
121
  throw new factory.errors.Argument('object.reservationFor.id', `invalid event type ${event.typeOf}`);
122
122
  }
123
- if (event.typeOf === factory.eventType.ScreeningEvent || event.typeOf === factory.eventType.Event) {
123
+ if (event.typeOf === factory.eventType.ScreeningEvent) {
124
124
  validateEvent({ now, event }, options);
125
125
  }
126
126
  // 受け入れたオファーIDだけ取得する(2023-01-26~)
@@ -2,10 +2,10 @@ import * as factory from '../../../factory';
2
2
  import { IMinimizedIndividualEvent } from '../../../factory/event';
3
3
  import type { IssuerRepo } from '../../../repo/issuer';
4
4
  import type { MemberProgramRepo } from '../../../repo/memberProgram';
5
- import type { EventOfferRepo } from '../../../repo/offer/event';
5
+ import type { ProductOfferRepo } from '../../../repo/productOffer';
6
6
  declare function validateStartRequest(params: {
7
7
  object: factory.assetTransaction.reserve.IObjectWithoutDetail;
8
- event: Pick<IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>, 'offers' | 'id' | 'project'>;
8
+ event: Pick<IMinimizedIndividualEvent, 'offers' | 'id' | 'project'>;
9
9
  validateEventOfferPeriod?: boolean;
10
10
  validateEvent?: boolean;
11
11
  now: Date;
@@ -16,8 +16,8 @@ declare function validateStartRequest(params: {
16
16
  id?: string;
17
17
  };
18
18
  }): (repos: {
19
- eventOffer: EventOfferRepo;
20
19
  issuer: IssuerRepo;
21
20
  memberProgram: MemberProgramRepo;
21
+ productOffer: ProductOfferRepo;
22
22
  }) => Promise<void>;
23
23
  export { validateStartRequest };