@hubspot/local-dev-lib 0.1.3-experimental.0 → 0.1.5-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.
@@ -1,7 +1,7 @@
1
1
  import { FetchSchemasResponse, Schema, CreateObjectsResponse } from '../types/Schemas';
2
2
  import { HubSpotPromise } from '../types/Http';
3
- export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): HubSpotPromise<CreateObjectsResponse>;
4
- export declare function createObjectSchema(accountId: number, schema: JSON): HubSpotPromise<Schema>;
3
+ export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: Schema): HubSpotPromise<CreateObjectsResponse>;
4
+ export declare function createObjectSchema(accountId: number, schema: Schema): HubSpotPromise<Schema>;
5
5
  export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema): HubSpotPromise<Schema>;
6
6
  export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): HubSpotPromise<Schema>;
7
7
  export declare function fetchObjectSchemas(accountId: number): HubSpotPromise<FetchSchemasResponse>;
@@ -1,8 +1,9 @@
1
1
  import { Environment } from '../types/Config';
2
- import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse } from '../types/Accounts';
2
+ import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts';
3
3
  import { PublicAppInstallationData } from '../types/Apps';
4
4
  import { HubSpotPromise } from '../types/Http';
5
5
  export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
6
6
  export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
7
+ export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
7
8
  export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
8
9
  export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any>>;
@@ -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.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
6
+ exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeAuthorizationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
7
7
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
8
8
  const http_1 = require("../http");
9
9
  const environments_1 = require("../constants/environments");
@@ -32,6 +32,12 @@ function fetchScopeData(accountId, scopeGroup) {
32
32
  });
33
33
  }
34
34
  exports.fetchScopeData = fetchScopeData;
35
+ async function fetchScopeAuthorizationData(accountId) {
36
+ return http_1.http.get(accountId, {
37
+ url: `${LOCALDEVAUTH_API_AUTH_PATH}/scope-groups/authorized`,
38
+ });
39
+ }
40
+ exports.fetchScopeAuthorizationData = fetchScopeAuthorizationData;
35
41
  function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGroups, optionalScopeGroups = []) {
36
42
  return http_1.http.post(portalId, {
37
43
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/install-info`,
package/config/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare function updateDefaultAccount(nameOrId: string | number): void;
22
22
  export declare function renameAccount(currentName: string, newName: string): Promise<void>;
23
23
  export declare function getAccountId(nameOrId?: string | number): number | null;
24
24
  export declare function removeSandboxAccountFromConfig(nameOrId: string | number): boolean;
25
- export declare function deleteAccount(accountName: string): Promise<void>;
25
+ export declare function deleteAccount(accountName: string): Promise<void | boolean>;
26
26
  export declare function updateHttpTimeout(timeout: string): void;
27
27
  export declare function updateAllowUsageTracking(isEnabled: boolean): void;
28
28
  export declare function deleteConfigFile(): void;
package/config/index.js CHANGED
@@ -145,10 +145,10 @@ function updateDefaultAccount(nameOrId) {
145
145
  exports.updateDefaultAccount = updateDefaultAccount;
146
146
  async function renameAccount(currentName, newName) {
147
147
  if (CLIConfiguration_1.CLIConfiguration.isActive()) {
148
- CLIConfiguration_1.CLIConfiguration.renameAccount(currentName, newName);
148
+ return CLIConfiguration_1.CLIConfiguration.renameAccount(currentName, newName);
149
149
  }
150
150
  else {
151
- config_DEPRECATED.renameAccount(currentName, newName);
151
+ return config_DEPRECATED.renameAccount(currentName, newName);
152
152
  }
153
153
  }
154
154
  exports.renameAccount = renameAccount;
@@ -168,10 +168,10 @@ function removeSandboxAccountFromConfig(nameOrId) {
168
168
  exports.removeSandboxAccountFromConfig = removeSandboxAccountFromConfig;
169
169
  async function deleteAccount(accountName) {
170
170
  if (CLIConfiguration_1.CLIConfiguration.isActive()) {
171
- CLIConfiguration_1.CLIConfiguration.removeAccountFromConfig(accountName);
171
+ return CLIConfiguration_1.CLIConfiguration.removeAccountFromConfig(accountName);
172
172
  }
173
173
  else {
174
- config_DEPRECATED.deleteAccount(accountName);
174
+ return config_DEPRECATED.deleteAccount(accountName);
175
175
  }
176
176
  }
177
177
  exports.deleteAccount = deleteAccount;
@@ -1,4 +1,4 @@
1
- import { CLIAccount } from '../types/Accounts';
1
+ import { CLIAccount, ScopeGroupAuthorization } from '../types/Accounts';
2
2
  import { Environment } from '../types/Config';
3
3
  import { AccessToken } from '../types/Accounts';
4
4
  export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
@@ -7,4 +7,5 @@ export declare function enabledFeaturesForPersonalAccessKey(accountId: number):
7
7
  [key: string]: number;
8
8
  } | undefined>;
9
9
  export declare function scopesOnAccessToken(accountId: number): Promise<Array<string>>;
10
+ export declare function authorizedScopesForPortalAndUser(accountId: number): Promise<Array<ScopeGroupAuthorization>>;
10
11
  export declare function updateConfigWithAccessToken(token: AccessToken, personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean): Promise<CLIAccount | null>;
@@ -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.updateConfigWithAccessToken = exports.scopesOnAccessToken = exports.enabledFeaturesForPersonalAccessKey = exports.accessTokenForPersonalAccessKey = exports.getAccessToken = void 0;
6
+ exports.updateConfigWithAccessToken = exports.authorizedScopesForPortalAndUser = exports.scopesOnAccessToken = exports.enabledFeaturesForPersonalAccessKey = 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");
@@ -107,6 +107,10 @@ async function scopesOnAccessToken(accountId) {
107
107
  return (await getNewAccessTokenByAccountId(accountId)).scopeGroups;
108
108
  }
109
109
  exports.scopesOnAccessToken = scopesOnAccessToken;
110
+ async function authorizedScopesForPortalAndUser(accountId) {
111
+ return (await (0, localDevAuth_1.fetchScopeAuthorizationData)(accountId)).data.results;
112
+ }
113
+ exports.authorizedScopesForPortalAndUser = authorizedScopesForPortalAndUser;
110
114
  async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
111
115
  const { portalId, accessToken, expiresAt, accountType } = token;
112
116
  const accountEnv = env || (0, config_1.getEnv)(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.1.3-experimental.0",
3
+ "version": "0.1.5-experimental.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -92,7 +92,6 @@ export interface FlatAccountFields_NEW extends CLIAccount_NEW {
92
92
  scopes?: Array<string>;
93
93
  apiKey?: string;
94
94
  personalAccessKey?: string;
95
- environment?: Environment;
96
95
  }
97
96
  export interface FlatAccountFields_DEPRECATED extends CLIAccount_DEPRECATED {
98
97
  tokenInfo?: TokenInfo;
@@ -101,13 +100,25 @@ export interface FlatAccountFields_DEPRECATED extends CLIAccount_DEPRECATED {
101
100
  scopes?: Array<string>;
102
101
  apiKey?: string;
103
102
  personalAccessKey?: string;
104
- environment?: Environment;
105
103
  }
106
104
  export type FlatAccountFields = FlatAccountFields_NEW | FlatAccountFields_DEPRECATED;
107
105
  export type ScopeData = {
108
106
  portalScopesInGroup: Array<string>;
109
107
  userScopesInGroup: Array<string>;
110
108
  };
109
+ export type ScopeAuthorizationResponse = {
110
+ results: Array<ScopeGroupAuthorization>;
111
+ };
112
+ export type ScopeGroupAuthorization = {
113
+ scopeGroup: ScopeGroup;
114
+ portalAuthorized: boolean;
115
+ userAuthorized: boolean;
116
+ };
117
+ export type ScopeGroup = {
118
+ name: string;
119
+ shortDescription: string;
120
+ longDescription: string;
121
+ };
111
122
  export type AccessTokenResponse = {
112
123
  hubId: number;
113
124
  userId: number;