@hubspot/local-dev-lib 0.2.0 → 0.2.2
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 +1 -0
- package/lib/personalAccessKey.d.ts +2 -1
- package/lib/personalAccessKey.js +7 -13
- package/lib/text.d.ts +1 -0
- package/lib/text.js +9 -1
- package/package.json +1 -1
package/api/localDevAuth.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ type AccessTokenResponse = {
|
|
|
10
10
|
};
|
|
11
11
|
scopeGroups: Array<string>;
|
|
12
12
|
encodedOAuthRefreshToken: string;
|
|
13
|
+
hubName: string;
|
|
13
14
|
};
|
|
14
15
|
export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
|
|
15
16
|
export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
|
|
@@ -6,8 +6,9 @@ type AccessToken = {
|
|
|
6
6
|
expiresAt: string;
|
|
7
7
|
scopeGroups: Array<string>;
|
|
8
8
|
encodedOAuthRefreshToken: string;
|
|
9
|
+
hubName: string;
|
|
9
10
|
};
|
|
10
11
|
export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
|
|
11
12
|
export declare function accessTokenForPersonalAccessKey(accountId: number): Promise<string | undefined>;
|
|
12
|
-
export declare
|
|
13
|
+
export declare function updateConfigWithAccessToken(token: AccessToken, personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean): Promise<CLIAccount | null>;
|
|
13
14
|
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.updateConfigWithAccessToken = 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,6 +36,7 @@ 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,
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
exports.getAccessToken = getAccessToken;
|
|
@@ -90,17 +91,9 @@ async function accessTokenForPersonalAccessKey(accountId) {
|
|
|
90
91
|
return auth?.tokenInfo?.accessToken;
|
|
91
92
|
}
|
|
92
93
|
exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
|
|
93
|
-
|
|
94
|
-
const updateConfigWithPersonalAccessKey = async (personalAccessKey, env, name, makeDefault = false) => {
|
|
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
|
-
}
|
|
94
|
+
async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
|
|
103
95
|
const { portalId, accessToken, expiresAt } = token;
|
|
96
|
+
const accountEnv = env || (0, config_1.getEnv)(name);
|
|
104
97
|
let hubInfo;
|
|
105
98
|
try {
|
|
106
99
|
hubInfo = await (0, sandboxHubs_1.fetchSandboxHubData)(accessToken, portalId, accountEnv);
|
|
@@ -126,11 +119,12 @@ const updateConfigWithPersonalAccessKey = async (personalAccessKey, env, name, m
|
|
|
126
119
|
tokenInfo: { accessToken, expiresAt },
|
|
127
120
|
sandboxAccountType,
|
|
128
121
|
parentAccountId,
|
|
122
|
+
env: accountEnv,
|
|
129
123
|
});
|
|
130
124
|
(0, config_1.writeConfig)();
|
|
131
125
|
if (makeDefault && name) {
|
|
132
126
|
(0, config_1.updateDefaultAccount)(name);
|
|
133
127
|
}
|
|
134
128
|
return updatedConfig;
|
|
135
|
-
}
|
|
136
|
-
exports.
|
|
129
|
+
}
|
|
130
|
+
exports.updateConfigWithAccessToken = updateConfigWithAccessToken;
|
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.commaSeparatedValues = void 0;
|
|
3
|
+
exports.toKebabCase = exports.commaSeparatedValues = void 0;
|
|
4
4
|
function commaSeparatedValues(arr, conjunction = 'and', ifempty = '') {
|
|
5
5
|
const l = arr.length;
|
|
6
6
|
if (!l)
|
|
@@ -14,3 +14,11 @@ 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