@chevre/domain 21.4.0-alpha.21 → 21.4.0-alpha.23

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.
@@ -85,9 +85,9 @@ async function main() {
85
85
  'movieTheaterBranchCode:', movieTheaterBranchCode,
86
86
  i
87
87
  );
88
- // throw new Error('movieTheater not found');
88
+ throw new Error('movieTheater not found');
89
89
 
90
- return;
90
+ // return;
91
91
  }
92
92
  if (typeof sellerId === 'string') {
93
93
  const newProvider: chevre.factory.reservation.IProvider = {
@@ -53,12 +53,13 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
53
53
  };
54
54
  }, {
55
55
  typeOf: string;
56
+ project: any;
56
57
  reservationNumber: string;
58
+ provider: any;
57
59
  reservationStatus: string;
58
60
  checkedIn: boolean;
59
61
  attended: boolean;
60
62
  _id?: string | undefined;
61
- project?: any;
62
63
  broker?: any;
63
64
  price?: any;
64
65
  priceCurrency?: string | undefined;
@@ -67,7 +68,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
67
68
  underName?: any;
68
69
  issuedThrough?: any;
69
70
  subReservation?: any;
70
- provider?: any;
71
71
  reservedTicket?: any;
72
72
  additionalTicketText?: string | undefined;
73
73
  bookingTime?: Date | undefined;
@@ -82,12 +82,13 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
82
82
  previousReservationStatus?: string | undefined;
83
83
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
84
84
  typeOf: string;
85
+ project: any;
85
86
  reservationNumber: string;
87
+ provider: any;
86
88
  reservationStatus: string;
87
89
  checkedIn: boolean;
88
90
  attended: boolean;
89
91
  _id?: string | undefined;
90
- project?: any;
91
92
  broker?: any;
92
93
  price?: any;
93
94
  priceCurrency?: string | undefined;
@@ -96,7 +97,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
96
97
  underName?: any;
97
98
  issuedThrough?: any;
98
99
  subReservation?: any;
99
- provider?: any;
100
100
  reservedTicket?: any;
101
101
  additionalTicketText?: string | undefined;
102
102
  bookingTime?: Date | undefined;
@@ -111,12 +111,13 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
111
111
  previousReservationStatus?: string | undefined;
112
112
  }>> & Omit<import("mongoose").FlatRecord<{
113
113
  typeOf: string;
114
+ project: any;
114
115
  reservationNumber: string;
116
+ provider: any;
115
117
  reservationStatus: string;
116
118
  checkedIn: boolean;
117
119
  attended: boolean;
118
120
  _id?: string | undefined;
119
- project?: any;
120
121
  broker?: any;
121
122
  price?: any;
122
123
  priceCurrency?: string | undefined;
@@ -125,7 +126,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
125
126
  underName?: any;
126
127
  issuedThrough?: any;
127
128
  subReservation?: any;
128
- provider?: any;
129
129
  reservedTicket?: any;
130
130
  additionalTicketText?: string | undefined;
131
131
  bookingTime?: Date | undefined;
@@ -9,8 +9,14 @@ exports.modelName = modelName;
9
9
  * 予約スキーマ
10
10
  */
11
11
  const schema = new mongoose_1.Schema({
12
- project: mongoose_1.SchemaTypes.Mixed,
13
- provider: mongoose_1.SchemaTypes.Mixed,
12
+ project: {
13
+ type: mongoose_1.SchemaTypes.Mixed,
14
+ required: true
15
+ },
16
+ provider: {
17
+ type: mongoose_1.SchemaTypes.Mixed,
18
+ required: true
19
+ },
14
20
  _id: String,
15
21
  typeOf: {
16
22
  type: String,
@@ -76,10 +82,7 @@ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
76
82
  schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
77
83
  schema.index({ bookingTime: -1 }, { name: 'searchByBookingTime-v3' });
78
84
  schema.index({ 'project.id': 1, bookingTime: -1 }, { name: 'searchByProjectId-v20220721' });
79
- // schema.index(
80
- // { 'provider.id': 1, bookingTime: -1 },
81
- // { name: 'searchByProviderId' }
82
- // );
85
+ schema.index({ 'provider.id': 1, bookingTime: -1 }, { name: 'searchByProviderId' });
83
86
  schema.index({ typeOf: 1, bookingTime: -1 }, { name: 'searchByTypeOf-v3' });
84
87
  schema.index({ reservationNumber: 1, bookingTime: -1 }, { name: 'searchByReservationNumber-v3' });
85
88
  schema.index({ reservationStatus: 1, bookingTime: -1 }, { name: 'searchByReservationStatus-v3' });
@@ -1,9 +1,11 @@
1
1
  import * as factory from '../../factory';
2
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
3
3
  import { MongoRepository as EventRepo } from '../../repo/event';
4
+ import { MongoRepository as PlaceRepo } from '../../repo/place';
4
5
  import { MongoRepository as TaskRepo } from '../../repo/task';
5
6
  export declare function createEvent(params: factory.task.createEvent.IData): (repos: {
6
7
  action: ActionRepo;
7
8
  event: EventRepo;
9
+ place: PlaceRepo;
8
10
  task: TaskRepo;
9
11
  }) => Promise<void>;
@@ -11,33 +11,59 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createEvent = void 0;
13
13
  const factory = require("../../factory");
14
- // tslint:disable-next-line:max-func-body-length
15
14
  function createEvent(params) {
15
+ // tslint:disable-next-line:max-func-body-length
16
16
  return (repos) => __awaiter(this, void 0, void 0, function* () {
17
- var _a;
17
+ var _a, _b;
18
18
  const actionAttributes = params;
19
19
  const action = yield repos.action.start(actionAttributes);
20
20
  let eventIds = [];
21
21
  let eventType;
22
22
  try {
23
- if (((_a = actionAttributes.instrument) === null || _a === void 0 ? void 0 : _a.createScreeningEventSeriesIfNotExistByWorkPerformed) === true) {
24
- const bulkWriteResult = yield repos.event.createScreeningEventSeriesIfNotExistByWorkPerformed(actionAttributes.object.map((p) => {
25
- if (p.typeOf !== factory.eventType.ScreeningEventSeries) {
26
- throw new factory.errors.Argument('typeOf', `must be ${factory.eventType.ScreeningEventSeries}`);
23
+ if (actionAttributes.object.length > 0) {
24
+ if (((_a = actionAttributes.instrument) === null || _a === void 0 ? void 0 : _a.createScreeningEventSeriesIfNotExistByWorkPerformed) === true) {
25
+ const createScreeningEventSeriesOnAllLocation = ((_b = actionAttributes.instrument) === null || _b === void 0 ? void 0 : _b.createScreeningEventSeriesOnAllLocation) === true;
26
+ let creatingEventParams = actionAttributes.object.map((p) => {
27
+ if (p.typeOf !== factory.eventType.ScreeningEventSeries) {
28
+ throw new factory.errors.Argument('typeOf', `must be ${factory.eventType.ScreeningEventSeries}`);
29
+ }
30
+ return { attributes: p };
31
+ });
32
+ // 全施設対応(2023-07-21~)
33
+ if (createScreeningEventSeriesOnAllLocation) {
34
+ if (creatingEventParams.length !== 1) {
35
+ throw new factory.errors.NotImplemented('creatingEventAttributes.length must be 1');
36
+ }
37
+ const firstCreatingEventParams = creatingEventParams[0];
38
+ const movieTheaters = yield repos.place.searchMovieTheaters({
39
+ project: { id: { $eq: actionAttributes.project.id } }
40
+ }, ['_id', 'branchCode', 'kanaName', 'name'], []);
41
+ creatingEventParams = movieTheaters.map((movieTheater) => {
42
+ const location = {
43
+ branchCode: movieTheater.branchCode,
44
+ id: movieTheater.id,
45
+ kanaName: movieTheater.kanaName,
46
+ name: movieTheater.name,
47
+ typeOf: factory.placeType.MovieTheater
48
+ };
49
+ return {
50
+ attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location })
51
+ };
52
+ });
27
53
  }
28
- return { attributes: p };
29
- }));
30
- let upsertedIds;
31
- if (bulkWriteResult !== undefined) {
32
- upsertedIds = bulkWriteResult.getUpsertedIds()
33
- .map((doc) => doc._id.toString());
54
+ const bulkWriteResult = yield repos.event.createScreeningEventSeriesIfNotExistByWorkPerformed(creatingEventParams);
55
+ let upsertedIds;
56
+ if (bulkWriteResult !== undefined) {
57
+ upsertedIds = bulkWriteResult.getUpsertedIds()
58
+ .map((doc) => doc._id.toString());
59
+ }
60
+ eventIds = (Array.isArray(upsertedIds)) ? upsertedIds : [];
61
+ eventType = factory.eventType.ScreeningEventSeries;
62
+ }
63
+ else {
64
+ // no op
65
+ throw new factory.errors.NotImplemented('only createScreeningEventSeriesIfNotExistByWorkPerformed implemented');
34
66
  }
35
- eventIds = (Array.isArray(upsertedIds)) ? upsertedIds : [];
36
- eventType = factory.eventType.ScreeningEventSeries;
37
- }
38
- else {
39
- // no op
40
- throw new factory.errors.NotImplemented('only createScreeningEventSeriesIfNotExistByWorkPerformed implemented');
41
67
  }
42
68
  }
43
69
  catch (error) {
@@ -61,7 +87,7 @@ function createEvent(params) {
61
87
  })
62
88
  : undefined
63
89
  });
64
- if (Array.isArray(eventIds) && eventIds.length > 0) {
90
+ if (Array.isArray(eventIds) && eventIds.length > 0 && typeof eventType === 'string') {
65
91
  // 非同期に変更(2023-06-08~)
66
92
  const onEventChangedTask = {
67
93
  project: actionAttributes.project,
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
13
  const action_1 = require("../../repo/action");
14
14
  const event_1 = require("../../repo/event");
15
+ const place_1 = require("../../repo/place");
15
16
  const task_1 = require("../../repo/task");
16
17
  const EventService = require("../event");
17
18
  /**
@@ -22,6 +23,7 @@ function call(data) {
22
23
  yield EventService.createEvent(data)({
23
24
  action: new action_1.MongoRepository(settings.connection),
24
25
  event: new event_1.MongoRepository(settings.connection),
26
+ place: new place_1.MongoRepository(settings.connection),
25
27
  task: new task_1.MongoRepository(settings.connection)
26
28
  });
27
29
  });
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.316.0-alpha.3",
12
+ "@chevre/factory": "4.316.0-alpha.4",
13
13
  "@cinerino/sdk": "3.161.0-alpha.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -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.4.0-alpha.21"
120
+ "version": "21.4.0-alpha.23"
121
121
  }