Skip to content

Commit

Permalink
+fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Sep 2, 2024
1 parent 9b340be commit 5bf282b
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 66 deletions.
2 changes: 1 addition & 1 deletion docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform?
gem "wdm", "~> 0.2.0", :install_if => Gem.win_platform?

# kramdown v2 ships without the gfm parser by default. If you're using
# kramdown v1, comment out this line.
Expand Down
14 changes: 7 additions & 7 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.9.1)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
faraday (2.11.0)
faraday-net_http (>= 2.0, < 3.4)
logger
faraday-net_http (3.1.1)
faraday-net_http (3.3.0)
net-http
ffi (1.17.0-x64-mingw-ucrt)
ffi (1.17.0-x86_64-linux-gnu)
Expand Down Expand Up @@ -220,7 +220,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
logger (1.6.1)
mercenary (0.3.6)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
Expand Down Expand Up @@ -268,8 +268,8 @@ GEM
tzinfo-data (1.2024.1)
tzinfo (>= 1.0.0)
unicode-display_width (1.8.0)
uri (0.13.0)
wdm (0.1.1)
uri (0.13.1)
wdm (0.2.0)
webrick (1.8.1)

PLATFORMS
Expand All @@ -284,7 +284,7 @@ DEPENDENCIES
minima (~> 2.0)
tzinfo (~> 2.0)
tzinfo-data
wdm (~> 0.1.0)
wdm (~> 0.2.0)
webrick (~> 1.8)

BUNDLED WITH
Expand Down
4 changes: 4 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* Migrate from eslint to biome

## 12.7.0 (17-Jul-2024)

* Added `tm_leverage` field for the `languages` of the `Task` object:
Expand Down
13 changes: 5 additions & 8 deletions src/collections/base_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ export abstract class BaseCollection {

if (secondary) {
return new childClass.secondaryElementClass(json);
} else {
return new childClass.elementClass(json);
}
return new childClass.elementClass(json);
}

protected populateArrayFromJsonBulk(
Expand All @@ -164,7 +163,7 @@ export abstract class BaseCollection {
arr.push(<this>this.populateObjectFromJson(obj, headers));
}
const result: BulkResult = {
errors: json["errors"],
errors: json.errors,
items: arr,
};
return result;
Expand All @@ -188,9 +187,8 @@ export abstract class BaseCollection {
) {
const result: PaginatedResult = new PaginatedResult(arr, headers);
return result;
} else {
return arr;
}
return arr;
}

protected populateArrayFromJsonCursor(
Expand Down Expand Up @@ -237,7 +235,7 @@ export abstract class BaseCollection {
let result = null;

if (resolveFn !== null) {
result = resolveFn.call(this, data["json"], data["headers"]);
result = resolveFn.call(this, data.json, data.headers);
}

return Promise.resolve(result);
Expand Down Expand Up @@ -273,8 +271,7 @@ export abstract class BaseCollection {
protected objToArray(raw_body: Keyable | Keyable[]): Array<Keyable> {
if (!Array.isArray(raw_body)) {
return Array(raw_body);
} else {
return raw_body;
}
return raw_body;
}
}
2 changes: 1 addition & 1 deletion src/collections/user_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class UserGroups extends BaseCollection {
}

protected populateGroupFromJsonRoot(json: Keyable, headers: Headers): this {
const formatted_json = json["group"];
const formatted_json = json.group;
return <this>this.populateObjectFromJson(formatted_json, headers);
}
}
17 changes: 7 additions & 10 deletions src/http_client/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ export class ApiRequest {
}

protected getErrorFromResp(respJson: any): any {
if (typeof respJson["error"] === "object") {
return respJson["error"];
} else {
return respJson;
if (typeof respJson.error === "object") {
return respJson.error;
}
return respJson;
}

protected composeURI(rawUri: string): string {
Expand All @@ -114,13 +113,11 @@ export class ApiRequest {
delete this.params[paramName];

return t_param;
} else {
if (isMandaratory === "!") {
throw new Error("Missing required param: " + paramName);
} else {
return "";
}
}
if (isMandaratory === "!") {
throw new Error(`Missing required param: ${paramName}`);
}
return "";
};
}
}
4 changes: 2 additions & 2 deletions src/lokalise/base_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export class BaseClient {
* @returns LokaliseApi object to work with.
*/
constructor(params: ClientParams) {
const apiKey = params["apiKey"];
const apiKey = params.apiKey;
if (apiKey === null || apiKey === undefined || apiKey.length === 0) {
throw new Error("Error: Instantiation failed: Please pass an API key");
}
this.clientData.token = apiKey;
const compression = params["enableCompression"];
const compression = params.enableCompression;
if (compression !== null && compression !== undefined) {
this.clientData.enableCompression = compression;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lokalise/lokalise_api_oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class LokaliseApiOAuth extends LokaliseApi {
constructor(params: ClientParams) {
super(params);

const tokenType = params["tokenType"];
const tokenType = params.tokenType;
this.clientData.tokenType = tokenType ?? "Bearer";

this.clientData.authHeader = "Authorization";
Expand Down
2 changes: 1 addition & 1 deletion src/lokalise/lokalise_api_ota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class LokaliseApiOta extends BaseClient {
constructor(params: ClientParams) {
super(params);

this.clientData.tokenType = params["tokenType"] ?? "Bearer";
this.clientData.tokenType = params.tokenType ?? "Bearer";

this.clientData.authHeader = "Authorization";

Expand Down
2 changes: 1 addition & 1 deletion src/lokalise/pkg.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile } from "fs/promises";
import { readFile } from "node:fs/promises";
import type { Keyable } from "../interfaces/keyable.js";

export class LokalisePkg {
Expand Down
6 changes: 2 additions & 4 deletions src/models/paginated_result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ export class PaginatedResult implements PaginatedResultInterface {
nextPage(): number {
if (this.isLastPage()) {
return this.currentPage;
} else {
return this.currentPage + 1;
}
return this.currentPage + 1;
}

prevPage(): number {
if (this.isFirstPage()) {
return this.currentPage;
} else {
return this.currentPage - 1;
}
return this.currentPage - 1;
}

private safeParseInt(str: string | null): number {
Expand Down
12 changes: 6 additions & 6 deletions src/oauth2/lokalise_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class LokaliseAuth {
) {
if (
clientId == null ||
clientId.length == 0 ||
clientId.length === 0 ||
clientSecret == null ||
clientSecret.length == 0
clientSecret.length === 0
) {
throw new Error(
"Error: Instantiation failed: Please pass client id and client secret",
Expand All @@ -43,7 +43,7 @@ export class LokaliseAuth {
redirect_uri?: string,
state?: string,
): string {
if (scope instanceof Array) {
if (Array.isArray(scope)) {
scope = scope.join(" ");
}

Expand All @@ -53,11 +53,11 @@ export class LokaliseAuth {
};

if (state) {
params["state"] = state;
params.state = state;
}

if (redirect_uri) {
params["redirect_uri"] = redirect_uri;
params.redirect_uri = redirect_uri;
}

return this.buildUrl(params);
Expand Down Expand Up @@ -95,7 +95,7 @@ export class LokaliseAuth {
params,
this.authData,
);
return Promise.resolve(data["json"]);
return Promise.resolve(data.json);
} catch (err) {
return Promise.reject(this.handleReject(err));
}
Expand Down
2 changes: 1 addition & 1 deletion src/ota_collections/ota_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export abstract class OtaCollection extends BaseCollection {
}

protected returnJSONFromData(json: Keyable): Keyable | Array<Keyable> {
return json["data"];
return json.data;
}
}
4 changes: 2 additions & 2 deletions test/files/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ describe("Files", () => {

expect(process.process_id).to.eq(processId);
expect(process.status).to.eq("finished");
expect(process.details["files"].length).to.eq(1);
const file = process.details["files"][0];
expect(process.details.files.length).to.eq(1);
const file = process.details.files[0];
expect(file.name_original).to.eq("test_node.json");
expect(file.word_count_total).to.eq(3);
expect(file.status).to.eq("finished");
Expand Down
12 changes: 6 additions & 6 deletions test/keys/keys.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ describe("Keys", () => {
.keys()
.create(params, { project_id: projectId });

expect(keys.items[0].key_name["web"]).to.eq("welcome_web_new");
expect(keys.items[0].key_name.web).to.eq("welcome_web_new");
expect(keys.items[0].platforms).to.include("web");
expect(keys.items[0].filenames["web"]).to.eq("my_filename.json");
expect(keys.items[0].filenames.web).to.eq("my_filename.json");
expect(keys.items[0].translations[0].translation).to.eq("Welcome");

expect(keys.items[1].key_name["ios"]).to.eq("welcome_ios_new");
expect(keys.items[1].key_name.ios).to.eq("welcome_ios_new");
expect(keys.items[1].platforms).to.include("ios");
expect(keys.items[1].translations[0].language_iso).to.eq("en");
});
Expand Down Expand Up @@ -286,7 +286,7 @@ describe("Keys", () => {
.keys()
.create(params, { project_id: projectId });

expect(keys.items[0].key_name["ios"]).to.eq("welcome_ios_supernew");
expect(keys.items[0].key_name.ios).to.eq("welcome_ios_supernew");
expect(keys.items[0].platforms).to.include("ios");
expect(keys.items[0].translations[0].language_iso).to.eq("en");

Expand Down Expand Up @@ -330,8 +330,8 @@ describe("Keys", () => {

const key = keys.items[0];

expect(key.key_name["web"]).to.eq("name_for_web2");
expect(key.key_name["ios"]).to.eq("name_for_ios2");
expect(key.key_name.web).to.eq("name_for_web2");
expect(key.key_name.ios).to.eq("name_for_ios2");
expect(key.platforms).to.include("web", "ios");
expect(key.platforms).not.to.include("android", "other");
});
Expand Down
2 changes: 1 addition & 1 deletion test/languages/languages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("Languages", () => {

const stub = new Stub({
fixture: "languages/list_system_pagination.json",
uri: `system/languages`,
uri: "system/languages",
query: params,
respHeaders: {
"x-pagination-total-count": "619",
Expand Down
2 changes: 1 addition & 1 deletion test/orders/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("Orders", () => {
expect(order.source_language_iso).to.eq("en");
expect(order.target_language_isos).to.include("lv_LV");
expect(order.keys).to.include(35076371);
expect(order.source_words["lv_LV"]).to.eq(22);
expect(order.source_words.lv_LV).to.eq(22);
expect(order.provider_slug).to.eq("google");
expect(order.translation_style).to.eq(null);
expect(order.translation_tier).to.eq(1);
Expand Down
6 changes: 3 additions & 3 deletions test/payment_cards/payment_cards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("PaymentCards", () => {
it("lists", async () => {
const stub = new Stub({
fixture: "payment_cards/list.json",
uri: `payment_cards`,
uri: "payment_cards",
respHeaders: {
"x-pagination-total-count": "4",
"x-pagination-page": "1",
Expand All @@ -32,7 +32,7 @@ describe("PaymentCards", () => {

const stub = new Stub({
fixture: "payment_cards/list_pagination.json",
uri: `payment_cards`,
uri: "payment_cards",
query: params,
respHeaders: {
"x-pagination-total-count": "4",
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("PaymentCards", () => {

const stub = new Stub({
fixture: "payment_cards/create.json",
uri: `payment_cards`,
uri: "payment_cards",
method: "POST",
body: params,
});
Expand Down
8 changes: 4 additions & 4 deletions test/projects/projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Projects", () => {
it("lists", async () => {
const stub = new Stub({
fixture: "projects/list.json",
uri: `projects`,
uri: "projects",
respHeaders: {
"x-pagination-total-count": "2",
"x-pagination-page": "1",
Expand All @@ -34,7 +34,7 @@ describe("Projects", () => {

const stub = new Stub({
fixture: "projects/list_pagination.json",
uri: `projects`,
uri: "projects",
query: params,
respHeaders: {
"x-pagination-total-count": "2",
Expand Down Expand Up @@ -87,7 +87,7 @@ describe("Projects", () => {
fixture: "projects/retrieve_no_version.json",
uri: `projects/${projectId}`,
reqHeaders: {
"User-Agent": `node-lokalise-api/unknown`,
"User-Agent": "node-lokalise-api/unknown",
},
});

Expand All @@ -108,7 +108,7 @@ describe("Projects", () => {

const stub = new Stub({
fixture: "projects/create.json",
uri: `projects`,
uri: "projects",
method: "POST",
body: params,
});
Expand Down
Loading

0 comments on commit 5bf282b

Please sign in to comment.