@chevre/domain 20.1.0-alpha.9 → 20.1.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 (102) hide show
  1. package/example/src/chevre/deleteReservationTicketUnderNames.ts +20 -0
  2. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +157 -0
  3. package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +116 -0
  4. package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +17 -5
  5. package/example/src/chevre/migrateEventProjectAttributes.ts +57 -0
  6. package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
  7. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
  8. package/example/src/chevre/searchEvents.ts +36 -16
  9. package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -4
  10. package/example/src/chevre/transaction/orderMembershipService.ts +0 -4
  11. package/lib/chevre/factory/reservedAgentIdentifireNames.d.ts +1 -0
  12. package/lib/chevre/factory/reservedAgentIdentifireNames.js +12 -0
  13. package/lib/chevre/repo/accountAction.d.ts +0 -18
  14. package/lib/chevre/repo/accountAction.js +402 -355
  15. package/lib/chevre/repo/accountTitle.d.ts +1 -0
  16. package/lib/chevre/repo/accountTitle.js +6 -1
  17. package/lib/chevre/repo/additionalProperty.d.ts +35 -0
  18. package/lib/chevre/repo/additionalProperty.js +205 -0
  19. package/lib/chevre/repo/categoryCode.d.ts +1 -0
  20. package/lib/chevre/repo/categoryCode.js +15 -1
  21. package/lib/chevre/repo/creativeWork.js +10 -1
  22. package/lib/chevre/repo/customer.d.ts +1 -0
  23. package/lib/chevre/repo/customer.js +5 -0
  24. package/lib/chevre/repo/event.d.ts +12 -4
  25. package/lib/chevre/repo/event.js +84 -48
  26. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
  27. package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
  28. package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
  29. package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
  30. package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
  31. package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
  32. package/lib/chevre/repo/mongoose/model/event.js +6 -0
  33. package/lib/chevre/repo/mongoose/model/offer.js +7 -1
  34. package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
  35. package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
  36. package/lib/chevre/repo/mongoose/model/place.js +24 -0
  37. package/lib/chevre/repo/offer.js +10 -1
  38. package/lib/chevre/repo/offerCatalog.js +10 -10
  39. package/lib/chevre/repo/person.js +4 -1
  40. package/lib/chevre/repo/place.d.ts +1 -0
  41. package/lib/chevre/repo/place.js +54 -7
  42. package/lib/chevre/repo/reservation.d.ts +17 -2
  43. package/lib/chevre/repo/reservation.js +41 -1
  44. package/lib/chevre/repo/transaction.js +20 -5
  45. package/lib/chevre/repository.d.ts +6 -3
  46. package/lib/chevre/repository.js +10 -5
  47. package/lib/chevre/service/account.d.ts +0 -4
  48. package/lib/chevre/service/account.js +24 -22
  49. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
  50. package/lib/chevre/service/accountTransaction/deposit.js +3 -3
  51. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
  52. package/lib/chevre/service/accountTransaction/transfer.js +3 -3
  53. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
  54. package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
  55. package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +86 -42
  56. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +7 -18
  57. package/lib/chevre/service/assetTransaction/reserve/factory.js +81 -113
  58. package/lib/chevre/service/assetTransaction/reserve.js +41 -95
  59. package/lib/chevre/service/event.js +20 -6
  60. package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
  61. package/lib/chevre/service/offer/event/authorize.js +32 -21
  62. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  63. package/lib/chevre/service/offer/event/factory.js +17 -12
  64. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
  65. package/lib/chevre/service/offer/factory.js +7 -20
  66. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +32 -22
  67. package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -5
  68. package/lib/chevre/service/reserve/cancelReservation.js +260 -107
  69. package/lib/chevre/service/reserve/confirmReservation.js +65 -33
  70. package/lib/chevre/service/reserve/factory.d.ts +14 -2
  71. package/lib/chevre/service/reserve/factory.js +13 -6
  72. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
  73. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +85 -30
  74. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
  75. package/lib/chevre/service/transaction/orderProgramMembership.js +15 -28
  76. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -0
  77. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +14 -1
  78. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
  79. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
  80. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
  81. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
  82. package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
  83. package/lib/chevre/service/transaction/returnOrder.js +10 -1
  84. package/lib/chevre/service.d.ts +2 -0
  85. package/lib/chevre/service.js +2 -0
  86. package/package.json +4 -4
  87. package/example/src/chevre/accountBlanceTest.ts +0 -24
  88. package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
  89. package/example/src/chevre/createSeats.ts +0 -59
  90. package/example/src/chevre/deleteEvents.ts +0 -50
  91. package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
  92. package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
  93. package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
  94. package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
  95. package/example/src/chevre/publishConfirmationNumber.ts +0 -30
  96. package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
  97. package/example/src/chevre/publishTransactionNumber.ts +0 -28
  98. package/example/src/chevre/renameTransaction.ts +0 -22
  99. package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
  100. package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
  101. package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
  102. package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
@@ -0,0 +1,20 @@
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 reservationRepo = new chevre.repository.Reservation(mongoose.connection);
12
+
13
+ const result = await reservationRepo.deleteReservedTicketUnderName();
14
+
15
+ console.log('deleted', result);
16
+ }
17
+
18
+ main()
19
+ .then()
20
+ .catch(console.error);
@@ -0,0 +1,157 @@
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 EXCLUDED_PROJECT_ID = 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 accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
15
+
16
+ const cursor = accountTitleRepo.getCursor(
17
+ {
18
+ // 'project.id': { $eq: project.id },
19
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID }
20
+ // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
21
+ // starDate: { $gte: new Date() }
22
+ // _id: { $eq: 'al6aff83w' }
23
+ },
24
+ {
25
+ // _id: 1,
26
+ }
27
+ );
28
+ console.log('accountTitles found');
29
+
30
+ const additionalPropertyNamesOnCategories: string[] = [];
31
+ const additionalPropertyNames: string[] = [];
32
+ const additionalPropertyNamesOnTitles: string[] = [];
33
+ const projectIdsOnCategories: string[] = [];
34
+ const projectIds: string[] = [];
35
+ const projectIdsOnTitles: string[] = [];
36
+ const unexpextedprojectIdsOnCategories: string[] = [];
37
+ const unexpextedprojectIds: string[] = [];
38
+ const unexpextedprojectIdsOnTitles: string[] = [];
39
+
40
+ let i = 0;
41
+ let updateCount = 0;
42
+ // tslint:disable-next-line:max-func-body-length
43
+ await cursor.eachAsync(async (doc) => {
44
+ i += 1;
45
+ const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
46
+
47
+ const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
48
+ console.log(
49
+ (Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
50
+ 'additionalPropertyNamesOnCategory found',
51
+ accountTitleCategory.project.id,
52
+ accountTitleCategory.codeValue
53
+ );
54
+ if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
55
+ console.log(
56
+ additionalPropertyNamesOnCategory.length,
57
+ 'additionalPropertyNamesOnResource found',
58
+ accountTitleCategory.project.id,
59
+ accountTitleCategory.codeValue
60
+ );
61
+ additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
62
+ projectIdsOnCategories.push(accountTitleCategory.project.id);
63
+ additionalPropertyNamesOnCategory.forEach((name) => {
64
+ if (!name.match(/^[a-zA-Z]*$/)) {
65
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
66
+ unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
67
+ }
68
+ // tslint:disable-next-line:no-magic-numbers
69
+ if (name.length < 5) {
70
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
71
+ unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
72
+ }
73
+ });
74
+ }
75
+
76
+ if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
77
+ accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
78
+ const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
79
+ console.log(
80
+ (Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
81
+ 'additionalPropertyNamesOnResource found',
82
+ accountTitleCategory.project.id,
83
+ accountTitleCategory.codeValue
84
+ );
85
+ if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
86
+ console.log(
87
+ additionalPropertyNamesOnResource.length,
88
+ 'additionalPropertyNamesOnResource found',
89
+ accountTitleCategory.project.id,
90
+ accountTitleCategory.codeValue
91
+ );
92
+ additionalPropertyNames.push(...additionalPropertyNamesOnResource);
93
+ projectIds.push(accountTitleCategory.project.id);
94
+ additionalPropertyNamesOnResource.forEach((name) => {
95
+ if (!name.match(/^[a-zA-Z]*$/)) {
96
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
97
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
98
+ }
99
+ // tslint:disable-next-line:no-magic-numbers
100
+ if (name.length < 5) {
101
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
102
+ unexpextedprojectIds.push(accountTitleCategory.project.id);
103
+ }
104
+ });
105
+ }
106
+
107
+ if (Array.isArray(accountTitleSet.hasCategoryCode)) {
108
+ accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
109
+ const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
110
+ console.log(
111
+ (Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
112
+ 'additionalPropertyNamesOnSection found',
113
+ accountTitleCategory.project.id,
114
+ accountTitleCategory.codeValue
115
+ );
116
+ if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
117
+ console.log(
118
+ additionalPropertyNamesOnSection.length,
119
+ 'additionalPropertyNamesOnSection found',
120
+ accountTitleCategory.project.id,
121
+ accountTitleCategory.codeValue
122
+ );
123
+ additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
124
+ projectIdsOnTitles.push(accountTitleCategory.project.id);
125
+ additionalPropertyNamesOnSection.forEach((name) => {
126
+ if (!name.match(/^[a-zA-Z]*$/)) {
127
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
128
+ unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
129
+ }
130
+ // tslint:disable-next-line:no-magic-numbers
131
+ if (name.length < 5) {
132
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
133
+ unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
134
+ }
135
+ });
136
+ }
137
+ });
138
+ }
139
+ });
140
+ }
141
+ });
142
+ console.log(i, 'places checked');
143
+ console.log(updateCount, 'places updated');
144
+ console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
145
+ console.log([...new Set(projectIdsOnCategories)], 'categories');
146
+ console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
147
+ console.log([...new Set(additionalPropertyNames)], 'sets');
148
+ console.log([...new Set(projectIds)], 'sets');
149
+ console.log([...new Set(unexpextedprojectIds)], 'sets');
150
+ console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
151
+ console.log([...new Set(projectIdsOnTitles)], 'titles');
152
+ console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
153
+ }
154
+
155
+ main()
156
+ .then()
157
+ .catch(console.error);
@@ -0,0 +1,116 @@
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 EXCLUDED_PROJECT_ID = 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 customerRepo = new chevre.repository.Customer(mongoose.connection);
15
+ // const sellerRepo = new chevre.repository.Seller(mongoose.connection);
16
+ // const eventRepo = new chevre.repository.Event(mongoose.connection);
17
+ // const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
18
+ // const placeRepo = new chevre.repository.Place(mongoose.connection);
19
+ // const offerRepo = new chevre.repository.Offer(mongoose.connection);
20
+ // const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
21
+ // const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
22
+ // const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
23
+ const merchantReturnPolicyRepo = new chevre.repository.MerchantReturnPolicy(mongoose.connection);
24
+
25
+ // const cursor = customerRepo.getCursor(
26
+ // const cursor = sellerRepo.getCursor(
27
+ // const cursor = eventRepo.getCursor(
28
+ // const cursor = categoryCodeRepo.getCursor(
29
+ // const cursor = offerRepo.getCursor(
30
+ // const cursor = creativeWorkRepo.getCursor(
31
+ // const cursor = placeRepo.getCursor(
32
+ // const cursor = offerCatalogRepo.getCursor(
33
+ const cursor = merchantReturnPolicyRepo.getCursor(
34
+ {
35
+ // 'project.id': { $eq: project.id },
36
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID },
37
+ // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
38
+ // starDate: { $gte: new Date() }
39
+ // _id: { $eq: 'al6aff83w' }
40
+ },
41
+ {
42
+ // _id: 1,
43
+ }
44
+ );
45
+ console.log('creativeWorks found');
46
+
47
+ const additionalPropertyNames: string[] = [];
48
+ const projectIds: string[] = [];
49
+ const unexpextedprojectIds: string[] = [];
50
+
51
+ let i = 0;
52
+ let updateCount = 0;
53
+ await cursor.eachAsync(async (doc) => {
54
+ i += 1;
55
+ const creativeWork: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
56
+
57
+ const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
58
+ if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
59
+ console.log(
60
+ additionalPropertyNamesOnEvent.length,
61
+ 'additionalPropertyNamesOnEvent found',
62
+ creativeWork.project.id,
63
+ creativeWork.id
64
+ );
65
+ additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
66
+ projectIds.push(creativeWork.project.id);
67
+ additionalPropertyNamesOnEvent.forEach((name) => {
68
+ if (!name.match(/^[a-zA-Z]*$/)) {
69
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
70
+ unexpextedprojectIds.push(creativeWork.project.id);
71
+ }
72
+ // tslint:disable-next-line:no-magic-numbers
73
+ if (name.length < 5) {
74
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
75
+ unexpextedprojectIds.push(creativeWork.project.id);
76
+ }
77
+ });
78
+
79
+ // for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
80
+ // const existings = await additionalPropertyRepo.search({
81
+ // project: { id: { $eq: event.project.id } },
82
+ // limit: 1,
83
+ // page: 1,
84
+ // name: { $regex: `^${additionalPropertyNameOnEvent}$` }
85
+ // });
86
+ // if (existings.length > 0) {
87
+ // console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
88
+ // } else {
89
+ // updateCount += 1;
90
+ // await additionalPropertyRepo.save({
91
+ // attributes: {
92
+ // project: event.project,
93
+ // typeOf: 'CategoryCode',
94
+ // codeValue: additionalPropertyNameOnEvent,
95
+ // inCodeSet: {
96
+ // typeOf: 'CategoryCodeSet',
97
+ // identifier: <any>event.typeOf
98
+ // },
99
+ // name: { ja: additionalPropertyNameOnEvent }
100
+ // }
101
+ // });
102
+ // console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
103
+ // }
104
+ // }
105
+ }
106
+ });
107
+ console.log(i, 'events checked');
108
+ console.log(updateCount, 'events updated');
109
+ console.log([...new Set(additionalPropertyNames)]);
110
+ console.log([...new Set(projectIds)]);
111
+ console.log([...new Set(unexpextedprojectIds)]);
112
+ }
113
+
114
+ main()
115
+ .then()
116
+ .catch(console.error);
@@ -12,6 +12,7 @@ if (typeof POS_CLIENT_ID !== 'string') {
12
12
  throw new Error('set POS_CLIENT_ID');
13
13
  }
14
14
  const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = 93;
15
+ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
15
16
 
16
17
  // tslint:disable-next-line:max-func-body-length
17
18
  async function main() {
@@ -23,7 +24,7 @@ async function main() {
23
24
  const cursor = eventRepo.getCursor(
24
25
  {
25
26
  // 'project.id': { $eq: project.id },
26
- 'project.id': { $ne: 'sskts-test' },
27
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID },
27
28
  typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
28
29
  startDate: {
29
30
  $gte: moment()
@@ -52,9 +53,20 @@ async function main() {
52
53
 
53
54
  const makesOfferFromEvent = eventOffers.seller.makesOffer;
54
55
 
55
- if (Array.isArray(makesOfferFromEvent) && makesOfferFromEvent.length > 0) {
56
+ const alreadyMigrated = Array.isArray(makesOfferFromEvent)
57
+ && makesOfferFromEvent.length > 0
58
+ && makesOfferFromEvent.every((offer) => {
59
+ return offer.availabilityEnds instanceof Date
60
+ && offer.availabilityStarts instanceof Date
61
+ && offer.validFrom instanceof Date
62
+ && offer.validThrough instanceof Date
63
+ && Array.isArray(offer.availableAtOrFrom)
64
+ && offer.availableAtOrFrom.length === 1;
65
+ });
66
+
67
+ if (alreadyMigrated) {
56
68
  console.log(
57
- 'already exist...', event.project.id, event.id, makesOfferFromEvent.length, i);
69
+ 'already exist...', event.project.id, event.id, event.startDate, makesOfferFromEvent.length, i);
58
70
  } else {
59
71
  let existingApplicationMembers = await memberRepo.search({
60
72
  limit: 100,
@@ -104,7 +116,7 @@ async function main() {
104
116
  }
105
117
  });
106
118
  console.log(
107
- 'updating seller...', event.project.id, event.id, newMakesOffer.length, i);
119
+ 'updating seller...', event.project.id, event.id, event.startDate, newMakesOffer.length, i);
108
120
  await eventRepo.updatePartiallyById({
109
121
  id: event.id,
110
122
  attributes: <any>{
@@ -114,7 +126,7 @@ async function main() {
114
126
  });
115
127
  updateCount += 1;
116
128
  console.log(
117
- 'updated...', event.project.id, event.id, newMakesOffer.length, i);
129
+ 'updated...', event.project.id, event.id, event.startDate, newMakesOffer.length, i);
118
130
  }
119
131
  });
120
132
 
@@ -0,0 +1,57 @@
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 EXCLUDED_PROJECT_ID = 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);
13
+
14
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
15
+
16
+ const cursor = eventRepo.getCursor(
17
+ {
18
+ // 'project.id': { $eq: project.id },
19
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
21
+ // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
22
+ startDate: {
23
+ $gte: moment()
24
+ .add(-1, 'month')
25
+ .toDate()
26
+ }
27
+ // _id: { $eq: 'al6aff83w' }
28
+ },
29
+ {
30
+ // _id: 1,
31
+ }
32
+ );
33
+ console.log('events found');
34
+
35
+ let i = 0;
36
+ let updateCount = 0;
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
40
+
41
+ const locationProjectId = (<any>event.location).project?.id;
42
+ if (typeof locationProjectId !== 'string') {
43
+ console.log('already deleted', event.id, event.startDate, event.project.id, i);
44
+ } else {
45
+ updateCount += 1;
46
+ console.log('deleting project...', event.id, event.startDate, event.project.id, i);
47
+ await eventRepo.deleteUnnecessaryProjectAttributesById({ id: event.id });
48
+ console.log('project deleted', event.id, event.startDate, event.project.id, i);
49
+ }
50
+ });
51
+ console.log(i, 'events checked');
52
+ console.log(updateCount, 'events updated');
53
+ }
54
+
55
+ main()
56
+ .then()
57
+ .catch(console.error);
@@ -0,0 +1,162 @@
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 EXCLUDED_PROJECT_ID = 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 placeRepo = new chevre.repository.Place(mongoose.connection);
15
+
16
+ const cursor = placeRepo.getCursor(
17
+ {
18
+ // 'project.id': { $eq: project.id },
19
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID }
20
+ // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
21
+ // starDate: { $gte: new Date() }
22
+ // _id: { $eq: 'al6aff83w' }
23
+ },
24
+ {
25
+ // _id: 1,
26
+ }
27
+ );
28
+ console.log('creativeWorks found');
29
+
30
+ const additionalPropertyNames: string[] = [];
31
+ const additionalPropertyNamesOnSections: string[] = [];
32
+ const additionalPropertyNamesOnSeats: string[] = [];
33
+ const projectIds: string[] = [];
34
+ const unexpextedprojectIds: string[] = [];
35
+ const projectIdsOnSections: string[] = [];
36
+ const unexpextedprojectIdsOnSections: string[] = [];
37
+ const projectIdsOnSeats: string[] = [];
38
+ const unexpextedprojectIdsOnSeats: string[] = [];
39
+
40
+ let i = 0;
41
+ let updateCount = 0;
42
+ // tslint:disable-next-line:max-func-body-length
43
+ await cursor.eachAsync(async (doc) => {
44
+ i += 1;
45
+ const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
46
+
47
+ if (Array.isArray(movieTheater.containsPlace)) {
48
+ movieTheater.containsPlace.forEach((screeningRoom) => {
49
+ const additionalPropertyNamesOnResource = screeningRoom.additionalProperty?.map((p) => p.name);
50
+ console.log(
51
+ (Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
52
+ 'additionalPropertyNamesOnResource found',
53
+ movieTheater.project.id,
54
+ movieTheater.id
55
+ );
56
+ if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
57
+ console.log(
58
+ additionalPropertyNamesOnResource.length,
59
+ 'additionalPropertyNamesOnResource found',
60
+ movieTheater.project.id,
61
+ movieTheater.id
62
+ );
63
+ additionalPropertyNames.push(...additionalPropertyNamesOnResource);
64
+ projectIds.push(movieTheater.project.id);
65
+ additionalPropertyNamesOnResource.forEach((name) => {
66
+ if (!name.match(/^[a-zA-Z]*$/)) {
67
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
68
+ unexpextedprojectIds.push(movieTheater.project.id);
69
+ }
70
+ // tslint:disable-next-line:no-magic-numbers
71
+ if (name.length < 5) {
72
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
73
+ unexpextedprojectIds.push(movieTheater.project.id);
74
+ }
75
+ });
76
+ }
77
+
78
+ if (Array.isArray(screeningRoom.containsPlace)) {
79
+ screeningRoom.containsPlace.forEach((section) => {
80
+ const additionalPropertyNamesOnSection = section.additionalProperty?.map((p) => p.name);
81
+ console.log(
82
+ (Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
83
+ 'additionalPropertyNamesOnSection found',
84
+ movieTheater.project.id,
85
+ movieTheater.id
86
+ );
87
+ if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
88
+ console.log(
89
+ additionalPropertyNamesOnSection.length,
90
+ 'additionalPropertyNamesOnSection found',
91
+ movieTheater.project.id,
92
+ movieTheater.id
93
+ );
94
+ additionalPropertyNamesOnSections.push(...additionalPropertyNamesOnSection);
95
+ projectIdsOnSections.push(movieTheater.project.id);
96
+ additionalPropertyNamesOnSection.forEach((name) => {
97
+ if (!name.match(/^[a-zA-Z]*$/)) {
98
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
99
+ unexpextedprojectIdsOnSections.push(movieTheater.project.id);
100
+ }
101
+ // tslint:disable-next-line:no-magic-numbers
102
+ if (name.length < 5) {
103
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
104
+ unexpextedprojectIdsOnSections.push(movieTheater.project.id);
105
+ }
106
+ });
107
+ }
108
+
109
+ if (Array.isArray(section.containsPlace)) {
110
+ section.containsPlace.forEach((seat) => {
111
+ const additionalPropertyNamesOnSeat = seat.additionalProperty?.map((p) => p.name);
112
+ console.log(
113
+ (Array.isArray(additionalPropertyNamesOnSeat)) ? additionalPropertyNamesOnSeat.length : 0,
114
+ 'additionalPropertyNamesOnSeat found',
115
+ movieTheater.project.id,
116
+ movieTheater.id
117
+ );
118
+ if (Array.isArray(additionalPropertyNamesOnSeat) && additionalPropertyNamesOnSeat.length > 0) {
119
+ console.log(
120
+ additionalPropertyNamesOnSeat.length,
121
+ 'additionalPropertyNamesOnSeat found',
122
+ movieTheater.project.id,
123
+ movieTheater.id
124
+ );
125
+ additionalPropertyNamesOnSeats.push(...additionalPropertyNamesOnSeat);
126
+ projectIdsOnSeats.push(movieTheater.project.id);
127
+ additionalPropertyNamesOnSeat.forEach((name) => {
128
+ if (!name.match(/^[a-zA-Z]*$/)) {
129
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
130
+ unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
131
+ }
132
+ // tslint:disable-next-line:no-magic-numbers
133
+ if (name.length < 5) {
134
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
135
+ unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
136
+ }
137
+ });
138
+ }
139
+
140
+ });
141
+ }
142
+ });
143
+ }
144
+ });
145
+ }
146
+ });
147
+ console.log(i, 'places checked');
148
+ console.log(updateCount, 'places updated');
149
+ console.log([...new Set(additionalPropertyNames)], 'screeningRooms');
150
+ console.log([...new Set(projectIds)], 'screeningRooms');
151
+ console.log([...new Set(unexpextedprojectIds)], 'screeningRooms');
152
+ console.log([...new Set(additionalPropertyNamesOnSections)], 'sections');
153
+ console.log([...new Set(projectIdsOnSections)], 'sections');
154
+ console.log([...new Set(unexpextedprojectIdsOnSections)], 'sections');
155
+ console.log([...new Set(additionalPropertyNamesOnSeats)], 'seats');
156
+ console.log([...new Set(projectIdsOnSeats)], 'seats');
157
+ console.log([...new Set(unexpextedprojectIdsOnSeats)], 'seats');
158
+ }
159
+
160
+ main()
161
+ .then()
162
+ .catch(console.error);
@@ -0,0 +1,64 @@
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 DELETING_PROPERTY_NAME: string = 'COA_ENDPOINT';
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
13
+
14
+ const cursor = eventRepo.getCursor(
15
+ {
16
+ 'project.id': { $eq: project.id },
17
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries }
18
+ // typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
19
+ // startDate: { $gte: new Date() }
20
+ },
21
+ {
22
+ // _id: 1,
23
+ }
24
+ );
25
+ console.log('events found');
26
+
27
+ let i = 0;
28
+ let updateCount = 0;
29
+ await cursor.eachAsync(async (doc) => {
30
+ i += 1;
31
+ const event: chevre.factory.event.IEvent<chevre.factory.eventType> = doc.toObject();
32
+
33
+ const coaEndpointPropert = event.additionalProperty?.find((p) => p.name === DELETING_PROPERTY_NAME);
34
+
35
+ if (coaEndpointPropert !== undefined) {
36
+ const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] =
37
+ (Array.isArray(event.additionalProperty))
38
+ ? event.additionalProperty.filter((p) => {
39
+ return p.name !== DELETING_PROPERTY_NAME;
40
+ })
41
+ : [];
42
+ console.log(
43
+ 'updating event...', event.project.id, event.id, event.startDate, coaEndpointPropert.value, newAdditionalProperty, i);
44
+ await eventRepo.updatePartiallyById({
45
+ id: event.id,
46
+ attributes: <any>{
47
+ typeOf: event.typeOf,
48
+ additionalProperty: newAdditionalProperty
49
+ }
50
+ });
51
+ updateCount += 1;
52
+ console.log('event updated', event.project.id, event.id, event.startDate, i);
53
+ } else {
54
+ console.log('no property...', event.project.id, event.id, event.startDate, i);
55
+ }
56
+ });
57
+
58
+ console.log(i, 'events checked');
59
+ console.log(updateCount, 'events updated');
60
+ }
61
+
62
+ main()
63
+ .then()
64
+ .catch(console.error);