@hubspot/cli 7.8.11-experimental.0 → 7.8.12-experimental.1

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.
Files changed (252) hide show
  1. package/bin/cli.js +31 -25
  2. package/commands/__tests__/auth.test.js +5 -0
  3. package/commands/__tests__/doctor.test.js +16 -16
  4. package/commands/account/clean.js +18 -27
  5. package/commands/account/createOverride.js +13 -31
  6. package/commands/account/info.js +20 -31
  7. package/commands/account/list.js +16 -22
  8. package/commands/account/remove.js +12 -20
  9. package/commands/account/removeOverride.js +11 -21
  10. package/commands/account/rename.js +6 -9
  11. package/commands/account/use.js +12 -26
  12. package/commands/account.js +2 -2
  13. package/commands/app/__tests__/migrate.test.js +5 -5
  14. package/commands/app/migrate.js +13 -18
  15. package/commands/auth.d.ts +1 -0
  16. package/commands/auth.js +16 -7
  17. package/commands/cms/convertFields.js +7 -9
  18. package/commands/cms/getReactModule.js +9 -14
  19. package/commands/cms/lighthouseScore.js +33 -36
  20. package/commands/cms.js +2 -2
  21. package/commands/completion.js +3 -3
  22. package/commands/config/set.d.ts +1 -1
  23. package/commands/config/set.js +64 -36
  24. package/commands/config.js +2 -2
  25. package/commands/create.js +2 -2
  26. package/commands/customObject/create.js +10 -12
  27. package/commands/customObject/schema/create.js +9 -11
  28. package/commands/customObject/schema/delete.js +16 -16
  29. package/commands/customObject/schema/fetch-all.js +12 -11
  30. package/commands/customObject/schema/fetch.js +15 -15
  31. package/commands/customObject/schema/list.js +4 -4
  32. package/commands/customObject/schema/update.js +13 -13
  33. package/commands/customObject/schema.js +2 -2
  34. package/commands/customObject.js +6 -7
  35. package/commands/doctor.js +8 -11
  36. package/commands/feedback.js +6 -11
  37. package/commands/fetch.js +8 -8
  38. package/commands/filemanager/fetch.js +7 -7
  39. package/commands/filemanager/upload.js +15 -34
  40. package/commands/filemanager.js +2 -2
  41. package/commands/function/deploy.js +11 -29
  42. package/commands/function/list.js +8 -8
  43. package/commands/function/server.js +9 -11
  44. package/commands/function.d.ts +1 -1
  45. package/commands/function.js +2 -2
  46. package/commands/getStarted.js +2 -2
  47. package/commands/hubdb/clear.js +7 -15
  48. package/commands/hubdb/create.js +9 -15
  49. package/commands/hubdb/delete.js +8 -15
  50. package/commands/hubdb/fetch.js +6 -9
  51. package/commands/hubdb.d.ts +1 -1
  52. package/commands/hubdb.js +2 -2
  53. package/commands/init.js +2 -3
  54. package/commands/lint.js +16 -16
  55. package/commands/list.js +8 -14
  56. package/commands/logs.js +14 -20
  57. package/commands/mv.js +6 -17
  58. package/commands/open.js +5 -5
  59. package/commands/project/__tests__/add.test.js +4 -2
  60. package/commands/project/__tests__/deploy.test.js +3 -4
  61. package/commands/project/__tests__/installDeps.test.js +8 -8
  62. package/commands/project/__tests__/logs.test.js +1 -1
  63. package/commands/project/__tests__/migrate.test.js +5 -5
  64. package/commands/project/__tests__/migrateApp.test.js +2 -5
  65. package/commands/project/__tests__/validate.test.js +98 -0
  66. package/commands/project/add.js +3 -3
  67. package/commands/project/cloneApp.js +14 -19
  68. package/commands/project/create.js +0 -1
  69. package/commands/project/deploy.js +3 -3
  70. package/commands/project/dev/deprecatedFlow.js +7 -16
  71. package/commands/project/dev/index.js +14 -12
  72. package/commands/project/dev/unifiedFlow.js +3 -1
  73. package/commands/project/download.js +10 -13
  74. package/commands/project/installDeps.js +8 -8
  75. package/commands/project/listBuilds.js +11 -20
  76. package/commands/project/logs.js +21 -24
  77. package/commands/project/migrate.js +14 -16
  78. package/commands/project/migrateApp.js +9 -15
  79. package/commands/project/open.js +6 -13
  80. package/commands/project/upload.js +16 -25
  81. package/commands/project/validate.js +6 -6
  82. package/commands/project/watch.js +13 -22
  83. package/commands/project.js +2 -2
  84. package/commands/sandbox/__tests__/create.test.js +5 -5
  85. package/commands/sandbox/create.js +22 -32
  86. package/commands/sandbox/delete.js +38 -63
  87. package/commands/sandbox.js +2 -2
  88. package/commands/secret/addSecret.js +7 -17
  89. package/commands/secret/deleteSecret.js +10 -20
  90. package/commands/secret/listSecret.js +8 -10
  91. package/commands/secret/updateSecret.js +9 -17
  92. package/commands/secret.js +2 -2
  93. package/commands/testAccount/__tests__/delete.test.js +2 -4
  94. package/commands/testAccount/delete.d.ts +4 -3
  95. package/commands/testAccount/delete.js +155 -14
  96. package/commands/theme/preview.js +1 -4
  97. package/lang/en.d.ts +310 -102
  98. package/lang/en.js +351 -147
  99. package/lang/en.lyaml +2 -2
  100. package/lib/__tests__/buildAccount.test.js +2 -1
  101. package/lib/__tests__/commonOpts.test.js +1 -1
  102. package/lib/__tests__/dependencyManagement.test.js +1 -1
  103. package/lib/__tests__/developerTestAccounts.test.js +3 -3
  104. package/lib/__tests__/npm.test.js +1 -1
  105. package/lib/__tests__/oauth.test.js +4 -4
  106. package/lib/__tests__/process.test.js +10 -5
  107. package/lib/__tests__/sandboxSync.test.js +8 -8
  108. package/lib/__tests__/sandboxes.test.js +8 -8
  109. package/lib/__tests__/serverlessLogs.test.js +1 -1
  110. package/lib/__tests__/usageTracking.test.js +5 -5
  111. package/lib/__tests__/validation.test.js +2 -1
  112. package/lib/__tests__/yargsUtils.test.js +83 -9
  113. package/lib/app/__tests__/migrate.test.js +5 -5
  114. package/lib/app/__tests__/migrate_legacy.test.js +1 -1
  115. package/lib/app/migrate.js +1 -1
  116. package/lib/app/migrate_legacy.js +20 -24
  117. package/lib/buildAccount.js +25 -57
  118. package/lib/commonOpts.d.ts +1 -1
  119. package/lib/commonOpts.js +25 -22
  120. package/lib/configOptions.js +7 -0
  121. package/lib/constants.d.ts +6 -1
  122. package/lib/constants.js +10 -1
  123. package/lib/dependencyManagement.js +9 -27
  124. package/lib/developerTestAccounts.js +9 -23
  125. package/lib/doctor/Diagnosis.js +11 -23
  126. package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
  127. package/lib/doctor/Doctor.js +42 -90
  128. package/lib/doctor/__tests__/Doctor.test.js +4 -4
  129. package/lib/errorHandlers/index.js +12 -20
  130. package/lib/errorHandlers/suppressError.js +11 -18
  131. package/lib/lang.js +6 -5
  132. package/lib/links.js +4 -4
  133. package/lib/middleware/__test__/commandTargetingUtils.test.d.ts +1 -0
  134. package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
  135. package/lib/middleware/__test__/configMiddleware.test.js +11 -11
  136. package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
  137. package/lib/middleware/commandTargetingUtils.d.ts +8 -0
  138. package/lib/middleware/commandTargetingUtils.js +78 -0
  139. package/lib/middleware/configMiddleware.d.ts +1 -1
  140. package/lib/middleware/configMiddleware.js +21 -81
  141. package/lib/middleware/fireAlarmMiddleware.js +15 -17
  142. package/lib/middleware/gitMiddleware.js +5 -1
  143. package/lib/middleware/notificationsMiddleware.js +5 -11
  144. package/lib/middleware/yargsChecksMiddleware.js +6 -9
  145. package/lib/npm.js +2 -2
  146. package/lib/oauth.js +5 -5
  147. package/lib/process.js +5 -4
  148. package/lib/projects/__tests__/AppDevModeInterface.test.js +14 -34
  149. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +70 -39
  150. package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
  151. package/lib/projects/__tests__/platformVersion.test.js +8 -8
  152. package/lib/projects/__tests__/projects.test.js +12 -12
  153. package/lib/projects/__tests__/structure.test.js +3 -3
  154. package/lib/projects/__tests__/upload.test.d.ts +1 -0
  155. package/lib/projects/__tests__/upload.test.js +82 -0
  156. package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
  157. package/lib/projects/add/__tests__/v3AddComponent.test.js +4 -4
  158. package/lib/projects/create/__tests__/legacy.test.js +5 -5
  159. package/lib/projects/create/__tests__/v3.test.js +1 -1
  160. package/lib/projects/create/index.js +2 -2
  161. package/lib/projects/create/legacy.js +2 -2
  162. package/lib/projects/create/v3.js +2 -2
  163. package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
  164. package/lib/projects/localDev/AppDevModeInterface.js +22 -20
  165. package/lib/projects/localDev/LocalDevLogger.js +10 -11
  166. package/lib/projects/localDev/LocalDevManager.js +4 -5
  167. package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +0 -1
  168. package/lib/projects/localDev/LocalDevWebsocketServer.js +7 -10
  169. package/lib/projects/localDev/helpers/project.d.ts +1 -0
  170. package/lib/projects/localDev/helpers/project.js +37 -0
  171. package/lib/projects/platformVersion.d.ts +1 -1
  172. package/lib/projects/platformVersion.js +1 -1
  173. package/lib/projects/structure.js +6 -6
  174. package/lib/projects/upload.d.ts +1 -1
  175. package/lib/projects/upload.js +17 -8
  176. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
  177. package/lib/prompts/accountNamePrompt.js +14 -19
  178. package/lib/prompts/accountsPrompt.js +2 -2
  179. package/lib/prompts/cmsFieldPrompt.js +2 -2
  180. package/lib/prompts/createApiSamplePrompt.js +5 -5
  181. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
  182. package/lib/prompts/createFunctionPrompt.js +14 -14
  183. package/lib/prompts/createModulePrompt.js +9 -9
  184. package/lib/prompts/createTemplatePrompt.js +2 -2
  185. package/lib/prompts/downloadProjectPrompt.js +5 -8
  186. package/lib/prompts/personalAccessKeyPrompt.js +3 -3
  187. package/lib/prompts/previewPrompt.js +6 -6
  188. package/lib/prompts/projectAddPrompt.js +6 -0
  189. package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
  190. package/lib/prompts/projectNamePrompt.js +4 -8
  191. package/lib/prompts/projectsLogsPrompt.js +2 -4
  192. package/lib/prompts/promptUtils.js +27 -9
  193. package/lib/prompts/sandboxesPrompt.js +7 -7
  194. package/lib/prompts/secretPrompt.js +3 -3
  195. package/lib/prompts/selectAppPrompt.js +3 -3
  196. package/lib/prompts/selectHubDBTablePrompt.js +9 -13
  197. package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
  198. package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
  199. package/lib/prompts/uploadPrompt.js +5 -5
  200. package/lib/sandboxSync.js +24 -41
  201. package/lib/sandboxes.js +19 -47
  202. package/lib/schema.js +3 -3
  203. package/lib/serverlessLogs.js +11 -13
  204. package/lib/theme/__tests__/migrate.test.js +3 -3
  205. package/lib/theme/migrate.js +2 -2
  206. package/lib/ui/SpinniesManager.d.ts +2 -0
  207. package/lib/ui/SpinniesManager.js +7 -0
  208. package/lib/ui/boxen.js +1 -2
  209. package/lib/ui/git.js +13 -10
  210. package/lib/ui/index.d.ts +4 -0
  211. package/lib/ui/index.js +47 -38
  212. package/lib/ui/serverlessFunctionLogs.js +9 -7
  213. package/lib/ui/uiMessages.d.ts +68 -0
  214. package/lib/ui/uiMessages.js +71 -0
  215. package/lib/usageTracking.js +7 -7
  216. package/lib/validation.js +20 -23
  217. package/lib/yargsUtils.d.ts +1 -1
  218. package/lib/yargsUtils.js +12 -5
  219. package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
  220. package/mcp-server/tools/index.js +4 -0
  221. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
  222. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
  223. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
  224. package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
  225. package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
  226. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
  227. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
  228. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
  229. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
  230. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
  231. package/mcp-server/utils/toolUsageTracking.js +2 -2
  232. package/package.json +7 -7
  233. package/ui/components/BoxWithTitle.d.ts +8 -0
  234. package/ui/components/BoxWithTitle.js +9 -0
  235. package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
  236. package/ui/components/HorizontalSelectPrompt.js +30 -0
  237. package/ui/components/StatusMessageBoxes.d.ts +12 -0
  238. package/ui/components/StatusMessageBoxes.js +31 -0
  239. package/ui/index.d.ts +1 -0
  240. package/ui/index.js +6 -0
  241. package/ui/lib/ui-testing-utils.d.ts +9 -0
  242. package/ui/lib/ui-testing-utils.js +47 -0
  243. package/ui/lib/useTerminalSize.d.ts +13 -0
  244. package/ui/lib/useTerminalSize.js +31 -0
  245. package/ui/styles.d.ts +18 -0
  246. package/ui/styles.js +18 -0
  247. package/ui/views/UiSandbox.d.ts +5 -0
  248. package/ui/views/UiSandbox.js +25 -0
  249. package/lib/middleware/__test__/utils.test.js +0 -51
  250. package/lib/middleware/utils.d.ts +0 -8
  251. package/lib/middleware/utils.js +0 -14
  252. /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
package/lib/yargsUtils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { addCustomHelpOutput, addTestingOptions, addAccountOptions, addConfigOptions, addGlobalOptions, addUseEnvironmentOptions, addCmsPublishModeOptions, addJSONOutputOptions, } from './commonOpts.js';
2
2
  import { hasFlag } from './utils/hasFlag.js';
3
+ import { commands } from '../lang/en.js';
3
4
  // Re-export for backwards compatibility
4
5
  export { hasFlag };
5
6
  export function makeYargsBuilder(callback, command, describe, options = {}) {
@@ -34,9 +35,15 @@ export function makeYargsBuilder(callback, command, describe, options = {}) {
34
35
  return result;
35
36
  };
36
37
  }
37
- export function getExclusiveConflicts(options) {
38
- return options.reduce((acc, curr) => {
39
- acc[curr] = options.filter(s => s !== curr);
40
- return acc;
41
- }, {});
38
+ export function strictEnforceBoolean(rawArgs, booleanOptions) {
39
+ for (const option of booleanOptions) {
40
+ const argIndex = rawArgs.findIndex(arg => arg.startsWith(`--${option}=`));
41
+ if (argIndex !== -1) {
42
+ const value = rawArgs[argIndex].split('=')[1];
43
+ if (value && !['true', 'false'].includes(value.toLowerCase())) {
44
+ throw new Error(commands.config.subcommands.set.errors.invalidBoolean(option, value));
45
+ }
46
+ }
47
+ }
48
+ return true;
42
49
  }
@@ -13,19 +13,19 @@ declare const inputSchemaZodObject: z.ZodObject<{
13
13
  }, "strip", z.ZodTypeAny, {
14
14
  absoluteCurrentWorkingDirectory: string;
15
15
  dest?: string | undefined;
16
- global?: boolean | undefined;
17
16
  moduleLabel?: string | undefined;
18
17
  reactType?: boolean | undefined;
19
18
  contentTypes?: string | undefined;
19
+ global?: boolean | undefined;
20
20
  availableForNewContent?: boolean | undefined;
21
21
  userSuppliedName?: string | undefined;
22
22
  }, {
23
23
  absoluteCurrentWorkingDirectory: string;
24
24
  dest?: string | undefined;
25
- global?: boolean | undefined;
26
25
  moduleLabel?: string | undefined;
27
26
  reactType?: boolean | undefined;
28
27
  contentTypes?: string | undefined;
28
+ global?: boolean | undefined;
29
29
  availableForNewContent?: boolean | undefined;
30
30
  userSuppliedName?: string | undefined;
31
31
  }>;
@@ -7,6 +7,8 @@ import { ValidateProjectTool } from './project/ValidateProjectTool.js';
7
7
  import { GetConfigValuesTool } from './project/GetConfigValuesTool.js';
8
8
  import { DocsSearchTool } from './project/DocsSearchTool.js';
9
9
  import { DocFetchTool } from './project/DocFetchTool.js';
10
+ import { GetApiUsagePatternsByAppIdTool } from './project/GetApiUsagePatternsByAppIdTool.js';
11
+ import { GetApplicationInfoTool } from './project/GetApplicationInfoTool.js';
10
12
  import { HsListTool } from './cms/HsListTool.js';
11
13
  import { HsCreateModuleTool } from './cms/HsCreateModuleTool.js';
12
14
  import { HsCreateTemplateTool } from './cms/HsCreateTemplateTool.js';
@@ -24,6 +26,8 @@ export function registerProjectTools(mcpServer) {
24
26
  new GetConfigValuesTool(mcpServer).register(),
25
27
  new DocsSearchTool(mcpServer).register(),
26
28
  new DocFetchTool(mcpServer).register(),
29
+ new GetApiUsagePatternsByAppIdTool(mcpServer).register(),
30
+ new GetApplicationInfoTool(mcpServer).register(),
27
31
  ];
28
32
  }
29
33
  export function registerCmsTools(mcpServer) {
@@ -0,0 +1,23 @@
1
+ import { TextContentResponse, Tool } from '../../types.js';
2
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { z } from 'zod';
4
+ declare const inputSchemaZodObject: z.ZodObject<{
5
+ appId: z.ZodString;
6
+ startDate: z.ZodOptional<z.ZodString>;
7
+ endDate: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ appId: string;
10
+ startDate?: string | undefined;
11
+ endDate?: string | undefined;
12
+ }, {
13
+ appId: string;
14
+ startDate?: string | undefined;
15
+ endDate?: string | undefined;
16
+ }>;
17
+ export type GetApiUsagePatternsByAppIdInputSchema = z.infer<typeof inputSchemaZodObject>;
18
+ export declare class GetApiUsagePatternsByAppIdTool extends Tool<GetApiUsagePatternsByAppIdInputSchema> {
19
+ constructor(mcpServer: McpServer);
20
+ handler({ appId, startDate, endDate, }: GetApiUsagePatternsByAppIdInputSchema): Promise<TextContentResponse>;
21
+ register(): RegisteredTool;
22
+ }
23
+ export {};
@@ -0,0 +1,68 @@
1
+ import { Tool } from '../../types.js';
2
+ import { z } from 'zod';
3
+ import { trackToolUsage } from '../../utils/toolUsageTracking.js';
4
+ import { http } from '@hubspot/local-dev-lib/http';
5
+ import { formatTextContents } from '../../utils/content.js';
6
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
7
+ import { getAccountId } from '@hubspot/local-dev-lib/config';
8
+ const inputSchema = {
9
+ appId: z
10
+ .string()
11
+ .regex(/^\d+$/, 'App ID must be a numeric string')
12
+ .describe('The numeric app ID as a string (e.g., "3003909"). Use get-applications-info to find available app IDs.'),
13
+ startDate: z
14
+ .string()
15
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'Start date must be in YYYY-MM-DD format')
16
+ .optional()
17
+ .describe('Start date for the usage patterns query in ISO 8601 format (e.g., 2025-01-01).'),
18
+ endDate: z
19
+ .string()
20
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'End date must be in YYYY-MM-DD format')
21
+ .optional()
22
+ .describe('End date for the usage patterns query in ISO 8601 format (e.g., 2025-12-31).'),
23
+ };
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ const inputSchemaZodObject = z.object({ ...inputSchema });
26
+ const toolName = 'get-api-usage-patterns-by-app-id';
27
+ export class GetApiUsagePatternsByAppIdTool extends Tool {
28
+ constructor(mcpServer) {
29
+ super(mcpServer);
30
+ }
31
+ async handler({ appId, startDate, endDate, }) {
32
+ await trackToolUsage(toolName);
33
+ try {
34
+ // Get account ID from CLI config
35
+ const accountId = getAccountId();
36
+ if (!accountId) {
37
+ const authErrorMessage = `No account ID found. Please run \`hs account auth\` to configure an account, or set a default account with \`hs account use <account>\``;
38
+ return formatTextContents(authErrorMessage);
39
+ }
40
+ const response = await http.get(accountId, {
41
+ url: `app/feature/utilization/public/v3/insights/app/${appId}/usage-patterns`,
42
+ params: {
43
+ ...(startDate && { startDate }),
44
+ ...(endDate && { endDate }),
45
+ },
46
+ });
47
+ // Format the response for display
48
+ const { data } = response;
49
+ const formattedResult = JSON.stringify(data, null, 2);
50
+ return formatTextContents(formattedResult);
51
+ }
52
+ catch (error) {
53
+ if (isHubSpotHttpError(error)) {
54
+ // Handle HubSpot-specific HTTP errors
55
+ return formatTextContents(error.toString());
56
+ }
57
+ const errorMessage = `${error instanceof Error ? error.message : String(error)}`;
58
+ return formatTextContents(errorMessage);
59
+ }
60
+ }
61
+ register() {
62
+ return this.mcpServer.registerTool(toolName, {
63
+ title: 'Get API Usage Patterns by App ID',
64
+ description: 'Retrieves detailed API usage pattern analytics for a specific HubSpot application. Requires an appId (string) to identify the target application. Optionally accepts startDate and endDate parameters in YYYY-MM-DD format to filter results within a specific time range. Returns patternSummaries object containing usage statistics including portalPercentage (percentage of portals using this pattern) and numOfPortals (total count of portals) for different usage patterns. This data helps analyze how the application is being used across different HubSpot portals and can inform optimization decisions.',
65
+ inputSchema,
66
+ }, this.handler);
67
+ }
68
+ }
@@ -0,0 +1,11 @@
1
+ import { TextContentResponse, Tool } from '../../types.js';
2
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { z } from 'zod';
4
+ declare const inputSchemaZodObject: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
5
+ export type GetApplicationInfoInputSchema = z.infer<typeof inputSchemaZodObject>;
6
+ export declare class GetApplicationInfoTool extends Tool<GetApplicationInfoInputSchema> {
7
+ constructor(mcpServer: McpServer);
8
+ handler({}: GetApplicationInfoInputSchema): Promise<TextContentResponse>;
9
+ register(): RegisteredTool;
10
+ }
11
+ export {};
@@ -0,0 +1,49 @@
1
+ import { Tool } from '../../types.js';
2
+ import { z } from 'zod';
3
+ import { trackToolUsage } from '../../utils/toolUsageTracking.js';
4
+ import { http } from '@hubspot/local-dev-lib/http';
5
+ import { formatTextContents } from '../../utils/content.js';
6
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
7
+ import { getAccountId } from '@hubspot/local-dev-lib/config';
8
+ const inputSchema = {};
9
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
+ const inputSchemaZodObject = z.object({ ...inputSchema });
11
+ const toolName = 'get-applications-info';
12
+ export class GetApplicationInfoTool extends Tool {
13
+ constructor(mcpServer) {
14
+ super(mcpServer);
15
+ }
16
+ async handler({}) {
17
+ await trackToolUsage(toolName);
18
+ try {
19
+ // Get account ID from CLI config
20
+ const accountId = getAccountId();
21
+ if (!accountId) {
22
+ const authErrorMessage = `No account ID found. Please run \`hs account auth\` to configure an account, or set a default account with \`hs account use <account>\``;
23
+ return formatTextContents(authErrorMessage);
24
+ }
25
+ const response = await http.get(accountId, {
26
+ url: `app/feature/utilization/public/v3/insights/apps`,
27
+ });
28
+ // Format the response for display
29
+ const { data } = response;
30
+ const formattedResult = JSON.stringify(data, null, 2);
31
+ return formatTextContents(formattedResult);
32
+ }
33
+ catch (error) {
34
+ if (isHubSpotHttpError(error)) {
35
+ // Handle HubSpot-specific HTTP errors
36
+ return formatTextContents(error.toString());
37
+ }
38
+ const errorMessage = `${error instanceof Error ? error.message : String(error)}`;
39
+ return formatTextContents(errorMessage);
40
+ }
41
+ }
42
+ register() {
43
+ return this.mcpServer.registerTool(toolName, {
44
+ title: 'Get Applications Information',
45
+ description: 'Retrieves a list of all HubSpot applications available in the current account. Returns an array of applications, where each application contains an appId (numeric identifier) and appName (string). This information is useful for identifying available applications before using other tools that require specific application IDs, such as getting API usage patterns. No input parameters are required - this tool fetches all applications from the HubSpot Insights API.',
46
+ inputSchema,
47
+ }, this.handler);
48
+ }
49
+ }
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  import { formatTextContents } from '../../utils/content.js';
4
4
  import { absoluteCurrentWorkingDirectory } from './constants.js';
5
5
  import { getIntermediateRepresentationSchema, mapToInternalType, } from '@hubspot/project-parsing-lib';
6
- import { useV3Api } from '../../../lib/projects/platformVersion.js';
6
+ import { isV2Project } from '../../../lib/projects/platformVersion.js';
7
7
  import { getAccountIdFromCliConfig } from '../../utils/cliConfig.js';
8
8
  const inputSchema = {
9
9
  absoluteCurrentWorkingDirectory,
@@ -25,7 +25,7 @@ export class GetConfigValuesTool extends Tool {
25
25
  }
26
26
  async handler({ absoluteCurrentWorkingDirectory, platformVersion, featureType, }) {
27
27
  try {
28
- if (!useV3Api(platformVersion)) {
28
+ if (!isV2Project(platformVersion)) {
29
29
  return formatTextContents(`Can only be used on projects with a minimum platformVersion of 2025.2`);
30
30
  }
31
31
  const accountId = getAccountIdFromCliConfig(absoluteCurrentWorkingDirectory);
@@ -4,9 +4,9 @@ import { z } from 'zod';
4
4
  declare const inputSchemaZodObject: z.ZodObject<{
5
5
  command: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"hs init">, z.ZodLiteral<"hs auth">, z.ZodLiteral<"hs project create">, z.ZodLiteral<"hs project upload">]>>;
6
6
  }, "strip", z.ZodTypeAny, {
7
- command?: "hs auth" | "hs project upload" | "hs project create" | "hs init" | undefined;
7
+ command?: "hs auth" | "hs project create" | "hs project upload" | "hs init" | undefined;
8
8
  }, {
9
- command?: "hs auth" | "hs project upload" | "hs project create" | "hs init" | undefined;
9
+ command?: "hs auth" | "hs project create" | "hs project upload" | "hs init" | undefined;
10
10
  }>;
11
11
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
12
12
  export declare class GuidedWalkthroughTool extends Tool<InputSchemaType> {
@@ -0,0 +1,169 @@
1
+ import { GetApiUsagePatternsByAppIdTool } from '../GetApiUsagePatternsByAppIdTool.js';
2
+ import { z } from 'zod';
3
+ import { getAccountId } from '@hubspot/local-dev-lib/config';
4
+ import { http } from '@hubspot/local-dev-lib/http';
5
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
6
+ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
7
+ vi.mock('../../../utils/toolUsageTracking');
8
+ vi.mock('@hubspot/local-dev-lib/http');
9
+ vi.mock('@hubspot/local-dev-lib/errors/index');
10
+ vi.mock('@hubspot/local-dev-lib/config');
11
+ const mockGetAccountId = getAccountId;
12
+ const mockHttp = http;
13
+ const mockIsHubSpotHttpError = isHubSpotHttpError;
14
+ describe('mcp-server/tools/project/GetApiUsagePatternsByAppIdTool', () => {
15
+ let mockMcpServer;
16
+ let tool;
17
+ let mockRegisteredTool;
18
+ beforeEach(() => {
19
+ vi.clearAllMocks();
20
+ // @ts-expect-error Not mocking the whole thing
21
+ mockMcpServer = {
22
+ registerTool: vi.fn(),
23
+ };
24
+ mockRegisteredTool = {};
25
+ mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
26
+ tool = new GetApiUsagePatternsByAppIdTool(mockMcpServer);
27
+ });
28
+ describe('register', () => {
29
+ it('should register tool with correct parameters', () => {
30
+ const result = tool.register();
31
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('get-api-usage-patterns-by-app-id', {
32
+ title: 'Get API Usage Patterns by App ID',
33
+ description: 'Retrieves detailed API usage pattern analytics for a specific HubSpot application. Requires an appId (string) to identify the target application. Optionally accepts startDate and endDate parameters in YYYY-MM-DD format to filter results within a specific time range. Returns patternSummaries object containing usage statistics including portalPercentage (percentage of portals using this pattern) and numOfPortals (total count of portals) for different usage patterns. This data helps analyze how the application is being used across different HubSpot portals and can inform optimization decisions.',
34
+ inputSchema: expect.objectContaining({
35
+ appId: expect.objectContaining({
36
+ describe: expect.any(Function),
37
+ }),
38
+ startDate: expect.objectContaining({
39
+ optional: expect.any(Function),
40
+ }),
41
+ endDate: expect.objectContaining({
42
+ optional: expect.any(Function),
43
+ }),
44
+ }),
45
+ }, tool.handler);
46
+ expect(result).toBe(mockRegisteredTool);
47
+ });
48
+ });
49
+ describe('input validation', () => {
50
+ const inputSchema = z.object({
51
+ appId: z
52
+ .string()
53
+ .describe('The application ID to get API usage patterns for.'),
54
+ startDate: z
55
+ .string()
56
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'Start date must be in YYYY-MM-DD format')
57
+ .optional()
58
+ .describe('Start date for the usage patterns query in ISO 8601 format (e.g., 2025-01-01).'),
59
+ endDate: z
60
+ .string()
61
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'End date must be in YYYY-MM-DD format')
62
+ .optional()
63
+ .describe('End date for the usage patterns query in ISO 8601 format (e.g., 2025-12-31).'),
64
+ });
65
+ it('should validate date format correctly', () => {
66
+ const validInput = {
67
+ appId: '12345',
68
+ startDate: '2025-01-01',
69
+ endDate: '2025-12-31',
70
+ };
71
+ const invalidInput = {
72
+ appId: '12345',
73
+ startDate: '2025-1-1',
74
+ endDate: '2025-12-31T00:00:00Z',
75
+ };
76
+ expect(() => inputSchema.parse(validInput)).not.toThrow();
77
+ expect(() => inputSchema.parse(invalidInput)).toThrow();
78
+ });
79
+ });
80
+ describe('handler', () => {
81
+ const input = {
82
+ appId: '12345',
83
+ startDate: '2025-01-01',
84
+ endDate: '2025-12-31',
85
+ };
86
+ beforeEach(() => {
87
+ mockGetAccountId.mockReturnValue(123456789);
88
+ mockIsHubSpotHttpError.mockReturnValue(false);
89
+ });
90
+ it('should return API usage patterns successfully', async () => {
91
+ const mockResponse = {
92
+ data: {
93
+ patternSummaries: {
94
+ additionalProp1: {
95
+ portalPercentage: 25.5,
96
+ numOfPortals: 150,
97
+ },
98
+ additionalProp2: {
99
+ portalPercentage: 18.2,
100
+ numOfPortals: 89,
101
+ },
102
+ additionalProp3: {
103
+ portalPercentage: 32.1,
104
+ numOfPortals: 201,
105
+ },
106
+ },
107
+ },
108
+ status: 200,
109
+ statusText: 'OK',
110
+ headers: {},
111
+ config: { headers: {} },
112
+ };
113
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
+ mockHttp.get.mockResolvedValue(mockResponse);
115
+ const result = await tool.handler(input);
116
+ expect(mockGetAccountId).toHaveBeenCalledWith();
117
+ expect(mockHttp.get).toHaveBeenCalledWith(123456789, {
118
+ url: 'app/feature/utilization/public/v3/insights/app/12345/usage-patterns',
119
+ params: {
120
+ startDate: '2025-01-01',
121
+ endDate: '2025-12-31',
122
+ },
123
+ });
124
+ expect(result).toEqual({
125
+ content: [
126
+ {
127
+ type: 'text',
128
+ text: JSON.stringify(mockResponse.data, null, 2),
129
+ },
130
+ ],
131
+ });
132
+ });
133
+ it('should return error when account ID cannot be determined', async () => {
134
+ mockGetAccountId.mockReturnValue(null);
135
+ const result = await tool.handler(input);
136
+ expect(result).toEqual({
137
+ content: [
138
+ {
139
+ type: 'text',
140
+ text: 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`',
141
+ },
142
+ ],
143
+ });
144
+ expect(mockHttp.get).not.toHaveBeenCalled();
145
+ });
146
+ it('should handle empty usage patterns response', async () => {
147
+ const mockResponse = {
148
+ data: {
149
+ patternSummaries: {},
150
+ },
151
+ status: 200,
152
+ statusText: 'OK',
153
+ headers: {},
154
+ config: { headers: {} },
155
+ };
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
+ mockHttp.get.mockResolvedValue(mockResponse);
158
+ const result = await tool.handler(input);
159
+ expect(result).toEqual({
160
+ content: [
161
+ {
162
+ type: 'text',
163
+ text: JSON.stringify(mockResponse.data, null, 2),
164
+ },
165
+ ],
166
+ });
167
+ });
168
+ });
169
+ });
@@ -0,0 +1,115 @@
1
+ import { GetApplicationInfoTool } from '../GetApplicationInfoTool.js';
2
+ import { getAccountId } from '@hubspot/local-dev-lib/config';
3
+ import { http } from '@hubspot/local-dev-lib/http';
4
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
5
+ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
6
+ vi.mock('../../utils/toolUsageTracking');
7
+ vi.mock('@hubspot/local-dev-lib/http');
8
+ vi.mock('@hubspot/local-dev-lib/errors/index');
9
+ vi.mock('@hubspot/local-dev-lib/config');
10
+ const mockGetAccountId = getAccountId;
11
+ const mockHttp = http;
12
+ const mockIsHubSpotHttpError = isHubSpotHttpError;
13
+ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
14
+ let mockMcpServer;
15
+ let tool;
16
+ let mockRegisteredTool;
17
+ beforeEach(() => {
18
+ vi.clearAllMocks();
19
+ // @ts-expect-error Not mocking the whole thing
20
+ mockMcpServer = {
21
+ registerTool: vi.fn(),
22
+ };
23
+ mockRegisteredTool = {};
24
+ mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
25
+ tool = new GetApplicationInfoTool(mockMcpServer);
26
+ });
27
+ describe('register', () => {
28
+ it('should register tool with correct parameters', () => {
29
+ const result = tool.register();
30
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('get-applications-info', {
31
+ title: 'Get Applications Information',
32
+ description: 'Retrieves a list of all HubSpot applications available in the current account. Returns an array of applications, where each application contains an appId (numeric identifier) and appName (string). This information is useful for identifying available applications before using other tools that require specific application IDs, such as getting API usage patterns. No input parameters are required - this tool fetches all applications from the HubSpot Insights API.',
33
+ inputSchema: {},
34
+ }, tool.handler);
35
+ expect(result).toBe(mockRegisteredTool);
36
+ });
37
+ });
38
+ describe('handler', () => {
39
+ const input = {};
40
+ beforeEach(() => {
41
+ mockGetAccountId.mockReturnValue(123456789);
42
+ mockIsHubSpotHttpError.mockReturnValue(false);
43
+ });
44
+ it('should return application information successfully', async () => {
45
+ const mockResponse = {
46
+ data: {
47
+ applications: [
48
+ {
49
+ appId: 12345,
50
+ appName: 'Test App 1',
51
+ },
52
+ {
53
+ appId: 67890,
54
+ appName: 'Test App 2',
55
+ },
56
+ ],
57
+ },
58
+ status: 200,
59
+ statusText: 'OK',
60
+ headers: {},
61
+ config: { headers: {} },
62
+ };
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ mockHttp.get.mockResolvedValue(mockResponse);
65
+ const result = await tool.handler(input);
66
+ expect(mockGetAccountId).toHaveBeenCalledWith();
67
+ expect(mockHttp.get).toHaveBeenCalledWith(123456789, {
68
+ url: 'app/feature/utilization/public/v3/insights/apps',
69
+ });
70
+ expect(result).toEqual({
71
+ content: [
72
+ {
73
+ type: 'text',
74
+ text: JSON.stringify(mockResponse.data, null, 2),
75
+ },
76
+ ],
77
+ });
78
+ });
79
+ it('should return error when account ID cannot be determined', async () => {
80
+ mockGetAccountId.mockReturnValue(null);
81
+ const result = await tool.handler(input);
82
+ expect(result).toEqual({
83
+ content: [
84
+ {
85
+ type: 'text',
86
+ text: 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`',
87
+ },
88
+ ],
89
+ });
90
+ expect(mockHttp.get).not.toHaveBeenCalled();
91
+ });
92
+ it('should handle empty applications response', async () => {
93
+ const mockResponse = {
94
+ data: {
95
+ applications: [],
96
+ },
97
+ status: 200,
98
+ statusText: 'OK',
99
+ headers: {},
100
+ config: { headers: {} },
101
+ };
102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
+ mockHttp.get.mockResolvedValue(mockResponse);
104
+ const result = await tool.handler(input);
105
+ expect(result).toEqual({
106
+ content: [
107
+ {
108
+ type: 'text',
109
+ text: JSON.stringify(mockResponse.data, null, 2),
110
+ },
111
+ ],
112
+ });
113
+ });
114
+ });
115
+ });
@@ -1,7 +1,7 @@
1
1
  import { trackUsage } from '@hubspot/local-dev-lib/trackUsage';
2
- import { logger } from '@hubspot/local-dev-lib/logger';
3
2
  import { EventClass, getNodeVersionData, getPlatform, } from '../../lib/usageTracking.js';
4
3
  import { getAccountId, isTrackingAllowed } from '@hubspot/local-dev-lib/config';
4
+ import { uiLogger } from '../../lib/ui/logger.js';
5
5
  export async function trackToolUsage(toolName, meta) {
6
6
  if (!isTrackingAllowed()) {
7
7
  return;
@@ -16,7 +16,7 @@ export async function trackToolUsage(toolName, meta) {
16
16
  };
17
17
  const accountId = getAccountId() || undefined;
18
18
  try {
19
- logger.info('Tracking tool usage');
19
+ uiLogger.info('Tracking tool usage');
20
20
  await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
21
21
  }
22
22
  catch (error) { }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.8.11-experimental.0",
3
+ "version": "7.8.12-experimental.1",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
7
7
  "type": "module",
8
8
  "dependencies": {
9
- "@hubspot/local-dev-lib": "3.19.1",
10
- "@hubspot/project-parsing-lib": "0.8.6",
9
+ "@hubspot/local-dev-lib": "3.20.0",
10
+ "@hubspot/project-parsing-lib": "0.10.0-beta.0",
11
11
  "@hubspot/serverless-dev-runtime": "7.0.6",
12
12
  "@hubspot/theme-preview-dev-server": "0.0.10",
13
- "@hubspot/ui-extensions-dev-server": "0.10.0",
13
+ "@hubspot/ui-extensions-dev-server": "0.10.1",
14
14
  "archiver": "7.0.1",
15
15
  "boxen": "8.0.1",
16
16
  "chalk": "5.4.1",
@@ -20,6 +20,7 @@
20
20
  "express": "4.21.2",
21
21
  "findup-sync": "4.0.0",
22
22
  "fs-extra": "8.1.0",
23
+ "ink": "5.2.1",
23
24
  "inquirer": "12.7.0",
24
25
  "js-yaml": "4.1.0",
25
26
  "moment": "2.30.1",
@@ -28,7 +29,7 @@
28
29
  "react": "^18.0.0",
29
30
  "strip-ansi": "7.1.0",
30
31
  "table": "6.9.0",
31
- "tmp": "0.2.3",
32
+ "tmp": "0.2.4",
32
33
  "update-notifier": "7.3.1",
33
34
  "ws": "^8.18.2",
34
35
  "yargs": "17.7.2",
@@ -51,11 +52,10 @@
51
52
  "@types/yargs": "^17.0.33",
52
53
  "@typescript-eslint/eslint-plugin": "^8.30.1",
53
54
  "@typescript-eslint/parser": "^8.11.0",
54
- "axios": "^1.7.4",
55
+ "axios": "^1.12.2",
55
56
  "eslint": "^8.56.0",
56
57
  "eslint-plugin-import": "^2.31.0",
57
58
  "husky": "^4.3.8",
58
- "ink": "5.2.1",
59
59
  "lint-staged": "^10.5.4",
60
60
  "madge": "^8.0.0",
61
61
  "mock-stdin": "^1.0.0",
@@ -0,0 +1,8 @@
1
+ export interface BoxWithTitleProps {
2
+ title: string;
3
+ message: string;
4
+ titleBackgroundColor?: string;
5
+ borderColor?: string;
6
+ }
7
+ export declare function getBoxWithTitle(props: BoxWithTitleProps): React.ReactNode;
8
+ export declare function BoxWithTitle({ title, message, titleBackgroundColor, borderColor, }: BoxWithTitleProps): React.ReactNode;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { CONTAINER_STYLES } from '../styles.js';
4
+ export function getBoxWithTitle(props) {
5
+ return _jsx(BoxWithTitle, { ...props });
6
+ }
7
+ export function BoxWithTitle({ title, message, titleBackgroundColor, borderColor, }) {
8
+ return (_jsxs(Box, { ...CONTAINER_STYLES, borderStyle: "round", borderColor: borderColor, children: [_jsx(Box, { position: "absolute", marginTop: -2, paddingX: 0, alignSelf: "flex-start", justifyContent: "center", alignItems: "center", children: _jsx(Text, { backgroundColor: titleBackgroundColor, bold: true, children: ` ${title} ` }) }), _jsx(Box, { justifyContent: "center", alignItems: "center", children: _jsx(Text, { children: message }) })] }));
9
+ }
@@ -0,0 +1,8 @@
1
+ export interface HorizontalSelectPromptProps {
2
+ defaultOption?: string;
3
+ options: string[];
4
+ onSelect: (value: string) => void;
5
+ prompt?: string;
6
+ }
7
+ export declare function getHorizontalSelectPrompt(props: HorizontalSelectPromptProps): React.ReactNode;
8
+ export declare function HorizontalSelectPrompt({ defaultOption, options, onSelect, prompt, }: HorizontalSelectPromptProps): React.ReactNode;