@chevre/domain 22.0.0-alpha.9 → 22.0.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 (117) hide show
  1. package/example/src/chevre/aggregateAllEvents2.ts +3 -1
  2. package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +56 -52
  3. package/example/src/chevre/changeOrderStatus.ts +29 -0
  4. package/example/src/chevre/projectEventFieldsById.ts +35 -0
  5. package/example/src/chevre/projectOrderFieldsById.ts +41 -0
  6. package/example/src/chevre/searchEvents.ts +8 -7
  7. package/example/src/chevre/searchOrders.ts +14 -4
  8. package/example/src/chevre/sendGrid/filterEmailActivity.ts +33 -0
  9. package/lib/chevre/credentials.d.ts +0 -5
  10. package/lib/chevre/credentials.js +0 -13
  11. package/lib/chevre/emailMessageBuilder.d.ts +3 -5
  12. package/lib/chevre/factory/event.d.ts +3 -1
  13. package/lib/chevre/index.d.ts +1 -0
  14. package/lib/chevre/repo/aggregateReservation.js +14 -4
  15. package/lib/chevre/repo/event.d.ts +13 -6
  16. package/lib/chevre/repo/event.js +58 -68
  17. package/lib/chevre/repo/order.d.ts +16 -7
  18. package/lib/chevre/repo/order.js +93 -56
  19. package/lib/chevre/repo/rateLimit/offer.js +0 -8
  20. package/lib/chevre/repo/stockHolder.js +0 -7
  21. package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +0 -2
  22. package/lib/chevre/service/aggregation/event/aggregateOffers.js +6 -4
  23. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +12 -1
  24. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +5 -7
  25. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -2
  26. package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +7 -3
  27. package/lib/chevre/service/assetTransaction/pay.js +1 -1
  28. package/lib/chevre/service/assetTransaction/reserve/confirm.js +1 -1
  29. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +4 -0
  30. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -2
  31. package/lib/chevre/service/assetTransaction/reserve/start.js +14 -15
  32. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +1 -1
  33. package/lib/chevre/service/offer/event/authorize/factory.d.ts +1 -1
  34. package/lib/chevre/service/offer/event/authorize/factory.js +2 -1
  35. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  36. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -1
  37. package/lib/chevre/service/offer/event/authorize.js +9 -11
  38. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
  39. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +13 -5
  40. package/lib/chevre/service/offer/event/voidTransaction.d.ts +6 -4
  41. package/lib/chevre/service/offer/event/voidTransaction.js +16 -5
  42. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +4 -1
  43. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +5 -1
  44. package/lib/chevre/service/offer/event.js +0 -1
  45. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +6 -4
  46. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +5 -3
  47. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +5 -2
  48. package/lib/chevre/service/offer.js +3 -2
  49. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +1 -1
  50. package/lib/chevre/service/order/deleteOrder.js +1 -1
  51. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +29 -18
  52. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +1 -1
  53. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +1 -1
  54. package/lib/chevre/service/order/returnOrder.js +1 -1
  55. package/lib/chevre/service/order/sendOrder.js +2 -2
  56. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +6 -7
  57. package/lib/chevre/service/payment/movieTicket/factory.d.ts +13 -2
  58. package/lib/chevre/service/payment/movieTicket/factory.js +12 -5
  59. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +6 -2
  60. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +11 -1
  61. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +12 -5
  62. package/lib/chevre/service/payment/movieTicket/validation.js +4 -3
  63. package/lib/chevre/service/payment.js +2 -2
  64. package/lib/chevre/service/reserve/searchByOrder.js +1 -1
  65. package/lib/chevre/service/task/acceptCOAOffer.js +8 -17
  66. package/lib/chevre/service/task/aggregateOffers.js +11 -13
  67. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +9 -9
  68. package/lib/chevre/service/task/cancelMoneyTransfer.js +5 -5
  69. package/lib/chevre/service/task/cancelPendingReservation.js +2 -2
  70. package/lib/chevre/service/task/cancelReservation.js +2 -2
  71. package/lib/chevre/service/task/confirmMoneyTransfer.js +6 -6
  72. package/lib/chevre/service/task/confirmPayTransaction.js +10 -14
  73. package/lib/chevre/service/task/confirmRegisterService.js +4 -4
  74. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +6 -6
  75. package/lib/chevre/service/task/confirmReserveTransaction.js +9 -17
  76. package/lib/chevre/service/task/createAccountingReport.js +5 -2
  77. package/lib/chevre/service/task/createEvent.js +5 -5
  78. package/lib/chevre/service/task/deleteTransaction.js +13 -13
  79. package/lib/chevre/service/task/givePointAward.js +7 -7
  80. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +4 -12
  81. package/lib/chevre/service/task/importEventsFromCOA.js +4 -12
  82. package/lib/chevre/service/task/importOffersFromCOA.js +5 -13
  83. package/lib/chevre/service/task/moneyTransfer.js +5 -5
  84. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +0 -3
  85. package/lib/chevre/service/task/onOrderPaymentCompleted.js +0 -3
  86. package/lib/chevre/service/task/pay.js +2 -2
  87. package/lib/chevre/service/task/placeOrder.js +2 -2
  88. package/lib/chevre/service/task/refund.js +2 -2
  89. package/lib/chevre/service/task/registerService.js +6 -6
  90. package/lib/chevre/service/task/reserve.js +2 -2
  91. package/lib/chevre/service/task/returnMoneyTransfer.js +9 -9
  92. package/lib/chevre/service/task/returnPayTransaction.js +12 -12
  93. package/lib/chevre/service/task/returnPointAward.js +7 -7
  94. package/lib/chevre/service/task/returnReserveTransaction.js +5 -13
  95. package/lib/chevre/service/task/sendEmailMessage.js +2 -2
  96. package/lib/chevre/service/task/sendOrder.js +2 -2
  97. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -6
  98. package/lib/chevre/service/task/voidPayTransaction.js +2 -2
  99. package/lib/chevre/service/task/voidPayment.js +2 -2
  100. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +6 -9
  101. package/lib/chevre/service/task/voidReserveTransaction.js +7 -15
  102. package/lib/chevre/service/task.d.ts +13 -4
  103. package/lib/chevre/service/task.js +2 -12
  104. package/lib/chevre/service/transaction/moneyTransfer.js +6 -3
  105. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
  106. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +1 -1
  107. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.d.ts +1 -1
  108. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +4 -6
  109. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +0 -28
  110. package/lib/chevre/service/transaction/returnOrder/preStart.js +5 -2
  111. package/lib/chevre/service/transaction/returnOrder.js +9 -6
  112. package/lib/chevre/service/validation/validateOrder.js +4 -2
  113. package/lib/chevre/settings.d.ts +6 -0
  114. package/lib/chevre/settings.js +2 -1
  115. package/package.json +3 -3
  116. package/lib/chevre/credentials/coa.d.ts +0 -17
  117. package/lib/chevre/credentials/coa.js +0 -17
@@ -35,7 +35,8 @@ export async function aggregateScreeningEvent() {
35
35
  try {
36
36
  console.log('executing...', count);
37
37
  await (await chevre.service.task.createService()).executeByName({
38
- name: chevre.factory.taskName.AggregateScreeningEvent
38
+ name: chevre.factory.taskName.AggregateScreeningEvent,
39
+ executor: { name: 'sample' }
39
40
  })({
40
41
  connection: mongoose.connection,
41
42
  redisClient,
@@ -68,6 +69,7 @@ export async function aggregateScreeningEvent() {
68
69
  deliverOrderLimit: 1,
69
70
  transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
70
71
  abortedTasksWithoutReport: [],
72
+ coa: { timeout: 1000 },
71
73
  gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
72
74
  movieticketReserve: { timeout: 1000, timeoutCheck: 1000 },
73
75
  numTryConfirmReserveTransaction: 10,
@@ -1,78 +1,82 @@
1
1
  // tslint:disable:no-console
2
2
  import * as mongoose from 'mongoose';
3
- import * as redis from 'redis';
3
+ // import * as redis from 'redis';
4
4
 
5
5
  import { chevre } from '../../../../lib/index';
6
6
 
7
7
  const project = { id: <string>process.env.PROJECT_ID };
8
- const EVENT_ID = String(process.env.EVENT_ID);
8
+ // const EVENT_ID = String(process.env.EVENT_ID);
9
9
 
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
14
- socket: {
15
- port: Number(<string>process.env.REDIS_PORT),
16
- host: <string>process.env.REDIS_HOST
17
- },
18
- password: <string>process.env.REDIS_KEY
19
- });
20
- await client.connect();
13
+ // const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
14
+ // socket: {
15
+ // port: Number(<string>process.env.REDIS_PORT),
16
+ // host: <string>process.env.REDIS_HOST
17
+ // },
18
+ // password: <string>process.env.REDIS_KEY
19
+ // });
20
+ // await client.connect();
21
21
 
22
22
  const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
23
- let aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
23
+ const aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
24
24
  {
25
- limit: 100,
25
+ limit: 10,
26
26
  page: 1,
27
27
  project: { id: { $eq: project.id } },
28
28
  reservationFor: {
29
- id: { $eq: EVENT_ID },
29
+ id: {
30
+ $in: [
31
+ 'blvcj2vfl', 'blvcj2w48',
32
+ 'blvcj2wqj', 'blvcj2y1n',
33
+ 'blvcj2ylh', 'blvcj2z7k',
34
+ 'blvcj2zqz', 'blvcj30d3',
35
+ 'blvcj30wo', 'blvcj32as'
36
+ ]
37
+ },
30
38
  typeOf: chevre.factory.eventType.ScreeningEvent
31
- }
39
+ },
40
+ sort: { 'reservationFor.startDate': 1 }
32
41
  },
33
42
  ['aggregateEntranceGate', 'aggregateOffer']
34
43
  );
35
44
  console.log('aggregateReservations:', aggregateReservations);
45
+ console.log('aggregateReservations:', aggregateReservations.map(({ id }) => id));
36
46
 
37
- await (await chevre.service.aggregation.createService()).event.aggregateOffers({
38
- id: EVENT_ID,
39
- typeOf: chevre.factory.eventType.ScreeningEvent
40
- })({
41
- aggregateReservation: aggregateReservationRepo,
42
- event: await chevre.repository.Event.createInstance(mongoose.connection),
43
- stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
44
- offer: await chevre.repository.Offer.createInstance(mongoose.connection),
45
- offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
46
- offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
47
- screeningRoom: await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection),
48
- product: await chevre.repository.Product.createInstance(mongoose.connection),
49
- reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
50
- task: await chevre.repository.Task.createInstance(mongoose.connection)
51
- });
52
- console.log('aggregateReserveAction processed.');
47
+ // await (await chevre.service.aggregation.createService()).event.aggregateOffers({
48
+ // id: EVENT_ID,
49
+ // typeOf: chevre.factory.eventType.ScreeningEvent
50
+ // })({
51
+ // aggregateReservation: aggregateReservationRepo,
52
+ // event: await chevre.repository.Event.createInstance(mongoose.connection),
53
+ // stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
54
+ // offer: await chevre.repository.Offer.createInstance(mongoose.connection),
55
+ // offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
56
+ // offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
57
+ // screeningRoom: await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection),
58
+ // product: await chevre.repository.Product.createInstance(mongoose.connection),
59
+ // reservation: await chevre.repository.Reservation.createInstance(mongoose.connection)
60
+ // });
61
+ // console.log('aggregateReserveAction processed.');
53
62
 
54
- aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
55
- {
56
- limit: 1,
57
- page: 1,
58
- sort: { 'reservationFor.startDate': 1 },
59
- project: { id: { $eq: project.id } },
60
- reservationFor: {
61
- id: {
62
- $eq: EVENT_ID,
63
- $in: [EVENT_ID]
64
- },
65
- typeOf: chevre.factory.eventType.ScreeningEvent
66
- // startFrom: moment()
67
- // .toDate(),
68
- // startThrough: moment()
69
- // .add(1, 'minutes')
70
- // .toDate()
71
- }
72
- },
73
- []
74
- );
75
- console.log('aggregateReservations:', aggregateReservations);
63
+ // aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
64
+ // {
65
+ // limit: 1,
66
+ // page: 1,
67
+ // sort: { 'reservationFor.startDate': 1 },
68
+ // project: { id: { $eq: project.id } },
69
+ // reservationFor: {
70
+ // id: {
71
+ // $eq: EVENT_ID,
72
+ // $in: [EVENT_ID]
73
+ // },
74
+ // typeOf: chevre.factory.eventType.ScreeningEvent
75
+ // }
76
+ // },
77
+ // []
78
+ // );
79
+ // console.log('aggregateReservations:', aggregateReservations);
76
80
  }
77
81
 
78
82
  main()
@@ -0,0 +1,29 @@
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, { autoIndex: false });
10
+
11
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
12
+ const result = await orderRepo.changeStatus(
13
+ {
14
+ project: {
15
+ id: project.id
16
+ },
17
+ orderNumber: 'CIN1-3723005-2440693',
18
+ orderStatus: chevre.factory.orderStatus.OrderDelivered,
19
+ previousOrderStatus: chevre.factory.orderStatus.OrderInTransit
20
+ }
21
+ );
22
+ // tslint:disable-next-line:no-null-keyword
23
+ console.dir(result, { depth: null });
24
+ console.log(result);
25
+ }
26
+
27
+ main()
28
+ .then(console.log)
29
+ .catch(console.error);
@@ -0,0 +1,35 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ const startTime = process.hrtime();
5
+ import { chevre } from '../../../lib/index';
6
+ const diff = process.hrtime(startTime);
7
+ console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
8
+
9
+ // const PROJECT_ID = process.env.PROJECT_ID;
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
15
+
16
+ const event = await eventRepo.projectFieldsById(
17
+ {
18
+ // id: '120162210202407171202250'
19
+ id: 'blxonxv1m'
20
+ },
21
+ // [
22
+ // 'project', 'organizer', 'typeOf',
23
+ // 'name', 'doorTime', 'endDate', 'eventStatus',
24
+ // 'location', 'startDate', 'superEvent',
25
+ // 'offers'
26
+ // ]
27
+ ['project', 'startDate', 'typeOf', 'superEvent.location.id']
28
+ );
29
+ // tslint:disable-next-line:no-null-keyword
30
+ console.dir(event, { depth: null });
31
+ }
32
+
33
+ main()
34
+ .then(console.log)
35
+ .catch(console.error);
@@ -0,0 +1,41 @@
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
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
16
+ const result = await orderRepo.projectFieldsById(
17
+ {
18
+ id: '66a04d962582d528b3ba6521',
19
+ inclusion: ['orderNumber']
20
+ }
21
+ );
22
+ // tslint:disable-next-line:no-null-keyword
23
+ console.dir(result, { depth: null });
24
+
25
+ const findByOrderNumberResult = await orderRepo.projectFieldsByOrderNumber(
26
+ {
27
+ orderNumber: 'CIN0-2152162-0949752',
28
+ project: { id: project.id },
29
+ inclusion: [
30
+ // 'orderNumber', 'orderStatus', 'typeOf',
31
+ 'project'
32
+ ]
33
+ }
34
+ );
35
+ // tslint:disable-next-line:no-null-keyword
36
+ console.log(findByOrderNumberResult);
37
+ }
38
+
39
+ main()
40
+ .then(console.log)
41
+ .catch(console.error);
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  const diff = process.hrtime(startTime);
7
7
  console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
8
8
 
9
- const PROJECT_ID = process.env.PROJECT_ID;
9
+ // const PROJECT_ID = process.env.PROJECT_ID;
10
10
 
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
@@ -15,18 +15,19 @@ async function main() {
15
15
 
16
16
  const events = await eventRepo.search<chevre.factory.eventType.ScreeningEvent>(
17
17
  {
18
- limit: 100,
18
+ limit: 1,
19
19
  page: 1,
20
20
  // sort: { startDate: 1 },
21
21
  typeOf: chevre.factory.eventType.ScreeningEvent,
22
- project: { id: { $eq: PROJECT_ID } }
23
- // id: { $eq: 'al6aff83y' },
24
- // typeOfIn: [chevre.factory.eventType.Event, chevre.factory.eventType.ScreeningEvent]
22
+ // project: { id: { $eq: PROJECT_ID } },
23
+ // id: { $eq: '120162210202407171202250' }
24
+ id: { $eq: 'blxonxv1m' }
25
25
  },
26
- ['_id', 'name'],
26
+ ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'],
27
27
  []
28
28
  );
29
- console.log(events);
29
+ // tslint:disable-next-line:no-null-keyword
30
+ console.dir(events, { depth: null });
30
31
  console.log(events.length, 'events found');
31
32
  }
32
33
 
@@ -21,7 +21,7 @@ async function main() {
21
21
 
22
22
  const orders = await orderRepo.search(
23
23
  {
24
- limit: 10,
24
+ limit: 1,
25
25
  project: { id: { $eq: project.id } },
26
26
  acceptedOffers: {
27
27
  // itemOffered: {
@@ -48,11 +48,21 @@ async function main() {
48
48
  // }
49
49
  },
50
50
  {
51
- orderNumber: 1,
52
- customer: 1
51
+ inclusion: {
52
+ confirmationNumber: 1,
53
+ // customer: 1,
54
+ identifier: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
55
+ // orderedItem: 1,
56
+ // paymentMethods: 1,
57
+ price: 1, priceCurrency: 1, project: 1,
58
+ // seller: 1,
59
+ typeOf: 1
60
+ },
61
+ exclusion: {}
53
62
  }
54
63
  );
55
- console.log('orders found', orders);
64
+ // tslint:disable-next-line:no-null-keyword
65
+ console.dir(orders, { depth: null });
56
66
  console.log(orders.length, 'orders found');
57
67
  }
58
68
 
@@ -0,0 +1,33 @@
1
+ // tslint:disable:no-console
2
+ // tslint:disable-next-line:no-implicit-dependencies
3
+ import * as client from '@sendgrid/client';
4
+
5
+ // tslint:disable-next-line:max-func-body-length
6
+ async function main() {
7
+ client.setApiKey(<string>process.env.SENDGRID_API_KEY);
8
+
9
+ const queryParams = {
10
+ // "query": "from_email=\"email@example.com\"",
11
+ // "limit": 10
12
+ };
13
+
14
+ const request = {
15
+ url: `/v3/messages`,
16
+ method: 'GET',
17
+ qs: queryParams
18
+ };
19
+
20
+ client.request(request)
21
+ .then(([response, body]) => {
22
+ console.log(response.statusCode);
23
+ console.log(response.body, body);
24
+ })
25
+ .catch((error) => {
26
+ console.error(error);
27
+ });
28
+
29
+ }
30
+
31
+ main()
32
+ .then()
33
+ .catch(console.error);
@@ -1,4 +1,3 @@
1
- import type { COACredentials } from './credentials/coa';
2
1
  import type { CustomSearchCredentials } from './credentials/customSearch';
3
2
  import type { JWTCredentials } from './credentials/jwt';
4
3
  import type { LINENotifyCredentials } from './credentials/lineNotify';
@@ -7,10 +6,6 @@ import type { SendGridCredentials } from './credentials/sendGrid';
7
6
  * 外部サービス認証情報
8
7
  */
9
8
  export declare namespace credentials {
10
- type COA = COACredentials;
11
- namespace COA {
12
- function createInstance(...params: ConstructorParameters<typeof COACredentials>): Promise<COACredentials>;
13
- }
14
9
  type CustomSearch = CustomSearchCredentials;
15
10
  namespace CustomSearch {
16
11
  function createInstance(...params: ConstructorParameters<typeof CustomSearchCredentials>): Promise<CustomSearchCredentials>;
@@ -28,19 +28,6 @@ var credentials;
28
28
  // export const sendGrid = {
29
29
  // apiKey: process.env.SENDGRID_API_KEY
30
30
  // };
31
- let COA;
32
- (function (COA) {
33
- let cred;
34
- function createInstance(...params) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- if (cred === undefined) {
37
- cred = (yield Promise.resolve().then(() => require('./credentials/coa'))).COACredentials;
38
- }
39
- return new cred(...params);
40
- });
41
- }
42
- COA.createInstance = createInstance;
43
- })(COA = credentials.COA || (credentials.COA = {}));
44
31
  let CustomSearch;
45
32
  (function (CustomSearch) {
46
33
  let cred;
@@ -4,9 +4,7 @@ type ISendableEmailMessage = factory.action.transfer.send.message.email.IObjectA
4
4
  identifier: string;
5
5
  name: string;
6
6
  };
7
- export type IOrderAsCreateEmailParams = Pick<factory.order.IOrder, 'confirmationNumber' | 'identifier' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf'> & {
8
- customer: factory.order.ICustomer;
9
- };
7
+ export type IOrderAsCreateEmailParams = Pick<factory.order.IOrder, 'confirmationNumber' | 'identifier' | 'customer' | 'orderDate' | 'orderNumber' | 'orderStatus' | 'orderedItem' | 'paymentMethods' | 'price' | 'priceCurrency' | 'seller' | 'typeOf'> & {};
10
8
  /**
11
9
  * 注文配送メッセージを作成する
12
10
  */
@@ -20,7 +18,7 @@ declare function createSendOrderMessage(params: {
20
18
  * 注文返品メッセージを作成する
21
19
  */
22
20
  declare function createReturnOrderMessage(params: {
23
- order: factory.order.IOrder;
21
+ order: IOrderAsCreateEmailParams;
24
22
  email?: factory.creativeWork.message.email.ICustomization;
25
23
  emailMessage?: factory.creativeWork.message.email.ICreativeWork;
26
24
  index: number;
@@ -29,7 +27,7 @@ declare function createReturnOrderMessage(params: {
29
27
  * 返金メッセージを作成する
30
28
  */
31
29
  declare function createRefundMessage(params: {
32
- order: factory.order.IOrder;
30
+ order: IOrderAsCreateEmailParams;
33
31
  email?: factory.creativeWork.message.email.ICustomization;
34
32
  paymentMethodId: string;
35
33
  }, settings: Settings): Promise<ISendableEmailMessage>;
@@ -1,5 +1,7 @@
1
1
  import * as factory from '../factory';
2
- export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
2
+ export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> & {
3
+ superEvent?: never;
4
+ } : never;
3
5
  /**
4
6
  * 興行イベントのsuperEventを作成する
5
7
  */
@@ -13,5 +13,6 @@ import * as service from './service';
13
13
  import * as settings from './settings';
14
14
  export { credentials, errorHandler, eventEmitter, factory, repository, service, settings };
15
15
  export declare function loadPecorinoapi(): Promise<typeof Pecorinoapi>;
16
+ export type COA = typeof COAService;
16
17
  export declare function loadCOA(): Promise<typeof COAService>;
17
18
  export declare function loadGMO(): Promise<typeof GMOService>;
@@ -68,17 +68,18 @@ class AggregateReservationRepo {
68
68
  var _a;
69
69
  return __awaiter(this, void 0, void 0, function* () {
70
70
  const matchStages = AggregateReservationRepo.CREATE_MONGO_CONDITIONS(params);
71
- let projection = {
71
+ let projectStage = {
72
72
  _id: 0,
73
73
  id: '$reservationFor.id'
74
74
  };
75
75
  if (Array.isArray(inclusion) && inclusion.length > 0) {
76
76
  inclusion.forEach((field) => {
77
- projection[field] = 1;
77
+ projectStage[field] = { $ifNull: [`$${field}`, '$false'] };
78
+ // projectStage[field] = 1;
78
79
  });
79
80
  }
80
81
  else {
81
- projection = {
82
+ projectStage = {
82
83
  _id: 0,
83
84
  id: '$reservationFor.id',
84
85
  aggregateEntranceGate: 1,
@@ -91,7 +92,16 @@ class AggregateReservationRepo {
91
92
  ...(typeof sortByStartDate === 'number')
92
93
  ? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
93
94
  : [],
94
- { $project: projection }
95
+ // 現時点でreservationFor.idへのunique indexがないので、重複ドキュメント対応として、$group
96
+ {
97
+ $group: {
98
+ _id: '$reservationFor.id',
99
+ reservationFor: { $first: '$reservationFor' },
100
+ aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
101
+ aggregateOffer: { $first: '$aggregateOffer' }
102
+ }
103
+ },
104
+ { $project: projectStage }
95
105
  ]);
96
106
  if (typeof params.limit === 'number' && params.limit > 0) {
97
107
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
@@ -68,13 +68,16 @@ interface IStatus {
68
68
  interface IAggregateEvent {
69
69
  statuses: IStatus[];
70
70
  }
71
- type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'aggregateEntranceGate' | 'aggregateOffer';
71
+ export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
72
+ type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered';
73
+ /**
74
+ * minimizedEvent検索時のprojection候補
75
+ * add(2024-07-18~)
76
+ */
77
+ type IKeyOfProjection4minimizedEvent<T extends factory.eventType> = T extends factory.eventType.ScreeningEvent ? Exclude<keyof IMinimizedIndividualEvent<T>, 'additionalProperty' | 'id'> | 'superEvent.id' | 'location.branchCode' | 'superEvent.workPerformed.identifier' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id' | 'offers.offeredThrough' | 'offers.unacceptedPaymentMethod' | 'offers.eligibleQuantity' : T extends factory.eventType.Event ? Exclude<keyof IMinimizedIndividualEvent<T>, 'additionalProperty' | 'id'> | 'superEvent.id' | 'location.branchCode' | 'superEvent.workPerformed.identifier' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id' | 'offers.offeredThrough' | 'offers.unacceptedPaymentMethod' | 'offers.eligibleQuantity' : never;
72
78
  type IUnset<T extends factory.eventType> = {
73
79
  [key in keyof factory.event.IEvent<T>]?: 1;
74
80
  };
75
- export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
76
- export declare const keyOfMinimizedScreeningEvent: IKeyOfProjection<factory.eventType.ScreeningEvent>[];
77
- export declare const keyOfMinimizedEvent: IKeyOfProjection<factory.eventType.Event>[];
78
81
  /**
79
82
  * イベントリポジトリ
80
83
  */
@@ -159,9 +162,13 @@ export declare class EventRepo {
159
162
  */
160
163
  search<T extends factory.eventType>(params: ISearchConditions<T>, inclusion: IKeyOfProjection<T>[], exclusion: IKeyOfProjection<T>[]): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]>;
161
164
  searchIds<T extends factory.eventType>(params: ISearchConditions<T>): Promise<string[]>;
162
- findMinimizedIndividualEventById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
165
+ /**
166
+ * 特定イベントから指定フィールドのみ取得する
167
+ * イベント IDは必ず返ります
168
+ */
169
+ projectFieldsById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
163
170
  id: string;
164
- }): Promise<IMinimizedIndividualEvent<T>>;
171
+ }, inclusion: IKeyOfProjection4minimizedEvent<T>[]): Promise<IMinimizedIndividualEvent<T>>;
165
172
  /**
166
173
  * イベントをキャンセルする
167
174
  */