@hubspot/local-dev-lib 0.0.9 → 0.0.10

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.
@@ -26,7 +26,7 @@ export declare function loadConfig(path?: string, options?: CLIOptions): CLIConf
26
26
  export declare function isTrackingAllowed(): boolean;
27
27
  export declare function getAndLoadConfigIfNeeded(options?: {}): Partial<CLIConfig_DEPRECATED>;
28
28
  export declare function findConfig(directory: string): string | null;
29
- export declare function getEnv(nameOrId: string | number): Environment;
29
+ export declare function getEnv(nameOrId?: string | number): Environment;
30
30
  export declare function getAccountConfig(accountId: number | undefined): CLIAccount_DEPRECATED | undefined;
31
31
  export declare function getAccountId(nameOrId?: string | number): number | undefined;
32
32
  /**
package/config/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare function updateAllowUsageTracking(isEnabled: boolean): void;
26
26
  export declare function deleteConfigFile(): void;
27
27
  export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
28
28
  export declare function isTrackingAllowed(): boolean;
29
- export declare function getEnv(nameOrId: string | number): import("../types/Config").Environment;
29
+ export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
30
30
  export declare const getConfigAccounts: typeof config_DEPRECATED.getConfigAccounts;
31
31
  export declare const getConfigDefaultAccount: typeof config_DEPRECATED.getConfigDefaultAccount;
32
32
  export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
@@ -1,2 +1,5 @@
1
1
  import { BaseError, FileSystemErrorContext } from '../types/Error';
2
+ /**
3
+ * @throws
4
+ */
2
5
  export declare function throwFileSystemError(error: BaseError, context: FileSystemErrorContext): void;
@@ -4,6 +4,9 @@ exports.throwFileSystemError = void 0;
4
4
  const lang_1 = require("../utils/lang");
5
5
  const standardErrors_1 = require("./standardErrors");
6
6
  const i18nKey = 'errors.fileSystemErrors';
7
+ /**
8
+ * @throws
9
+ */
7
10
  function throwFileSystemError(error, context) {
8
11
  let fileAction = '';
9
12
  if (context.read) {
@@ -10,10 +10,13 @@ const findup_sync_1 = __importDefault(require("findup-sync"));
10
10
  const path_2 = require("../path");
11
11
  const github_1 = require("../github");
12
12
  const logger_1 = require("../../utils/logger");
13
- const objectUtils_1 = require("../../utils/objectUtils");
14
13
  const standardErrors_1 = require("../../errors/standardErrors");
15
14
  const fileSystemErrors_1 = require("../../errors/fileSystemErrors");
16
15
  const i18nKey = 'lib.cms.functions';
16
+ function isObjectOrFunction(value) {
17
+ const type = typeof value;
18
+ return value != null && (type === 'object' || type === 'function');
19
+ }
17
20
  function createEndpoint(endpointMethod, filename) {
18
21
  return {
19
22
  method: endpointMethod || 'GET',
@@ -62,7 +65,7 @@ function updateExistingConfig(configFilePath, { endpointPath, endpointMethod, fu
62
65
  read: true,
63
66
  });
64
67
  }
65
- if (!(0, objectUtils_1.isObject)(config)) {
68
+ if (!isObjectOrFunction(config)) {
66
69
  (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateExistingConfig.errors.configIsNotObjectError`, { configFilePath });
67
70
  }
68
71
  if (config.endpoints) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getValidEnv = void 0;
4
4
  const environments_1 = require("../constants/environments");
5
5
  function getValidEnv(env, maskedProductionValue) {
6
- const prodValue = maskedProductionValue
6
+ const prodValue = typeof maskedProductionValue === 'string'
7
7
  ? maskedProductionValue
8
8
  : environments_1.ENVIRONMENTS.PROD;
9
9
  const returnVal = typeof env &&
@@ -30,7 +30,7 @@ export declare class Logger {
30
30
  }
31
31
  export declare function setLogger(logger: Logger): void;
32
32
  export declare function setLogLevel(level: number): void;
33
- export declare function shouldLog(level: number): number;
33
+ export declare function shouldLog(level: number): boolean;
34
34
  export declare function getLogLevel(): number;
35
35
  export declare const logger: {
36
36
  error(...args: any[]): void;
@@ -88,7 +88,7 @@ function setLogLevel(level) {
88
88
  }
89
89
  exports.setLogLevel = setLogLevel;
90
90
  function shouldLog(level) {
91
- return currentLogLevel & level;
91
+ return !!(currentLogLevel & level);
92
92
  }
93
93
  exports.shouldLog = shouldLog;
94
94
  function getLogLevel() {
package/lib/text.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function commaSeparatedValues(arr: Array<string>, conjunction?: string, ifempty?: string): string;
1
+ export declare function commaSeparatedValues(arr: Array<string>, conjunction?: null | string, ifempty?: string): string;
@@ -1 +1 @@
1
- export declare function trackUsage(eventName: string, eventClass: string, meta: {} | undefined, accountId: number): Promise<void>;
1
+ export declare function trackUsage(eventName: string, eventClass: string, meta?: {}, accountId?: number): Promise<void>;
package/lib/trackUsage.js CHANGED
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.trackUsage = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const getAxiosConfig_1 = require("../http/getAxiosConfig");
7
9
  const logger_1 = require("../utils/logger");
8
10
  const http_1 = __importDefault(require("../http"));
9
11
  const config_1 = require("../config");
@@ -42,12 +44,13 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
42
44
  });
43
45
  }
44
46
  const env = (0, config_1.getEnv)(accountId);
45
- (0, logger_1.debug)(`${i18nKey}.sendingEventUnauthenticated`);
46
- http_1.default.post(accountId, {
47
+ const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
47
48
  env,
48
49
  url: path,
49
50
  data: usageEvent,
50
51
  resolveWithFullResponse: true,
51
52
  });
53
+ (0, logger_1.debug)(`${i18nKey}.sendingEventUnauthenticated`);
54
+ (0, axios_1.default)({ ...axiosConfig, method: 'post' });
52
55
  }
53
56
  exports.trackUsage = trackUsage;
package/lib/validate.js CHANGED
@@ -7,8 +7,8 @@ exports.lint = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const extensions_1 = require("../constants/extensions");
9
9
  const validateHubl_1 = require("../api/validateHubl");
10
- const fs_1 = require("../lib/fs");
11
- const path_1 = require("../lib/path");
10
+ const fs_1 = require("./fs");
11
+ const path_1 = require("./path");
12
12
  async function lint(accountId, filepath, callback) {
13
13
  const stats = await fs_extra_1.default.stat(filepath);
14
14
  const files = stats.isDirectory() ? await (0, fs_1.walk)(filepath) : [filepath];
@@ -20,7 +20,9 @@ class OAuth2Manager {
20
20
  this.writeTokenInfo = writeTokenInfo;
21
21
  this.refreshTokenRequest = null;
22
22
  this.account = account;
23
- // NOTE: Potential issues by not using maskProductionValue = '' for env like in cli-lib
23
+ if (this.account.env) {
24
+ this.account.env = (0, environment_1.getValidEnv)(this.account.env, '');
25
+ }
24
26
  }
25
27
  async accessToken() {
26
28
  if (!this.account.auth.tokenInfo?.refreshToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- export declare function isObject(value: object): boolean;
1
+ export declare function isObject(item: any): any;
2
2
  export declare function mergeDeep(target: {
3
3
  [key: string]: any;
4
4
  }, ...sources: Array<{
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeDeep = exports.isObject = void 0;
4
- function isObject(value) {
5
- const type = typeof value;
6
- return value != null && (type === 'object' || type === 'function');
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ function isObject(item) {
6
+ return item && typeof item === 'object' && !Array.isArray(item);
7
7
  }
8
8
  exports.isObject = isObject;
9
9
  function mergeDeep(