@hubspot/local-dev-lib 1.11.0 → 1.13.0
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/localDevAuth.d.ts +2 -1
- package/api/localDevAuth.js +7 -1
- package/errors/apiErrors.js +2 -17
- package/lang/en.json +0 -2
- package/lang/lang/en.json +0 -2
- package/lib/cms/handleFieldsJS.js +1 -1
- package/lib/path.d.ts +1 -0
- package/lib/path.js +13 -1
- package/lib/trackUsage.js +1 -1
- package/package.json +1 -1
- package/types/Accounts.d.ts +5 -0
- package/types/Error.d.ts +0 -1
package/api/localDevAuth.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Environment } from '../types/Config';
|
|
2
|
-
import { ScopeData, AccessTokenResponse } from '../types/Accounts';
|
|
2
|
+
import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse } from '../types/Accounts';
|
|
3
3
|
import { PublicAppInstallationData } from '../types/Apps';
|
|
4
4
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
5
5
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
|
6
6
|
export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): Promise<PublicAppInstallationData>;
|
|
7
|
+
export declare function fetchEnabledFeatures(accountId: number): Promise<EnabledFeaturesResponse>;
|
package/api/localDevAuth.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchAppInstallationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
|
|
6
|
+
exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
|
|
7
7
|
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
8
8
|
const http_1 = __importDefault(require("../http"));
|
|
9
9
|
const environments_1 = require("../constants/environments");
|
|
@@ -46,3 +46,9 @@ async function fetchAppInstallationData(portalId, projectId, appUid, requiredSco
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
exports.fetchAppInstallationData = fetchAppInstallationData;
|
|
49
|
+
async function fetchEnabledFeatures(accountId) {
|
|
50
|
+
return http_1.default.get(accountId, {
|
|
51
|
+
url: `${LOCALDEVAUTH_API_AUTH_PATH}/enabled-features`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.fetchEnabledFeatures = fetchEnabledFeatures;
|
package/errors/apiErrors.js
CHANGED
|
@@ -90,7 +90,6 @@ function getAxiosErrorWithContext(
|
|
|
90
90
|
error, context = {}) {
|
|
91
91
|
const status = error.response?.status;
|
|
92
92
|
const method = error.config?.method;
|
|
93
|
-
const { projectName } = context;
|
|
94
93
|
let messageDetail;
|
|
95
94
|
if (context.accountId) {
|
|
96
95
|
const action = (method && api_1.HTTP_METHOD_VERBS[method]) || api_1.HTTP_METHOD_VERBS.get;
|
|
@@ -111,8 +110,6 @@ error, context = {}) {
|
|
|
111
110
|
if ((method === 'put' || method === 'post') && context.payload) {
|
|
112
111
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.unableToUpload`, { payload: context.payload }));
|
|
113
112
|
}
|
|
114
|
-
const isProjectMissingScopeError = isMissingScopeError(error) && !!projectName;
|
|
115
|
-
const isProjectGatingError = isGatingError(error) && !!projectName;
|
|
116
113
|
switch (status) {
|
|
117
114
|
case 400:
|
|
118
115
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
|
|
@@ -121,19 +118,7 @@ error, context = {}) {
|
|
|
121
118
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.401`, { messageDetail }));
|
|
122
119
|
break;
|
|
123
120
|
case 403:
|
|
124
|
-
|
|
125
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403ProjectMissingScope`, {
|
|
126
|
-
accountId: context.accountId || '',
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
else if (isProjectGatingError) {
|
|
130
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403ProjectGating`, {
|
|
131
|
-
accountId: context.accountId || '',
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403`, { messageDetail }));
|
|
136
|
-
}
|
|
121
|
+
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403`, { messageDetail }));
|
|
137
122
|
break;
|
|
138
123
|
case 404:
|
|
139
124
|
errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404`, { messageDetail }));
|
|
@@ -158,7 +143,7 @@ error, context = {}) {
|
|
|
158
143
|
}
|
|
159
144
|
if (error?.response?.data) {
|
|
160
145
|
const { message, errors } = error.response.data;
|
|
161
|
-
if (message
|
|
146
|
+
if (message) {
|
|
162
147
|
errorMessage.push(message);
|
|
163
148
|
}
|
|
164
149
|
if (errors) {
|
package/lang/en.json
CHANGED
|
@@ -379,8 +379,6 @@
|
|
|
379
379
|
"404": "The {{ messageDetail }} was not found.",
|
|
380
380
|
"429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
|
|
381
381
|
"503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
|
|
382
|
-
"403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
|
|
383
|
-
"403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
|
|
384
382
|
"500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
|
|
385
383
|
"400Generic": "The {{ messageDetail }} failed due to a client error.",
|
|
386
384
|
"generic": "The {{ messageDetail }} failed."
|
package/lang/lang/en.json
CHANGED
|
@@ -379,8 +379,6 @@
|
|
|
379
379
|
"404": "The {{ messageDetail }} was not found.",
|
|
380
380
|
"429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
|
|
381
381
|
"503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
|
|
382
|
-
"403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
|
|
383
|
-
"403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
|
|
384
382
|
"500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
|
|
385
383
|
"400Generic": "The {{ messageDetail }} failed due to a client error.",
|
|
386
384
|
"generic": "The {{ messageDetail }} failed."
|
|
@@ -121,7 +121,7 @@ function isConvertableFieldJs(rootDir, filePath, convertFields = false) {
|
|
|
121
121
|
const inModuleFolder = (0, modules_1.isModuleFolderChild)({ path: filePath, isLocal: true });
|
|
122
122
|
return !!(convertFields &&
|
|
123
123
|
allowedFieldsNames.includes(baseName) &&
|
|
124
|
-
(inModuleFolder || relativePath ==
|
|
124
|
+
(inModuleFolder || relativePath == path_1.default.sep));
|
|
125
125
|
}
|
|
126
126
|
exports.isConvertableFieldJs = isConvertableFieldJs;
|
|
127
127
|
// Try creating tempdir
|
package/lib/path.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare function isAllowedExtension(filepath: string, allowList?: Array<s
|
|
|
11
11
|
export declare function getAbsoluteFilePath(_path: string): string;
|
|
12
12
|
export declare function sanitizeFileName(fileName: string): string;
|
|
13
13
|
export declare function isValidPath(_path: string): boolean;
|
|
14
|
+
export declare function untildify(pathWithTilde: string): string;
|
package/lib/path.js
CHANGED
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
6
|
+
exports.untildify = exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const unixify_1 = __importDefault(require("unixify"));
|
|
9
9
|
const extensions_1 = require("../constants/extensions");
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
10
11
|
function convertToUnixPath(_path) {
|
|
11
12
|
return (0, unixify_1.default)(path_1.default.normalize(_path));
|
|
12
13
|
}
|
|
@@ -120,3 +121,14 @@ function isValidPath(_path) {
|
|
|
120
121
|
return true;
|
|
121
122
|
}
|
|
122
123
|
exports.isValidPath = isValidPath;
|
|
124
|
+
// Based on the untildify package: https://github.com/sindresorhus/untildify/blob/main/index.js
|
|
125
|
+
function untildify(pathWithTilde) {
|
|
126
|
+
const homeDirectory = os_1.default.homedir();
|
|
127
|
+
if (typeof pathWithTilde !== 'string') {
|
|
128
|
+
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
|
|
129
|
+
}
|
|
130
|
+
return homeDirectory
|
|
131
|
+
? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
|
|
132
|
+
: pathWithTilde;
|
|
133
|
+
}
|
|
134
|
+
exports.untildify = untildify;
|
package/lib/trackUsage.js
CHANGED
|
@@ -52,6 +52,6 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
52
52
|
resolveWithFullResponse: true,
|
|
53
53
|
});
|
|
54
54
|
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.sendingEventUnauthenticated`));
|
|
55
|
-
(0, axios_1.default)({ ...axiosConfig, method: 'post' });
|
|
55
|
+
return (0, axios_1.default)({ ...axiosConfig, method: 'post' });
|
|
56
56
|
}
|
|
57
57
|
exports.trackUsage = trackUsage;
|
package/package.json
CHANGED
package/types/Accounts.d.ts
CHANGED
|
@@ -115,6 +115,11 @@ export type AccessTokenResponse = {
|
|
|
115
115
|
hubName: string;
|
|
116
116
|
accountType: ValueOf<typeof HUBSPOT_ACCOUNT_TYPES>;
|
|
117
117
|
};
|
|
118
|
+
export type EnabledFeaturesResponse = {
|
|
119
|
+
enabledFeatures: {
|
|
120
|
+
[key: string]: boolean;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
118
123
|
export type UpdateAccountConfigOptions = Partial<FlatAccountFields_DEPRECATED> & {
|
|
119
124
|
environment?: Environment;
|
|
120
125
|
};
|