@hubspot/cli 7.0.1 → 7.0.2-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.
Files changed (67) hide show
  1. package/bin/cli.js +7 -2
  2. package/commands/account/info.d.ts +7 -0
  3. package/commands/account/info.js +28 -25
  4. package/commands/account/remove.js +4 -4
  5. package/commands/account/use.js +3 -3
  6. package/commands/auth.js +3 -3
  7. package/commands/function/deploy.js +1 -1
  8. package/commands/init.js +1 -1
  9. package/commands/logs.js +1 -7
  10. package/commands/project/cloneApp.js +1 -1
  11. package/commands/project/create.js +6 -0
  12. package/commands/project/dev.js +4 -3
  13. package/commands/project/installDeps.js +2 -4
  14. package/commands/project/migrateApp.js +1 -1
  15. package/commands/project/upload.js +4 -4
  16. package/commands/project/watch.js +4 -4
  17. package/commands/sandbox/create.js +7 -18
  18. package/commands/sandbox/delete.js +6 -10
  19. package/commands/theme/preview.js +3 -2
  20. package/lang/en.lyaml +11 -4
  21. package/lib/DevServerManager.d.ts +40 -1
  22. package/lib/DevServerManager.js +39 -30
  23. package/lib/LocalDevManager.d.ts +58 -1
  24. package/lib/LocalDevManager.js +162 -121
  25. package/lib/buildAccount.d.ts +12 -0
  26. package/lib/buildAccount.js +110 -95
  27. package/lib/commonOpts.d.ts +4 -8
  28. package/lib/commonOpts.js +2 -14
  29. package/lib/constants.d.ts +1 -7
  30. package/lib/constants.js +2 -8
  31. package/lib/dependencyManagement.d.ts +9 -4
  32. package/lib/dependencyManagement.js +45 -49
  33. package/lib/developerTestAccounts.d.ts +1 -0
  34. package/lib/developerTestAccounts.js +1 -0
  35. package/lib/errorHandlers/index.js +5 -2
  36. package/lib/localDev.d.ts +17 -1
  37. package/lib/localDev.js +203 -203
  38. package/lib/polling.d.ts +13 -5
  39. package/lib/polling.js +21 -7
  40. package/lib/projects/buildAndDeploy.d.ts +1 -7
  41. package/lib/projects/buildAndDeploy.js +3 -3
  42. package/lib/projects/index.js +9 -4
  43. package/lib/projects/structure.d.ts +5 -71
  44. package/lib/projects/structure.js +27 -10
  45. package/lib/projects/upload.d.ts +4 -3
  46. package/lib/projects/upload.js +3 -5
  47. package/lib/prompts/createProjectPrompt.js +8 -1
  48. package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
  49. package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -1
  50. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -2
  51. package/lib/sandboxSync.d.ts +4 -1
  52. package/lib/sandboxSync.js +67 -68
  53. package/lib/sandboxes.d.ts +20 -1
  54. package/lib/sandboxes.js +77 -175
  55. package/lib/serverlessLogs.d.ts +4 -1
  56. package/lib/serverlessLogs.js +64 -60
  57. package/lib/ui/serverlessFunctionLogs.d.ts +8 -0
  58. package/lib/ui/serverlessFunctionLogs.js +1 -3
  59. package/lib/validation.d.ts +2 -0
  60. package/lib/validation.js +5 -8
  61. package/package.json +8 -7
  62. package/types/Projects.d.ts +74 -0
  63. package/types/Projects.js +7 -0
  64. package/types/Sandboxes.d.ts +3 -0
  65. package/types/Sandboxes.js +2 -0
  66. package/types/Yargs.d.ts +14 -0
  67. package/types/Yargs.js +2 -0
@@ -197,13 +197,13 @@ function makePollTaskStatusFunc({ statusFn, structureFn, statusText, statusStrin
197
197
  resolve(taskStatus);
198
198
  }
199
199
  }
200
- }, constants_1.POLLING_DELAY);
200
+ }, constants_1.DEFAULT_POLLING_DELAY);
201
201
  });
202
202
  };
203
203
  }
204
204
  function pollBuildAutodeployStatus(accountId, taskName, buildId) {
205
205
  return new Promise((resolve, reject) => {
206
- let maxIntervals = (30 * 1000) / constants_1.POLLING_DELAY; // Num of intervals in ~30s
206
+ let maxIntervals = (30 * 1000) / constants_1.DEFAULT_POLLING_DELAY; // Num of intervals in ~30s
207
207
  const pollInterval = setInterval(async () => {
208
208
  let build;
209
209
  try {
@@ -224,7 +224,7 @@ function pollBuildAutodeployStatus(accountId, taskName, buildId) {
224
224
  else {
225
225
  maxIntervals -= 1;
226
226
  }
227
- }, constants_1.POLLING_DELAY);
227
+ }, constants_1.DEFAULT_POLLING_DELAY);
228
228
  });
229
229
  }
230
230
  exports.pollBuildStatus = makePollTaskStatusFunc({
@@ -20,7 +20,6 @@ const github_1 = require("@hubspot/local-dev-lib/github");
20
20
  const projects_1 = require("@hubspot/local-dev-lib/api/projects");
21
21
  const index_1 = require("@hubspot/local-dev-lib/errors/index");
22
22
  const path_2 = require("@hubspot/local-dev-lib/path");
23
- const github_2 = require("@hubspot/local-dev-lib/github");
24
23
  const constants_1 = require("../constants");
25
24
  const promptUtils_1 = require("../prompts/promptUtils");
26
25
  const exitCodes_1 = require("../enums/exitCodes");
@@ -96,7 +95,10 @@ async function createProjectConfig(projectPath, projectName, template, templateS
96
95
  const projectConfigPath = path_1.default.join(projectPath, constants_1.PROJECT_CONFIG_FILE);
97
96
  logger_1.logger.log(`Creating project config in ${projectPath ? projectPath : 'the current folder'}`);
98
97
  const hasCustomTemplateSource = Boolean(templateSource);
99
- await (0, github_2.downloadGithubRepoContents)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, template.path, projectPath, hasCustomTemplateSource ? undefined : githubRef);
98
+ await (0, github_1.cloneGithubRepo)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, projectPath, {
99
+ sourceDir: template.path,
100
+ tag: hasCustomTemplateSource ? undefined : githubRef,
101
+ });
100
102
  const _config = JSON.parse(fs_extra_1.default.readFileSync(projectConfigPath).toString());
101
103
  writeProjectConfig(projectConfigPath, {
102
104
  ..._config,
@@ -169,7 +171,7 @@ async function pollFetchProject(accountId, projectName) {
169
171
  reject(err);
170
172
  }
171
173
  }
172
- }, constants_1.POLLING_DELAY);
174
+ }, constants_1.DEFAULT_POLLING_DELAY);
173
175
  });
174
176
  }
175
177
  async function ensureProjectExists(accountId, projectName, { forceCreate = false, allowCreate = true, noLogs = false, withPolling = false, uploadCommand = false, } = {}) {
@@ -248,7 +250,10 @@ async function createProjectComponent(component, name, projectComponentsVersion)
248
250
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
249
251
  }
250
252
  const componentPath = path_1.default.join(configInfo.projectDir, configInfo.projectConfig.srcDir, component.insertPath, componentName);
251
- await (0, github_2.downloadGithubRepoContents)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, component.path, componentPath, projectComponentsVersion);
253
+ await (0, github_1.cloneGithubRepo)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, componentPath, {
254
+ sourceDir: component.path,
255
+ tag: projectComponentsVersion,
256
+ });
252
257
  }
253
258
  async function getProjectComponentsByVersion(projectComponentsVersion) {
254
259
  const config = await (0, github_1.fetchFileFromRepository)(constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', projectComponentsVersion);
@@ -1,78 +1,12 @@
1
- import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
2
- export type Component = {
3
- type: ComponentTypes;
4
- config: object;
5
- runnable: boolean;
6
- path: string;
7
- };
8
- type PrivateAppComponentConfig = {
9
- name: string;
10
- description: string;
11
- uid: string;
12
- scopes: Array<string>;
13
- public: boolean;
14
- extensions?: {
15
- crm: {
16
- cards: Array<{
17
- file: string;
18
- }>;
19
- };
20
- };
21
- };
22
- type PublicAppComponentConfig = {
23
- name: string;
24
- uid: string;
25
- description: string;
26
- allowedUrls: Array<string>;
27
- auth: {
28
- redirectUrls: Array<string>;
29
- requiredScopes: Array<string>;
30
- optionalScopes: Array<string>;
31
- conditionallyRequiredScopes: Array<string>;
32
- };
33
- support: {
34
- supportEmail: string;
35
- documentationUrl: string;
36
- supportUrl: string;
37
- supportPhone: string;
38
- };
39
- extensions?: {
40
- crm: {
41
- cards: Array<{
42
- file: string;
43
- }>;
44
- };
45
- };
46
- webhooks?: {
47
- file: string;
48
- };
49
- };
50
- type AppCardComponentConfig = {
51
- type: 'crm-card';
52
- data: {
53
- title: string;
54
- uid: string;
55
- location: string;
56
- module: {
57
- file: string;
58
- };
59
- objectTypes: Array<{
60
- name: string;
61
- }>;
62
- };
63
- };
64
- export declare const COMPONENT_TYPES: {
65
- readonly privateApp: "private-app";
66
- readonly publicApp: "public-app";
67
- readonly hublTheme: "hubl-theme";
68
- };
69
- type ComponentTypes = ValueOf<typeof COMPONENT_TYPES>;
1
+ import { ComponentTypes, Component, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
70
2
  export declare const CONFIG_FILES: {
71
- [k in ValueOf<typeof COMPONENT_TYPES>]: string;
3
+ [k in ComponentTypes]: string;
72
4
  };
73
5
  export declare function getAppCardConfigs(appConfig: PublicAppComponentConfig | PrivateAppComponentConfig, appPath: string): Array<AppCardComponentConfig>;
74
6
  export declare function findProjectComponents(projectSourceDir: string): Promise<Array<Component>>;
75
7
  export declare function getProjectComponentTypes(components: Array<Component>): {
76
8
  [key in ComponentTypes]?: boolean;
77
9
  };
78
- export {};
10
+ export declare function getComponentUid(component?: Component | null): string | null;
11
+ export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
12
+ export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
@@ -33,24 +33,23 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.CONFIG_FILES = exports.COMPONENT_TYPES = void 0;
36
+ exports.CONFIG_FILES = void 0;
37
37
  exports.getAppCardConfigs = getAppCardConfigs;
38
38
  exports.findProjectComponents = findProjectComponents;
39
39
  exports.getProjectComponentTypes = getProjectComponentTypes;
40
+ exports.getComponentUid = getComponentUid;
41
+ exports.componentIsApp = componentIsApp;
42
+ exports.componentIsPublicApp = componentIsPublicApp;
40
43
  const fs = __importStar(require("fs"));
41
44
  const path = __importStar(require("path"));
42
45
  const fs_1 = require("@hubspot/local-dev-lib/fs");
43
46
  const logger_1 = require("@hubspot/local-dev-lib/logger");
44
47
  const index_1 = require("../errorHandlers/index");
45
- exports.COMPONENT_TYPES = {
46
- privateApp: 'private-app',
47
- publicApp: 'public-app',
48
- hublTheme: 'hubl-theme',
49
- };
48
+ const Projects_1 = require("../../types/Projects");
50
49
  exports.CONFIG_FILES = {
51
- [exports.COMPONENT_TYPES.privateApp]: 'app.json',
52
- [exports.COMPONENT_TYPES.publicApp]: 'public-app.json',
53
- [exports.COMPONENT_TYPES.hublTheme]: 'theme.json',
50
+ [Projects_1.ComponentTypes.PrivateApp]: 'app.json',
51
+ [Projects_1.ComponentTypes.PublicApp]: 'public-app.json',
52
+ [Projects_1.ComponentTypes.HublTheme]: 'theme.json',
54
53
  };
55
54
  function getComponentTypeFromConfigFile(configFile) {
56
55
  let key;
@@ -129,7 +128,7 @@ async function findProjectComponents(projectSourceDir) {
129
128
  const parsedConfig = loadConfigFile(projectFile);
130
129
  if (parsedConfig) {
131
130
  const isLegacy = getIsLegacyApp(parsedConfig, dir);
132
- const isHublTheme = base === exports.CONFIG_FILES[exports.COMPONENT_TYPES.hublTheme];
131
+ const isHublTheme = base === exports.CONFIG_FILES[Projects_1.ComponentTypes.HublTheme];
133
132
  const componentType = getComponentTypeFromConfigFile(base);
134
133
  if (componentType) {
135
134
  components.push({
@@ -149,3 +148,21 @@ function getProjectComponentTypes(components) {
149
148
  components.forEach(({ type }) => (projectContents[type] = true));
150
149
  return projectContents;
151
150
  }
151
+ function getComponentUid(component) {
152
+ if (!component) {
153
+ return null;
154
+ }
155
+ else if ('uid' in component.config) {
156
+ return component.config.uid;
157
+ }
158
+ else {
159
+ return component.config.data.uid;
160
+ }
161
+ }
162
+ function componentIsApp(component) {
163
+ return (component?.type === Projects_1.ComponentTypes.PublicApp ||
164
+ component?.type === Projects_1.ComponentTypes.PrivateApp);
165
+ }
166
+ function componentIsPublicApp(component) {
167
+ return component?.type === Projects_1.ComponentTypes.PublicApp;
168
+ }
@@ -1,8 +1,9 @@
1
1
  import { FileResult } from 'tmp';
2
2
  import { ProjectConfig } from '../../types/Projects';
3
- type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId?: number) => Promise<T | undefined>;
4
- type ProjectUploadDefaultResult = {
3
+ type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId?: number) => Promise<T>;
4
+ type ProjectUploadResult<T> = {
5
+ result?: T;
5
6
  uploadError?: unknown;
6
7
  };
7
- export declare function handleProjectUpload<T = ProjectUploadDefaultResult>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string): Promise<unknown>;
8
+ export declare function handleProjectUpload<T>(accountId: number, projectConfig: ProjectConfig, projectDir: string, callbackFunc: ProjectUploadCallbackFunction<T>, uploadMessage: string): Promise<ProjectUploadResult<T>>;
8
9
  export {};
@@ -71,19 +71,17 @@ async function handleProjectUpload(accountId, projectConfig, projectDir, callbac
71
71
  const output = fs_extra_1.default.createWriteStream(tempFile.name);
72
72
  const archive = (0, archiver_1.default)('zip');
73
73
  const result = new Promise(resolve => output.on('close', async function () {
74
- let uploadResult;
75
74
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.handleProjectUpload.compressed`, {
76
75
  byteCount: archive.pointer(),
77
76
  }));
78
77
  const { buildId, error } = await uploadProjectFiles(accountId, projectConfig.name, tempFile.name, uploadMessage, projectConfig.platformVersion);
79
78
  if (error) {
80
- console.log(error);
81
- uploadResult = { uploadError: error };
79
+ resolve({ uploadError: error });
82
80
  }
83
81
  else if (callbackFunc) {
84
- uploadResult = await callbackFunc(accountId, projectConfig, tempFile, buildId);
82
+ const uploadResult = await callbackFunc(accountId, projectConfig, tempFile, buildId);
83
+ resolve({ result: uploadResult });
85
84
  }
86
- resolve(uploadResult || {});
87
85
  }));
88
86
  archive.pipe(output);
89
87
  let loggedIgnoredNodeModule = false;
@@ -23,7 +23,14 @@ async function createTemplateOptions(templateSource, githubRef) {
23
23
  const branch = hasCustomTemplateSource
24
24
  ? constants_1.DEFAULT_PROJECT_TEMPLATE_BRANCH
25
25
  : githubRef;
26
- const config = await (0, github_1.fetchFileFromRepository)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
26
+ let config;
27
+ try {
28
+ config = await (0, github_1.fetchFileFromRepository)(templateSource || constants_1.HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'config.json', branch);
29
+ }
30
+ catch (e) {
31
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.missingConfigFileTemplateSource`));
32
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
33
+ }
27
34
  if (!config || !config[constants_1.PROJECT_COMPONENT_TYPES.PROJECTS]) {
28
35
  logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noProjectsInConfig`));
29
36
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
@@ -1 +1 @@
1
- export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId: number, scopes: string[], redirectUrls: string[], isReinstall?: boolean): Promise<void>;
1
+ export declare function installPublicAppPrompt(env: string, targetAccountId: number, clientId: string, scopes: string[], redirectUrls: string[], isReinstall?: boolean): Promise<void>;
@@ -21,7 +21,7 @@ type ScopesPromptResponse = {
21
21
  */
22
22
  export declare function personalAccessKeyPrompt({ env, account, }: {
23
23
  env: string;
24
- account?: string;
24
+ account?: number;
25
25
  }): Promise<PersonalAccessKeyPromptResponse>;
26
26
  export declare const OAUTH_FLOW: (PromptConfig<{
27
27
  name: string;
@@ -1,6 +1,6 @@
1
- import { CLIAccount, AccountType } from '@hubspot/local-dev-lib/types/Accounts';
1
+ import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
2
  import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
3
3
  export declare function selectSandboxTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
4
4
  export declare function selectDeveloperTestTargetAccountPrompt(accounts: CLIAccount[], defaultAccountConfig: CLIAccount): Promise<DeveloperTestAccount | CLIAccount>;
5
- export declare function confirmDefaultAccountPrompt(accountName: string, accountType: AccountType): Promise<boolean>;
5
+ export declare function confirmDefaultAccountPrompt(accountName: string, accountType: string): Promise<boolean>;
6
6
  export declare function confirmUseExistingDeveloperTestAccountPrompt(account: DeveloperTestAccount): Promise<boolean>;
@@ -1 +1,4 @@
1
- export {};
1
+ import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
+ import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
+ import { SandboxSyncTask } from '../types/Sandboxes';
4
+ export declare function syncSandbox(accountConfig: CLIAccount, parentAccountConfig: CLIAccount, env: Environment, syncTasks: Array<SandboxSyncTask>, slimInfoMessage?: boolean): Promise<void>;
@@ -1,128 +1,127 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-nocheck
4
- const SpinniesManager = require('./ui/SpinniesManager');
5
- const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
6
- const { logger } = require('@hubspot/local-dev-lib/logger');
7
- const { i18n } = require('./lang');
8
- const { getAvailableSyncTypes } = require('./sandboxes');
9
- const { initiateSync } = require('@hubspot/local-dev-lib/api/sandboxSync');
10
- const { debugError, logError, ApiErrorContext, } = require('./errorHandlers/index');
11
- const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
12
- const { getSandboxTypeAsString } = require('./sandboxes');
13
- const { getAccountId } = require('@hubspot/local-dev-lib/config');
14
- const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
15
- const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
16
- const { isDevelopmentSandbox } = require('./accountTypes');
6
+ exports.syncSandbox = syncSandbox;
7
+ const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
8
+ const urls_1 = require("@hubspot/local-dev-lib/urls");
9
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
10
+ const sandboxSync_1 = require("@hubspot/local-dev-lib/api/sandboxSync");
11
+ const index_1 = require("@hubspot/local-dev-lib/errors/index");
12
+ const config_1 = require("@hubspot/local-dev-lib/config");
13
+ const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
14
+ const lang_1 = require("./lang");
15
+ const sandboxes_1 = require("./sandboxes");
16
+ const index_2 = require("./errorHandlers/index");
17
+ const sandboxes_2 = require("./sandboxes");
18
+ const ui_1 = require("./ui");
19
+ const accountTypes_1 = require("./accountTypes");
17
20
  const i18nKey = 'lib.sandbox.sync';
18
- /**
19
- * @param {Object} accountConfig - Account config of sandbox portal
20
- * @param {Object} parentAccountConfig - Account config of parent portal
21
- * @param {String} env - Environment (QA/Prod)
22
- * @param {Array} syncTasks - Array of available sync tasks
23
- * @returns
24
- */
25
- const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
26
- const id = getAccountIdentifier(accountConfig);
27
- const accountId = getAccountId(id);
28
- const parentId = getAccountIdentifier(parentAccountConfig);
29
- const parentAccountId = getAccountId(parentId);
30
- const isDevSandbox = isDevelopmentSandbox(accountConfig);
31
- SpinniesManager.init({
21
+ async function syncSandbox(accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false) {
22
+ const id = (0, getAccountIdentifier_1.getAccountIdentifier)(accountConfig);
23
+ const accountId = (0, config_1.getAccountId)(id);
24
+ const parentId = (0, getAccountIdentifier_1.getAccountIdentifier)(parentAccountConfig);
25
+ const parentAccountId = (0, config_1.getAccountId)(parentId);
26
+ const isDevSandbox = (0, accountTypes_1.isDevelopmentSandbox)(accountConfig);
27
+ if (!accountId || !parentAccountId) {
28
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.failure.invalidUser`, {
29
+ accountName: (0, ui_1.uiAccountDescription)(accountId),
30
+ parentAccountName: (0, ui_1.uiAccountDescription)(parentAccountId),
31
+ }));
32
+ }
33
+ SpinniesManager_1.default.init({
32
34
  succeedColor: 'white',
33
35
  });
34
36
  let availableSyncTasks = syncTasks;
35
- const baseUrl = getHubSpotWebsiteOrigin(env);
36
- const syncStatusUrl = `${baseUrl}/sandboxes-developer/${parentAccountId}/${getSandboxTypeAsString(accountConfig.accountType)}`;
37
+ const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)(env);
38
+ const syncStatusUrl = `${baseUrl}/sandboxes-developer/${parentAccountId}/${(0, sandboxes_2.getSandboxTypeAsString)(accountConfig.accountType)}`;
37
39
  try {
38
40
  // If no sync tasks exist, fetch sync types based on default account. Parent account required for fetch
39
41
  if (!availableSyncTasks ||
40
42
  (typeof availableSyncTasks === 'object' &&
41
43
  availableSyncTasks.length === 0)) {
42
- availableSyncTasks = await getAvailableSyncTypes(parentAccountConfig, accountConfig);
44
+ availableSyncTasks = await (0, sandboxes_1.getAvailableSyncTypes)(parentAccountConfig, accountConfig);
43
45
  }
44
- SpinniesManager.add('sandboxSync', {
45
- text: i18n(`${i18nKey}.loading.startSync`),
46
+ SpinniesManager_1.default.add('sandboxSync', {
47
+ text: (0, lang_1.i18n)(`${i18nKey}.loading.startSync`),
46
48
  });
47
- await initiateSync(parentAccountId, accountId, availableSyncTasks, accountId);
49
+ await (0, sandboxSync_1.initiateSync)(parentAccountId, accountId, availableSyncTasks, accountId);
48
50
  const spinniesText = isDevSandbox
49
51
  ? `${i18nKey}.loading.succeedDevSb`
50
52
  : `${i18nKey}.loading.succeed`;
51
- SpinniesManager.succeed('sandboxSync', {
52
- text: i18n(slimInfoMessage ? `${i18nKey}.loading.successDevSbInfo` : spinniesText, {
53
- accountName: uiAccountDescription(accountId),
54
- url: uiLink(i18n(`${i18nKey}.info.syncStatusDetailsLinkText`), syncStatusUrl),
53
+ SpinniesManager_1.default.succeed('sandboxSync', {
54
+ text: (0, lang_1.i18n)(slimInfoMessage ? `${i18nKey}.loading.successDevSbInfo` : spinniesText, {
55
+ accountName: (0, ui_1.uiAccountDescription)(accountId),
56
+ url: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.info.syncStatusDetailsLinkText`), syncStatusUrl),
55
57
  }),
56
58
  });
57
59
  }
58
60
  catch (err) {
59
- debugError(err);
60
- SpinniesManager.fail('sandboxSync', {
61
- text: i18n(`${i18nKey}.loading.fail`),
61
+ (0, index_2.debugError)(err);
62
+ SpinniesManager_1.default.fail('sandboxSync', {
63
+ text: (0, lang_1.i18n)(`${i18nKey}.loading.fail`),
62
64
  });
63
- logger.log('');
64
- if (isSpecifiedError(err, {
65
+ logger_1.logger.log('');
66
+ if ((0, index_1.isSpecifiedError)(err, {
65
67
  statusCode: 403,
66
68
  category: 'BANNED',
67
69
  subCategory: 'sandboxes-sync-api.SYNC_NOT_ALLOWED_INVALID_USER',
68
70
  })) {
69
- logger.error(i18n(`${i18nKey}.failure.invalidUser`, {
70
- accountName: uiAccountDescription(accountId),
71
- parentAccountName: uiAccountDescription(parentAccountId),
71
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.invalidUser`, {
72
+ accountName: (0, ui_1.uiAccountDescription)(accountId),
73
+ parentAccountName: (0, ui_1.uiAccountDescription)(parentAccountId),
72
74
  }));
73
75
  }
74
- else if (isSpecifiedError(err, {
76
+ else if ((0, index_1.isSpecifiedError)(err, {
75
77
  statusCode: 429,
76
78
  category: 'RATE_LIMITS',
77
79
  subCategory: 'sandboxes-sync-api.SYNC_IN_PROGRESS',
78
80
  })) {
79
- logger.error(i18n(`${i18nKey}.failure.syncInProgress`, {
81
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.syncInProgress`, {
80
82
  url: `${baseUrl}/sandboxes-developer/${parentAccountId}/syncactivitylog`,
81
83
  }));
82
84
  }
83
- else if (isSpecifiedError(err, {
85
+ else if ((0, index_1.isSpecifiedError)(err, {
84
86
  statusCode: 403,
85
87
  category: 'BANNED',
86
88
  subCategory: 'sandboxes-sync-api.SYNC_NOT_ALLOWED_INVALID_USERID',
87
89
  })) {
88
90
  // This will only trigger if a user is not a super admin of the target account.
89
- logger.error(i18n(`${i18nKey}.failure.notSuperAdmin`, {
90
- account: uiAccountDescription(accountId),
91
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.notSuperAdmin`, {
92
+ account: (0, ui_1.uiAccountDescription)(accountId),
91
93
  }));
92
94
  }
93
- else if (isSpecifiedError(err, {
95
+ else if ((0, index_1.isSpecifiedError)(err, {
94
96
  statusCode: 404,
95
97
  category: 'OBJECT_NOT_FOUND',
96
98
  subCategory: 'SandboxErrors.SANDBOX_NOT_FOUND',
97
99
  })) {
98
- logger.error(i18n(`${i18nKey}.failure.objectNotFound`, {
99
- account: uiAccountDescription(accountId),
100
+ logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.objectNotFound`, {
101
+ account: (0, ui_1.uiAccountDescription)(accountId),
100
102
  }));
101
103
  }
102
- else if (isSpecifiedError(err, {
104
+ else if ((0, index_1.isSpecifiedError)(err, {
103
105
  statusCode: 404,
104
106
  })) {
105
- uiCommandDisabledBanner('hs sandbox sync', 'https://app.hubspot.com/l/docs/guides/crm/project-cli-commands#developer-projects-cli-commands-beta');
107
+ (0, ui_1.uiCommandDisabledBanner)('hs sandbox sync', 'https://app.hubspot.com/l/docs/guides/crm/project-cli-commands#developer-projects-cli-commands-beta');
106
108
  }
107
109
  else {
108
- logError(err, new ApiErrorContext({
110
+ (0, index_2.logError)(err, new index_2.ApiErrorContext({
109
111
  accountId: parentAccountId,
110
112
  request: 'sandbox sync',
111
113
  }));
112
114
  }
113
- logger.log('');
115
+ logger_1.logger.log('');
114
116
  throw err;
115
117
  }
116
118
  if (!slimInfoMessage) {
117
- logger.log();
118
- uiLine();
119
- logger.info(i18n(`${i18nKey}.info.${isDevSandbox ? 'syncMessageDevSb' : 'syncMessage'}`, {
120
- url: uiLink(i18n(`${i18nKey}.info.syncStatusDetailsLinkText`), syncStatusUrl),
119
+ logger_1.logger.log();
120
+ (0, ui_1.uiLine)();
121
+ logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.info.${isDevSandbox ? 'syncMessageDevSb' : 'syncMessage'}`, {
122
+ url: (0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.info.syncStatusDetailsLinkText`), syncStatusUrl),
121
123
  }));
122
- uiLine();
123
- logger.log();
124
+ (0, ui_1.uiLine)();
125
+ logger_1.logger.log();
124
126
  }
125
- };
126
- module.exports = {
127
- syncSandbox,
128
- };
127
+ }
@@ -1 +1,20 @@
1
- export {};
1
+ import { AccountType, CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
+ import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
+ import { SandboxSyncTask } from '../types/Sandboxes';
4
+ export declare const SYNC_TYPES: {
5
+ readonly OBJECT_RECORDS: "object-records";
6
+ };
7
+ export declare const SANDBOX_TYPE_MAP: {
8
+ readonly dev: "DEVELOPMENT_SANDBOX";
9
+ readonly developer: "DEVELOPMENT_SANDBOX";
10
+ readonly development: "DEVELOPMENT_SANDBOX";
11
+ readonly standard: "STANDARD_SANDBOX";
12
+ };
13
+ export declare const SANDBOX_API_TYPE_MAP: {
14
+ readonly STANDARD_SANDBOX: 1;
15
+ readonly DEVELOPMENT_SANDBOX: 2;
16
+ };
17
+ export declare function getSandboxTypeAsString(accountType?: AccountType): string;
18
+ export declare function getAvailableSyncTypes(parentAccountConfig: CLIAccount, config: CLIAccount): Promise<Array<SandboxSyncTask>>;
19
+ export declare function validateSandboxUsageLimits(accountConfig: CLIAccount, sandboxType: AccountType, env: Environment): Promise<void>;
20
+ export declare function handleSandboxCreateError(err: unknown, env: Environment, name: string, accountId: number): never;