@chevre/domain 23.2.0-alpha.1 → 23.2.0-alpha.2
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.
|
@@ -11,15 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = call;
|
|
13
13
|
const COA = require("@motionpicture/coa-service");
|
|
14
|
+
const moment = require("moment-timezone");
|
|
14
15
|
const factory = require("../../factory");
|
|
15
16
|
const action_1 = require("../../repo/action");
|
|
16
17
|
const categoryCode_1 = require("../../repo/categoryCode");
|
|
17
18
|
const creativeWork_1 = require("../../repo/creativeWork");
|
|
18
19
|
const credentials_1 = require("../../repo/credentials");
|
|
19
|
-
|
|
20
|
+
const event_1 = require("../../repo/event");
|
|
20
21
|
const eventSeries_1 = require("../../repo/eventSeries");
|
|
21
22
|
const movieTheater_1 = require("../../repo/place/movieTheater");
|
|
23
|
+
const screeningRoom_1 = require("../../repo/place/screeningRoom");
|
|
22
24
|
const reserveInterface_1 = require("../../repo/reserveInterface");
|
|
25
|
+
const saveScreeningEvents_1 = require("../event/saveScreeningEvents");
|
|
23
26
|
const saveScreeningEventSeries_1 = require("../event/saveScreeningEventSeries");
|
|
24
27
|
let coaAuthClient;
|
|
25
28
|
/**
|
|
@@ -63,10 +66,11 @@ function call(params) {
|
|
|
63
66
|
endpoint: coaAuthClient.options.endpoint, // same as authClient(2024-07-17~)
|
|
64
67
|
auth: coaAuthClient
|
|
65
68
|
}, { timeout: settings.coa.timeout });
|
|
66
|
-
const { object } = params.data;
|
|
69
|
+
const { agent, object } = params.data;
|
|
67
70
|
if (object.typeOf === factory.eventType.ScreeningEventSeries) {
|
|
68
71
|
yield syncEventSeries({
|
|
69
72
|
project: { id: params.project.id },
|
|
73
|
+
agent,
|
|
70
74
|
object,
|
|
71
75
|
sameAs: { id: params.id }
|
|
72
76
|
})({
|
|
@@ -78,6 +82,23 @@ function call(params) {
|
|
|
78
82
|
masterService
|
|
79
83
|
});
|
|
80
84
|
}
|
|
85
|
+
else if (object.typeOf === factory.eventType.ScreeningEvent) {
|
|
86
|
+
yield syncEvents({
|
|
87
|
+
project: { id: params.project.id },
|
|
88
|
+
agent,
|
|
89
|
+
object,
|
|
90
|
+
sameAs: { id: params.id }
|
|
91
|
+
})({
|
|
92
|
+
action: actionRepo,
|
|
93
|
+
categoryCode: new categoryCode_1.CategoryCodeRepo(connection),
|
|
94
|
+
creativeWork: new creativeWork_1.CreativeWorkRepo(connection),
|
|
95
|
+
event: new event_1.EventRepo(connection),
|
|
96
|
+
eventSeries: new eventSeries_1.EventSeriesRepo(connection),
|
|
97
|
+
movieTheater: new movieTheater_1.MovieTheaterRepo(connection),
|
|
98
|
+
screeningRoom: new screeningRoom_1.ScreeningRoomRepo(connection),
|
|
99
|
+
masterService
|
|
100
|
+
});
|
|
101
|
+
}
|
|
81
102
|
}
|
|
82
103
|
catch (error) {
|
|
83
104
|
let throwsError = true;
|
|
@@ -101,22 +122,10 @@ function call(params) {
|
|
|
101
122
|
function syncEventSeries(params) {
|
|
102
123
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
103
124
|
const { locationBranchCode, titleBranchNum, titleCode } = params.object;
|
|
104
|
-
const movieTheater = (yield repos.movieTheater.projectFields({
|
|
105
|
-
limit: 1,
|
|
106
|
-
page: 1,
|
|
107
|
-
project: { id: { $eq: params.project.id } },
|
|
108
|
-
branchCode: { $eq: locationBranchCode }
|
|
109
|
-
}, ['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
|
|
110
|
-
// []
|
|
111
|
-
)).shift();
|
|
112
|
-
if (movieTheater === undefined) {
|
|
113
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
114
|
-
}
|
|
115
|
-
// console.log('movieTheater:', movieTheater);
|
|
116
125
|
const actionAttributes = {
|
|
117
126
|
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
118
127
|
typeOf: factory.actionType.ReplaceAction,
|
|
119
|
-
agent:
|
|
128
|
+
agent: params.agent,
|
|
120
129
|
// tslint:disable-next-line:no-suspicious-comment
|
|
121
130
|
// TODO define object
|
|
122
131
|
object: Object.assign(Object.assign({}, params.object), { typeOf: factory.eventType.ScreeningEventSeries }),
|
|
@@ -127,6 +136,18 @@ function syncEventSeries(params) {
|
|
|
127
136
|
const action = yield repos.action.start(actionAttributes);
|
|
128
137
|
let saveResult;
|
|
129
138
|
try {
|
|
139
|
+
const movieTheater = (yield repos.movieTheater.projectFields({
|
|
140
|
+
limit: 1,
|
|
141
|
+
page: 1,
|
|
142
|
+
project: { id: { $eq: params.project.id } },
|
|
143
|
+
branchCode: { $eq: locationBranchCode }
|
|
144
|
+
}, ['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
|
|
145
|
+
// []
|
|
146
|
+
)).shift();
|
|
147
|
+
if (movieTheater === undefined) {
|
|
148
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
149
|
+
}
|
|
150
|
+
// console.log('movieTheater:', movieTheater);
|
|
130
151
|
saveResult = yield (0, saveScreeningEventSeries_1.saveScreeningEventSeries)({
|
|
131
152
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
132
153
|
seller: { id: movieTheater.parentOrganization.id },
|
|
@@ -164,3 +185,115 @@ function syncEventSeries(params) {
|
|
|
164
185
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
|
|
165
186
|
});
|
|
166
187
|
}
|
|
188
|
+
// tslint:disable-next-line:max-func-body-length
|
|
189
|
+
function syncEvents(params) {
|
|
190
|
+
// tslint:disable-next-line:max-func-body-length
|
|
191
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const { locationBranchCode, titleBranchNum, titleCode, roomCode, startDate } = params.object;
|
|
193
|
+
const actionAttributes = {
|
|
194
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
195
|
+
typeOf: factory.actionType.ReplaceAction,
|
|
196
|
+
agent: params.agent,
|
|
197
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
198
|
+
// TODO define object
|
|
199
|
+
object: Object.assign(Object.assign({}, params.object), { typeOf: factory.eventType.ScreeningEvent }),
|
|
200
|
+
// instrument,
|
|
201
|
+
targetCollection: { typeOf: factory.eventType.ScreeningEvent },
|
|
202
|
+
sameAs: { id: params.sameAs.id, typeOf: 'Task' }
|
|
203
|
+
};
|
|
204
|
+
const action = yield repos.action.start(actionAttributes);
|
|
205
|
+
let saveResult;
|
|
206
|
+
try {
|
|
207
|
+
const movieTheater = (yield repos.movieTheater.projectFields({
|
|
208
|
+
limit: 1,
|
|
209
|
+
page: 1,
|
|
210
|
+
project: { id: { $eq: params.project.id } },
|
|
211
|
+
branchCode: { $eq: locationBranchCode }
|
|
212
|
+
}, ['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
|
|
213
|
+
// []
|
|
214
|
+
)).shift();
|
|
215
|
+
if (movieTheater === undefined) {
|
|
216
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
217
|
+
}
|
|
218
|
+
// console.log('movieTheater:', movieTheater);
|
|
219
|
+
const screeningRoom = (yield repos.screeningRoom.searchScreeningRooms({
|
|
220
|
+
project: { id: { $eq: params.project.id } },
|
|
221
|
+
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
|
|
222
|
+
branchCode: { $eq: roomCode }
|
|
223
|
+
})).shift();
|
|
224
|
+
if (screeningRoom === undefined) {
|
|
225
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
226
|
+
}
|
|
227
|
+
// console.log(screeningRoom);
|
|
228
|
+
const eventSeriesId = (0, saveScreeningEventSeries_1.createScreeningEventSeriesId)({
|
|
229
|
+
theaterCode: locationBranchCode,
|
|
230
|
+
titleCode,
|
|
231
|
+
titleBranchNum
|
|
232
|
+
});
|
|
233
|
+
const eventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
234
|
+
id: { $eq: eventSeriesId },
|
|
235
|
+
project: { id: { $eq: params.project.id } }
|
|
236
|
+
}, [
|
|
237
|
+
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
238
|
+
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
239
|
+
'organizer', 'videoFormat', 'soundFormat', 'workPerformed',
|
|
240
|
+
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
241
|
+
'offers', 'additionalProperty'
|
|
242
|
+
])).shift();
|
|
243
|
+
if (eventSeries === undefined) {
|
|
244
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
245
|
+
}
|
|
246
|
+
// console.log(eventSeries);
|
|
247
|
+
const targetImportFrom = moment(startDate)
|
|
248
|
+
.tz('Asia/Tokyo')
|
|
249
|
+
.startOf('day');
|
|
250
|
+
const targetImportThrough = moment(startDate)
|
|
251
|
+
.tz('Asia/Tokyo')
|
|
252
|
+
.endOf('day');
|
|
253
|
+
const begin = moment(targetImportFrom)
|
|
254
|
+
.add(-1, 'day') // 深夜帯スケジュールが前日検索の結果に含まれるため
|
|
255
|
+
.tz('Asia/Tokyo')
|
|
256
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
257
|
+
const end = moment(targetImportThrough)
|
|
258
|
+
// .add(-1, 'day')
|
|
259
|
+
.tz('Asia/Tokyo')
|
|
260
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
261
|
+
// console.log('importing screening events...', targetImportFrom, targetImportThrough, begin, end);
|
|
262
|
+
saveResult = yield (0, saveScreeningEvents_1.saveScreeningEvents)({
|
|
263
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
264
|
+
seller: { id: movieTheater.parentOrganization.id },
|
|
265
|
+
movieTheater,
|
|
266
|
+
screeningRooms: [screeningRoom],
|
|
267
|
+
screeningEventSerieses: [eventSeries],
|
|
268
|
+
targetImportFrom: targetImportFrom.toDate(),
|
|
269
|
+
targetImportThrough: targetImportThrough.toDate(),
|
|
270
|
+
instrument: {
|
|
271
|
+
theaterCode: locationBranchCode,
|
|
272
|
+
begin, // debug(2024-04-24~)
|
|
273
|
+
end, // debug(2024-04-24~)
|
|
274
|
+
typeOf: 'WebAPI',
|
|
275
|
+
identifier: factory.service.webAPI.Identifier.COA
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
filterSchedulesFromCOA: { titleBranchNum, titleCode, roomCode }
|
|
279
|
+
})(repos);
|
|
280
|
+
// console.log('saveResult:', saveResult.length, 'events');
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
try {
|
|
284
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
285
|
+
}
|
|
286
|
+
catch (__) {
|
|
287
|
+
// no op
|
|
288
|
+
}
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
const result = saveResult.map((event) => {
|
|
292
|
+
return {
|
|
293
|
+
id: event.id,
|
|
294
|
+
typeOf: event.typeOf
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
|
|
298
|
+
});
|
|
299
|
+
}
|
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": "5.4.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.4.0-alpha.5",
|
|
15
15
|
"@cinerino/sdk": "12.12.1",
|
|
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": "23.2.0-alpha.
|
|
118
|
+
"version": "23.2.0-alpha.2"
|
|
119
119
|
}
|