Skip to content

Commit

Permalink
Fetch API (#406)
Browse files Browse the repository at this point in the history
* use fetch instead of got, first draft

* goodbye got

* env

* branches

* contributors

* keys

* languages

* orders

* cards

* projects

* screens-1

* screens-2

* main endpoints ready

* prepare for v12
  • Loading branch information
bodrovis authored Sep 23, 2023
1 parent cf5c69e commit 9651256
Show file tree
Hide file tree
Showing 453 changed files with 9,409 additions and 39,432 deletions.
1 change: 0 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = {
"node/no-missing-import": "off",
"node/no-unpublished-import": ["off"],
"import/no-unresolved": "error",
"import/no-named-as-default": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 18
- 19
- 20
os:
- ubuntu-latest
env:
API_KEY: 123abc
OAUTH2_CLIENT_ID: fake
OAUTH2_CLIENT_SECRET: fake
OAUTH2_ACCESS_TOKEN: fake
OAUTH2_REFRESH_TOKEN: fake
API_JWT: fake
SDK_TOKEN: fake
steps:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3 Clause

Copyright 2020 Lokalise Group, Ilya Bodrov
Copyright 2023 Lokalise Group, Ilya Bodrov

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
22 changes: 11 additions & 11 deletions dist/collections/base_collection.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Options } from "got";
import { HttpMethod } from "../types/http_method.js";
import { ApiRequest } from "../http_client/base.js";
import { ApiError } from "../models/api_error.js";
import { PaginatedResult } from "../models/paginated_result.js";
import { Keyable } from "../interfaces/keyable.js";
import { ClientData } from "../interfaces/client_data.js";
import { BulkResult } from "../interfaces/bulk_result.js";
type RejectHandler = (data: any) => ApiError;
type ResolveHandler = (json: Keyable, headers: Keyable, ...args: any[]) => any;
type ResolveHandler = (json: Keyable, headers: Headers, ...args: any[]) => any;
export declare abstract class BaseCollection {
readonly clientData: ClientData;
protected static rootElementName: string;
Expand All @@ -20,18 +20,18 @@ export declare abstract class BaseCollection {
protected doList(req_params: Keyable): Promise<any>;
protected doGet(id: string | number, req_params?: Keyable): Promise<any>;
protected doDelete(id: string | number, req_params?: Keyable): Promise<any>;
protected doCreate(body: Keyable | null, req_params?: Keyable, resolveFn?: (json: Keyable, _headers: Keyable, secondary?: boolean) => any): Promise<any>;
protected doUpdate(id: string | number, body: Keyable | null, req_params: Keyable, resolveFn?: (json: Keyable, headers: Keyable) => any, method?: Options["method"]): Promise<any>;
protected populateObjectFromJsonRoot(json: Keyable, headers: Keyable): any;
protected populateSecondaryObjectFromJsonRoot(json: Keyable, headers: Keyable): any;
protected populateObjectFromJson(json: Keyable, _headers: Keyable, secondary?: boolean): any;
protected populateArrayFromJsonBulk(json: Keyable, headers: Keyable): BulkResult | this[];
protected populateArrayFromJson(json: Keyable, headers: Keyable): PaginatedResult | Keyable | this[];
protected doCreate(body: Keyable | null, req_params?: Keyable, resolveFn?: (json: Keyable, _headers: Headers, secondary?: boolean) => any): Promise<any>;
protected doUpdate(id: string | number, body: Keyable | null, req_params: Keyable, resolveFn?: (json: Keyable, headers: Headers) => any, method?: HttpMethod): Promise<any>;
protected populateObjectFromJsonRoot(json: Keyable, headers: Headers): any;
protected populateSecondaryObjectFromJsonRoot(json: Keyable, headers: Headers): any;
protected populateObjectFromJson(json: Keyable, _headers: Headers, secondary?: boolean): any;
protected populateArrayFromJsonBulk(json: Keyable, headers: Headers): BulkResult | this[];
protected populateArrayFromJson(json: Keyable, headers: Headers): PaginatedResult | Keyable | this[];
protected populateApiErrorFromJson(json: any): ApiError;
protected returnBareJSON(json: Keyable | Array<Keyable>): Keyable | Array<Keyable>;
protected handleReject(data: any): ApiError;
protected createPromise(method: Options["method"], params: Keyable, resolveFn: ResolveHandler | null, rejectFn: RejectHandler, body: object | object[] | null, uri?: string | null): Promise<any>;
protected prepareRequest(method: Options["method"], body: object | object[] | null, params: Keyable, uri?: string | null): ApiRequest;
protected createPromise(method: HttpMethod, params: Keyable, resolveFn: ResolveHandler | null, rejectFn: RejectHandler, body: object | object[] | null, uri?: string | null): Promise<any>;
protected prepareRequest(method: HttpMethod, body: object | object[] | null, params: Keyable, uri?: string | null): ApiRequest;
protected getUri(uri: string | null): string;
protected objToArray(raw_body: Keyable | Keyable[]): Array<Keyable>;
}
Expand Down
3 changes: 2 additions & 1 deletion dist/collections/base_collection.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/collections/base_collection.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/collections/comments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type CommentData = {
type CommentDeleted = {
project_id: string;
comment_deleted: boolean;
branch?: string;
};
export declare class Comments extends BaseCollection {
protected static rootElementName: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/collections/comments.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/collections/contributors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ContributorUpdateData = {
type ContributorDeleted = {
project_id: string;
contributor_deleted: boolean;
branch?: string;
};
export declare class Contributors extends BaseCollection {
protected static rootElementName: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/collections/contributors.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions dist/collections/files.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { File } from "../models/file.js";
import { QueuedProcess } from "../models/queued_process.js";
import { UploadFileParams } from "../interfaces/upload_file_params.js";
import { DownloadFileParams } from "../interfaces/download_file_params.js";
import { Keyable } from "../interfaces/keyable.js";
import { ProjectWithPagination } from "../interfaces/project_with_pagination.js";
import { PaginatedResult } from "../interfaces/paginated_result.js";
import { ProjectOnly } from "../interfaces/project_only.js";
Expand All @@ -14,6 +13,11 @@ type FileDeleted = {
project_id: string;
file_deleted: boolean;
};
type DownloadBundle = {
project_id: string;
bundle_url: string;
branch?: string;
};
export declare class Files extends BaseCollection {
protected static rootElementName: string;
protected static prefixURI: string;
Expand All @@ -22,7 +26,7 @@ export declare class Files extends BaseCollection {
protected static secondaryElementClass: typeof QueuedProcess;
list(request_params: ListFileParams): Promise<PaginatedResult<File>>;
upload(project_id: string, upload: UploadFileParams): Promise<QueuedProcess>;
download(project_id: string, download: DownloadFileParams): Promise<Keyable>;
download(project_id: string, download: DownloadFileParams): Promise<DownloadBundle>;
delete(file_id: string | number, request_params: ProjectOnly): Promise<FileDeleted>;
}
export {};
Loading

0 comments on commit 9651256

Please sign in to comment.