@hubspot/local-dev-lib 1.13.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/appsDev.d.ts +6 -5
- package/api/appsDev.js +6 -10
- package/api/customObjects.d.ts +7 -6
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +3 -2
- package/api/designManager.js +5 -8
- package/api/developerTestAccounts.d.ts +5 -4
- package/api/developerTestAccounts.js +9 -10
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +9 -9
- package/api/fileMapper.d.ts +8 -8
- package/api/fileMapper.js +16 -16
- package/api/fileTransport.d.ts +4 -3
- package/api/fileTransport.js +5 -5
- package/api/functions.d.ts +6 -5
- package/api/functions.js +11 -14
- package/api/github.d.ts +6 -6
- package/api/github.js +29 -13
- package/api/hubdb.d.ts +9 -8
- package/api/hubdb.js +17 -20
- package/api/lighthouseScore.d.ts +4 -3
- package/api/lighthouseScore.js +7 -10
- package/api/localDevAuth.d.ts +5 -4
- package/api/localDevAuth.js +8 -9
- package/api/marketplaceValidation.d.ts +4 -3
- package/api/marketplaceValidation.js +4 -7
- package/api/projects.d.ts +31 -30
- package/api/projects.js +52 -52
- package/api/sandboxHubs.d.ts +5 -4
- package/api/sandboxHubs.js +9 -10
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +5 -14
- package/api/secrets.d.ts +5 -4
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/CLIConfiguration.d.ts +3 -3
- package/config/CLIConfiguration.js +22 -20
- package/config/configFile.js +7 -14
- package/config/config_DEPRECATED.js +5 -2
- package/config/index.js +45 -48
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/index.d.ts +18 -0
- package/errors/index.js +63 -0
- package/http/addQueryParams.d.ts +2 -0
- package/http/addQueryParams.js +14 -0
- package/http/getAxiosConfig.d.ts +2 -2
- package/http/getAxiosConfig.js +10 -2
- package/http/index.d.ts +9 -14
- package/http/index.js +28 -53
- package/http/unauthed.d.ts +15 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +1 -2
- package/lang/lang/en.json +1 -2
- package/lib/archive.js +11 -10
- package/lib/cms/functions.d.ts +7 -1
- package/lib/cms/functions.js +22 -18
- package/lib/cms/handleFieldsJS.js +8 -7
- package/lib/cms/modules.js +4 -5
- package/lib/cms/processFieldsJs.js +8 -7
- package/lib/cms/templates.js +2 -3
- package/lib/cms/uploadFolder.js +16 -14
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.js +16 -9
- package/lib/customObjects.js +4 -15
- package/lib/fileManager.js +22 -21
- package/lib/fileMapper.js +24 -31
- package/lib/fs.js +2 -2
- package/lib/github.js +21 -21
- package/lib/gitignore.js +2 -2
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/lib/notify.js +2 -2
- package/lib/oauth.d.ts +1 -1
- package/lib/oauth.js +8 -17
- package/lib/personalAccessKey.js +16 -21
- package/lib/portManager.js +2 -2
- package/lib/trackUsage.js +3 -3
- package/models/FileSystemError.d.ts +6 -0
- package/models/FileSystemError.js +47 -0
- package/models/HubSpotHttpError.d.ts +24 -0
- package/models/HubSpotHttpError.js +197 -0
- package/models/OAuth2Manager.d.ts +1 -2
- package/models/OAuth2Manager.js +13 -28
- package/package.json +2 -1
- package/types/Error.d.ts +7 -5
- package/types/Files.d.ts +4 -4
- package/types/Http.d.ts +6 -10
- package/types/Sandbox.d.ts +0 -5
- package/utils/PortManagerServer.d.ts +3 -3
- package/utils/PortManagerServer.js +9 -9
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/errors/apiErrors.d.ts +0 -25
- package/errors/apiErrors.js +0 -176
- package/errors/fileSystemErrors.d.ts +0 -6
- package/errors/fileSystemErrors.js +0 -35
- package/errors/standardErrors.d.ts +0 -20
- package/errors/standardErrors.js +0 -62
- package/lib/developerTestAccounts.d.ts +0 -4
- package/lib/developerTestAccounts.js +0 -35
- package/lib/sandboxes.d.ts +0 -14
- package/lib/sandboxes.js +0 -70
- package/models/HubSpotAuthError.d.ts +0 -12
- package/models/HubSpotAuthError.js +0 -20
package/errors/apiErrors.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwApiUploadError = exports.throwApiError = exports.getAxiosErrorWithContext = exports.parseValidationErrors = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
4
|
-
const axios_1 = require("axios");
|
|
5
|
-
const api_1 = require("../constants/api");
|
|
6
|
-
const lang_1 = require("../utils/lang");
|
|
7
|
-
const standardErrors_1 = require("./standardErrors");
|
|
8
|
-
const HubSpotAuthError_1 = require("../models/HubSpotAuthError");
|
|
9
|
-
const i18nKey = 'errors.apiErrors';
|
|
10
|
-
function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
|
|
11
|
-
if (!(err instanceof Error)) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const error = (err && err.cause) || err;
|
|
16
|
-
const statusCodeErr = !statusCode || error.response?.status === statusCode;
|
|
17
|
-
const categoryErr = !category || error.response?.data?.category === category;
|
|
18
|
-
const subCategoryErr = !subCategory || error.response?.data?.subCategory === subCategory;
|
|
19
|
-
const errorTypeErr = !errorType || error.response?.data?.errorType === errorType;
|
|
20
|
-
const codeError = !code || error.code === code;
|
|
21
|
-
return (error.isAxiosError &&
|
|
22
|
-
statusCodeErr &&
|
|
23
|
-
categoryErr &&
|
|
24
|
-
subCategoryErr &&
|
|
25
|
-
errorTypeErr &&
|
|
26
|
-
codeError);
|
|
27
|
-
}
|
|
28
|
-
exports.isSpecifiedError = isSpecifiedError;
|
|
29
|
-
function isMissingScopeError(err) {
|
|
30
|
-
return isSpecifiedError(err, { statusCode: 403, category: 'MISSING_SCOPES' });
|
|
31
|
-
}
|
|
32
|
-
exports.isMissingScopeError = isMissingScopeError;
|
|
33
|
-
function isGatingError(err) {
|
|
34
|
-
return isSpecifiedError(err, { statusCode: 403, category: 'GATED' });
|
|
35
|
-
}
|
|
36
|
-
exports.isGatingError = isGatingError;
|
|
37
|
-
function isTimeoutError(err) {
|
|
38
|
-
return isSpecifiedError(err, { code: 'ETIMEDOUT' });
|
|
39
|
-
}
|
|
40
|
-
exports.isTimeoutError = isTimeoutError;
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
function isApiUploadValidationError(err) {
|
|
43
|
-
return ((0, axios_1.isAxiosError)(err) &&
|
|
44
|
-
(err.status === 400 || err.response?.status === 400) &&
|
|
45
|
-
!!err.response &&
|
|
46
|
-
!!(err.response?.data?.message || !!err.response?.data?.errors));
|
|
47
|
-
}
|
|
48
|
-
exports.isApiUploadValidationError = isApiUploadValidationError;
|
|
49
|
-
function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) {
|
|
50
|
-
if (!err || !(err instanceof HubSpotAuthError_1.HubSpotAuthError)) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
const statusCodeErr = !status || err.status === status;
|
|
54
|
-
const categoryErr = !category || err.category === category;
|
|
55
|
-
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
56
|
-
return Boolean(statusCodeErr && categoryErr && subCategoryErr);
|
|
57
|
-
}
|
|
58
|
-
exports.isSpecifiedHubSpotAuthError = isSpecifiedHubSpotAuthError;
|
|
59
|
-
function parseValidationErrors(responseData = { errors: [], message: '' }) {
|
|
60
|
-
const errorMessages = [];
|
|
61
|
-
const { errors, message } = responseData;
|
|
62
|
-
if (message) {
|
|
63
|
-
errorMessages.push(message);
|
|
64
|
-
}
|
|
65
|
-
if (errors) {
|
|
66
|
-
const specificErrors = errors.map(error => {
|
|
67
|
-
let errorMessage = error.message;
|
|
68
|
-
if (error.errorTokens && error.errorTokens.line) {
|
|
69
|
-
errorMessage = `line ${error.errorTokens.line}: ${errorMessage}`;
|
|
70
|
-
}
|
|
71
|
-
return errorMessage;
|
|
72
|
-
});
|
|
73
|
-
errorMessages.push(...specificErrors);
|
|
74
|
-
}
|
|
75
|
-
return errorMessages;
|
|
76
|
-
}
|
|
77
|
-
exports.parseValidationErrors = parseValidationErrors;
|
|
78
|
-
/**
|
|
79
|
-
* @throws
|
|
80
|
-
*/
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
-
function throwValidationError(error) {
|
|
83
|
-
const validationErrorMessages = parseValidationErrors(error?.response?.data);
|
|
84
|
-
if (validationErrorMessages.length) {
|
|
85
|
-
return new Error(validationErrorMessages.join(' '), { cause: error });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function getAxiosErrorWithContext(
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
error, context = {}) {
|
|
91
|
-
const status = error.response?.status;
|
|
92
|
-
const method = error.config?.method;
|
|
93
|
-
let messageDetail;
|
|
94
|
-
if (context.accountId) {
|
|
95
|
-
const action = (method && api_1.HTTP_METHOD_VERBS[method]) || api_1.HTTP_METHOD_VERBS.get;
|
|
96
|
-
const preposition = (method && api_1.HTTP_METHOD_PREPOSITIONS[method]) ||
|
|
97
|
-
api_1.HTTP_METHOD_PREPOSITIONS.get;
|
|
98
|
-
const requestName = context.request
|
|
99
|
-
? `${action} ${preposition} '${context.request}'`
|
|
100
|
-
: action;
|
|
101
|
-
messageDetail = (0, lang_1.i18n)(`${i18nKey}.messageDetail`, {
|
|
102
|
-
accountId: context.accountId,
|
|
103
|
-
requestName,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
messageDetail = (0, lang_1.i18n)(`${i18nKey}.genericMessageDetail`);
|
|
108
|
-
}
|
|
109
|
-
const errorMessage = [];
|
|
110
|
-
if ((method === 'put' || method === 'post') && context.payload) {
|
|
111
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.unableToUpload`, { payload: context.payload }));
|
|
112
|
-
}
|
|
113
|
-
switch (status) {
|
|
114
|
-
case 400:
|
|
115
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
|
|
116
|
-
break;
|
|
117
|
-
case 401:
|
|
118
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.401`, { messageDetail }));
|
|
119
|
-
break;
|
|
120
|
-
case 403:
|
|
121
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403`, { messageDetail }));
|
|
122
|
-
break;
|
|
123
|
-
case 404:
|
|
124
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404`, { messageDetail }));
|
|
125
|
-
break;
|
|
126
|
-
case 429:
|
|
127
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.429`, { messageDetail }));
|
|
128
|
-
break;
|
|
129
|
-
case 503:
|
|
130
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
|
|
131
|
-
break;
|
|
132
|
-
default:
|
|
133
|
-
if (status && status >= 500 && status < 600) {
|
|
134
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
|
|
135
|
-
}
|
|
136
|
-
else if (status && status >= 400 && status < 500) {
|
|
137
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.generic`, { messageDetail }));
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
if (error?.response?.data) {
|
|
145
|
-
const { message, errors } = error.response.data;
|
|
146
|
-
if (message) {
|
|
147
|
-
errorMessage.push(message);
|
|
148
|
-
}
|
|
149
|
-
if (errors) {
|
|
150
|
-
errors.forEach((err) => {
|
|
151
|
-
if (err.message) {
|
|
152
|
-
errorMessage.push('\n- ' + err.message);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return new Error(errorMessage.join(' '), { cause: error });
|
|
158
|
-
}
|
|
159
|
-
exports.getAxiosErrorWithContext = getAxiosErrorWithContext;
|
|
160
|
-
/**
|
|
161
|
-
* @throws
|
|
162
|
-
*/
|
|
163
|
-
function throwApiError(error, context = {}) {
|
|
164
|
-
if ((0, axios_1.isAxiosError)(error)) {
|
|
165
|
-
throw getAxiosErrorWithContext(error, context);
|
|
166
|
-
}
|
|
167
|
-
(0, standardErrors_1.throwError)(error);
|
|
168
|
-
}
|
|
169
|
-
exports.throwApiError = throwApiError;
|
|
170
|
-
function throwApiUploadError(error, context = {}) {
|
|
171
|
-
if (isApiUploadValidationError(error)) {
|
|
172
|
-
throwValidationError(error);
|
|
173
|
-
}
|
|
174
|
-
throwApiError(error, context);
|
|
175
|
-
}
|
|
176
|
-
exports.throwApiUploadError = throwApiUploadError;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FileSystemErrorContext } from '../types/Error';
|
|
2
|
-
export declare function getFileSystemError(error: unknown, context: FileSystemErrorContext): Error;
|
|
3
|
-
/**
|
|
4
|
-
* @throws
|
|
5
|
-
*/
|
|
6
|
-
export declare function throwFileSystemError(error: unknown, context: FileSystemErrorContext): void;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwFileSystemError = exports.getFileSystemError = void 0;
|
|
4
|
-
const lang_1 = require("../utils/lang");
|
|
5
|
-
const standardErrors_1 = require("./standardErrors");
|
|
6
|
-
const i18nKey = 'errors.fileSystemErrors';
|
|
7
|
-
function getFileSystemError(error, context) {
|
|
8
|
-
let fileAction = '';
|
|
9
|
-
if (context.read) {
|
|
10
|
-
fileAction = (0, lang_1.i18n)(`${i18nKey}.readAction`);
|
|
11
|
-
}
|
|
12
|
-
else if (context.write) {
|
|
13
|
-
fileAction = (0, lang_1.i18n)(`${i18nKey}.writeAction`);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
fileAction = (0, lang_1.i18n)(`${i18nKey}.otherAction`);
|
|
17
|
-
}
|
|
18
|
-
const filepath = context.filepath
|
|
19
|
-
? `"${context.filepath}"`
|
|
20
|
-
: (0, lang_1.i18n)(`${i18nKey}.unknownFilepath`);
|
|
21
|
-
const message = [(0, lang_1.i18n)(`${i18nKey}.baseMessage`, { fileAction, filepath })];
|
|
22
|
-
// Many `fs` errors will be `SystemError`s
|
|
23
|
-
if ((0, standardErrors_1.isSystemError)(error)) {
|
|
24
|
-
message.push((0, lang_1.i18n)(`${i18nKey}.baseMessage`, { errorMessage: error.message }));
|
|
25
|
-
}
|
|
26
|
-
return new Error(message.join(' '), { cause: error });
|
|
27
|
-
}
|
|
28
|
-
exports.getFileSystemError = getFileSystemError;
|
|
29
|
-
/**
|
|
30
|
-
* @throws
|
|
31
|
-
*/
|
|
32
|
-
function throwFileSystemError(error, context) {
|
|
33
|
-
throw getFileSystemError(error, context);
|
|
34
|
-
}
|
|
35
|
-
exports.throwFileSystemError = throwFileSystemError;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BaseError } from '../types/Error';
|
|
2
|
-
import { LangKey } from '../types/Lang';
|
|
3
|
-
export declare function isSystemError(err: unknown): err is BaseError;
|
|
4
|
-
export declare function isFatalError(err: unknown): err is BaseError;
|
|
5
|
-
/**
|
|
6
|
-
* @throws
|
|
7
|
-
*/
|
|
8
|
-
export declare function throwErrorWithMessage(identifier: LangKey, interpolation?: {
|
|
9
|
-
[key: string]: string | number;
|
|
10
|
-
}, cause?: unknown): never;
|
|
11
|
-
/**
|
|
12
|
-
* @throws
|
|
13
|
-
*/
|
|
14
|
-
export declare function throwAuthErrorWithMessage(identifier: LangKey, interpolation?: {
|
|
15
|
-
[key: string]: string | number;
|
|
16
|
-
}, cause?: unknown): never;
|
|
17
|
-
/**
|
|
18
|
-
* @throws
|
|
19
|
-
*/
|
|
20
|
-
export declare function throwError(error: unknown): never;
|
package/errors/standardErrors.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwError = exports.throwAuthErrorWithMessage = exports.throwErrorWithMessage = exports.isFatalError = exports.isSystemError = void 0;
|
|
4
|
-
const HubSpotAuthError_1 = require("../models/HubSpotAuthError");
|
|
5
|
-
const lang_1 = require("../utils/lang");
|
|
6
|
-
function isSystemError(err) {
|
|
7
|
-
return (err instanceof Error &&
|
|
8
|
-
'errno' in err &&
|
|
9
|
-
err.errno != null &&
|
|
10
|
-
'code' in err &&
|
|
11
|
-
err.code != null &&
|
|
12
|
-
'syscall' in err &&
|
|
13
|
-
err.syscall != null);
|
|
14
|
-
}
|
|
15
|
-
exports.isSystemError = isSystemError;
|
|
16
|
-
function isFatalError(err) {
|
|
17
|
-
return err instanceof HubSpotAuthError_1.HubSpotAuthError;
|
|
18
|
-
}
|
|
19
|
-
exports.isFatalError = isFatalError;
|
|
20
|
-
function genericThrowErrorWithMessage(ErrorType, identifier, interpolation, cause) {
|
|
21
|
-
const message = (0, lang_1.i18n)(identifier, interpolation);
|
|
22
|
-
if (cause) {
|
|
23
|
-
throw new ErrorType(message, { cause });
|
|
24
|
-
}
|
|
25
|
-
throw new ErrorType(message);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @throws
|
|
29
|
-
*/
|
|
30
|
-
function throwErrorWithMessage(identifier, interpolation, cause) {
|
|
31
|
-
genericThrowErrorWithMessage(Error, identifier, interpolation, cause);
|
|
32
|
-
}
|
|
33
|
-
exports.throwErrorWithMessage = throwErrorWithMessage;
|
|
34
|
-
/**
|
|
35
|
-
* @throws
|
|
36
|
-
*/
|
|
37
|
-
function throwAuthErrorWithMessage(identifier, interpolation, cause) {
|
|
38
|
-
genericThrowErrorWithMessage(
|
|
39
|
-
// @ts-expect-error HubSpotAuthError is not callable
|
|
40
|
-
HubSpotAuthError_1.HubSpotAuthError, identifier, interpolation, cause);
|
|
41
|
-
}
|
|
42
|
-
exports.throwAuthErrorWithMessage = throwAuthErrorWithMessage;
|
|
43
|
-
/**
|
|
44
|
-
* @throws
|
|
45
|
-
*/
|
|
46
|
-
function throwError(error) {
|
|
47
|
-
if (!(error instanceof Error)) {
|
|
48
|
-
throw new Error('', { cause: error });
|
|
49
|
-
}
|
|
50
|
-
// Error or Error subclass
|
|
51
|
-
const message = error.name && error.name !== 'Error'
|
|
52
|
-
? [(0, lang_1.i18n)('errors.generic', { name: error.name })]
|
|
53
|
-
: [];
|
|
54
|
-
if (error.message) {
|
|
55
|
-
message.push(error.message);
|
|
56
|
-
}
|
|
57
|
-
if ('reason' in error && error.reason) {
|
|
58
|
-
message.push(error.reason);
|
|
59
|
-
}
|
|
60
|
-
throw new Error(message.join(' '), { cause: error });
|
|
61
|
-
}
|
|
62
|
-
exports.throwError = throwError;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { DeveloperTestAccount, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
|
|
2
|
-
export declare function createDeveloperTestAccount(accountId: number, accountName: string): Promise<DeveloperTestAccount>;
|
|
3
|
-
export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): Promise<void>;
|
|
4
|
-
export declare function fetchDeveloperTestAccounts(accountId: number): Promise<FetchDeveloperTestAccountsResponse>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchDeveloperTestAccounts = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = void 0;
|
|
4
|
-
const developerTestAccounts_1 = require("../api/developerTestAccounts");
|
|
5
|
-
const apiErrors_1 = require("../errors/apiErrors");
|
|
6
|
-
async function createDeveloperTestAccount(accountId, accountName) {
|
|
7
|
-
try {
|
|
8
|
-
const resp = await (0, developerTestAccounts_1.createDeveloperTestAccount)(accountId, accountName);
|
|
9
|
-
return resp;
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.createDeveloperTestAccount = createDeveloperTestAccount;
|
|
16
|
-
async function deleteDeveloperTestAccount(accountId, testAccountId) {
|
|
17
|
-
try {
|
|
18
|
-
const resp = await (0, developerTestAccounts_1.deleteDeveloperTestAccount)(accountId, testAccountId);
|
|
19
|
-
return resp;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
|
|
26
|
-
async function fetchDeveloperTestAccounts(accountId) {
|
|
27
|
-
try {
|
|
28
|
-
const resp = await (0, developerTestAccounts_1.fetchDeveloperTestAccounts)(accountId);
|
|
29
|
-
return resp;
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
|
package/lib/sandboxes.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { InitiateSyncResponse, Sandbox, SandboxType, SyncTaskStatusType, TaskRequestData, Usage } from '../types/Sandbox';
|
|
2
|
-
export declare function createSandbox(accountId: number, name: string, type: 1 | 2): Promise<{
|
|
3
|
-
name: string;
|
|
4
|
-
sandbox: Sandbox;
|
|
5
|
-
personalAccessKey: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): Promise<{
|
|
8
|
-
parentAccountId: number;
|
|
9
|
-
sandboxAccountId: number;
|
|
10
|
-
}>;
|
|
11
|
-
export declare function getSandboxUsageLimits(parentAccountId: number): Promise<Usage | void>;
|
|
12
|
-
export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): Promise<InitiateSyncResponse>;
|
|
13
|
-
export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<SyncTaskStatusType>;
|
|
14
|
-
export declare function fetchTypes(accountId: number, toHubId: number): Promise<Array<SandboxType> | void>;
|
package/lib/sandboxes.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchTypes = exports.fetchTaskStatus = exports.initiateSync = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
|
|
4
|
-
const sandboxHubs_1 = require("../api/sandboxHubs");
|
|
5
|
-
const sandboxSync_1 = require("../api/sandboxSync");
|
|
6
|
-
const apiErrors_1 = require("../errors/apiErrors");
|
|
7
|
-
async function createSandbox(accountId, name, type) {
|
|
8
|
-
try {
|
|
9
|
-
const resp = await (0, sandboxHubs_1.createSandbox)(accountId, name, type);
|
|
10
|
-
return {
|
|
11
|
-
name,
|
|
12
|
-
...resp,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.createSandbox = createSandbox;
|
|
20
|
-
async function deleteSandbox(parentAccountId, sandboxAccountId) {
|
|
21
|
-
try {
|
|
22
|
-
await (0, sandboxHubs_1.deleteSandbox)(parentAccountId, sandboxAccountId);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
parentAccountId,
|
|
29
|
-
sandboxAccountId,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.deleteSandbox = deleteSandbox;
|
|
33
|
-
async function getSandboxUsageLimits(parentAccountId) {
|
|
34
|
-
try {
|
|
35
|
-
const resp = await (0, sandboxHubs_1.getSandboxUsageLimits)(parentAccountId);
|
|
36
|
-
return resp && resp.usage;
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.getSandboxUsageLimits = getSandboxUsageLimits;
|
|
43
|
-
async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
44
|
-
try {
|
|
45
|
-
return await (0, sandboxSync_1.initiateSync)(fromHubId, toHubId, tasks, sandboxHubId);
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.initiateSync = initiateSync;
|
|
52
|
-
async function fetchTaskStatus(accountId, taskId) {
|
|
53
|
-
try {
|
|
54
|
-
return await (0, sandboxSync_1.fetchTaskStatus)(accountId, taskId);
|
|
55
|
-
}
|
|
56
|
-
catch (err) {
|
|
57
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.fetchTaskStatus = fetchTaskStatus;
|
|
61
|
-
async function fetchTypes(accountId, toHubId) {
|
|
62
|
-
try {
|
|
63
|
-
const resp = await (0, sandboxSync_1.fetchTypes)(accountId, toHubId);
|
|
64
|
-
return resp && resp.results;
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
(0, apiErrors_1.throwApiError)(err);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.fetchTypes = fetchTypes;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AxiosError } from 'axios';
|
|
2
|
-
export declare class HubSpotAuthError extends Error {
|
|
3
|
-
status?: number;
|
|
4
|
-
category?: string;
|
|
5
|
-
subCategory?: string;
|
|
6
|
-
constructor(message: string, { cause, }: {
|
|
7
|
-
cause?: Partial<AxiosError<{
|
|
8
|
-
category?: string;
|
|
9
|
-
subCategory?: string;
|
|
10
|
-
}>>;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HubSpotAuthError = void 0;
|
|
4
|
-
class HubSpotAuthError extends Error {
|
|
5
|
-
status;
|
|
6
|
-
category;
|
|
7
|
-
subCategory;
|
|
8
|
-
constructor(message, { cause = {}, }) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = 'HubSpotAuthError';
|
|
11
|
-
this.status = cause.response?.status;
|
|
12
|
-
this.category = cause?.response?.data?.category || undefined;
|
|
13
|
-
this.subCategory =
|
|
14
|
-
(cause.response &&
|
|
15
|
-
cause.response.data &&
|
|
16
|
-
cause.response.data.subCategory) ||
|
|
17
|
-
undefined;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.HubSpotAuthError = HubSpotAuthError;
|