@chevre/domain 20.2.0-alpha.4 → 20.2.0-alpha.40

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 (116) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +112 -0
  3. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  4. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  5. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  6. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  7. package/example/src/chevre/processReserve.ts +2 -0
  8. package/example/src/chevre/searchEventIds.ts +24 -0
  9. package/example/src/chevre/searchEventTicketOffers.ts +4 -4
  10. package/example/src/chevre/searchEvents.ts +20 -41
  11. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  12. package/example/src/chevre/updateTransaction.ts +38 -0
  13. package/lib/chevre/factory/event.d.ts +2 -0
  14. package/lib/chevre/factory/event.js +2 -0
  15. package/lib/chevre/repo/action.d.ts +67 -0
  16. package/lib/chevre/repo/action.js +209 -0
  17. package/lib/chevre/repo/aggregation.d.ts +37 -0
  18. package/lib/chevre/repo/aggregation.js +67 -0
  19. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  20. package/lib/chevre/repo/assetTransaction.js +148 -0
  21. package/lib/chevre/repo/event.d.ts +62 -16
  22. package/lib/chevre/repo/event.js +458 -156
  23. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  24. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  25. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  26. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  27. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  28. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  29. package/lib/chevre/repo/offer.d.ts +10 -0
  30. package/lib/chevre/repo/offer.js +47 -16
  31. package/lib/chevre/repo/order.d.ts +2 -0
  32. package/lib/chevre/repo/order.js +29 -7
  33. package/lib/chevre/repo/place.d.ts +26 -1
  34. package/lib/chevre/repo/place.js +216 -12
  35. package/lib/chevre/repo/product.d.ts +1 -0
  36. package/lib/chevre/repo/product.js +5 -0
  37. package/lib/chevre/repo/project.d.ts +4 -1
  38. package/lib/chevre/repo/project.js +9 -10
  39. package/lib/chevre/repo/reservation.d.ts +0 -6
  40. package/lib/chevre/repo/reservation.js +106 -66
  41. package/lib/chevre/repo/task.d.ts +31 -3
  42. package/lib/chevre/repo/task.js +141 -27
  43. package/lib/chevre/repo/transaction.d.ts +45 -5
  44. package/lib/chevre/repo/transaction.js +187 -29
  45. package/lib/chevre/repo/trip.js +33 -27
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  49. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -59
  50. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  51. package/lib/chevre/service/aggregation/system.d.ts +93 -0
  52. package/lib/chevre/service/aggregation/system.js +377 -0
  53. package/lib/chevre/service/aggregation.d.ts +2 -0
  54. package/lib/chevre/service/aggregation.js +3 -1
  55. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  57. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  58. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  59. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  60. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  61. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  62. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  63. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  64. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  65. package/lib/chevre/service/assetTransaction/reserve.js +119 -94
  66. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  67. package/lib/chevre/service/delivery/factory.js +1 -0
  68. package/lib/chevre/service/event.d.ts +2 -4
  69. package/lib/chevre/service/event.js +35 -14
  70. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  71. package/lib/chevre/service/offer/event/authorize.js +26 -87
  72. package/lib/chevre/service/offer/event/cancel.js +0 -1
  73. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  74. package/lib/chevre/service/offer/event/factory.js +25 -5
  75. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +13 -7
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +81 -45
  77. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  78. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  79. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  80. package/lib/chevre/service/offer/factory.js +10 -3
  81. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  82. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  83. package/lib/chevre/service/offer/product.d.ts +1 -0
  84. package/lib/chevre/service/offer/product.js +6 -2
  85. package/lib/chevre/service/offer.d.ts +5 -1
  86. package/lib/chevre/service/offer.js +67 -46
  87. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  88. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  89. package/lib/chevre/service/order/placeOrder.js +16 -0
  90. package/lib/chevre/service/order/returnOrder.js +1 -1
  91. package/lib/chevre/service/order/sendOrder.js +4 -2
  92. package/lib/chevre/service/payment/any.d.ts +5 -0
  93. package/lib/chevre/service/payment/any.js +1 -1
  94. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  95. package/lib/chevre/service/payment/movieTicket.js +8 -2
  96. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  99. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  100. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -1
  101. package/lib/chevre/service/reserve/useReservation.js +7 -2
  102. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  103. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  104. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  105. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  106. package/lib/chevre/service/task/returnPayTransaction.js +5 -1
  107. package/lib/chevre/service/task.js +6 -9
  108. package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
  109. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  110. package/lib/chevre/service/transaction/placeOrderInProgress.js +7 -7
  111. package/lib/chevre/service/transaction/returnOrder.js +3 -3
  112. package/lib/chevre/settings.d.ts +2 -0
  113. package/lib/chevre/settings.js +7 -2
  114. package/package.json +3 -3
  115. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  116. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -0,0 +1,37 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import * as redis from 'redis';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: <string>process.env.PROJECT_ID };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
+ const client = redis.createClient({
12
+ host: process.env.REDIS_HOST,
13
+ port: Number(process.env.REDIS_PORT),
14
+ password: process.env.REDIS_KEY
15
+ });
16
+
17
+ // const now = new Date();
18
+ await chevre.service.aggregation.event.aggregateScreeningEvent({
19
+ id: 'alb35u7m4'
20
+ })({
21
+ event: new chevre.repository.Event(mongoose.connection),
22
+ eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
23
+ offer: new chevre.repository.Offer(mongoose.connection),
24
+ offerRateLimit: new chevre.repository.rateLimit.Offer(client),
25
+ place: new chevre.repository.Place(mongoose.connection),
26
+ product: new chevre.repository.Product(mongoose.connection),
27
+ project: new chevre.repository.Project(mongoose.connection),
28
+ reservation: new chevre.repository.Reservation(mongoose.connection),
29
+ task: new chevre.repository.Task(mongoose.connection)
30
+ });
31
+ }
32
+
33
+ main()
34
+ .then(() => {
35
+ console.log('success!');
36
+ })
37
+ .catch(console.error);
@@ -0,0 +1,112 @@
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
+ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
8
+ const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
9
+ const AGGREGATE_CLIENT_IDS = (typeof process.env.AGGREGATE_CLIENT_IDS === 'string') ? process.env.AGGREGATE_CLIENT_IDS.split(',') : [];
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
15
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
16
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
17
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
18
+ const actionRepo = new chevre.repository.Action(mongoose.connection);
19
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
20
+
21
+ await aggregationRepo.aggregationModel.deleteMany({
22
+ typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
23
+ })
24
+ .exec();
25
+
26
+ await chevre.service.aggregation.system.aggregatePayTransaction({
27
+ aggregationDays: AGGREGATE_DAYS,
28
+ excludedProjectId: EXCLUDED_PROJECT_ID
29
+ })({
30
+ agregation: aggregationRepo,
31
+ assetTransaction: assetTransactionRepo
32
+ });
33
+
34
+ await chevre.service.aggregation.system.aggregateEvent({
35
+ aggregationDays: AGGREGATE_DAYS,
36
+ excludedProjectId: EXCLUDED_PROJECT_ID
37
+ })({
38
+ agregation: aggregationRepo,
39
+ event: eventRepo
40
+ });
41
+
42
+ await chevre.service.aggregation.system.aggregateTask({
43
+ aggregationDays: AGGREGATE_DAYS,
44
+ excludedProjectId: EXCLUDED_PROJECT_ID
45
+ })({
46
+ agregation: aggregationRepo,
47
+ task: taskRepo
48
+ });
49
+
50
+ await chevre.service.aggregation.system.aggregateReserveTransaction({
51
+ aggregationDays: AGGREGATE_DAYS,
52
+ excludedProjectId: EXCLUDED_PROJECT_ID
53
+ })({
54
+ agregation: aggregationRepo,
55
+ assetTransaction: assetTransactionRepo
56
+ });
57
+
58
+ await chevre.service.aggregation.system.aggregatePlaceOrder({
59
+ aggregationDays: AGGREGATE_DAYS,
60
+ excludedProjectId: EXCLUDED_PROJECT_ID,
61
+ clientIds: AGGREGATE_CLIENT_IDS
62
+ })({
63
+ agregation: aggregationRepo,
64
+ transaction: transactionRepo
65
+ });
66
+
67
+ await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
68
+ aggregationDays: AGGREGATE_DAYS,
69
+ excludedProjectId: EXCLUDED_PROJECT_ID
70
+ })({
71
+ agregation: aggregationRepo,
72
+ action: actionRepo
73
+ });
74
+
75
+ await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
76
+ aggregationDays: AGGREGATE_DAYS,
77
+ excludedProjectId: EXCLUDED_PROJECT_ID
78
+ })({
79
+ agregation: aggregationRepo,
80
+ action: actionRepo
81
+ });
82
+
83
+ await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
84
+ aggregationDays: AGGREGATE_DAYS,
85
+ excludedProjectId: EXCLUDED_PROJECT_ID
86
+ })({
87
+ agregation: aggregationRepo,
88
+ action: actionRepo
89
+ });
90
+
91
+ await chevre.service.aggregation.system.aggregateUseAction({
92
+ aggregationDays: AGGREGATE_DAYS,
93
+ excludedProjectId: EXCLUDED_PROJECT_ID
94
+ })({
95
+ agregation: aggregationRepo,
96
+ action: actionRepo
97
+ });
98
+
99
+ await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
100
+ aggregationDays: AGGREGATE_DAYS,
101
+ excludedProjectId: EXCLUDED_PROJECT_ID
102
+ })({
103
+ agregation: aggregationRepo,
104
+ action: actionRepo
105
+ });
106
+ }
107
+
108
+ main()
109
+ .then(() => {
110
+ console.log('success!');
111
+ })
112
+ .catch(console.error);
@@ -0,0 +1,27 @@
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 placeRepo = new chevre.repository.Place(mongoose.connection);
10
+
11
+ const event = await placeRepo.findScreeningRoomsByBranchCode({
12
+ branchCode: {
13
+ $eq: '20'
14
+ },
15
+ containedInPlace: {
16
+ id: {
17
+ $eq: '5bfb841d5a78d7948369979a'
18
+ }
19
+ }
20
+ });
21
+ console.log('room found', event);
22
+
23
+ }
24
+
25
+ main()
26
+ .then(console.log)
27
+ .catch(console.error);
@@ -14,6 +14,7 @@ async function main() {
14
14
  const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
15
15
  const eventRepo = new chevre.repository.Event(mongoose.connection);
16
16
  const placeRepo = new chevre.repository.Place(mongoose.connection);
17
+ const sellerRepo = new chevre.repository.Seller(mongoose.connection);
17
18
 
18
19
  await chevre.service.event.importFromCOA({
19
20
  project: {
@@ -28,7 +29,13 @@ async function main() {
28
29
  .toDate(),
29
30
  saveMovieTheater: false,
30
31
  saveScreeningEventSeries: false
31
- })({ action: actionRepo, categoryCode: categoryCodeRepo, event: eventRepo, place: placeRepo });
32
+ })({
33
+ action: actionRepo,
34
+ categoryCode: categoryCodeRepo,
35
+ event: eventRepo,
36
+ place: placeRepo,
37
+ seller: sellerRepo
38
+ });
32
39
  console.log('imported');
33
40
  }
34
41
 
@@ -21,7 +21,8 @@ async function main() {
21
21
  typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
22
22
  startDate: {
23
23
  $gte: moment()
24
- .add(-1, 'month')
24
+ // tslint:disable-next-line:no-magic-numbers
25
+ .add(-6, 'months')
25
26
  .toDate()
26
27
  }
27
28
  // _id: { $eq: 'al6aff83w' }
@@ -0,0 +1,51 @@
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
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const projectRepo = new chevre.repository.Project(mongoose.connection);
12
+
13
+ const cursor = projectRepo.getCursor(
14
+ {
15
+ },
16
+ {
17
+ // _id: 1,
18
+ }
19
+ );
20
+ console.log('projects found');
21
+
22
+ let i = 0;
23
+ let updateCount = 0;
24
+ // tslint:disable-next-line:max-func-body-length
25
+ await cursor.eachAsync(async (doc) => {
26
+ i += 1;
27
+ const project: chevre.factory.project.IProject = doc.toObject();
28
+
29
+ const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
30
+ const alreadyMigrated = useEventServiceAsProduct === true;
31
+
32
+ if (alreadyMigrated) {
33
+ console.log('already migrated.', project.id, i);
34
+ } else {
35
+ console.log(
36
+ 'updating product...', project.id, i);
37
+ await projectRepo.findByIdAndIUpdate({
38
+ id: project.id,
39
+ subscription: { useEventServiceAsProduct: true }
40
+ });
41
+ updateCount += 1;
42
+ console.log('updated...', project.id, i);
43
+ }
44
+ });
45
+ console.log(i, 'projects checked');
46
+ console.log(updateCount, 'projects updated');
47
+ }
48
+
49
+ main()
50
+ .then()
51
+ .catch(console.error);
@@ -63,6 +63,8 @@ async function main() {
63
63
  ],
64
64
  reservationFor: { id: 'ckuz8uj0c' }
65
65
  },
66
+ validateEvent: false,
67
+ validateEventOfferPeriod: false,
66
68
  validateAppliesToMovieTicket: true
67
69
  })({
68
70
  eventAvailability: itemAvailabilityRepo,
@@ -0,0 +1,24 @@
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 eventRepo = new chevre.repository.Event(mongoose.connection);
12
+
13
+ const ids = await eventRepo.searchIds({
14
+ typeOf: chevre.factory.eventType.ScreeningEvent,
15
+ project: { id: { $eq: PROJECT_ID } },
16
+ id: { $in: ['al6afe7ad', 'al6afe7ae'] }
17
+ });
18
+ console.log(ids);
19
+ console.log(ids.length);
20
+ }
21
+
22
+ main()
23
+ .then(console.log)
24
+ .catch(console.error);
@@ -21,9 +21,10 @@ async function main() {
21
21
  const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
- const offers = await chevre.service.offer.event.searchEventTicketOffers({
24
+ const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
25
  event: { id: 'al9ew43f5' },
26
- onlyValid: true
26
+ onlyValid: true,
27
+ sort: true
27
28
  // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
28
29
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
29
30
  })({
@@ -33,8 +34,7 @@ async function main() {
33
34
  priceSpecification: priceSpecificationRepo,
34
35
  product: productRepo
35
36
  });
36
- // console.log(offers);
37
- console.log(offers.length);
37
+ console.log(ticketOffers.length);
38
38
  }
39
39
 
40
40
  main()
@@ -1,5 +1,4 @@
1
1
  // tslint:disable:no-console
2
- import * as moment from 'moment';
3
2
  import * as mongoose from 'mongoose';
4
3
 
5
4
  import { chevre } from '../../../lib/index';
@@ -11,47 +10,27 @@ async function main() {
11
10
 
12
11
  const eventRepo = new chevre.repository.Event(mongoose.connection);
13
12
 
14
- const events = await eventRepo.search({
15
- limit: 100,
16
- page: 1,
17
- sort: { startDate: 1 },
18
- typeOf: chevre.factory.eventType.ScreeningEvent,
19
- project: { id: { $eq: PROJECT_ID } },
20
- offers: {
21
- seller: {
22
- makesOffer: {
23
- $elemMatch: {
24
- 'availableAtOrFrom.id': { $eq: '5h3gs22mu9j3ok7o63uog9o9i3' },
25
- availabilityEnds: {
26
- $gte: moment('2022-11-18T02:20:00.000Z')
27
- .toDate(),
28
- $lte: moment('2022-11-18T02:20:00.000Z')
29
- .toDate()
30
- },
31
- availabilityStarts: {
32
- $gte: moment('2022-11-15T15:00:00.000Z')
33
- .toDate(),
34
- $lte: moment('2022-11-15T15:00:00.000Z')
35
- .toDate()
36
- },
37
- validFrom: {
38
- $gte: moment('2022-11-15T15:00:00.000Z')
39
- .toDate(),
40
- $lte: moment('2022-11-15T15:00:00.000Z')
41
- .toDate()
42
- },
43
- validThrough: {
44
- $gte: moment('2022-11-18T02:20:00.000Z')
45
- .toDate(),
46
- $lte: moment('2022-11-18T02:20:00.000Z')
47
- .toDate()
48
- }
49
- }
50
- }
51
- }
13
+ const event = await eventRepo.findById(
14
+ { id: 'al6aff83y' },
15
+ {
16
+ name: 1
17
+ }
18
+ );
19
+ console.log('event found', event);
20
+
21
+ const events = await eventRepo.search(
22
+ {
23
+ limit: 100,
24
+ page: 1,
25
+ sort: { startDate: 1 },
26
+ typeOf: chevre.factory.eventType.ScreeningEvent,
27
+ project: { id: { $eq: PROJECT_ID } },
28
+ id: { $in: ['al6aff83y'] }
52
29
  },
53
- id: { $in: ['al6aff83y'] }
54
- });
30
+ {
31
+ name: 1
32
+ }
33
+ );
55
34
  console.log(events);
56
35
  console.log(events.length);
57
36
  }
@@ -0,0 +1,27 @@
1
+ // tslint:disable:no-console
2
+ // import * as redis from 'redis';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const offers = await offerRepo.findOffersByOfferCatalogId({
13
+ ids: ['al96nqj7z', 'xxx', '1001'],
14
+ // ids: ['xx', 'xxx'],
15
+ offerCatalog: {
16
+ id: '0001'
17
+ // id: 'xxx'
18
+ },
19
+ sort: true
20
+ });
21
+ console.log(offers.map((o) => o.id));
22
+ console.log(offers.length);
23
+ }
24
+
25
+ main()
26
+ .then(console.log)
27
+ .catch(console.error);
@@ -0,0 +1,38 @@
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
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
+
10
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
11
+ const transactionId = '63ce4d501c45c2000bdb2f9d';
12
+ let update = {
13
+ $set: { 'object.modifiedTime': new Date() }
14
+ };
15
+
16
+ let now = moment();
17
+ await transactionRepo.findByIdAndUpdate({
18
+ id: transactionId,
19
+ update
20
+ });
21
+ console.log(moment()
22
+ .diff(now));
23
+
24
+ update = {
25
+ $set: { 'object.modifiedTime': new Date() }
26
+ };
27
+ now = moment();
28
+ // await transactionRepo.updateById({
29
+ // id: transactionId,
30
+ // update
31
+ // });
32
+ console.log(moment()
33
+ .diff(now));
34
+ }
35
+
36
+ main()
37
+ .then()
38
+ .catch(console.error);
@@ -0,0 +1,2 @@
1
+ import * as factory from '../factory';
2
+ export declare type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,6 +7,23 @@ export interface IUseActionCountByOffer {
7
7
  _id: string[];
8
8
  useActionCount?: number;
9
9
  }
10
+ interface IAggregationByStatus {
11
+ actionCount: number;
12
+ avgDuration: number;
13
+ maxDuration: number;
14
+ minDuration: number;
15
+ percentilesDuration: {
16
+ name: string;
17
+ value: number;
18
+ }[];
19
+ }
20
+ interface IStatus {
21
+ status: factory.actionStatusType;
22
+ aggregation: IAggregationByStatus;
23
+ }
24
+ interface IAggregateAction {
25
+ statuses: IStatus[];
26
+ }
10
27
  export { modelName };
11
28
  /**
12
29
  * アクションリポジトリ
@@ -107,4 +124,54 @@ export declare class MongoRepository {
107
124
  deleteEndDatePassedCertainPeriod(params: {
108
125
  $lt: Date;
109
126
  }): Promise<void>;
127
+ aggregateAuthorizeEventServiceOfferAction(params: {
128
+ project?: {
129
+ id?: {
130
+ $ne?: string;
131
+ };
132
+ };
133
+ startFrom: Date;
134
+ startThrough: Date;
135
+ typeOf: factory.actionType;
136
+ }): Promise<IAggregateAction>;
137
+ aggregateAuthorizePaymentAction(params: {
138
+ project?: {
139
+ id?: {
140
+ $ne?: string;
141
+ };
142
+ };
143
+ startFrom: Date;
144
+ startThrough: Date;
145
+ typeOf: factory.actionType;
146
+ }): Promise<IAggregateAction>;
147
+ aggregateAuthorizeOrderAction(params: {
148
+ project?: {
149
+ id?: {
150
+ $ne?: string;
151
+ };
152
+ };
153
+ startFrom: Date;
154
+ startThrough: Date;
155
+ typeOf: factory.actionType;
156
+ }): Promise<IAggregateAction>;
157
+ aggregateUseAction(params: {
158
+ project?: {
159
+ id?: {
160
+ $ne?: string;
161
+ };
162
+ };
163
+ startFrom: Date;
164
+ startThrough: Date;
165
+ typeOf: factory.actionType;
166
+ }): Promise<IAggregateAction>;
167
+ aggregateCheckMovieTicketAction(params: {
168
+ project?: {
169
+ id?: {
170
+ $ne?: string;
171
+ };
172
+ };
173
+ startFrom: Date;
174
+ startThrough: Date;
175
+ }): Promise<IAggregateAction>;
176
+ private agggregateByStatus;
110
177
  }