@chevre/domain 21.4.0 → 21.5.0-alpha.1

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.
@@ -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,6 +163,23 @@ 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;
@@ -185,6 +202,14 @@ export declare class MongoRepository {
185
202
  branchCode: string;
186
203
  };
187
204
  }): Promise<import("mongodb").DeleteResult>;
205
+ deleteManyByOrganizerId(params: {
206
+ project: {
207
+ id: string;
208
+ };
209
+ organizer: {
210
+ id: string;
211
+ };
212
+ }): Promise<import("mongodb").DeleteResult>;
188
213
  deleteByProject(params: {
189
214
  project: {
190
215
  id: string;
@@ -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({
@@ -871,6 +902,15 @@ class MongoRepository {
871
902
  .exec();
872
903
  });
873
904
  }
905
+ deleteManyByOrganizerId(params) {
906
+ return __awaiter(this, void 0, void 0, function* () {
907
+ return this.eventModel.deleteMany({
908
+ 'project.id': { $eq: params.project.id },
909
+ 'organizer.id': { $exists: true, $eq: params.organizer.id }
910
+ })
911
+ .exec();
912
+ });
913
+ }
874
914
  deleteByProject(params) {
875
915
  return __awaiter(this, void 0, void 0, function* () {
876
916
  yield this.eventModel.deleteMany({
@@ -115,6 +115,21 @@ export declare class MongoRepository {
115
115
  };
116
116
  };
117
117
  }): Promise<void>;
118
+ deleteManyByMemberOfId(params: {
119
+ project: {
120
+ id: string;
121
+ };
122
+ member: {
123
+ memberOf: {
124
+ id: {
125
+ $eq: string;
126
+ };
127
+ typeOf: {
128
+ $eq: factory.organizationType.Corporation | factory.organizationType.Project;
129
+ };
130
+ };
131
+ };
132
+ }): Promise<import("mongodb").DeleteResult>;
118
133
  /**
119
134
  * メンバーの権限を持つプロジェクト検索
120
135
  */
@@ -223,6 +223,16 @@ class MongoRepository {
223
223
  }
224
224
  });
225
225
  }
226
+ deleteManyByMemberOfId(params) {
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ return this.memberModel.deleteMany({
229
+ 'project.id': { $eq: params.project.id },
230
+ 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq },
231
+ 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq }
232
+ })
233
+ .exec();
234
+ });
235
+ }
226
236
  /**
227
237
  * メンバーの権限を持つプロジェクト検索
228
238
  */
@@ -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>>;
@@ -62,4 +62,9 @@ export declare class MongoRepository {
62
62
  }): Promise<{
63
63
  id: string;
64
64
  }>;
65
+ deleteManyByProviderId(params: Pick<factory.service.paymentService.IProvider, 'id'> & {
66
+ project: {
67
+ id: string;
68
+ };
69
+ }): Promise<import("mongodb").UpdateResult>;
65
70
  }
@@ -152,5 +152,16 @@ class MongoRepository {
152
152
  return doc.toObject();
153
153
  });
154
154
  }
155
+ deleteManyByProviderId(params) {
156
+ return __awaiter(this, void 0, void 0, function* () {
157
+ return this.productModel.updateMany({
158
+ 'project.id': { $eq: params.project.id },
159
+ 'provider.id': { $eq: params.id }
160
+ }, {
161
+ $pull: { provider: { id: params.id } }
162
+ })
163
+ .exec();
164
+ });
165
+ }
155
166
  }
156
167
  exports.MongoRepository = MongoRepository;
@@ -302,6 +302,17 @@ export declare class MongoRepository {
302
302
  }): Promise<{
303
303
  id: string;
304
304
  } | undefined>;
305
+ deleteManyByParentOrganizationId(params: {
306
+ project: {
307
+ id: string;
308
+ };
309
+ parentOrganization: {
310
+ /**
311
+ * 販売者ID
312
+ */
313
+ id: string;
314
+ };
315
+ }): Promise<import("mongodb").DeleteResult>;
305
316
  deleteByProject(params: {
306
317
  project: {
307
318
  id: string;
@@ -1279,6 +1279,15 @@ class MongoRepository {
1279
1279
  });
1280
1280
  });
1281
1281
  }
1282
+ deleteManyByParentOrganizationId(params) {
1283
+ return __awaiter(this, void 0, void 0, function* () {
1284
+ return this.placeModel.deleteMany({
1285
+ 'project.id': { $eq: params.project.id },
1286
+ 'parentOrganization.id': { $exists: true, $eq: params.parentOrganization.id }
1287
+ })
1288
+ .exec();
1289
+ });
1290
+ }
1282
1291
  deleteByProject(params) {
1283
1292
  return __awaiter(this, void 0, void 0, function* () {
1284
1293
  yield this.placeModel.deleteMany({
@@ -69,4 +69,9 @@ export declare class MongoRepository {
69
69
  }): Promise<{
70
70
  id: string;
71
71
  }>;
72
+ deleteManyBySellerId(params: Pick<factory.product.IOffer, 'seller'> & {
73
+ project: {
74
+ id: string;
75
+ };
76
+ }): Promise<import("mongodb").UpdateResult>;
72
77
  }
@@ -181,5 +181,21 @@ class MongoRepository {
181
181
  return doc.toObject();
182
182
  });
183
183
  }
184
+ deleteManyBySellerId(params) {
185
+ var _a;
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
188
+ if (typeof sellerId !== 'string' || sellerId.length === 0) {
189
+ throw new factory.errors.ArgumentNull('seller.id');
190
+ }
191
+ return this.productModel.updateMany({
192
+ 'project.id': { $eq: params.project.id },
193
+ 'offers.seller.id': { $exists: true, $eq: sellerId }
194
+ }, {
195
+ $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
196
+ })
197
+ .exec();
198
+ });
199
+ }
184
200
  }
185
201
  exports.MongoRepository = MongoRepository;
@@ -50,18 +50,18 @@ export declare function searchEventSeatOffersWithPaging(params: {
50
50
  /**
51
51
  * イベント変更時処理
52
52
  */
53
- export declare function onEventChanged(params: {
54
- id: string[];
55
- typeOf: factory.eventType;
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
- isNew: boolean;
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 = [];
@@ -12,10 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
13
  const factory = require("../../factory");
14
14
  const accountTitle_1 = require("../../repo/accountTitle");
15
+ const action_1 = require("../../repo/action");
15
16
  const categoryCode_1 = require("../../repo/categoryCode");
16
17
  const creativeWork_1 = require("../../repo/creativeWork");
18
+ const event_1 = require("../../repo/event");
19
+ const member_1 = require("../../repo/member");
20
+ const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
17
21
  const place_1 = require("../../repo/place");
18
22
  const product_1 = require("../../repo/product");
23
+ const productOffer_1 = require("../../repo/productOffer");
19
24
  const task_1 = require("../../repo/task");
20
25
  const settings_1 = require("../../settings");
21
26
  const informResources = settings_1.settings.onResourceUpdated.informResource;
@@ -26,10 +31,15 @@ function call(data) {
26
31
  return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
27
32
  yield onResourceUpdated(data)({
28
33
  accountTitle: new accountTitle_1.MongoRepository(connectionSettings.connection),
34
+ action: new action_1.MongoRepository(connectionSettings.connection),
29
35
  categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
30
36
  creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
37
+ event: new event_1.MongoRepository(connectionSettings.connection),
38
+ member: new member_1.MongoRepository(connectionSettings.connection),
39
+ paymentServiceProvider: new paymentServiceProvider_1.MongoRepository(connectionSettings.connection),
31
40
  place: new place_1.MongoRepository(connectionSettings.connection),
32
41
  product: new product_1.MongoRepository(connectionSettings.connection),
42
+ productOffer: new productOffer_1.MongoRepository(connectionSettings.connection),
33
43
  task: new task_1.MongoRepository(connectionSettings.connection)
34
44
  });
35
45
  });
@@ -37,38 +47,65 @@ function call(data) {
37
47
  exports.call = call;
38
48
  function onResourceUpdated(params) {
39
49
  return (repos) => __awaiter(this, void 0, void 0, function* () {
40
- if (params.useInform === true) {
50
+ const isDeleted = params.isDeleted === true;
51
+ if (isDeleted) {
41
52
  switch (params.typeOf) {
42
- case factory.creativeWorkType.Movie:
43
- yield createInformMovieTasks({
53
+ case factory.organizationType.Corporation:
54
+ yield deleteResourcesBySeller({
44
55
  project: { id: params.project.id },
45
- ids: params.id,
46
- typeOf: params.typeOf
47
- })(repos);
48
- break;
49
- case factory.product.ProductType.EventService:
50
- yield createInformProductTasks({
51
- project: { id: params.project.id },
52
- ids: params.id,
53
- typeOf: params.typeOf
54
- })(repos);
55
- break;
56
- case 'CategoryCode':
57
- yield createInformCategoryCodeTasks({
58
- project: { id: params.project.id },
59
- ids: params.id,
60
- typeOf: params.typeOf
56
+ ids: params.id
61
57
  })(repos);
62
58
  break;
59
+ default:
60
+ // no op
61
+ }
62
+ }
63
+ else {
64
+ if (params.useInform === true) {
65
+ switch (params.typeOf) {
66
+ case factory.creativeWorkType.Movie:
67
+ yield createInformMovieTasks({
68
+ project: { id: params.project.id },
69
+ ids: params.id,
70
+ typeOf: params.typeOf
71
+ })(repos);
72
+ break;
73
+ case factory.product.ProductType.EventService:
74
+ yield createInformProductTasks({
75
+ project: { id: params.project.id },
76
+ ids: params.id,
77
+ typeOf: params.typeOf
78
+ })(repos);
79
+ break;
80
+ case 'CategoryCode':
81
+ yield createInformCategoryCodeTasks({
82
+ project: { id: params.project.id },
83
+ ids: params.id,
84
+ typeOf: params.typeOf
85
+ })(repos);
86
+ break;
87
+ case factory.placeType.MovieTheater:
88
+ yield createInformMovieTheaterTasks({
89
+ project: { id: params.project.id },
90
+ ids: params.id,
91
+ typeOf: params.typeOf
92
+ })(repos);
93
+ break;
94
+ case 'AccountTitle':
95
+ yield createInformAccountTitleTasks({
96
+ project: { id: params.project.id },
97
+ ids: params.id,
98
+ typeOf: params.typeOf
99
+ })(repos);
100
+ break;
101
+ default:
102
+ // no op
103
+ }
104
+ }
105
+ switch (params.typeOf) {
106
+ // 施設名称を同期する(2023-06-29~)
63
107
  case factory.placeType.MovieTheater:
64
- yield createInformMovieTheaterTasks({
65
- project: { id: params.project.id },
66
- ids: params.id,
67
- typeOf: params.typeOf
68
- })(repos);
69
- break;
70
- case 'AccountTitle':
71
- yield createInformAccountTitleTasks({
108
+ yield syncMovieTheater({
72
109
  project: { id: params.project.id },
73
110
  ids: params.id,
74
111
  typeOf: params.typeOf
@@ -78,18 +115,6 @@ function onResourceUpdated(params) {
78
115
  // no op
79
116
  }
80
117
  }
81
- switch (params.typeOf) {
82
- // 施設名称を同期する(2023-06-29~)
83
- case factory.placeType.MovieTheater:
84
- yield syncMovieTheater({
85
- project: { id: params.project.id },
86
- ids: params.id,
87
- typeOf: params.typeOf
88
- })(repos);
89
- break;
90
- default:
91
- // no op
92
- }
93
118
  });
94
119
  }
95
120
  function createInformMovieTasks(params) {
@@ -394,3 +419,67 @@ function syncMovieTheater(params) {
394
419
  });
395
420
  });
396
421
  }
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
+ }
@@ -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
  }
@@ -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.316.0",
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.4.0"
120
+ "version": "21.5.0-alpha.1"
121
121
  }