Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-api-promise

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-api-promise - npm Package Compare versions

Comparing version 1.16.0-modify-rollup-config.164 to 1.18.0

2

build/request-helpers.d.ts

@@ -6,3 +6,3 @@ declare class Request {

private logRequestSucess;
assembleQueryParams(params: any, paramNames: string[]): any;
assembleQueryParams(params: any, paramNames: string[]): string;
standardRequest(url: string, method?: string, body?: any): Promise<unknown>;

@@ -9,0 +9,0 @@ extendedRequest(url: string, method?: string, body?: any): Promise<unknown>;

@@ -60,7 +60,8 @@ import { Params } from "../types";

*
* @param {string} id - The team id
* @param {string} id - The team id
* @param {string} org_id - The org id
*
* @return {object} team data
*/
getTeam: (id: string) => Promise<{
getTeam: (id: string, org_id: string) => Promise<{
id: number;

@@ -286,2 +287,3 @@ node_id: string;

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} body - The request body

@@ -308,3 +310,3 @@ * @param {string} body.name - Required. The name of the team.

*/
editTeam: (id: string, body: Params) => Promise<{
editTeam: (id: string, org_id: string, body: Params) => Promise<{
id: number;

@@ -403,7 +405,7 @@ node_id: string;

*
* @param {string} id - The team ID
*
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @return {nothing}
*/
deleteTeam: (id: string) => Promise<never>;
deleteTeam: (id: string, org_id: string) => Promise<never>;
/**

@@ -417,2 +419,3 @@ * List child teams

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -423,3 +426,3 @@ * @param {int} params.page - The page of results to retrieve

*/
getChildTeams: (id: string, params?: Params) => Promise<{
getChildTeams: (id: string, org_id: string, params?: Params) => Promise<{
id: number;

@@ -466,2 +469,3 @@ node_id: string;

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -472,3 +476,3 @@ * @param {int} params.page - The page of results to retrieve

*/
getTeamRepos: (id: string, params?: Params) => Promise<{
getTeamRepos: (id: string, org_id: string, params?: Params) => Promise<{
id: number;

@@ -866,9 +870,11 @@ node_id: string;

*
* @param {string} id - The team ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @return {nothing} 204 if is managed, 404 if not
*/
getIsRepoManagedByTeam: (id: string, owner: string, repo: string) => Promise<{
getIsRepoManagedByTeam: (id: string, org_id: string, owner: string, repo: string) => Promise<{
id: number;

@@ -1266,2 +1272,3 @@ node_id: string;

* @param {string} id - The team ID
* @param {string} org_id - The organization ID
* @param {string} owner - The owner name

@@ -1281,3 +1288,3 @@ * @param {string} repo - The repo name

*/
updateTeamRepository: (id: string, owner: string, repo: string, body?: any) => Promise<never>;
updateTeamRepository: (id: string, org_id: string, owner: string, repo: string, body?: any) => Promise<never>;
/**

@@ -1290,9 +1297,10 @@ * Remove team repository

*
* @param {string} id - The team ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @return {nothing}
*/
removeTeamRepository: (id: string, owner: string, repo: string) => Promise<never>;
removeTeamRepository: (id: string, org_id: string, owner: string, repo: string) => Promise<never>;
/**

@@ -1405,2 +1413,3 @@ * List user teams

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -1411,3 +1420,3 @@ * @param {int} params.page - The page of results to retrieve

*/
getTeamProjects: (id: string, params?: Params) => Promise<{
getTeamProjects: (id: string, org_id: string, params?: Params) => Promise<{
owner_url: string;

@@ -1464,2 +1473,3 @@ url: string;

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -1469,3 +1479,3 @@ *

*/
getTeamProject: (id: string, projectId: string) => Promise<{
getTeamProject: (id: string, org_id: string, projectId: string) => Promise<{
owner_url: string;

@@ -1522,2 +1532,3 @@ url: string;

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -1536,3 +1547,3 @@ * @param {object} body - The request body

*/
updateTeamProject: (id: string, projectId: string, body: Params) => Promise<never>;
updateTeamProject: (id: string, org_id: string, projectId: string, body: Params) => Promise<never>;
/**

@@ -1546,2 +1557,3 @@ * Remove team project

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -1551,4 +1563,4 @@ *

*/
removeTeamProject: (id: string, projectId: string) => Promise<never>;
removeTeamProject: (id: string, org_id: string, projectId: string) => Promise<never>;
};
export default _default;
{
"name": "github-api-promise",
"version": "1.16.0-modify-rollup-config.164",
"description": "A node module for interfacing with the Github API",
"type": "module",
"types": "build/app.d.ts",
"exports": {
"require": "./src/app.ts",
"default": "./build/app.js"
},
"author": "Tim Smith",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/purecloudlabs/github-api-promise.git"
},
"dependencies": {
"axios": "^0.27.2",
"lodash": "^4.17.10",
"log4js": "^6.6.1"
},
"bugs": {
"url": "https://github.com/purecloudlabs/github-api-promise/issues"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"docdash": "^0.4.0",
"jsdoc": "^3.6.3",
"rollup": "^2.78.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.31.1",
"typescript": "^4.7.4"
},
"peerDependencies": {
"octokit": "^2.0.5"
},
"scripts": {
"build": "rm -rf build && rollup -c rollup.config.js",
"generate-docs": "node ./node_modules/jsdoc/jsdoc.js -r -c jsdoc.json -R README.md",
"test": "echo \"0/0 tests passed. That's technically a perfect score. Keep up the great work!\""
},
"files": [
"build",
"src"
]
}
"name": "github-api-promise",
"version": "1.18.0",
"description": "A node module for interfacing with the Github API",
"type": "module",
"types": "build/app.d.ts",
"exports": {
"require": "./src/app.ts",
"default": "./build/app.js"
},
"author": "Genesys",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/purecloudlabs/github-api-promise.git"
},
"dependencies": {
"axios": "^0.27.2",
"log4js": "^6.6.1"
},
"bugs": {
"url": "https://github.com/purecloudlabs/github-api-promise/issues"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"docdash": "^0.4.0",
"jsdoc": "^3.6.11",
"rollup": "^2.78.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.31.1",
"typescript": "^4.7.4"
},
"peerDependencies": {
"octokit": "^2.0.5"
},
"scripts": {
"build": "rm -rf build && rollup -c rollup.config.js",
"generate-docs": "node ./node_modules/jsdoc/jsdoc.js -r -c jsdoc.json -R README.md",
"test": "echo \"0/0 tests passed. That's technically a perfect score. Keep up the great work!\""
},
"files": [
"build",
"src"
]
}

@@ -1,3 +0,2 @@

import axios, { AxiosInstance, AxiosResponse, AxiosError } from "axios";
import _ from "lodash";
import axios, { AxiosInstance, AxiosResponse } from "axios";
import config from "./config";

@@ -48,4 +47,4 @@ import { getLogger } from "log4js";

});
return _.trimStart(s, "&");
//remove leading `&`
return s.slice(1);
}

@@ -67,3 +66,3 @@

// Returns an object with additional information about the request/response
public extendedRequest(
public async extendedRequest(
url: string,

@@ -73,73 +72,70 @@ method = "get",

): Promise<unknown> {
return new Promise((resolve, reject) => {
try {
let req: Promise<AxiosResponse>;
switch (method.toLowerCase().trim()) {
case "post": {
req = this.request.post(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "patch": {
req = this.request.patch(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "put": {
req = this.request.put(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "delete": {
req = this.request.delete(url, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "get": {
req = this.request.get(url, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
default: {
throw new Error(`Unsupported HTTP verb: ${method}`);
}
try {
let req: Promise<AxiosResponse>;
switch (method.toLowerCase().trim()) {
case "post": {
req = this.request.post(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "patch": {
req = this.request.patch(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "put": {
req = this.request.put(url, body, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "delete": {
req = this.request.delete(url, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
case "get": {
req = this.request.get(url, {
headers: {
Authorization: `token ${config.token}`,
},
});
break;
}
default: {
throw new Error(`Unsupported HTTP verb: ${method}`);
}
}
this.requestCount++;
this.requestCount++;
// Set standard stuff and handle response
req
.then((res) => {
this.logRequestSucess(res.data);
resolve(res.data);
})
.catch((err: AxiosError) => {
// TODO: handle rate limiting (github sends a 403, not a 429)
// https://developer.github.com/v3/#rate-limiting
log.error(err.response.data);
reject({
status: err.response.status,
errMessage: err.response.data,
});
});
// Set standard stuff and handle response
try {
const res = await req;
this.logRequestSucess(res.data);
return res.data;
} catch (err) {
log.error(err);
reject(err);
// TODO: handle rate limiting (github sends a 403, not a 429)
// https://developer.github.com/v3/#rate-limiting
log.error(err.response.data);
throw {
status: err.response.status,
errMessage: err.response.data,
};
}
});
} catch (err) {
log.error(err);
throw err;
}
}

@@ -146,0 +142,0 @@ }

@@ -38,9 +38,12 @@ import { Params } from "../types";

*
* @param {string} id - The team id
* @param {string} id - The team id
* @param {string} org_id - The org id
*
* @return {object} team data
*/
getTeam: function (id: string) {
return req.standardRequest(`${config.host}/teams/${id}`) as Promise<
Endpoints["GET /teams/{team_id}"]["response"]["data"]
getTeam: function (id: string, org_id: string) {
return req.standardRequest(
`${config.host}/organizations/${org_id}/team/${id}`
) as Promise<
Endpoints["GET /orgs/{org}/teams/{team_slug}"]["response"]["data"]
>;

@@ -104,2 +107,3 @@ },

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} body - The request body

@@ -126,8 +130,10 @@ * @param {string} body.name - Required. The name of the team.

*/
editTeam: function (id: string, body: Params) {
editTeam: function (id: string, org_id: string, body: Params) {
return req.standardRequest(
`${config.host}/teams/${id}`,
`${config.host}/organizations/${org_id}/team/${id}`,
"patch",
body
) as Promise<Endpoints["PATCH /teams/{team_id}"]["response"]["data"]>;
) as Promise<
Endpoints["PATCH /orgs/{org}/teams/{team_slug}"]["response"]["data"]
>;
},

@@ -142,11 +148,13 @@

*
* @param {string} id - The team ID
*
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @return {nothing}
*/
deleteTeam: function (id: string) {
deleteTeam: function (id: string, org_id: string) {
return req.standardRequest(
`${config.host}/teams/${id}`,
`${config.host}/organizations/${org_id}/team/${id}`,
"delete"
) as Promise<Endpoints["DELETE /teams/{team_id}"]["response"]["data"]>;
) as Promise<
Endpoints["DELETE /orgs/{org}/teams/{team_slug}"]["response"]["data"]
>;
},

@@ -162,2 +170,3 @@

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -168,8 +177,13 @@ * @param {int} params.page - The page of results to retrieve

*/
getChildTeams: function (id: string, params?: Params) {
getChildTeams: function (id: string, org_id: string, params?: Params) {
return req.standardRequest(
`${config.host}/teams/${id}/teams?${req.assembleQueryParams(params, [
"page",
])}`
) as Promise<Endpoints["GET /teams/{team_id}/teams"]["response"]["data"]>;
`${
config.host
}/organizations/${org_id}/team/${id}/teams?${req.assembleQueryParams(
params,
["page"]
)}`
) as Promise<
Endpoints["GET /orgs/{org}/teams/{team_slug}/teams"]["response"]["data"]
>;
},

@@ -185,2 +199,3 @@

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -191,8 +206,13 @@ * @param {int} params.page - The page of results to retrieve

*/
getTeamRepos: function (id: string, params?: Params) {
getTeamRepos: function (id: string, org_id: string, params?: Params) {
return req.standardRequest(
`${config.host}/teams/${id}/repos?${req.assembleQueryParams(params, [
"page",
])}`
) as Promise<Endpoints["GET /teams/{team_id}/repos"]["response"]["data"]>;
`${
config.host
}/organizations/${org_id}/team/${id}/repos?${req.assembleQueryParams(
params,
["page"]
)}`
) as Promise<
Endpoints["GET /orgs/{org}/teams/{team_slug}/repos"]["response"]["data"]
>;
},

@@ -207,13 +227,20 @@

*
* @param {string} id - The team ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @return {nothing} 204 if is managed, 404 if not
*/
getIsRepoManagedByTeam: function (id: string, owner: string, repo: string) {
getIsRepoManagedByTeam: function (
id: string,
org_id: string,
owner: string,
repo: string
) {
return req.standardRequest(
`${config.host}/teams/${id}/repos/${owner}/${repo}`
`${config.host}/organizations/${org_id}/team/${id}/repos/${owner}/${repo}`
) as Promise<
Endpoints["GET /teams/{team_id}/repos/{owner}/{repo}"]["response"]["data"]
Endpoints["GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"]["response"]["data"]
>;

@@ -230,2 +257,3 @@ },

* @param {string} id - The team ID
* @param {string} org_id - The organization ID
* @param {string} owner - The owner name

@@ -247,2 +275,3 @@ * @param {string} repo - The repo name

id: string,
org_id: string,
owner: string,

@@ -253,7 +282,7 @@ repo: string,

return req.standardRequest(
`${config.host}/teams/${id}/repos/${owner}/${repo}`,
`${config.host}/organizations/${org_id}/team/${id}/repos/${owner}/${repo}`,
"put",
body
) as Promise<
Endpoints["PUT /teams/{team_id}/repos/{owner}/{repo}"]["response"]["data"]
Endpoints["PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"]["response"]["data"]
>;

@@ -269,14 +298,20 @@ },

*
* @param {string} id - The team ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} owner - The owner name
* @param {string} repo - The repo name
*
* @return {nothing}
*/
removeTeamRepository: function (id: string, owner: string, repo: string) {
removeTeamRepository: function (
id: string,
org_id: string,
owner: string,
repo: string
) {
return req.standardRequest(
`${config.host}/teams/${id}/repos/${owner}/${repo}`,
`${config.host}/organizations/${org_id}/team/${id}/repos/${owner}/${repo}`,
"delete"
) as Promise<
Endpoints["DELETE /teams/{team_id}/repos/{owner}/{repo}"]["response"]["data"]
Endpoints["DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"]["response"]["data"]
>;

@@ -311,2 +346,3 @@ },

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {object} params - An object of parameters for the request

@@ -317,9 +353,12 @@ * @param {int} params.page - The page of results to retrieve

*/
getTeamProjects: function (id: string, params?: Params) {
getTeamProjects: function (id: string, org_id: string, params?: Params) {
return req.standardRequest(
`${config.host}/teams/${id}/projects?${req.assembleQueryParams(params, [
"page",
])}`
`${
config.host
}/organizations/${org_id}/team/${id}/projects?${req.assembleQueryParams(
params,
["page"]
)}`
) as Promise<
Endpoints["GET /teams/{team_id}/projects"]["response"]["data"]
Endpoints["GET /orgs/{org}/teams/{team_slug}/projects"]["response"]["data"]
>;

@@ -336,2 +375,3 @@ },

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -341,5 +381,5 @@ *

*/
getTeamProject: function (id: string, projectId: string) {
getTeamProject: function (id: string, org_id: string, projectId: string) {
return req.standardRequest(
`${config.host}/teams/${id}/projects/${projectId}`
`${config.host}/organizations/${org_id}/team/${id}/projects/${projectId}`
) as Promise<

@@ -358,2 +398,3 @@ Endpoints["GET /teams/{team_id}/projects/{project_id}"]["response"]["data"]

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -372,9 +413,14 @@ * @param {object} body - The request body

*/
updateTeamProject: function (id: string, projectId: string, body: Params) {
updateTeamProject: function (
id: string,
org_id: string,
projectId: string,
body: Params
) {
return req.standardRequest(
`${config.host}/teams/${id}/projects/${projectId}`,
`${config.host}/organizations/${org_id}/team/${id}/projects/${projectId}`,
"put",
body
) as Promise<
Endpoints["PUT /teams/{team_id}/projects/{project_id}"]["response"]["data"]
Endpoints["PUT /orgs/{org}/teams/{team_slug}/projects/{project_id}"]["response"]["data"]
>;

@@ -391,2 +437,3 @@ },

* @param {string} id - The team ID
* @param {string} org_id - The org ID
* @param {string} projectId - The project ID

@@ -396,5 +443,5 @@ *

*/
removeTeamProject: function (id: string, projectId: string) {
removeTeamProject: function (id: string, org_id: string, projectId: string) {
return req.standardRequest(
`${config.host}/teams/${id}/projects/${projectId}`,
`${config.host}/organizations/${org_id}/team/${id}/projects/${projectId}`,
"delete"

@@ -401,0 +448,0 @@ ) as Promise<

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc