@chevre/domain 22.14.0-alpha.2 → 22.14.0-alpha.21

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 (65) hide show
  1. package/example/src/chevre/{createEventBySchedule.ts → addEventBySchedule.ts} +2 -2
  2. package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
  3. package/example/src/chevre/findReservationByCode.ts +0 -1
  4. package/example/src/chevre/productOffer/publishMemberTierToken.ts +92 -0
  5. package/lib/chevre/repo/accountingReport.d.ts +4 -4
  6. package/lib/chevre/repo/accountingReport.js +1 -1
  7. package/lib/chevre/repo/action.d.ts +1 -1
  8. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  9. package/lib/chevre/repo/creativeWork.js +65 -47
  10. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +2 -15
  11. package/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +36 -0
  12. package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +9 -53
  13. package/lib/chevre/repo/note.d.ts +15 -3
  14. package/lib/chevre/repo/note.js +19 -1
  15. package/lib/chevre/repo/productOffer.d.ts +63 -65
  16. package/lib/chevre/repo/productOffer.js +121 -163
  17. package/lib/chevre/repo/task.js +2 -2
  18. package/lib/chevre/repository.d.ts +0 -5
  19. package/lib/chevre/repository.js +2 -15
  20. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +0 -2
  21. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
  22. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  23. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -2
  24. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +79 -57
  25. package/lib/chevre/service/event.js +10 -2
  26. package/lib/chevre/service/offer/event/authorize/factory.d.ts +1 -1
  27. package/lib/chevre/service/offer/event/authorize/factory.js +2 -2
  28. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -3
  29. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  30. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  31. package/lib/chevre/service/offer/event/authorize.js +2 -2
  32. package/lib/chevre/service/offer/product.d.ts +0 -3
  33. package/lib/chevre/service/offer/product.js +29 -38
  34. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +0 -1
  35. package/lib/chevre/service/order/deleteOrder.js +1 -1
  36. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
  37. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
  38. package/lib/chevre/service/reserve/useReservation.js +2 -3
  39. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -2
  40. package/lib/chevre/service/task/checkResource.d.ts +2 -2
  41. package/lib/chevre/service/task/checkResource.js +8 -6
  42. package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
  43. package/lib/chevre/service/task/createAccountingReport.js +15 -15
  44. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
  45. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +3 -2
  46. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
  47. package/lib/chevre/service/task/deletePerson.js +11 -10
  48. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -2
  49. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +13 -6
  50. package/lib/chevre/service/task/onResourceUpdated.js +1 -2
  51. package/lib/chevre/service/task/useReservation.js +1 -2
  52. package/lib/chevre/service/taskHandler.js +2 -0
  53. package/lib/chevre/service/transaction/deleteTransaction.js +9 -9
  54. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -1
  55. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -1
  56. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -1
  57. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -1
  58. package/package.json +2 -2
  59. package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
  60. package/example/src/chevre/migrateDeleteTransactionTasks.ts +0 -132
  61. package/example/src/chevre/optimizeDeleteTransactionTasks.ts +0 -119
  62. package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
  63. package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +0 -10
  64. package/lib/chevre/repo/offer/event.d.ts +0 -38
  65. package/lib/chevre/repo/offer/event.js +0 -142
@@ -1,77 +1,75 @@
1
- import { Connection } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery } from 'mongoose';
2
3
  import * as factory from '../factory';
4
+ import { IDocType } from './mongoose/schemas/productOffer';
5
+ export { IDocType as IProductOffer };
6
+ interface ISearchConditions {
7
+ limit?: number;
8
+ page?: number;
9
+ sort?: {
10
+ validFrom?: factory.sortType;
11
+ };
12
+ project?: {
13
+ id?: {
14
+ $eq?: string;
15
+ };
16
+ };
17
+ id?: {
18
+ $eq?: string;
19
+ };
20
+ itemOffered?: {
21
+ identifier?: {
22
+ $eq?: string;
23
+ };
24
+ };
25
+ validForMemberTier?: {
26
+ identifier?: {
27
+ $eq?: string;
28
+ };
29
+ };
30
+ validFrom?: {
31
+ $lte?: Date;
32
+ };
33
+ validThrough?: {
34
+ $gte?: Date;
35
+ };
36
+ }
37
+ export type ISavingOffer = Pick<IDocType, 'identifier' | 'itemOffered' | 'project' | 'typeOf' | 'validFrom' | 'validThrough' | 'availability' | 'validForMemberTier' | 'acceptedPaymentMethod'> & {
38
+ id?: never;
39
+ };
40
+ type IUnset = {
41
+ [key in keyof IDocType]?: 1;
42
+ };
43
+ type IDocWithId = IDocType & {
44
+ id: string;
45
+ };
46
+ type IKeyOfProjection = keyof IDocType;
3
47
  /**
4
48
  * プロダクトオファーリポジトリ
5
49
  */
6
50
  export declare class ProductOfferRepo {
7
- private readonly productModel;
51
+ private readonly productOfferModel;
8
52
  constructor(connection: Connection);
53
+ static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<IDocType>[];
54
+ findProductOffers(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
9
55
  /**
10
- * プロダクトオファー検索
56
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
11
57
  */
12
- search(params: {
13
- limit?: number;
14
- page?: number;
15
- project?: {
16
- id?: {
17
- $eq?: string;
18
- };
19
- };
20
- itemOffered?: {
21
- id?: {
22
- $eq?: string;
23
- };
24
- };
25
- seller?: {
26
- id?: {
27
- $eq?: string;
28
- };
29
- };
30
- }): Promise<(Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
31
- itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
32
- })[]>;
33
- create(params: factory.product.IOffer & {
34
- project: {
35
- id: string;
36
- };
37
- itemOffered: {
38
- /**
39
- * プロダクトID
40
- */
41
- id: string;
58
+ upsertOffersByIdentifier(params: {
59
+ $set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
60
+ id?: never;
42
61
  };
62
+ $unset: IUnset;
63
+ }[], options: {
64
+ /**
65
+ * falseの場合setOnInsertのみ
66
+ * trueの場合setのみ
67
+ */
68
+ update: boolean;
43
69
  }): Promise<{
44
- id: string;
45
- }>;
46
- update(params: factory.product.IOffer & {
47
- project: {
70
+ bulkWriteResult: BulkWriteResult;
71
+ modifiedNotes: {
48
72
  id: string;
49
- };
50
- itemOffered: {
51
- /**
52
- * プロダクトID
53
- */
54
- id: string;
55
- };
56
- }): Promise<{
57
- id: string;
58
- }>;
59
- deleteOne(params: Pick<factory.product.IOffer, 'seller'> & {
60
- project: {
61
- id: string;
62
- };
63
- itemOffered: {
64
- /**
65
- * プロダクトID
66
- */
67
- id: string;
68
- };
69
- }): Promise<{
70
- id: string;
71
- }>;
72
- deleteManyBySellerId(params: Pick<factory.product.IOffer, 'seller'> & {
73
- project: {
74
- id: string;
75
- };
76
- }): Promise<import("mongoose").UpdateWriteOpResult>;
73
+ }[];
74
+ } | void>;
77
75
  }
@@ -10,191 +10,149 @@ 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
+ 'typeOf',
21
+ 'validFrom',
22
+ 'validThrough',
23
+ 'availability',
24
+ 'acceptedPaymentMethod',
25
+ 'validForMemberTier'
26
+ ];
17
27
  /**
18
28
  * プロダクトオファーリポジトリ
19
29
  */
20
30
  class ProductOfferRepo {
21
31
  constructor(connection) {
22
- this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
32
+ this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
23
33
  }
24
- /**
25
- * プロダクトオファー検索
26
- */
27
- search(params) {
34
+ static CREATE_MONGO_CONDITIONS(params) {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
36
+ const andConditions = [];
37
+ const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
38
+ if (typeof idEq === 'string') {
39
+ andConditions.push({ _id: { $eq: idEq } });
40
+ }
41
+ const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
42
+ if (typeof projectIdEq === 'string') {
43
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
44
+ }
45
+ const itemOfferedIdentifierEq = (_e = (_d = params.itemOffered) === null || _d === void 0 ? void 0 : _d.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
46
+ if (typeof itemOfferedIdentifierEq === 'string') {
47
+ andConditions.push({ 'itemOffered.identifier': { $eq: itemOfferedIdentifierEq } });
48
+ }
49
+ const validForMemberTierIdentifierEq = (_g = (_f = params.validForMemberTier) === null || _f === void 0 ? void 0 : _f.identifier) === null || _g === void 0 ? void 0 : _g.$eq;
50
+ if (typeof validForMemberTierIdentifierEq === 'string') {
51
+ andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
52
+ }
53
+ const validFromLte = (_h = params.validFrom) === null || _h === void 0 ? void 0 : _h.$lte;
54
+ if (validFromLte instanceof Date) {
55
+ andConditions.push({ validFrom: { $lte: validFromLte } });
56
+ }
57
+ const validThroughGte = (_j = params.validThrough) === null || _j === void 0 ? void 0 : _j.$gte;
58
+ if (validThroughGte instanceof Date) {
59
+ andConditions.push({ validThrough: { $gte: validThroughGte } });
60
+ }
61
+ return andConditions;
62
+ }
63
+ findProductOffers(params, inclusion) {
28
64
  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 } } });
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));
43
70
  }
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) } } });
71
+ else {
72
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
47
73
  }
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 } } });
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 });
51
78
  }
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
79
  if (typeof params.limit === 'number' && params.limit > 0) {
77
80
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
78
- aggregate.limit(params.limit * page)
81
+ query.limit(params.limit)
79
82
  .skip(params.limit * (page - 1));
80
83
  }
81
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
84
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
85
+ .lean()
82
86
  .exec();
83
87
  });
84
88
  }
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
- })
154
- .exec();
155
- if (doc === null) {
156
- throw new factory.errors.NotFound('Product');
157
- }
158
- return doc.toObject();
159
- });
160
- }
161
- deleteOne(params) {
89
+ /**
90
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
91
+ */
92
+ upsertOffersByIdentifier(params, options) {
162
93
  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');
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
+ });
180
144
  }
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');
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 };
190
155
  }
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();
198
156
  });
199
157
  }
200
158
  }
@@ -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.task.deleteTransaction.SpecifyingMethod.Id) {
310
- throw new factory.errors.NotImplemented(`only ${factory.task.deleteTransaction.SpecifyingMethod.Id} implemented`);
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`);
311
311
  }
312
312
  const createdTask = yield this.taskModel.findOneAndUpdate({
313
313
  'project.id': { $eq: params.project.id },
@@ -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;
@@ -5,7 +5,6 @@ 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[];
@@ -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 };
@@ -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({
@@ -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 { 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
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;
20
19
  issuer: IssuerRepo;
21
20
  memberProgram: MemberProgramRepo;
21
+ productOffer: ProductOfferRepo;
22
22
  }) => Promise<void>;
23
23
  export { validateStartRequest };