@chevre/domain 21.2.0-alpha.108 → 21.2.0-alpha.109
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/example/src/chevre/aggregation/aggregateSystem.ts +34 -40
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +34 -23
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
- package/lib/chevre/service/task/onResourceUpdated.d.ts +0 -23
- package/lib/chevre/service/task/onResourceUpdated.js +57 -6
- package/package.json +2 -2
|
@@ -4,6 +4,7 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
import { chevre } from '../../../../lib/index';
|
|
5
5
|
|
|
6
6
|
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
7
|
+
const AGGREGATE_DURATION_UNIT = <'days' | 'hours'>String(process.env.AGGREGATE_DURATION_UNIT);
|
|
7
8
|
const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
|
|
8
9
|
const AGGREGATE_CLIENT_IDS = (typeof process.env.AGGREGATE_CLIENT_IDS === 'string') ? process.env.AGGREGATE_CLIENT_IDS.split(' ') : [];
|
|
9
10
|
const ONE_DAY_IN_HOURS = 24;
|
|
@@ -22,24 +23,19 @@ async function main() {
|
|
|
22
23
|
|
|
23
24
|
let result: { aggregationCount: number; aggregateDuration: string };
|
|
24
25
|
|
|
25
|
-
result = await chevre.service.aggregation.system.
|
|
26
|
-
aggregateDurationUnit:
|
|
27
|
-
|
|
28
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
29
|
-
// aggregationCount: AGGREGATE_DAYS,
|
|
26
|
+
result = await chevre.service.aggregation.system.aggregateReserveAction({
|
|
27
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
28
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
30
29
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
31
30
|
})({
|
|
32
31
|
agregation: aggregationRepo,
|
|
33
32
|
action: actionRepo
|
|
34
33
|
});
|
|
35
|
-
console.log('
|
|
36
|
-
return;
|
|
34
|
+
console.log('aggregateReserveAction processed.', result);
|
|
37
35
|
|
|
38
|
-
result = await chevre.service.aggregation.system.
|
|
39
|
-
aggregateDurationUnit:
|
|
40
|
-
|
|
41
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
42
|
-
// aggregationCount: AGGREGATE_DAYS,
|
|
36
|
+
result = await chevre.service.aggregation.system.aggregateOrderAction({
|
|
37
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
38
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
43
39
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
44
40
|
})({
|
|
45
41
|
agregation: aggregationRepo,
|
|
@@ -47,21 +43,19 @@ async function main() {
|
|
|
47
43
|
});
|
|
48
44
|
console.log('aggregateReserveAction processed.', result);
|
|
49
45
|
|
|
50
|
-
result = await chevre.service.aggregation.system.
|
|
51
|
-
aggregateDurationUnit:
|
|
52
|
-
|
|
53
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
54
|
-
// aggregationCount: AGGREGATE_DAYS,
|
|
46
|
+
result = await chevre.service.aggregation.system.aggregateCancelReservationAction({
|
|
47
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
48
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
55
49
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
56
50
|
})({
|
|
57
51
|
agregation: aggregationRepo,
|
|
58
52
|
action: actionRepo
|
|
59
53
|
});
|
|
60
|
-
console.log('
|
|
54
|
+
console.log('aggregateCancelReservationAction processed.', result);
|
|
61
55
|
|
|
62
56
|
result = await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
63
|
-
aggregateDurationUnit:
|
|
64
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
57
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
58
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
65
59
|
excludedProjectId: EXCLUDED_PROJECT_ID,
|
|
66
60
|
clientIds: AGGREGATE_CLIENT_IDS
|
|
67
61
|
})({
|
|
@@ -72,8 +66,8 @@ async function main() {
|
|
|
72
66
|
// return;
|
|
73
67
|
|
|
74
68
|
result = await chevre.service.aggregation.system.aggregateTask({
|
|
75
|
-
aggregateDurationUnit:
|
|
76
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
69
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
70
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
77
71
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
78
72
|
})({
|
|
79
73
|
agregation: aggregationRepo,
|
|
@@ -82,8 +76,8 @@ async function main() {
|
|
|
82
76
|
console.log('aggregateTask processed.', result);
|
|
83
77
|
|
|
84
78
|
result = await chevre.service.aggregation.system.aggregatePayMovieTicketAction({
|
|
85
|
-
aggregateDurationUnit:
|
|
86
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
79
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
80
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
87
81
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
88
82
|
})({
|
|
89
83
|
agregation: aggregationRepo,
|
|
@@ -92,8 +86,8 @@ async function main() {
|
|
|
92
86
|
console.log('aggregatePayMovieTicketAction processed.', result);
|
|
93
87
|
|
|
94
88
|
result = await chevre.service.aggregation.system.aggregatePayTransaction({
|
|
95
|
-
aggregateDurationUnit:
|
|
96
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
89
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
90
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
97
91
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
98
92
|
})({
|
|
99
93
|
agregation: aggregationRepo,
|
|
@@ -102,8 +96,8 @@ async function main() {
|
|
|
102
96
|
console.log('aggregatePayTransaction processed.', result);
|
|
103
97
|
|
|
104
98
|
result = await chevre.service.aggregation.system.aggregateEvent({
|
|
105
|
-
aggregateDurationUnit:
|
|
106
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
99
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
100
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
107
101
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
108
102
|
})({
|
|
109
103
|
agregation: aggregationRepo,
|
|
@@ -112,8 +106,8 @@ async function main() {
|
|
|
112
106
|
console.log('aggregateEvent processed.', result);
|
|
113
107
|
|
|
114
108
|
result = await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
115
|
-
aggregateDurationUnit:
|
|
116
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
109
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
110
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
117
111
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
118
112
|
})({
|
|
119
113
|
agregation: aggregationRepo,
|
|
@@ -122,8 +116,8 @@ async function main() {
|
|
|
122
116
|
console.log('aggregateReserveTransaction processed.', result);
|
|
123
117
|
|
|
124
118
|
result = await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
|
|
125
|
-
aggregateDurationUnit:
|
|
126
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
119
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
120
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
127
121
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
128
122
|
})({
|
|
129
123
|
agregation: aggregationRepo,
|
|
@@ -132,8 +126,8 @@ async function main() {
|
|
|
132
126
|
console.log('aggregateAuthorizeOrderAction processed.', result);
|
|
133
127
|
|
|
134
128
|
result = await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
|
|
135
|
-
aggregateDurationUnit:
|
|
136
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
129
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
130
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
137
131
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
138
132
|
})({
|
|
139
133
|
agregation: aggregationRepo,
|
|
@@ -142,8 +136,8 @@ async function main() {
|
|
|
142
136
|
console.log('aggregateAuthorizeEventServiceOfferAction processed.', result);
|
|
143
137
|
|
|
144
138
|
result = await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
|
|
145
|
-
aggregateDurationUnit:
|
|
146
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
139
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
140
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
147
141
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
148
142
|
})({
|
|
149
143
|
agregation: aggregationRepo,
|
|
@@ -152,8 +146,8 @@ async function main() {
|
|
|
152
146
|
console.log('aggregateAuthorizePaymentAction processed.', result);
|
|
153
147
|
|
|
154
148
|
result = await chevre.service.aggregation.system.aggregateUseAction({
|
|
155
|
-
aggregateDurationUnit:
|
|
156
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
149
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
150
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
157
151
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
158
152
|
})({
|
|
159
153
|
agregation: aggregationRepo,
|
|
@@ -162,8 +156,8 @@ async function main() {
|
|
|
162
156
|
console.log('aggregateUseAction processed.', result);
|
|
163
157
|
|
|
164
158
|
result = await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
|
|
165
|
-
aggregateDurationUnit:
|
|
166
|
-
aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
|
|
159
|
+
aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
|
|
160
|
+
aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
|
|
167
161
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
168
162
|
})({
|
|
169
163
|
agregation: aggregationRepo,
|
|
@@ -35,7 +35,7 @@ export declare class MongoRepository {
|
|
|
35
35
|
/**
|
|
36
36
|
* 検索
|
|
37
37
|
*/
|
|
38
|
-
search(params: factory.categoryCode.ISearchConditions): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
38
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
39
39
|
findById(params: {
|
|
40
40
|
id: string;
|
|
41
41
|
}): Promise<factory.categoryCode.ICategoryCode>;
|
|
@@ -33,7 +33,7 @@ class MongoRepository {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
37
37
|
// MongoDB検索条件
|
|
38
38
|
const andConditions = [];
|
|
39
39
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -49,16 +49,13 @@ class MongoRepository {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
52
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
53
|
+
if (typeof idEq === 'string') {
|
|
54
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
55
|
+
}
|
|
56
|
+
const idIn = (_b = params.id) === null || _b === void 0 ? void 0 : _b.$in;
|
|
57
|
+
if (Array.isArray(idIn)) {
|
|
58
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
62
59
|
}
|
|
63
60
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
64
61
|
/* istanbul ignore else */
|
|
@@ -82,7 +79,7 @@ class MongoRepository {
|
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
const codeValueEq = (
|
|
82
|
+
const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
86
83
|
if (typeof codeValueEq === 'string') {
|
|
87
84
|
andConditions.push({
|
|
88
85
|
codeValue: {
|
|
@@ -91,7 +88,7 @@ class MongoRepository {
|
|
|
91
88
|
}
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
|
-
const codeValueIn = (
|
|
91
|
+
const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
|
|
95
92
|
if (Array.isArray(codeValueIn)) {
|
|
96
93
|
andConditions.push({
|
|
97
94
|
codeValue: {
|
|
@@ -114,7 +111,7 @@ class MongoRepository {
|
|
|
114
111
|
}
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
|
-
const inCodeSetIdentifierIn = (
|
|
114
|
+
const inCodeSetIdentifierIn = (_f = (_e = params.inCodeSet) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$in;
|
|
118
115
|
if (Array.isArray(inCodeSetIdentifierIn)) {
|
|
119
116
|
andConditions.push({
|
|
120
117
|
'inCodeSet.identifier': {
|
|
@@ -123,7 +120,7 @@ class MongoRepository {
|
|
|
123
120
|
}
|
|
124
121
|
});
|
|
125
122
|
}
|
|
126
|
-
const paymentMethodTypeOfEq = (
|
|
123
|
+
const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
127
124
|
if (typeof paymentMethodTypeOfEq === 'string') {
|
|
128
125
|
andConditions.push({
|
|
129
126
|
'paymentMethod.typeOf': {
|
|
@@ -132,7 +129,7 @@ class MongoRepository {
|
|
|
132
129
|
}
|
|
133
130
|
});
|
|
134
131
|
}
|
|
135
|
-
const paymentMethodTypeOfIn = (
|
|
132
|
+
const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
|
|
136
133
|
if (Array.isArray(paymentMethodTypeOfIn)) {
|
|
137
134
|
andConditions.push({
|
|
138
135
|
'paymentMethod.typeOf': {
|
|
@@ -141,7 +138,7 @@ class MongoRepository {
|
|
|
141
138
|
}
|
|
142
139
|
});
|
|
143
140
|
}
|
|
144
|
-
const additionalPropertyElemMatch = (
|
|
141
|
+
const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
145
142
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
146
143
|
andConditions.push({
|
|
147
144
|
additionalProperty: {
|
|
@@ -163,14 +160,28 @@ class MongoRepository {
|
|
|
163
160
|
/**
|
|
164
161
|
* 検索
|
|
165
162
|
*/
|
|
166
|
-
search(params) {
|
|
163
|
+
search(params, inclusion, exclusion) {
|
|
167
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
165
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
166
|
+
let projection = {};
|
|
167
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
168
|
+
inclusion.forEach((field) => {
|
|
169
|
+
projection[field] = 1;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
projection = {
|
|
174
|
+
__v: 0,
|
|
175
|
+
createdAt: 0,
|
|
176
|
+
updatedAt: 0
|
|
177
|
+
};
|
|
178
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
179
|
+
exclusion.forEach((field) => {
|
|
180
|
+
projection[field] = 0;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
174
185
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
175
186
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
176
187
|
query.limit(params.limit)
|
|
@@ -214,7 +214,7 @@ function saveScreeningEventSeries(params) {
|
|
|
214
214
|
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
215
215
|
project: { id: { $eq: params.project.id } },
|
|
216
216
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
217
|
-
});
|
|
217
|
+
}, [], []);
|
|
218
218
|
const screeningEventSerieses = filmsFromCOA.map((filmFromCOA) => {
|
|
219
219
|
return createScreeningEventSeriesFromCOA({
|
|
220
220
|
project: project,
|
|
@@ -20,7 +20,7 @@ function importFromCOA(params) {
|
|
|
20
20
|
page: 1,
|
|
21
21
|
project: { id: { $eq: params.project.id } },
|
|
22
22
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.CurrencyType } }
|
|
23
|
-
});
|
|
23
|
+
}, [], []);
|
|
24
24
|
const defaultCurrencyType = currencyTypes.shift();
|
|
25
25
|
// メンバーシップ区分検索
|
|
26
26
|
const membershipTypes = yield repos.categoryCode.search({
|
|
@@ -28,7 +28,7 @@ function importFromCOA(params) {
|
|
|
28
28
|
page: 1,
|
|
29
29
|
project: { id: { $eq: params.project.id } },
|
|
30
30
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.MembershipType } }
|
|
31
|
-
});
|
|
31
|
+
}, [], []);
|
|
32
32
|
const defaultMembershipType = membershipTypes.shift();
|
|
33
33
|
try {
|
|
34
34
|
const ticketResults = yield repos.masterService.ticket({ theaterCode: params.theaterCode });
|
|
@@ -29,21 +29,19 @@ function authorize(params) {
|
|
|
29
29
|
throw new factory.errors.Forbidden('Transaction not yours');
|
|
30
30
|
}
|
|
31
31
|
// イベント取得属性最適化(2023-01-23~)
|
|
32
|
-
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
33
|
-
id: params.object.event.id
|
|
34
|
-
});
|
|
32
|
+
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({ id: params.object.event.id });
|
|
35
33
|
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
36
34
|
project: { id: { $eq: transaction.project.id } },
|
|
37
35
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
38
|
-
});
|
|
36
|
+
}, [], []);
|
|
39
37
|
const seatingTypes = yield repos.categoryCode.search({
|
|
40
38
|
project: { id: { $eq: transaction.project.id } },
|
|
41
39
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
42
|
-
});
|
|
40
|
+
}, [], []);
|
|
43
41
|
const videoFormatTypes = yield repos.categoryCode.search({
|
|
44
42
|
project: { id: { $eq: transaction.project.id } },
|
|
45
43
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
|
|
46
|
-
});
|
|
44
|
+
}, [], []);
|
|
47
45
|
// COA仮予約後にリクエストが来る前提
|
|
48
46
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
49
47
|
object: params.object,
|
|
@@ -183,15 +181,15 @@ function changeOffers(params) {
|
|
|
183
181
|
const availablePaymentMethodTypes = yield repos.categoryCode.search({
|
|
184
182
|
project: { id: { $eq: transaction.project.id } },
|
|
185
183
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.PaymentMethodType } }
|
|
186
|
-
});
|
|
184
|
+
}, [], []);
|
|
187
185
|
const seatingTypes = yield repos.categoryCode.search({
|
|
188
186
|
project: { id: { $eq: transaction.project.id } },
|
|
189
187
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
190
|
-
});
|
|
188
|
+
}, [], []);
|
|
191
189
|
const videoFormatTypes = yield repos.categoryCode.search({
|
|
192
190
|
project: { id: { $eq: transaction.project.id } },
|
|
193
191
|
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.VideoFormatType } }
|
|
194
|
-
});
|
|
192
|
+
}, [], []);
|
|
195
193
|
// COA仮予約後にリクエストが来る前提
|
|
196
194
|
const { acceptedOffers } = yield (0, validateAcceptedOffers_1.validateAcceptedOffers)({
|
|
197
195
|
object: params.object,
|
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
|
-
import { MongoRepository as CreativeWorkRepo } from '../../repo/creativeWork';
|
|
3
|
-
import { MongoRepository as ProductRepo } from '../../repo/product';
|
|
4
|
-
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
2
|
import { IConnectionSettings } from '../task';
|
|
6
3
|
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
7
4
|
/**
|
|
8
5
|
* タスク実行関数
|
|
9
6
|
*/
|
|
10
7
|
export declare function call(data: factory.task.onResourceUpdated.IData): IOperation<void>;
|
|
11
|
-
export declare function createInformMovieTasks(params: {
|
|
12
|
-
project: {
|
|
13
|
-
id: string;
|
|
14
|
-
};
|
|
15
|
-
ids: string[];
|
|
16
|
-
typeOf: factory.creativeWorkType;
|
|
17
|
-
}): (repos: {
|
|
18
|
-
creativeWork: CreativeWorkRepo;
|
|
19
|
-
task: TaskRepo;
|
|
20
|
-
}) => Promise<void>;
|
|
21
|
-
export declare function createInformProductTasks(params: {
|
|
22
|
-
project: {
|
|
23
|
-
id: string;
|
|
24
|
-
};
|
|
25
|
-
ids: string[];
|
|
26
|
-
typeOf: factory.product.ProductType;
|
|
27
|
-
}): (repos: {
|
|
28
|
-
product: ProductRepo;
|
|
29
|
-
task: TaskRepo;
|
|
30
|
-
}) => Promise<void>;
|
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.call = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
|
+
const categoryCode_1 = require("../../repo/categoryCode");
|
|
14
15
|
const creativeWork_1 = require("../../repo/creativeWork");
|
|
15
16
|
const product_1 = require("../../repo/product");
|
|
16
17
|
const task_1 = require("../../repo/task");
|
|
@@ -22,6 +23,7 @@ const informResources = settings_1.settings.onResourceUpdated.informResource;
|
|
|
22
23
|
function call(data) {
|
|
23
24
|
return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
25
|
yield onResourceUpdated(data)({
|
|
26
|
+
categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
|
|
25
27
|
creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
|
|
26
28
|
product: new product_1.MongoRepository(connectionSettings.connection),
|
|
27
29
|
task: new task_1.MongoRepository(connectionSettings.connection)
|
|
@@ -48,7 +50,11 @@ function onResourceUpdated(params) {
|
|
|
48
50
|
})(repos);
|
|
49
51
|
break;
|
|
50
52
|
case 'CategoryCode':
|
|
51
|
-
|
|
53
|
+
yield createInformCategoryCodeTasks({
|
|
54
|
+
project: { id: params.project.id },
|
|
55
|
+
ids: params.id,
|
|
56
|
+
typeOf: params.typeOf
|
|
57
|
+
})(repos);
|
|
52
58
|
break;
|
|
53
59
|
default:
|
|
54
60
|
// no op
|
|
@@ -60,7 +66,7 @@ function createInformMovieTasks(params) {
|
|
|
60
66
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
61
67
|
const movies4inform = yield repos.creativeWork.searchMovies({ id: { $in: params.ids } }, [
|
|
62
68
|
'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
|
|
63
|
-
'typeOf', '
|
|
69
|
+
'typeOf', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
|
|
64
70
|
], []);
|
|
65
71
|
if (movies4inform.length > 0) {
|
|
66
72
|
const taskRunsAt = new Date();
|
|
@@ -70,6 +76,8 @@ function createInformMovieTasks(params) {
|
|
|
70
76
|
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
71
77
|
movies4inform.forEach((movie4inform) => {
|
|
72
78
|
var _a;
|
|
79
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
80
|
+
delete movie4inform._id;
|
|
73
81
|
const informActionAttributes = {
|
|
74
82
|
agent: movie4inform.project,
|
|
75
83
|
object: movie4inform,
|
|
@@ -100,13 +108,12 @@ function createInformMovieTasks(params) {
|
|
|
100
108
|
}
|
|
101
109
|
});
|
|
102
110
|
}
|
|
103
|
-
exports.createInformMovieTasks = createInformMovieTasks;
|
|
104
111
|
function createInformProductTasks(params) {
|
|
105
112
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
106
113
|
const products4inform = yield repos.product.search({
|
|
107
114
|
typeOf: { $eq: params.typeOf },
|
|
108
115
|
id: { $in: params.ids }
|
|
109
|
-
}, ['additionalProperty', 'description', '
|
|
116
|
+
}, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
|
|
110
117
|
if (products4inform.length > 0) {
|
|
111
118
|
const taskRunsAt = new Date();
|
|
112
119
|
const informTasks = [];
|
|
@@ -115,6 +122,8 @@ function createInformProductTasks(params) {
|
|
|
115
122
|
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
116
123
|
products4inform.forEach((product4inform) => {
|
|
117
124
|
var _a;
|
|
125
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
126
|
+
delete product4inform._id;
|
|
118
127
|
const informActionAttributes = {
|
|
119
128
|
agent: product4inform.project,
|
|
120
129
|
object: product4inform,
|
|
@@ -145,4 +154,46 @@ function createInformProductTasks(params) {
|
|
|
145
154
|
}
|
|
146
155
|
});
|
|
147
156
|
}
|
|
148
|
-
|
|
157
|
+
function createInformCategoryCodeTasks(params) {
|
|
158
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const categoryCodes4inform = yield repos.categoryCode.search({ id: { $in: params.ids } }, ['color', 'image', 'name', 'additionalProperty', 'project', 'typeOf', 'codeValue', 'inCodeSet'], []);
|
|
160
|
+
if (categoryCodes4inform.length > 0) {
|
|
161
|
+
const taskRunsAt = new Date();
|
|
162
|
+
const informTasks = [];
|
|
163
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
164
|
+
var _a;
|
|
165
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
166
|
+
categoryCodes4inform.forEach((categoryCode4inform) => {
|
|
167
|
+
var _a;
|
|
168
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
169
|
+
delete categoryCode4inform._id;
|
|
170
|
+
const informActionAttributes = {
|
|
171
|
+
agent: categoryCode4inform.project,
|
|
172
|
+
object: categoryCode4inform,
|
|
173
|
+
project: categoryCode4inform.project,
|
|
174
|
+
recipient: {
|
|
175
|
+
id: '',
|
|
176
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
177
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
178
|
+
url: informUrl
|
|
179
|
+
},
|
|
180
|
+
typeOf: factory.actionType.InformAction
|
|
181
|
+
};
|
|
182
|
+
informTasks.push({
|
|
183
|
+
project: categoryCode4inform.project,
|
|
184
|
+
name: factory.taskName.TriggerWebhook,
|
|
185
|
+
status: factory.taskStatus.Ready,
|
|
186
|
+
runsAt: taskRunsAt,
|
|
187
|
+
remainingNumberOfTries: 10,
|
|
188
|
+
numberOfTried: 0,
|
|
189
|
+
executionResults: [],
|
|
190
|
+
data: informActionAttributes
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
if (informTasks.length > 0) {
|
|
195
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.34",
|
|
13
13
|
"@cinerino/sdk": "3.157.0-alpha.11",
|
|
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.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.109"
|
|
121
121
|
}
|