@chevre/domain 21.13.0 → 21.14.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 (44) hide show
  1. package/example/src/chevre/aggregateAllEvents.ts +2 -2
  2. package/example/src/chevre/aggregateAllEvents2.ts +1 -1
  3. package/example/src/chevre/aggregateEventReservation.ts +11 -11
  4. package/example/src/chevre/aggregateSellerPaymentAccepted.ts +1 -1
  5. package/example/src/chevre/aggregation/aggregateSystem.ts +20 -20
  6. package/example/src/chevre/attendIfNotAttended.ts +1 -1
  7. package/example/src/chevre/checkEventDuration.ts +59 -0
  8. package/example/src/chevre/cleanAccountingReports.ts +1 -1
  9. package/example/src/chevre/cleanActions.ts +1 -1
  10. package/example/src/chevre/deleteRunsAtPassedCertainPeriod.ts +1 -1
  11. package/example/src/chevre/deleteTasksByName.ts +1 -1
  12. package/example/src/chevre/findItemListElementByCatalogId.ts +1 -1
  13. package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +1 -1
  14. package/example/src/chevre/importCategoryCodesFromCOA.ts +5 -4
  15. package/example/src/chevre/importOffersFromCOA.ts +7 -6
  16. package/example/src/chevre/lockStockHolder.ts +1 -1
  17. package/example/src/chevre/migrateCategoryCodeAdditionalProperties.ts +2 -2
  18. package/example/src/chevre/migrateIAMMemberMemberOf.ts +1 -1
  19. package/example/src/chevre/migrateMovieAvailabilityStarts.ts +1 -1
  20. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +3 -3
  21. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +1 -1
  22. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +1 -1
  23. package/example/src/chevre/optimizeCatalogs.ts +1 -1
  24. package/example/src/chevre/place/adminHasPOS.ts +1 -1
  25. package/example/src/chevre/pullAddOnsFromOffer.ts +1 -1
  26. package/example/src/chevre/pushIncludedInDataCatalog.ts +1 -1
  27. package/example/src/chevre/searchActions.ts +1 -1
  28. package/example/src/chevre/searchAggregateOffers.ts +1 -1
  29. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +5 -5
  30. package/example/src/chevre/searchEventIds.ts +1 -1
  31. package/example/src/chevre/searchEventSeats.ts +1 -1
  32. package/example/src/chevre/searchOfferCatalogItemAvailability.ts +5 -5
  33. package/example/src/chevre/searchOfferCatalogItems.ts +5 -5
  34. package/example/src/chevre/searchOffers.ts +2 -2
  35. package/example/src/chevre/searchPermissions.ts +3 -3
  36. package/example/src/chevre/searchProductOffers.ts +1 -1
  37. package/example/src/chevre/searchSellers.ts +2 -2
  38. package/lib/chevre/repo/priceSpecification.d.ts +0 -5
  39. package/lib/chevre/repo/priceSpecification.js +0 -9
  40. package/lib/chevre/repo/stockHolder.d.ts +0 -11
  41. package/lib/chevre/repo/stockHolder.js +11 -284
  42. package/package.json +1 -1
  43. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +0 -21
  44. package/example/src/chevre/place/migrateHasPOS.ts +0 -76
@@ -9,8 +9,8 @@ const project = { typeOf: chevre.factory.organizationType.Project, id: String(pr
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
11
 
12
- const eventRepo = new chevre.repository.Event(mongoose.connection);
13
- const taskRepo = new chevre.repository.Task(mongoose.connection);
12
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
13
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
14
14
 
15
15
  const now = new Date();
16
16
 
@@ -34,7 +34,7 @@ export async function aggregateScreeningEvent() {
34
34
 
35
35
  try {
36
36
  console.log('executing...', count);
37
- await chevre.service.task.executeByName({
37
+ await (await chevre.service.task.createService()).executeByName({
38
38
  name: chevre.factory.taskName.AggregateScreeningEvent
39
39
  })({ connection: mongoose.connection, redisClient: redisClient });
40
40
  console.log('executed', count);
@@ -18,19 +18,19 @@ async function main() {
18
18
  await client.connect();
19
19
 
20
20
  // const now = new Date();
21
- await chevre.service.aggregation.event.aggregateScreeningEvent({
21
+ await (await chevre.service.aggregation.createService()).event.aggregateScreeningEvent({
22
22
  id: String(process.env.EVENT_ID)
23
23
  })({
24
- event: new chevre.repository.Event(mongoose.connection),
25
- stockHolder: new chevre.repository.StockHolder(client, mongoose.connection),
26
- offer: new chevre.repository.Offer(mongoose.connection),
27
- offerCatalog: new chevre.repository.OfferCatalog(mongoose.connection),
28
- offerRateLimit: new chevre.repository.rateLimit.Offer(client),
29
- place: new chevre.repository.Place(mongoose.connection),
30
- product: new chevre.repository.Product(mongoose.connection),
31
- project: new chevre.repository.Project(mongoose.connection),
32
- reservation: new chevre.repository.Reservation(mongoose.connection),
33
- task: new chevre.repository.Task(mongoose.connection)
24
+ event: await chevre.repository.Event.createInstance(mongoose.connection),
25
+ stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
26
+ offer: await chevre.repository.Offer.createInstance(mongoose.connection),
27
+ offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
28
+ offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
29
+ place: await chevre.repository.Place.createInstance(mongoose.connection),
30
+ product: await chevre.repository.Product.createInstance(mongoose.connection),
31
+ project: await chevre.repository.Project.createInstance(mongoose.connection),
32
+ reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
33
+ task: await chevre.repository.Task.createInstance(mongoose.connection)
34
34
  });
35
35
  }
36
36
 
@@ -9,7 +9,7 @@ const project = { typeOf: chevre.factory.organizationType.Project, id: String(pr
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const sellerRepo = new chevre.repository.Seller(mongoose.connection);
12
+ const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
13
13
 
14
14
  const paymentMethodTypes = await sellerRepo.searchPaymentAcceptedById({
15
15
  limit: 100,
@@ -14,16 +14,16 @@ console.log('AGGREGATE_CLIENT_IDS:', AGGREGATE_CLIENT_IDS);
14
14
  async function main() {
15
15
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
16
16
 
17
- const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
18
- const eventRepo = new chevre.repository.Event(mongoose.connection);
19
- const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
20
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
21
- const actionRepo = new chevre.repository.Action(mongoose.connection);
22
- const taskRepo = new chevre.repository.Task(mongoose.connection);
17
+ const aggregationRepo = await chevre.repository.Aggregation.createInstance(mongoose.connection);
18
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
19
+ const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
20
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
21
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
22
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
23
23
 
24
24
  let result: { aggregationCount: number; aggregateDuration: string };
25
25
 
26
- result = await chevre.service.aggregation.system.aggregateReserveAction({
26
+ result = await (await chevre.service.aggregation.createService()).system.aggregateReserveAction({
27
27
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
28
28
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
29
29
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -33,7 +33,7 @@ async function main() {
33
33
  });
34
34
  console.log('aggregateReserveAction processed.', result);
35
35
 
36
- result = await chevre.service.aggregation.system.aggregateOrderAction({
36
+ result = await (await chevre.service.aggregation.createService()).system.aggregateOrderAction({
37
37
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
38
38
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
39
39
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -43,7 +43,7 @@ async function main() {
43
43
  });
44
44
  console.log('aggregateReserveAction processed.', result);
45
45
 
46
- result = await chevre.service.aggregation.system.aggregateCancelReservationAction({
46
+ result = await (await chevre.service.aggregation.createService()).system.aggregateCancelReservationAction({
47
47
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
48
48
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
49
49
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -53,7 +53,7 @@ async function main() {
53
53
  });
54
54
  console.log('aggregateCancelReservationAction processed.', result);
55
55
 
56
- result = await chevre.service.aggregation.system.aggregatePlaceOrder({
56
+ result = await (await chevre.service.aggregation.createService()).system.aggregatePlaceOrder({
57
57
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
58
58
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
59
59
  excludedProjectId: EXCLUDED_PROJECT_ID,
@@ -65,7 +65,7 @@ async function main() {
65
65
  console.log('aggregatePlaceOrder processed.', result);
66
66
  // return;
67
67
 
68
- result = await chevre.service.aggregation.system.aggregateTask({
68
+ result = await (await chevre.service.aggregation.createService()).system.aggregateTask({
69
69
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
70
70
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
71
71
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -75,7 +75,7 @@ async function main() {
75
75
  });
76
76
  console.log('aggregateTask processed.', result);
77
77
 
78
- result = await chevre.service.aggregation.system.aggregatePayMovieTicketAction({
78
+ result = await (await chevre.service.aggregation.createService()).system.aggregatePayMovieTicketAction({
79
79
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
80
80
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
81
81
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -85,7 +85,7 @@ async function main() {
85
85
  });
86
86
  console.log('aggregatePayMovieTicketAction processed.', result);
87
87
 
88
- result = await chevre.service.aggregation.system.aggregatePayTransaction({
88
+ result = await (await chevre.service.aggregation.createService()).system.aggregatePayTransaction({
89
89
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
90
90
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
91
91
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -95,7 +95,7 @@ async function main() {
95
95
  });
96
96
  console.log('aggregatePayTransaction processed.', result);
97
97
 
98
- result = await chevre.service.aggregation.system.aggregateEvent({
98
+ result = await (await chevre.service.aggregation.createService()).system.aggregateEvent({
99
99
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
100
100
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
101
101
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -105,7 +105,7 @@ async function main() {
105
105
  });
106
106
  console.log('aggregateEvent processed.', result);
107
107
 
108
- result = await chevre.service.aggregation.system.aggregateReserveTransaction({
108
+ result = await (await chevre.service.aggregation.createService()).system.aggregateReserveTransaction({
109
109
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
110
110
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
111
111
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -115,7 +115,7 @@ async function main() {
115
115
  });
116
116
  console.log('aggregateReserveTransaction processed.', result);
117
117
 
118
- result = await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
118
+ result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizeOrderAction({
119
119
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
120
120
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
121
121
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -125,7 +125,7 @@ async function main() {
125
125
  });
126
126
  console.log('aggregateAuthorizeOrderAction processed.', result);
127
127
 
128
- result = await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
128
+ result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizeEventServiceOfferAction({
129
129
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
130
130
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
131
131
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -135,7 +135,7 @@ async function main() {
135
135
  });
136
136
  console.log('aggregateAuthorizeEventServiceOfferAction processed.', result);
137
137
 
138
- result = await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
138
+ result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizePaymentAction({
139
139
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
140
140
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
141
141
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -145,7 +145,7 @@ async function main() {
145
145
  });
146
146
  console.log('aggregateAuthorizePaymentAction processed.', result);
147
147
 
148
- result = await chevre.service.aggregation.system.aggregateUseAction({
148
+ result = await (await chevre.service.aggregation.createService()).system.aggregateUseAction({
149
149
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
150
150
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
151
151
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -155,7 +155,7 @@ async function main() {
155
155
  });
156
156
  console.log('aggregateUseAction processed.', result);
157
157
 
158
- result = await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
158
+ result = await (await chevre.service.aggregation.createService()).system.aggregateCheckMovieTicketAction({
159
159
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
160
160
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
161
161
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
8
 
9
- const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
9
+ const reservationRepo = await chevre.repository.Reservation.createInstance(mongoose.connection);
10
10
 
11
11
  const reservation = await reservationRepo.attendIfNotAttended(
12
12
  {
@@ -0,0 +1,59 @@
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 = await chevre.repository.Event.createInstance(mongoose.connection);
15
+
16
+ const cursor = eventRepo.getCursor(
17
+ {
18
+ endDate: { $gte: new Date() },
19
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
20
+ eventStatus: { $eq: chevre.factory.eventStatusType.EventScheduled }
21
+ // 'project.id': { $eq: project.id },
22
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
23
+ },
24
+ {
25
+ startDate: 1,
26
+ endDate: 1,
27
+ 'project.id': 1,
28
+ _id: 1
29
+ }
30
+ );
31
+ console.log('events found');
32
+
33
+ let i = 0;
34
+ let numLongEvents = 0;
35
+ await cursor.eachAsync(async (doc) => {
36
+ i += 1;
37
+ const event: Pick<
38
+ chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
39
+ 'startDate' | 'endDate' | 'project' | 'id'
40
+ > = doc.toObject();
41
+
42
+ const endDateShouldBe = moment(event.startDate)
43
+ // tslint:disable-next-line:no-magic-numbers
44
+ .add(31, 'days');
45
+ // const duration = moment(event.endDate)
46
+ // .diff(moment(event.startDate));
47
+ if (moment(event.endDate)
48
+ .isAfter(endDateShouldBe)) {
49
+ numLongEvents += 1;
50
+ console.log(event.project.id, event.id, 'is long');
51
+ }
52
+ });
53
+ console.log(i, 'events checked');
54
+ console.log(numLongEvents, 'long events found');
55
+ }
56
+
57
+ main()
58
+ .then()
59
+ .catch(console.error);
@@ -10,7 +10,7 @@ import { chevre } from '../../../lib/index';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
12
 
13
- const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection);
13
+ const accountingReportRepo = await chevre.repository.AccountingReport.createInstance(mongoose.connection);
14
14
 
15
15
  const cursor = await accountingReportRepo.accountingReportModel.find(
16
16
  {
@@ -7,7 +7,7 @@ import { chevre } from '../../../lib/index';
7
7
  async function main() {
8
8
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
9
 
10
- const actionRepo = new chevre.repository.Action(mongoose.connection);
10
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
11
 
12
12
  const result = await actionRepo.deleteStartDatePassedCertainPeriod({
13
13
  $lt: moment()
@@ -10,7 +10,7 @@ async function main() {
10
10
  const now = new Date();
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
12
 
13
- const taskRepo = new chevre.repository.Task(mongoose.connection);
13
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
14
14
 
15
15
  const result = await taskRepo.deleteRunsAtPassedCertainPeriod({
16
16
  runsAt: {
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const taskRepo = new chevre.repository.Task(mongoose.connection);
12
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
13
13
 
14
14
  const result = await taskRepo.deleteByName({
15
15
  name: <any>'orderProgramMembership',
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
9
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
10
10
 
11
11
  const catalog = await offerCatalogRepo.findItemListElementById(
12
12
  {
@@ -10,7 +10,7 @@ import { chevre } from '../../../lib/index';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
12
 
13
- const actionRepo = new chevre.repository.Action(mongoose.connection);
13
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
14
  const startLte = moment()
15
15
  .add(-1, 'week')
16
16
  .toDate();
@@ -1,4 +1,5 @@
1
1
  // tslint:disable:no-console
2
+ import * as COA from '@motionpicture/coa-service';
2
3
  // import * as redis from 'redis';
3
4
  import * as mongoose from 'mongoose';
4
5
 
@@ -6,7 +7,7 @@ import { chevre } from '../../../lib/index';
6
7
 
7
8
  const project = { id: String(process.env.PROJECT_ID) };
8
9
 
9
- const coaAuthClient = new chevre.COA.auth.RefreshToken({
10
+ const coaAuthClient = new COA.auth.RefreshToken({
10
11
  endpoint: chevre.credentials.coa.endpoint,
11
12
  refreshToken: chevre.credentials.coa.refreshToken
12
13
  });
@@ -14,8 +15,8 @@ const coaAuthClient = new chevre.COA.auth.RefreshToken({
14
15
  async function main() {
15
16
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
16
17
 
17
- const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
18
- const masterService = new chevre.COA.service.Master(
18
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
19
+ const masterService = new COA.service.Master(
19
20
  {
20
21
  endpoint: chevre.credentials.coa.endpoint,
21
22
  auth: coaAuthClient
@@ -23,7 +24,7 @@ async function main() {
23
24
  { timeout: chevre.credentials.coa.timeout }
24
25
  );
25
26
 
26
- await chevre.service.offer.event.importCategoryCodesFromCOA({
27
+ await (await chevre.service.offer.createService()).event.importCategoryCodesFromCOA({
27
28
  project,
28
29
  theaterCode: '120'
29
30
  })({ categoryCode: categoryCodeRepo, masterService });
@@ -1,12 +1,13 @@
1
1
  // tslint:disable:no-console
2
2
  // import * as redis from 'redis';
3
+ import * as COA from '@motionpicture/coa-service';
3
4
  import * as mongoose from 'mongoose';
4
5
 
5
6
  import { chevre } from '../../../lib/index';
6
7
 
7
8
  const project = { id: String(process.env.PROJECT_ID) };
8
9
 
9
- const coaAuthClient = new chevre.COA.auth.RefreshToken({
10
+ const coaAuthClient = new COA.auth.RefreshToken({
10
11
  endpoint: chevre.credentials.coa.endpoint,
11
12
  refreshToken: chevre.credentials.coa.refreshToken
12
13
  });
@@ -14,10 +15,10 @@ const coaAuthClient = new chevre.COA.auth.RefreshToken({
14
15
  async function main() {
15
16
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
16
17
 
17
- const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
18
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
19
- const taskRepo = new chevre.repository.Task(mongoose.connection);
20
- const masterService = new chevre.COA.service.Master(
18
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
19
+ const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
20
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
21
+ const masterService = new COA.service.Master(
21
22
  {
22
23
  endpoint: chevre.credentials.coa.endpoint,
23
24
  auth: coaAuthClient
@@ -25,7 +26,7 @@ async function main() {
25
26
  { timeout: chevre.credentials.coa.timeout }
26
27
  );
27
28
 
28
- await chevre.service.offer.event.importFromCOA({
29
+ await (await chevre.service.offer.createService()).event.importFromCOA({
29
30
  project,
30
31
  theaterCode: '120'
31
32
  })({
@@ -20,7 +20,7 @@ async function main() {
20
20
 
21
21
  const startDate = moment('2023-04-18T00:00:00Z');
22
22
 
23
- const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
23
+ const stockHolderRepo = await chevre.repository.StockHolder.createInstance(client, mongoose.connection);
24
24
  await stockHolderRepo.lock({
25
25
  project,
26
26
  eventId: 'sampleEventId',
@@ -11,8 +11,8 @@ import { chevre } from '../../../lib/index';
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
15
- const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
14
+ const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
+ const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
16
16
 
17
17
  const cursor = categoryCodeRepo.getCursor(
18
18
  {
@@ -11,7 +11,7 @@ import { chevre } from '../../../lib/index';
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const memberRepo = new chevre.repository.Member(mongoose.connection);
14
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
15
15
 
16
16
  const cursor = memberRepo.getCursor(
17
17
  {},
@@ -11,7 +11,7 @@ import { chevre } from '../../../lib/index';
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
14
+ const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
15
15
 
16
16
  const cursor = creativeWorkRepo.getCursor(
17
17
  {
@@ -10,7 +10,7 @@ import { chevre } from '../../../lib/index';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
12
 
13
- const orderRepo = new chevre.repository.Order(mongoose.connection);
13
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
14
14
 
15
15
  const cursor = orderRepo.getCursor(
16
16
  {
@@ -48,7 +48,7 @@ async function main() {
48
48
  const noPayment = order.paymentMethods.length === 0;
49
49
  const alreadyMigrated = order.paymentMethods.every((invoice) => {
50
50
  return typeof invoice.paymentMethod?.identifier === 'string'
51
- && invoice.paymentMethod.identifier === invoice.typeOf;
51
+ && invoice.paymentMethod.identifier === (<any>invoice).typeOf;
52
52
  });
53
53
 
54
54
  if (noPayment) {
@@ -63,7 +63,7 @@ async function main() {
63
63
  orderNumber: order.orderNumber,
64
64
  invoice: {
65
65
  paymentMethodId: invoice.paymentMethodId,
66
- paymentMethod: { identifier: invoice.typeOf }
66
+ paymentMethod: { identifier: (<any>invoice).typeOf }
67
67
  }
68
68
  });
69
69
  }
@@ -10,7 +10,7 @@ import { chevre } from '../../../lib/index';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
12
 
13
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
13
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
14
14
 
15
15
  const cursor = assetTransactionRepo.getCursor(
16
16
  {
@@ -10,7 +10,7 @@ import { chevre } from '../../../lib/index';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
12
 
13
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
13
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
14
14
 
15
15
  const cursor = assetTransactionRepo.getCursor(
16
16
  {
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
12
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
13
13
 
14
14
  const cursor = offerCatalogRepo.getCursor(
15
15
  {
@@ -9,7 +9,7 @@ const project = { typeOf: chevre.factory.organizationType.Project, id: String(pr
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const posRepo = new chevre.repository.place.HasPOS(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
12
+ const posRepo = await chevre.repository.place.HasPOS.createInstance(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
13
13
 
14
14
  const poses = await posRepo.search({
15
15
  limit: 10,
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
9
+ const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
10
10
 
11
11
  const result = await offerRepo.pullAddOns({
12
12
  project: { id: String(process.env.PROJECT_ID) },
@@ -9,7 +9,7 @@ const project = { id: String(process.env.PROJECT_ID) };
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const aggregateOfferRepo = new chevre.repository.AggregateOffer(mongoose.connection);
12
+ const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
13
13
 
14
14
  await aggregateOfferRepo.pushIncludedInDataCatalog({
15
15
  project: {
@@ -8,7 +8,7 @@ import * as mongoose from 'mongoose';
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
10
 
11
- const actionRepo = new chevre.repository.Action(mongoose.connection);
11
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
12
12
  const actions = await actionRepo.search(
13
13
  {
14
14
  typeOf: { $eq: chevre.factory.actionType.CheckAction },
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
- const aggregateOfferRepo = new chevre.repository.AggregateOffer(mongoose.connection);
9
+ const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
10
10
 
11
11
  const offers = await aggregateOfferRepo.search(
12
12
  {
@@ -6,10 +6,10 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
- const eventRepo = new chevre.repository.Event(mongoose.connection);
10
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
12
- const productRepo = new chevre.repository.Product(mongoose.connection);
9
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
10
+ const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
11
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
12
+ const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
13
13
 
14
14
  let result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
15
15
  limit: 10,
@@ -25,7 +25,7 @@ async function main() {
25
25
  console.log(result);
26
26
  console.log(result.length);
27
27
 
28
- result = await chevre.service.offer.event.searchOfferAppliesToMovieTicket({
28
+ result = await (await chevre.service.offer.createService()).event.searchOfferAppliesToMovieTicket({
29
29
  event: { id: 'cllkq475p' },
30
30
  onlyValid: true,
31
31
  useIncludeInDataCatalog: true,
@@ -8,7 +8,7 @@ const PROJECT_ID = process.env.PROJECT_ID;
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
10
 
11
- const eventRepo = new chevre.repository.Event(mongoose.connection);
11
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
12
 
13
13
  const ids = await eventRepo.searchIds({
14
14
  typeOf: chevre.factory.eventType.ScreeningEvent,
@@ -17,7 +17,7 @@ async function main() {
17
17
  });
18
18
  await client.connect();
19
19
 
20
- const itemAvailabilityRepo = new chevre.repository.StockHolder(client, mongoose.connection);
20
+ const itemAvailabilityRepo = await chevre.repository.StockHolder.createInstance(client, mongoose.connection);
21
21
 
22
22
  const result = await itemAvailabilityRepo.searchHolders({
23
23
  project,
@@ -11,12 +11,12 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const eventRepo = new chevre.repository.Event(mongoose.connection);
15
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
16
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
17
- const productRepo = new chevre.repository.Product(mongoose.connection);
14
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
15
+ const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
16
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
17
+ const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
18
18
 
19
- const result = await chevre.service.offer.event.searchOfferCatalogItemAvailability({
19
+ const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItemAvailability({
20
20
  event: {
21
21
  id: 'cllkq475u'
22
22
  },
@@ -11,12 +11,12 @@ mongoose.Model.on('index', (...args) => {
11
11
  async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const eventRepo = new chevre.repository.Event(mongoose.connection);
15
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
16
- const offerCatalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
17
- const productRepo = new chevre.repository.Product(mongoose.connection);
14
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
15
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
16
+ const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
17
+ const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
18
18
 
19
- const result = await chevre.service.offer.event.searchOfferCatalogItems({
19
+ const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItems({
20
20
  event: {
21
21
  id: 'cllkq475u'
22
22
  },
@@ -8,7 +8,7 @@ mongoose.Model.on('index', (...args) => {
8
8
  });
9
9
 
10
10
  async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
12
 
13
13
  const indexes = await mongoose.connection.db.collection('aggregateOffers')
14
14
  .indexes();
@@ -18,7 +18,7 @@ async function main() {
18
18
  // .dropIndexes();
19
19
  // console.log('indexes droped');
20
20
 
21
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
21
+ const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
22
22
 
23
23
  const offers = await offerRepo.search({
24
24
  limit: 100,
@@ -10,13 +10,13 @@ const memberId = 'xxx';
10
10
  async function main() {
11
11
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
12
 
13
- const memberRepo = new chevre.repository.Member(mongoose.connection);
14
- const roleRepo = new chevre.repository.Role(mongoose.connection);
13
+ const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
14
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
15
15
 
16
16
  let now: Date;
17
17
 
18
18
  now = new Date();
19
- const searchPermissionsResult = await chevre.service.iam.searchPermissions({
19
+ const searchPermissionsResult = await (await chevre.service.iam.createService()).searchPermissions({
20
20
  project: { id: PROJECT_ID },
21
21
  member: {
22
22
  id: memberId,
@@ -8,7 +8,7 @@ const PROJECT_ID = String(process.env.PROJECT_ID);
8
8
  async function main() {
9
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
10
 
11
- const productOfferRepo = new chevre.repository.ProductOffer(mongoose.connection);
11
+ const productOfferRepo = await chevre.repository.ProductOffer.createInstance(mongoose.connection);
12
12
 
13
13
  const offers = await productOfferRepo.search({
14
14
  project: { id: { $eq: PROJECT_ID } }
@@ -6,9 +6,9 @@ import { chevre } from '../../../lib/index';
6
6
  const project = { id: String(process.env.PROJECT_ID) };
7
7
 
8
8
  async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
10
 
11
- const sellerRepo = new chevre.repository.Seller(mongoose.connection);
11
+ const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
12
12
 
13
13
  const sellers = await sellerRepo.search(
14
14
  {
@@ -54,11 +54,6 @@ export declare class MongoRepository {
54
54
  id: string;
55
55
  };
56
56
  }): Promise<void>;
57
- deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params: {
58
- project?: {
59
- id?: string;
60
- };
61
- }): Promise<import("mongodb").DeleteResult>;
62
57
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
63
58
  reIndex(): Promise<import("bson").Document>;
64
59
  }
@@ -240,15 +240,6 @@ class MongoRepository {
240
240
  .exec();
241
241
  });
242
242
  }
243
- deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params) {
244
- var _a;
245
- return __awaiter(this, void 0, void 0, function* () {
246
- return this.priceSpecificationModel.deleteMany(Object.assign({ typeOf: { $eq: factory.priceSpecificationType.MovieTicketTypeChargeSpecification }, price: { $eq: 0 } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === 'string')
247
- ? { 'project.id': { $eq: params.project.id } }
248
- : undefined))
249
- .exec();
250
- });
251
- }
252
243
  getCursor(conditions, projection) {
253
244
  return this.priceSpecificationModel.find(conditions, projection)
254
245
  .sort({ price: factory.sortType.Ascending })
@@ -83,7 +83,6 @@ export interface ISearchResult {
83
83
  */
84
84
  export declare class StockHolderRepository {
85
85
  static KEY_PREFIX_NEW: string;
86
- static KEY_PREFIX: string;
87
86
  private readonly redisClient;
88
87
  constructor(redisClient: RedisClientType, __: Connection);
89
88
  private static offer2field;
@@ -104,9 +103,6 @@ export declare class StockHolderRepository {
104
103
  * 座席ロックを解除する
105
104
  */
106
105
  unlock(params: IUnlockKey): Promise<void>;
107
- /**
108
- * 空席でない座席を検索する
109
- */
110
106
  /**
111
107
  * 空席でない座席をカウントする
112
108
  */
@@ -130,11 +126,4 @@ export declare class StockHolderRepository {
130
126
  hasTicketedSeat: boolean;
131
127
  offers: IOffer[];
132
128
  }): Promise<IGetHolderResult[]>;
133
- /**
134
- * 汎用的な検索(mongooseのみ対応)
135
- */
136
- /**
137
- * 汎用的な集計(mongooseのみ対応)
138
- */
139
- private checkIfConflicted;
140
129
  }
@@ -13,7 +13,7 @@ exports.StockHolderRepository = void 0;
13
13
  const createDebug = require("debug");
14
14
  const moment = require("moment");
15
15
  const factory = require("../factory");
16
- const settings_1 = require("../settings");
16
+ // import { USE_NEW_EVENT_AVAILABILITY_KEY_FROM } from '../settings';
17
17
  const debug = createDebug('chevre-domain:repo:stockHolder');
18
18
  /**
19
19
  * イベントストックホルダーリポジトリ
@@ -38,41 +38,18 @@ class StockHolderRepository {
38
38
  }
39
39
  }
40
40
  }
41
- // private static offer2subReservation(params: IOffer, hasTicketedSeat: boolean): ISubReservation {
42
- // if (hasTicketedSeat) {
43
- // return {
44
- // identifier: `${params.seatSection}:${params.seatNumber}`,
45
- // reservedTicket: {
46
- // ticketedSeat: {
47
- // seatSection: params.seatSection,
48
- // seatNumber: params.seatNumber
49
- // }
50
- // }
51
- // };
52
- // } else {
53
- // const serviceOutputId = params.itemOffered?.serviceOutput?.id;
54
- // if (typeof serviceOutputId === 'string') {
55
- // return {
56
- // id: serviceOutputId,
57
- // identifier: serviceOutputId
58
- // };
59
- // } else {
60
- // throw new factory.errors.ServiceUnavailable('offer2subReservation requires itemOffered.serviceOutput.id');
61
- // }
62
- // }
63
- // }
64
41
  static createKey(params) {
65
42
  if (!(params.startDate instanceof Date)) {
66
43
  throw new factory.errors.Argument('startDate', 'must be Date');
67
44
  }
68
- const useNewKey = moment(params.startDate)
69
- .isSameOrAfter(settings_1.USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
70
- if (useNewKey) {
71
- return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
72
- }
73
- else {
74
- return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
75
- }
45
+ return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
46
+ // const useNewKey: boolean = moment(params.startDate)
47
+ // .isSameOrAfter(USE_NEW_EVENT_AVAILABILITY_KEY_FROM);
48
+ // if (useNewKey) {
49
+ // return `${StockHolderRepository.KEY_PREFIX_NEW}:${params.eventId}`;
50
+ // } else {
51
+ // return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
52
+ // }
76
53
  }
77
54
  /**
78
55
  * 新リポジトリを使用するかどうか
@@ -125,7 +102,7 @@ class StockHolderRepository {
125
102
  hasTicketedSeat: lockKey.hasTicketedSeat
126
103
  });
127
104
  const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
128
- yield this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
105
+ // await this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
129
106
  if (useMongoose) {
130
107
  throw new factory.errors.NotImplemented('new stock holder repository not implemented');
131
108
  }
@@ -182,7 +159,7 @@ class StockHolderRepository {
182
159
  hasTicketedSeat: params.hasTicketedSeat
183
160
  });
184
161
  const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
185
- yield this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
162
+ // await this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
186
163
  if (useMongoose) {
187
164
  throw new factory.errors.NotImplemented('new stock holder repository not implemented');
188
165
  }
@@ -194,23 +171,6 @@ class StockHolderRepository {
194
171
  }
195
172
  });
196
173
  }
197
- /**
198
- * 空席でない座席を検索する
199
- */
200
- // public async findUnavailableOffersByEventId(params: { eventId: string; startDate: Date }): Promise<IOffer[]> {
201
- // const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
202
- // const reply = await this.redisClient.hGetAll(key);
203
- // let offers: IOffer[] = [];
204
- // if (reply !== null) {
205
- // offers = Object.keys(reply)
206
- // .map((field) => {
207
- // const seatSection = field.split(':')[0];
208
- // const seatNumber = field.split(':')[1];
209
- // return { seatSection, seatNumber };
210
- // });
211
- // }
212
- // return offers;
213
- // }
214
174
  /**
215
175
  * 空席でない座席をカウントする
216
176
  */
@@ -277,239 +237,6 @@ class StockHolderRepository {
277
237
  }
278
238
  });
279
239
  }
280
- // public async migrateKey(params: {
281
- // key: string;
282
- // eventId: string;
283
- // }): Promise<void> {
284
- // // 旧キーと新キーの両方存在検証(念のため)
285
- // const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
286
- // const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
287
- // if (params.key !== oldKey) {
288
- // // newの場合oldが存在するはずがない
289
- // const existingOldKeyCount = await this.redisClient.exists(oldKey);
290
- // debug('existingOldKeyCount:', existingOldKeyCount);
291
- // if (existingOldKeyCount > 0) {
292
- // await this.redisClient.del(oldKey);
293
- // }
294
- // }
295
- // if (params.key !== newKey) {
296
- // // oldの場合newが存在するはずがない
297
- // const existingNewKeyCount = await this.redisClient.exists(newKey);
298
- // debug('existingNewKeyCount:', existingNewKeyCount);
299
- // if (existingNewKeyCount > 0) {
300
- // await this.redisClient.del(newKey);
301
- // }
302
- // }
303
- // }
304
- /**
305
- * 汎用的な検索(mongooseのみ対応)
306
- */
307
- // tslint:disable-next-line:max-func-body-length
308
- // public async search(params: {
309
- // limit?: number;
310
- // page?: number;
311
- // sort?: { 'reservationFor.startDate': factory.sortType };
312
- // project?: { id?: { $eq?: string } };
313
- // reservationFor?: { id?: { $eq?: string } };
314
- // reservationNumber?: { $eq?: string };
315
- // id?: { $eq?: string };
316
- // identifier?: { $eq?: string };
317
- // reservedTicket?: {
318
- // ticketedSeat?: {
319
- // seatNumber?: { $eq?: string };
320
- // seatSection?: { $eq?: string };
321
- // };
322
- // };
323
- // }): Promise<ISearchResult[]> {
324
- // const matchStages: IMatchStage[] = [];
325
- // const projectIdEq = params.project?.id?.$eq;
326
- // if (typeof projectIdEq === 'string') {
327
- // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
328
- // }
329
- // const reservationForIdEq = params.reservationFor?.id?.$eq;
330
- // if (typeof reservationForIdEq === 'string') {
331
- // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
332
- // }
333
- // const reservationNumberEq = params.reservationNumber?.$eq;
334
- // if (typeof reservationNumberEq === 'string') {
335
- // matchStages.push({ $match: { 'reservations.reservationNumber': { $exists: true, $eq: reservationNumberEq } } });
336
- // }
337
- // const identifierEq = params.identifier?.$eq;
338
- // if (typeof identifierEq === 'string') {
339
- // matchStages.push({ $match: { 'reservations.subReservation.identifier': { $exists: true, $eq: identifierEq } } });
340
- // }
341
- // const idEq = params.id?.$eq;
342
- // if (typeof idEq === 'string') {
343
- // matchStages.push({
344
- // $match: { 'reservations.subReservation.id': { $exists: true, $eq: idEq } }
345
- // });
346
- // }
347
- // const seatNumberEq = params.reservedTicket?.ticketedSeat?.seatNumber?.$eq;
348
- // if (typeof seatNumberEq === 'string') {
349
- // matchStages.push({
350
- // $match: {
351
- // 'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': {
352
- // $exists: true,
353
- // $eq: seatNumberEq
354
- // }
355
- // }
356
- // });
357
- // }
358
- // const seatSectionEq = params.reservedTicket?.ticketedSeat?.seatSection?.$eq;
359
- // if (typeof seatSectionEq === 'string') {
360
- // matchStages.push({
361
- // $match: {
362
- // 'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': {
363
- // $exists: true,
364
- // $eq: seatSectionEq
365
- // }
366
- // }
367
- // });
368
- // }
369
- // const aggregate = this.holdReservationModel.aggregate([
370
- // ...(typeof params.sort?.['reservationFor.startDate'] === 'number')
371
- // ? [{ $sort: { 'reservationFor.startDate': params.sort['reservationFor.startDate'] } }]
372
- // : [],
373
- // {
374
- // $unwind: {
375
- // path: '$reservations',
376
- // includeArrayIndex: 'reservationPackageIndex'
377
- // }
378
- // },
379
- // {
380
- // $unwind: {
381
- // path: '$reservations.subReservation',
382
- // includeArrayIndex: 'subReservationIndex'
383
- // }
384
- // },
385
- // ...matchStages,
386
- // {
387
- // $project: {
388
- // _id: 0,
389
- // id: '$reservations.subReservation.id',
390
- // identifier: '$reservations.subReservation.identifier',
391
- // reservationFor: {
392
- // id: '$reservationFor.id',
393
- // startDate: '$reservationFor.startDate',
394
- // aggregateReservation: {
395
- // reservationCount: '$reservationCount'
396
- // }
397
- // },
398
- // reservationNumber: '$reservations.reservationNumber',
399
- // reservedTicket: '$reservations.subReservation.reservedTicket',
400
- // objectSize: { $bsonSize: '$$ROOT' },
401
- // reservationPackageIndex: '$reservationPackageIndex',
402
- // subReservationIndex: '$subReservationIndex'
403
- // }
404
- // }
405
- // ]);
406
- // if (typeof params.limit === 'number' && params.limit > 0) {
407
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
408
- // aggregate.limit(params.limit * page)
409
- // .skip(params.limit * (page - 1));
410
- // }
411
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
412
- // .exec();
413
- // }
414
- /**
415
- * 汎用的な集計(mongooseのみ対応)
416
- */
417
- // public async aggregateByReservationFor(params: {
418
- // limit?: number;
419
- // page?: number;
420
- // project?: { id?: { $eq?: string } };
421
- // reservationFor?: { id?: { $eq?: string } };
422
- // }): Promise<{
423
- // typeOf: 'AggregateReservation';
424
- // reservationCount: number;
425
- // reservationFor: {
426
- // id: string;
427
- // startDate: Date;
428
- // };
429
- // reservationPackageCount: number;
430
- // objectSize: number;
431
- // }[]> {
432
- // const matchStages: IMatchStage[] = [];
433
- // const projectIdEq = params.project?.id?.$eq;
434
- // if (typeof projectIdEq === 'string') {
435
- // matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
436
- // }
437
- // const reservationForIdEq = params.reservationFor?.id?.$eq;
438
- // if (typeof reservationForIdEq === 'string') {
439
- // matchStages.push({ $match: { 'reservationFor.id': { $eq: reservationForIdEq } } });
440
- // }
441
- // const aggregate = this.holdReservationModel.aggregate([
442
- // ...matchStages,
443
- // {
444
- // $project: {
445
- // _id: 0,
446
- // typeOf: '$typeOf',
447
- // reservationCount: '$reservationCount',
448
- // reservationFor: '$reservationFor',
449
- // reservationPackageCount: { $size: '$reservations' },
450
- // objectSize: { $bsonSize: '$$ROOT' }
451
- // }
452
- // }
453
- // ]);
454
- // if (typeof params.limit === 'number' && params.limit > 0) {
455
- // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
456
- // aggregate.limit(params.limit * page)
457
- // .skip(params.limit * (page - 1));
458
- // }
459
- // return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
460
- // .exec();
461
- // }
462
- checkIfConflicted(params) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- // 旧キーと新キーの両方存在検証(念のため)
465
- const oldKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2020-01-01T00:00:00Z') });
466
- const newKey = StockHolderRepository.createKey({ eventId: params.eventId, startDate: new Date('2030-01-01T00:00:00Z') });
467
- if (params.useMongoose) {
468
- throw new factory.errors.NotImplemented('new stock holder repository not implemented');
469
- // newもoldも存在するはずがない
470
- // newの場合oldが存在するはずがない
471
- // const existingOldKeyCount = await this.redisClient.exists(oldKey);
472
- // debug('existingOldKeyCount:', existingOldKeyCount);
473
- // if (existingOldKeyCount > 0) {
474
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
475
- // }
476
- // oldの場合newが存在するはずがない
477
- // const existingNewKeyCount = await this.redisClient.exists(newKey);
478
- // debug('existingNewKeyCount:', existingNewKeyCount);
479
- // if (existingNewKeyCount > 0) {
480
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
481
- // }
482
- }
483
- else {
484
- // collectionにdocumentが存在するはずがない
485
- // const existingHoldReservationCount = await this.holdReservationModel.count(
486
- // { 'reservationFor.id': { $eq: params.eventId } }
487
- // )
488
- // .exec();
489
- // debug('existingHoldReservationCount:', existingHoldReservationCount);
490
- // if (existingHoldReservationCount > 0) {
491
- // throw new factory.errors.ServiceUnavailable(`stockHolder storage conflicted. eventId:${params.eventId}`);
492
- // }
493
- if (params.key !== oldKey) {
494
- // newの場合oldが存在するはずがない
495
- const existingOldKeyCount = yield this.redisClient.exists(oldKey);
496
- debug('existingOldKeyCount:', existingOldKeyCount);
497
- if (existingOldKeyCount > 0) {
498
- throw new factory.errors.ServiceUnavailable(`stockHolder keys conflicted. eventId:${params.eventId}`);
499
- }
500
- }
501
- if (params.key !== newKey) {
502
- // oldの場合newが存在するはずがない
503
- const existingNewKeyCount = yield this.redisClient.exists(newKey);
504
- debug('existingNewKeyCount:', existingNewKeyCount);
505
- if (existingNewKeyCount > 0) {
506
- throw new factory.errors.ServiceUnavailable(`stockHolder keys conflicted. eventId:${params.eventId}`);
507
- }
508
- }
509
- }
510
- });
511
- }
512
240
  }
513
241
  StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
514
- StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
515
242
  exports.StockHolderRepository = StockHolderRepository;
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.13.0"
120
+ "version": "21.14.0"
121
121
  }
@@ -1,21 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- const project = { id: process.env.PROJECT_ID };
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
12
-
13
- const result = await priceSpecificationRepo.deleteUnnecessaryMovieTicketTypeChargePriceSpecs({
14
- project: { id: project.id }
15
- });
16
- console.log('deleted', result);
17
- }
18
-
19
- main()
20
- .then()
21
- .catch(console.error);
@@ -1,76 +0,0 @@
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: {
21
- $eq: chevre.factory.placeType.MovieTheater
22
- }
23
- // organizer: { $exists: false }
24
- },
25
- {
26
- branchCode: 1,
27
- _id: 1, name: 1, project: 1, hasPOS: 1
28
- }
29
- );
30
- console.log('places found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const movieTheater: Pick<chevre.factory.place.movieTheater.IPlace,
37
- 'branchCode' | 'id' | 'name' | 'project' | 'hasPOS'> = doc.toObject();
38
- console.log(movieTheater);
39
-
40
- if (!Array.isArray(movieTheater.hasPOS)) {
41
- console.log('has no pos', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
42
- } else {
43
- const alreadyMigrated = movieTheater.hasPOS.every((pos) => pos.branchCode === pos.id);
44
- if (alreadyMigrated) {
45
- console.log('already migrated...', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
46
- } else {
47
- if (movieTheater.hasPOS.length > 0) {
48
- const newHasPOS: chevre.factory.place.movieTheater.IPOS[] = movieTheater.hasPOS.map((pos) => {
49
- return {
50
- id: pos.id,
51
- branchCode: pos.id,
52
- name: pos.name
53
- };
54
- });
55
- console.log('updating place...', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i, newHasPOS);
56
- await placeRepo.saveMovieTheater(<any>{
57
- project: movieTheater.project,
58
- branchCode: movieTheater.branchCode,
59
- id: movieTheater.id,
60
- typeOf: chevre.factory.placeType.MovieTheater,
61
- hasPOS: newHasPOS
62
- });
63
- updateCount += 1;
64
- console.log('updated.', movieTheater.project.id, movieTheater.branchCode, movieTheater.name.ja, i);
65
- }
66
- }
67
- }
68
- });
69
-
70
- console.log(i, 'places checked');
71
- console.log(updateCount, 'places updated');
72
- }
73
-
74
- main()
75
- .then()
76
- .catch(console.error);