@chevre/domain 22.11.0-alpha.8 → 22.11.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/aggregation/aggregateOrderOfCustomer.ts +21 -10
- package/example/src/chevre/aggregation/aggregateTasks.ts +41 -0
- 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/addEventOfferPermissionIfNotExists.ts +27 -0
- package/example/src/chevre/roles/{addAdminInventoryManagerRole.ts → addProjectCreatorRole.ts} +6 -8
- 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/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/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/pendingReservation.js +1 -0
- package/lib/chevre/repo/product.js +12 -17
- package/lib/chevre/repo/role.d.ts +13 -4
- package/lib/chevre/repo/role.js +52 -32
- package/lib/chevre/repo/setting.d.ts +1 -10
- package/lib/chevre/repo/setting.js +2 -11
- package/lib/chevre/repo/stockHolder.d.ts +4 -27
- package/lib/chevre/repo/stockHolder.js +163 -175
- 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/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/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/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/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/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/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/refund.d.ts +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/returnOrder.d.ts +1 -1
- package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
- package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.d.ts +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 +1 -1
- 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.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 -186
- package/example/src/chevre/stockHolder/migratePendingReservations.ts +0 -96
- package/example/src/chevre/stockHolder/playAroundStockHolder.ts +0 -256
- package/example/src/chevre/upsertProductsByProductId.ts +0 -100
- package/lib/chevre/adminAuth.d.ts +0 -2
- package/lib/chevre/adminAuth.js +0 -6
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { SignJWT } from 'jose';
|
|
5
|
+
import * as uuid from 'uuid';
|
|
6
|
+
|
|
7
|
+
const PRIVATE_KEY_FILE_PATH = `${__dirname}/../../samplePrivateKey.pem`;
|
|
8
|
+
|
|
9
|
+
interface IAuth0Config {
|
|
10
|
+
auth0Domain: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
privateKeyContent: string; // PEM形式の秘密鍵の内容 (例: fs.readFileSync('private_key.pem', 'utf8'))
|
|
13
|
+
audience: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 環境変数から機密情報を取得することを強く推奨します
|
|
17
|
+
const auth0config: IAuth0Config = {
|
|
18
|
+
auth0Domain: String(process.env.AUTH0_DOMAIN),
|
|
19
|
+
clientId: String(process.env.AUTH0_CLIENT_ID),
|
|
20
|
+
// keyId: 'xxx',
|
|
21
|
+
privateKeyContent: readFileSync(PRIVATE_KEY_FILE_PATH, 'utf8'), // 秘密鍵の内容を読み込む
|
|
22
|
+
audience: String(process.env.AUTH0_AUDIENCE)
|
|
23
|
+
// scopes: process.env.OKTA_SCOPES || 'api_access_scope openid', // 必要なスコープを指定
|
|
24
|
+
// authServerId: 'aussd9v86wlIar3cX697', // デフォルト承認サーバーを使用する場合はコメントアウトまたは指定しない
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
async function generateJwtAssertion(config: IAuth0Config) {
|
|
28
|
+
const privateKeyPEM = crypto.createPrivateKey(readFileSync(PRIVATE_KEY_FILE_PATH, 'utf8'));
|
|
29
|
+
|
|
30
|
+
return new SignJWT({})
|
|
31
|
+
.setProtectedHeader({
|
|
32
|
+
alg: 'RS256' // or RS384 or PS256
|
|
33
|
+
// kid: '(OPTIONAL) KID_GENERATED_BY_AUTH0'
|
|
34
|
+
})
|
|
35
|
+
.setIssuedAt()
|
|
36
|
+
.setIssuer(config.clientId)
|
|
37
|
+
.setSubject(config.clientId)
|
|
38
|
+
.setAudience(`https://${config.auth0Domain}/`)
|
|
39
|
+
.setExpirationTime('1m')
|
|
40
|
+
.setJti(uuid.v4())
|
|
41
|
+
.sign(privateKeyPEM);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function getToken() {
|
|
45
|
+
try {
|
|
46
|
+
const jwtAssertion = await generateJwtAssertion(auth0config);
|
|
47
|
+
console.log('jwtAssertion:', jwtAssertion);
|
|
48
|
+
|
|
49
|
+
const body = new URLSearchParams({
|
|
50
|
+
grant_type: 'client_credentials',
|
|
51
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
|
52
|
+
client_assertion: jwtAssertion,
|
|
53
|
+
audience: auth0config.audience
|
|
54
|
+
// scope: config.scopes,
|
|
55
|
+
}).toString();
|
|
56
|
+
const response = await fetch(
|
|
57
|
+
`https://${auth0config.auth0Domain}/oauth/token`,
|
|
58
|
+
{
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
61
|
+
body: body
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
console.log(await response.json());
|
|
66
|
+
throw new Error('Network response was not ok');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const data = await response.json();
|
|
70
|
+
console.log(data);
|
|
71
|
+
|
|
72
|
+
return data;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error fetching token:', error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function main() {
|
|
79
|
+
const token = await getToken();
|
|
80
|
+
console.log(token);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main()
|
|
84
|
+
.catch(console.error);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
const projectIdMustBe = /^[0-9a-z-]+$/; // 記号はhyphenのみ許可
|
|
3
|
+
|
|
4
|
+
let projectId: string;
|
|
5
|
+
|
|
6
|
+
projectId = 'projectId';
|
|
7
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
8
|
+
|
|
9
|
+
projectId = 'projectid';
|
|
10
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
11
|
+
|
|
12
|
+
projectId = 'abcd1234-test';
|
|
13
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
14
|
+
|
|
15
|
+
projectId = 'a-z';
|
|
16
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
17
|
+
|
|
18
|
+
projectId = '0-9';
|
|
19
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
20
|
+
|
|
21
|
+
projectId = '---';
|
|
22
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
23
|
+
|
|
24
|
+
projectId = '-';
|
|
25
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
26
|
+
|
|
27
|
+
projectId = '&';
|
|
28
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
29
|
+
|
|
30
|
+
projectId = 'A';
|
|
31
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
@@ -12,30 +12,53 @@ interface IExecuteSettings {
|
|
|
12
12
|
*/
|
|
13
13
|
redisClient?: RedisClientType;
|
|
14
14
|
}
|
|
15
|
-
type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
16
|
-
type INextFunction = (task: Pick<factory.task.ITask<factory.taskName>, 'id'>) => IOperationExecute<void>;
|
|
17
15
|
interface IReadyTask {
|
|
18
16
|
id: string;
|
|
19
17
|
name?: factory.taskName;
|
|
20
18
|
status: factory.taskStatus.Ready;
|
|
19
|
+
remainingNumberOfTries?: never;
|
|
21
20
|
expires?: Date;
|
|
22
21
|
executionResult?: never;
|
|
23
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* タスク名不明の遅延実行中タスク
|
|
25
|
+
*/
|
|
24
26
|
interface IRunningTask {
|
|
25
27
|
id: string;
|
|
26
28
|
status: factory.taskStatus.Running;
|
|
27
29
|
name?: never;
|
|
30
|
+
remainingNumberOfTries?: never;
|
|
31
|
+
expires?: never;
|
|
32
|
+
executionResult?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* タスク名指定での遅延実行中タスク
|
|
36
|
+
*/
|
|
37
|
+
interface IRunningTaskByName {
|
|
38
|
+
id: string;
|
|
39
|
+
status: factory.taskStatus.Running;
|
|
40
|
+
name: factory.taskName;
|
|
41
|
+
remainingNumberOfTries?: never;
|
|
28
42
|
expires?: never;
|
|
29
43
|
executionResult?: never;
|
|
30
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* 実行後タスクイベント
|
|
47
|
+
*/
|
|
31
48
|
interface IExecutedTask {
|
|
32
49
|
id: string;
|
|
33
|
-
status: factory.taskStatus;
|
|
50
|
+
status: factory.taskStatus.Executed | factory.taskStatus.Running | factory.taskStatus.Aborted;
|
|
51
|
+
name: factory.taskName;
|
|
34
52
|
executionResult: factory.task.IExecutionResult;
|
|
35
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 実行されたタスクの残り試行回数
|
|
55
|
+
*/
|
|
56
|
+
remainingNumberOfTries: number;
|
|
36
57
|
expires?: never;
|
|
37
58
|
}
|
|
38
|
-
type IChangedTask = IReadyTask | IRunningTask | IExecutedTask;
|
|
59
|
+
type IChangedTask = IReadyTask | IRunningTask | IRunningTaskByName | IExecutedTask;
|
|
60
|
+
type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
61
|
+
type INextFunction = (task: IExecutedTask) => IOperationExecute<void>;
|
|
39
62
|
type IOnTaskStatusChangedListener = (task: IChangedTask, next?: INextFunction) => void;
|
|
40
63
|
/**
|
|
41
64
|
* タスクイベントエミッター
|
|
@@ -45,4 +68,4 @@ declare class TaskEventEmitter extends EventEmitter {
|
|
|
45
68
|
emitTaskStatusChanged(task: IChangedTask, next?: INextFunction): void;
|
|
46
69
|
}
|
|
47
70
|
declare const taskEventEmitter: TaskEventEmitter;
|
|
48
|
-
export { IChangedTask, IReadyTask, IRunningTask, IExecutedTask, IExecuteSettings, INextFunction, IOnTaskStatusChangedListener, taskEventEmitter };
|
|
71
|
+
export { IChangedTask, IReadyTask, IRunningTask, IRunningTaskByName, IExecutedTask, IExecuteSettings, INextFunction, IOnTaskStatusChangedListener, taskEventEmitter };
|
package/lib/chevre/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as COAService from '@motionpicture/coa-service';
|
|
5
5
|
import type * as GMOService from '@motionpicture/gmo-service';
|
|
6
|
-
import type * as AdminAuth from './adminAuth';
|
|
7
6
|
import type * as Pecorinoapi from './pecorinoapi';
|
|
8
7
|
import { credentials } from './credentials';
|
|
9
8
|
import * as errorHandler from './errorHandler';
|
|
@@ -13,7 +12,6 @@ import * as repository from './repository';
|
|
|
13
12
|
import * as service from './service';
|
|
14
13
|
import * as settings from './settings';
|
|
15
14
|
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings };
|
|
16
|
-
export declare function loadAdminAuth(): Promise<typeof AdminAuth>;
|
|
17
15
|
export declare function loadPecorinoapi(): Promise<typeof Pecorinoapi>;
|
|
18
16
|
export type COA = typeof COAService;
|
|
19
17
|
export declare function loadCOA(): Promise<typeof COAService>;
|
package/lib/chevre/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.settings = exports.service = exports.repository = exports.factory = exports.eventEmitter = exports.errorHandler = exports.credentials = void 0;
|
|
13
|
-
exports.loadAdminAuth = loadAdminAuth;
|
|
14
13
|
exports.loadPecorinoapi = loadPecorinoapi;
|
|
15
14
|
exports.loadCOA = loadCOA;
|
|
16
15
|
exports.loadGMO = loadGMO;
|
|
@@ -28,15 +27,6 @@ const service = require("./service");
|
|
|
28
27
|
exports.service = service;
|
|
29
28
|
const settings = require("./settings");
|
|
30
29
|
exports.settings = settings;
|
|
31
|
-
let adminAuth;
|
|
32
|
-
function loadAdminAuth() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
if (adminAuth === undefined) {
|
|
35
|
-
adminAuth = yield Promise.resolve().then(() => require('./adminAuth'));
|
|
36
|
-
}
|
|
37
|
-
return adminAuth;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
30
|
let pecorinoapi;
|
|
41
31
|
function loadPecorinoapi() {
|
|
42
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Connection, FilterQuery, QueryOptions } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
|
|
3
|
+
type ISavingSoftwareApplicationIdentity = Pick<factory.creativeWork.certification.softwareApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
4
|
+
type ISavingWebApplicationIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
5
|
+
export type ISavingIdentity = (ISavingSoftwareApplicationIdentity | ISavingWebApplicationIdentity) & {
|
|
4
6
|
id?: never;
|
|
5
7
|
dateCreated?: never;
|
|
6
8
|
dateModified?: never;
|
|
@@ -11,7 +13,7 @@ interface IUnset {
|
|
|
11
13
|
[key: string]: 1;
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
|
-
type IIdentityWithId = factory.creativeWork.certification.webApplication.ICertification & {
|
|
16
|
+
type IIdentityWithId = (factory.creativeWork.certification.softwareApplication.ICertification | factory.creativeWork.certification.webApplication.ICertification) & {
|
|
15
17
|
id: string;
|
|
16
18
|
};
|
|
17
19
|
type IKeyOfProjection = keyof factory.creativeWork.certification.webApplication.ICertification;
|
|
@@ -35,39 +37,15 @@ export declare class IdentityRepo {
|
|
|
35
37
|
id: string;
|
|
36
38
|
};
|
|
37
39
|
}): Promise<void>;
|
|
38
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
39
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
40
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
41
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
42
|
-
dateCreated?: Date | undefined;
|
|
43
|
-
dateModified?: Date | undefined;
|
|
44
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
45
|
-
}> & {
|
|
46
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
47
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
48
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
49
|
-
dateCreated?: Date | undefined;
|
|
50
|
-
dateModified?: Date | undefined;
|
|
51
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
52
|
-
} & {
|
|
40
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
53
41
|
_id: import("mongoose").Types.ObjectId;
|
|
54
|
-
}
|
|
55
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
56
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
57
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
58
|
-
dateCreated?: Date | undefined;
|
|
59
|
-
dateModified?: Date | undefined;
|
|
60
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
61
|
-
}> & {
|
|
62
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
63
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
64
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
65
|
-
dateCreated?: Date | undefined;
|
|
66
|
-
dateModified?: Date | undefined;
|
|
67
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
68
|
-
} & {
|
|
42
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
69
43
|
_id: import("mongoose").Types.ObjectId;
|
|
70
|
-
}
|
|
44
|
+
})), QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
45
|
+
_id: import("mongoose").Types.ObjectId;
|
|
46
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
47
|
+
_id: import("mongoose").Types.ObjectId;
|
|
48
|
+
}))>>;
|
|
71
49
|
updateIssuedBy2array(params: Pick<ISavingIdentity, 'issuedBy'> & {
|
|
72
50
|
id: string;
|
|
73
51
|
}): Promise<void>;
|
|
@@ -8,17 +8,6 @@ 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
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.IdentityRepo = void 0;
|
|
24
13
|
const factory = require("../factory");
|
|
@@ -76,12 +65,15 @@ class IdentityRepo {
|
|
|
76
65
|
throw new factory.errors.ArgumentNull('id');
|
|
77
66
|
}
|
|
78
67
|
// issuedByのみ更新可能
|
|
79
|
-
const
|
|
68
|
+
const { project, $unset, issuedBy } = params.attributes;
|
|
80
69
|
const filter = {
|
|
81
70
|
_id: { $eq: savingId },
|
|
82
71
|
'project.id': { $eq: project.id }
|
|
83
72
|
};
|
|
84
|
-
const update = Object.assign({ $set:
|
|
73
|
+
const update = Object.assign({ $set: {
|
|
74
|
+
issuedBy,
|
|
75
|
+
dateModified: new Date()
|
|
76
|
+
} }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
85
77
|
const options = {
|
|
86
78
|
upsert: false,
|
|
87
79
|
new: true,
|
|
@@ -96,8 +88,11 @@ class IdentityRepo {
|
|
|
96
88
|
savedId = savingId;
|
|
97
89
|
}
|
|
98
90
|
else {
|
|
99
|
-
const
|
|
100
|
-
const result = yield this.identityModel.insertMany(
|
|
91
|
+
const { typeOf, about, project, issuedBy } = params.attributes;
|
|
92
|
+
const result = yield this.identityModel.insertMany({
|
|
93
|
+
typeOf, about, project, issuedBy,
|
|
94
|
+
dateCreated: new Date()
|
|
95
|
+
}, { rawResult: true });
|
|
101
96
|
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
102
97
|
if (typeof insertedId !== 'string') {
|
|
103
98
|
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
@@ -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
|
+
}
|