@chevre/domain 21.2.0-alpha.107 → 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/example/src/chevre/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +34 -23
- package/lib/chevre/repo/creativeWork.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.js +32 -10
- package/lib/chevre/repo/product.d.ts +1 -3
- package/lib/chevre/repo/product.js +23 -3
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- 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/offer/product.js +2 -2
- package/lib/chevre/service/payment/creditCard.js +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
- package/lib/chevre/service/task/onResourceUpdated.js +199 -0
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +1 -1
- package/lib/chevre/settings.d.ts +3 -0
- package/lib/chevre/settings.js +15 -0
- package/package.json +2 -2
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
|
@@ -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,
|
|
@@ -21,10 +21,14 @@ async function main() {
|
|
|
21
21
|
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
22
22
|
|
|
23
23
|
// プロダクト検索
|
|
24
|
-
const products = await productRepo.search(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const products = await productRepo.search(
|
|
25
|
+
{
|
|
26
|
+
project: { id: { $eq: project.id } },
|
|
27
|
+
typeOf: { $eq: chevre.factory.product.ProductType.MembershipService }
|
|
28
|
+
},
|
|
29
|
+
[],
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
28
32
|
console.log(products);
|
|
29
33
|
|
|
30
34
|
const product = products[0];
|
|
@@ -21,10 +21,14 @@ async function main() {
|
|
|
21
21
|
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
22
22
|
|
|
23
23
|
// プロダクト検索
|
|
24
|
-
const products = await productRepo.search(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const products = await productRepo.search(
|
|
25
|
+
{
|
|
26
|
+
project: { id: { $eq: project.id } },
|
|
27
|
+
typeOf: { $eq: chevre.factory.product.ProductType.PaymentCard }
|
|
28
|
+
},
|
|
29
|
+
[],
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
28
32
|
console.log(products);
|
|
29
33
|
|
|
30
34
|
const product = products[0];
|
|
@@ -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)
|
|
@@ -42,7 +42,7 @@ export declare class MongoRepository {
|
|
|
42
42
|
/**
|
|
43
43
|
* コンテンツを検索する
|
|
44
44
|
*/
|
|
45
|
-
searchMovies(params: factory.creativeWork.movie.ISearchConditions): Promise<factory.creativeWork.movie.ICreativeWork[]>;
|
|
45
|
+
searchMovies(params: factory.creativeWork.movie.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.creativeWork.movie.ICreativeWork[]>;
|
|
46
46
|
/**
|
|
47
47
|
* コンテンツを削除する
|
|
48
48
|
*/
|
|
@@ -33,7 +33,7 @@ class MongoRepository {
|
|
|
33
33
|
}
|
|
34
34
|
// tslint:disable-next-line:max-func-body-length
|
|
35
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
37
37
|
// MongoDB検索条件
|
|
38
38
|
const andConditions = [
|
|
39
39
|
{
|
|
@@ -66,6 +66,14 @@ class MongoRepository {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
+
const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
70
|
+
if (typeof idEq === 'string') {
|
|
71
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
72
|
+
}
|
|
73
|
+
const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
74
|
+
if (Array.isArray(idIn)) {
|
|
75
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
76
|
+
}
|
|
69
77
|
if (typeof params.identifier === 'string') {
|
|
70
78
|
if (params.identifier.length > 0) {
|
|
71
79
|
andConditions.push({
|
|
@@ -74,13 +82,13 @@ class MongoRepository {
|
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
else {
|
|
77
|
-
const identifierEq = (
|
|
85
|
+
const identifierEq = (_h = params.identifier) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
78
86
|
if (typeof identifierEq === 'string') {
|
|
79
87
|
andConditions.push({
|
|
80
88
|
identifier: { $eq: identifierEq }
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
|
-
const identifierIn = (
|
|
91
|
+
const identifierIn = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$in;
|
|
84
92
|
if (Array.isArray(identifierIn)) {
|
|
85
93
|
andConditions.push({
|
|
86
94
|
identifier: { $in: identifierIn }
|
|
@@ -156,7 +164,7 @@ class MongoRepository {
|
|
|
156
164
|
});
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
|
-
const additionalPropertyElemMatch = (
|
|
167
|
+
const additionalPropertyElemMatch = (_k = params.additionalProperty) === null || _k === void 0 ? void 0 : _k.$elemMatch;
|
|
160
168
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
161
169
|
andConditions.push({
|
|
162
170
|
additionalProperty: {
|
|
@@ -213,15 +221,29 @@ class MongoRepository {
|
|
|
213
221
|
/**
|
|
214
222
|
* コンテンツを検索する
|
|
215
223
|
*/
|
|
216
|
-
searchMovies(params) {
|
|
224
|
+
searchMovies(params, inclusion, exclusion) {
|
|
217
225
|
var _a;
|
|
218
226
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
227
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
228
|
+
let projection = {};
|
|
229
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
230
|
+
inclusion.forEach((field) => {
|
|
231
|
+
projection[field] = 1;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
projection = {
|
|
236
|
+
__v: 0,
|
|
237
|
+
createdAt: 0,
|
|
238
|
+
updatedAt: 0
|
|
239
|
+
};
|
|
240
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
241
|
+
exclusion.forEach((field) => {
|
|
242
|
+
projection[field] = 0;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const query = this.creativeWorkModel.find({ $and: conditions }, projection);
|
|
225
247
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
226
248
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
227
249
|
query.limit(params.limit)
|
|
@@ -37,9 +37,7 @@ export declare class MongoRepository {
|
|
|
37
37
|
}, projection?: {
|
|
38
38
|
[key: string]: number;
|
|
39
39
|
}): Promise<IProduct>;
|
|
40
|
-
search(conditions: factory.product.ISearchConditions,
|
|
41
|
-
[key: string]: number;
|
|
42
|
-
}): Promise<IProduct[]>;
|
|
40
|
+
search(conditions: factory.product.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<IProduct[]>;
|
|
43
41
|
deleteById(params: {
|
|
44
42
|
id: string;
|
|
45
43
|
}): Promise<void>;
|
|
@@ -156,11 +156,31 @@ class MongoRepository {
|
|
|
156
156
|
return doc.toObject();
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
search(conditions,
|
|
159
|
+
search(conditions,
|
|
160
|
+
// projection?: { [key: string]: number }
|
|
161
|
+
inclusion, exclusion) {
|
|
160
162
|
var _a;
|
|
161
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
164
|
const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
|
|
163
|
-
|
|
165
|
+
let projection = {};
|
|
166
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
167
|
+
inclusion.forEach((field) => {
|
|
168
|
+
projection[field] = 1;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
projection = {
|
|
173
|
+
__v: 0,
|
|
174
|
+
createdAt: 0,
|
|
175
|
+
updatedAt: 0
|
|
176
|
+
};
|
|
177
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
178
|
+
exclusion.forEach((field) => {
|
|
179
|
+
projection[field] = 0;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const query = this.productModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
164
184
|
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
165
185
|
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
166
186
|
query.limit(conditions.limit)
|
|
@@ -193,7 +213,7 @@ class MongoRepository {
|
|
|
193
213
|
project: { id: { $eq: params.project.id } },
|
|
194
214
|
typeOf: { $eq: params.typeOf },
|
|
195
215
|
id: { $eq: params.id }
|
|
196
|
-
});
|
|
216
|
+
}, [], []);
|
|
197
217
|
const paymentServiceSetting = paymentServices.shift();
|
|
198
218
|
if (paymentServiceSetting === undefined) {
|
|
199
219
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -63,7 +63,7 @@ export declare class MongoRepository {
|
|
|
63
63
|
*/
|
|
64
64
|
$nin?: factory.taskName[];
|
|
65
65
|
};
|
|
66
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
66
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
67
67
|
retry(params: {
|
|
68
68
|
intervalInMinutes: number;
|
|
69
69
|
}): Promise<void>;
|
|
@@ -34,7 +34,7 @@ function start(params) {
|
|
|
34
34
|
project: { id: { $eq: params.project.id } },
|
|
35
35
|
typeOf: { $eq: factory.product.ProductType.PaymentCard },
|
|
36
36
|
id: { $eq: issuedThroughId }
|
|
37
|
-
});
|
|
37
|
+
}, [], []);
|
|
38
38
|
const product = products.shift();
|
|
39
39
|
if (product === undefined) {
|
|
40
40
|
throw new factory.errors.NotFound('Product');
|
|
@@ -194,7 +194,7 @@ function fixPaymentService(params) {
|
|
|
194
194
|
project: { id: { $eq: params.project.id } },
|
|
195
195
|
typeOf: { $eq: paymentServiceType },
|
|
196
196
|
id: { $eq: paymentServiceId }
|
|
197
|
-
});
|
|
197
|
+
}, [], []);
|
|
198
198
|
paymentService = paymentServices.shift();
|
|
199
199
|
if (paymentService === undefined) {
|
|
200
200
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -91,7 +91,7 @@ function fixPaymentService(params) {
|
|
|
91
91
|
project: { id: { $eq: params.payAction.project.id } },
|
|
92
92
|
typeOf: { $eq: params.paymentServiceType },
|
|
93
93
|
id: { $eq: paymentServiceId }
|
|
94
|
-
});
|
|
94
|
+
}, [], []);
|
|
95
95
|
paymentService = paymentServices.shift();
|
|
96
96
|
if (paymentService === undefined) {
|
|
97
97
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -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,
|
|
@@ -32,7 +32,7 @@ function search(params) {
|
|
|
32
32
|
page: 1,
|
|
33
33
|
project: { id: { $eq: params.project.id } },
|
|
34
34
|
id: { $eq: params.itemOffered.id }
|
|
35
|
-
});
|
|
35
|
+
}, [], []);
|
|
36
36
|
const product = searchProductsResult.shift();
|
|
37
37
|
if (product === undefined) {
|
|
38
38
|
throw new factory.errors.NotFound('Product');
|
|
@@ -206,7 +206,7 @@ function fixProductAndOffers(params) {
|
|
|
206
206
|
page: 1,
|
|
207
207
|
project: { id: { $eq: params.project.id } },
|
|
208
208
|
id: { $eq: productId }
|
|
209
|
-
});
|
|
209
|
+
}, [], []);
|
|
210
210
|
const product = searchProductsResult.shift();
|
|
211
211
|
if (product === undefined) {
|
|
212
212
|
throw new factory.errors.NotFound('Product');
|
|
@@ -534,7 +534,7 @@ function getGMOInfoFromSeller(params) {
|
|
|
534
534
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
535
535
|
// serviceType: { codeValue: { $eq: params.paymentMethodType } },
|
|
536
536
|
id: { $eq: params.paymentServiceId }
|
|
537
|
-
});
|
|
537
|
+
}, [], []);
|
|
538
538
|
const paymentService = paymentServices.shift();
|
|
539
539
|
if (paymentService === undefined) {
|
|
540
540
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -22,7 +22,7 @@ function getCredentials(params) {
|
|
|
22
22
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.MovieTicket },
|
|
23
23
|
// serviceType: { codeValue: { $eq: params.paymentMethodType } },
|
|
24
24
|
id: { $eq: params.paymentServiceId }
|
|
25
|
-
});
|
|
25
|
+
}, [], []);
|
|
26
26
|
const paymentService = paymentServices.shift();
|
|
27
27
|
if (paymentService === undefined) {
|
|
28
28
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.onResourceUpdated.IData): IOperation<void>;
|
|
@@ -0,0 +1,199 @@
|
|
|
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.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const categoryCode_1 = require("../../repo/categoryCode");
|
|
15
|
+
const creativeWork_1 = require("../../repo/creativeWork");
|
|
16
|
+
const product_1 = require("../../repo/product");
|
|
17
|
+
const task_1 = require("../../repo/task");
|
|
18
|
+
const settings_1 = require("../../settings");
|
|
19
|
+
const informResources = settings_1.settings.onResourceUpdated.informResource;
|
|
20
|
+
/**
|
|
21
|
+
* タスク実行関数
|
|
22
|
+
*/
|
|
23
|
+
function call(data) {
|
|
24
|
+
return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
yield onResourceUpdated(data)({
|
|
26
|
+
categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
|
|
27
|
+
creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
|
|
28
|
+
product: new product_1.MongoRepository(connectionSettings.connection),
|
|
29
|
+
task: new task_1.MongoRepository(connectionSettings.connection)
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.call = call;
|
|
34
|
+
function onResourceUpdated(params) {
|
|
35
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (params.useInform === true) {
|
|
37
|
+
switch (params.typeOf) {
|
|
38
|
+
case factory.creativeWorkType.Movie:
|
|
39
|
+
yield createInformMovieTasks({
|
|
40
|
+
project: { id: params.project.id },
|
|
41
|
+
ids: params.id,
|
|
42
|
+
typeOf: params.typeOf
|
|
43
|
+
})(repos);
|
|
44
|
+
break;
|
|
45
|
+
case factory.product.ProductType.EventService:
|
|
46
|
+
yield createInformProductTasks({
|
|
47
|
+
project: { id: params.project.id },
|
|
48
|
+
ids: params.id,
|
|
49
|
+
typeOf: params.typeOf
|
|
50
|
+
})(repos);
|
|
51
|
+
break;
|
|
52
|
+
case 'CategoryCode':
|
|
53
|
+
yield createInformCategoryCodeTasks({
|
|
54
|
+
project: { id: params.project.id },
|
|
55
|
+
ids: params.id,
|
|
56
|
+
typeOf: params.typeOf
|
|
57
|
+
})(repos);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
// no op
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function createInformMovieTasks(params) {
|
|
66
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const movies4inform = yield repos.creativeWork.searchMovies({ id: { $in: params.ids } }, [
|
|
68
|
+
'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
|
|
69
|
+
'typeOf', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
|
|
70
|
+
], []);
|
|
71
|
+
if (movies4inform.length > 0) {
|
|
72
|
+
const taskRunsAt = new Date();
|
|
73
|
+
const informTasks = [];
|
|
74
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
77
|
+
movies4inform.forEach((movie4inform) => {
|
|
78
|
+
var _a;
|
|
79
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
80
|
+
delete movie4inform._id;
|
|
81
|
+
const informActionAttributes = {
|
|
82
|
+
agent: movie4inform.project,
|
|
83
|
+
object: movie4inform,
|
|
84
|
+
project: movie4inform.project,
|
|
85
|
+
recipient: {
|
|
86
|
+
id: '',
|
|
87
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
88
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
89
|
+
url: informUrl
|
|
90
|
+
},
|
|
91
|
+
typeOf: factory.actionType.InformAction
|
|
92
|
+
};
|
|
93
|
+
informTasks.push({
|
|
94
|
+
project: movie4inform.project,
|
|
95
|
+
name: factory.taskName.TriggerWebhook,
|
|
96
|
+
status: factory.taskStatus.Ready,
|
|
97
|
+
runsAt: taskRunsAt,
|
|
98
|
+
remainingNumberOfTries: 10,
|
|
99
|
+
numberOfTried: 0,
|
|
100
|
+
executionResults: [],
|
|
101
|
+
data: informActionAttributes
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
if (informTasks.length > 0) {
|
|
106
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function createInformProductTasks(params) {
|
|
112
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const products4inform = yield repos.product.search({
|
|
114
|
+
typeOf: { $eq: params.typeOf },
|
|
115
|
+
id: { $in: params.ids }
|
|
116
|
+
}, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
|
|
117
|
+
if (products4inform.length > 0) {
|
|
118
|
+
const taskRunsAt = new Date();
|
|
119
|
+
const informTasks = [];
|
|
120
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
121
|
+
var _a;
|
|
122
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
123
|
+
products4inform.forEach((product4inform) => {
|
|
124
|
+
var _a;
|
|
125
|
+
// _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
|
|
126
|
+
delete product4inform._id;
|
|
127
|
+
const informActionAttributes = {
|
|
128
|
+
agent: product4inform.project,
|
|
129
|
+
object: product4inform,
|
|
130
|
+
project: product4inform.project,
|
|
131
|
+
recipient: {
|
|
132
|
+
id: '',
|
|
133
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
134
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
135
|
+
url: informUrl
|
|
136
|
+
},
|
|
137
|
+
typeOf: factory.actionType.InformAction
|
|
138
|
+
};
|
|
139
|
+
informTasks.push({
|
|
140
|
+
project: product4inform.project,
|
|
141
|
+
name: factory.taskName.TriggerWebhook,
|
|
142
|
+
status: factory.taskStatus.Ready,
|
|
143
|
+
runsAt: taskRunsAt,
|
|
144
|
+
remainingNumberOfTries: 10,
|
|
145
|
+
numberOfTried: 0,
|
|
146
|
+
executionResults: [],
|
|
147
|
+
data: informActionAttributes
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
if (informTasks.length > 0) {
|
|
152
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
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
|
+
}
|
|
@@ -106,7 +106,7 @@ function getCreditCardPaymentServiceChannel(params) {
|
|
|
106
106
|
project: { id: { $eq: params.project.id } },
|
|
107
107
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
108
108
|
serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
109
|
-
});
|
|
109
|
+
}, [], []);
|
|
110
110
|
const paymentServiceSetting = paymentServices.shift();
|
|
111
111
|
if (paymentServiceSetting === undefined) {
|
|
112
112
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -22,7 +22,7 @@ function findPaymentCardPermit(params) {
|
|
|
22
22
|
page: 1,
|
|
23
23
|
project: { id: { $eq: params.project.id } },
|
|
24
24
|
typeOf: { $eq: factory.product.ProductType.PaymentCard }
|
|
25
|
-
});
|
|
25
|
+
}, [], []);
|
|
26
26
|
const accountProduct = searchProductsResult
|
|
27
27
|
.find((p) => { var _a, _b; return ((_b = (_a = p.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency) === params.accountType; });
|
|
28
28
|
if (accountProduct === undefined) {
|
|
@@ -316,7 +316,7 @@ function processAuthorizeCreditCard(params) {
|
|
|
316
316
|
project: { id: { $eq: params.project.id } },
|
|
317
317
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
318
318
|
serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
319
|
-
});
|
|
319
|
+
}, [], []);
|
|
320
320
|
const creditCardPaymentService = searchCreditCardPaymentServicesResult.shift();
|
|
321
321
|
if (creditCardPaymentService === undefined) {
|
|
322
322
|
throw new factory.errors.NotFound('CreditCardPaymentService');
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type ISettings = factory.project.ISettings & {
|
|
|
23
23
|
onReservationStatusChanged: {
|
|
24
24
|
informReservation?: factory.project.IInformParams[];
|
|
25
25
|
};
|
|
26
|
+
onResourceUpdated: {
|
|
27
|
+
informResource?: factory.project.IInformParams[];
|
|
28
|
+
};
|
|
26
29
|
maximumReservationGracePeriodInDays: number;
|
|
27
30
|
userPoolIdOld: string;
|
|
28
31
|
userPoolIdNew: string;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -15,6 +15,9 @@ const informOrderUrls = (typeof process.env.INFORM_ORDER_URL === 'string')
|
|
|
15
15
|
const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'string')
|
|
16
16
|
? process.env.INFORM_RESERVATION_URL.split(' ')
|
|
17
17
|
: [];
|
|
18
|
+
const informResourceUrls = (typeof process.env.INFORM_RESOURCE_URL === 'string')
|
|
19
|
+
? process.env.INFORM_RESOURCE_URL.split(' ')
|
|
20
|
+
: [];
|
|
18
21
|
// tslint:disable-next-line:no-magic-numbers
|
|
19
22
|
const triggerWebhookTimeout = (process.env.TRIGGER_WEBHOOK_TIMEOUT !== undefined) ? Number(process.env.TRIGGER_WEBHOOK_TIMEOUT) : 15000;
|
|
20
23
|
exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = (typeof process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT === 'string')
|
|
@@ -96,6 +99,18 @@ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onEvent
|
|
|
96
99
|
}
|
|
97
100
|
};
|
|
98
101
|
})
|
|
102
|
+
}, onResourceUpdated: {
|
|
103
|
+
informResource: informResourceUrls
|
|
104
|
+
.filter((url) => url.length > 0)
|
|
105
|
+
.map((url) => {
|
|
106
|
+
return {
|
|
107
|
+
recipient: {
|
|
108
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
109
|
+
name: 'Global HUB',
|
|
110
|
+
url
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
})
|
|
99
114
|
},
|
|
100
115
|
// 廃止(2022-10-29~)
|
|
101
116
|
// onPaymentStatusChanged: {
|
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
|
}
|
|
@@ -1,123 +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
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
-
|
|
12
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
|
-
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
14
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
'project.id': { $ne: '' },
|
|
20
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
-
startDate: {
|
|
22
|
-
$gte: moment()
|
|
23
|
-
.add(-1, 'month')
|
|
24
|
-
.toDate()
|
|
25
|
-
}
|
|
26
|
-
// _id: { $eq: 'al6afd7np' }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
// _id: 1,
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
console.log('events found');
|
|
33
|
-
|
|
34
|
-
let i = 0;
|
|
35
|
-
let updateCount = 0;
|
|
36
|
-
await cursor.eachAsync(async (doc) => {
|
|
37
|
-
i += 1;
|
|
38
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
39
|
-
|
|
40
|
-
const itemOfferedId = (<chevre.factory.event.screeningEvent.IOffer | undefined>event.offers)?.itemOffered?.id;
|
|
41
|
-
const catalogId = (<any>event).hasOfferCatalog?.id;
|
|
42
|
-
|
|
43
|
-
if (typeof catalogId === 'string' && catalogId.length > 0) {
|
|
44
|
-
if (typeof itemOfferedId === 'string' && itemOfferedId.length > 0) {
|
|
45
|
-
console.log(
|
|
46
|
-
'already exist...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
47
|
-
} else {
|
|
48
|
-
const existingCatalogs = await offerCatalogRepo.search({
|
|
49
|
-
limit: 1,
|
|
50
|
-
page: 1,
|
|
51
|
-
project: { id: { $eq: event.project.id } },
|
|
52
|
-
id: { $in: [catalogId] }
|
|
53
|
-
});
|
|
54
|
-
const existingCatalog = existingCatalogs.shift();
|
|
55
|
-
|
|
56
|
-
if (existingCatalog !== undefined) {
|
|
57
|
-
const existingProducts = await productRepo.search({
|
|
58
|
-
limit: 1,
|
|
59
|
-
page: 1,
|
|
60
|
-
project: { id: { $eq: event.project.id } },
|
|
61
|
-
productID: { $eq: `${chevre.factory.product.ProductType.EventService}${catalogId}` }
|
|
62
|
-
});
|
|
63
|
-
const existingProduct = existingProducts.shift();
|
|
64
|
-
if (existingProduct === undefined) {
|
|
65
|
-
throw new Error(`product not found ${event.id}`);
|
|
66
|
-
}
|
|
67
|
-
console.log(
|
|
68
|
-
'updating event...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
69
|
-
await eventRepo.updatePartiallyById({
|
|
70
|
-
id: event.id,
|
|
71
|
-
attributes: <any>{
|
|
72
|
-
typeOf: event.typeOf,
|
|
73
|
-
'offers.itemOffered.id': String(existingProduct.id)
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
updateCount += 1;
|
|
77
|
-
console.log(
|
|
78
|
-
'updated', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
79
|
-
} else {
|
|
80
|
-
// カタログが存在しないのではもはや無効なのでスルー
|
|
81
|
-
console.log(
|
|
82
|
-
'catalog not exist', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
console.log(
|
|
87
|
-
'no catalog...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
console.log(i, 'events checked');
|
|
92
|
-
console.log(updateCount, 'events updated');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// function offerCatalog2eventService(offerCatalog: chevre.factory.offerCatalog.IOfferCatalog): chevre.factory.product.IProduct {
|
|
96
|
-
// tslint:disable-next-line:max-line-length
|
|
97
|
-
// const serviceType: chevre.factory.product.IServiceType | undefined = (typeof offerCatalog.itemOffered.serviceType?.typeOf === 'string')
|
|
98
|
-
// ? {
|
|
99
|
-
// codeValue: offerCatalog.itemOffered.serviceType.codeValue,
|
|
100
|
-
// inCodeSet: offerCatalog.itemOffered.serviceType.inCodeSet,
|
|
101
|
-
// project: offerCatalog.itemOffered.serviceType.project,
|
|
102
|
-
// typeOf: offerCatalog.itemOffered.serviceType.typeOf
|
|
103
|
-
// }
|
|
104
|
-
// : undefined;
|
|
105
|
-
|
|
106
|
-
// if (typeof offerCatalog.id !== 'string' || offerCatalog.id.length === 0) {
|
|
107
|
-
// throw new Error('offerCatalog.id undefined');
|
|
108
|
-
// }
|
|
109
|
-
|
|
110
|
-
// return {
|
|
111
|
-
// project: offerCatalog.project,
|
|
112
|
-
// typeOf: chevre.factory.product.ProductType.EventService,
|
|
113
|
-
// // productIDフォーマット確定(matches(/^[0-9a-zA-Z]+$/)に注意)(.isLength({ min: 3, max: 30 })に注意)
|
|
114
|
-
// productID: `${chevre.factory.product.ProductType.EventService}${offerCatalog.id}`,
|
|
115
|
-
// name: offerCatalog.name,
|
|
116
|
-
// hasOfferCatalog: { id: offerCatalog.id, typeOf: offerCatalog.typeOf },
|
|
117
|
-
// ...(typeof serviceType?.typeOf === 'string') ? { serviceType } : undefined
|
|
118
|
-
// };
|
|
119
|
-
// }
|
|
120
|
-
|
|
121
|
-
main()
|
|
122
|
-
.then()
|
|
123
|
-
.catch(console.error);
|