@hubspot/local-dev-lib 0.3.15 → 0.4.0-experimental.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 (178) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +17 -0
  3. package/api/appsDev.d.ts +6 -0
  4. package/api/appsDev.js +29 -0
  5. package/api/customObjects.d.ts +8 -20
  6. package/api/customObjects.js +13 -16
  7. package/api/designManager.d.ts +4 -14
  8. package/api/designManager.js +5 -8
  9. package/api/devSecrets.d.ts +6 -0
  10. package/api/devSecrets.js +40 -0
  11. package/api/developerTestAccounts.d.ts +12 -5
  12. package/api/developerTestAccounts.js +17 -10
  13. package/api/fileManager.d.ts +5 -4
  14. package/api/fileManager.js +9 -9
  15. package/api/fileMapper.d.ts +8 -7
  16. package/api/fileMapper.js +16 -16
  17. package/api/fileTransport.d.ts +4 -3
  18. package/api/fileTransport.js +5 -5
  19. package/api/fireAlarm.d.ts +3 -0
  20. package/api/fireAlarm.js +11 -0
  21. package/api/functions.d.ts +7 -7
  22. package/api/functions.js +11 -14
  23. package/api/github.d.ts +8 -9
  24. package/api/github.js +30 -13
  25. package/api/hubdb.d.ts +11 -10
  26. package/api/hubdb.js +24 -21
  27. package/api/lighthouseScore.d.ts +4 -4
  28. package/api/lighthouseScore.js +7 -10
  29. package/api/localDevAuth.d.ts +9 -19
  30. package/api/localDevAuth.js +34 -9
  31. package/api/marketplaceValidation.d.ts +4 -4
  32. package/api/marketplaceValidation.js +4 -7
  33. package/api/projects.d.ts +47 -35
  34. package/api/projects.js +145 -57
  35. package/api/sandboxHubs.d.ts +6 -4
  36. package/api/sandboxHubs.js +9 -10
  37. package/api/sandboxSync.d.ts +4 -4
  38. package/api/sandboxSync.js +4 -13
  39. package/api/secrets.d.ts +6 -8
  40. package/api/secrets.js +9 -12
  41. package/api/validateHubl.d.ts +2 -1
  42. package/api/validateHubl.js +3 -6
  43. package/config/CLIConfiguration.d.ts +16 -9
  44. package/config/CLIConfiguration.js +148 -74
  45. package/config/configFile.js +8 -17
  46. package/config/configUtils.d.ts +2 -21
  47. package/config/configUtils.js +2 -2
  48. package/config/config_DEPRECATED.d.ts +10 -8
  49. package/config/config_DEPRECATED.js +62 -32
  50. package/config/getAccountIdentifier.d.ts +2 -0
  51. package/config/getAccountIdentifier.js +15 -0
  52. package/config/index.d.ts +14 -8
  53. package/config/index.js +108 -59
  54. package/config/migrate.d.ts +22 -0
  55. package/config/migrate.js +178 -0
  56. package/constants/config.d.ts +13 -1
  57. package/constants/config.js +19 -2
  58. package/constants/extensions.d.ts +1 -0
  59. package/constants/extensions.js +2 -1
  60. package/constants/files.d.ts +2 -2
  61. package/constants/files.js +3 -3
  62. package/constants/projects.d.ts +12 -0
  63. package/constants/projects.js +15 -0
  64. package/errors/errors_DEPRECATED.d.ts +1 -5
  65. package/errors/errors_DEPRECATED.js +2 -2
  66. package/errors/index.d.ts +18 -0
  67. package/errors/index.js +63 -0
  68. package/http/addQueryParams.d.ts +2 -0
  69. package/http/addQueryParams.js +14 -0
  70. package/http/getAxiosConfig.d.ts +2 -2
  71. package/http/getAxiosConfig.js +31 -2
  72. package/http/index.d.ts +10 -10
  73. package/http/index.js +80 -34
  74. package/http/unauthed.d.ts +14 -0
  75. package/http/unauthed.js +38 -0
  76. package/lang/en.json +384 -376
  77. package/lib/archive.d.ts +3 -6
  78. package/lib/archive.js +26 -20
  79. package/lib/cms/functions.d.ts +6 -9
  80. package/lib/cms/functions.js +24 -19
  81. package/lib/cms/handleFieldsJS.d.ts +2 -2
  82. package/lib/cms/handleFieldsJS.js +13 -9
  83. package/lib/cms/modules.d.ts +5 -13
  84. package/lib/cms/modules.js +40 -23
  85. package/lib/cms/processFieldsJs.js +8 -7
  86. package/lib/cms/templates.d.ts +42 -0
  87. package/lib/cms/templates.js +48 -5
  88. package/lib/cms/uploadFolder.d.ts +3 -18
  89. package/lib/cms/uploadFolder.js +19 -17
  90. package/lib/cms/validate.js +1 -1
  91. package/lib/cms/watch.d.ts +2 -15
  92. package/lib/cms/watch.js +31 -23
  93. package/lib/customObjects.js +4 -15
  94. package/lib/fileManager.js +22 -22
  95. package/lib/fileMapper.d.ts +4 -13
  96. package/lib/fileMapper.js +47 -50
  97. package/lib/fs.d.ts +1 -1
  98. package/lib/fs.js +10 -6
  99. package/lib/github.d.ts +11 -11
  100. package/lib/github.js +44 -30
  101. package/lib/gitignore.d.ts +1 -6
  102. package/lib/gitignore.js +2 -2
  103. package/lib/hubdb.d.ts +3 -2
  104. package/lib/hubdb.js +11 -9
  105. package/lib/notify.js +2 -2
  106. package/lib/oauth.d.ts +1 -1
  107. package/lib/oauth.js +9 -18
  108. package/lib/path.d.ts +3 -0
  109. package/lib/path.js +46 -1
  110. package/lib/personalAccessKey.d.ts +5 -17
  111. package/lib/personalAccessKey.js +42 -32
  112. package/lib/portManager.d.ts +3 -5
  113. package/lib/portManager.js +18 -6
  114. package/lib/text.d.ts +1 -1
  115. package/lib/text.js +3 -0
  116. package/lib/trackUsage.js +13 -7
  117. package/models/FileSystemError.d.ts +6 -0
  118. package/models/FileSystemError.js +47 -0
  119. package/models/HubSpotHttpError.d.ts +26 -0
  120. package/models/HubSpotHttpError.js +208 -0
  121. package/models/OAuth2Manager.d.ts +2 -27
  122. package/models/OAuth2Manager.js +14 -29
  123. package/package.json +38 -35
  124. package/types/Accounts.d.ts +98 -3
  125. package/types/Apps.d.ts +77 -0
  126. package/types/Apps.js +2 -0
  127. package/types/Archive.d.ts +9 -0
  128. package/types/Archive.js +2 -0
  129. package/types/Build.d.ts +4 -2
  130. package/types/ComponentStructure.d.ts +30 -10
  131. package/types/Config.d.ts +21 -2
  132. package/types/Deploy.d.ts +3 -2
  133. package/types/DesignManager.d.ts +15 -0
  134. package/types/DesignManager.js +2 -0
  135. package/types/DevSecrets.d.ts +5 -0
  136. package/types/DevSecrets.js +2 -0
  137. package/types/Error.d.ts +9 -5
  138. package/types/FieldsJS.d.ts +1 -0
  139. package/types/FieldsJS.js +2 -0
  140. package/types/FileManager.d.ts +1 -1
  141. package/types/Files.d.ts +43 -4
  142. package/types/FireAlarm.d.ts +9 -0
  143. package/types/FireAlarm.js +2 -0
  144. package/types/Functions.d.ts +52 -0
  145. package/types/Github.d.ts +13 -0
  146. package/types/Http.d.ts +12 -11
  147. package/types/Hubdb.d.ts +9 -0
  148. package/types/MarketplaceValidation.d.ts +7 -3
  149. package/types/Migration.d.ts +30 -0
  150. package/types/Migration.js +12 -0
  151. package/types/Modules.d.ts +11 -0
  152. package/types/PortManager.d.ts +7 -0
  153. package/types/Project.d.ts +30 -0
  154. package/types/Sandbox.d.ts +25 -36
  155. package/types/Schemas.d.ts +56 -0
  156. package/types/Secrets.d.ts +3 -0
  157. package/types/Secrets.js +2 -0
  158. package/types/developerTestAccounts.d.ts +11 -0
  159. package/utils/PortManagerServer.d.ts +6 -7
  160. package/utils/PortManagerServer.js +15 -9
  161. package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +0 -6
  162. package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
  163. package/utils/cms/fieldsJS.d.ts +1 -2
  164. package/utils/cms/modules.js +2 -2
  165. package/utils/detectPort.js +3 -3
  166. package/errors/apiErrors.d.ts +0 -25
  167. package/errors/apiErrors.js +0 -186
  168. package/errors/fileSystemErrors.d.ts +0 -6
  169. package/errors/fileSystemErrors.js +0 -35
  170. package/errors/standardErrors.d.ts +0 -21
  171. package/errors/standardErrors.js +0 -52
  172. package/lang/lang/en.json +0 -391
  173. package/lib/developerTestAccounts.d.ts +0 -4
  174. package/lib/developerTestAccounts.js +0 -35
  175. package/lib/sandboxes.d.ts +0 -14
  176. package/lib/sandboxes.js +0 -70
  177. package/models/HubSpotAuthError.d.ts +0 -12
  178. package/models/HubSpotAuthError.js +0 -20
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.mergeExistingConfigs = exports.mergeConfigProperties = exports.migrateConfig = exports.getConfigPath = exports.configFileExists = exports.getGlobalConfig = exports.getDeprecatedConfig = void 0;
30
+ const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
31
+ const CLIConfiguration_1 = require("./CLIConfiguration");
32
+ const index_1 = require("./index");
33
+ const configFile_1 = require("./configFile");
34
+ const config_1 = require("../constants/config");
35
+ const lang_1 = require("../utils/lang");
36
+ const fs_1 = __importDefault(require("fs"));
37
+ const path_1 = __importDefault(require("path"));
38
+ const i18nKey = 'config.migrate';
39
+ function getDeprecatedConfig(configPath) {
40
+ return config_DEPRECATED.loadConfig(configPath);
41
+ }
42
+ exports.getDeprecatedConfig = getDeprecatedConfig;
43
+ function getGlobalConfig() {
44
+ if (CLIConfiguration_1.CLIConfiguration.isActive()) {
45
+ return CLIConfiguration_1.CLIConfiguration.config;
46
+ }
47
+ return null;
48
+ }
49
+ exports.getGlobalConfig = getGlobalConfig;
50
+ function configFileExists(useHiddenConfig = false, configPath) {
51
+ return useHiddenConfig
52
+ ? (0, configFile_1.configFileExists)()
53
+ : Boolean(config_DEPRECATED.getConfigPath(configPath));
54
+ }
55
+ exports.configFileExists = configFileExists;
56
+ function getConfigPath(configPath, useHiddenConfig = false) {
57
+ if (useHiddenConfig) {
58
+ return (0, configFile_1.getConfigFilePath)();
59
+ }
60
+ return config_DEPRECATED.getConfigPath(configPath);
61
+ }
62
+ exports.getConfigPath = getConfigPath;
63
+ function writeGlobalConfigFile(updatedConfig, isMigrating = false) {
64
+ const updatedConfigJson = JSON.stringify(updatedConfig);
65
+ if (isMigrating) {
66
+ (0, index_1.createEmptyConfigFile)({}, true);
67
+ }
68
+ (0, index_1.loadConfig)('');
69
+ try {
70
+ (0, index_1.writeConfig)({ source: updatedConfigJson });
71
+ const oldConfigPath = config_DEPRECATED.getConfigPath();
72
+ if (oldConfigPath) {
73
+ const dir = path_1.default.dirname(oldConfigPath);
74
+ const newConfigPath = path_1.default.join(dir, config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME);
75
+ fs_1.default.renameSync(oldConfigPath, newConfigPath);
76
+ }
77
+ }
78
+ catch (error) {
79
+ (0, index_1.deleteEmptyConfigFile)();
80
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.writeConfig`, { configPath: config_1.GLOBAL_CONFIG_PATH }), { cause: error });
81
+ }
82
+ }
83
+ function migrateConfig(deprecatedConfig) {
84
+ if (!deprecatedConfig) {
85
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noDeprecatedConfig`));
86
+ }
87
+ const { defaultPortal, portals, ...rest } = deprecatedConfig;
88
+ const updatedConfig = {
89
+ ...rest,
90
+ defaultAccount: defaultPortal,
91
+ accounts: portals
92
+ .filter(({ portalId }) => portalId !== undefined)
93
+ .map(({ portalId, ...rest }) => ({
94
+ ...rest,
95
+ accountId: portalId,
96
+ })),
97
+ };
98
+ writeGlobalConfigFile(updatedConfig, true);
99
+ }
100
+ exports.migrateConfig = migrateConfig;
101
+ function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
102
+ const propertiesToCheck = [
103
+ config_1.DEFAULT_CMS_PUBLISH_MODE,
104
+ config_1.HTTP_TIMEOUT,
105
+ config_1.ENV,
106
+ config_1.HTTP_USE_LOCALHOST,
107
+ config_1.ALLOW_USAGE_TRACKING,
108
+ ];
109
+ const conflicts = [];
110
+ propertiesToCheck.forEach(prop => {
111
+ if (prop in deprecatedConfig) {
112
+ if (force ||
113
+ !(prop in globalConfig) ||
114
+ globalConfig[prop] === deprecatedConfig[prop]) {
115
+ // @ts-expect-error Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED types
116
+ globalConfig[prop] = deprecatedConfig[prop];
117
+ }
118
+ else {
119
+ conflicts.push({
120
+ property: prop,
121
+ oldValue: deprecatedConfig[prop],
122
+ newValue: globalConfig[prop],
123
+ });
124
+ }
125
+ }
126
+ });
127
+ if (config_1.DEFAULT_ACCOUNT in globalConfig &&
128
+ config_1.DEFAULT_PORTAL in deprecatedConfig &&
129
+ globalConfig.defaultAccount !== deprecatedConfig.defaultPortal) {
130
+ if (force) {
131
+ globalConfig.defaultAccount = deprecatedConfig.defaultPortal;
132
+ }
133
+ else {
134
+ conflicts.push({
135
+ property: config_1.DEFAULT_ACCOUNT,
136
+ oldValue: deprecatedConfig.defaultPortal,
137
+ newValue: globalConfig.defaultAccount,
138
+ });
139
+ }
140
+ }
141
+ else if (config_1.DEFAULT_PORTAL in deprecatedConfig) {
142
+ globalConfig.defaultAccount = deprecatedConfig.defaultPortal;
143
+ }
144
+ return { initialConfig: globalConfig, conflicts };
145
+ }
146
+ exports.mergeConfigProperties = mergeConfigProperties;
147
+ function mergeAccounts(globalConfig, deprecatedConfig) {
148
+ let existingAccountIds = [];
149
+ const skippedAccountIds = [];
150
+ if (globalConfig.accounts && deprecatedConfig.portals) {
151
+ existingAccountIds = globalConfig.accounts.map(account => account.accountId);
152
+ const newAccounts = deprecatedConfig.portals
153
+ .filter(portal => {
154
+ const isExisting = existingAccountIds.includes(portal.portalId);
155
+ if (isExisting) {
156
+ skippedAccountIds.push(portal.portalId);
157
+ }
158
+ return !isExisting;
159
+ })
160
+ .map(({ portalId, ...rest }) => ({
161
+ ...rest,
162
+ accountId: portalId,
163
+ }));
164
+ if (newAccounts.length > 0) {
165
+ globalConfig.accounts.push(...newAccounts);
166
+ }
167
+ }
168
+ return {
169
+ finalConfig: globalConfig,
170
+ skippedAccountIds,
171
+ };
172
+ }
173
+ function mergeExistingConfigs(globalConfig, deprecatedConfig) {
174
+ const { finalConfig, skippedAccountIds } = mergeAccounts(globalConfig, deprecatedConfig);
175
+ writeGlobalConfigFile(finalConfig);
176
+ return { finalConfig, skippedAccountIds };
177
+ }
178
+ exports.mergeExistingConfigs = mergeExistingConfigs;
@@ -1,6 +1,18 @@
1
1
  export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
2
- export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hubspot";
2
+ export declare const ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = "archived.hubspot.config.yml";
3
+ export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
3
4
  export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
5
+ export declare const GLOBAL_CONFIG_PATH: string;
6
+ export declare const DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = ".hsaccount";
7
+ export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID";
8
+ export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND";
9
+ export declare const DEFAULT_CMS_PUBLISH_MODE = "defaultCmsPublishMode";
10
+ export declare const HTTP_TIMEOUT = "httpTimeout";
11
+ export declare const ENV = "env";
12
+ export declare const HTTP_USE_LOCALHOST = "httpUseLocalhost";
13
+ export declare const ALLOW_USAGE_TRACKING = "allowUsageTracking";
14
+ export declare const DEFAULT_ACCOUNT = "defaultAccount";
15
+ export declare const DEFAULT_PORTAL = "defaultPortal";
4
16
  export declare const MIN_HTTP_TIMEOUT = 3000;
5
17
  export declare const HUBSPOT_ACCOUNT_TYPES: {
6
18
  readonly DEVELOPMENT_SANDBOX: "DEVELOPMENT_SANDBOX";
@@ -1,10 +1,27 @@
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
- exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
6
+ exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
4
7
  const lang_1 = require("../utils/lang");
8
+ const path_1 = __importDefault(require("path"));
9
+ const os_1 = __importDefault(require("os"));
5
10
  exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
6
- exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
11
+ exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = 'archived.hubspot.config.yml';
12
+ exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
7
13
  exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
14
+ exports.GLOBAL_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_CONFIGURATION_FILE);
15
+ exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = '.hsaccount';
16
+ exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID';
17
+ exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND';
18
+ exports.DEFAULT_CMS_PUBLISH_MODE = 'defaultCmsPublishMode';
19
+ exports.HTTP_TIMEOUT = 'httpTimeout';
20
+ exports.ENV = 'env';
21
+ exports.HTTP_USE_LOCALHOST = 'httpUseLocalhost';
22
+ exports.ALLOW_USAGE_TRACKING = 'allowUsageTracking';
23
+ exports.DEFAULT_ACCOUNT = 'defaultAccount';
24
+ exports.DEFAULT_PORTAL = 'defaultPortal';
8
25
  exports.MIN_HTTP_TIMEOUT = 3000;
9
26
  exports.HUBSPOT_ACCOUNT_TYPES = {
10
27
  DEVELOPMENT_SANDBOX: 'DEVELOPMENT_SANDBOX',
@@ -1,4 +1,5 @@
1
1
  export declare const ALLOWED_EXTENSIONS: Set<string>;
2
+ export declare const JSR_ALLOWED_EXTENSIONS: Set<string>;
2
3
  export declare const HUBL_EXTENSIONS: Set<string>;
3
4
  export declare const MODULE_EXTENSION = "module";
4
5
  export declare const FUNCTIONS_EXTENSION = "functions";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FOLDER_DOT_EXTENSIONS = exports.FUNCTIONS_EXTENSION = exports.MODULE_EXTENSION = exports.HUBL_EXTENSIONS = exports.ALLOWED_EXTENSIONS = void 0;
3
+ exports.FOLDER_DOT_EXTENSIONS = exports.FUNCTIONS_EXTENSION = exports.MODULE_EXTENSION = exports.HUBL_EXTENSIONS = exports.JSR_ALLOWED_EXTENSIONS = exports.ALLOWED_EXTENSIONS = void 0;
4
4
  exports.ALLOWED_EXTENSIONS = new Set([
5
5
  'css',
6
6
  'js',
@@ -21,6 +21,7 @@ exports.ALLOWED_EXTENSIONS = new Set([
21
21
  'woff2',
22
22
  'graphql',
23
23
  ]);
24
+ exports.JSR_ALLOWED_EXTENSIONS = new Set(['jsx', 'tsx', 'ts']);
24
25
  exports.HUBL_EXTENSIONS = new Set(['css', 'html', 'js']);
25
26
  exports.MODULE_EXTENSION = 'module';
26
27
  exports.FUNCTIONS_EXTENSION = 'functions';
@@ -3,11 +3,11 @@ export declare const STAT_TYPES: {
3
3
  readonly SYMBOLIC_LINK: "symlink";
4
4
  readonly DIRECTORY: "dir";
5
5
  };
6
- export declare const MODE: {
6
+ export declare const CMS_PUBLISH_MODE: {
7
7
  readonly draft: "draft";
8
8
  readonly publish: "publish";
9
9
  };
10
- export declare const DEFAULT_MODE: "publish";
10
+ export declare const DEFAULT_CMS_PUBLISH_MODE: "publish";
11
11
  export declare const FILE_UPLOAD_RESULT_TYPES: {
12
12
  readonly SUCCESS: "SUCCESS";
13
13
  readonly FAILURE: "FAILURE";
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FILE_TYPES = exports.FILE_UPLOAD_RESULT_TYPES = exports.DEFAULT_MODE = exports.MODE = exports.STAT_TYPES = void 0;
3
+ exports.FILE_TYPES = exports.FILE_UPLOAD_RESULT_TYPES = exports.DEFAULT_CMS_PUBLISH_MODE = exports.CMS_PUBLISH_MODE = exports.STAT_TYPES = void 0;
4
4
  exports.STAT_TYPES = {
5
5
  FILE: 'file',
6
6
  SYMBOLIC_LINK: 'symlink',
7
7
  DIRECTORY: 'dir',
8
8
  };
9
- exports.MODE = {
9
+ exports.CMS_PUBLISH_MODE = {
10
10
  draft: 'draft',
11
11
  publish: 'publish',
12
12
  };
13
- exports.DEFAULT_MODE = exports.MODE.publish;
13
+ exports.DEFAULT_CMS_PUBLISH_MODE = exports.CMS_PUBLISH_MODE.publish;
14
14
  exports.FILE_UPLOAD_RESULT_TYPES = {
15
15
  SUCCESS: 'SUCCESS',
16
16
  FAILURE: 'FAILURE',
@@ -0,0 +1,12 @@
1
+ export declare const UNMIGRATABLE_REASONS: {
2
+ UP_TO_DATE: string;
3
+ IS_A_PRIVATE_APP: string;
4
+ LISTED_IN_MARKETPLACE: string;
5
+ PROJECT_CONNECTED_TO_GITHUB: string;
6
+ };
7
+ export declare const PLATFORM_VERSIONS: {
8
+ v2023_2: string;
9
+ v2025_1: string;
10
+ v2025_2: string;
11
+ unstable: string;
12
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLATFORM_VERSIONS = exports.UNMIGRATABLE_REASONS = void 0;
4
+ exports.UNMIGRATABLE_REASONS = {
5
+ UP_TO_DATE: 'UP_TO_DATE',
6
+ IS_A_PRIVATE_APP: 'IS_A_PRIVATE_APP',
7
+ LISTED_IN_MARKETPLACE: 'LISTED_IN_MARKETPLACE',
8
+ PROJECT_CONNECTED_TO_GITHUB: 'PROJECT_CONNECTED_TO_GITHUB',
9
+ };
10
+ exports.PLATFORM_VERSIONS = {
11
+ v2023_2: '2023.2',
12
+ v2025_1: '2025.1',
13
+ v2025_2: '2025.2',
14
+ unstable: 'unstable',
15
+ };
@@ -1,7 +1,3 @@
1
- import { BaseError, FileSystemErrorContext } from '../types/Error';
2
- type ErrorContext = {
3
- accountId?: number;
4
- };
1
+ import { BaseError, FileSystemErrorContext, ErrorContext } from '../types/Error';
5
2
  export declare function logErrorInstance(error: BaseError, context?: ErrorContext): void;
6
3
  export declare function logFileSystemErrorInstance(error: BaseError, context: FileSystemErrorContext): void;
7
- export {};
@@ -37,10 +37,10 @@ function logErrorInstance(error, context) {
37
37
  exports.logErrorInstance = logErrorInstance;
38
38
  function logFileSystemErrorInstance(error, context) {
39
39
  let fileAction = '';
40
- if (context.read) {
40
+ if (context.operation === 'read') {
41
41
  fileAction = 'reading from';
42
42
  }
43
- else if (context.write) {
43
+ else if (context.operation === 'write') {
44
44
  fileAction = 'writing to';
45
45
  }
46
46
  else {
@@ -0,0 +1,18 @@
1
+ import { HubSpotHttpError } from '../models/HubSpotHttpError';
2
+ import { BaseError } from '../types/Error';
3
+ import { FileSystemError } from '../models/FileSystemError';
4
+ export declare function isSpecifiedError(err: unknown, { statusCode, category, subCategory, errorType, code, }: {
5
+ statusCode?: number;
6
+ category?: string;
7
+ subCategory?: string;
8
+ errorType?: string;
9
+ code?: string;
10
+ }): err is HubSpotHttpError;
11
+ export declare function isMissingScopeError(err: unknown): err is HubSpotHttpError;
12
+ export declare function isGatingError(err: unknown): err is HubSpotHttpError;
13
+ export declare function isTimeoutError(err: unknown): err is HubSpotHttpError;
14
+ export declare function isAuthError(err: unknown): err is HubSpotHttpError;
15
+ export declare function isValidationError(err: unknown): boolean;
16
+ export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
17
+ export declare function isSystemError(err: unknown): err is BaseError;
18
+ export declare function isFileSystemError(err: unknown): err is FileSystemError;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFileSystemError = exports.isSystemError = exports.isHubSpotHttpError = exports.isValidationError = exports.isAuthError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
4
+ const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
5
+ const FileSystemError_1 = require("../models/FileSystemError");
6
+ function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
7
+ if (!isHubSpotHttpError(err)) {
8
+ return false;
9
+ }
10
+ const { data, status, code: actualCode } = err;
11
+ const statusCodeMatchesError = !statusCode || status === statusCode;
12
+ const categoryMatchesError = !category || data?.category === category;
13
+ const subCategoryMatchesError = !subCategory || data?.subCategory === subCategory;
14
+ const errorTypeMatchesError = !errorType || data?.errorType === errorType;
15
+ const codeMatchesError = !code || actualCode === code;
16
+ return (statusCodeMatchesError &&
17
+ categoryMatchesError &&
18
+ subCategoryMatchesError &&
19
+ errorTypeMatchesError &&
20
+ codeMatchesError);
21
+ }
22
+ exports.isSpecifiedError = isSpecifiedError;
23
+ function isMissingScopeError(err) {
24
+ return isSpecifiedError(err, { statusCode: 403, category: 'MISSING_SCOPES' });
25
+ }
26
+ exports.isMissingScopeError = isMissingScopeError;
27
+ function isGatingError(err) {
28
+ return isSpecifiedError(err, { statusCode: 403, category: 'GATED' });
29
+ }
30
+ exports.isGatingError = isGatingError;
31
+ function isTimeoutError(err) {
32
+ return isSpecifiedError(err, { code: 'ETIMEDOUT' });
33
+ }
34
+ exports.isTimeoutError = isTimeoutError;
35
+ function isAuthError(err) {
36
+ return (isSpecifiedError(err, { statusCode: 401 }) ||
37
+ isSpecifiedError(err, { statusCode: 403 }));
38
+ }
39
+ exports.isAuthError = isAuthError;
40
+ function isValidationError(err) {
41
+ return (isHubSpotHttpError(err) &&
42
+ isSpecifiedError(err, { statusCode: 400 }) &&
43
+ !!(err?.data?.message || !!err.data?.errors));
44
+ }
45
+ exports.isValidationError = isValidationError;
46
+ function isHubSpotHttpError(error) {
47
+ return !!error && error instanceof HubSpotHttpError_1.HubSpotHttpError;
48
+ }
49
+ exports.isHubSpotHttpError = isHubSpotHttpError;
50
+ function isSystemError(err) {
51
+ return (err instanceof Error &&
52
+ 'errno' in err &&
53
+ err.errno != null &&
54
+ 'code' in err &&
55
+ err.code != null &&
56
+ 'syscall' in err &&
57
+ err.syscall != null);
58
+ }
59
+ exports.isSystemError = isSystemError;
60
+ function isFileSystemError(err) {
61
+ return err instanceof FileSystemError_1.FileSystemError;
62
+ }
63
+ exports.isFileSystemError = isFileSystemError;
@@ -0,0 +1,2 @@
1
+ import { HttpOptions, QueryParams } from '../types/Http';
2
+ export declare function addQueryParams(configOptions: HttpOptions, queryParams?: QueryParams): HttpOptions;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addQueryParams = void 0;
4
+ function addQueryParams(configOptions, queryParams = {}) {
5
+ const { params } = configOptions;
6
+ return {
7
+ ...configOptions,
8
+ params: {
9
+ ...queryParams,
10
+ ...params,
11
+ },
12
+ };
13
+ }
14
+ exports.addQueryParams = addQueryParams;
@@ -1,4 +1,4 @@
1
- import { AxiosConfigOptions } from '../types/Http';
1
+ import { HttpOptions } from '../types/Http';
2
2
  import { AxiosRequestConfig } from 'axios';
3
3
  export declare const USER_AGENTS: {
4
4
  [key: string]: string;
@@ -6,4 +6,4 @@ export declare const USER_AGENTS: {
6
6
  export declare function getDefaultUserAgentHeader(): {
7
7
  'User-Agent': string;
8
8
  };
9
- export declare function getAxiosConfig(options: AxiosConfigOptions): AxiosRequestConfig;
9
+ export declare function getAxiosConfig(options: HttpOptions): AxiosRequestConfig;
@@ -1,9 +1,28 @@
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
6
  exports.getAxiosConfig = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
4
7
  const package_json_1 = require("../package.json");
5
8
  const config_1 = require("../config");
6
9
  const urls_1 = require("../lib/urls");
10
+ const https_1 = __importDefault(require("https"));
11
+ const http_1 = __importDefault(require("http"));
12
+ // Total number of sockets across all hosts
13
+ const MAX_TOTAL_SOCKETS = 25;
14
+ // Total number of sockets per each host
15
+ const MAX_SOCKETS_PER_HOST = 5;
16
+ const httpAgent = new http_1.default.Agent({
17
+ keepAlive: true,
18
+ maxTotalSockets: MAX_TOTAL_SOCKETS,
19
+ maxSockets: MAX_SOCKETS_PER_HOST,
20
+ });
21
+ const httpsAgent = new https_1.default.Agent({
22
+ keepAlive: true,
23
+ maxTotalSockets: MAX_TOTAL_SOCKETS,
24
+ maxSockets: MAX_SOCKETS_PER_HOST,
25
+ });
7
26
  exports.USER_AGENTS = {
8
27
  'HubSpot Local Dev Lib': package_json_1.version,
9
28
  };
@@ -22,15 +41,25 @@ const DEFAULT_TRANSITIONAL = {
22
41
  };
23
42
  function getAxiosConfig(options) {
24
43
  const { env, localHostOverride, headers, ...rest } = options;
25
- const { httpTimeout, httpUseLocalhost } = (0, config_1.getAndLoadConfigIfNeeded)();
44
+ const config = (0, config_1.getAndLoadConfigIfNeeded)();
45
+ let httpTimeout = 15000;
46
+ let httpUseLocalhost = false;
47
+ if (config && config.httpTimeout) {
48
+ httpTimeout = config.httpTimeout;
49
+ }
50
+ if (config && config.httpUseLocalhost) {
51
+ httpUseLocalhost = config.httpUseLocalhost;
52
+ }
26
53
  return {
27
54
  baseURL: (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost),
28
55
  headers: {
29
56
  ...getDefaultUserAgentHeader(),
30
57
  ...(headers || {}),
31
58
  },
32
- timeout: httpTimeout || 15000,
59
+ timeout: httpTimeout,
33
60
  transitional: DEFAULT_TRANSITIONAL,
61
+ httpAgent,
62
+ httpsAgent,
34
63
  ...rest,
35
64
  };
36
65
  }
package/http/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { AxiosResponse } from 'axios';
2
- import { HttpOptions } from '../types/Http';
1
+ import { AxiosPromise } from 'axios';
2
+ import { HttpOptions, HubSpotPromise } from '../types/Http';
3
3
  export declare function addUserAgentHeader(key: string, value: string): void;
4
- declare function getRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
5
- declare function postRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
6
- declare function putRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
7
- declare function patchRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
8
- declare function deleteRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
9
- declare const http: {
4
+ declare function getRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
5
+ declare function postRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
6
+ declare function putRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
7
+ declare function patchRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
8
+ declare function deleteRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
9
+ export declare const http: {
10
10
  get: typeof getRequest;
11
11
  post: typeof postRequest;
12
12
  put: typeof putRequest;
13
13
  patch: typeof patchRequest;
14
14
  delete: typeof deleteRequest;
15
- getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => Promise<AxiosResponse>;
15
+ getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => AxiosPromise<any>;
16
16
  };
17
- export default http;
17
+ export {};