@hubspot/local-dev-lib 0.2.1 → 0.2.2-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 (189) 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 -7
  6. package/api/customObjects.js +13 -16
  7. package/api/designManager.d.ts +4 -13
  8. package/api/designManager.js +6 -9
  9. package/api/developerTestAccounts.d.ts +7 -0
  10. package/api/developerTestAccounts.js +48 -0
  11. package/api/fileManager.d.ts +5 -4
  12. package/api/fileManager.js +11 -11
  13. package/api/fileMapper.d.ts +8 -7
  14. package/api/fileMapper.js +17 -17
  15. package/api/fileTransport.d.ts +4 -0
  16. package/api/fileTransport.js +39 -0
  17. package/api/functions.d.ts +7 -4
  18. package/api/functions.js +22 -11
  19. package/api/github.d.ts +7 -9
  20. package/api/github.js +31 -13
  21. package/api/hubdb.d.ts +11 -10
  22. package/api/hubdb.js +28 -22
  23. package/api/lighthouseScore.d.ts +4 -4
  24. package/api/lighthouseScore.js +9 -12
  25. package/api/localDevAuth.d.ts +8 -16
  26. package/api/localDevAuth.js +34 -13
  27. package/api/marketplaceValidation.d.ts +4 -4
  28. package/api/marketplaceValidation.js +8 -11
  29. package/api/projects.d.ts +31 -24
  30. package/api/projects.js +164 -44
  31. package/api/sandboxHubs.d.ts +6 -4
  32. package/api/sandboxHubs.js +10 -11
  33. package/api/sandboxSync.d.ts +4 -4
  34. package/api/sandboxSync.js +4 -13
  35. package/api/secrets.d.ts +6 -8
  36. package/api/secrets.js +9 -12
  37. package/api/validateHubl.d.ts +2 -1
  38. package/api/validateHubl.js +3 -6
  39. package/config/CLIConfiguration.d.ts +15 -11
  40. package/config/CLIConfiguration.js +175 -90
  41. package/config/configFile.js +13 -21
  42. package/config/configUtils.d.ts +2 -21
  43. package/config/configUtils.js +5 -4
  44. package/config/config_DEPRECATED.d.ts +6 -8
  45. package/config/config_DEPRECATED.js +79 -25
  46. package/config/environment.js +5 -4
  47. package/config/getAccountIdentifier.d.ts +2 -0
  48. package/config/getAccountIdentifier.js +15 -0
  49. package/config/index.d.ts +13 -8
  50. package/config/index.js +97 -57
  51. package/config/migrate.d.ts +20 -0
  52. package/config/migrate.js +150 -0
  53. package/constants/config.d.ts +25 -1
  54. package/constants/config.js +32 -3
  55. package/constants/environments.d.ts +1 -0
  56. package/constants/environments.js +1 -0
  57. package/constants/extensions.d.ts +2 -0
  58. package/constants/extensions.js +3 -1
  59. package/constants/files.d.ts +2 -2
  60. package/constants/files.js +3 -3
  61. package/errors/errors_DEPRECATED.d.ts +1 -5
  62. package/errors/errors_DEPRECATED.js +2 -2
  63. package/errors/index.d.ts +18 -0
  64. package/errors/index.js +63 -0
  65. package/http/addQueryParams.d.ts +2 -0
  66. package/http/addQueryParams.js +14 -0
  67. package/http/getAxiosConfig.d.ts +6 -3
  68. package/http/getAxiosConfig.js +51 -7
  69. package/http/index.d.ts +11 -12
  70. package/http/index.js +35 -41
  71. package/http/unauthed.d.ts +14 -0
  72. package/http/unauthed.js +38 -0
  73. package/lang/en.json +384 -386
  74. package/lib/archive.d.ts +2 -8
  75. package/lib/archive.js +34 -30
  76. package/lib/cms/functions.d.ts +7 -12
  77. package/lib/cms/functions.js +49 -51
  78. package/lib/cms/handleFieldsJS.js +16 -14
  79. package/lib/cms/modules.d.ts +4 -15
  80. package/lib/cms/modules.js +81 -78
  81. package/lib/cms/processFieldsJs.js +10 -33
  82. package/lib/cms/templates.d.ts +43 -3
  83. package/lib/cms/templates.js +53 -11
  84. package/lib/cms/uploadFolder.d.ts +3 -14
  85. package/lib/cms/uploadFolder.js +58 -42
  86. package/lib/cms/validate.js +1 -1
  87. package/lib/cms/watch.d.ts +2 -18
  88. package/lib/cms/watch.js +63 -68
  89. package/lib/customObjects.js +4 -15
  90. package/lib/fileManager.d.ts +2 -6
  91. package/lib/fileManager.js +54 -65
  92. package/lib/fileMapper.d.ts +4 -15
  93. package/lib/fileMapper.js +67 -88
  94. package/lib/fs.d.ts +1 -1
  95. package/lib/fs.js +10 -6
  96. package/lib/github.d.ts +12 -14
  97. package/lib/github.js +70 -35
  98. package/lib/gitignore.d.ts +2 -0
  99. package/lib/gitignore.js +21 -4
  100. package/lib/hubdb.d.ts +3 -2
  101. package/lib/hubdb.js +11 -9
  102. package/{utils → lib}/notify.js +2 -2
  103. package/lib/oauth.d.ts +2 -5
  104. package/lib/oauth.js +14 -25
  105. package/lib/path.d.ts +3 -0
  106. package/lib/path.js +46 -1
  107. package/lib/personalAccessKey.d.ts +8 -11
  108. package/lib/personalAccessKey.js +76 -38
  109. package/lib/portManager.d.ts +3 -5
  110. package/lib/portManager.js +18 -6
  111. package/lib/trackUsage.js +18 -11
  112. package/lib/urls.js +5 -1
  113. package/models/FileSystemError.d.ts +6 -0
  114. package/models/FileSystemError.js +47 -0
  115. package/models/HubSpotHttpError.d.ts +24 -0
  116. package/models/HubSpotHttpError.js +197 -0
  117. package/models/OAuth2Manager.d.ts +5 -27
  118. package/models/OAuth2Manager.js +41 -64
  119. package/package.json +35 -35
  120. package/types/Accounts.d.ts +103 -3
  121. package/types/Apps.d.ts +77 -0
  122. package/types/Archive.d.ts +9 -0
  123. package/types/Archive.js +2 -0
  124. package/types/Build.d.ts +4 -2
  125. package/types/ComponentStructure.d.ts +30 -10
  126. package/types/Config.d.ts +19 -2
  127. package/types/Deploy.d.ts +3 -2
  128. package/types/DesignManager.d.ts +10 -0
  129. package/types/DesignManager.js +2 -0
  130. package/types/Error.d.ts +9 -5
  131. package/types/FieldsJS.d.ts +1 -0
  132. package/types/FieldsJS.js +2 -0
  133. package/types/FileManager.d.ts +1 -1
  134. package/types/Files.d.ts +43 -4
  135. package/types/Functions.d.ts +52 -0
  136. package/types/Github.d.ts +13 -0
  137. package/types/Http.d.ts +12 -11
  138. package/types/Hubdb.d.ts +9 -0
  139. package/types/MarketplaceValidation.d.ts +7 -3
  140. package/types/Migration.d.ts +28 -0
  141. package/types/Migration.js +10 -0
  142. package/types/Modules.d.ts +11 -0
  143. package/types/PortManager.d.ts +7 -0
  144. package/types/Project.d.ts +30 -0
  145. package/types/ProjectLog.d.ts +9 -0
  146. package/types/ProjectLog.js +2 -0
  147. package/types/Sandbox.d.ts +37 -47
  148. package/types/Schemas.d.ts +56 -0
  149. package/types/Secrets.d.ts +3 -0
  150. package/types/Secrets.js +2 -0
  151. package/types/developerTestAccounts.d.ts +13 -0
  152. package/types/developerTestAccounts.js +2 -0
  153. package/utils/PortManagerServer.d.ts +6 -7
  154. package/utils/PortManagerServer.js +22 -16
  155. package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +0 -6
  156. package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
  157. package/utils/cms/fieldsJS.d.ts +1 -2
  158. package/utils/cms/modules.js +2 -2
  159. package/utils/detectPort.js +3 -3
  160. package/utils/git.d.ts +1 -7
  161. package/utils/git.js +2 -18
  162. package/errors/apiErrors.d.ts +0 -19
  163. package/errors/apiErrors.js +0 -179
  164. package/errors/fileSystemErrors.d.ts +0 -5
  165. package/errors/fileSystemErrors.js +0 -31
  166. package/errors/standardErrors.d.ts +0 -27
  167. package/errors/standardErrors.js +0 -59
  168. package/lang/lang/en.json +0 -401
  169. package/lib/logging/git.d.ts +0 -2
  170. package/lib/logging/git.js +0 -54
  171. package/lib/logging/logs.d.ts +0 -22
  172. package/lib/logging/logs.js +0 -86
  173. package/lib/logging/table.d.ts +0 -3
  174. package/lib/logging/table.js +0 -47
  175. package/lib/sandboxes.d.ts +0 -14
  176. package/lib/sandboxes.js +0 -71
  177. package/models/HubSpotAuthError.d.ts +0 -12
  178. package/models/HubSpotAuthError.js +0 -20
  179. package/types/LogCallbacks.d.ts +0 -7
  180. package/utils/logger.d.ts +0 -5
  181. package/utils/logger.js +0 -23
  182. package/utils/objectUtils.d.ts +0 -8
  183. package/utils/objectUtils.js +0 -33
  184. /package/{utils → lib}/escapeRegExp.d.ts +0 -0
  185. /package/{utils → lib}/escapeRegExp.js +0 -0
  186. /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
  187. /package/lib/{logging/logger.js → logger.js} +0 -0
  188. /package/{utils → lib}/notify.d.ts +0 -0
  189. /package/types/{LogCallbacks.js → Apps.js} +0 -0
@@ -1,179 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwApiUploadError = exports.throwApiError = exports.throwAxiosErrorWithContext = exports.isSpecifiedHubSpotAuthError = exports.isApiUploadValidationError = exports.isGatingError = exports.isMissingScopeError = void 0;
4
- const api_1 = require("../constants/api");
5
- const lang_1 = require("../utils/lang");
6
- const standardErrors_1 = require("./standardErrors");
7
- const i18nKey = 'errors.apiErrors';
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- function isMissingScopeError(err) {
10
- return (err.isAxiosError &&
11
- err.status === 403 &&
12
- !!err.response &&
13
- err.response.data.category === 'MISSING_SCOPES');
14
- }
15
- exports.isMissingScopeError = isMissingScopeError;
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- function isGatingError(err) {
18
- return (err.isAxiosError &&
19
- err.status === 403 &&
20
- !!err.response &&
21
- err.response.data.category === 'GATED');
22
- }
23
- exports.isGatingError = isGatingError;
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- function isApiUploadValidationError(err) {
26
- return (err.isAxiosError &&
27
- err.status === 400 &&
28
- !!err.response &&
29
- !!(err.response?.data?.message || !!err.response?.data?.errors));
30
- }
31
- exports.isApiUploadValidationError = isApiUploadValidationError;
32
- function isSpecifiedHubSpotAuthError(err, { status, category, subCategory }) {
33
- const statusCodeErr = !status || err.status === status;
34
- const categoryErr = !category || err.category === category;
35
- const subCategoryErr = !subCategory || err.subCategory === subCategory;
36
- return Boolean(err.name === 'HubSpotAuthError' &&
37
- statusCodeErr &&
38
- categoryErr &&
39
- subCategoryErr);
40
- }
41
- exports.isSpecifiedHubSpotAuthError = isSpecifiedHubSpotAuthError;
42
- function parseValidationErrors(responseData = { errors: [], message: '' }) {
43
- const errorMessages = [];
44
- const { errors, message } = responseData;
45
- if (message) {
46
- errorMessages.push(message);
47
- }
48
- if (errors) {
49
- const specificErrors = errors.map(error => {
50
- let errorMessage = error.message;
51
- if (error.errorTokens && error.errorTokens.line) {
52
- errorMessage = `line ${error.errorTokens.line}: ${errorMessage}`;
53
- }
54
- return errorMessage;
55
- });
56
- errorMessages.push(...specificErrors);
57
- }
58
- return errorMessages;
59
- }
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- function logValidationErrors(error) {
62
- const validationErrorMessages = parseValidationErrors(error?.response?.data);
63
- if (validationErrorMessages.length) {
64
- (0, standardErrors_1.throwError)(new Error(validationErrorMessages.join(' '), { cause: error }));
65
- }
66
- }
67
- /**
68
- * @throws
69
- */
70
- function throwAxiosErrorWithContext(
71
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- error, context = {}) {
73
- const { status } = error;
74
- const method = error.config?.method;
75
- const { projectName } = context;
76
- const isPutOrPost = method === 'put' || method === 'post';
77
- const action = method && (api_1.HTTP_METHOD_VERBS[method] || api_1.HTTP_METHOD_VERBS.get);
78
- const preposition = (method && api_1.HTTP_METHOD_PREPOSITIONS[method]) ||
79
- api_1.HTTP_METHOD_PREPOSITIONS.get;
80
- const request = context.request
81
- ? `${action} ${preposition} "${context.request}"`
82
- : action;
83
- const messageDetail = request && context.accountId
84
- ? (0, lang_1.i18n)(`${i18nKey}.messageDetail`, {
85
- request,
86
- accountId: context.accountId,
87
- })
88
- : 'request';
89
- const errorMessage = [];
90
- if (isPutOrPost && context.payload) {
91
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.unableToUpload`, { payload: context.payload }));
92
- }
93
- const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
94
- const isProjectGatingError = isGatingError(error) && projectName;
95
- switch (status) {
96
- case 400:
97
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
98
- break;
99
- case 401:
100
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.401`, { messageDetail }));
101
- break;
102
- case 403:
103
- if (isProjectMissingScopeError) {
104
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403MissingScope`, {
105
- accountId: context.accountId || '',
106
- }));
107
- }
108
- else if (isProjectGatingError) {
109
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403Gating`, {
110
- accountId: context.accountId || '',
111
- }));
112
- }
113
- else {
114
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.403`, { messageDetail }));
115
- }
116
- break;
117
- case 404:
118
- if (context.request) {
119
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404Request`, {
120
- action: action || 'request',
121
- request: context.request,
122
- account: context.accountId || '',
123
- }));
124
- }
125
- else {
126
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404`, { messageDetail }));
127
- }
128
- break;
129
- case 429:
130
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.429`, { messageDetail }));
131
- break;
132
- case 503:
133
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
134
- break;
135
- default:
136
- if (status && status >= 500 && status < 600) {
137
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
138
- }
139
- else if (status && status >= 400 && status < 500) {
140
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
141
- }
142
- else {
143
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.generic`, { messageDetail }));
144
- }
145
- break;
146
- }
147
- if (error?.response?.data?.message &&
148
- !isProjectMissingScopeError &&
149
- !isProjectGatingError) {
150
- errorMessage.push(error.response.data.message);
151
- }
152
- if (error?.response?.data?.errors) {
153
- error.response.data.errors.forEach((err) => {
154
- errorMessage.push('\n- ' + err.message);
155
- });
156
- }
157
- (0, standardErrors_1.throwError)(new Error(errorMessage.join(' '), { cause: error }));
158
- }
159
- exports.throwAxiosErrorWithContext = throwAxiosErrorWithContext;
160
- /**
161
- * @throws
162
- */
163
- function throwApiError(error, context = {}) {
164
- if (error.isAxiosError) {
165
- throwAxiosErrorWithContext(error, context);
166
- }
167
- (0, standardErrors_1.throwError)(error);
168
- }
169
- exports.throwApiError = throwApiError;
170
- /**
171
- * @throws
172
- */
173
- function throwApiUploadError(error, context = {}) {
174
- if (isApiUploadValidationError(error)) {
175
- logValidationErrors(error);
176
- }
177
- throwApiError(error, context);
178
- }
179
- exports.throwApiUploadError = throwApiUploadError;
@@ -1,5 +0,0 @@
1
- import { BaseError, FileSystemErrorContext } from '../types/Error';
2
- /**
3
- * @throws
4
- */
5
- export declare function throwFileSystemError(error: BaseError, context: FileSystemErrorContext): void;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwFileSystemError = void 0;
4
- const lang_1 = require("../utils/lang");
5
- const standardErrors_1 = require("./standardErrors");
6
- const i18nKey = 'errors.fileSystemErrors';
7
- /**
8
- * @throws
9
- */
10
- function throwFileSystemError(error, context) {
11
- let fileAction = '';
12
- if (context.read) {
13
- fileAction = (0, lang_1.i18n)(`${i18nKey}.readAction`);
14
- }
15
- else if (context.write) {
16
- fileAction = (0, lang_1.i18n)(`${i18nKey}.writeAction`);
17
- }
18
- else {
19
- fileAction = (0, lang_1.i18n)(`${i18nKey}.otherAction`);
20
- }
21
- const filepath = context.filepath
22
- ? `"${context.filepath}"`
23
- : (0, lang_1.i18n)(`${i18nKey}.unknownFilepath`);
24
- const message = [(0, lang_1.i18n)(`${i18nKey}.baseMessage`, { fileAction, filepath })];
25
- // Many `fs` errors will be `SystemError`s
26
- if ((0, standardErrors_1.isSystemError)(error)) {
27
- message.push((0, lang_1.i18n)(`${i18nKey}.baseMessage`, { errorMessage: error.message }));
28
- }
29
- throw new Error(message.join(' '), { cause: error });
30
- }
31
- exports.throwFileSystemError = throwFileSystemError;
@@ -1,27 +0,0 @@
1
- import { BaseError } from '../types/Error';
2
- import { LangKey } from '../types/Lang';
3
- import { AxiosError } from 'axios';
4
- export declare function isSystemError(err: BaseError): boolean;
5
- export declare function isFatalError(err: BaseError): boolean;
6
- /**
7
- * @throws
8
- */
9
- export declare function throwErrorWithMessage(identifier: LangKey, interpolation?: {
10
- [key: string]: string | number;
11
- }, cause?: BaseError): never;
12
- /**
13
- * @throws
14
- */
15
- export declare function throwTypeErrorWithMessage(identifier: LangKey, interpolation?: {
16
- [key: string]: string | number;
17
- }, cause?: BaseError): never;
18
- /**
19
- * @throws
20
- */
21
- export declare function throwAuthErrorWithMessage(identifier: LangKey, interpolation?: {
22
- [key: string]: string | number;
23
- }, cause?: AxiosError): never;
24
- /**
25
- * @throws
26
- */
27
- export declare function throwError(error: BaseError): never;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwError = exports.throwAuthErrorWithMessage = exports.throwTypeErrorWithMessage = exports.throwErrorWithMessage = exports.isFatalError = exports.isSystemError = void 0;
4
- const HubSpotAuthError_1 = require("../models/HubSpotAuthError");
5
- const lang_1 = require("../utils/lang");
6
- function isSystemError(err) {
7
- return err.errno != null && err.code != null && err.syscall != null;
8
- }
9
- exports.isSystemError = isSystemError;
10
- function isFatalError(err) {
11
- return err instanceof HubSpotAuthError_1.HubSpotAuthError;
12
- }
13
- exports.isFatalError = isFatalError;
14
- function genericThrowErrorWithMessage(ErrorType, identifier, interpolation, cause) {
15
- const message = (0, lang_1.i18n)(identifier, interpolation);
16
- if (cause) {
17
- throw new ErrorType(message, { cause });
18
- }
19
- throw new ErrorType(message);
20
- }
21
- /**
22
- * @throws
23
- */
24
- function throwErrorWithMessage(identifier, interpolation, cause) {
25
- genericThrowErrorWithMessage(Error, identifier, interpolation, cause);
26
- }
27
- exports.throwErrorWithMessage = throwErrorWithMessage;
28
- /**
29
- * @throws
30
- */
31
- function throwTypeErrorWithMessage(identifier, interpolation, cause) {
32
- genericThrowErrorWithMessage(TypeError, identifier, interpolation, cause);
33
- }
34
- exports.throwTypeErrorWithMessage = throwTypeErrorWithMessage;
35
- /**
36
- * @throws
37
- */
38
- function throwAuthErrorWithMessage(identifier, interpolation, cause) {
39
- genericThrowErrorWithMessage(
40
- // @ts-expect-error HubSpotAuthError is not callable
41
- HubSpotAuthError_1.HubSpotAuthError, identifier, interpolation, cause);
42
- }
43
- exports.throwAuthErrorWithMessage = throwAuthErrorWithMessage;
44
- /**
45
- * @throws
46
- */
47
- function throwError(error) {
48
- // Error or Error subclass
49
- const message = error.name && error.name !== 'Error'
50
- ? [(0, lang_1.i18n)('errors.generic', { name: error.name })]
51
- : [];
52
- [error.message, error.reason].forEach(msg => {
53
- if (msg) {
54
- message.push(msg);
55
- }
56
- });
57
- throw new Error(message.join(' '), { cause: error });
58
- }
59
- exports.throwError = throwError;