Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Jul 11, 2023
2 parents 3ab3805 + 027b25e commit 5e93d2f
Show file tree
Hide file tree
Showing 45 changed files with 311 additions and 302 deletions.
267 changes: 138 additions & 129 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@types/mocha": "^10.0.0",
"@types/node": "^20.1.2",
"@types/sinon": "^10.0.13",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"c8": "^8.0",
"chai": "^4.2.0",
"dotenv": "^16.0.0",
Expand All @@ -36,10 +36,10 @@
"eslint-import-resolver-typescript": "^3.5.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^5.0.0",
"mocha": "^10.0.0",
"mocha-cassettes": "1.2.6",
"prettier": "^2.4.1",
"prettier": "^3.0.0",
"sinon": "^15.0.1",
"source-map-support": "^0.5.21",
"ts-mocha": "^10.0.0",
Expand Down
32 changes: 16 additions & 16 deletions src/collections/base_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export abstract class BaseCollection {
params,
this.populateArrayFromJson,
this.handleReject,
null
null,
);
}

Expand All @@ -49,13 +49,13 @@ export abstract class BaseCollection {
params,
this.populateObjectFromJsonRoot,
this.handleReject,
null
null,
);
}

protected doDelete(
id: string | number,
req_params: Keyable = {}
req_params: Keyable = {},
): Promise<any> {
const params = {
...req_params,
Expand All @@ -66,14 +66,14 @@ export abstract class BaseCollection {
params,
this.returnBareJSON,
this.handleReject,
null
null,
);
}

protected doCreate(
body: Keyable | null,
req_params: Keyable = {},
resolveFn = this.populateObjectFromJson
resolveFn = this.populateObjectFromJson,
): Promise<any> {
const params = {
...req_params,
Expand All @@ -83,15 +83,15 @@ export abstract class BaseCollection {
params,
resolveFn,
this.handleReject,
body
body,
);
}

protected doUpdate(
id: string | number,
body: Keyable | null,
req_params: Keyable,
resolveFn = this.populateObjectFromJsonRoot
resolveFn = this.populateObjectFromJsonRoot,
): Promise<any> {
const params = {
...req_params,
Expand All @@ -102,7 +102,7 @@ export abstract class BaseCollection {
params,
resolveFn,
this.handleReject,
body
body,
);
}

Expand All @@ -116,7 +116,7 @@ export abstract class BaseCollection {

protected populateSecondaryObjectFromJsonRoot(
json: Keyable,
headers: Keyable
headers: Keyable,
): any {
const childClass = <typeof BaseCollection>this.constructor;
json = Object(json)[<string>childClass.secondaryElementNameSingular];
Expand All @@ -126,7 +126,7 @@ export abstract class BaseCollection {
protected populateObjectFromJson(
json: Keyable,
_headers: Keyable,
secondary = false
secondary = false,
): any {
const childClass = <typeof BaseCollection>this.constructor;

Expand All @@ -139,7 +139,7 @@ export abstract class BaseCollection {

protected populateArrayFromJsonBulk(
json: Keyable,
headers: Keyable
headers: Keyable,
): BulkResult | this[] {
const childClass = <typeof BaseCollection>this.constructor;
const arr: this[] = [];
Expand All @@ -156,7 +156,7 @@ export abstract class BaseCollection {

protected populateArrayFromJson(
json: Keyable,
headers: Keyable
headers: Keyable,
): PaginatedResult | Keyable | this[] {
const childClass = <typeof BaseCollection>this.constructor;
const arr: this[] = [];
Expand All @@ -178,7 +178,7 @@ export abstract class BaseCollection {
}

protected returnBareJSON(
json: Keyable | Array<Keyable>
json: Keyable | Array<Keyable>,
): Keyable | Array<Keyable> {
return json;
}
Expand All @@ -193,7 +193,7 @@ export abstract class BaseCollection {
resolveFn: ResolveHandler,
rejectFn: RejectHandler,
body: object | object[] | null,
uri: string | null = null
uri: string | null = null,
): Promise<any> {
const childClass = <typeof BaseCollection>this.constructor;
if (!uri) {
Expand All @@ -204,12 +204,12 @@ export abstract class BaseCollection {
method,
body,
params,
this.clientData
this.clientData,
);
try {
const data = await request.promise;
return Promise.resolve(
resolveFn.call(this, data["json"], data["headers"])
resolveFn.call(this, data["json"], data["headers"]),
);
} catch (err) {
return Promise.reject(rejectFn.call(this, err));
Expand Down
16 changes: 8 additions & 8 deletions src/collections/branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,48 +32,48 @@ export class Branches extends BaseCollection {
protected static elementClass = Branch;

list(
request_params: ProjectWithPagination
request_params: ProjectWithPagination,
): Promise<PaginatedResult<Branch>> {
return this.doList(request_params);
}

create(
branch_params: BranchParams,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Branch> {
return this.doCreate(
branch_params,
request_params,
this.populateObjectFromJsonRoot
this.populateObjectFromJsonRoot,
);
}

get(
branch_id: string | number,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Branch> {
return this.doGet(branch_id, request_params);
}

update(
branch_id: string | number,
branch_params: BranchParams,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Branch> {
return this.doUpdate(branch_id, branch_params, request_params);
}

delete(
branch_id: string | number,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<BranchDeleted> {
return this.doDelete(branch_id, request_params);
}

merge(
branch_id: string | number,
request_params: ProjectOnly,
body: MergeBranchParams = {}
body: MergeBranchParams = {},
): Promise<BranchMerged> {
const params = {
...request_params,
Expand All @@ -86,7 +86,7 @@ export class Branches extends BaseCollection {
this.returnBareJSON,
this.handleReject,
body,
"projects/{!:project_id}/branches/{:id}/merge"
"projects/{!:project_id}/branches/{:id}/merge",
);
}
}
12 changes: 6 additions & 6 deletions src/collections/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,43 @@ export class Comments extends BaseCollection {
protected static elementClass = Comment;

list(
request_params: ParamsWithPagination
request_params: ParamsWithPagination,
): Promise<PaginatedResult<Comment>> {
return this.doList(request_params);
}

create(
comment_params: CommentData | CommentData[],
request_params: ProjectAndKey
request_params: ProjectAndKey,
): Promise<Comment[]> {
const body = { comments: this.objToArray(comment_params) };
return this.doCreate(body, request_params, this.populateArrayFromJson);
}

get(
comment_id: string | number,
request_params: ProjectAndKey
request_params: ProjectAndKey,
): Promise<Comment> {
return this.doGet(comment_id, request_params);
}

delete(
comment_id: string | number,
request_params: ProjectAndKey
request_params: ProjectAndKey,
): Promise<CommentDeleted> {
return this.doDelete(comment_id, request_params);
}

list_project_comments(
params: ProjectWithPagination
params: ProjectWithPagination,
): Promise<PaginatedResult<Comment>> {
return this.createPromise(
"GET",
params,
this.populateArrayFromJson,
this.handleReject,
null,
"projects/{!:project_id}/comments"
"projects/{!:project_id}/comments",
);
}
}
10 changes: 5 additions & 5 deletions src/collections/contributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,37 @@ export class Contributors extends BaseCollection {
protected static elementClass = Contributor;

list(
request_params: ProjectWithPagination
request_params: ProjectWithPagination,
): Promise<PaginatedResult<Contributor>> {
return this.doList(request_params);
}

create(
contributor_params: ContributorCreateData | ContributorCreateData[],
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Contributor[]> {
const body = { contributors: this.objToArray(contributor_params) };
return this.doCreate(body, request_params, this.populateArrayFromJson);
}

get(
contributor_id: string | number,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Contributor> {
return this.doGet(contributor_id, request_params);
}

update(
contributor_id: string | number,
contributor_params: ContributorUpdateData,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<Contributor> {
return this.doUpdate(contributor_id, contributor_params, request_params);
}

delete(
contributor_id: string | number,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<ContributorDeleted> {
return this.doDelete(contributor_id, request_params);
}
Expand Down
6 changes: 3 additions & 3 deletions src/collections/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Files extends BaseCollection {
this.populateSecondaryObjectFromJsonRoot,
this.handleReject,
upload,
"projects/{!:project_id}/files/upload"
"projects/{!:project_id}/files/upload",
);
}

Expand All @@ -47,13 +47,13 @@ export class Files extends BaseCollection {
this.returnBareJSON,
this.handleReject,
download,
"projects/{!:project_id}/files/download"
"projects/{!:project_id}/files/download",
);
}

delete(
file_id: string | number,
request_params: ProjectOnly
request_params: ProjectOnly,
): Promise<FileDeleted> {
return this.doDelete(file_id, request_params);
}
Expand Down
Loading

0 comments on commit 5e93d2f

Please sign in to comment.