@soos-io/api-client
Advanced tools
Comparing version 0.3.5 to 1.0.0
@@ -23,7 +23,7 @@ "use strict"; | ||
if (request.data) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request URL: ${request.method?.toLocaleUpperCase()} ${request.url}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request URL: ${request.method?.toLocaleUpperCase()} ${request.url}`); | ||
if (request.params) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request Params: ${JSON.stringify(request.params)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request Params: ${JSON.stringify(request.params)}`); | ||
} | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request Body: ${JSON.stringify(request.data)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request Body: ${JSON.stringify(request.data)}`); | ||
} | ||
@@ -35,3 +35,3 @@ return request; | ||
client.interceptors.response.use((response) => { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
return response; | ||
@@ -38,0 +38,0 @@ }, (rejectedResponse) => { |
import { LogLevel } from "../enums"; | ||
declare class SOOSLogger { | ||
private verbose; | ||
private console; | ||
private minLogLevel; | ||
constructor(verbose?: boolean, minLogLevel?: LogLevel, console?: Console); | ||
constructor(minLogLevel?: LogLevel, console?: Console); | ||
private getTimeStamp; | ||
private logWithTimestamp; | ||
private shouldLog; | ||
setVerbose(verbose: boolean): void; | ||
setMinLogLevel(minLogLevel: LogLevel): void; | ||
@@ -18,8 +16,2 @@ debug(message?: any, ...optionalParams: any[]): void; | ||
groupEnd(): void; | ||
verboseDebug(message?: any, ...optionalParams: any[]): void; | ||
verboseInfo(message?: any, ...optionalParams: any[]): void; | ||
verboseWarn(message?: any, ...optionalParams: any[]): void; | ||
verboseError(message?: any, ...optionalParams: any[]): void; | ||
verboseGroup(...label: any[]): void; | ||
verboseGroupEnd(): void; | ||
always(message?: any, ...optionalParams: any[]): void; | ||
@@ -26,0 +18,0 @@ logLineSeparator(): void; |
@@ -6,6 +6,5 @@ "use strict"; | ||
class SOOSLogger { | ||
constructor(verbose = false, minLogLevel = enums_1.LogLevel.INFO, console = global.console) { | ||
this.verbose = verbose; | ||
constructor(minLogLevel = enums_1.LogLevel.INFO, console = global.console) { | ||
this.console = console; | ||
this.minLogLevel = this.verbose ? enums_1.LogLevel.DEBUG : minLogLevel; | ||
this.minLogLevel = minLogLevel; | ||
} | ||
@@ -36,11 +35,4 @@ getTimeStamp() { | ||
} | ||
setVerbose(verbose) { | ||
this.verbose = this.minLogLevel === enums_1.LogLevel.DEBUG || verbose; | ||
if (this.verbose) | ||
this.minLogLevel = enums_1.LogLevel.DEBUG; | ||
} | ||
setMinLogLevel(minLogLevel) { | ||
this.minLogLevel = minLogLevel; | ||
if (this.minLogLevel === enums_1.LogLevel.DEBUG) | ||
this.verbose = true; | ||
} | ||
@@ -66,32 +58,2 @@ debug(message, ...optionalParams) { | ||
} | ||
verboseDebug(message, ...optionalParams) { | ||
if (this.verbose) { | ||
this.debug(message, ...optionalParams); | ||
} | ||
} | ||
verboseInfo(message, ...optionalParams) { | ||
if (this.verbose) { | ||
this.info(message, ...optionalParams); | ||
} | ||
} | ||
verboseWarn(message, ...optionalParams) { | ||
if (this.verbose) { | ||
this.warn(message, ...optionalParams); | ||
} | ||
} | ||
verboseError(message, ...optionalParams) { | ||
if (this.verbose) { | ||
this.error(message, ...optionalParams); | ||
} | ||
} | ||
verboseGroup(...label) { | ||
if (this.verbose) { | ||
this.group(...label); | ||
} | ||
} | ||
verboseGroupEnd() { | ||
if (this.verbose) { | ||
this.groupEnd(); | ||
} | ||
} | ||
always(message, ...optionalParams) { | ||
@@ -98,0 +60,0 @@ const timestamp = this.getTimeStamp(); |
@@ -39,3 +39,3 @@ "use strict"; | ||
const contributors = await this.auditProvider.audit(implementationParams); | ||
logging_1.soosLogger.verboseDebug(`Contributing Developers found: ${JSON.stringify(contributors, null, 2)}`); | ||
logging_1.soosLogger.debug(`Contributing Developers found: ${JSON.stringify(contributors, null, 2)}`); | ||
return contributors; | ||
@@ -42,0 +42,0 @@ } |
@@ -65,3 +65,3 @@ "use strict"; | ||
client.interceptors.response.use(async (response) => { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
if (response.data.next) { | ||
@@ -76,3 +76,3 @@ return await paginationFunction(response, client, dateToFilter); | ||
if (response?.status === 429 && config.retryCount < maxRetries) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Rate limit exceeded on the BitbucketCloud API. Waiting ${constants_1.SOOS_BITBUCKET_CLOUD_CONTRIBUTOR_AUDIT_CONSTANTS.RetrySeconds} seconds before retrying. Retry count: ${config.retryCount}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Rate limit exceeded on the BitbucketCloud API. Waiting ${constants_1.SOOS_BITBUCKET_CLOUD_CONTRIBUTOR_AUDIT_CONSTANTS.RetrySeconds} seconds before retrying. Retry count: ${config.retryCount}`); | ||
config.retryCount += 1; | ||
@@ -83,3 +83,3 @@ await (0, utilities_1.sleep)(constants_1.SOOS_BITBUCKET_CLOUD_CONTRIBUTOR_AUDIT_CONSTANTS.RetrySeconds * 1000); | ||
if (response?.status) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Status: ${response.status}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Status: ${response.status}`); | ||
} | ||
@@ -94,3 +94,3 @@ return Promise.reject(error); | ||
while (nextUrl && isWithinDateRange) { | ||
SOOSLogger_1.soosLogger.verboseDebug("Fetching next page", nextUrl); | ||
SOOSLogger_1.soosLogger.debug("Fetching next page", nextUrl); | ||
const nextPageResponse = await client.get(nextUrl); | ||
@@ -109,6 +109,6 @@ data.values = data.values.concat(nextPageResponse.data.values); | ||
while (nextUrl && isWithinDateRange) { | ||
SOOSLogger_1.soosLogger.verboseDebug("Fetching next page", nextUrl); | ||
SOOSLogger_1.soosLogger.debug("Fetching next page", nextUrl); | ||
const nextPageResponse = await client.get(nextUrl); | ||
data.values = data.values.concat(nextPageResponse.data.values); | ||
SOOSLogger_1.soosLogger.verboseDebug(`Checking if commits are within date range min date ${new Date(dateToFilter)}`); | ||
SOOSLogger_1.soosLogger.debug(`Checking if commits are within date range min date ${new Date(dateToFilter)}`); | ||
lastCommitDate = new Date(nextPageResponse.data.values[nextPageResponse.data.values.length - 1].date); | ||
@@ -115,0 +115,0 @@ isWithinDateRange = utilities_1.DateUtilities.isWithinDateRange(lastCommitDate, new Date(dateToFilter)); |
@@ -16,3 +16,3 @@ "use strict"; | ||
const repositories = await bitbucketApiClient.getBitbucketCloudRepositories(); | ||
logging_1.soosLogger.verboseDebug("Fetching commits for each repository"); | ||
logging_1.soosLogger.debug("Fetching commits for each repository"); | ||
const contributors = await this.getBitbucketCloudRepositoryContributors(bitbucketApiClient, repositories, constants_1.SOOS_BITBUCKET_CLOUD_CONTRIBUTOR_AUDIT_CONSTANTS.RequestBatchSize); | ||
@@ -19,0 +19,0 @@ const scriptVersion = utilities_1.ParamUtilities.getAsString(implementationParams, "scriptVersion"); |
@@ -30,7 +30,7 @@ "use strict"; | ||
if (request.data) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request URL: ${request.method?.toLocaleUpperCase()} ${request.url}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request URL: ${request.method?.toLocaleUpperCase()} ${request.url}`); | ||
if (request.params) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request Params: ${JSON.stringify(request.params)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request Params: ${JSON.stringify(request.params)}`); | ||
} | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Request Body: ${JSON.stringify(request.data)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Request Body: ${JSON.stringify(request.data)}`); | ||
} | ||
@@ -42,3 +42,3 @@ return request; | ||
client.interceptors.response.use(async (response) => { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Body: ${JSON.stringify(response.data)}`); | ||
if (response.config.url?.includes("per_page")) { | ||
@@ -56,6 +56,6 @@ return await GitHubApiClient.handleNextPage(response, client); | ||
if (rateLimitReset) { | ||
SOOSLogger_1.soosLogger.verboseDebug(`Trying to parse rate limit reset: ${rateLimitReset}`); | ||
SOOSLogger_1.soosLogger.debug(`Trying to parse rate limit reset: ${rateLimitReset}`); | ||
const rateLimitDate = utilities_1.DateUtilities.getDateFromUnixUTC(rateLimitReset); | ||
const timeToWait = Math.floor((rateLimitDate.getTime() - Date.now()) / 1000); | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Rate limit exceeded on the GitHub API. Waiting ${timeToWait} seconds before retrying. Retry count: ${config.retryCount}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Rate limit exceeded on the GitHub API. Waiting ${timeToWait} seconds before retrying. Retry count: ${config.retryCount}`); | ||
config.retryCount += 1; | ||
@@ -67,6 +67,6 @@ await (0, utilities_1.sleep)(timeToWait * 1000); | ||
if (response?.status) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Status: ${response.status}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Status: ${response.status}`); | ||
} | ||
if (response?.data?.message) { | ||
SOOSLogger_1.soosLogger.verboseDebug(apiClientName, `Response Message: ${response.data.message}`); | ||
SOOSLogger_1.soosLogger.debug(apiClientName, `Response Message: ${response.data.message}`); | ||
} | ||
@@ -81,3 +81,3 @@ return Promise.reject(error); | ||
if (nextUrl) { | ||
SOOSLogger_1.soosLogger.verboseDebug("Fetching next page", nextUrl); | ||
SOOSLogger_1.soosLogger.debug("Fetching next page", nextUrl); | ||
const nextPageResponse = await client.get(nextUrl); | ||
@@ -84,0 +84,0 @@ data = data.concat(nextPageResponse.data); |
@@ -15,5 +15,5 @@ "use strict"; | ||
const organizations = await gitHubApiClient.getGitHubOrganizations(); | ||
logging_1.soosLogger.verboseDebug("Fetching GitHub repositories"); | ||
logging_1.soosLogger.debug("Fetching GitHub repositories"); | ||
const repositories = await Promise.all(organizations.map((org) => gitHubApiClient.getGitHubOrganizationRepositories(org))); | ||
logging_1.soosLogger.verboseDebug("Fetching commits for each repository"); | ||
logging_1.soosLogger.debug("Fetching commits for each repository"); | ||
const contributors = await this.getGitHubRepositoryContributors(gitHubApiClient, repositories.flatMap((repoArray) => { | ||
@@ -20,0 +20,0 @@ return repoArray; |
{ | ||
"name": "@soos-io/api-client", | ||
"version": "0.3.5", | ||
"version": "1.0.0", | ||
"description": "This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform.", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"check": "npm run format && npm run typecheck && npm run test", | ||
"check": "npm run format && npm run typecheck && npm run test && (npm outdated || exit 0)", | ||
"patch": "npm version patch --no-git-tag-version", | ||
@@ -58,7 +58,7 @@ "build:link": "npm run build && npm link" | ||
"form-data": "^4.0.0", | ||
"glob": "^10.4.5", | ||
"tslib": "^2.6.3" | ||
"glob": "^11.0.0", | ||
"tslib": "^2.7.0" | ||
}, | ||
"overrides": { | ||
"glob": "^10.4.5" | ||
"glob": "^11.0.0" | ||
}, | ||
@@ -68,6 +68,6 @@ "devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.14.14", | ||
"@types/node": "^20.16.1", | ||
"jest": "^29.1.2", | ||
"prettier": "^3.3.3", | ||
"ts-jest": "^29.2.4", | ||
"ts-jest": "^29.2.5", | ||
"ts-node": "^10.9.2", | ||
@@ -74,0 +74,0 @@ "typescript": "^5.5.4" |
@@ -14,3 +14,1 @@ # [About SOOS](https://soos.io/) | ||
This is the SOOS API Client for registered clients leveraging the various integrations to the SOOS platform. | ||
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
323282
3142
14
+ Addedglob@11.0.0(transitive)
+ Addedjackspeak@4.0.2(transitive)
+ Addedlru-cache@11.0.2(transitive)
+ Addedminimatch@10.0.1(transitive)
+ Addedpath-scurry@2.0.0(transitive)
- Removed@pkgjs/parseargs@0.11.0(transitive)
- Removedglob@10.4.5(transitive)
- Removedjackspeak@3.4.3(transitive)
- Removedlru-cache@10.4.3(transitive)
- Removedminimatch@9.0.5(transitive)
- Removedpath-scurry@1.11.1(transitive)
Updatedglob@^11.0.0
Updatedtslib@^2.7.0