@hubspot/local-dev-lib
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import { ProjectLog } from '../types/ProjectLog'; | ||
import { MigrateAppResponse, PollAppResponse } from '../types/Migration'; | ||
import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration'; | ||
export declare function fetchProjects(accountId: number): Promise<FetchProjectResponse>; | ||
@@ -42,2 +42,5 @@ export declare function createProject(accountId: number, name: string): Promise<Project>; | ||
export declare function checkMigrationStatus(accountId: number, id: number): Promise<PollAppResponse>; | ||
export declare function cloneApp(accountId: number, appId: number): Promise<CloneAppResponse>; | ||
export declare function checkCloneStatus(accountId: number, exportId: number): Promise<CloneAppResponse>; | ||
export declare function downloadClonedProject(accountId: number, exportId: number): Promise<Buffer>; | ||
export {}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0; | ||
exports.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0; | ||
const http_1 = __importDefault(require("../http")); | ||
@@ -194,1 +194,24 @@ const fs_1 = __importDefault(require("fs")); | ||
exports.checkMigrationStatus = checkMigrationStatus; | ||
async function cloneApp(accountId, appId) { | ||
return http_1.default.post(accountId, { | ||
url: `${MIGRATIONS_API_PATH}/exports`, | ||
data: { | ||
componentId: appId, | ||
componentType: 'PUBLIC_APP_ID', | ||
}, | ||
}); | ||
} | ||
exports.cloneApp = cloneApp; | ||
async function checkCloneStatus(accountId, exportId) { | ||
return http_1.default.get(accountId, { | ||
url: `${MIGRATIONS_API_PATH}/exports/statuses/${exportId}`, | ||
}); | ||
} | ||
exports.checkCloneStatus = checkCloneStatus; | ||
async function downloadClonedProject(accountId, exportId) { | ||
return http_1.default.get(accountId, { | ||
url: `${MIGRATIONS_API_PATH}/exports/${exportId}/download-as-clone`, | ||
responseType: 'arraybuffer', | ||
}); | ||
} | ||
exports.downloadClonedProject = downloadClonedProject; |
import { AxiosError } from 'axios'; | ||
import { GenericError, AxiosErrorContext, ValidationError } from '../types/Error'; | ||
import { AxiosErrorContext, ValidationError } from '../types/Error'; | ||
import { HubSpotAuthError } from '../models/HubSpotAuthError'; | ||
export declare function isSpecifiedError(err: Error | AxiosError, { statusCode, category, subCategory, errorType, code, }: { | ||
export declare function isSpecifiedError(err: unknown, { statusCode, category, subCategory, errorType, code, }: { | ||
statusCode?: number; | ||
@@ -11,7 +11,7 @@ category?: string; | ||
}): boolean; | ||
export declare function isMissingScopeError(err: Error | AxiosError): boolean; | ||
export declare function isGatingError(err: Error | AxiosError): boolean; | ||
export declare function isTimeoutError(err: Error | AxiosError): boolean; | ||
export declare function isApiUploadValidationError(err: AxiosError<any>): boolean; | ||
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean; | ||
export declare function isMissingScopeError(err: unknown): boolean; | ||
export declare function isGatingError(err: unknown): boolean; | ||
export declare function isTimeoutError(err: unknown): boolean; | ||
export declare function isApiUploadValidationError(err: unknown): boolean; | ||
export declare function isSpecifiedHubSpotAuthError(err: unknown, { status, category, subCategory }: Partial<HubSpotAuthError>): err is HubSpotAuthError; | ||
export declare function parseValidationErrors(responseData?: { | ||
@@ -25,3 +25,3 @@ errors?: Array<ValidationError>; | ||
*/ | ||
export declare function throwApiError(error: AxiosError, context?: AxiosErrorContext): never; | ||
export declare function throwApiError(error: unknown, context?: AxiosErrorContext): never; | ||
export declare function throwApiUploadError(error: AxiosError, context?: AxiosErrorContext): never; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.throwApiUploadError = exports.throwApiError = exports.getAxiosErrorWithContext = exports.parseValidationErrors = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0; | ||
const axios_1 = require("axios"); | ||
const api_1 = require("../constants/api"); | ||
const lang_1 = require("../utils/lang"); | ||
const standardErrors_1 = require("./standardErrors"); | ||
const HubSpotAuthError_1 = require("../models/HubSpotAuthError"); | ||
const i18nKey = 'errors.apiErrors'; | ||
function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) { | ||
if (!(err instanceof Error)) { | ||
return false; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -38,3 +43,3 @@ const error = (err && err.cause) || err; | ||
function isApiUploadValidationError(err) { | ||
return (err.isAxiosError && | ||
return ((0, axios_1.isAxiosError)(err) && | ||
(err.status === 400 || err.response?.status === 400) && | ||
@@ -46,9 +51,9 @@ !!err.response && | ||
function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) { | ||
if (!err || !(err instanceof HubSpotAuthError_1.HubSpotAuthError)) { | ||
return false; | ||
} | ||
const statusCodeErr = !status || err.status === status; | ||
const categoryErr = !category || err.category === category; | ||
const subCategoryErr = !subCategory || err.subCategory === subCategory; | ||
return Boolean(err.name === 'HubSpotAuthError' && | ||
statusCodeErr && | ||
categoryErr && | ||
subCategoryErr); | ||
return Boolean(statusCodeErr && categoryErr && subCategoryErr); | ||
} | ||
@@ -176,3 +181,3 @@ exports.isSpecifiedHubSpotAuthError = isSpecifiedHubSpotAuthError; | ||
function throwApiError(error, context = {}) { | ||
if (error.isAxiosError) { | ||
if ((0, axios_1.isAxiosError)(error)) { | ||
throw getAxiosErrorWithContext(error, context); | ||
@@ -179,0 +184,0 @@ } |
@@ -1,6 +0,6 @@ | ||
import { BaseError, FileSystemErrorContext } from '../types/Error'; | ||
export declare function getFileSystemError(error: BaseError, context: FileSystemErrorContext): Error; | ||
import { FileSystemErrorContext } from '../types/Error'; | ||
export declare function getFileSystemError(error: unknown, context: FileSystemErrorContext): Error; | ||
/** | ||
* @throws | ||
*/ | ||
export declare function throwFileSystemError(error: BaseError, context: FileSystemErrorContext): void; | ||
export declare function throwFileSystemError(error: unknown, context: FileSystemErrorContext): void; |
import { BaseError } from '../types/Error'; | ||
import { LangKey } from '../types/Lang'; | ||
import { AxiosError } from 'axios'; | ||
export declare function isSystemError(err: BaseError): boolean; | ||
export declare function isFatalError(err: BaseError): boolean; | ||
export declare function isSystemError(err: unknown): err is BaseError; | ||
export declare function isFatalError(err: unknown): err is BaseError; | ||
/** | ||
@@ -11,3 +10,3 @@ * @throws | ||
[key: string]: string | number; | ||
}, cause?: BaseError | AxiosError): never; | ||
}, cause?: unknown): never; | ||
/** | ||
@@ -18,6 +17,6 @@ * @throws | ||
[key: string]: string | number; | ||
}, cause?: AxiosError): never; | ||
}, cause?: unknown): never; | ||
/** | ||
* @throws | ||
*/ | ||
export declare function throwError(error: BaseError): never; | ||
export declare function throwError(error: unknown): never; |
@@ -7,3 +7,9 @@ "use strict"; | ||
function isSystemError(err) { | ||
return err.errno != null && err.code != null && err.syscall != null; | ||
return (err instanceof Error && | ||
'errno' in err && | ||
err.errno != null && | ||
'code' in err && | ||
err.code != null && | ||
'syscall' in err && | ||
err.syscall != null); | ||
} | ||
@@ -42,2 +48,5 @@ exports.isSystemError = isSystemError; | ||
function throwError(error) { | ||
if (!(error instanceof Error)) { | ||
throw new Error('', { cause: error }); | ||
} | ||
// Error or Error subclass | ||
@@ -47,9 +56,10 @@ const message = error.name && error.name !== 'Error' | ||
: []; | ||
[error.message, error.reason].forEach(msg => { | ||
if (msg) { | ||
message.push(msg); | ||
} | ||
}); | ||
if (error.message) { | ||
message.push(error.message); | ||
} | ||
if ('reason' in error && error.reason) { | ||
message.push(error.reason); | ||
} | ||
throw new Error(message.join(' '), { cause: error }); | ||
} | ||
exports.throwError = throwError; |
@@ -41,5 +41,4 @@ "use strict"; | ||
catch (err) { | ||
const error = err; | ||
if ((0, standardErrors_1.isFatalError)(error)) { | ||
(0, standardErrors_1.throwError)(error); | ||
if ((0, standardErrors_1.isFatalError)(err)) { | ||
(0, standardErrors_1.throwError)(err); | ||
} | ||
@@ -46,0 +45,0 @@ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.uploadFailed`, { |
@@ -41,4 +41,3 @@ "use strict"; | ||
catch (err) { | ||
const error = err; | ||
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchReleaseData.errors.fetchFail`, { tag: tag || 'latest' }, error); | ||
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchReleaseData.errors.fetchFail`, { tag: tag || 'latest' }, err); | ||
} | ||
@@ -45,0 +44,0 @@ } |
{ | ||
"name": "@hubspot/local-dev-lib", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ReadStream } from 'fs'; | ||
import { Stream } from 'stream'; | ||
export type Data = { | ||
@@ -15,3 +18,3 @@ [key: string]: any; | ||
params?: QueryParams; | ||
data?: Data; | ||
data?: Data | string | ArrayBuffer | ArrayBufferView | URLSearchParams | Stream | Buffer; | ||
resolveWithFullResponse?: boolean; | ||
@@ -18,0 +21,0 @@ timeout?: number; |
@@ -14,2 +14,6 @@ import { ValueOf } from './Utils'; | ||
}; | ||
export type CloneAppResponse = { | ||
exportId: number; | ||
status: ValueOf<typeof MIGRATION_STATUS>; | ||
}; | ||
export type PollAppResponse = { | ||
@@ -23,4 +27,4 @@ id: number; | ||
}; | ||
error: OptionalError; | ||
error?: OptionalError; | ||
status: ValueOf<typeof MIGRATION_STATUS>; | ||
}; |
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
412784
10348