@chevre/domain 20.4.0-alpha.2 → 20.4.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/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
  3. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  4. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
  5. package/example/src/chevre/searchEventTicketOffers.ts +7 -4
  6. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +21 -0
  8. package/lib/chevre/repo/account.d.ts +4 -10
  9. package/lib/chevre/repo/account.js +72 -60
  10. package/lib/chevre/repo/assetTransaction.d.ts +1 -0
  11. package/lib/chevre/repo/assetTransaction.js +5 -0
  12. package/lib/chevre/repo/event.d.ts +5 -4
  13. package/lib/chevre/repo/event.js +12 -30
  14. package/lib/chevre/repo/mongoose/model/comments.d.ts +1 -1
  15. package/lib/chevre/repo/mongoose/model/comments.js +1 -1
  16. package/lib/chevre/repo/mongoose/model/offer.js +12 -0
  17. package/lib/chevre/repo/offer.d.ts +17 -2
  18. package/lib/chevre/repo/offer.js +77 -44
  19. package/lib/chevre/repo/priceSpecification.d.ts +10 -0
  20. package/lib/chevre/repo/priceSpecification.js +9 -0
  21. package/lib/chevre/repo/serviceOutput.d.ts +4 -0
  22. package/lib/chevre/repo/serviceOutput.js +6 -0
  23. package/lib/chevre/repository.d.ts +6 -0
  24. package/lib/chevre/repository.js +8 -1
  25. package/lib/chevre/service/account.d.ts +0 -8
  26. package/lib/chevre/service/account.js +16 -10
  27. package/lib/chevre/service/accountTransaction/deposit.js +2 -1
  28. package/lib/chevre/service/accountTransaction/factory.js +25 -20
  29. package/lib/chevre/service/accountTransaction/transfer.js +4 -2
  30. package/lib/chevre/service/accountTransaction/withdraw.js +2 -1
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +46 -83
  32. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  33. package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
  34. package/lib/chevre/service/assetTransaction/pay.js +19 -14
  35. package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
  36. package/lib/chevre/service/assetTransaction/reserve.js +2 -0
  37. package/lib/chevre/service/delivery.js +12 -3
  38. package/lib/chevre/service/event.js +3 -23
  39. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  40. package/lib/chevre/service/moneyTransfer.js +7 -8
  41. package/lib/chevre/service/offer/event/authorize.js +2 -1
  42. package/lib/chevre/service/offer/event/factory.js +1 -1
  43. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +6 -6
  44. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +106 -91
  45. package/lib/chevre/service/offer/factory.d.ts +4 -1
  46. package/lib/chevre/service/offer/factory.js +57 -26
  47. package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
  48. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
  49. package/lib/chevre/service/offer/product/searchProductOffers.js +5 -1
  50. package/lib/chevre/service/payment/any/factory.js +29 -2
  51. package/lib/chevre/service/payment/any.js +11 -4
  52. package/lib/chevre/service/payment/movieTicket.d.ts +7 -2
  53. package/lib/chevre/service/payment/movieTicket.js +17 -8
  54. package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
  55. package/lib/chevre/service/payment/paymentCard.js +16 -8
  56. package/lib/chevre/service/permit.d.ts +5 -1
  57. package/lib/chevre/service/permit.js +18 -11
  58. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  59. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  60. package/lib/chevre/settings.d.ts +6 -0
  61. package/lib/chevre/settings.js +8 -2
  62. package/package.json +3 -3
  63. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
  64. package/example/src/chevre/migrateProjectSubscription.ts +0 -51
  65. package/example/src/chevre/migrateSection.ts +0 -105
@@ -16,7 +16,7 @@ async function main() {
16
16
 
17
17
  // const now = new Date();
18
18
  await chevre.service.aggregation.event.aggregateScreeningEvent({
19
- id: 'alb35u7m4'
19
+ id: 'blaqxj0ak'
20
20
  })({
21
21
  event: new chevre.repository.Event(mongoose.connection),
22
22
  eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
@@ -31,16 +31,16 @@ async function main() {
31
31
  .toDate(),
32
32
  endDate: moment('2023-02-01T06:00:00.000Z')
33
33
  .toDate(),
34
- workPerformed: {
35
- typeOf: chevre.factory.creativeWorkType.Movie,
36
- identifier: '1622100',
37
- id: '5bfb841d5a78d7948369980a',
38
- name: {
39
- en: 'Pet',
40
- ja: 'ペット'
41
- },
42
- duration: 'PT2H3M'
43
- },
34
+ // workPerformed: {
35
+ // typeOf: chevre.factory.creativeWorkType.Movie,
36
+ // identifier: '1622100',
37
+ // id: '5bfb841d5a78d7948369980a',
38
+ // name: {
39
+ // en: 'Pet',
40
+ // ja: 'ペット'
41
+ // },
42
+ // duration: 'PT2H3M'
43
+ // },
44
44
  location: {
45
45
  typeOf: chevre.factory.placeType.ScreeningRoom,
46
46
  branchCode: '10',
@@ -0,0 +1,21 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
+
13
+ const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
+ // project: { id: 'cinerino' }
15
+ });
16
+ console.log('deleted', result);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -0,0 +1,96 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const accountTransactionRepo = new chevre.repository.AccountTransaction(mongoose.connection);
14
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
15
+
16
+ const cursor = assetTransactionRepo.getCursor(
17
+ {
18
+ 'project.id': { $eq: project.id },
19
+ typeOf: { $eq: chevre.factory.assetTransactionType.MoneyTransfer },
20
+ startDate: {
21
+ $gte: moment('2023-02-17T15:00:00Z')
22
+ .toDate()
23
+ }
24
+ // _id: { $eq: 'al6aff83w' }
25
+ },
26
+ {
27
+ // _id: 1,
28
+ }
29
+ );
30
+ console.log('assetTransactions found');
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ // tslint:disable-next-line:max-func-body-length
35
+ await cursor.eachAsync(async (doc) => {
36
+ i += 1;
37
+ const moneyTransferTransaction: chevre.factory.assetTransaction.moneyTransfer.ITransaction = doc.toObject();
38
+
39
+ const description = moneyTransferTransaction.object.description;
40
+ if (description !== '鑑賞' && description !== '受け取り') {
41
+ console.log(
42
+ 'no operation needed',
43
+ description,
44
+ moneyTransferTransaction.project.id,
45
+ moneyTransferTransaction.transactionNumber,
46
+ moneyTransferTransaction.startDate
47
+ );
48
+ } else {
49
+ const pendingTransactionIdentifier = moneyTransferTransaction.object.pendingTransaction?.identifier;
50
+ if (typeof pendingTransactionIdentifier === 'string' && pendingTransactionIdentifier.length > 0) {
51
+ console.log(
52
+ 'pendingTransactionIdentifier found',
53
+ description,
54
+ moneyTransferTransaction.project.id,
55
+ moneyTransferTransaction.transactionNumber,
56
+ moneyTransferTransaction.startDate
57
+ );
58
+ } else {
59
+ // 口座取引からidentifierを取得
60
+ const accountTransaction =
61
+ await accountTransactionRepo.findByTransactionNumber({ transactionNumber: moneyTransferTransaction.transactionNumber });
62
+ console.log(
63
+ 'updating identifier...',
64
+ accountTransaction.identifier,
65
+ description,
66
+ moneyTransferTransaction.project.id,
67
+ moneyTransferTransaction.transactionNumber,
68
+ moneyTransferTransaction.startDate
69
+ );
70
+ if (typeof accountTransaction.identifier === 'string') {
71
+ await assetTransactionRepo.findByIdAndUpdate({
72
+ id: moneyTransferTransaction.id,
73
+ update: {
74
+ 'object.pendingTransaction.identifier': accountTransaction.identifier
75
+ }
76
+ });
77
+ }
78
+ console.log(
79
+ 'ientifier updated',
80
+ accountTransaction.identifier,
81
+ description,
82
+ moneyTransferTransaction.project.id,
83
+ moneyTransferTransaction.transactionNumber,
84
+ moneyTransferTransaction.startDate
85
+ );
86
+ updateCount += 1;
87
+ }
88
+ }
89
+ });
90
+ console.log(i, 'assetTransactions checked');
91
+ console.log(updateCount, 'assetTransactions updated');
92
+ }
93
+
94
+ main()
95
+ .then()
96
+ .catch(console.error);
@@ -22,11 +22,13 @@ async function main() {
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
24
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
- event: { id: 'al9ew43f5' },
25
+ event: { id: 'ale6qiedi' },
26
26
  onlyValid: true,
27
- sort: true,
28
- validateOfferRateLimit: true
29
- // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
27
+ sort: false,
28
+ validateOfferRateLimit: true,
29
+ addSortIndex: true,
30
+ limit: 100,
31
+ page: 1
30
32
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
31
33
  })({
32
34
  event: eventRepo,
@@ -35,6 +37,7 @@ async function main() {
35
37
  priceSpecification: priceSpecificationRepo,
36
38
  product: productRepo
37
39
  });
40
+ console.log(ticketOffers.map((o) => o.sortIndex));
38
41
  console.log(ticketOffers.length);
39
42
  }
40
43
 
@@ -9,13 +9,14 @@ async function main() {
9
9
 
10
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
11
 
12
- const offers = await offerRepo.findOffersByOfferCatalogId({
12
+ const { offers } = await offerRepo.findOffersByOfferCatalogId({
13
13
  ids: ['al96nqj7z', 'xxx', '1001'],
14
14
  // ids: ['xx', 'xxx'],
15
15
  offerCatalog: {
16
16
  id: '0001'
17
17
  // id: 'xxx'
18
18
  },
19
+ excludeAppliesToMovieTicket: false,
19
20
  sort: true
20
21
  });
21
22
  console.log(offers.map((o) => o.id));
@@ -0,0 +1,21 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+
9
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
10
+
11
+ let updateResult: any;
12
+ updateResult = await offerRepo.unsetUnnecessaryFields({
13
+ filter: { 'category.project': { $exists: true } },
14
+ $unset: { 'category.project': 1 }
15
+ });
16
+ console.log('offers unset', updateResult);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -45,16 +45,6 @@ export declare class MongoRepository {
45
45
  /**
46
46
  * 口座を解約する
47
47
  */
48
- close(params: {
49
- /**
50
- * 口座番号
51
- */
52
- accountNumber: string;
53
- /**
54
- * 解約日時
55
- */
56
- closeDate: Date;
57
- }): Promise<void>;
58
48
  /**
59
49
  * 口座番号で検索する
60
50
  */
@@ -134,4 +124,8 @@ export declare class MongoRepository {
134
124
  * 口座を検索する
135
125
  */
136
126
  search(params: factory.account.ISearchConditions): Promise<factory.account.IAccount[]>;
127
+ unsetUnnecessaryFields(params: {
128
+ filter: any;
129
+ $unset: any;
130
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
137
131
  }
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = exports.modelName = void 0;
13
- const createDebug = require("debug");
14
13
  const account_1 = require("./mongoose/model/account");
15
14
  Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return account_1.modelName; } });
16
15
  const factory = require("../factory");
17
- const debug = createDebug('chevre-domain:repository');
18
16
  /**
19
17
  * 口座リポジトリ
20
18
  */
@@ -93,11 +91,11 @@ class MongoRepository {
93
91
  }
94
92
  // tslint:disable-next-line:no-single-line-block-comment
95
93
  /* istanbul ignore else */
96
- if (Array.isArray(params.statuses) && params.statuses.length > 0) {
97
- andConditions.push({
98
- status: { $in: params.statuses }
99
- });
100
- }
94
+ // if (Array.isArray(params.statuses) && params.statuses.length > 0) {
95
+ // andConditions.push({
96
+ // status: { $in: params.statuses }
97
+ // });
98
+ // }
101
99
  const nameRegex = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$regex;
102
100
  // tslint:disable-next-line:no-single-line-block-comment
103
101
  /* istanbul ignore else */
@@ -159,8 +157,8 @@ class MongoRepository {
159
157
  balance: p.initialBalance,
160
158
  availableBalance: p.initialBalance,
161
159
  pendingTransactions: [],
162
- openDate: p.openDate,
163
- status: factory.account.AccountStatusType.Opened
160
+ openDate: p.openDate
161
+ // status: factory.account.AccountStatusType.Opened
164
162
  };
165
163
  });
166
164
  // const doc = await this.accountModel.create(account);
@@ -179,39 +177,47 @@ class MongoRepository {
179
177
  /**
180
178
  * 口座を解約する
181
179
  */
182
- close(params) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- debug('closing account...');
185
- const doc = yield this.accountModel.findOneAndUpdate({
186
- accountNumber: params.accountNumber,
187
- pendingTransactions: { $size: 0 },
188
- status: factory.account.AccountStatusType.Opened
189
- }, {
190
- closeDate: params.closeDate,
191
- status: factory.account.AccountStatusType.Closed
192
- }, {
193
- new: true
194
- })
195
- .exec();
196
- // NotFoundであれば口座状態確認
197
- if (doc === null) {
198
- const account = yield this.findByAccountNumber({
199
- accountNumber: params.accountNumber
200
- });
201
- if (account.status === factory.account.AccountStatusType.Closed) {
202
- // すでに口座解約済の場合
203
- return;
204
- }
205
- else if (Array.isArray(account.pendingTransactions) && account.pendingTransactions.length > 0) {
206
- // 進行中取引が存在する場合の場合
207
- throw new factory.errors.Argument('accountNumber', 'Pending transactions exist');
208
- }
209
- else {
210
- throw new factory.errors.NotFound(this.accountModel.modelName);
211
- }
212
- }
213
- });
214
- }
180
+ // public async close(params: {
181
+ // /**
182
+ // * 口座番号
183
+ // */
184
+ // accountNumber: string;
185
+ // /**
186
+ // * 解約日時
187
+ // */
188
+ // closeDate: Date;
189
+ // }) {
190
+ // const doc = await this.accountModel.findOneAndUpdate(
191
+ // {
192
+ // accountNumber: params.accountNumber,
193
+ // pendingTransactions: { $size: 0 },
194
+ // status: factory.account.AccountStatusType.Opened
195
+ // },
196
+ // {
197
+ // closeDate: params.closeDate,
198
+ // status: factory.account.AccountStatusType.Closed
199
+ // },
200
+ // {
201
+ // new: true
202
+ // }
203
+ // )
204
+ // .exec();
205
+ // // NotFoundであれば口座状態確認
206
+ // if (doc === null) {
207
+ // const account = await this.findByAccountNumber({
208
+ // accountNumber: params.accountNumber
209
+ // });
210
+ // if (account.status === factory.account.AccountStatusType.Closed) {
211
+ // // すでに口座解約済の場合
212
+ // return;
213
+ // } else if (Array.isArray(account.pendingTransactions) && account.pendingTransactions.length > 0) {
214
+ // // 進行中取引が存在する場合の場合
215
+ // throw new factory.errors.Argument('accountNumber', 'Pending transactions exist');
216
+ // } else {
217
+ // throw new factory.errors.NotFound(this.accountModel.modelName);
218
+ // }
219
+ // }
220
+ // }
215
221
  /**
216
222
  * 口座番号で検索する
217
223
  */
@@ -233,7 +239,7 @@ class MongoRepository {
233
239
  */
234
240
  authorizeAmount(params) {
235
241
  return __awaiter(this, void 0, void 0, function* () {
236
- const doc = yield this.accountModel.findOneAndUpdate(Object.assign({ accountNumber: params.accountNumber, status: factory.account.AccountStatusType.Opened }, (params.force === true) ? undefined : { availableBalance: { $gte: params.amount } } // 利用可能金額確認
242
+ const doc = yield this.accountModel.findOneAndUpdate(Object.assign({ accountNumber: params.accountNumber }, (params.force === true) ? undefined : { availableBalance: { $gte: params.amount } } // 利用可能金額確認
237
243
  ), {
238
244
  $inc: { availableBalance: -params.amount },
239
245
  $push: { pendingTransactions: params.transaction } // 進行中取引追加
@@ -244,11 +250,11 @@ class MongoRepository {
244
250
  const account = yield this.findByAccountNumber({
245
251
  accountNumber: params.accountNumber
246
252
  });
247
- if (account.status === factory.account.AccountStatusType.Closed) {
248
- // 口座解約済の場合
249
- throw new factory.errors.Argument('accountNumber', 'Account already closed');
250
- }
251
- else if (typeof account.availableBalance === 'number' && account.availableBalance < params.amount) {
253
+ // if (account.status === factory.account.AccountStatusType.Closed) {
254
+ // // 口座解約済の場合
255
+ // throw new factory.errors.Argument('accountNumber', 'Account already closed');
256
+ // } else
257
+ if (typeof account.availableBalance === 'number' && account.availableBalance < params.amount) {
252
258
  // 残高不足の場合
253
259
  throw new factory.errors.Argument('accountNumber', 'Insufficient balance');
254
260
  }
@@ -264,22 +270,22 @@ class MongoRepository {
264
270
  startTransaction(params) {
265
271
  return __awaiter(this, void 0, void 0, function* () {
266
272
  const doc = yield this.accountModel.findOneAndUpdate({
267
- accountNumber: params.accountNumber,
268
- status: factory.account.AccountStatusType.Opened // 開いている口座
273
+ accountNumber: params.accountNumber
274
+ // status: factory.account.AccountStatusType.Opened // 開いている口座
269
275
  }, { $push: { pendingTransactions: params.transaction } })
270
276
  .exec();
271
277
  // NotFoundであれば口座状態確認
272
278
  if (doc === null) {
273
- const account = yield this.findByAccountNumber({
274
- accountNumber: params.accountNumber
275
- });
276
- if (account.status === factory.account.AccountStatusType.Closed) {
277
- // 口座解約済の場合
278
- throw new factory.errors.Argument('accountNumber', 'Account already closed');
279
- }
280
- else {
281
- throw new factory.errors.NotFound(this.accountModel.modelName);
282
- }
279
+ // const account = await this.findByAccountNumber({
280
+ // accountNumber: params.accountNumber
281
+ // });
282
+ // if (account.status === factory.account.AccountStatusType.Closed) {
283
+ // // 口座解約済の場合
284
+ // throw new factory.errors.Argument('accountNumber', 'Account already closed');
285
+ // } else {
286
+ // throw new factory.errors.NotFound(this.accountModel.modelName);
287
+ // }
288
+ throw new factory.errors.NotFound(this.accountModel.modelName);
283
289
  }
284
290
  });
285
291
  }
@@ -419,5 +425,11 @@ class MongoRepository {
419
425
  .then((docs) => docs.map((doc) => doc.toObject()));
420
426
  });
421
427
  }
428
+ unsetUnnecessaryFields(params) {
429
+ return __awaiter(this, void 0, void 0, function* () {
430
+ return this.accountModel.updateMany(params.filter, { $unset: params.$unset })
431
+ .exec();
432
+ });
433
+ }
422
434
  }
423
435
  exports.MongoRepository = MongoRepository;
@@ -144,6 +144,7 @@ export declare class MongoRepository {
144
144
  findByIdAndDelete(params: {
145
145
  id: string;
146
146
  }): Promise<void>;
147
+ getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
147
148
  aggregateAssetTransaction(params: {
148
149
  project?: {
149
150
  id?: {
@@ -536,6 +536,11 @@ class MongoRepository {
536
536
  .exec();
537
537
  });
538
538
  }
539
+ getCursor(conditions, projection) {
540
+ return this.transactionModel.find(conditions, projection)
541
+ .sort({ startDate: factory.sortType.Ascending })
542
+ .cursor();
543
+ }
539
544
  aggregateAssetTransaction(params) {
540
545
  return __awaiter(this, void 0, void 0, function* () {
541
546
  const statuses = yield Promise.all([
@@ -10,7 +10,7 @@ export interface IUpdateAggregateReservationParams {
10
10
  $set: {
11
11
  updatedAt: Date;
12
12
  aggregateReservation: factory.event.screeningEvent.IAggregateReservation;
13
- aggregateOffer: factory.event.screeningEvent.IAggregateOffer;
13
+ aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
14
14
  maximumAttendeeCapacity?: number;
15
15
  remainingAttendeeCapacity?: number;
16
16
  checkInCount?: number;
@@ -141,9 +141,10 @@ export declare class MongoRepository {
141
141
  }, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
142
142
  bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
143
143
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
144
- deleteUnnecessaryProjectAttributesById(params: {
145
- id: string;
146
- }): Promise<void>;
144
+ unsetUnnecessaryFields(params: {
145
+ filter: any;
146
+ $unset: any;
147
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
147
148
  aggregateEvent(params: {
148
149
  project?: {
149
150
  id?: {
@@ -473,11 +473,11 @@ class MongoRepository {
473
473
  if (typeof additionalPropertyValue !== 'string') {
474
474
  throw new factory.errors.NotFound('additionalProperty.value');
475
475
  }
476
- const _c = creatingEventParams.attributes, { identifier, project, superEvent, workPerformed, typeOf, location, name, remainingAttendeeCapacity, maximumAttendeeCapacity } = _c, updateFields = __rest(_c, ["identifier", "project", "superEvent", "workPerformed", "typeOf", "location", "name", "remainingAttendeeCapacity", "maximumAttendeeCapacity"]);
476
+ const _c = creatingEventParams.attributes, { eventStatus } = _c, setOnInsertFields = __rest(_c, ["eventStatus"]);
477
477
  bulkWriteOps.push({
478
478
  updateOne: {
479
479
  filter: {
480
- typeOf,
480
+ typeOf: creatingEventParams.attributes.typeOf,
481
481
  // 追加特性をキーに更新
482
482
  additionalProperty: {
483
483
  $exists: true,
@@ -485,18 +485,9 @@ class MongoRepository {
485
485
  }
486
486
  },
487
487
  update: {
488
- $setOnInsert: {
489
- _id: uniqid(),
490
- typeOf,
491
- project,
492
- superEvent,
493
- workPerformed,
494
- location,
495
- name
496
- // ...creatingEventParams.attributes
497
- },
488
+ $setOnInsert: Object.assign(Object.assign({}, setOnInsertFields), { _id: uniqid() }),
498
489
  // 変更可能な属性のみ上書き
499
- $set: updateFields
490
+ $set: { eventStatus }
500
491
  },
501
492
  upsert: true
502
493
  }
@@ -647,14 +638,14 @@ class MongoRepository {
647
638
  return __awaiter(this, void 0, void 0, function* () {
648
639
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
649
640
  const positiveProjectionExists = (projection !== undefined && projection !== null)
650
- ? Object.keys(projection)
651
- .some((key) => projection[key] !== 0)
641
+ ? Object.values(projection)
642
+ .some((value) => value !== 0)
652
643
  : false;
653
644
  const query = this.eventModel.find({ $and: conditions },
654
645
  // :1対応(2023-01-25~)
655
646
  (positiveProjectionExists)
656
647
  ? projection
657
- : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
648
+ : Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
658
649
  if (typeof params.limit === 'number') {
659
650
  const page = (typeof params.page === 'number') ? params.page : 1;
660
651
  query.limit(params.limit)
@@ -689,14 +680,14 @@ class MongoRepository {
689
680
  findById(params, projection) {
690
681
  return __awaiter(this, void 0, void 0, function* () {
691
682
  const positiveProjectionExists = (projection !== undefined && projection !== null)
692
- ? Object.keys(projection)
693
- .some((key) => projection[key] !== 0)
683
+ ? Object.values(projection)
684
+ .some((value) => value !== 0)
694
685
  : false;
695
686
  const doc = yield this.eventModel.findOne({ _id: params.id },
696
687
  // :1対応(2023-01-25~)
697
688
  (positiveProjectionExists)
698
689
  ? projection
699
- : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
690
+ : Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }))
700
691
  .exec();
701
692
  if (doc === null) {
702
693
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -760,18 +751,9 @@ class MongoRepository {
760
751
  .sort({ startDate: factory.sortType.Descending })
761
752
  .cursor();
762
753
  }
763
- deleteUnnecessaryProjectAttributesById(params) {
754
+ unsetUnnecessaryFields(params) {
764
755
  return __awaiter(this, void 0, void 0, function* () {
765
- yield this.eventModel.updateOne({
766
- _id: { $eq: params.id }
767
- }, {
768
- $unset: {
769
- 'location.project': 1,
770
- 'workPerformed.project': 1,
771
- 'superEvent.location.project': 1,
772
- 'superEvent.workPerformed.project': 1
773
- }
774
- })
756
+ return this.eventModel.updateMany(params.filter, { $unset: params.$unset })
775
757
  .exec();
776
758
  });
777
759
  }
@@ -1,5 +1,5 @@
1
1
  import * as mongoose from 'mongoose';
2
- declare const modelName = "CreativeWork";
2
+ declare const modelName = "Comment";
3
3
  /**
4
4
  * コメントスキーマ
5
5
  */
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.schema = exports.modelName = void 0;
4
4
  const mongoose = require("mongoose");
5
- const modelName = 'CreativeWork';
5
+ const modelName = 'Comment';
6
6
  exports.modelName = modelName;
7
7
  const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
8
8
  /**
@@ -196,6 +196,18 @@ schema.index({ additionalProperty: 1, 'priceSpecification.price': 1 }, {
196
196
  additionalProperty: { $exists: true }
197
197
  }
198
198
  });
199
+ schema.index({ validFrom: 1, 'priceSpecification.price': 1 }, {
200
+ name: 'searchByValidFrom',
201
+ partialFilterExpression: {
202
+ validFrom: { $exists: true }
203
+ }
204
+ });
205
+ schema.index({ validThrough: 1, 'priceSpecification.price': 1 }, {
206
+ name: 'searchByValidThrough',
207
+ partialFilterExpression: {
208
+ validThrough: { $exists: true }
209
+ }
210
+ });
199
211
  mongoose.model(modelName, schema)
200
212
  .on('index',
201
213
  // tslint:disable-next-line:no-single-line-block-comment