@chevre/domain 21.8.0-alpha.9 → 21.9.0-alpha.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 (132) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +30 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  5. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  7. package/example/src/chevre/optimizeCatalogs.ts +54 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/pushIncludedInDataCatalog.ts +47 -0
  12. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  13. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +26 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -1
  15. package/example/src/chevre/searchEvents.ts +9 -7
  16. package/example/src/chevre/searchOfferCatalogs.ts +7 -3
  17. package/example/src/chevre/searchOffers.ts +5 -2
  18. package/example/src/chevre/searchOffersByCatalog.ts +15 -9
  19. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  20. package/example/src/chevre/searchOrders.ts +9 -7
  21. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +85 -0
  22. package/lib/chevre/emailMessageBuilder.js +6 -5
  23. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  24. package/lib/chevre/repo/aggregateOffer.js +562 -0
  25. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  26. package/lib/chevre/repo/assetTransaction.js +54 -2
  27. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  28. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +189 -0
  29. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  30. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  31. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  32. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +3 -0
  33. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +10 -1
  34. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  35. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  36. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  37. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  38. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  39. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  40. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  41. package/lib/chevre/repo/offer.d.ts +106 -51
  42. package/lib/chevre/repo/offer.js +555 -283
  43. package/lib/chevre/repo/offerCatalog.d.ts +32 -3
  44. package/lib/chevre/repo/offerCatalog.js +97 -10
  45. package/lib/chevre/repo/order.d.ts +15 -0
  46. package/lib/chevre/repo/order.js +58 -26
  47. package/lib/chevre/repo/task.d.ts +6 -2
  48. package/lib/chevre/repo/task.js +58 -4
  49. package/lib/chevre/repository.d.ts +3 -0
  50. package/lib/chevre/repository.js +5 -1
  51. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -41
  52. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +2 -0
  53. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -40
  54. package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +16 -0
  55. package/lib/chevre/service/aggregation/event/findEventOffers.js +58 -0
  56. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  57. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  58. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  59. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  60. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  61. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  62. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  63. package/lib/chevre/service/offer/event/authorize.js +39 -35
  64. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  65. package/lib/chevre/service/offer/event/factory.js +8 -8
  66. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  67. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -0
  68. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +48 -17
  69. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  70. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  71. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  72. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  73. package/lib/chevre/service/offer/factory.d.ts +12 -4
  74. package/lib/chevre/service/offer/factory.js +9 -11
  75. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +10 -1
  76. package/lib/chevre/service/offer/product/searchProductOffers.js +51 -12
  77. package/lib/chevre/service/offer/product.d.ts +2 -0
  78. package/lib/chevre/service/offer/product.js +3 -2
  79. package/lib/chevre/service/offer.d.ts +1 -0
  80. package/lib/chevre/service/offer.js +7 -1
  81. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  82. package/lib/chevre/service/order/confirmPayTransaction.js +20 -46
  83. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  84. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  85. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  86. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  87. package/lib/chevre/service/order/onOrderStatusChanged.js +49 -9
  88. package/lib/chevre/service/order/payOrder.js +4 -45
  89. package/lib/chevre/service/order/placeOrder.js +11 -24
  90. package/lib/chevre/service/order.d.ts +3 -1
  91. package/lib/chevre/service/order.js +6 -2
  92. package/lib/chevre/service/payment/any/factory.js +33 -8
  93. package/lib/chevre/service/payment/any.js +30 -21
  94. package/lib/chevre/service/payment/creditCard.js +12 -12
  95. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  96. package/lib/chevre/service/payment/movieTicket.js +10 -11
  97. package/lib/chevre/service/payment/paymentCard.js +9 -12
  98. package/lib/chevre/service/project.js +1 -1
  99. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  100. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  101. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  102. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  103. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  104. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  105. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  106. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  107. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  108. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +2 -0
  109. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  110. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  111. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  112. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  113. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  114. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  115. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  116. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  117. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +78 -0
  118. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  119. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  120. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  122. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  123. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  124. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  125. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  126. package/lib/chevre/settings.d.ts +3 -3
  127. package/lib/chevre/settings.js +4 -12
  128. package/package.json +3 -3
  129. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  130. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
  131. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +0 -149
  132. package/lib/chevre/repo/mongoose/schemas/offer.js +0 -210
@@ -0,0 +1,32 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+
12
+ const result = await offerRepo.count(
13
+ {
14
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
15
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
16
+ id: {
17
+ // $eq: '1001'
18
+ // $in: string[];
19
+ },
20
+ identifier: {
21
+ // $eq: '1001'
22
+ // $in: string[];
23
+ // $regex: '003'
24
+ }
25
+ }
26
+ );
27
+ console.log(result);
28
+ }
29
+
30
+ main()
31
+ .then(console.log)
32
+ .catch(console.error);
@@ -0,0 +1,30 @@
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, { autoIndex: false });
8
+
9
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
10
+
11
+ const catalog = await offerCatalogRepo.findItemListElementById(
12
+ {
13
+ id: '0001',
14
+ project: { id: String(process.env.PROJECT_ID) }
15
+ }
16
+ );
17
+ console.log(catalog);
18
+ console.log(catalog.itemListElement.length);
19
+
20
+ const firstElement = await offerCatalogRepo.findFirstItemListElementById(
21
+ {
22
+ id: '0001'
23
+ }
24
+ );
25
+ console.log('firstElement:', firstElement);
26
+ }
27
+
28
+ main()
29
+ .then(console.log)
30
+ .catch(console.error);
@@ -16,6 +16,7 @@ async function main() {
16
16
 
17
17
  const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
18
18
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
19
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
19
20
  const masterService = new chevre.COA.service.Master(
20
21
  {
21
22
  endpoint: chevre.credentials.coa.endpoint,
@@ -27,7 +28,12 @@ async function main() {
27
28
  await chevre.service.offer.event.importFromCOA({
28
29
  project,
29
30
  theaterCode: '120'
30
- })({ categoryCode: categoryCodeRepo, offer: offerRepo, masterService });
31
+ })({
32
+ categoryCode: categoryCodeRepo,
33
+ offer: offerRepo,
34
+ task: taskRepo,
35
+ masterService
36
+ });
31
37
  console.log('imported');
32
38
  }
33
39
 
@@ -0,0 +1,81 @@
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 orderRepo = new chevre.repository.Order(mongoose.connection);
14
+
15
+ const cursor = orderRepo.getCursor(
16
+ {
17
+ // 'project.id': { $eq: project.id },
18
+ // orderNumber: { $eq: 'KNR1-3961294-9087043' },
19
+ orderDate: {
20
+ $gte: moment()
21
+ // tslint:disable-next-line:no-magic-numbers
22
+ .add(-12, 'months')
23
+ .toDate()
24
+ // $lte: moment()
25
+ // // tslint:disable-next-line:no-magic-numbers
26
+ // .add(-6, 'months')
27
+ // .toDate()
28
+ }
29
+ },
30
+ {
31
+ orderDate: 1,
32
+ orderNumber: 1,
33
+ project: 1,
34
+ paymentMethods: 1
35
+ }
36
+ );
37
+ console.log('orders found');
38
+
39
+ let i = 0;
40
+ let updateCount = 0;
41
+ await cursor.eachAsync(async (doc) => {
42
+ i += 1;
43
+ const order: Pick<
44
+ chevre.factory.order.IOrder,
45
+ 'orderDate' | 'orderNumber' | 'project' | 'paymentMethods'
46
+ > = doc.toObject();
47
+
48
+ const noPayment = order.paymentMethods.length === 0;
49
+ const alreadyMigrated = order.paymentMethods.every((invoice) => {
50
+ return typeof invoice.paymentMethod?.identifier === 'string'
51
+ && invoice.paymentMethod.identifier === invoice.typeOf;
52
+ });
53
+
54
+ if (noPayment) {
55
+ console.log('noPayment.', order.project.id, order.orderNumber, order.orderDate, i);
56
+ } else if (alreadyMigrated) {
57
+ console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
58
+ } else {
59
+ console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i);
60
+ for (const invoice of order.paymentMethods) {
61
+ await orderRepo.fixPaymentMethodIdentifier({
62
+ project: { id: order.project.id },
63
+ orderNumber: order.orderNumber,
64
+ invoice: {
65
+ paymentMethodId: invoice.paymentMethodId,
66
+ paymentMethod: { identifier: invoice.typeOf }
67
+ }
68
+ });
69
+ }
70
+ updateCount += 1;
71
+ console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i);
72
+ }
73
+ });
74
+
75
+ console.log(i, 'orders checked');
76
+ console.log(updateCount, 'orders updated');
77
+ }
78
+
79
+ main()
80
+ .then()
81
+ .catch(console.error);
@@ -0,0 +1,72 @@
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 assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
14
+
15
+ const cursor = assetTransactionRepo.getCursor(
16
+ {
17
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
18
+ // 'object.paymentMethodId': { $exists: false },
19
+ // 'project.id': { $eq: project.id },
20
+ startDate: {
21
+ $gte: moment()
22
+ // tslint:disable-next-line:no-magic-numbers
23
+ .add(-12, 'months')
24
+ .toDate()
25
+ }
26
+ },
27
+ {
28
+ typeOf: 1,
29
+ project: 1,
30
+ object: 1,
31
+ transactionNumber: 1,
32
+ startDate: 1
33
+ }
34
+ );
35
+ console.log('transactions found');
36
+
37
+ let i = 0;
38
+ let updateCount = 0;
39
+ await cursor.eachAsync(async (doc) => {
40
+ i += 1;
41
+ const payTransaction: Pick<
42
+ chevre.factory.assetTransaction.pay.ITransaction,
43
+ 'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
44
+ > = doc.toObject();
45
+
46
+ const alreadyMigrated = typeof payTransaction.object.paymentMethodId === 'string'
47
+ && payTransaction.object.paymentMethodId === (<any>payTransaction.object.paymentMethod).paymentMethodId;
48
+
49
+ if (alreadyMigrated) {
50
+ console.log(
51
+ 'already exist.',
52
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
53
+ } else {
54
+ const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
55
+ console.log(
56
+ 'updating...',
57
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
58
+ paymentMethodIdentifier);
59
+ updateCount += 1;
60
+ console.log(
61
+ 'updated.',
62
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
63
+ }
64
+ });
65
+
66
+ console.log(i, 'transactions checked');
67
+ console.log(updateCount, 'transactions updated');
68
+ }
69
+
70
+ main()
71
+ .then()
72
+ .catch(console.error);
@@ -0,0 +1,78 @@
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 assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
14
+
15
+ const cursor = assetTransactionRepo.getCursor(
16
+ {
17
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
18
+ // 'project.id': { $eq: project.id },
19
+ startDate: {
20
+ $gte: moment('2023-05-08T00:00:00Z')
21
+ // tslint:disable-next-line:no-magic-numbers
22
+ // .add(-12, 'months')
23
+ .toDate(),
24
+ $lte: moment('2023-08-30T21:00:00Z')
25
+ .toDate()
26
+ }
27
+ },
28
+ {
29
+ typeOf: 1,
30
+ project: 1,
31
+ object: 1,
32
+ transactionNumber: 1,
33
+ startDate: 1
34
+ }
35
+ );
36
+ console.log('transactions found');
37
+
38
+ let i = 0;
39
+ let updateCount = 0;
40
+ await cursor.eachAsync(async (doc) => {
41
+ i += 1;
42
+ const payTransaction: Pick<
43
+ chevre.factory.assetTransaction.pay.ITransaction,
44
+ 'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
45
+ > = doc.toObject();
46
+
47
+ const alreadyMigrated = payTransaction.object.paymentMethod.identifier
48
+ === (<any>payTransaction.object.paymentMethod).typeOf;
49
+
50
+ if (alreadyMigrated) {
51
+ console.log(
52
+ 'already exist.',
53
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate,
54
+ i, updateCount);
55
+ } else {
56
+ const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
57
+ console.log(
58
+ 'updating...',
59
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
60
+ paymentMethodIdentifier);
61
+ await assetTransactionRepo.migratePaymentMethodIdentifier({
62
+ transactionNumber: payTransaction.transactionNumber,
63
+ object: { paymentMethod: { identifier: paymentMethodIdentifier } }
64
+ });
65
+ updateCount += 1;
66
+ console.log(
67
+ 'updated.',
68
+ payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
69
+ }
70
+ });
71
+
72
+ console.log(i, 'transactions checked');
73
+ console.log(updateCount, 'transactions updated');
74
+ }
75
+
76
+ main()
77
+ .then()
78
+ .catch(console.error);
@@ -0,0 +1,54 @@
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
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
13
+
14
+ const cursor = offerCatalogRepo.getCursor(
15
+ {
16
+ // 'project.id': { $eq: project.id }
17
+ },
18
+ {
19
+ __v: 0,
20
+ createdAt: 0,
21
+ updatedAt: 0
22
+ }
23
+ );
24
+ console.log('catalogs found');
25
+
26
+ let i = 0;
27
+ let updateCount = 0;
28
+ await cursor.eachAsync(async (doc) => {
29
+ i += 1;
30
+ const { _id, ...offerCatalog } = <chevre.factory.offerCatalog.IOfferCatalog & { _id: string }>doc.toObject();
31
+
32
+ let itemListElementTypeOfEqOffer = false;
33
+ itemListElementTypeOfEqOffer = offerCatalog.itemListElement.every((element) => element.typeOf === chevre.factory.offerType.Offer);
34
+ if (!itemListElementTypeOfEqOffer) {
35
+ throw new Error(`itemListElementTypeOfEqOffer: false. ${offerCatalog.project.id} ${offerCatalog.id}`);
36
+ }
37
+
38
+ const itemOfferedKeys = Object.keys(offerCatalog.itemOffered);
39
+ console.log(itemOfferedKeys);
40
+ if (itemOfferedKeys.length > 1) {
41
+ console.log(itemOfferedKeys, offerCatalog.project.id, offerCatalog.id);
42
+ updateCount += 1;
43
+ }
44
+ });
45
+
46
+ console.log(i, 'catalogs checked');
47
+ console.log(updateCount, 'catalogs synced');
48
+
49
+ await offerCatalogRepo.optimizeAll();
50
+ console.log('optmized');
51
+ }
52
+ main()
53
+ .then()
54
+ .catch(console.error);
@@ -43,14 +43,13 @@ async function main() {
43
43
  .toDate(),
44
44
  object: {
45
45
  typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
46
- id: '5f9a6986cc98a1eb13a90285',
46
+ id: 'xxx',
47
47
  paymentMethod: {
48
48
  amount: 1,
49
- // paymentMethodId?: string;
50
- typeOf: 'CreditCard',
49
+ identifier: 'CreditCard',
51
50
  method: '1',
52
51
  creditCard: {
53
- memberId: 'a7909268-a584-425e-8212-d7d10f344093',
52
+ memberId: 'xxx',
54
53
  cardSeq: 91
55
54
  // cardPass?: string;
56
55
  }
@@ -0,0 +1,56 @@
1
+ // tslint:disable:no-console
2
+ import * as jwt from 'jsonwebtoken';
3
+ import { chevre } from '../../../lib/index';
4
+
5
+ function getToken(params: {
6
+ expiresIn: number;
7
+ payload: chevre.factory.authorization.IOwnershipInfoAsObject;
8
+ }) {
9
+ return async (__: {}) => {
10
+ // const now = new Date();
11
+
12
+ // const data = authorization.object;
13
+
14
+ return new Promise<string>((resolve, reject) => {
15
+ // 所有権を暗号化する
16
+ jwt.sign(
17
+ params.payload,
18
+ chevre.credentials.jwt.secret,
19
+ // params.secret,
20
+ {
21
+ issuer: chevre.credentials.jwt.issuer,
22
+ // issuer: params.issuer,
23
+ expiresIn: params.expiresIn
24
+ },
25
+ (err, encoded) => {
26
+ if (err instanceof Error) {
27
+ reject(err);
28
+ } else {
29
+ if (typeof encoded !== 'string') {
30
+ reject(new chevre.factory.errors.ServiceUnavailable('authorization.object cannot be signed unexpectedly'));
31
+ } else {
32
+ resolve(encoded);
33
+ }
34
+ }
35
+ }
36
+ );
37
+ });
38
+ };
39
+ }
40
+
41
+ getToken({
42
+ expiresIn: 2678400,
43
+ payload: {
44
+ typeOf: 'OwnershipInfo',
45
+ id: '',
46
+ typeOfGood: {
47
+ typeOf: chevre.factory.permit.PermitType.Permit,
48
+ identifier: 'xxxxxxxxxxxx',
49
+ issuedThrough: { id: '64f193ad5e79fe8a06ca3156', typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
50
+ }
51
+ }
52
+ })({})
53
+ .then((token) => {
54
+ console.log('token:', token);
55
+ })
56
+ .catch(console.error);
@@ -0,0 +1,26 @@
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, { autoIndex: false });
8
+
9
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
10
+
11
+ const result = await offerRepo.pullAddOns({
12
+ project: { id: String(process.env.PROJECT_ID) },
13
+ addOn: {
14
+ itemOffered: {
15
+ id: {
16
+ $in: ['xxx']
17
+ }
18
+ }
19
+ }
20
+ });
21
+ console.log(result);
22
+ }
23
+
24
+ main()
25
+ .then(console.log)
26
+ .catch(console.error);
@@ -0,0 +1,47 @@
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
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const aggregateOfferRepo = new chevre.repository.AggregateOffer(mongoose.connection);
13
+
14
+ await aggregateOfferRepo.pushIncludedInDataCatalog({
15
+ project: {
16
+ id: project.id
17
+ },
18
+ id: {
19
+ $in: ['1001']
20
+ },
21
+ $push: {
22
+ includedInDataCatalog: {
23
+ $each: [{ id: '0001' }]
24
+ }
25
+ }
26
+ });
27
+ console.log('pushed');
28
+
29
+ // const pullResult = await aggregateOfferRepo.pullIncludedInDataCatalog({
30
+ // project: {
31
+ // id: project.id
32
+ // },
33
+ // id: {
34
+ // // $nin: ['1001']
35
+ // },
36
+ // $pull: {
37
+ // includedInDataCatalog: {
38
+ // $elemMatch: { id: { $eq: '0001' } }
39
+ // }
40
+ // }
41
+ // });
42
+ // console.log('pulled', pullResult);
43
+ }
44
+
45
+ main()
46
+ .then()
47
+ .catch(console.error);
@@ -0,0 +1,48 @@
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, { autoIndex: false });
8
+
9
+ const aggregateOfferRepo = new chevre.repository.AggregateOffer(mongoose.connection);
10
+
11
+ const offers = await aggregateOfferRepo.search(
12
+ {
13
+ limit: 10,
14
+ // page: 1,
15
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
16
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
17
+ itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } },
18
+ // identifier: { $eq: '901' },
19
+ sort: {
20
+ 'priceSpecification.price': 1,
21
+ identifier: 1
22
+ }
23
+ },
24
+ {
25
+ id: 1,
26
+ identifier: 1,
27
+ name: 1,
28
+ priceSpecification: 1
29
+ }
30
+ );
31
+ console.log(offers);
32
+ console.log(offers[0]?.offers);
33
+ console.log(offers.map((offer) => {
34
+ return `${offer.project.id} ${(<any>offer).offerCount} ${offer.offers[0].identifier} ${offer.offers[0].name.ja} ${offer.offers[0].priceSpecification.price}`;
35
+ }));
36
+ console.log(offers.length);
37
+
38
+ const aggregateOfferCount = await aggregateOfferRepo.count({
39
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
40
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
41
+ itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
42
+ });
43
+ console.log('aggregateOfferCount:', aggregateOfferCount);
44
+ }
45
+
46
+ main()
47
+ .then(console.log)
48
+ .catch(console.error);
@@ -0,0 +1,26 @@
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, { autoIndex: false });
8
+
9
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
10
+
11
+ const result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
12
+ limit: 10,
13
+ page: 1,
14
+ subOfferCatalog: {
15
+ id: '0001'
16
+ },
17
+ excludeAppliesToMovieTicket: false,
18
+ unacceptedPaymentMethod: []
19
+ });
20
+ console.log(result);
21
+ console.log(result.length);
22
+ }
23
+
24
+ main()
25
+ .then(console.log)
26
+ .catch(console.error);
@@ -16,11 +16,12 @@ async function main() {
16
16
  });
17
17
  await client.connect();
18
18
 
19
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
19
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
20
 
21
21
  const eventRepo = new chevre.repository.Event(mongoose.connection);
22
22
  const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
23
23
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
24
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
24
25
  const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
25
26
  const productRepo = new chevre.repository.Product(mongoose.connection);
26
27
 
@@ -29,16 +30,19 @@ async function main() {
29
30
  onlyValid: true,
30
31
  validateOfferRateLimit: true,
31
32
  addSortIndex: true,
33
+ useIncludeInDataCatalog: true,
32
34
  limit: 100,
33
35
  page: 1
34
36
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
35
37
  })({
36
38
  event: eventRepo,
37
39
  offer: offerRepo,
40
+ offerCatalog: offerCatalogRepo,
38
41
  offerRateLimit: offerRateLimitRepo,
39
42
  priceSpecification: priceSpecificationRepo,
40
43
  product: productRepo
41
44
  });
45
+ console.log(ticketOffers);
42
46
  console.log(ticketOffers.map((o) => o.sortIndex));
43
47
  console.log(ticketOffers.length);
44
48
  }
@@ -6,21 +6,23 @@ import { chevre } from '../../../lib/index';
6
6
  const PROJECT_ID = process.env.PROJECT_ID;
7
7
 
8
8
  async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
10
 
11
11
  const eventRepo = new chevre.repository.Event(mongoose.connection);
12
12
 
13
13
  const events = await eventRepo.search(
14
14
  {
15
- limit: 100,
16
- page: 1,
17
- sort: { startDate: 1 },
18
- typeOf: chevre.factory.eventType.ScreeningEvent,
15
+ // limit: 100,
16
+ // page: 1,
17
+ // sort: { startDate: 1 },
18
+ // typeOf: chevre.factory.eventType.ScreeningEvent,
19
19
  project: { id: { $eq: PROJECT_ID } },
20
- id: { $eq: 'al6aff83y' }
20
+ id: { $eq: 'al6aff83y' },
21
+ typeOfIn: [chevre.factory.eventType.Event, chevre.factory.eventType.ScreeningEvent]
21
22
  },
22
23
  {
23
- name: 1
24
+ _id: 1
25
+ // name: 1
24
26
  }
25
27
  );
26
28
  console.log(events);