@chevre/domain 21.5.0-alpha.1 → 21.5.0-alpha.3
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/repo/event.d.ts +32 -5
- package/lib/chevre/repo/event.js +51 -8
- package/lib/chevre/repo/place.d.ts +1 -1
- package/lib/chevre/repo/place.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +25 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +230 -0
- package/lib/chevre/service/task/onResourceUpdated.js +2 -74
- package/package.json +3 -3
- package/example/src/chevre/cleanEventsByMovieTheater.ts +0 -32
|
@@ -186,30 +186,57 @@ export declare class MongoRepository {
|
|
|
186
186
|
};
|
|
187
187
|
id: string;
|
|
188
188
|
}): Promise<void>;
|
|
189
|
-
|
|
189
|
+
deleteManyByOrganizerId(params: {
|
|
190
|
+
project: {
|
|
191
|
+
id: string;
|
|
192
|
+
};
|
|
193
|
+
organizer: {
|
|
194
|
+
id: string;
|
|
195
|
+
};
|
|
196
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
197
|
+
deleteManyByLocationId(params: {
|
|
190
198
|
project: {
|
|
191
199
|
id: string;
|
|
192
200
|
};
|
|
193
201
|
location: {
|
|
194
|
-
|
|
202
|
+
id: string;
|
|
195
203
|
};
|
|
196
204
|
}): Promise<import("mongodb").DeleteResult>;
|
|
197
|
-
|
|
205
|
+
deleteManyByScreeningRoom(params: {
|
|
198
206
|
project: {
|
|
199
207
|
id: string;
|
|
200
208
|
};
|
|
201
209
|
location: {
|
|
210
|
+
/**
|
|
211
|
+
* ルームコード
|
|
212
|
+
*/
|
|
202
213
|
branchCode: string;
|
|
214
|
+
containedInPlace: {
|
|
215
|
+
/**
|
|
216
|
+
* 施設ID
|
|
217
|
+
*/
|
|
218
|
+
id: string;
|
|
219
|
+
};
|
|
203
220
|
};
|
|
204
221
|
}): Promise<import("mongodb").DeleteResult>;
|
|
205
|
-
|
|
222
|
+
deleteManyBySuperEventId(params: {
|
|
206
223
|
project: {
|
|
207
224
|
id: string;
|
|
208
225
|
};
|
|
209
|
-
|
|
226
|
+
superEvent: {
|
|
210
227
|
id: string;
|
|
211
228
|
};
|
|
212
229
|
}): Promise<import("mongodb").DeleteResult>;
|
|
230
|
+
deleteManyBySuperEventLocationId(params: {
|
|
231
|
+
project: {
|
|
232
|
+
id: string;
|
|
233
|
+
};
|
|
234
|
+
superEvent: {
|
|
235
|
+
location: {
|
|
236
|
+
id: string;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
213
240
|
deleteByProject(params: {
|
|
214
241
|
project: {
|
|
215
242
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -882,31 +882,74 @@ class MongoRepository {
|
|
|
882
882
|
.exec();
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
|
-
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) {
|
|
886
912
|
return __awaiter(this, void 0, void 0, function* () {
|
|
887
913
|
return this.eventModel.deleteMany({
|
|
888
|
-
typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
889
914
|
'project.id': { $eq: params.project.id },
|
|
890
|
-
'
|
|
915
|
+
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
891
916
|
})
|
|
892
917
|
.exec();
|
|
893
918
|
});
|
|
894
919
|
}
|
|
895
|
-
|
|
920
|
+
deleteManyByLocationId(params) {
|
|
896
921
|
return __awaiter(this, void 0, void 0, function* () {
|
|
897
922
|
return this.eventModel.deleteMany({
|
|
898
|
-
typeOf: { $eq: factory.eventType.ScreeningEventSeries },
|
|
899
923
|
'project.id': { $eq: params.project.id },
|
|
900
|
-
'location.
|
|
924
|
+
'location.id': { $exists: true, $eq: params.location.id }
|
|
901
925
|
})
|
|
902
926
|
.exec();
|
|
903
927
|
});
|
|
904
928
|
}
|
|
905
|
-
|
|
929
|
+
deleteManyByScreeningRoom(params) {
|
|
906
930
|
return __awaiter(this, void 0, void 0, function* () {
|
|
907
931
|
return this.eventModel.deleteMany({
|
|
908
932
|
'project.id': { $eq: params.project.id },
|
|
909
|
-
'
|
|
933
|
+
'location.branchCode': { $exists: true, $eq: params.location.branchCode },
|
|
934
|
+
'superEvent.location.id': { $exists: true, $eq: params.location.containedInPlace.id }
|
|
935
|
+
})
|
|
936
|
+
.exec();
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
deleteManyBySuperEventId(params) {
|
|
940
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
941
|
+
return this.eventModel.deleteMany({
|
|
942
|
+
'project.id': { $eq: params.project.id },
|
|
943
|
+
'superEvent.id': { $exists: true, $eq: params.superEvent.id }
|
|
944
|
+
})
|
|
945
|
+
.exec();
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
deleteManyBySuperEventLocationId(params) {
|
|
949
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
950
|
+
return this.eventModel.deleteMany({
|
|
951
|
+
'project.id': { $eq: params.project.id },
|
|
952
|
+
'superEvent.location.id': { $exists: true, $eq: params.superEvent.location.id }
|
|
910
953
|
})
|
|
911
954
|
.exec();
|
|
912
955
|
});
|
|
@@ -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 }
|
|
@@ -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,230 @@
|
|
|
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.eventType.ScreeningEventSeries:
|
|
20
|
+
yield deleteResourcesByScreeningEventSeries({
|
|
21
|
+
project: { id: params.project.id },
|
|
22
|
+
ids: params.id
|
|
23
|
+
})(repos);
|
|
24
|
+
break;
|
|
25
|
+
case factory.placeType.ScreeningRoom:
|
|
26
|
+
yield deleteResourcesByScreeningRoom({
|
|
27
|
+
project: { id: params.project.id },
|
|
28
|
+
branchCode: params.branchCode,
|
|
29
|
+
containedInPlace: { id: params.containedInPlace.id }
|
|
30
|
+
})(repos);
|
|
31
|
+
break;
|
|
32
|
+
case factory.placeType.MovieTheater:
|
|
33
|
+
yield deleteResourcesByMovieTheater({
|
|
34
|
+
project: { id: params.project.id },
|
|
35
|
+
ids: params.id
|
|
36
|
+
})(repos);
|
|
37
|
+
break;
|
|
38
|
+
case factory.organizationType.Corporation:
|
|
39
|
+
yield deleteResourcesBySeller({
|
|
40
|
+
project: { id: params.project.id },
|
|
41
|
+
ids: params.id
|
|
42
|
+
})(repos);
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
// no op
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.onResourceDeleted = onResourceDeleted;
|
|
51
|
+
function deleteResourcesByScreeningEventSeries(params) {
|
|
52
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (params.ids.length !== 1) {
|
|
54
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
55
|
+
}
|
|
56
|
+
for (const eventId of params.ids) {
|
|
57
|
+
const deleteActionAttributes = {
|
|
58
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
59
|
+
object: { id: eventId, typeOf: factory.eventType.ScreeningEventSeries },
|
|
60
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
61
|
+
typeOf: factory.actionType.DeleteAction
|
|
62
|
+
};
|
|
63
|
+
let deleteResult;
|
|
64
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
65
|
+
try {
|
|
66
|
+
// イベント削除
|
|
67
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyBySuperEventId({
|
|
68
|
+
project: { id: params.project.id },
|
|
69
|
+
superEvent: { id: eventId }
|
|
70
|
+
});
|
|
71
|
+
deleteResult = { deleteScreeningEventResult };
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
try {
|
|
75
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
76
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
77
|
+
}
|
|
78
|
+
catch (_) {
|
|
79
|
+
// no op
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function deleteResourcesByScreeningRoom(params) {
|
|
88
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const deleteActionAttributes = {
|
|
90
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
91
|
+
object: { branchCode: params.branchCode, containedInPlace: params.containedInPlace, typeOf: factory.placeType.ScreeningRoom },
|
|
92
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
93
|
+
typeOf: factory.actionType.DeleteAction
|
|
94
|
+
};
|
|
95
|
+
let deleteResult;
|
|
96
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
97
|
+
try {
|
|
98
|
+
// イベント削除
|
|
99
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyByScreeningRoom({
|
|
100
|
+
project: { id: params.project.id },
|
|
101
|
+
location: {
|
|
102
|
+
branchCode: params.branchCode,
|
|
103
|
+
containedInPlace: { id: params.containedInPlace.id }
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
deleteResult = { deleteScreeningEventResult };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
try {
|
|
110
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
111
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
112
|
+
}
|
|
113
|
+
catch (_) {
|
|
114
|
+
// no op
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function deleteResourcesByMovieTheater(params) {
|
|
122
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
if (params.ids.length !== 1) {
|
|
124
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
125
|
+
}
|
|
126
|
+
for (const placeId of params.ids) {
|
|
127
|
+
const deleteActionAttributes = {
|
|
128
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
129
|
+
object: { id: placeId, typeOf: factory.placeType.MovieTheater },
|
|
130
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
131
|
+
typeOf: factory.actionType.DeleteAction
|
|
132
|
+
};
|
|
133
|
+
let deleteResult;
|
|
134
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
135
|
+
try {
|
|
136
|
+
// イベント削除
|
|
137
|
+
const deleteScreeningEventResult = yield repos.event.deleteManyBySuperEventLocationId({
|
|
138
|
+
project: { id: params.project.id },
|
|
139
|
+
superEvent: { location: { id: placeId } }
|
|
140
|
+
});
|
|
141
|
+
// 施設コンテンツ削除
|
|
142
|
+
const deleteScreeningEventSeriesResult = yield repos.event.deleteManyByLocationId({
|
|
143
|
+
project: { id: params.project.id },
|
|
144
|
+
location: { id: placeId }
|
|
145
|
+
});
|
|
146
|
+
// ルーム削除
|
|
147
|
+
const deletePlaceResult = yield repos.place.deleteScreeningRoomsByMovieTheaterId({
|
|
148
|
+
project: { id: params.project.id },
|
|
149
|
+
containedInPlace: { id: placeId }
|
|
150
|
+
});
|
|
151
|
+
deleteResult = { deleteScreeningEventResult, deleteScreeningEventSeriesResult, deletePlaceResult };
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
try {
|
|
155
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
156
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
157
|
+
}
|
|
158
|
+
catch (_) {
|
|
159
|
+
// no op
|
|
160
|
+
}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function deleteResourcesBySeller(params) {
|
|
168
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
if (params.ids.length !== 1) {
|
|
170
|
+
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
171
|
+
}
|
|
172
|
+
for (const sellerId of params.ids) {
|
|
173
|
+
const deleteActionAttributes = {
|
|
174
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
175
|
+
object: { id: sellerId, typeOf: factory.organizationType.Corporation },
|
|
176
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
177
|
+
typeOf: factory.actionType.DeleteAction
|
|
178
|
+
};
|
|
179
|
+
let deleteResult;
|
|
180
|
+
const action = yield repos.action.start(deleteActionAttributes);
|
|
181
|
+
try {
|
|
182
|
+
// メンバー削除
|
|
183
|
+
const deleteMemberResult = yield repos.member.deleteManyByMemberOfId({
|
|
184
|
+
project: { id: params.project.id },
|
|
185
|
+
member: {
|
|
186
|
+
memberOf: {
|
|
187
|
+
id: { $eq: sellerId },
|
|
188
|
+
typeOf: { $eq: factory.organizationType.Corporation }
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// 提供決済サービス削除
|
|
193
|
+
const deletePaymentServiceProviderResult = yield repos.paymentServiceProvider.deleteManyByProviderId({
|
|
194
|
+
project: { id: params.project.id },
|
|
195
|
+
id: sellerId
|
|
196
|
+
});
|
|
197
|
+
// プロダクトオファー削除
|
|
198
|
+
const deleteProductOfferResult = yield repos.productOffer.deleteManyBySellerId({
|
|
199
|
+
project: { id: params.project.id },
|
|
200
|
+
seller: { id: sellerId }
|
|
201
|
+
});
|
|
202
|
+
// イベント削除
|
|
203
|
+
const deleteEventResult = yield repos.event.deleteManyByOrganizerId({
|
|
204
|
+
project: { id: params.project.id },
|
|
205
|
+
organizer: { id: sellerId }
|
|
206
|
+
});
|
|
207
|
+
// 施設削除
|
|
208
|
+
const deletePlaceResult = yield repos.place.deleteManyByParentOrganizationId({
|
|
209
|
+
project: { id: params.project.id },
|
|
210
|
+
parentOrganization: { id: sellerId }
|
|
211
|
+
});
|
|
212
|
+
deleteResult = {
|
|
213
|
+
deleteMemberResult, deletePaymentServiceProviderResult, deleteProductOfferResult,
|
|
214
|
+
deleteEventResult, deletePlaceResult
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
try {
|
|
219
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
220
|
+
yield repos.action.giveUp({ typeOf: deleteActionAttributes.typeOf, id: action.id, error: actionError });
|
|
221
|
+
}
|
|
222
|
+
catch (_) {
|
|
223
|
+
// no op
|
|
224
|
+
}
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
yield repos.action.complete({ typeOf: deleteActionAttributes.typeOf, id: action.id, result: deleteResult });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
@@ -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/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.162.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.320.0",
|
|
13
|
+
"@cinerino/sdk": "3.162.0-alpha.7",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.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.3"
|
|
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);
|