@chevre/domain 21.4.0 → 21.5.0-alpha.0
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 +8 -0
- package/lib/chevre/repo/event.js +9 -0
- package/lib/chevre/repo/member.d.ts +15 -0
- package/lib/chevre/repo/member.js +10 -0
- package/lib/chevre/repo/paymentServiceProvider.d.ts +5 -0
- package/lib/chevre/repo/paymentServiceProvider.js +11 -0
- package/lib/chevre/repo/place.d.ts +11 -0
- package/lib/chevre/repo/place.js +9 -0
- package/lib/chevre/repo/productOffer.d.ts +5 -0
- package/lib/chevre/repo/productOffer.js +16 -0
- package/lib/chevre/service/task/onResourceUpdated.js +128 -39
- package/package.json +2 -2
|
@@ -185,6 +185,14 @@ export declare class MongoRepository {
|
|
|
185
185
|
branchCode: string;
|
|
186
186
|
};
|
|
187
187
|
}): Promise<import("mongodb").DeleteResult>;
|
|
188
|
+
deleteManyByOrganizerId(params: {
|
|
189
|
+
project: {
|
|
190
|
+
id: string;
|
|
191
|
+
};
|
|
192
|
+
organizer: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
188
196
|
deleteByProject(params: {
|
|
189
197
|
project: {
|
|
190
198
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -871,6 +871,15 @@ class MongoRepository {
|
|
|
871
871
|
.exec();
|
|
872
872
|
});
|
|
873
873
|
}
|
|
874
|
+
deleteManyByOrganizerId(params) {
|
|
875
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
876
|
+
return this.eventModel.deleteMany({
|
|
877
|
+
'project.id': { $eq: params.project.id },
|
|
878
|
+
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
879
|
+
})
|
|
880
|
+
.exec();
|
|
881
|
+
});
|
|
882
|
+
}
|
|
874
883
|
deleteByProject(params) {
|
|
875
884
|
return __awaiter(this, void 0, void 0, function* () {
|
|
876
885
|
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
|
*/
|
|
@@ -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;
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -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({
|
|
@@ -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;
|
|
@@ -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
|
-
|
|
50
|
+
const isDeleted = params.isDeleted === true;
|
|
51
|
+
if (isDeleted) {
|
|
41
52
|
switch (params.typeOf) {
|
|
42
|
-
case factory.
|
|
43
|
-
yield
|
|
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
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.318.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.
|
|
120
|
+
"version": "21.5.0-alpha.0"
|
|
121
121
|
}
|