@chevre/domain 22.11.0-alpha.4 → 22.11.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/aggregation/aggregateOrderOfCustomer.ts +21 -10
- package/example/src/chevre/aggregation/aggregateTasks.ts +41 -0
- package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
- package/example/src/chevre/checkCustomerAttributesLength.ts +109 -0
- package/example/src/chevre/notifyAbortedTasksByEmail.ts +1 -1
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +132 -0
- package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
- package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
- package/example/src/chevre/roles/addProjectCreatorRole.ts +48 -0
- package/example/src/chevre/roles/assignGlobalRoles.ts +72 -0
- package/example/src/chevre/roles/findPermissions.ts +84 -0
- package/example/src/chevre/roles/findRoleNames.ts +117 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
- package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +46 -0
- package/example/src/chevre/roles/removePermissionIfExists.ts +39 -0
- package/example/src/chevre/searchEventSeats.ts +1 -1
- package/example/src/chevre/searchProducts.ts +28 -0
- package/example/src/chevre/settings/addSettings.ts +31 -17
- package/example/src/chevre/task/countPotentiallyRunning.ts +41 -0
- package/example/src/chevre/task/countTasks.ts +51 -0
- package/example/src/chevre/{deleteRunsAtPassedCertainPeriod.ts → task/deleteRunsAtPassedCertainPeriod.ts} +4 -3
- package/example/src/chevre/task/deleteUnexpectedTasks.ts +23 -0
- package/example/src/chevre/task/emitRunning.ts +89 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -5
- package/example/src/idaas/auth0/adminApplications.ts +183 -0
- package/example/src/idaas/auth0/getToken.ts +55 -0
- package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
- package/example/src/regex.ts +31 -0
- package/lib/chevre/eventEmitter/task.d.ts +29 -6
- package/lib/chevre/index.d.ts +0 -2
- package/lib/chevre/index.js +0 -10
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -3
- package/lib/chevre/repo/confirmationNumber.js +12 -47
- package/lib/chevre/repo/identity.d.ts +11 -33
- package/lib/chevre/repo/identity.js +10 -15
- package/lib/chevre/repo/member.d.ts +22 -4
- package/lib/chevre/repo/member.js +81 -27
- package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +14 -0
- package/lib/chevre/repo/mongoose/schemas/member/global.js +82 -0
- package/lib/chevre/repo/mongoose/schemas/product.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +15 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +9 -0
- package/lib/chevre/repo/order.d.ts +17 -2
- package/lib/chevre/repo/order.js +47 -8
- package/lib/chevre/repo/orderNumber.d.ts +0 -3
- package/lib/chevre/repo/orderNumber.js +10 -44
- package/lib/chevre/repo/pendingReservation.js +1 -0
- package/lib/chevre/repo/product.js +12 -17
- package/lib/chevre/repo/role.d.ts +16 -4
- package/lib/chevre/repo/role.js +71 -32
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -3
- package/lib/chevre/repo/serviceOutputIdentifier.js +10 -27
- package/lib/chevre/repo/setting.d.ts +5 -10
- package/lib/chevre/repo/setting.js +4 -7
- package/lib/chevre/repo/stockHolder.d.ts +4 -27
- package/lib/chevre/repo/stockHolder.js +163 -186
- package/lib/chevre/repo/task.d.ts +58 -38
- package/lib/chevre/repo/task.js +126 -296
- package/lib/chevre/repo/transaction.js +10 -10
- package/lib/chevre/repo/transactionNumber.d.ts +0 -3
- package/lib/chevre/repo/transactionNumber.js +10 -44
- package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
- package/lib/chevre/repo/transactionNumberCounter.js +34 -29
- package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +4 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +19 -16
- package/lib/chevre/service/code.d.ts +5 -28
- package/lib/chevre/service/code.js +3 -79
- package/lib/chevre/service/iam.d.ts +17 -7
- package/lib/chevre/service/iam.js +26 -6
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +15 -0
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +38 -0
- package/lib/chevre/service/notification.d.ts +2 -1
- package/lib/chevre/service/notification.js +3 -1
- package/lib/chevre/service/offer/product.js +4 -0
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +6 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +3 -3
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +6 -5
- package/lib/chevre/service/task/aggregateOffers.d.ts +1 -1
- package/lib/chevre/service/task/aggregateOffers.js +1 -1
- package/lib/chevre/service/task/aggregateOnSystem.d.ts +4 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/authorizePayment.d.ts +1 -1
- package/lib/chevre/service/task/authorizePayment.js +7 -6
- package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.d.ts +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
- package/lib/chevre/service/task/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/task/cancelReservation.js +1 -1
- package/lib/chevre/service/task/checkMovieTicket.d.ts +1 -1
- package/lib/chevre/service/task/checkMovieTicket.js +4 -3
- package/lib/chevre/service/task/checkResource.d.ts +1 -1
- package/lib/chevre/service/task/checkResource.js +1 -1
- package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/confirmPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +3 -2
- package/lib/chevre/service/task/confirmRegisterService.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -2
- package/lib/chevre/service/task/confirmReserveTransaction.js +3 -3
- package/lib/chevre/service/task/createAccountingReport.d.ts +1 -1
- package/lib/chevre/service/task/createEvent.d.ts +1 -1
- package/lib/chevre/service/task/deletePerson.d.ts +1 -1
- package/lib/chevre/service/task/deleteTransaction.d.ts +1 -1
- package/lib/chevre/service/task/givePointAward.d.ts +1 -1
- package/lib/chevre/service/task/givePointAward.js +1 -1
- package/lib/chevre/service/task/handleNotification.d.ts +4 -2
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/importEventsFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/importOffersFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +1 -1
- package/lib/chevre/service/task/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/moneyTransfer.js +1 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +1 -1
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +1 -1
- package/lib/chevre/service/task/onEventChanged.d.ts +1 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +1 -1
- package/lib/chevre/service/task/onResourceUpdated.d.ts +1 -1
- package/lib/chevre/service/task/pay.d.ts +1 -1
- package/lib/chevre/service/task/placeOrder.d.ts +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.d.ts +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.js +6 -7
- package/lib/chevre/service/task/refund.d.ts +1 -1
- package/lib/chevre/service/task/refund.js +1 -1
- package/lib/chevre/service/task/registerService.d.ts +1 -1
- package/lib/chevre/service/task/reserve.d.ts +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/task/returnOrder.d.ts +1 -1
- package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
- package/lib/chevre/service/task/returnPointAward.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendEmailMessage.d.ts +1 -1
- package/lib/chevre/service/task/sendOrder.d.ts +1 -1
- package/lib/chevre/service/task/triggerWebhook.d.ts +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +1 -1
- package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidPayTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidPayment.d.ts +1 -1
- package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
- package/lib/chevre/service/task.d.ts +7 -29
- package/lib/chevre/service/task.js +9 -114
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.d.ts +11 -0
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +105 -0
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +17 -0
- package/lib/chevre/service/taskHandler/onOperationFailed.js +70 -0
- package/lib/chevre/service/taskHandler.d.ts +26 -0
- package/lib/chevre/service/taskHandler.js +97 -0
- package/lib/chevre/service/validation/validateEvent.d.ts +2 -2
- package/lib/chevre/service/validation/validateEvent.js +16 -10
- package/lib/chevre/service/validation/validateOrder.js +55 -37
- package/lib/chevre/service.d.ts +0 -4
- package/lib/chevre/service.js +10 -14
- package/lib/chevre/settings/aggregation.d.ts +6 -1
- package/lib/chevre/settings/aggregation.js +2 -1
- package/package.json +6 -4
- package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
- package/example/src/chevre/executeOneTask.ts +0 -41
- package/example/src/chevre/executeTaskIfExists.ts +0 -80
- package/example/src/chevre/findExecutableTask.ts +0 -50
- package/example/src/chevre/findSetting.ts +0 -79
- package/example/src/chevre/roles/addRoleMembers.ts +0 -75
- package/example/src/chevre/searchPermissions.ts +0 -46
- package/example/src/chevre/searchProductOffers.ts +0 -29
- package/example/src/chevre/stockHolder/checkIfConflicted.ts +0 -76
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +0 -195
- package/example/src/chevre/stockHolder/migratePendingReservations.ts +0 -96
- package/example/src/chevre/stockHolder/playAroundStockHolder.ts +0 -256
- package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
- package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
- package/example/src/chevre/upsertProductsByProductId.ts +0 -100
- package/lib/chevre/adminAuth.d.ts +0 -2
- package/lib/chevre/adminAuth.js +0 -6
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
+
import { IGlobalMember } from './mongoose/schemas/member/global';
|
|
3
4
|
type IKeyOfProjection = keyof factory.iam.IMember;
|
|
4
5
|
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'>;
|
|
5
6
|
/**
|
|
6
7
|
* IAMメンバーリポジトリ
|
|
7
8
|
*/
|
|
8
9
|
export declare class MemberRepo {
|
|
10
|
+
private readonly globalMemberModel;
|
|
9
11
|
private readonly memberModel;
|
|
10
12
|
constructor(connection: Connection);
|
|
11
13
|
static CREATE_MONGO_CONDITIONS(params: factory.iam.ISearchConditions): FilterQuery<factory.iam.IMember>[];
|
|
@@ -37,7 +39,10 @@ export declare class MemberRepo {
|
|
|
37
39
|
}): Promise<{
|
|
38
40
|
member: ICustomerMember;
|
|
39
41
|
}[]>;
|
|
40
|
-
|
|
42
|
+
/**
|
|
43
|
+
* distinctコマンドを使用して、プロジェクトメンバーのロールを検索する
|
|
44
|
+
*/
|
|
45
|
+
findRoleNamesByMember(params: {
|
|
41
46
|
project: {
|
|
42
47
|
id: {
|
|
43
48
|
$eq: string;
|
|
@@ -56,9 +61,7 @@ export declare class MemberRepo {
|
|
|
56
61
|
};
|
|
57
62
|
};
|
|
58
63
|
};
|
|
59
|
-
}): Promise<
|
|
60
|
-
roleName: string;
|
|
61
|
-
}[]>;
|
|
64
|
+
}): Promise<string[]>;
|
|
62
65
|
deleteByProject(params: {
|
|
63
66
|
project: {
|
|
64
67
|
id: string;
|
|
@@ -163,6 +166,21 @@ export declare class MemberRepo {
|
|
|
163
166
|
filter: any;
|
|
164
167
|
$unset: any;
|
|
165
168
|
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
169
|
+
/**
|
|
170
|
+
* グローバルメンバー作成
|
|
171
|
+
* 2025-07-21~
|
|
172
|
+
*/
|
|
173
|
+
createGlobalMember(params: IGlobalMember[]): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* distinctコマンドを使用して、グローバルメンバーのロールを検索する
|
|
176
|
+
*/
|
|
177
|
+
findGlobalRoleNamesByMember(params: {
|
|
178
|
+
member: {
|
|
179
|
+
id: {
|
|
180
|
+
$eq: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}): Promise<string[]>;
|
|
166
184
|
private projectFields;
|
|
167
185
|
}
|
|
168
186
|
export {};
|
|
@@ -13,16 +13,19 @@ exports.MemberRepo = void 0;
|
|
|
13
13
|
const factory = require("../factory");
|
|
14
14
|
const settings_1 = require("../settings");
|
|
15
15
|
const member_1 = require("./mongoose/schemas/member");
|
|
16
|
+
const global_1 = require("./mongoose/schemas/member/global");
|
|
16
17
|
const AVAILABLE_PROJECT_FIELDS = [
|
|
17
18
|
'project',
|
|
18
19
|
'typeOf',
|
|
19
20
|
'member'
|
|
20
21
|
];
|
|
22
|
+
const ANY_PROJECT_ID = '*';
|
|
21
23
|
/**
|
|
22
24
|
* IAMメンバーリポジトリ
|
|
23
25
|
*/
|
|
24
26
|
class MemberRepo {
|
|
25
27
|
constructor(connection) {
|
|
28
|
+
this.globalMemberModel = connection.model(global_1.modelName, (0, global_1.createSchema)());
|
|
26
29
|
this.memberModel = connection.model(member_1.modelName, (0, member_1.createSchema)());
|
|
27
30
|
}
|
|
28
31
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
@@ -112,7 +115,7 @@ class MemberRepo {
|
|
|
112
115
|
throw new factory.errors.ArgumentNull('project.id');
|
|
113
116
|
}
|
|
114
117
|
const filterQueries = MemberRepo.CREATE_MONGO_CONDITIONS({
|
|
115
|
-
project: { id: { $in: [params.project.id,
|
|
118
|
+
project: { id: { $in: [params.project.id, ANY_PROJECT_ID] } }, // 全プロジェクトで利用可能なクライアントを考慮(2025-01-11~)
|
|
116
119
|
member: {
|
|
117
120
|
typeOf: { $eq: factory.creativeWorkType.WebApplication },
|
|
118
121
|
memberOf: { typeOf: { $eq: factory.organizationType.Project } }, // プロジェクトメンバーのはず
|
|
@@ -163,32 +166,55 @@ class MemberRepo {
|
|
|
163
166
|
.exec();
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
|
-
|
|
169
|
+
// migrate to findRoleNamesByMember(2025-07-21~)
|
|
170
|
+
// public async aggregateRoleNames(params: {
|
|
171
|
+
// project: { id: { $eq: string } };
|
|
172
|
+
// member: {
|
|
173
|
+
// id: { $eq: string };
|
|
174
|
+
// memberOf: {
|
|
175
|
+
// id: { $eq: string };
|
|
176
|
+
// typeOf: { $eq: factory.organizationType.Corporation | factory.organizationType.Project };
|
|
177
|
+
// };
|
|
178
|
+
// };
|
|
179
|
+
// }): Promise<{ roleName: string }[]> {
|
|
180
|
+
// const matchStages: IMatchStage[] = [
|
|
181
|
+
// { $match: { 'project.id': { $eq: params.project.id.$eq } } },
|
|
182
|
+
// { $match: { 'member.id': { $eq: params.member.id.$eq } } },
|
|
183
|
+
// { $match: { 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq } } },
|
|
184
|
+
// { $match: { 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq } } }
|
|
185
|
+
// ];
|
|
186
|
+
// const aggregate = this.memberModel.aggregate([
|
|
187
|
+
// // ...(typeof params.sort?.productID === 'number')
|
|
188
|
+
// // ? [{ $sort: { productID: params.sort.productID } }]
|
|
189
|
+
// // : [],
|
|
190
|
+
// ...matchStages,
|
|
191
|
+
// {
|
|
192
|
+
// $unwind: {
|
|
193
|
+
// path: '$member.hasRole'
|
|
194
|
+
// }
|
|
195
|
+
// },
|
|
196
|
+
// {
|
|
197
|
+
// $project: {
|
|
198
|
+
// _id: 0,
|
|
199
|
+
// roleName: '$member.hasRole.roleName'
|
|
200
|
+
// }
|
|
201
|
+
// }
|
|
202
|
+
// ]);
|
|
203
|
+
// return aggregate.option({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
204
|
+
// .exec();
|
|
205
|
+
// }
|
|
206
|
+
/**
|
|
207
|
+
* distinctコマンドを使用して、プロジェクトメンバーのロールを検索する
|
|
208
|
+
*/
|
|
209
|
+
findRoleNamesByMember(params) {
|
|
167
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
// ...(typeof params.sort?.productID === 'number')
|
|
176
|
-
// ? [{ $sort: { productID: params.sort.productID } }]
|
|
177
|
-
// : [],
|
|
178
|
-
...matchStages,
|
|
179
|
-
{
|
|
180
|
-
$unwind: {
|
|
181
|
-
path: '$member.hasRole'
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
$project: {
|
|
186
|
-
_id: 0,
|
|
187
|
-
roleName: '$member.hasRole.roleName'
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
]);
|
|
191
|
-
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
211
|
+
return this.memberModel.distinct('member.hasRole.roleName', {
|
|
212
|
+
'project.id': { $eq: params.project.id.$eq },
|
|
213
|
+
'member.id': { $eq: params.member.id.$eq },
|
|
214
|
+
'member.memberOf.id': { $eq: params.member.memberOf.id.$eq },
|
|
215
|
+
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq }
|
|
216
|
+
})
|
|
217
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
192
218
|
.exec();
|
|
193
219
|
});
|
|
194
220
|
}
|
|
@@ -293,7 +319,9 @@ class MemberRepo {
|
|
|
293
319
|
if (typeof params.page !== 'number') {
|
|
294
320
|
throw new factory.errors.ArgumentNull('page');
|
|
295
321
|
}
|
|
296
|
-
const matchStages = [
|
|
322
|
+
const matchStages = [
|
|
323
|
+
{ $match: { 'member.id': { $eq: params.member.id } } }
|
|
324
|
+
];
|
|
297
325
|
if (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') {
|
|
298
326
|
matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
|
|
299
327
|
}
|
|
@@ -343,6 +371,32 @@ class MemberRepo {
|
|
|
343
371
|
.exec();
|
|
344
372
|
});
|
|
345
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* グローバルメンバー作成
|
|
376
|
+
* 2025-07-21~
|
|
377
|
+
*/
|
|
378
|
+
createGlobalMember(params) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
+
if (params.length > 0) {
|
|
381
|
+
yield this.globalMemberModel.insertMany(params.map(({ typeOf, member }) => ({ typeOf, member })));
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
// no op
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* distinctコマンドを使用して、グローバルメンバーのロールを検索する
|
|
390
|
+
*/
|
|
391
|
+
findGlobalRoleNamesByMember(params) {
|
|
392
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
393
|
+
return this.globalMemberModel.distinct('member.hasRole.roleName', {
|
|
394
|
+
'member.id': { $eq: params.member.id.$eq }
|
|
395
|
+
})
|
|
396
|
+
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
397
|
+
.exec();
|
|
398
|
+
});
|
|
399
|
+
}
|
|
346
400
|
projectFields(params, inclusion) {
|
|
347
401
|
return __awaiter(this, void 0, void 0, function* () {
|
|
348
402
|
const conditions = MemberRepo.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
-
type IDocType = Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
|
|
3
|
+
type IDocType = Omit<factory.creativeWork.certification.softwareApplication.ICertification, 'id'> | Omit<factory.creativeWork.certification.webApplication.ICertification, 'id'>;
|
|
4
4
|
type IModel = Model<IDocType>;
|
|
5
5
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
6
|
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../../factory';
|
|
3
|
+
type IMemberOfRole = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'image' | 'name' | 'typeOf' | 'username'>;
|
|
4
|
+
type IGlobalMember = Pick<factory.iam.IMember, 'typeOf'> & {
|
|
5
|
+
member: IMemberOfRole;
|
|
6
|
+
};
|
|
7
|
+
type IDocType = IGlobalMember;
|
|
8
|
+
type IModel = Model<IDocType>;
|
|
9
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
10
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
11
|
+
declare const modelName = "Member.Global";
|
|
12
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
13
|
+
declare function createSchema(): ISchema;
|
|
14
|
+
export { createSchema, IGlobalMember, IModel, indexes, modelName };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = void 0;
|
|
4
|
+
exports.createSchema = createSchema;
|
|
5
|
+
const mongoose_1 = require("mongoose");
|
|
6
|
+
const writeConcern_1 = require("../../writeConcern");
|
|
7
|
+
const settings_1 = require("../../../../settings");
|
|
8
|
+
const modelName = 'Member.Global';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
// globalロール管理なのでprojectは不要
|
|
12
|
+
// project: {
|
|
13
|
+
// type: SchemaTypes.Mixed,
|
|
14
|
+
// required: true
|
|
15
|
+
// },
|
|
16
|
+
typeOf: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
member: {
|
|
21
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const schemaOptions = {
|
|
26
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
27
|
+
autoCreate: false,
|
|
28
|
+
collection: 'members.global',
|
|
29
|
+
id: true,
|
|
30
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
31
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
32
|
+
strict: true,
|
|
33
|
+
strictQuery: false,
|
|
34
|
+
timestamps: false,
|
|
35
|
+
versionKey: false,
|
|
36
|
+
toJSON: {
|
|
37
|
+
getters: false,
|
|
38
|
+
virtuals: false,
|
|
39
|
+
minimize: false,
|
|
40
|
+
versionKey: false
|
|
41
|
+
},
|
|
42
|
+
toObject: {
|
|
43
|
+
getters: false,
|
|
44
|
+
virtuals: true,
|
|
45
|
+
minimize: false,
|
|
46
|
+
versionKey: false
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const indexes = [
|
|
50
|
+
[
|
|
51
|
+
{ 'member.id': 1 },
|
|
52
|
+
{
|
|
53
|
+
name: 'uniqueIAMMember',
|
|
54
|
+
unique: true
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
{ 'member.hasRole.roleName': 1, 'member.id': 1 },
|
|
59
|
+
{
|
|
60
|
+
name: 'searchByMemberHasRoleRoleName',
|
|
61
|
+
partialFilterExpression: {
|
|
62
|
+
'member.hasRole.roleName': { $exists: true }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
];
|
|
67
|
+
exports.indexes = indexes;
|
|
68
|
+
/**
|
|
69
|
+
* グロバールIAMメンバースキーマ
|
|
70
|
+
*/
|
|
71
|
+
let schema;
|
|
72
|
+
function createSchema() {
|
|
73
|
+
if (schema === undefined) {
|
|
74
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
75
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
76
|
+
indexes.forEach((indexParams) => {
|
|
77
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return schema;
|
|
82
|
+
}
|
|
@@ -120,6 +120,15 @@ const indexes = [
|
|
|
120
120
|
'name.en': { $exists: true }
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
{ additionalProperty: 1, productID: 1 },
|
|
126
|
+
{
|
|
127
|
+
name: 'additionalProperty',
|
|
128
|
+
partialFilterExpression: {
|
|
129
|
+
additionalProperty: { $exists: true }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
123
132
|
]
|
|
124
133
|
];
|
|
125
134
|
exports.indexes = indexes;
|
|
@@ -13,6 +13,20 @@ interface IOnReservationStatusChanged {
|
|
|
13
13
|
*/
|
|
14
14
|
informReservation?: factory.project.IInformParams[];
|
|
15
15
|
}
|
|
16
|
+
interface IOnTaskStatusChanged {
|
|
17
|
+
/**
|
|
18
|
+
* AggService通知先
|
|
19
|
+
*/
|
|
20
|
+
informTask?: factory.project.IInformParams[];
|
|
21
|
+
/**
|
|
22
|
+
* 分析連携するtaskNameリスト
|
|
23
|
+
*/
|
|
24
|
+
informTaskNames?: factory.taskName[];
|
|
25
|
+
/**
|
|
26
|
+
* 分析連携するtaskStatusリスト
|
|
27
|
+
*/
|
|
28
|
+
informTaskStatuses?: factory.taskStatus[];
|
|
29
|
+
}
|
|
16
30
|
interface IOnEventChanged {
|
|
17
31
|
informEvent2agg?: factory.project.IInformParams[];
|
|
18
32
|
}
|
|
@@ -102,6 +116,7 @@ export interface ISetting {
|
|
|
102
116
|
onEventChanged?: IOnEventChanged;
|
|
103
117
|
onOrderStatusChanged: IOnOrderStatusChanged;
|
|
104
118
|
onReservationStatusChanged?: IOnReservationStatusChanged;
|
|
119
|
+
onTaskStatusChanged?: IOnTaskStatusChanged;
|
|
105
120
|
onResourceUpdated?: {
|
|
106
121
|
informResource?: factory.project.IInformParams[];
|
|
107
122
|
};
|
|
@@ -14,6 +14,7 @@ const schemaDefinition = {
|
|
|
14
14
|
onEventChanged: mongoose_1.SchemaTypes.Mixed,
|
|
15
15
|
onOrderStatusChanged: mongoose_1.SchemaTypes.Mixed,
|
|
16
16
|
onReservationStatusChanged: mongoose_1.SchemaTypes.Mixed,
|
|
17
|
+
onTaskStatusChanged: mongoose_1.SchemaTypes.Mixed,
|
|
17
18
|
onResourceUpdated: mongoose_1.SchemaTypes.Mixed,
|
|
18
19
|
onTransactionStatusChanged: mongoose_1.SchemaTypes.Mixed,
|
|
19
20
|
quota: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -186,6 +186,15 @@ const indexes = [
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
],
|
|
189
|
+
[
|
|
190
|
+
{ status: 1, lastTriedAt: 1, remainingNumberOfTries: 1, name: 1 },
|
|
191
|
+
{
|
|
192
|
+
name: 'abortMany',
|
|
193
|
+
partialFilterExpression: {
|
|
194
|
+
lastTriedAt: { $type: 'date' }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
],
|
|
189
198
|
[
|
|
190
199
|
{ status: 1, expires: 1 },
|
|
191
200
|
{
|
|
@@ -204,8 +204,8 @@ export declare class OrderRepo {
|
|
|
204
204
|
emailCount?: number;
|
|
205
205
|
};
|
|
206
206
|
}>;
|
|
207
|
-
|
|
208
|
-
project
|
|
207
|
+
aggregateOrderOfCustomerByProject(params: {
|
|
208
|
+
project?: {
|
|
209
209
|
id: {
|
|
210
210
|
$eq: string;
|
|
211
211
|
};
|
|
@@ -225,5 +225,20 @@ export declare class OrderRepo {
|
|
|
225
225
|
emailCount?: number;
|
|
226
226
|
};
|
|
227
227
|
}>;
|
|
228
|
+
aggregateOrderOfCustomerGlobally(params: {
|
|
229
|
+
orderDate: {
|
|
230
|
+
$gte: Date;
|
|
231
|
+
$lte: Date;
|
|
232
|
+
};
|
|
233
|
+
customer: {
|
|
234
|
+
email: {
|
|
235
|
+
$eq: string;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
}): Promise<{
|
|
239
|
+
aggregation: Pick<IAggregation, 'orderCount'> & {
|
|
240
|
+
sumGraceTime?: never;
|
|
241
|
+
};
|
|
242
|
+
}>;
|
|
228
243
|
}
|
|
229
244
|
export {};
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -1198,17 +1198,13 @@ class OrderRepo {
|
|
|
1198
1198
|
};
|
|
1199
1199
|
});
|
|
1200
1200
|
}
|
|
1201
|
-
|
|
1201
|
+
aggregateOrderOfCustomerByProject(params) {
|
|
1202
1202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1203
|
-
|
|
1204
|
-
|
|
1203
|
+
var _a;
|
|
1204
|
+
const matchConditions = Object.assign(Object.assign({ orderDate: {
|
|
1205
1205
|
$gte: params.orderDate.$gte,
|
|
1206
1206
|
$lte: params.orderDate.$lte
|
|
1207
|
-
},
|
|
1208
|
-
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1209
|
-
'project.id': { $eq: params.project.id.$eq },
|
|
1210
|
-
'customer.email': { $exists: true, $eq: params.customer.email.$eq }
|
|
1211
|
-
};
|
|
1207
|
+
}, typeOf: { $eq: factory.order.OrderType.Order } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string') ? { 'project.id': { $eq: params.project.id.$eq } } : undefined), { 'customer.email': { $exists: true, $eq: params.customer.email.$eq } });
|
|
1212
1208
|
const aggregations = yield this.orderModel.aggregate([
|
|
1213
1209
|
{ $match: matchConditions },
|
|
1214
1210
|
{
|
|
@@ -1250,5 +1246,48 @@ class OrderRepo {
|
|
|
1250
1246
|
};
|
|
1251
1247
|
});
|
|
1252
1248
|
}
|
|
1249
|
+
aggregateOrderOfCustomerGlobally(params) {
|
|
1250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1251
|
+
const matchConditions = {
|
|
1252
|
+
orderDate: {
|
|
1253
|
+
$gte: params.orderDate.$gte,
|
|
1254
|
+
$lte: params.orderDate.$lte
|
|
1255
|
+
},
|
|
1256
|
+
typeOf: { $eq: factory.order.OrderType.Order },
|
|
1257
|
+
'customer.email': { $exists: true, $eq: params.customer.email.$eq }
|
|
1258
|
+
};
|
|
1259
|
+
const aggregations = yield this.orderModel.aggregate([
|
|
1260
|
+
{ $match: matchConditions },
|
|
1261
|
+
{
|
|
1262
|
+
$project: {
|
|
1263
|
+
typeOf: '$typeOf'
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
$group: {
|
|
1268
|
+
_id: '$typeOf',
|
|
1269
|
+
orderCount: { $sum: 1 }
|
|
1270
|
+
}
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
$project: {
|
|
1274
|
+
_id: 0,
|
|
1275
|
+
orderCount: '$orderCount'
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
])
|
|
1279
|
+
.exec();
|
|
1280
|
+
if (aggregations.length === 0) {
|
|
1281
|
+
return {
|
|
1282
|
+
aggregation: {
|
|
1283
|
+
orderCount: 0
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
return {
|
|
1288
|
+
aggregation: Object.assign({}, aggregations[0])
|
|
1289
|
+
};
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1253
1292
|
}
|
|
1254
1293
|
exports.OrderRepo = OrderRepo;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
2
|
/**
|
|
4
3
|
* 注文番号リポジトリ
|
|
5
4
|
*/
|
|
6
5
|
export declare class OrderNumberRepo {
|
|
7
6
|
private readonly counterRepo;
|
|
8
7
|
constructor(params: {
|
|
9
|
-
redisClient: RedisClientType;
|
|
10
8
|
connection: Connection;
|
|
11
9
|
});
|
|
12
10
|
/**
|
|
@@ -21,5 +19,4 @@ export declare class OrderNumberRepo {
|
|
|
21
19
|
*/
|
|
22
20
|
orderDate: Date;
|
|
23
21
|
}): Promise<string>;
|
|
24
|
-
private useMongoBySettings;
|
|
25
22
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.OrderNumberRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
+
// import { RedisClientType } from 'redis';
|
|
15
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
17
|
const fpe = require('node-fpe');
|
|
17
18
|
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
@@ -52,27 +53,15 @@ class OrderNumberRepo {
|
|
|
52
53
|
let dataFeedExpires;
|
|
53
54
|
const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
|
|
54
55
|
let incrReply;
|
|
55
|
-
const useMongoBySettings =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
dataFeedExpires = moment(params.orderDate)
|
|
68
|
-
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
69
|
-
.toDate();
|
|
70
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
71
|
-
identifier: dataFeedIdentifier,
|
|
72
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
|
|
73
|
-
expires: dataFeedExpires
|
|
74
|
-
});
|
|
75
|
-
}
|
|
56
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
57
|
+
dataFeedExpires = moment(params.orderDate)
|
|
58
|
+
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
59
|
+
.toDate();
|
|
60
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
61
|
+
identifier: dataFeedIdentifier,
|
|
62
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.orderNumber },
|
|
63
|
+
expires: dataFeedExpires
|
|
64
|
+
});
|
|
76
65
|
let orderNumber = `${timestamp}${incrReply}`;
|
|
77
66
|
// checkdigit
|
|
78
67
|
const cd = cdigit.luhn.compute(orderNumber);
|
|
@@ -90,28 +79,5 @@ class OrderNumberRepo {
|
|
|
90
79
|
return orderNumber;
|
|
91
80
|
});
|
|
92
81
|
}
|
|
93
|
-
// /**
|
|
94
|
-
// * DB移行時のみに使用目的の設定更新
|
|
95
|
-
// */
|
|
96
|
-
// public async setUseMongo4orderNumberFrom(params: {
|
|
97
|
-
// useMongo4orderNumberFrom: Date;
|
|
98
|
-
// }) {
|
|
99
|
-
// const { useMongo4orderNumberFrom } = params;
|
|
100
|
-
// return this.settingModel.findOneAndUpdate(
|
|
101
|
-
// { 'project.id': { $eq: '*' } },
|
|
102
|
-
// {
|
|
103
|
-
// $set: { useMongo4orderNumberFrom }
|
|
104
|
-
// },
|
|
105
|
-
// { projection: { _id: 0, useMongo4orderNumberFrom: 1 } }
|
|
106
|
-
// )
|
|
107
|
-
// .lean<Pick<ISetting, 'useMongo4orderNumberFrom'> | null>()
|
|
108
|
-
// .exec();
|
|
109
|
-
// }
|
|
110
|
-
// tslint:disable-next-line:prefer-function-over-method
|
|
111
|
-
useMongoBySettings(__) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return true;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
82
|
}
|
|
117
83
|
exports.OrderNumberRepo = OrderNumberRepo;
|
|
@@ -48,7 +48,7 @@ class ProductRepo {
|
|
|
48
48
|
}
|
|
49
49
|
// tslint:disable-next-line:max-func-body-length
|
|
50
50
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
52
52
|
// MongoDB検索条件
|
|
53
53
|
const andConditions = [];
|
|
54
54
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -151,25 +151,20 @@ class ProductRepo {
|
|
|
151
151
|
const nameRegexExp = new RegExp(nameRegex);
|
|
152
152
|
andConditions.push({
|
|
153
153
|
$or: [
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
$exists: true,
|
|
157
|
-
$regex: nameRegexExp
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
'name.en': {
|
|
162
|
-
$exists: true,
|
|
163
|
-
$regex: nameRegexExp
|
|
164
|
-
}
|
|
165
|
-
}
|
|
154
|
+
{ 'name.ja': { $exists: true, $regex: nameRegexExp } },
|
|
155
|
+
{ 'name.en': { $exists: true, $regex: nameRegexExp } }
|
|
166
156
|
]
|
|
167
157
|
});
|
|
168
158
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
159
|
+
const additionalPropertyElemMatchNameEq = (_w = params.additionalPropertyMatch) === null || _w === void 0 ? void 0 : _w.nameEq;
|
|
160
|
+
if (typeof additionalPropertyElemMatchNameEq === 'string') {
|
|
161
|
+
andConditions.push({
|
|
162
|
+
additionalProperty: {
|
|
163
|
+
$exists: true,
|
|
164
|
+
$elemMatch: { name: { $eq: additionalPropertyElemMatchNameEq } }
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
173
168
|
return andConditions;
|
|
174
169
|
}
|
|
175
170
|
/**
|