@hubspot/local-dev-lib 3.21.0-beta.0 → 3.21.1-beta.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/config/migrate.js CHANGED
@@ -105,6 +105,8 @@ function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
105
105
  config_1.ENV,
106
106
  config_1.HTTP_USE_LOCALHOST,
107
107
  config_1.ALLOW_USAGE_TRACKING,
108
+ config_1.AUTO_OPEN_BROWSER,
109
+ config_1.ALLOW_AUTO_UPDATES,
108
110
  ];
109
111
  const conflicts = [];
110
112
  propertiesToCheck.forEach(prop => {
@@ -0,0 +1,3 @@
1
+ import { HubSpotState } from '../types/Config';
2
+ export declare function getStateValue<K extends keyof HubSpotState>(key: K): HubSpotState[K];
3
+ export declare function setStateValue<K extends keyof HubSpotState>(key: K, value: HubSpotState[K]): void;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.setStateValue = exports.getStateValue = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const lang_1 = require("../utils/lang");
30
+ const config_1 = require("../constants/config");
31
+ const logger_1 = require("../lib/logger");
32
+ const i18nKey = 'config.state';
33
+ const DEFAULT_STATE = {
34
+ mcpTotalToolCalls: 0,
35
+ };
36
+ function ensureCLIDirectory() {
37
+ try {
38
+ const dir = path.dirname(config_1.STATE_FILE_PATH);
39
+ if (!fs.existsSync(dir)) {
40
+ fs.mkdirSync(dir, { recursive: true });
41
+ }
42
+ }
43
+ catch (error) {
44
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.ensureCLIDirectory.errors.cannotCreateDirectory`, {
45
+ error: error instanceof Error ? error.message : String(error),
46
+ }));
47
+ }
48
+ }
49
+ function sanitizeAndMerge(parsed) {
50
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
51
+ return structuredClone(DEFAULT_STATE);
52
+ }
53
+ const state = parsed;
54
+ const result = structuredClone(DEFAULT_STATE);
55
+ for (const key in DEFAULT_STATE) {
56
+ const typedKey = key;
57
+ if (key in state &&
58
+ typeof state[typedKey] === typeof DEFAULT_STATE[typedKey]) {
59
+ result[typedKey] = state[typedKey];
60
+ }
61
+ // keys not in parsed file remain as DEFAULT values
62
+ }
63
+ return result;
64
+ }
65
+ function getCurrentState() {
66
+ try {
67
+ if (!fs.existsSync(config_1.STATE_FILE_PATH)) {
68
+ return structuredClone(DEFAULT_STATE);
69
+ }
70
+ const data = fs.readFileSync(config_1.STATE_FILE_PATH, 'utf-8');
71
+ if (!data?.trim()) {
72
+ logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.getCurrentState.debug.emptyStateFile`));
73
+ return structuredClone(DEFAULT_STATE);
74
+ }
75
+ const parsed = JSON.parse(data);
76
+ return sanitizeAndMerge(parsed);
77
+ }
78
+ catch (error) {
79
+ logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.getCurrentState.errors.errorReading`, {
80
+ error: error instanceof Error ? error.message : String(error),
81
+ }));
82
+ return structuredClone(DEFAULT_STATE);
83
+ }
84
+ }
85
+ function getStateValue(key) {
86
+ ensureCLIDirectory();
87
+ const state = getCurrentState();
88
+ return state[key];
89
+ }
90
+ exports.getStateValue = getStateValue;
91
+ function setStateValue(key, value) {
92
+ ensureCLIDirectory();
93
+ const currentState = getCurrentState();
94
+ const newState = { ...currentState, [key]: value };
95
+ try {
96
+ fs.writeFileSync(config_1.STATE_FILE_PATH, JSON.stringify(newState, null, 2), 'utf-8');
97
+ }
98
+ catch (error) {
99
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.setStateValue.errors.failedToWrite`, {
100
+ error: error instanceof Error ? error.message : String(error),
101
+ }));
102
+ }
103
+ }
104
+ exports.setStateValue = setStateValue;
@@ -2,7 +2,9 @@ export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml
2
2
  export declare const ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = "archived.hubspot.config.yml";
3
3
  export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
4
4
  export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
5
+ export declare const HUBSPOT_STATE_FILE = "state.json";
5
6
  export declare const GLOBAL_CONFIG_PATH: string;
7
+ export declare const STATE_FILE_PATH: string;
6
8
  export declare const DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = ".hsaccount";
7
9
  export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID";
8
10
  export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND";
@@ -11,6 +13,8 @@ export declare const HTTP_TIMEOUT = "httpTimeout";
11
13
  export declare const ENV = "env";
12
14
  export declare const HTTP_USE_LOCALHOST = "httpUseLocalhost";
13
15
  export declare const ALLOW_USAGE_TRACKING = "allowUsageTracking";
16
+ export declare const AUTO_OPEN_BROWSER = "autoOpenBrowser";
17
+ export declare const ALLOW_AUTO_UPDATES = "allowAutoUpdates";
14
18
  export declare const DEFAULT_ACCOUNT = "defaultAccount";
15
19
  export declare const DEFAULT_PORTAL = "defaultPortal";
16
20
  export declare const MIN_HTTP_TIMEOUT = 3000;
@@ -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.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
6
+ exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_AUTO_UPDATES = exports.AUTO_OPEN_BROWSER = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.STATE_FILE_PATH = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_STATE_FILE = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
7
7
  const lang_1 = require("../utils/lang");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const os_1 = __importDefault(require("os"));
@@ -11,7 +11,9 @@ exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
11
11
  exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = 'archived.hubspot.config.yml';
12
12
  exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
13
13
  exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
14
+ exports.HUBSPOT_STATE_FILE = 'state.json';
14
15
  exports.GLOBAL_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_CONFIGURATION_FILE);
16
+ exports.STATE_FILE_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_STATE_FILE);
15
17
  exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = '.hsaccount';
16
18
  exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID';
17
19
  exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND';
@@ -20,6 +22,8 @@ exports.HTTP_TIMEOUT = 'httpTimeout';
20
22
  exports.ENV = 'env';
21
23
  exports.HTTP_USE_LOCALHOST = 'httpUseLocalhost';
22
24
  exports.ALLOW_USAGE_TRACKING = 'allowUsageTracking';
25
+ exports.AUTO_OPEN_BROWSER = 'autoOpenBrowser';
26
+ exports.ALLOW_AUTO_UPDATES = 'allowAutoUpdates';
23
27
  exports.DEFAULT_ACCOUNT = 'defaultAccount';
24
28
  exports.DEFAULT_PORTAL = 'defaultPortal';
25
29
  exports.MIN_HTTP_TIMEOUT = 3000;
package/lang/en.json CHANGED
@@ -320,6 +320,26 @@
320
320
  "configUtils": {
321
321
  "unknownType": "Unknown auth type {{ type }}"
322
322
  },
323
+ "state": {
324
+ "ensureCLIDirectory": {
325
+ "errors": {
326
+ "cannotCreateDirectory": "Cannot create CLI state directory: {{ error }}"
327
+ }
328
+ },
329
+ "getCurrentState": {
330
+ "debug": {
331
+ "emptyStateFile": "State file is empty, using default state"
332
+ },
333
+ "errors": {
334
+ "errorReading": "Error reading CLI state, using defaults: {{ error }}"
335
+ }
336
+ },
337
+ "setStateValue": {
338
+ "errors": {
339
+ "failedToWrite": "Failed to write CLI state: {{ error }}"
340
+ }
341
+ }
342
+ },
323
343
  "environment": {
324
344
  "loadConfig": {
325
345
  "missingAccountId": "Unable to load config from environment variables: Missing accountId",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "3.21.0-beta.0",
3
+ "version": "3.21.1-beta.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,6 +52,7 @@
52
52
  "./http/*": "./http/*.js",
53
53
  "./config/getAccountIdentifier": "./config/getAccountIdentifier.js",
54
54
  "./config/migrate": "./config/migrate.js",
55
+ "./config/state": "./config/state.js",
55
56
  "./config": "./config/index.js",
56
57
  "./constants/*": "./constants/*.js",
57
58
  "./models/*": "./models/*.js",
package/types/Config.d.ts CHANGED
@@ -44,3 +44,6 @@ export type GitInclusionResult = {
44
44
  configIgnored: boolean;
45
45
  gitignoreFiles: Array<string>;
46
46
  };
47
+ export type HubSpotState = {
48
+ mcpTotalToolCalls: number;
49
+ };