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

@hubspot/local-dev-lib

Package Overview
Dependencies
Maintainers
27
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hubspot/local-dev-lib - npm Package Compare versions

Comparing version 0.0.11 to 0.1.0

api/github.d.ts

22

constants/api.d.ts
export declare const HTTP_METHOD_VERBS: {
readonly DEFAULT: "request";
readonly DELETE: "delete";
readonly GET: "request";
readonly PATCH: "update";
readonly POST: "post";
readonly PUT: "update";
readonly delete: "delete";
readonly get: "request";
readonly patch: "update";
readonly post: "post";
readonly put: "update";
};
export declare const HTTP_METHOD_PREPOSITIONS: {
readonly DEFAULT: "for";
readonly DELETE: "of";
readonly GET: "for";
readonly PATCH: "to";
readonly POST: "to";
readonly PUT: "to";
readonly delete: "of";
readonly get: "for";
readonly patch: "to";
readonly post: "to";
readonly put: "to";
};
export declare const SANDBOX_TIMEOUT = 60000;

@@ -5,17 +5,15 @@ "use strict";

exports.HTTP_METHOD_VERBS = {
DEFAULT: 'request',
DELETE: 'delete',
GET: 'request',
PATCH: 'update',
POST: 'post',
PUT: 'update',
delete: 'delete',
get: 'request',
patch: 'update',
post: 'post',
put: 'update',
};
exports.HTTP_METHOD_PREPOSITIONS = {
DEFAULT: 'for',
DELETE: 'of',
GET: 'for',
PATCH: 'to',
POST: 'to',
PUT: 'to',
delete: 'of',
get: 'for',
patch: 'to',
post: 'to',
put: 'to',
};
exports.SANDBOX_TIMEOUT = 60000;

@@ -1,7 +0,7 @@

import { GenericError, StatusCodeError, StatusCodeErrorContext } from '../types/Error';
import { AxiosError } from 'axios';
import { GenericError, AxiosErrorContext } from '../types/Error';
import { HubSpotAuthError } from '../models/HubSpotAuthError';
export declare function isApiStatusCodeError(err: GenericError): boolean;
export declare function isMissingScopeError(err: GenericError): boolean;
export declare function isGatingError(err: GenericError): boolean;
export declare function isApiUploadValidationError(err: GenericError): boolean;
export declare function isMissingScopeError(err: AxiosError<any>): boolean;
export declare function isGatingError(err: AxiosError<any>): boolean;
export declare function isApiUploadValidationError(err: AxiosError<any>): boolean;
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean;

@@ -11,14 +11,10 @@ /**

*/
export declare function throwStatusCodeError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
export declare function throwAxiosErrorWithContext(error: AxiosError<any>, context?: AxiosErrorContext): never;
/**
* @throws
*/
export declare function throwApiStatusCodeError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
export declare function throwApiError(error: AxiosError, context?: AxiosErrorContext): never;
/**
* @throws
*/
export declare function throwApiError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
/**
* @throws
*/
export declare function throwApiUploadError(error: StatusCodeError, context?: StatusCodeErrorContext): never;
export declare function throwApiUploadError(error: AxiosError, context?: AxiosErrorContext): never;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwApiUploadError = exports.throwApiError = exports.throwApiStatusCodeError = exports.throwStatusCodeError = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = exports.isApiStatusCodeError = void 0;
exports.throwApiUploadError = exports.throwApiError = exports.throwAxiosErrorWithContext = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = void 0;
const api_1 = require("../constants/api");

@@ -8,27 +8,24 @@ const lang_1 = require("../utils/lang");

const i18nKey = 'errors.apiErrors';
function isApiStatusCodeError(err) {
return (err.name === 'StatusCodeError' ||
(!!err.status && err.status >= 100 && err.status < 600));
}
exports.isApiStatusCodeError = isApiStatusCodeError;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isMissingScopeError(err) {
return (isApiStatusCodeError(err) &&
return (err.isAxiosError &&
err.status === 403 &&
!!err.error &&
err.error.category === 'MISSING_SCOPES');
!!err.response &&
err.response.data.category === 'MISSING_SCOPES');
}
exports.isMissingScopeError = isMissingScopeError;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isGatingError(err) {
return (isApiStatusCodeError(err) &&
return (err.isAxiosError &&
err.status === 403 &&
!!err.error &&
err.error.category === 'GATED');
!!err.response &&
err.response.data.category === 'GATED');
}
exports.isGatingError = isGatingError;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isApiUploadValidationError(err) {
return (isApiStatusCodeError(err) &&
return (err.isAxiosError &&
err.status === 400 &&
!!err.response &&
!!err.response.body &&
!!(err.response.body.message || !!err.response.body.errors));
!!(err.response?.data?.message || !!err.response?.data?.errors));
}

@@ -46,5 +43,5 @@ exports.isApiUploadValidationError = isApiUploadValidationError;

exports.isSpecifiedHubSpotAuthError = isSpecifiedHubSpotAuthError;
function parseValidationErrors(responseBody = { errors: [], message: '' }) {
function parseValidationErrors(responseData = { errors: [], message: '' }) {
const errorMessages = [];
const { errors, message } = responseBody;
const { errors, message } = responseData;
if (message) {

@@ -65,5 +62,5 @@ errorMessages.push(message);

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function logValidationErrors(error) {
const { response = { body: undefined } } = error;
const validationErrorMessages = parseValidationErrors(response.body);
const validationErrorMessages = parseValidationErrors(error?.response?.data);
if (validationErrorMessages.length) {

@@ -76,27 +73,12 @@ (0, standardErrors_1.throwError)(new Error(validationErrorMessages.join(' '), { cause: error }));

*/
function throwStatusCodeError(error, context = {}) {
const { status, message, response } = error;
const errorData = JSON.stringify({
status,
message,
url: response ? response.request.href : null,
method: response ? response.request.method : null,
response: response ? response.body : null,
headers: response ? response.headers : null,
context,
});
throw new Error(errorData, { cause: error });
}
exports.throwStatusCodeError = throwStatusCodeError;
/**
* @throws
*/
function throwApiStatusCodeError(error, context = {}) {
function throwAxiosErrorWithContext(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error, context = {}) {
const { status } = error;
const { method } = error.options || {};
const method = error.config?.method;
const { projectName } = context;
const isPutOrPost = method === 'PUT' || method === 'POST';
const action = method && (api_1.HTTP_METHOD_VERBS[method] || api_1.HTTP_METHOD_VERBS.DEFAULT);
const isPutOrPost = method === 'put' || method === 'post';
const action = method && (api_1.HTTP_METHOD_VERBS[method] || api_1.HTTP_METHOD_VERBS.get);
const preposition = (method && api_1.HTTP_METHOD_PREPOSITIONS[method]) ||
api_1.HTTP_METHOD_PREPOSITIONS.DEFAULT;
api_1.HTTP_METHOD_PREPOSITIONS.get;
const request = context.request

@@ -169,9 +151,9 @@ ? `${action} ${preposition} "${context.request}"`

}
if (error?.error?.message &&
if (error?.response?.data?.message &&
!isProjectMissingScopeError &&
!isProjectGatingError) {
errorMessage.push(error.error.message);
errorMessage.push(error.response.data.message);
}
if (error.error && error.error.errors) {
error.error.errors.forEach(err => {
if (error?.response?.data?.errors) {
error.response.data.errors.forEach((err) => {
errorMessage.push('\n- ' + err.message);

@@ -182,3 +164,3 @@ });

}
exports.throwApiStatusCodeError = throwApiStatusCodeError;
exports.throwAxiosErrorWithContext = throwAxiosErrorWithContext;
/**

@@ -188,4 +170,4 @@ * @throws

function throwApiError(error, context = {}) {
if (isApiStatusCodeError(error)) {
throwApiStatusCodeError(error, context);
if (error.isAxiosError) {
throwAxiosErrorWithContext(error, context);
}

@@ -192,0 +174,0 @@ (0, standardErrors_1.throwError)(error);

@@ -8,16 +8,3 @@ "use strict";

function debugErrorAndContext(error, context) {
if (error.name === 'StatusCodeError') {
const { status, message, response } = error;
console.debug('Error: %o', {
status,
message,
url: response.request.href,
method: response.request.method,
response: response.body,
headers: response.headers,
});
}
else {
console.debug('Error: %o', error);
}
console.debug('Error: %o', error);
console.debug('Context: %o', context);

@@ -24,0 +11,0 @@ }

@@ -1,3 +0,4 @@

import { BaseError, StatusCodeError } from '../types/Error';
import { BaseError } from '../types/Error';
import { LangKey } from '../types/Lang';
import { AxiosError } from 'axios';
export declare function isSystemError(err: BaseError): boolean;

@@ -22,3 +23,3 @@ export declare function isFatalError(err: BaseError): boolean;

[key: string]: string | number;
}, cause?: StatusCodeError): never;
}, cause?: AxiosError): never;
/**

@@ -25,0 +26,0 @@ * @throws

@@ -6,3 +6,2 @@ "use strict";

const lang_1 = require("../utils/lang");
const apiErrors_1 = require("./apiErrors");
function isSystemError(err) {

@@ -50,17 +49,13 @@ return err.errno != null && err.code != null && err.syscall != null;

function throwError(error) {
if (error.name === 'StatusCodeError') {
(0, apiErrors_1.throwStatusCodeError)(error);
}
else {
// Error or Error subclass
const name = error.name || 'Error';
const message = [(0, lang_1.i18n)('errors.generic', { name })];
[error.message, error.reason].forEach(msg => {
if (msg) {
message.push(msg);
}
});
throw new Error(message.join(' '), { cause: error });
}
// Error or Error subclass
const message = error.name && error.name !== 'Error'
? [(0, lang_1.i18n)('errors.generic', { name: error.name })]
: [];
[error.message, error.reason].forEach(msg => {
if (msg) {
message.push(msg);
}
});
throw new Error(message.join(' '), { cause: error });
}
exports.throwError = throwError;

@@ -33,4 +33,4 @@ {

"github": {
"fetchJsonFromRepository": {
"fetching": "Fetching {{ url }}...",
"fetchFileFromRepository": {
"fetching": "Fetching {{ path }}...",
"errors": {

@@ -46,3 +46,3 @@ "fetchFail": "An error occured fetching JSON file."

"downloadGithubRepoZip": {
"fetching": "Fetching {{ releaseType }} with name {{ repoName }}...",
"fetching": "Fetching repository with name {{ repoPath }}...",
"fetchingName": "Fetching {{ name }}...",

@@ -383,4 +383,4 @@ "completed": "Completed project fetch.",

},
"generic": "A {{ name }} has occurred"
"generic": "{{ name }}:"
}
}

@@ -33,4 +33,4 @@ {

"github": {
"fetchJsonFromRepository": {
"fetching": "Fetching {{ url }}...",
"fetchFileFromRepository": {
"fetching": "Fetching {{ path }}...",
"errors": {

@@ -46,3 +46,3 @@ "fetchFail": "An error occured fetching JSON file."

"downloadGithubRepoZip": {
"fetching": "Fetching {{ releaseType }} with name {{ repoName }}...",
"fetching": "Fetching repository with name {{ repoPath }}...",
"fetchingName": "Fetching {{ name }}...",

@@ -383,4 +383,4 @@ "completed": "Completed project fetch.",

},
"generic": "A {{ name }} has occurred"
"generic": "{{ name }}:"
}
}

@@ -125,4 +125,4 @@ "use strict";

(0, logger_1.debug)(`${i18nKey}.uploadFolder.failed`, { file, destPath });
if (error.response && error.response.body) {
console.debug(error.response.body);
if (error.response && error.response.data) {
console.debug(error.response.data);
}

@@ -129,0 +129,0 @@ else {

import chokidar from 'chokidar';
import { AxiosError } from 'axios';
import { LogCallbacksArg } from '../../types/LogCallbacks';
import { Mode } from '../../types/Files';
import { UploadFolderResults } from '../../types/Files';
import { StatusCodeError } from '../../types/Error';
declare const watchCallbackKeys: readonly ["notifyOfThemePreview", "uploadSuccess", "deleteSuccess", "folderUploadSuccess", "ready", "deleteSuccessWithType"];

@@ -18,4 +18,4 @@ type WatchLogCallbacks = LogCallbacksArg<typeof watchCallbackKeys>;

};
type ErrorHandler = (error: StatusCodeError) => void;
type ErrorHandler = (error: AxiosError) => void;
export declare function watch(accountId: number, src: string, dest: string, { mode, remove, disableInitial, notify, commandOptions, filePaths, }: WatchOptions, postInitialUploadCallback?: ((result: Array<UploadFolderResults>) => void) | null, onUploadFolderError?: ErrorHandler, onQueueAddError?: ErrorHandler, logCallbacks?: WatchLogCallbacks): chokidar.FSWatcher;
export {};

@@ -16,3 +16,2 @@ "use strict";

const fileSystemErrors_1 = require("../errors/fileSystemErrors");
const apiErrors_1 = require("../errors/apiErrors");
const logger_1 = require("../utils/logger");

@@ -162,6 +161,3 @@ const i18nKey = 'lib.fileMapper';

catch (err) {
(0, apiErrors_1.throwStatusCodeError)(err, {
accountId,
request: srcPath,
});
(0, standardErrors_1.throwError)(err);
}

@@ -245,3 +241,3 @@ await writeUtimes(accountId, filepath, node);

const error = err;
if (isHubspot && isTimeout(err)) {
if (isHubspot && isTimeout(error)) {
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.assetTimeout`, {}, error);

@@ -277,6 +273,3 @@ }

else {
(0, apiErrors_1.throwStatusCodeError)(error, {
accountId,
request: src,
});
(0, standardErrors_1.throwError)(error);
}

@@ -283,0 +276,0 @@ }

@@ -1,20 +0,17 @@

import { GITHUB_RELEASE_TYPES } from '../constants/github';
/// <reference types="node" />
import { GithubReleaseData } from '../types/Github';
import { ValueOf } from '../types/Utils';
import { LogCallbacksArg } from '../types/LogCallbacks';
declare global {
var githubToken: string;
}
type RepoPath = `${string}/${string}`;
export declare function fetchJsonFromRepository(repoPath: RepoPath, filePath: string, ref: string): Promise<JSON>;
export declare function fetchFileFromRepository(repoPath: RepoPath, filePath: string, ref: string): Promise<Buffer>;
export declare function fetchReleaseData(repoPath: RepoPath, tag?: string): Promise<GithubReleaseData>;
type CloneGithubRepoOptions = {
themeVersion?: string;
projectVersion?: string;
releaseType?: ValueOf<typeof GITHUB_RELEASE_TYPES>;
ref?: string;
isRelease?: boolean;
type?: string;
branch?: string;
tag?: string;
sourceDir?: string;
};
declare const cloneGithubRepoCallbackKeys: string[];
export declare function cloneGithubRepo(dest: string, type: string, repoPath: RepoPath, sourceDir: string, options?: CloneGithubRepoOptions, logCallbacks?: LogCallbacksArg<typeof cloneGithubRepoCallbackKeys>): Promise<boolean>;
export declare function cloneGithubRepo(repoPath: RepoPath, dest: string, options?: CloneGithubRepoOptions, logCallbacks?: LogCallbacksArg<typeof cloneGithubRepoCallbackKeys>): Promise<boolean>;
export declare function downloadGithubRepoContents(repoPath: RepoPath, contentPath: string, dest: string, ref?: string, filter?: (contentPiecePath: string, downloadPath: string) => boolean): Promise<void>;
export {};

@@ -6,4 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.downloadGithubRepoContents = exports.cloneGithubRepo = exports.fetchReleaseData = exports.fetchJsonFromRepository = void 0;
const axios_1 = __importDefault(require("axios"));
exports.downloadGithubRepoContents = exports.cloneGithubRepo = exports.fetchReleaseData = exports.fetchFileFromRepository = void 0;
const path_1 = __importDefault(require("path"));

@@ -14,34 +13,27 @@ const fs_extra_1 = __importDefault(require("fs-extra"));

const archive_1 = require("./archive");
const github_1 = require("../constants/github");
const getAxiosConfig_1 = require("../http/getAxiosConfig");
const github_1 = require("../api/github");
const i18nKey = 'lib.github';
const GITHUB_AUTH_HEADERS = {
authorization: global && global.githubToken ? `Bearer ${global.githubToken}` : null,
};
async function fetchJsonFromRepository(repoPath, filePath, ref) {
async function fetchFileFromRepository(repoPath, filePath, ref) {
try {
const URL = `https://raw.githubusercontent.com/${repoPath}/${ref}/${filePath}`;
(0, logger_1.debug)(`${i18nKey}.fetchJsonFromRepository.fetching`, { url: URL });
const { data } = await axios_1.default.get(URL, {
headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
(0, logger_1.debug)(`${i18nKey}.fetchFileFromRepository.fetching`, {
path: `${repoPath}/${ref}/${filePath}`,
});
const { data } = await (0, github_1.fetchRepoFile)(repoPath, filePath, ref);
return data;
}
catch (err) {
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchJsonFromRepository.errors.fetchFail`, {}, err);
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchFileFromRepository.errors.fetchFail`, {}, err);
}
}
exports.fetchJsonFromRepository = fetchJsonFromRepository;
async function fetchReleaseData(repoPath, tag = '') {
tag = tag.trim().toLowerCase();
if (tag.length && tag[0] !== 'v') {
tag = `v${tag}`;
exports.fetchFileFromRepository = fetchFileFromRepository;
// Fetches information about a specific release (Defaults to latest)
async function fetchReleaseData(repoPath, tag) {
if (tag) {
tag = tag.trim().toLowerCase();
if (tag.length && tag[0] !== 'v') {
tag = `v${tag}`;
}
}
const URI = tag
? `https://api.github.com/repos/${repoPath}/releases/tags/${tag}`
: `https://api.github.com/repos/${repoPath}/releases/latest`;
try {
const { data } = await axios_1.default.get(URI, {
headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
});
const { data } = await (0, github_1.fetchRepoReleaseData)(repoPath, tag);
return data;

@@ -55,13 +47,9 @@ }

exports.fetchReleaseData = fetchReleaseData;
async function downloadGithubRepoZip(repoPath, tag = '', releaseType = github_1.GITHUB_RELEASE_TYPES.RELEASE, ref) {
async function downloadGithubRepoZip(repoPath, isRelease = false, options = {}) {
const { branch, tag } = options;
try {
let zipUrl;
if (releaseType === github_1.GITHUB_RELEASE_TYPES.REPOSITORY) {
(0, logger_1.debug)(`${i18nKey}.downloadGithubRepoZip.fetching`, {
releaseType,
repoPath,
});
zipUrl = `https://api.github.com/repos/${repoPath}/zipball${ref ? `/${ref}` : ''}`;
}
else {
if (isRelease) {
// If downloading a release, first get the release info using fetchReleaseData().
// Supports a custom tag, but will default to the latest release
const releaseData = await fetchReleaseData(repoPath, tag);

@@ -72,5 +60,9 @@ zipUrl = releaseData.zipball_url;

}
const { data } = await axios_1.default.get(zipUrl, {
headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
});
else {
// If downloading a repository, manually construct the zip url. This url supports both branches and tags as refs
(0, logger_1.debug)(`${i18nKey}.downloadGithubRepoZip.fetching`, { repoPath });
const ref = branch || tag;
zipUrl = `https://api.github.com/repos/${repoPath}/zipball${ref ? `/${ref}` : ''}`;
}
const { data } = await (0, github_1.fetchRepoAsZip)(zipUrl);
(0, logger_1.debug)(`${i18nKey}.downloadGithubRepoZip.completed`);

@@ -84,11 +76,16 @@ return data;

const cloneGithubRepoCallbackKeys = ['success'];
async function cloneGithubRepo(dest, type, repoPath, sourceDir, options = {}, logCallbacks) {
async function cloneGithubRepo(repoPath, dest, options = {}, logCallbacks) {
const logger = (0, logger_1.makeTypedLogger)(logCallbacks);
const { themeVersion, projectVersion, releaseType, ref } = options;
const tag = projectVersion || themeVersion;
const zip = await downloadGithubRepoZip(repoPath, tag, releaseType, ref);
const { tag, isRelease, branch, sourceDir, type } = options;
const zip = await downloadGithubRepoZip(repoPath, isRelease, {
tag,
branch,
});
const repoName = repoPath.split('/')[1];
const success = await (0, archive_1.extractZipArchive)(zip, repoName, dest, { sourceDir });
if (success) {
logger('success', `${i18nKey}.cloneGithubRepo.success`, { type, dest });
logger('success', `${i18nKey}.cloneGithubRepo.success`, {
type: type || '',
dest,
});
}

@@ -98,14 +95,4 @@ return success;

exports.cloneGithubRepo = cloneGithubRepo;
async function getGitHubRepoContentsAtPath(repoPath, path, ref) {
const refQuery = ref ? `?ref=${ref}` : '';
const contentsRequestUrl = `https://api.github.com/repos/${repoPath}/contents/${path}${refQuery}`;
const response = await axios_1.default.get(contentsRequestUrl, {
headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
});
return response.data;
}
async function fetchGitHubRepoContentFromDownloadUrl(dest, downloadUrl) {
const resp = await axios_1.default.get(downloadUrl, {
headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
});
const resp = await (0, github_1.fetchRepoFileByDownloadUrl)(downloadUrl);
fs_extra_1.default.writeFileSync(dest, resp.data, 'utf8');

@@ -117,5 +104,5 @@ }

try {
const contentsResp = await getGitHubRepoContentsAtPath(repoPath, contentPath, ref);
const { data: contentsResp } = await (0, github_1.fetchRepoContents)(repoPath, contentPath, ref);
const downloadContent = async (contentPiece) => {
const { path: contentPiecePath, download_url } = contentPiece;
const { path: contentPiecePath, download_url, type: contentPieceType, } = contentPiece;
const downloadPath = path_1.default.join(dest, contentPiecePath.replace(contentPath, ''));

@@ -130,2 +117,7 @@ if (filter && !filter(contentPiecePath, downloadPath)) {

});
if (contentPieceType === 'dir') {
const { data: innerDirContent } = await (0, github_1.fetchRepoContents)(repoPath, contentPiecePath, ref);
await Promise.all(innerDirContent.map(downloadContent));
return Promise.resolve();
}
return fetchGitHubRepoContentFromDownloadUrl(downloadPath, download_url);

@@ -140,3 +132,3 @@ };

}
Promise.all(contentPromises);
await Promise.all(contentPromises);
}

@@ -143,0 +135,0 @@ catch (e) {

@@ -12,3 +12,3 @@ import { CLIAccount } from '../types/Accounts';

export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
export declare const updateConfigWithPersonalAccessKey: (personalAccessKey: string, name: string, env: Environment, makeDefault?: boolean) => Promise<CLIAccount | null>;
export declare const updateConfigWithPersonalAccessKey: (personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean) => Promise<CLIAccount | null>;
export {};

@@ -26,4 +26,4 @@ "use strict";

const error = e;
if (error.response && error.response.body) {
(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.errors.invalidPersonalAccessKey`, { errorMessage: error.response.body.message || '' }, error);
if (error.response) {
(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.errors.invalidPersonalAccessKey`, { errorMessage: error.response.data.message || '' }, error);
}

@@ -95,3 +95,3 @@ else {

// Adds an account to the config using authType: personalAccessKey
const updateConfigWithPersonalAccessKey = async (personalAccessKey, name, env, makeDefault = false) => {
const updateConfigWithPersonalAccessKey = async (personalAccessKey, env, name, makeDefault = false) => {
const accountEnv = env || (0, config_1.getEnv)(name);

@@ -133,3 +133,3 @@ let token;

(0, config_1.writeConfig)();
if (makeDefault) {
if (makeDefault && name) {
(0, config_1.updateDefaultAccount)(name);

@@ -136,0 +136,0 @@ }

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

import { StatusCodeError } from '../types/Error';
import { AxiosError } from 'axios';
export declare class HubSpotAuthError extends Error {

@@ -6,5 +6,8 @@ status?: number;

subCategory?: string;
constructor(message: string, { cause }: {
cause?: Partial<StatusCodeError>;
constructor(message: string, { cause, }: {
cause?: Partial<AxiosError<{
category?: string;
subCategory?: string;
}>>;
});
}

@@ -8,11 +8,11 @@ "use strict";

subCategory;
constructor(message, { cause = {} }) {
constructor(message, { cause = {}, }) {
super(message);
this.name = 'HubSpotAuthError';
this.status = cause.status;
this.category = cause?.response?.body?.category || undefined;
this.status = cause.response?.status;
this.category = cause?.response?.data?.category || undefined;
this.subCategory =
(cause.response &&
cause.response.body &&
cause.response.body.subCategory) ||
cause.response.data &&
cause.response.data.subCategory) ||
undefined;

@@ -19,0 +19,0 @@ }

@@ -92,3 +92,3 @@ "use strict";

(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.errors.auth`, {
token: error.response.body.message || '',
token: error.response.data.message || '',
}, error);

@@ -95,0 +95,0 @@ }

{
"name": "@hubspot/local-dev-lib",
"version": "0.0.11",
"version": "0.1.0",
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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

import { HttpMethod } from './Api';
export interface GenericError extends Error {

@@ -16,32 +15,6 @@ [key: string]: any;

}
export interface StatusCodeError extends BaseError {
name: string;
status?: number;
message: string;
category?: string;
subCategory?: string;
response: {
request: {
href: string;
method: string;
};
body: {
message?: string;
errors?: Array<StatusCodeError>;
category?: string;
subCategory?: string;
};
headers: {
[key: string]: string;
};
status: number;
};
options?: {
method: HttpMethod;
};
export interface ValidationError extends BaseError {
errorTokens?: {
line: number;
};
error?: StatusCodeError;
errors?: Array<StatusCodeError>;
}

@@ -54,3 +27,3 @@ export type FileSystemErrorContext = {

};
export type StatusCodeErrorContext = {
export type AxiosErrorContext = {
accountId?: number;

@@ -57,0 +30,0 @@ request?: string;

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

import { AxiosError } from 'axios';
import { ValueOf } from '../types/Utils';

@@ -5,3 +6,2 @@ import { STAT_TYPES, FILE_TYPES, FILE_UPLOAD_RESULT_TYPES } from '../constants/files';

import { HttpOptions } from './Http';
import { StatusCodeError } from './Error';
export type StatType = ValueOf<typeof STAT_TYPES>;

@@ -33,3 +33,3 @@ export type FileData = {

resultType: ResultType;
error: StatusCodeError | null;
error: AxiosError | null;
file: string;

@@ -36,0 +36,0 @@ };

@@ -143,3 +143,3 @@ "use strict";

this.deletePort(instanceId);
res.send(200);
res.sendStatus(200);
}

@@ -153,3 +153,3 @@ else {

(0, logger_1.debug)(`${i18nKey}.close`);
res.send(200);
res.sendStatus(200);
this.server.close();

@@ -156,0 +156,0 @@ this.reset();

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