@hubspot/local-dev-lib 0.0.7 → 0.0.8
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/customObjects.js +3 -3
- package/api/functions.js +1 -1
- package/api/hubdb.js +4 -4
- package/api/lighthouseScore.d.ts +2 -2
- package/api/lighthouseScore.js +2 -2
- package/api/localDevAuth.d.ts +5 -1
- package/api/localDevAuth.js +1 -1
- package/api/marketplaceValidation.d.ts +2 -2
- package/api/marketplaceValidation.js +2 -2
- package/api/projects.js +2 -2
- package/api/sandboxHubs.js +1 -1
- package/api/sandboxSync.js +1 -1
- package/api/secrets.js +2 -2
- package/api/validateHubl.js +1 -1
- package/config/config_DEPRECATED.js +3 -1
- package/errors/apiErrors.d.ts +1 -1
- package/errors/apiErrors.js +12 -12
- package/errors/errors_DEPRECATED.js +2 -2
- package/http/index.js +1 -0
- package/lib/fileMapper.js +1 -1
- package/lib/hubdb.d.ts +1 -1
- package/lib/hubdb.js +1 -1
- package/lib/personalAccessKey.d.ts +1 -1
- package/lib/personalAccessKey.js +3 -3
- package/lib/trackUsage.js +2 -2
- package/models/HubSpotAuthError.d.ts +1 -1
- package/models/HubSpotAuthError.js +2 -2
- package/models/OAuth2Manager.d.ts +1 -1
- package/models/OAuth2Manager.js +3 -3
- package/package.json +2 -2
- package/types/Error.d.ts +3 -3
- package/types/Http.d.ts +8 -11
- package/types/Hubdb.d.ts +27 -17
package/api/customObjects.js
CHANGED
|
@@ -10,21 +10,21 @@ const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
|
|
|
10
10
|
async function batchCreateObjects(accountId, objectTypeId, objects) {
|
|
11
11
|
http_1.default.post(accountId, {
|
|
12
12
|
url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
|
|
13
|
-
|
|
13
|
+
data: objects,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
exports.batchCreateObjects = batchCreateObjects;
|
|
17
17
|
async function createObjectSchema(accountId, schema) {
|
|
18
18
|
return http_1.default.post(accountId, {
|
|
19
19
|
url: SCHEMA_API_PATH,
|
|
20
|
-
|
|
20
|
+
data: schema,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.createObjectSchema = createObjectSchema;
|
|
24
24
|
async function updateObjectSchema(accountId, schemaObjectType, schema) {
|
|
25
25
|
return http_1.default.patch(accountId, {
|
|
26
26
|
url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
|
|
27
|
-
|
|
27
|
+
data: schema,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
exports.updateObjectSchema = updateObjectSchema;
|
package/api/functions.js
CHANGED
package/api/hubdb.js
CHANGED
|
@@ -15,14 +15,14 @@ exports.fetchTable = fetchTable;
|
|
|
15
15
|
async function createTable(accountId, schema) {
|
|
16
16
|
return http_1.default.post(accountId, {
|
|
17
17
|
url: `${HUBDB_API_PATH}/tables`,
|
|
18
|
-
|
|
18
|
+
data: schema,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
exports.createTable = createTable;
|
|
22
22
|
async function updateTable(accountId, tableId, schema) {
|
|
23
23
|
return http_1.default.patch(accountId, {
|
|
24
24
|
url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
|
|
25
|
-
|
|
25
|
+
data: schema,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
exports.updateTable = updateTable;
|
|
@@ -41,7 +41,7 @@ exports.deleteTable = deleteTable;
|
|
|
41
41
|
async function createRows(accountId, tableId, rows) {
|
|
42
42
|
return http_1.default.post(accountId, {
|
|
43
43
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
|
|
44
|
-
|
|
44
|
+
data: { inputs: rows },
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
exports.createRows = createRows;
|
|
@@ -55,7 +55,7 @@ exports.fetchRows = fetchRows;
|
|
|
55
55
|
async function deleteRows(accountId, tableId, rowIds) {
|
|
56
56
|
return http_1.default.post(accountId, {
|
|
57
57
|
url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
|
|
58
|
-
|
|
58
|
+
data: { inputs: rowIds },
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
exports.deleteRows = deleteRows;
|
package/api/lighthouseScore.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Data, QueryParams } from '../types/Http';
|
|
2
2
|
import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
|
|
3
|
-
export declare function requestLighthouseScore(accountId: number,
|
|
3
|
+
export declare function requestLighthouseScore(accountId: number, data?: Data): Promise<RequestLighthouseScoreResponse>;
|
|
4
4
|
export declare function getLighthouseScoreStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
5
|
export declare function getLighthouseScore(accountId: number, query?: QueryParams): Promise<GetLighthouseScoreResponse>;
|
package/api/lighthouseScore.js
CHANGED
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../http"));
|
|
8
8
|
const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
|
|
9
|
-
async function requestLighthouseScore(accountId,
|
|
9
|
+
async function requestLighthouseScore(accountId, data = {}) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
|
|
12
|
-
|
|
12
|
+
data,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.requestLighthouseScore = requestLighthouseScore;
|
package/api/localDevAuth.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { Environment } from '../types/Config';
|
|
|
2
2
|
import { ScopeData } from '../types/Accounts';
|
|
3
3
|
type AccessTokenResponse = {
|
|
4
4
|
hubId: number;
|
|
5
|
+
userId: number;
|
|
5
6
|
oauthAccessToken: string;
|
|
6
7
|
expiresAtMillis: number;
|
|
8
|
+
enabledFeatures?: {
|
|
9
|
+
[key: string]: number;
|
|
10
|
+
};
|
|
7
11
|
scopeGroups: Array<string>;
|
|
8
|
-
|
|
12
|
+
encodedOAuthRefreshToken: string;
|
|
9
13
|
};
|
|
10
14
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
11
15
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
package/api/localDevAuth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Data, QueryParams } from '../types/Http';
|
|
2
2
|
import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
|
|
3
|
-
export declare function requestValidation(accountId: number,
|
|
3
|
+
export declare function requestValidation(accountId: number, data?: Data): Promise<number>;
|
|
4
4
|
export declare function getValidationStatus(accountId: number, query?: QueryParams): Promise<string>;
|
|
5
5
|
export declare function getValidationResults(accountId: number, query?: QueryParams): Promise<GetValidationResultsResponse>;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getValidationResults = exports.getValidationStatus = exports.requestValidation = void 0;
|
|
7
7
|
const http_1 = __importDefault(require("../http"));
|
|
8
8
|
const VALIDATION_API_BASE = 'quality-engine/v1/validation';
|
|
9
|
-
function requestValidation(accountId,
|
|
9
|
+
function requestValidation(accountId, data = {}) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: `${VALIDATION_API_BASE}/request`,
|
|
12
|
-
|
|
12
|
+
data,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.requestValidation = requestValidation;
|
package/api/projects.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.fetchProjects = fetchProjects;
|
|
|
18
18
|
async function createProject(accountId, name) {
|
|
19
19
|
return http_1.default.post(accountId, {
|
|
20
20
|
url: PROJECTS_API_PATH,
|
|
21
|
-
|
|
21
|
+
data: {
|
|
22
22
|
name,
|
|
23
23
|
},
|
|
24
24
|
});
|
|
@@ -87,7 +87,7 @@ exports.getBuildStructure = getBuildStructure;
|
|
|
87
87
|
async function deployProject(accountId, projectName, buildId) {
|
|
88
88
|
return http_1.default.post(accountId, {
|
|
89
89
|
url: `${PROJECTS_DEPLOY_API_PATH}/deploys/queue/async`,
|
|
90
|
-
|
|
90
|
+
data: {
|
|
91
91
|
projectName,
|
|
92
92
|
buildId,
|
|
93
93
|
},
|
package/api/sandboxHubs.js
CHANGED
|
@@ -13,7 +13,7 @@ const SANDBOX_API_PATH = 'sandbox-hubs/v1';
|
|
|
13
13
|
const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
|
|
14
14
|
async function createSandbox(accountId, name, type) {
|
|
15
15
|
return http_1.default.post(accountId, {
|
|
16
|
-
|
|
16
|
+
data: { name, type, generatePersonalAccessKey: true },
|
|
17
17
|
timeout: api_1.SANDBOX_TIMEOUT,
|
|
18
18
|
url: SANDBOX_API_PATH_V2, // Create uses v2 for sandbox type and PAK generation support
|
|
19
19
|
});
|
package/api/sandboxSync.js
CHANGED
|
@@ -9,7 +9,7 @@ const api_1 = require("../constants/api");
|
|
|
9
9
|
const SANDBOXES_SYNC_API_PATH = 'sandboxes-sync/v1';
|
|
10
10
|
async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
11
11
|
return http_1.default.post(fromHubId, {
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
command: 'SYNC',
|
|
14
14
|
fromHubId,
|
|
15
15
|
toHubId,
|
package/api/secrets.js
CHANGED
|
@@ -9,7 +9,7 @@ const SECRETS_API_PATH = 'cms/v3/functions/secrets';
|
|
|
9
9
|
async function addSecret(accountId, key, value) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: SECRETS_API_PATH,
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
key,
|
|
14
14
|
secret: value,
|
|
15
15
|
},
|
|
@@ -19,7 +19,7 @@ exports.addSecret = addSecret;
|
|
|
19
19
|
async function updateSecret(accountId, key, value) {
|
|
20
20
|
return http_1.default.put(accountId, {
|
|
21
21
|
url: SECRETS_API_PATH,
|
|
22
|
-
|
|
22
|
+
data: {
|
|
23
23
|
key,
|
|
24
24
|
secret: value,
|
|
25
25
|
},
|
package/api/validateHubl.js
CHANGED
|
@@ -9,7 +9,7 @@ const HUBL_VALIDATE_API_PATH = 'cos-rendering/v1/internal/validate';
|
|
|
9
9
|
async function validateHubl(accountId, sourceCode, hublValidationOptions) {
|
|
10
10
|
return http_1.default.post(accountId, {
|
|
11
11
|
url: HUBL_VALIDATE_API_PATH,
|
|
12
|
-
|
|
12
|
+
data: {
|
|
13
13
|
template_source: sourceCode,
|
|
14
14
|
...hublValidationOptions,
|
|
15
15
|
},
|
|
@@ -377,7 +377,9 @@ function updateAccountConfig(configOptions) {
|
|
|
377
377
|
tokenInfo,
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
const env = (0, environment_1.getValidEnv)(environment ||
|
|
380
|
+
const env = (0, environment_1.getValidEnv)(environment ||
|
|
381
|
+
(configOptions && configOptions.env) ||
|
|
382
|
+
(accountConfig && accountConfig.env));
|
|
381
383
|
const mode = defaultMode && defaultMode.toLowerCase();
|
|
382
384
|
const nextAccountConfig = {
|
|
383
385
|
...accountConfig,
|
package/errors/apiErrors.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function isApiStatusCodeError(err: GenericError): boolean;
|
|
|
4
4
|
export declare function isMissingScopeError(err: GenericError): boolean;
|
|
5
5
|
export declare function isGatingError(err: GenericError): boolean;
|
|
6
6
|
export declare function isApiUploadValidationError(err: GenericError): boolean;
|
|
7
|
-
export declare function isSpecifiedHubSpotAuthError(err: GenericError, {
|
|
7
|
+
export declare function isSpecifiedHubSpotAuthError(err: GenericError, { status, category, subCategory }: Partial<HubSpotAuthError>): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* @throws
|
|
10
10
|
*/
|
package/errors/apiErrors.js
CHANGED
|
@@ -6,33 +6,33 @@ const lang_1 = require("../utils/lang");
|
|
|
6
6
|
const standardErrors_1 = require("./standardErrors");
|
|
7
7
|
function isApiStatusCodeError(err) {
|
|
8
8
|
return (err.name === 'StatusCodeError' ||
|
|
9
|
-
(!!err.
|
|
9
|
+
(!!err.status && err.status >= 100 && err.status < 600));
|
|
10
10
|
}
|
|
11
11
|
exports.isApiStatusCodeError = isApiStatusCodeError;
|
|
12
12
|
function isMissingScopeError(err) {
|
|
13
13
|
return (isApiStatusCodeError(err) &&
|
|
14
|
-
err.
|
|
14
|
+
err.status === 403 &&
|
|
15
15
|
!!err.error &&
|
|
16
16
|
err.error.category === 'MISSING_SCOPES');
|
|
17
17
|
}
|
|
18
18
|
exports.isMissingScopeError = isMissingScopeError;
|
|
19
19
|
function isGatingError(err) {
|
|
20
20
|
return (isApiStatusCodeError(err) &&
|
|
21
|
-
err.
|
|
21
|
+
err.status === 403 &&
|
|
22
22
|
!!err.error &&
|
|
23
23
|
err.error.category === 'GATED');
|
|
24
24
|
}
|
|
25
25
|
exports.isGatingError = isGatingError;
|
|
26
26
|
function isApiUploadValidationError(err) {
|
|
27
27
|
return (isApiStatusCodeError(err) &&
|
|
28
|
-
err.
|
|
28
|
+
err.status === 400 &&
|
|
29
29
|
!!err.response &&
|
|
30
30
|
!!err.response.body &&
|
|
31
31
|
!!(err.response.body.message || !!err.response.body.errors));
|
|
32
32
|
}
|
|
33
33
|
exports.isApiUploadValidationError = isApiUploadValidationError;
|
|
34
|
-
function isSpecifiedHubSpotAuthError(err, {
|
|
35
|
-
const statusCodeErr = !
|
|
34
|
+
function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) {
|
|
35
|
+
const statusCodeErr = !status || err.status === status;
|
|
36
36
|
const categoryErr = !category || err.category === category;
|
|
37
37
|
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
38
38
|
return Boolean(err.name === 'HubSpotAuthError' &&
|
|
@@ -70,9 +70,9 @@ function logValidationErrors(error) {
|
|
|
70
70
|
* @throws
|
|
71
71
|
*/
|
|
72
72
|
function throwStatusCodeError(error, context = {}) {
|
|
73
|
-
const {
|
|
73
|
+
const { status, message, response } = error;
|
|
74
74
|
const errorData = JSON.stringify({
|
|
75
|
-
|
|
75
|
+
status,
|
|
76
76
|
message,
|
|
77
77
|
url: response ? response.request.href : null,
|
|
78
78
|
method: response ? response.request.method : null,
|
|
@@ -88,7 +88,7 @@ exports.throwStatusCodeError = throwStatusCodeError;
|
|
|
88
88
|
*/
|
|
89
89
|
function throwApiStatusCodeError(error, context = {}) {
|
|
90
90
|
const i18nKey = 'errors.errorTypes.api';
|
|
91
|
-
const {
|
|
91
|
+
const { status } = error;
|
|
92
92
|
const { method } = error.options || {};
|
|
93
93
|
const { projectName } = context;
|
|
94
94
|
const isPutOrPost = method === 'PUT' || method === 'POST';
|
|
@@ -110,7 +110,7 @@ function throwApiStatusCodeError(error, context = {}) {
|
|
|
110
110
|
}
|
|
111
111
|
const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
|
|
112
112
|
const isProjectGatingError = isGatingError(error) && projectName;
|
|
113
|
-
switch (
|
|
113
|
+
switch (status) {
|
|
114
114
|
case 400:
|
|
115
115
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
|
|
116
116
|
break;
|
|
@@ -151,10 +151,10 @@ function throwApiStatusCodeError(error, context = {}) {
|
|
|
151
151
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
|
|
152
152
|
break;
|
|
153
153
|
default:
|
|
154
|
-
if (
|
|
154
|
+
if (status && status >= 500 && status < 600) {
|
|
155
155
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
|
|
156
156
|
}
|
|
157
|
-
else if (
|
|
157
|
+
else if (status && status >= 400 && status < 500) {
|
|
158
158
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
|
|
159
159
|
}
|
|
160
160
|
else {
|
|
@@ -6,9 +6,9 @@ function isSystemError(err) {
|
|
|
6
6
|
}
|
|
7
7
|
function debugErrorAndContext(error, context) {
|
|
8
8
|
if (error.name === 'StatusCodeError') {
|
|
9
|
-
const {
|
|
9
|
+
const { status, message, response } = error;
|
|
10
10
|
console.debug('Error: %o', {
|
|
11
|
-
|
|
11
|
+
status,
|
|
12
12
|
message,
|
|
13
13
|
url: response.request.href,
|
|
14
14
|
method: response.request.method,
|
package/http/index.js
CHANGED
package/lib/fileMapper.js
CHANGED
|
@@ -197,7 +197,7 @@ async function writeFileMapperNode(accountId, filepath, node, mode, options = {}
|
|
|
197
197
|
return true;
|
|
198
198
|
}
|
|
199
199
|
function isTimeout(err) {
|
|
200
|
-
return !!err && (err.
|
|
200
|
+
return !!err && (err.status === 408 || err.code === 'ESOCKETTIMEDOUT');
|
|
201
201
|
}
|
|
202
202
|
async function downloadFile(accountId, src, destPath, mode, options = {}, logCallbacks) {
|
|
203
203
|
const logger = (0, logger_1.makeTypedLogger)(logCallbacks, 'filemapper');
|
package/lib/hubdb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Row } from '../types/Hubdb';
|
|
2
|
-
export declare function addRowsToHubDbTable(accountId: number, tableId: string, rows
|
|
2
|
+
export declare function addRowsToHubDbTable(accountId: number, tableId: string, rows?: Array<Row>): Promise<{
|
|
3
3
|
tableId: string;
|
|
4
4
|
rowCount: number;
|
|
5
5
|
}>;
|
package/lib/hubdb.js
CHANGED
|
@@ -28,7 +28,7 @@ function validateJsonFile(src) {
|
|
|
28
28
|
}
|
|
29
29
|
validateJsonPath(src);
|
|
30
30
|
}
|
|
31
|
-
async function addRowsToHubDbTable(accountId, tableId, rows) {
|
|
31
|
+
async function addRowsToHubDbTable(accountId, tableId, rows = []) {
|
|
32
32
|
const rowsToUpdate = rows.map(row => {
|
|
33
33
|
const values = row.values;
|
|
34
34
|
return {
|
|
@@ -5,7 +5,7 @@ type AccessToken = {
|
|
|
5
5
|
accessToken: string;
|
|
6
6
|
expiresAt: string;
|
|
7
7
|
scopeGroups: Array<string>;
|
|
8
|
-
|
|
8
|
+
encodedOAuthRefreshToken: string;
|
|
9
9
|
};
|
|
10
10
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
11
11
|
export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
|
package/lib/personalAccessKey.js
CHANGED
|
@@ -22,7 +22,7 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
22
22
|
}
|
|
23
23
|
catch (e) {
|
|
24
24
|
const error = e;
|
|
25
|
-
if (error.response) {
|
|
25
|
+
if (error.response && error.response.body) {
|
|
26
26
|
(0, standardErrors_1.throwAuthErrorWithMessage)('personalAccessKey.invalidPersonalAccessKey', { errorMessage: error.response.body.message || '' }, error);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
@@ -34,7 +34,7 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
34
34
|
accessToken: response.oauthAccessToken,
|
|
35
35
|
expiresAt: (0, moment_1.default)(response.expiresAtMillis).toISOString(),
|
|
36
36
|
scopeGroups: response.scopeGroups,
|
|
37
|
-
|
|
37
|
+
encodedOAuthRefreshToken: response.encodedOAuthRefreshToken,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
exports.getAccessToken = getAccessToken;
|
|
@@ -89,7 +89,7 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
89
89
|
return auth?.tokenInfo?.accessToken;
|
|
90
90
|
}
|
|
91
91
|
exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
|
|
92
|
-
// Adds
|
|
92
|
+
// Adds an account to the config using authType: personalAccessKey
|
|
93
93
|
const updateConfigWithPersonalAccessKey = async (personalAccessKey, name, env, makeDefault = false) => {
|
|
94
94
|
const accountEnv = env || (0, config_1.getEnv)(name);
|
|
95
95
|
let token;
|
package/lib/trackUsage.js
CHANGED
|
@@ -37,7 +37,7 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
37
37
|
(0, logger_1.debug)(`${i18nKey}.sendingEventAuthenticated`);
|
|
38
38
|
return http_1.default.post(accountId, {
|
|
39
39
|
url: `${path}/authenticated`,
|
|
40
|
-
|
|
40
|
+
data: usageEvent,
|
|
41
41
|
resolveWithFullResponse: true,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -46,7 +46,7 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
46
46
|
http_1.default.post(accountId, {
|
|
47
47
|
env,
|
|
48
48
|
url: path,
|
|
49
|
-
|
|
49
|
+
data: usageEvent,
|
|
50
50
|
resolveWithFullResponse: true,
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HubSpotAuthError = void 0;
|
|
4
4
|
class HubSpotAuthError extends Error {
|
|
5
|
-
|
|
5
|
+
status;
|
|
6
6
|
category;
|
|
7
7
|
subCategory;
|
|
8
8
|
constructor(message, { cause = {} }) {
|
|
9
9
|
super(message);
|
|
10
10
|
this.name = 'HubSpotAuthError';
|
|
11
|
-
this.
|
|
11
|
+
this.status = cause.status;
|
|
12
12
|
this.category = cause?.response?.body?.category || undefined;
|
|
13
13
|
this.subCategory =
|
|
14
14
|
(cause.response &&
|
|
@@ -21,7 +21,7 @@ declare class OAuth2Manager {
|
|
|
21
21
|
exchangeForTokens(exchangeProof: ExchangeProof): Promise<void>;
|
|
22
22
|
refreshAccessToken(): Promise<void>;
|
|
23
23
|
toObj(): {
|
|
24
|
-
|
|
24
|
+
env: import("../types/Config").Environment;
|
|
25
25
|
clientSecret: string | undefined;
|
|
26
26
|
clientId: string | undefined;
|
|
27
27
|
scopes: string[] | undefined;
|
package/models/OAuth2Manager.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
|
-
const environments_1 = require("../constants/environments");
|
|
9
8
|
const urls_1 = require("../lib/urls");
|
|
10
9
|
const environment_1 = require("../lib/environment");
|
|
11
10
|
const logger_1 = require("../utils/logger");
|
|
@@ -18,9 +17,10 @@ class OAuth2Manager {
|
|
|
18
17
|
writeTokenInfo;
|
|
19
18
|
refreshTokenRequest;
|
|
20
19
|
constructor(account, writeTokenInfo) {
|
|
21
|
-
this.account = account;
|
|
22
20
|
this.writeTokenInfo = writeTokenInfo;
|
|
23
21
|
this.refreshTokenRequest = null;
|
|
22
|
+
this.account = account;
|
|
23
|
+
// NOTE: Potential issues by not using maskProductionValue = '' for env like in cli-lib
|
|
24
24
|
}
|
|
25
25
|
async accessToken() {
|
|
26
26
|
if (!this.account.auth.tokenInfo?.refreshToken) {
|
|
@@ -106,7 +106,7 @@ class OAuth2Manager {
|
|
|
106
106
|
}
|
|
107
107
|
toObj() {
|
|
108
108
|
return {
|
|
109
|
-
|
|
109
|
+
env: this.account.env,
|
|
110
110
|
clientSecret: this.account.auth.clientSecret,
|
|
111
111
|
clientId: this.account.auth.clientId,
|
|
112
112
|
scopes: this.account.auth.scopes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"release:major": "yarn check-main && yarn version --major && yarn build && yarn pub && yarn push",
|
|
25
25
|
"release:minor": "yarn check-main && yarn version --minor && yarn build && yarn pub && yarn push",
|
|
26
26
|
"release:patch": "yarn check-main && yarn version --patch && yarn build && yarn pub && yarn push",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "node --experimental-vm-modules ./node_modules/.bin/jest"
|
|
28
28
|
},
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
package/types/Error.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ export interface BaseError extends Error {
|
|
|
9
9
|
code?: string | null;
|
|
10
10
|
syscall?: string | null;
|
|
11
11
|
reason?: string;
|
|
12
|
-
|
|
12
|
+
status?: number;
|
|
13
13
|
error?: BaseError;
|
|
14
14
|
errors?: Array<BaseError>;
|
|
15
15
|
}
|
|
16
16
|
export interface StatusCodeError extends BaseError {
|
|
17
17
|
name: string;
|
|
18
|
-
|
|
18
|
+
status?: number;
|
|
19
19
|
message: string;
|
|
20
20
|
category?: string;
|
|
21
21
|
subCategory?: string;
|
|
@@ -33,7 +33,7 @@ export interface StatusCodeError extends BaseError {
|
|
|
33
33
|
headers: {
|
|
34
34
|
[key: string]: string;
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
status: number;
|
|
37
37
|
};
|
|
38
38
|
options?: {
|
|
39
39
|
method: HttpMethod;
|
package/types/Http.d.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ReadStream } from 'fs';
|
|
3
|
-
export type
|
|
3
|
+
export type Data = {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
};
|
|
6
|
+
export type QueryParams = {
|
|
7
|
+
[key: string]: string | number | boolean | undefined;
|
|
8
|
+
};
|
|
6
9
|
export type AxiosConfigOptions = {
|
|
10
|
+
baseURL?: string;
|
|
7
11
|
url: string;
|
|
8
12
|
env?: string;
|
|
9
13
|
localHostOverride?: boolean;
|
|
10
|
-
params?:
|
|
11
|
-
|
|
12
|
-
buffer?: boolean;
|
|
13
|
-
environmentId?: number;
|
|
14
|
-
version?: string;
|
|
15
|
-
};
|
|
16
|
-
body?: Body | JSON;
|
|
14
|
+
params?: QueryParams;
|
|
15
|
+
data?: Data;
|
|
17
16
|
resolveWithFullResponse?: boolean;
|
|
18
|
-
|
|
19
|
-
export type QueryParams = {
|
|
20
|
-
[key: string]: string | number | boolean;
|
|
17
|
+
timeout?: number;
|
|
21
18
|
};
|
|
22
19
|
export type FormData = {
|
|
23
20
|
[key: string]: string | ReadStream;
|
package/types/Hubdb.d.ts
CHANGED
|
@@ -10,22 +10,25 @@ export type Schema = {
|
|
|
10
10
|
export type Table = {
|
|
11
11
|
id: string;
|
|
12
12
|
name: string;
|
|
13
|
-
portalId
|
|
13
|
+
portalId?: number;
|
|
14
14
|
createdAt: string;
|
|
15
15
|
publishedAt: string;
|
|
16
16
|
updatedAt: string;
|
|
17
17
|
label: string;
|
|
18
18
|
columns: Array<Column>;
|
|
19
|
-
rows
|
|
20
|
-
partitioningSettings?:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
rows?: Array<Row>;
|
|
20
|
+
partitioningSettings?: {
|
|
21
|
+
teamIds: Array<any>;
|
|
22
|
+
userIds: Array<any>;
|
|
23
|
+
};
|
|
24
|
+
published?: boolean;
|
|
25
|
+
cosObjectType?: string;
|
|
26
|
+
updated?: number;
|
|
24
27
|
archived: boolean;
|
|
25
|
-
columnCount
|
|
26
|
-
cdnPurgeEmbargoTime
|
|
28
|
+
columnCount?: number;
|
|
29
|
+
cdnPurgeEmbargoTime?: number | null;
|
|
27
30
|
rowCount: number;
|
|
28
|
-
createdBy
|
|
31
|
+
createdBy?: {
|
|
29
32
|
id: string;
|
|
30
33
|
email: string;
|
|
31
34
|
firstName: string;
|
|
@@ -34,15 +37,17 @@ export type Table = {
|
|
|
34
37
|
useForPages: boolean;
|
|
35
38
|
allowChildTables: boolean;
|
|
36
39
|
enableChildTablePages: boolean;
|
|
37
|
-
crmObjectTypeId
|
|
38
|
-
dynamicMetaTags?:
|
|
40
|
+
crmObjectTypeId?: number;
|
|
41
|
+
dynamicMetaTags?: {
|
|
42
|
+
[key: string]: number;
|
|
43
|
+
};
|
|
39
44
|
allowPublicApiAccess: boolean;
|
|
40
45
|
};
|
|
41
46
|
export type Column = {
|
|
42
47
|
name: string;
|
|
43
48
|
label: string;
|
|
44
|
-
id
|
|
45
|
-
archived
|
|
49
|
+
id?: string;
|
|
50
|
+
archived?: boolean;
|
|
46
51
|
type: string;
|
|
47
52
|
deleted?: boolean;
|
|
48
53
|
foreignIdsByName?: {
|
|
@@ -66,7 +71,9 @@ export type Row = {
|
|
|
66
71
|
updatedAt: string;
|
|
67
72
|
publishedAt: string | null;
|
|
68
73
|
values: {
|
|
69
|
-
text_column
|
|
74
|
+
text_column?: string;
|
|
75
|
+
number_column?: number;
|
|
76
|
+
multiselect?: Array<any>;
|
|
70
77
|
};
|
|
71
78
|
path: string | null;
|
|
72
79
|
name: string | null;
|
|
@@ -76,8 +83,11 @@ export type Row = {
|
|
|
76
83
|
export type CreateRowsResponse = {
|
|
77
84
|
status: string;
|
|
78
85
|
results: Array<Row>;
|
|
79
|
-
startedAt
|
|
80
|
-
completedAt
|
|
86
|
+
startedAt?: string;
|
|
87
|
+
completedAt?: string;
|
|
88
|
+
links?: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
};
|
|
81
91
|
};
|
|
82
92
|
export type FetchRowsResponse = {
|
|
83
93
|
total: number;
|
|
@@ -86,5 +96,5 @@ export type FetchRowsResponse = {
|
|
|
86
96
|
next: {
|
|
87
97
|
after: string | null;
|
|
88
98
|
};
|
|
89
|
-
};
|
|
99
|
+
} | null;
|
|
90
100
|
};
|