@chevre/domain 20.1.0-alpha.10 → 20.1.0-alpha.12

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.
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  // tslint:disable:no-console
2
- // import * as redis from 'redis';
2
+ import * as moment from 'moment';
3
3
  import * as mongoose from 'mongoose';
4
4
 
5
5
  import { chevre } from '../../../lib/index';
@@ -15,22 +15,42 @@ async function main() {
15
15
  limit: 100,
16
16
  page: 1,
17
17
  sort: { startDate: 1 },
18
- typeOf: chevre.factory.eventType.ScreeningEventSeries,
18
+ typeOf: chevre.factory.eventType.ScreeningEvent,
19
19
  project: { id: { $eq: PROJECT_ID } },
20
- workPerformed: { identifiers: ['xxx', 'xxx2', 'xxx3', 'xxx4'] }
21
- // eventStatuses: [chevre.factory.eventStatusType.EventScheduled]
22
- // offers: {
23
- // itemOffered: {
24
- // serviceOutput: {
25
- // reservedTicket: {
26
- // ticketedSeat: {
27
- // // 座席指定有のみの検索の場合
28
- // typeOfs: [chevre.factory.placeType.Seat]
29
- // }
30
- // }
31
- // }
32
- // }
33
- // }
20
+ offers: {
21
+ seller: {
22
+ makesOffer: {
23
+ $elemMatch: {
24
+ 'availableAtOrFrom.id': { $eq: '5h3gs22mu9j3ok7o63uog9o9i3' },
25
+ availabilityEnds: {
26
+ $gte: moment('2022-11-18T02:20:00.000Z')
27
+ .toDate(),
28
+ $lte: moment('2022-11-18T02:20:00.000Z')
29
+ .toDate()
30
+ },
31
+ availabilityStarts: {
32
+ $gte: moment('2022-11-15T15:00:00.000Z')
33
+ .toDate(),
34
+ $lte: moment('2022-11-15T15:00:00.000Z')
35
+ .toDate()
36
+ },
37
+ validFrom: {
38
+ $gte: moment('2022-11-15T15:00:00.000Z')
39
+ .toDate(),
40
+ $lte: moment('2022-11-15T15:00:00.000Z')
41
+ .toDate()
42
+ },
43
+ validThrough: {
44
+ $gte: moment('2022-11-18T02:20:00.000Z')
45
+ .toDate(),
46
+ $lte: moment('2022-11-18T02:20:00.000Z')
47
+ .toDate()
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ id: { $in: ['al6aff83y'] }
34
54
  });
35
55
  console.log(events);
36
56
  console.log(events.length);
@@ -33,7 +33,7 @@ class MongoRepository {
33
33
  }
34
34
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
35
35
  static CREATE_MONGO_CONDITIONS(conditions) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
37
37
  const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
38
38
  const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
39
39
  if (typeof projectIdEq === 'string') {
@@ -280,6 +280,15 @@ class MongoRepository {
280
280
  }
281
281
  }
282
282
  }
283
+ const sellerMakesOfferElemMatch = (_q = (_p = (_o = params.offers) === null || _o === void 0 ? void 0 : _o.seller) === null || _p === void 0 ? void 0 : _p.makesOffer) === null || _q === void 0 ? void 0 : _q.$elemMatch;
284
+ if (typeof ((_r = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _r === void 0 ? void 0 : _r.$eq) === 'string') {
285
+ andConditions.push({
286
+ 'offers.seller.makesOffer': {
287
+ $exists: true,
288
+ $elemMatch: sellerMakesOfferElemMatch
289
+ }
290
+ });
291
+ }
283
292
  break;
284
293
  case factory.eventType.ScreeningEventSeries:
285
294
  params = conditions;
@@ -309,7 +318,7 @@ class MongoRepository {
309
318
  ]
310
319
  });
311
320
  }
312
- const locationIdEq = (_p = (_o = params.location) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$eq;
321
+ const locationIdEq = (_t = (_s = params.location) === null || _s === void 0 ? void 0 : _s.id) === null || _t === void 0 ? void 0 : _t.$eq;
313
322
  // tslint:disable-next-line:no-single-line-block-comment
314
323
  /* istanbul ignore else */
315
324
  if (typeof locationIdEq === 'string') {
@@ -331,7 +340,7 @@ class MongoRepository {
331
340
  });
332
341
  }
333
342
  }
334
- const workPerformedIdentifierIn = (_q = params.workPerformed) === null || _q === void 0 ? void 0 : _q.identifiers;
343
+ const workPerformedIdentifierIn = (_u = params.workPerformed) === null || _u === void 0 ? void 0 : _u.identifiers;
335
344
  // tslint:disable-next-line:no-single-line-block-comment
336
345
  /* istanbul ignore else */
337
346
  if (Array.isArray(workPerformedIdentifierIn)) {
@@ -342,7 +351,7 @@ class MongoRepository {
342
351
  }
343
352
  });
344
353
  }
345
- const videoFormatTypeOfEq = (_s = (_r = params.videoFormat) === null || _r === void 0 ? void 0 : _r.typeOf) === null || _s === void 0 ? void 0 : _s.$eq;
354
+ const videoFormatTypeOfEq = (_w = (_v = params.videoFormat) === null || _v === void 0 ? void 0 : _v.typeOf) === null || _w === void 0 ? void 0 : _w.$eq;
346
355
  if (typeof videoFormatTypeOfEq === 'string') {
347
356
  andConditions.push({
348
357
  'videoFormat.typeOf': {
@@ -351,7 +360,7 @@ class MongoRepository {
351
360
  }
352
361
  });
353
362
  }
354
- const videoFormatTypeOfIn = (_u = (_t = params.videoFormat) === null || _t === void 0 ? void 0 : _t.typeOf) === null || _u === void 0 ? void 0 : _u.$in;
363
+ const videoFormatTypeOfIn = (_y = (_x = params.videoFormat) === null || _x === void 0 ? void 0 : _x.typeOf) === null || _y === void 0 ? void 0 : _y.$in;
355
364
  if (Array.isArray(videoFormatTypeOfIn)) {
356
365
  andConditions.push({
357
366
  'videoFormat.typeOf': {
@@ -360,7 +369,7 @@ class MongoRepository {
360
369
  }
361
370
  });
362
371
  }
363
- const soundFormatTypeOfEq = (_w = (_v = params.soundFormat) === null || _v === void 0 ? void 0 : _v.typeOf) === null || _w === void 0 ? void 0 : _w.$eq;
372
+ const soundFormatTypeOfEq = (_0 = (_z = params.soundFormat) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$eq;
364
373
  if (typeof soundFormatTypeOfEq === 'string') {
365
374
  andConditions.push({
366
375
  'soundFormat.typeOf': {
@@ -369,7 +378,7 @@ class MongoRepository {
369
378
  }
370
379
  });
371
380
  }
372
- const soundFormatTypeOfIn = (_y = (_x = params.soundFormat) === null || _x === void 0 ? void 0 : _x.typeOf) === null || _y === void 0 ? void 0 : _y.$in;
381
+ const soundFormatTypeOfIn = (_2 = (_1 = params.soundFormat) === null || _1 === void 0 ? void 0 : _1.typeOf) === null || _2 === void 0 ? void 0 : _2.$in;
373
382
  if (Array.isArray(soundFormatTypeOfIn)) {
374
383
  andConditions.push({
375
384
  'soundFormat.typeOf': {
@@ -185,6 +185,62 @@ schema.index({
185
185
  },
186
186
  name: 'searchByOffersItemOfferedId'
187
187
  });
188
+ // tslint:disable-next-line:no-suspicious-comment
189
+ // TODO add index
190
+ // schema.index(
191
+ // { 'offers.seller.makesOffer': 1, startDate: 1 },
192
+ // {
193
+ // name: 'searchBySellerMakesOffer',
194
+ // partialFilterExpression: {
195
+ // 'offers.seller.makesOffer': { $exists: true }
196
+ // }
197
+ // }
198
+ // );
199
+ // schema.index(
200
+ // { 'offers.seller.makesOffer.availableAtOrFrom.id': 1, startDate: 1 },
201
+ // {
202
+ // name: 'searchBySellerMakesOfferAvailableAtOrFromId',
203
+ // partialFilterExpression: {
204
+ // 'offers.seller.makesOffer.availableAtOrFrom.id': { $exists: true }
205
+ // }
206
+ // }
207
+ // );
208
+ // schema.index(
209
+ // { 'offers.seller.makesOffer.availabilityEnds': 1, startDate: 1 },
210
+ // {
211
+ // name: 'searchBySellerMakesOfferAvailabilityEnds',
212
+ // partialFilterExpression: {
213
+ // 'offers.seller.makesOffer.availabilityEnds': { $exists: true }
214
+ // }
215
+ // }
216
+ // );
217
+ // schema.index(
218
+ // { 'offers.seller.makesOffer.availabilityStarts': 1, startDate: 1 },
219
+ // {
220
+ // name: 'searchBySellerMakesOfferAvailabilityStarts',
221
+ // partialFilterExpression: {
222
+ // 'offers.seller.makesOffer.availabilityStarts': { $exists: true }
223
+ // }
224
+ // }
225
+ // );
226
+ // schema.index(
227
+ // { 'offers.seller.makesOffer.validThrough': 1, startDate: 1 },
228
+ // {
229
+ // name: 'searchBySellerMakesOfferValidThrough',
230
+ // partialFilterExpression: {
231
+ // 'offers.seller.makesOffer.validThrough': { $exists: true }
232
+ // }
233
+ // }
234
+ // );
235
+ // schema.index(
236
+ // { 'offers.seller.makesOffer.validFrom': 1, startDate: 1 },
237
+ // {
238
+ // name: 'searchBySellerMakesOfferValidFrom',
239
+ // partialFilterExpression: {
240
+ // 'offers.seller.makesOffer.validFrom': { $exists: true }
241
+ // }
242
+ // }
243
+ // );
188
244
  schema.index({ 'videoFormat.typeOf': 1, startDate: 1 }, {
189
245
  name: 'searchByVideoFormatTypeOf',
190
246
  partialFilterExpression: {
@@ -13,7 +13,6 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.createCompoundPriceSpec4event = void 0;
15
15
  const factory = require("../../factory");
16
- const USE_MULTIPLE_MOVIE_TICKET_CHARGE = process.env.USE_MULTIPLE_MOVIE_TICKET_CHARGE === '1';
17
16
  function categoryCodeChargePriceSpec2component(params) {
18
17
  var _a;
19
18
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToCategoryCode: params.appliesToCategoryCode }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
@@ -35,25 +34,13 @@ function createCompoundPriceSpec4event(params) {
35
34
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
36
35
  unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
37
36
  // すべての上映方式に該当する加算料金を追加(2022-10-29~)
38
- if (USE_MULTIPLE_MOVIE_TICKET_CHARGE) {
39
- const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
40
- var _a;
41
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
42
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
43
- && params.videoFormatTypes.includes(s.appliesToVideoFormat);
44
- });
45
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
46
- }
47
- else {
48
- const mvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
49
- var _a;
50
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
51
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType;
52
- });
53
- if (mvtkSpec4appliesToMovieTicket !== undefined) {
54
- mvtkPriceComponents.push(mvtkChargePriceSpec2component(mvtkSpec4appliesToMovieTicket));
55
- }
56
- }
37
+ const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
38
+ var _a;
39
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
40
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
41
+ && params.videoFormatTypes.includes(s.appliesToVideoFormat);
42
+ });
43
+ mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
57
44
  });
58
45
  }
59
46
  else {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.278.0-alpha.1",
13
- "@cinerino/sdk": "3.132.1",
12
+ "@chevre/factory": "4.278.0-alpha.2",
13
+ "@cinerino/sdk": "3.133.0-alpha.1",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.1.0-alpha.10"
123
+ "version": "20.1.0-alpha.12"
124
124
  }