Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Job Launcher] Lint fixes #1249

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/apps/job-launcher/server/src/common/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ export const envValidator = Joi.object({
REPUTATION_ORACLE_FEE: Joi.string().default(10),
EXCHANGE_ORACLE_FEE: Joi.string().default(10),
REPUTATION_ORACLE_ADDRESS: Joi.string().required(),
FORTUNE_EXCHANGE_ORACLE_WEBHOOK_URL: Joi.string().default('http://localhost:3004'),
FORTUNE_EXCHANGE_ORACLE_WEBHOOK_URL: Joi.string().default(
'http://localhost:3004',
),
FORTUNE_EXCHANGE_ORACLE_ADDRESS: Joi.string().required(),
FORTUNE_RECORDING_ORACLE_ADDRESS: Joi.string().required(),
CVAT_EXCHANGE_ORACLE_WEBHOOK_URL: Joi.string().default('http://localhost:3005'),
CVAT_EXCHANGE_ORACLE_WEBHOOK_URL: Joi.string().default(
'http://localhost:3005',
),
CVAT_EXCHANGE_ORACLE_ADDRESS: Joi.string().required(),
CVAT_RECORDING_ORACLE_ADDRESS: Joi.string().required(),
HCAPTCHA_RECORDING_ORACLE_ADDRESS: Joi.string().required(),
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/job-launcher/server/src/common/config/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const s3Config = registerAs('s3', () => ({
}));

export const s3ConfigKey = s3Config.KEY;
export type S3ConfigType = ConfigType<typeof s3Config>;
export type S3ConfigType = ConfigType<typeof s3Config>;
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export enum ErrorAuth {
RefreshTokenHasExpired = 'Refresh token has expired',
UserNotActive = 'User not active',
ApiKeyCouldNotBeCreatedOrUpdated = 'API key could not be created or updated',
ApiKeyNotFound = 'API key not found'
ApiKeyNotFound = 'API key not found',
}

/**
Expand Down Expand Up @@ -94,7 +94,7 @@ export enum ErrorBucket {
NotExist = 'Bucket does not exist',
NotPublic = 'Bucket is not public',
UnableSaveFile = 'Unable to save file',
FailedToFetchBucketContents = 'Failed to fetch bucket contents'
FailedToFetchBucketContents = 'Failed to fetch bucket contents',
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ export const HCAPTCHA_IMMO_MIN_LENGTH = 1;
export const HCAPTCHA_IMMO_MAX_LENGTH = 100;
export const HCAPTCHA_ORACLE_STAKE = 0.05;

export const HCAPTCHA_NOT_PRESENTED_LABEL = 'Not presented';
export const HCAPTCHA_NOT_PRESENTED_LABEL = 'Not presented';
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './public';
export * from './apikey';
export * from './apikey';
230 changes: 115 additions & 115 deletions packages/apps/job-launcher/server/src/common/enums/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export enum JobRequestType {
}

export enum JobCaptchaMode {
BATCH = 'batch'
BATCH = 'batch',
}

export enum JobCaptchaRequestType {
IMAGE_LABEL_BINARY = 'image_label_binary',
IMAGE_LABEL_MULTIPLE_CHOICE = 'image_label_multiple_choice',
IMAGE_LABEL_MULTIPLE_CHOICE = 'image_label_multiple_choice',
IMAGE_LABEL_AREA_SELECT = 'image_label_area_select',
TEXT_FREEE_NTRY = 'text_free_entry',
}
Expand All @@ -41,119 +41,119 @@ export enum JobCaptchaShapeType {
POINT = 'point',
BOUNDING_BOX = 'bounding_box',
COMPARISON = 'comparison',
IMMO = 'immo'
IMMO = 'immo',
}

export enum WorkerLanguage {
AF = "af",
SQ = "sq",
AM = "am",
AR = "ar",
HY = "hy",
AZ = "az",
EU = "eu",
BE = "be",
BN = "bn",
BG = "bg",
BS = "bs",
MY = "my",
CA = "ca",
CEB = "ceb",
ZH = "zh",
CO = "co",
HR = "hr",
CS = "cs",
DA = "da",
NL = "nl",
EN = "en",
EO = "eo",
ET = "et",
FA = "fa",
FI = "fi",
FR = "fr",
FY = "fy",
GD = "gd",
GL = "gl",
KA = "ka",
DE = "de",
EL = "el",
GU = "gu",
HT = "ht",
HA = "ha",
HAW = "haw",
HE = "he",
HI = "hi",
HMN = "hmn",
HU = "hu",
IS = "is",
IG = "ig",
ID = "id",
GA = "ga",
IT = "it",
JA = "ja",
JW = "jw",
KN = "kn",
KK = "kk",
KM = "km",
RW = "rw",
KY = "ky",
KO = "ko",
KU = "ku",
LO = "lo",
LA = "la",
LV = "lv",
LT = "lt",
LB = "lb",
MK = "mk",
MG = "mg",
MS = "ms",
ML = "ml",
MT = "mt",
MI = "mi",
MR = "mr",
MN = "mn",
NE = "ne",
NO = "no",
NY = "ny",
OR = "or",
PL = "pl",
PT = "pt",
PS = "ps",
PA = "pa",
RO = "ro",
RU = "ru",
SM = "sm",
SN = "sn",
SD = "sd",
SI = "si",
SR = "sr",
SK = "sk",
SL = "sl",
SO = "so",
ST = "st",
ES = "es",
SU = "su",
SW = "sw",
SV = "sv",
TL = "tl",
TG = "tg",
TA = "ta",
TT = "tt",
TE = "te",
TH = "th",
TR = "tr",
TK = "tk",
UG = "ug",
UK = "uk",
UR = "ur",
UZ = "uz",
VI = "vi",
CY = "cy",
XH = "xh",
YI = "yi",
YO = "yo",
ZU = "zu"
};
AF = 'af',
SQ = 'sq',
AM = 'am',
AR = 'ar',
HY = 'hy',
AZ = 'az',
EU = 'eu',
BE = 'be',
BN = 'bn',
BG = 'bg',
BS = 'bs',
MY = 'my',
CA = 'ca',
CEB = 'ceb',
ZH = 'zh',
CO = 'co',
HR = 'hr',
CS = 'cs',
DA = 'da',
NL = 'nl',
EN = 'en',
EO = 'eo',
ET = 'et',
FA = 'fa',
FI = 'fi',
FR = 'fr',
FY = 'fy',
GD = 'gd',
GL = 'gl',
KA = 'ka',
DE = 'de',
EL = 'el',
GU = 'gu',
HT = 'ht',
HA = 'ha',
HAW = 'haw',
HE = 'he',
HI = 'hi',
HMN = 'hmn',
HU = 'hu',
IS = 'is',
IG = 'ig',
ID = 'id',
GA = 'ga',
IT = 'it',
JA = 'ja',
JW = 'jw',
KN = 'kn',
KK = 'kk',
KM = 'km',
RW = 'rw',
KY = 'ky',
KO = 'ko',
KU = 'ku',
LO = 'lo',
LA = 'la',
LV = 'lv',
LT = 'lt',
LB = 'lb',
MK = 'mk',
MG = 'mg',
MS = 'ms',
ML = 'ml',
MT = 'mt',
MI = 'mi',
MR = 'mr',
MN = 'mn',
NE = 'ne',
NO = 'no',
NY = 'ny',
OR = 'or',
PL = 'pl',
PT = 'pt',
PS = 'ps',
PA = 'pa',
RO = 'ro',
RU = 'ru',
SM = 'sm',
SN = 'sn',
SD = 'sd',
SI = 'si',
SR = 'sr',
SK = 'sk',
SL = 'sl',
SO = 'so',
ST = 'st',
ES = 'es',
SU = 'su',
SW = 'sw',
SV = 'sv',
TL = 'tl',
TG = 'tg',
TA = 'ta',
TT = 'tt',
TE = 'te',
TH = 'th',
TR = 'tr',
TK = 'tk',
UG = 'ug',
UK = 'uk',
UR = 'ur',
UZ = 'uz',
VI = 'vi',
CY = 'cy',
XH = 'xh',
YI = 'yi',
YO = 'yo',
ZU = 'zu',
}

export enum WorkerLocation {
AF = 'AF',
Expand Down Expand Up @@ -409,11 +409,11 @@ export enum WorkerLocation {
EH = 'EH',
YE = 'YE',
ZM = 'ZM',
ZW = 'ZW'
ZW = 'ZW',
}

export enum WorkerBrowser {
DESKTOP = 'desktop',
MOBILE = 'mobile',
MODERN_BROWSER = 'modern_browser'
}
MODERN_BROWSER = 'modern_browser',
}
4 changes: 2 additions & 2 deletions packages/apps/job-launcher/server/src/common/enums/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export enum ContentType {

export enum Extension {
JSON = '.json',
ZIP = '.zip'
}
ZIP = '.zip',
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('ApiKeyGuard', () => {

describe('canActivate', () => {
const userEntity: Partial<UserEntity> = {
id: 1,
email: '[email protected]',
id: 1,
email: '[email protected]',
};
it('should return true if API key is valid', async () => {
const context = {
Expand All @@ -46,7 +46,9 @@ describe('ApiKeyGuard', () => {
}),
} as ExecutionContext;

jest.spyOn(authService, 'validateAPIKeyAndGetUser').mockResolvedValue(userEntity as UserEntity);
jest
.spyOn(authService, 'validateAPIKeyAndGetUser')
.mockResolvedValue(userEntity as UserEntity);

expect(await guard.canActivate(context)).toBe(true);
});
Expand All @@ -63,9 +65,13 @@ describe('ApiKeyGuard', () => {
}),
} as ExecutionContext;

jest.spyOn(authService, 'validateAPIKeyAndGetUser').mockRejectedValue(new Error());
jest
.spyOn(authService, 'validateAPIKeyAndGetUser')
.mockRejectedValue(new Error());

await expect(guard.canActivate(context)).rejects.toThrow('Invalid API Key');
await expect(guard.canActivate(context)).rejects.toThrow(
'Invalid API Key',
);
});

it('should throw UnauthorizedException for invalid API key format', async () => {
Expand All @@ -80,8 +86,9 @@ describe('ApiKeyGuard', () => {
}),
} as ExecutionContext;

await expect(guard.canActivate(context)).rejects.toThrow('Invalid API Key format');
await expect(guard.canActivate(context)).rejects.toThrow(
'Invalid API Key format',
);
});

});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './jwt.auth';
export * from './signature.auth';
export * from './apikey.auth';
export * from './apikey.auth';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JobRequestType, JobStatus } from '../enums/job';
import { JobStatus } from '../enums/job';
import { IBase } from './base';

export interface IJob extends IBase {
Expand All @@ -13,4 +13,4 @@ export interface IJob extends IBase {
failedReason?: string;
retriesCount?: number;
waitUntil: Date;
}
}
Loading