@chevre/domain 21.30.0-alpha.44 → 21.30.0-alpha.46
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/migrateMembers.ts +94 -0
- package/example/src/chevre/optimizeActions.ts +14 -36
- package/example/src/chevre/unsetUnnecessaryFields.ts +12 -8
- package/lib/chevre/repo/code.d.ts +4 -0
- package/lib/chevre/repo/code.js +6 -0
- package/lib/chevre/repo/customer.d.ts +7 -6
- package/lib/chevre/repo/customer.js +31 -36
- package/lib/chevre/repo/member.d.ts +4 -0
- package/lib/chevre/repo/member.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/member.js +5 -12
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +5 -12
- package/lib/chevre/repo/ownershipInfo.d.ts +4 -0
- package/lib/chevre/repo/ownershipInfo.js +6 -0
- package/lib/chevre/service/code.js +13 -11
- package/lib/chevre/settings.d.ts +0 -1
- package/lib/chevre/settings.js +1 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +0 -93
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = memberRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
'member.memberOf.typeOf': { $eq: chevre.factory.organizationType.Corporation }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
console.log('members found');
|
|
22
|
+
|
|
23
|
+
let projectIds: string[] = [];
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
await cursor.eachAsync(async (doc) => {
|
|
27
|
+
i += 1;
|
|
28
|
+
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
29
|
+
|
|
30
|
+
const alreadyMigrated = false;
|
|
31
|
+
projectIds.push(iamMember.project.id);
|
|
32
|
+
|
|
33
|
+
if (alreadyMigrated) {
|
|
34
|
+
console.log(
|
|
35
|
+
'already exist.',
|
|
36
|
+
iamMember.project.id,
|
|
37
|
+
iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
console.log(
|
|
41
|
+
'updating...',
|
|
42
|
+
iamMember.project.id,
|
|
43
|
+
iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
|
|
44
|
+
);
|
|
45
|
+
updateCount += 1;
|
|
46
|
+
console.log(
|
|
47
|
+
'updated.',
|
|
48
|
+
iamMember.project.id,
|
|
49
|
+
iamMember.member.memberOf.typeOf, iamMember.member.memberOf.id, i, updateCount
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
projectIds = [...new Set(projectIds)];
|
|
55
|
+
console.log(projectIds);
|
|
56
|
+
console.log(i, 'members checked');
|
|
57
|
+
console.log(updateCount, 'members updated');
|
|
58
|
+
|
|
59
|
+
// 販売者メンバーの存在するプロジェクトについて、inventoryManagerにiam.roleAdminを追加
|
|
60
|
+
const NEW_ROLE_NAME = 'iam.roleAdmin';
|
|
61
|
+
for (const projectId of projectIds) {
|
|
62
|
+
const inventoryManagers = await memberRepo.search({
|
|
63
|
+
project: { id: { $eq: projectId } },
|
|
64
|
+
member: {
|
|
65
|
+
hasRole: { roleName: { $eq: 'inventoryManager' } },
|
|
66
|
+
memberOf: { typeOf: { $eq: chevre.factory.organizationType.Project } }
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
console.log(inventoryManagers.length, 'inventoryManagers found', projectId);
|
|
70
|
+
for (const inventoryManager of inventoryManagers) {
|
|
71
|
+
const alreadyRoleAdmin = inventoryManager.member.hasRole.some(({ roleName }) => roleName === NEW_ROLE_NAME);
|
|
72
|
+
if (!alreadyRoleAdmin) {
|
|
73
|
+
const newHasRole: chevre.factory.iam.IMemberRole[] = [
|
|
74
|
+
{ typeOf: chevre.factory.iam.RoleType.OrganizationRole, roleName: NEW_ROLE_NAME },
|
|
75
|
+
...inventoryManager.member.hasRole
|
|
76
|
+
];
|
|
77
|
+
console.log('adding newRole', projectId, inventoryManager.member.id, newHasRole);
|
|
78
|
+
await memberRepo.updateByMemberId({
|
|
79
|
+
project: { id: inventoryManager.project.id },
|
|
80
|
+
member: {
|
|
81
|
+
id: inventoryManager.member.id,
|
|
82
|
+
memberOf: inventoryManager.member.memberOf,
|
|
83
|
+
hasRole: newHasRole
|
|
84
|
+
},
|
|
85
|
+
$unset: {}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main()
|
|
93
|
+
.then()
|
|
94
|
+
.catch(console.error);
|
|
@@ -16,9 +16,9 @@ async function main() {
|
|
|
16
16
|
for (let index = 0; index < 24 * 1000; index++) {
|
|
17
17
|
const updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
18
18
|
filter: {
|
|
19
|
-
typeOf: { $eq: chevre.factory.actionType.
|
|
20
|
-
'object.typeOf': { $exists: true, $eq:
|
|
21
|
-
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
19
|
+
typeOf: { $eq: chevre.factory.actionType.UseAction },
|
|
20
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.reservationType.EventReservation },
|
|
21
|
+
// actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
22
22
|
startDate: {
|
|
23
23
|
// $exists: true,
|
|
24
24
|
$gte: moment()
|
|
@@ -31,39 +31,17 @@ async function main() {
|
|
|
31
31
|
// _id: { $eq: '61da235d94a80f000af85f6b' }
|
|
32
32
|
},
|
|
33
33
|
$unset: {
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'result.refundTransaction.updatedAt': 1
|
|
46
|
-
// 'recipient.identifier': 1,
|
|
47
|
-
// 'recipient.memberOf': 1,
|
|
48
|
-
// 'recipient.email': 1,
|
|
49
|
-
// 'recipient.familyName': 1,
|
|
50
|
-
// 'recipient.givenName': 1,
|
|
51
|
-
// 'recipient.telephone': 1
|
|
52
|
-
// 'object.project': 1,
|
|
53
|
-
// 'object.seller': 1,
|
|
54
|
-
// 'object.customer': 1,
|
|
55
|
-
// 'object.paymentMethods': 1,
|
|
56
|
-
// 'object.discounts': 1,
|
|
57
|
-
// 'object.acceptedOffers': 1,
|
|
58
|
-
// 'object.url': 1,
|
|
59
|
-
// 'object.orderStatus': 1,
|
|
60
|
-
// 'object.identifier': 1,
|
|
61
|
-
// 'object.isGift': 1,
|
|
62
|
-
// 'object.broker': 1,
|
|
63
|
-
// 'object.dateReturned': 1,
|
|
64
|
-
// 'object.name': 1,
|
|
65
|
-
// 'object.orderedItem': 1,
|
|
66
|
-
// 'object.returner': 1
|
|
34
|
+
'object.0.issuedThrough.availableChannel': 1,
|
|
35
|
+
'object.0.issuedThrough.serviceType': 1,
|
|
36
|
+
'object.0.reservationFor.superEvent': 1,
|
|
37
|
+
'object.0.reservationFor.location': 1,
|
|
38
|
+
'object.0.reservationFor.name': 1,
|
|
39
|
+
'object.0.reservedTicket.issuedBy': 1,
|
|
40
|
+
'object.0.reservedTicket.ticketType.description': 1,
|
|
41
|
+
'object.0.reservedTicket.ticketType.name': 1,
|
|
42
|
+
'object.0.reservedTicket.ticketType.additionalProperty': 1,
|
|
43
|
+
'object.0.reservedTicket.ticketType.category': 1,
|
|
44
|
+
'object.0.reservedTicket.ticketType.color': 1
|
|
67
45
|
}
|
|
68
46
|
});
|
|
69
47
|
console.log(
|
|
@@ -8,23 +8,27 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
let updateResult: any;
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
12
|
+
const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
|
|
13
|
+
updateResult = await memberRepo.unsetUnnecessaryFields({
|
|
13
14
|
filter: {
|
|
14
|
-
|
|
15
|
+
_id: { $exists: true }
|
|
15
16
|
},
|
|
16
17
|
$unset: {
|
|
17
|
-
|
|
18
|
+
__v: 1,
|
|
19
|
+
createdAt: 1,
|
|
20
|
+
updatedAt: 1
|
|
18
21
|
}
|
|
19
22
|
});
|
|
20
23
|
console.log('unset processed.', updateResult);
|
|
21
|
-
|
|
22
|
-
updateResult = await orderRepo.unsetUnnecessaryFields({
|
|
24
|
+
updateResult = await ownershipInfoRepo.unsetUnnecessaryFields({
|
|
23
25
|
filter: {
|
|
24
|
-
|
|
26
|
+
_id: { $exists: true }
|
|
25
27
|
},
|
|
26
28
|
$unset: {
|
|
27
|
-
|
|
29
|
+
__v: 1,
|
|
30
|
+
createdAt: 1,
|
|
31
|
+
updatedAt: 1
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
console.log('unset processed.', updateResult);
|
|
@@ -44,6 +44,10 @@ export declare class AuthorizationRepo {
|
|
|
44
44
|
deleteValidUntilPassedCertainPeriod(params: {
|
|
45
45
|
$lt: Date;
|
|
46
46
|
}): Promise<void>;
|
|
47
|
+
unsetUnnecessaryFields(params: {
|
|
48
|
+
filter: FilterQuery<factory.authorization.IAuthorization>;
|
|
49
|
+
$unset: any;
|
|
50
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
47
51
|
/**
|
|
48
52
|
* コードを保管する
|
|
49
53
|
*/
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -183,6 +183,12 @@ class AuthorizationRepo {
|
|
|
183
183
|
.exec();
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
+
unsetUnnecessaryFields(params) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
return this.authorizationModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
189
|
+
.exec();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
186
192
|
/**
|
|
187
193
|
* コードを保管する
|
|
188
194
|
*/
|
|
@@ -22,18 +22,16 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import type { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
+
type IKeyOfProjection = keyof factory.customer.ICustomer | '_id';
|
|
27
28
|
/**
|
|
28
29
|
* 顧客リポジトリ
|
|
29
30
|
*/
|
|
30
31
|
export declare class MongoRepository {
|
|
31
32
|
private readonly customerModel;
|
|
32
33
|
constructor(connection: Connection);
|
|
33
|
-
static CREATE_MONGO_CONDITIONS(params: factory.customer.ISearchConditions):
|
|
34
|
-
findById(conditions: {
|
|
35
|
-
id: string;
|
|
36
|
-
}, projection?: any): Promise<factory.customer.ICustomer>;
|
|
34
|
+
static CREATE_MONGO_CONDITIONS(params: factory.customer.ISearchConditions): FilterQuery<factory.customer.ICustomer>[];
|
|
37
35
|
save(params: {
|
|
38
36
|
id?: string;
|
|
39
37
|
attributes: factory.customer.ICustomer;
|
|
@@ -41,9 +39,12 @@ export declare class MongoRepository {
|
|
|
41
39
|
/**
|
|
42
40
|
* 顧客検索
|
|
43
41
|
*/
|
|
44
|
-
search(conditions: factory.customer.ISearchConditions, projection?:
|
|
42
|
+
search(conditions: factory.customer.ISearchConditions, projection?: {
|
|
43
|
+
[key in IKeyOfProjection]?: 0;
|
|
44
|
+
}): Promise<factory.customer.ICustomer[]>;
|
|
45
45
|
deleteById(params: {
|
|
46
46
|
id: string;
|
|
47
47
|
}): Promise<void>;
|
|
48
48
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
49
49
|
}
|
|
50
|
+
export {};
|
|
@@ -31,58 +31,53 @@ class MongoRepository {
|
|
|
31
31
|
constructor(connection) {
|
|
32
32
|
this.customerModel = connection.model(customer_1.modelName, (0, customer_1.createSchema)());
|
|
33
33
|
}
|
|
34
|
-
// tslint:disable-next-line:max-func-body-length
|
|
35
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
|
-
var _a, _b, _c, _d;
|
|
37
|
-
// MongoDB検索条件
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
38
36
|
const andConditions = [];
|
|
39
37
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
40
38
|
if (typeof projectIdEq === 'string') {
|
|
41
|
-
andConditions.push({
|
|
42
|
-
'project.id': {
|
|
43
|
-
$eq: projectIdEq
|
|
44
|
-
}
|
|
45
|
-
});
|
|
39
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
46
40
|
}
|
|
47
41
|
const branchCodeRegex = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$regex;
|
|
48
42
|
if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
49
|
-
andConditions.push({
|
|
50
|
-
branchCode: {
|
|
51
|
-
$regex: new RegExp(branchCodeRegex)
|
|
52
|
-
}
|
|
53
|
-
});
|
|
43
|
+
andConditions.push({ branchCode: { $regex: new RegExp(branchCodeRegex) } });
|
|
54
44
|
}
|
|
55
|
-
const
|
|
45
|
+
const idEq = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
46
|
+
if (typeof idEq === 'string') {
|
|
47
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
48
|
+
}
|
|
49
|
+
const nameRegex = (_e = params.name) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
56
50
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
57
51
|
andConditions.push({
|
|
58
52
|
$or: [
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
$exists: true,
|
|
62
|
-
$regex: new RegExp(nameRegex)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
'name.en': {
|
|
67
|
-
$exists: true,
|
|
68
|
-
$regex: new RegExp(nameRegex)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
53
|
+
{ 'name.ja': { $exists: true, $regex: new RegExp(nameRegex) } },
|
|
54
|
+
{ 'name.en': { $exists: true, $regex: new RegExp(nameRegex) } }
|
|
71
55
|
]
|
|
72
56
|
});
|
|
73
57
|
}
|
|
74
58
|
return andConditions;
|
|
75
59
|
}
|
|
76
|
-
findById(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
// public async findById(
|
|
61
|
+
// conditions: {
|
|
62
|
+
// id: string;
|
|
63
|
+
// },
|
|
64
|
+
// projection?: any
|
|
65
|
+
// ): Promise<factory.customer.ICustomer> {
|
|
66
|
+
// const doc = await this.customerModel.findOne(
|
|
67
|
+
// { _id: conditions.id },
|
|
68
|
+
// {
|
|
69
|
+
// __v: 0,
|
|
70
|
+
// createdAt: 0,
|
|
71
|
+
// updatedAt: 0,
|
|
72
|
+
// ...projection
|
|
73
|
+
// }
|
|
74
|
+
// )
|
|
75
|
+
// .exec();
|
|
76
|
+
// if (doc === null) {
|
|
77
|
+
// throw new factory.errors.NotFound(this.customerModel.modelName);
|
|
78
|
+
// }
|
|
79
|
+
// return doc.toObject();
|
|
80
|
+
// }
|
|
86
81
|
save(params) {
|
|
87
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
83
|
let customer;
|
|
@@ -169,4 +169,8 @@ export declare class MongoRepository {
|
|
|
169
169
|
};
|
|
170
170
|
}): Promise<string[]>;
|
|
171
171
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
172
|
+
unsetUnnecessaryFields(params: {
|
|
173
|
+
filter: any;
|
|
174
|
+
$unset: any;
|
|
175
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
172
176
|
}
|
|
@@ -295,5 +295,11 @@ class MongoRepository {
|
|
|
295
295
|
.sort({ 'member.id': factory.sortType.Ascending })
|
|
296
296
|
.cursor();
|
|
297
297
|
}
|
|
298
|
+
unsetUnnecessaryFields(params) {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
+
return this.memberModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
301
|
+
.exec();
|
|
302
|
+
});
|
|
303
|
+
}
|
|
298
304
|
}
|
|
299
305
|
exports.MongoRepository = MongoRepository;
|
|
@@ -19,6 +19,9 @@ const schemaDefinition = {
|
|
|
19
19
|
type: mongoose_1.SchemaTypes.Mixed,
|
|
20
20
|
required: true
|
|
21
21
|
}
|
|
22
|
+
// __v: SchemaTypes.Mixed,
|
|
23
|
+
// createdAt: SchemaTypes.Mixed,
|
|
24
|
+
// updatedAt: SchemaTypes.Mixed
|
|
22
25
|
};
|
|
23
26
|
const schemaOptions = {
|
|
24
27
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -29,10 +32,8 @@ const schemaOptions = {
|
|
|
29
32
|
writeConcern: writeConcern_1.writeConcern,
|
|
30
33
|
strict: true,
|
|
31
34
|
strictQuery: false,
|
|
32
|
-
timestamps:
|
|
33
|
-
|
|
34
|
-
updatedAt: 'updatedAt'
|
|
35
|
-
},
|
|
35
|
+
timestamps: false,
|
|
36
|
+
versionKey: false,
|
|
36
37
|
toJSON: {
|
|
37
38
|
getters: false,
|
|
38
39
|
virtuals: false,
|
|
@@ -58,14 +59,6 @@ function createSchema() {
|
|
|
58
59
|
}
|
|
59
60
|
exports.createSchema = createSchema;
|
|
60
61
|
const indexes = [
|
|
61
|
-
[
|
|
62
|
-
{ createdAt: 1 },
|
|
63
|
-
{ name: 'searchByCreatedAt' }
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
{ updatedAt: 1 },
|
|
67
|
-
{ name: 'searchByUpdatedAt' }
|
|
68
|
-
],
|
|
69
62
|
[
|
|
70
63
|
{ 'member.id': 1 },
|
|
71
64
|
{ name: 'searchByMemberId' }
|
|
@@ -22,6 +22,9 @@ const schemaDefinition = {
|
|
|
22
22
|
ownedFrom: Date,
|
|
23
23
|
ownedThrough: Date,
|
|
24
24
|
typeOfGood: mongoose_1.SchemaTypes.Mixed
|
|
25
|
+
// __v: SchemaTypes.Mixed,
|
|
26
|
+
// createdAt: SchemaTypes.Mixed,
|
|
27
|
+
// updatedAt: SchemaTypes.Mixed
|
|
25
28
|
};
|
|
26
29
|
const schemaOptions = {
|
|
27
30
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -32,10 +35,8 @@ const schemaOptions = {
|
|
|
32
35
|
writeConcern: writeConcern_1.writeConcern,
|
|
33
36
|
strict: true,
|
|
34
37
|
strictQuery: false,
|
|
35
|
-
timestamps:
|
|
36
|
-
|
|
37
|
-
updatedAt: 'updatedAt'
|
|
38
|
-
},
|
|
38
|
+
timestamps: false,
|
|
39
|
+
versionKey: false,
|
|
39
40
|
toJSON: {
|
|
40
41
|
getters: false,
|
|
41
42
|
virtuals: false,
|
|
@@ -61,14 +62,6 @@ function createSchema() {
|
|
|
61
62
|
}
|
|
62
63
|
exports.createSchema = createSchema;
|
|
63
64
|
const indexes = [
|
|
64
|
-
[
|
|
65
|
-
{ createdAt: 1 },
|
|
66
|
-
{ name: 'searchByCreatedAt' }
|
|
67
|
-
],
|
|
68
|
-
[
|
|
69
|
-
{ updatedAt: 1 },
|
|
70
|
-
{ name: 'searchByUpdatedAt' }
|
|
71
|
-
],
|
|
72
65
|
[
|
|
73
66
|
// 識別子はユニークな前提
|
|
74
67
|
{ identifier: 1 },
|
|
@@ -427,5 +427,11 @@ class MongoRepository {
|
|
|
427
427
|
}
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
|
+
unsetUnnecessaryFields(params) {
|
|
431
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
432
|
+
return this.ownershipInfoModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
433
|
+
.exec();
|
|
434
|
+
});
|
|
435
|
+
}
|
|
430
436
|
}
|
|
431
437
|
exports.MongoRepository = MongoRepository;
|
|
@@ -16,7 +16,6 @@ exports.verifyToken = exports.getToken = void 0;
|
|
|
16
16
|
const jwt = require("jsonwebtoken");
|
|
17
17
|
const credentials_1 = require("../credentials");
|
|
18
18
|
const factory = require("../factory");
|
|
19
|
-
const settings_1 = require("../settings");
|
|
20
19
|
const ALGORITHM = 'HS256';
|
|
21
20
|
/**
|
|
22
21
|
* コードをトークンに変換する
|
|
@@ -54,12 +53,15 @@ function getToken(params) {
|
|
|
54
53
|
typ = `${credentials_1.credentials.jwt.payloadTypPrefix}:${params.agent.typeOf}`;
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
const isAuthorize4order = authorization.object.typeOf === factory.order.OrderType.Order;
|
|
58
|
-
const payload =
|
|
56
|
+
// const isAuthorize4order: boolean = authorization.object.typeOf === factory.order.OrderType.Order;
|
|
57
|
+
const payload = {
|
|
58
|
+
// NO_VERSIONを廃止(2024-05-06~)
|
|
59
|
+
// ...(USE_TOKEN_WITH_NO_VERSION && isAuthorize4order) ? authorization.object : undefined,
|
|
59
60
|
// sub: authorization.id, // 拡張(2024-05-01~)
|
|
60
|
-
token_use: 'access',
|
|
61
|
+
token_use: 'access',
|
|
62
|
+
version: credentials_1.credentials.jwt.version,
|
|
61
63
|
typ // 拡張(2024-05-07~)
|
|
62
|
-
|
|
64
|
+
};
|
|
63
65
|
return new Promise((resolve, reject) => {
|
|
64
66
|
// 所有権を暗号化する
|
|
65
67
|
jwt.sign(payload, credentials_1.credentials.jwt.secret, Object.assign(Object.assign({ algorithm: ALGORITHM,
|
|
@@ -179,12 +181,12 @@ function verifyToken(params) {
|
|
|
179
181
|
}
|
|
180
182
|
else {
|
|
181
183
|
// NO_VERSIONを廃止(2024-05-06~)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
else {
|
|
186
|
-
|
|
187
|
-
}
|
|
184
|
+
throw new factory.errors.NotImplemented('USE_TOKEN_WITH_NO_VERSION discontinued');
|
|
185
|
+
// if (USE_TOKEN_WITH_NO_VERSION) {
|
|
186
|
+
// result = payload;
|
|
187
|
+
// } else {
|
|
188
|
+
// throw new factory.errors.NotImplemented('USE_TOKEN_WITH_NO_VERSION not implemented');
|
|
189
|
+
// }
|
|
188
190
|
}
|
|
189
191
|
return result;
|
|
190
192
|
});
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export declare const USE_CHECK_RESOURCE_TASK: boolean;
|
|
|
40
40
|
export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
|
|
41
41
|
export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
|
|
42
42
|
export declare const USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER: boolean;
|
|
43
|
-
export declare const USE_TOKEN_WITH_NO_VERSION: boolean;
|
|
44
43
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
45
44
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
46
45
|
export declare const MONGO_AUTO_INDEX: boolean;
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -63,7 +63,6 @@ exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_R
|
|
|
63
63
|
: [];
|
|
64
64
|
exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
|
|
65
65
|
exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = process.env.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER === '1';
|
|
66
|
-
exports.USE_TOKEN_WITH_NO_VERSION = process.env.USE_TOKEN_WITH_NO_VERSION === '1';
|
|
67
66
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
68
67
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
69
68
|
// tslint:disable-next-line:no-magic-numbers
|
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.369.
|
|
14
|
-
"@cinerino/sdk": "
|
|
13
|
+
"@chevre/factory": "4.369.1",
|
|
14
|
+
"@cinerino/sdk": "6.1.0-alpha.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.30.0-alpha.
|
|
113
|
+
"version": "21.30.0-alpha.46"
|
|
114
114
|
}
|
|
@@ -1,93 +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 EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = actionRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'instrument.transactionNumber': { $exists: false },
|
|
19
|
-
'object.typeOf': { $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
|
|
20
|
-
// 'project.id': { $eq: project.id },
|
|
21
|
-
startDate: {
|
|
22
|
-
$gte: moment()
|
|
23
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
.add(-12, 'months')
|
|
25
|
-
.toDate()
|
|
26
|
-
// $lte: moment('2023-08-01T21:20:43.133Z')
|
|
27
|
-
// .toDate()
|
|
28
|
-
},
|
|
29
|
-
// actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus }
|
|
30
|
-
'project.id': {
|
|
31
|
-
$ne: EXCLUDED_PROJECT_ID
|
|
32
|
-
}
|
|
33
|
-
// _id: { $eq: '6500d53f8f5a524f061b4771' }
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
startDate: 1,
|
|
37
|
-
object: 1,
|
|
38
|
-
project: 1,
|
|
39
|
-
instrument: 1,
|
|
40
|
-
purpose: 1
|
|
41
|
-
// result: 1
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
console.log('actions found');
|
|
45
|
-
|
|
46
|
-
let i = 0;
|
|
47
|
-
let updateCount = 0;
|
|
48
|
-
await cursor.eachAsync(async (doc) => {
|
|
49
|
-
i += 1;
|
|
50
|
-
const action: Pick<
|
|
51
|
-
chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
|
|
52
|
-
'startDate' | 'object' | 'project' | 'instrument' | 'id' | 'purpose'
|
|
53
|
-
> = doc.toObject();
|
|
54
|
-
|
|
55
|
-
const noPendingTransaction = false;
|
|
56
|
-
const transactionNumber = action.object.pendingTransaction?.transactionNumber;
|
|
57
|
-
// const transactionNumberFromResult = (<any>action).result?.responseBody?.tmpReserveNum;
|
|
58
|
-
if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
|
|
59
|
-
// noPendingTransaction = true;
|
|
60
|
-
// console.error('transactionNumber not found.', action.project.id, action.id, transactionNumber, action.startDate, i);
|
|
61
|
-
// if (typeof transactionNumberFromResult !== 'string' || transactionNumberFromResult.length === 0) {
|
|
62
|
-
// throw new Error('transactionNumber & transactionNumberFromResult not found.');
|
|
63
|
-
// } else {
|
|
64
|
-
// transactionNumber = transactionNumberFromResult;
|
|
65
|
-
// }
|
|
66
|
-
throw new Error('transactionNumber & transactionNumberFromResult not found.');
|
|
67
|
-
}
|
|
68
|
-
const alreadyMigrated = typeof action.instrument.transactionNumber === 'string'
|
|
69
|
-
&& action.instrument.transactionNumber === transactionNumber;
|
|
70
|
-
|
|
71
|
-
if (alreadyMigrated) {
|
|
72
|
-
console.log('already exist.', action.project.id, action.id, action.purpose.id, transactionNumber, action.startDate, i);
|
|
73
|
-
} else {
|
|
74
|
-
console.log('updating...', action.project.id, action.id, action.purpose.id, transactionNumber, action.startDate, i);
|
|
75
|
-
await actionRepo.fixInstrumentTransactionNumber({
|
|
76
|
-
id: action.id,
|
|
77
|
-
instrument: { transactionNumber },
|
|
78
|
-
...(noPendingTransaction)
|
|
79
|
-
? { object: { pendingTransaction: { transactionNumber } } }
|
|
80
|
-
: undefined
|
|
81
|
-
});
|
|
82
|
-
updateCount += 1;
|
|
83
|
-
console.log('updated.', action.project.id, action.id, transactionNumber, action.startDate, i);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
console.log(i, 'actions checked');
|
|
88
|
-
console.log(updateCount, 'actions updated');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
main()
|
|
92
|
-
.then()
|
|
93
|
-
.catch(console.error);
|