@chevre/domain 22.13.0-alpha.6 → 22.13.0-alpha.8

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.
@@ -56,7 +56,9 @@ type IKeyOfProjection4minimizedEvent<T extends AvailableEventType> = T extends f
56
56
  type IUnset<T extends AvailableEventType> = {
57
57
  [key in keyof factory.event.IEvent<T>]?: 1;
58
58
  };
59
- export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'>;
59
+ export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'> & {
60
+ identifier: string;
61
+ };
60
62
  /**
61
63
  * イベントリポジトリ
62
64
  */
@@ -160,7 +162,6 @@ export declare class EventRepo {
160
162
  * tttsイベントを識別子によって冪等作成する
161
163
  */
162
164
  saveEventByIdentifier4ttts(params: {
163
- oldEventId: string;
164
165
  attributes: ICreatingEvent4ttts;
165
166
  }): Promise<{
166
167
  id: string;
@@ -659,19 +659,28 @@ class EventRepo {
659
659
  */
660
660
  saveEventByIdentifier4ttts(params) {
661
661
  return __awaiter(this, void 0, void 0, function* () {
662
- const { oldEventId } = params;
663
- const _a = params.attributes, { project, typeOf, eventStatus } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus"]);
664
- const identifier = oldEventId;
662
+ // const { oldEventId } = params;
663
+ const _a = params.attributes, { project, typeOf, eventStatus, identifier, organizer } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus", "identifier", "organizer"]);
664
+ // const identifier = oldEventId;
665
+ if (typeof identifier !== 'string' || identifier.length === 0) {
666
+ throw new factory.errors.ArgumentNull('identifier');
667
+ }
665
668
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
666
669
  const id = uniqid();
667
- const doc = yield this.eventModel.findOneAndUpdate({
670
+ const doc = yield this.eventModel.findOneAndUpdate(
671
+ // 全イベントにidentifierを保証したので、additionalPropertyによるフィルターからidentifierによるフィルターへ変更(2025-09-05~)
672
+ // {
673
+ // 'project.id': { $eq: project.id },
674
+ // typeOf: { $eq: typeOf },
675
+ // // 追加特性をキーに更新
676
+ // additionalProperty: {
677
+ // $exists: true,
678
+ // $all: [{ name: 'oldEventId', value: identifier }]
679
+ // }
680
+ // },
681
+ {
668
682
  'project.id': { $eq: project.id },
669
- typeOf: { $eq: typeOf },
670
- // 追加特性をキーに更新
671
- additionalProperty: {
672
- $exists: true,
673
- $all: [{ name: 'oldEventId', value: oldEventId }]
674
- }
683
+ identifier: { $exists: true, $eq: identifier }
675
684
  },
676
685
  // upsertの場合、createがありうるので属性を除外しない
677
686
  {
@@ -680,6 +689,7 @@ class EventRepo {
680
689
  typeOf,
681
690
  project,
682
691
  eventStatus,
692
+ organizer,
683
693
  identifier // イベントコードを必ず追加(2025-09-03~)
684
694
  // ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
685
695
  },
@@ -5,14 +5,11 @@ import type * as COA from '@motionpicture/coa-service';
5
5
  import type { ActionRepo } from '../repo/action';
6
6
  import type { CategoryCodeRepo } from '../repo/categoryCode';
7
7
  import type { CreativeWorkRepo } from '../repo/creativeWork';
8
- import type { EventRepo, ICreatingEvent4ttts } from '../repo/event';
8
+ import type { EventRepo } from '../repo/event';
9
9
  import type { EventSeriesRepo } from '../repo/eventSeries';
10
10
  import type { MovieTheaterRepo } from '../repo/place/movieTheater';
11
11
  import type { ScreeningRoomRepo } from '../repo/place/screeningRoom';
12
- import type { ProjectRepo } from '../repo/project';
13
12
  import type { SellerRepo } from '../repo/seller';
14
- import type { SettingRepo } from '../repo/setting';
15
- import type { TaskRepo } from '../repo/task';
16
13
  import * as factory from '../factory';
17
14
  interface IImportFromCOAParams {
18
15
  project: {
@@ -38,7 +35,7 @@ interface IImportFromCOAParams {
38
35
  /**
39
36
  * イベントをインポートする
40
37
  */
41
- export declare function importFromCOA(params: IImportFromCOAParams): (repos: {
38
+ declare function importFromCOA(params: IImportFromCOAParams): (repos: {
42
39
  action: ActionRepo;
43
40
  categoryCode: CategoryCodeRepo;
44
41
  creativeWork: CreativeWorkRepo;
@@ -49,13 +46,10 @@ export declare function importFromCOA(params: IImportFromCOAParams): (repos: {
49
46
  seller: SellerRepo;
50
47
  masterService: COA.service.Master;
51
48
  }) => Promise<void>;
52
- export declare function minimizeSuperEvent(params: {
53
- superEvent: factory.event.screeningEventSeries.IEvent;
54
- }): factory.event.screeningEvent.ISuperEvent;
55
49
  /**
56
50
  * COA情報からイベントIDを作成する
57
51
  */
58
- export declare function createScreeningEventIdFromCOA(params: {
52
+ declare function createScreeningEventIdFromCOA(params: {
59
53
  theaterCode: string;
60
54
  titleCode: string;
61
55
  titleBranchNum: string;
@@ -63,27 +57,4 @@ export declare function createScreeningEventIdFromCOA(params: {
63
57
  screenCode: string;
64
58
  timeBegin: string;
65
59
  }): string;
66
- /**
67
- * イベントコード指定でtttsイベントを冪等更新する
68
- */
69
- export declare function updateEvent4ttts(params: {
70
- /**
71
- * 旧イベントID
72
- */
73
- oldEventId: string;
74
- /**
75
- * イベント属性
76
- */
77
- attributes: ICreatingEvent4ttts;
78
- project: {
79
- id: string;
80
- };
81
- }): (repos: {
82
- action: ActionRepo;
83
- event: EventRepo;
84
- eventSeries: EventSeriesRepo;
85
- project: ProjectRepo;
86
- setting: SettingRepo;
87
- task: TaskRepo;
88
- }) => Promise<void>;
89
- export { ICreatingEvent4ttts };
60
+ export { importFromCOA, createScreeningEventIdFromCOA };
@@ -10,17 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.importFromCOA = importFromCOA;
13
- exports.minimizeSuperEvent = minimizeSuperEvent;
14
13
  exports.createScreeningEventIdFromCOA = createScreeningEventIdFromCOA;
15
- exports.updateEvent4ttts = updateEvent4ttts;
16
14
  const createDebug = require("debug");
17
15
  // @ts-ignore
18
16
  const difference = require("lodash.difference");
19
17
  // import { google } from 'googleapis';
20
18
  const moment = require("moment-timezone");
21
19
  const factory = require("../factory");
22
- // import { Settings } from '../settings';
23
- const onEventChanged_1 = require("./offer/onEventChanged");
24
20
  const debug = createDebug('chevre-domain:service:event');
25
21
  /**
26
22
  * イベントをインポートする
@@ -858,54 +854,3 @@ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
858
854
  parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
859
855
  };
860
856
  }
861
- /**
862
- * イベントコード指定でtttsイベントを冪等更新する
863
- */
864
- function updateEvent4ttts(params) {
865
- return (repos) => __awaiter(this, void 0, void 0, function* () {
866
- const updateObject = {
867
- id: params.oldEventId,
868
- identifier: params.oldEventId, // support identifier(2025-09-03~)
869
- typeOf: factory.eventType.ScreeningEvent
870
- };
871
- const actionAttributes = {
872
- project: { typeOf: factory.organizationType.Project, id: params.project.id },
873
- typeOf: factory.actionType.UpdateAction,
874
- agent: { typeOf: factory.organizationType.Project, id: params.project.id },
875
- object: updateObject,
876
- // replacee: reservation,
877
- // replacer: params.attributes, // $unsetもありうるのでいったん保留
878
- targetCollection: {
879
- id: params.oldEventId,
880
- typeOf: factory.eventType.ScreeningEvent
881
- }
882
- };
883
- const action = yield repos.action.start(actionAttributes);
884
- let savedEvent;
885
- try {
886
- savedEvent = yield repos.event.saveEventByIdentifier4ttts({
887
- oldEventId: params.oldEventId,
888
- attributes: params.attributes
889
- });
890
- }
891
- catch (error) {
892
- try {
893
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
894
- }
895
- catch (__) {
896
- // 失敗したら仕方ない
897
- }
898
- throw error;
899
- }
900
- yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
901
- yield (0, onEventChanged_1.onEventChanged)({
902
- id: [savedEvent.id],
903
- project: { id: params.project.id },
904
- typeOf: factory.eventType.ScreeningEvent,
905
- isNew: false,
906
- useInform: true
907
- })(repos
908
- // スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
909
- );
910
- });
911
- }
@@ -0,0 +1,22 @@
1
+ import type { ICreatingEvent4ttts } from '../../../../repo/event';
2
+ import type { ICustomerMember } from '../../../../repo/member';
3
+ import * as factory from '../../../../factory';
4
+ declare function tour2creatingEvent(tour: ITourBySchedule, movieTheater: Pick<factory.place.movieTheater.IPlace, 'id' | 'branchCode' | 'parentOrganization'>, screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>, existingApplicationMembers: {
5
+ member: ICustomerMember;
6
+ }[], maxValue: number, eventService: Pick<factory.product.IProduct, 'id' | 'name'> & {
7
+ id: string;
8
+ }, screeningEventSeries: Pick<factory.event.screeningEventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | 'videoFormat' | 'workPerformed'>, project: {
9
+ id: string;
10
+ }): ICreatingEvent4ttts;
11
+ interface ITourBySchedule {
12
+ day: string;
13
+ start_time: string;
14
+ end_time?: never;
15
+ door_time: Date;
16
+ start_date: Date;
17
+ end_date: Date;
18
+ duration?: never;
19
+ tour_number: string;
20
+ }
21
+ declare function schedule2tours(settings: factory.schedule.IEventWithSchedule, createDate: Date): ITourBySchedule[];
22
+ export { tour2creatingEvent, schedule2tours };
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tour2creatingEvent = tour2creatingEvent;
4
+ exports.schedule2tours = schedule2tours;
5
+ const moment = require("moment-timezone");
6
+ const factory = require("../../../../factory");
7
+ // tslint:disable-next-line:max-func-body-length
8
+ // function schedule2createEventParams(
9
+ // schedule: factory.schedule.IEventWithSchedule,
10
+ // createDate: Date
11
+ // ): factory.event.screeningEvent.ICreateParams[] {
12
+ // const eventServiceId = schedule.offers?.itemOffered?.id;
13
+ // const makesOffer = schedule.offers?.seller?.makesOffer;
14
+ // const applicationIds: string[] = (Array.isArray(makesOffer))
15
+ // ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
16
+ // : [];
17
+ // const eventSeriesId = schedule.superEvent?.id;
18
+ // if (typeof eventServiceId !== 'string' || eventServiceId === '') {
19
+ // throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
20
+ // }
21
+ // if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
22
+ // throw new factory.errors.NotFound('schedule.superEvent.id');
23
+ // }
24
+ // // 引数情報取得
25
+ // if (schedule.eventSchedule === undefined) {
26
+ // throw new factory.errors.NotFound('eventSchedule');
27
+ // }
28
+ // const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
29
+ // debug(targetInfo.length, 'targetInfos ->', targetInfo);
30
+ // const createParams: factory.event.screeningEvent.ICreateParams[] = [];
31
+ // for (const performanceInfo of targetInfo) {
32
+ // const oldEventId = [
33
+ // // tslint:disable-next-line:no-magic-numbers
34
+ // performanceInfo.day.slice(-6),
35
+ // workPerformedIdentifier,
36
+ // movieTheater.branchCode,
37
+ // screeningRoom.branchCode,
38
+ // performanceInfo.start_time
39
+ // ].join('');
40
+ // const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
41
+ // const availabilityEnds: Date = moment(performanceInfo.end_date)
42
+ // .tz('Asia/Tokyo')
43
+ // .endOf('date')
44
+ // .toDate();
45
+ // const availabilityStarts: Date = moment(performanceInfo.start_date)
46
+ // .tz('Asia/Tokyo')
47
+ // .startOf('date')
48
+ // // tslint:disable-next-line:no-magic-numbers
49
+ // .add(-3, 'months')
50
+ // .toDate();
51
+ // const validThrough: Date = moment(performanceInfo.end_date)
52
+ // .tz('Asia/Tokyo')
53
+ // .endOf('date')
54
+ // .toDate();
55
+ // const validFrom: Date = moment(performanceInfo.start_date)
56
+ // .tz('Asia/Tokyo')
57
+ // .startOf('date')
58
+ // // tslint:disable-next-line:no-magic-numbers
59
+ // .add(-3, 'months')
60
+ // .toDate();
61
+ // // イベント作成
62
+ // createParams.push({
63
+ // eventStatus: factory.eventStatusType.EventScheduled,
64
+ // doorTime: performanceInfo.door_time,
65
+ // startDate: performanceInfo.start_date,
66
+ // endDate: performanceInfo.end_date,
67
+ // offers: {
68
+ // eligibleQuantity: {
69
+ // ...(typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
70
+ // },
71
+ // itemOffered: {
72
+ // // 興行ID追加(2022-09-01~)
73
+ // id: eventServiceId,
74
+ // serviceOutput: {
75
+ // typeOf: factory.reservationType.EventReservation,
76
+ // reservedTicket: {
77
+ // typeOf: 'Ticket',
78
+ // ticketedSeat: { typeOf: factory.placeType.Seat }
79
+ // }
80
+ // },
81
+ // },
82
+ // seller: {
83
+ // // event.offersにseller.makesOfferを追加(2022-11-18~)
84
+ // makesOffer: applicationIds.map((applicationId) => {
85
+ // return {
86
+ // typeOf: factory.offerType.Offer,
87
+ // availableAtOrFrom: { id: applicationId }, // support no-array(2024-10-13~),
88
+ // availabilityEnds,
89
+ // availabilityStarts,
90
+ // validFrom,
91
+ // validThrough
92
+ // };
93
+ // })
94
+ // }
95
+ // },
96
+ // // 旧フォーマットIDを追加特性に追加(2022-09-08~)
97
+ // additionalProperty: [
98
+ // { name: 'tourNumber', value: String(performanceInfo.tour_number) },
99
+ // { name: 'oldEventId', value: oldEventId }
100
+ // ],
101
+ // identifier: oldEventId
102
+ // });
103
+ // }
104
+ // return createParams;
105
+ // }
106
+ // tslint:disable-next-line:max-func-body-length
107
+ function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project) {
108
+ var _a;
109
+ const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
110
+ const oldEventId = [
111
+ // tslint:disable-next-line:no-magic-numbers
112
+ tour.day.slice(-6),
113
+ workPerformedIdentifier,
114
+ movieTheater.branchCode,
115
+ screeningRoom.branchCode,
116
+ tour.start_time
117
+ ].join('');
118
+ const availabilityEnds = moment(tour.end_date)
119
+ .tz('Asia/Tokyo')
120
+ .endOf('date')
121
+ .toDate();
122
+ const availabilityStarts = moment(tour.start_date)
123
+ .tz('Asia/Tokyo')
124
+ .startOf('date')
125
+ // tslint:disable-next-line:no-magic-numbers
126
+ .add(-3, 'months')
127
+ .toDate();
128
+ const validThrough = moment(tour.end_date)
129
+ .tz('Asia/Tokyo')
130
+ .endOf('date')
131
+ .toDate();
132
+ const validFrom = moment(tour.start_date)
133
+ .tz('Asia/Tokyo')
134
+ .startOf('date')
135
+ // tslint:disable-next-line:no-magic-numbers
136
+ .add(-3, 'months')
137
+ .toDate();
138
+ const seller = movieTheater.parentOrganization;
139
+ const offersSeller = {
140
+ typeOf: factory.organizationType.Corporation,
141
+ id: seller.id,
142
+ // event.offersにseller.makesOfferを追加(2022-11-18~)
143
+ makesOffer: existingApplicationMembers.map((a) => {
144
+ return {
145
+ typeOf: factory.offerType.Offer,
146
+ availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
147
+ availabilityEnds,
148
+ availabilityStarts,
149
+ validFrom,
150
+ validThrough
151
+ };
152
+ })
153
+ };
154
+ const offers = {
155
+ typeOf: factory.offerType.Offer,
156
+ eligibleQuantity: {
157
+ typeOf: 'QuantitativeValue',
158
+ unitCode: factory.unitCode.C62,
159
+ maxValue
160
+ },
161
+ itemOffered: Object.assign({
162
+ // 興行ID追加(2022-09-01~)
163
+ id: eventService.id, serviceOutput: {
164
+ typeOf: factory.reservationType.EventReservation,
165
+ reservedTicket: {
166
+ typeOf: 'Ticket',
167
+ ticketedSeat: { typeOf: factory.placeType.Seat }
168
+ }
169
+ }, typeOf: factory.product.ProductType.EventService, availableChannel: {
170
+ typeOf: 'ServiceChannel',
171
+ serviceLocation: {
172
+ typeOf: screeningRoom.typeOf,
173
+ branchCode: screeningRoom.branchCode,
174
+ name: screeningRoom.name,
175
+ containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
176
+ ? { name: screeningEventSeries.location.name }
177
+ : undefined)
178
+ }
179
+ } }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_a = eventService.name) === null || _a === void 0 ? void 0 : _a.ja) } }),
180
+ seller: offersSeller
181
+ };
182
+ const screeningEventSuperEvent = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: screeningEventSeries.typeOf, id: screeningEventSeries.id, videoFormat: screeningEventSeries.videoFormat, soundFormat: screeningEventSeries.soundFormat, workPerformed: screeningEventSeries.workPerformed, location: screeningEventSeries.location, kanaName: screeningEventSeries.kanaName, name: screeningEventSeries.name }, (Array.isArray(screeningEventSeries.additionalProperty))
183
+ ? { additionalProperty: screeningEventSeries.additionalProperty }
184
+ : undefined), (screeningEventSeries.startDate !== undefined)
185
+ ? { startDate: screeningEventSeries.startDate }
186
+ : undefined), (screeningEventSeries.endDate !== undefined)
187
+ ? { endDate: screeningEventSeries.endDate }
188
+ : undefined), (screeningEventSeries.description !== undefined)
189
+ ? { description: screeningEventSeries.description }
190
+ : undefined), (screeningEventSeries.headline !== undefined)
191
+ ? { headline: screeningEventSeries.headline }
192
+ : undefined);
193
+ const location = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined);
194
+ return {
195
+ project: { id: project.id, typeOf: factory.organizationType.Project },
196
+ typeOf: factory.eventType.ScreeningEvent,
197
+ eventStatus: factory.eventStatusType.EventScheduled,
198
+ name: screeningEventSeries.name,
199
+ doorTime: tour.door_time,
200
+ startDate: tour.start_date,
201
+ endDate: tour.end_date,
202
+ superEvent: screeningEventSuperEvent,
203
+ location,
204
+ offers,
205
+ // 旧フォーマットIDを追加特性に追加(2022-09-08~)
206
+ additionalProperty: [
207
+ { name: 'tourNumber', value: String(tour.tour_number) },
208
+ { name: 'oldEventId', value: oldEventId }
209
+ ],
210
+ // organizer追加(2023-07-12~)
211
+ organizer: { id: seller.id },
212
+ identifier: oldEventId
213
+ };
214
+ }
215
+ function schedule2tours(settings, createDate) {
216
+ const tours = [];
217
+ const { eventSchedule } = settings;
218
+ // 作成対象時間: 9,10,11など
219
+ // const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
220
+ // const minutes = ['00', '15', '30', '45'];
221
+ // const tours = ['1', '2', '3', '4'];
222
+ // 1日分作成する
223
+ const now = (createDate instanceof Date)
224
+ ? moment(createDate)
225
+ : moment();
226
+ let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
227
+ .format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
228
+ const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
229
+ .format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
230
+ const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
231
+ .asMinutes();
232
+ // tslint:disable-next-line:no-magic-numbers
233
+ const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
234
+ let i = 0;
235
+ while (startDate < startDateShouldBeLte) {
236
+ i += 1;
237
+ if (i > 1) {
238
+ startDate = moment(startDate)
239
+ .add(moment.duration(eventSchedule.repeatFrequency));
240
+ }
241
+ const hour = `0${moment(startDate)
242
+ .format('HH')}`
243
+ // 2桁でない時は'0'詰め
244
+ // tslint:disable-next-line:no-magic-numbers
245
+ .slice(-2);
246
+ let tourIndex = i % repeatCountInHour;
247
+ if (tourIndex === 0) {
248
+ tourIndex = repeatCountInHour;
249
+ }
250
+ const tourNumber = `${hour}${tourIndex}`;
251
+ const endDate = moment(startDate)
252
+ .add(moment.duration(eventSchedule.duration));
253
+ const day = moment(startDate)
254
+ .tz(eventSchedule.scheduleTimezone)
255
+ .format('YYYYMMDD');
256
+ const startTime = moment(startDate)
257
+ .tz(eventSchedule.scheduleTimezone)
258
+ .format('HHmm');
259
+ // const endTime = moment(endDate)
260
+ // .tz(eventSchedule.scheduleTimezone)
261
+ // .format('HHmm');
262
+ tours.push({
263
+ day: day,
264
+ start_time: startTime,
265
+ // end_time: endTime,
266
+ door_time: startDate.toDate(),
267
+ start_date: startDate.toDate(),
268
+ end_date: endDate.toDate(),
269
+ tour_number: tourNumber
270
+ // duration: eventSchedule.duration
271
+ });
272
+ }
273
+ return tours;
274
+ }
@@ -0,0 +1,15 @@
1
+ import type { ICreatingEvent4ttts } from '../../../../repo/event';
2
+ import type { EventSeriesRepo } from '../../../../repo/eventSeries';
3
+ import type { MemberRepo } from '../../../../repo/member';
4
+ import type { MovieTheaterRepo } from '../../../../repo/place/movieTheater';
5
+ import type { ScreeningRoomRepo } from '../../../../repo/place/screeningRoom';
6
+ import type { ProductRepo } from '../../../../repo/product';
7
+ import * as factory from '../../../../factory';
8
+ declare function schedule2events(schedule: factory.schedule.IEventWithSchedule, createDate: Date): (repos: {
9
+ eventSeries: EventSeriesRepo;
10
+ member: MemberRepo;
11
+ movieTheater: MovieTheaterRepo;
12
+ screeningRoom: ScreeningRoomRepo;
13
+ product: ProductRepo;
14
+ }) => Promise<ICreatingEvent4ttts[]>;
15
+ export { schedule2events };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.schedule2events = schedule2events;
13
+ const createDebug = require("debug");
14
+ const factory = require("../../../../factory");
15
+ const factory_1 = require("./factory");
16
+ const debug = createDebug('chevre-domain:service:task:createEvent');
17
+ function schedule2relatedResources(schedule) {
18
+ // tslint:disable-next-line:max-func-body-length
19
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
20
+ var _a, _b, _c, _d, _e, _f, _g, _h;
21
+ debug('schedule2relatedResources processing...', JSON.stringify(schedule));
22
+ const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
23
+ const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
24
+ const applicationIds = (Array.isArray(makesOffer))
25
+ ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
26
+ : [];
27
+ const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
28
+ const maxValue = (_g = (_f = schedule.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
29
+ const locationBranchCode = (_h = schedule.location) === null || _h === void 0 ? void 0 : _h.branchCode;
30
+ if (typeof eventServiceId !== 'string' || eventServiceId === '') {
31
+ throw new factory.errors.NotFound('schedule.offers.itemOffered.id required');
32
+ }
33
+ if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
34
+ throw new factory.errors.NotFound('schedule.superEvent.id required');
35
+ }
36
+ if (typeof maxValue !== 'number') {
37
+ throw new factory.errors.NotFound('schedule.offers.eligibleQuantity.maxValue required');
38
+ }
39
+ if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
40
+ throw new factory.errors.NotFound('location.branchCode required');
41
+ }
42
+ const project = schedule.project;
43
+ // 施設コンテンツ検索
44
+ const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
45
+ project: { id: { $eq: project.id } },
46
+ id: { $eq: eventSeriesId }
47
+ }, [
48
+ 'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
49
+ 'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
50
+ ])).shift();
51
+ if (screeningEventSeries === undefined) {
52
+ throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
53
+ }
54
+ // 劇場検索
55
+ const movieTheater = (yield repos.movieTheater.projectFields({
56
+ limit: 1,
57
+ page: 1,
58
+ project: { id: { $eq: project.id } },
59
+ branchCode: { $eq: screeningEventSeries.location.branchCode }
60
+ }, ['id', 'branchCode', 'parentOrganization'])).shift();
61
+ if (movieTheater === undefined) {
62
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
63
+ }
64
+ const screeningRoom = (yield repos.screeningRoom.searchScreeningRooms({
65
+ limit: 1,
66
+ page: 1,
67
+ project: { id: { $eq: project.id } },
68
+ containedInPlace: { id: { $eq: movieTheater.id } },
69
+ branchCode: { $eq: locationBranchCode }
70
+ })).shift();
71
+ if (screeningRoom === undefined) {
72
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom, `${factory.placeType.ScreeningRoom} ${locationBranchCode} not found`);
73
+ }
74
+ // 興行検索
75
+ const eventService = (yield repos.product.projectFields({
76
+ limit: 1,
77
+ page: 1,
78
+ project: { id: { $eq: project.id } },
79
+ id: { $eq: eventServiceId }
80
+ // productID: { $eq: eventServiceProductID }
81
+ }, ['name'])).shift();
82
+ if (typeof (eventService === null || eventService === void 0 ? void 0 : eventService.id) !== 'string') {
83
+ throw new Error(`EventService ${eventServiceId} not found`);
84
+ }
85
+ let existingApplicationMembers = [];
86
+ if (applicationIds.length > 0) {
87
+ existingApplicationMembers = yield repos.member.searchCustomerMembers({
88
+ limit: 100,
89
+ page: 1,
90
+ project: { id: project.id },
91
+ member: {
92
+ // typeOf: {
93
+ // $eq: factory.creativeWorkType.WebApplication
94
+ // },
95
+ id: { $in: applicationIds }
96
+ }
97
+ });
98
+ }
99
+ return {
100
+ movieTheater, screeningRoom,
101
+ existingApplicationMembers, maxValue, eventService, screeningEventSeries
102
+ };
103
+ });
104
+ }
105
+ function schedule2events(schedule, createDate) {
106
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
107
+ if (schedule.eventSchedule === undefined) {
108
+ throw new factory.errors.NotFound('schedule.eventSchedule required');
109
+ }
110
+ const { movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries } = yield schedule2relatedResources(schedule)(repos);
111
+ const project = schedule.project;
112
+ const tours = (0, factory_1.schedule2tours)(schedule, createDate);
113
+ debug(tours.length, 'tours ->', JSON.stringify(tours));
114
+ return tours.map((tour) => (0, factory_1.tour2creatingEvent)(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project));
115
+ });
116
+ }
@@ -11,349 +11,85 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createEventBySchedule = createEventBySchedule;
13
13
  const createDebug = require("debug");
14
- // import * as fs from 'fs';
15
- const moment = require("moment-timezone");
16
14
  const factory = require("../../../factory");
15
+ const onEventChanged_1 = require("../../offer/onEventChanged");
17
16
  // import { Settings } from '../../../settings';
18
- const event_1 = require("../../event");
19
- const debug = createDebug('chevre-domain:service:task');
17
+ const schedule2events_1 = require("./createEventBySchedule/schedule2events");
18
+ const debug = createDebug('chevre-domain:service:task:createEvent');
19
+ /**
20
+ * イベントコード指定でtttsイベントを冪等更新する
21
+ */
22
+ function updateEvent4ttts(params) {
23
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
24
+ const updateObject = {
25
+ id: params.attributes.identifier,
26
+ identifier: params.attributes.identifier, // support identifier(2025-09-03~)
27
+ typeOf: factory.eventType.ScreeningEvent
28
+ };
29
+ const actionAttributes = {
30
+ project: { typeOf: factory.organizationType.Project, id: params.project.id },
31
+ typeOf: factory.actionType.UpdateAction,
32
+ agent: { typeOf: factory.organizationType.Project, id: params.project.id },
33
+ object: updateObject,
34
+ // replacee: reservation,
35
+ // replacer: params.attributes, // $unsetもありうるのでいったん保留
36
+ targetCollection: {
37
+ id: params.attributes.identifier,
38
+ typeOf: factory.eventType.ScreeningEvent
39
+ }
40
+ };
41
+ const action = yield repos.action.start(actionAttributes);
42
+ let savedEvent;
43
+ try {
44
+ savedEvent = yield repos.event.saveEventByIdentifier4ttts({
45
+ // oldEventId: params.oldEventId,
46
+ attributes: params.attributes
47
+ });
48
+ }
49
+ catch (error) {
50
+ try {
51
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
52
+ }
53
+ catch (__) {
54
+ // 失敗したら仕方ない
55
+ }
56
+ throw error;
57
+ }
58
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
59
+ yield (0, onEventChanged_1.onEventChanged)({
60
+ id: [savedEvent.id],
61
+ project: { id: params.project.id },
62
+ typeOf: factory.eventType.ScreeningEvent,
63
+ isNew: false,
64
+ useInform: true
65
+ })(repos
66
+ // スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
67
+ );
68
+ });
69
+ }
20
70
  function createEvents(
21
71
  // schedule: factory.schedule.ISchedule4ttts | factory.schedule.IEventWithSchedule,
22
72
  schedule, createDate) {
23
- // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
24
73
  return (repos
25
74
  // settings: Settings
26
75
  ) => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b, _c, _d, _e, _f, _g, _h;
28
- // console.log(moment.duration(15, 'minute').toISOString());
29
- // return;
30
- const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
31
- const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
32
- const applicationIds = (Array.isArray(makesOffer))
33
- ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
34
- : [];
35
- const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
36
- if (typeof eventServiceId !== 'string' || eventServiceId === '') {
37
- throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
38
- }
39
- if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
40
- throw new factory.errors.NotFound('schedule.superEvent.id');
41
- }
42
- const project = schedule.project;
43
- // 引数情報取得
44
- if (schedule.eventSchedule === undefined) {
45
- throw new factory.errors.NotFound('eventSchedule');
46
- }
47
- const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
48
- debug(targetInfo.length, 'targetInfos ->', targetInfo);
49
- // fs.writeFileSync(
50
- // `${__dirname}/../../../../../targetInfo_${schedule.eventSchedule?.typeOf}.json`,
51
- // JSON.stringify(targetInfo, null, ' ')
52
- // );
53
- // return;
54
- // 施設コンテンツ検索
55
- const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
56
- project: { id: { $eq: project.id } },
57
- id: { $eq: eventSeriesId }
58
- }, [
59
- 'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
60
- 'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
61
- ])).shift();
62
- if (screeningEventSeries === undefined) {
63
- throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
64
- }
65
- const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
66
- // 劇場検索
67
- const movieTheaters = yield repos.movieTheater.projectFields({
68
- limit: 1,
69
- page: 1,
70
- project: { id: { $eq: project.id } },
71
- branchCode: { $eq: screeningEventSeries.location.branchCode }
72
- }, ['id', 'branchCode', 'offers', 'parentOrganization']);
73
- const movieTheater = movieTheaters.shift();
74
- if (movieTheater === undefined) {
75
- throw new factory.errors.NotFound(factory.placeType.MovieTheater);
76
- }
77
- const seller = movieTheater.parentOrganization;
78
- const screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
79
- limit: 1,
80
- page: 1,
81
- project: { id: { $eq: project.id } },
82
- containedInPlace: { id: { $eq: movieTheater.id } }
83
- });
84
- const screeningRoom = screeningRooms.shift();
85
- if (screeningRoom === undefined) {
86
- throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
87
- }
88
- // 興行検索
89
- // const eventServiceProductID = schedule.eventServiceProductID; // 興行設定に変更(2023-09-24~)
90
- const searchEventServicesResult = yield repos.product.projectFields({
91
- limit: 1,
92
- page: 1,
93
- project: { id: { $eq: project.id } },
94
- id: { $eq: eventServiceId }
95
- // productID: { $eq: eventServiceProductID }
96
- }, ['name']);
97
- const eventService = searchEventServicesResult.shift();
98
- if (typeof (eventService === null || eventService === void 0 ? void 0 : eventService.id) !== 'string') {
99
- throw new Error(`EventService ${eventServiceId} not found`);
100
- }
101
- let existingApplicationMembers = [];
102
- if (applicationIds.length > 0) {
103
- existingApplicationMembers = yield repos.member.searchCustomerMembers({
104
- limit: 100,
105
- page: 1,
106
- project: { id: project.id },
107
- member: {
108
- // typeOf: {
109
- // $eq: factory.creativeWorkType.WebApplication
110
- // },
111
- id: { $in: applicationIds }
112
- }
113
- });
114
- }
115
- // ロールで絞る(customer or pos)
116
- // existingApplicationMembers = existingApplicationMembers
117
- // .filter((m) => {
118
- // return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
119
- // });
120
- for (const performanceInfo of targetInfo) {
121
- const oldEventId = [
122
- // tslint:disable-next-line:no-magic-numbers
123
- performanceInfo.day.slice(-6),
124
- workPerformedIdentifier,
125
- movieTheater.branchCode,
126
- screeningRoom.branchCode,
127
- performanceInfo.start_time
128
- ].join('');
129
- const maxValue = (_g = (_f = movieTheater.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
130
- const availabilityEnds = moment(performanceInfo.end_date)
131
- .tz('Asia/Tokyo')
132
- .endOf('date')
133
- .toDate();
134
- const availabilityStarts = moment(performanceInfo.start_date)
135
- .tz('Asia/Tokyo')
136
- .startOf('date')
137
- // tslint:disable-next-line:no-magic-numbers
138
- .add(-3, 'months')
139
- .toDate();
140
- const validThrough = moment(performanceInfo.end_date)
141
- .tz('Asia/Tokyo')
142
- .endOf('date')
143
- .toDate();
144
- const validFrom = moment(performanceInfo.start_date)
145
- .tz('Asia/Tokyo')
146
- .startOf('date')
147
- // tslint:disable-next-line:no-magic-numbers
148
- .add(-3, 'months')
149
- .toDate();
150
- const offersSeller = {
151
- typeOf: factory.organizationType.Corporation,
152
- id: String(seller === null || seller === void 0 ? void 0 : seller.id),
153
- // event.offersにseller.makesOfferを追加(2022-11-18~)
154
- makesOffer: existingApplicationMembers.map((a) => {
155
- return {
156
- typeOf: factory.offerType.Offer,
157
- availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
158
- availabilityEnds,
159
- availabilityStarts,
160
- validFrom,
161
- validThrough
162
- };
163
- })
164
- };
165
- const offers = Object.assign({ typeOf: factory.offerType.Offer, eligibleQuantity: Object.assign({ typeOf: 'QuantitativeValue', unitCode: factory.unitCode.C62 }, (typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
166
- ), itemOffered: Object.assign({
167
- // 興行ID追加(2022-09-01~)
168
- id: eventService.id, serviceOutput: {
169
- typeOf: factory.reservationType.EventReservation,
170
- reservedTicket: {
171
- typeOf: 'Ticket',
172
- ticketedSeat: { typeOf: factory.placeType.Seat }
173
- }
174
- }, typeOf: factory.product.ProductType.EventService, availableChannel: {
175
- typeOf: 'ServiceChannel',
176
- serviceLocation: {
177
- typeOf: screeningRoom.typeOf,
178
- branchCode: screeningRoom.branchCode,
179
- name: screeningRoom.name,
180
- containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
181
- ? { name: screeningEventSeries.location.name }
182
- : undefined)
183
- }
184
- } }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_h = eventService.name) === null || _h === void 0 ? void 0 : _h.ja) } }), seller: offersSeller }, {
185
- // availabilityEnds, // discontinue(2024-10-16~)
186
- // availabilityStarts,
187
- // validThrough,
188
- // validFrom
189
- });
190
- const screeningEventSuperEvent = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: screeningEventSeries.typeOf, id: screeningEventSeries.id, videoFormat: screeningEventSeries.videoFormat, soundFormat: screeningEventSeries.soundFormat, workPerformed: screeningEventSeries.workPerformed, location: screeningEventSeries.location, kanaName: screeningEventSeries.kanaName, name: screeningEventSeries.name }, (Array.isArray(screeningEventSeries.additionalProperty))
191
- ? { additionalProperty: screeningEventSeries.additionalProperty }
192
- : undefined), (screeningEventSeries.startDate !== undefined)
193
- ? { startDate: screeningEventSeries.startDate }
194
- : undefined), (screeningEventSeries.endDate !== undefined)
195
- ? { endDate: screeningEventSeries.endDate }
196
- : undefined), (screeningEventSeries.description !== undefined)
197
- ? { description: screeningEventSeries.description }
198
- : undefined), (screeningEventSeries.headline !== undefined)
199
- ? { headline: screeningEventSeries.headline }
200
- : undefined);
201
- // イベント作成
202
- const eventAttributes = {
203
- project: { id: project.id, typeOf: factory.organizationType.Project },
204
- typeOf: factory.eventType.ScreeningEvent,
205
- eventStatus: factory.eventStatusType.EventScheduled,
206
- name: screeningEventSeries.name,
207
- doorTime: performanceInfo.door_time,
208
- startDate: performanceInfo.start_date,
209
- endDate: performanceInfo.end_date,
210
- superEvent: screeningEventSuperEvent,
211
- location: Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined),
212
- offers: offers,
213
- // checkInCount: undefined,
214
- // attendeeCount: undefined,
215
- // 旧フォーマットIDを追加特性に追加(2022-09-08~)
216
- additionalProperty: [
217
- { name: 'tourNumber', value: String(performanceInfo.tour_number) },
218
- { name: 'oldEventId', value: oldEventId }
219
- ],
220
- // organizer追加(2023-07-12~)
221
- organizer: { id: seller.id }
222
- };
76
+ const creatingEvents = yield (0, schedule2events_1.schedule2events)(schedule, createDate)(repos);
77
+ for (const eventAttributes of creatingEvents) {
223
78
  // domain.serviceで実装(2022-09-10~)
224
- debug('updating event...', oldEventId, eventAttributes.startDate);
225
- yield (0, event_1.updateEvent4ttts)({
226
- oldEventId,
79
+ debug('updating event...', eventAttributes.identifier, eventAttributes.startDate);
80
+ yield updateEvent4ttts({
81
+ // oldEventId,
227
82
  attributes: eventAttributes,
228
83
  project: { id: eventAttributes.project.id }
229
84
  // agent: eventAttributes.project
230
85
  })(repos
231
86
  // settings
232
87
  );
233
- debug('event update(updateEvent4ttts)', oldEventId, eventAttributes.startDate);
88
+ debug('event update(updateEvent4ttts)', eventAttributes.identifier, eventAttributes.startDate);
234
89
  }
235
- debug(targetInfo.length, 'events updated');
90
+ debug(creatingEvents.length, 'events updated');
236
91
  });
237
92
  }
238
- /**
239
- * パフォーマンス作成・作成対象情報取得
240
- */
241
- // function getTargetInfoForCreateFromSetting(
242
- // settings: factory.schedule.ISchedule4ttts,
243
- // createDate: Date
244
- // ): ITargetPerformanceInfo[] {
245
- // const performanceInfos: ITargetPerformanceInfo[] = [];
246
- // const { days, duration, noPerformanceTimes, hours, minutes, tours } = settings;
247
- // // 本日日付+開始日までの日数から作成開始日セット
248
- // // 作成日数分の作成対象日付作成
249
- // for (let index = 0; index < days; index = index + 1) {
250
- // const now = (createDate instanceof Date)
251
- // ? moment(createDate)
252
- // .add(index, 'days')
253
- // : moment()
254
- // .add(index, 'days');
255
- // hours.forEach((hourStr) => {
256
- // // 2桁でない時は'0'詰め
257
- // // tslint:disable-next-line:no-magic-numbers
258
- // const hour = `0${hourStr}`.slice(-2);
259
- // minutes.forEach((minute, minuteIndex) => {
260
- // // ツアー情報作成
261
- // const tourNumber = `${hour}${tours[minuteIndex]}`;
262
- // const startDate = moment(
263
- // `${now.tz('Asia/Tokyo')
264
- // .format('YYYYMMDD')} ${hour}:${minute}:00+09:00`,
265
- // 'YYYYMMDD HH:mm:ssZ'
266
- // );
267
- // const endDate = moment(startDate)
268
- // .add(duration, 'minutes');
269
- // const day = moment(startDate)
270
- // .tz('Asia/Tokyo')
271
- // .format('YYYYMMDD');
272
- // const startTime = moment(startDate)
273
- // .tz('Asia/Tokyo')
274
- // .format('HHmm');
275
- // const endTime = moment(endDate)
276
- // .tz('Asia/Tokyo')
277
- // .format('HHmm');
278
- // // パフォーマンスを作成しない時刻に指定されていなかったら作成
279
- // if (noPerformanceTimes.indexOf(`${hour}${minute}`) < 0) {
280
- // performanceInfos.push({
281
- // day: day,
282
- // start_time: startTime,
283
- // end_time: endTime,
284
- // door_time: startDate.toDate(),
285
- // start_date: startDate.toDate(),
286
- // end_date: endDate.toDate(),
287
- // tour_number: tourNumber,
288
- // duration: moment.duration(duration, 'minutes')
289
- // .toISOString()
290
- // });
291
- // }
292
- // });
293
- // });
294
- // }
295
- // return performanceInfos;
296
- // }
297
- function getTargetInfoByEventWithSchedule(settings, createDate) {
298
- const performanceInfos = [];
299
- const { eventSchedule } = settings;
300
- // 作成対象時間: 9,10,11など
301
- // const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
302
- // const minutes = ['00', '15', '30', '45'];
303
- // const tours = ['1', '2', '3', '4'];
304
- // 1日分作成する
305
- const now = (createDate instanceof Date)
306
- ? moment(createDate)
307
- : moment();
308
- let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
309
- .format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
310
- const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
311
- .format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
312
- const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
313
- .asMinutes();
314
- // tslint:disable-next-line:no-magic-numbers
315
- const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
316
- let i = 0;
317
- while (startDate < startDateShouldBeLte) {
318
- i += 1;
319
- if (i > 1) {
320
- startDate = moment(startDate)
321
- .add(moment.duration(eventSchedule.repeatFrequency));
322
- }
323
- const hour = `0${moment(startDate)
324
- .format('HH')}`
325
- // 2桁でない時は'0'詰め
326
- // tslint:disable-next-line:no-magic-numbers
327
- .slice(-2);
328
- let tourIndex = i % repeatCountInHour;
329
- if (tourIndex === 0) {
330
- tourIndex = repeatCountInHour;
331
- }
332
- const tourNumber = `${hour}${tourIndex}`;
333
- const endDate = moment(startDate)
334
- .add(moment.duration(eventSchedule.duration));
335
- const day = moment(startDate)
336
- .tz(eventSchedule.scheduleTimezone)
337
- .format('YYYYMMDD');
338
- const startTime = moment(startDate)
339
- .tz(eventSchedule.scheduleTimezone)
340
- .format('HHmm');
341
- const endTime = moment(endDate)
342
- .tz(eventSchedule.scheduleTimezone)
343
- .format('HHmm');
344
- performanceInfos.push({
345
- day: day,
346
- start_time: startTime,
347
- end_time: endTime,
348
- door_time: startDate.toDate(),
349
- start_date: startDate.toDate(),
350
- end_date: endDate.toDate(),
351
- tour_number: tourNumber,
352
- duration: eventSchedule.duration
353
- });
354
- }
355
- return performanceInfos;
356
- }
357
93
  function createEventBySchedule(params) {
358
94
  return (repos
359
95
  // settings: Settings
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.398.0-alpha.3",
14
+ "@chevre/factory": "4.398.0-alpha.4",
15
15
  "@cinerino/sdk": "12.2.0",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "22.13.0-alpha.6"
118
+ "version": "22.13.0-alpha.8"
119
119
  }