@hubspot/local-dev-lib 0.3.0 → 0.3.1-experimental.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/LICENSE +12 -0
- package/README.md +17 -0
- package/api/appsDev.d.ts +6 -0
- package/api/appsDev.js +29 -0
- package/api/customObjects.d.ts +8 -7
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +4 -13
- package/api/designManager.js +6 -9
- package/api/developerTestAccounts.d.ts +7 -0
- package/api/developerTestAccounts.js +48 -0
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +11 -11
- package/api/fileMapper.d.ts +8 -7
- package/api/fileMapper.js +16 -16
- package/api/fileTransport.d.ts +4 -0
- package/api/fileTransport.js +39 -0
- package/api/fireAlarm.d.ts +3 -0
- package/api/fireAlarm.js +11 -0
- package/api/functions.d.ts +7 -7
- package/api/functions.js +13 -16
- package/api/github.d.ts +8 -9
- package/api/github.js +31 -13
- package/api/hubdb.d.ts +11 -10
- package/api/hubdb.js +28 -22
- package/api/lighthouseScore.d.ts +4 -4
- package/api/lighthouseScore.js +9 -12
- package/api/localDevAuth.d.ts +9 -16
- package/api/localDevAuth.js +36 -14
- package/api/marketplaceValidation.d.ts +4 -4
- package/api/marketplaceValidation.js +8 -11
- package/api/projects.d.ts +47 -24
- package/api/projects.js +178 -43
- package/api/sandboxHubs.d.ts +6 -4
- package/api/sandboxHubs.js +10 -11
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +4 -13
- package/api/secrets.d.ts +6 -8
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/CLIConfiguration.d.ts +12 -8
- package/config/CLIConfiguration.js +140 -64
- package/config/configFile.js +9 -18
- package/config/configUtils.d.ts +2 -21
- package/config/configUtils.js +3 -3
- package/config/config_DEPRECATED.d.ts +5 -8
- package/config/config_DEPRECATED.js +60 -26
- package/config/environment.js +1 -1
- package/config/getAccountIdentifier.d.ts +2 -0
- package/config/getAccountIdentifier.js +15 -0
- package/config/index.d.ts +13 -8
- package/config/index.js +99 -59
- package/config/migrate.d.ts +22 -0
- package/config/migrate.js +178 -0
- package/constants/config.d.ts +22 -3
- package/constants/config.js +29 -5
- package/constants/environments.d.ts +1 -0
- package/constants/environments.js +1 -0
- package/constants/extensions.d.ts +2 -0
- package/constants/extensions.js +3 -1
- package/constants/files.d.ts +2 -2
- package/constants/files.js +3 -3
- package/constants/projects.d.ts +12 -0
- package/constants/projects.js +15 -0
- package/errors/errors_DEPRECATED.d.ts +1 -5
- 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 +6 -3
- package/http/getAxiosConfig.js +49 -6
- package/http/index.d.ts +11 -10
- package/http/index.js +87 -36
- package/http/unauthed.d.ts +14 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +384 -386
- package/lib/archive.d.ts +3 -6
- package/lib/archive.js +27 -21
- package/lib/cms/functions.d.ts +6 -9
- package/lib/cms/functions.js +25 -20
- package/lib/cms/handleFieldsJS.d.ts +2 -2
- package/lib/cms/handleFieldsJS.js +15 -11
- package/lib/cms/modules.d.ts +5 -13
- package/lib/cms/modules.js +71 -73
- package/lib/cms/processFieldsJs.js +10 -33
- package/lib/cms/templates.d.ts +42 -0
- package/lib/cms/templates.js +49 -6
- package/lib/cms/uploadFolder.d.ts +3 -12
- package/lib/cms/uploadFolder.js +57 -39
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.d.ts +2 -15
- package/lib/cms/watch.js +36 -28
- package/lib/customObjects.js +4 -15
- package/lib/fileManager.js +24 -24
- package/lib/fileMapper.d.ts +4 -13
- package/lib/fileMapper.js +57 -67
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +10 -6
- package/lib/github.d.ts +11 -11
- package/lib/github.js +45 -31
- package/lib/gitignore.d.ts +2 -0
- package/lib/gitignore.js +21 -4
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/{utils → lib}/notify.js +2 -2
- package/lib/oauth.d.ts +1 -1
- package/lib/oauth.js +10 -19
- package/lib/path.d.ts +3 -0
- package/lib/path.js +46 -1
- package/lib/personalAccessKey.d.ts +8 -11
- package/lib/personalAccessKey.js +72 -52
- package/lib/portManager.d.ts +3 -5
- package/lib/portManager.js +18 -6
- package/lib/text.d.ts +1 -1
- package/lib/text.js +3 -0
- package/lib/trackUsage.js +14 -8
- package/lib/urls.js +5 -1
- package/models/FileSystemError.d.ts +6 -0
- package/models/FileSystemError.js +47 -0
- package/models/HubSpotHttpError.d.ts +26 -0
- package/models/HubSpotHttpError.js +208 -0
- package/models/OAuth2Manager.d.ts +2 -27
- package/models/OAuth2Manager.js +15 -30
- package/package.json +38 -36
- package/types/Accounts.d.ts +98 -3
- package/types/Apps.d.ts +77 -0
- package/types/Apps.js +2 -0
- package/types/Archive.d.ts +9 -0
- package/types/Archive.js +2 -0
- package/types/Build.d.ts +4 -2
- package/types/ComponentStructure.d.ts +30 -10
- package/types/Config.d.ts +19 -2
- package/types/Deploy.d.ts +3 -2
- package/types/DesignManager.d.ts +15 -0
- package/types/DesignManager.js +2 -0
- package/types/Error.d.ts +9 -5
- package/types/FieldsJS.d.ts +1 -0
- package/types/FieldsJS.js +2 -0
- package/types/FileManager.d.ts +1 -1
- package/types/Files.d.ts +43 -4
- package/types/FireAlarm.d.ts +9 -0
- package/types/FireAlarm.js +2 -0
- package/types/Functions.d.ts +52 -0
- package/types/Github.d.ts +13 -0
- package/types/Http.d.ts +13 -12
- package/types/Hubdb.d.ts +9 -0
- package/types/MarketplaceValidation.d.ts +7 -3
- package/types/Migration.d.ts +30 -0
- package/types/Migration.js +12 -0
- package/types/Modules.d.ts +11 -0
- package/types/PortManager.d.ts +7 -0
- package/types/Project.d.ts +30 -0
- package/types/ProjectLog.d.ts +9 -0
- package/types/ProjectLog.js +2 -0
- package/types/Sandbox.d.ts +25 -36
- package/types/Schemas.d.ts +56 -0
- package/types/Secrets.d.ts +3 -0
- package/types/Secrets.js +2 -0
- package/types/developerTestAccounts.d.ts +23 -0
- package/types/developerTestAccounts.js +2 -0
- package/utils/PortManagerServer.d.ts +6 -7
- package/utils/PortManagerServer.js +16 -10
- package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +0 -6
- package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
- package/utils/cms/fieldsJS.d.ts +1 -2
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/utils/git.d.ts +1 -7
- package/utils/git.js +2 -18
- package/errors/apiErrors.d.ts +0 -21
- package/errors/apiErrors.js +0 -177
- package/errors/fileSystemErrors.d.ts +0 -6
- package/errors/fileSystemErrors.js +0 -35
- package/errors/standardErrors.d.ts +0 -21
- package/errors/standardErrors.js +0 -52
- package/lang/lang/en.json +0 -401
- package/lib/logging/git.d.ts +0 -2
- package/lib/logging/git.js +0 -54
- package/lib/logging/logs.d.ts +0 -22
- package/lib/logging/logs.js +0 -86
- package/lib/logging/table.d.ts +0 -3
- package/lib/logging/table.js +0 -47
- 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/utils/objectUtils.d.ts +0 -8
- package/utils/objectUtils.js +0 -33
- /package/{utils → lib}/escapeRegExp.d.ts +0 -0
- /package/{utils → lib}/escapeRegExp.js +0 -0
- /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
- /package/lib/{logging/logger.js → logger.js} +0 -0
- /package/{utils → lib}/notify.d.ts +0 -0
package/http/index.js
CHANGED
|
@@ -1,25 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.http = exports.addUserAgentHeader = void 0;
|
|
6
30
|
const path_1 = __importDefault(require("path"));
|
|
7
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
32
|
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
9
|
-
const axios_1 =
|
|
33
|
+
const axios_1 = __importStar(require("axios"));
|
|
10
34
|
const config_1 = require("../config");
|
|
11
35
|
const getAxiosConfig_1 = require("./getAxiosConfig");
|
|
36
|
+
const addQueryParams_1 = require("./addQueryParams");
|
|
12
37
|
const personalAccessKey_1 = require("../lib/personalAccessKey");
|
|
13
38
|
const oauth_1 = require("../lib/oauth");
|
|
14
|
-
const
|
|
15
|
-
const logger_1 = require("../lib/logging/logger");
|
|
39
|
+
const logger_1 = require("../lib/logger");
|
|
16
40
|
const lang_1 = require("../utils/lang");
|
|
41
|
+
const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
|
|
42
|
+
const localDevAuth_1 = require("../api/localDevAuth");
|
|
43
|
+
const util = __importStar(require("util"));
|
|
17
44
|
const i18nKey = 'http.index';
|
|
45
|
+
function logRequest(response) {
|
|
46
|
+
try {
|
|
47
|
+
if (process.env.HUBSPOT_NETWORK_LOGGING) {
|
|
48
|
+
if (response.config.url === localDevAuth_1.LOCALDEVAUTH_ACCESS_TOKEN_PATH) {
|
|
49
|
+
// Don't log access tokens
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
logger_1.logger.debug(util.inspect({
|
|
53
|
+
method: response.config.method,
|
|
54
|
+
baseURL: response.config.baseURL,
|
|
55
|
+
url: response.config.url,
|
|
56
|
+
data: response.data,
|
|
57
|
+
status: response.status,
|
|
58
|
+
}, false, null, true));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// Ignore any errors that occur while logging the response
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
axios_1.default.interceptors.response.use((response) => {
|
|
66
|
+
logRequest(response);
|
|
67
|
+
return response;
|
|
68
|
+
}, error => {
|
|
69
|
+
try {
|
|
70
|
+
if ((0, axios_1.isAxiosError)(error) && error.response) {
|
|
71
|
+
logRequest(error.response);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
// Ignore any errors that occur while logging the response
|
|
76
|
+
}
|
|
77
|
+
// Wrap all axios errors in our own Error class. Attach the error
|
|
78
|
+
// as the cause for the new error, so we maintain the stack trace
|
|
79
|
+
return Promise.reject(new HubSpotHttpError_1.HubSpotHttpError(error.message, { cause: error }));
|
|
80
|
+
});
|
|
81
|
+
function addUserAgentHeader(key, value) {
|
|
82
|
+
getAxiosConfig_1.USER_AGENTS[key] = value;
|
|
83
|
+
}
|
|
84
|
+
exports.addUserAgentHeader = addUserAgentHeader;
|
|
18
85
|
async function withOauth(accountId, accountConfig, axiosConfig) {
|
|
19
86
|
const { headers } = axiosConfig;
|
|
20
87
|
const oauth = (0, oauth_1.getOauthManager)(accountId, accountConfig);
|
|
21
88
|
if (!oauth) {
|
|
22
|
-
(0,
|
|
89
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.withOauth`, { accountId }));
|
|
23
90
|
}
|
|
24
91
|
const accessToken = await oauth.accessToken();
|
|
25
92
|
return {
|
|
@@ -54,7 +121,7 @@ function withPortalId(portalId, axiosConfig) {
|
|
|
54
121
|
async function withAuth(accountId, options) {
|
|
55
122
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
56
123
|
if (!accountConfig) {
|
|
57
|
-
(0,
|
|
124
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.withAuth`, { accountId }));
|
|
58
125
|
}
|
|
59
126
|
const { env, authType, apiKey } = accountConfig;
|
|
60
127
|
const axiosConfig = withPortalId(accountId, (0, getAxiosConfig_1.getAxiosConfig)({ env, ...options }));
|
|
@@ -73,47 +140,32 @@ async function withAuth(accountId, options) {
|
|
|
73
140
|
},
|
|
74
141
|
};
|
|
75
142
|
}
|
|
76
|
-
function addQueryParams(configOptions, queryParams = {}) {
|
|
77
|
-
const { params } = configOptions;
|
|
78
|
-
return {
|
|
79
|
-
...configOptions,
|
|
80
|
-
params: {
|
|
81
|
-
...queryParams,
|
|
82
|
-
...params,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
143
|
async function getRequest(accountId, options) {
|
|
87
|
-
const {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
return data;
|
|
144
|
+
const { params, ...rest } = options;
|
|
145
|
+
const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
146
|
+
const requestConfig = await withAuth(accountId, optionsWithParams);
|
|
147
|
+
return (0, axios_1.default)(requestConfig);
|
|
92
148
|
}
|
|
93
149
|
async function postRequest(accountId, options) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
return data;
|
|
150
|
+
const requestConfig = await withAuth(accountId, options);
|
|
151
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'post' });
|
|
97
152
|
}
|
|
98
153
|
async function putRequest(accountId, options) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
return data;
|
|
154
|
+
const requestConfig = await withAuth(accountId, options);
|
|
155
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'put' });
|
|
102
156
|
}
|
|
103
157
|
async function patchRequest(accountId, options) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
return data;
|
|
158
|
+
const requestConfig = await withAuth(accountId, options);
|
|
159
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'patch' });
|
|
107
160
|
}
|
|
108
161
|
async function deleteRequest(accountId, options) {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
return data;
|
|
162
|
+
const requestConfig = await withAuth(accountId, options);
|
|
163
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'delete' });
|
|
112
164
|
}
|
|
113
165
|
function createGetRequestStream(contentType) {
|
|
114
166
|
return async (accountId, options, destPath) => {
|
|
115
|
-
const {
|
|
116
|
-
const axiosConfig = addQueryParams(rest,
|
|
167
|
+
const { params, ...rest } = options;
|
|
168
|
+
const axiosConfig = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
117
169
|
// eslint-disable-next-line no-async-promise-executor
|
|
118
170
|
return new Promise(async (resolve, reject) => {
|
|
119
171
|
try {
|
|
@@ -167,7 +219,7 @@ function createGetRequestStream(contentType) {
|
|
|
167
219
|
};
|
|
168
220
|
}
|
|
169
221
|
const getOctetStream = createGetRequestStream('application/octet-stream');
|
|
170
|
-
|
|
222
|
+
exports.http = {
|
|
171
223
|
get: getRequest,
|
|
172
224
|
post: postRequest,
|
|
173
225
|
put: putRequest,
|
|
@@ -175,4 +227,3 @@ const http = {
|
|
|
175
227
|
delete: deleteRequest,
|
|
176
228
|
getOctetStream,
|
|
177
229
|
};
|
|
178
|
-
exports.default = http;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpOptions, HubSpotPromise } from '../types/Http';
|
|
2
|
+
declare function getRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
3
|
+
declare function postRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
4
|
+
declare function putRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
5
|
+
declare function patchRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
6
|
+
declare function deleteRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
7
|
+
export declare const http: {
|
|
8
|
+
get: typeof getRequest;
|
|
9
|
+
post: typeof postRequest;
|
|
10
|
+
put: typeof putRequest;
|
|
11
|
+
patch: typeof patchRequest;
|
|
12
|
+
delete: typeof deleteRequest;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
package/http/unauthed.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.http = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getAxiosConfig_1 = require("./getAxiosConfig");
|
|
9
|
+
const addQueryParams_1 = require("./addQueryParams");
|
|
10
|
+
async function getRequest(options) {
|
|
11
|
+
const { params, ...rest } = options;
|
|
12
|
+
const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
13
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(optionsWithParams);
|
|
14
|
+
return (0, axios_1.default)(requestConfig);
|
|
15
|
+
}
|
|
16
|
+
async function postRequest(options) {
|
|
17
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
18
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'post' });
|
|
19
|
+
}
|
|
20
|
+
async function putRequest(options) {
|
|
21
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
22
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'put' });
|
|
23
|
+
}
|
|
24
|
+
async function patchRequest(options) {
|
|
25
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
26
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'patch' });
|
|
27
|
+
}
|
|
28
|
+
async function deleteRequest(options) {
|
|
29
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
30
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'delete' });
|
|
31
|
+
}
|
|
32
|
+
exports.http = {
|
|
33
|
+
get: getRequest,
|
|
34
|
+
post: postRequest,
|
|
35
|
+
put: putRequest,
|
|
36
|
+
patch: patchRequest,
|
|
37
|
+
delete: deleteRequest,
|
|
38
|
+
};
|