@hubspot/local-dev-lib 0.1.2 → 0.2.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 +0 -1
- package/lib/personalAccessKey.d.ts +1 -2
- package/lib/personalAccessKey.js +13 -6
- package/lib/text.d.ts +0 -1
- package/lib/text.js +1 -9
- package/package.json +1 -1
package/api/localDevAuth.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ type AccessTokenResponse = {
|
|
|
10
10
|
};
|
|
11
11
|
scopeGroups: Array<string>;
|
|
12
12
|
encodedOAuthRefreshToken: string;
|
|
13
|
-
hubName: string;
|
|
14
13
|
};
|
|
15
14
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
16
15
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
|
@@ -6,9 +6,8 @@ type AccessToken = {
|
|
|
6
6
|
expiresAt: string;
|
|
7
7
|
scopeGroups: Array<string>;
|
|
8
8
|
encodedOAuthRefreshToken: string;
|
|
9
|
-
hubName: string;
|
|
10
9
|
};
|
|
11
10
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
12
11
|
export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
|
|
13
|
-
export declare
|
|
12
|
+
export declare const updateConfigWithPersonalAccessKey: (personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean) => Promise<CLIAccount | null>;
|
|
14
13
|
export {};
|
package/lib/personalAccessKey.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.
|
|
6
|
+
exports.updateConfigWithPersonalAccessKey = exports.accessTokenForPersonalAccessKey = exports.getAccessToken = void 0;
|
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
const environments_1 = require("../constants/environments");
|
|
9
9
|
const auth_1 = require("../constants/auth");
|
|
@@ -36,7 +36,6 @@ async function getAccessToken(personalAccessKey, env = environments_1.ENVIRONMEN
|
|
|
36
36
|
expiresAt: (0, moment_1.default)(response.expiresAtMillis).toISOString(),
|
|
37
37
|
scopeGroups: response.scopeGroups,
|
|
38
38
|
encodedOAuthRefreshToken: response.encodedOAuthRefreshToken,
|
|
39
|
-
hubName: response.hubName,
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
exports.getAccessToken = getAccessToken;
|
|
@@ -91,9 +90,17 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
91
90
|
return auth?.tokenInfo?.accessToken;
|
|
92
91
|
}
|
|
93
92
|
exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
// Adds an account to the config using authType: personalAccessKey
|
|
94
|
+
const updateConfigWithPersonalAccessKey = async (personalAccessKey, env, name, makeDefault = false) => {
|
|
96
95
|
const accountEnv = env || (0, config_1.getEnv)(name);
|
|
96
|
+
let token;
|
|
97
|
+
try {
|
|
98
|
+
token = await getAccessToken(personalAccessKey, accountEnv);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
(0, standardErrors_1.throwError)(err);
|
|
102
|
+
}
|
|
103
|
+
const { portalId, accessToken, expiresAt } = token;
|
|
97
104
|
let hubInfo;
|
|
98
105
|
try {
|
|
99
106
|
hubInfo = await (0, sandboxHubs_1.fetchSandboxHubData)(accessToken, portalId, accountEnv);
|
|
@@ -125,5 +132,5 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
|
|
|
125
132
|
(0, config_1.updateDefaultAccount)(name);
|
|
126
133
|
}
|
|
127
134
|
return updatedConfig;
|
|
128
|
-
}
|
|
129
|
-
exports.
|
|
135
|
+
};
|
|
136
|
+
exports.updateConfigWithPersonalAccessKey = updateConfigWithPersonalAccessKey;
|
package/lib/text.d.ts
CHANGED
package/lib/text.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.commaSeparatedValues = void 0;
|
|
4
4
|
function commaSeparatedValues(arr, conjunction = 'and', ifempty = '') {
|
|
5
5
|
const l = arr.length;
|
|
6
6
|
if (!l)
|
|
@@ -14,11 +14,3 @@ function commaSeparatedValues(arr, conjunction = 'and', ifempty = '') {
|
|
|
14
14
|
return arr.join(', ');
|
|
15
15
|
}
|
|
16
16
|
exports.commaSeparatedValues = commaSeparatedValues;
|
|
17
|
-
function toKebabCase(str) {
|
|
18
|
-
return (str
|
|
19
|
-
.replace(/[.,/#!$%^&*;:{}=\-_'"`~()]/g, '')
|
|
20
|
-
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) || [])
|
|
21
|
-
.join('-')
|
|
22
|
-
.toLowerCase();
|
|
23
|
-
}
|
|
24
|
-
exports.toKebabCase = toKebabCase;
|
package/package.json
CHANGED