@chevre/domain 22.5.0-alpha.3 → 22.5.0-alpha.31

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 (126) hide show
  1. package/example/src/chevre/aggregateAllEvents2.ts +1 -1
  2. package/example/src/chevre/aggregateEventPublicFields.ts +47 -0
  3. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +32 -0
  4. package/example/src/chevre/findReservationByCode.ts +11 -10
  5. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +101 -0
  6. package/example/src/chevre/migrateProjectMakesOfferAvailableAt.ts +85 -0
  7. package/example/src/chevre/person/cleanUpCognitoUsers.ts +89 -0
  8. package/example/src/chevre/searchCategoryCodesByAggregate.ts +1 -2
  9. package/example/src/chevre/searchEventHasOfferCatalog.ts +43 -0
  10. package/example/src/chevre/searchOfferCatalogItemListElement.ts +26 -0
  11. package/example/src/chevre/searchOfferCatalogItems.ts +3 -2
  12. package/example/src/chevre/searchProjects.ts +2 -4
  13. package/example/src/chevre/searchSellersByAggregate.ts +4 -6
  14. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -19
  15. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +25 -14
  16. package/example/src/chevre/upsertProductsByProductId.ts +1 -1
  17. package/lib/chevre/repo/action.d.ts +1 -1
  18. package/lib/chevre/repo/action.js +5 -39
  19. package/lib/chevre/repo/categoryCode.d.ts +4 -8
  20. package/lib/chevre/repo/categoryCode.js +8 -36
  21. package/lib/chevre/repo/creativeWork.js +1 -20
  22. package/lib/chevre/repo/customer.d.ts +1 -1
  23. package/lib/chevre/repo/customer.js +4 -4
  24. package/lib/chevre/repo/event.d.ts +22 -1
  25. package/lib/chevre/repo/event.js +159 -62
  26. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +54 -0
  27. package/lib/chevre/repo/eventSellerMakesOffer.js +73 -0
  28. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -3
  29. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +0 -3
  30. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +0 -3
  31. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +0 -3
  32. package/lib/chevre/repo/mongoose/schemas/customer.js +0 -3
  33. package/lib/chevre/repo/mongoose/schemas/event.js +9 -54
  34. package/lib/chevre/repo/mongoose/schemas/member.js +0 -3
  35. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -3
  36. package/lib/chevre/repo/mongoose/schemas/paymentService.js +0 -3
  37. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -3
  39. package/lib/chevre/repo/mongoose/schemas/project.js +0 -3
  40. package/lib/chevre/repo/mongoose/schemas/reservation.js +0 -3
  41. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -3
  42. package/lib/chevre/repo/mongoose/schemas/trip.js +0 -3
  43. package/lib/chevre/repo/offer.js +0 -3
  44. package/lib/chevre/repo/offerCatalog.d.ts +15 -0
  45. package/lib/chevre/repo/offerCatalog.js +31 -0
  46. package/lib/chevre/repo/paymentService.js +0 -19
  47. package/lib/chevre/repo/place/movieTheater.js +1 -25
  48. package/lib/chevre/repo/product.d.ts +16 -3
  49. package/lib/chevre/repo/product.js +30 -6
  50. package/lib/chevre/repo/project.d.ts +5 -2
  51. package/lib/chevre/repo/project.js +13 -26
  52. package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
  53. package/lib/chevre/repo/projectMakesOffer.js +5 -2
  54. package/lib/chevre/repo/role.js +0 -7
  55. package/lib/chevre/repo/seller.d.ts +6 -4
  56. package/lib/chevre/repo/seller.js +13 -31
  57. package/lib/chevre/repository.d.ts +5 -0
  58. package/lib/chevre/repository.js +15 -2
  59. package/lib/chevre/service/aggregation/project.js +1 -2
  60. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -4
  61. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  62. package/lib/chevre/service/assetTransaction/reserve/start.js +9 -8
  63. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +4 -1
  64. package/lib/chevre/service/event.js +2 -2
  65. package/lib/chevre/service/moneyTransfer.js +1 -2
  66. package/lib/chevre/service/notification.js +1 -2
  67. package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
  68. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
  69. package/lib/chevre/service/offer/event/authorize.js +25 -8
  70. package/lib/chevre/service/offer/event/checkAvailability.d.ts +10 -0
  71. package/lib/chevre/service/offer/event/checkAvailability.js +48 -0
  72. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  73. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -89
  74. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +40 -357
  75. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
  76. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
  77. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +48 -0
  78. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +109 -0
  79. package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +38 -0
  80. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +95 -0
  81. package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +57 -0
  82. package/lib/chevre/service/offer/event/searchOffersByIds.js +238 -0
  83. package/lib/chevre/service/offer/event/searchPriceSpecs4event.d.ts +19 -0
  84. package/lib/chevre/service/offer/event/searchPriceSpecs4event.js +69 -0
  85. package/lib/chevre/service/offer/event.d.ts +4 -1
  86. package/lib/chevre/service/offer/event.js +6 -3
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  88. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +1 -1
  89. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +4 -4
  90. package/lib/chevre/service/offer/onEventChanged.js +9 -1
  91. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -1
  92. package/lib/chevre/service/offer.d.ts +6 -0
  93. package/lib/chevre/service/offer.js +12 -15
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  97. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  98. package/lib/chevre/service/order/placeOrder.js +1 -1
  99. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  100. package/lib/chevre/service/payment/any.js +1 -1
  101. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +0 -3
  102. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  103. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +50 -57
  104. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  105. package/lib/chevre/service/payment/paymentCard.js +0 -5
  106. package/lib/chevre/service/report/telemetry.js +1 -1
  107. package/lib/chevre/service/reserve/cancelReservation.js +1 -1
  108. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  109. package/lib/chevre/service/reserve/findByCode.js +0 -1
  110. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  111. package/lib/chevre/service/reserve/useReservation.js +4 -4
  112. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
  113. package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
  114. package/lib/chevre/service/task/deletePerson.d.ts +6 -0
  115. package/lib/chevre/service/task/deletePerson.js +420 -0
  116. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  117. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  118. package/lib/chevre/service/task.js +1 -0
  119. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  120. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
  121. package/lib/chevre/service/transaction/returnOrder/preStart.js +2 -3
  122. package/lib/chevre/settings.d.ts +8 -0
  123. package/package.json +5 -7
  124. package/example/src/chevre/migratePayTransactionRecipes.ts +0 -252
  125. package/example/src/chevre/migrateProductHasOfferCatalog.ts +0 -80
  126. package/example/src/chevre/migrateProjectMakesOffer.ts +0 -78
@@ -71,7 +71,7 @@ export async function aggregateScreeningEvent() {
71
71
  abortedTasksWithoutReport: [],
72
72
  coa: { timeout: 1000 },
73
73
  gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
74
- movieticketReserve: { timeout: 1000, timeoutCheck: 1000 },
74
+ movieticketReserve: { timeout: 1000, timeoutCheck: 1000, minIntervalBetweenPayAndRefund: 0 },
75
75
  numTryConfirmReserveTransaction: 10,
76
76
  useAssetTransactionSyncProcessing: true,
77
77
  useExperimentalFeature: false
@@ -0,0 +1,47 @@
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
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
13
+ const result = await eventRepo.aggregatePublicFields<chevre.factory.eventType.ScreeningEvent>(
14
+ {
15
+ limit: 10,
16
+ page: 1,
17
+ sort: { startDate: chevre.factory.sortType.Ascending },
18
+ // id: { $eq: 'bm0f0cadu' },
19
+ typeOf: chevre.factory.eventType.ScreeningEvent,
20
+ project: { id: { $eq: project.id } },
21
+ startFrom: new Date(),
22
+ startThrough: moment()
23
+ // tslint:disable-next-line:no-magic-numbers
24
+ .add(3, 'days')
25
+ .toDate()
26
+ // availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
27
+ // itemOffered: {
28
+ // serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
29
+ // }
30
+ },
31
+ ['eventStatus', 'startDate'],
32
+ {
33
+ includeOffers: true,
34
+ includeSellerMakesOffer: false,
35
+ // includeOffers: false,
36
+ sellerMakesOfferAvailableAtIn: ['51qbjcfr72h62m06vtv5kkhgje', 'g']
37
+ }
38
+ );
39
+ // tslint:disable-next-line:no-null-keyword
40
+ console.dir(result, { depth: null });
41
+ console.log(result.length, 'results found');
42
+ console.log(result.at(0)?.offers?.seller?.makesOffer?.length, 'makesOffer found');
43
+ }
44
+
45
+ main()
46
+ .then(console.log)
47
+ .catch(console.error);
@@ -0,0 +1,32 @@
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 eventSellerMakesOfferRepo = await chevre.repository.EventSellerMakesOffer.createInstance(mongoose.connection);
12
+ const result = await eventSellerMakesOfferRepo.aggregateMakesOffer(
13
+ {
14
+ limit: 10,
15
+ page: 1,
16
+ // id: { $eq: 'bm0f0cadu' },
17
+ // typeOf: chevre.factory.eventType.ScreeningEvent,
18
+ project: { id: { $eq: project.id } },
19
+ availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
20
+ itemOffered: {
21
+ serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
22
+ }
23
+ }
24
+ );
25
+ // tslint:disable-next-line:no-null-keyword
26
+ console.dir(result, { depth: null });
27
+ console.dir(result.length, 'results found');
28
+ }
29
+
30
+ main()
31
+ .then(console.log)
32
+ .catch(console.error);
@@ -32,17 +32,18 @@ async function main() {
32
32
  authorization: authorizationRepo,
33
33
  order: orderRepo,
34
34
  ticket: ticketRepo
35
- },
36
- {
37
- jwt: await chevre.credentials.JWT.createInstance({
38
- secret: <string>process.env.TOKEN_SECRET,
39
- issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
40
- ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
41
- : [],
42
- version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
43
- payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
44
- })
45
35
  }
36
+ // {
37
+ // jwt: await chevre.credentials.JWT.createInstance({
38
+ // secret: <string>process.env.TOKEN_SECRET,
39
+ // issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
40
+ // ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
41
+ // : [],
42
+ // version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
43
+ // payloadTypPrefix:
44
+ // (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
45
+ // })
46
+ // }
46
47
  );
47
48
  console.log('verified.');
48
49
 
@@ -0,0 +1,101 @@
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
+ const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
9
+
10
+ // tslint:disable-next-line:max-func-body-length
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
15
+
16
+ const cursor = eventRepo.getCursor(
17
+ {
18
+ 'project.id': { $ne: excludedProject.id },
19
+ startDate: {
20
+ $gte: moment()
21
+ .add(-1, 'days')
22
+ .toDate()
23
+ },
24
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
25
+ // _id: { $eq: 'blyk9q24f' }
26
+ },
27
+ {
28
+ _id: 1,
29
+ offers: 1,
30
+ startDate: 1,
31
+ project: 1,
32
+ typeOf: 1
33
+ }
34
+ );
35
+ console.log('events found');
36
+
37
+ let i = 0;
38
+ let updateCount = 0;
39
+ await cursor.eachAsync(async (doc) => {
40
+ i += 1;
41
+ const event: Pick<
42
+ chevre.factory.event.screeningEvent.IEvent,
43
+ 'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
44
+ > = doc.toObject();
45
+
46
+ console.log(
47
+ 'alreadyMigrated?', event.project.id, event.typeOf, event.id, event.startDate, i);
48
+ const originMakesOffer = event.offers.seller.makesOffer;
49
+ const alreadyMigrated = !Array.isArray(originMakesOffer)
50
+ || (Array.isArray(originMakesOffer)
51
+ && originMakesOffer.every(
52
+ ({ availableAtOrFrom }) => !Array.isArray(availableAtOrFrom) && typeof availableAtOrFrom?.id === 'string'
53
+ ));
54
+
55
+ if (alreadyMigrated) {
56
+ console.log(
57
+ 'already migrated.', event.project.id, event.typeOf, event.id, event.startDate, i);
58
+ } else {
59
+ if (Array.isArray(originMakesOffer)) {
60
+ const newMakesOffer: chevre.factory.event.screeningEvent.ISellerMakesOffer[] = originMakesOffer.map((offer) => {
61
+ let newAvailableAtOrFrom: { id: string } | undefined;
62
+ if (Array.isArray(offer.availableAtOrFrom)) {
63
+ newAvailableAtOrFrom = offer.availableAtOrFrom.at(0);
64
+ }
65
+ if (newAvailableAtOrFrom === undefined) {
66
+ throw new Error('newAvailableAtOrFrom undefined');
67
+ }
68
+
69
+ return {
70
+ ...offer,
71
+ availableAtOrFrom: newAvailableAtOrFrom
72
+ };
73
+ });
74
+ console.log(
75
+ 'updating project...',
76
+ event.project.id, event.typeOf, event.id, event.startDate, i);
77
+ await eventRepo.updatePartiallyById({
78
+ project: { id: event.project.id },
79
+ id: event.id,
80
+ attributes: {
81
+ typeOf: event.typeOf,
82
+ ...{
83
+ 'offers.seller.makesOffer': newMakesOffer
84
+ }
85
+ }
86
+ });
87
+ updateCount += 1;
88
+ console.log(
89
+ 'updated.',
90
+ event.project.id, event.typeOf, event.id, event.startDate, i);
91
+ }
92
+ }
93
+ });
94
+
95
+ console.log(i, 'events checked');
96
+ console.log(updateCount, 'events updated');
97
+ }
98
+
99
+ main()
100
+ .then()
101
+ .catch(console.error);
@@ -0,0 +1,85 @@
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 excludedProject = { id: String(process.env.EXCLUDED_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 projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
14
+
15
+ const cursor = projectRepo.getCursor(
16
+ {
17
+ // _id: { $eq: 'cinerino' }
18
+ },
19
+ {
20
+ _id: 1,
21
+ makesOffer: 1,
22
+ typeOf: 1
23
+ }
24
+ );
25
+ console.log('docs found');
26
+
27
+ let i = 0;
28
+ let updateCount = 0;
29
+ await cursor.eachAsync(async (doc) => {
30
+ i += 1;
31
+ const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf'
32
+ > & {
33
+ makesOffer: chevre.factory.project.IMakesOffer[];
34
+ } = doc.toObject();
35
+
36
+ console.log(
37
+ 'alreadyMigrated?', project.id, i);
38
+ const originMakesOffer = project.makesOffer;
39
+ const alreadyMigrated = !Array.isArray(originMakesOffer)
40
+ || (Array.isArray(originMakesOffer)
41
+ && originMakesOffer.every(
42
+ ({ availableAtOrFrom }) => !Array.isArray(availableAtOrFrom) && typeof availableAtOrFrom?.id === 'string'
43
+ ));
44
+
45
+ if (alreadyMigrated) {
46
+ console.log(
47
+ 'already migrated.', project.id, i);
48
+ } else {
49
+ if (Array.isArray(originMakesOffer)) {
50
+ const newMakesOffer: chevre.factory.project.IMakesOffer[] = originMakesOffer.map((offer) => {
51
+ let newAvailableAtOrFrom: { id: string } | undefined;
52
+ if (Array.isArray(offer.availableAtOrFrom)) {
53
+ newAvailableAtOrFrom = offer.availableAtOrFrom.at(0);
54
+ }
55
+ if (newAvailableAtOrFrom === undefined) {
56
+ throw new Error('newAvailableAtOrFrom undefined');
57
+ }
58
+
59
+ return {
60
+ ...offer,
61
+ availableAtOrFrom: newAvailableAtOrFrom
62
+ };
63
+ });
64
+ console.log(
65
+ 'updating project...',
66
+ project.id, i, newMakesOffer);
67
+ await projectRepo.updateMakesOfferById({
68
+ id: project.id,
69
+ makesOffer: newMakesOffer
70
+ });
71
+ updateCount += 1;
72
+ console.log(
73
+ 'updated.',
74
+ project.id, i);
75
+ }
76
+ }
77
+ });
78
+
79
+ console.log(i, 'docs checked');
80
+ console.log(updateCount, 'docs updated');
81
+ }
82
+
83
+ main()
84
+ .then()
85
+ .catch(console.error);
@@ -0,0 +1,89 @@
1
+ // tslint:disable:no-console
2
+ import { CognitoIdentityProvider, UserType } from '@aws-sdk/client-cognito-identity-provider';
3
+ import { fromEnv } from '@aws-sdk/credential-providers';
4
+ import * as moment from 'moment';
5
+
6
+ import { chevre } from '../../../../lib/index';
7
+
8
+ export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
9
+ export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
10
+ const NEW_USERPOOL_PROVIDER_NAME = 'SSKTS';
11
+
12
+ // tslint:disable-next-line:max-func-body-length
13
+ async function main(): Promise<void> {
14
+ const awsCredentials = fromEnv();
15
+ const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
16
+ apiVersion: 'latest',
17
+ region: 'ap-northeast-1',
18
+ credentials: awsCredentials
19
+ });
20
+
21
+ // create user
22
+ const newPersonRepo = await chevre.repository.Person.createInstance({
23
+ userPoolId: USERPOOL_ID_NEW,
24
+ cognitoIdentityServiceProvider
25
+ });
26
+
27
+ const users: UserType[] = [];
28
+ let nextToken: string | undefined = '';
29
+ let page: number = 0;
30
+ while (typeof nextToken === 'string') {
31
+ page += 1;
32
+ console.log('listUsersInGroup processing...', nextToken, page);
33
+ const listUsersInGroupResult = await newPersonRepo.cognitoIdentityServiceProvider.listUsersInGroup(
34
+ {
35
+ Limit: 50,
36
+ UserPoolId: USERPOOL_ID_NEW,
37
+ GroupName: 'ap-northeast-1_UWLLyMcjt_SSKTS',
38
+ ...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
39
+ }
40
+ );
41
+ // tslint:disable-next-line:no-null-keyword
42
+ console.dir(listUsersInGroupResult.Users?.at(0), { depth: null });
43
+ nextToken = listUsersInGroupResult.NextToken;
44
+ if (Array.isArray(listUsersInGroupResult.Users)) {
45
+ users.push(...listUsersInGroupResult.Users);
46
+ }
47
+ }
48
+ console.log('listUsersInGroup processed', nextToken, page);
49
+ console.log(users.length, 'users found');
50
+
51
+ const oneMonthAgo = moment()
52
+ .add(-1, 'months');
53
+ for (const user of users) {
54
+ const isSSKTSMember = user.Username?.startsWith(NEW_USERPOOL_PROVIDER_NAME, 0);
55
+ if (!isSSKTSMember) {
56
+ console.error(user);
57
+ throw new Error('not ssktsMember');
58
+ }
59
+
60
+ const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
61
+ // if (user.Enabled === true && sub === '46686164-2c18-491a-8594-52c944d895e9') {
62
+ if (user.Enabled === true) {
63
+ console.log('disabling...', user.Username, sub);
64
+ // disable link provider
65
+ const adminDisableUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDisableUser({
66
+ UserPoolId: USERPOOL_ID_NEW,
67
+ Username: user.Username
68
+ });
69
+ console.log('disabled.', user.Username, sub, adminDisableUserResult);
70
+ } else {
71
+ if (user.UserLastModifiedDate instanceof Date) {
72
+ if (moment(user.UserLastModifiedDate)
73
+ .isBefore(oneMonthAgo)) {
74
+ console.log('adminDeleteUser prossing...', user.Username, sub);
75
+ const adminDeleteUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDeleteUser({
76
+ UserPoolId: USERPOOL_ID_NEW,
77
+ Username: user.Username
78
+ });
79
+ console.log('adminDeleteUser processed.', user.Username, sub, adminDeleteUserResult);
80
+ }
81
+ }
82
+
83
+ }
84
+ }
85
+ }
86
+
87
+ main()
88
+ .then()
89
+ .catch(console.error);
@@ -20,8 +20,7 @@ async function main() {
20
20
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
21
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
22
  },
23
- ['_id'],
24
- []
23
+ ['id']
25
24
  );
26
25
  console.log('categoryCodes found', categoryCodes[0]);
27
26
  console.log(categoryCodes.length, 'categoryCodes found');
@@ -0,0 +1,43 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
+ const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
13
+
14
+ const event = (await eventRepo.projectEventFields(
15
+ {
16
+ id: { $eq: 'bm0f0cadm' },
17
+ typeOf: chevre.factory.eventType.ScreeningEvent,
18
+ project: { id: { $eq: project.id } }
19
+ },
20
+ ['offers.itemOffered.id']
21
+ )).shift();
22
+ console.log('event:', event);
23
+ if (event === undefined) {
24
+ throw new Error('event not found');
25
+ }
26
+ const productId = event.offers.itemOffered.id;
27
+ if (typeof productId !== 'string') {
28
+ throw new Error('offers.itemOffered.id undefined');
29
+ }
30
+ const catalogs = await productRepo.aggregateHasOfferCatalog(
31
+ {
32
+ id: productId,
33
+ limit: 10,
34
+ page: 1
35
+ }
36
+ );
37
+ console.log(catalogs);
38
+ console.log(catalogs.length);
39
+ }
40
+
41
+ main()
42
+ .then(console.log)
43
+ .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
+ // const PROJECT_ID = process.env.PROJECT_ID;
7
+ mongoose.Model.on('index', (...args) => {
8
+ console.error('******** index event emitted. ********\n', args);
9
+ });
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
15
+
16
+ const result = await offerCatalogRepo.searchItemListElement({
17
+ id: { $in: ['blpj322ni', 'blpc770py', 'xxxx', 'blos0d5gu'] },
18
+ itemListElement: { id: { $in: ['xxx', '65669285c7b871dba60ed72e', '65669285c7b871dba60ed742', '1008'] } }
19
+ });
20
+ console.log(result);
21
+ console.log(result.length);
22
+ }
23
+
24
+ main()
25
+ .then(console.log)
26
+ .catch(console.error);
@@ -18,10 +18,11 @@ async function main() {
18
18
 
19
19
  const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItems({
20
20
  event: {
21
- id: 'cllkq475u'
21
+ id: 'bm0f0cadm'
22
22
  },
23
23
  limit: 10,
24
- page: 1
24
+ page: 1,
25
+ options: { includedInDataCatalog: { id: 'blpj322ni' } }
25
26
  })({
26
27
  event: eventRepo,
27
28
  offerCatalog: offerCatalogRepo,
@@ -12,8 +12,7 @@ async function main() {
12
12
 
13
13
  const project = await projectRepo.findById({
14
14
  id: PROJECT_ID,
15
- inclusion: [],
16
- exclusion: ['settings', 'hasMerchantReturnPolicy']
15
+ inclusion: ['settings']
17
16
  });
18
17
  console.log('project:', project);
19
18
 
@@ -23,8 +22,7 @@ async function main() {
23
22
  page: 1,
24
23
  id: { $eq: project.id }
25
24
  },
26
- ['typeOf'],
27
- []
25
+ ['typeOf']
28
26
  );
29
27
  console.log(projects);
30
28
  console.log(projects.length, 'projects found');
@@ -12,15 +12,14 @@ async function main() {
12
12
 
13
13
  const sellersByAggregate = await sellerRepo.searchByAggregate(
14
14
  {
15
- limit: 5,
15
+ limit: 1,
16
16
  page: 1,
17
- sort: { branchCode: chevre.factory.sortType.Descending },
18
- id: { $eq: '59d20831e53ebc2b4e774466' }
17
+ sort: { branchCode: chevre.factory.sortType.Descending }
18
+ // id: { $eq: '59d20831e53ebc2b4e774466' }
19
19
  // project: { id: { $eq: project.id } }
20
20
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
21
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
22
  },
23
- [],
24
23
  ['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
25
24
  );
26
25
  console.log('sellers found', sellersByAggregate, sellersByAggregate[0]?.hasMerchantReturnPolicy);
@@ -36,8 +35,7 @@ async function main() {
36
35
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
37
36
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
38
37
  },
39
- [],
40
- ['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
38
+ ['id', 'typeOf']
41
39
  );
42
40
  console.log('sellers found', sellers, sellers[0]?.hasMerchantReturnPolicy);
43
41
  console.log(sellers.length, 'sellers found');
@@ -1,35 +1,33 @@
1
1
  // tslint:disable:no-console
2
+ import * as moment from 'moment';
2
3
  import * as mongoose from 'mongoose';
3
4
 
4
5
  import { chevre } from '../../../lib/index';
5
6
 
7
+ const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
+
6
9
  async function main() {
7
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
11
 
9
- const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
10
- const offerItemConditionRepo = await chevre.repository.OfferItemCondition.createInstance(mongoose.connection);
12
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
11
13
 
12
14
  let updateResult: any;
13
- updateResult = await creativeWorkRepo.unsetUnnecessaryFields({
14
- filter: {
15
- _id: { $exists: true }
16
- },
17
- $unset: <any>{
18
- createdAt: 1,
19
- updatedAt: 1,
20
- __v: 1
21
- }
22
- });
23
- console.log(updateResult);
24
-
25
- updateResult = await offerItemConditionRepo.unsetUnnecessaryFields({
15
+ updateResult = await eventRepo.unsetUnnecessaryFields({
26
16
  filter: {
27
- _id: { $exists: true }
17
+ 'project.id': { $ne: excludedProject.id },
18
+ 'offers.validFrom': { $exists: true },
19
+ startDate: {
20
+ $gte: moment()
21
+ .add(-1, 'days')
22
+ .toDate()
23
+ }
24
+ // _id: { $eq: 'blxd1grz3' }
28
25
  },
29
26
  $unset: <any>{
30
- createdAt: 1,
31
- updatedAt: 1,
32
- __v: 1
27
+ 'offers.availabilityEnds': 1,
28
+ 'offers.availabilityStarts': 1,
29
+ 'offers.validFrom': 1,
30
+ 'offers.validThrough': 1
33
31
  }
34
32
  });
35
33
  console.log(updateResult);