@chevre/domain 21.28.0-alpha.9 → 21.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/playAroundProductModel.ts +64 -0
- package/example/src/chevre/searchCustomerTypes.ts +57 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +14 -10
- package/lib/chevre/repo/aggregateOffer.d.ts +5 -1
- package/lib/chevre/repo/aggregateOffer.js +6 -0
- package/lib/chevre/repo/categoryCode.d.ts +6 -1
- package/lib/chevre/repo/categoryCode.js +6 -15
- package/lib/chevre/repo/customerType.d.ts +22 -0
- package/lib/chevre/repo/customerType.js +105 -0
- package/lib/chevre/repo/mongoose/schemas/customerType.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/customerType.js +66 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +22 -38
- package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/productModel.js +68 -0
- package/lib/chevre/repo/paymentService.d.ts +0 -3
- package/lib/chevre/repo/paymentService.js +1 -45
- package/lib/chevre/repo/product.d.ts +4 -0
- package/lib/chevre/repo/product.js +6 -0
- package/lib/chevre/repo/productModel.d.ts +61 -0
- package/lib/chevre/repo/productModel.js +138 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/pay.js +6 -1
- package/lib/chevre/service/offer/event/authorize.js +18 -1
- package/package.json +3 -3
- package/example/src/chevre/deleteOldPaymentServices.ts +0 -18
- package/example/src/chevre/migratePaymentServicesToNewCollection.ts +0 -21
- package/example/src/chevre/playAroundProjectMakesOffer.ts +0 -47
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const productModelRepo = await chevre.repository.ProductModel.createInstance(mongoose.connection);
|
|
12
|
+
const result = await productModelRepo.search(
|
|
13
|
+
{
|
|
14
|
+
limit: 100,
|
|
15
|
+
page: 1,
|
|
16
|
+
category: {
|
|
17
|
+
codeValue: { $in: ['Premium'] },
|
|
18
|
+
inCodeSet: { identifier: { $eq: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
[],
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
console.log('result:', result);
|
|
25
|
+
|
|
26
|
+
const productModel = {
|
|
27
|
+
project: {
|
|
28
|
+
id: project.id,
|
|
29
|
+
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
30
|
+
},
|
|
31
|
+
typeOf: <'ProductModel'>'ProductModel',
|
|
32
|
+
category: {
|
|
33
|
+
codeValue: 'Premium',
|
|
34
|
+
inCodeSet: {
|
|
35
|
+
identifier: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType,
|
|
36
|
+
typeOf: <'CategoryCodeSet'>'CategoryCodeSet'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
name: { ja: 'プレミアムシート' },
|
|
40
|
+
offers: [{
|
|
41
|
+
typeOf: <chevre.factory.offerType.Offer>chevre.factory.offerType.Offer
|
|
42
|
+
}]
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const createdModel = await productModelRepo.save({
|
|
46
|
+
$set: productModel
|
|
47
|
+
});
|
|
48
|
+
console.log('created. id:', createdModel);
|
|
49
|
+
|
|
50
|
+
await productModelRepo.save({
|
|
51
|
+
id: createdModel.id,
|
|
52
|
+
$set: productModel
|
|
53
|
+
});
|
|
54
|
+
console.log('updated. id:', createdModel.id);
|
|
55
|
+
|
|
56
|
+
await productModelRepo.deleteById({
|
|
57
|
+
id: createdModel.id
|
|
58
|
+
});
|
|
59
|
+
console.log('deleted. id:', createdModel.id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then(console.log)
|
|
64
|
+
.catch(console.error);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const customerTypeRepo = await chevre.repository.CustomerType.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const saveResult = await customerTypeRepo.saveManyByCodeValue([
|
|
14
|
+
{
|
|
15
|
+
attributes: {
|
|
16
|
+
typeOf: 'CategoryCode',
|
|
17
|
+
codeValue: 'Enduser',
|
|
18
|
+
name: { ja: 'エンドユーザー' }
|
|
19
|
+
},
|
|
20
|
+
upsert: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
attributes: {
|
|
24
|
+
typeOf: 'CategoryCode',
|
|
25
|
+
codeValue: 'POS',
|
|
26
|
+
name: { ja: 'POS' }
|
|
27
|
+
},
|
|
28
|
+
upsert: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
attributes: {
|
|
32
|
+
typeOf: 'CategoryCode',
|
|
33
|
+
codeValue: 'TVM',
|
|
34
|
+
name: { ja: '券売機' }
|
|
35
|
+
},
|
|
36
|
+
upsert: true
|
|
37
|
+
}
|
|
38
|
+
]);
|
|
39
|
+
console.log('saved,', saveResult);
|
|
40
|
+
|
|
41
|
+
const categoryCodes = await customerTypeRepo.search(
|
|
42
|
+
{
|
|
43
|
+
limit: 100,
|
|
44
|
+
page: 1,
|
|
45
|
+
sort: { codeValue: chevre.factory.sortType.Ascending },
|
|
46
|
+
codeValue: { $eq: 'Enduser' }
|
|
47
|
+
},
|
|
48
|
+
[],
|
|
49
|
+
[]
|
|
50
|
+
);
|
|
51
|
+
console.log('categoryCodes found', categoryCodes);
|
|
52
|
+
console.log(categoryCodes.length, 'categoryCodes found');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then()
|
|
57
|
+
.catch(console.error);
|
|
@@ -8,18 +8,22 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
let updateResult: any;
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
updateResult = await
|
|
11
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
12
|
+
updateResult = await productRepo.unsetUnnecessaryFields({
|
|
13
13
|
filter: {
|
|
14
|
-
|
|
15
|
-
$in: [
|
|
16
|
-
chevre.factory.eventType.ScreeningEvent
|
|
17
|
-
]
|
|
18
|
-
}
|
|
14
|
+
'serviceType.project': { $exists: true }
|
|
19
15
|
},
|
|
20
|
-
$unset:
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
$unset: {
|
|
17
|
+
'serviceType.project': 1
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
console.log('unset processed.', updateResult);
|
|
21
|
+
updateResult = await productRepo.unsetUnnecessaryFields({
|
|
22
|
+
filter: {
|
|
23
|
+
provider: { $exists: true }
|
|
24
|
+
},
|
|
25
|
+
$unset: {
|
|
26
|
+
provider: 1
|
|
23
27
|
}
|
|
24
28
|
});
|
|
25
29
|
console.log('unset processed.', updateResult);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
1
|
+
import type { AnyExpression, Connection, FilterQuery, PipelineStage } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
type IMatchStage = PipelineStage.Match;
|
|
4
4
|
type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
|
|
@@ -69,5 +69,9 @@ export declare class MongoRepository {
|
|
|
69
69
|
* 単価オファー最適化作業における一時的な処理
|
|
70
70
|
*/
|
|
71
71
|
optimizeOffers(): Promise<import("mongodb").UpdateResult>;
|
|
72
|
+
unsetUnnecessaryFields(params: {
|
|
73
|
+
filter: FilterQuery<factory.aggregateOffer.IAggregateOffer>;
|
|
74
|
+
$unset: any;
|
|
75
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
72
76
|
}
|
|
73
77
|
export {};
|
|
@@ -588,5 +588,11 @@ class MongoRepository {
|
|
|
588
588
|
.exec();
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
|
+
unsetUnnecessaryFields(params) {
|
|
592
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
593
|
+
return this.aggregateOfferModel.updateMany(params.filter, { $unset: params.$unset })
|
|
594
|
+
.exec();
|
|
595
|
+
});
|
|
596
|
+
}
|
|
591
597
|
}
|
|
592
598
|
exports.MongoRepository = MongoRepository;
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode | '_id';
|
|
28
|
+
type IUnset = {
|
|
29
|
+
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
|
|
30
|
+
};
|
|
28
31
|
/**
|
|
29
32
|
* 区分リポジトリ
|
|
30
33
|
*/
|
|
@@ -45,7 +48,9 @@ export declare class MongoRepository {
|
|
|
45
48
|
search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
46
49
|
save(params: {
|
|
47
50
|
id?: string;
|
|
48
|
-
attributes: factory.categoryCode.ICategoryCode
|
|
51
|
+
attributes: factory.categoryCode.ICategoryCode & {
|
|
52
|
+
$unset?: IUnset;
|
|
53
|
+
};
|
|
49
54
|
}): Promise<factory.categoryCode.ICategoryCode>;
|
|
50
55
|
saveManyByCodeValue(params: {
|
|
51
56
|
attributes: factory.categoryCode.ICategoryCode;
|
|
@@ -83,21 +83,11 @@ class MongoRepository {
|
|
|
83
83
|
}
|
|
84
84
|
const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
85
85
|
if (typeof codeValueEq === 'string') {
|
|
86
|
-
andConditions.push({
|
|
87
|
-
codeValue: {
|
|
88
|
-
$exists: true,
|
|
89
|
-
$eq: codeValueEq
|
|
90
|
-
}
|
|
91
|
-
});
|
|
86
|
+
andConditions.push({ codeValue: { $eq: codeValueEq } });
|
|
92
87
|
}
|
|
93
88
|
const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
|
|
94
89
|
if (Array.isArray(codeValueIn)) {
|
|
95
|
-
andConditions.push({
|
|
96
|
-
codeValue: {
|
|
97
|
-
$exists: true,
|
|
98
|
-
$in: codeValueIn
|
|
99
|
-
}
|
|
100
|
-
});
|
|
90
|
+
andConditions.push({ codeValue: { $in: codeValueIn } });
|
|
101
91
|
}
|
|
102
92
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
103
93
|
/* istanbul ignore else */
|
|
@@ -259,12 +249,13 @@ class MongoRepository {
|
|
|
259
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
260
250
|
let doc;
|
|
261
251
|
if (typeof params.id !== 'string') {
|
|
262
|
-
|
|
252
|
+
const _a = params.attributes, { id, $unset } = _a, creatingDoc = __rest(_a, ["id", "$unset"]);
|
|
253
|
+
doc = yield this.categoryCodeModel.create(creatingDoc);
|
|
263
254
|
}
|
|
264
255
|
else {
|
|
265
256
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
266
|
-
const
|
|
267
|
-
doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
257
|
+
const _b = params.attributes, { id, codeValue, inCodeSet, project, typeOf, $unset } = _b, updateFields = __rest(_b, ["id", "codeValue", "inCodeSet", "project", "typeOf", "$unset"]);
|
|
258
|
+
doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true })
|
|
268
259
|
.exec();
|
|
269
260
|
}
|
|
270
261
|
if (doc === null) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
type ICustomerType = Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'id' | 'name' | 'typeOf'>;
|
|
5
|
+
type IKeyOfProjection = keyof ICustomerType | '_id';
|
|
6
|
+
/**
|
|
7
|
+
* カスタマータイプリポジトリ
|
|
8
|
+
*/
|
|
9
|
+
export declare class MongoRepository {
|
|
10
|
+
private readonly customerTypeModel;
|
|
11
|
+
constructor(connection: Connection);
|
|
12
|
+
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<ICustomerType>[];
|
|
13
|
+
/**
|
|
14
|
+
* 検索
|
|
15
|
+
*/
|
|
16
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<ICustomerType[]>;
|
|
17
|
+
saveManyByCodeValue(params: {
|
|
18
|
+
attributes: ICustomerType;
|
|
19
|
+
upsert?: boolean;
|
|
20
|
+
}[]): Promise<BulkWriteResult | void>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
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.MongoRepository = void 0;
|
|
13
|
+
const customerType_1 = require("./mongoose/schemas/customerType");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
/**
|
|
16
|
+
* カスタマータイプリポジトリ
|
|
17
|
+
*/
|
|
18
|
+
class MongoRepository {
|
|
19
|
+
constructor(connection) {
|
|
20
|
+
this.customerTypeModel = connection.model(customerType_1.modelName, (0, customerType_1.createSchema)());
|
|
21
|
+
}
|
|
22
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
23
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const andConditions = [];
|
|
26
|
+
const codeValueEq = (_a = params.codeValue) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
27
|
+
if (typeof codeValueEq === 'string') {
|
|
28
|
+
andConditions.push({ codeValue: { $exists: true, $eq: codeValueEq } });
|
|
29
|
+
}
|
|
30
|
+
const codeValueIn = (_b = params.codeValue) === null || _b === void 0 ? void 0 : _b.$in;
|
|
31
|
+
if (Array.isArray(codeValueIn)) {
|
|
32
|
+
andConditions.push({ codeValue: { $exists: true, $in: codeValueIn } });
|
|
33
|
+
}
|
|
34
|
+
return andConditions;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 検索
|
|
38
|
+
*/
|
|
39
|
+
search(params, inclusion, exclusion) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
42
|
+
let projection = {};
|
|
43
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
44
|
+
inclusion.forEach((field) => {
|
|
45
|
+
projection[field] = 1;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
projection = {
|
|
50
|
+
__v: 0,
|
|
51
|
+
createdAt: 0,
|
|
52
|
+
updatedAt: 0
|
|
53
|
+
};
|
|
54
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
55
|
+
exclusion.forEach((field) => {
|
|
56
|
+
projection[field] = 0;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const query = this.customerTypeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
61
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
62
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
63
|
+
query.limit(params.limit)
|
|
64
|
+
.skip(params.limit * (page - 1));
|
|
65
|
+
}
|
|
66
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
67
|
+
/* istanbul ignore else */
|
|
68
|
+
if (params.sort !== undefined) {
|
|
69
|
+
query.sort(params.sort);
|
|
70
|
+
}
|
|
71
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
72
|
+
.exec()
|
|
73
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
saveManyByCodeValue(params) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const bulkWriteOps = [];
|
|
79
|
+
if (Array.isArray(params)) {
|
|
80
|
+
params.forEach((p) => {
|
|
81
|
+
const $set = Object.assign({}, p.attributes);
|
|
82
|
+
if (typeof $set.id === 'string') {
|
|
83
|
+
delete $set.id;
|
|
84
|
+
}
|
|
85
|
+
bulkWriteOps.push({
|
|
86
|
+
updateOne: {
|
|
87
|
+
filter: {
|
|
88
|
+
codeValue: { $eq: p.attributes.codeValue }
|
|
89
|
+
},
|
|
90
|
+
update: {
|
|
91
|
+
$set
|
|
92
|
+
// $setOnInsert: {}
|
|
93
|
+
},
|
|
94
|
+
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (bulkWriteOps.length > 0) {
|
|
100
|
+
return this.customerTypeModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchema = exports.indexes = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'CustomerType';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
typeOf: { type: String, required: true },
|
|
11
|
+
codeValue: { type: String, required: true },
|
|
12
|
+
name: mongoose_1.SchemaTypes.Mixed
|
|
13
|
+
};
|
|
14
|
+
const schemaOptions = {
|
|
15
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
16
|
+
autoCreate: false,
|
|
17
|
+
collection: 'customerTypes',
|
|
18
|
+
id: true,
|
|
19
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
20
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
21
|
+
strict: true,
|
|
22
|
+
strictQuery: false,
|
|
23
|
+
timestamps: {
|
|
24
|
+
createdAt: 'createdAt',
|
|
25
|
+
updatedAt: 'updatedAt'
|
|
26
|
+
},
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const indexes = [
|
|
41
|
+
[
|
|
42
|
+
{ createdAt: 1 },
|
|
43
|
+
{ name: 'searchByCreatedAt' }
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
{ updatedAt: 1 },
|
|
47
|
+
{ name: 'searchByUpdatedAt' }
|
|
48
|
+
]
|
|
49
|
+
];
|
|
50
|
+
exports.indexes = indexes;
|
|
51
|
+
/**
|
|
52
|
+
* カスタマータイプスキーマ
|
|
53
|
+
*/
|
|
54
|
+
let schema;
|
|
55
|
+
function createSchema() {
|
|
56
|
+
if (schema === undefined) {
|
|
57
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
58
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
59
|
+
indexes.forEach((indexParams) => {
|
|
60
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
exports.createSchema = createSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Product";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|
|
@@ -8,21 +8,15 @@ const modelName = 'Product';
|
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
10
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
-
typeOf: {
|
|
12
|
-
type: String,
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
15
12
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
16
13
|
availableChannel: mongoose_1.SchemaTypes.Mixed,
|
|
17
14
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
18
15
|
hasOfferCatalog: mongoose_1.SchemaTypes.Mixed,
|
|
19
16
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
20
17
|
offers: [mongoose_1.SchemaTypes.Mixed],
|
|
21
|
-
productID: {
|
|
22
|
-
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
25
|
-
provider: [mongoose_1.SchemaTypes.Mixed],
|
|
18
|
+
productID: { type: String, required: true },
|
|
19
|
+
// provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
|
|
26
20
|
serviceOutput: mongoose_1.SchemaTypes.Mixed,
|
|
27
21
|
serviceType: mongoose_1.SchemaTypes.Mixed
|
|
28
22
|
};
|
|
@@ -52,17 +46,6 @@ const schemaOptions = {
|
|
|
52
46
|
versionKey: false
|
|
53
47
|
}
|
|
54
48
|
};
|
|
55
|
-
/**
|
|
56
|
-
* プロダクトスキーマ
|
|
57
|
-
*/
|
|
58
|
-
let schema;
|
|
59
|
-
function createSchema() {
|
|
60
|
-
if (schema === undefined) {
|
|
61
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
62
|
-
}
|
|
63
|
-
return schema;
|
|
64
|
-
}
|
|
65
|
-
exports.createSchema = createSchema;
|
|
66
49
|
const indexes = [
|
|
67
50
|
[
|
|
68
51
|
{ createdAt: 1 },
|
|
@@ -74,15 +57,11 @@ const indexes = [
|
|
|
74
57
|
],
|
|
75
58
|
[
|
|
76
59
|
{ productID: 1 },
|
|
77
|
-
{
|
|
78
|
-
name: 'searchByProductID'
|
|
79
|
-
}
|
|
60
|
+
{ name: 'searchByProductID' }
|
|
80
61
|
],
|
|
81
62
|
[
|
|
82
63
|
{ 'project.id': 1, productID: 1 },
|
|
83
|
-
{
|
|
84
|
-
name: 'searchByProjectId-v20220721'
|
|
85
|
-
}
|
|
64
|
+
{ name: 'searchByProjectId-v20220721' }
|
|
86
65
|
],
|
|
87
66
|
[
|
|
88
67
|
{ 'hasOfferCatalog.id': 1, productID: 1 },
|
|
@@ -122,9 +101,7 @@ const indexes = [
|
|
|
122
101
|
],
|
|
123
102
|
[
|
|
124
103
|
{ typeOf: 1, productID: 1 },
|
|
125
|
-
{
|
|
126
|
-
name: 'searchByTypeOf'
|
|
127
|
-
}
|
|
104
|
+
{ name: 'searchByTypeOf' }
|
|
128
105
|
],
|
|
129
106
|
[
|
|
130
107
|
{ 'name.ja': 1, productID: 1 },
|
|
@@ -143,15 +120,22 @@ const indexes = [
|
|
|
143
120
|
'name.en': { $exists: true }
|
|
144
121
|
}
|
|
145
122
|
}
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
{ 'provider.id': 1, productID: 1 },
|
|
149
|
-
{
|
|
150
|
-
name: 'searchByProviderId',
|
|
151
|
-
partialFilterExpression: {
|
|
152
|
-
'provider.id': { $exists: true }
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
123
|
]
|
|
156
124
|
];
|
|
157
125
|
exports.indexes = indexes;
|
|
126
|
+
/**
|
|
127
|
+
* プロダクトスキーマ
|
|
128
|
+
*/
|
|
129
|
+
let schema;
|
|
130
|
+
function createSchema() {
|
|
131
|
+
if (schema === undefined) {
|
|
132
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
133
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
134
|
+
indexes.forEach((indexParams) => {
|
|
135
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return schema;
|
|
140
|
+
}
|
|
141
|
+
exports.createSchema = createSchema;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchema = exports.indexes = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'ProductModel';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
12
|
+
category: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
+
offers: mongoose_1.SchemaTypes.Mixed
|
|
15
|
+
};
|
|
16
|
+
const schemaOptions = {
|
|
17
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
18
|
+
autoCreate: false,
|
|
19
|
+
collection: 'productModels',
|
|
20
|
+
id: true,
|
|
21
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
22
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
23
|
+
strict: true,
|
|
24
|
+
strictQuery: false,
|
|
25
|
+
timestamps: {
|
|
26
|
+
createdAt: 'createdAt',
|
|
27
|
+
updatedAt: 'updatedAt'
|
|
28
|
+
},
|
|
29
|
+
toJSON: {
|
|
30
|
+
getters: false,
|
|
31
|
+
virtuals: false,
|
|
32
|
+
minimize: false,
|
|
33
|
+
versionKey: false
|
|
34
|
+
},
|
|
35
|
+
toObject: {
|
|
36
|
+
getters: false,
|
|
37
|
+
virtuals: true,
|
|
38
|
+
minimize: false,
|
|
39
|
+
versionKey: false
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const indexes = [
|
|
43
|
+
[
|
|
44
|
+
{ createdAt: 1 },
|
|
45
|
+
{ name: 'searchByCreatedAt' }
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
{ updatedAt: 1 },
|
|
49
|
+
{ name: 'searchByUpdatedAt' }
|
|
50
|
+
]
|
|
51
|
+
];
|
|
52
|
+
exports.indexes = indexes;
|
|
53
|
+
/**
|
|
54
|
+
* プロダクトモデルスキーマ
|
|
55
|
+
*/
|
|
56
|
+
let schema;
|
|
57
|
+
function createSchema() {
|
|
58
|
+
if (schema === undefined) {
|
|
59
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
60
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
61
|
+
indexes.forEach((indexParams) => {
|
|
62
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
exports.createSchema = createSchema;
|
|
@@ -11,7 +11,6 @@ type ISearchConditions4paymentService = factory.service.paymentService.ISearchCo
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class MongoRepository {
|
|
13
13
|
private readonly paymentServiceModel;
|
|
14
|
-
private readonly productModel;
|
|
15
14
|
constructor(connection: Connection);
|
|
16
15
|
static CREATE_MONGO_CONDITIONS(params: ISearchConditions4paymentService): FilterQuery<import("@chevre/factory/lib/service/paymentService").IService>[];
|
|
17
16
|
/**
|
|
@@ -52,7 +51,5 @@ export declare class MongoRepository {
|
|
|
52
51
|
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard | factory.service.paymentService.PaymentServiceType.MovieTicket;
|
|
53
52
|
id: string;
|
|
54
53
|
}): Promise<factory.product.IAvailableChannel>;
|
|
55
|
-
migratePaymentServicesToNewCollection(): Promise<void>;
|
|
56
|
-
deleteOldPaymentServices(): Promise<import("mongodb").DeleteResult>;
|
|
57
54
|
}
|
|
58
55
|
export {};
|
|
@@ -21,17 +21,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
|
-
const paymentService_1 = require("./mongoose/schemas/paymentService");
|
|
25
|
-
const product_1 = require("./mongoose/schemas/product");
|
|
26
24
|
const factory = require("../factory");
|
|
27
25
|
const settings_1 = require("../settings");
|
|
26
|
+
const paymentService_1 = require("./mongoose/schemas/paymentService");
|
|
28
27
|
/**
|
|
29
28
|
* 決済サービスリポジトリ
|
|
30
29
|
*/
|
|
31
30
|
class MongoRepository {
|
|
32
31
|
constructor(connection) {
|
|
33
32
|
this.paymentServiceModel = connection.model(paymentService_1.modelName, (0, paymentService_1.createSchema)());
|
|
34
|
-
this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
|
|
35
33
|
}
|
|
36
34
|
// tslint:disable-next-line:max-func-body-length
|
|
37
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
@@ -266,47 +264,5 @@ class MongoRepository {
|
|
|
266
264
|
return availableChannel;
|
|
267
265
|
});
|
|
268
266
|
}
|
|
269
|
-
migratePaymentServicesToNewCollection() {
|
|
270
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
-
const cursor = this.productModel.find({
|
|
272
|
-
typeOf: {
|
|
273
|
-
$in: [
|
|
274
|
-
factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
275
|
-
factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
276
|
-
]
|
|
277
|
-
}
|
|
278
|
-
// _id: { $eq: 'xxx' }
|
|
279
|
-
})
|
|
280
|
-
.cursor();
|
|
281
|
-
let i = 0;
|
|
282
|
-
yield cursor.eachAsync((doc) => __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
i += 1;
|
|
284
|
-
const existingPaymentService = doc.toObject();
|
|
285
|
-
const { _id, id, createdAt, updatedAt, offers } = existingPaymentService, setFields = __rest(existingPaymentService, ["_id", "id", "createdAt", "updatedAt", "offers"]);
|
|
286
|
-
// tslint:disable-next-line:no-console
|
|
287
|
-
// console.log('migrating paymentService...', setFields, id, i);
|
|
288
|
-
yield this.paymentServiceModel.findByIdAndUpdate(id, {
|
|
289
|
-
// $setOnInsert: { _id },
|
|
290
|
-
$set: setFields
|
|
291
|
-
}, { upsert: true })
|
|
292
|
-
.exec();
|
|
293
|
-
// tslint:disable-next-line:no-console
|
|
294
|
-
console.log('paymentService migrated.', i);
|
|
295
|
-
}));
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
deleteOldPaymentServices() {
|
|
299
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
-
return this.productModel.deleteMany({
|
|
301
|
-
typeOf: {
|
|
302
|
-
$in: [
|
|
303
|
-
factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
304
|
-
factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
305
|
-
]
|
|
306
|
-
}
|
|
307
|
-
})
|
|
308
|
-
.exec();
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
267
|
}
|
|
312
268
|
exports.MongoRepository = MongoRepository;
|
|
@@ -109,5 +109,9 @@ export declare class MongoRepository {
|
|
|
109
109
|
};
|
|
110
110
|
}): Promise<void>;
|
|
111
111
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
112
|
+
unsetUnnecessaryFields(params: {
|
|
113
|
+
filter: FilterQuery<factory.product.IProduct>;
|
|
114
|
+
$unset: any;
|
|
115
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
112
116
|
}
|
|
113
117
|
export {};
|
|
@@ -342,5 +342,11 @@ class MongoRepository {
|
|
|
342
342
|
.sort({ productID: factory.sortType.Ascending })
|
|
343
343
|
.cursor();
|
|
344
344
|
}
|
|
345
|
+
unsetUnnecessaryFields(params) {
|
|
346
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
+
return this.productModel.updateMany(params.filter, { $unset: params.$unset })
|
|
348
|
+
.exec();
|
|
349
|
+
});
|
|
350
|
+
}
|
|
345
351
|
}
|
|
346
352
|
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
interface IProductModel {
|
|
4
|
+
id?: string;
|
|
5
|
+
project: {
|
|
6
|
+
id: string;
|
|
7
|
+
typeOf: factory.organizationType.Project;
|
|
8
|
+
};
|
|
9
|
+
typeOf: 'ProductModel';
|
|
10
|
+
category: Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'inCodeSet'>;
|
|
11
|
+
name: factory.multilingualString;
|
|
12
|
+
offers: {
|
|
13
|
+
typeOf: factory.offerType.Offer;
|
|
14
|
+
eligibleCustomerType?: {
|
|
15
|
+
codeValue: string;
|
|
16
|
+
}[];
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
type IKeyOfProjection = keyof IProductModel | '_id';
|
|
20
|
+
type ISearchConditions = Pick<factory.product.ISearchConditions, 'id' | 'limit' | 'page' | 'project'> & {
|
|
21
|
+
category?: {
|
|
22
|
+
codeValue?: {
|
|
23
|
+
$in?: string[];
|
|
24
|
+
};
|
|
25
|
+
inCodeSet?: {
|
|
26
|
+
identifier?: {
|
|
27
|
+
$eq?: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* プロダクトモデルリポジトリ
|
|
34
|
+
*/
|
|
35
|
+
export declare class MongoRepository {
|
|
36
|
+
private readonly productModelModel;
|
|
37
|
+
constructor(connection: Connection);
|
|
38
|
+
static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<factory.product.IProduct>[];
|
|
39
|
+
search(conditions: ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<IProductModel[]>;
|
|
40
|
+
deleteById(params: {
|
|
41
|
+
id: string;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* プロダクトを保管する
|
|
45
|
+
*/
|
|
46
|
+
save(params: {
|
|
47
|
+
/**
|
|
48
|
+
* idを指定すれば更新
|
|
49
|
+
*/
|
|
50
|
+
id?: string;
|
|
51
|
+
$set: IProductModel;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
id: string;
|
|
54
|
+
}>;
|
|
55
|
+
deleteByProject(params: {
|
|
56
|
+
project: {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.MongoRepository = void 0;
|
|
24
|
+
const factory = require("../factory");
|
|
25
|
+
const settings_1 = require("../settings");
|
|
26
|
+
const productModel_1 = require("./mongoose/schemas/productModel");
|
|
27
|
+
/**
|
|
28
|
+
* プロダクトモデルリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class MongoRepository {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.productModelModel = connection.model(productModel_1.modelName, (0, productModel_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
37
|
+
// MongoDB検索条件
|
|
38
|
+
const andConditions = [];
|
|
39
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
|
+
if (typeof projectIdEq === 'string') {
|
|
41
|
+
andConditions.push({
|
|
42
|
+
'project.id': { $eq: projectIdEq }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
46
|
+
if (typeof idEq === 'string') {
|
|
47
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
48
|
+
}
|
|
49
|
+
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
50
|
+
if (Array.isArray(idIn)) {
|
|
51
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
52
|
+
}
|
|
53
|
+
const categoryCodeValueIn = (_f = (_e = params.category) === null || _e === void 0 ? void 0 : _e.codeValue) === null || _f === void 0 ? void 0 : _f.$in;
|
|
54
|
+
if (Array.isArray(categoryCodeValueIn)) {
|
|
55
|
+
andConditions.push({ 'category.codeValue': { $exists: true, $in: categoryCodeValueIn } });
|
|
56
|
+
}
|
|
57
|
+
const categoryInCodeSetIdentifierEq = (_j = (_h = (_g = params.category) === null || _g === void 0 ? void 0 : _g.inCodeSet) === null || _h === void 0 ? void 0 : _h.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
58
|
+
if (typeof categoryInCodeSetIdentifierEq === 'string') {
|
|
59
|
+
andConditions.push({ 'category.inCodeSet.identifier': { $exists: true, $eq: categoryInCodeSetIdentifierEq } });
|
|
60
|
+
}
|
|
61
|
+
return andConditions;
|
|
62
|
+
}
|
|
63
|
+
search(conditions, inclusion, exclusion) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
|
|
66
|
+
let projection = {};
|
|
67
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
68
|
+
inclusion.forEach((field) => {
|
|
69
|
+
projection[field] = 1;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
projection = {
|
|
74
|
+
__v: 0,
|
|
75
|
+
createdAt: 0,
|
|
76
|
+
updatedAt: 0
|
|
77
|
+
};
|
|
78
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
79
|
+
exclusion.forEach((field) => {
|
|
80
|
+
projection[field] = 0;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const query = this.productModelModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
85
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
86
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
87
|
+
query.limit(conditions.limit)
|
|
88
|
+
.skip(conditions.limit * (page - 1));
|
|
89
|
+
}
|
|
90
|
+
// if (conditions.sort?.productID !== undefined) {
|
|
91
|
+
// query.sort({ productID: conditions.sort.productID });
|
|
92
|
+
// }
|
|
93
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
94
|
+
.exec()
|
|
95
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
deleteById(params) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
yield this.productModelModel.findOneAndDelete({ _id: params.id })
|
|
101
|
+
.exec();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* プロダクトを保管する
|
|
106
|
+
*/
|
|
107
|
+
save(params) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
let doc;
|
|
110
|
+
if (typeof params.id === 'string') {
|
|
111
|
+
// 上書き禁止属性を除外
|
|
112
|
+
const _a = params.$set, { id, project, typeOf, offers } = _a, setFields = __rest(_a, ["id", "project", "typeOf", "offers"]);
|
|
113
|
+
doc = yield this.productModelModel.findOneAndUpdate({ _id: { $eq: params.id } }, {
|
|
114
|
+
$set: setFields
|
|
115
|
+
// $unset: params.$unset
|
|
116
|
+
}, { upsert: false, new: true, projection: { _id: 1 } })
|
|
117
|
+
.exec();
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
|
|
121
|
+
doc = yield this.productModelModel.create(createParams);
|
|
122
|
+
}
|
|
123
|
+
if (doc === null) {
|
|
124
|
+
throw new factory.errors.NotFound(this.productModelModel.modelName);
|
|
125
|
+
}
|
|
126
|
+
return doc.toObject();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
deleteByProject(params) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
yield this.productModelModel.deleteMany({
|
|
132
|
+
'project.id': { $eq: params.project.id }
|
|
133
|
+
})
|
|
134
|
+
.exec();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -17,6 +17,7 @@ import type { MongoRepository as CodeRepo } from './repo/code';
|
|
|
17
17
|
import type { MongoRepository as CommentRepo } from './repo/comment';
|
|
18
18
|
import type { MongoRepository as CreativeWorkRepo } from './repo/creativeWork';
|
|
19
19
|
import type { MongoRepository as CustomerRepo } from './repo/customer';
|
|
20
|
+
import type { MongoRepository as CustomerTypeRepo } from './repo/customerType';
|
|
20
21
|
import type { MongoRepository as EmailMessageRepo } from './repo/emailMessage';
|
|
21
22
|
import type { MongoRepository as EventRepo } from './repo/event';
|
|
22
23
|
import type { MongoRepository as MemberRepo } from './repo/member';
|
|
@@ -40,6 +41,7 @@ import type { MongoRepository as SeatRepo } from './repo/place/seat';
|
|
|
40
41
|
import type { MongoRepository as SectionRepo } from './repo/place/section';
|
|
41
42
|
import type { MongoRepository as PriceSpecificationRepo } from './repo/priceSpecification';
|
|
42
43
|
import type { MongoRepository as ProductRepo } from './repo/product';
|
|
44
|
+
import type { MongoRepository as ProductModelRepo } from './repo/productModel';
|
|
43
45
|
import type { MongoRepository as ProductOfferRepo } from './repo/productOffer';
|
|
44
46
|
import type { MongoRepository as ProjectRepo } from './repo/project';
|
|
45
47
|
import type { MongoRepository as ProjectMakesOfferRepo } from './repo/projectMakesOffer';
|
|
@@ -128,6 +130,10 @@ export type Customer = CustomerRepo;
|
|
|
128
130
|
export declare namespace Customer {
|
|
129
131
|
function createInstance(...params: ConstructorParameters<typeof CustomerRepo>): Promise<CustomerRepo>;
|
|
130
132
|
}
|
|
133
|
+
export type CustomerType = CustomerTypeRepo;
|
|
134
|
+
export declare namespace CustomerType {
|
|
135
|
+
function createInstance(...params: ConstructorParameters<typeof CustomerTypeRepo>): Promise<CustomerTypeRepo>;
|
|
136
|
+
}
|
|
131
137
|
export type EmailMessage = EmailMessageRepo;
|
|
132
138
|
export declare namespace EmailMessage {
|
|
133
139
|
function createInstance(...params: ConstructorParameters<typeof EmailMessageRepo>): Promise<EmailMessageRepo>;
|
|
@@ -257,6 +263,10 @@ export type Product = ProductRepo;
|
|
|
257
263
|
export declare namespace Product {
|
|
258
264
|
function createInstance(...params: ConstructorParameters<typeof ProductRepo>): Promise<ProductRepo>;
|
|
259
265
|
}
|
|
266
|
+
export type ProductModel = ProductModelRepo;
|
|
267
|
+
export declare namespace ProductModel {
|
|
268
|
+
function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
|
|
269
|
+
}
|
|
260
270
|
export type ProductOffer = ProductOfferRepo;
|
|
261
271
|
export declare namespace ProductOffer {
|
|
262
272
|
function createInstance(...params: ConstructorParameters<typeof ProductOfferRepo>): Promise<ProductOfferRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = void 0;
|
|
12
|
+
exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -232,6 +232,19 @@ var Customer;
|
|
|
232
232
|
}
|
|
233
233
|
Customer.createInstance = createInstance;
|
|
234
234
|
})(Customer = exports.Customer || (exports.Customer = {}));
|
|
235
|
+
var CustomerType;
|
|
236
|
+
(function (CustomerType) {
|
|
237
|
+
let repo;
|
|
238
|
+
function createInstance(...params) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
if (repo === undefined) {
|
|
241
|
+
repo = (yield Promise.resolve().then(() => require('./repo/customerType'))).MongoRepository;
|
|
242
|
+
}
|
|
243
|
+
return new repo(...params);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
CustomerType.createInstance = createInstance;
|
|
247
|
+
})(CustomerType = exports.CustomerType || (exports.CustomerType = {}));
|
|
235
248
|
var EmailMessage;
|
|
236
249
|
(function (EmailMessage) {
|
|
237
250
|
let repo;
|
|
@@ -594,6 +607,19 @@ var Product;
|
|
|
594
607
|
}
|
|
595
608
|
Product.createInstance = createInstance;
|
|
596
609
|
})(Product = exports.Product || (exports.Product = {}));
|
|
610
|
+
var ProductModel;
|
|
611
|
+
(function (ProductModel) {
|
|
612
|
+
let repo;
|
|
613
|
+
function createInstance(...params) {
|
|
614
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
615
|
+
if (repo === undefined) {
|
|
616
|
+
repo = (yield Promise.resolve().then(() => require('./repo/productModel'))).MongoRepository;
|
|
617
|
+
}
|
|
618
|
+
return new repo(...params);
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
ProductModel.createInstance = createInstance;
|
|
622
|
+
})(ProductModel = exports.ProductModel || (exports.ProductModel = {}));
|
|
597
623
|
var ProductOffer;
|
|
598
624
|
(function (ProductOffer) {
|
|
599
625
|
let repo;
|
|
@@ -345,12 +345,17 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId, optio
|
|
|
345
345
|
function processAuthorizeMovieTicket(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet) {
|
|
346
346
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
347
347
|
const { accountId, payAction, accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
|
|
348
|
+
const payActionInObject = {
|
|
349
|
+
actionStatus: payAction.actionStatus,
|
|
350
|
+
id: payAction.id,
|
|
351
|
+
typeOf: payAction.typeOf
|
|
352
|
+
};
|
|
348
353
|
return saveAuthorizeResult({
|
|
349
354
|
id: transaction.id,
|
|
350
355
|
update: {
|
|
351
356
|
'object.accountId': accountId,
|
|
352
357
|
'object.paymentMethod.accountId': accountId,
|
|
353
|
-
'object.payAction':
|
|
358
|
+
'object.payAction': payActionInObject,
|
|
354
359
|
// 認証レスポンスより計上金額を保管(2023-05-15~)
|
|
355
360
|
'object.accountsReceivablesByServiceType': accountsReceivablesByServiceType
|
|
356
361
|
}
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.authorize = void 0;
|
|
13
24
|
const factory = require("../../../factory");
|
|
@@ -244,7 +255,13 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
|
|
|
244
255
|
});
|
|
245
256
|
const acceptedAppliesToMovieTicket = (_a = offerWithoutDetail.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
246
257
|
// 承認アクションオブジェクトのacceptedOfferにappliesToMovieTicketを連携する(2022-08-02~)
|
|
247
|
-
const priceSpecification = Object.assign(
|
|
258
|
+
const priceSpecification = Object.assign({
|
|
259
|
+
// 必要な属性のみに最適化(2024-04-09~)
|
|
260
|
+
// ...offer.priceSpecification,
|
|
261
|
+
typeOf: offer.priceSpecification.typeOf, priceCurrency: offer.priceSpecification.priceCurrency, valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded, priceComponent: offer.priceSpecification.priceComponent.map((_a) => {
|
|
262
|
+
var { name, accounting, id, priceCurrency, valueAddedTaxIncluded } = _a, necessaryComponentFields = __rest(_a, ["name", "accounting", "id", "priceCurrency", "valueAddedTaxIncluded"]);
|
|
263
|
+
return necessaryComponentFields;
|
|
264
|
+
}) }, (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
|
|
248
265
|
? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
|
|
249
266
|
: undefined);
|
|
250
267
|
const acceptedAddOns = (Array.isArray(offerWithoutDetail.addOn))
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.366.0
|
|
14
|
-
"@cinerino/sdk": "5.17.
|
|
13
|
+
"@chevre/factory": "4.366.0",
|
|
14
|
+
"@cinerino/sdk": "5.17.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.28.0
|
|
113
|
+
"version": "21.28.0"
|
|
114
114
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
// tslint:disable-next-line:max-func-body-length
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
const result = await paymentServiceRepo.deleteOldPaymentServices();
|
|
13
|
-
console.log(result);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
main()
|
|
17
|
-
.then()
|
|
18
|
-
.catch(console.error);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
mongoose.Model.on('index', (...args) => {
|
|
7
|
-
console.error('******** index event emitted. ********\n', args);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: process.env.MONGO_AUTO_INDEX === '1' });
|
|
13
|
-
|
|
14
|
-
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
await paymentServiceRepo.migratePaymentServicesToNewCollection();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
main()
|
|
20
|
-
.then()
|
|
21
|
-
.catch(console.error);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
const CLIENT_ID = 'xxxx';
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const projectMakesOfferRepo = await chevre.repository.ProjectMakesOffer.createInstance(mongoose.connection);
|
|
13
|
-
const result = await projectMakesOfferRepo.search({
|
|
14
|
-
limit: 100,
|
|
15
|
-
page: 1,
|
|
16
|
-
offeredBy: { id: { $eq: project.id } },
|
|
17
|
-
availableAtOrFrom: { id: { $eq: CLIENT_ID } }
|
|
18
|
-
});
|
|
19
|
-
console.log('result:', result);
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await projectMakesOfferRepo.create({
|
|
23
|
-
availableAtOrFrom: { id: CLIENT_ID },
|
|
24
|
-
offeredBy: { id: project.id }
|
|
25
|
-
});
|
|
26
|
-
console.log('offer created');
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error(error);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await projectMakesOfferRepo.updateOne({
|
|
32
|
-
availableAtOrFrom: { id: CLIENT_ID },
|
|
33
|
-
eligibleCustomerType: [{ codeValue: 'Enduser' }],
|
|
34
|
-
offeredBy: { id: project.id }
|
|
35
|
-
});
|
|
36
|
-
console.log('offer updated');
|
|
37
|
-
|
|
38
|
-
await projectMakesOfferRepo.deleteOne({
|
|
39
|
-
availableAtOrFrom: { id: CLIENT_ID },
|
|
40
|
-
offeredBy: { id: project.id }
|
|
41
|
-
});
|
|
42
|
-
console.log('offer deleted');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
main()
|
|
46
|
-
.then(console.log)
|
|
47
|
-
.catch(console.error);
|