@hubspot/local-dev-lib 0.2.1-experimental.1 → 0.2.2-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/api/github.d.ts +0 -1
- package/api/projects.d.ts +0 -1
- package/config/CLIConfiguration.d.ts +65 -0
- package/config/CLIConfiguration.js +509 -0
- package/config/configFile.d.ts +21 -0
- package/config/configFile.js +100 -0
- package/config/configUtils.d.ts +5 -0
- package/config/configUtils.js +87 -0
- package/config/config_DEPRECATED.d.ts +76 -0
- package/config/config_DEPRECATED.js +693 -0
- package/config/environment.d.ts +2 -0
- package/config/environment.js +60 -0
- package/config/getAccountIdentifier.d.ts +2 -0
- package/config/getAccountIdentifier.js +15 -0
- package/config/index.d.ts +41 -25
- package/config/index.js +236 -248
- package/config/migrate.d.ts +20 -0
- package/config/migrate.js +150 -0
- package/constants/config.d.ts +7 -24
- package/constants/config.js +13 -25
- package/constants/environments.d.ts +11 -0
- package/constants/environments.js +12 -1
- package/http/getAxiosConfig.js +1 -7
- package/http/index.js +19 -23
- package/lang/en.json +81 -67
- package/lib/archive.d.ts +0 -1
- package/lib/cms/themes.js +1 -3
- package/lib/environment.d.ts +1 -1
- package/lib/github.d.ts +0 -1
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +16 -8
- package/lib/personalAccessKey.d.ts +2 -2
- package/lib/personalAccessKey.js +30 -39
- package/lib/trackUsage.js +3 -6
- package/models/OAuth2Manager.d.ts +4 -3
- package/models/OAuth2Manager.js +29 -20
- package/package.json +4 -3
- package/types/Accounts.d.ts +109 -20
- package/types/Config.d.ts +24 -11
- package/types/Http.d.ts +0 -1
- package/utils/accounts.d.ts +4 -0
- package/utils/accounts.js +28 -0
- package/config/defaultAccountOverride.d.ts +0 -2
- package/config/defaultAccountOverride.js +0 -57
- package/config/utils.d.ts +0 -70
- package/config/utils.js +0 -328
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadConfigFromEnvironment = void 0;
|
|
4
|
+
const logger_1 = require("../lib/logger");
|
|
5
|
+
const environments_1 = require("../constants/environments");
|
|
6
|
+
const auth_1 = require("../constants/auth");
|
|
7
|
+
const configUtils_1 = require("./configUtils");
|
|
8
|
+
const environment_1 = require("../lib/environment");
|
|
9
|
+
const lang_1 = require("../utils/lang");
|
|
10
|
+
const i18nKey = 'config.environment';
|
|
11
|
+
function getConfigVariablesFromEnv() {
|
|
12
|
+
const env = process.env;
|
|
13
|
+
return {
|
|
14
|
+
apiKey: env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_API_KEY],
|
|
15
|
+
clientId: env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_CLIENT_ID],
|
|
16
|
+
clientSecret: env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_CLIENT_SECRET],
|
|
17
|
+
personalAccessKey: env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_PERSONAL_ACCESS_KEY],
|
|
18
|
+
accountId: parseInt(env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_ACCOUNT_ID], 10),
|
|
19
|
+
refreshToken: env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_REFRESH_TOKEN],
|
|
20
|
+
env: (0, environment_1.getValidEnv)(env[environments_1.ENVIRONMENT_VARIABLES.HUBSPOT_ENVIRONMENT]),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function loadConfigFromEnvironment() {
|
|
24
|
+
const { apiKey, clientId, clientSecret, personalAccessKey, accountId, refreshToken, env, } = getConfigVariablesFromEnv();
|
|
25
|
+
if (!accountId) {
|
|
26
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.missingAccountId`));
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (!env) {
|
|
30
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.missingEnv`));
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (personalAccessKey) {
|
|
34
|
+
return (0, configUtils_1.generateConfig)(auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value, {
|
|
35
|
+
accountId,
|
|
36
|
+
personalAccessKey,
|
|
37
|
+
env,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else if (clientId && clientSecret && refreshToken) {
|
|
41
|
+
return (0, configUtils_1.generateConfig)(auth_1.OAUTH_AUTH_METHOD.value, {
|
|
42
|
+
accountId,
|
|
43
|
+
clientId,
|
|
44
|
+
clientSecret,
|
|
45
|
+
refreshToken,
|
|
46
|
+
scopes: auth_1.OAUTH_SCOPES.map((scope) => scope.value),
|
|
47
|
+
env,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (apiKey) {
|
|
51
|
+
return (0, configUtils_1.generateConfig)(auth_1.API_KEY_AUTH_METHOD.value, {
|
|
52
|
+
accountId,
|
|
53
|
+
apiKey,
|
|
54
|
+
env,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.loadConfig.unknownAuthType`));
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
exports.loadConfigFromEnvironment = loadConfigFromEnvironment;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAccountIdentifier = void 0;
|
|
4
|
+
function getAccountIdentifier(account) {
|
|
5
|
+
if (!account) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
else if (Object.hasOwn(account, 'portalId')) {
|
|
9
|
+
return account.portalId;
|
|
10
|
+
}
|
|
11
|
+
else if (Object.hasOwn(account, 'accountId')) {
|
|
12
|
+
return account.accountId;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.getAccountIdentifier = getAccountIdentifier;
|
package/config/index.d.ts
CHANGED
|
@@ -1,27 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as config_DEPRECATED from './config_DEPRECATED';
|
|
2
|
+
import { CLIConfig_NEW, CLIConfig } from '../types/Config';
|
|
3
|
+
import { CLIOptions, WriteConfigOptions } from '../types/CLIOptions';
|
|
4
|
+
import { AccountType, CLIAccount, CLIAccount_NEW, CLIAccount_DEPRECATED, FlatAccountFields } from '../types/Accounts';
|
|
3
5
|
import { CmsPublishMode } from '../types/Files';
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export declare function loadConfig(path: string, options?: CLIOptions): CLIConfig | null;
|
|
7
|
+
export declare function getAndLoadConfigIfNeeded(options?: CLIOptions): Partial<CLIConfig> | null;
|
|
8
|
+
export declare function validateConfig(): boolean;
|
|
9
|
+
export declare function loadConfigFromEnvironment(): boolean;
|
|
10
|
+
export declare function createEmptyConfigFile(options?: {
|
|
11
|
+
path?: string;
|
|
12
|
+
}, useHiddenConfig?: boolean): void;
|
|
13
|
+
export declare function deleteEmptyConfigFile(): void;
|
|
14
|
+
export declare function getConfig(): CLIConfig | null;
|
|
15
|
+
export declare function writeConfig(options?: WriteConfigOptions): void;
|
|
16
|
+
export declare function getConfigPath(path?: string, useHiddenConfig?: boolean): string | null;
|
|
17
|
+
export declare function configFileExists(useHiddenConfig?: boolean, path?: string): boolean;
|
|
18
|
+
export declare function getAccountConfig(accountId?: number): CLIAccount | null;
|
|
19
|
+
export declare function accountNameExistsInConfig(name: string): boolean;
|
|
20
|
+
export declare function updateAccountConfig(configOptions: Partial<FlatAccountFields>): FlatAccountFields | null;
|
|
21
|
+
export declare function updateDefaultAccount(nameOrId: string | number): void;
|
|
22
|
+
export declare function renameAccount(currentName: string, newName: string): Promise<void>;
|
|
23
|
+
export declare function getAccountId(nameOrId?: string | number): number | null;
|
|
24
|
+
export declare function removeSandboxAccountFromConfig(nameOrId: string | number): boolean;
|
|
25
|
+
export declare function deleteAccount(accountName: string): Promise<void | boolean>;
|
|
26
|
+
export declare function updateHttpTimeout(timeout: string): void;
|
|
27
|
+
export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
11
28
|
export declare function deleteConfigFile(): void;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare
|
|
22
|
-
export declare
|
|
23
|
-
export declare
|
|
24
|
-
export declare
|
|
25
|
-
export declare
|
|
26
|
-
export declare
|
|
27
|
-
export declare function isConfigFlagEnabled(flag: ConfigFlag, defaultValue?: boolean): boolean;
|
|
29
|
+
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
30
|
+
export declare function isTrackingAllowed(): boolean;
|
|
31
|
+
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
32
|
+
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
33
|
+
export declare function getConfigDefaultAccount(): string | number | null | undefined;
|
|
34
|
+
export declare function getConfigAccounts(): Array<CLIAccount_NEW> | Array<CLIAccount_DEPRECATED> | null | undefined;
|
|
35
|
+
export declare function updateDefaultCmsPublishMode(cmsPublishMode: CmsPublishMode): void | CLIConfig_NEW | null;
|
|
36
|
+
export declare function getCWDAccountOverride(): string | number | null | undefined;
|
|
37
|
+
export declare function getDefaultAccountOverrideFilePath(): string | null | undefined;
|
|
38
|
+
export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
|
|
39
|
+
export declare const getOrderedAccount: typeof config_DEPRECATED.getOrderedAccount;
|
|
40
|
+
export declare const getOrderedConfig: typeof config_DEPRECATED.getOrderedConfig;
|
|
41
|
+
export declare const setConfig: typeof config_DEPRECATED.setConfig;
|
|
42
|
+
export declare const setConfigPath: typeof config_DEPRECATED.setConfigPath;
|
|
43
|
+
export declare const findConfig: typeof config_DEPRECATED.findConfig;
|