@chevre/domain 20.4.0-alpha.9 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +2 -1
  2. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  3. package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
  4. package/example/src/chevre/reIndex.ts +25 -0
  5. package/example/src/chevre/searchEventTicketOffers.ts +7 -4
  6. package/example/src/chevre/searchOfferCatalogs.ts +14 -16
  7. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  8. package/example/src/chevre/searchProductOffers.ts +38 -0
  9. package/example/src/chevre/searchTasks.ts +22 -0
  10. package/example/src/chevre/unsetUnnecessaryFields.ts +6 -11
  11. package/lib/chevre/errorHandler.js +1 -0
  12. package/lib/chevre/repo/accountTransaction.d.ts +0 -5
  13. package/lib/chevre/repo/accountTransaction.js +44 -38
  14. package/lib/chevre/repo/code.d.ts +0 -7
  15. package/lib/chevre/repo/code.js +0 -17
  16. package/lib/chevre/repo/event.d.ts +5 -4
  17. package/lib/chevre/repo/event.js +8 -17
  18. package/lib/chevre/repo/mongoose/model/accountTransaction.js +0 -5
  19. package/lib/chevre/repo/mongoose/model/member.js +5 -2
  20. package/lib/chevre/repo/mongoose/model/offer.js +19 -9
  21. package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
  22. package/lib/chevre/repo/mongoose/model/product.js +15 -2
  23. package/lib/chevre/repo/offer.d.ts +17 -2
  24. package/lib/chevre/repo/offer.js +77 -44
  25. package/lib/chevre/repo/offerCatalog.d.ts +3 -5
  26. package/lib/chevre/repo/offerCatalog.js +78 -37
  27. package/lib/chevre/repo/priceSpecification.d.ts +11 -0
  28. package/lib/chevre/repo/priceSpecification.js +44 -66
  29. package/lib/chevre/repo/task.d.ts +8 -0
  30. package/lib/chevre/repo/task.js +21 -9
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
  32. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +93 -96
  33. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  34. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -3
  35. package/lib/chevre/service/assetTransaction/pay.js +2 -3
  36. package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
  37. package/lib/chevre/service/assetTransaction/registerService/factory.js +6 -3
  38. package/lib/chevre/service/assetTransaction/registerService.js +3 -1
  39. package/lib/chevre/service/assetTransaction/reserve/factory/price.d.ts +1 -1
  40. package/lib/chevre/service/assetTransaction/reserve/factory/price.js +0 -7
  41. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +2 -2
  42. package/lib/chevre/service/assetTransaction/reserve/factory.js +0 -1
  43. package/lib/chevre/service/assetTransaction/reserve.js +47 -17
  44. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  45. package/lib/chevre/service/code.d.ts +0 -8
  46. package/lib/chevre/service/code.js +1 -38
  47. package/lib/chevre/service/event.js +20 -3
  48. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  49. package/lib/chevre/service/moneyTransfer.js +7 -8
  50. package/lib/chevre/service/offer/event/authorize.js +5 -5
  51. package/lib/chevre/service/offer/event/factory.js +1 -1
  52. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
  53. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +222 -346
  54. package/lib/chevre/service/offer/factory.d.ts +8 -3
  55. package/lib/chevre/service/offer/factory.js +44 -26
  56. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
  57. package/lib/chevre/service/offer/product/searchProductOffers.js +15 -7
  58. package/lib/chevre/service/offer/product.d.ts +11 -4
  59. package/lib/chevre/service/offer/product.js +59 -50
  60. package/lib/chevre/service/payment/any/factory.js +30 -21
  61. package/lib/chevre/service/payment/any.js +11 -4
  62. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +22 -0
  63. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +183 -0
  64. package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
  65. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +13 -0
  66. package/lib/chevre/service/payment/movieTicket/getCredentials.js +45 -0
  67. package/lib/chevre/service/payment/movieTicket/validation.d.ts +15 -0
  68. package/lib/chevre/service/{assetTransaction/pay → payment}/movieTicket/validation.js +8 -7
  69. package/lib/chevre/service/payment/movieTicket.d.ts +10 -22
  70. package/lib/chevre/service/payment/movieTicket.js +15 -210
  71. package/lib/chevre/service/permit.d.ts +5 -1
  72. package/lib/chevre/service/permit.js +18 -11
  73. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  74. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
  75. package/lib/chevre/service/transaction/orderProgramMembership.js +5 -6
  76. package/lib/chevre/settings.d.ts +4 -1
  77. package/lib/chevre/settings.js +7 -1
  78. package/package.json +3 -3
  79. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.d.ts +0 -14
  80. package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
  81. package/lib/chevre/service/task/deleteAuthorization.js +0 -29
@@ -16,11 +16,12 @@ async function main() {
16
16
 
17
17
  // const now = new Date();
18
18
  await chevre.service.aggregation.event.aggregateScreeningEvent({
19
- id: 'alb35u7m4'
19
+ id: String(process.env.EVENT_ID)
20
20
  })({
21
21
  event: new chevre.repository.Event(mongoose.connection),
22
22
  eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
23
23
  offer: new chevre.repository.Offer(mongoose.connection),
24
+ offerCatalog: new chevre.repository.OfferCatalog(mongoose.connection),
24
25
  offerRateLimit: new chevre.repository.rateLimit.Offer(client),
25
26
  place: new chevre.repository.Place(mongoose.connection),
26
27
  product: new chevre.repository.Product(mongoose.connection),
@@ -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: 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: project.id }
15
+ });
16
+ console.log('deleted', result);
17
+ }
18
+
19
+ main()
20
+ .then()
21
+ .catch(console.error);
@@ -8,9 +8,11 @@ import { chevre } from '../../../lib/index';
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
10
 
11
- const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
11
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
12
12
 
13
- const result = await reservationRepo.deleteReservedTicketUnderName();
13
+ const result = await taskRepo.deleteByName({
14
+ name: <any>'deleteAuthorization'
15
+ });
14
16
 
15
17
  console.log('deleted', result);
16
18
  }
@@ -0,0 +1,25 @@
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 priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
10
+ const result = await priceSpecificationRepo.reIndex();
11
+ console.log(result);
12
+ }
13
+
14
+ main()
15
+ .then()
16
+ .catch(console.error);
17
+ // setInterval(
18
+ // () => {
19
+ // main()
20
+ // .then()
21
+ // .catch(console.error);
22
+ // },
23
+ // // tslint:disable-next-line:no-magic-numbers
24
+ // 60000
25
+ // );
@@ -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: 'ale6qiedq' },
26
26
  onlyValid: true,
27
- sort: true,
28
- validateOfferRateLimit: true
29
- // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
27
+ validateOfferRateLimit: true,
28
+ addSortIndex: true,
29
+ limit: 100,
30
+ page: 1,
31
+ searchAddOns: true
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
 
@@ -1,28 +1,26 @@
1
1
  // tslint:disable:no-console
2
- // import * as redis from 'redis';
3
2
  import * as mongoose from 'mongoose';
4
3
 
5
4
  import { chevre } from '../../../lib/index';
6
5
 
6
+ const PROJECT_ID = process.env.PROJECT_ID;
7
+
7
8
  async function main() {
8
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
10
 
10
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
11
+ const catalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
11
12
 
12
- const catalogs = await offerCatalogRepo.search({
13
- limit: 100,
14
- page: 1,
15
- // id: { $in: ['0001'] },
16
- itemListElement: {
17
- id: {
18
- $all: ['901', '3001']
19
- // $in: ['1001'],
20
- // $nin: ['1005']
21
- }
22
- },
23
- itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
24
- });
25
- console.log(catalogs);
13
+ console.log('searching...');
14
+ const catalogs = await catalogRepo.search(
15
+ {
16
+ project: { id: { $eq: PROJECT_ID } },
17
+ identifier: { $eq: '0001' },
18
+ sort: { identifier: chevre.factory.sortType.Descending },
19
+ limit: 2,
20
+ page: 1
21
+ }
22
+ );
23
+ console.log('catalogs found', catalogs.map((catalog) => `${catalog.identifier} ${catalog.numberOfItems}`));
26
24
  console.log(catalogs.length);
27
25
  }
28
26
 
@@ -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,38 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const PROJECT_ID = process.env.PROJECT_ID;
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
12
+ const productRepo = new chevre.repository.Product(mongoose.connection);
13
+
14
+ const { offers } = await chevre.service.offer.product.search({
15
+ ids: ['7k7bbepxp', 'yyyyyy'],
16
+ project: { id: String(PROJECT_ID) },
17
+ itemOffered: { id: '62b90fef5b3eb4000b75150f' },
18
+ // seller?: {
19
+ // id: string;
20
+ // },
21
+ // availableAt?: {
22
+ // id: string;
23
+ // },
24
+ onlyValid: true,
25
+ // limit?: number,
26
+ // page?: number,
27
+ addSortIndex: false
28
+ })({
29
+ offer: offerRepo,
30
+ product: productRepo
31
+ });
32
+ console.log(offers.map((o) => `${o.sortIndex} ${o.id}`));
33
+ console.log(offers.length);
34
+ }
35
+
36
+ main()
37
+ .then(console.log)
38
+ .catch(console.error);
@@ -0,0 +1,22 @@
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 taskRepo = new chevre.repository.Task(mongoose.connection);
10
+
11
+ const tasks = await taskRepo.search({
12
+ limit: 100,
13
+ page: 1,
14
+ id: { $eq: '63b7a54d8ba861284895937f' }
15
+ });
16
+ console.log(tasks);
17
+ console.log(tasks.length);
18
+ }
19
+
20
+ main()
21
+ .then(console.log)
22
+ .catch(console.error);
@@ -6,19 +6,14 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
8
 
9
- const accountRepo = new chevre.repository.Account(mongoose.connection);
10
- const permitRepo = new chevre.repository.ServiceOutput(mongoose.connection);
9
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
10
 
12
- let updateResult = await accountRepo.unsetUnnecessaryFields({
13
- filter: { status: { $exists: true } },
14
- $unset: { status: 1 }
11
+ let updateResult: any;
12
+ updateResult = await offerRepo.unsetUnnecessaryFields({
13
+ filter: { 'category.project': { $exists: true } },
14
+ $unset: { 'category.project': 1 }
15
15
  });
16
- console.log('accounts unset.', updateResult);
17
- updateResult = await permitRepo.unsetUnnecessaryFields({
18
- filter: { 'paymentAccount.accountType': { $exists: true } },
19
- $unset: { 'paymentAccount.accountType': 1 }
20
- });
21
- console.log('permits unset', updateResult);
16
+ console.log('offers unset', updateResult);
22
17
  }
23
18
 
24
19
  main()
@@ -19,6 +19,7 @@ function handleMongoError(error) {
19
19
  if (handledError instanceof mongoose_1.mongo.MongoError) {
20
20
  switch (handledError.code) {
21
21
  case MongoErrorCode.DuplicateKey:
22
+ handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
22
23
  // no op
23
24
  break;
24
25
  case MongoErrorCode.MaxTimeMSExpired:
@@ -47,18 +47,13 @@ export declare class MongoRepository {
47
47
  /**
48
48
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
49
49
  */
50
- startExportTasks<T extends factory.account.transactionType>(status: factory.transactionStatusType): Promise<factory.account.transaction.ITransaction<T> | null>;
51
50
  /**
52
51
  * タスクエクスポートリトライ
53
52
  * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
54
53
  */
55
- reexportTasks(params: {
56
- intervalInMinutes: number;
57
- }): Promise<void>;
58
54
  /**
59
55
  * タスクをエクスポート済に変更する
60
56
  */
61
- setTasksExportedById(transactionId: string): Promise<void>;
62
57
  /**
63
58
  * 取引を期限切れにする
64
59
  */
@@ -76,7 +76,7 @@ class MongoRepository {
76
76
  */
77
77
  start(params) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
- return this.transactionModel.create(Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
79
+ return this.transactionModel.create(Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined }))
80
80
  .then((doc) => doc.toObject());
81
81
  });
82
82
  }
@@ -94,7 +94,7 @@ class MongoRepository {
94
94
  $in: [factory.transactionStatusType.InProgress, factory.transactionStatusType.Confirmed]
95
95
  }
96
96
  }, {
97
- $setOnInsert: Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: startDate, endDate: undefined, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported })
97
+ $setOnInsert: Object.assign(Object.assign({}, params), { status: factory.transactionStatusType.InProgress, startDate: startDate, endDate: undefined })
98
98
  }, {
99
99
  new: true,
100
100
  upsert: true
@@ -225,50 +225,56 @@ class MongoRepository {
225
225
  /**
226
226
  * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
227
227
  */
228
- startExportTasks(status) {
229
- return __awaiter(this, void 0, void 0, function* () {
230
- return this.transactionModel.findOneAndUpdate({
231
- status: status,
232
- tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
233
- }, { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting }, { new: true })
234
- .exec()
235
- // tslint:disable-next-line:no-null-keyword
236
- .then((doc) => (doc === null) ? null : doc.toObject());
237
- });
238
- }
228
+ // public async startExportTasks<T extends factory.account.transactionType>(
229
+ // status: factory.transactionStatusType
230
+ // ): Promise<factory.account.transaction.ITransaction<T> | null> {
231
+ // return this.transactionModel.findOneAndUpdate(
232
+ // {
233
+ // status: status,
234
+ // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
235
+ // },
236
+ // { tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting },
237
+ // { new: true }
238
+ // )
239
+ // .exec()
240
+ // // tslint:disable-next-line:no-null-keyword
241
+ // .then((doc) => (doc === null) ? null : doc.toObject());
242
+ // }
239
243
  // tslint:disable-next-line:no-suspicious-comment
240
244
  /**
241
245
  * タスクエクスポートリトライ
242
246
  * TODO updatedAtを基準にしているが、タスクエクスポートトライ日時を持たせた方が安全か?
243
247
  */
244
- reexportTasks(params) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- yield this.transactionModel.updateMany({
247
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
248
- updatedAt: {
249
- $lt: moment()
250
- .add(-params.intervalInMinutes, 'minutes')
251
- .toDate()
252
- }
253
- }, {
254
- tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
255
- })
256
- .exec();
257
- });
258
- }
248
+ // public async reexportTasks(params: { intervalInMinutes: number }): Promise<void> {
249
+ // await this.transactionModel.updateMany(
250
+ // {
251
+ // tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
252
+ // updatedAt: {
253
+ // $lt: moment()
254
+ // .add(-params.intervalInMinutes, 'minutes')
255
+ // .toDate()
256
+ // }
257
+ // },
258
+ // {
259
+ // tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
260
+ // }
261
+ // )
262
+ // .exec();
263
+ // }
259
264
  /**
260
265
  * タスクをエクスポート済に変更する
261
266
  */
262
- setTasksExportedById(transactionId) {
263
- return __awaiter(this, void 0, void 0, function* () {
264
- yield this.transactionModel.findByIdAndUpdate(transactionId, {
265
- tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
266
- tasksExportedAt: moment()
267
- .toDate()
268
- })
269
- .exec();
270
- });
271
- }
267
+ // public async setTasksExportedById(transactionId: string): Promise<void> {
268
+ // await this.transactionModel.findByIdAndUpdate(
269
+ // transactionId,
270
+ // {
271
+ // tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
272
+ // tasksExportedAt: moment()
273
+ // .toDate()
274
+ // }
275
+ // )
276
+ // .exec();
277
+ // }
272
278
  /**
273
279
  * 取引を期限切れにする
274
280
  */
@@ -35,13 +35,6 @@ export declare class MongoRepository {
35
35
  }): Promise<IObject>;
36
36
  count(params: factory.authorization.ISearchConditions): Promise<number>;
37
37
  search(params: factory.authorization.ISearchConditions): Promise<factory.authorization.IAuthorization[]>;
38
- deleteByCode(params: {
39
- code: string;
40
- }): Promise<{
41
- n?: number;
42
- ok?: number;
43
- deletedCount?: number;
44
- } | null>;
45
38
  /**
46
39
  * 有効期限を一定期間過ぎた承認を削除する
47
40
  */
@@ -204,23 +204,6 @@ class MongoRepository {
204
204
  .then((docs) => docs.map((doc) => doc.toObject()));
205
205
  });
206
206
  }
207
- deleteByCode(params) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- return this.authorizationModel.deleteOne({
210
- code: { $exists: true, $eq: params.code }
211
- })
212
- .exec()
213
- .then((result) => {
214
- return {
215
- n: result === null || result === void 0 ? void 0 : result.n,
216
- // opTime: result.opTime,
217
- ok: result === null || result === void 0 ? void 0 : result.ok,
218
- // operationTime,
219
- deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
220
- };
221
- });
222
- });
223
- }
224
207
  /**
225
208
  * 有効期限を一定期間過ぎた承認を削除する
226
209
  */
@@ -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?: {
@@ -638,14 +638,14 @@ class MongoRepository {
638
638
  return __awaiter(this, void 0, void 0, function* () {
639
639
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
640
640
  const positiveProjectionExists = (projection !== undefined && projection !== null)
641
- ? Object.keys(projection)
642
- .some((key) => projection[key] !== 0)
641
+ ? Object.values(projection)
642
+ .some((value) => value !== 0)
643
643
  : false;
644
644
  const query = this.eventModel.find({ $and: conditions },
645
645
  // :1対応(2023-01-25~)
646
646
  (positiveProjectionExists)
647
647
  ? projection
648
- : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
648
+ : Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
649
649
  if (typeof params.limit === 'number') {
650
650
  const page = (typeof params.page === 'number') ? params.page : 1;
651
651
  query.limit(params.limit)
@@ -680,14 +680,14 @@ class MongoRepository {
680
680
  findById(params, projection) {
681
681
  return __awaiter(this, void 0, void 0, function* () {
682
682
  const positiveProjectionExists = (projection !== undefined && projection !== null)
683
- ? Object.keys(projection)
684
- .some((key) => projection[key] !== 0)
683
+ ? Object.values(projection)
684
+ .some((value) => value !== 0)
685
685
  : false;
686
686
  const doc = yield this.eventModel.findOne({ _id: params.id },
687
687
  // :1対応(2023-01-25~)
688
688
  (positiveProjectionExists)
689
689
  ? projection
690
- : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
690
+ : Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }))
691
691
  .exec();
692
692
  if (doc === null) {
693
693
  throw new factory.errors.NotFound(this.eventModel.modelName);
@@ -751,18 +751,9 @@ class MongoRepository {
751
751
  .sort({ startDate: factory.sortType.Descending })
752
752
  .cursor();
753
753
  }
754
- deleteUnnecessaryProjectAttributesById(params) {
754
+ unsetUnnecessaryFields(params) {
755
755
  return __awaiter(this, void 0, void 0, function* () {
756
- yield this.eventModel.updateOne({
757
- _id: { $eq: params.id }
758
- }, {
759
- $unset: {
760
- 'location.project': 1,
761
- 'workPerformed.project': 1,
762
- 'superEvent.location.project': 1,
763
- 'superEvent.workPerformed.project': 1
764
- }
765
- })
756
+ return this.eventModel.updateMany(params.filter, { $unset: params.$unset })
766
757
  .exec();
767
758
  });
768
759
  }
@@ -25,15 +25,10 @@ const schema = new mongoose.Schema({
25
25
  },
26
26
  agent: mongoose.SchemaTypes.Mixed,
27
27
  recipient: mongoose.SchemaTypes.Mixed,
28
- error: mongoose.SchemaTypes.Mixed,
29
- result: mongoose.SchemaTypes.Mixed,
30
28
  object: mongoose.SchemaTypes.Mixed,
31
29
  expires: Date,
32
30
  startDate: Date,
33
31
  endDate: Date,
34
- dateReturned: Date,
35
- tasksExportedAt: Date,
36
- tasksExportationStatus: String,
37
32
  potentialActions: mongoose.SchemaTypes.Mixed
38
33
  }, {
39
34
  collection: 'accountTransactions',
@@ -10,14 +10,17 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
10
10
  */
11
11
  const schema = new mongoose.Schema({
12
12
  project: mongoose.SchemaTypes.Mixed,
13
- typeOf: String,
13
+ typeOf: {
14
+ type: String,
15
+ required: true
16
+ },
14
17
  member: mongoose.SchemaTypes.Mixed
15
18
  }, {
16
19
  collection: 'members',
17
20
  id: true,
18
21
  read: 'primaryPreferred',
19
22
  writeConcern: writeConcern,
20
- strict: false,
23
+ strict: true,
21
24
  useNestedStrict: true,
22
25
  timestamps: {
23
26
  createdAt: 'createdAt',
@@ -11,8 +11,6 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
11
11
  const schema = new mongoose.Schema({
12
12
  project: mongoose.SchemaTypes.Mixed,
13
13
  _id: String,
14
- // Stringに変更(2022-08-08~)
15
- // identifier: mongoose.SchemaTypes.Mixed,
16
14
  identifier: String,
17
15
  typeOf: String,
18
16
  name: mongoose.SchemaTypes.Mixed,
@@ -21,16 +19,16 @@ const schema = new mongoose.Schema({
21
19
  color: mongoose.SchemaTypes.Mixed,
22
20
  additionalProperty: [mongoose.SchemaTypes.Mixed],
23
21
  alternateName: mongoose.SchemaTypes.Mixed,
24
- acceptedPaymentMethod: mongoose.SchemaTypes.Mixed,
25
- addOn: mongoose.SchemaTypes.Mixed,
26
- availableAddOn: mongoose.SchemaTypes.Mixed,
22
+ // acceptedPaymentMethod: mongoose.SchemaTypes.Mixed, // 削除(2023-02-27~)
23
+ addOn: [mongoose.SchemaTypes.Mixed],
24
+ // availableAddOn: mongoose.SchemaTypes.Mixed, // 削除(2023-02-27~)
27
25
  availability: String,
28
- availabilityEnds: Date,
29
- availabilityStarts: Date,
30
- availableAtOrFrom: mongoose.SchemaTypes.Mixed,
26
+ // availabilityEnds: Date, // 削除(2023-02-27~)
27
+ // availabilityStarts: Date, // 削除(2023-02-27~)
28
+ availableAtOrFrom: [mongoose.SchemaTypes.Mixed],
31
29
  hasMerchantReturnPolicy: mongoose.SchemaTypes.Mixed,
32
30
  itemOffered: mongoose.SchemaTypes.Mixed,
33
- price: Number,
31
+ // price: Number, // 削除(2023-02-27~)
34
32
  priceCurrency: String,
35
33
  priceSpecification: mongoose.SchemaTypes.Mixed,
36
34
  eligibleCustomerType: mongoose.SchemaTypes.Mixed,
@@ -196,6 +194,18 @@ schema.index({ additionalProperty: 1, 'priceSpecification.price': 1 }, {
196
194
  additionalProperty: { $exists: true }
197
195
  }
198
196
  });
197
+ schema.index({ validFrom: 1, 'priceSpecification.price': 1 }, {
198
+ name: 'searchByValidFrom',
199
+ partialFilterExpression: {
200
+ validFrom: { $exists: true }
201
+ }
202
+ });
203
+ schema.index({ validThrough: 1, 'priceSpecification.price': 1 }, {
204
+ name: 'searchByValidThrough',
205
+ partialFilterExpression: {
206
+ validThrough: { $exists: true }
207
+ }
208
+ });
199
209
  mongoose.model(modelName, schema)
200
210
  .on('index',
201
211
  // tslint:disable-next-line:no-single-line-block-comment