@crowdin/crowdin-api-client
Advanced tools
Comparing version 1.28.0 to 1.28.1
@@ -119,3 +119,3 @@ import { HttpClientError } from './http-client-error'; | ||
}[]; | ||
constructor(messsage: string, validationCodes: { | ||
constructor(message: string, validationCodes: { | ||
key: string; | ||
@@ -122,0 +122,0 @@ codes: string[]; |
@@ -32,4 +32,4 @@ "use strict"; | ||
class CrowdinValidationError extends CrowdinError { | ||
constructor(messsage, validationCodes) { | ||
super(messsage, 400); | ||
constructor(message, validationCodes) { | ||
super(message, 400); | ||
this.validationCodes = validationCodes; | ||
@@ -39,2 +39,6 @@ } | ||
exports.CrowdinValidationError = CrowdinValidationError; | ||
function isAxiosError(error) { | ||
var _a; | ||
return error instanceof axios_1.AxiosError || !!((_a = error.response) === null || _a === void 0 ? void 0 : _a.data); | ||
} | ||
/** | ||
@@ -44,10 +48,15 @@ * @internal | ||
function handleHttpClientError(error) { | ||
var _a, _b, _c, _d; | ||
const crowdinResponseErrors = error instanceof axios_1.AxiosError | ||
? (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors | ||
: error instanceof fetchClientError_1.FetchClientJsonPayloadError | ||
? error.jsonPayload && typeof error.jsonPayload === 'object' && 'errors' in error.jsonPayload | ||
? error.jsonPayload.errors | ||
: null | ||
: null; | ||
var _a, _b, _c, _d, _e, _f; | ||
let crowdinResponseErrors = null; | ||
if (isAxiosError(error)) { | ||
crowdinResponseErrors = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.errors) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error); | ||
} | ||
else if (error instanceof fetchClientError_1.FetchClientJsonPayloadError) { | ||
crowdinResponseErrors = | ||
error.jsonPayload && | ||
typeof error.jsonPayload === 'object' && | ||
('errors' in error.jsonPayload || 'error' in error.jsonPayload) | ||
? error.jsonPayload.errors || error.jsonPayload.error | ||
: null; | ||
} | ||
if (Array.isArray(crowdinResponseErrors)) { | ||
@@ -75,5 +84,8 @@ const validationCodes = []; | ||
} | ||
else if ((crowdinResponseErrors === null || crowdinResponseErrors === void 0 ? void 0 : crowdinResponseErrors.message) && (crowdinResponseErrors === null || crowdinResponseErrors === void 0 ? void 0 : crowdinResponseErrors.code)) { | ||
throw new CrowdinError(crowdinResponseErrors.message, crowdinResponseErrors.code); | ||
} | ||
if (error instanceof Error) { | ||
const code = error instanceof axios_1.AxiosError && ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) | ||
? (_d = error.response) === null || _d === void 0 ? void 0 : _d.status | ||
const code = error instanceof axios_1.AxiosError && ((_e = error.response) === null || _e === void 0 ? void 0 : _e.status) | ||
? (_f = error.response) === null || _f === void 0 ? void 0 : _f.status | ||
: error instanceof fetchClientError_1.FetchClientJsonPayloadError | ||
@@ -80,0 +92,0 @@ ? error.statusCode |
@@ -11,6 +11,6 @@ import { CrowdinApi, PaginationOptions, PatchRequest, ResponseList, ResponseObject } from '../core'; | ||
* @param projectId project identifier | ||
* @param options optional pagination parameters for the request | ||
* @param options search options | ||
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.screenshots.getMany | ||
*/ | ||
listScreenshots(projectId: number, options?: PaginationOptions): Promise<ResponseList<ScreenshotsModel.Screenshot>>; | ||
listScreenshots(projectId: number, options?: ScreenshotsModel.ListScreenshotParams): Promise<ResponseList<ScreenshotsModel.Screenshot>>; | ||
/** | ||
@@ -116,2 +116,7 @@ * @param projectId project identifier | ||
export declare namespace ScreenshotsModel { | ||
interface ListScreenshotParams extends PaginationOptions { | ||
stringId?: number; | ||
labelIds?: string; | ||
excludeLabelIds?: string; | ||
} | ||
interface Screenshot { | ||
@@ -126,2 +131,3 @@ id: number; | ||
labels: number[]; | ||
labelIds: number[]; | ||
createdAt: string; | ||
@@ -137,2 +143,3 @@ updatedAt: string; | ||
directoryId?: number; | ||
labelIds?: number[]; | ||
} | ||
@@ -139,0 +146,0 @@ interface UpdateScreenshotRequest { |
@@ -16,3 +16,6 @@ "use strict"; | ||
} | ||
const url = `${this.url}/projects/${projectId}/screenshots`; | ||
let url = `${this.url}/projects/${projectId}/screenshots`; | ||
url = this.addQueryParam(url, 'stringId', options.stringId); | ||
url = this.addQueryParam(url, 'labelIds', options.labelIds); | ||
url = this.addQueryParam(url, 'excludeLabelIds', options.excludeLabelIds); | ||
return this.getList(url, options.limit, options.offset); | ||
@@ -19,0 +22,0 @@ } |
{ | ||
"name": "@crowdin/crowdin-api-client", | ||
"version": "1.28.0", | ||
"version": "1.28.1", | ||
"description": "JavaScript library for Crowdin API", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
414981
9461