@hubspot/local-dev-lib 0.5.0-experimental.1 → 0.5.0-experimental.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/lib/personalAccessKey.js +13 -7
- package/package.json +1 -1
package/lib/personalAccessKey.js
CHANGED
|
@@ -122,9 +122,9 @@ exports.authorizedScopesForPortalAndUser = authorizedScopesForPortalAndUser;
|
|
|
122
122
|
async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
|
|
123
123
|
const { portalId, accessToken, expiresAt, accountType } = token;
|
|
124
124
|
const account = name
|
|
125
|
-
? (0, config_1.
|
|
126
|
-
: (0, config_1.
|
|
127
|
-
const accountEnv = env || account.
|
|
125
|
+
? (0, config_1.getConfigAccountIfExists)(name)
|
|
126
|
+
: (0, config_1.getConfigDefaultAccountIfExists)();
|
|
127
|
+
const accountEnv = env || account?.env || environments_1.ENVIRONMENTS.PROD;
|
|
128
128
|
let parentAccountId;
|
|
129
129
|
try {
|
|
130
130
|
if (accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
|
|
@@ -161,15 +161,21 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
|
|
|
161
161
|
accountId: portalId,
|
|
162
162
|
accountType,
|
|
163
163
|
personalAccessKey,
|
|
164
|
-
name: name || account.
|
|
164
|
+
name: name || account?.name || token.hubName,
|
|
165
165
|
authType: auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
166
166
|
auth: { tokenInfo: { accessToken, expiresAt } },
|
|
167
167
|
parentAccountId,
|
|
168
168
|
env: accountEnv,
|
|
169
169
|
};
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
(0, config_1.
|
|
170
|
+
// Add new account if it doesn't exist, otherwise update existing account
|
|
171
|
+
if (account) {
|
|
172
|
+
(0, config_1.updateConfigAccount)(updatedAccount);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
(0, config_1.addConfigAccount)(updatedAccount);
|
|
176
|
+
}
|
|
177
|
+
if (makeDefault) {
|
|
178
|
+
(0, config_1.setConfigAccountAsDefault)(updatedAccount.accountId);
|
|
173
179
|
}
|
|
174
180
|
return updatedAccount;
|
|
175
181
|
}
|
package/package.json
CHANGED