@chevre/domain 21.13.0 → 21.15.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) 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/factory/event.d.ts +1 -1
  39. package/lib/chevre/factory/event.js +2 -8
  40. package/lib/chevre/repo/event.d.ts +5 -20
  41. package/lib/chevre/repo/event.js +47 -56
  42. package/lib/chevre/repo/priceSpecification.d.ts +0 -5
  43. package/lib/chevre/repo/priceSpecification.js +0 -9
  44. package/lib/chevre/repo/stockHolder.d.ts +0 -11
  45. package/lib/chevre/repo/stockHolder.js +11 -284
  46. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  47. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -8
  48. package/lib/chevre/service/offer.js +25 -7
  49. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +3 -1
  50. package/lib/chevre/service/transaction/returnOrder.js +5 -3
  51. package/package.json +1 -1
  52. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +0 -21
  53. 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
  },