@hubspot/cli 8.14.0 → 8.15.0-beta.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 (109) hide show
  1. package/commands/cms/theme/preview.js +8 -1
  2. package/commands/getStarted.js +16 -21
  3. package/commands/project/add.js +7 -6
  4. package/commands/project/appInstallStatus.d.ts +1 -1
  5. package/commands/project/appInstallStatus.js +8 -4
  6. package/commands/project/create.js +24 -7
  7. package/commands/project/delete.js +1 -1
  8. package/commands/project/deploy.d.ts +1 -1
  9. package/commands/project/deploy.js +14 -12
  10. package/commands/project/dev/index.js +4 -7
  11. package/commands/project/download.d.ts +3 -2
  12. package/commands/project/download.js +18 -5
  13. package/commands/project/info.d.ts +1 -1
  14. package/commands/project/info.js +8 -5
  15. package/commands/project/installApp.d.ts +1 -1
  16. package/commands/project/installApp.js +9 -4
  17. package/commands/project/installDeps.js +6 -5
  18. package/commands/project/lint.js +16 -9
  19. package/commands/project/list.d.ts +3 -2
  20. package/commands/project/list.js +21 -3
  21. package/commands/project/listBuilds.d.ts +1 -1
  22. package/commands/project/listBuilds.js +4 -8
  23. package/commands/project/migrate.js +14 -19
  24. package/commands/project/open.js +15 -7
  25. package/commands/project/profile/add.js +8 -4
  26. package/commands/project/profile/delete.js +8 -4
  27. package/commands/project/release/create.d.ts +1 -1
  28. package/commands/project/release/create.js +5 -7
  29. package/commands/project/release/info.d.ts +1 -1
  30. package/commands/project/release/info.js +4 -4
  31. package/commands/project/release/list.d.ts +1 -1
  32. package/commands/project/release/list.js +4 -4
  33. package/commands/project/updateDeps.js +6 -5
  34. package/commands/project/upload.d.ts +1 -1
  35. package/commands/project/upload.js +26 -15
  36. package/commands/project/validate.d.ts +3 -2
  37. package/commands/project/validate.js +67 -97
  38. package/commands/project/watch.js +8 -11
  39. package/commands/project.js +1 -1
  40. package/commands/testAccount/create.d.ts +1 -1
  41. package/commands/testAccount/create.js +1 -1
  42. package/lang/en.d.ts +9 -19
  43. package/lang/en.js +9 -19
  44. package/lib/app/migrate.js +5 -7
  45. package/lib/constants.d.ts +0 -1
  46. package/lib/constants.js +0 -1
  47. package/lib/dependencyManagement.js +3 -10
  48. package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -2
  49. package/lib/doctor/DiagnosticInfoBuilder.js +8 -8
  50. package/lib/doctor/Doctor.js +7 -9
  51. package/lib/errors/ProjectErrors.d.ts +0 -6
  52. package/lib/errors/ProjectErrors.js +0 -12
  53. package/lib/errors/ProjectValidationError.d.ts +2 -1
  54. package/lib/errors/ProjectValidationError.js +3 -1
  55. package/lib/filesystem.d.ts +6 -0
  56. package/lib/filesystem.js +9 -0
  57. package/lib/getStartedV2Actions.js +14 -18
  58. package/lib/jsonOutput/appInstallStatus.d.ts +14 -0
  59. package/lib/jsonOutput/appInstallStatus.js +14 -0
  60. package/lib/jsonOutput/createTestAccount.d.ts +7 -0
  61. package/lib/jsonOutput/createTestAccount.js +6 -0
  62. package/lib/jsonOutput/deploy.d.ts +5 -0
  63. package/lib/jsonOutput/deploy.js +4 -0
  64. package/lib/jsonOutput/download.d.ts +7 -0
  65. package/lib/jsonOutput/download.js +6 -0
  66. package/lib/jsonOutput/info.d.ts +21 -0
  67. package/lib/jsonOutput/info.js +19 -0
  68. package/lib/jsonOutput/installApp.d.ts +11 -0
  69. package/lib/jsonOutput/installApp.js +10 -0
  70. package/lib/jsonOutput/listBuilds.d.ts +75 -0
  71. package/lib/jsonOutput/listBuilds.js +65 -0
  72. package/lib/jsonOutput/projectList.d.ts +29 -0
  73. package/lib/jsonOutput/projectList.js +28 -0
  74. package/lib/jsonOutput/release.d.ts +42 -0
  75. package/lib/jsonOutput/release.js +37 -0
  76. package/lib/jsonOutput/upload.d.ts +29 -0
  77. package/lib/jsonOutput/upload.js +23 -0
  78. package/lib/jsonOutput/validate.d.ts +36 -0
  79. package/lib/jsonOutput/validate.js +20 -0
  80. package/lib/npm/packageJson.js +1 -1
  81. package/lib/projects/ProjectLogsManager.js +1 -4
  82. package/lib/projects/config.d.ts +6 -5
  83. package/lib/projects/config.js +7 -38
  84. package/lib/projects/create/tracking.d.ts +1 -0
  85. package/lib/projects/create/tracking.js +27 -0
  86. package/lib/projects/delete.js +14 -1
  87. package/lib/projects/localDev/LocalDevProcess.js +7 -7
  88. package/lib/projects/projectProfiles.d.ts +3 -2
  89. package/lib/projects/projectProfiles.js +8 -3
  90. package/lib/projects/release.js +1 -1
  91. package/lib/projects/uieLinting.d.ts +2 -0
  92. package/lib/projects/uieLinting.js +13 -11
  93. package/lib/projects/upload.d.ts +5 -1
  94. package/lib/projects/upload.js +6 -1
  95. package/lib/projects/validate.d.ts +18 -0
  96. package/lib/projects/validate.js +142 -0
  97. package/lib/projects/validateLintConfigOnUpload.js +6 -5
  98. package/lib/projects/workspaces.js +6 -13
  99. package/lib/theme/migrate.js +1 -4
  100. package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +1 -1
  101. package/mcp-server/tools/project/CreateProjectTool.d.ts +1 -1
  102. package/mcp-server/tools/project/GetBuildLogsTool.js +2 -3
  103. package/mcp-server/tools/project/GetBuildStatusTool.js +2 -3
  104. package/mcp-server/tools/project/UploadProjectTools.js +3 -5
  105. package/mcp-server/tools/project/constants.d.ts +1 -1
  106. package/package.json +3 -3
  107. package/types/Projects.d.ts +1 -5
  108. package/lib/jsonOutput.d.ts +0 -182
  109. package/lib/jsonOutput.js +0 -158
@@ -182,21 +182,14 @@ async function updatePackagesInDirectory({ directory, packages, npmWorkspaceDire
182
182
  }
183
183
  }
184
184
  export async function getProjectPackageJsonLocations(dir, isUpdate = false) {
185
- const projectConfig = await getProjectConfig(dir);
186
- if (!projectConfig ||
187
- !projectConfig.projectDir ||
188
- !projectConfig.projectConfig) {
189
- throw new Error(isUpdate
190
- ? commands.project.updateDeps.noProjectConfig
191
- : commands.project.installDeps.noProjectConfig);
192
- }
193
- const { projectDir, projectConfig: { srcDir, name }, } = projectConfig;
185
+ const { projectConfig, projectDir } = getProjectConfig(dir);
186
+ const { srcDir, name } = projectConfig;
194
187
  if (!(await isGloballyInstalled(DEFAULT_PACKAGE_MANAGER))) {
195
188
  throw new Error(isUpdate
196
189
  ? commands.project.updateDeps.packageManagerNotInstalled(DEFAULT_PACKAGE_MANAGER)
197
190
  : commands.project.installDeps.packageManagerNotInstalled(DEFAULT_PACKAGE_MANAGER));
198
191
  }
199
- if (!fs.existsSync(projectConfig.projectDir) ||
192
+ if (!fs.existsSync(projectDir) ||
200
193
  !fs.existsSync(path.join(projectDir, srcDir))) {
201
194
  throw new NoPackageJsonFilesError(name, isUpdate);
202
195
  }
@@ -1,9 +1,9 @@
1
- import { getProjectConfig } from '../projects/config.js';
2
1
  import { Environment } from '@hubspot/local-dev-lib/types/Accounts';
3
2
  import { AccessToken, AccountType, AuthType } from '@hubspot/local-dev-lib/types/Accounts';
4
3
  import { Project } from '@hubspot/local-dev-lib/types/Project';
5
4
  import process from 'process';
6
- export type ProjectConfig = Awaited<ReturnType<typeof getProjectConfig>>;
5
+ import type { LoadedProjectConfig } from '../projects/config.js';
6
+ export type ProjectConfig = LoadedProjectConfig | undefined;
7
7
  declare const hubspotCli = "@hubspot/cli";
8
8
  interface FilesInfo {
9
9
  files: string[];
@@ -50,12 +50,15 @@ export class DiagnosticInfoBuilder {
50
50
  this.processInfo = processInfo;
51
51
  }
52
52
  async generateDiagnosticInfo() {
53
- this._projectConfig = await getProjectConfig();
54
- if (this._projectConfig?.projectConfig) {
53
+ try {
54
+ this._projectConfig = getProjectConfig();
55
+ }
56
+ catch {
57
+ this._projectConfig = undefined;
58
+ }
59
+ if (this._projectConfig) {
55
60
  await this.fetchProjectDetails();
56
61
  await this.fetchAccessToken();
57
- }
58
- if (this._projectConfig?.projectDir) {
59
62
  await this.fetchProjectFilenames();
60
63
  }
61
64
  const { platform, arch, versions: { node }, mainModule, } = this.processInfo;
@@ -89,9 +92,7 @@ export class DiagnosticInfoBuilder {
89
92
  }
90
93
  async fetchProjectDetails() {
91
94
  try {
92
- const { data } = await fetchProject(this.accountId,
93
- // We check that config exists before running this function
94
- this._projectConfig.projectConfig.name);
95
+ const { data } = await fetchProject(this.accountId, this._projectConfig.projectConfig.name);
95
96
  this.projectDetails = data;
96
97
  }
97
98
  catch (e) {
@@ -109,7 +110,6 @@ export class DiagnosticInfoBuilder {
109
110
  }
110
111
  async fetchProjectFilenames() {
111
112
  try {
112
- // We check that projectDir exists before running this function
113
113
  this.files = (await walk(this._projectConfig.projectDir, ['node_modules'])).map(filename => path.relative(this._projectConfig.projectDir, filename));
114
114
  }
115
115
  catch (e) {
@@ -26,7 +26,7 @@ import { isServerRunningAtUrl } from '../http.js';
26
26
  import { detectConfiguredMcpClients } from '../mcp/promotion.js';
27
27
  import { MCP_CLIENTS } from '../mcp/clients.js';
28
28
  import { WEBHOOKS_KEY, APP_KEY } from '@hubspot/project-parsing-lib/constants';
29
- import { validateProjectConfig } from '../projects/config.js';
29
+ import { validateProjectConfig } from '@hubspot/project-parsing-lib/projects';
30
30
  import { validateSourceDirectory, handleTranslate, } from '../projects/upload.js';
31
31
  import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
32
32
  import { validateProjectForProfile } from '../projects/projectProfiles.js';
@@ -57,7 +57,7 @@ export class Doctor {
57
57
  ...this.performCliChecks(),
58
58
  ...this.performCliConfigChecks(),
59
59
  ...this.performNetworkingChecks(),
60
- ...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
60
+ ...(this.projectConfig ? this.performProjectChecks() : []),
61
61
  ]);
62
62
  this.performDefaultAccountOverrideFileChecks();
63
63
  this.performCliConfigSettingsChecks();
@@ -283,7 +283,7 @@ export class Doctor {
283
283
  for (const packageFile of this.diagnosticInfo?.packageFiles || []) {
284
284
  const packageDirName = path.dirname(packageFile);
285
285
  try {
286
- const needsInstall = await hasMissingPackages(path.join(this.projectConfig?.projectDir || '', packageDirName));
286
+ const needsInstall = await hasMissingPackages(path.join(this.projectConfig?.projectDir ?? '', packageDirName));
287
287
  if (needsInstall) {
288
288
  foundError = true;
289
289
  this.diagnosis?.addProjectSection({
@@ -331,7 +331,7 @@ export class Doctor {
331
331
  async checkProjectConfigJsonFiles() {
332
332
  let foundError = false;
333
333
  for (const jsonFile of this.diagnosticInfo?.jsonFiles || []) {
334
- const fileToCheck = path.join(this.projectConfig?.projectDir || '', jsonFile);
334
+ const fileToCheck = path.join(this.projectConfig?.projectDir ?? '', jsonFile);
335
335
  if (!(await this.isValidJsonFile(fileToCheck))) {
336
336
  foundError = true;
337
337
  this.diagnosis?.addProjectSection({
@@ -432,7 +432,7 @@ export class Doctor {
432
432
  const hsMetaFiles = this.diagnosticInfo?.hsMetaFiles || [];
433
433
  for (const metaFiles of hsMetaFiles) {
434
434
  try {
435
- const content = await fs.promises.readFile(path.join(this.projectConfig?.projectDir || '', metaFiles), 'utf8');
435
+ const content = await fs.promises.readFile(path.join(this.projectConfig?.projectDir ?? '', metaFiles), 'utf8');
436
436
  const contents = JSON.parse(content);
437
437
  if (contents.type === WEBHOOKS_KEY &&
438
438
  contents.config?.settings?.targetUrl) {
@@ -461,7 +461,7 @@ export class Doctor {
461
461
  const hsMetaFiles = this.diagnosticInfo?.hsMetaFiles || [];
462
462
  for (const metaFile of hsMetaFiles) {
463
463
  try {
464
- const content = await fs.promises.readFile(path.join(this.projectConfig?.projectDir || '', metaFile), 'utf8');
464
+ const content = await fs.promises.readFile(path.join(this.projectConfig?.projectDir ?? '', metaFile), 'utf8');
465
465
  const contents = JSON.parse(content);
466
466
  if (contents.type === APP_KEY &&
467
467
  Array.isArray(contents.config?.auth?.redirectUrls)) {
@@ -550,9 +550,7 @@ export class Doctor {
550
550
  }
551
551
  }
552
552
  async checkProjectValidation() {
553
- if (!this.projectConfig?.projectConfig ||
554
- !this.projectConfig?.projectDir ||
555
- !this.accountId) {
553
+ if (!this.projectConfig || !this.accountId) {
556
554
  return;
557
555
  }
558
556
  const { projectConfig, projectDir } = this.projectConfig;
@@ -1,12 +1,6 @@
1
1
  export declare class ProjectNestingError extends Error {
2
2
  constructor(message: string);
3
3
  }
4
- export declare class ProjectConfigNotFoundError extends Error {
5
- constructor(message: string);
6
- }
7
- export declare class ProjectValidationError extends Error {
8
- constructor(message: string);
9
- }
10
4
  export declare class ProjectUploadError extends Error {
11
5
  constructor(message: string, cause?: unknown);
12
6
  }
@@ -4,18 +4,6 @@ export class ProjectNestingError extends Error {
4
4
  this.name = 'ProjectNestingError';
5
5
  }
6
6
  }
7
- export class ProjectConfigNotFoundError extends Error {
8
- constructor(message) {
9
- super(message);
10
- this.name = 'ProjectConfigNotFoundError';
11
- }
12
- }
13
- export class ProjectValidationError extends Error {
14
- constructor(message) {
15
- super(message);
16
- this.name = 'ProjectValidationError';
17
- }
18
- }
19
7
  export class ProjectUploadError extends Error {
20
8
  constructor(message, cause) {
21
9
  super(message, { cause });
@@ -1,4 +1,5 @@
1
+ import { ProjectConfigValidationError } from '@hubspot/project-parsing-lib/projects';
1
2
  export default class ProjectValidationError extends Error {
2
3
  constructor(message: string, options?: ErrorOptions);
3
4
  }
4
- export declare function isProjectValidationError(err: unknown): err is ProjectValidationError;
5
+ export declare function isProjectValidationError(err: unknown): err is ProjectValidationError | ProjectConfigValidationError;
@@ -1,3 +1,4 @@
1
+ import { ProjectConfigValidationError } from '@hubspot/project-parsing-lib/projects';
1
2
  export default class ProjectValidationError extends Error {
2
3
  constructor(message, options) {
3
4
  super(message, options);
@@ -5,5 +6,6 @@ export default class ProjectValidationError extends Error {
5
6
  }
6
7
  }
7
8
  export function isProjectValidationError(err) {
8
- return err instanceof ProjectValidationError;
9
+ return (err instanceof ProjectValidationError ||
10
+ err instanceof ProjectConfigValidationError);
9
11
  }
@@ -1,2 +1,8 @@
1
1
  export declare function resolveLocalPath(filepath?: string): string;
2
+ /**
3
+ * Returns true if childPath is parentDirectory itself or a descendant of it.
4
+ * Compares resolved paths segment by segment, so sibling directories with a
5
+ * shared name prefix (foo-backup vs. foo) are not treated as descendants.
6
+ */
7
+ export declare function isPathInsideDirectory(childPath: string, parentDirectory: string): boolean;
2
8
  export declare function isPathFolder(path: string): boolean;
package/lib/filesystem.js CHANGED
@@ -7,6 +7,15 @@ export function resolveLocalPath(filepath) {
7
7
  : // Use CWD if optional filepath is not passed.
8
8
  getCwd();
9
9
  }
10
+ /**
11
+ * Returns true if childPath is parentDirectory itself or a descendant of it.
12
+ * Compares resolved paths segment by segment, so sibling directories with a
13
+ * shared name prefix (foo-backup vs. foo) are not treated as descendants.
14
+ */
15
+ export function isPathInsideDirectory(childPath, parentDirectory) {
16
+ const relativePath = path.relative(path.resolve(parentDirectory), path.resolve(childPath));
17
+ return !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
18
+ }
10
19
  export function isPathFolder(path) {
11
20
  const splitPath = path.split('/');
12
21
  const fileOrFolderName = splitPath[splitPath.length - 1];
@@ -11,8 +11,8 @@ import { translate, } from '@hubspot/project-parsing-lib/translate';
11
11
  import { commands, lib } from '../lang/en.js';
12
12
  import { getStaticAuthAppInstallUrl } from '../lib/app/urls.js';
13
13
  import { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, PROJECT_CONFIG_FILE, } from '../lib/constants.js';
14
- import { ProjectNestingError, ProjectConfigNotFoundError, ProjectValidationError, ProjectUploadError, ProjectBuildDeployError, } from './errors/ProjectErrors.js';
15
- import { getProjectConfig, validateProjectConfig, writeProjectConfig, } from '../lib/projects/config.js';
14
+ import { ProjectNestingError, ProjectUploadError, ProjectBuildDeployError, } from './errors/ProjectErrors.js';
15
+ import { getProjectConfig, writeProjectConfig, } from '../lib/projects/config.js';
16
16
  import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
17
17
  import { pollProjectBuildAndDeploy } from '../lib/projects/pollProjectBuildAndDeploy.js';
18
18
  import { handleProjectUpload } from '../lib/projects/upload.js';
@@ -29,11 +29,17 @@ export async function createProjectAction({ projectName, projectDest, }) {
29
29
  : 'Invalid project directory');
30
30
  }
31
31
  const projectDestAbsolute = path.resolve(getCwd(), projectDest);
32
- const { projectConfig: existingProjectConfig, projectDir: existingProjectDir, } = await getProjectConfig(projectDestAbsolute);
33
- if (existingProjectConfig &&
34
- existingProjectDir &&
35
- projectDestAbsolute.startsWith(existingProjectDir)) {
36
- throw new ProjectNestingError(commands.project.create.errors.cannotNestProjects(existingProjectDir));
32
+ try {
33
+ const { projectDir: existingProjectDir } = getProjectConfig(projectDestAbsolute);
34
+ if (projectDestAbsolute.startsWith(existingProjectDir)) {
35
+ throw new ProjectNestingError(commands.project.create.errors.cannotNestProjects(existingProjectDir));
36
+ }
37
+ }
38
+ catch (error) {
39
+ if (error instanceof ProjectNestingError) {
40
+ throw error;
41
+ }
42
+ // Not in a project directory, which is the expected case
37
43
  }
38
44
  try {
39
45
  await cloneGithubRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, projectDestAbsolute, {
@@ -88,17 +94,7 @@ async function buildProjectMetadata(projectDir, projectConfig, accountId) {
88
94
  };
89
95
  }
90
96
  export async function uploadAndDeployAction({ accountId, projectDest, }) {
91
- const { projectConfig, projectDir } = await getProjectConfig(projectDest);
92
- if (!projectConfig || !projectDir) {
93
- throw new ProjectConfigNotFoundError(commands.getStarted.errors.configFileNotFound);
94
- }
95
- try {
96
- validateProjectConfig(projectConfig, projectDir);
97
- }
98
- catch (error) {
99
- const message = error instanceof Error ? error.message : String(error);
100
- throw new ProjectValidationError(message);
101
- }
97
+ const { projectConfig, projectDir } = getProjectConfig(projectDest);
102
98
  const env = getConfigAccountEnvironment(accountId);
103
99
  try {
104
100
  const { result, uploadError } = await handleProjectUpload({
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export declare const InstallStatusSchema: z.ZodObject<{
3
+ appId: z.ZodOptional<z.ZodNumber>;
4
+ appUid: z.ZodString;
5
+ accountId: z.ZodNumber;
6
+ projectId: z.ZodNumber;
7
+ isInstalled: z.ZodBoolean;
8
+ isInstalledWithCurrentScopes: z.ZodBoolean;
9
+ previouslyAuthorizedScopeGroups: z.ZodArray<z.ZodObject<{
10
+ id: z.ZodNumber;
11
+ name: z.ZodString;
12
+ }, z.core.$strip>>;
13
+ }, z.core.$strip>;
14
+ export type InstallStatusJsonOutput = z.infer<typeof InstallStatusSchema>;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ const ScopeGroupSchema = z.object({
3
+ id: z.number(),
4
+ name: z.string(),
5
+ });
6
+ export const InstallStatusSchema = z.object({
7
+ appId: z.number().optional(),
8
+ appUid: z.string(),
9
+ accountId: z.number(),
10
+ projectId: z.number(),
11
+ isInstalled: z.boolean(),
12
+ isInstalledWithCurrentScopes: z.boolean(),
13
+ previouslyAuthorizedScopeGroups: z.array(ScopeGroupSchema),
14
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const CreateTestAccountSchema: z.ZodObject<{
3
+ accountName: z.ZodOptional<z.ZodString>;
4
+ accountId: z.ZodOptional<z.ZodNumber>;
5
+ personalAccessKey: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export type CreateTestAccountJsonOutput = z.infer<typeof CreateTestAccountSchema>;
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export const CreateTestAccountSchema = z.object({
3
+ accountName: z.string().optional(),
4
+ accountId: z.number().optional(),
5
+ personalAccessKey: z.string().optional(),
6
+ });
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const DeploySchema: z.ZodObject<{
3
+ deployId: z.ZodOptional<z.ZodNumber>;
4
+ }, z.core.$strip>;
5
+ export type DeployJsonOutput = z.infer<typeof DeploySchema>;
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ export const DeploySchema = z.object({
3
+ deployId: z.number().optional(),
4
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const DownloadSchema: z.ZodObject<{
3
+ projectName: z.ZodString;
4
+ buildId: z.ZodNumber;
5
+ dest: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export type DownloadJsonOutput = z.infer<typeof DownloadSchema>;
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export const DownloadSchema = z.object({
3
+ projectName: z.string(),
4
+ buildId: z.number(),
5
+ dest: z.string(),
6
+ });
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const ProjectInfoSchema: z.ZodObject<{
3
+ projectName: z.ZodString;
4
+ platformVersion: z.ZodString;
5
+ projectId: z.ZodNumber;
6
+ deployedBuildId: z.ZodNumber;
7
+ autoDeployEnabled: z.ZodBoolean;
8
+ projectUrl: z.ZodOptional<z.ZodString>;
9
+ app: z.ZodOptional<z.ZodObject<{
10
+ name: z.ZodString;
11
+ id: z.ZodNumber;
12
+ uid: z.ZodString;
13
+ authType: z.ZodOptional<z.ZodString>;
14
+ distributionType: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>>;
16
+ components: z.ZodArray<z.ZodObject<{
17
+ uid: z.ZodString;
18
+ type: z.ZodString;
19
+ }, z.core.$strip>>;
20
+ }, z.core.$strip>;
21
+ export type ProjectInfoJsonOutput = z.infer<typeof ProjectInfoSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export const ProjectInfoSchema = z.object({
3
+ projectName: z.string(),
4
+ platformVersion: z.string(),
5
+ projectId: z.number(),
6
+ deployedBuildId: z.number(),
7
+ autoDeployEnabled: z.boolean(),
8
+ projectUrl: z.string().optional(),
9
+ app: z
10
+ .object({
11
+ name: z.string(),
12
+ id: z.number(),
13
+ uid: z.string(),
14
+ authType: z.string().optional(),
15
+ distributionType: z.string().optional(),
16
+ })
17
+ .optional(),
18
+ components: z.array(z.object({ uid: z.string(), type: z.string() })),
19
+ });
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ export declare const InstallAppSchema: z.ZodObject<{
3
+ appId: z.ZodNumber;
4
+ appUid: z.ZodString;
5
+ accountId: z.ZodNumber;
6
+ projectId: z.ZodNumber;
7
+ installationState: z.ZodString;
8
+ installed: z.ZodBoolean;
9
+ reinstalled: z.ZodBoolean;
10
+ }, z.core.$strip>;
11
+ export type InstallAppJsonOutput = z.infer<typeof InstallAppSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export const InstallAppSchema = z.object({
3
+ appId: z.number(),
4
+ appUid: z.string(),
5
+ accountId: z.number(),
6
+ projectId: z.number(),
7
+ installationState: z.string(),
8
+ installed: z.boolean(),
9
+ reinstalled: z.boolean(),
10
+ });
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ import { Build } from '@hubspot/local-dev-lib/types/Build';
3
+ declare const BuildSubbuildStatusSchema: z.ZodObject<{
4
+ buildName: z.ZodString;
5
+ buildType: z.ZodString;
6
+ status: z.ZodString;
7
+ errorMessage: z.ZodOptional<z.ZodString>;
8
+ startedAt: z.ZodOptional<z.ZodString>;
9
+ finishedAt: z.ZodOptional<z.ZodString>;
10
+ rootPath: z.ZodOptional<z.ZodString>;
11
+ id: z.ZodOptional<z.ZodString>;
12
+ visible: z.ZodOptional<z.ZodBoolean>;
13
+ }, z.core.$strip>;
14
+ export declare const BuildSchema: z.ZodObject<{
15
+ buildId: z.ZodNumber;
16
+ status: z.ZodString;
17
+ isDeployed: z.ZodBoolean;
18
+ isAutoDeployEnabled: z.ZodOptional<z.ZodBoolean>;
19
+ deployableState: z.ZodOptional<z.ZodString>;
20
+ platformVersion: z.ZodOptional<z.ZodString>;
21
+ uploadMessage: z.ZodOptional<z.ZodString>;
22
+ enqueuedAt: z.ZodOptional<z.ZodString>;
23
+ startedAt: z.ZodOptional<z.ZodString>;
24
+ finishedAt: z.ZodOptional<z.ZodString>;
25
+ createdAt: z.ZodOptional<z.ZodString>;
26
+ subbuildStatuses: z.ZodArray<z.ZodObject<{
27
+ buildName: z.ZodString;
28
+ buildType: z.ZodString;
29
+ status: z.ZodString;
30
+ errorMessage: z.ZodOptional<z.ZodString>;
31
+ startedAt: z.ZodOptional<z.ZodString>;
32
+ finishedAt: z.ZodOptional<z.ZodString>;
33
+ rootPath: z.ZodOptional<z.ZodString>;
34
+ id: z.ZodOptional<z.ZodString>;
35
+ visible: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>>;
37
+ }, z.core.$strip>;
38
+ export declare const ProjectBuildsListSchema: z.ZodObject<{
39
+ projectName: z.ZodString;
40
+ deployedBuildId: z.ZodOptional<z.ZodNumber>;
41
+ results: z.ZodArray<z.ZodObject<{
42
+ buildId: z.ZodNumber;
43
+ status: z.ZodString;
44
+ isDeployed: z.ZodBoolean;
45
+ isAutoDeployEnabled: z.ZodOptional<z.ZodBoolean>;
46
+ deployableState: z.ZodOptional<z.ZodString>;
47
+ platformVersion: z.ZodOptional<z.ZodString>;
48
+ uploadMessage: z.ZodOptional<z.ZodString>;
49
+ enqueuedAt: z.ZodOptional<z.ZodString>;
50
+ startedAt: z.ZodOptional<z.ZodString>;
51
+ finishedAt: z.ZodOptional<z.ZodString>;
52
+ createdAt: z.ZodOptional<z.ZodString>;
53
+ subbuildStatuses: z.ZodArray<z.ZodObject<{
54
+ buildName: z.ZodString;
55
+ buildType: z.ZodString;
56
+ status: z.ZodString;
57
+ errorMessage: z.ZodOptional<z.ZodString>;
58
+ startedAt: z.ZodOptional<z.ZodString>;
59
+ finishedAt: z.ZodOptional<z.ZodString>;
60
+ rootPath: z.ZodOptional<z.ZodString>;
61
+ id: z.ZodOptional<z.ZodString>;
62
+ visible: z.ZodOptional<z.ZodBoolean>;
63
+ }, z.core.$strip>>;
64
+ }, z.core.$strip>>;
65
+ paging: z.ZodOptional<z.ZodObject<{
66
+ next: z.ZodObject<{
67
+ after: z.ZodString;
68
+ }, z.core.$strip>;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>;
71
+ export type BuildSubbuildStatusJsonOutput = z.infer<typeof BuildSubbuildStatusSchema>;
72
+ export type BuildJsonOutput = z.infer<typeof BuildSchema>;
73
+ export type ProjectBuildsListJsonOutput = z.infer<typeof ProjectBuildsListSchema>;
74
+ export declare function mapBuildToJsonOutput(build: Build, deployedBuildId?: number): BuildJsonOutput;
75
+ export {};
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ const BuildSubbuildStatusSchema = z.object({
3
+ buildName: z.string(),
4
+ buildType: z.string(),
5
+ status: z.string(),
6
+ errorMessage: z.string().optional(),
7
+ startedAt: z.string().optional(),
8
+ finishedAt: z.string().optional(),
9
+ rootPath: z.string().optional(),
10
+ id: z.string().optional(),
11
+ visible: z.boolean().optional(),
12
+ });
13
+ export const BuildSchema = z.object({
14
+ buildId: z.number(),
15
+ status: z.string(),
16
+ isDeployed: z.boolean(),
17
+ isAutoDeployEnabled: z.boolean().optional(),
18
+ deployableState: z.string().optional(),
19
+ platformVersion: z.string().optional(),
20
+ uploadMessage: z.string().optional(),
21
+ enqueuedAt: z.string().optional(),
22
+ startedAt: z.string().optional(),
23
+ finishedAt: z.string().optional(),
24
+ createdAt: z.string().optional(),
25
+ subbuildStatuses: z.array(BuildSubbuildStatusSchema),
26
+ });
27
+ export const ProjectBuildsListSchema = z.object({
28
+ projectName: z.string(),
29
+ deployedBuildId: z.number().optional(),
30
+ results: z.array(BuildSchema),
31
+ paging: z
32
+ .object({
33
+ next: z.object({
34
+ after: z.string(),
35
+ }),
36
+ })
37
+ .optional(),
38
+ });
39
+ export function mapBuildToJsonOutput(build, deployedBuildId) {
40
+ const { buildId, status, isAutoDeployEnabled, deployableState, platformVersion, uploadMessage, enqueuedAt, startedAt, finishedAt, createdAt, subbuildStatuses, } = build;
41
+ return {
42
+ buildId,
43
+ status,
44
+ isDeployed: buildId === deployedBuildId,
45
+ isAutoDeployEnabled,
46
+ deployableState,
47
+ platformVersion,
48
+ uploadMessage,
49
+ enqueuedAt,
50
+ startedAt,
51
+ finishedAt,
52
+ createdAt,
53
+ subbuildStatuses: subbuildStatuses.map(subbuild => ({
54
+ buildName: subbuild.buildName,
55
+ buildType: subbuild.buildType,
56
+ status: subbuild.status,
57
+ errorMessage: subbuild.errorMessage,
58
+ startedAt: subbuild.startedAt,
59
+ finishedAt: subbuild.finishedAt,
60
+ rootPath: subbuild.rootPath,
61
+ id: subbuild.id,
62
+ visible: subbuild.visible,
63
+ })),
64
+ };
65
+ }
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { Project } from '@hubspot/local-dev-lib/types/Project';
3
+ declare const ProjectListItemSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ id: z.ZodNumber;
6
+ createdAt: z.ZodNumber;
7
+ updatedAt: z.ZodNumber;
8
+ platformVersion: z.ZodOptional<z.ZodString>;
9
+ latestBuildId: z.ZodOptional<z.ZodNumber>;
10
+ deployedBuildId: z.ZodOptional<z.ZodNumber>;
11
+ isLocked: z.ZodBoolean;
12
+ }, z.core.$strip>;
13
+ export declare const ProjectListSchema: z.ZodObject<{
14
+ accountId: z.ZodNumber;
15
+ results: z.ZodArray<z.ZodObject<{
16
+ name: z.ZodString;
17
+ id: z.ZodNumber;
18
+ createdAt: z.ZodNumber;
19
+ updatedAt: z.ZodNumber;
20
+ platformVersion: z.ZodOptional<z.ZodString>;
21
+ latestBuildId: z.ZodOptional<z.ZodNumber>;
22
+ deployedBuildId: z.ZodOptional<z.ZodNumber>;
23
+ isLocked: z.ZodBoolean;
24
+ }, z.core.$strip>>;
25
+ }, z.core.$strip>;
26
+ export type ProjectListItemJsonOutput = z.infer<typeof ProjectListItemSchema>;
27
+ export type ProjectListJsonOutput = z.infer<typeof ProjectListSchema>;
28
+ export declare function mapProjectToListItem(project: Project): ProjectListItemJsonOutput;
29
+ export {};
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ const ProjectListItemSchema = z.object({
3
+ name: z.string(),
4
+ id: z.number(),
5
+ createdAt: z.number(),
6
+ updatedAt: z.number(),
7
+ platformVersion: z.string().optional(),
8
+ latestBuildId: z.number().optional(),
9
+ deployedBuildId: z.number().optional(),
10
+ isLocked: z.boolean(),
11
+ });
12
+ export const ProjectListSchema = z.object({
13
+ accountId: z.number(),
14
+ results: z.array(ProjectListItemSchema),
15
+ });
16
+ export function mapProjectToListItem(project) {
17
+ const { name, id, createdAt, updatedAt, isLocked, latestBuild, deployedBuildId, } = project;
18
+ return {
19
+ name,
20
+ id,
21
+ createdAt,
22
+ updatedAt,
23
+ platformVersion: latestBuild?.platformVersion,
24
+ latestBuildId: latestBuild?.buildId,
25
+ deployedBuildId,
26
+ isLocked,
27
+ };
28
+ }