@chevre/domain 22.14.0-alpha.17 → 22.14.0-alpha.3

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 (56) hide show
  1. package/example/src/chevre/{addEventBySchedule.ts → createEventBySchedule.ts} +2 -2
  2. package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
  3. package/example/src/chevre/findReservationByCode.ts +1 -0
  4. package/example/src/chevre/migrateDeleteTransactionTasks.ts +132 -0
  5. package/example/src/chevre/optimizeDeleteTransactionTasks.ts +119 -0
  6. package/example/src/chevre/upsertMoviesByIdentifier.ts +58 -0
  7. package/lib/chevre/repo/accountingReport.d.ts +4 -4
  8. package/lib/chevre/repo/accountingReport.js +1 -1
  9. package/lib/chevre/repo/action.d.ts +1 -1
  10. package/lib/chevre/repo/creativeWork.d.ts +3 -1
  11. package/lib/chevre/repo/creativeWork.js +47 -65
  12. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +15 -2
  13. package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +10 -0
  14. package/lib/chevre/repo/mongoose/schemas/{productOffer.js → offer/event.js} +53 -9
  15. package/lib/chevre/repo/offer/event.d.ts +38 -0
  16. package/lib/chevre/repo/offer/event.js +142 -0
  17. package/lib/chevre/repo/productOffer.d.ts +65 -60
  18. package/lib/chevre/repo/productOffer.js +163 -121
  19. package/lib/chevre/repo/task.js +2 -2
  20. package/lib/chevre/repository.d.ts +5 -0
  21. package/lib/chevre/repository.js +15 -2
  22. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +2 -0
  23. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
  24. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  25. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -2
  26. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +53 -68
  27. package/lib/chevre/service/event.js +2 -10
  28. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
  29. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  30. package/lib/chevre/service/offer/product.d.ts +3 -0
  31. package/lib/chevre/service/offer/product.js +38 -29
  32. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -0
  33. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  34. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
  35. package/lib/chevre/service/reserve/useReservation.js +3 -2
  36. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +2 -0
  37. package/lib/chevre/service/task/checkResource.d.ts +2 -2
  38. package/lib/chevre/service/task/checkResource.js +6 -8
  39. package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
  40. package/lib/chevre/service/task/createAccountingReport.js +15 -15
  41. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
  42. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -3
  43. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
  44. package/lib/chevre/service/task/deletePerson.js +10 -11
  45. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  46. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +5 -7
  47. package/lib/chevre/service/task/onResourceUpdated.js +2 -1
  48. package/lib/chevre/service/task/useReservation.js +2 -1
  49. package/lib/chevre/service/taskHandler.js +0 -2
  50. package/lib/chevre/service/transaction/deleteTransaction.js +9 -9
  51. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -1
  52. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -1
  53. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -1
  54. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +1 -0
  55. package/package.json +2 -2
  56. package/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +0 -36
@@ -10,149 +10,191 @@ 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");
13
15
  const factory = require("../factory");
14
16
  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
- 'typeOf',
21
- 'validFrom',
22
- 'validThrough',
23
- 'availability',
24
- 'acceptedPaymentMethod',
25
- 'validForMemberTier'
26
- ];
27
17
  /**
28
18
  * プロダクトオファーリポジトリ
29
19
  */
30
20
  class ProductOfferRepo {
31
21
  constructor(connection) {
32
- this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
22
+ this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
33
23
  }
34
- static CREATE_MONGO_CONDITIONS(params) {
35
- var _a, _b, _c, _d, _e, _f, _g, _h;
36
- const andConditions = [];
37
- // const idIn = params.id?.$in;
38
- // if (Array.isArray(idIn)) {
39
- // andConditions.push({ _id: { $in: idIn } });
40
- // }
41
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
42
- if (typeof projectIdEq === 'string') {
43
- andConditions.push({ 'project.id': { $eq: projectIdEq } });
44
- }
45
- const itemOfferedIdentifierEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
46
- if (typeof itemOfferedIdentifierEq === 'string') {
47
- andConditions.push({ 'itemOffered.identifier': { $eq: itemOfferedIdentifierEq } });
48
- }
49
- const validForMemberTierIdentifierEq = (_f = (_e = params.validForMemberTier) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$eq;
50
- if (typeof validForMemberTierIdentifierEq === 'string') {
51
- andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
52
- }
53
- const validFromLte = (_g = params.validFrom) === null || _g === void 0 ? void 0 : _g.$lte;
54
- if (validFromLte instanceof Date) {
55
- andConditions.push({ validFrom: { $lte: validFromLte } });
56
- }
57
- const validThroughGte = (_h = params.validThrough) === null || _h === void 0 ? void 0 : _h.$gte;
58
- if (validThroughGte instanceof Date) {
59
- andConditions.push({ validThrough: { $gte: validThroughGte } });
60
- }
61
- return andConditions;
62
- }
63
- findProductOffers(params, inclusion) {
24
+ /**
25
+ * プロダクトオファー検索
26
+ */
27
+ search(params) {
64
28
  return __awaiter(this, void 0, void 0, function* () {
65
- var _a;
66
- const conditions = ProductOfferRepo.CREATE_MONGO_CONDITIONS(params);
67
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
68
- if (Array.isArray(inclusion) && inclusion.length > 0) {
69
- positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
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 } } });
70
43
  }
71
- else {
72
- throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
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) } } });
73
47
  }
74
- const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
75
- const query = this.productOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
76
- if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
77
- query.sort({ validFrom: params.sort.validFrom });
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 } } });
78
51
  }
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
+ ]);
79
76
  if (typeof params.limit === 'number' && params.limit > 0) {
80
77
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
81
- query.limit(params.limit)
78
+ aggregate.limit(params.limit * page)
82
79
  .skip(params.limit * (page - 1));
83
80
  }
84
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
85
- .lean()
81
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
86
82
  .exec();
87
83
  });
88
84
  }
89
- /**
90
- * オファーコードとオファーコレクションコードをキーにして冪等置換
91
- */
92
- upsertOffersByIdentifier(params, options) {
85
+ create(params) {
93
86
  return __awaiter(this, void 0, void 0, function* () {
94
- const { update } = options;
95
- const bulkWriteOps = [];
96
- const queryFilters = [];
97
- if (Array.isArray(params)) {
98
- params.forEach(({ $set, $unset }) => {
99
- const { availability, identifier, itemOffered, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
100
- if (typeof identifier !== 'string' || identifier === '') {
101
- throw new factory.errors.ArgumentNull('identifier');
102
- }
103
- if (typeof itemOffered.identifier !== 'string' || itemOffered.identifier === '') {
104
- throw new factory.errors.ArgumentNull('itemOffered.identifier');
105
- }
106
- // リソースのユニークネスを保証するfilter
107
- const filter = {
108
- 'project.id': { $eq: project.id },
109
- 'itemOffered.identifier': { $eq: itemOffered.identifier },
110
- identifier: { $eq: identifier }
111
- };
112
- queryFilters.push({
113
- 'project.id': { $eq: project.id },
114
- 'itemOffered.identifier': { $eq: itemOffered.identifier },
115
- identifier: { $eq: identifier }
116
- });
117
- if (update === true) {
118
- const setFields = Object.assign(Object.assign({ availability,
119
- validFrom,
120
- 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);
121
- const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
122
- const updateOne = {
123
- filter,
124
- update: updateFilter,
125
- upsert: false
126
- };
127
- bulkWriteOps.push({ updateOne });
128
- }
129
- else {
130
- const setOnInsert = Object.assign(Object.assign({ itemOffered, identifier, project, typeOf: factory.offerType.Offer, availability,
131
- validFrom,
132
- 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);
133
- const updateFilter = {
134
- $setOnInsert: setOnInsert
135
- };
136
- const updateOne = {
137
- filter,
138
- update: updateFilter,
139
- upsert: true
140
- };
141
- bulkWriteOps.push({ updateOne });
142
- }
143
- });
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');
144
91
  }
145
- if (bulkWriteOps.length > 0) {
146
- const bulkWriteResult = yield this.productOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
147
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
148
- const modifiedNotes = yield this.productOfferModel.find({ $or: queryFilters }, {
149
- _id: 0,
150
- id: { $toString: '$_id' }
151
- })
152
- .lean()
153
- .exec();
154
- return { bulkWriteResult, modifiedNotes };
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');
155
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
+ })
154
+ .exec();
155
+ if (doc === null) {
156
+ throw new factory.errors.NotFound('Product');
157
+ }
158
+ return doc.toObject();
159
+ });
160
+ }
161
+ deleteOne(params) {
162
+ 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');
167
+ }
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');
180
+ }
181
+ return doc.toObject();
182
+ });
183
+ }
184
+ deleteManyBySellerId(params) {
185
+ 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({
192
+ 'project.id': { $eq: params.project.id },
193
+ 'offers.seller.id': { $exists: true, $eq: sellerId }
194
+ }, {
195
+ $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
196
+ })
197
+ .exec();
156
198
  });
157
199
  }
158
200
  }
@@ -306,8 +306,8 @@ class TaskRepo {
306
306
  // resolve uniqueness of identifier(2025-03-27~)
307
307
  params, options) {
308
308
  return __awaiter(this, void 0, void 0, function* () {
309
- if (params.data.object.specifyingMethod !== factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id) {
310
- throw new factory.errors.NotImplemented(`only ${factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.Id} implemented`);
309
+ if (params.data.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.Id) {
310
+ throw new factory.errors.NotImplemented(`only ${factory.task.deleteTransaction.SpecifyingMethod.Id} implemented`);
311
311
  }
312
312
  const createdTask = yield this.taskModel.findOneAndUpdate({
313
313
  'project.id': { $eq: params.project.id },
@@ -34,6 +34,7 @@ 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';
37
38
  import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
38
39
  import type { OfferCatalogRepo } from './repo/offerCatalog';
39
40
  import type { OfferCatalogItemRepo } from './repo/offerCatalogItem';
@@ -179,6 +180,10 @@ export type Event = EventRepo;
179
180
  export declare namespace Event {
180
181
  function createInstance(...params: ConstructorParameters<typeof EventRepo>): Promise<EventRepo>;
181
182
  }
183
+ export type EventOffer = EventOfferRepo;
184
+ export declare namespace EventOffer {
185
+ function createInstance(...params: ConstructorParameters<typeof EventOfferRepo>): Promise<EventOfferRepo>;
186
+ }
182
187
  export type EventSellerMakesOffer = EventSellerMakesOfferRepo;
183
188
  export declare namespace EventSellerMakesOffer {
184
189
  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.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;
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;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -310,6 +310,19 @@ 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 = {}));
313
326
  var EventSellerMakesOffer;
314
327
  (function (EventSellerMakesOffer) {
315
328
  let repo;
@@ -5,6 +5,7 @@ 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';
8
9
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
9
10
  declare function createSubReservations(params: {
10
11
  acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
@@ -24,5 +25,6 @@ declare function createSubReservations(params: {
24
25
  offerCatalog: OfferCatalogRepo;
25
26
  paymentService: PaymentServiceRepo;
26
27
  product: ProductRepo;
28
+ productOffer: ProductOfferRepo;
27
29
  }) => Promise<IObjectSubReservation[]>;
28
30
  export { createSubReservations };
@@ -6,6 +6,7 @@ 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';
9
10
  import type { OfferRepo } from '../../../repo/offer/unitPriceInCatalog';
10
11
  import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
11
12
  import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
@@ -23,6 +24,7 @@ interface IStartOperationRepos {
23
24
  advanceBookingRequirement: AdvanceBookingRequirementRepo;
24
25
  stockHolder: StockHolderRepo;
25
26
  event: EventRepo;
27
+ eventOffer: EventOfferRepo;
26
28
  eventSeries: EventSeriesRepo;
27
29
  issuer: IssuerRepo;
28
30
  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,
50
51
  issuer: repos.issuer,
51
- memberProgram: repos.memberProgram,
52
- productOffer: repos.productOffer
52
+ memberProgram: repos.memberProgram
53
53
  });
54
54
  // objectに必要な情報をそろえる
55
55
  const { acceptedOffers4transactionObject, objectSubReservations } = yield createObjectAttributes({
@@ -2,7 +2,7 @@ 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 { ProductOfferRepo } from '../../../repo/productOffer';
5
+ import type { EventOfferRepo } from '../../../repo/offer/event';
6
6
  declare function validateStartRequest(params: {
7
7
  object: factory.assetTransaction.reserve.IObjectWithoutDetail;
8
8
  event: Pick<IMinimizedIndividualEvent<factory.eventType.Event | factory.eventType.ScreeningEvent>, 'offers' | 'id' | 'project'>;
@@ -16,8 +16,8 @@ declare function validateStartRequest(params: {
16
16
  id?: string;
17
17
  };
18
18
  }): (repos: {
19
+ eventOffer: EventOfferRepo;
19
20
  issuer: IssuerRepo;
20
21
  memberProgram: MemberProgramRepo;
21
- productOffer: ProductOfferRepo;
22
22
  }) => Promise<void>;
23
23
  export { validateStartRequest };
@@ -13,6 +13,7 @@ exports.validateStartRequest = validateStartRequest;
13
13
  const jwt = require("jsonwebtoken");
14
14
  const moment = require("moment");
15
15
  const factory = require("../../../factory");
16
+ const ROLE_DATE_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ';
16
17
  function verifyOfferedByToken(params) {
17
18
  return __awaiter(this, void 0, void 0, function* () {
18
19
  let result;
@@ -66,7 +67,7 @@ function validateStartRequest(params) {
66
67
  function validateMemberTier(params) {
67
68
  return (repos) => __awaiter(this, void 0, void 0, function* () {
68
69
  var _a, _b, _c, _d, _e;
69
- const { acceptedDate, event, verifiedValidForMemberTier, memberProgramIdentifierMustBe, aggregateOfferIdentifier } = params;
70
+ const { acceptedDate, event, availableAt, verifiedValidForMemberTier, memberProgramIdentifierMustBe } = params;
70
71
  const tierIdentifier = (_b = (_a = verifiedValidForMemberTier.member) === null || _a === void 0 ? void 0 : _a.memberOf) === null || _b === void 0 ? void 0 : _b.identifier;
71
72
  const memberProgramIdentifier = (_e = (_d = (_c = verifiedValidForMemberTier.member) === null || _c === void 0 ? void 0 : _c.memberOf) === null || _d === void 0 ? void 0 : _d.isTierOf) === null || _e === void 0 ? void 0 : _e.identifier;
72
73
  if (typeof tierIdentifier !== 'string') {
@@ -78,36 +79,28 @@ function validateMemberTier(params) {
78
79
  if (memberProgramIdentifier !== memberProgramIdentifierMustBe) {
79
80
  throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', 'member program not matched');
80
81
  }
81
- // 有効なプロダクトオファーを検証
82
- const productOfferForMemberTier = (yield repos.productOffer.findProductOffers({
82
+ // イベントオファーを検索して有効期間検証
83
+ const eventOfferForMemberTier = (yield repos.eventOffer.projectFields({
83
84
  limit: 1,
84
85
  page: 1,
85
86
  project: { id: { $eq: event.project.id } },
86
- // availableAtOrFrom: { id: { $eq: availableAt.id } },
87
- itemOffered: { identifier: { $eq: aggregateOfferIdentifier } }, // オファーコレクションコード
88
- validForMemberTier: { identifier: { $eq: tierIdentifier } },
89
- validFrom: { $lte: acceptedDate.toDate() },
90
- validThrough: { $gte: acceptedDate.toDate() }
91
- }, ['identifier'])).shift();
92
- if (productOfferForMemberTier === undefined) {
93
- throw new factory.errors.NotFound(factory.offerType.Offer, 'product offer for member tier not found');
87
+ availableAtOrFrom: { id: { $eq: availableAt.id } },
88
+ itemOffered: { id: { $eq: event.id } },
89
+ validForMemberTier: { identifier: { $eq: tierIdentifier } }
90
+ }, ['validFrom', 'validThrough'])).shift();
91
+ if (eventOfferForMemberTier === undefined) {
92
+ throw new factory.errors.NotFound(factory.offerType.Offer, 'event offer for member tier not found');
93
+ }
94
+ let validThroughMoment;
95
+ let validFromMoment;
96
+ validThroughMoment = moment(eventOfferForMemberTier.validThrough, ROLE_DATE_FORMAT, true);
97
+ validFromMoment = moment(eventOfferForMemberTier.validFrom, ROLE_DATE_FORMAT, true);
98
+ if (acceptedDate.isBefore(validFromMoment)) {
99
+ throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', `the offer id valid from ${validFromMoment}`);
100
+ }
101
+ if (acceptedDate.isAfter(validThroughMoment)) {
102
+ throw new factory.errors.Argument('reservationFor.offers.validForMemberTier', `the offer id valid through ${validThroughMoment}`);
94
103
  }
95
- // let validThroughMoment: moment.Moment;
96
- // let validFromMoment: moment.Moment;
97
- // validThroughMoment = moment(productOfferForMemberTier.validThrough, ROLE_DATE_FORMAT, true);
98
- // validFromMoment = moment(productOfferForMemberTier.validFrom, ROLE_DATE_FORMAT, true);
99
- // if (acceptedDate.isBefore(validFromMoment)) {
100
- // throw new factory.errors.Argument(
101
- // 'reservationFor.offers.validForMemberTier',
102
- // `the offer id valid from ${validFromMoment}`
103
- // );
104
- // }
105
- // if (acceptedDate.isAfter(validThroughMoment)) {
106
- // throw new factory.errors.Argument(
107
- // 'reservationFor.offers.validForMemberTier',
108
- // `the offer id valid through ${validThroughMoment}`
109
- // );
110
- // }
111
104
  });
112
105
  }
113
106
  /**
@@ -123,11 +116,11 @@ function validateEventOfferPeriod(params) {
123
116
  const makesOfferOnApplication = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.seller.makesOffer.find((offer) => {
124
117
  var _a, _b;
125
118
  // support non-array(2024-10-11~)
126
- return (Array.isArray(offer.availableAtOrFrom) && ((_a = offer.availableAtOrFrom.at(0)) === null || _a === void 0 ? void 0 : _a.id) === availableAt.id)
127
- || (!Array.isArray(offer.availableAtOrFrom) && ((_b = offer.availableAtOrFrom) === null || _b === void 0 ? void 0 : _b.id) === availableAt.id);
119
+ return (Array.isArray(offer.availableAtOrFrom) && ((_a = offer.availableAtOrFrom.at(0)) === null || _a === void 0 ? void 0 : _a.id) === params.availableAt.id)
120
+ || (!Array.isArray(offer.availableAtOrFrom) && ((_b = offer.availableAtOrFrom) === null || _b === void 0 ? void 0 : _b.id) === params.availableAt.id);
128
121
  });
129
122
  if (makesOfferOnApplication === undefined) {
130
- throw new factory.errors.Argument('reservationFor.id', `seller makes no available offer at ${availableAt.id}`);
123
+ throw new factory.errors.Argument('reservationFor.id', `seller makes no available offer at ${params.availableAt.id}`);
131
124
  }
132
125
  const validFrom = makesOfferOnApplication.validFrom;
133
126
  const validThrough = makesOfferOnApplication.validThrough;
@@ -144,45 +137,37 @@ function validateEventOfferPeriod(params) {
144
137
  }
145
138
  }
146
139
  // support validForMemberTier(2025-05-14~)
147
- if (makesOfferOnApplication.typeOf === factory.offerType.AggregateOffer) {
148
- const memberProgramIdentifierMustBe = (_b = (_a = makesOfferOnApplication.validForMemberTier) === null || _a === void 0 ? void 0 : _a.isTierOf) === null || _b === void 0 ? void 0 : _b.identifier;
149
- if (typeof memberProgramIdentifierMustBe === 'string') {
150
- // 有効メンバープログラムティアが存在する場合、ティアトークンが必須
151
- if (typeof validForMemberTierToken !== 'string' || validForMemberTierToken === '') {
152
- throw new factory.errors.ArgumentNull('reservationFor.offers.validForMemberTier');
153
- }
154
- // 有効メンバープログラムティアが存在する場合、オファーコレクションコードが必須
155
- const aggregateOfferIdentifier = makesOfferOnApplication.identifier;
156
- if (typeof aggregateOfferIdentifier !== 'string' || aggregateOfferIdentifier === '') {
157
- throw new factory.errors.NotFound('makesOfferOnApplication.identifier');
158
- }
159
- // トークン検証
160
- const memberProgram = (yield repos.memberProgram.projectMemberPrograms({
161
- limit: 1,
162
- page: 1,
163
- project: { id: { $eq: params.event.project.id } },
164
- identifier: { $eq: memberProgramIdentifierMustBe }
165
- })).shift();
166
- if (memberProgram === undefined) {
167
- throw new factory.errors.NotFound('MemberProgram');
168
- }
169
- const issuer = yield repos.issuer.findByIdentifier({
170
- project: { id: params.event.project.id },
171
- identifier: memberProgram.hostingOrganization.identifier
172
- });
173
- if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
174
- throw new factory.errors.NotFound('issuer.tokenSecret');
175
- }
176
- const verifiedValidForMemberTier = yield verifyOfferedByToken({
177
- secret: issuer.tokenSecret,
178
- issuer: issuer.url,
179
- token: validForMemberTierToken
180
- });
181
- yield validateMemberTier({
182
- event, acceptedDate, verifiedValidForMemberTier,
183
- memberProgramIdentifierMustBe, aggregateOfferIdentifier
184
- })(repos);
140
+ const memberProgramIdentifierMustBe = (_b = (_a = makesOfferOnApplication.validForMemberTier) === null || _a === void 0 ? void 0 : _a.isTierOf) === null || _b === void 0 ? void 0 : _b.identifier;
141
+ if (typeof memberProgramIdentifierMustBe === 'string') {
142
+ if (typeof validForMemberTierToken !== 'string' || validForMemberTierToken === '') {
143
+ throw new factory.errors.ArgumentNull('reservationFor.offers.validForMemberTier');
185
144
  }
145
+ // トークン検証
146
+ const memberProgram = (yield repos.memberProgram.projectMemberPrograms({
147
+ limit: 1,
148
+ page: 1,
149
+ project: { id: { $eq: params.event.project.id } },
150
+ identifier: { $eq: memberProgramIdentifierMustBe }
151
+ })).shift();
152
+ if (memberProgram === undefined) {
153
+ throw new factory.errors.NotFound('MemberProgram');
154
+ }
155
+ const issuer = yield repos.issuer.findByIdentifier({
156
+ project: { id: params.event.project.id },
157
+ identifier: memberProgram.hostingOrganization.identifier
158
+ });
159
+ if (typeof issuer.tokenSecret !== 'string' || issuer.tokenSecret === '') {
160
+ throw new factory.errors.NotFound('issuer.tokenSecret');
161
+ }
162
+ const verifiedValidForMemberTier = yield verifyOfferedByToken({
163
+ secret: issuer.tokenSecret,
164
+ issuer: issuer.url,
165
+ token: validForMemberTierToken
166
+ });
167
+ yield validateMemberTier({
168
+ event, availableAt, acceptedDate, verifiedValidForMemberTier,
169
+ memberProgramIdentifierMustBe
170
+ })(repos);
186
171
  }
187
172
  });
188
173
  }
@@ -63,8 +63,7 @@ function importFromCOA(params) {
63
63
  object: Object.assign(Object.assign({}, params), { startDate: `${moment(targetImportFrom) // debug(2024-04-26~)
64
64
  .toISOString()}/${moment(targetImportThrough)
65
65
  .toISOString()}`, superEvent: { location: { branchCode: params.locationBranchCode } }, typeOf: factory.eventType.ScreeningEvent }),
66
- instrument,
67
- targetCollection: { typeOf: factory.eventType.ScreeningEvent }
66
+ instrument
68
67
  };
69
68
  const action = yield repos.action.start(actionAttributes);
70
69
  let savedScreeningEventsCount = 0;
@@ -151,8 +150,7 @@ function processUpdateMovieTheater(params) {
151
150
  theaterCode: params.locationBranchCode,
152
151
  typeOf: 'WebAPI',
153
152
  identifier: factory.service.webAPI.Identifier.COA
154
- },
155
- targetCollection: { typeOf: factory.placeType.MovieTheater }
153
+ }
156
154
  };
157
155
  const action = yield repos.action.start(actionAttributes);
158
156
  let seller;
@@ -347,12 +345,6 @@ function createScreeningEvents(params) {
347
345
  // tslint:disable-next-line:max-func-body-length
348
346
  return (repos) => __awaiter(this, void 0, void 0, function* () {
349
347
  const project = params.project;
350
- if (typeof params.instrument.begin !== 'string') {
351
- throw new factory.errors.ArgumentNull('instrument.begin');
352
- }
353
- if (typeof params.instrument.end !== 'string') {
354
- throw new factory.errors.ArgumentNull('instrument.end');
355
- }
356
348
  // COAからイベント取得;
357
349
  const schedulesFromCOA = yield repos.masterService.schedule({
358
350
  theaterCode: params.instrument.theaterCode,