@chevre/domain 21.5.0-alpha.0 → 21.5.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.
- package/lib/chevre/factory/event.d.ts +6 -0
- package/lib/chevre/factory/event.js +47 -0
- package/lib/chevre/repo/event.d.ts +27 -8
- package/lib/chevre/repo/event.js +63 -8
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +6 -6
- package/lib/chevre/repo/place.d.ts +1 -1
- package/lib/chevre/repo/place.js +1 -1
- package/lib/chevre/service/offer.d.ts +7 -7
- package/lib/chevre/service/offer.js +27 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +25 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +147 -0
- package/lib/chevre/service/task/onResourceUpdated.js +2 -74
- package/lib/chevre/service.d.ts +2 -0
- package/lib/chevre/service.js +3 -0
- package/package.json +2 -2
- package/example/src/chevre/cleanEventsByMovieTheater.ts +0 -32
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
2
|
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
3
|
+
/**
|
|
4
|
+
* 興行イベントのsuperEventを作成する
|
|
5
|
+
*/
|
|
6
|
+
export declare function minimizeSuperEvent(params: {
|
|
7
|
+
superEventFromDB: factory.event.screeningEventSeries.IEvent;
|
|
8
|
+
}): factory.event.screeningEvent.ISuperEvent;
|
|
@@ -1,2 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minimizeSuperEvent = void 0;
|
|
4
|
+
const factory = require("../factory");
|
|
5
|
+
/**
|
|
6
|
+
* 興行イベントのsuperEventを作成する
|
|
7
|
+
*/
|
|
8
|
+
function minimizeSuperEvent(params) {
|
|
9
|
+
const workPerformed = Object.assign(Object.assign(Object.assign(Object.assign({
|
|
10
|
+
// 不要なので廃止(2022-12-19~)
|
|
11
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: params.project.id },
|
|
12
|
+
typeOf: factory.creativeWorkType.Movie, identifier: String(params.superEventFromDB.workPerformed.identifier) }, (typeof params.superEventFromDB.workPerformed.id === 'string')
|
|
13
|
+
? { id: params.superEventFromDB.workPerformed.id }
|
|
14
|
+
: undefined), (params.superEventFromDB.workPerformed.name !== undefined)
|
|
15
|
+
? { name: params.superEventFromDB.workPerformed.name }
|
|
16
|
+
: undefined), (typeof params.superEventFromDB.workPerformed.duration === 'string')
|
|
17
|
+
? { duration: params.superEventFromDB.workPerformed.duration }
|
|
18
|
+
: undefined), (typeof params.superEventFromDB.workPerformed.contentRating === 'string')
|
|
19
|
+
? { contentRating: params.superEventFromDB.workPerformed.contentRating }
|
|
20
|
+
: undefined);
|
|
21
|
+
const location = Object.assign(Object.assign({
|
|
22
|
+
// 不要なので廃止(2022-12-19~)
|
|
23
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: params.project.id },
|
|
24
|
+
typeOf: factory.placeType.MovieTheater, id: params.superEventFromDB.location.id, branchCode: params.superEventFromDB.location.branchCode }, (params.superEventFromDB.location.name !== undefined)
|
|
25
|
+
? { name: params.superEventFromDB.location.name }
|
|
26
|
+
: undefined), (typeof params.superEventFromDB.location.kanaName === 'string')
|
|
27
|
+
? { kanaName: params.superEventFromDB.location.kanaName }
|
|
28
|
+
: undefined);
|
|
29
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.eventType.ScreeningEventSeries,
|
|
30
|
+
// 不要なので廃止(2023-06-09~)
|
|
31
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: params.project.id },
|
|
32
|
+
id: params.superEventFromDB.id, videoFormat: params.superEventFromDB.videoFormat, soundFormat: params.superEventFromDB.soundFormat, workPerformed,
|
|
33
|
+
location, kanaName: params.superEventFromDB.kanaName, name: Object.assign(Object.assign({}, (typeof params.superEventFromDB.name.en === 'string') ? { en: params.superEventFromDB.name.en } : undefined), (typeof params.superEventFromDB.name.ja === 'string') ? { ja: params.superEventFromDB.name.ja } : undefined) }, (Array.isArray(params.superEventFromDB.additionalProperty))
|
|
34
|
+
? { additionalProperty: params.superEventFromDB.additionalProperty }
|
|
35
|
+
: undefined), (params.superEventFromDB.startDate instanceof Date)
|
|
36
|
+
? { startDate: params.superEventFromDB.startDate }
|
|
37
|
+
: undefined), (params.superEventFromDB.endDate instanceof Date)
|
|
38
|
+
? { endDate: params.superEventFromDB.endDate }
|
|
39
|
+
: undefined), (params.superEventFromDB.description !== undefined)
|
|
40
|
+
? { description: params.superEventFromDB.description }
|
|
41
|
+
: undefined), (params.superEventFromDB.headline !== undefined)
|
|
42
|
+
? { headline: params.superEventFromDB.headline }
|
|
43
|
+
: undefined), (params.superEventFromDB.dubLanguage !== undefined)
|
|
44
|
+
? { dubLanguage: params.superEventFromDB.dubLanguage }
|
|
45
|
+
: undefined), (params.superEventFromDB.subtitleLanguage !== undefined)
|
|
46
|
+
? { subtitleLanguage: params.superEventFromDB.subtitleLanguage }
|
|
47
|
+
: undefined);
|
|
48
|
+
}
|
|
49
|
+
exports.minimizeSuperEvent = minimizeSuperEvent;
|
|
@@ -163,34 +163,53 @@ export declare class MongoRepository {
|
|
|
163
163
|
};
|
|
164
164
|
id: string;
|
|
165
165
|
}): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* 興行イベントのsuperEventを最新の情報に同期する
|
|
168
|
+
*/
|
|
169
|
+
syncScreeningEventSeries2screeningEvents(params: {
|
|
170
|
+
project: {
|
|
171
|
+
id: string;
|
|
172
|
+
};
|
|
173
|
+
superEvent: {
|
|
174
|
+
/**
|
|
175
|
+
* 施設コンテンツID
|
|
176
|
+
*/
|
|
177
|
+
id: string;
|
|
178
|
+
};
|
|
179
|
+
startDate: {
|
|
180
|
+
$gte: Date;
|
|
181
|
+
};
|
|
182
|
+
}): Promise<void>;
|
|
166
183
|
deleteById(params: {
|
|
167
184
|
project: {
|
|
168
185
|
id: string;
|
|
169
186
|
};
|
|
170
187
|
id: string;
|
|
171
188
|
}): Promise<void>;
|
|
172
|
-
|
|
189
|
+
deleteManyByOrganizerId(params: {
|
|
173
190
|
project: {
|
|
174
191
|
id: string;
|
|
175
192
|
};
|
|
176
|
-
|
|
177
|
-
|
|
193
|
+
organizer: {
|
|
194
|
+
id: string;
|
|
178
195
|
};
|
|
179
196
|
}): Promise<import("mongodb").DeleteResult>;
|
|
180
|
-
|
|
197
|
+
deleteManyByLocationId(params: {
|
|
181
198
|
project: {
|
|
182
199
|
id: string;
|
|
183
200
|
};
|
|
184
201
|
location: {
|
|
185
|
-
|
|
202
|
+
id: string;
|
|
186
203
|
};
|
|
187
204
|
}): Promise<import("mongodb").DeleteResult>;
|
|
188
|
-
|
|
205
|
+
deleteManyBySuperEventLocationId(params: {
|
|
189
206
|
project: {
|
|
190
207
|
id: string;
|
|
191
208
|
};
|
|
192
|
-
|
|
193
|
-
|
|
209
|
+
superEvent: {
|
|
210
|
+
location: {
|
|
211
|
+
id: string;
|
|
212
|
+
};
|
|
194
213
|
};
|
|
195
214
|
}): Promise<import("mongodb").DeleteResult>;
|
|
196
215
|
deleteByProject(params: {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.MongoRepository = exports.PROJECTION_MINIMIZED_EVENT = void 0;
|
|
24
24
|
const uniqid = require("uniqid");
|
|
25
25
|
const factory = require("../factory");
|
|
26
|
+
const EventFactory = require("../factory/event");
|
|
26
27
|
const event_1 = require("./mongoose/schemas/event");
|
|
27
28
|
const errorHandler_1 = require("../errorHandler");
|
|
28
29
|
const settings_1 = require("../settings");
|
|
@@ -842,6 +843,36 @@ class MongoRepository {
|
|
|
842
843
|
.exec();
|
|
843
844
|
});
|
|
844
845
|
}
|
|
846
|
+
/**
|
|
847
|
+
* 興行イベントのsuperEventを最新の情報に同期する
|
|
848
|
+
*/
|
|
849
|
+
syncScreeningEventSeries2screeningEvents(params) {
|
|
850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
851
|
+
const superEvents = yield this.search({
|
|
852
|
+
limit: 1,
|
|
853
|
+
page: 1,
|
|
854
|
+
typeOf: factory.eventType.ScreeningEventSeries,
|
|
855
|
+
id: { $eq: params.superEvent.id },
|
|
856
|
+
project: { id: { $eq: params.project.id } }
|
|
857
|
+
});
|
|
858
|
+
const superEventFromDB = superEvents.shift();
|
|
859
|
+
if (superEventFromDB === undefined) {
|
|
860
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
861
|
+
}
|
|
862
|
+
const superEvent = EventFactory.minimizeSuperEvent({ superEventFromDB });
|
|
863
|
+
yield this.eventModel.updateMany({
|
|
864
|
+
typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
865
|
+
'project.id': { $eq: params.project.id },
|
|
866
|
+
'superEvent.id': { $exists: true, $eq: params.superEvent.id },
|
|
867
|
+
startDate: { $gte: params.startDate.$gte }
|
|
868
|
+
}, {
|
|
869
|
+
$set: {
|
|
870
|
+
superEvent
|
|
871
|
+
}
|
|
872
|
+
})
|
|
873
|
+
.exec();
|
|
874
|
+
});
|
|
875
|
+
}
|
|
845
876
|
deleteById(params) {
|
|
846
877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
847
878
|
yield this.eventModel.findOneAndDelete({
|
|
@@ -851,31 +882,55 @@ class MongoRepository {
|
|
|
851
882
|
.exec();
|
|
852
883
|
});
|
|
853
884
|
}
|
|
854
|
-
deleteScreeningEventsByMovieTheaterBranchCode(params
|
|
885
|
+
// public async deleteScreeningEventsByMovieTheaterBranchCode(params: {
|
|
886
|
+
// project: { id: string };
|
|
887
|
+
// location: { branchCode: string };
|
|
888
|
+
// }) {
|
|
889
|
+
// return this.eventModel.deleteMany(
|
|
890
|
+
// {
|
|
891
|
+
// typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
892
|
+
// 'project.id': { $eq: params.project.id },
|
|
893
|
+
// 'superEvent.location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
894
|
+
// }
|
|
895
|
+
// )
|
|
896
|
+
// .exec();
|
|
897
|
+
// }
|
|
898
|
+
// public async deleteScreeningEventSeriesByMovieTheaterBranchCode(params: {
|
|
899
|
+
// project: { id: string };
|
|
900
|
+
// location: { branchCode: string };
|
|
901
|
+
// }) {
|
|
902
|
+
// return this.eventModel.deleteMany(
|
|
903
|
+
// {
|
|
904
|
+
// typeOf: { $eq: factory.eventType.ScreeningEventSeries },
|
|
905
|
+
// 'project.id': { $eq: params.project.id },
|
|
906
|
+
// 'location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
907
|
+
// }
|
|
908
|
+
// )
|
|
909
|
+
// .exec();
|
|
910
|
+
// }
|
|
911
|
+
deleteManyByOrganizerId(params) {
|
|
855
912
|
return __awaiter(this, void 0, void 0, function* () {
|
|
856
913
|
return this.eventModel.deleteMany({
|
|
857
|
-
typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
858
914
|
'project.id': { $eq: params.project.id },
|
|
859
|
-
'
|
|
915
|
+
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
860
916
|
})
|
|
861
917
|
.exec();
|
|
862
918
|
});
|
|
863
919
|
}
|
|
864
|
-
|
|
920
|
+
deleteManyByLocationId(params) {
|
|
865
921
|
return __awaiter(this, void 0, void 0, function* () {
|
|
866
922
|
return this.eventModel.deleteMany({
|
|
867
|
-
typeOf: { $eq: factory.eventType.ScreeningEventSeries },
|
|
868
923
|
'project.id': { $eq: params.project.id },
|
|
869
|
-
'location.
|
|
924
|
+
'location.id': { $exists: true, $eq: params.location.id }
|
|
870
925
|
})
|
|
871
926
|
.exec();
|
|
872
927
|
});
|
|
873
928
|
}
|
|
874
|
-
|
|
929
|
+
deleteManyBySuperEventLocationId(params) {
|
|
875
930
|
return __awaiter(this, void 0, void 0, function* () {
|
|
876
931
|
return this.eventModel.deleteMany({
|
|
877
932
|
'project.id': { $eq: params.project.id },
|
|
878
|
-
'
|
|
933
|
+
'superEvent.location.id': { $exists: true, $eq: params.superEvent.location.id }
|
|
879
934
|
})
|
|
880
935
|
.exec();
|
|
881
936
|
});
|
|
@@ -82,9 +82,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
82
82
|
remainingAttendeeCapacity?: number | undefined;
|
|
83
83
|
videoFormat?: any;
|
|
84
84
|
soundFormat?: any;
|
|
85
|
-
subtitleLanguage?: any;
|
|
86
|
-
dubLanguage?: any;
|
|
87
85
|
kanaName?: string | undefined;
|
|
86
|
+
dubLanguage?: any;
|
|
87
|
+
subtitleLanguage?: any;
|
|
88
88
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
89
89
|
typeOf: string;
|
|
90
90
|
project: any;
|
|
@@ -116,9 +116,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
116
116
|
remainingAttendeeCapacity?: number | undefined;
|
|
117
117
|
videoFormat?: any;
|
|
118
118
|
soundFormat?: any;
|
|
119
|
-
subtitleLanguage?: any;
|
|
120
|
-
dubLanguage?: any;
|
|
121
119
|
kanaName?: string | undefined;
|
|
120
|
+
dubLanguage?: any;
|
|
121
|
+
subtitleLanguage?: any;
|
|
122
122
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
123
123
|
typeOf: string;
|
|
124
124
|
project: any;
|
|
@@ -150,9 +150,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
150
150
|
remainingAttendeeCapacity?: number | undefined;
|
|
151
151
|
videoFormat?: any;
|
|
152
152
|
soundFormat?: any;
|
|
153
|
-
subtitleLanguage?: any;
|
|
154
|
-
dubLanguage?: any;
|
|
155
153
|
kanaName?: string | undefined;
|
|
154
|
+
dubLanguage?: any;
|
|
155
|
+
subtitleLanguage?: any;
|
|
156
156
|
}> & Required<{
|
|
157
157
|
_id: string;
|
|
158
158
|
}>, never>>;
|
|
@@ -136,7 +136,7 @@ export declare class MongoRepository {
|
|
|
136
136
|
*/
|
|
137
137
|
id: string;
|
|
138
138
|
};
|
|
139
|
-
}): Promise<
|
|
139
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
140
140
|
createScreeningRoomSection(screeningRoomSection: IScreeningRoomSectionWithoutContainsPlace & {
|
|
141
141
|
parentOrganization?: {
|
|
142
142
|
id?: string;
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -475,7 +475,7 @@ class MongoRepository {
|
|
|
475
475
|
}
|
|
476
476
|
deleteScreeningRoomsByMovieTheaterId(params) {
|
|
477
477
|
return __awaiter(this, void 0, void 0, function* () {
|
|
478
|
-
|
|
478
|
+
return this.placeModel.deleteMany({
|
|
479
479
|
typeOf: { $eq: factory.placeType.ScreeningRoom },
|
|
480
480
|
'project.id': { $eq: params.project.id },
|
|
481
481
|
'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id }
|
|
@@ -50,18 +50,18 @@ export declare function searchEventSeatOffersWithPaging(params: {
|
|
|
50
50
|
/**
|
|
51
51
|
* イベント変更時処理
|
|
52
52
|
*/
|
|
53
|
-
export declare function onEventChanged(params: {
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
export declare function onEventChanged(params: factory.task.onEventChanged.IData): (repos: {
|
|
54
|
+
event: EventRepo;
|
|
55
|
+
project: ProjectRepo;
|
|
56
|
+
task: TaskRepo;
|
|
57
|
+
}) => Promise<void>;
|
|
58
|
+
export declare function syncEventSeries2screeningEvents(params: {
|
|
56
59
|
project: {
|
|
57
60
|
id: string;
|
|
58
61
|
};
|
|
59
|
-
|
|
60
|
-
useInform?: boolean;
|
|
62
|
+
ids: string[];
|
|
61
63
|
}): (repos: {
|
|
62
64
|
event: EventRepo;
|
|
63
|
-
project: ProjectRepo;
|
|
64
|
-
task: TaskRepo;
|
|
65
65
|
}) => Promise<void>;
|
|
66
66
|
export declare function createAggregateScreeningEventIfNotExist(params: {
|
|
67
67
|
project: {
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createInformTasks = exports.createAggregateScreeningEventIfNotExist = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
|
|
12
|
+
exports.createInformTasks = exports.createAggregateScreeningEventIfNotExist = exports.syncEventSeries2screeningEvents = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const factory = require("../factory");
|
|
15
15
|
const EventOfferService = require("./offer/event");
|
|
@@ -121,13 +121,11 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
exports.searchEventSeatOffersWithPaging = searchEventSeatOffersWithPaging;
|
|
124
|
-
// type IChangedEvent = factory.task.onEventChanged.IChangedEvent;
|
|
125
124
|
/**
|
|
126
125
|
* イベント変更時処理
|
|
127
126
|
*/
|
|
128
127
|
function onEventChanged(params) {
|
|
129
128
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
// const changedEvents = (Array.isArray(params.event)) ? params.event : [params.event];
|
|
131
129
|
if (params.id.length > 0) {
|
|
132
130
|
// ScreeningEventであれば集計タスク
|
|
133
131
|
if (params.typeOf === factory.eventType.ScreeningEvent) {
|
|
@@ -148,10 +146,36 @@ function onEventChanged(params) {
|
|
|
148
146
|
typeOf: params.typeOf
|
|
149
147
|
})(repos);
|
|
150
148
|
}
|
|
149
|
+
if (params.useSync === true) {
|
|
150
|
+
switch (params.typeOf) {
|
|
151
|
+
case factory.eventType.ScreeningEventSeries:
|
|
152
|
+
// 施設コンテンツを興行イベントへ同期(2023-07-28~)
|
|
153
|
+
yield syncEventSeries2screeningEvents({
|
|
154
|
+
project: { id: params.project.id },
|
|
155
|
+
ids: params.id
|
|
156
|
+
})(repos);
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
// no op
|
|
160
|
+
}
|
|
161
|
+
}
|
|
151
162
|
}
|
|
152
163
|
});
|
|
153
164
|
}
|
|
154
165
|
exports.onEventChanged = onEventChanged;
|
|
166
|
+
function syncEventSeries2screeningEvents(params) {
|
|
167
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const now = new Date();
|
|
169
|
+
for (const eventSeriesId of params.ids) {
|
|
170
|
+
yield repos.event.syncScreeningEventSeries2screeningEvents({
|
|
171
|
+
project: { id: params.project.id },
|
|
172
|
+
superEvent: { id: eventSeriesId },
|
|
173
|
+
startDate: { $gte: now }
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.syncEventSeries2screeningEvents = syncEventSeries2screeningEvents;
|
|
155
179
|
function createAggregateScreeningEventIfNotExist(params) {
|
|
156
180
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
157
181
|
let aggregateTasks = [];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as factory from '../../../factory';
|
|
2
|
+
import { MongoRepository as AccountTitleRepo } from '../../../repo/accountTitle';
|
|
3
|
+
import { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
4
|
+
import { MongoRepository as CategoryCodeRepo } from '../../../repo/categoryCode';
|
|
5
|
+
import { MongoRepository as CreativeWorkRepo } from '../../../repo/creativeWork';
|
|
6
|
+
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
7
|
+
import { MongoRepository as MemberRepo } from '../../../repo/member';
|
|
8
|
+
import { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
9
|
+
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
10
|
+
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
11
|
+
import { MongoRepository as ProductOfferRepo } from '../../../repo/productOffer';
|
|
12
|
+
import { MongoRepository as TaskRepo } from '../../../repo/task';
|
|
13
|
+
export declare function onResourceDeleted(params: factory.task.onResourceUpdated.IData): (repos: {
|
|
14
|
+
accountTitle: AccountTitleRepo;
|
|
15
|
+
action: ActionRepo;
|
|
16
|
+
categoryCode: CategoryCodeRepo;
|
|
17
|
+
creativeWork: CreativeWorkRepo;
|
|
18
|
+
event: EventRepo;
|
|
19
|
+
member: MemberRepo;
|
|
20
|
+
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
21
|
+
place: PlaceRepo;
|
|
22
|
+
product: ProductRepo;
|
|
23
|
+
productOffer: ProductOfferRepo;
|
|
24
|
+
task: TaskRepo;
|
|
25
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,147 @@
|
|
|
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.onResourceDeleted = void 0;
|
|
13
|
+
const factory = require("../../../factory");
|
|
14
|
+
function onResourceDeleted(params) {
|
|
15
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const isDeleted = params.isDeleted === true;
|
|
17
|
+
if (isDeleted) {
|
|
18
|
+
switch (params.typeOf) {
|
|
19
|
+
case factory.placeType.MovieTheater:
|
|
20
|
+
yield deleteResourcesByMovieTheater({
|
|
21
|
+
project: { id: params.project.id },
|
|
22
|
+
ids: params.id
|
|
23
|
+
})(repos);
|
|
24
|
+
break;
|
|
25
|
+
case factory.organizationType.Corporation:
|
|
26
|
+
yield deleteResourcesBySeller({
|
|
27
|
+
project: { id: params.project.id },
|
|
28
|
+
ids: params.id
|
|
29
|
+
})(repos);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
// no op
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.onResourceDeleted = onResourceDeleted;
|
|
38
|
+
function deleteResourcesByMovieTheater(params) {
|
|
39
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (params.ids.length !== 1) {
|
|
41
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
42
|
+
}
|
|
43
|
+
for (const placeId of params.ids) {
|
|
44
|
+
const deleteActionAttributes = {
|
|
45
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
46
|
+
object: { id: placeId, typeOf: factory.placeType.MovieTheater },
|
|
47
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
48
|
+
typeOf: factory.actionType.DeleteAction
|
|
49
|
+
};
|
|
50
|
+
let deleteResult;
|
|
51
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
52
|
+
try {
|
|
53
|
+
// イベント削除
|
|
54
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyBySuperEventLocationId({
|
|
55
|
+
project: { id: params.project.id },
|
|
56
|
+
superEvent: { location: { id: placeId } }
|
|
57
|
+
});
|
|
58
|
+
// 施設コンテンツ削除
|
|
59
|
+
const deleteScreeningEventSeriesResult = yield repos.event.deleteManyByLocationId({
|
|
60
|
+
project: { id: params.project.id },
|
|
61
|
+
location: { id: placeId }
|
|
62
|
+
});
|
|
63
|
+
// ルーム削除
|
|
64
|
+
const deletePlaceResult = yield repos.place.deleteScreeningRoomsByMovieTheaterId({
|
|
65
|
+
project: { id: params.project.id },
|
|
66
|
+
containedInPlace: { id: placeId }
|
|
67
|
+
});
|
|
68
|
+
deleteResult = { deleteScreeningEventResult, deleteScreeningEventSeriesResult, deletePlaceResult };
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
try {
|
|
72
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
73
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
74
|
+
}
|
|
75
|
+
catch (_) {
|
|
76
|
+
// no op
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function deleteResourcesBySeller(params) {
|
|
85
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (params.ids.length !== 1) {
|
|
87
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
88
|
+
}
|
|
89
|
+
for (const sellerId of params.ids) {
|
|
90
|
+
const deleteActionAttributes = {
|
|
91
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
92
|
+
object: { id: sellerId, typeOf: factory.organizationType.Corporation },
|
|
93
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
94
|
+
typeOf: factory.actionType.DeleteAction
|
|
95
|
+
};
|
|
96
|
+
let deleteResult;
|
|
97
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
98
|
+
try {
|
|
99
|
+
// メンバー削除
|
|
100
|
+
const deleteMemberResult = yield repos.member.deleteManyByMemberOfId({
|
|
101
|
+
project: { id: params.project.id },
|
|
102
|
+
member: {
|
|
103
|
+
memberOf: {
|
|
104
|
+
id: { $eq: sellerId },
|
|
105
|
+
typeOf: { $eq: factory.organizationType.Corporation }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
// 提供決済サービス削除
|
|
110
|
+
const deletePaymentServiceProviderResult = yield repos.paymentServiceProvider.deleteManyByProviderId({
|
|
111
|
+
project: { id: params.project.id },
|
|
112
|
+
id: sellerId
|
|
113
|
+
});
|
|
114
|
+
// プロダクトオファー削除
|
|
115
|
+
const deleteProductOfferResult = yield repos.productOffer.deleteManyBySellerId({
|
|
116
|
+
project: { id: params.project.id },
|
|
117
|
+
seller: { id: sellerId }
|
|
118
|
+
});
|
|
119
|
+
// イベント削除
|
|
120
|
+
const deleteEventResult = yield repos.event.deleteManyByOrganizerId({
|
|
121
|
+
project: { id: params.project.id },
|
|
122
|
+
organizer: { id: sellerId }
|
|
123
|
+
});
|
|
124
|
+
// 施設削除
|
|
125
|
+
const deletePlaceResult = yield repos.place.deleteManyByParentOrganizationId({
|
|
126
|
+
project: { id: params.project.id },
|
|
127
|
+
parentOrganization: { id: sellerId }
|
|
128
|
+
});
|
|
129
|
+
deleteResult = {
|
|
130
|
+
deleteMemberResult, deletePaymentServiceProviderResult, deleteProductOfferResult,
|
|
131
|
+
deleteEventResult, deletePlaceResult
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
try {
|
|
136
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
137
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
138
|
+
}
|
|
139
|
+
catch (_) {
|
|
140
|
+
// no op
|
|
141
|
+
}
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
@@ -22,6 +22,7 @@ const place_1 = require("../../repo/place");
|
|
|
22
22
|
const product_1 = require("../../repo/product");
|
|
23
23
|
const productOffer_1 = require("../../repo/productOffer");
|
|
24
24
|
const task_1 = require("../../repo/task");
|
|
25
|
+
const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
|
|
25
26
|
const settings_1 = require("../../settings");
|
|
26
27
|
const informResources = settings_1.settings.onResourceUpdated.informResource;
|
|
27
28
|
/**
|
|
@@ -49,16 +50,7 @@ function onResourceUpdated(params) {
|
|
|
49
50
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
50
51
|
const isDeleted = params.isDeleted === true;
|
|
51
52
|
if (isDeleted) {
|
|
52
|
-
|
|
53
|
-
case factory.organizationType.Corporation:
|
|
54
|
-
yield deleteResourcesBySeller({
|
|
55
|
-
project: { id: params.project.id },
|
|
56
|
-
ids: params.id
|
|
57
|
-
})(repos);
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
// no op
|
|
61
|
-
}
|
|
53
|
+
yield (0, onResourceDeleted_1.onResourceDeleted)(params)(repos);
|
|
62
54
|
}
|
|
63
55
|
else {
|
|
64
56
|
if (params.useInform === true) {
|
|
@@ -419,67 +411,3 @@ function syncMovieTheater(params) {
|
|
|
419
411
|
});
|
|
420
412
|
});
|
|
421
413
|
}
|
|
422
|
-
function deleteResourcesBySeller(params) {
|
|
423
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
424
|
-
if (params.ids.length !== 1) {
|
|
425
|
-
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
426
|
-
}
|
|
427
|
-
for (const sellerId of params.ids) {
|
|
428
|
-
const deleteActionAttributes = {
|
|
429
|
-
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
430
|
-
object: { id: sellerId, typeOf: factory.organizationType.Corporation },
|
|
431
|
-
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
432
|
-
typeOf: factory.actionType.DeleteAction
|
|
433
|
-
};
|
|
434
|
-
let deleteResult;
|
|
435
|
-
const action = yield repos.action.start(deleteActionAttributes);
|
|
436
|
-
try {
|
|
437
|
-
// メンバー削除
|
|
438
|
-
const deleteMemberResult = yield repos.member.deleteManyByMemberOfId({
|
|
439
|
-
project: { id: params.project.id },
|
|
440
|
-
member: {
|
|
441
|
-
memberOf: {
|
|
442
|
-
id: { $eq: sellerId },
|
|
443
|
-
typeOf: { $eq: factory.organizationType.Corporation }
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
// 提供決済サービス削除
|
|
448
|
-
const deletePaymentServiceProviderResult = yield repos.paymentServiceProvider.deleteManyByProviderId({
|
|
449
|
-
project: { id: params.project.id },
|
|
450
|
-
id: sellerId
|
|
451
|
-
});
|
|
452
|
-
// プロダクトオファー削除
|
|
453
|
-
const deleteProductOfferResult = yield repos.productOffer.deleteManyBySellerId({
|
|
454
|
-
project: { id: params.project.id },
|
|
455
|
-
seller: { id: sellerId }
|
|
456
|
-
});
|
|
457
|
-
// イベント削除
|
|
458
|
-
const deleteEventResult = yield repos.event.deleteManyByOrganizerId({
|
|
459
|
-
project: { id: params.project.id },
|
|
460
|
-
organizer: { id: sellerId }
|
|
461
|
-
});
|
|
462
|
-
// 施設削除
|
|
463
|
-
const deletePlaceResult = yield repos.place.deleteManyByParentOrganizationId({
|
|
464
|
-
project: { id: params.project.id },
|
|
465
|
-
parentOrganization: { id: sellerId }
|
|
466
|
-
});
|
|
467
|
-
deleteResult = {
|
|
468
|
-
deleteMemberResult, deletePaymentServiceProviderResult, deleteProductOfferResult,
|
|
469
|
-
deleteEventResult, deletePlaceResult
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
catch (error) {
|
|
473
|
-
try {
|
|
474
|
-
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
475
|
-
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
476
|
-
}
|
|
477
|
-
catch (_) {
|
|
478
|
-
// no op
|
|
479
|
-
}
|
|
480
|
-
throw error;
|
|
481
|
-
}
|
|
482
|
-
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
}
|
package/lib/chevre/service.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* service module
|
|
3
3
|
*/
|
|
4
4
|
import * as AccountTransactionIdentifierFactory from './factory/accountTransactionIdentifier';
|
|
5
|
+
import * as EventFactory from './factory/event';
|
|
5
6
|
import * as OrderFactory from './factory/order';
|
|
6
7
|
import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
|
|
7
8
|
import * as AccountService from './service/account';
|
|
@@ -46,6 +47,7 @@ export import transaction = TransactionService;
|
|
|
46
47
|
export import util = UtilService;
|
|
47
48
|
export declare namespace factory {
|
|
48
49
|
export import accountTransactionIdentifier = AccountTransactionIdentifierFactory;
|
|
50
|
+
export import event = EventFactory;
|
|
49
51
|
export import order = OrderFactory;
|
|
50
52
|
export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
51
53
|
}
|
package/lib/chevre/service.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.factory = exports.util = exports.transaction = exports.task = exports.re
|
|
|
5
5
|
* service module
|
|
6
6
|
*/
|
|
7
7
|
const AccountTransactionIdentifierFactory = require("./factory/accountTransactionIdentifier");
|
|
8
|
+
const EventFactory = require("./factory/event");
|
|
8
9
|
const OrderFactory = require("./factory/order");
|
|
9
10
|
const ReservedAgentIdentifireNamesFactory = require("./factory/reservedAgentIdentifireNames");
|
|
10
11
|
const AccountService = require("./service/account");
|
|
@@ -52,6 +53,8 @@ var factory;
|
|
|
52
53
|
(function (factory) {
|
|
53
54
|
factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
|
|
54
55
|
// tslint:disable-next-line:no-shadowed-variable
|
|
56
|
+
factory.event = EventFactory;
|
|
57
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
55
58
|
factory.order = OrderFactory;
|
|
56
59
|
factory.reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
57
60
|
})(factory = exports.factory || (exports.factory = {}));
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.319.0",
|
|
13
13
|
"@cinerino/sdk": "3.162.0-alpha.6",
|
|
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.5.0-alpha.
|
|
120
|
+
"version": "21.5.0-alpha.2"
|
|
121
121
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 LOCATION_BRANCH_CODE = String(process.env.LOCATION_BRANCH_CODE);
|
|
9
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
10
|
-
|
|
11
|
-
// tslint:disable-next-line:max-func-body-length
|
|
12
|
-
async function main() {
|
|
13
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
-
|
|
15
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
let result = await eventRepo.deleteScreeningEventSeriesByMovieTheaterBranchCode({
|
|
18
|
-
project: { id: project.id },
|
|
19
|
-
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
20
|
-
});
|
|
21
|
-
console.log('deleteScreeningEventSeriesByMovieTheaterBranchCode processed.', result);
|
|
22
|
-
|
|
23
|
-
result = await eventRepo.deleteScreeningEventsByMovieTheaterBranchCode({
|
|
24
|
-
project: { id: project.id },
|
|
25
|
-
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
26
|
-
});
|
|
27
|
-
console.log('deleteScreeningEventsByMovieTheaterBranchCode processed.', result);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
main()
|
|
31
|
-
.then()
|
|
32
|
-
.catch(console.error);
|