@hubspot/cli 7.7.34-experimental.0 → 7.8.0-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/bin/cli.js +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/getStarted.test.js +2 -2
- package/commands/__tests__/mcp.test.js +1 -1
- package/commands/__tests__/project.test.js +0 -3
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -6
- package/commands/app/migrate.js +13 -19
- package/commands/app/secret/add.js +2 -1
- package/commands/app/secret/delete.js +2 -1
- package/commands/app/secret/list.js +2 -1
- package/commands/app/secret/update.js +2 -1
- package/commands/app/secret.js +2 -1
- package/commands/app.js +3 -8
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +16 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -37
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +7 -12
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.d.ts +0 -2
- package/commands/getStarted.js +4 -4
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mcp/__tests__/setup.test.js +2 -2
- package/commands/mcp/setup.js +11 -2
- package/commands/mcp.js +3 -3
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +4 -2
- package/commands/project/__tests__/create.test.js +6 -6
- package/commands/project/__tests__/deploy.test.js +3 -7
- package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/logs.test.js +1 -4
- package/commands/project/__tests__/migrate.test.js +6 -7
- package/commands/project/__tests__/migrateApp.test.js +3 -7
- package/commands/project/__tests__/profile.test.js +1 -1
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.js +4 -8
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +3 -10
- package/commands/project/deploy.js +5 -5
- package/commands/project/dev/deprecatedFlow.js +7 -16
- package/commands/project/dev/index.js +16 -13
- package/commands/project/dev/unifiedFlow.js +8 -4
- package/commands/project/download.js +10 -14
- package/commands/project/installDeps.js +8 -9
- package/commands/project/listBuilds.js +12 -21
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +41 -13
- package/commands/project/migrateApp.js +10 -17
- package/commands/project/open.js +6 -14
- package/commands/project/profile/add.js +3 -3
- package/commands/project/profile/delete.js +1 -2
- package/commands/project/profile.js +2 -3
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +17 -26
- package/commands/project/validate.js +7 -7
- package/commands/project/watch.js +13 -22
- package/commands/project.js +2 -3
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +35 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +0 -3
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/testAccount/importData.d.ts +1 -1
- package/commands/testAccount/importData.js +1 -1
- package/commands/testAccount.js +1 -1
- package/lang/en.d.ts +317 -120
- package/lang/en.js +312 -118
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -1
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +19 -56
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.d.ts +2 -8
- package/lib/app/migrate.js +5 -80
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.js +25 -57
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +13 -0
- package/lib/constants.js +17 -0
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +10 -17
- package/lib/lang.js +6 -5
- package/lib/links.d.ts +1 -0
- package/lib/links.js +14 -7
- package/lib/mcp/setup.js +1 -1
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +78 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/fireAlarmMiddleware.js +15 -5
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projectProfiles.d.ts +1 -1
- package/lib/projectProfiles.js +2 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +2 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +227 -16
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +86 -60
- package/lib/projects/__tests__/deploy.test.js +71 -6
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +6 -2
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v3AddComponent.test.js +4 -4
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v3.test.js +80 -5
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/v3.js +10 -8
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
- package/lib/projects/localDev/AppDevModeInterface.js +21 -12
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +27 -6
- package/lib/projects/localDev/LocalDevManager.js +4 -5
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +90 -19
- package/lib/projects/localDev/LocalDevState.d.ts +9 -8
- package/lib/projects/localDev/LocalDevState.js +18 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +2 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +62 -33
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +42 -1
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +4 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +10 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +2 -3
- package/lib/projects/upload.js +17 -9
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.js +8 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +30 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectProjectTemplatePrompt.js +2 -0
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.d.ts +1 -0
- package/lib/theme/__tests__/migrate.test.js +233 -0
- package/lib/theme/migrate.d.ts +13 -0
- package/lib/theme/migrate.js +90 -0
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.js +38 -37
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +68 -0
- package/lib/ui/uiMessages.js +71 -0
- package/lib/usageTracking.js +8 -8
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +5 -5
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +12 -6
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +12 -10
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -7
- package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
- package/mcp-server/utils/cliConfig.d.ts +1 -0
- package/mcp-server/utils/cliConfig.js +12 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +4 -4
- package/types/LocalDev.d.ts +19 -3
- package/types/Yargs.d.ts +1 -1
- package/ui/index.js +1 -1
- package/commands/app/__tests__/install.test.js +0 -47
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -122
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- /package/commands/{app/__tests__/install.test.d.ts → project/__tests__/validate.test.d.ts} +0 -0
- /package/lib/middleware/__test__/{utils.test.d.ts → commandTargetingUtils.test.d.ts} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare const uiMessages: {
|
|
2
|
+
betaTag: string;
|
|
3
|
+
deprecatedTag: string;
|
|
4
|
+
deprecatedDescription: (message: string, command: string, url?: string) => string;
|
|
5
|
+
disabledMessage: (command: string, url?: string) => string;
|
|
6
|
+
disabledUrlText: string;
|
|
7
|
+
featureHighlight: {
|
|
8
|
+
defaultTitle: string;
|
|
9
|
+
featureKeys: {
|
|
10
|
+
accountOption: {
|
|
11
|
+
command: string;
|
|
12
|
+
message: (command: string) => string;
|
|
13
|
+
};
|
|
14
|
+
accountsListCommand: {
|
|
15
|
+
command: string;
|
|
16
|
+
message: (command: string) => string;
|
|
17
|
+
};
|
|
18
|
+
accountsUseCommand: {
|
|
19
|
+
command: string;
|
|
20
|
+
message: (command: string) => string;
|
|
21
|
+
};
|
|
22
|
+
authCommand: {
|
|
23
|
+
command: string;
|
|
24
|
+
message: (command: string) => string;
|
|
25
|
+
};
|
|
26
|
+
feedbackCommand: {
|
|
27
|
+
command: string;
|
|
28
|
+
message: (command: string) => string;
|
|
29
|
+
};
|
|
30
|
+
helpCommand: {
|
|
31
|
+
command: string;
|
|
32
|
+
message: (command: string) => string;
|
|
33
|
+
};
|
|
34
|
+
projectCreateCommand: {
|
|
35
|
+
command: string;
|
|
36
|
+
message: (command: string) => string;
|
|
37
|
+
};
|
|
38
|
+
projectDeployCommand: {
|
|
39
|
+
command: string;
|
|
40
|
+
message: (command: string) => string;
|
|
41
|
+
};
|
|
42
|
+
projectHelpCommand: {
|
|
43
|
+
command: string;
|
|
44
|
+
message: (command: string) => string;
|
|
45
|
+
};
|
|
46
|
+
projectUploadCommand: {
|
|
47
|
+
command: string;
|
|
48
|
+
message: (command: string) => string;
|
|
49
|
+
};
|
|
50
|
+
projectDevCommand: {
|
|
51
|
+
command: string;
|
|
52
|
+
message: (command: string) => string;
|
|
53
|
+
};
|
|
54
|
+
projectInstallDepsCommand: {
|
|
55
|
+
command: string;
|
|
56
|
+
message: (command: string) => string;
|
|
57
|
+
};
|
|
58
|
+
projectCommandTip: {
|
|
59
|
+
message: string;
|
|
60
|
+
};
|
|
61
|
+
sampleProjects: {
|
|
62
|
+
linkText: string;
|
|
63
|
+
url: string;
|
|
64
|
+
message: (link: string) => string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// UI messages for the UI module - separate file to avoid circular imports with lang/en.ts
|
|
2
|
+
// This contains the same strings that would be in lib.ui.* from lang/en.ts
|
|
3
|
+
import { uiCommandReference, uiLink } from './index.js';
|
|
4
|
+
export const uiMessages = {
|
|
5
|
+
betaTag: '[BETA]',
|
|
6
|
+
deprecatedTag: '[DEPRECATED]',
|
|
7
|
+
deprecatedDescription: (message, command, url) => `${message}. The ${uiCommandReference(command)} command is deprecated and will be disabled soon. ${url ? uiLink('Learn more', url) : ''}`,
|
|
8
|
+
disabledMessage: (command, url) => `The ${uiCommandReference(command)} command is disabled. Run ${uiCommandReference('npm i -g @hubspot/cli@latest')} to update to the latest HubSpot CLI version. ${url ? uiLink('Learn more', url) : ''}`,
|
|
9
|
+
disabledUrlText: 'See all HubSpot CLI commands here.',
|
|
10
|
+
featureHighlight: {
|
|
11
|
+
defaultTitle: "What's next?",
|
|
12
|
+
featureKeys: {
|
|
13
|
+
accountOption: {
|
|
14
|
+
command: '--account',
|
|
15
|
+
message: (command) => `Use the ${command} option with any command to override the default account`,
|
|
16
|
+
},
|
|
17
|
+
accountsListCommand: {
|
|
18
|
+
command: 'hs accounts list',
|
|
19
|
+
message: (command) => `${command} - See a list of configured HubSpot accounts`,
|
|
20
|
+
},
|
|
21
|
+
accountsUseCommand: {
|
|
22
|
+
command: 'hs accounts use',
|
|
23
|
+
message: (command) => `${command} - Set the Hubspot account that the CLI will target by default`,
|
|
24
|
+
},
|
|
25
|
+
authCommand: {
|
|
26
|
+
command: 'hs auth',
|
|
27
|
+
message: (command) => `${command} - Connect the CLI to additional HubSpot accounts`,
|
|
28
|
+
},
|
|
29
|
+
feedbackCommand: {
|
|
30
|
+
command: 'hs feedback',
|
|
31
|
+
message: (command) => `${command} - Report a bug or leave feedback`,
|
|
32
|
+
},
|
|
33
|
+
helpCommand: {
|
|
34
|
+
command: 'hs help',
|
|
35
|
+
message: (command) => `${command} - See a list of available commands`,
|
|
36
|
+
},
|
|
37
|
+
projectCreateCommand: {
|
|
38
|
+
command: 'hs project create',
|
|
39
|
+
message: (command) => `${command} - Create a new project`,
|
|
40
|
+
},
|
|
41
|
+
projectDeployCommand: {
|
|
42
|
+
command: 'hs project deploy',
|
|
43
|
+
message: (command) => `Ready to take your project live? Run ${command}`,
|
|
44
|
+
},
|
|
45
|
+
projectHelpCommand: {
|
|
46
|
+
command: 'hs project --help',
|
|
47
|
+
message: (command) => `${command} - Learn more about available project commands`,
|
|
48
|
+
},
|
|
49
|
+
projectUploadCommand: {
|
|
50
|
+
command: 'hs project upload',
|
|
51
|
+
message: (command) => `${command} - Upload your project to HubSpot and trigger builds`,
|
|
52
|
+
},
|
|
53
|
+
projectDevCommand: {
|
|
54
|
+
command: 'hs project dev',
|
|
55
|
+
message: (command) => `${command} - Set up a test environment and start local development`,
|
|
56
|
+
},
|
|
57
|
+
projectInstallDepsCommand: {
|
|
58
|
+
command: 'hs project install-deps',
|
|
59
|
+
message: (command) => `${command} - Install all project dependencies`,
|
|
60
|
+
},
|
|
61
|
+
projectCommandTip: {
|
|
62
|
+
message: 'Tip: All project commands must be run from within a project directory',
|
|
63
|
+
},
|
|
64
|
+
sampleProjects: {
|
|
65
|
+
linkText: "HubSpot's sample projects",
|
|
66
|
+
url: 'https://developers.hubspot.com/docs/platform/sample-projects?utm_source=cli&utm_content=project_create_whats_next',
|
|
67
|
+
message: (link) => `See ${link}`,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
package/lib/usageTracking.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { trackUsage } from '@hubspot/local-dev-lib/trackUsage';
|
|
2
2
|
import { isTrackingAllowed, getAccountConfig, } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { API_KEY_AUTH_METHOD } from '@hubspot/local-dev-lib/constants/auth';
|
|
4
|
-
import {
|
|
4
|
+
import { uiLogger } from './ui/logger.js';
|
|
5
5
|
import packageJson from '../package.json' with { type: 'json' };
|
|
6
6
|
const version = packageJson.version;
|
|
7
7
|
import { debugError } from './errorHandlers/index.js';
|
|
@@ -31,7 +31,7 @@ export async function trackCommandUsage(command, meta = {}, accountId) {
|
|
|
31
31
|
if (!isTrackingAllowed()) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
uiLogger.debug(`Attempting to track usage of "${command}" command`);
|
|
35
35
|
let authType = 'unknown';
|
|
36
36
|
if (accountId) {
|
|
37
37
|
const accountConfig = getAccountConfig(accountId);
|
|
@@ -44,7 +44,7 @@ export async function trackCommandUsage(command, meta = {}, accountId) {
|
|
|
44
44
|
action: 'cli-command',
|
|
45
45
|
command,
|
|
46
46
|
authType,
|
|
47
|
-
|
|
47
|
+
meta,
|
|
48
48
|
accountId,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -53,10 +53,10 @@ export async function trackHelpUsage(command) {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
if (command) {
|
|
56
|
-
|
|
56
|
+
uiLogger.debug(`Tracking help usage of "${command}" sub-command`);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
|
|
59
|
+
uiLogger.debug('Tracking help usage of main command');
|
|
60
60
|
}
|
|
61
61
|
return trackCliInteraction({
|
|
62
62
|
action: 'cli-help',
|
|
@@ -84,7 +84,7 @@ export async function trackCommandMetadataUsage(command, meta = {}, accountId) {
|
|
|
84
84
|
if (!isTrackingAllowed()) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
uiLogger.debug(`Attempting to track metadata usage of "${command}" command`);
|
|
88
88
|
let authType = 'unknown';
|
|
89
89
|
if (accountId) {
|
|
90
90
|
const accountConfig = getAccountConfig(accountId);
|
|
@@ -122,7 +122,7 @@ async function trackCliInteraction({ action, accountId, command, authType, meta
|
|
|
122
122
|
action: 'cli-mcp-server',
|
|
123
123
|
type: process.env.HUBSPOT_MCP_AI_AGENT,
|
|
124
124
|
}, accountId);
|
|
125
|
-
|
|
125
|
+
uiLogger.debug('Sent AI usage tracking command event:', {
|
|
126
126
|
...usageTrackingEvent,
|
|
127
127
|
action: 'cli-mcp-server',
|
|
128
128
|
type: process.env.HUBSPOT_MCP_AI_AGENT,
|
|
@@ -133,12 +133,12 @@ async function trackCliInteraction({ action, accountId, command, authType, meta
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
try {
|
|
136
|
+
uiLogger.debug('Sent usage tracking command event:', usageTrackingEvent);
|
|
136
137
|
return trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
|
137
138
|
}
|
|
138
139
|
catch (error) {
|
|
139
140
|
debugError(error);
|
|
140
141
|
}
|
|
141
|
-
logger.debug('Sent usage tracking command event: %o', usageTrackingEvent);
|
|
142
142
|
}
|
|
143
143
|
catch (e) {
|
|
144
144
|
debugError(e);
|
package/lib/validation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { uiLogger } from '../lib/ui/logger.js';
|
|
4
4
|
import { CMS_PUBLISH_MODE } from '@hubspot/local-dev-lib/constants/files';
|
|
5
5
|
import { API_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, PERSONAL_ACCESS_KEY_AUTH_METHOD, } from '@hubspot/local-dev-lib/constants/auth';
|
|
6
6
|
import { commaSeparatedValues } from '@hubspot/local-dev-lib/text';
|
|
@@ -10,43 +10,43 @@ import { accessTokenForPersonalAccessKey } from '@hubspot/local-dev-lib/personal
|
|
|
10
10
|
import { getAbsoluteFilePath, getCwd, getExt, } from '@hubspot/local-dev-lib/path';
|
|
11
11
|
import { getCmsPublishMode } from './commonOpts.js';
|
|
12
12
|
import { logError } from './errorHandlers/index.js';
|
|
13
|
+
import { lib } from '../lang/en.js';
|
|
13
14
|
export async function validateAccount(options) {
|
|
14
15
|
const { derivedAccountId, userProvidedAccount } = options;
|
|
15
16
|
const accountId = getAccountId(derivedAccountId);
|
|
16
17
|
if (!accountId) {
|
|
17
18
|
if (userProvidedAccount) {
|
|
18
|
-
|
|
19
|
+
uiLogger.error(lib.validation.accountNotFoundInConfig(userProvidedAccount));
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
|
|
22
|
+
uiLogger.error(lib.validation.accountRequired);
|
|
22
23
|
}
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
25
26
|
if (userProvidedAccount && loadConfigFromEnvironment()) {
|
|
26
|
-
throw new Error(
|
|
27
|
+
throw new Error(lib.validation.userProvidedAccount);
|
|
27
28
|
}
|
|
28
29
|
const accountConfig = getAccountConfig(accountId);
|
|
29
30
|
if (!accountConfig) {
|
|
30
|
-
|
|
31
|
+
uiLogger.error(lib.validation.accountNotConfigured(accountId));
|
|
31
32
|
return false;
|
|
32
33
|
}
|
|
33
34
|
const { authType, auth, apiKey, personalAccessKey } = accountConfig;
|
|
34
35
|
if (typeof authType === 'string' && authType !== authType.toLowerCase()) {
|
|
35
|
-
|
|
36
|
+
uiLogger.error(lib.validation.invalidAuthType(authType, accountId, getConfigPath() || '', commaSeparatedValues([
|
|
36
37
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
37
38
|
OAUTH_AUTH_METHOD,
|
|
38
39
|
API_KEY_AUTH_METHOD,
|
|
39
|
-
].map(method => method.value))
|
|
40
|
+
].map(method => method.value))));
|
|
40
41
|
}
|
|
41
42
|
if (authType === 'oauth2') {
|
|
42
43
|
if (typeof auth !== 'object') {
|
|
43
|
-
|
|
44
|
+
uiLogger.error(lib.validation.oauth2ConfigMissing(accountId));
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
46
47
|
const { clientId, clientSecret, tokenInfo } = auth;
|
|
47
48
|
if (!clientId || !clientSecret || !tokenInfo || !tokenInfo.refreshToken) {
|
|
48
|
-
|
|
49
|
-
logger.error('Run "hs auth --type=oauth2" to reauthenticate');
|
|
49
|
+
uiLogger.error(lib.validation.oauth2ConfigIncorrect(accountId));
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
52
|
const oauth = getOauthManager(accountId, accountConfig);
|
|
@@ -56,7 +56,7 @@ export async function validateAccount(options) {
|
|
|
56
56
|
accessToken = await oauth.accessToken();
|
|
57
57
|
}
|
|
58
58
|
if (!accessToken) {
|
|
59
|
-
|
|
59
|
+
uiLogger.error(lib.validation.oauth2AccessTokenNotFound(accountId));
|
|
60
60
|
return false;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -67,13 +67,13 @@ export async function validateAccount(options) {
|
|
|
67
67
|
}
|
|
68
68
|
else if (authType === 'personalaccesskey') {
|
|
69
69
|
if (!personalAccessKey) {
|
|
70
|
-
|
|
70
|
+
uiLogger.error(lib.validation.personalAccessKeyMissing(accountId));
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
try {
|
|
74
74
|
const accessToken = await accessTokenForPersonalAccessKey(accountId);
|
|
75
75
|
if (!accessToken) {
|
|
76
|
-
|
|
76
|
+
uiLogger.error(lib.validation.personalAccessKeyTokenRetrievalFailed(accountId));
|
|
77
77
|
return false;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -83,7 +83,7 @@ export async function validateAccount(options) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
else if (!apiKey) {
|
|
86
|
-
|
|
86
|
+
uiLogger.error(lib.validation.authConfigurationMissing(accountId));
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
89
|
return true;
|
|
@@ -93,15 +93,12 @@ export function validateCmsPublishMode(options) {
|
|
|
93
93
|
if (CMS_PUBLISH_MODE[cmsPublishMode]) {
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
96
|
-
const modesMessage =
|
|
96
|
+
const modesMessage = lib.validation.availableCMSModes(Object.values(CMS_PUBLISH_MODE).join(', '));
|
|
97
97
|
if (cmsPublishMode != null) {
|
|
98
|
-
|
|
99
|
-
`The CMS publish mode "${cmsPublishMode}" is invalid.`,
|
|
100
|
-
modesMessage,
|
|
101
|
-
].join(' '));
|
|
98
|
+
uiLogger.error(lib.validation.invalidCmsPublishMode(cmsPublishMode, modesMessage));
|
|
102
99
|
}
|
|
103
100
|
else {
|
|
104
|
-
|
|
101
|
+
uiLogger.error(lib.validation.missingCmsPublishMode(modesMessage));
|
|
105
102
|
}
|
|
106
103
|
return false;
|
|
107
104
|
}
|
|
@@ -124,11 +121,11 @@ export function fileExists(_path) {
|
|
|
124
121
|
export function checkAndConvertToJson(_path) {
|
|
125
122
|
const filePath = getAbsoluteFilePath(_path);
|
|
126
123
|
if (!fileExists(filePath)) {
|
|
127
|
-
|
|
124
|
+
uiLogger.error(lib.validation.pathNotFile(_path));
|
|
128
125
|
return null;
|
|
129
126
|
}
|
|
130
127
|
if (getExt(_path) !== 'json') {
|
|
131
|
-
|
|
128
|
+
uiLogger.error(lib.validation.fileNotJson(_path));
|
|
132
129
|
return null;
|
|
133
130
|
}
|
|
134
131
|
let result;
|
|
@@ -136,7 +133,7 @@ export function checkAndConvertToJson(_path) {
|
|
|
136
133
|
result = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
137
134
|
}
|
|
138
135
|
catch (e) {
|
|
139
|
-
|
|
136
|
+
uiLogger.error(lib.validation.fileInvalidJson(_path));
|
|
140
137
|
result = null;
|
|
141
138
|
}
|
|
142
139
|
return result;
|
package/lib/yargsUtils.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>,
|
|
|
13
13
|
};
|
|
14
14
|
useJSONOutputOptions?: boolean;
|
|
15
15
|
}): (yargs: Argv) => Promise<Argv<T>>;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function strictEnforceBoolean(rawArgs: string[], booleanOptions: string[]): boolean;
|
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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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) {
|
|
@@ -12,13 +12,13 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
12
12
|
addApp: boolean;
|
|
13
13
|
auth?: "oauth" | "static" | undefined;
|
|
14
14
|
distribution?: "marketplace" | "private" | undefined;
|
|
15
|
-
features?: ("card" | "
|
|
15
|
+
features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
|
|
16
16
|
}, {
|
|
17
17
|
absoluteProjectPath: string;
|
|
18
18
|
addApp: boolean;
|
|
19
19
|
auth?: "oauth" | "static" | undefined;
|
|
20
20
|
distribution?: "marketplace" | "private" | undefined;
|
|
21
|
-
features?: ("card" | "
|
|
21
|
+
features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
|
|
22
22
|
}>;
|
|
23
23
|
export type AddFeatureInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
24
24
|
export declare class AddFeatureToProjectTool extends Tool<AddFeatureInputSchema> {
|
|
@@ -16,7 +16,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
16
16
|
name?: string | undefined;
|
|
17
17
|
auth?: "oauth" | "static" | undefined;
|
|
18
18
|
distribution?: "marketplace" | "private" | undefined;
|
|
19
|
-
features?: ("card" | "
|
|
19
|
+
features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
projectBase: "app" | "empty";
|
|
22
22
|
absoluteCurrentWorkingDirectory: string;
|
|
@@ -24,7 +24,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
24
24
|
name?: string | undefined;
|
|
25
25
|
auth?: "oauth" | "static" | undefined;
|
|
26
26
|
distribution?: "marketplace" | "private" | undefined;
|
|
27
|
-
features?: ("card" | "
|
|
27
|
+
features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
|
|
28
28
|
}>;
|
|
29
29
|
export type CreateProjectInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
30
30
|
export declare class CreateProjectTool extends Tool<CreateProjectInputSchema> {
|
|
@@ -2,10 +2,13 @@ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import { TextContentResponse, Tool } from '../../types.js';
|
|
4
4
|
declare const inputSchemaZodObject: z.ZodObject<{
|
|
5
|
+
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
5
6
|
docsSearchQuery: z.ZodString;
|
|
6
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
absoluteCurrentWorkingDirectory: string;
|
|
7
9
|
docsSearchQuery: string;
|
|
8
10
|
}, {
|
|
11
|
+
absoluteCurrentWorkingDirectory: string;
|
|
9
12
|
docsSearchQuery: string;
|
|
10
13
|
}>;
|
|
11
14
|
export interface DocsSearchResponse {
|
|
@@ -20,7 +23,7 @@ export interface DocsSearchResponse {
|
|
|
20
23
|
type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
|
|
21
24
|
export declare class DocsSearchTool extends Tool<InputSchemaType> {
|
|
22
25
|
constructor(mcpServer: McpServer);
|
|
23
|
-
handler({ docsSearchQuery, }: InputSchemaType): Promise<TextContentResponse>;
|
|
26
|
+
handler({ absoluteCurrentWorkingDirectory, docsSearchQuery, }: InputSchemaType): Promise<TextContentResponse>;
|
|
24
27
|
register(): RegisteredTool;
|
|
25
28
|
}
|
|
26
29
|
export {};
|
|
@@ -3,10 +3,11 @@ import z from 'zod';
|
|
|
3
3
|
import { Tool } from '../../types.js';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
5
|
import { trackToolUsage } from '../../utils/toolUsageTracking.js';
|
|
6
|
-
import { docsSearchQuery } from './constants.js';
|
|
7
|
-
import { getAccountId, getConfigPath, loadConfig, } from '@hubspot/local-dev-lib/config';
|
|
6
|
+
import { absoluteCurrentWorkingDirectory, docsSearchQuery, } from './constants.js';
|
|
8
7
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
8
|
+
import { getAccountIdFromCliConfig } from '../../utils/cliConfig.js';
|
|
9
9
|
const inputSchema = {
|
|
10
|
+
absoluteCurrentWorkingDirectory,
|
|
10
11
|
docsSearchQuery,
|
|
11
12
|
};
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -18,10 +19,9 @@ export class DocsSearchTool extends Tool {
|
|
|
18
19
|
constructor(mcpServer) {
|
|
19
20
|
super(mcpServer);
|
|
20
21
|
}
|
|
21
|
-
async handler({ docsSearchQuery, }) {
|
|
22
|
+
async handler({ absoluteCurrentWorkingDirectory, docsSearchQuery, }) {
|
|
22
23
|
await trackToolUsage(toolName, { mode: docsSearchQuery });
|
|
23
|
-
|
|
24
|
-
const accountId = getAccountId();
|
|
24
|
+
const accountId = getAccountIdFromCliConfig(absoluteCurrentWorkingDirectory);
|
|
25
25
|
if (!accountId) {
|
|
26
26
|
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>\``;
|
|
27
27
|
return formatTextContents(authErrorMessage);
|
|
@@ -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 {};
|