@hubspot/local-dev-lib 0.0.7 → 0.0.9
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/fileMapper.d.ts +2 -0
- package/api/fileMapper.js +3 -2
- 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/CLIConfiguration.js +20 -18
- package/config/configFile.js +1 -2
- package/config/configUtils.js +2 -1
- package/config/config_DEPRECATED.js +27 -24
- package/config/environment.js +4 -3
- package/constants/ports.d.ts +3 -0
- package/constants/ports.js +6 -0
- package/errors/apiErrors.d.ts +1 -1
- package/errors/apiErrors.js +13 -13
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/fileSystemErrors.js +1 -1
- package/errors/standardErrors.d.ts +4 -3
- package/errors/standardErrors.js +2 -2
- package/http/index.js +8 -4
- package/lang/en.json +383 -0
- package/lang/lang/en.json +383 -0
- package/lib/archive.js +10 -9
- package/lib/cms/functions.js +13 -13
- package/lib/cms/handleFieldsJS.js +8 -6
- package/lib/cms/modules.js +5 -4
- package/lib/cms/processFieldsJs.js +6 -8
- package/lib/cms/templates.js +10 -5
- package/lib/cms/uploadFolder.js +11 -7
- package/lib/cms/watch.js +33 -21
- package/lib/customObjects.d.ts +4 -4
- package/lib/customObjects.js +21 -4
- package/lib/fileMapper.js +28 -21
- package/lib/github.js +15 -11
- package/lib/gitignore.js +2 -1
- package/lib/hubdb.d.ts +1 -1
- package/lib/hubdb.js +5 -4
- package/lib/logging/git.js +1 -1
- package/lib/logging/logs.js +5 -1
- package/lib/oauth.js +5 -4
- package/lib/personalAccessKey.d.ts +1 -1
- package/lib/personalAccessKey.js +6 -5
- package/lib/portManager.d.ts +13 -0
- package/lib/portManager.js +45 -0
- package/lib/sandboxes.js +7 -7
- package/lib/trackUsage.js +3 -3
- package/models/HubSpotAuthError.d.ts +1 -1
- package/models/HubSpotAuthError.js +2 -2
- package/models/OAuth2Manager.d.ts +1 -1
- package/models/OAuth2Manager.js +5 -5
- package/package.json +7 -2
- package/types/Error.d.ts +3 -3
- package/types/Http.d.ts +8 -11
- package/types/Hubdb.d.ts +27 -17
- package/types/Lang.d.ts +7 -0
- package/types/Lang.js +2 -0
- package/types/PortManager.d.ts +4 -0
- package/types/PortManager.js +2 -0
- package/types/Schemas.d.ts +18 -33
- package/types/Utils.d.ts +5 -0
- package/utils/PortManagerServer.d.ts +29 -0
- package/utils/PortManagerServer.js +158 -0
- package/utils/cms/modules.js +2 -1
- package/utils/detectPort.d.ts +1 -0
- package/utils/detectPort.js +102 -0
- package/utils/lang.d.ts +2 -4
- package/utils/lang.js +12 -14
- package/utils/logger.d.ts +4 -3
- package/utils/logger.js +4 -3
- package/utils/notify.js +2 -1
- package/lang/en.lyaml +0 -247
package/lib/hubdb.js
CHANGED
|
@@ -10,9 +10,10 @@ const prettier_1 = __importDefault(require("prettier"));
|
|
|
10
10
|
const hubdb_1 = require("../api/hubdb");
|
|
11
11
|
const path_2 = require("./path");
|
|
12
12
|
const standardErrors_1 = require("../errors/standardErrors");
|
|
13
|
+
const i18nKey = 'lib.hubdb';
|
|
13
14
|
function validateJsonPath(src) {
|
|
14
15
|
if (path_1.default.extname(src) !== '.json') {
|
|
15
|
-
(0, standardErrors_1.throwErrorWithMessage)(
|
|
16
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.invalidJsonPath`);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
function validateJsonFile(src) {
|
|
@@ -21,14 +22,14 @@ function validateJsonFile(src) {
|
|
|
21
22
|
stats = fs_extra_1.default.statSync(src);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
|
-
(0, standardErrors_1.throwErrorWithMessage)(
|
|
25
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.invalidJsonFile`, { src }, err);
|
|
25
26
|
}
|
|
26
27
|
if (!stats.isFile()) {
|
|
27
|
-
(0, standardErrors_1.throwErrorWithMessage)(
|
|
28
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.invalidJsonFile`, { src });
|
|
28
29
|
}
|
|
29
30
|
validateJsonPath(src);
|
|
30
31
|
}
|
|
31
|
-
async function addRowsToHubDbTable(accountId, tableId, rows) {
|
|
32
|
+
async function addRowsToHubDbTable(accountId, tableId, rows = []) {
|
|
32
33
|
const rowsToUpdate = rows.map(row => {
|
|
33
34
|
const values = row.values;
|
|
34
35
|
return {
|
package/lib/logging/git.js
CHANGED
|
@@ -12,7 +12,7 @@ const logger_1 = require("./logger");
|
|
|
12
12
|
const lang_1 = require("../../utils/lang");
|
|
13
13
|
const config_1 = require("../../constants/config");
|
|
14
14
|
const GITIGNORE_FILE = '.gitignore';
|
|
15
|
-
const i18nKey = '
|
|
15
|
+
const i18nKey = 'lib.logging.git';
|
|
16
16
|
function checkAndWarnGitInclusion(configPath) {
|
|
17
17
|
try {
|
|
18
18
|
const { inGit, configIgnored } = (0, git_1.checkGitInclusion)(configPath);
|
package/lib/logging/logs.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.outputLogs = void 0;
|
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const logger_1 = require("./logger");
|
|
10
|
+
const lang_1 = require("../../utils/lang");
|
|
11
|
+
const i18nKey = 'lib.logging.logs';
|
|
10
12
|
const SEPARATOR = ' - ';
|
|
11
13
|
const LOG_STATUS_COLORS = {
|
|
12
14
|
SUCCESS: logger_1.Styles.success,
|
|
@@ -61,7 +63,9 @@ function processLog(log, options) {
|
|
|
61
63
|
return logHandler[log.status](log, options);
|
|
62
64
|
}
|
|
63
65
|
catch (e) {
|
|
64
|
-
logger_1.logger.error(
|
|
66
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.unableToProcessLog`, {
|
|
67
|
+
log: JSON.stringify(log),
|
|
68
|
+
}));
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
function processLogs(logsResp, options) {
|
package/lib/oauth.js
CHANGED
|
@@ -11,10 +11,11 @@ const logger_1 = require("../utils/logger");
|
|
|
11
11
|
const logger_2 = require("../utils/logger");
|
|
12
12
|
const getAccountIdentifier_1 = require("../utils/getAccountIdentifier");
|
|
13
13
|
const config_1 = require("../config");
|
|
14
|
+
const i18nKey = 'lib.oauth';
|
|
14
15
|
const oauthManagers = new Map();
|
|
15
16
|
function writeOauthTokenInfo(accountConfig) {
|
|
16
17
|
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
|
|
17
|
-
(0, logger_1.debug)(
|
|
18
|
+
(0, logger_1.debug)(`${i18nKey}.writeTokenInfo`, { portalId: accountId || '' });
|
|
18
19
|
(0, config_1.updateAccountConfig)(accountConfig);
|
|
19
20
|
(0, config_1.writeConfig)();
|
|
20
21
|
}
|
|
@@ -27,15 +28,15 @@ function getOauthManager(accountId, accountConfig) {
|
|
|
27
28
|
exports.getOauthManager = getOauthManager;
|
|
28
29
|
const addOauthToAccountConfigCallbackKeys = ['init', 'success'];
|
|
29
30
|
function addOauthToAccountConfig(oauth, logCallbacks) {
|
|
30
|
-
const logger = (0, logger_2.makeTypedLogger)(logCallbacks
|
|
31
|
-
logger('init');
|
|
31
|
+
const logger = (0, logger_2.makeTypedLogger)(logCallbacks);
|
|
32
|
+
logger('init', `${i18nKey}.addOauthToAccountConfig.init`);
|
|
32
33
|
try {
|
|
33
34
|
(0, config_1.updateAccountConfig)({
|
|
34
35
|
...oauth.toObj(),
|
|
35
36
|
authType: auth_1.AUTH_METHODS.oauth.value,
|
|
36
37
|
});
|
|
37
38
|
(0, config_1.writeConfig)();
|
|
38
|
-
logger('success');
|
|
39
|
+
logger('success', `${i18nKey}.addOauthToAccountConfig.success`);
|
|
39
40
|
}
|
|
40
41
|
catch (err) {
|
|
41
42
|
(0, standardErrors_1.throwError)(err);
|
|
@@ -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
|
@@ -11,6 +11,7 @@ const standardErrors_1 = require("../errors/standardErrors");
|
|
|
11
11
|
const localDevAuth_1 = require("../api/localDevAuth");
|
|
12
12
|
const sandboxHubs_1 = require("../api/sandboxHubs");
|
|
13
13
|
const config_1 = require("../config");
|
|
14
|
+
const i18nKey = 'lib.personalAccessKey';
|
|
14
15
|
const refreshRequests = new Map();
|
|
15
16
|
function getRefreshKey(personalAccessKey, expiration) {
|
|
16
17
|
return `${personalAccessKey}-${expiration || 'fresh'}`;
|
|
@@ -22,8 +23,8 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
22
23
|
}
|
|
23
24
|
catch (e) {
|
|
24
25
|
const error = e;
|
|
25
|
-
if (error.response) {
|
|
26
|
-
(0, standardErrors_1.throwAuthErrorWithMessage)(
|
|
26
|
+
if (error.response && error.response.body) {
|
|
27
|
+
(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.errors.invalidPersonalAccessKey`, { errorMessage: error.response.body.message || '' }, error);
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
(0, standardErrors_1.throwError)(e);
|
|
@@ -34,7 +35,7 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
34
35
|
accessToken: response.oauthAccessToken,
|
|
35
36
|
expiresAt: (0, moment_1.default)(response.expiresAtMillis).toISOString(),
|
|
36
37
|
scopeGroups: response.scopeGroups,
|
|
37
|
-
|
|
38
|
+
encodedOAuthRefreshToken: response.encodedOAuthRefreshToken,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
exports.getAccessToken = getAccessToken;
|
|
@@ -77,7 +78,7 @@ async function getNewAccessToken(accountId, personalAccessKey, expiresAt, env) {
|
|
|
77
78
|
async function accessTokenForPersonalAccessKey(accountId) {
|
|
78
79
|
const account = (0, config_1.getAccountConfig)(accountId);
|
|
79
80
|
if (!account) {
|
|
80
|
-
(0, standardErrors_1.throwErrorWithMessage)(
|
|
81
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.accountNotFound`, { accountId });
|
|
81
82
|
}
|
|
82
83
|
const { auth, personalAccessKey, env } = account;
|
|
83
84
|
const authTokenInfo = auth && auth.tokenInfo;
|
|
@@ -89,7 +90,7 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
89
90
|
return auth?.tokenInfo?.accessToken;
|
|
90
91
|
}
|
|
91
92
|
exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
|
|
92
|
-
// Adds
|
|
93
|
+
// Adds an account to the config using authType: personalAccessKey
|
|
93
94
|
const updateConfigWithPersonalAccessKey = async (personalAccessKey, name, env, makeDefault = false) => {
|
|
94
95
|
const accountEnv = env || (0, config_1.getEnv)(name);
|
|
95
96
|
let token;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const BASE_URL: string;
|
|
2
|
+
export declare function startPortManagerServer(): Promise<void>;
|
|
3
|
+
export declare function stopPortManagerServer(): Promise<void>;
|
|
4
|
+
type RequestPortsData = {
|
|
5
|
+
instanceId: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function requestPorts(portData: Array<RequestPortsData>): Promise<{
|
|
9
|
+
[instanceId: string]: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function deleteServerInstance(serverInstanceId: string): Promise<void>;
|
|
12
|
+
export declare function portManagerHasActiveServers(): Promise<boolean>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
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.portManagerHasActiveServers = exports.deleteServerInstance = exports.requestPorts = exports.stopPortManagerServer = exports.startPortManagerServer = exports.BASE_URL = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const PortManagerServer_1 = __importDefault(require("../utils/PortManagerServer"));
|
|
9
|
+
const detectPort_1 = require("../utils/detectPort");
|
|
10
|
+
const ports_1 = require("../constants/ports");
|
|
11
|
+
exports.BASE_URL = `http://localhost:${ports_1.PORT_MANAGER_SERVER_PORT}`;
|
|
12
|
+
async function isPortManagerServerRunning() {
|
|
13
|
+
const port = await (0, detectPort_1.detectPort)(ports_1.PORT_MANAGER_SERVER_PORT);
|
|
14
|
+
return port !== ports_1.PORT_MANAGER_SERVER_PORT;
|
|
15
|
+
}
|
|
16
|
+
async function startPortManagerServer() {
|
|
17
|
+
const isRunning = await isPortManagerServerRunning();
|
|
18
|
+
if (!isRunning) {
|
|
19
|
+
await PortManagerServer_1.default.init();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.startPortManagerServer = startPortManagerServer;
|
|
23
|
+
async function stopPortManagerServer() {
|
|
24
|
+
const isRunning = await isPortManagerServerRunning();
|
|
25
|
+
if (isRunning) {
|
|
26
|
+
await axios_1.default.post(`${exports.BASE_URL}/close`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.stopPortManagerServer = stopPortManagerServer;
|
|
30
|
+
async function requestPorts(portData) {
|
|
31
|
+
const { data } = await axios_1.default.post(`${exports.BASE_URL}/servers`, {
|
|
32
|
+
portData: portData,
|
|
33
|
+
});
|
|
34
|
+
return data.ports;
|
|
35
|
+
}
|
|
36
|
+
exports.requestPorts = requestPorts;
|
|
37
|
+
async function deleteServerInstance(serverInstanceId) {
|
|
38
|
+
await axios_1.default.delete(`${exports.BASE_URL}/servers/${serverInstanceId}`);
|
|
39
|
+
}
|
|
40
|
+
exports.deleteServerInstance = deleteServerInstance;
|
|
41
|
+
async function portManagerHasActiveServers() {
|
|
42
|
+
const { data } = await axios_1.default.get(`${exports.BASE_URL}/servers`);
|
|
43
|
+
return data.count > 0;
|
|
44
|
+
}
|
|
45
|
+
exports.portManagerHasActiveServers = portManagerHasActiveServers;
|
package/lib/sandboxes.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.fetchTypes = exports.fetchTaskStatus = exports.initiateSync = exports.ge
|
|
|
4
4
|
const sandboxHubs_1 = require("../api/sandboxHubs");
|
|
5
5
|
const sandboxSync_1 = require("../api/sandboxSync");
|
|
6
6
|
const standardErrors_1 = require("../errors/standardErrors");
|
|
7
|
-
const i18nKey = 'sandboxes';
|
|
7
|
+
const i18nKey = 'lib.sandboxes';
|
|
8
8
|
async function createSandbox(accountId, name, type) {
|
|
9
9
|
try {
|
|
10
10
|
const resp = await (0, sandboxHubs_1.createSandbox)(accountId, name, type);
|
|
@@ -14,7 +14,7 @@ async function createSandbox(accountId, name, type) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
catch (err) {
|
|
17
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.createSandbox`, {}, err);
|
|
17
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.createSandbox`, {}, err);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.createSandbox = createSandbox;
|
|
@@ -23,7 +23,7 @@ async function deleteSandbox(parentAccountId, sandboxAccountId) {
|
|
|
23
23
|
await (0, sandboxHubs_1.deleteSandbox)(parentAccountId, sandboxAccountId);
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.deleteSandbox`, {}, err);
|
|
26
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.deleteSandbox`, {}, err);
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
29
29
|
parentAccountId,
|
|
@@ -37,7 +37,7 @@ async function getSandboxUsageLimits(parentAccountId) {
|
|
|
37
37
|
return resp && resp.usage;
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.getSandboxUsageLimits`, {}, err);
|
|
40
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.getSandboxUsageLimits`, {}, err);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.getSandboxUsageLimits = getSandboxUsageLimits;
|
|
@@ -46,7 +46,7 @@ async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
|
46
46
|
return await (0, sandboxSync_1.initiateSync)(fromHubId, toHubId, tasks, sandboxHubId);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.initiateSync`, {}, err);
|
|
49
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.initiateSync`, {}, err);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
exports.initiateSync = initiateSync;
|
|
@@ -55,7 +55,7 @@ async function fetchTaskStatus(accountId, taskId) {
|
|
|
55
55
|
return await (0, sandboxSync_1.fetchTaskStatus)(accountId, taskId);
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchTaskStatus`, {}, err);
|
|
58
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.fetchTaskStatus`, {}, err);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
exports.fetchTaskStatus = fetchTaskStatus;
|
|
@@ -65,7 +65,7 @@ async function fetchTypes(accountId, toHubId) {
|
|
|
65
65
|
return resp && resp.results;
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
68
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.fetchTypes`, {}, err);
|
|
68
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.fetchTypes`, {}, err);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
exports.fetchTypes = fetchTypes;
|
package/lib/trackUsage.js
CHANGED
|
@@ -8,8 +8,8 @@ const logger_1 = require("../utils/logger");
|
|
|
8
8
|
const http_1 = __importDefault(require("../http"));
|
|
9
9
|
const config_1 = require("../config");
|
|
10
10
|
const fileMapper_1 = require("../api/fileMapper");
|
|
11
|
+
const i18nKey = 'lib.trackUsage';
|
|
11
12
|
async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
12
|
-
const i18nKey = 'api.filemapper.trackUsage';
|
|
13
13
|
const usageEvent = {
|
|
14
14
|
accountId,
|
|
15
15
|
eventName,
|
|
@@ -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,13 +17,14 @@ 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) {
|
|
27
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.missingRefreshToken`, {
|
|
27
|
+
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.missingRefreshToken`, {
|
|
28
28
|
accountId: (0, getAccountIdentifier_1.getAccountIdentifier)(this.account),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
@@ -86,7 +86,7 @@ class OAuth2Manager {
|
|
|
86
86
|
catch (e) {
|
|
87
87
|
const error = e;
|
|
88
88
|
if (error.response) {
|
|
89
|
-
(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.auth`, {
|
|
89
|
+
(0, standardErrors_1.throwAuthErrorWithMessage)(`${i18nKey}.errors.auth`, {
|
|
90
90
|
token: error.response.body.message || '',
|
|
91
91
|
}, error);
|
|
92
92
|
}
|
|
@@ -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.9",
|
|
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,12 +24,14 @@
|
|
|
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": {
|
|
31
31
|
"@types/content-disposition": "^0.5.5",
|
|
32
|
+
"@types/cors": "^2.8.15",
|
|
32
33
|
"@types/debounce": "^1.2.1",
|
|
34
|
+
"@types/express": "^4.17.18",
|
|
33
35
|
"@types/findup-sync": "^4.0.2",
|
|
34
36
|
"@types/fs-extra": "^11.0.1",
|
|
35
37
|
"@types/jest": "^29.5.0",
|
|
@@ -55,9 +57,12 @@
|
|
|
55
57
|
"./logger": "./lib/logging/logger.js"
|
|
56
58
|
},
|
|
57
59
|
"dependencies": {
|
|
60
|
+
"address": "^2.0.1",
|
|
58
61
|
"axios": "^1.3.5",
|
|
59
62
|
"chokidar": "^3.5.3",
|
|
60
63
|
"content-disposition": "^0.5.4",
|
|
64
|
+
"cors": "^2.8.5",
|
|
65
|
+
"express": "^4.18.2",
|
|
61
66
|
"extract-zip": "^2.0.1",
|
|
62
67
|
"findup-sync": "^5.0.0",
|
|
63
68
|
"fs-extra": "^11.1.0",
|
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
|
};
|
package/types/Lang.d.ts
ADDED
package/types/Lang.js
ADDED
package/types/Schemas.d.ts
CHANGED
|
@@ -1,41 +1,26 @@
|
|
|
1
1
|
export type Schema = {
|
|
2
2
|
id: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
calculated: boolean;
|
|
16
|
-
externalOptions: boolean;
|
|
17
|
-
archived: boolean;
|
|
18
|
-
hasUniqueValue: boolean;
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
associations?: [
|
|
22
|
-
{
|
|
23
|
-
id: string;
|
|
24
|
-
fromObjectTypeId: string;
|
|
25
|
-
toObjectTypeId: string;
|
|
26
|
-
name: string;
|
|
27
|
-
}
|
|
28
|
-
];
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt?: string;
|
|
5
|
+
updatedAt?: string;
|
|
6
|
+
properties: Array<any>;
|
|
7
|
+
associations: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
fromObjectTypeId: string;
|
|
10
|
+
toObjectTypeId: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
createdAt?: string | null;
|
|
13
|
+
updatedAt?: string | null;
|
|
14
|
+
}>;
|
|
29
15
|
labels: {
|
|
30
|
-
singular
|
|
31
|
-
plural
|
|
16
|
+
singular?: string;
|
|
17
|
+
plural?: string;
|
|
32
18
|
};
|
|
33
19
|
requiredProperties: Array<string>;
|
|
34
|
-
searchableProperties
|
|
35
|
-
primaryDisplayProperty
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
name: string;
|
|
20
|
+
searchableProperties?: Array<string>;
|
|
21
|
+
primaryDisplayProperty?: string;
|
|
22
|
+
fullyQualifiedName?: string;
|
|
23
|
+
[key: string]: any;
|
|
39
24
|
};
|
|
40
25
|
export type FetchSchemasResponse = {
|
|
41
26
|
results: Array<Schema>;
|
package/types/Utils.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export type ValueOf<T> = T[keyof T];
|
|
2
|
+
type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${'' extends P ? '' : '.'}${P}` : never : never;
|
|
3
|
+
export type Leaves<T> = [10] extends [never] ? never : T extends object ? {
|
|
4
|
+
[K in keyof T]-?: Join<K, Leaves<T[K]>>;
|
|
5
|
+
}[keyof T] : '';
|
|
6
|
+
export {};
|