@chevre/domain 21.2.0-alpha.106 → 21.2.0-alpha.108
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/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- 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 +4 -1
- 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 +30 -0
- package/lib/chevre/service/task/onResourceUpdated.js +148 -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 +3 -3
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -208
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
|
@@ -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];
|
|
@@ -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');
|
|
@@ -586,7 +586,10 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
586
586
|
endDate: endDate,
|
|
587
587
|
startDate: startDate,
|
|
588
588
|
coaInfo,
|
|
589
|
-
offers: Object.assign({
|
|
589
|
+
offers: Object.assign({
|
|
590
|
+
// 不要なので廃止(2023-06-09~)
|
|
591
|
+
// project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
592
|
+
typeOf: factory.offerType.Offer, priceCurrency: factory.priceCurrency.JPY }, (Array.isArray(unacceptedPaymentMethod)) ? { unacceptedPaymentMethod: unacceptedPaymentMethod } : undefined),
|
|
590
593
|
additionalProperty
|
|
591
594
|
};
|
|
592
595
|
}
|
|
@@ -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,30 @@
|
|
|
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
|
+
import { IConnectionSettings } from '../task';
|
|
6
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* タスク実行関数
|
|
9
|
+
*/
|
|
10
|
+
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>;
|
|
@@ -0,0 +1,148 @@
|
|
|
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.createInformProductTasks = exports.createInformMovieTasks = exports.call = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
const creativeWork_1 = require("../../repo/creativeWork");
|
|
15
|
+
const product_1 = require("../../repo/product");
|
|
16
|
+
const task_1 = require("../../repo/task");
|
|
17
|
+
const settings_1 = require("../../settings");
|
|
18
|
+
const informResources = settings_1.settings.onResourceUpdated.informResource;
|
|
19
|
+
/**
|
|
20
|
+
* タスク実行関数
|
|
21
|
+
*/
|
|
22
|
+
function call(data) {
|
|
23
|
+
return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield onResourceUpdated(data)({
|
|
25
|
+
creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
|
|
26
|
+
product: new product_1.MongoRepository(connectionSettings.connection),
|
|
27
|
+
task: new task_1.MongoRepository(connectionSettings.connection)
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.call = call;
|
|
32
|
+
function onResourceUpdated(params) {
|
|
33
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
if (params.useInform === true) {
|
|
35
|
+
switch (params.typeOf) {
|
|
36
|
+
case factory.creativeWorkType.Movie:
|
|
37
|
+
yield createInformMovieTasks({
|
|
38
|
+
project: { id: params.project.id },
|
|
39
|
+
ids: params.id,
|
|
40
|
+
typeOf: params.typeOf
|
|
41
|
+
})(repos);
|
|
42
|
+
break;
|
|
43
|
+
case factory.product.ProductType.EventService:
|
|
44
|
+
yield createInformProductTasks({
|
|
45
|
+
project: { id: params.project.id },
|
|
46
|
+
ids: params.id,
|
|
47
|
+
typeOf: params.typeOf
|
|
48
|
+
})(repos);
|
|
49
|
+
break;
|
|
50
|
+
case 'CategoryCode':
|
|
51
|
+
// no op
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
// no op
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function createInformMovieTasks(params) {
|
|
60
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const movies4inform = yield repos.creativeWork.searchMovies({ id: { $in: params.ids } }, [
|
|
62
|
+
'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
|
|
63
|
+
'typeOf', 'id', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
|
|
64
|
+
], []);
|
|
65
|
+
if (movies4inform.length > 0) {
|
|
66
|
+
const taskRunsAt = new Date();
|
|
67
|
+
const informTasks = [];
|
|
68
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
69
|
+
var _a;
|
|
70
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
71
|
+
movies4inform.forEach((movie4inform) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const informActionAttributes = {
|
|
74
|
+
agent: movie4inform.project,
|
|
75
|
+
object: movie4inform,
|
|
76
|
+
project: movie4inform.project,
|
|
77
|
+
recipient: {
|
|
78
|
+
id: '',
|
|
79
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
80
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
81
|
+
url: informUrl
|
|
82
|
+
},
|
|
83
|
+
typeOf: factory.actionType.InformAction
|
|
84
|
+
};
|
|
85
|
+
informTasks.push({
|
|
86
|
+
project: movie4inform.project,
|
|
87
|
+
name: factory.taskName.TriggerWebhook,
|
|
88
|
+
status: factory.taskStatus.Ready,
|
|
89
|
+
runsAt: taskRunsAt,
|
|
90
|
+
remainingNumberOfTries: 10,
|
|
91
|
+
numberOfTried: 0,
|
|
92
|
+
executionResults: [],
|
|
93
|
+
data: informActionAttributes
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
if (informTasks.length > 0) {
|
|
98
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.createInformMovieTasks = createInformMovieTasks;
|
|
104
|
+
function createInformProductTasks(params) {
|
|
105
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const products4inform = yield repos.product.search({
|
|
107
|
+
typeOf: { $eq: params.typeOf },
|
|
108
|
+
id: { $in: params.ids }
|
|
109
|
+
}, ['additionalProperty', 'description', 'id', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
|
|
110
|
+
if (products4inform.length > 0) {
|
|
111
|
+
const taskRunsAt = new Date();
|
|
112
|
+
const informTasks = [];
|
|
113
|
+
informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
|
|
114
|
+
var _a;
|
|
115
|
+
const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
|
|
116
|
+
products4inform.forEach((product4inform) => {
|
|
117
|
+
var _a;
|
|
118
|
+
const informActionAttributes = {
|
|
119
|
+
agent: product4inform.project,
|
|
120
|
+
object: product4inform,
|
|
121
|
+
project: product4inform.project,
|
|
122
|
+
recipient: {
|
|
123
|
+
id: '',
|
|
124
|
+
name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
|
|
125
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
126
|
+
url: informUrl
|
|
127
|
+
},
|
|
128
|
+
typeOf: factory.actionType.InformAction
|
|
129
|
+
};
|
|
130
|
+
informTasks.push({
|
|
131
|
+
project: product4inform.project,
|
|
132
|
+
name: factory.taskName.TriggerWebhook,
|
|
133
|
+
status: factory.taskStatus.Ready,
|
|
134
|
+
runsAt: taskRunsAt,
|
|
135
|
+
remainingNumberOfTries: 10,
|
|
136
|
+
numberOfTried: 0,
|
|
137
|
+
executionResults: [],
|
|
138
|
+
data: informActionAttributes
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
if (informTasks.length > 0) {
|
|
143
|
+
yield repos.task.saveMany(informTasks, { emitImmediately: true });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
exports.createInformProductTasks = createInformProductTasks;
|
|
@@ -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,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.157.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.33",
|
|
13
|
+
"@cinerino/sdk": "3.157.0-alpha.11",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.108"
|
|
121
121
|
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
-
const filterName: string = 'eventIdentifier';
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
-
|
|
14
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const result = await eventRepo.createManyIfNotExist<chevre.factory.eventType.ScreeningEvent>([
|
|
17
|
-
{
|
|
18
|
-
attributes: {
|
|
19
|
-
additionalProperty: [{
|
|
20
|
-
name: filterName,
|
|
21
|
-
value: '20230201143000-03'
|
|
22
|
-
}],
|
|
23
|
-
project: {
|
|
24
|
-
id: PROJECT_ID,
|
|
25
|
-
typeOf: chevre.factory.organizationType.Project
|
|
26
|
-
},
|
|
27
|
-
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
28
|
-
doorTime: moment('2023-02-01T05:00:00.000Z')
|
|
29
|
-
.toDate(),
|
|
30
|
-
startDate: moment('2023-02-01T05:00:00.000Z')
|
|
31
|
-
.toDate(),
|
|
32
|
-
endDate: moment('2023-02-01T06:00:00.000Z')
|
|
33
|
-
.toDate(),
|
|
34
|
-
// workPerformed: {
|
|
35
|
-
// typeOf: chevre.factory.creativeWorkType.Movie,
|
|
36
|
-
// identifier: '1622100',
|
|
37
|
-
// id: '5bfb841d5a78d7948369980a',
|
|
38
|
-
// name: {
|
|
39
|
-
// en: 'Pet',
|
|
40
|
-
// ja: 'ペット'
|
|
41
|
-
// },
|
|
42
|
-
// duration: 'PT2H3M'
|
|
43
|
-
// },
|
|
44
|
-
location: {
|
|
45
|
-
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
46
|
-
branchCode: '10',
|
|
47
|
-
name: {
|
|
48
|
-
ja: 'シネマ1',
|
|
49
|
-
en: 'CINEMA1'
|
|
50
|
-
},
|
|
51
|
-
address: {
|
|
52
|
-
ja: '7階',
|
|
53
|
-
en: '7F'
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
superEvent: {
|
|
57
|
-
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
58
|
-
project: {
|
|
59
|
-
typeOf: chevre.factory.organizationType.Project,
|
|
60
|
-
id: 'cinerino'
|
|
61
|
-
},
|
|
62
|
-
id: '7k9ayl8hc',
|
|
63
|
-
videoFormat: [
|
|
64
|
-
{
|
|
65
|
-
typeOf: '2D',
|
|
66
|
-
name: '2D'
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
soundFormat: [],
|
|
70
|
-
workPerformed: {
|
|
71
|
-
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
72
|
-
identifier: '1622100',
|
|
73
|
-
id: '5bfb841d5a78d7948369980a',
|
|
74
|
-
name: {
|
|
75
|
-
en: 'Pet',
|
|
76
|
-
ja: 'ペット'
|
|
77
|
-
},
|
|
78
|
-
duration: 'PT2H3M'
|
|
79
|
-
},
|
|
80
|
-
location: {
|
|
81
|
-
typeOf: chevre.factory.placeType.MovieTheater,
|
|
82
|
-
id: '5bfb841d5a78d7948369979a',
|
|
83
|
-
branchCode: '118',
|
|
84
|
-
name: {
|
|
85
|
-
ja: 'シネモーション赤坂 ',
|
|
86
|
-
en: 'CineMotion Akasaka'
|
|
87
|
-
},
|
|
88
|
-
kanaName: 'シネモーションアカサカ'
|
|
89
|
-
},
|
|
90
|
-
kanaName: 'ペットカナタイトル',
|
|
91
|
-
name: {
|
|
92
|
-
en: 'PetPetPetPet',
|
|
93
|
-
ja: 'ペット'
|
|
94
|
-
},
|
|
95
|
-
additionalProperty: [
|
|
96
|
-
{
|
|
97
|
-
name: 'sortNumber',
|
|
98
|
-
value: '99'
|
|
99
|
-
}
|
|
100
|
-
],
|
|
101
|
-
startDate: moment('2020-03-31T15:00:00.000Z')
|
|
102
|
-
.toDate(),
|
|
103
|
-
endDate: moment('2034-12-01T15:00:00.000Z')
|
|
104
|
-
.toDate(),
|
|
105
|
-
description: {
|
|
106
|
-
en: 'english description',
|
|
107
|
-
ja: 'ムビチケ検証用のイベントです。'
|
|
108
|
-
},
|
|
109
|
-
headline: {
|
|
110
|
-
en: 'headlineheadlineheadlineheadlineheadlineheadlineheadline',
|
|
111
|
-
ja: 'サブタイトルkanaName'
|
|
112
|
-
},
|
|
113
|
-
subtitleLanguage: {
|
|
114
|
-
typeOf: 'Language',
|
|
115
|
-
name: 'Japanese'
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
name: {
|
|
119
|
-
en: 'PetPetPetPet',
|
|
120
|
-
ja: 'ペット'
|
|
121
|
-
},
|
|
122
|
-
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
123
|
-
offers: {
|
|
124
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
125
|
-
priceCurrency: chevre.factory.priceCurrency.JPY,
|
|
126
|
-
availabilityEnds: moment('2023-02-01T01:20:00.000Z')
|
|
127
|
-
.toDate(),
|
|
128
|
-
availabilityStarts: moment('2023-01-30T15:00:00.000Z')
|
|
129
|
-
.toDate(),
|
|
130
|
-
eligibleQuantity: {
|
|
131
|
-
typeOf: 'QuantitativeValue',
|
|
132
|
-
unitCode: chevre.factory.unitCode.C62,
|
|
133
|
-
maxValue: 6,
|
|
134
|
-
value: 1
|
|
135
|
-
},
|
|
136
|
-
itemOffered: {
|
|
137
|
-
id: '6308580bdef565000a9aa1fd',
|
|
138
|
-
name: {
|
|
139
|
-
ja: '通常興行カタログ'
|
|
140
|
-
},
|
|
141
|
-
serviceOutput: {
|
|
142
|
-
typeOf: chevre.factory.reservationType.EventReservation,
|
|
143
|
-
reservedTicket: {
|
|
144
|
-
typeOf: 'Ticket',
|
|
145
|
-
ticketedSeat: {
|
|
146
|
-
typeOf: chevre.factory.placeType.Seat
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
typeOf: chevre.factory.product.ProductType.EventService,
|
|
151
|
-
availableChannel: {
|
|
152
|
-
typeOf: 'ServiceChannel',
|
|
153
|
-
serviceLocation: {
|
|
154
|
-
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
155
|
-
branchCode: '10',
|
|
156
|
-
name: {
|
|
157
|
-
ja: 'シネマ1',
|
|
158
|
-
en: 'CINEMA1'
|
|
159
|
-
},
|
|
160
|
-
containedInPlace: {
|
|
161
|
-
typeOf: chevre.factory.placeType.MovieTheater,
|
|
162
|
-
id: '5bfb841d5a78d7948369979a',
|
|
163
|
-
branchCode: '118',
|
|
164
|
-
name: {
|
|
165
|
-
ja: 'シネモーション赤坂 ',
|
|
166
|
-
en: 'CineMotion Akasaka'
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
serviceType: {
|
|
172
|
-
codeValue: '0001',
|
|
173
|
-
id: '5e3361d01dc1ef1a20dd8737',
|
|
174
|
-
inCodeSet: {
|
|
175
|
-
typeOf: 'CategoryCodeSet',
|
|
176
|
-
identifier: chevre.factory.categoryCode.CategorySetIdentifier.ServiceType
|
|
177
|
-
},
|
|
178
|
-
typeOf: 'CategoryCode'
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
validFrom: moment('2023-01-29T15:00:00.000Z')
|
|
182
|
-
.toDate(),
|
|
183
|
-
validThrough: moment('2023-02-01T01:20:00.000Z')
|
|
184
|
-
.toDate(),
|
|
185
|
-
seller: {
|
|
186
|
-
typeOf: chevre.factory.organizationType.Corporation,
|
|
187
|
-
id: '59d20831e53ebc2b4e774466',
|
|
188
|
-
name: {
|
|
189
|
-
ja: 'シネモーション赤坂',
|
|
190
|
-
en: 'CineMotion Akasaka'
|
|
191
|
-
},
|
|
192
|
-
makesOffer: []
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
filter: { name: filterName }
|
|
197
|
-
}
|
|
198
|
-
]);
|
|
199
|
-
console.log(result);
|
|
200
|
-
console.log('upsertedIds:', (Array.isArray(result?.getUpsertedIds()))
|
|
201
|
-
? result?.getUpsertedIds()
|
|
202
|
-
.map((u: any) => u._id)
|
|
203
|
-
: []);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
main()
|
|
207
|
-
.then(console.log)
|
|
208
|
-
.catch(console.error);
|
|
@@ -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);
|