Merged PR 624: クエリログに追跡用IDと実行日時を追加する(各作業まとめブランチ)
## 概要 [Task3309: 修正をまとめる用のブランチ](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3309) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど - このPull Requestでの対象/対象外 - 影響範囲(他の機能にも影響があるか) ## レビューポイント - 特にレビューしてほしい箇所 - 軽微なものや自明なものは記載不要 - 修正範囲が大きい場合などに記載 - 全体的にや仕様を満たしているか等は本当に必要な時のみ記載 ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 ## 動作確認状況 - ローカルで確認、develop環境で確認など ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
b8b3416795
commit
45b2cad30c
143
dictation_server/src/common/repository/index.ts
Normal file
143
dictation_server/src/common/repository/index.ts
Normal file
@ -0,0 +1,143 @@
|
||||
import {
|
||||
ObjectLiteral,
|
||||
Repository,
|
||||
EntityTarget,
|
||||
UpdateResult,
|
||||
DeleteResult,
|
||||
UpdateQueryBuilder,
|
||||
Brackets,
|
||||
FindOptionsWhere,
|
||||
} from 'typeorm';
|
||||
import { Context } from '../log';
|
||||
|
||||
/**
|
||||
* VS Code上で型解析エラーが発生するため、typeorm内の型定義と同一の型定義をここに記述する
|
||||
*/
|
||||
type QueryDeepPartialEntity<T> = _QueryDeepPartialEntity<
|
||||
ObjectLiteral extends T ? unknown : T
|
||||
>;
|
||||
type _QueryDeepPartialEntity<T> = {
|
||||
[P in keyof T]?:
|
||||
| (T[P] extends Array<infer U>
|
||||
? Array<_QueryDeepPartialEntity<U>>
|
||||
: T[P] extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<_QueryDeepPartialEntity<U>>
|
||||
: _QueryDeepPartialEntity<T[P]>)
|
||||
| (() => string);
|
||||
};
|
||||
|
||||
interface InsertEntityOptions {
|
||||
id: number;
|
||||
}
|
||||
|
||||
const insertEntity = async <T extends InsertEntityOptions & ObjectLiteral>(
|
||||
entity: EntityTarget<T>,
|
||||
repository: Repository<T>,
|
||||
value: QueryDeepPartialEntity<T>,
|
||||
isCommentOut: boolean,
|
||||
context: Context,
|
||||
): Promise<T> => {
|
||||
let query = repository.createQueryBuilder().insert().into(entity);
|
||||
if (isCommentOut) {
|
||||
query = query.comment(
|
||||
`${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
);
|
||||
}
|
||||
const result = await query.values(value).execute();
|
||||
// result.identifiers[0].idがnumber型でない場合はエラー
|
||||
if (typeof result.identifiers[0].id !== 'number') {
|
||||
throw new Error('Failed to insert entity');
|
||||
}
|
||||
const where: FindOptionsWhere<T> = { id: result.identifiers[0].id } as T;
|
||||
|
||||
// 結果をもとにセレクトする
|
||||
const inserted = await repository.findOne({
|
||||
where,
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
if (!inserted) {
|
||||
throw new Error('Failed to insert entity');
|
||||
}
|
||||
return inserted;
|
||||
};
|
||||
|
||||
const insertEntities = async <T extends InsertEntityOptions & ObjectLiteral>(
|
||||
entity: EntityTarget<T>,
|
||||
repository: Repository<T>,
|
||||
values: QueryDeepPartialEntity<T>[],
|
||||
isCommentOut: boolean,
|
||||
context: Context,
|
||||
): Promise<T[]> => {
|
||||
let query = repository.createQueryBuilder().insert().into(entity);
|
||||
if (isCommentOut) {
|
||||
query = query.comment(
|
||||
`${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
);
|
||||
}
|
||||
const result = await query.values(values).execute();
|
||||
|
||||
// 挿入するレコードが0で、結果も0であれば、からの配列を返す
|
||||
if (values.length === 0 && result.identifiers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 挿入するレコード数と挿入されたレコード数が一致しない場合はエラー
|
||||
if (result.identifiers.length !== values.length) {
|
||||
throw new Error('Failed to insert entities');
|
||||
}
|
||||
const where: FindOptionsWhere<T>[] = result.identifiers.map((i) => {
|
||||
// idがnumber型でない場合はエラー
|
||||
if (typeof i.id !== 'number') {
|
||||
throw new Error('Failed to insert entities');
|
||||
}
|
||||
return { id: i.id } as T;
|
||||
});
|
||||
|
||||
// 結果をもとにセレクトする
|
||||
const inserted = await repository.find({
|
||||
where,
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
if (!inserted) {
|
||||
throw new Error('Failed to insert entity');
|
||||
}
|
||||
return inserted;
|
||||
};
|
||||
|
||||
const updateEntity = async <T extends ObjectLiteral>(
|
||||
repository: Repository<T>,
|
||||
criteria:
|
||||
| string
|
||||
| ((qb: UpdateQueryBuilder<T>) => string)
|
||||
| Brackets
|
||||
| ObjectLiteral
|
||||
| ObjectLiteral[],
|
||||
values: QueryDeepPartialEntity<T>,
|
||||
isCommentOut: boolean,
|
||||
context: Context,
|
||||
): Promise<UpdateResult> => {
|
||||
let query = repository.createQueryBuilder().update();
|
||||
if (isCommentOut) {
|
||||
query = query.comment(
|
||||
`${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
);
|
||||
}
|
||||
return await query.set(values).where(criteria).execute();
|
||||
};
|
||||
|
||||
const deleteEntity = async <T extends ObjectLiteral>(
|
||||
repository: Repository<T>,
|
||||
criteria: string | Brackets | ObjectLiteral | ObjectLiteral[],
|
||||
isCommentOut: boolean,
|
||||
context: Context,
|
||||
): Promise<DeleteResult> => {
|
||||
let query = repository.createQueryBuilder().delete();
|
||||
if (isCommentOut) {
|
||||
query = query.comment(
|
||||
`${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
);
|
||||
}
|
||||
return await query.where(criteria).execute();
|
||||
};
|
||||
|
||||
export { insertEntity, insertEntities, updateEntity, deleteEntity };
|
||||
File diff suppressed because it is too large
Load Diff
@ -229,6 +229,7 @@ export class AccountsService {
|
||||
// アカウントと管理者をセットで作成
|
||||
const { newAccount, adminUser } =
|
||||
await this.accountRepository.createAccount(
|
||||
context,
|
||||
companyName,
|
||||
country,
|
||||
dealerAccountId,
|
||||
@ -377,7 +378,7 @@ export class AccountsService {
|
||||
} | params: { accountId: ${accountId}, userId: ${userId} };`,
|
||||
);
|
||||
try {
|
||||
await this.accountRepository.deleteAccount(accountId, userId);
|
||||
await this.accountRepository.deleteAccount(context, accountId, userId);
|
||||
this.logger.log(
|
||||
`[${context.getTrackingId()}] delete account: ${accountId}, user: ${userId}`,
|
||||
);
|
||||
@ -801,6 +802,7 @@ export class AccountsService {
|
||||
// アカウントと管理者をセットで作成
|
||||
const { newAccount, adminUser } =
|
||||
await this.accountRepository.createAccount(
|
||||
context,
|
||||
companyName,
|
||||
country,
|
||||
myAccountId,
|
||||
|
||||
@ -31,7 +31,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.RyieW-VHsHPQOjXbbhRc307AYJOc1sq2hrcu4SW1-K0pvLlkplepxvx02a3vCwQrnBYrIP5w6HExG-S_JgW5nYyWr6DeY11mA484n9KA8GeAcAXV37StH1gfWUJvfGb4C8BaMbMM9Ix4Z9NGwKA9vjNwevfmBZnz9lQUePgv6BJNmyvCt8ElJ01O-1WODbZuojJ4xXymA1OqluzfbphPOsqWTSNmTn0emkLjjnlMQf1iwM4C_kvvr8dUCFg0_UGDfQVJnzPEKB38UqnhLnC5WacrddDwQ0kBuGKZgZ_63Q_7fOvqAZivqLK7BPmbPxi6mx3R1S9Eq2ugzpY1LfJOjA';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(await service.getVerifiedIdToken(context, token)).toEqual(
|
||||
idTokenPayload,
|
||||
);
|
||||
@ -43,7 +43,7 @@ describe('AuthService', () => {
|
||||
const service = await makeAuthServiceMock(adb2cParam, configMockValue);
|
||||
const token = 'invalid.id.token';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000101'), HttpStatus.UNAUTHORIZED),
|
||||
);
|
||||
@ -58,7 +58,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjEwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.r9x61Mf1S2qFgU_QDKB6tRFBmTQXyOEtpoacOlL_bQzFz1t3GsxMy6SJIvQQ-LtDgylQ1UCdMFiRuy4V8nyLuME0fR-9IkKsboGvwllHB_Isai3XFoja0jpDHMVby1m0B3Z9xOTb7YsaQGyEH-qs1TtnRm6Ny98h4Po80nK8HGefQZHBOlfQN_B1LiHwI3nLXV18NL-4olKXj2NloNRYtnWM0PaqDQcGvZFaSNvtrSYpo9ddD906QWDGVOQ7WvGSUgdNCoxX8Lb3r2-VSj6n84jpb-Y1Fz-GhLluNglAsBhasnJfUIvCIO3iG5pRyTYjHFAVHmzjr8xMOmhS3s41Jw';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000102'), HttpStatus.UNAUTHORIZED),
|
||||
);
|
||||
@ -73,7 +73,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6OTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.fX2Gbd7fDPNE3Lw-xbum_5CVqQYqEmMhv_v5u8A-U81pmPD2P5rsJEJx66ns1taFLVaE3j9_OzotxrqjqqQqbACkagGcN5wvA3_ZIxyqmhrKYFJc53ZcO7d0pFWiQlluNBI_pnFNDlSMB2Ut8Th5aiPy2uamBM9wC99bcjo7HkHvTKBf6ljU6rPKoD51qGDWqNxjoH-hdSJ29wprvyxyk_yX6dp-cxXUj5DIgXYQuIZF71rdiPtGlAiyTBns8rS2QlEEXapZVlvYrK4mkpUXVDA7ifD8q6gAC2BStqHeys7CGp2MbV4ZwKCVbAUbMs6Tboh8rADZvQhuTEq7qlhZ-w';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000103'), HttpStatus.UNAUTHORIZED),
|
||||
);
|
||||
@ -86,7 +86,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdXNlciIsInN1YiI6InN1YiIsImF1ZCI6ImF1ZCIsIm5vbmNlIjoiZGVmYXVsdE5vbmNlIiwiaWF0IjoxMDAwMDAwMDAwLCJhdXRoX3RpbWUiOjEwMDAwMDAwMDAsImVtYWlscyI6WyJ4eHhAeHguY29tIl0sInRmcCI6InNpZ25pbl91c2VyZmxvdyJ9.sign';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000104'), HttpStatus.UNAUTHORIZED),
|
||||
);
|
||||
@ -101,7 +101,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaW52bGlkX2lzc3VlciIsInN1YiI6InN1YiIsImF1ZCI6ImF1ZCIsIm5vbmNlIjoiZGVmYXVsdE5vbmNlIiwiaWF0IjoxMDAwMDAwMDAwLCJhdXRoX3RpbWUiOjEwMDAwMDAwMDAsImVtYWlscyI6WyJ4eHhAeHguY29tIl0sInRmcCI6InNpZ25pbl91c2VyZmxvdyJ9.0bp3e1mDG78PX3lo8zgOLXGenIqG_Vi6kw7CbwauAQM-cnUZ_aVCoJ_dAv_QmPElOQKcCkRrAvAZ91FwuHDlBGuuDqx8OwqN0VaD-4NPouoAswj-9HNvBm8gUn-pGaXkvWt_72UdCJavZJjDj_RHur8y8kFt5Qeab3mUP2x-uNcV2Q2x3M_IIfcRiIZkRZm_azKfiVIy7tzoUFLDss97y938aR8imMVxazoSQvj7RWIWylgeRr9yVt7qYl18cnEVL0IGtslFbqhfNsiEmRCMsttm5kXs7E9B0bhhUe_xbJW9VumQ6G7dgMrswevp_jRgbpWJoZsgErtqIRl9Tc9ikA';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000105'), HttpStatus.UNAUTHORIZED),
|
||||
);
|
||||
@ -115,7 +115,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.RyieW-VHsHPQOjXbbhRc307AYJOc1sq2hrcu4SW1-K0pvLlkplepxvx02a3vCwQrnBYrIP5w6HExG-S_JgW5nYyWr6DeY11mA484n9KA8GeAcAXV37StH1gfWUJvfGb4C8BaMbMM9Ix4Z9NGwKA9vjNwevfmBZnz9lQUePgv6BJNmyvCt8ElJ01O-1WODbZuojJ4xXymA1OqluzfbphPOsqWTSNmTn0emkLjjnlMQf1iwM4C_kvvr8dUCFg0_UGDfQVJnzPEKB38UqnhLnC5WacrddDwQ0kBuGKZgZ_63Q_7fOvqAZivqLK7BPmbPxi6mx3R1S9Eq2ugzpY1LfJOjA';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -131,7 +131,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.RyieW-VHsHPQOjXbbhRc307AYJOc1sq2hrcu4SW1-K0pvLlkplepxvx02a3vCwQrnBYrIP5w6HExG-S_JgW5nYyWr6DeY11mA484n9KA8GeAcAXV37StH1gfWUJvfGb4C8BaMbMM9Ix4Z9NGwKA9vjNwevfmBZnz9lQUePgv6BJNmyvCt8ElJ01O-1WODbZuojJ4xXymA1OqluzfbphPOsqWTSNmTn0emkLjjnlMQf1iwM4C_kvvr8dUCFg0_UGDfQVJnzPEKB38UqnhLnC5WacrddDwQ0kBuGKZgZ_63Q_7fOvqAZivqLK7BPmbPxi6mx3R1S9Eq2ugzpY1LfJOjA';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -150,7 +150,7 @@ describe('AuthService', () => {
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtpZCJ9.eyJleHAiOjkwMDAwMDAwMDAsIm5iZiI6MTAwMDAwMDAwMCwidmVyIjoiMS4wIiwiaXNzIjoiaXNzdWVyIiwic3ViIjoic3ViIiwiYXVkIjoiYXVkIiwibm9uY2UiOiJkZWZhdWx0Tm9uY2UiLCJpYXQiOjEwMDAwMDAwMDAsImF1dGhfdGltZSI6MTAwMDAwMDAwMCwiZW1haWxzIjpbInh4eEB4eC5jb20iXSwidGZwIjoic2lnbmluX3VzZXJmbG93In0.RyieW-VHsHPQOjXbbhRc307AYJOc1sq2hrcu4SW1-K0pvLlkplepxvx02a3vCwQrnBYrIP5w6HExG-S_JgW5nYyWr6DeY11mA484n9KA8GeAcAXV37StH1gfWUJvfGb4C8BaMbMM9Ix4Z9NGwKA9vjNwevfmBZnz9lQUePgv6BJNmyvCt8ElJ01O-1WODbZuojJ4xXymA1OqluzfbphPOsqWTSNmTn0emkLjjnlMQf1iwM4C_kvvr8dUCFg0_UGDfQVJnzPEKB38UqnhLnC5WacrddDwQ0kBuGKZgZ_63Q_7fOvqAZivqLK7BPmbPxi6mx3R1S9Eq2ugzpY1LfJOjA';
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.getVerifiedIdToken(context, token)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -186,7 +186,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 5,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -210,7 +210,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -234,7 +234,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 5,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -258,7 +258,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -282,7 +282,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -306,7 +306,7 @@ describe('checkIsAcceptedLatestVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const idToken = {
|
||||
emails: [],
|
||||
@ -361,11 +361,7 @@ describe('generateDelegationRefreshToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
const delegationRefreshToken = await service.generateDelegationRefreshToken(
|
||||
context,
|
||||
@ -403,11 +399,7 @@ describe('generateDelegationRefreshToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
try {
|
||||
await service.generateDelegationRefreshToken(
|
||||
@ -445,11 +437,7 @@ describe('generateDelegationRefreshToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
try {
|
||||
await service.generateDelegationRefreshToken(
|
||||
@ -507,11 +495,7 @@ describe('generateDelegationAccessToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
const delegationRefreshToken = await service.generateDelegationRefreshToken(
|
||||
context,
|
||||
@ -556,11 +540,7 @@ describe('generateDelegationAccessToken', () => {
|
||||
tier: 4,
|
||||
});
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
try {
|
||||
await service.generateDelegationAccessToken(context, 'invalid token');
|
||||
@ -615,11 +595,7 @@ describe('updateDelegationAccessToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
const delegationRefreshToken = await service.generateDelegationRefreshToken(
|
||||
context,
|
||||
@ -677,11 +653,7 @@ describe('updateDelegationAccessToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
const delegationRefreshToken = await service.generateDelegationRefreshToken(
|
||||
context,
|
||||
@ -747,11 +719,7 @@ describe('updateDelegationAccessToken', () => {
|
||||
{ role: USER_ROLES.NONE },
|
||||
);
|
||||
|
||||
const context = makeContext(
|
||||
parentAdmin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(parentAdmin.external_id, 'requestId');
|
||||
|
||||
const delegationRefreshToken = await service.generateDelegationRefreshToken(
|
||||
context,
|
||||
|
||||
@ -85,7 +85,7 @@ describe('publishUploadSas', () => {
|
||||
null,
|
||||
null,
|
||||
);
|
||||
const context = makeContext(externalId, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(externalId, 'requestId');
|
||||
const baseUrl = `https://saodmsusdev.blob.core.windows.net/account-${account.id}/${userId}`;
|
||||
|
||||
//SASトークンを返却する
|
||||
@ -107,11 +107,7 @@ describe('publishUploadSas', () => {
|
||||
// 第四階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 4 });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//Blobコンテナ存在チェックに失敗するようにする
|
||||
overrideBlobstorageService(service, {
|
||||
@ -139,11 +135,7 @@ describe('publishUploadSas', () => {
|
||||
// 第四階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 4 });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//BlobのSASトークン生成に失敗するようにする
|
||||
overrideBlobstorageService(service, {
|
||||
@ -172,11 +164,7 @@ describe('publishUploadSas', () => {
|
||||
// 第五階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 5, locked: true });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
try {
|
||||
await service.publishUploadSas(context, admin.external_id);
|
||||
@ -222,7 +210,7 @@ describe('publishUploadSas', () => {
|
||||
|
||||
await expect(
|
||||
service.publishUploadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
),
|
||||
).rejects.toEqual(
|
||||
@ -283,7 +271,7 @@ describe('publishUploadSas', () => {
|
||||
|
||||
await expect(
|
||||
service.publishUploadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
),
|
||||
).rejects.toEqual(
|
||||
@ -366,7 +354,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
const result = await service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId,
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '',
|
||||
@ -386,7 +374,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
expect(result).toEqual({ jobNumber: '00000001' });
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId}`],
|
||||
{
|
||||
authorId: 'AUTHOR_ID',
|
||||
@ -467,7 +455,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
const result = await service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId,
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '',
|
||||
@ -487,7 +475,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
expect(result).toEqual({ jobNumber: '00000002' });
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId}`],
|
||||
{
|
||||
authorId: 'AUTHOR_ID',
|
||||
@ -590,7 +578,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
const result = await service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
myExternalId, // API実行者のユーザーIDを設定
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
|
||||
@ -610,7 +598,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
expect(result).toEqual({ jobNumber: '00000001' });
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId}`],
|
||||
{
|
||||
authorId: 'AUTHOR_ID',
|
||||
@ -712,7 +700,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
const result = await service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
myExternalId, // API実行者のユーザーIDを設定
|
||||
'http://blob/url/file.zip',
|
||||
'XXXXXXXXXX', // 音声ファイルの情報には、録音者のAuthorIDが入る
|
||||
@ -732,7 +720,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
expect(result).toEqual({ jobNumber: '00000001' });
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId}`],
|
||||
{
|
||||
authorId: 'XXXXXXXXXX',
|
||||
@ -781,7 +769,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
const service = module.get<FilesService>(FilesService);
|
||||
|
||||
const result = await service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId, // API実行者のユーザーIDを設定
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
|
||||
@ -837,7 +825,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
|
||||
await expect(
|
||||
service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId,
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '',
|
||||
@ -884,7 +872,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
|
||||
await expect(
|
||||
service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId,
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '',
|
||||
@ -925,7 +913,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
|
||||
await expect(
|
||||
service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
'authorExternalId',
|
||||
'http://blob/url/file.zip',
|
||||
'authorAuthorId',
|
||||
@ -976,7 +964,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
|
||||
|
||||
await expect(
|
||||
service.uploadFinished(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
authorExternalId,
|
||||
'http://blob/url/file.zip',
|
||||
authorAuthorId ?? '',
|
||||
@ -1061,7 +1049,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
expect(
|
||||
await service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1131,7 +1119,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
expect(
|
||||
await service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1178,7 +1166,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1232,7 +1220,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1277,7 +1265,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1309,7 +1297,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
1,
|
||||
),
|
||||
@ -1358,7 +1346,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1413,7 +1401,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1485,7 +1473,7 @@ describe('音声ファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishAudioFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1553,7 +1541,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
expect(
|
||||
await service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1623,7 +1611,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
expect(
|
||||
await service.publishTemplateFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1664,7 +1652,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1714,7 +1702,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1759,7 +1747,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1791,7 +1779,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
1,
|
||||
),
|
||||
@ -1839,7 +1827,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('tracking', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('tracking', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1894,7 +1882,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -1966,7 +1954,7 @@ describe('テンプレートファイルダウンロードURL取得', () => {
|
||||
|
||||
await expect(
|
||||
service.publishTemplateFileDownloadSas(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
audioFileId,
|
||||
),
|
||||
@ -2003,11 +1991,7 @@ describe('publishTemplateFileUploadSas', () => {
|
||||
// 第五階層のアカウント作成
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
const baseUrl = `https://saodmsusdev.blob.core.windows.net/account-${account.id}/Templates`;
|
||||
|
||||
//SASトークンを返却する
|
||||
@ -2032,11 +2016,7 @@ describe('publishTemplateFileUploadSas', () => {
|
||||
// 第五階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 5 });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//Blobコンテナ存在チェックに失敗するようにする
|
||||
overrideBlobstorageService(service, {
|
||||
@ -2064,11 +2044,7 @@ describe('publishTemplateFileUploadSas', () => {
|
||||
// 第五階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 5 });
|
||||
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//BlobのSASトークン生成に失敗するようにする
|
||||
overrideBlobstorageService(service, {
|
||||
@ -2117,11 +2093,7 @@ describe('templateUploadFinished', () => {
|
||||
const service = module.get<FilesService>(FilesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const fileName = 'test.docs';
|
||||
const url = `https://blob.url/account-${account.id}/Templates`;
|
||||
@ -2155,11 +2127,7 @@ describe('templateUploadFinished', () => {
|
||||
const service = module.get<FilesService>(FilesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const fileName = 'test.docs';
|
||||
const url = `https://blob.url/account-${account.id}/Templates`;
|
||||
@ -2199,11 +2167,7 @@ describe('templateUploadFinished', () => {
|
||||
const service = module.get<FilesService>(FilesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const fileName = 'test.docs';
|
||||
const url = `https://blob.url/account-${account.id}/Templates`;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { AccessToken } from '../../common/token';
|
||||
import {
|
||||
CreateOrdersRequest,
|
||||
IssueCardLicensesRequest,
|
||||
@ -59,7 +58,7 @@ describe('LicensesService', () => {
|
||||
const userId = '0001';
|
||||
body.orderCount = 1000;
|
||||
body.poNumber = '1';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(
|
||||
await service.licenseOrders(
|
||||
context,
|
||||
@ -87,7 +86,7 @@ describe('LicensesService', () => {
|
||||
const userId = '';
|
||||
body.orderCount = 1000;
|
||||
body.poNumber = '1';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.licenseOrders(context, userId, body.poNumber, body.orderCount),
|
||||
).rejects.toEqual(
|
||||
@ -115,7 +114,7 @@ describe('LicensesService', () => {
|
||||
const userId = '0001';
|
||||
body.orderCount = 1000;
|
||||
body.poNumber = '1';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.licenseOrders(context, userId, body.poNumber, body.orderCount),
|
||||
).rejects.toEqual(
|
||||
@ -143,7 +142,7 @@ describe('LicensesService', () => {
|
||||
const userId = '0001';
|
||||
body.orderCount = 1000;
|
||||
body.poNumber = '1';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.licenseOrders(context, userId, body.poNumber, body.orderCount),
|
||||
).rejects.toEqual(
|
||||
@ -181,7 +180,7 @@ describe('LicensesService', () => {
|
||||
'AEJWRFFSWRQYQQJ6WVLV',
|
||||
],
|
||||
};
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(
|
||||
await service.issueCardLicenseKeys(context, userId, body.createCount),
|
||||
).toEqual(issueCardLicensesResponse);
|
||||
@ -201,7 +200,7 @@ describe('LicensesService', () => {
|
||||
const body = new IssueCardLicensesRequest();
|
||||
const userId = '0001';
|
||||
body.createCount = 1000;
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.issueCardLicenseKeys(context, userId, body.createCount),
|
||||
).rejects.toEqual(
|
||||
@ -225,7 +224,7 @@ describe('LicensesService', () => {
|
||||
const body = new ActivateCardLicensesRequest();
|
||||
const userId = '0001';
|
||||
body.cardLicenseKey = 'WZCETXC0Z9PQZ9GKRGGY';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(
|
||||
await service.activateCardLicenseKey(
|
||||
context,
|
||||
@ -249,7 +248,7 @@ describe('LicensesService', () => {
|
||||
const body = new ActivateCardLicensesRequest();
|
||||
const userId = '0001';
|
||||
body.cardLicenseKey = 'WZCETXC0Z9PQZ9GKRGGY';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.activateCardLicenseKey(context, userId, body.cardLicenseKey),
|
||||
).rejects.toEqual(
|
||||
@ -276,7 +275,7 @@ describe('LicensesService', () => {
|
||||
const body = new ActivateCardLicensesRequest();
|
||||
const userId = '0001';
|
||||
body.cardLicenseKey = 'WZCETXC0Z9PQZ9GKRGGY';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.activateCardLicenseKey(context, userId, body.cardLicenseKey),
|
||||
).rejects.toEqual(
|
||||
@ -299,7 +298,7 @@ describe('LicensesService', () => {
|
||||
const body = new ActivateCardLicensesRequest();
|
||||
const userId = '0001';
|
||||
body.cardLicenseKey = 'WZCETXC0Z9PQZ9GKRGGY';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(
|
||||
service.activateCardLicenseKey(context, userId, body.cardLicenseKey),
|
||||
).rejects.toEqual(
|
||||
@ -342,7 +341,7 @@ describe('DBテスト', () => {
|
||||
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
const issueCount = 500;
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await service.issueCardLicenseKeys(context, externalId, issueCount);
|
||||
const dbSelectResult = await selectCardLicensesCount(source);
|
||||
expect(dbSelectResult.count).toEqual(issueCount);
|
||||
@ -382,7 +381,7 @@ describe('DBテスト', () => {
|
||||
await createCardLicenseIssue(source, issueId);
|
||||
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await service.activateCardLicenseKey(context, externalId, cardLicenseKey);
|
||||
const dbSelectResultFromCardLicense = await selectCardLicense(
|
||||
@ -529,7 +528,7 @@ describe('DBテスト', () => {
|
||||
null,
|
||||
);
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
const context = makeContext('userId', 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext('userId', 'requestId');
|
||||
const response = await service.getAllocatableLicenses(context, externalId);
|
||||
// 対象外のデータは取得していないことを確認する
|
||||
expect(response.allocatableLicenses.length).toBe(5);
|
||||
@ -600,7 +599,7 @@ describe('ライセンス割り当て', () => {
|
||||
const expiry_date = new NewAllocatedLicenseExpirationDate();
|
||||
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
1,
|
||||
);
|
||||
@ -669,7 +668,7 @@ describe('ライセンス割り当て', () => {
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
1,
|
||||
);
|
||||
@ -748,7 +747,7 @@ describe('ライセンス割り当て', () => {
|
||||
const expiry_date = new NewAllocatedLicenseExpirationDate();
|
||||
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
2,
|
||||
);
|
||||
@ -851,7 +850,7 @@ describe('ライセンス割り当て', () => {
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
2,
|
||||
);
|
||||
@ -915,7 +914,7 @@ describe('ライセンス割り当て', () => {
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
2,
|
||||
);
|
||||
@ -979,7 +978,7 @@ describe('ライセンス割り当て', () => {
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
2,
|
||||
);
|
||||
@ -1025,7 +1024,7 @@ describe('ライセンス割り当て', () => {
|
||||
|
||||
await expect(
|
||||
service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
1,
|
||||
),
|
||||
@ -1077,7 +1076,7 @@ describe('ライセンス割り当て', () => {
|
||||
|
||||
await expect(
|
||||
service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
1,
|
||||
),
|
||||
@ -1086,7 +1085,7 @@ describe('ライセンス割り当て', () => {
|
||||
);
|
||||
await expect(
|
||||
service.allocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
2,
|
||||
),
|
||||
@ -1152,7 +1151,7 @@ describe('ライセンス割り当て解除', () => {
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.deallocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
);
|
||||
|
||||
@ -1242,10 +1241,7 @@ describe('ライセンス割り当て解除', () => {
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await expect(
|
||||
service.deallocateLicense(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
userId,
|
||||
),
|
||||
service.deallocateLicense(makeContext('trackingId', 'requestId'), userId),
|
||||
).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E010807'), HttpStatus.BAD_REQUEST),
|
||||
);
|
||||
@ -1301,7 +1297,7 @@ describe('ライセンス注文キャンセル', () => {
|
||||
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
await service.cancelOrder(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
tier2Accounts[0].users[0].external_id,
|
||||
poNumber,
|
||||
);
|
||||
@ -1337,7 +1333,7 @@ describe('ライセンス注文キャンセル', () => {
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
await expect(
|
||||
service.cancelOrder(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
tier2Accounts[0].users[0].external_id,
|
||||
poNumber,
|
||||
),
|
||||
@ -1368,7 +1364,7 @@ describe('ライセンス注文キャンセル', () => {
|
||||
const service = module.get<LicensesService>(LicensesService);
|
||||
await expect(
|
||||
service.cancelOrder(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
tier2Accounts[0].users[0].external_id,
|
||||
poNumber,
|
||||
),
|
||||
|
||||
@ -19,7 +19,7 @@ describe('NotificationService.register', () => {
|
||||
|
||||
expect(
|
||||
await service.register(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
'external_id',
|
||||
'apns',
|
||||
'handler',
|
||||
@ -38,7 +38,7 @@ describe('NotificationService.register', () => {
|
||||
|
||||
await expect(
|
||||
service.register(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
'external_id',
|
||||
'apns',
|
||||
'handler',
|
||||
@ -63,7 +63,7 @@ describe('NotificationService.register', () => {
|
||||
|
||||
await expect(
|
||||
service.register(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
'external_id',
|
||||
'apns',
|
||||
'handler',
|
||||
|
||||
@ -63,7 +63,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
expect(
|
||||
await service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -138,7 +138,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -180,7 +180,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -266,7 +266,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -309,7 +309,7 @@ describe('TasksService', () => {
|
||||
const status = ['Uploaded', 'Backup'];
|
||||
const paramName = 'JOB_NUMBER';
|
||||
const direction = 'ASC';
|
||||
const context = makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext('trackingId', 'requestId');
|
||||
const result = await service.tasksService.getTasks(
|
||||
context,
|
||||
userId,
|
||||
@ -394,7 +394,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[USER_ROLES.AUTHOR],
|
||||
offset,
|
||||
@ -438,7 +438,7 @@ describe('TasksService', () => {
|
||||
const status = ['Uploaded', 'Backup'];
|
||||
const paramName = 'JOB_NUMBER';
|
||||
const direction = 'ASC';
|
||||
const context = makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext('trackingId', 'requestId');
|
||||
const result = await service.tasksService.getTasks(
|
||||
context,
|
||||
userId,
|
||||
@ -523,7 +523,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[USER_ROLES.TYPIST],
|
||||
offset,
|
||||
@ -565,7 +565,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
await expect(
|
||||
service.tasksService.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
userId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -625,7 +625,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
|
||||
const { tasks, total } = await service.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
externalId,
|
||||
[ADMIN_ROLES.ADMIN, USER_ROLES.NONE],
|
||||
offset,
|
||||
@ -683,7 +683,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
|
||||
const { tasks, total } = await service.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
external_id,
|
||||
[USER_ROLES.AUTHOR],
|
||||
offset,
|
||||
@ -755,7 +755,7 @@ describe('TasksService', () => {
|
||||
const direction = 'ASC';
|
||||
|
||||
const { tasks, total } = await service.getTasks(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
external_id,
|
||||
[USER_ROLES.AUTHOR],
|
||||
offset,
|
||||
@ -841,7 +841,7 @@ describe('changeCheckoutPermission', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'typist-user-2', typistUserId: typistUserId_2 }],
|
||||
'author-user-external-id',
|
||||
@ -858,7 +858,7 @@ describe('changeCheckoutPermission', () => {
|
||||
const resultTask = await getTask(source, taskId);
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId_2}`],
|
||||
{
|
||||
authorId: 'MY_AUTHOR_ID',
|
||||
@ -924,7 +924,7 @@ describe('changeCheckoutPermission', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'USER_GROUP_B', typistGroupId: userGroupId_2 }],
|
||||
'author-user-external-id',
|
||||
@ -942,7 +942,7 @@ describe('changeCheckoutPermission', () => {
|
||||
const resultTask = await getTask(source, taskId);
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId_2}`],
|
||||
{
|
||||
authorId: 'MY_AUTHOR_ID',
|
||||
@ -994,7 +994,7 @@ describe('changeCheckoutPermission', () => {
|
||||
await createCheckoutPermissions(source, taskId, undefined, userGroupId);
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[],
|
||||
'author-user-external-id',
|
||||
@ -1047,7 +1047,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'not-exist-user', typistUserId: 999 }],
|
||||
'author-user-external-id',
|
||||
@ -1113,7 +1113,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'not-verified-user', typistUserId: typistUserId_2 }],
|
||||
'author-user-external-id',
|
||||
@ -1173,7 +1173,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'not-exist-user-group', typistGroupId: 999 }],
|
||||
'author-user-external-id',
|
||||
@ -1215,7 +1215,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'typist-user', typistUserId: typistUserId }],
|
||||
'author-user-external-id',
|
||||
@ -1267,7 +1267,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'typist-user', typistUserId: typistUserId }],
|
||||
'author-user-external-id',
|
||||
@ -1319,7 +1319,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'typist-user', typistUserId: typistUserId }],
|
||||
'author-user-external-id',
|
||||
@ -1385,7 +1385,7 @@ describe('changeCheckoutPermission', () => {
|
||||
|
||||
try {
|
||||
await service.changeCheckoutPermission(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
[{ typistName: 'typist-user-2', typistUserId: typistUserId_2 }],
|
||||
'author-user-external-id',
|
||||
@ -1462,7 +1462,7 @@ describe('checkout', () => {
|
||||
const initTask = await getTask(source, taskId);
|
||||
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1522,7 +1522,7 @@ describe('checkout', () => {
|
||||
const initTask = await getTask(source, taskId);
|
||||
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1575,7 +1575,7 @@ describe('checkout', () => {
|
||||
const initTask = await getTask(source, taskId);
|
||||
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1627,7 +1627,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1674,7 +1674,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1735,7 +1735,7 @@ describe('checkout', () => {
|
||||
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
audioFileId,
|
||||
['typist'],
|
||||
'typist-user-external-id',
|
||||
@ -1800,7 +1800,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
2,
|
||||
['typist'],
|
||||
'typist-user-external-id2',
|
||||
@ -1841,7 +1841,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
expect(
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['author'],
|
||||
'author-user-external-id',
|
||||
@ -1875,7 +1875,7 @@ describe('checkout', () => {
|
||||
|
||||
expect(
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['author'],
|
||||
'author-user-external-id',
|
||||
@ -1898,7 +1898,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['author'],
|
||||
'author-user-external-id',
|
||||
@ -1939,7 +1939,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['author'],
|
||||
'author-user-external-id',
|
||||
@ -1970,7 +1970,7 @@ describe('checkout', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
try {
|
||||
await service.checkout(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
['none'],
|
||||
'none-user-external-id',
|
||||
@ -2045,7 +2045,7 @@ describe('checkin', () => {
|
||||
const initTask = await getTask(source, taskId);
|
||||
|
||||
await service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
);
|
||||
@ -2092,7 +2092,7 @@ describe('checkin', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await expect(
|
||||
service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2144,7 +2144,7 @@ describe('checkin', () => {
|
||||
|
||||
await expect(
|
||||
service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2180,7 +2180,7 @@ describe('checkin', () => {
|
||||
|
||||
await expect(
|
||||
service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2245,7 +2245,7 @@ describe('suspend', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.suspend(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
);
|
||||
@ -2291,7 +2291,7 @@ describe('suspend', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await expect(
|
||||
service.suspend(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2343,7 +2343,7 @@ describe('suspend', () => {
|
||||
|
||||
await expect(
|
||||
service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2379,7 +2379,7 @@ describe('suspend', () => {
|
||||
|
||||
await expect(
|
||||
service.checkin(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
),
|
||||
@ -2445,7 +2445,7 @@ describe('cancel', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['typist', 'standard'],
|
||||
@ -2494,7 +2494,7 @@ describe('cancel', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['typist', 'standard'],
|
||||
@ -2546,7 +2546,7 @@ describe('cancel', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['admin', 'author'],
|
||||
@ -2597,7 +2597,7 @@ describe('cancel', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['admin', 'author'],
|
||||
@ -2647,7 +2647,7 @@ describe('cancel', () => {
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await expect(
|
||||
service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['admin', 'author'],
|
||||
@ -2700,7 +2700,7 @@ describe('cancel', () => {
|
||||
|
||||
await expect(
|
||||
service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['typist', 'standard'],
|
||||
@ -2737,7 +2737,7 @@ describe('cancel', () => {
|
||||
|
||||
await expect(
|
||||
service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['typist', 'standard'],
|
||||
@ -2806,7 +2806,7 @@ describe('cancel', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
'typist-user-external-id',
|
||||
['typist', 'standard'],
|
||||
@ -2823,7 +2823,7 @@ describe('cancel', () => {
|
||||
expect(permisions[0].user_id).toEqual(typistUserId);
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${typistUserId}`],
|
||||
{
|
||||
authorId: 'AUTHOR_ID',
|
||||
@ -2916,7 +2916,7 @@ describe('cancel', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
external_id,
|
||||
role.split(' ') as Roles[],
|
||||
@ -2933,7 +2933,7 @@ describe('cancel', () => {
|
||||
expect(permisions[0].user_id).toEqual(autoRoutingTypistUserId);
|
||||
// 通知処理が想定通りの引数で呼ばれているか確認
|
||||
expect(NotificationHubService.notify).toHaveBeenCalledWith(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
[`user_${autoRoutingTypistUserId}`],
|
||||
{
|
||||
authorId: 'AUTHOR_ID',
|
||||
@ -2988,7 +2988,7 @@ describe('cancel', () => {
|
||||
NotificationhubService,
|
||||
);
|
||||
await service.cancel(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
1,
|
||||
external_id,
|
||||
role.split(' ') as Roles[],
|
||||
@ -3062,7 +3062,7 @@ describe('backup', () => {
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await service.backup(
|
||||
makeContext(admin.external_id, 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext(admin.external_id, 'requestId'),
|
||||
audioFileId,
|
||||
admin.external_id,
|
||||
);
|
||||
@ -3114,7 +3114,7 @@ describe('backup', () => {
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
await service.backup(
|
||||
makeContext(admin.external_id, 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext(admin.external_id, 'requestId'),
|
||||
audioFileId,
|
||||
admin.external_id,
|
||||
);
|
||||
@ -3167,7 +3167,7 @@ describe('backup', () => {
|
||||
|
||||
try {
|
||||
await service.backup(
|
||||
makeContext(admin.external_id, 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext(admin.external_id, 'requestId'),
|
||||
audioFileId,
|
||||
admin.external_id,
|
||||
);
|
||||
@ -3222,7 +3222,7 @@ describe('backup', () => {
|
||||
|
||||
try {
|
||||
await service.backup(
|
||||
makeContext(admin.external_id, 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext(admin.external_id, 'requestId'),
|
||||
9999, // 存在しないタスクID
|
||||
admin.external_id,
|
||||
);
|
||||
@ -3283,7 +3283,7 @@ describe('backup', () => {
|
||||
|
||||
try {
|
||||
await service.backup(
|
||||
makeContext(admin.external_id, 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext(admin.external_id, 'requestId'),
|
||||
audioFileId,
|
||||
admin.external_id,
|
||||
);
|
||||
@ -3376,11 +3376,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId2, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3452,11 +3448,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId2, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3528,11 +3520,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId2, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3604,11 +3592,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId2, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3680,11 +3664,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId2, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3732,11 +3712,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId1, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const nextAudioFileId = await service.getNextTask(
|
||||
context,
|
||||
@ -3783,11 +3759,7 @@ describe('getNextTask', () => {
|
||||
await createCheckoutPermissions(source, taskId1, typistUserId);
|
||||
|
||||
const service = module.get<TasksService>(TasksService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
// 実行結果が正しいか確認
|
||||
try {
|
||||
|
||||
@ -35,11 +35,7 @@ describe('getTemplates', () => {
|
||||
const service = module.get<TemplatesService>(TemplatesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const template1 = await createTemplateFile(
|
||||
source,
|
||||
@ -80,11 +76,7 @@ describe('getTemplates', () => {
|
||||
const service = module.get<TemplatesService>(TemplatesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
const templates = await service.getTemplates(context, admin.external_id);
|
||||
|
||||
@ -102,11 +94,7 @@ describe('getTemplates', () => {
|
||||
const service = module.get<TemplatesService>(TemplatesService);
|
||||
// 第五階層のアカウント作成
|
||||
const { admin } = await makeTestAccount(source, { tier: 5 });
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//DBアクセスに失敗するようにする
|
||||
const typistGroupService = module.get<TemplateFilesRepositoryService>(
|
||||
|
||||
@ -39,7 +39,7 @@ describe('利用規約取得', () => {
|
||||
await createTermInfo(source, 'DPA', 'v1.0');
|
||||
await createTermInfo(source, 'DPA', 'v1.2');
|
||||
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
const result = await service.getTermsInfo(context);
|
||||
|
||||
expect(result[0].documentType).toBe('EULA');
|
||||
@ -55,7 +55,7 @@ describe('利用規約取得', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<TermsService>(TermsService);
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
await expect(service.getTermsInfo(context)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -70,7 +70,7 @@ describe('利用規約取得', () => {
|
||||
if (!module) fail();
|
||||
const service = module.get<TermsService>(TermsService);
|
||||
await createTermInfo(source, 'DPA', 'v1.0');
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
await expect(service.getTermsInfo(context)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -85,7 +85,7 @@ describe('利用規約取得', () => {
|
||||
if (!module) fail();
|
||||
const service = module.get<TermsService>(TermsService);
|
||||
await createTermInfo(source, 'PrivacyNotice', 'v1.0');
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
await expect(service.getTermsInfo(context)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -100,7 +100,7 @@ describe('利用規約取得', () => {
|
||||
if (!module) fail();
|
||||
const service = module.get<TermsService>(TermsService);
|
||||
await createTermInfo(source, 'EULA', 'v1.0');
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
await expect(service.getTermsInfo(context)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
|
||||
@ -174,6 +174,7 @@ export class UsersController {
|
||||
@Get()
|
||||
async getUsers(@Req() req: Request): Promise<GetUsersResponse> {
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
|
||||
@ -97,7 +97,7 @@ describe('UsersService.confirmUser', () => {
|
||||
// account id:1, user id: 2のトークン
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await service.confirmUser(context, token);
|
||||
//result
|
||||
const resultUser = await getUser(source, userId);
|
||||
@ -141,7 +141,7 @@ describe('UsersService.confirmUser', () => {
|
||||
if (!module) fail();
|
||||
const token = 'invalid.id.token';
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.confirmUser(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E000101'), HttpStatus.BAD_REQUEST),
|
||||
);
|
||||
@ -177,7 +177,7 @@ describe('UsersService.confirmUser', () => {
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.confirmUser(context, token)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E010202'), HttpStatus.BAD_REQUEST),
|
||||
);
|
||||
@ -189,7 +189,7 @@ describe('UsersService.confirmUser', () => {
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const token =
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
await expect(service.confirmUser(context, token)).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
@ -246,7 +246,7 @@ describe('UsersService.confirmUserAndInitPassword', () => {
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
expect(
|
||||
await service.confirmUserAndInitPassword(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
token,
|
||||
),
|
||||
).toEqual(undefined);
|
||||
@ -296,7 +296,7 @@ describe('UsersService.confirmUserAndInitPassword', () => {
|
||||
const token = 'invalid.id.token';
|
||||
await expect(
|
||||
service.confirmUserAndInitPassword(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
token,
|
||||
),
|
||||
).rejects.toEqual(
|
||||
@ -352,7 +352,7 @@ describe('UsersService.confirmUserAndInitPassword', () => {
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
await expect(
|
||||
service.confirmUserAndInitPassword(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
token,
|
||||
),
|
||||
).rejects.toEqual(
|
||||
@ -405,7 +405,7 @@ describe('UsersService.confirmUserAndInitPassword', () => {
|
||||
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjEsInVzZXJJZCI6MiwiZW1haWwiOiJ4eHhAeHh4Lnh4eCIsImlhdCI6MTAwMDAwMDAwMCwiZXhwIjo5MDAwMDAwMDAwfQ.26L6BdNg-3TbyKT62PswlJ6RPMkcTtHzlDXW2Uo9XbMPVSrl2ObcuS6EcXjFFN2DEfNTKbqX_zevIWMpHOAdLNgGhk528nLrBrNvPASqtTjvW9muxMXpjUdjRVkmVbOylBHWW3YpWL9JEbJQ7rAzWDfaIdPhMovdaxumnZt_UwnlnrdaVPLACW7tkH_laEcAU507iSiM4mqxxG8FuTs34t6PEdwRuzZAQPN2IOPYNSvGNdJYryPacSeSNZ_z1xeBYXLOLQfOBZzyTReYDOhXdikhrNUbxjgnZQlSXBCVMlZ9PH42bHfp-LJIeJzW0yqnF6oLklvJP-fo8eW0k5iDOw';
|
||||
await expect(
|
||||
service.confirmUserAndInitPassword(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
token,
|
||||
),
|
||||
).rejects.toEqual(
|
||||
@ -491,7 +491,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
expect(
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -579,7 +579,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
expect(
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -670,7 +670,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
expect(
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -758,7 +758,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
expect(
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -851,7 +851,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -871,7 +871,7 @@ describe('UsersService.createUser', () => {
|
||||
// ADB2Cに作成したユーザーを削除するメソッドが呼ばれていることを確認
|
||||
expect(b2cService.deleteUser).toBeCalledWith(
|
||||
externalId,
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
);
|
||||
});
|
||||
|
||||
@ -938,7 +938,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -963,7 +963,7 @@ describe('UsersService.createUser', () => {
|
||||
// ADB2Cに作成したユーザーを削除するメソッドが呼ばれていることを確認
|
||||
expect(b2cService.deleteUser).toBeCalledWith(
|
||||
externalId,
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
);
|
||||
});
|
||||
|
||||
@ -1019,7 +1019,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1098,7 +1098,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1179,7 +1179,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
expect(
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1220,7 +1220,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1316,7 +1316,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1344,7 +1344,7 @@ describe('UsersService.createUser', () => {
|
||||
// ADB2Cに作成したユーザーを削除するメソッドが呼ばれていることを確認
|
||||
expect(b2cService.deleteUser).toBeCalledWith(
|
||||
externalId,
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
);
|
||||
});
|
||||
|
||||
@ -1405,7 +1405,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1431,7 +1431,7 @@ describe('UsersService.createUser', () => {
|
||||
// ADB2Cに作成したユーザーを削除するメソッドが呼ばれていることを確認
|
||||
expect(b2cService.deleteUser).toBeCalledWith(
|
||||
externalId,
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
);
|
||||
});
|
||||
|
||||
@ -1497,7 +1497,7 @@ describe('UsersService.createUser', () => {
|
||||
|
||||
try {
|
||||
await service.createUser(
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
adminExternalId,
|
||||
name,
|
||||
role,
|
||||
@ -1521,7 +1521,7 @@ describe('UsersService.createUser', () => {
|
||||
// ADB2Cに作成したユーザーを削除するメソッドが呼ばれていることを確認
|
||||
expect(b2cService.deleteUser).toBeCalledWith(
|
||||
externalId,
|
||||
makeContext('trackingId', 'xxx-xxx-xxx-xxx', 'requestId'),
|
||||
makeContext('trackingId', 'requestId'),
|
||||
);
|
||||
});
|
||||
});
|
||||
@ -1644,7 +1644,7 @@ describe('UsersService.getUsers', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(await service.getUsers(context, externalId_author)).toEqual(
|
||||
expectedUsers,
|
||||
);
|
||||
@ -1763,7 +1763,7 @@ describe('UsersService.getUsers', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
expect(await service.getUsers(context, external_id1)).toEqual(
|
||||
expectedUsers,
|
||||
);
|
||||
@ -1787,7 +1787,7 @@ describe('UsersService.getUsers', () => {
|
||||
prompt: false,
|
||||
});
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await expect(
|
||||
service.getUsers(context, 'externalId_failed'),
|
||||
@ -1815,7 +1815,7 @@ describe('UsersService.getUsers', () => {
|
||||
prompt: false,
|
||||
});
|
||||
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await expect(service.getUsers(context, externalId_author)).rejects.toEqual(
|
||||
new HttpException(makeErrorResponse('E009999'), HttpStatus.NOT_FOUND),
|
||||
@ -1840,7 +1840,7 @@ describe('UsersService.updateSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateSortCriteria(
|
||||
@ -1871,7 +1871,7 @@ describe('UsersService.updateSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.updateSortCriteria(context, 'AUTHOR_ID', 'ASC', 'external_id'),
|
||||
@ -1903,7 +1903,7 @@ describe('UsersService.updateSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.updateSortCriteria(context, 'AUTHOR_ID', 'ASC', 'external_id'),
|
||||
@ -1933,7 +1933,7 @@ describe('UsersService.getSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(await service.getSortCriteria(context, 'external_id')).toEqual({
|
||||
direction: 'ASC',
|
||||
@ -1962,7 +1962,7 @@ describe('UsersService.getSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.getSortCriteria(context, 'external_id'),
|
||||
@ -1997,7 +1997,7 @@ describe('UsersService.getSortCriteria', () => {
|
||||
configMockValue,
|
||||
sortCriteriaRepositoryMockValue,
|
||||
);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.getSortCriteria(context, 'external_id'),
|
||||
@ -2057,7 +2057,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2116,7 +2116,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2175,7 +2175,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2234,7 +2234,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2293,7 +2293,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2352,7 +2352,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.updateUser(
|
||||
@ -2401,7 +2401,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2460,7 +2460,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
expect(
|
||||
await service.updateUser(
|
||||
@ -2519,7 +2519,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.updateUser(
|
||||
@ -2579,7 +2579,7 @@ describe('UsersService.updateUser', () => {
|
||||
});
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const context = makeContext(`uuidv4`, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(`uuidv4`, 'requestId');
|
||||
|
||||
await expect(
|
||||
service.updateUser(
|
||||
@ -2627,7 +2627,7 @@ describe('UsersService.updateAcceptedVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 5,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.updateAcceptedVersion(
|
||||
@ -2648,7 +2648,7 @@ describe('UsersService.updateAcceptedVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.updateAcceptedVersion(
|
||||
@ -2671,7 +2671,7 @@ describe('UsersService.updateAcceptedVersion', () => {
|
||||
const { admin } = await makeTestAccount(source, {
|
||||
tier: 4,
|
||||
});
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await expect(
|
||||
@ -2714,7 +2714,7 @@ describe('UsersService.getUserName', () => {
|
||||
try {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.getUserName(context, 'external_id');
|
||||
@ -2809,7 +2809,7 @@ describe('UsersService.getRelations', () => {
|
||||
expect(workflows[3].author_id).toBe(user2);
|
||||
}
|
||||
|
||||
const context = makeContext(external_id, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(external_id, 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const relations = await service.getRelations(context, external_id);
|
||||
@ -2872,7 +2872,7 @@ describe('UsersService.getRelations', () => {
|
||||
expect(workflows[0].author_id).toBe(user2);
|
||||
}
|
||||
|
||||
const context = makeContext(external_id, 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(external_id, 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
const relations = await service.getRelations(context, external_id);
|
||||
@ -2898,7 +2898,7 @@ describe('UsersService.getRelations', () => {
|
||||
try {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const context = makeContext(uuidv4(), 'xxx-xxx-xxx-xxx', 'requestId');
|
||||
const context = makeContext(uuidv4(), 'requestId');
|
||||
|
||||
const service = module.get<UsersService>(UsersService);
|
||||
await service.getRelations(context, 'external_id');
|
||||
|
||||
@ -257,7 +257,10 @@ export class UsersService {
|
||||
prompt,
|
||||
);
|
||||
// ユーザ作成
|
||||
newUser = await this.usersRepository.createNormalUser(newUserInfo);
|
||||
newUser = await this.usersRepository.createNormalUser(
|
||||
context,
|
||||
newUserInfo,
|
||||
);
|
||||
} catch (e) {
|
||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||
this.logger.error(`[${context.getTrackingId()}]create user failed`);
|
||||
@ -352,7 +355,7 @@ export class UsersService {
|
||||
} | params: { userId: ${userId} }`,
|
||||
);
|
||||
try {
|
||||
await this.usersRepository.deleteNormalUser(userId);
|
||||
await this.usersRepository.deleteNormalUser(context, userId);
|
||||
this.logger.log(`[${context.getTrackingId()}] delete user: ${userId}`);
|
||||
} catch (error) {
|
||||
this.logger.error(`[${context.getTrackingId()}] error=${error}`);
|
||||
|
||||
@ -118,11 +118,7 @@ describe('getWorkflows', () => {
|
||||
await createWorkflowTypist(source, workflow3.id, undefined, userGroupId);
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//作成したデータを確認
|
||||
{
|
||||
@ -194,11 +190,7 @@ describe('getWorkflows', () => {
|
||||
const { admin } = await makeTestAccount(source, { tier: 5 });
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
overrideAdB2cService(service, {
|
||||
getUsers: async () => [],
|
||||
@ -220,11 +212,7 @@ describe('getWorkflows', () => {
|
||||
const { account, admin } = await makeTestAccount(source, { tier: 5 });
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//DBアクセスに失敗するようにする
|
||||
const templatesService = module.get<WorkflowsRepositoryService>(
|
||||
@ -304,11 +292,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.createWorkflow(
|
||||
context,
|
||||
@ -373,11 +357,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.createWorkflow(
|
||||
context,
|
||||
@ -441,11 +421,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.createWorkflow(
|
||||
context,
|
||||
@ -503,11 +479,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.createWorkflow(
|
||||
context,
|
||||
@ -571,11 +543,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
// 同一AuthorIDのワークフローを作成
|
||||
await service.createWorkflow(
|
||||
@ -648,11 +616,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
//実行結果を確認
|
||||
try {
|
||||
await service.createWorkflow(
|
||||
@ -709,11 +673,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -774,11 +734,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -838,11 +794,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -904,11 +856,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -976,11 +924,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1042,11 +986,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1117,11 +1057,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1188,11 +1124,7 @@ describe('createWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//DBアクセスに失敗するようにする
|
||||
const templatesService = module.get<WorkflowsRepositoryService>(
|
||||
@ -1311,11 +1243,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.updateWorkflow(
|
||||
context,
|
||||
@ -1405,11 +1333,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.updateWorkflow(
|
||||
context,
|
||||
@ -1498,11 +1422,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.updateWorkflow(
|
||||
context,
|
||||
@ -1585,11 +1505,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.updateWorkflow(
|
||||
context,
|
||||
@ -1692,11 +1608,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.updateWorkflow(
|
||||
context,
|
||||
@ -1775,11 +1687,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1822,11 +1730,7 @@ describe('updateWorkflow', () => {
|
||||
});
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1900,11 +1804,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -1973,11 +1873,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2045,11 +1941,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2124,11 +2016,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2209,11 +2097,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2288,11 +2172,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2361,11 +2241,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2434,11 +2310,7 @@ describe('updateWorkflow', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//DBアクセスに失敗するようにする
|
||||
const workflowsRepositoryService = module.get<WorkflowsRepositoryService>(
|
||||
@ -2529,11 +2401,7 @@ describe('deleteWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.deleteWorkflow(context, admin.external_id, workflow.id);
|
||||
|
||||
@ -2584,11 +2452,7 @@ describe('deleteWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
await service.deleteWorkflow(context, admin.external_id, workflow1.id);
|
||||
|
||||
@ -2639,11 +2503,7 @@ describe('deleteWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2718,11 +2578,7 @@ describe('deleteWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//実行結果を確認
|
||||
try {
|
||||
@ -2777,11 +2633,7 @@ describe('deleteWorkflows', () => {
|
||||
}
|
||||
|
||||
const service = module.get<WorkflowsService>(WorkflowsService);
|
||||
const context = makeContext(
|
||||
admin.external_id,
|
||||
'xxx-xxx-xxx-xxx',
|
||||
'requestId',
|
||||
);
|
||||
const context = makeContext(admin.external_id, 'requestId');
|
||||
|
||||
//DBアクセスに失敗するようにする
|
||||
const workflowsRepositoryService = module.get<WorkflowsRepositoryService>(
|
||||
|
||||
@ -57,12 +57,19 @@ import { AudioOptionItem } from '../audio_option_items/entity/audio_option_item.
|
||||
import { UserGroup } from '../user_groups/entity/user_group.entity';
|
||||
import { UserGroupMember } from '../user_groups/entity/user_group_member.entity';
|
||||
import { TemplateFile } from '../template_files/entity/template_file.entity';
|
||||
import {
|
||||
insertEntity,
|
||||
insertEntities,
|
||||
updateEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class AccountsRepositoryService {
|
||||
// クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
* 管理ユーザー無しでアカウントを作成する
|
||||
* @param companyName
|
||||
@ -72,6 +79,7 @@ export class AccountsRepositoryService {
|
||||
* @returns create
|
||||
*/
|
||||
async create(
|
||||
context: Context,
|
||||
companyName: string,
|
||||
country: string,
|
||||
dealerAccountId: number | null,
|
||||
@ -89,7 +97,13 @@ export class AccountsRepositoryService {
|
||||
async (entityManager) => {
|
||||
const repo = entityManager.getRepository(Account);
|
||||
const newAccount = repo.create(account);
|
||||
const persisted = await repo.save(newAccount);
|
||||
const persisted = await insertEntity(
|
||||
Account,
|
||||
repo,
|
||||
newAccount,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
return persisted;
|
||||
},
|
||||
);
|
||||
@ -101,10 +115,16 @@ export class AccountsRepositoryService {
|
||||
* @param account
|
||||
* @returns update
|
||||
*/
|
||||
async update(account: Account): Promise<UpdateResult> {
|
||||
async update(context: Context, account: Account): Promise<UpdateResult> {
|
||||
return await this.dataSource.transaction(async (entityManager) => {
|
||||
const repo = entityManager.getRepository(Account);
|
||||
return await repo.update({ id: account.id }, account);
|
||||
return await updateEntity(
|
||||
repo,
|
||||
{ id: account.id },
|
||||
account,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -121,6 +141,7 @@ export class AccountsRepositoryService {
|
||||
* @returns account/admin user
|
||||
*/
|
||||
async createAccount(
|
||||
context: Context,
|
||||
companyName: string,
|
||||
country: string,
|
||||
dealerAccountId: number | undefined,
|
||||
@ -141,7 +162,13 @@ export class AccountsRepositoryService {
|
||||
}
|
||||
const accountsRepo = entityManager.getRepository(Account);
|
||||
const newAccount = accountsRepo.create(account);
|
||||
const persistedAccount = await accountsRepo.save(newAccount);
|
||||
const persistedAccount = await insertEntity(
|
||||
Account,
|
||||
accountsRepo,
|
||||
newAccount,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 作成されたAccountのIDを使用してユーザーを作成
|
||||
const user = new User();
|
||||
@ -156,14 +183,23 @@ export class AccountsRepositoryService {
|
||||
}
|
||||
const usersRepo = entityManager.getRepository(User);
|
||||
const newUser = usersRepo.create(user);
|
||||
const persistedUser = await usersRepo.save(newUser);
|
||||
const persistedUser = await insertEntity(
|
||||
User,
|
||||
usersRepo,
|
||||
newUser,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// アカウントに管理者を設定して更新
|
||||
persistedAccount.primary_admin_user_id = persistedUser.id;
|
||||
|
||||
const result = await accountsRepo.update(
|
||||
const result = await updateEntity(
|
||||
accountsRepo,
|
||||
{ id: persistedAccount.id },
|
||||
persistedAccount,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 想定外の更新が行われた場合はロールバックを行った上でエラー送出
|
||||
@ -180,7 +216,13 @@ export class AccountsRepositoryService {
|
||||
}
|
||||
const sortCriteriaRepo = entityManager.getRepository(SortCriteria);
|
||||
const newSortCriteria = sortCriteriaRepo.create(sortCriteria);
|
||||
await sortCriteriaRepo.save(newSortCriteria);
|
||||
await insertEntity(
|
||||
SortCriteria,
|
||||
sortCriteriaRepo,
|
||||
newSortCriteria,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
return { newAccount: persistedAccount, adminUser: persistedUser };
|
||||
});
|
||||
@ -191,19 +233,31 @@ export class AccountsRepositoryService {
|
||||
* @param accountId
|
||||
* @returns delete
|
||||
*/
|
||||
async deleteAccount(accountId: number, userId: number): Promise<void> {
|
||||
async deleteAccount(
|
||||
context: Context,
|
||||
accountId: number,
|
||||
userId: number,
|
||||
): Promise<void> {
|
||||
await this.dataSource.transaction(async (entityManager) => {
|
||||
const accountsRepo = entityManager.getRepository(Account);
|
||||
const usersRepo = entityManager.getRepository(User);
|
||||
const sortCriteriaRepo = entityManager.getRepository(SortCriteria);
|
||||
// ソート条件を削除
|
||||
await sortCriteriaRepo.delete({
|
||||
user_id: userId,
|
||||
});
|
||||
await deleteEntity(
|
||||
sortCriteriaRepo,
|
||||
{ user_id: userId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// プライマリ管理者を削除
|
||||
await usersRepo.delete({ id: userId });
|
||||
await deleteEntity(usersRepo, { id: userId }, this.isCommentOut, context);
|
||||
// アカウントを削除
|
||||
await accountsRepo.delete({ id: accountId });
|
||||
await deleteEntity(
|
||||
accountsRepo,
|
||||
{ id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -352,6 +406,7 @@ export class AccountsRepositoryService {
|
||||
status: LICENSE_ALLOCATED_STATUS.ALLOCATED,
|
||||
},
|
||||
],
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
|
||||
// 総ライセンス数のうち、ユーザーに割り当てたことがあるが、現在は割り当て解除され誰にも割り当たっていないライセンス数を取得する
|
||||
@ -768,18 +823,33 @@ export class AccountsRepositoryService {
|
||||
// 注文を発行待ちに戻す
|
||||
updatedOrder.issued_at = null;
|
||||
updatedOrder.status = LICENSE_ISSUE_STATUS.ISSUE_REQUESTING;
|
||||
await orderRepo.save(updatedOrder);
|
||||
await updateEntity(
|
||||
orderRepo,
|
||||
{ id: targetOrder.id },
|
||||
updatedOrder,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 発行時に削除したライセンスを未割当に戻す
|
||||
await licenseRepo.update(
|
||||
await updateEntity(
|
||||
licenseRepo,
|
||||
{ delete_order_id: targetOrder.id },
|
||||
{
|
||||
status: LICENSE_ALLOCATED_STATUS.UNALLOCATED,
|
||||
deleted_at: null,
|
||||
delete_order_id: null,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// 発行時に発行されたライセンスを削除する
|
||||
await licenseRepo.delete({ order_id: targetOrder.id });
|
||||
await deleteEntity(
|
||||
licenseRepo,
|
||||
{ order_id: targetOrder.id },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -964,7 +1034,8 @@ export class AccountsRepositoryService {
|
||||
}
|
||||
const accountRepo = entityManager.getRepository(Account);
|
||||
// アカウント情報を更新
|
||||
await accountRepo.update(
|
||||
await updateEntity(
|
||||
accountRepo,
|
||||
{ id: myAccountId },
|
||||
{
|
||||
parent_account_id: parentAccountId ?? null,
|
||||
@ -972,6 +1043,8 @@ export class AccountsRepositoryService {
|
||||
primary_admin_user_id: primaryAdminUserId,
|
||||
secondary_admin_user_id: secondryAdminUserId ?? null,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1005,9 +1078,12 @@ export class AccountsRepositoryService {
|
||||
}
|
||||
|
||||
// アカウントのActiveWorktypeIDを更新
|
||||
await accountRepo.update(
|
||||
await updateEntity(
|
||||
accountRepo,
|
||||
{ id: accountId },
|
||||
{ active_worktype_id: id ?? null },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1030,12 +1106,13 @@ export class AccountsRepositoryService {
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
const userArchiveRepo = entityManager.getRepository(UserArchive);
|
||||
await userArchiveRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(UserArchive)
|
||||
.values(users)
|
||||
.execute();
|
||||
await insertEntities(
|
||||
UserArchive,
|
||||
userArchiveRepo,
|
||||
users,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 削除対象のライセンスを退避テーブルに退避
|
||||
const licenses = await this.dataSource.getRepository(License).find({
|
||||
@ -1045,12 +1122,13 @@ export class AccountsRepositoryService {
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
const licenseArchiveRepo = entityManager.getRepository(LicenseArchive);
|
||||
await licenseArchiveRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(LicenseArchive)
|
||||
.values(licenses)
|
||||
.execute();
|
||||
await insertEntities(
|
||||
LicenseArchive,
|
||||
licenseArchiveRepo,
|
||||
licenses,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 削除対象のライセンス割り当て履歴を退避テーブルに退避
|
||||
const licenseHistories = await this.dataSource
|
||||
@ -1064,22 +1142,30 @@ export class AccountsRepositoryService {
|
||||
const licenseHistoryArchiveRepo = entityManager.getRepository(
|
||||
LicenseAllocationHistoryArchive,
|
||||
);
|
||||
await licenseHistoryArchiveRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(LicenseAllocationHistoryArchive)
|
||||
.values(licenseHistories)
|
||||
.execute();
|
||||
await insertEntities(
|
||||
LicenseAllocationHistoryArchive,
|
||||
licenseHistoryArchiveRepo,
|
||||
licenseHistories,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// アカウントを削除
|
||||
const accountRepo = entityManager.getRepository(Account);
|
||||
await accountRepo.delete({ id: accountId });
|
||||
|
||||
await deleteEntity(
|
||||
accountRepo,
|
||||
{ id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// ライセンス系(card_license_issue以外)のテーブルのレコードを削除する
|
||||
const orderRepo = entityManager.getRepository(LicenseOrder);
|
||||
await orderRepo.delete({
|
||||
from_account_id: accountId,
|
||||
});
|
||||
await deleteEntity(
|
||||
orderRepo,
|
||||
{ from_account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
const licenseRepo = entityManager.getRepository(License);
|
||||
const targetLicenses = await licenseRepo.find({
|
||||
where: {
|
||||
@ -1088,18 +1174,27 @@ export class AccountsRepositoryService {
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
const cardLicenseRepo = entityManager.getRepository(CardLicense);
|
||||
await cardLicenseRepo.delete({
|
||||
license_id: In(targetLicenses.map((license) => license.id)),
|
||||
});
|
||||
await licenseRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
await deleteEntity(
|
||||
cardLicenseRepo,
|
||||
{ license_id: In(targetLicenses.map((license) => license.id)) },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
licenseRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
const LicenseAllocationHistoryRepo = entityManager.getRepository(
|
||||
LicenseAllocationHistory,
|
||||
);
|
||||
await LicenseAllocationHistoryRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
await deleteEntity(
|
||||
LicenseAllocationHistoryRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ワークタイプ系のテーブルのレコードを削除する
|
||||
const worktypeRepo = entityManager.getRepository(Worktype);
|
||||
@ -1109,10 +1204,18 @@ export class AccountsRepositoryService {
|
||||
});
|
||||
|
||||
const optionItemRepo = entityManager.getRepository(OptionItem);
|
||||
await optionItemRepo.delete({
|
||||
worktype_id: In(taggerWorktypes.map((worktype) => worktype.id)),
|
||||
});
|
||||
await worktypeRepo.delete({ account_id: accountId });
|
||||
await deleteEntity(
|
||||
optionItemRepo,
|
||||
{ worktype_id: In(taggerWorktypes.map((worktype) => worktype.id)) },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
worktypeRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// タスク系のテーブルのレコードを削除する
|
||||
const taskRepo = entityManager.getRepository(Task);
|
||||
@ -1124,12 +1227,18 @@ export class AccountsRepositoryService {
|
||||
});
|
||||
const checkoutPermissionRepo =
|
||||
entityManager.getRepository(CheckoutPermission);
|
||||
await checkoutPermissionRepo.delete({
|
||||
task_id: In(targetTasks.map((task) => task.id)),
|
||||
});
|
||||
await taskRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
await deleteEntity(
|
||||
checkoutPermissionRepo,
|
||||
{ task_id: In(targetTasks.map((task) => task.id)) },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
taskRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// オーディオファイル系のテーブルのレコードを削除する
|
||||
const audioFileRepo = entityManager.getRepository(AudioFile);
|
||||
@ -1140,12 +1249,20 @@ export class AccountsRepositoryService {
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
const audioOptionItemsRepo = entityManager.getRepository(AudioOptionItem);
|
||||
await audioOptionItemsRepo.delete({
|
||||
await deleteEntity(
|
||||
audioOptionItemsRepo,
|
||||
{
|
||||
audio_file_id: In(targetaudioFiles.map((audioFile) => audioFile.id)),
|
||||
});
|
||||
await audioFileRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
audioFileRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ユーザーグループ系のテーブルのレコードを削除する
|
||||
const userGroupRepo = entityManager.getRepository(UserGroup);
|
||||
@ -1156,28 +1273,47 @@ export class AccountsRepositoryService {
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
const userGroupMemberRepo = entityManager.getRepository(UserGroupMember);
|
||||
await userGroupMemberRepo.delete({
|
||||
await deleteEntity(
|
||||
userGroupMemberRepo,
|
||||
{
|
||||
user_group_id: In(targetUserGroup.map((userGroup) => userGroup.id)),
|
||||
});
|
||||
await userGroupRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
userGroupRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// テンプレートファイルテーブルのレコードを削除する
|
||||
const templateFileRepo = entityManager.getRepository(TemplateFile);
|
||||
await templateFileRepo.delete({ account_id: accountId });
|
||||
await deleteEntity(
|
||||
templateFileRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ユーザテーブルのレコードを削除する
|
||||
const userRepo = entityManager.getRepository(User);
|
||||
await userRepo.delete({
|
||||
account_id: accountId,
|
||||
});
|
||||
await deleteEntity(
|
||||
userRepo,
|
||||
{ account_id: accountId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ソート条件のテーブルのレコードを削除する
|
||||
const sortCriteriaRepo = entityManager.getRepository(SortCriteria);
|
||||
await sortCriteriaRepo.delete({
|
||||
user_id: In(users.map((user) => user.id)),
|
||||
});
|
||||
await deleteEntity(
|
||||
sortCriteriaRepo,
|
||||
{ user_id: In(users.map((user) => user.id)) },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
return users;
|
||||
});
|
||||
}
|
||||
|
||||
@ -32,10 +32,17 @@ import {
|
||||
DateWithZeroTime,
|
||||
} from '../../features/licenses/types/types';
|
||||
import { NewAllocatedLicenseExpirationDate } from '../../features/licenses/types/types';
|
||||
import {
|
||||
insertEntity,
|
||||
insertEntities,
|
||||
updateEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class LicensesRepositoryService {
|
||||
//クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
constructor(private dataSource: DataSource) {}
|
||||
private readonly logger = new Logger(LicensesRepositoryService.name);
|
||||
|
||||
@ -81,7 +88,13 @@ export class LicensesRepositoryService {
|
||||
|
||||
const repo = entityManager.getRepository(LicenseOrder);
|
||||
const newLicenseOrder = repo.create(licenseOrder);
|
||||
const persisted = await repo.save(newLicenseOrder);
|
||||
const persisted = await insertEntity(
|
||||
LicenseOrder,
|
||||
repo,
|
||||
newLicenseOrder,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
return persisted;
|
||||
},
|
||||
);
|
||||
@ -116,19 +129,24 @@ export class LicensesRepositoryService {
|
||||
license.type = LICENSE_TYPE.CARD;
|
||||
licenses.push(license);
|
||||
}
|
||||
const savedLicenses = await licensesRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(License)
|
||||
.values(licenses)
|
||||
.execute();
|
||||
const savedLicenses = await insertEntities(
|
||||
License,
|
||||
licensesRepo,
|
||||
licenses,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// カードライセンス発行テーブルを作成する
|
||||
const cardLicenseIssue = new CardLicenseIssue();
|
||||
cardLicenseIssue.issued_at = new Date();
|
||||
const newCardLicenseIssue = cardLicenseIssueRepo.create(cardLicenseIssue);
|
||||
const savedCardLicensesIssue = await cardLicenseIssueRepo.save(
|
||||
const savedCardLicensesIssue = await insertEntity(
|
||||
CardLicenseIssue,
|
||||
cardLicenseIssueRepo,
|
||||
newCardLicenseIssue,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
let isDuplicateKeysExist = true;
|
||||
@ -173,17 +191,20 @@ export class LicensesRepositoryService {
|
||||
// カードライセンステーブルを作成する(BULK INSERT)
|
||||
for (let i = 0; i < count; i++) {
|
||||
const cardLicense = new CardLicense();
|
||||
cardLicense.license_id = savedLicenses.generatedMaps[i].id; // Licenseテーブルの自動採番されたIDを挿入
|
||||
cardLicense.license_id = savedLicenses[i].id; // Licenseテーブルの自動採番されたIDを挿入
|
||||
cardLicense.issue_id = savedCardLicensesIssue.id; // CardLicenseIssueテーブルの自動採番されたIDを挿入
|
||||
cardLicense.card_license_key = licenseKeys[i];
|
||||
cardLicenses.push(cardLicense);
|
||||
}
|
||||
await cardLicenseRepo
|
||||
//TODO カードライセンステーブルのみPKがidではなかったためInsertEntitiesに置き換えができなかった。
|
||||
const query = cardLicenseRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(CardLicense)
|
||||
.values(cardLicenses)
|
||||
.execute();
|
||||
.into(CardLicense);
|
||||
if (this.isCommentOut) {
|
||||
query.comment(`${context.getTrackingId()}_${new Date().toUTCString()}`);
|
||||
}
|
||||
query.values(cardLicenses).execute();
|
||||
});
|
||||
return licenseKeys;
|
||||
}
|
||||
@ -275,11 +296,23 @@ export class LicensesRepositoryService {
|
||||
|
||||
// ライセンステーブルを更新する
|
||||
targetLicense.account_id = accountId;
|
||||
await licensesRepo.save(targetLicense);
|
||||
await updateEntity(
|
||||
licensesRepo,
|
||||
{ id: targetLicense.id },
|
||||
targetLicense,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// カードライセンステーブルを更新する
|
||||
targetCardLicense.activated_at = new Date();
|
||||
await cardLicenseRepo.save(targetCardLicense);
|
||||
await updateEntity(
|
||||
cardLicenseRepo,
|
||||
{ license_id: targetCardLicense.license_id },
|
||||
targetCardLicense,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
this.logger.log(
|
||||
`activate success. licence_id: ${targetCardLicense.license_id}`,
|
||||
@ -380,20 +413,24 @@ export class LicensesRepositoryService {
|
||||
return license;
|
||||
});
|
||||
// ライセンス注文テーブルを更新(注文元)
|
||||
await licenseOrderRepo.update(
|
||||
await updateEntity(
|
||||
licenseOrderRepo,
|
||||
{ id: issuingOrder.id },
|
||||
{
|
||||
issued_at: nowDate,
|
||||
status: LICENSE_ISSUE_STATUS.ISSUED,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// ライセンステーブルを登録(注文元)
|
||||
await licenseRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(License)
|
||||
.values(newLicenses)
|
||||
.execute();
|
||||
await insertEntities(
|
||||
License,
|
||||
licenseRepo,
|
||||
newLicenses,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 第一階層の場合はストックライセンスの概念が存在しないため、ストックライセンス変更処理は行わない
|
||||
if (tier !== TIERS.TIER1) {
|
||||
@ -422,7 +459,17 @@ export class LicensesRepositoryService {
|
||||
licenseToUpdate.delete_order_id = issuingOrder.id;
|
||||
}
|
||||
// 自身のライセンスを削除(論理削除)する
|
||||
await licenseRepo.save(licensesToUpdate);
|
||||
await updateEntity(
|
||||
licenseRepo,
|
||||
{ id: In(licensesToUpdate.map((l) => l.id)) },
|
||||
{
|
||||
status: LICENSE_ALLOCATED_STATUS.DELETED,
|
||||
deleted_at: nowDate,
|
||||
delete_order_id: issuingOrder.id,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -527,7 +574,13 @@ export class LicensesRepositoryService {
|
||||
allocatedLicense.status = LICENSE_ALLOCATED_STATUS.REUSABLE;
|
||||
allocatedLicense.allocated_user_id = null;
|
||||
|
||||
await licenseRepo.save(allocatedLicense);
|
||||
await updateEntity(
|
||||
licenseRepo,
|
||||
{ id: allocatedLicense.id },
|
||||
allocatedLicense,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ライセンス割り当て履歴テーブルへ登録
|
||||
const deallocationHistory = new LicenseAllocationHistory();
|
||||
@ -537,7 +590,13 @@ export class LicensesRepositoryService {
|
||||
deallocationHistory.is_allocated = false;
|
||||
deallocationHistory.executed_at = new Date();
|
||||
deallocationHistory.switch_from_type = SWITCH_FROM_TYPE.NONE;
|
||||
await licenseAllocationHistoryRepo.save(deallocationHistory);
|
||||
await insertEntity(
|
||||
LicenseAllocationHistory,
|
||||
licenseAllocationHistoryRepo,
|
||||
deallocationHistory,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
// ライセンス割り当てを実施
|
||||
@ -547,7 +606,13 @@ export class LicensesRepositoryService {
|
||||
if (!targetLicense.expiry_date) {
|
||||
targetLicense.expiry_date = new NewAllocatedLicenseExpirationDate();
|
||||
}
|
||||
await licenseRepo.save(targetLicense);
|
||||
await updateEntity(
|
||||
licenseRepo,
|
||||
{ id: targetLicense.id },
|
||||
targetLicense,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 直近割り当てたライセンス種別を取得
|
||||
const oldLicenseType = await licenseAllocationHistoryRepo.findOne({
|
||||
@ -586,7 +651,13 @@ export class LicensesRepositoryService {
|
||||
// TODO switchFromTypeの値については「PBI1234: 第一階層として、ライセンス数推移情報をCSV出力したい」で正式対応
|
||||
allocationHistory.switch_from_type = switchFromType;
|
||||
|
||||
await licenseAllocationHistoryRepo.save(allocationHistory);
|
||||
await insertEntity(
|
||||
LicenseAllocationHistory,
|
||||
licenseAllocationHistoryRepo,
|
||||
allocationHistory,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -623,7 +694,13 @@ export class LicensesRepositoryService {
|
||||
// ライセンスの割り当てを解除
|
||||
allocatedLicense.status = LICENSE_ALLOCATED_STATUS.REUSABLE;
|
||||
allocatedLicense.allocated_user_id = null;
|
||||
await licenseRepo.save(allocatedLicense);
|
||||
await updateEntity(
|
||||
licenseRepo,
|
||||
{ id: allocatedLicense.id },
|
||||
allocatedLicense,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ライセンス割り当て履歴テーブルへ登録
|
||||
const deallocationHistory = new LicenseAllocationHistory();
|
||||
@ -633,7 +710,13 @@ export class LicensesRepositoryService {
|
||||
deallocationHistory.is_allocated = false;
|
||||
deallocationHistory.executed_at = new Date();
|
||||
deallocationHistory.switch_from_type = SWITCH_FROM_TYPE.NONE;
|
||||
await licenseAllocationHistoryRepo.save(deallocationHistory);
|
||||
await insertEntity(
|
||||
LicenseAllocationHistory,
|
||||
licenseAllocationHistoryRepo,
|
||||
deallocationHistory,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -670,7 +753,13 @@ export class LicensesRepositoryService {
|
||||
// 注文キャンセル処理
|
||||
targetOrder.status = LICENSE_ISSUE_STATUS.CANCELED;
|
||||
targetOrder.canceled_at = new Date();
|
||||
await orderRepo.save(targetOrder);
|
||||
await updateEntity(
|
||||
orderRepo,
|
||||
{ id: targetOrder.id },
|
||||
targetOrder,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import {
|
||||
TaskListSortableAttribute,
|
||||
SortDirection,
|
||||
} from '../../common/types/sort';
|
||||
import { updateEntity } from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
@ -23,7 +24,7 @@ export class SortCriteriaRepositoryService {
|
||||
userId: number,
|
||||
parameter: TaskListSortableAttribute,
|
||||
direction: SortDirection,
|
||||
): Promise<SortCriteria> {
|
||||
): Promise<void> {
|
||||
this.logger.log(
|
||||
` ${this.updateSortCriteria.name}; parameter:${parameter}, direction:${direction}`,
|
||||
);
|
||||
@ -43,8 +44,13 @@ export class SortCriteriaRepositoryService {
|
||||
targetSortCriteria.parameter = parameter;
|
||||
targetSortCriteria.direction = direction;
|
||||
|
||||
const persisted = await repo.save(targetSortCriteria);
|
||||
return persisted;
|
||||
await updateEntity(
|
||||
repo,
|
||||
{ id: targetSortCriteria.id },
|
||||
targetSortCriteria,
|
||||
false,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
||||
@ -41,10 +41,18 @@ import { TaskStatus, isTaskStatus } from '../../common/types/taskStatus';
|
||||
import { SortCriteria } from '../sort_criteria/entity/sort_criteria.entity';
|
||||
import { Workflow } from '../workflows/entity/workflow.entity';
|
||||
import { Worktype } from '../worktypes/entity/worktype.entity';
|
||||
import {
|
||||
insertEntities,
|
||||
insertEntity,
|
||||
updateEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class TasksRepositoryService {
|
||||
//クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
@ -252,7 +260,8 @@ export class TasksRepositoryService {
|
||||
|
||||
// 対象タスクの文字起こし開始日時を現在時刻に更新。割り当てユーザーを自身のユーザーIDに更新
|
||||
// タスクのステータスがUploaded以外の場合、文字起こし開始時刻は更新しない
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ audio_file_id: audio_file_id },
|
||||
{
|
||||
started_at:
|
||||
@ -262,18 +271,31 @@ export class TasksRepositoryService {
|
||||
typist_user_id: user_id,
|
||||
status: TASK_STATUS.IN_PROGRESS,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
//対象のタスクに紐づくチェックアウト権限レコードを削除
|
||||
await checkoutRepo.delete({
|
||||
await deleteEntity(
|
||||
checkoutRepo,
|
||||
{
|
||||
task_id: task.id,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
//対象のタスクチェックアウト権限を自身のユーザーIDで作成
|
||||
await checkoutRepo.save({
|
||||
insertEntity(
|
||||
CheckoutPermission,
|
||||
checkoutRepo,
|
||||
{
|
||||
task_id: task.id,
|
||||
user_id: user_id,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -315,12 +337,15 @@ export class TasksRepositoryService {
|
||||
}
|
||||
|
||||
// 対象タスクの文字起こし終了日時を現在時刻に更新。ステータスをFinishedに更新
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ audio_file_id: audio_file_id },
|
||||
{
|
||||
finished_at: new Date().toISOString(),
|
||||
status: TASK_STATUS.FINISHED,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -374,12 +399,15 @@ export class TasksRepositoryService {
|
||||
}
|
||||
|
||||
// 対象タスクの文字起こし担当をnull,ステータスをUploadedに更新
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ audio_file_id: audio_file_id },
|
||||
{
|
||||
typist_user_id: null,
|
||||
status: TASK_STATUS.UPLOADED,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
const checkoutPermissionRepo =
|
||||
@ -388,9 +416,14 @@ export class TasksRepositoryService {
|
||||
// 対象タスクの文字起こし候補を削除
|
||||
/* 対象タスクがInprogress,Pendingの状態の場合、文字起こし担当者個人指定のレコードのみだが、ユーザーIDの指定はしない
|
||||
(データの不整合があっても問題ないように)*/
|
||||
await checkoutPermissionRepo.delete({
|
||||
await deleteEntity(
|
||||
checkoutPermissionRepo,
|
||||
{
|
||||
task_id: task.id,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -432,11 +465,14 @@ export class TasksRepositoryService {
|
||||
}
|
||||
|
||||
// 対象タスクの文字起こし終了日時を現在時刻に更新。ステータスをFinishedに更新
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ audio_file_id: audio_file_id },
|
||||
{
|
||||
status: TASK_STATUS.PENDING,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -479,12 +515,15 @@ export class TasksRepositoryService {
|
||||
}
|
||||
|
||||
// ステータスをバックアップに更新、JobNumberを無効化
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ audio_file_id: audio_file_id },
|
||||
{
|
||||
status: TASK_STATUS.BACKUP,
|
||||
is_job_number_enabled: false,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -809,7 +848,13 @@ export class TasksRepositoryService {
|
||||
async (entityManager) => {
|
||||
const audioFileRepo = entityManager.getRepository(AudioFile);
|
||||
const newAudioFile = audioFileRepo.create(audioFile);
|
||||
const savedAudioFile = await audioFileRepo.save(newAudioFile);
|
||||
const savedAudioFile = await insertEntity(
|
||||
AudioFile,
|
||||
audioFileRepo,
|
||||
newAudioFile,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
task.audio_file_id = savedAudioFile.id;
|
||||
|
||||
@ -835,7 +880,13 @@ export class TasksRepositoryService {
|
||||
}
|
||||
task.job_number = newJobNumber;
|
||||
|
||||
const persisted = await taskRepo.save(task);
|
||||
const persisted = await insertEntity(
|
||||
Task,
|
||||
taskRepo,
|
||||
task,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
const optionItems = paramOptionItems.map((x) => {
|
||||
return {
|
||||
@ -847,7 +898,13 @@ export class TasksRepositoryService {
|
||||
|
||||
const optionItemRepo = entityManager.getRepository(AudioOptionItem);
|
||||
const newAudioOptionItems = optionItemRepo.create(optionItems);
|
||||
await optionItemRepo.save(newAudioOptionItems);
|
||||
await insertEntities(
|
||||
AudioOptionItem,
|
||||
optionItemRepo,
|
||||
newAudioOptionItems,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
return persisted;
|
||||
},
|
||||
);
|
||||
@ -946,9 +1003,14 @@ export class TasksRepositoryService {
|
||||
// 当該タスクに紐づく既存checkoutPermissionをdelete
|
||||
const checkoutPermissionRepo =
|
||||
entityManager.getRepository(CheckoutPermission);
|
||||
await checkoutPermissionRepo.delete({
|
||||
await deleteEntity(
|
||||
checkoutPermissionRepo,
|
||||
{
|
||||
task_id: taskRecord.id,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 当該タスクに紐づく新規checkoutPermissionをinsert
|
||||
const checkoutPermissions: CheckoutPermission[] = assignees.map(
|
||||
@ -961,7 +1023,13 @@ export class TasksRepositoryService {
|
||||
},
|
||||
);
|
||||
|
||||
return await checkoutPermissionRepo.save(checkoutPermissions);
|
||||
return await insertEntities(
|
||||
CheckoutPermission,
|
||||
checkoutPermissionRepo,
|
||||
checkoutPermissions,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1025,7 +1093,10 @@ export class TasksRepositoryService {
|
||||
|
||||
const groupMemberRepo = entityManager.getRepository(UserGroupMember);
|
||||
// ユーザーの所属するすべてのグループを列挙
|
||||
const groups = await groupMemberRepo.find({ where: { user_id: userId } });
|
||||
const groups = await groupMemberRepo.find({
|
||||
where: { user_id: userId },
|
||||
comment: `${context.getTrackingId()}_${new Date().toUTCString()}`,
|
||||
});
|
||||
// ユーザーの所属するすべてのグループIDを列挙
|
||||
const groupIds = groups.map((member) => member.user_group_id);
|
||||
|
||||
@ -1236,11 +1307,14 @@ export class TasksRepositoryService {
|
||||
|
||||
// タスクのテンプレートIDを更新
|
||||
const taskRepo = entityManager.getRepository(Task);
|
||||
await taskRepo.update(
|
||||
await updateEntity(
|
||||
taskRepo,
|
||||
{ id: task.id },
|
||||
{
|
||||
template_file_id: template_id,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 取得したルーティングルールのタイピストまたはタイピストグループをチェックアウト権限に設定する
|
||||
@ -1274,9 +1348,14 @@ export class TasksRepositoryService {
|
||||
entityManager.getRepository(CheckoutPermission);
|
||||
|
||||
// 当該タスクに紐づく既存checkoutPermissionをdelete
|
||||
await checkoutPermissionRepo.delete({
|
||||
await deleteEntity(
|
||||
checkoutPermissionRepo,
|
||||
{
|
||||
task_id: task.id,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ルーティング候補ユーザーのチェックアウト権限を作成
|
||||
const typistPermissions = typistUsers.map((typistUser) => {
|
||||
@ -1293,7 +1372,13 @@ export class TasksRepositoryService {
|
||||
return permission;
|
||||
});
|
||||
const permissions = [...typistPermissions, ...typistGroupPermissions];
|
||||
await checkoutPermissionRepo.save(permissions);
|
||||
await insertEntities(
|
||||
CheckoutPermission,
|
||||
checkoutPermissionRepo,
|
||||
permissions,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// user_idsとuser_group_idsを返却する
|
||||
return {
|
||||
typistIds: typistIds,
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { TemplateFile } from './entity/template_file.entity';
|
||||
import { insertEntity, updateEntity } from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class TemplateFilesRepositoryService {
|
||||
//クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
@ -52,16 +56,25 @@ export class TemplateFilesRepositoryService {
|
||||
|
||||
// 同名ファイルは同じものとして扱うため、すでにファイルがあれば更新(更新日時の履歴を残しておきたい)
|
||||
if (template) {
|
||||
await templateFilesRepo.update(
|
||||
await updateEntity(
|
||||
templateFilesRepo,
|
||||
{ id: template.id },
|
||||
{ file_name: fileName, url: url },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
const newTemplate = new TemplateFile();
|
||||
newTemplate.account_id = accountId;
|
||||
newTemplate.file_name = fileName;
|
||||
newTemplate.url = url;
|
||||
await templateFilesRepo.save(newTemplate);
|
||||
await insertEntity(
|
||||
TemplateFile,
|
||||
templateFilesRepo,
|
||||
newTemplate,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -5,10 +5,18 @@ import { UserGroupMember } from './entity/user_group_member.entity';
|
||||
import { User } from '../users/entity/user.entity';
|
||||
import { TypistGroupNotExistError, TypistIdInvalidError } from './errors/types';
|
||||
import { USER_ROLES } from '../../constants';
|
||||
import {
|
||||
insertEntities,
|
||||
insertEntity,
|
||||
updateEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class UserGroupsRepositoryService {
|
||||
//クエリログにコメントを付与するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
async getUserGroups(
|
||||
@ -124,10 +132,16 @@ export class UserGroupsRepositoryService {
|
||||
);
|
||||
}
|
||||
// userGroupをDBに保存する
|
||||
const userGroup = await userGroupRepo.save({
|
||||
account_id: accountId,
|
||||
const userGroup = await insertEntity(
|
||||
UserGroup,
|
||||
userGroupRepo,
|
||||
{
|
||||
name,
|
||||
});
|
||||
account_id: accountId,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
const userGroupMembers = userRecords.map((user) => {
|
||||
return {
|
||||
@ -136,7 +150,13 @@ export class UserGroupsRepositoryService {
|
||||
};
|
||||
});
|
||||
// userGroupMembersをDBに保存する
|
||||
await userGroupMemberRepo.save(userGroupMembers);
|
||||
await insertEntities(
|
||||
UserGroupMember,
|
||||
userGroupMemberRepo,
|
||||
userGroupMembers,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
return userGroup;
|
||||
});
|
||||
@ -195,12 +215,23 @@ export class UserGroupsRepositoryService {
|
||||
// 対象のタイピストグループを更新する
|
||||
// ユーザーグループ名を更新する
|
||||
typistGroup.name = typistGroupName;
|
||||
await userGroupRepo.save(typistGroup);
|
||||
await updateEntity(
|
||||
userGroupRepo,
|
||||
{ id: typistGroupId },
|
||||
typistGroup,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// user_group_membersテーブルから対象のタイピストグループのユーザーを削除する
|
||||
await userGroupMemberRepo.delete({
|
||||
await deleteEntity(
|
||||
userGroupMemberRepo,
|
||||
{
|
||||
user_group_id: typistGroupId,
|
||||
});
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
const typistGroupMembers = userRecords.map((typist) => {
|
||||
return {
|
||||
@ -208,7 +239,13 @@ export class UserGroupsRepositoryService {
|
||||
user_id: typist.id,
|
||||
};
|
||||
});
|
||||
await userGroupMemberRepo.save(typistGroupMembers);
|
||||
await insertEntities(
|
||||
UserGroupMember,
|
||||
userGroupMemberRepo,
|
||||
typistGroupMembers,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
return typistGroup;
|
||||
});
|
||||
|
||||
@ -36,9 +36,18 @@ import { Account } from '../accounts/entity/account.entity';
|
||||
import { Workflow } from '../workflows/entity/workflow.entity';
|
||||
import { Worktype } from '../worktypes/entity/worktype.entity';
|
||||
import { Context } from '../../common/log';
|
||||
import {
|
||||
insertEntity,
|
||||
insertEntities,
|
||||
updateEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
|
||||
@Injectable()
|
||||
export class UsersRepositoryService {
|
||||
// クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
@ -46,7 +55,7 @@ export class UsersRepositoryService {
|
||||
* @param user
|
||||
* @returns User
|
||||
*/
|
||||
async createNormalUser(user: newUser): Promise<User> {
|
||||
async createNormalUser(context: Context, user: newUser): Promise<User> {
|
||||
const {
|
||||
account_id: accountId,
|
||||
external_id: externalUserId,
|
||||
@ -80,7 +89,13 @@ export class UsersRepositoryService {
|
||||
async (entityManager) => {
|
||||
const repo = entityManager.getRepository(User);
|
||||
const newUser = repo.create(userEntity);
|
||||
const persisted = await repo.save(newUser);
|
||||
const persisted = await insertEntity(
|
||||
User,
|
||||
repo,
|
||||
newUser,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ユーザーのタスクソート条件を作成
|
||||
const sortCriteria = new SortCriteria();
|
||||
@ -91,7 +106,13 @@ export class UsersRepositoryService {
|
||||
}
|
||||
const sortCriteriaRepo = entityManager.getRepository(SortCriteria);
|
||||
const newSortCriteria = sortCriteriaRepo.create(sortCriteria);
|
||||
await sortCriteriaRepo.save(newSortCriteria);
|
||||
await insertEntity(
|
||||
SortCriteria,
|
||||
sortCriteriaRepo,
|
||||
newSortCriteria,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
return persisted;
|
||||
},
|
||||
@ -256,7 +277,13 @@ export class UsersRepositoryService {
|
||||
targetUser.license_alert = licenseAlart;
|
||||
targetUser.notification = notification;
|
||||
|
||||
const result = await repo.update({ id: id }, targetUser);
|
||||
const result = await updateEntity(
|
||||
repo,
|
||||
{ id: id },
|
||||
targetUser,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// 想定外の更新が行われた場合はロールバックを行った上でエラー送出
|
||||
if (result.affected !== 1) {
|
||||
@ -295,7 +322,13 @@ export class UsersRepositoryService {
|
||||
|
||||
targetUser.email_verified = true;
|
||||
|
||||
return await repo.update({ id: targetUser.id }, targetUser);
|
||||
return await updateEntity(
|
||||
repo,
|
||||
{ id: targetUser.id },
|
||||
targetUser,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -331,7 +364,13 @@ export class UsersRepositoryService {
|
||||
|
||||
targetUser.email_verified = true;
|
||||
|
||||
await userRepo.update({ id: targetUser.id }, targetUser);
|
||||
await updateEntity(
|
||||
userRepo,
|
||||
{ id: targetUser.id },
|
||||
targetUser,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// トライアルライセンス100件を作成する
|
||||
const licenseRepo = entityManager.getRepository(License);
|
||||
@ -349,12 +388,13 @@ export class UsersRepositoryService {
|
||||
licenses.push(license);
|
||||
}
|
||||
|
||||
await licenseRepo
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(License)
|
||||
.values(licenses)
|
||||
.execute();
|
||||
await insertEntities(
|
||||
License,
|
||||
licenseRepo,
|
||||
licenses,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -457,16 +497,19 @@ export class UsersRepositoryService {
|
||||
* @param userId
|
||||
* @returns delete
|
||||
*/
|
||||
async deleteNormalUser(userId: number): Promise<void> {
|
||||
async deleteNormalUser(context: Context, userId: number): Promise<void> {
|
||||
await this.dataSource.transaction(async (entityManager) => {
|
||||
const usersRepo = entityManager.getRepository(User);
|
||||
const sortCriteriaRepo = entityManager.getRepository(SortCriteria);
|
||||
// ソート条件を削除
|
||||
await sortCriteriaRepo.delete({
|
||||
user_id: userId,
|
||||
});
|
||||
await deleteEntity(
|
||||
sortCriteriaRepo,
|
||||
{ user_id: userId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
// プライマリ管理者を削除
|
||||
await usersRepo.delete({ id: userId });
|
||||
await deleteEntity(usersRepo, { id: userId }, this.isCommentOut, context);
|
||||
});
|
||||
}
|
||||
|
||||
@ -599,7 +642,13 @@ export class UsersRepositoryService {
|
||||
user.accepted_privacy_notice_version =
|
||||
privacyNoticeVersion ?? user.accepted_privacy_notice_version;
|
||||
user.accepted_dpa_version = dpaVersion ?? user.accepted_dpa_version;
|
||||
await userRepo.update({ id: user.id }, user);
|
||||
await updateEntity(
|
||||
userRepo,
|
||||
{ id: user.id },
|
||||
user,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -15,10 +15,18 @@ import {
|
||||
AuthorIdAndWorktypeIdPairAlreadyExistsError,
|
||||
WorkflowNotFoundError,
|
||||
} from './errors/types';
|
||||
import {
|
||||
insertEntities,
|
||||
insertEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class WorkflowsRepositoryService {
|
||||
// クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
@ -165,7 +173,13 @@ export class WorkflowsRepositoryService {
|
||||
templateId,
|
||||
);
|
||||
|
||||
await workflowRepo.save(newWorkflow);
|
||||
await insertEntity(
|
||||
Workflow,
|
||||
workflowRepo,
|
||||
newWorkflow,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ルーティング候補のデータ作成
|
||||
const workflowTypists = typists.map((typist) =>
|
||||
@ -177,7 +191,13 @@ export class WorkflowsRepositoryService {
|
||||
);
|
||||
|
||||
const workflowTypistsRepo = entityManager.getRepository(DbWorkflowTypist);
|
||||
await workflowTypistsRepo.save(workflowTypists);
|
||||
await insertEntities(
|
||||
DbWorkflowTypist,
|
||||
workflowTypistsRepo,
|
||||
workflowTypists,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -290,8 +310,18 @@ export class WorkflowsRepositoryService {
|
||||
const workflowTypistsRepo = entityManager.getRepository(DbWorkflowTypist);
|
||||
|
||||
// 既存データの削除
|
||||
await workflowTypistsRepo.delete({ workflow_id: workflowId });
|
||||
await workflowRepo.delete(workflowId);
|
||||
await deleteEntity(
|
||||
workflowTypistsRepo,
|
||||
{ workflow_id: workflowId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
workflowRepo,
|
||||
{ id: workflowId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
{
|
||||
// ワークフローの重複確認
|
||||
@ -318,7 +348,13 @@ export class WorkflowsRepositoryService {
|
||||
templateId,
|
||||
);
|
||||
|
||||
await workflowRepo.save(newWorkflow);
|
||||
await insertEntity(
|
||||
Workflow,
|
||||
workflowRepo,
|
||||
newWorkflow,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ルーティング候補のデータ作成
|
||||
const workflowTypists = typists.map((typist) =>
|
||||
@ -329,7 +365,13 @@ export class WorkflowsRepositoryService {
|
||||
),
|
||||
);
|
||||
|
||||
await workflowTypistsRepo.save(workflowTypists);
|
||||
await insertEntities(
|
||||
DbWorkflowTypist,
|
||||
workflowTypistsRepo,
|
||||
workflowTypists,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -358,9 +400,18 @@ export class WorkflowsRepositoryService {
|
||||
`workflow not found. id: ${workflowId}`,
|
||||
);
|
||||
}
|
||||
|
||||
await workflowTypistsRepo.delete({ workflow_id: workflowId });
|
||||
await workflowRepo.delete(workflowId);
|
||||
await deleteEntity(
|
||||
workflowTypistsRepo,
|
||||
{ workflow_id: workflowId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await deleteEntity(
|
||||
workflowRepo,
|
||||
{ id: workflowId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -17,10 +17,19 @@ import { PostWorktypeOptionItem } from '../../features/accounts/types/types';
|
||||
import { AccountNotFoundError } from '../accounts/errors/types';
|
||||
import { Account } from '../accounts/entity/account.entity';
|
||||
import { Workflow } from '../workflows/entity/workflow.entity';
|
||||
import {
|
||||
insertEntities,
|
||||
insertEntity,
|
||||
updateEntity,
|
||||
deleteEntity,
|
||||
} from '../../common/repository';
|
||||
import { Context } from '../../common/log';
|
||||
|
||||
@Injectable()
|
||||
export class WorktypesRepositoryService {
|
||||
// クエリログにコメントを出力するかどうか
|
||||
private readonly isCommentOut = process.env.STAGE !== 'local';
|
||||
|
||||
constructor(private dataSource: DataSource) {}
|
||||
|
||||
/**
|
||||
@ -101,11 +110,17 @@ export class WorktypesRepositoryService {
|
||||
}
|
||||
|
||||
// ワークタイプを作成
|
||||
const worktype = await worktypeRepo.save({
|
||||
const worktype = await insertEntity(
|
||||
Worktype,
|
||||
worktypeRepo,
|
||||
{
|
||||
account_id: accountId,
|
||||
custom_worktype_id: worktypeId,
|
||||
description: description,
|
||||
});
|
||||
description: description ?? null,
|
||||
},
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ワークタイプに紐づくオプションアイテムを10件作成
|
||||
const newOptionItems = Array.from({ length: OPTION_ITEM_NUM }, () => {
|
||||
@ -118,7 +133,13 @@ export class WorktypesRepositoryService {
|
||||
return optionItem;
|
||||
});
|
||||
|
||||
await optionItemRepo.save(newOptionItems);
|
||||
await insertEntities(
|
||||
OptionItem,
|
||||
optionItemRepo,
|
||||
newOptionItems,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -168,7 +189,13 @@ export class WorktypesRepositoryService {
|
||||
// ワークタイプを更新
|
||||
worktype.custom_worktype_id = worktypeId;
|
||||
worktype.description = description ?? null;
|
||||
await worktypeRepo.save(worktype);
|
||||
await updateEntity(
|
||||
worktypeRepo,
|
||||
{ id: id },
|
||||
{ custom_worktype_id: worktypeId, description: description ?? null },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -203,9 +230,12 @@ export class WorktypesRepositoryService {
|
||||
});
|
||||
|
||||
if (account?.active_worktype_id === id) {
|
||||
await accountRepo.update(
|
||||
await updateEntity(
|
||||
accountRepo,
|
||||
{ id: accountId },
|
||||
{ active_worktype_id: null },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
@ -224,10 +254,15 @@ export class WorktypesRepositoryService {
|
||||
|
||||
// ワークタイプに紐づくオプションアイテムを削除
|
||||
const optionItemRepo = entityManager.getRepository(OptionItem);
|
||||
await optionItemRepo.delete({ worktype_id: id });
|
||||
await deleteEntity(
|
||||
optionItemRepo,
|
||||
{ worktype_id: id },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
|
||||
// ワークタイプを削除
|
||||
await worktypeRepo.delete({ id: id });
|
||||
await deleteEntity(worktypeRepo, { id: id }, this.isCommentOut, context);
|
||||
});
|
||||
}
|
||||
|
||||
@ -307,8 +342,19 @@ export class WorktypesRepositoryService {
|
||||
});
|
||||
|
||||
// ワークタイプに紐づくオプションアイテムを削除してから再登録
|
||||
await optionItemRepo.delete({ worktype_id: worktypeId });
|
||||
await optionItemRepo.save(optionItems);
|
||||
await deleteEntity(
|
||||
optionItemRepo,
|
||||
{ worktype_id: worktypeId },
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
await insertEntities(
|
||||
OptionItem,
|
||||
optionItemRepo,
|
||||
optionItems,
|
||||
this.isCommentOut,
|
||||
context,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user